@dropins/storefront-checkout 2.0.1 → 2.1.0-alpha1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/api/fragments.d.ts +4 -1
  2. package/api/getNegotiableQuote/getNegotiableQuote.d.ts +22 -0
  3. package/api/getNegotiableQuote/graphql/getNegotiableQuote.graphql.d.ts +18 -0
  4. package/{errors → api/getNegotiableQuote/graphql}/index.d.ts +2 -2
  5. package/{signals → api/getNegotiableQuote}/index.d.ts +2 -2
  6. package/api/getStoreConfig/getStoreConfig.d.ts +1 -0
  7. package/api/graphql/CartAddressFragment.graphql.d.ts +2 -2
  8. package/api/graphql/NegotiableQuoteAddressFragment.graphql.d.ts +19 -0
  9. package/api/graphql/NegotiableQuoteFragment.graphql.d.ts +18 -0
  10. package/api/graphql/{CartPaymentMethodFragment.graphql.d.ts → PaymentMethodFragment.graphql.d.ts} +1 -1
  11. package/api/graphql/ShippingMethodFragment.graphql.d.ts +19 -0
  12. package/api/index.d.ts +1 -2
  13. package/api/initialize/initialize.d.ts +3 -0
  14. package/api/initializeCheckout/initializeCheckout.d.ts +2 -2
  15. package/api/setBillingAddress/graphql/index.d.ts +19 -0
  16. package/api/{setPaymentMethod/graphql/setPaymentMethod.graphql.d.ts → setBillingAddress/graphql/setBillingAddressOnCartMutation.graphql.d.ts} +2 -2
  17. package/api/setBillingAddress/graphql/setBillingAddressOnQuoteMutation.graphql.d.ts +18 -0
  18. package/api/setBillingAddress/setBillingAddress.d.ts +2 -2
  19. package/api/setPaymentMethod/graphql/index.d.ts +19 -0
  20. package/api/{setBillingAddress/graphql/setBillingAddress.graphql.d.ts → setPaymentMethod/graphql/setPaymentMethodOnCart.graphql.d.ts} +2 -2
  21. package/api/setPaymentMethod/graphql/setPaymentMethodOnQuote.graphql.d.ts +18 -0
  22. package/api/setPaymentMethod/setPaymentMethod.d.ts +2 -2
  23. package/api/setShippingAddress/graphql/index.d.ts +21 -0
  24. package/api/setShippingAddress/graphql/{setShippingAddressAndUseAsBilling.graphql.d.ts → setShippingAddressOnCartAndUseAsBillingMutation.graphql.d.ts} +2 -2
  25. package/api/setShippingAddress/graphql/{setShippingAddress.graphql.d.ts → setShippingAddressOnCartMutation.graphql.d.ts} +2 -2
  26. package/api/setShippingAddress/graphql/setShippingAddressOnQuote.graphql.d.ts +18 -0
  27. package/api/setShippingAddress/graphql/setShippingAddressOnQuoteAndUseAsBillingMutation.graphql.d.ts +18 -0
  28. package/api/setShippingAddress/setShippingAddress.d.ts +1 -1
  29. package/api/setShippingMethods/graphql/index.d.ts +19 -0
  30. package/api/setShippingMethods/graphql/setShippingMethodsOnCart.graphql.d.ts +1 -1
  31. package/api/setShippingMethods/graphql/setShippingMethodsOnQuote.graphql.d.ts +18 -0
  32. package/api/setShippingMethods/index.d.ts +1 -0
  33. package/api/setShippingMethods/setShippingMethods.d.ts +3 -17
  34. package/api/synchronizeCheckout/synchronizeCheckout.d.ts +2 -2
  35. package/api.js +2 -66
  36. package/api.js.map +1 -1
  37. package/chunks/ConditionalWrapper.js +1 -1
  38. package/chunks/ConditionalWrapper.js.map +1 -1
  39. package/chunks/checkout.js.map +1 -1
  40. package/chunks/dom.js.map +1 -1
  41. package/chunks/events.js +4 -0
  42. package/chunks/events.js.map +1 -0
  43. package/chunks/events2.js +4 -0
  44. package/chunks/events2.js.map +1 -0
  45. package/chunks/fetch-graphql.js +14 -0
  46. package/chunks/fetch-graphql.js.map +1 -0
  47. package/chunks/guards.js +4 -0
  48. package/chunks/guards.js.map +1 -0
  49. package/chunks/setBillingAddress.js +25 -5
  50. package/chunks/setBillingAddress.js.map +1 -1
  51. package/chunks/setGuestEmailOnCart.js +3 -3
  52. package/chunks/setGuestEmailOnCart.js.map +1 -1
  53. package/chunks/setPaymentMethod.js +21 -6
  54. package/chunks/setPaymentMethod.js.map +1 -1
  55. package/chunks/setShippingAddress.js +109 -0
  56. package/chunks/setShippingAddress.js.map +1 -0
  57. package/chunks/setShippingMethods.js +19 -4
  58. package/chunks/setShippingMethods.js.map +1 -1
  59. package/chunks/synchronizeCheckout.js +11 -3
  60. package/chunks/synchronizeCheckout.js.map +1 -1
  61. package/chunks/transform-shipping-estimate.js +4 -0
  62. package/chunks/transform-shipping-estimate.js.map +1 -0
  63. package/chunks/transform-shipping-methods.js +4 -0
  64. package/chunks/transform-shipping-methods.js.map +1 -0
  65. package/chunks/values.js +1 -1
  66. package/chunks/values.js.map +1 -1
  67. package/components/AddressValidation/AddressValidation.d.ts +14 -0
  68. package/components/AddressValidation/index.d.ts +19 -0
  69. package/components/PaymentMethods/PaymentMethods.d.ts +1 -1
  70. package/components/ShippingMethods/ShippingMethods.d.ts +1 -1
  71. package/components/index.d.ts +1 -0
  72. package/containers/AddressValidation/AddressValidation.d.ts +12 -0
  73. package/containers/AddressValidation/index.d.ts +19 -0
  74. package/containers/AddressValidation.d.ts +3 -0
  75. package/containers/AddressValidation.js +4 -0
  76. package/containers/AddressValidation.js.map +1 -0
  77. package/containers/BillToShippingAddress.js +1 -1
  78. package/containers/BillToShippingAddress.js.map +1 -1
  79. package/containers/EstimateShipping.js +1 -1
  80. package/containers/EstimateShipping.js.map +1 -1
  81. package/containers/LoginForm/LoginForm.d.ts +1 -1
  82. package/containers/LoginForm.js +1 -1
  83. package/containers/LoginForm.js.map +1 -1
  84. package/containers/OutOfStock.js +1 -1
  85. package/containers/OutOfStock.js.map +1 -1
  86. package/containers/PaymentMethods/PaymentMethods.d.ts +1 -2
  87. package/containers/PaymentMethods.js +1 -1
  88. package/containers/PaymentMethods.js.map +1 -1
  89. package/containers/PlaceOrder.js +1 -1
  90. package/containers/PlaceOrder.js.map +1 -1
  91. package/containers/ServerError.js +1 -1
  92. package/containers/ServerError.js.map +1 -1
  93. package/containers/ShippingMethods/ShippingMethods.d.ts +1 -2
  94. package/containers/ShippingMethods.js +1 -1
  95. package/containers/ShippingMethods.js.map +1 -1
  96. package/containers/TermsAndConditions.js +1 -1
  97. package/containers/TermsAndConditions.js.map +1 -1
  98. package/containers/index.d.ts +1 -0
  99. package/data/models/address.d.ts +11 -6
  100. package/data/models/api.d.ts +23 -10
  101. package/data/models/cart.d.ts +7 -7
  102. package/data/models/checkout.d.ts +14 -0
  103. package/data/models/country.d.ts +1 -1
  104. package/data/models/index.d.ts +2 -1
  105. package/data/models/{price.d.ts → money.d.ts} +2 -2
  106. package/data/models/quote.d.ts +16 -0
  107. package/data/models/shipping-estimate.d.ts +4 -4
  108. package/data/models/shipping-method.d.ts +4 -4
  109. package/data/models/values.d.ts +1 -1
  110. package/data/transforms/index.d.ts +8 -1
  111. package/data/transforms/transform-api.d.ts +12 -0
  112. package/data/transforms/{transform-address.d.ts → transform-cart-address.d.ts} +39 -43
  113. package/data/transforms/transform-cart.d.ts +1 -1
  114. package/data/transforms/transform-country.d.ts +8 -0
  115. package/data/transforms/transform-custom-attributes.d.ts +5 -0
  116. package/data/transforms/transform-negotiable-quote.d.ts +7 -0
  117. package/data/transforms/transform-payment-methods.d.ts +1 -1
  118. package/data/transforms/transform-quote-address.d.ts +88 -0
  119. package/data/transforms/transform-region.d.ts +8 -0
  120. package/fragments.js +180 -71
  121. package/fragments.js.map +1 -1
  122. package/i18n/en_US.json.d.ts +6 -0
  123. package/lib/enqueueRequest.d.ts +2 -2
  124. package/lib/errors/classifiers.d.ts +36 -0
  125. package/lib/errors/customErrors.d.ts +42 -0
  126. package/lib/errors/index.d.ts +20 -0
  127. package/lib/errors/mapErrorToCode.d.ts +4 -0
  128. package/lib/events.d.ts +3 -2
  129. package/lib/guards.d.ts +18 -0
  130. package/lib/index.d.ts +2 -2
  131. package/lib/state.d.ts +5 -3
  132. package/lib/utils/api.d.ts +16 -0
  133. package/lib/utils/events.d.ts +10 -0
  134. package/lib/utils/forms.d.ts +5 -0
  135. package/lib/utils/fragments.d.ts +19 -0
  136. package/lib/utils/index.d.ts +24 -0
  137. package/lib/utils/meta.d.ts +19 -0
  138. package/lib/utils/transformers.d.ts +6 -0
  139. package/lib/utils.d.ts +1 -0
  140. package/lib/utils.js +4 -0
  141. package/lib/utils.js.map +1 -0
  142. package/package.json +1 -1
  143. package/render.js +3 -3
  144. package/render.js.map +1 -1
  145. package/tests/constants.d.ts +1 -0
  146. package/tests/fixtures/fragments/cart.d.ts +43 -42
  147. package/tests/fixtures/fragments/shipping-address.d.ts +2 -1
  148. package/tests/fixtures/models/index.d.ts +1 -1
  149. package/tests/fixtures/models/quote.d.ts +9 -0
  150. package/types/api.d.ts +6 -0
  151. package/types/{TitleProps.d.ts → components.d.ts} +2 -1
  152. package/types/guards.d.ts +5 -0
  153. package/types/index.d.ts +21 -0
  154. package/types/storefront.d.ts +165 -0
  155. package/chunks/ServerErrorSignal.js +0 -4
  156. package/chunks/ServerErrorSignal.js.map +0 -1
  157. package/chunks/errors.js +0 -14
  158. package/chunks/errors.js.map +0 -1
  159. package/errors/errors.d.ts +0 -30
  160. package/lib/network-error.d.ts +0 -22
  161. package/signals/ServerErrorSignal.d.ts +0 -18
  162. package/types/ComponentTypes.d.ts +0 -18
  163. /package/lib/{dom.d.ts → utils/dom.d.ts} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sources":["/@dropins/storefront-checkout/src/lib/state.ts","/@dropins/storefront-checkout/src/data/models/store-config.ts","/@dropins/storefront-checkout/src/lib/enqueueRequest.ts","/@dropins/storefront-checkout/src/lib/filterControlledErrors.ts","/@dropins/storefront-checkout/src/lib/network-error.ts","/@dropins/storefront-checkout/src/lib/dispatchApiCall.ts","/@dropins/storefront-checkout/src/api/getStoreConfig/graphql/getStoreConfig.graphql.ts","/@dropins/storefront-checkout/src/api/getStoreConfig/getStoreConfig.ts","/@dropins/storefront-checkout/src/data/transforms/transform-store-config.ts","/@dropins/storefront-checkout/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-checkout/src/errors/errors.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { StoreConfig } from '@/checkout/data/models';\n\ntype State = {\n authenticated: boolean;\n cartId: string | null;\n initialized: boolean;\n config: StoreConfig | null;\n};\n\nconst _state: State = (() => ({\n authenticated: false,\n cartId: null,\n initialized: false,\n config: null,\n}))();\n\n// Proxy state to allow reactivity\nexport const state = new Proxy(_state, {\n set(target, key, value) {\n // @ts-ignore\n target[key] = value;\n return true;\n },\n get(target, key) {\n return target[key as keyof State];\n },\n});\n\nexport const getStoreConfigCache = () => state.config;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport enum TaxDisplay {\n EXCLUDING_TAX = 'EXCLUDING_TAX',\n INCLUDING_EXCLUDING_TAX = 'INCLUDING_AND_EXCLUDING_TAX',\n INCLUDING_TAX = 'INCLUDING_TAX',\n}\n\nexport interface StoreConfig {\n defaultCountry: string;\n agreementsEnabled: boolean;\n shoppingCartDisplaySetting: {\n shipping: TaxDisplay;\n };\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Cart } from '@/checkout/data/models';\nimport {\n computed,\n ReadonlySignal,\n signal,\n} from '@adobe-commerce/elsie/lib/signals';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport enum QueueName {\n CartUpdate = 'cartUpdate',\n Default = 'default',\n ShippingEstimate = 'shippingEstimate',\n}\n\ntype Request<T> = () => Promise<T>;\ntype QueueCompletedHandler<T> = (result: T) => void;\n\ninterface QueuedRequest<T> {\n requestFn: Request<T>;\n resolve: (value: T) => void;\n reject: (error: any) => void;\n}\n\nconst queues = new Map<QueueName, QueuedRequest<any>[]>();\nconst processing = new Map<QueueName, boolean>();\nconst pendingRequests = signal<Set<QueueName>>(new Set());\nconst onQueueCompleted = new Map<QueueName, QueueCompletedHandler<any>>();\n\nonQueueCompleted.set(QueueName.CartUpdate, (latestResult: Cart) => {\n events.emit('checkout/updated', latestResult);\n});\n\nasync function processQueue(type: QueueName): Promise<void> {\n processing.set(type, true);\n\n const queue = queues.get(type)!;\n let latestSuccessResult: any;\n\n while (queue.length > 0) {\n const request = queue.shift()!;\n\n try {\n const result = await request.requestFn();\n request.resolve(result);\n latestSuccessResult = result;\n } catch (error) {\n request.reject(error);\n }\n }\n\n processing.set(type, false);\n\n const pendingSet = new Set(pendingRequests.value);\n pendingSet.delete(type);\n pendingRequests.value = pendingSet;\n\n const handler = onQueueCompleted.get(type);\n\n if (handler && latestSuccessResult) {\n handler(latestSuccessResult);\n }\n}\n\nexport function enqueueRequest<T>(\n requestFn: Request<T>,\n name: QueueName = QueueName.Default\n): Promise<T> {\n if (!queues.has(name)) {\n queues.set(name, []);\n }\n\n const queue = queues.get(name)!;\n\n const promise = new Promise<T>((resolve, reject) => {\n queue.push({ requestFn, resolve, reject });\n });\n\n const pendingSet = new Set(pendingRequests.value);\n pendingSet.add(name);\n pendingRequests.value = pendingSet;\n\n if (!processing.get(name)) {\n processQueue(name);\n }\n\n return promise;\n}\n\nexport const hasPendingCartUpdates: ReadonlySignal<boolean> = computed(() => {\n return pendingRequests.value.has(QueueName.CartUpdate);\n});\n\nexport const hasPendingShippingEstimate: ReadonlySignal<boolean> = computed(\n () => {\n return pendingRequests.value.has(QueueName.ShippingEstimate);\n }\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FetchQueryError } from '@/checkout/api/fetch-graphql';\n\ntype ErrorPath = (string | number)[];\n\nexport type ErrorWithPath = FetchQueryError[number] & {\n path?: ErrorPath;\n};\n\nconst controlledErrorProps: string[] = ['sender_email', 'recipient_email'];\n\n/**\n * Filters out errors with known paths from a list of errors generated by a GraphQL query.\n *\n * Known issue: The query does not differentiate between physical and virtual gift cards, leading\n * to errors for physical ones as they don't have 'sender_email' and 'recipient_email' properties.\n *\n * @param {ErrorWithPath[]} errors - Array of errors to be filtered.\n * @return {ErrorWithPath[]} Uncontrolled (unexpected) errors not matching predefined paths.\n */\n\nexport function filterControlledErrors(errors: ErrorWithPath[]) {\n return errors.filter(\n (error) =>\n !error.path ||\n !controlledErrorProps.some((controlledErrorProp) => {\n return error.path?.at(-1) === controlledErrorProp;\n })\n );\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { events } from '@adobe-commerce/event-bus';\n\n/**\n * A function which can be attached to fetchGraphQL to handle thrown errors in\n * a generic way.\n */\nexport const handleNetworkError = (error: Error) => {\n const isAbortError =\n error instanceof DOMException && error.name === 'AbortError';\n\n if (!isAbortError) {\n events.emit('error', {\n source: 'checkout',\n type: 'network',\n error,\n });\n }\n\n throw error;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n FetchError,\n fetchGraphQl,\n FetchOptions,\n FetchQueryError,\n} from '@/checkout/api';\nimport { enqueueRequest, QueueName } from '@/checkout/lib/enqueueRequest';\nimport { filterControlledErrors } from '@/checkout/lib/filterControlledErrors';\nimport { handleNetworkError } from '@/checkout/lib/network-error';\n\ntype DispatchApiCallParams<T> = {\n defaultValueOnFail?: T;\n options?: FetchOptions;\n path: string;\n query: string;\n queueName?: QueueName;\n transformer?: (data: any) => T;\n type: 'query' | 'mutation';\n};\n\nexport function getValueAtPath(obj: any, path: string) {\n return path\n .split('.')\n .reduce(\n (acc, part) => (acc && acc[part] !== undefined ? acc[part] : undefined),\n obj\n );\n}\n\nasync function dispatchApiCall<T>(\n params: DispatchApiCallParams<T>\n): Promise<T> {\n const {\n defaultValueOnFail,\n options,\n path,\n query,\n queueName,\n transformer,\n type,\n } = params;\n\n try {\n const processApiCall = async () => {\n const { data, errors } = await fetchGraphQl<T>(query, {\n method: type === 'query' ? 'GET' : 'POST',\n cache: type === 'query' ? 'no-cache' : undefined,\n ...options,\n }).catch(handleNetworkError);\n\n if (errors) {\n const uncontrolledErrors = filterControlledErrors(errors);\n\n if (uncontrolledErrors.length > 0) {\n throw new FetchError(uncontrolledErrors as FetchQueryError);\n }\n }\n\n let result = getValueAtPath(data, path);\n\n if (result === undefined) {\n throw new Error(`No data found at path: ${path}`);\n }\n\n return transformer ? transformer(result) : result;\n };\n\n // Execute the API call, either directly or through the queue\n const result =\n type === 'mutation'\n ? await enqueueRequest<T>(processApiCall, queueName)\n : await processApiCall();\n\n return result;\n } catch (error: any) {\n if (defaultValueOnFail !== undefined) return defaultValueOnFail;\n throw error;\n }\n}\n\nexport { dispatchApiCall };\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const getStoreConfigQuery = /* GraphQL */ `\n query getStoreConfig {\n storeConfig {\n default_country\n is_checkout_agreements_enabled\n is_guest_checkout_enabled\n is_one_page_checkout_enabled\n shopping_cart_display_shipping\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { StoreConfig, TaxDisplay } from '@/checkout/data/models';\nimport { transformStoreConfig } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib';\nimport { getStoreConfigQuery } from './graphql/getStoreConfig.graphql';\n\nexport const DEFAULT_COUNTRY = 'US';\n\nexport const STORE_CONFIG_DEFAULTS: StoreConfig = {\n defaultCountry: DEFAULT_COUNTRY,\n agreementsEnabled: true,\n shoppingCartDisplaySetting: {\n shipping: TaxDisplay.EXCLUDING_TAX,\n },\n};\n\nexport const getStoreConfig = async () => {\n return await dispatchApiCall({\n defaultValueOnFail: STORE_CONFIG_DEFAULTS,\n options: { method: 'GET', cache: 'no-cache' },\n path: 'storeConfig',\n query: getStoreConfigQuery,\n transformer: transformStoreConfig,\n type: 'query',\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { GetStoreConfigQuery } from '@/checkout/__generated__/types';\nimport { STORE_CONFIG_DEFAULTS } from '@/checkout/api/getStoreConfig';\nimport { StoreConfig, TaxDisplay } from '@/checkout/data/models';\n\nexport function transformTaxDisplay(data: number | null | undefined) {\n switch (data) {\n case 1:\n return TaxDisplay.EXCLUDING_TAX;\n case 2:\n return TaxDisplay.INCLUDING_TAX;\n case 3:\n return TaxDisplay.INCLUDING_EXCLUDING_TAX;\n default:\n return TaxDisplay.EXCLUDING_TAX;\n }\n}\n\nexport function transformStoreConfig(\n data: GetStoreConfigQuery['storeConfig']\n): StoreConfig {\n if (!data) return STORE_CONFIG_DEFAULTS;\n\n const {\n default_country,\n is_checkout_agreements_enabled,\n shopping_cart_display_shipping,\n } = data;\n\n return {\n defaultCountry: default_country || STORE_CONFIG_DEFAULTS.defaultCountry,\n agreementsEnabled: is_checkout_agreements_enabled,\n shoppingCartDisplaySetting: {\n shipping: transformTaxDisplay(shopping_cart_display_shipping),\n },\n };\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n\nexport type {\n FetchOptions,\n FetchQueryError,\n} from '@adobe-commerce/fetch-graphql';\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FetchQueryError } from '@/checkout/api/fetch-graphql';\n\nexport class FetchError extends Error {\n constructor(reasons: FetchQueryError) {\n super(reasons.map((e: any) => e.message).join(' '));\n this.name = 'FetchError';\n }\n}\n\nexport class InvalidArgument extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidArgument';\n }\n}\n\nexport class UnexpectedError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'UnexpectedError';\n }\n}\n\nexport class MissingCart extends InvalidArgument {\n constructor() {\n super('Cart ID is required');\n }\n}\nexport class MissingEmail extends InvalidArgument {\n constructor() {\n super('Email is required');\n }\n}\n\nexport class MissingPaymentMethod extends InvalidArgument {\n constructor() {\n super('Payment method code is required');\n }\n}\n\nexport class MissingShippinghAddress extends InvalidArgument {\n constructor() {\n super('Shipping address is required');\n }\n}\n\nexport class MissingBillingAddress extends InvalidArgument {\n constructor() {\n super('Billing address is required');\n }\n}\n\nexport class MissingCountry extends InvalidArgument {\n constructor() {\n super('Country Code is required');\n }\n}\n"],"names":["_state","state","target","key","value","getStoreConfigCache","TaxDisplay","QueueName","queues","processing","pendingRequests","signal","onQueueCompleted","latestResult","events","processQueue","type","queue","latestSuccessResult","request","result","error","pendingSet","handler","enqueueRequest","requestFn","name","promise","resolve","reject","hasPendingCartUpdates","computed","hasPendingShippingEstimate","controlledErrorProps","filterControlledErrors","errors","controlledErrorProp","_a","handleNetworkError","getValueAtPath","obj","path","acc","part","dispatchApiCall","params","defaultValueOnFail","options","query","queueName","transformer","processApiCall","data","fetchGraphQl","uncontrolledErrors","FetchError","getStoreConfigQuery","DEFAULT_COUNTRY","STORE_CONFIG_DEFAULTS","getStoreConfig","transformStoreConfig","transformTaxDisplay","default_country","is_checkout_agreements_enabled","shopping_cart_display_shipping","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","getConfig","FetchGraphQL","reasons","e","InvalidArgument","message","UnexpectedError","MissingCart","MissingEmail","MissingPaymentMethod","MissingShippinghAddress","MissingBillingAddress","MissingCountry"],"mappings":"mNA0BA,MAAMA,EAAwB,CAC5B,cAAe,GACf,OAAQ,KACR,YAAa,GACb,OAAQ,IACV,EAGaC,EAAQ,IAAI,MAAMD,EAAQ,CACrC,IAAIE,EAAQC,EAAKC,EAAO,CAEtB,OAAAF,EAAOC,CAAG,EAAIC,EACP,EACT,EACA,IAAIF,EAAQC,EAAK,CACf,OAAOD,EAAOC,CAAkB,CAAA,CAEpC,CAAC,EAEYE,EAAsB,IAAMJ,EAAM,OC5BnC,IAAAK,GAAAA,IACVA,EAAA,cAAgB,gBAChBA,EAAA,wBAA0B,8BAC1BA,EAAA,cAAgB,gBAHNA,IAA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AAA,EAAQ,IAAKC,GAAWA,EAAE,OAAO,EAAE,KAAK,GAAG,CAAC,EAClD,KAAK,KAAO,YAAA,CAEhB,CAEO,MAAMC,UAAwB,KAAM,CACzC,YAAYC,EAAiB,CAC3B,MAAMA,CAAO,EACb,KAAK,KAAO,iBAAA,CAEhB,CAEO,MAAMC,WAAwB,KAAM,CACzC,YAAYD,EAAiB,CAC3B,MAAMA,CAAO,EACb,KAAK,KAAO,iBAAA,CAEhB,CAEO,MAAME,WAAoBH,CAAgB,CAC/C,aAAc,CACZ,MAAM,qBAAqB,CAAA,CAE/B,CACO,MAAMI,WAAqBJ,CAAgB,CAChD,aAAc,CACZ,MAAM,mBAAmB,CAAA,CAE7B,CAEO,MAAMK,WAA6BL,CAAgB,CACxD,aAAc,CACZ,MAAM,iCAAiC,CAAA,CAE3C,CAEO,MAAMM,WAAgCN,CAAgB,CAC3D,aAAc,CACZ,MAAM,8BAA8B,CAAA,CAExC,CAEO,MAAMO,WAA8BP,CAAgB,CACzD,aAAc,CACZ,MAAM,6BAA6B,CAAA,CAEvC,CAEO,MAAMQ,WAAuBR,CAAgB,CAClD,aAAc,CACZ,MAAM,0BAA0B,CAAA,CAEpC"}
@@ -1,30 +0,0 @@
1
- import { FetchQueryError } from '../api/fetch-graphql';
2
-
3
- export declare class FetchError extends Error {
4
- constructor(reasons: FetchQueryError);
5
- }
6
- export declare class InvalidArgument extends Error {
7
- constructor(message: string);
8
- }
9
- export declare class UnexpectedError extends Error {
10
- constructor(message: string);
11
- }
12
- export declare class MissingCart extends InvalidArgument {
13
- constructor();
14
- }
15
- export declare class MissingEmail extends InvalidArgument {
16
- constructor();
17
- }
18
- export declare class MissingPaymentMethod extends InvalidArgument {
19
- constructor();
20
- }
21
- export declare class MissingShippinghAddress extends InvalidArgument {
22
- constructor();
23
- }
24
- export declare class MissingBillingAddress extends InvalidArgument {
25
- constructor();
26
- }
27
- export declare class MissingCountry extends InvalidArgument {
28
- constructor();
29
- }
30
- //# sourceMappingURL=errors.d.ts.map
@@ -1,22 +0,0 @@
1
- /********************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * __________________
4
- *
5
- * Copyright 2024 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
- *******************************************************************/
17
- /**
18
- * A function which can be attached to fetchGraphQL to handle thrown errors in
19
- * a generic way.
20
- */
21
- export declare const handleNetworkError: (error: Error) => never;
22
- //# sourceMappingURL=network-error.d.ts.map
@@ -1,18 +0,0 @@
1
- /********************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * __________________
4
- *
5
- * Copyright 2024 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
- *******************************************************************/
17
- export declare const serverErrorSignal: import('@preact/signals-core').Signal<string | undefined>;
18
- //# sourceMappingURL=ServerErrorSignal.d.ts.map
@@ -1,18 +0,0 @@
1
- /********************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * __________________
4
- *
5
- * Copyright 2024 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
- *******************************************************************/
17
- export type UIComponentType = 'ToggleButton' | 'RadioButton';
18
- //# sourceMappingURL=ComponentTypes.d.ts.map
File without changes