@dropins/storefront-checkout 2.0.1 → 2.1.0-alpha2
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.
- package/api/fragments.d.ts +4 -1
- package/api/getCompanyCredit/getCompanyCredit.d.ts +4 -0
- package/api/getCompanyCredit/graphql/getCompanyCredit.graphql.d.ts +18 -0
- package/api/getCompanyCredit/graphql/index.d.ts +18 -0
- package/{errors → api/getCompanyCredit}/index.d.ts +1 -1
- package/api/getNegotiableQuote/getNegotiableQuote.d.ts +22 -0
- package/api/getNegotiableQuote/graphql/getNegotiableQuote.graphql.d.ts +18 -0
- package/api/getNegotiableQuote/graphql/index.d.ts +18 -0
- package/{signals → api/getNegotiableQuote}/index.d.ts +2 -2
- package/api/getStoreConfig/getStoreConfig.d.ts +1 -0
- package/api/graphql/CartAddressFragment.graphql.d.ts +2 -2
- package/api/graphql/NegotiableQuoteAddressFragment.graphql.d.ts +19 -0
- package/api/graphql/NegotiableQuoteFragment.graphql.d.ts +18 -0
- package/api/graphql/{CartPaymentMethodFragment.graphql.d.ts → PaymentMethodFragment.graphql.d.ts} +2 -2
- package/api/graphql/ShippingMethodFragment.graphql.d.ts +19 -0
- package/api/index.d.ts +2 -2
- package/api/initialize/initialize.d.ts +21 -3
- package/api/initialize/listeners.d.ts +3 -17
- package/api/initializeCheckout/initializeCheckout.d.ts +2 -2
- package/api/setBillingAddress/graphql/index.d.ts +19 -0
- package/api/{setPaymentMethod/graphql/setPaymentMethod.graphql.d.ts → setBillingAddress/graphql/setBillingAddressOnCartMutation.graphql.d.ts} +2 -2
- package/api/setBillingAddress/graphql/setBillingAddressOnQuoteMutation.graphql.d.ts +18 -0
- package/api/setBillingAddress/setBillingAddress.d.ts +2 -2
- package/api/setPaymentMethod/graphql/index.d.ts +19 -0
- package/api/{setBillingAddress/graphql/setBillingAddress.graphql.d.ts → setPaymentMethod/graphql/setPaymentMethodOnCart.graphql.d.ts} +2 -2
- package/api/setPaymentMethod/graphql/setPaymentMethodOnQuote.graphql.d.ts +18 -0
- package/api/setPaymentMethod/setPaymentMethod.d.ts +2 -2
- package/api/setShippingAddress/graphql/index.d.ts +21 -0
- package/api/setShippingAddress/graphql/{setShippingAddressAndUseAsBilling.graphql.d.ts → setShippingAddressOnCartAndUseAsBillingMutation.graphql.d.ts} +2 -2
- package/api/setShippingAddress/graphql/{setShippingAddress.graphql.d.ts → setShippingAddressOnCartMutation.graphql.d.ts} +2 -2
- package/api/setShippingAddress/graphql/setShippingAddressOnQuote.graphql.d.ts +18 -0
- package/api/setShippingAddress/graphql/setShippingAddressOnQuoteAndUseAsBillingMutation.graphql.d.ts +18 -0
- package/api/setShippingAddress/setShippingAddress.d.ts +1 -1
- package/api/setShippingMethods/graphql/index.d.ts +19 -0
- package/api/setShippingMethods/graphql/setShippingMethodsOnCart.graphql.d.ts +1 -1
- package/api/setShippingMethods/graphql/setShippingMethodsOnQuote.graphql.d.ts +18 -0
- package/api/setShippingMethods/index.d.ts +1 -0
- package/api/setShippingMethods/setShippingMethods.d.ts +3 -17
- package/api/synchronizeCheckout/synchronizeCheckout.d.ts +2 -2
- package/api.js +2 -66
- package/api.js.map +1 -1
- package/chunks/ConditionalWrapper.js +1 -1
- package/chunks/ConditionalWrapper.js.map +1 -1
- package/chunks/PaymentOnAccount2.js +4 -0
- package/chunks/PaymentOnAccount2.js.map +1 -0
- package/chunks/PurchaseOrder.js +4 -0
- package/chunks/PurchaseOrder.js.map +1 -0
- package/chunks/checkout.js.map +1 -1
- package/chunks/classifiers.js +4 -0
- package/chunks/classifiers.js.map +1 -0
- package/chunks/dom.js.map +1 -1
- package/chunks/events.js +4 -0
- package/chunks/events.js.map +1 -0
- package/chunks/events2.js +4 -0
- package/chunks/events2.js.map +1 -0
- package/chunks/fetch-graphql.js +14 -0
- package/chunks/fetch-graphql.js.map +1 -0
- package/chunks/getCompanyCredit.js +15 -0
- package/chunks/getCompanyCredit.js.map +1 -0
- package/chunks/guards.js +4 -0
- package/chunks/guards.js.map +1 -0
- package/chunks/render.js +10 -0
- package/chunks/render.js.map +1 -0
- package/chunks/setBillingAddress.js +25 -5
- package/chunks/setBillingAddress.js.map +1 -1
- package/chunks/setGuestEmailOnCart.js +3 -3
- package/chunks/setGuestEmailOnCart.js.map +1 -1
- package/chunks/setPaymentMethod.js +21 -6
- package/chunks/setPaymentMethod.js.map +1 -1
- package/chunks/setShippingAddress.js +109 -0
- package/chunks/setShippingAddress.js.map +1 -0
- package/chunks/setShippingMethods.js +19 -4
- package/chunks/setShippingMethods.js.map +1 -1
- package/chunks/synchronizeCheckout.js +13 -5
- package/chunks/synchronizeCheckout.js.map +1 -1
- package/chunks/transform-shipping-estimate.js +4 -0
- package/chunks/transform-shipping-estimate.js.map +1 -0
- package/chunks/transform-shipping-methods.js +4 -0
- package/chunks/transform-shipping-methods.js.map +1 -0
- package/chunks/values.js +1 -1
- package/chunks/values.js.map +1 -1
- package/components/AddressValidation/AddressValidation.d.ts +14 -0
- package/components/AddressValidation/index.d.ts +19 -0
- package/components/PaymentMethods/PaymentMethods.d.ts +1 -1
- package/components/PaymentOnAccount/PaymentOnAccount.d.ts +17 -0
- package/components/PaymentOnAccount/PaymentOnAccountSkeleton.d.ts +4 -0
- package/components/PaymentOnAccount/index.d.ts +20 -0
- package/components/PurchaseOrder/PurchaseOrder.d.ts +10 -0
- package/components/PurchaseOrder/index.d.ts +19 -0
- package/components/ShippingMethods/ShippingMethods.d.ts +1 -1
- package/components/index.d.ts +4 -1
- package/containers/AddressValidation/AddressValidation.d.ts +12 -0
- package/containers/AddressValidation/index.d.ts +19 -0
- package/containers/AddressValidation.d.ts +3 -0
- package/containers/AddressValidation.js +4 -0
- package/containers/AddressValidation.js.map +1 -0
- package/containers/BillToShippingAddress.js +1 -1
- package/containers/BillToShippingAddress.js.map +1 -1
- package/containers/EstimateShipping.js +1 -1
- package/containers/EstimateShipping.js.map +1 -1
- package/containers/LoginForm/LoginForm.d.ts +1 -1
- package/containers/LoginForm.js +1 -1
- package/containers/LoginForm.js.map +1 -1
- package/containers/MergedCartBanner.js +1 -1
- package/containers/MergedCartBanner.js.map +1 -1
- package/containers/OutOfStock.js +1 -1
- package/containers/OutOfStock.js.map +1 -1
- package/containers/PaymentMethods/PaymentMethods.d.ts +9 -8
- package/containers/PaymentMethods/handlers.d.ts +11 -0
- package/containers/PaymentMethods.js +1 -1
- package/containers/PaymentMethods.js.map +1 -1
- package/containers/PaymentOnAccount/PaymentOnAccount.d.ts +10 -0
- package/containers/PaymentOnAccount/index.d.ts +11 -0
- package/containers/PaymentOnAccount.d.ts +3 -0
- package/containers/PaymentOnAccount.js +4 -0
- package/containers/PaymentOnAccount.js.map +1 -0
- package/containers/PlaceOrder/PlaceOrder.d.ts +2 -1
- package/containers/PlaceOrder.js +1 -1
- package/containers/PlaceOrder.js.map +1 -1
- package/containers/PurchaseOrder/PurchaseOrder.d.ts +10 -0
- package/containers/PurchaseOrder/index.d.ts +19 -0
- package/containers/PurchaseOrder.d.ts +3 -0
- package/containers/PurchaseOrder.js +4 -0
- package/containers/PurchaseOrder.js.map +1 -0
- package/containers/ServerError/ServerError.d.ts +2 -1
- package/containers/ServerError.js +1 -1
- package/containers/ServerError.js.map +1 -1
- package/containers/ShippingMethods/ShippingMethods.d.ts +2 -2
- package/containers/ShippingMethods.js +1 -1
- package/containers/ShippingMethods.js.map +1 -1
- package/containers/TermsAndConditions.js +1 -1
- package/containers/TermsAndConditions.js.map +1 -1
- package/containers/index.d.ts +3 -0
- package/data/models/address.d.ts +11 -6
- package/data/models/api.d.ts +23 -10
- package/data/models/cart.d.ts +7 -7
- package/data/models/checkout.d.ts +14 -0
- package/data/models/company-credit.d.ts +7 -0
- package/data/models/country.d.ts +1 -1
- package/data/models/index.d.ts +3 -1
- package/data/models/{price.d.ts → money.d.ts} +2 -2
- package/data/models/payment-method.d.ts +2 -0
- package/data/models/quote.d.ts +16 -0
- package/data/models/shipping-estimate.d.ts +4 -4
- package/data/models/shipping-method.d.ts +4 -4
- package/data/models/values.d.ts +1 -1
- package/data/transforms/index.d.ts +9 -1
- package/data/transforms/transform-api.d.ts +12 -0
- package/data/transforms/{transform-address.d.ts → transform-cart-address.d.ts} +41 -43
- package/data/transforms/transform-cart.d.ts +1 -1
- package/data/transforms/transform-company-credit.d.ts +7 -0
- package/data/transforms/transform-country.d.ts +8 -0
- package/data/transforms/transform-custom-attributes.d.ts +5 -0
- package/data/transforms/transform-negotiable-quote.d.ts +7 -0
- package/data/transforms/transform-payment-methods.d.ts +1 -1
- package/data/transforms/transform-quote-address.d.ts +90 -0
- package/data/transforms/transform-region.d.ts +8 -0
- package/fragments.js +180 -70
- package/fragments.js.map +1 -1
- package/i18n/en_US.json.d.ts +26 -0
- package/lib/enqueueRequest.d.ts +2 -2
- package/lib/errors/classifiers.d.ts +38 -0
- package/lib/errors/customErrors.d.ts +42 -0
- package/lib/errors/index.d.ts +20 -0
- package/lib/errors/mapErrorToCode.d.ts +4 -0
- package/lib/events.d.ts +3 -2
- package/lib/guards.d.ts +18 -0
- package/lib/index.d.ts +2 -2
- package/lib/state.d.ts +5 -3
- package/lib/utils/api.d.ts +16 -0
- package/lib/utils/events.d.ts +10 -0
- package/lib/utils/forms.d.ts +5 -0
- package/lib/utils/fragments.d.ts +19 -0
- package/lib/utils/index.d.ts +24 -0
- package/lib/utils/meta.d.ts +19 -0
- package/lib/utils/transformers.d.ts +6 -0
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +4 -0
- package/lib/utils.js.map +1 -0
- package/package.json +1 -1
- package/render.js +4 -4
- package/render.js.map +1 -1
- package/tests/constants.d.ts +1 -0
- package/tests/fixtures/fragments/cart.d.ts +47 -42
- package/tests/fixtures/fragments/shipping-address.d.ts +2 -1
- package/tests/fixtures/helpers/session-storage.d.ts +68 -0
- package/tests/fixtures/index.d.ts +1 -0
- package/tests/fixtures/models/index.d.ts +1 -1
- package/tests/fixtures/models/quote.d.ts +9 -0
- package/tests/fixtures/queries/get-company-credit.d.ts +14 -0
- package/tests/fixtures/queries/index.d.ts +1 -0
- package/types/api.d.ts +6 -0
- package/types/{TitleProps.d.ts → components.d.ts} +2 -1
- package/types/guards.d.ts +5 -0
- package/types/index.d.ts +22 -0
- package/types/storefront.d.ts +165 -0
- package/types/utils.d.ts +19 -0
- package/chunks/ServerErrorSignal.js +0 -4
- package/chunks/ServerErrorSignal.js.map +0 -1
- package/chunks/errors.js +0 -14
- package/chunks/errors.js.map +0 -1
- package/errors/errors.d.ts +0 -30
- package/lib/network-error.d.ts +0 -22
- package/signals/ServerErrorSignal.d.ts +0 -18
- package/types/ComponentTypes.d.ts +0 -18
- /package/lib/{dom.d.ts → utils/dom.d.ts} +0 -0
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{CHECKOUT_DATA_FRAGMENT as
|
|
4
|
-
mutation setBillingAddress(
|
|
5
|
-
|
|
3
|
+
import{CHECKOUT_DATA_FRAGMENT as A,NEGOTIABLE_QUOTE_FRAGMENT as I}from"../fragments.js";import{e as g,c as p,d as c}from"./guards.js";import{t as B,e as m}from"./synchronizeCheckout.js";import{s as r,d as f,Q as C,I as o,l as a}from"./fetch-graphql.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";const Q=`
|
|
4
|
+
mutation setBillingAddress(
|
|
5
|
+
$cartId: String!
|
|
6
|
+
$billingAddress: BillingAddressInput!
|
|
7
|
+
) {
|
|
8
|
+
setBillingAddressOnCart(
|
|
9
|
+
input: { cart_id: $cartId, billing_address: $billingAddress }
|
|
10
|
+
) {
|
|
6
11
|
cart {
|
|
7
12
|
...CHECKOUT_DATA_FRAGMENT
|
|
8
13
|
}
|
|
9
14
|
}
|
|
10
15
|
}
|
|
11
16
|
|
|
12
|
-
${
|
|
13
|
-
`,
|
|
17
|
+
${A}
|
|
18
|
+
`,T=`
|
|
19
|
+
mutation setBillingAddressOnQuote(
|
|
20
|
+
$quoteId: ID!
|
|
21
|
+
$billingAddress: NegotiableQuoteBillingAddressInput!
|
|
22
|
+
) {
|
|
23
|
+
setNegotiableQuoteBillingAddress(
|
|
24
|
+
input: { quote_uid: $quoteId, billing_address: $billingAddress }
|
|
25
|
+
) {
|
|
26
|
+
quote {
|
|
27
|
+
...NEGOTIABLE_QUOTE_FRAGMENT
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
${I}
|
|
33
|
+
`,n=(t,s,e,i,d,l)=>async u=>await f({type:"mutation",query:e,options:{variables:{[s]:t,billingAddress:d(u)}},path:l,queueName:C.Updates,transformer:i}),b=({address:t,customerAddressId:s,customerAddressUid:e,sameAsShipping:i=!1})=>{if(!s&&e)throw new o("customerAddressUid is not supported");if(!i&&!s&&!t)throw new a},E=({address:t,customerAddressId:s,customerAddressUid:e,sameAsShipping:i=!1})=>{if(!e&&s)throw new o("customerAddressId is not supported");if(!i&&!e&&!t)throw new a},N=t=>{const s=!!r.cartId,e=!!r.quoteId;s?b(t):e&&E(t)},G=async t=>(g(),N(t),await(!!r.cartId?n(r.cartId,"cartId",Q,B,p,"setBillingAddressOnCart.cart"):n(r.quoteId,"quoteId",T,m,c,"setNegotiableQuoteBillingAddress.quote"))(t));export{G as s};
|
|
14
34
|
//# sourceMappingURL=setBillingAddress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setBillingAddress.js","sources":["/@dropins/storefront-checkout/src/api/setBillingAddress/graphql/setBillingAddress.graphql.ts","/@dropins/storefront-checkout/src/api/setBillingAddress/setBillingAddress.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 { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const
|
|
1
|
+
{"version":3,"file":"setBillingAddress.js","sources":["/@dropins/storefront-checkout/src/api/setBillingAddress/graphql/setBillingAddressOnCartMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setBillingAddress/graphql/setBillingAddressOnQuoteMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setBillingAddress/setBillingAddress.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 { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setBillingAddressOnCartMutation = /* GraphQL */ `\n mutation setBillingAddress(\n $cartId: String!\n $billingAddress: BillingAddressInput!\n ) {\n setBillingAddressOnCart(\n input: { cart_id: $cartId, billing_address: $billingAddress }\n ) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const setBillingAddressOnQuoteMutation = /* GraphQL */ `\n mutation setBillingAddressOnQuote(\n $quoteId: ID!\n $billingAddress: NegotiableQuoteBillingAddressInput!\n ) {\n setNegotiableQuoteBillingAddress(\n input: { quote_uid: $quoteId, billing_address: $billingAddress }\n ) {\n quote {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\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 setBillingAddressOnCartMutation,\n setBillingAddressOnQuoteMutation,\n} from '@/checkout/api/setBillingAddress/graphql';\nimport { BillingAddressInput as BillingAddressInputModel } from '@/checkout/data/models';\nimport {\n transformBillingAddressInputModelToCartInput,\n transformBillingAddressInputModelToQuoteInput,\n transformCart,\n transformNegotiableQuote,\n} from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { QueueName } from '@/checkout/lib/enqueueRequest';\nimport { InvalidInput, MissingBillingAddress } from '@/checkout/lib/errors';\nimport { ensureHasCartOrQuoteId } from '@/checkout/lib/guards';\nimport { state } from '@/checkout/lib/state';\n\nconst createBillingAddressSetter = <TTransformedInput, TTransformedOutput>(\n entityId: string,\n entityKey: string,\n mutation: string,\n transformer: (data: any) => TTransformedOutput,\n transformInput: (input: BillingAddressInputModel) => TTransformedInput,\n path: string\n) => {\n return async (\n input: BillingAddressInputModel\n ): Promise<TTransformedOutput> => {\n return await dispatchApiCall({\n type: 'mutation',\n query: mutation,\n options: {\n variables: {\n [entityKey]: entityId,\n billingAddress: transformInput(input),\n },\n },\n path,\n queueName: QueueName.Updates,\n transformer,\n });\n };\n};\n\nconst ensureIsValidCartInput = ({\n address,\n customerAddressId,\n customerAddressUid,\n sameAsShipping = false,\n}: BillingAddressInputModel) => {\n if (!customerAddressId && customerAddressUid) {\n throw new InvalidInput('customerAddressUid is not supported');\n }\n\n if (!sameAsShipping && !customerAddressId && !address) {\n throw new MissingBillingAddress();\n }\n};\n\nconst ensureIsValidQuoteInput = ({\n address,\n customerAddressId,\n customerAddressUid,\n sameAsShipping = false,\n}: BillingAddressInputModel) => {\n if (!customerAddressUid && customerAddressId) {\n throw new InvalidInput('customerAddressId is not supported');\n }\n\n if (!sameAsShipping && !customerAddressUid && !address) {\n throw new MissingBillingAddress();\n }\n};\n\nconst ensureIsValidInput = (input: BillingAddressInputModel) => {\n const isCart = Boolean(state.cartId);\n const isQuote = Boolean(state.quoteId);\n\n if (isCart) {\n ensureIsValidCartInput(input);\n } else if (isQuote) {\n ensureIsValidQuoteInput(input);\n }\n};\n\nexport const setBillingAddress = async (input: BillingAddressInputModel) => {\n ensureHasCartOrQuoteId();\n ensureIsValidInput(input);\n\n const isCart = Boolean(state.cartId);\n\n const setter = isCart\n ? createBillingAddressSetter(\n state.cartId!,\n 'cartId',\n setBillingAddressOnCartMutation,\n transformCart,\n transformBillingAddressInputModelToCartInput,\n 'setBillingAddressOnCart.cart'\n )\n : createBillingAddressSetter(\n state.quoteId!,\n 'quoteId',\n setBillingAddressOnQuoteMutation,\n transformNegotiableQuote,\n transformBillingAddressInputModelToQuoteInput,\n 'setNegotiableQuoteBillingAddress.quote'\n );\n\n return await setter(input);\n};\n"],"names":["setBillingAddressOnCartMutation","CHECKOUT_DATA_FRAGMENT","setBillingAddressOnQuoteMutation","NEGOTIABLE_QUOTE_FRAGMENT","createBillingAddressSetter","entityId","entityKey","mutation","transformer","transformInput","path","input","dispatchApiCall","QueueName","ensureIsValidCartInput","address","customerAddressId","customerAddressUid","sameAsShipping","InvalidInput","MissingBillingAddress","ensureIsValidQuoteInput","ensureIsValidInput","isCart","state","isQuote","setBillingAddress","ensureHasCartOrQuoteId","transformCart","transformBillingAddressInputModelToCartInput","transformNegotiableQuote","transformBillingAddressInputModelToQuoteInput"],"mappings":"+TAmBa,MAAAA,EAAgD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAczDC,CAAsB;AAAA,ECdbC,EAAiD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc1DC,CAAyB;AAAA,ECCvBC,EAA6B,CACjCC,EACAC,EACAC,EACAC,EACAC,EACAC,IAEO,MACLC,GAEO,MAAMC,EAAgB,CAC3B,KAAM,WACN,MAAOL,EACP,QAAS,CACP,UAAW,CACT,CAACD,CAAS,EAAGD,EACb,eAAgBI,EAAeE,CAAK,CAAA,CAExC,EACA,KAAAD,EACA,UAAWG,EAAU,QACrB,YAAAL,CAAA,CACD,EAICM,EAAyB,CAAC,CAC9B,QAAAC,EACA,kBAAAC,EACA,mBAAAC,EACA,eAAAC,EAAiB,EACnB,IAAgC,CAC1B,GAAA,CAACF,GAAqBC,EAClB,MAAA,IAAIE,EAAa,qCAAqC,EAG9D,GAAI,CAACD,GAAkB,CAACF,GAAqB,CAACD,EAC5C,MAAM,IAAIK,CAEd,EAEMC,EAA0B,CAAC,CAC/B,QAAAN,EACA,kBAAAC,EACA,mBAAAC,EACA,eAAAC,EAAiB,EACnB,IAAgC,CAC1B,GAAA,CAACD,GAAsBD,EACnB,MAAA,IAAIG,EAAa,oCAAoC,EAG7D,GAAI,CAACD,GAAkB,CAACD,GAAsB,CAACF,EAC7C,MAAM,IAAIK,CAEd,EAEME,EAAsBX,GAAoC,CACxD,MAAAY,EAAS,EAAQC,EAAM,OACvBC,EAAU,EAAQD,EAAM,QAE1BD,EACFT,EAAuBH,CAAK,EACnBc,GACTJ,EAAwBV,CAAK,CAEjC,EAEae,EAAoB,MAAOf,IACfgB,EAAA,EACvBL,EAAmBX,CAAK,EAsBjB,MApBQ,EAAQa,EAAM,OAGzBpB,EACEoB,EAAM,OACN,SACAxB,EACA4B,EACAC,EACA,8BAAA,EAEFzB,EACEoB,EAAM,QACN,UACAtB,EACA4B,EACAC,EACA,wCACF,GAEgBpB,CAAK"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{CUSTOMER_FRAGMENT as o,CHECKOUT_DATA_FRAGMENT as n}from"../fragments.js";import{s as m,d as r,
|
|
3
|
+
import{CUSTOMER_FRAGMENT as o,CHECKOUT_DATA_FRAGMENT as n}from"../fragments.js";import{s as m,d as r,q as l,n as u,Q as c}from"./fetch-graphql.js";import{merge as E}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import{c as f,t as p}from"./synchronizeCheckout.js";const C=t=>{var i,a,s;if(!t)return null;const e={firstName:t.firstname||"",lastName:t.lastname||"",email:t.email||""};return E(e,(s=(a=(i=f.getConfig().models)==null?void 0:i.CustomerModel)==null?void 0:a.transformer)==null?void 0:s.call(a,t))},y=t=>!!(t!=null&&t.is_email_available),A=`
|
|
4
4
|
query getCustomer {
|
|
5
5
|
customer {
|
|
6
6
|
...CUSTOMER_FRAGMENT
|
|
@@ -8,7 +8,7 @@ import{CUSTOMER_FRAGMENT as o,CHECKOUT_DATA_FRAGMENT as n}from"../fragments.js";
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
${o}
|
|
11
|
-
`,
|
|
11
|
+
`,M=async()=>m.authenticated?await r({options:{method:"GET",cache:"no-cache"},path:"customer",query:A,transformer:C,type:"query"}):null,g=`
|
|
12
12
|
query isEmailAvailable($email: String!) {
|
|
13
13
|
isEmailAvailable(email: $email) {
|
|
14
14
|
is_email_available
|
|
@@ -24,5 +24,5 @@ import{CUSTOMER_FRAGMENT as o,CHECKOUT_DATA_FRAGMENT as n}from"../fragments.js";
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
${n}
|
|
27
|
-
`,N=async t=>{const
|
|
27
|
+
`,N=async t=>{const e=m.cartId;if(!e)throw new u;return await r({options:{variables:{cartId:e,email:t}},path:"setGuestEmailOnCart.cart",query:h,queueName:c.Updates,transformer:p,type:"mutation"})};export{M as g,q as i,N as s};
|
|
28
28
|
//# sourceMappingURL=setGuestEmailOnCart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setGuestEmailOnCart.js","sources":["/@dropins/storefront-checkout/src/data/transforms/transform-customer.ts","/@dropins/storefront-checkout/src/data/transforms/transform-email-availability.ts","/@dropins/storefront-checkout/src/api/getCustomer/graphql/getCustomer.graphql.ts","/@dropins/storefront-checkout/src/api/getCustomer/getCustomer.ts","/@dropins/storefront-checkout/src/api/isEmailAvailable/graphql/isEmailAvailable.graphql.ts","/@dropins/storefront-checkout/src/api/isEmailAvailable/isEmailAvailable.ts","/@dropins/storefront-checkout/src/api/setGuestEmailOnCart/graphql/setGuestEmailOnCart.graphql.ts","/@dropins/storefront-checkout/src/api/setGuestEmailOnCart/setGuestEmailOnCart.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 { config } from '@/checkout/api';\nimport { Customer as CustomerModel } from '@/checkout/data/models';\nimport { GetCustomerQuery } from '@/checkout/__generated__/types';\nimport { merge } from '@adobe-commerce/elsie/lib';\n\ntype Customer = GetCustomerQuery['customer'];\n\nconst transformCustomer = (data: Customer): CustomerModel | null => {\n if (!data) return null;\n\n const model = {\n firstName: data.firstname || '',\n lastName: data.lastname || '',\n email: data.email || '',\n };\n\n // Extend the model merging custom transformer, if provided\n return merge(\n model, // default transformer\n config.getConfig().models?.CustomerModel?.transformer?.(data) // custom transformer\n );\n};\n\nexport { Customer, transformCustomer };\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 { IsEmailAvailableQuery } from '@/checkout/__generated__/types';\nimport { EmailAvailability } from '@/checkout/data/models';\n\nconst transformEmailAvailability = (\n data: IsEmailAvailableQuery['isEmailAvailable']\n): EmailAvailability => {\n return Boolean(data?.is_email_available);\n};\n\nexport { transformEmailAvailability };\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 { CUSTOMER_FRAGMENT } from '@/checkout/api/graphql/CustomerFragment.graphql';\n\nexport const getCustomerQuery = /* GraphQL */ `\n query getCustomer {\n customer {\n ...CUSTOMER_FRAGMENT\n }\n }\n\n ${CUSTOMER_FRAGMENT}\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 { getCustomerQuery } from '@/checkout/api/getCustomer/graphql/getCustomer.graphql';\nimport { Customer } from '@/checkout/data/models';\nimport { transformCustomer } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { state } from '@/checkout/lib/state';\n\nexport const getCustomer = async (): Promise<Customer | null> => {\n if (!state.authenticated) return null;\n\n return await dispatchApiCall({\n options: { method: 'GET', cache: 'no-cache' },\n path: 'customer',\n query: getCustomerQuery,\n transformer: transformCustomer,\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\nexport const isEmailAvailableQuery = /* GraphQL */ `\n query isEmailAvailable($email: String!) {\n isEmailAvailable(email: $email) {\n is_email_available\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 { isEmailAvailableQuery } from '@/checkout/api/isEmailAvailable/graphql/isEmailAvailable.graphql';\nimport { EmailAvailability } from '@/checkout/data/models/email-availability';\nimport { transformEmailAvailability } from '@/checkout/data/transforms';\nimport { MissingEmail } from '@/checkout/errors';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\n\nexport const isEmailAvailable = async (\n email: string\n): Promise<EmailAvailability> => {\n if (!email) throw new MissingEmail();\n\n return await dispatchApiCall({\n options: { method: 'GET', cache: 'no-cache', variables: { email } },\n path: 'isEmailAvailable',\n query: isEmailAvailableQuery,\n transformer: transformEmailAvailability,\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 { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setGuestEmailMutation = /* GraphQL */ `\n mutation setGuestEmail($cartId: String!, $email: String!) {\n setGuestEmailOnCart(input: { cart_id: $cartId, email: $email }) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\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 { setGuestEmailMutation } from '@/checkout/api/setGuestEmailOnCart/graphql/setGuestEmailOnCart.graphql';\nimport { transformCart } from '@/checkout/data/transforms';\nimport { MissingCart } from '@/checkout/errors';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { QueueName } from '@/checkout/lib/enqueueRequest';\nimport { state } from '@/checkout/lib/state';\n\nexport const setGuestEmailOnCart = async (email: string) => {\n const cartId = state.cartId;\n\n if (!cartId) throw new MissingCart();\n\n return await dispatchApiCall({\n options: { variables: { cartId, email } },\n path: 'setGuestEmailOnCart.cart',\n query: setGuestEmailMutation,\n queueName: QueueName.CartUpdate,\n transformer: transformCart,\n type: 'mutation',\n });\n};\n"],"names":["transformCustomer","data","model","merge","_c","_b","_a","config","transformEmailAvailability","getCustomerQuery","CUSTOMER_FRAGMENT","getCustomer","state","dispatchApiCall","isEmailAvailableQuery","isEmailAvailable","email","MissingEmail","setGuestEmailMutation","CHECKOUT_DATA_FRAGMENT","setGuestEmailOnCart","cartId","MissingCart","QueueName","transformCart"],"mappings":"kRAwBA,MAAMA,EAAqBC,GAAyC,WAC9D,GAAA,CAACA,EAAa,OAAA,KAElB,MAAMC,EAAQ,CACZ,UAAWD,EAAK,WAAa,GAC7B,SAAUA,EAAK,UAAY,GAC3B,MAAOA,EAAK,OAAS,EACvB,EAGO,OAAAE,EACLD,GACAE,GAAAC,GAAAC,EAAAC,EAAO,UAAU,EAAE,SAAnB,YAAAD,EAA2B,gBAA3B,YAAAD,EAA0C,cAA1C,YAAAD,EAAA,KAAAC,EAAwDJ,EAC1D,CACF,EClBMO,EACJP,GAEO,GAAQA,GAAA,MAAAA,EAAM,oBCJVQ,EAAiC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO1CC,CAAiB;AAAA,ECHRC,EAAc,SACpBC,EAAM,cAEJ,MAAMC,EAAgB,CAC3B,QAAS,CAAE,OAAQ,MAAO,MAAO,UAAW,EAC5C,KAAM,WACN,MAAOJ,EACP,YAAaT,EACb,KAAM,OAAA,CACP,EARgC,KCPtBc,EAAsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECMtCC,EAAmB,MAC9BC,GAC+B,CAC/B,GAAI,CAACA,EAAa,MAAA,IAAIC,EAEtB,OAAO,MAAMJ,EAAgB,CAC3B,QAAS,CAAE,OAAQ,MAAO,MAAO,WAAY,UAAW,CAAE,MAAAG,EAAQ,EAClE,KAAM,mBACN,MAAOF,EACP,YAAaN,EACb,KAAM,OAAA,CACP,CACH,EChBaU,EAAsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAS/CC,CAAsB;AAAA,ECJbC,EAAsB,MAAOJ,GAAkB,CAC1D,MAAMK,EAAST,EAAM,OAErB,GAAI,CAACS,EAAc,MAAA,IAAIC,EAEvB,OAAO,MAAMT,EAAgB,CAC3B,QAAS,CAAE,UAAW,CAAE,OAAAQ,EAAQ,MAAAL,EAAQ,EACxC,KAAM,2BACN,MAAOE,EACP,UAAWK,EAAU,WACrB,YAAaC,EACb,KAAM,UAAA,CACP,CACH"}
|
|
1
|
+
{"version":3,"file":"setGuestEmailOnCart.js","sources":["/@dropins/storefront-checkout/src/data/transforms/transform-customer.ts","/@dropins/storefront-checkout/src/data/transforms/transform-email-availability.ts","/@dropins/storefront-checkout/src/api/getCustomer/graphql/getCustomer.graphql.ts","/@dropins/storefront-checkout/src/api/getCustomer/getCustomer.ts","/@dropins/storefront-checkout/src/api/isEmailAvailable/graphql/isEmailAvailable.graphql.ts","/@dropins/storefront-checkout/src/api/isEmailAvailable/isEmailAvailable.ts","/@dropins/storefront-checkout/src/api/setGuestEmailOnCart/graphql/setGuestEmailOnCart.graphql.ts","/@dropins/storefront-checkout/src/api/setGuestEmailOnCart/setGuestEmailOnCart.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 { config } from '@/checkout/api';\nimport { Customer as CustomerModel } from '@/checkout/data/models';\nimport { GetCustomerQuery } from '@/checkout/__generated__/types';\nimport { merge } from '@adobe-commerce/elsie/lib';\n\ntype Customer = GetCustomerQuery['customer'];\n\nconst transformCustomer = (data: Customer): CustomerModel | null => {\n if (!data) return null;\n\n const model = {\n firstName: data.firstname || '',\n lastName: data.lastname || '',\n email: data.email || '',\n };\n\n // Extend the model merging custom transformer, if provided\n return merge(\n model, // default transformer\n config.getConfig().models?.CustomerModel?.transformer?.(data) // custom transformer\n );\n};\n\nexport { Customer, transformCustomer };\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 { IsEmailAvailableQuery } from '@/checkout/__generated__/types';\nimport { EmailAvailability } from '@/checkout/data/models';\n\nconst transformEmailAvailability = (\n data: IsEmailAvailableQuery['isEmailAvailable']\n): EmailAvailability => {\n return Boolean(data?.is_email_available);\n};\n\nexport { transformEmailAvailability };\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 { CUSTOMER_FRAGMENT } from '@/checkout/api/graphql/CustomerFragment.graphql';\n\nexport const getCustomerQuery = /* GraphQL */ `\n query getCustomer {\n customer {\n ...CUSTOMER_FRAGMENT\n }\n }\n\n ${CUSTOMER_FRAGMENT}\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 { getCustomerQuery } from '@/checkout/api/getCustomer/graphql/getCustomer.graphql';\nimport { Customer } from '@/checkout/data/models';\nimport { transformCustomer } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { state } from '@/checkout/lib/state';\n\nexport const getCustomer = async (): Promise<Customer | null> => {\n if (!state.authenticated) return null;\n\n return await dispatchApiCall({\n options: { method: 'GET', cache: 'no-cache' },\n path: 'customer',\n query: getCustomerQuery,\n transformer: transformCustomer,\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\nexport const isEmailAvailableQuery = /* GraphQL */ `\n query isEmailAvailable($email: String!) {\n isEmailAvailable(email: $email) {\n is_email_available\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 { isEmailAvailableQuery } from '@/checkout/api/isEmailAvailable/graphql/isEmailAvailable.graphql';\nimport { EmailAvailability } from '@/checkout/data/models/email-availability';\nimport { transformEmailAvailability } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { MissingEmail } from '@/checkout/lib/errors';\n\nexport const isEmailAvailable = async (\n email: string\n): Promise<EmailAvailability> => {\n if (!email) throw new MissingEmail();\n\n return await dispatchApiCall({\n options: { method: 'GET', cache: 'no-cache', variables: { email } },\n path: 'isEmailAvailable',\n query: isEmailAvailableQuery,\n transformer: transformEmailAvailability,\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 { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setGuestEmailMutation = /* GraphQL */ `\n mutation setGuestEmail($cartId: String!, $email: String!) {\n setGuestEmailOnCart(input: { cart_id: $cartId, email: $email }) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\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 { setGuestEmailMutation } from '@/checkout/api/setGuestEmailOnCart/graphql/setGuestEmailOnCart.graphql';\nimport { transformCart } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { QueueName } from '@/checkout/lib/enqueueRequest';\nimport { MissingCart } from '@/checkout/lib/errors';\nimport { state } from '@/checkout/lib/state';\n\nexport const setGuestEmailOnCart = async (email: string) => {\n const cartId = state.cartId;\n\n if (!cartId) throw new MissingCart();\n\n return await dispatchApiCall({\n options: { variables: { cartId, email } },\n path: 'setGuestEmailOnCart.cart',\n query: setGuestEmailMutation,\n queueName: QueueName.Updates,\n transformer: transformCart,\n type: 'mutation',\n });\n};\n"],"names":["transformCustomer","data","model","merge","_c","_b","_a","config","transformEmailAvailability","getCustomerQuery","CUSTOMER_FRAGMENT","getCustomer","state","dispatchApiCall","isEmailAvailableQuery","isEmailAvailable","email","MissingEmail","setGuestEmailMutation","CHECKOUT_DATA_FRAGMENT","setGuestEmailOnCart","cartId","MissingCart","QueueName","transformCart"],"mappings":"yRAwBA,MAAMA,EAAqBC,GAAyC,WAC9D,GAAA,CAACA,EAAa,OAAA,KAElB,MAAMC,EAAQ,CACZ,UAAWD,EAAK,WAAa,GAC7B,SAAUA,EAAK,UAAY,GAC3B,MAAOA,EAAK,OAAS,EACvB,EAGO,OAAAE,EACLD,GACAE,GAAAC,GAAAC,EAAAC,EAAO,UAAU,EAAE,SAAnB,YAAAD,EAA2B,gBAA3B,YAAAD,EAA0C,cAA1C,YAAAD,EAAA,KAAAC,EAAwDJ,EAC1D,CACF,EClBMO,EACJP,GAEO,GAAQA,GAAA,MAAAA,EAAM,oBCJVQ,EAAiC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO1CC,CAAiB;AAAA,ECHRC,EAAc,SACpBC,EAAM,cAEJ,MAAMC,EAAgB,CAC3B,QAAS,CAAE,OAAQ,MAAO,MAAO,UAAW,EAC5C,KAAM,WACN,MAAOJ,EACP,YAAaT,EACb,KAAM,OAAA,CACP,EARgC,KCPtBc,EAAsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECMtCC,EAAmB,MAC9BC,GAC+B,CAC/B,GAAI,CAACA,EAAa,MAAA,IAAIC,EAEtB,OAAO,MAAMJ,EAAgB,CAC3B,QAAS,CAAE,OAAQ,MAAO,MAAO,WAAY,UAAW,CAAE,MAAAG,EAAQ,EAClE,KAAM,mBACN,MAAOF,EACP,YAAaN,EACb,KAAM,OAAA,CACP,CACH,EChBaU,EAAsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAS/CC,CAAsB;AAAA,ECJbC,EAAsB,MAAOJ,GAAkB,CAC1D,MAAMK,EAAST,EAAM,OAErB,GAAI,CAACS,EAAc,MAAA,IAAIC,EAEvB,OAAO,MAAMT,EAAgB,CAC3B,QAAS,CAAE,UAAW,CAAE,OAAAQ,EAAQ,MAAAL,EAAQ,EACxC,KAAM,2BACN,MAAOE,EACP,UAAWK,EAAU,QACrB,YAAaC,EACb,KAAM,UAAA,CACP,CACH"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{CHECKOUT_DATA_FRAGMENT as
|
|
4
|
-
mutation
|
|
3
|
+
import{CHECKOUT_DATA_FRAGMENT as d,NEGOTIABLE_QUOTE_FRAGMENT as i}from"../fragments.js";import{e as p,a as M,b as y}from"./guards.js";import{t as c,e as h}from"./synchronizeCheckout.js";import{s as e,k as I,d as P,Q as C}from"./fetch-graphql.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";const T=`
|
|
4
|
+
mutation setPaymentMethodOnCart(
|
|
5
5
|
$cartId: String!
|
|
6
|
-
$
|
|
6
|
+
$input: PaymentMethodInput!
|
|
7
7
|
) {
|
|
8
8
|
setPaymentMethodOnCart(
|
|
9
|
-
input: { cart_id: $cartId, payment_method: $
|
|
9
|
+
input: { cart_id: $cartId, payment_method: $input }
|
|
10
10
|
) {
|
|
11
11
|
cart {
|
|
12
12
|
...CHECKOUT_DATA_FRAGMENT
|
|
@@ -14,6 +14,21 @@ import{CHECKOUT_DATA_FRAGMENT as e}from"../fragments.js";import{b as r}from"./sy
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
${
|
|
18
|
-
`,
|
|
17
|
+
${d}
|
|
18
|
+
`,O=`
|
|
19
|
+
mutation setPaymentMethodOnQuote(
|
|
20
|
+
$quoteId: ID!
|
|
21
|
+
$input: NegotiableQuotePaymentMethodInput!
|
|
22
|
+
) {
|
|
23
|
+
setNegotiableQuotePaymentMethod(
|
|
24
|
+
input: { quote_uid: $quoteId, payment_method: $input }
|
|
25
|
+
) {
|
|
26
|
+
quote {
|
|
27
|
+
...NEGOTIABLE_QUOTE_FRAGMENT
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
${i}
|
|
33
|
+
`,n=(t,a,o,r,s,u)=>async m=>await P({type:"mutation",query:o,options:{variables:{[a]:t,input:s(m)}},path:u,queueName:C.Updates,transformer:r}),E=t=>{if(!t.code)throw new I},f=async t=>(p(),E(t),await(!!e.cartId?n(e.cartId,"cartId",T,c,M,"setPaymentMethodOnCart.cart"):n(e.quoteId,"quoteId",O,h,y,"setNegotiableQuotePaymentMethod.quote"))(t));export{f as s};
|
|
19
34
|
//# sourceMappingURL=setPaymentMethod.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setPaymentMethod.js","sources":["/@dropins/storefront-checkout/src/api/setPaymentMethod/graphql/setPaymentMethod.graphql.ts","/@dropins/storefront-checkout/src/api/setPaymentMethod/setPaymentMethod.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 { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const
|
|
1
|
+
{"version":3,"file":"setPaymentMethod.js","sources":["/@dropins/storefront-checkout/src/api/setPaymentMethod/graphql/setPaymentMethodOnCart.graphql.ts","/@dropins/storefront-checkout/src/api/setPaymentMethod/graphql/setPaymentMethodOnQuote.graphql.ts","/@dropins/storefront-checkout/src/api/setPaymentMethod/setPaymentMethod.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 { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setPaymentMethodOnCartMutation = /* GraphQL */ `\n mutation setPaymentMethodOnCart(\n $cartId: String!\n $input: PaymentMethodInput!\n ) {\n setPaymentMethodOnCart(\n input: { cart_id: $cartId, payment_method: $input }\n ) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const setPaymentMethodOnQuoteMutation = /* GraphQL */ `\n mutation setPaymentMethodOnQuote(\n $quoteId: ID!\n $input: NegotiableQuotePaymentMethodInput!\n ) {\n setNegotiableQuotePaymentMethod(\n input: { quote_uid: $quoteId, payment_method: $input }\n ) {\n quote {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\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 setPaymentMethodOnCartMutation,\n setPaymentMethodOnQuoteMutation,\n} from '@/checkout/api/setPaymentMethod/graphql';\nimport { PaymentMethodInput as PaymentMethodInputModel } from '@/checkout/data/models';\nimport {\n transformCart,\n transformNegotiableQuote,\n transformPaymentMethodInputModelToCartInput,\n transformPaymentMethodInputModelToQuoteInput,\n} from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { QueueName } from '@/checkout/lib/enqueueRequest';\nimport { MissingPaymentMethod } from '@/checkout/lib/errors/customErrors';\nimport { ensureHasCartOrQuoteId } from '@/checkout/lib/guards';\nimport { state } from '@/checkout/lib/state';\n\nconst createPaymentMethodSetter = <TTransformedInput, TTransformedOutput>(\n entityId: string,\n entityKey: string,\n mutation: string,\n transformer: (data: any) => TTransformedOutput,\n transformInput: (input: PaymentMethodInputModel) => TTransformedInput,\n path: string\n) => {\n return async (\n input: PaymentMethodInputModel\n ): Promise<TTransformedOutput> => {\n return await dispatchApiCall({\n type: 'mutation',\n query: mutation,\n options: {\n variables: {\n [entityKey]: entityId,\n input: transformInput(input),\n },\n },\n path,\n queueName: QueueName.Updates,\n transformer,\n });\n };\n};\n\nconst ensureHasPaymentMethodCode = (input: PaymentMethodInputModel) => {\n if (!input.code) {\n throw new MissingPaymentMethod();\n }\n};\n\nexport const setPaymentMethod = async (input: PaymentMethodInputModel) => {\n ensureHasCartOrQuoteId();\n ensureHasPaymentMethodCode(input);\n\n const isCart = Boolean(state.cartId);\n\n const setter = isCart\n ? createPaymentMethodSetter(\n state.cartId!,\n 'cartId',\n setPaymentMethodOnCartMutation,\n transformCart,\n transformPaymentMethodInputModelToCartInput,\n 'setPaymentMethodOnCart.cart'\n )\n : createPaymentMethodSetter(\n state.quoteId!,\n 'quoteId',\n setPaymentMethodOnQuoteMutation,\n transformNegotiableQuote,\n transformPaymentMethodInputModelToQuoteInput,\n 'setNegotiableQuotePaymentMethod.quote'\n );\n\n return await setter(input);\n};\n"],"names":["setPaymentMethodOnCartMutation","CHECKOUT_DATA_FRAGMENT","setPaymentMethodOnQuoteMutation","NEGOTIABLE_QUOTE_FRAGMENT","createPaymentMethodSetter","entityId","entityKey","mutation","transformer","transformInput","path","input","dispatchApiCall","QueueName","ensureHasPaymentMethodCode","MissingPaymentMethod","setPaymentMethod","ensureHasCartOrQuoteId","state","transformCart","transformPaymentMethodInputModelToCartInput","transformNegotiableQuote","transformPaymentMethodInputModelToQuoteInput"],"mappings":"wTAmBa,MAAAA,EAA+C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAcxDC,CAAsB;AAAA,ECdbC,EAAgD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAczDC,CAAyB;AAAA,ECCvBC,EAA4B,CAChCC,EACAC,EACAC,EACAC,EACAC,EACAC,IAEO,MACLC,GAEO,MAAMC,EAAgB,CAC3B,KAAM,WACN,MAAOL,EACP,QAAS,CACP,UAAW,CACT,CAACD,CAAS,EAAGD,EACb,MAAOI,EAAeE,CAAK,CAAA,CAE/B,EACA,KAAAD,EACA,UAAWG,EAAU,QACrB,YAAAL,CAAA,CACD,EAICM,EAA8BH,GAAmC,CACjE,GAAA,CAACA,EAAM,KACT,MAAM,IAAII,CAEd,EAEaC,EAAmB,MAAOL,IACdM,EAAA,EACvBH,EAA2BH,CAAK,EAsBzB,MApBQ,EAAQO,EAAM,OAGzBd,EACEc,EAAM,OACN,SACAlB,EACAmB,EACAC,EACA,6BAAA,EAEFhB,EACEc,EAAM,QACN,UACAhB,EACAmB,EACAC,EACA,uCACF,GAEgBX,CAAK"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{s as o,n as G,o as D,d as q,Q as E,I as l,p as Q}from"./fetch-graphql.js";import"@dropins/tools/lib.js";import{t as F,a as O}from"./transform-shipping-estimate.js";import{a as R}from"./transform-shipping-methods.js";import{events as $}from"@dropins/tools/event-bus.js";import{g as N}from"./values.js";import{c as w,t as x,e as H}from"./synchronizeCheckout.js";import{e as V,f as K,g as L}from"./guards.js";import{CHECKOUT_DATA_FRAGMENT as y,NEGOTIABLE_QUOTE_FRAGMENT as B}from"../fragments.js";const k=`
|
|
4
|
+
mutation estimateShippingMethods(
|
|
5
|
+
$cartId: String!
|
|
6
|
+
$address: EstimateAddressInput!
|
|
7
|
+
) {
|
|
8
|
+
estimateShippingMethods(input: { cart_id: $cartId, address: $address }) {
|
|
9
|
+
carrier_title
|
|
10
|
+
carrier_code
|
|
11
|
+
method_title
|
|
12
|
+
method_code
|
|
13
|
+
available
|
|
14
|
+
amount {
|
|
15
|
+
currency
|
|
16
|
+
value
|
|
17
|
+
}
|
|
18
|
+
price_excl_tax {
|
|
19
|
+
currency
|
|
20
|
+
value
|
|
21
|
+
}
|
|
22
|
+
price_incl_tax {
|
|
23
|
+
currency
|
|
24
|
+
value
|
|
25
|
+
}
|
|
26
|
+
error_message
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`,ae=async e=>{var _,m,I,S;const s=o.cartId,t=((_=e==null?void 0:e.criteria)==null?void 0:_.country_code)??((m=o.config)==null?void 0:m.defaultCountry);if(!s)throw new G;if(!t)throw new D;const{region_id:i,region_name:a,zip:p}=(e==null?void 0:e.criteria)??{},n=i||a?{region_id:typeof i=="string"?parseInt(i,10):i,region_code:a}:void 0,h={country_code:t,...p&&{postcode:p},...n&&{region:{...n.region_id&&{region_id:n.region_id},...n.region_code&&{region_code:n.region_code}}}},A={country_id:t,region:(I=h.region)==null?void 0:I.region_code,region_id:(S=h.region)==null?void 0:S.region_id,postcode:p},b=O(A);return q({options:{variables:{cartId:s,address:h}},path:"estimateShippingMethods",query:k,queueName:E.ShippingEstimate,transformer:R,type:"mutation"}).then(r=>{const{defaults:c,shipping:u}=w.getConfig(),f=u!=null&&u.filterOptions?r.filter(u.filterOptions):r,v=f.length>0,U=O(A);let M=null;if(v){const d=N("selectedShippingMethod");let g=r.find(C=>C.code===(d==null?void 0:d.code)&&C.carrier.code===(d==null?void 0:d.carrier.code));!g&&(c!=null&&c.selectedShippingMethod)&&(g=c.selectedShippingMethod(r)??void 0),g||(g=r[0]),M=F(g)}return $.emit("shipping/estimate",{address:U,availableShippingMethods:r,shippingMethod:M,success:!0}),f}).catch(r=>{throw $.emit("shipping/estimate",{address:b,shippingMethod:null,availableShippingMethods:[],success:!1}),r})},z=`
|
|
30
|
+
mutation setShippingAddressOnCartAndUseAsBilling(
|
|
31
|
+
$cartId: String!
|
|
32
|
+
$shippingAddress: ShippingAddressInput!
|
|
33
|
+
) {
|
|
34
|
+
setShippingAddressesOnCart(
|
|
35
|
+
input: { cart_id: $cartId, shipping_addresses: [$shippingAddress] }
|
|
36
|
+
) {
|
|
37
|
+
cart {
|
|
38
|
+
id
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
setBillingAddressOnCart(
|
|
43
|
+
input: { cart_id: $cartId, billing_address: { same_as_shipping: true } }
|
|
44
|
+
) {
|
|
45
|
+
cart {
|
|
46
|
+
...CHECKOUT_DATA_FRAGMENT
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
${y}
|
|
52
|
+
`,P=`
|
|
53
|
+
mutation setShippingAddressOnCart(
|
|
54
|
+
$cartId: String!
|
|
55
|
+
$shippingAddress: ShippingAddressInput!
|
|
56
|
+
) {
|
|
57
|
+
setShippingAddressesOnCart(
|
|
58
|
+
input: { cart_id: $cartId, shipping_addresses: [$shippingAddress] }
|
|
59
|
+
) {
|
|
60
|
+
cart {
|
|
61
|
+
...CHECKOUT_DATA_FRAGMENT
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
${y}
|
|
67
|
+
`,j=`
|
|
68
|
+
mutation setShippingAddressOnQuote(
|
|
69
|
+
$quoteId: ID!
|
|
70
|
+
$shippingAddress: NegotiableQuoteShippingAddressInput!
|
|
71
|
+
) {
|
|
72
|
+
setNegotiableQuoteShippingAddress(
|
|
73
|
+
input: { quote_uid: $quoteId, shipping_addresses: [$shippingAddress] }
|
|
74
|
+
) {
|
|
75
|
+
quote {
|
|
76
|
+
...NEGOTIABLE_QUOTE_FRAGMENT
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
${B}
|
|
82
|
+
`,J=`
|
|
83
|
+
mutation setShippingAddressOnQuoteAndUseAsBilling(
|
|
84
|
+
$quoteId: ID!
|
|
85
|
+
$shippingAddress: NegotiableQuoteShippingAddressInput!
|
|
86
|
+
) {
|
|
87
|
+
setNegotiableQuoteShippingAddress(
|
|
88
|
+
input: { quote_uid: $quoteId, shipping_addresses: [$shippingAddress] }
|
|
89
|
+
) {
|
|
90
|
+
quote {
|
|
91
|
+
uid
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
setNegotiableQuoteBillingAddress(
|
|
96
|
+
input: {
|
|
97
|
+
quote_uid: $quoteId
|
|
98
|
+
billing_address: { same_as_shipping: true }
|
|
99
|
+
}
|
|
100
|
+
) {
|
|
101
|
+
quote {
|
|
102
|
+
...NEGOTIABLE_QUOTE_FRAGMENT
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
${B}
|
|
108
|
+
`,W=({address:e,customerAddressId:s,customerAddressUid:t,pickupLocationCode:i})=>{if(!s&&t)throw new l("customerAddressUid is not supported");if(!s&&!i&&!e)throw new Q},X=({address:e,customerAddressId:s,customerAddressUid:t,pickupLocationCode:i})=>{if(i)throw new l("pickup location is not supported in quotes");if(!t&&s)throw new l("customerAddressId is not supported in quotes");if(!t&&!e)throw new Q},Y=e=>{const s=!!o.cartId,t=!!o.quoteId;s?W(e):t&&X(e)},T=(e,s,t,i,a,p)=>async n=>await q({type:"mutation",query:t,options:{variables:{[s]:e,shippingAddress:a(n)}},path:p,queueName:E.Updates,transformer:i}),pe=async e=>{V(),Y(e);const{defaults:s}=w.getConfig(),t=N("isBillToShipping")??(s==null?void 0:s.isBillToShipping);return await(!!o.cartId?T(o.cartId,"cartId",t?z:P,x,K,t?"setBillingAddressOnCart.cart":"setShippingAddressesOnCart.cart"):T(o.quoteId,"quoteId",t?J:j,H,L,t?"setNegotiableQuoteBillingAddress.quote":"setNegotiableQuoteShippingAddress.quote"))(e)};export{ae as e,pe as s};
|
|
109
|
+
//# sourceMappingURL=setShippingAddress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setShippingAddress.js","sources":["/@dropins/storefront-checkout/src/api/estimateShippingMethods/graphql/estimateShippingMethods.graphql.ts","/@dropins/storefront-checkout/src/api/estimateShippingMethods/estimateShippingMethods.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnCartAndUseAsBillingMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnCartMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnQuote.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnQuoteAndUseAsBillingMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/setShippingAddress.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\nexport const estimateShippingMethodsMutation = /* GraphQL */ `\n mutation estimateShippingMethods(\n $cartId: String!\n $address: EstimateAddressInput!\n ) {\n estimateShippingMethods(input: { cart_id: $cartId, address: $address }) {\n carrier_title\n carrier_code\n method_title\n method_code\n available\n amount {\n currency\n value\n }\n price_excl_tax {\n currency\n value\n }\n price_incl_tax {\n currency\n value\n }\n error_message\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 { config } from '@/checkout/api';\nimport { estimateShippingMethodsMutation } from '@/checkout/api/estimateShippingMethods/graphql';\nimport { ShippingMethod } from '@/checkout/data/models';\nimport {\n transformShippingEstimatePartialAddress,\n transformShippingEstimateShippingMethod,\n transformShippingMethods,\n} from '@/checkout/data/transforms';\nimport { dispatchApiCall, getValue, QueueName, state } from '@/checkout/lib';\nimport { MissingCart, MissingCountry } from '@/checkout/lib/errors';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface ShippingEstimationCriteria {\n country_code: string;\n region_name?: string;\n region_id?: string | number;\n zip?: string;\n}\n\nexport type EstimateShippingInput = {\n criteria: ShippingEstimationCriteria;\n};\n\nexport const estimateShippingMethods = async (\n input?: EstimateShippingInput\n): Promise<ShippingMethod[] | undefined> => {\n const cartId = state.cartId;\n const countryCode =\n input?.criteria?.country_code ?? state.config?.defaultCountry;\n\n if (!cartId) throw new MissingCart();\n if (!countryCode) throw new MissingCountry();\n\n const { region_id, region_name, zip } = input?.criteria ?? {};\n\n // Process region information\n const region =\n region_id || region_name\n ? {\n region_id:\n typeof region_id === 'string' ? parseInt(region_id, 10) : region_id,\n region_code: region_name,\n }\n : undefined;\n\n // Build address for API call\n const address = {\n country_code: countryCode,\n ...(zip && { postcode: zip }),\n ...(region && {\n region: {\n ...(region.region_id && { region_id: region.region_id }),\n ...(region.region_code && { region_code: region.region_code }),\n },\n }),\n };\n\n // Create address data for transformation\n const estimateShippingAddressData = {\n country_id: countryCode,\n region: address.region?.region_code,\n region_id: address.region?.region_id,\n postcode: zip,\n };\n\n const partialAddress = transformShippingEstimatePartialAddress(\n estimateShippingAddressData\n );\n\n return dispatchApiCall({\n options: { variables: { cartId, address } },\n path: 'estimateShippingMethods',\n query: estimateShippingMethodsMutation,\n queueName: QueueName.ShippingEstimate,\n transformer: transformShippingMethods,\n type: 'mutation',\n })\n .then((estimation) => {\n const { defaults, shipping } = config.getConfig();\n\n const filteredOptions = shipping?.filterOptions\n ? estimation.filter(shipping.filterOptions)\n : estimation;\n\n const hasAvailableOptions = filteredOptions.length > 0;\n const partialAddress = transformShippingEstimatePartialAddress(\n estimateShippingAddressData\n );\n\n let shippingMethod = null;\n\n if (hasAvailableOptions) {\n const userSelection = getValue('selectedShippingMethod');\n\n let selection = estimation.find(\n (method) =>\n method.code === userSelection?.code &&\n method.carrier.code === userSelection?.carrier.code\n );\n\n if (!selection && defaults?.selectedShippingMethod) {\n selection = defaults.selectedShippingMethod(estimation) ?? undefined;\n }\n\n if (!selection) {\n selection = estimation[0];\n }\n\n shippingMethod = transformShippingEstimateShippingMethod(selection);\n }\n\n events.emit('shipping/estimate', {\n address: partialAddress,\n availableShippingMethods: estimation,\n shippingMethod,\n success: true,\n });\n\n return filteredOptions;\n })\n .catch((error) => {\n events.emit('shipping/estimate', {\n address: partialAddress,\n shippingMethod: null,\n availableShippingMethods: [],\n success: false,\n });\n\n throw error;\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 { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setShippingAddressOnCartAndUseAsBillingMutation = /* GraphQL */ `\n mutation setShippingAddressOnCartAndUseAsBilling(\n $cartId: String!\n $shippingAddress: ShippingAddressInput!\n ) {\n setShippingAddressesOnCart(\n input: { cart_id: $cartId, shipping_addresses: [$shippingAddress] }\n ) {\n cart {\n id\n }\n }\n\n setBillingAddressOnCart(\n input: { cart_id: $cartId, billing_address: { same_as_shipping: true } }\n ) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\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 { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setShippingAddressOnCartMutation = /* GraphQL */ `\n mutation setShippingAddressOnCart(\n $cartId: String!\n $shippingAddress: ShippingAddressInput!\n ) {\n setShippingAddressesOnCart(\n input: { cart_id: $cartId, shipping_addresses: [$shippingAddress] }\n ) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const setShippingAddressOnQuoteMutation = /* GraphQL */ `\n mutation setShippingAddressOnQuote(\n $quoteId: ID!\n $shippingAddress: NegotiableQuoteShippingAddressInput!\n ) {\n setNegotiableQuoteShippingAddress(\n input: { quote_uid: $quoteId, shipping_addresses: [$shippingAddress] }\n ) {\n quote {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const setShippingAddressOnQuoteAndUseAsBillingMutation = /* GraphQL */ `\n mutation setShippingAddressOnQuoteAndUseAsBilling(\n $quoteId: ID!\n $shippingAddress: NegotiableQuoteShippingAddressInput!\n ) {\n setNegotiableQuoteShippingAddress(\n input: { quote_uid: $quoteId, shipping_addresses: [$shippingAddress] }\n ) {\n quote {\n uid\n }\n }\n\n setNegotiableQuoteBillingAddress(\n input: {\n quote_uid: $quoteId\n billing_address: { same_as_shipping: true }\n }\n ) {\n quote {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\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 { config } from '@/checkout/api';\nimport {\n setShippingAddressOnCartAndUseAsBillingMutation,\n setShippingAddressOnCartMutation,\n setShippingAddressOnQuoteAndUseAsBillingMutation,\n setShippingAddressOnQuoteMutation,\n} from '@/checkout/api/setShippingAddress/graphql';\nimport { ShippingAddressInput as ShippingAddressInputModel } from '@/checkout/data/models';\nimport {\n transformCart,\n transformNegotiableQuote,\n transformShippingAddressInputModelToCartInput,\n transformShippingAddressInputModelToQuoteInput,\n} from '@/checkout/data/transforms';\nimport { dispatchApiCall, getValue, QueueName } from '@/checkout/lib';\nimport { InvalidInput, MissingShippingAddress } from '@/checkout/lib/errors';\nimport { ensureHasCartOrQuoteId } from '@/checkout/lib/guards';\nimport { state } from '@/checkout/lib/state';\n\nconst ensureIsValidCartInput = ({\n address,\n customerAddressId,\n customerAddressUid,\n pickupLocationCode,\n}: ShippingAddressInputModel) => {\n if (!customerAddressId && customerAddressUid) {\n throw new InvalidInput('customerAddressUid is not supported');\n }\n\n if (!customerAddressId && !pickupLocationCode && !address) {\n throw new MissingShippingAddress();\n }\n};\n\nconst ensureIsValidQuoteInput = ({\n address,\n customerAddressId,\n customerAddressUid,\n pickupLocationCode,\n}: ShippingAddressInputModel) => {\n if (pickupLocationCode) {\n throw new InvalidInput('pickup location is not supported in quotes');\n }\n\n if (!customerAddressUid && customerAddressId) {\n throw new InvalidInput('customerAddressId is not supported in quotes');\n }\n\n if (!customerAddressUid && !address) {\n throw new MissingShippingAddress();\n }\n};\n\nconst ensureIsValidInput = (input: ShippingAddressInputModel) => {\n const isCart = Boolean(state.cartId);\n const isQuote = Boolean(state.quoteId);\n\n if (isCart) {\n ensureIsValidCartInput(input);\n } else if (isQuote) {\n ensureIsValidQuoteInput(input);\n }\n};\n\nconst createShippingAddressSetter = <TTransformedInput, TTransformedOutput>(\n entityId: string,\n entityKey: string,\n mutation: string,\n transformer: (data: any) => TTransformedOutput,\n transformInput: (input: ShippingAddressInputModel) => TTransformedInput,\n path: string\n) => {\n return async (\n input: ShippingAddressInputModel\n ): Promise<TTransformedOutput> => {\n return await dispatchApiCall({\n type: 'mutation',\n query: mutation,\n options: {\n variables: {\n [entityKey]: entityId,\n shippingAddress: transformInput(input),\n },\n },\n path,\n queueName: QueueName.Updates,\n transformer,\n });\n };\n};\n\nexport const setShippingAddress = async (input: ShippingAddressInputModel) => {\n ensureHasCartOrQuoteId();\n ensureIsValidInput(input);\n\n const { defaults } = config.getConfig();\n\n const isBillToShipping =\n getValue('isBillToShipping') ?? defaults?.isBillToShipping;\n\n const isCart = Boolean(state.cartId);\n\n const setter = isCart\n ? createShippingAddressSetter(\n state.cartId!,\n 'cartId',\n isBillToShipping\n ? setShippingAddressOnCartAndUseAsBillingMutation\n : setShippingAddressOnCartMutation,\n transformCart,\n transformShippingAddressInputModelToCartInput,\n isBillToShipping\n ? 'setBillingAddressOnCart.cart'\n : 'setShippingAddressesOnCart.cart'\n )\n : createShippingAddressSetter(\n state.quoteId!,\n 'quoteId',\n isBillToShipping\n ? setShippingAddressOnQuoteAndUseAsBillingMutation\n : setShippingAddressOnQuoteMutation,\n transformNegotiableQuote,\n transformShippingAddressInputModelToQuoteInput,\n isBillToShipping\n ? 'setNegotiableQuoteBillingAddress.quote'\n : 'setNegotiableQuoteShippingAddress.quote'\n );\n\n return await setter(input);\n};\n"],"names":["estimateShippingMethodsMutation","estimateShippingMethods","input","cartId","state","countryCode","_a","_b","MissingCart","MissingCountry","region_id","region_name","zip","region","address","estimateShippingAddressData","_c","_d","partialAddress","transformShippingEstimatePartialAddress","dispatchApiCall","QueueName","transformShippingMethods","estimation","defaults","shipping","config","filteredOptions","hasAvailableOptions","shippingMethod","userSelection","getValue","selection","method","transformShippingEstimateShippingMethod","events","error","setShippingAddressOnCartAndUseAsBillingMutation","CHECKOUT_DATA_FRAGMENT","setShippingAddressOnCartMutation","setShippingAddressOnQuoteMutation","NEGOTIABLE_QUOTE_FRAGMENT","setShippingAddressOnQuoteAndUseAsBillingMutation","ensureIsValidCartInput","customerAddressId","customerAddressUid","pickupLocationCode","InvalidInput","MissingShippingAddress","ensureIsValidQuoteInput","ensureIsValidInput","isCart","isQuote","createShippingAddressSetter","entityId","entityKey","mutation","transformer","transformInput","path","setShippingAddress","ensureHasCartOrQuoteId","isBillToShipping","transformCart","transformShippingAddressInputModelToCartInput","transformNegotiableQuote","transformShippingAddressInputModelToQuoteInput"],"mappings":"qfAiBa,MAAAA,EAAgD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECuBhDC,GAA0B,MACrCC,GAC0C,aAC1C,MAAMC,EAASC,EAAM,OACfC,IACJC,EAAAJ,GAAA,YAAAA,EAAO,WAAP,YAAAI,EAAiB,iBAAgBC,EAAAH,EAAM,SAAN,YAAAG,EAAc,gBAEjD,GAAI,CAACJ,EAAc,MAAA,IAAIK,EACvB,GAAI,CAACH,EAAmB,MAAA,IAAII,EAE5B,KAAM,CAAE,UAAAC,EAAW,YAAAC,EAAa,IAAAC,IAAQV,GAAA,YAAAA,EAAO,WAAY,CAAC,EAGtDW,EACJH,GAAaC,EACT,CACE,UACE,OAAOD,GAAc,SAAW,SAASA,EAAW,EAAE,EAAIA,EAC5D,YAAaC,CAAA,EAEf,OAGAG,EAAU,CACd,aAAcT,EACd,GAAIO,GAAO,CAAE,SAAUA,CAAI,EAC3B,GAAIC,GAAU,CACZ,OAAQ,CACN,GAAIA,EAAO,WAAa,CAAE,UAAWA,EAAO,SAAU,EACtD,GAAIA,EAAO,aAAe,CAAE,YAAaA,EAAO,WAAY,CAAA,CAC9D,CAEJ,EAGME,EAA8B,CAClC,WAAYV,EACZ,QAAQW,EAAAF,EAAQ,SAAR,YAAAE,EAAgB,YACxB,WAAWC,EAAAH,EAAQ,SAAR,YAAAG,EAAgB,UAC3B,SAAUL,CACZ,EAEMM,EAAiBC,EACrBJ,CACF,EAEA,OAAOK,EAAgB,CACrB,QAAS,CAAE,UAAW,CAAE,OAAAjB,EAAQ,QAAAW,EAAU,EAC1C,KAAM,0BACN,MAAOd,EACP,UAAWqB,EAAU,iBACrB,YAAaC,EACb,KAAM,UAAA,CACP,EACE,KAAMC,GAAe,CACpB,KAAM,CAAE,SAAAC,EAAU,SAAAC,GAAaC,EAAO,UAAU,EAE1CC,EAAkBF,GAAA,MAAAA,EAAU,cAC9BF,EAAW,OAAOE,EAAS,aAAa,EACxCF,EAEEK,EAAsBD,EAAgB,OAAS,EAC/CT,EAAiBC,EACrBJ,CACF,EAEA,IAAIc,EAAiB,KAErB,GAAID,EAAqB,CACjB,MAAAE,EAAgBC,EAAS,wBAAwB,EAEvD,IAAIC,EAAYT,EAAW,KACxBU,GACCA,EAAO,QAASH,GAAA,YAAAA,EAAe,OAC/BG,EAAO,QAAQ,QAASH,GAAA,YAAAA,EAAe,QAAQ,KACnD,EAEI,CAACE,IAAaR,GAAA,MAAAA,EAAU,0BACdQ,EAAAR,EAAS,uBAAuBD,CAAU,GAAK,QAGxDS,IACHA,EAAYT,EAAW,CAAC,GAG1BM,EAAiBK,EAAwCF,CAAS,CAAA,CAGpE,OAAAG,EAAO,KAAK,oBAAqB,CAC/B,QAASjB,EACT,yBAA0BK,EAC1B,eAAAM,EACA,QAAS,EAAA,CACV,EAEMF,CAAA,CACR,EACA,MAAOS,GAAU,CAChB,MAAAD,EAAO,KAAK,oBAAqB,CAC/B,QAASjB,EACT,eAAgB,KAChB,yBAA0B,CAAC,EAC3B,QAAS,EAAA,CACV,EAEKkB,CAAA,CACP,CACL,EChIaC,EAAgE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAsBzEC,CAAsB;AAAA,ECtBbC,EAAiD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc1DD,CAAsB;AAAA,ECdbE,EAAkD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc3DC,CAAyB;AAAA,ECdhBC,EAAiE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAyB1ED,CAAyB;AAAA,ECRvBE,EAAyB,CAAC,CAC9B,QAAA7B,EACA,kBAAA8B,EACA,mBAAAC,EACA,mBAAAC,CACF,IAAiC,CAC3B,GAAA,CAACF,GAAqBC,EAClB,MAAA,IAAIE,EAAa,qCAAqC,EAG9D,GAAI,CAACH,GAAqB,CAACE,GAAsB,CAAChC,EAChD,MAAM,IAAIkC,CAEd,EAEMC,EAA0B,CAAC,CAC/B,QAAAnC,EACA,kBAAA8B,EACA,mBAAAC,EACA,mBAAAC,CACF,IAAiC,CAC/B,GAAIA,EACI,MAAA,IAAIC,EAAa,4CAA4C,EAGjE,GAAA,CAACF,GAAsBD,EACnB,MAAA,IAAIG,EAAa,8CAA8C,EAGnE,GAAA,CAACF,GAAsB,CAAC/B,EAC1B,MAAM,IAAIkC,CAEd,EAEME,EAAsBhD,GAAqC,CACzD,MAAAiD,EAAS,EAAQ/C,EAAM,OACvBgD,EAAU,EAAQhD,EAAM,QAE1B+C,EACFR,EAAuBzC,CAAK,EACnBkD,GACTH,EAAwB/C,CAAK,CAEjC,EAEMmD,EAA8B,CAClCC,EACAC,EACAC,EACAC,EACAC,EACAC,IAEO,MACLzD,GAEO,MAAMkB,EAAgB,CAC3B,KAAM,WACN,MAAOoC,EACP,QAAS,CACP,UAAW,CACT,CAACD,CAAS,EAAGD,EACb,gBAAiBI,EAAexD,CAAK,CAAA,CAEzC,EACA,KAAAyD,EACA,UAAWtC,EAAU,QACrB,YAAAoC,CAAA,CACD,EAIQG,GAAqB,MAAO1D,GAAqC,CACrD2D,EAAA,EACvBX,EAAmBhD,CAAK,EAExB,KAAM,CAAE,SAAAsB,CAAA,EAAaE,EAAO,UAAU,EAEhCoC,EACJ/B,EAAS,kBAAkB,IAAKP,GAAA,YAAAA,EAAU,kBA8BrC,OAAA,MA5BQ,EAAQpB,EAAM,OAGzBiD,EACEjD,EAAM,OACN,SACA0D,EACIzB,EACAE,EACJwB,EACAC,EACAF,EACI,+BACA,iCAAA,EAENT,EACEjD,EAAM,QACN,UACA0D,EACIpB,EACAF,EACJyB,EACAC,EACAJ,EACI,yCACA,yCACN,GAEgB5D,CAAK,CAC3B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{
|
|
4
|
-
mutation
|
|
3
|
+
import{CHECKOUT_DATA_FRAGMENT as r,NEGOTIABLE_QUOTE_FRAGMENT as h}from"../fragments.js";import{e as d,t as u}from"./guards.js";import{t as g,e as M}from"./synchronizeCheckout.js";import{s as e,j as m,d as c,Q as I}from"./fetch-graphql.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";const S=`
|
|
4
|
+
mutation setShippingMethodsOnCart(
|
|
5
5
|
$cartId: String!
|
|
6
6
|
$shippingMethods: [ShippingMethodInput]!
|
|
7
7
|
) {
|
|
@@ -14,6 +14,21 @@ import{s as r,M as i,d as n,Q as e}from"./errors.js";import{b as s}from"./synchr
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
${
|
|
18
|
-
`,
|
|
17
|
+
${r}
|
|
18
|
+
`,A=`
|
|
19
|
+
mutation setShippingMethodsOnQuote(
|
|
20
|
+
$quoteId: ID!
|
|
21
|
+
$shippingMethods: [ShippingMethodInput]!
|
|
22
|
+
) {
|
|
23
|
+
setNegotiableQuoteShippingMethods(
|
|
24
|
+
input: { quote_uid: $quoteId, shipping_methods: $shippingMethods }
|
|
25
|
+
) {
|
|
26
|
+
quote {
|
|
27
|
+
...NEGOTIABLE_QUOTE_FRAGMENT
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
${h}
|
|
33
|
+
`,o=(t,s,i,n,p)=>async a=>await c({type:"mutation",query:i,queueName:I.Updates,options:{variables:{[s]:t,shippingMethods:u(a)}},path:p,transformer:n}),C=t=>{if(!Array.isArray(t)||t.length===0)throw new m},Q=async t=>(d(),C(t),await(!!e.cartId?o(e.cartId,"cartId",S,g,"setShippingMethodsOnCart.cart"):o(e.quoteId,"quoteId",A,M,"setNegotiableQuoteShippingMethods.quote"))(t));export{Q as s};
|
|
19
34
|
//# sourceMappingURL=setShippingMethods.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setShippingMethods.js","sources":["/@dropins/storefront-checkout/src/
|
|
1
|
+
{"version":3,"file":"setShippingMethods.js","sources":["/@dropins/storefront-checkout/src/api/setShippingMethods/graphql/setShippingMethodsOnCart.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingMethods/graphql/setShippingMethodsOnQuote.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingMethods/setShippingMethods.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 { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setShippingMethodsOnCartMutation = /* GraphQL */ `\n mutation setShippingMethodsOnCart(\n $cartId: String!\n $shippingMethods: [ShippingMethodInput]!\n ) {\n setShippingMethodsOnCart(\n input: { cart_id: $cartId, shipping_methods: $shippingMethods }\n ) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const setShippingMethodsOnQuoteMutation = /* GraphQL */ `\n mutation setShippingMethodsOnQuote(\n $quoteId: ID!\n $shippingMethods: [ShippingMethodInput]!\n ) {\n setNegotiableQuoteShippingMethods(\n input: { quote_uid: $quoteId, shipping_methods: $shippingMethods }\n ) {\n quote {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\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 setShippingMethodsOnCartMutation,\n setShippingMethodsOnQuoteMutation,\n} from '@/checkout/api/setShippingMethods/graphql';\nimport { ShippingMethodInput as ShippingMethodInputModel } from '@/checkout/data/models/api';\nimport {\n transformCart,\n transformNegotiableQuote,\n transformShippingMethodsInputModel,\n} from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { QueueName } from '@/checkout/lib/enqueueRequest';\nimport { MissingShippingMethod } from '@/checkout/lib/errors/customErrors';\nimport { ensureHasCartOrQuoteId } from '@/checkout/lib/guards';\nimport { state } from '@/checkout/lib/state';\n\nconst createShippingMethodsSetter = <TTransformedOutput>(\n entityId: string,\n entityKey: string,\n mutation: string,\n transformer: (data: any) => TTransformedOutput,\n path: string\n) => {\n return async (\n input: Array<ShippingMethodInputModel>\n ): Promise<TTransformedOutput> => {\n return await dispatchApiCall({\n type: 'mutation',\n query: mutation,\n queueName: QueueName.Updates,\n options: {\n variables: {\n [entityKey]: entityId,\n shippingMethods: transformShippingMethodsInputModel(input),\n },\n },\n path,\n transformer,\n });\n };\n};\n\nconst ensureIsValidInput = (input: Array<ShippingMethodInputModel>) => {\n if (!Array.isArray(input) || input.length === 0) {\n throw new MissingShippingMethod();\n }\n};\n\nexport const setShippingMethods = async (\n input: Array<ShippingMethodInputModel>\n) => {\n ensureHasCartOrQuoteId();\n ensureIsValidInput(input);\n\n const isCart = Boolean(state.cartId);\n\n const setter = isCart\n ? createShippingMethodsSetter(\n state.cartId!,\n 'cartId',\n setShippingMethodsOnCartMutation,\n transformCart,\n 'setShippingMethodsOnCart.cart'\n )\n : createShippingMethodsSetter(\n state.quoteId!,\n 'quoteId',\n setShippingMethodsOnQuoteMutation,\n transformNegotiableQuote,\n 'setNegotiableQuoteShippingMethods.quote'\n );\n\n return await setter(input);\n};\n"],"names":["setShippingMethodsOnCartMutation","CHECKOUT_DATA_FRAGMENT","setShippingMethodsOnQuoteMutation","NEGOTIABLE_QUOTE_FRAGMENT","createShippingMethodsSetter","entityId","entityKey","mutation","transformer","path","input","dispatchApiCall","QueueName","transformShippingMethodsInputModel","ensureIsValidInput","MissingShippingMethod","setShippingMethods","ensureHasCartOrQuoteId","state","transformCart","transformNegotiableQuote"],"mappings":"iTAmBa,MAAAA,EAAiD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc1DC,CAAsB;AAAA,ECdbC,EAAkD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc3DC,CAAyB;AAAA,ECAvBC,EAA8B,CAClCC,EACAC,EACAC,EACAC,EACAC,IAEO,MACLC,GAEO,MAAMC,EAAgB,CAC3B,KAAM,WACN,MAAOJ,EACP,UAAWK,EAAU,QACrB,QAAS,CACP,UAAW,CACT,CAACN,CAAS,EAAGD,EACb,gBAAiBQ,EAAmCH,CAAK,CAAA,CAE7D,EACA,KAAAD,EACA,YAAAD,CAAA,CACD,EAICM,EAAsBJ,GAA2C,CACrE,GAAI,CAAC,MAAM,QAAQA,CAAK,GAAKA,EAAM,SAAW,EAC5C,MAAM,IAAIK,CAEd,EAEaC,EAAqB,MAChCN,IAEuBO,EAAA,EACvBH,EAAmBJ,CAAK,EAoBjB,MAlBQ,EAAQQ,EAAM,OAGzBd,EACEc,EAAM,OACN,SACAlB,EACAmB,EACA,+BAAA,EAEFf,EACEc,EAAM,QACN,UACAhB,EACAkB,EACA,yCACF,GAEgBV,CAAK"}
|
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{s as r,
|
|
3
|
+
import{s as r,n as Q,d as y,U as N,t as D,e as S}from"./fetch-graphql.js";import{merge as k,Initializer as z,deepmerge as G}from"@dropins/tools/lib.js";import{events as d}from"@dropins/tools/event-bus.js";import{CHECKOUT_DATA_FRAGMENT as C,NEGOTIABLE_QUOTE_FRAGMENT as O}from"../fragments.js";import{b as R,c as P,d as U,a as L,e as x,f as B,g as $}from"./transform-shipping-methods.js";import{E as g}from"./classifiers.js";const F=async(e=!1)=>{r.authenticated=e},_=e=>{if(!e)return;const{code:t,title:i,...s}=e;return{code:t,title:i,additionalData:s}},b=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:i,title:s,...c}=t;return{code:i,title:s,additionalData:c}})},H=e=>{var i,s,c;if(!e)return;const t={availablePaymentMethods:b(e.available_payment_methods),billingAddress:P(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:_(e.selected_payment_method),shippingAddresses:R(e.shipping_addresses),isGuest:!r.authenticated};return k(t,(c=(s=(i=te.getConfig().models)==null?void 0:i.CartModel)==null?void 0:s.transformer)==null?void 0:c.call(s,e))},q=e=>{const t=e.street.filter(Boolean);return{city:e.city,company:e.company||void 0,country:$(e.country),customAttributes:B(e.custom_attributes),fax:e.fax||void 0,firstName:e.firstname,lastName:e.lastname,middleName:e.middlename||void 0,postCode:e.postcode||void 0,prefix:e.prefix||void 0,region:x(e.region),street:t,suffix:e.suffix||void 0,telephone:e.telephone||void 0,uid:e.uid,vatId:e.vat_id||void 0}},K=e=>{if(e)return q(e)},V=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:i,selected_shipping_method:s,...c}=t;return{...q(c),availableShippingMethods:L(i),selectedShippingMethod:U(s)}}),W=e=>e?{availablePaymentMethods:b(e.available_payment_methods),billingAddress:K(e.billing_address),email:e.email??"",isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,name:e.name,selectedPaymentMethod:_(e.selected_payment_method),shippingAddresses:V(e.shipping_addresses),status:e.status,uid:e.uid}:null,Y=`
|
|
4
4
|
query getCart($cartId: String!) {
|
|
5
5
|
cart(cart_id: $cartId) {
|
|
6
6
|
...CHECKOUT_DATA_FRAGMENT
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
${
|
|
11
|
-
`,
|
|
10
|
+
${C}
|
|
11
|
+
`,j=`
|
|
12
12
|
query getCustomerCart {
|
|
13
13
|
cart: customerCart {
|
|
14
14
|
...CHECKOUT_DATA_FRAGMENT
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
${
|
|
19
|
-
`,
|
|
18
|
+
${C}
|
|
19
|
+
`,I=async()=>{const e=r.cartId,t=r.authenticated===!1,i=t?Y:j,s=t?{cartId:e}:{};if(t&&!e)throw new Q;return await y({type:"query",query:i,options:{method:"POST",cache:"no-cache",variables:s},path:"cart",transformer:H})},J=`
|
|
20
|
+
query getNegotiableQuote($quoteId: ID!) {
|
|
21
|
+
negotiableQuote(uid: $quoteId) {
|
|
22
|
+
...NEGOTIABLE_QUOTE_FRAGMENT
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
${O}
|
|
27
|
+
`,A=async(e={})=>{const t=e.uid??r.quoteId;if(r.authenticated===!1)throw new N;if(!t)throw new D;return await y({type:"query",query:J,options:{method:"GET",cache:"no-cache",variables:{quoteId:t}},path:"negotiableQuote",transformer:W})},m={eager:!0},X=e=>{var f,p;const t=((p=(f=e==null?void 0:e.features)==null?void 0:f.b2b)==null?void 0:p.quotes)??!1;return[["authenticated",(u=!1)=>{var o,a,l;if(F(u),!t||u)return;const n=(l=(a=(o=e==null?void 0:e.features)==null?void 0:o.b2b)==null?void 0:a.routeLogin)==null?void 0:l.call(a);n&&window.location.assign(n)},m],...t?[["quote-management/quote-data/initialized",u=>{var n,o,a,l;if(!u.quote.canCheckout){const M=((l=(a=(o=(n=e==null?void 0:e.langDefinitions)==null?void 0:n.default)==null?void 0:o.Checkout)==null?void 0:a.Quote)==null?void 0:l.permissionDenied)||"You do not have permission to checkout with this quote.";d.emit("checkout/error",{message:M,code:g.QUOTE_PERMISSION_DENIED});return}h(u.quote)},m],["quote-management/quote-data/error",()=>{var n,o,a,l;const u=((l=(a=(o=(n=e==null?void 0:e.langDefinitions)==null?void 0:n.default)==null?void 0:o.Checkout)==null?void 0:a.Quote)==null?void 0:l.dataError)||"We were unable to retrieve the quote data. Please try again later.";d.emit("checkout/error",{message:u,code:g.QUOTE_DATA_ERROR})}]]:[["cart/initialized",h,m],["cart/reset",w],["cart/updated",T]]].map(([u,n,o])=>d.on(u,n,o))},Z=new URL(window.location.href),ee=Z.searchParams.get("quoteId");r.quoteId=ee;const E=new z({init:async(e={})=>{E.config.setConfig(G({defaults:{isBillToShipping:!0,selectedShippingMethod:t=>t.length>0?t[0]:null},features:{b2b:{quotes:!1}}},e))},listeners:X}),te=E.config,v=e=>"id"in e,re=async e=>{try{return v(e)?(r.cartId=e.id,r.quoteId=null,await I()??null):(r.cartId=null,r.quoteId=e.uid,await A()??null)}catch(t){return console.error("Checkout initialization failed:",t),null}},h=async e=>{if(r.initialized){await T(e);return}r.config||(r.config=await S());const t=e?await re(e):null;r.initialized=!0,d.emit("checkout/initialized",t)},w=()=>{r.initialized&&(r.cartId=null,r.quoteId=null,d.emit("checkout/updated",null))},se=async e=>{try{return v(e)?(r.cartId=e.id,r.quoteId=null,await I()??null):(r.cartId=null,r.quoteId=e.uid,await A()??null)}catch(t){return console.error("Checkout synchronization failed:",t),null}},T=async e=>{if(!r.initialized)return h(e);if(e===null){w();return}const t=await se(e);d.emit("checkout/updated",t)};export{F as a,A as b,te as c,h as d,W as e,I as g,E as i,w as r,T as s,H as t};
|
|
20
28
|
//# sourceMappingURL=synchronizeCheckout.js.map
|