{"version":3,"sources":["../../src/service-plugins-types.ts","../../src/interfaces-billing-v1-tax-calculation-provider.public.ts","../../src/interfaces-billing-v1-tax-calculation-provider.context.ts"],"sourcesContent":["/** Items and information to calculate tax for. */\nexport interface CalculateTaxRequest {\n  /**\n   * 3-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format.\n   * @format CURRENCY\n   */\n  currency?: string;\n  /**\n   * Array of addresses. Each line item can individually reference the address to apply with `lineItems.addressIndex`.\n   * @minSize 1\n   * @maxSize 3\n   */\n  addresses?: Address[];\n  /**\n   * Line items to calculate tax for.\n   * @minSize 1\n   * @maxSize 300\n   */\n  lineItems?: LineItem[];\n}\n\n/** Wix common address format for physical address to use if you plan to store addresses in your service. */\nexport interface Address {\n  /**\n   * 2-letter country code in [ISO-3166 alpha-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) format.\n   * @format COUNTRY\n   */\n  country?: string | null;\n  /**\n   * Subdivision (such as state, prefecture, or province) in [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-2) format.\n   * @maxLength 50\n   */\n  subdivision?: string | null;\n  /**\n   * City name.\n   * @maxLength 100\n   */\n  city?: string | null;\n  /**\n   * Postal or zip code.\n   * @maxLength 50\n   */\n  postalCode?: string | null;\n  /**\n   * Main address line, usually street and number as free text.\n   * @maxLength 200\n   */\n  addressLine1?: string | null;\n  /**\n   * Free text providing more detailed address information, such as apartment, suite, or floor.\n   * @maxLength 200\n   */\n  addressLine2?: string | null;\n}\n\n/** Line items to calculate tax for. */\nexport interface LineItem {\n  /**\n   * Line item ID.\n   * @minLength 1\n   * @maxLength 100\n   */\n  _id?: string;\n  /**\n   * Line item name to display.\n   * @maxLength 250\n   */\n  itemName?: string | null;\n  /**\n   * Line item quantity.\n   * @min 1\n   * @max 100000\n   */\n  quantity?: number;\n  /**\n   * Line item price.\n   * @format DECIMAL_VALUE\n   * @decimalValue options { lte:1000000000000000 }\n   */\n  price?: string;\n  /**\n   * Stock keeping unit for this line item. Learn more about [SKUs](https://www.wix.com/encyclopedia/definition/stock-keeping-unit-sku).\n   * @maxLength 40\n   */\n  itemCode?: string | null;\n  /**\n   * Tax group ID for this line item. If not provided, the default tax group applies.\n   * @format GUID\n   */\n  taxGroupId?: string | null;\n  /** Whether tax is included in the price. */\n  taxIncludedInPrice?: boolean;\n  /** Index of the address from `addresses` to use to calculate tax for this specific line item. The index is zero-based. */\n  addressIndex?: AddressIndex;\n  /**\n   * Tax region ID for this line item.\n   * @format GUID\n   */\n  taxRegionId?: string | null;\n}\n\n/** Index of the address from `addresses` to use to calculate tax for this specific line item. The index is zero-based. */\nexport interface AddressIndex extends AddressIndexAddressIndexOptionsOneOf {\n  /** Single address to use for a sale location when only one address is required for tax calculations. The index is zero-based. */\n  singleAddress?: number;\n  /**\n   * Multiple addresses to use for a sale. For example, some tax calculations may require both the address where an item is shipped from,\n   * as well as the address the item is shipped to.\n   */\n  multipleAddresses?: MultipleAddresses;\n}\n\n/** @oneof */\nexport interface AddressIndexAddressIndexOptionsOneOf {\n  /** Single address to use for a sale location when only one address is required for tax calculations. The index is zero-based. */\n  singleAddress?: number;\n  /**\n   * Multiple addresses to use for a sale. For example, some tax calculations may require both the address where an item is shipped from,\n   * as well as the address the item is shipped to.\n   */\n  multipleAddresses?: MultipleAddresses;\n}\n\n/**\n * Multiple addresses to use for a sale. For example, some tax calculations may require both the address where an item\n * is shipped from, as well as the address the item is shipped to.\n */\nexport interface MultipleAddresses {\n  /** Index of the origin address. */\n  origin?: number;\n  /** Index of the destination address. */\n  destination?: number;\n}\n\n/** Calculated tax. */\nexport interface CalculateTaxResponse {\n  /**\n   * 3-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format.\n   * If this code doesn't match the `currency` passed in the request, then the response is invalid.\n   * @format CURRENCY\n   */\n  currency?: string;\n  /** Summary of the tax calculated. */\n  taxSummary?: TaxSummary;\n  /**\n   * Details of each tax applied to each line item.\n   * @minSize 1\n   * @maxSize 300\n   */\n  lineItemTaxDetails?: LineItemTaxDetails[];\n}\n\nexport interface TaxSummary {\n  /**\n   * Total price for all line items.\n   * @format DECIMAL_VALUE\n   * @decimalValue options { maxScale:4 }\n   */\n  totalAmount?: string;\n  /**\n   * Total amount of tax calculated for all line items.\n   * Note that due to rounding, `totalTax` may not equal the sum of `lineItemTaxDetails.taxSummary.taxAmount`.\n   * @format DECIMAL_VALUE\n   * @decimalValue options { maxScale:4 }\n   */\n  totalTax?: string;\n  /**\n   * Total taxable amount for all line items.\n   * @format DECIMAL_VALUE\n   * @decimalValue options { maxScale:4 }\n   */\n  totalTaxableAmount?: string;\n  /**\n   * Total amount of `totalTax` that is included in price. Applies to line items with `taxIncludedInPrice` set to `true`.\n   * @format DECIMAL_VALUE\n   * @decimalValue options { maxScale:4 }\n   */\n  totalTaxIncludedInPrice?: string | null;\n}\n\n/** Tax details for a specific line item. */\nexport interface LineItemTaxDetails {\n  /**\n   * Line item ID.\n   * @minLength 1\n   * @maxLength 100\n   */\n  _id?: string;\n  /**\n   * Line item name to display.\n   * @maxLength 250\n   */\n  itemName?: string | null;\n  /**\n   * Line item quantity.\n   * @min 1\n   * @max 100000\n   */\n  quantity?: number;\n  /**\n   * Array of each tax applied, grouped by `jurisdiction`, `jurisdictionType`, `taxName`, `rate`, and `taxType`.\n   * @maxSize 7\n   */\n  taxBreakdown?: TaxBreakdown[];\n  /** Summary of this line item's total price and tax. */\n  taxSummary?: LineItemTaxSummary;\n}\n\n/** A detailed description of all the tax authorities applied on this item. */\nexport interface TaxBreakdown {\n  /**\n   * Jurisdiction that taxes were calculated for.\n   * @maxLength 200\n   */\n  jurisdiction?: string | null;\n  /**\n   * Non-taxable amount of the price.\n   * @format DECIMAL_VALUE\n   * @decimalValue options { maxScale:4, gte:0 }\n   */\n  nonTaxableAmount?: string | null;\n  /**\n   * Tax rate used for this jurisdiction, as a decimal. For example, 10% tax is `\"0.1000\"` and 200% tax is `\"2.0000\"`.\n   * @format DECIMAL_VALUE\n   * @decimalValue options { maxScale:6, gte:0 }\n   */\n  rate?: string | null;\n  /**\n   * Amount of this tax calculated for this jurisdiction.\n   * @format DECIMAL_VALUE\n   * @decimalValue options { maxScale:4 }\n   */\n  taxAmount?: string | null;\n  /**\n   * Taxable amount of the price.\n   * @format DECIMAL_VALUE\n   * @decimalValue options { maxScale:4, gte:0 }\n   */\n  taxableAmount?: string | null;\n  /**\n   * Type of tax that was calculated. For example, `\"Sales Tax\"`, `\"Income Tax\"`, `\"Value Added Tax\"`, etc.\n   * @maxLength 200\n   */\n  taxType?: string | null;\n  /**\n   * Name of the tax that was calculated. For example, `\"NY State Sales Tax\"`, `\"Quebec GST\"`, etc.\n   * @maxLength 200\n   */\n  taxName?: string | null;\n  /** Type of jurisdiction that taxes were calculated for. For example, `\"State\"`, `\"County\"`, `\"City\"`, `\"Special\"`, etc. */\n  jurisdictionType?: JurisdictionType;\n}\n\n/** Type of jurisdiction that taxes were calculated for. For example, `\"State\"`, `\"County\"`, `\"City\"`, `\"Special\"`, etc. */\nexport enum JurisdictionType {\n  UNDEFINED = 'UNDEFINED',\n  COUNTRY = 'COUNTRY',\n  STATE = 'STATE',\n  COUNTY = 'COUNTY',\n  CITY = 'CITY',\n  SPECIAL = 'SPECIAL',\n}\n\nexport interface LineItemTaxSummary {\n  /**\n   * Total price for this line item.\n   * To determine the price for each individual unit of this line item, divide by `quantity`.\n   * @format DECIMAL_VALUE\n   * @decimalValue options { lte:1000000000000000 }\n   */\n  fullPrice?: string | null;\n  /**\n   * The total amount of tax calculated for this line item.\n   * @format DECIMAL_VALUE\n   * @decimalValue options { maxScale:4 }\n   */\n  taxAmount?: string;\n  /**\n   * Total taxable amount for this line item.\n   * @format DECIMAL_VALUE\n   * @decimalValue options { maxScale:4 }\n   */\n  taxableAmount?: string;\n}\n\nexport interface TaxCalculationConfig {\n  /**\n   * **Required.** Base URI where the endpoints are called. Wix appends the endpoint path to the base URI.\n   *\n   * For example, to call the Calculate Tax endpoint at `https://my-tax-calc.com/v1/calculateTax`, the base URI you provide here is `\"https://my-tax-calc.com/\"`.\n   */\n  deploymentUri?: SpiBaseUri;\n  /**\n   * Display name of the tax calculator.\n   * @minLength 1\n   * @maxLength 200\n   */\n  calculatorDisplayName?: string;\n  /**\n   * List of countries, in [ISO-3166 alpha-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) format, that the calculator does not support.\n   * @format COUNTRY\n   * @maxSize 195\n   */\n  unsupportedCountries?: string[];\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  CalculateTaxRequest,\n  CalculateTaxResponse,\n} from './service-plugins-types.js';\nimport { transformRESTAddressToSDKAddress } from '@wix/sdk-runtime/transformations/address';\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 CalculateTaxEnvelope {\n  request: CalculateTaxRequest;\n  metadata: Context;\n}\n\nexport const provideHandlers = ServicePluginDefinition<{\n  /**\n   *\n   * Calculates tax for the provided line items.\n   *\n   * Tax is calculated for each line item based on the tax region\n   * in `lineItems.taxRegionId` and the tax group in `lineItems.taxGroupId`.\n   *\n   * The breakdown of calculated tax returned, includes:\n   * + `taxSummary`: The overall total tax calculated.\n   * + `lineItemTaxDetails.taxBreakdown`: The tax calculated for each line item in each jurisdiction.\n   * + `lineItemTaxDetails.taxSummary`: The total tax calculated for each line item. */\n  calculateTax(\n    payload: CalculateTaxEnvelope\n  ): CalculateTaxResponse | Promise<CalculateTaxResponse>;\n}>('TAX_CALCULATION_PROVIDER', [\n  {\n    name: 'calculateTax',\n    primaryHttpMappingPath: '/v1/calculate-tax',\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: transformRESTAddressToSDKAddress,\n            paths: [{ path: 'request.addresses', isRepeated: true }],\n          },\n        ]);\n\n        return renameKeysFromRESTResponseToSDKResponse(fromRestRequest);\n      },\n    },\n  },\n]);\n","import './interfaces-billing-v1-tax-calculation-provider.public.js';\nimport { createServicePluginModule } from '@wix/sdk-runtime/service-plugin-modules';\nimport { BuildServicePluginDefinition } from '@wix/sdk-types';\nimport { provideHandlers as publicProvideHandlers } from './interfaces-billing-v1-tax-calculation-provider.public.js';\n\nexport { publicProvideHandlers };\n\nexport const provideHandlers: BuildServicePluginDefinition<\n  typeof publicProvideHandlers\n> &\n  typeof publicProvideHandlers = createServicePluginModule(\n  publicProvideHandlers\n);\n"],"mappings":";AA8PO,IAAK,mBAAL,kBAAKA,sBAAL;AACL,EAAAA,kBAAA,eAAY;AACZ,EAAAA,kBAAA,aAAU;AACV,EAAAA,kBAAA,WAAQ;AACR,EAAAA,kBAAA,YAAS;AACT,EAAAA,kBAAA,UAAO;AACP,EAAAA,kBAAA,aAAU;AANA,SAAAA;AAAA,GAAA;AAoHL,IAAK,eAAL,kBAAKC,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;;;AClXZ,SAAS,+BAA+B;AAMxC,SAAS,wCAAwC;AACjD,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAOA,IAAM,kBAAkB,wBAe5B,4BAA4B;AAAA,EAC7B;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,qBAAqB,YAAY,KAAK,CAAC;AAAA,UACzD;AAAA,QACF,CAAC;AAED,eAAO,wCAAwC,eAAe;AAAA,MAChE;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;ACtDD,SAAS,iCAAiC;AAMnC,IAAMC,mBAGoB;AAAA,EAC/B;AACF;","names":["JurisdictionType","IdentityType","provideHandlers"]}