import { ContentstackRegion } from '../../regions/index.cjs'; type ProxyAuthHeaders = Record; type ProxyAuthConfig = { getAccessToken: (request: Request) => Promise; getAuthHeaders?: never; } | { getAccessToken?: never; getAuthHeaders: (request: Request) => Promise; }; type CMAScope = "entries:read" | "entries:write" | "content-types:read" | "content-types:write" | "assets:read" | "assets:write" | "environments:read" | "locales:read" | "releases:read" | "releases:write" | "taxonomies:read" | "taxonomies:write" | "workflows:read" | "workflows:write" | "webhooks:read" | "webhooks:write"; type CMAProxyConfig = ProxyAuthConfig & { region: ContentstackRegion; apiKey: string; basePath?: string; allowedScopes?: CMAScope[]; unmappedScopeBehavior?: "allow" | "deny"; rateLimit?: number; timeout?: number; }; /** * Create a CMA proxy handler that forwards requests to Contentstack. * * The returned function accepts a standard `Request` and returns a `Response`, * making it compatible with Next.js route handlers, Deno/Bun servers, and * any framework that uses the Web API Request/Response model. * * @example * ```ts * // app/api/cma/[...path]/route.ts * const proxy = createCMAProxy({ * region: "us", * apiKey: "your-api-key", * getAccessToken: async (req) => { * const session = await auth() * return session?.accessToken ?? null * }, * }) * * export const GET = proxy * export const POST = proxy * export const PUT = proxy * export const DELETE = proxy * ``` */ declare function createCMAProxy(config: CMAProxyConfig): (request: Request) => Promise; /** * Resolve the required CMA scope for a given HTTP method and path. * * Path matching checks for known segments. The order matters: * `/entries` is checked before `/content_types` because entry URLs * like `/content_types/blog/entries` contain both. * * @returns The required scope, or `null` if the path is unrecognized. */ declare function resolveScope(method: string, path: string): CMAScope | null; /** * Check whether a required scope is present in the allowed scopes list. * * @returns An error message if the scope is not allowed, or `null` if permitted. */ declare function checkScope(required: CMAScope, allowed: CMAScope[]): string | null; type LaunchProxyConfig = ProxyAuthConfig & { /** Contentstack region */ region: ContentstackRegion; /** Organization UID — required for all Launch API calls */ organizationUid: string; /** URL prefix to strip when extracting the Launch API path (default: "/api/launch") */ basePath?: string; /** Restrict operations: "read" allows GET only, "manage" allows all methods */ allowedOperations?: ("read" | "manage")[]; /** Request timeout in milliseconds (default: 30000) */ timeout?: number; }; /** * Create a Launch API proxy handler that forwards requests to Contentstack Launch. * * The returned function accepts a standard `Request` and returns a `Response`, * making it compatible with Next.js route handlers, Deno/Bun servers, and * any framework that uses the Web API Request/Response model. * * @example * ```ts * // app/api/launch/[...path]/route.ts * const proxy = createLaunchProxy({ * region: "us", * organizationUid: "org-uid", * getAccessToken: async () => { * const session = await auth() * return session?.accessToken ?? null * }, * }) * * export const GET = proxy * export const POST = proxy * export const PUT = proxy * export const DELETE = proxy * ``` */ declare function createLaunchProxy(config: LaunchProxyConfig): (request: Request) => Promise; type BrandKitProxyConfig = ProxyAuthConfig & { /** Contentstack region */ region: ContentstackRegion; /** Organization UID — required for all Brand Kit API calls */ organizationUid: string; /** Brand Kit UID — required for all Brand Kit API calls */ brandKitUid: string; /** URL prefix to strip when extracting the API path (default: "/api/brandkit") */ basePath?: string; /** Restrict operations: "read" allows GET only, "manage" allows all methods */ allowedOperations?: ("read" | "manage")[]; /** Request timeout in milliseconds (default: 30000) */ timeout?: number; }; /** * Create a Brand Kit proxy handler that forwards requests to Contentstack * Brand Kit Management, Knowledge Vault, and Generative AI APIs. * * Routes are determined by path: * - Paths containing `/knowledge-vault` or `/generative-ai` → brandKitAI base URL * - All other paths (brand kits, voice profiles) → brandKit base URL * * @example * ```ts * // app/api/brandkit/[...path]/route.ts * const proxy = createBrandKitProxy({ * region: "us", * organizationUid: "org-uid", * brandKitUid: "bk-uid", * getAccessToken: async () => { * const session = await auth() * return session?.accessToken ?? null * }, * }) * * export const GET = proxy * export const POST = proxy * export const PUT = proxy * export const DELETE = proxy * ``` */ declare function createBrandKitProxy(config: BrandKitProxyConfig): (request: Request) => Promise; type DeveloperHubProxyConfig = ProxyAuthConfig & { /** Contentstack region */ region: ContentstackRegion; /** Organization UID — required for all Developer Hub API calls */ organizationUid: string; /** URL prefix to strip when extracting the Developer Hub API path (default: "/api/developerhub") */ basePath?: string; /** Restrict operations: "read" allows GET only, "manage" allows all methods */ allowedOperations?: ("read" | "manage")[]; /** Request timeout in milliseconds (default: 30000) */ timeout?: number; }; /** * Create a Developer Hub API proxy handler that forwards requests to Contentstack Developer Hub. * * The returned function accepts a standard `Request` and returns a `Response`, * making it compatible with Next.js route handlers, Deno/Bun servers, and * any framework that uses the Web API Request/Response model. * * @example * ```ts * // app/api/developerhub/[...path]/route.ts * const proxy = createDeveloperHubProxy({ * region: "us", * organizationUid: "org-uid", * getAccessToken: async () => { * const session = await auth() * return session?.accessToken ?? null * }, * }) * * export const GET = proxy * export const POST = proxy * export const PUT = proxy * export const DELETE = proxy * ``` */ declare function createDeveloperHubProxy(config: DeveloperHubProxyConfig): (request: Request) => Promise; export { type BrandKitProxyConfig, type CMAProxyConfig, type CMAScope, type DeveloperHubProxyConfig, type LaunchProxyConfig, type ProxyAuthConfig, type ProxyAuthHeaders, checkScope, createBrandKitProxy, createCMAProxy, createDeveloperHubProxy, createLaunchProxy, resolveScope };