import { P as PlatformAdapterInterface, A as ActionHandlerResult, G as GenericCreateAppRegisterHandlerOptions, d as WebhookContext } from '../../saleor-webhook-De0XK_dM.js'; import { NextApiRequest, NextApiResponse, NextApiHandler } from 'next'; import { C as CreateManifestHandlerOptions$1, P as ProtectedHandlerContext, G as GenericSaleorWebhook, a as GenericWebhookConfig } from '../../generic-saleor-webhook-wKiXRuB5.js'; import { APL } from '../../APL/index.js'; import { Permission, AsyncWebhookEventType, SyncWebhookEventType } from '../../types.js'; import '../../saleor-app.js'; import 'graphql'; import '../../verify-signature-mKf0fpOE.js'; type NextJsHandlerInput = NextApiRequest; type NextJsHandler = (req: NextApiRequest, res: NextApiResponse) => Promise; /** PlatformAdapter for Next.js /pages router API routes * * Platform adapters are used in Actions to handle generic request logic * like getting body, headers, etc. * * Thanks to this Actions logic can be re-used for each platform * @see {PlatformAdapterInterface} * @see {@link https://nextjs.org/docs/pages/building-your-application/routing/api-routes} * * */ declare class NextJsAdapter implements PlatformAdapterInterface { request: NextApiRequest; private res; readonly type: "next"; constructor(request: NextApiRequest, res: NextApiResponse); getHeader(name: string): string | null; getBody(): Promise; getRawBody(): Promise; getBaseUrl(): string; get method(): "POST" | "GET"; send(result: ActionHandlerResult): Promise; } type CreateAppRegisterHandlerOptions = GenericCreateAppRegisterHandlerOptions; /** * Returns API route handler for **Next.js pages router** * for register endpoint that is called by Saleor when installing the app * * It verifies the request and stores `app_token` from Saleor * in APL and along with all required AuthData fields (jwks, saleorApiUrl, ...) * * **Recommended path**: `/api/register` * (configured in manifest handler) * * To learn more check Saleor docs * @see {@link https://docs.saleor.io/developer/extending/apps/architecture/app-requirements#register-url} * */ declare const createAppRegisterHandler: (config: CreateAppRegisterHandlerOptions) => NextJsHandler; type CreateManifestHandlerOptions = CreateManifestHandlerOptions$1; /** Returns app manifest API route handler for Next.js pages router * * App manifest is an endpoint that Saleor will call your App metadata. * It has the App's name and description, as well as all the necessary information to * register webhooks, permissions, and extensions. * * **Recommended path**: `/api/manifest` * * To learn more check Saleor docs * @see {@link https://docs.saleor.io/developer/extending/apps/architecture/app-requirements#manifest-url} * @see {@link https://nextjs.org/docs/pages/building-your-application/routing/api-routes} * */ declare const createManifestHandler: (options: CreateManifestHandlerOptions) => NextJsHandler; type NextJsProtectedApiHandler = (req: NextApiRequest, res: NextApiResponse, ctx: ProtectedHandlerContext) => unknown | Promise; /** * Wraps provided function, to ensure incoming request comes from Saleor Dashboard. * Also provides additional `context` object containing request properties. */ declare const createProtectedHandler: (handlerFn: NextJsProtectedApiHandler, apl: APL, requiredPermissions?: Permission[]) => NextApiHandler; type WebhookConfig = GenericWebhookConfig; type NextJsWebhookHandler = (req: NextApiRequest, res: NextApiResponse, ctx: WebhookContext) => unknown | Promise; declare abstract class SaleorWebhook extends GenericSaleorWebhook { /** * Wraps provided function, to ensure incoming request comes from registered Saleor instance. * Also provides additional `context` object containing typed payload and request properties. */ createHandler(handlerFn: NextJsWebhookHandler): NextApiHandler; } declare class SaleorAsyncWebhook extends SaleorWebhook { readonly event: AsyncWebhookEventType; protected readonly eventType: "async"; constructor(configuration: WebhookConfig); createHandler(handlerFn: NextJsWebhookHandler): NextApiHandler; } type NextJsSyncWebhookHandler = NextJsWebhookHandler; declare class SaleorSyncWebhook extends SaleorWebhook { readonly event: TEvent; protected readonly eventType: "sync"; constructor(configuration: WebhookConfig); createHandler(handlerFn: NextJsSyncWebhookHandler): NextApiHandler; } export { type CreateAppRegisterHandlerOptions, type CreateManifestHandlerOptions, NextJsAdapter, type NextJsHandler, type NextJsHandlerInput, type NextJsProtectedApiHandler, type NextJsSyncWebhookHandler, type NextJsWebhookHandler, SaleorAsyncWebhook, SaleorSyncWebhook, createAppRegisterHandler, createManifestHandler, createProtectedHandler };