{"version":3,"sources":["../../src/service-plugins-types.ts","../../src/interfaces-ecommerce-v1-custom-trigger.public.ts","../../src/interfaces-ecommerce-v1-custom-trigger.context.ts"],"sourcesContent":["export interface ListTriggersRequest {}\n\nexport interface ListTriggersResponse {\n  /** Custom triggers. */\n  customTriggers?: ListTriggersResponseCustomTrigger[];\n}\n\nexport interface ListTriggersResponseCustomTrigger {\n  /**\n   * Custom trigger ID.\n   * @minLength 1\n   * @maxLength 100\n   */\n  _id?: string;\n  /**\n   * Custom trigger name to display in the dashboard.\n   * @minLength 1\n   * @maxLength 200\n   */\n  name?: string;\n}\n\nexport interface GetEligibleTriggersRequest {\n  /**\n   * List of line items in the cart/checkout.\n   * @maxSize 1000\n   */\n  lineItems?: LineItem[];\n  /**\n   * List of triggers to be checked for discount eligibility.\n   * @minSize 1\n   * @maxSize 1000\n   */\n  triggers?: TriggerToFilterBy[];\n  /**\n   * Persistent ID that correlates between the various eCommerce elements: cart, checkout, and order.\n   * @format GUID\n   */\n  purchaseFlowId?: string | null;\n  /** Shipping information. */\n  shippingInfo?: ShippingInfo;\n}\n\nexport interface LineItem {\n  /**\n   * Line item ID.\n   * @minLength 1\n   * @maxLength 100\n   */\n  _id?: string;\n  /**\n   * Item quantity in this line item.\n   * @max 100000\n   */\n  quantity?: number | null;\n  /**\n   * Catalog and item reference. Holds IDs for the item and the catalog it came from, as well as further optional info.\n   * This field may be empty in the case of a custom line item.\n   */\n  catalogReference?: CatalogReference;\n  /**\n   * Price of a single item.\n   * @decimalValue options { gte:0 }\n   */\n  price?: string;\n}\n\n/** Used for grouping line items. Sent when an item is added to a cart, checkout, or order. */\nexport interface CatalogReference {\n  /**\n   * ID of the item within the catalog it belongs to.\n   * @minLength 1\n   * @maxLength 36\n   */\n  catalogItemId?: string;\n  /**\n   * ID of the app providing the catalog.\n   *\n   * You can get your app's ID from its page in the [app dashboard](https://dev.wix.com/dc3/my-apps/).\n   *\n   * For items from Wix catalogs, the following values always apply:\n   * + Wix Stores: `\"215238eb-22a5-4c36-9e7b-e7c08025e04e\"`\n   * + Wix Bookings: `\"13d21c63-b5ec-5912-8397-c3a5ddb27a97\"`\n   * + Wix Restaurants: `\"9a5d83fd-8570-482e-81ab-cfa88942ee60\"`\n   * @minLength 1\n   */\n  appId?: string;\n  /**\n   * Additional item details in `key:value` pairs.\n   *\n   * Use this optional field for more specificity with item selection. The values of the `options` field differ depending on which catalog is providing the items.\n   *\n   * For Wix Stores products, learn more about integrating with [Catalog V3](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/e-commerce-integration)\n   * or [Catalog V1](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/catalog/e-commerce-integration), depending on [the version the site uses](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-versioning/introduction).\n   */\n  options?: Record<string, any> | null;\n}\n\nexport interface TriggerToFilterBy {\n  /** Custom trigger info. */\n  customTrigger?: CustomTrigger;\n  /**\n   * Unique trigger identifier. The same value must be returned in `eligibleTriggers[i].identifier`.\n   * @minLength 1\n   * @maxLength 120\n   */\n  identifier?: string | null;\n}\n\nexport interface CustomTrigger {\n  /**\n   * Custom trigger ID.\n   * @minLength 1\n   * @maxLength 100\n   */\n  _id?: string;\n}\n\nexport interface ShippingInfo {\n  /** Address (if applicable). */\n  address?: Address;\n  /**\n   * Preferred shipping option code. For example, \"usps_std_overnight\".\n   * @minLength 1\n   * @maxLength 100\n   */\n  preferredShippingOptionCode?: string | null;\n}\n\nexport interface Address {\n  /**\n   * Two-letter country code in [ISO-3166 alpha-2](https://www.iso.org/obp/ui/#search/code/) format.\n   * @format COUNTRY\n   */\n  country?: string | null;\n  /**\n   * Code for a subdivision (such as state, prefecture, or province) in [ISO 3166-2](https://www.iso.org/standard/72483.html) format.\n   * @maxLength 50\n   */\n  subdivision?: string | null;\n  /**\n   * City name.\n   * @maxLength 50\n   */\n  city?: string | null;\n}\n\nexport interface GetEligibleTriggersResponse {\n  /**\n   * List of eligible triggers. These are used by the Discount Rules API and Wix eCommerce to apply the relevant discount.\n   * @maxSize 1000\n   */\n  eligibleTriggers?: EligibleTrigger[];\n}\n\nexport interface EligibleTrigger {\n  /**\n   * Custom trigger ID. Must be passed with relevant `identifier`.\n   * @minLength 1\n   * @maxLength 100\n   */\n  customTriggerId?: string;\n  /**\n   * Unique trigger identifier. The value must be the same as its equivalent in `triggers[i].identifier` in the request payload.\n   * @minLength 1\n   * @maxLength 120\n   */\n  identifier?: string | null;\n}\n\nexport interface CustomTriggerConfig {\n  /**\n   * Required. Base URI where the endpoints are called.\n   * Wix appends the endpoint path to the base URI. For example, to call the Get Eligible Triggers endpoint at `https://my-discount-app.com/v1/getEligibleTriggers`, the base URI you provide here is `https://my-discount-app.com/`.\n   */\n  deploymentUri?: string;\n}\n\n/**\n * this message is not directly used by any service,\n * it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform.\n * e.g. SPIs, event-handlers, etc..\n * NOTE: this context object MUST be provided as the last argument in each Velo method signature.\n *\n * Example:\n * ```typescript\n * export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) {\n * ...\n * }\n * ```\n */\nexport interface Context {\n  /** A unique identifier of the request. You may print this ID to your logs to help with future debugging and easier correlation with Wix's logs. */\n  requestId?: string | null;\n  /**\n   * [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code.\n   * @format CURRENCY\n   */\n  currency?: string | null;\n  /** An object that describes the identity that triggered this request. */\n  identity?: IdentificationData;\n  /** A string representing a language and region in the format of `\"xx-XX\"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash \"-\", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `\"en-US\"`. */\n  languages?: string[];\n  /**\n   * The service provider app's instance ID.\n   * @format GUID\n   */\n  instanceId?: string | null;\n}\n\nexport enum IdentityType {\n  UNKNOWN = 'UNKNOWN',\n  ANONYMOUS_VISITOR = 'ANONYMOUS_VISITOR',\n  MEMBER = 'MEMBER',\n  WIX_USER = 'WIX_USER',\n  APP = 'APP',\n}\n\nexport interface IdentificationData extends IdentificationDataIdOneOf {\n  /**\n   * ID of a site visitor that has not logged in to the site.\n   * @format GUID\n   */\n  anonymousVisitorId?: string;\n  /**\n   * ID of a site visitor that has logged in to the site.\n   * @format GUID\n   */\n  memberId?: string;\n  /**\n   * ID of a Wix user (site owner, contributor, etc.).\n   * @format GUID\n   */\n  wixUserId?: string;\n  /**\n   * ID of an app.\n   * @format GUID\n   */\n  appId?: string;\n  /** @readonly */\n  identityType?: IdentityType;\n}\n\n/** @oneof */\nexport interface IdentificationDataIdOneOf {\n  /**\n   * ID of a site visitor that has not logged in to the site.\n   * @format GUID\n   */\n  anonymousVisitorId?: string;\n  /**\n   * ID of a site visitor that has logged in to the site.\n   * @format GUID\n   */\n  memberId?: string;\n  /**\n   * ID of a Wix user (site owner, contributor, etc.).\n   * @format GUID\n   */\n  wixUserId?: string;\n  /**\n   * ID of an app.\n   * @format GUID\n   */\n  appId?: string;\n}\n","import { ServicePluginDefinition } from '@wix/sdk-types';\nimport {\n  Context,\n  ListTriggersRequest,\n  ListTriggersResponse,\n  GetEligibleTriggersRequest,\n  GetEligibleTriggersResponse,\n} from './service-plugins-types.js';\nimport {\n  renameKeysFromSDKRequestToRESTRequest,\n  renameKeysFromRESTResponseToSDKResponse,\n} from '@wix/sdk-runtime/rename-all-nested-keys';\n\nexport interface ListTriggersEnvelope {\n  request: ListTriggersRequest;\n  metadata: Context;\n}\n\nexport interface GetEligibleTriggersEnvelope {\n  request: GetEligibleTriggersRequest;\n  metadata: Context;\n}\n\nexport const provideHandlers = ServicePluginDefinition<{\n  /**\n   *\n   * Lists all custom triggers provided by your service plugin integration.\n   *\n   * This method is automatically called by Wix eCommerce to populate the custom [minimum requirements section of an automatic discount](https://support.wix.com/en/article/wix-stores-creating-automatic-discounts#:~:text=Create%20minimum%20requirements). */\n  listTriggers(\n    payload: ListTriggersEnvelope\n  ): ListTriggersResponse | Promise<ListTriggersResponse>;\n\n  /**\n   *\n   * Retrieves eligible custom discount triggers based on the provided items.\n   *\n   * This method is automatically called by Wix eCommerce to retrieve the custom discount triggers provided by your extension.\n   * This happens when actions are performed on the cart and checkout entities/pages. For example, when an item is added to the cart. */\n  getEligibleTriggers(\n    payload: GetEligibleTriggersEnvelope\n  ): GetEligibleTriggersResponse | Promise<GetEligibleTriggersResponse>;\n}>('ECOM_DISCOUNTS_TRIGGER', [\n  {\n    name: 'listTriggers',\n    primaryHttpMappingPath: '/v1/list-triggers',\n    transformations: {\n      toREST: (payload: any) => {\n        const toRestResponse = payload;\n\n        return renameKeysFromSDKRequestToRESTRequest(toRestResponse);\n      },\n      fromREST: (payload: any) => {\n        const fromRestRequest = payload;\n\n        return renameKeysFromRESTResponseToSDKResponse(fromRestRequest);\n      },\n    },\n  },\n\n  {\n    name: 'getEligibleTriggers',\n    primaryHttpMappingPath: '/v1/get-eligible-triggers',\n    transformations: {\n      toREST: (payload: any) => {\n        const toRestResponse = payload;\n\n        return renameKeysFromSDKRequestToRESTRequest(toRestResponse);\n      },\n      fromREST: (payload: any) => {\n        const fromRestRequest = payload;\n\n        return renameKeysFromRESTResponseToSDKResponse(fromRestRequest);\n      },\n    },\n  },\n]);\n","import './interfaces-ecommerce-v1-custom-trigger.public.js';\nimport { createServicePluginModule } from '@wix/sdk-runtime/service-plugin-modules';\nimport { BuildServicePluginDefinition } from '@wix/sdk-types';\nimport { provideHandlers as publicProvideHandlers } from './interfaces-ecommerce-v1-custom-trigger.public.js';\n\nexport { publicProvideHandlers };\n\nexport const provideHandlers: BuildServicePluginDefinition<\n  typeof publicProvideHandlers\n> &\n  typeof publicProvideHandlers = createServicePluginModule(\n  publicProvideHandlers\n);\n"],"mappings":";AAkNO,IAAK,eAAL,kBAAKA,kBAAL;AACL,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,uBAAoB;AACpB,EAAAA,cAAA,YAAS;AACT,EAAAA,cAAA,cAAW;AACX,EAAAA,cAAA,SAAM;AALI,SAAAA;AAAA,GAAA;;;AClNZ,SAAS,+BAA+B;AAQxC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAYA,IAAM,kBAAkB,wBAmB5B,0BAA0B;AAAA,EAC3B;AAAA,IACE,MAAM;AAAA,IACN,wBAAwB;AAAA,IACxB,iBAAiB;AAAA,MACf,QAAQ,CAAC,YAAiB;AACxB,cAAM,iBAAiB;AAEvB,eAAO,sCAAsC,cAAc;AAAA,MAC7D;AAAA,MACA,UAAU,CAAC,YAAiB;AAC1B,cAAM,kBAAkB;AAExB,eAAO,wCAAwC,eAAe;AAAA,MAChE;AAAA,IACF;AAAA,EACF;AAAA,EAEA;AAAA,IACE,MAAM;AAAA,IACN,wBAAwB;AAAA,IACxB,iBAAiB;AAAA,MACf,QAAQ,CAAC,YAAiB;AACxB,cAAM,iBAAiB;AAEvB,eAAO,sCAAsC,cAAc;AAAA,MAC7D;AAAA,MACA,UAAU,CAAC,YAAiB;AAC1B,cAAM,kBAAkB;AAExB,eAAO,wCAAwC,eAAe;AAAA,MAChE;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;AC3ED,SAAS,iCAAiC;AAMnC,IAAMC,mBAGoB;AAAA,EAC/B;AACF;","names":["IdentityType","provideHandlers"]}