{"version":3,"sources":["../../src/service-plugins-types.ts","../../src/interfaces-loyalty-v1-earn-points-limit-provider.public.ts","../../src/interfaces-loyalty-v1-earn-points-limit-provider.context.ts"],"sourcesContent":["export interface ApplyPointsLimitRequest {\n  /**\n   * Loyalty account of the contact who would earn points. If the contact\n   * doesn't have a loyalty account yet, all `points` totals on the account\n   * are `0`.\n   */\n  account?: LoyaltyAccount;\n  /**\n   * ID of the contact who would earn loyalty points for the order.\n   * @format GUID\n   */\n  contactId?: string | null;\n  /**\n   * Number of loyalty points the contact would earn for the order before any\n   * limit is applied.\n   * @min 1\n   * @max 9999999\n   */\n  pointsToEarn?: number | null;\n  /**\n   * Total number of loyalty points the contact has earned since the start of\n   * the current calendar month, in UTC.\n   */\n  earnedThisMonth?: number | null;\n  /**\n   * Total number of loyalty points the contact has earned since the start of\n   * the current calendar year, in UTC.\n   */\n  earnedThisYear?: number | null;\n}\n\n/**\n * Subset of a contact's loyalty account information passed to service plugin\n * implementers.\n */\nexport interface LoyaltyAccount {\n  /**\n   * Loyalty account ID.\n   * @format GUID\n   * @readonly\n   */\n  _id?: string;\n  /**\n   * Points balance and totals for the loyalty account.\n   * @readonly\n   */\n  points?: Points;\n  /**\n   * Whether the contact has enough points to redeem at least one reward\n   * available on the site.\n   * @readonly\n   */\n  rewardAvailable?: boolean;\n  /**\n   * Date and time the loyalty account was created.\n   * @readonly\n   */\n  _createdDate?: Date | null;\n}\n\n/** Loyalty points balance and totals for a loyalty account. */\nexport interface Points {\n  /**\n   * Current points balance available to spend.\n   * @readonly\n   */\n  balance?: number | null;\n  /**\n   * Total number of points the contact has earned over the lifetime of the\n   * account.\n   * @readonly\n   */\n  earned?: number | null;\n  /**\n   * Total number of points the contact has redeemed over the lifetime of the\n   * account.\n   * @readonly\n   */\n  redeemed?: number | null;\n  /**\n   * Total points adjustments the site owner has applied to the account over\n   * its lifetime.\n   * @readonly\n   */\n  adjusted?: number | null;\n  /**\n   * Total number of points that have expired in the account over its lifetime.\n   * @readonly\n   */\n  expired?: number | null;\n}\n\nexport interface ApplyPointsLimitResponse {\n  /**\n   * Number of points to assign for the order, after applying the limit logic.\n   * Must be less than or equal to `pointsToEarn`. Higher values are capped at\n   * `pointsToEarn`. Set to `0` to block the contact from earning points for\n   * the order. Leave unset to assign `pointsToEarn` unchanged.\n   * @max 9999999\n   */\n  adjustedPointsToEarn?: number | null;\n}\n\n/** Configuration provided by each installed implementer of the service plugin. */\nexport interface EarnPointsLimitProviderConfig {\n  /**\n   * Base URI where the implementer is deployed. Wix sends `ApplyPointsLimit`\n   * requests to this URI.\n   */\n  baseUri?: SpiBaseUri;\n}\n\n/** Base URI configuration for a service plugin. Wix uses these URIs to call your service plugin methods. */\nexport interface SpiBaseUri {\n  /**\n   * Base URI for your service plugin. Wix appends each method's path to this URI.\n   *\n   * For example, to receive requests at `https://my-app.com/v1/my-method`, set this field to `https://my-app.com/`.\n   * @minLength 6\n   * @maxLength 2048\n   */\n  baseUri?: string;\n  /** Alternative URIs for specific methods. Use these to override the default URI for individual methods. */\n  alternativeUris?: AlternativeUri[];\n}\n\n/** Custom URI for the specified service plugin method. */\nexport interface AlternativeUri {\n  /**\n   * Name of the method to call at the absolute URI, in PascalCase. For example, to call [Get Shipping Rates](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/shipping-rates/shipping-rates-integration-service-plugin/get-shipping-rates) on an alternative URI, specify `GetShippingRates`.\n   * @minLength 3\n   * @maxLength 128\n   */\n  methodName?: string;\n  /**\n   * Absolute URI that Wix calls for this method. Wix doesn't append any path to this URI.\n   *\n   * The URI must begin with `https://`, such as `https://my-app.com/v1/my-custom-method`.\n   * @minLength 6\n   * @maxLength 2048\n   */\n  absoluteUri?: 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  ApplyPointsLimitRequest,\n  ApplyPointsLimitResponse,\n} from './service-plugins-types.js';\nimport { transformRESTTimestampToSDKTimestamp } from '@wix/sdk-runtime/transformations/timestamp';\nimport { transformPaths } from '@wix/sdk-runtime/transformations/transform-paths';\nimport {\n  renameKeysFromSDKRequestToRESTRequest,\n  renameKeysFromRESTResponseToSDKResponse,\n} from '@wix/sdk-runtime/rename-all-nested-keys';\n\nexport interface ApplyPointsLimitEnvelope {\n  request: ApplyPointsLimitRequest;\n  metadata: Context;\n}\n\nexport const provideHandlers = ServicePluginDefinition<{\n  /**\n   *\n   * Returns the number of loyalty points the contact may earn from the order\n   * after applying the limit logic.\n   *\n   * Wix calls this method when a contact is about to earn loyalty points from\n   * a paid eCommerce order, after any points-adjustment logic has run. The\n   * method runs for orders placed through Wix Stores, Wix Bookings, and other\n   * apps that use the Wix eCommerce checkout. It doesn't run for points earned\n   * through other triggers, such as Wix Automations actions.\n   *\n   * Wix uses the returned `adjustedPointsToEarn` value as the final number of\n   * points to assign for the order. When the returned value is `0`, an earn\n   * attempt is recorded in the contact's loyalty activity history and no\n   * points are assigned.\n   *\n   * **Error handling:** If the implementation returns an error or times out,\n   * Wix logs the failure and assigns `pointsToEarn` unchanged. No retries are\n   * performed at the service plugin layer. */\n  applyPointsLimit(\n    payload: ApplyPointsLimitEnvelope\n  ): ApplyPointsLimitResponse | Promise<ApplyPointsLimitResponse>;\n}>('LOYALTY_EARN_POINTS_LIMIT', [\n  {\n    name: 'applyPointsLimit',\n    primaryHttpMappingPath: '/v1/apply-points-limit',\n    transformations: {\n      toREST: (payload: any) => {\n        const toRestResponse = payload;\n\n        return renameKeysFromSDKRequestToRESTRequest(toRestResponse);\n      },\n      fromREST: (payload: any) => {\n        const fromRestRequest = transformPaths(payload, [\n          {\n            transformFn: transformRESTTimestampToSDKTimestamp,\n            paths: [{ path: 'request.account.createdDate' }],\n          },\n        ]);\n\n        return renameKeysFromRESTResponseToSDKResponse(fromRestRequest);\n      },\n    },\n  },\n]);\n","import './interfaces-loyalty-v1-earn-points-limit-provider.public.js';\nimport { createServicePluginModule } from '@wix/sdk-runtime/service-plugin-modules';\nimport { BuildServicePluginDefinition } from '@wix/sdk-types';\nimport { provideHandlers as publicProvideHandlers } from './interfaces-loyalty-v1-earn-points-limit-provider.public.js';\n\nexport { publicProvideHandlers };\n\nexport const provideHandlers: BuildServicePluginDefinition<\n  typeof publicProvideHandlers\n> &\n  typeof publicProvideHandlers = createServicePluginModule(\n  publicProvideHandlers\n);\n"],"mappings":";AAgLO,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;;;AChLZ,SAAS,+BAA+B;AAMxC,SAAS,4CAA4C;AACrD,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAOA,IAAM,kBAAkB,wBAuB5B,6BAA6B;AAAA,EAC9B;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,eAAe,SAAS;AAAA,UAC9C;AAAA,YACE,aAAa;AAAA,YACb,OAAO,CAAC,EAAE,MAAM,8BAA8B,CAAC;AAAA,UACjD;AAAA,QACF,CAAC;AAED,eAAO,wCAAwC,eAAe;AAAA,MAChE;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;AC9DD,SAAS,iCAAiC;AAMnC,IAAMC,mBAGoB;AAAA,EAC/B;AACF;","names":["IdentityType","provideHandlers"]}