{"version":3,"sources":["../../src/ecom-recommendations-v1-recommendation-recommendations.http.ts","../../src/ecom-recommendations-v1-recommendation-recommendations.types.ts","../../src/ecom-recommendations-v1-recommendation-recommendations.meta.ts"],"sourcesContent":["import { toURLSearchParams } from '@wix/sdk-runtime/rest-modules';\nimport { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixEcomRecommendationsV1RecommendationsServiceUrl(\n  opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n  const domainToMappings = {\n    'www.wixapis.com': [\n      {\n        srcPath: '/v1/recommendations',\n        destPath: '/v1/recommendations',\n      },\n      {\n        srcPath: '/ecom/v1/recommendations',\n        destPath: '/v1/recommendations',\n      },\n    ],\n    _: [\n      {\n        srcPath: '/v1/recommendations',\n        destPath: '/v1/recommendations',\n      },\n    ],\n    '*.dev.wix-code.com': [\n      {\n        srcPath: '/v1/recommendations',\n        destPath: '/v1/recommendations',\n      },\n    ],\n  };\n\n  return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_ecom_recommendations';\n\n/**\n * Returns a list of recommendation algorithms that can be used on your Wix site or project. These algorithms can be used with [`getRecommendation()`](#getRecommendation) to provide item recommendations to the customer.\n *\n * Algorithms are run by the apps that provide them, and can only be used on catalogs they support. Apps may provide algorithms for use with their own catalogs and/or catalogs from other apps.\n *\n * The app which provides an algorithm is referenced by that algorithm’s `appId`. The apps whose catalogs are supported by an algorithm are referenced by the IDs in that algorithm’s `catalogAppIds` array.\n *\n *\n * For an algorithm to be considered “Available” and returned in this method’s response, the algorithm must meet the following conditions:\n * 1. The algorithm’s `appId` must match the ID of an installed Wix app.\n * 2. At least 1 of the IDs in `catalogAppIds` must match the ID of an installed Wix app.\n *\n * Wix app IDs are [listed here](https://dev.wix.com/docs/api-reference/articles/get-started/apps-created-by-wix).\n */\nexport function listAvailableAlgorithms(\n  payload: object\n): RequestOptionsFactory<any> {\n  function __listAvailableAlgorithms({ host }: any) {\n    const metadata = {\n      entityFqdn: 'wix.ecom.recommendations.v1.recommendation',\n      method: 'GET' as any,\n      methodFqn:\n        'com.wix.ecom.recommendations.v1.RecommendationsService.ListAvailableAlgorithms',\n      packageName: PACKAGE_NAME,\n      migrationOptions: {\n        optInTransformResponse: true,\n      },\n      url: resolveComWixEcomRecommendationsV1RecommendationsServiceUrl({\n        protoPath: '/v1/recommendations/algorithms',\n        data: payload,\n        host,\n      }),\n      params: toURLSearchParams(payload),\n    };\n\n    return metadata;\n  }\n\n  return __listAvailableAlgorithms;\n}\n\n/**\n * Returns a recommendation object containing a list of items to recommend to the customer.\n *\n * `getRecommendation()` determines which items to recommend based on the given recommendation algorithms.\n *\n * `getRecommendation()` doesn’t run the algorithms. It calls the installed apps that provide them.\n *\n * Apps may provide algorithms for use with their own catalogs, or for use with catalogs from other apps.\n * For example, Wix Stores provides algorithms that can only be used on its own catalogs.\n * To run an algorithm, the app providing it must be installed, and an app providing a supported catalog must be installed.\n * For more information and to see which algorithms are available on your site or project, call [`listAvailableAlgorithms()`](#listavailablealgorithms).\n *\n * `getRecommendation()` operates as follows:\n * 1. `getRecommendation()` receives as input a list of algorithms as an array. These algorithms can be provided by different apps and can apply to different catalogs.\n * 2. `getRecommendation()` calls the app that corresponds to the `appId` of the first algorithm in the list of algorithms. It passes that algorithm’s ID and the IDs of any subsequent algorithms in the array for the same app.\n * 3. The app runs the algorithms.\n * 4. `getRecommendation()` returns items recommendations from the first algorithm (according to its position in the `algorithms` array) that meets the minimum number of recommendations. At that point `getRecommendation()` stops calling other apps.\n * 5. If none of the algorithms run by the first app meet the minimum recommended items, `getRecommendation()` finds the next algorithm in the array with a new `appId` (an ID of an app that has not yet been called), and repeats the process.\n * 6. If no algorithms in the `algorithms` array recommend at least the minimum recommended items, `getRecommendation()` returns an empty array.\n */\nexport function getRecommendation(payload: object): RequestOptionsFactory<any> {\n  function __getRecommendation({ host }: any) {\n    const metadata = {\n      entityFqdn: 'wix.ecom.recommendations.v1.recommendation',\n      method: 'POST' as any,\n      methodFqn:\n        'com.wix.ecom.recommendations.v1.RecommendationsService.GetRecommendation',\n      packageName: PACKAGE_NAME,\n      migrationOptions: {\n        optInTransformResponse: true,\n      },\n      url: resolveComWixEcomRecommendationsV1RecommendationsServiceUrl({\n        protoPath: '/v1/recommendations/get',\n        data: payload,\n        host,\n      }),\n      data: payload,\n    };\n\n    return metadata;\n  }\n\n  return __getRecommendation;\n}\n","export interface Recommendation {\n  /**\n   * Recommended items.\n   * @maxSize 100\n   */\n  items?: CatalogReference[];\n  /** The algorithm used to provide the recommendation. */\n  algorithm?: Algorithm;\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 Algorithm {\n  /**\n   * ID of the algorithm, as defined by the app that provides it.\n   * @format GUID\n   */\n  id?: string;\n  /**\n   * ID of the app providing the algorithm. This can be an app built by Wix or a 3rd-party app.\n   *\n   * See app IDs for [apps built by Wix](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/platform/about-apps-created-by-wix).\n   * @minLength 1\n   * @maxLength 36\n   */\n  appId?: string;\n}\n\nexport interface ListAvailableAlgorithmsRequest {}\n\nexport interface ListAvailableAlgorithmsResponse {\n  /**\n   * List of algorithms available for use on a site.\n   * @maxSize 500\n   */\n  availableAlgorithms?: AlgorithmInfo[];\n}\n\nexport interface AlgorithmInfo {\n  /** Algorithm configuration. */\n  config?: AlgorithmConfig;\n  /**\n   * ID of the app that provides the algorithm. This can be an app built by Wix or a 3rd-party app.\n   *\n   * See app IDs for [apps built by Wix](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/platform/about-apps-created-by-wix).\n   * @minLength 1\n   * @maxLength 36\n   */\n  appId?: string;\n  /**\n   * IDs of apps with catalogs that this algorithm supports. This can be an app built by Wix or a 3rd-party app.\n   *\n   * See app IDs for [apps built by Wix](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/platform/about-apps-created-by-wix).\n   * @minSize 1\n   * @maxSize 100\n   * @minLength 1\n   * @maxLength 36\n   */\n  catalogAppIds?: string[];\n}\n\nexport interface AlgorithmConfig {\n  /**\n   * Algorithm name. This value is not translatable.\n   * @minLength 1\n   * @maxLength 50\n   */\n  name?: string;\n  /**\n   * Algorithm description. This describes how the algorithm works and if it has any limitations regarding site content, number of items in the catalog, site traffic, and so on. This value is not translatable.\n   * @minLength 1\n   * @maxLength 500\n   */\n  description?: string;\n  /**\n   * A supplemental `description`. It can be used to help break up and organize information. You can, for example, display this information as a tooltip or as an additional section that is collapsed by default.\n   * @minLength 1\n   * @maxLength 300\n   */\n  additionalInfo?: string | null;\n  /**\n   * Algorithms may have the following types:\n   * * `RELATED_ITEMS` - This type of algorithm provides recommendations based on 1 or more other provided items. For example, when an item is added to a cart, the algorithm can suggest other items frequently bought together with that item.\n   * * `GLOBAL` - This type of algorithm provides general recommendations based on site or project statistics. For example, bestsellers or new arrivals.\n   */\n  algorithmType?: AlgorithmTypeWithLiterals;\n  /**\n   * Algorithm ID. This must be unique for a specific app but does not have to be unique across all apps on the site or in the project.\n   * @format GUID\n   */\n  algorithmId?: string;\n}\n\nexport enum AlgorithmType {\n  UNSPECIFIED = 'UNSPECIFIED',\n  RELATED_ITEMS = 'RELATED_ITEMS',\n  GLOBAL = 'GLOBAL',\n}\n\n/** @enumType */\nexport type AlgorithmTypeWithLiterals =\n  | AlgorithmType\n  | 'UNSPECIFIED'\n  | 'RELATED_ITEMS'\n  | 'GLOBAL';\n\nexport interface GetRecommendationRequest {\n  /**\n   * Catalog items to base recommendations on. Required if the algorithm's `algorithmType` is `RELATED_ITEMS`.\n   * @maxSize 300\n   */\n  items?: CatalogReference[];\n  /**\n   * Algorithms to specify for generating recommendations, ordered by preference. The method processes algorithms in order and provides recommendations from the first algorithm that meets the `minimumRecommendedItems` threshold.\n   * @minSize 1\n   * @maxSize 10\n   */\n  algorithms: Algorithm[];\n  /**\n   * Minimum number of items an algorithm must provide for its recommendations to be returned in the response. If no algorithm provides enough items, an empty array is returned.\n   * @max 100\n   */\n  minimumRecommendedItems?: number;\n}\n\nexport interface GetRecommendationResponse {\n  /** The recommended items and the algorithm that provided them. Empty if no algorithm met the `minimumRecommendedItems` threshold. */\n  recommendation?: Recommendation;\n}\n\nexport interface ItemAppIdNotSupportedByProvider {\n  /**\n   * Items with an App ID not supported by the provider. Supported App IDs can be found in the provider config in the app dashboard.\n   * @minSize 1\n   * @maxSize 300\n   */\n  items?: CatalogReference[];\n  /**\n   * Algorithms that don't support the requested items.\n   * @minSize 1\n   * @maxSize 10\n   */\n  algorithms?: Algorithm[];\n}\n\nexport interface RecommendationAlgorithmNotSupported {\n  /**\n   * Algorithms not supported by the provider.\n   * @minSize 1\n   * @maxSize 10\n   */\n  unsupportedAlgorithms?: Algorithm[];\n}\n\n/** @docsIgnore */\nexport type GetRecommendationApplicationErrors =\n  | {\n      code?: 'ITEM_APP_ID_NOT_SUPPORTED';\n      description?: string;\n      data?: ItemAppIdNotSupportedByProvider;\n    }\n  | {\n      code?: 'ALGORITHM_NOT_SUPPORTED';\n      description?: string;\n      data?: RecommendationAlgorithmNotSupported;\n    }\n  | {\n      code?: 'RECOMMENDATIONS_PROVIDER_NOT_FOUND';\n      description?: string;\n      data?: Record<string, any>;\n    };\n","import * as ambassadorWixEcomRecommendationsV1Recommendation from './ecom-recommendations-v1-recommendation-recommendations.http.js';\nimport * as ambassadorWixEcomRecommendationsV1RecommendationTypes from './ecom-recommendations-v1-recommendation-recommendations.types.js';\nimport * as ambassadorWixEcomRecommendationsV1RecommendationUniversalTypes from './ecom-recommendations-v1-recommendation-recommendations.universal.js';\n\nexport type __PublicMethodMetaInfo<\n  K = string,\n  M = unknown,\n  T = unknown,\n  S = unknown,\n  Q = unknown,\n  R = unknown\n> = {\n  getUrl: (context: any) => string;\n  httpMethod: K;\n  path: string;\n  pathParams: M;\n  __requestType: T;\n  __originalRequestType: S;\n  __responseType: Q;\n  __originalResponseType: R;\n};\n\nexport function listAvailableAlgorithms(): __PublicMethodMetaInfo<\n  'GET',\n  {},\n  ambassadorWixEcomRecommendationsV1RecommendationUniversalTypes.ListAvailableAlgorithmsRequest,\n  ambassadorWixEcomRecommendationsV1RecommendationTypes.ListAvailableAlgorithmsRequest,\n  ambassadorWixEcomRecommendationsV1RecommendationUniversalTypes.ListAvailableAlgorithmsResponse,\n  ambassadorWixEcomRecommendationsV1RecommendationTypes.ListAvailableAlgorithmsResponse\n> {\n  const payload = {} as any;\n\n  const getRequestOptions =\n    ambassadorWixEcomRecommendationsV1Recommendation.listAvailableAlgorithms(\n      payload\n    );\n\n  const getUrl = (context: any): string => {\n    const { url } = getRequestOptions(context);\n    return url!;\n  };\n\n  return {\n    getUrl,\n    httpMethod: 'GET',\n    path: '/v1/recommendations/algorithms',\n    pathParams: {},\n    __requestType: null as any,\n    __originalRequestType: null as any,\n    __responseType: null as any,\n    __originalResponseType: null as any,\n  };\n}\n\nexport function getRecommendation(): __PublicMethodMetaInfo<\n  'POST',\n  {},\n  ambassadorWixEcomRecommendationsV1RecommendationUniversalTypes.GetRecommendationRequest,\n  ambassadorWixEcomRecommendationsV1RecommendationTypes.GetRecommendationRequest,\n  ambassadorWixEcomRecommendationsV1RecommendationUniversalTypes.GetRecommendationResponse,\n  ambassadorWixEcomRecommendationsV1RecommendationTypes.GetRecommendationResponse\n> {\n  const payload = {} as any;\n\n  const getRequestOptions =\n    ambassadorWixEcomRecommendationsV1Recommendation.getRecommendation(payload);\n\n  const getUrl = (context: any): string => {\n    const { url } = getRequestOptions(context);\n    return url!;\n  };\n\n  return {\n    getUrl,\n    httpMethod: 'POST',\n    path: '/v1/recommendations/get',\n    pathParams: {},\n    __requestType: null as any,\n    __originalRequestType: null as any,\n    __responseType: null as any,\n    __originalResponseType: null as any,\n  };\n}\n\nexport {\n  Recommendation as RecommendationOriginal,\n  CatalogReference as CatalogReferenceOriginal,\n  Algorithm as AlgorithmOriginal,\n  ListAvailableAlgorithmsRequest as ListAvailableAlgorithmsRequestOriginal,\n  ListAvailableAlgorithmsResponse as ListAvailableAlgorithmsResponseOriginal,\n  AlgorithmInfo as AlgorithmInfoOriginal,\n  AlgorithmConfig as AlgorithmConfigOriginal,\n  AlgorithmType as AlgorithmTypeOriginal,\n  AlgorithmTypeWithLiterals as AlgorithmTypeWithLiteralsOriginal,\n  GetRecommendationRequest as GetRecommendationRequestOriginal,\n  GetRecommendationResponse as GetRecommendationResponseOriginal,\n  ItemAppIdNotSupportedByProvider as ItemAppIdNotSupportedByProviderOriginal,\n  RecommendationAlgorithmNotSupported as RecommendationAlgorithmNotSupportedOriginal,\n  GetRecommendationApplicationErrors as GetRecommendationApplicationErrorsOriginal,\n} from './ecom-recommendations-v1-recommendation-recommendations.types.js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