/** * @license * * Copyright 2026 Adobe. All rights reserved. * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ import { AdobeCommerceHttpClient, ApiFunction, CommerceHttpClientParams } from "@adobe/aio-commerce-lib-api"; import { Options } from "ky"; import * as v from "valibot"; //#region source/api/webhooks/schema.d.ts /** * Schema for the webhook payload sent to POST /webhooks/subscribe. * Matches the `webhook` property of the request body. * Required fields per the Commerce API: webhook_method, webhook_type, batch_name, hook_name, url. */ declare const WebhookSubscribeParamsSchema: v.ObjectSchema<{ readonly batch_name: v.SchemaWithPipe, v.NonEmptyAction]>; readonly batch_order: v.OptionalSchema, undefined>; readonly developer_console_oauth: v.OptionalSchema, v.NonEmptyAction]>; readonly client_secret: v.SchemaWithPipe, v.NonEmptyAction]>; readonly environment: v.OptionalSchema, undefined>; readonly org_id: v.SchemaWithPipe, v.NonEmptyAction]>; }, undefined>, undefined>; readonly fallback_error_message: v.OptionalSchema, undefined>; readonly fields: v.OptionalSchema, v.NonEmptyAction]>; readonly source: v.OptionalSchema, undefined>; }, undefined>, "Expected an array of field objects">, undefined>; readonly headers: v.OptionalSchema, v.NonEmptyAction]>; readonly value: v.SchemaWithPipe, v.NonEmptyAction]>; }, undefined>, "Expected an array of header objects">, undefined>; readonly hook_name: v.SchemaWithPipe, v.NonEmptyAction]>; readonly method: v.OptionalSchema, undefined>; readonly priority: v.OptionalSchema, undefined>; readonly required: v.OptionalSchema, undefined>; readonly rules: v.OptionalSchema, v.NonEmptyAction]>; readonly operator: v.SchemaWithPipe, v.NonEmptyAction]>; readonly value: v.StringSchema<"Expected a string for rule value">; }, undefined>, "Expected an array of rule objects">, undefined>; readonly soft_timeout: v.OptionalSchema, undefined>; readonly timeout: v.OptionalSchema, undefined>; readonly ttl: v.OptionalSchema, undefined>; readonly url: v.SchemaWithPipe, v.NonEmptyAction]>; readonly webhook_method: v.SchemaWithPipe, v.NonEmptyAction]>; readonly webhook_type: v.SchemaWithPipe, v.NonEmptyAction]>; }, undefined>; /** * Schema for the parameters sent to POST /webhooks/unsubscribe. * Required: webhook_method, webhook_type, batch_name, hook_name. */ declare const WebhookUnsubscribeParamsSchema: v.ObjectSchema<{ readonly batch_name: v.SchemaWithPipe, v.NonEmptyAction]>; readonly hook_name: v.SchemaWithPipe, v.NonEmptyAction]>; readonly webhook_method: v.SchemaWithPipe, v.NonEmptyAction]>; readonly webhook_type: v.SchemaWithPipe, v.NonEmptyAction]>; }, undefined>; /** * The parameters for POST /webhooks/subscribe. * @see https://developer.adobe.com/commerce/extensibility/webhooks/api/#subscribe-a-webhook */ type WebhookSubscribeParams = v.InferInput; /** * The parameters for POST /webhooks/unsubscribe. * @see https://developer.adobe.com/commerce/extensibility/webhooks/api/#unsubscribe-a-webhook */ type WebhookUnsubscribeParams = v.InferInput; //#endregion //#region source/api/webhooks/types.d.ts /** A field mapping in a Commerce webhook subscription. */ type CommerceWebhookField = { name: string; source?: string; }; /** A conditional rule in a Commerce webhook subscription. */ type CommerceWebhookRule = { field: string; operator: string; value: string; }; /** A custom HTTP header in a Commerce webhook subscription. */ type CommerceWebhookHeader = { name: string; value: string; }; /** Developer Console OAuth credentials attached to a webhook. */ type CommerceWebhookDeveloperConsoleOAuth = { client_id: string; client_secret: string; org_id: string; environment?: string; }; /** A single Commerce webhook subscription as returned by GET /webhooks/list. */ type CommerceWebhook = { webhook_method: string; webhook_type: string; batch_name: string; batch_order?: number; hook_name: string; url: string; priority?: number; required?: boolean; soft_timeout?: number; timeout?: number; method?: string; fallback_error_message?: string; ttl?: number; fields?: CommerceWebhookField[]; rules?: CommerceWebhookRule[]; headers?: CommerceWebhookHeader[]; developer_console_oauth?: CommerceWebhookDeveloperConsoleOAuth; }; /** The response type for GET /webhooks/list. */ type CommerceWebhookManyResponse = CommerceWebhook[]; /** A single entry from GET /webhooks/supportedList (SaaS only). */ type CommerceSupportedWebhook = { name: string; }; /** The response type for GET /webhooks/supportedList. */ type CommerceSupportedWebhookManyResponse = CommerceSupportedWebhook[]; //#endregion //#region source/api/webhooks/endpoints.d.ts /** * Returns a list of all subscribed webhooks in the Commerce instance. * @see https://developer.adobe.com/commerce/extensibility/webhooks/api/#get-a-list-of-all-subscribed-webhooks * * @param httpClient - The {@link AdobeCommerceHttpClient} to use to make the request. * @param fetchOptions - The {@link Options} to use to make the request. */ declare function getWebhookList(httpClient: AdobeCommerceHttpClient, fetchOptions?: Options): Promise; /** * Subscribes a webhook in the Commerce instance. * @see https://developer.adobe.com/commerce/extensibility/webhooks/api/#subscribe-a-webhook * * @param httpClient - The {@link AdobeCommerceHttpClient} to use to make the request. * @param params - The webhook payload (webhook_method, webhook_type, batch_name, hook_name, url, etc.). * @param fetchOptions - The {@link Options} to use to make the request. * * @throws A {@link CommerceSdkValidationError} If the parameters are in the wrong format. * @throws An {@link HTTPError} If the status code is not 2XX. */ declare function subscribeWebhook(httpClient: AdobeCommerceHttpClient, params: WebhookSubscribeParams, fetchOptions?: Options): Promise; /** * Unsubscribes a webhook from the Commerce instance. * @see https://developer.adobe.com/commerce/extensibility/webhooks/api/#unsubscribe-a-webhook * * @param httpClient - The {@link AdobeCommerceHttpClient} to use to make the request. * @param params - The webhook identifiers (webhook_method, webhook_type, batch_name, hook_name). * @param fetchOptions - The {@link Options} to use to make the request. * * @throws A {@link CommerceSdkValidationError} If the parameters are in the wrong format. * @throws An {@link HTTPError} If the status code is not 2XX. */ declare function unsubscribeWebhook(httpClient: AdobeCommerceHttpClient, params: WebhookUnsubscribeParams, fetchOptions?: Options): Promise; /** * Returns the list of webhooks supported in Adobe Commerce as a Cloud Service (SaaS only). * @see https://developer.adobe.com/commerce/extensibility/webhooks/api/#get-supported-webhooks-for-saas * * @param httpClient - The {@link AdobeCommerceHttpClient} to use to make the request. * @param fetchOptions - The {@link Options} to use to make the request. */ declare function getSupportedWebhookList(httpClient: AdobeCommerceHttpClient, fetchOptions?: Options): Promise; //#endregion //#region source/lib/api-client.d.ts /** * Creates a new API client for the Commerce Webhooks API. * @param params - The parameters to build the Commerce HTTP client. */ declare function createCommerceWebhooksApiClient(params: CommerceHttpClientParams): import("@adobe/aio-commerce-lib-api").ApiClientRecord; /** * An API client for the Commerce Webhooks API. * @see {@link createCommerceWebhooksApiClient} */ type CommerceWebhooksApiClient = ReturnType; /** * Creates a customized Commerce Webhooks API client with a user-specified set of endpoint functions. * @param params - The parameters to build the Commerce HTTP client. * @param functions - The API functions to include in the client. */ declare function createCustomCommerceWebhooksApiClient>>(params: CommerceHttpClientParams, functions: TFunctions): import("@adobe/aio-commerce-lib-api").ApiClientRecord; //#endregion export { type CommerceSupportedWebhook, type CommerceSupportedWebhookManyResponse, type CommerceWebhook, type CommerceWebhookDeveloperConsoleOAuth, type CommerceWebhookField, type CommerceWebhookHeader, type CommerceWebhookManyResponse, type CommerceWebhookRule, type CommerceWebhooksApiClient, type WebhookSubscribeParams, type WebhookUnsubscribeParams, createCommerceWebhooksApiClient, createCustomCommerceWebhooksApiClient, getSupportedWebhookList, getWebhookList, subscribeWebhook, unsubscribeWebhook };