@dropins/storefront-checkout 2.0.1-beta1 → 2.1.0-alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/fragments.d.ts +4 -1
- package/api/getNegotiableQuote/getNegotiableQuote.d.ts +22 -0
- package/api/getNegotiableQuote/graphql/getNegotiableQuote.graphql.d.ts +18 -0
- package/{errors → api/getNegotiableQuote/graphql}/index.d.ts +2 -2
- 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} +1 -1
- package/api/graphql/ShippingMethodFragment.graphql.d.ts +19 -0
- package/api/index.d.ts +1 -2
- package/api/initialize/initialize.d.ts +3 -0
- 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/checkout.js.map +1 -1
- 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/guards.js +4 -0
- package/chunks/guards.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 +11 -3
- 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/ShippingMethods/ShippingMethods.d.ts +1 -1
- package/components/index.d.ts +1 -0
- 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/OutOfStock.js +1 -1
- package/containers/OutOfStock.js.map +1 -1
- package/containers/PaymentMethods/PaymentMethods.d.ts +1 -2
- package/containers/PaymentMethods.js +1 -1
- package/containers/PaymentMethods.js.map +1 -1
- package/containers/PlaceOrder.js +1 -1
- package/containers/PlaceOrder.js.map +1 -1
- package/containers/ServerError.js +1 -1
- package/containers/ServerError.js.map +1 -1
- package/containers/ShippingMethods/ShippingMethods.d.ts +1 -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 +1 -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/country.d.ts +1 -1
- package/data/models/index.d.ts +2 -1
- package/data/models/{price.d.ts → money.d.ts} +2 -2
- 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 +8 -1
- package/data/transforms/transform-api.d.ts +12 -0
- package/data/transforms/{transform-address.d.ts → transform-cart-address.d.ts} +39 -43
- package/data/transforms/transform-cart.d.ts +1 -1
- 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 +88 -0
- package/data/transforms/transform-region.d.ts +8 -0
- package/fragments.js +180 -71
- package/fragments.js.map +1 -1
- package/i18n/en_US.json.d.ts +6 -0
- package/lib/enqueueRequest.d.ts +2 -2
- package/lib/errors/classifiers.d.ts +36 -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 +3 -3
- package/render.js.map +1 -1
- package/tests/constants.d.ts +1 -0
- package/tests/fixtures/fragments/cart.d.ts +43 -42
- package/tests/fixtures/fragments/shipping-address.d.ts +2 -1
- package/tests/fixtures/models/index.d.ts +1 -1
- package/tests/fixtures/models/quote.d.ts +9 -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 +21 -0
- package/types/storefront.d.ts +165 -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
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{s as o,m as B,n as b,d as M,Q as $,I as c,o as O}from"./fetch-graphql.js";import"@dropins/tools/lib.js";import{events as S}from"@dropins/tools/event-bus.js";import{g as T}from"./values.js";import{t as v,a as f}from"./transform-shipping-estimate.js";import{a as U}from"./transform-shipping-methods.js";import{e as G,c as D,d as F}from"./guards.js";import{c as R,t as x,e as H}from"./synchronizeCheckout.js";import{CHECKOUT_DATA_FRAGMENT as q,NEGOTIABLE_QUOTE_FRAGMENT as E}from"../fragments.js";const V=`
|
|
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
|
+
`,ne=async e=>{var h,l,A,_;const t=o.cartId,s=((h=e==null?void 0:e.criteria)==null?void 0:h.country_code)??((l=o.config)==null?void 0:l.defaultCountry);if(!t)throw new B;if(!s)throw new b;const{region_id:i,region_name:a,zip:p}=(e==null?void 0:e.criteria)??{},r=i||a?{region_id:typeof i=="string"?parseInt(i,10):i,region_code:a}:void 0,g={country_code:s,...p&&{postcode:p},...r&&{region:{...r.region_id&&{region_id:r.region_id},...r.region_code&&{region_code:r.region_code}}}},u={country_id:s,region:(A=g.region)==null?void 0:A.region_code,region_id:(_=g.region)==null?void 0:_.region_id,postcode:p},Q=f(u);return M({options:{variables:{cartId:t,address:g}},path:"estimateShippingMethods",query:V,queueName:$.ShippingEstimate,transformer:U,type:"mutation"}).then(n=>{const N=n.length>0,w=f(u);let m=null;if(N){const d=T("selectedShippingMethod"),y=n.find(I=>I.code===(d==null?void 0:d.code)&&I.carrier.code===(d==null?void 0:d.carrier.code));m=v(y??n[0])}return S.emit("shipping/estimate",{address:w,availableShippingMethods:n,shippingMethod:m,success:!0}),n}).catch(n=>{throw S.emit("shipping/estimate",{address:Q,shippingMethod:null,availableShippingMethods:[],success:!1}),n})},K=`
|
|
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
|
+
${q}
|
|
52
|
+
`,L=`
|
|
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
|
+
${q}
|
|
67
|
+
`,k=`
|
|
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
|
+
${E}
|
|
82
|
+
`,z=`
|
|
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
|
+
${E}
|
|
108
|
+
`,P=({address:e,customerAddressId:t,customerAddressUid:s,pickupLocationCode:i})=>{if(!t&&s)throw new c("customerAddressUid is not supported");if(!t&&!i&&!e)throw new O},j=({address:e,customerAddressId:t,customerAddressUid:s,pickupLocationCode:i})=>{if(i)throw new c("pickup location is not supported in quotes");if(!s&&t)throw new c("customerAddressId is not supported in quotes");if(!s&&!e)throw new O},J=e=>{const t=!!o.cartId,s=!!o.quoteId;t?P(e):s&&j(e)},C=(e,t,s,i,a,p)=>async r=>await M({type:"mutation",query:s,options:{variables:{[t]:e,shippingAddress:a(r)}},path:p,queueName:$.Updates,transformer:i}),oe=async e=>{G(),J(e);const{defaults:t}=R.getConfig(),s=T("isBillToShipping")??(t==null?void 0:t.isBillToShipping);return await(!!o.cartId?C(o.cartId,"cartId",s?K:L,x,D,s?"setBillingAddressOnCart.cart":"setShippingAddressesOnCart.cart"):C(o.quoteId,"quoteId",s?z:k,H,F,s?"setNegotiableQuoteBillingAddress.quote":"setNegotiableQuoteShippingAddress.quote"))(e)};export{ne as e,oe 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 { MissingCart, MissingCountry } from '@/checkout/lib/errors';\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 { 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 hasAvailableOptions = estimation.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 const selection = estimation.find(\n (method) =>\n method.code === userSelection?.code &&\n method.carrier.code === userSelection?.carrier.code\n );\n\n shippingMethod = transformShippingEstimateShippingMethod(\n selection ?? estimation[0]\n );\n }\n\n events.emit('shipping/estimate', {\n address: partialAddress,\n availableShippingMethods: estimation,\n shippingMethod,\n success: true,\n });\n\n return estimation;\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","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","defaults","config","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,ECsBhDC,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,EA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C,EACAC,EACAC,EACAC,IAEO,MACLrD,GAEO,MAAMkB,EAAgB,CAC3B,KAAM,WACN,MAAOgC,EACP,QAAS,CACP,UAAW,CACT,CAACD,CAAS,EAAGD,EACb,gBAAiBI,EAAepD,CAAK,CAAA,CAEzC,EACA,KAAAqD,EACA,UAAWlC,EAAU,QACrB,YAAAgC,CAAA,CACD,EAIQG,GAAqB,MAAOtD,GAAqC,CACrDuD,EAAA,EACvBX,EAAmB5C,CAAK,EAExB,KAAM,CAAE,SAAAwD,CAAA,EAAaC,EAAO,UAAU,EAEhCC,EACJjC,EAAS,kBAAkB,IAAK+B,GAAA,YAAAA,EAAU,kBA8BrC,OAAA,MA5BQ,EAAQtD,EAAM,OAGzB6C,EACE7C,EAAM,OACN,SACAwD,EACI3B,EACAE,EACJ0B,EACAC,EACAF,EACI,+BACA,iCAAA,EAENX,EACE7C,EAAM,QACN,UACAwD,EACItB,EACAF,EACJ2B,EACAC,EACAJ,EACI,yCACA,yCACN,GAEgB1D,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 M,e as g}from"./synchronizeCheckout.js";import{s as e,M 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,M,"setShippingMethodsOnCart.cart"):o(e.quoteId,"quoteId",A,g,"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,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{s as
|
|
3
|
+
import{s as i,m as A,d as l,U as _,t as b,i as v}from"./fetch-graphql.js";import{merge as q,Initializer as w}from"@dropins/tools/lib.js";import{events as n}from"@dropins/tools/event-bus.js";import{CHECKOUT_DATA_FRAGMENT as c,NEGOTIABLE_QUOTE_FRAGMENT as E}from"../fragments.js";import{b as M,c as T,d as N,a as Q,e as z,f as S,g as G}from"./transform-shipping-methods.js";const k=async(e=!1)=>{i.authenticated=e},d=e=>{if(e)return{code:e.code,title:e.title}},m=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:s,title:r}=t;return{code:s,title:r}})},D=e=>{var s,r,o;if(!e)return;const t={availablePaymentMethods:m(e.available_payment_methods),billingAddress:T(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:d(e.selected_payment_method),shippingAddresses:M(e.shipping_addresses),isGuest:!i.authenticated};return q(t,(o=(r=(s=H.getConfig().models)==null?void 0:s.CartModel)==null?void 0:r.transformer)==null?void 0:o.call(r,e))},h=e=>{const t=e.street.filter(Boolean);return{city:e.city,company:e.company||void 0,country:G(e.country),customAttributes:S(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:z(e.region),street:t,suffix:e.suffix||void 0,telephone:e.telephone||void 0,uid:e.uid,vatId:e.vat_id||void 0}},O=e=>{if(e)return h(e)},P=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:s,selected_shipping_method:r,...o}=t;return{...h(o),availableShippingMethods:Q(s),selectedShippingMethod:N(r)}}),U=e=>e?{availablePaymentMethods:m(e.available_payment_methods),billingAddress:O(e.billing_address),email:e.email??"",isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,name:e.name,selectedPaymentMethod:d(e.selected_payment_method),shippingAddresses:P(e.shipping_addresses),status:e.status,uid:e.uid}:null,x=`
|
|
4
4
|
query getCart($cartId: String!) {
|
|
5
5
|
cart(cart_id: $cartId) {
|
|
6
6
|
...CHECKOUT_DATA_FRAGMENT
|
|
@@ -8,7 +8,7 @@ import{s as r,M as h,d as g,l as y}from"./errors.js";import{merge as v,Initializ
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
${c}
|
|
11
|
-
`,
|
|
11
|
+
`,R=`
|
|
12
12
|
query getCustomerCart {
|
|
13
13
|
cart: customerCart {
|
|
14
14
|
...CHECKOUT_DATA_FRAGMENT
|
|
@@ -16,5 +16,13 @@ import{s as r,M as h,d as g,l as y}from"./errors.js";import{merge as v,Initializ
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
${c}
|
|
19
|
-
`,
|
|
19
|
+
`,f=async()=>{const e=i.cartId,t=i.authenticated===!1,s=t?x:R,r=t?{cartId:e}:{};if(t&&!e)throw new A;return await l({type:"query",query:s,options:{method:"POST",cache:"no-cache",variables:r},path:"cart",transformer:D})},$=`
|
|
20
|
+
query getNegotiableQuote($quoteId: ID!) {
|
|
21
|
+
negotiableQuote(uid: $quoteId) {
|
|
22
|
+
...NEGOTIABLE_QUOTE_FRAGMENT
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
${E}
|
|
27
|
+
`,p=async(e={})=>{const t=e.uid??i.quoteId;if(i.authenticated===!1)throw new _;if(!t)throw new b;return await l({type:"query",query:$,options:{method:"GET",cache:"no-cache",variables:{quoteId:t}},path:"negotiableQuote",transformer:U})},a={eager:!0},B=()=>[n.on("authenticated",k,a),n.on("cart/initialized",u,a),n.on("cart/reset",C),n.on("cart/updated",I),n.on("quote-management/quote-data",u,a)],F=new URL(window.location.href),L=F.searchParams.get("quoteId");i.quoteId=L;const g=new w({init:async e=>{g.config.setConfig({defaults:{isBillToShipping:!0,...e==null?void 0:e.defaults},...e})},listeners:B}),H=g.config,y=e=>"id"in e,K=async e=>{try{return y(e)?(i.cartId=e.id,i.quoteId=null,await f()??null):(i.cartId=null,i.quoteId=e.uid,await p()??null)}catch(t){return console.error("Checkout initialization failed:",t),null}},u=async e=>{if(i.initialized){await I(e);return}i.config||(i.config=await v());const t=e?await K(e):null;i.initialized=!0,n.emit("checkout/initialized",t)},C=()=>{i.initialized&&(i.cartId=null,i.quoteId=null,n.emit("checkout/updated",null))},V=async e=>{try{return y(e)?(i.cartId=e.id,i.quoteId=null,await f()??null):(i.cartId=null,i.quoteId=e.uid,await p()??null)}catch(t){return console.error("Checkout synchronization failed:",t),null}},I=async e=>{if(!i.initialized)return u(e);if(e===null){C();return}const t=await V(e);n.emit("checkout/updated",t)};export{k as a,p as b,H as c,u as d,U as e,f as g,g as i,C as r,I as s,D as t};
|
|
20
28
|
//# sourceMappingURL=synchronizeCheckout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synchronizeCheckout.js","sources":["/@dropins/storefront-checkout/src/api/authenticateCustomer/authenticateCustomer.ts","/@dropins/storefront-checkout/src/data/transforms/transform-shipping-methods.ts","/@dropins/storefront-checkout/src/data/transforms/transform-address.ts","/@dropins/storefront-checkout/src/data/transforms/transform-payment-methods.ts","/@dropins/storefront-checkout/src/data/transforms/transform-cart.ts","/@dropins/storefront-checkout/src/api/getCart/graphql/getCart.graphql.ts","/@dropins/storefront-checkout/src/api/getCart/getCart.ts","/@dropins/storefront-checkout/src/api/initialize/listeners.ts","/@dropins/storefront-checkout/src/api/initialize/initialize.ts","/@dropins/storefront-checkout/src/api/initializeCheckout/initializeCheckout.ts","/@dropins/storefront-checkout/src/api/resetCheckout/resetCheckout.ts","/@dropins/storefront-checkout/src/api/synchronizeCheckout/synchronizeCheckout.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 { state } from '@/checkout/lib/state';\n\nexport const authenticateCustomer = async (authenticated = false) => {\n state.authenticated = authenticated;\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 { ShippingMethod } from '@/checkout/data/models/shipping-method';\nimport { GetCartQuery } from '@/checkout/__generated__/types';\n\ntype Cart = NonNullable<GetCartQuery['cart']>;\ntype ShippingAddresses = Cart['shipping_addresses'];\ntype ShippingAddress = NonNullable<NonNullable<ShippingAddresses>[number]>;\ntype AvailableShippingMethods = ShippingAddress['available_shipping_methods'];\ntype AvailableShippingMethod = NonNullable<AvailableShippingMethods>[number];\ntype SelectedShippingMethod = ShippingAddress['selected_shipping_method'];\n\ntype FilteredShippingMethod = Omit<\n NonNullable<AvailableShippingMethod>,\n | 'method_code'\n | 'method_title'\n | 'amount'\n | 'price_excl_tax'\n | 'price_incl_tax'\n> & {\n method_code: string;\n method_title: string;\n amount: {\n value: number;\n currency: string;\n };\n price_excl_tax: {\n value: number;\n currency: string;\n };\n price_incl_tax: {\n value: number;\n currency: string;\n };\n};\n\nconst byPrice = (a: ShippingMethod, b: ShippingMethod) =>\n a.amount.value - b.amount.value;\n\nexport const isNullish = (value: any): boolean =>\n value === null || value === undefined;\n\nconst isValid = (method: AvailableShippingMethod | SelectedShippingMethod) => {\n if (!method) return false;\n if (!method.method_code || !method.method_title) return false;\n if (isNullish(method.amount.value) || !method.amount.currency) return false;\n return true;\n};\n\nconst buildShippingMethod = (data: FilteredShippingMethod): ShippingMethod => {\n return {\n amount: {\n value: data.amount.value,\n currency: data.amount.currency,\n },\n title: data.method_title,\n code: data.method_code,\n carrier: {\n code: data.carrier_code,\n title: data.carrier_title,\n },\n value: `${data.carrier_code} - ${data.method_code}`,\n ...(data.price_excl_tax && {\n amountExclTax: {\n value: data.price_excl_tax.value,\n currency: data.price_excl_tax.currency,\n },\n }),\n ...(data.price_incl_tax && {\n amountInclTax: {\n value: data.price_incl_tax.value,\n currency: data.price_incl_tax.currency,\n },\n }),\n };\n};\n\nexport const transformSelectedShippingMethod = (\n data: SelectedShippingMethod\n): ShippingMethod | undefined => {\n if (!isValid(data)) return;\n return buildShippingMethod(data as FilteredShippingMethod);\n};\n\nexport const transformAvailableShippingMethod = (\n data: AvailableShippingMethod\n): ShippingMethod | undefined => {\n if (!isValid(data)) return;\n return buildShippingMethod(data as FilteredShippingMethod);\n};\n\nexport const transformShippingMethods = (\n data: AvailableShippingMethods\n): ShippingMethod[] => {\n if (!data) return [];\n\n return data\n .filter(isValid)\n .map((method) => buildShippingMethod(method as FilteredShippingMethod))\n .sort(byPrice);\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 { CartAddressInput, GetCartQuery } from '@/checkout/__generated__/types';\nimport {\n Address as AddressModel,\n Country as CountryModel,\n CustomAttribute as CustomAttributeModel,\n Region as RegionModel,\n ShippingAddress as ShippingAddressModel,\n CartAddress as CartAddressModel,\n} from '@/checkout/data/models';\nimport {\n transformSelectedShippingMethod,\n transformShippingMethods,\n} from '@/checkout/data/transforms/transform-shipping-methods';\n\ntype ShippingAddresses = NonNullable<\n GetCartQuery['cart']\n>['shipping_addresses'];\ntype ShippingAddress = ShippingAddresses[0];\ntype NonNullableShippingAddress = NonNullable<ShippingAddress>;\n\ntype AddressRegion = NonNullableShippingAddress['region'];\ntype NonNullableAddressRegion = NonNullable<AddressRegion>;\ntype ValidatedAddressRegion = {\n code: NonNullable<NonNullableAddressRegion['code']>;\n label: NonNullable<NonNullableAddressRegion['label']>;\n region_id: NonNullableAddressRegion['region_id'];\n};\n\ntype AddressCountry = NonNullableShippingAddress['country'];\ntype NonNullableAddressCountry = NonNullable<AddressCountry>;\ntype ValidatedAddressCountry = {\n code: NonNullable<NonNullableAddressCountry['code']>;\n label: NonNullable<NonNullableAddressCountry['label']>;\n};\n\ntype BillingAddress = NonNullable<GetCartQuery['cart']>['billing_address'];\ntype NonNullableBillingAddress = NonNullable<BillingAddress>;\n\ntype CustomAttributes =\n | NonNullableShippingAddress['custom_attributes']\n | NonNullableBillingAddress['custom_attributes'];\n\nconst isValidAddressRegion = (region: AddressRegion): boolean => {\n if (!region) return false;\n return !!region.code && !!region.label;\n};\n\nconst transformAddressRegion = (\n data: AddressRegion\n): RegionModel | undefined => {\n if (!isValidAddressRegion(data)) return;\n const { code, label, region_id } = data as ValidatedAddressRegion;\n if (!region_id) return { code, name: label };\n return { code, name: label, id: region_id };\n};\n\nconst transformAddressCountry = (data: AddressCountry): CountryModel => {\n const { code, label } = data as ValidatedAddressCountry;\n return { value: code, label };\n};\n\nconst isValidCustomAttribute = (attribute: any): boolean => {\n if (!attribute) return false;\n return 'code' in attribute && 'value' in attribute;\n};\n\nexport const transformCustomAttributes = (\n data: CustomAttributes\n): CustomAttributeModel[] => {\n return data.filter(isValidCustomAttribute).map((attribute) => {\n const { code, value } = attribute as { code: string; value: string };\n return { code, value };\n });\n};\n\nconst buildBaseAddress = (\n data: NonNullableShippingAddress | NonNullableBillingAddress\n): AddressModel => {\n const street = data.street.filter(Boolean) as string[];\n\n return {\n id: data?.id || undefined,\n city: data.city,\n company: data.company || undefined,\n country: transformAddressCountry(data.country),\n customAttributes: transformCustomAttributes(data.custom_attributes),\n firstName: data.firstname,\n lastName: data.lastname,\n postCode: data.postcode || undefined,\n region: transformAddressRegion(data.region),\n street,\n telephone: data.telephone || undefined,\n vatId: data.vat_id || undefined,\n prefix: data.prefix || undefined,\n suffix: data.suffix || undefined,\n middleName: data.middlename || undefined,\n fax: data.fax || undefined,\n };\n};\n\nconst transformBillingAddress = (\n data: BillingAddress\n): AddressModel | undefined => {\n if (!data) return;\n return buildBaseAddress(data);\n};\n\nconst transformShippingAddresses = (\n data: ShippingAddresses\n): ShippingAddressModel[] | undefined => {\n return data\n .filter((address) => !!address)\n .map((address) => {\n const {\n available_shipping_methods,\n selected_shipping_method,\n same_as_billing,\n ...baseData\n } = address as NonNullableShippingAddress;\n\n return {\n ...buildBaseAddress(baseData as NonNullableShippingAddress),\n availableShippingMethods: transformShippingMethods(\n available_shipping_methods\n ),\n selectedShippingMethod: transformSelectedShippingMethod(\n selected_shipping_method\n ),\n sameAsBilling: same_as_billing,\n };\n });\n};\n\nconst transformCartAddressModelToInput = (\n address: CartAddressModel\n): CartAddressInput => {\n return {\n city: address.city,\n company: address.company,\n country_code: address.countryCode,\n custom_attributes: address.customAttributes.map((attribute) => ({\n attribute_code: attribute.code,\n value: attribute.value,\n })),\n firstname: address.firstName,\n lastname: address.lastName,\n postcode: address.postcode,\n region: address.region,\n region_id: address.regionId,\n save_in_address_book: address.saveInAddressBook ?? true,\n street: address.street,\n telephone: address.telephone,\n vat_id: address.vatId,\n prefix: address.prefix,\n suffix: address.suffix,\n middlename: address.middleName,\n fax: address.fax,\n };\n};\n\nexport {\n BillingAddress,\n ShippingAddress,\n transformCartAddressModelToInput,\n transformBillingAddress,\n transformShippingAddresses,\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 { GetCartQuery } from '@/checkout/__generated__/types';\nimport { PaymentMethod } from '@/checkout/data/models/payment-method';\n\ntype SelectedPaymentMethod = NonNullable<\n GetCartQuery['cart']\n>['selected_payment_method'];\n\ntype AvailablePaymentMethods = NonNullable<\n GetCartQuery['cart']\n>['available_payment_methods'];\n\ntype AvailablePaymentMethod = NonNullable<AvailablePaymentMethods>[number];\n\ntype NonNullabePaymentMethod = NonNullable<AvailablePaymentMethod>;\n\nconst transformSelectedPaymentMethod = (\n data: SelectedPaymentMethod\n): PaymentMethod | undefined => {\n if (!data) return;\n return { code: data.code, title: data.title };\n};\n\nconst transformAvailablePaymentMethods = (\n data: AvailablePaymentMethods\n): PaymentMethod[] | undefined => {\n if (!data) return;\n\n return data\n .filter((method) => !!method)\n .map((method) => {\n const { code, title } = method as NonNullabePaymentMethod;\n return { code, title };\n });\n};\n\nexport { transformAvailablePaymentMethods, transformSelectedPaymentMethod };\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 { GetCartQuery } from '@/checkout/__generated__/types';\nimport { config } from '@/checkout/api';\nimport { Cart as CartModel } from '@/checkout/data/models';\nimport {\n transformAvailablePaymentMethods,\n transformSelectedPaymentMethod,\n} from '@/checkout/data/transforms/transform-payment-methods';\nimport { merge } from '@adobe-commerce/elsie/lib';\n\nimport {\n transformBillingAddress,\n transformShippingAddresses,\n} from '@/checkout/data/transforms/transform-address';\nimport { state } from '@/checkout/lib/state';\n\ntype Cart = GetCartQuery['cart'];\n\nconst transformCart = (data: Cart): CartModel | undefined => {\n if (!data) return;\n\n const model = {\n availablePaymentMethods: transformAvailablePaymentMethods(\n data.available_payment_methods\n ),\n billingAddress: transformBillingAddress(data.billing_address),\n email: data.email ?? undefined,\n id: data.id,\n isEmpty: data.total_quantity === 0,\n isVirtual: data.is_virtual,\n selectedPaymentMethod: transformSelectedPaymentMethod(\n data.selected_payment_method\n ),\n shippingAddresses: transformShippingAddresses(data.shipping_addresses),\n isGuest: !state.authenticated,\n };\n\n // Extend the model merging custom transformer, if provided\n return merge(\n model, // default transformer\n config.getConfig().models?.CartModel?.transformer?.(data) // custom transformer\n );\n};\n\nexport { Cart, transformCart };\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 getCartQuery = /* GraphQL */ `\n query getCart($cartId: String!) {\n cart(cart_id: $cartId) {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n\nexport const getCustomerCartQuery = /* GraphQL */ `\n query getCustomerCart {\n cart: customerCart {\n ...CHECKOUT_DATA_FRAGMENT\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 {\n getCartQuery,\n getCustomerCartQuery,\n} from '@/checkout/api/getCart/graphql';\nimport { transformCart } from '@/checkout/data/transforms';\nimport { MissingCart } from '@/checkout/errors';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { state } from '@/checkout/lib/state';\n\nexport const getCart = async () => {\n const cartId = state.cartId;\n const isGuest = state.authenticated === false;\n const query = isGuest ? getCartQuery : getCustomerCartQuery;\n const variables = isGuest ? { cartId } : {};\n\n if (isGuest && !cartId) throw new MissingCart();\n\n return await dispatchApiCall({\n type: 'query',\n query,\n options: { method: 'POST', cache: 'no-cache', variables },\n path: 'cart',\n transformer: transformCart,\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 {\n authenticateCustomer,\n initializeCheckout,\n resetCheckout,\n synchronizeCheckout,\n} from '@/checkout/api';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const addCheckoutEventListeners = () => [\n events.on('authenticated', authenticateCustomer, { eager: true }),\n events.on('cart/initialized', initializeCheckout, { eager: true }),\n events.on('cart/reset', resetCheckout),\n events.on('cart/updated', synchronizeCheckout),\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 { addCheckoutEventListeners } from '@/checkout/api/initialize/listeners';\nimport {\n Cart as CartModel,\n Customer as CustomerModel,\n} from '@/checkout/data/models';\n\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { Initializer, Model } from '@adobe-commerce/elsie/lib';\n\nexport type ConfigProps = {\n langDefinitions?: Lang;\n models?: {\n CartModel?: Model<CartModel>;\n CustomerModel?: Model<CustomerModel>;\n };\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (_config) => {\n const config = { ..._config };\n initialize.config.setConfig(config);\n },\n listeners: addCheckoutEventListeners,\n});\n\nexport const config = initialize.config;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { getCart, getStoreConfig, synchronizeCheckout } from '@/checkout/api';\nimport { state } from '@/checkout/lib/state';\nimport { Cart, events } from '@adobe-commerce/event-bus';\n\nexport const initializeCheckout = async (cart: Cart | null): Promise<void> => {\n if (state.initialized) return synchronizeCheckout(cart);\n\n if (!state.config) {\n state.config = await getStoreConfig();\n }\n\n const cartId = cart ? cart.id : null;\n state.cartId = cartId;\n\n const initialData = cartId ? await getCart() : null;\n state.initialized = true;\n\n events.emit('checkout/initialized', initialData || null);\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 { state } from '@/checkout/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const resetCheckout = () => {\n state.cartId = null;\n events.emit('checkout/updated', null);\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 { getCart, initializeCheckout } from '@/checkout/api';\nimport { state } from '@/checkout/lib/state';\nimport { Cart, events } from '@adobe-commerce/event-bus';\n\nexport const synchronizeCheckout = async (cart: Cart | null) => {\n if (!state.initialized) return initializeCheckout(cart);\n const cartId = cart ? cart.id : null;\n state.cartId = cartId;\n const data = cartId ? await getCart() : null;\n events.emit('checkout/updated', data || null);\n};\n"],"names":["authenticateCustomer","authenticated","state","byPrice","a","b","isNullish","value","isValid","method","buildShippingMethod","data","transformSelectedShippingMethod","transformShippingMethods","isValidAddressRegion","region","transformAddressRegion","code","label","region_id","transformAddressCountry","isValidCustomAttribute","attribute","transformCustomAttributes","buildBaseAddress","street","transformBillingAddress","transformShippingAddresses","address","available_shipping_methods","selected_shipping_method","same_as_billing","baseData","transformCartAddressModelToInput","transformSelectedPaymentMethod","transformAvailablePaymentMethods","title","transformCart","model","merge","_c","_b","_a","config","getCartQuery","CHECKOUT_DATA_FRAGMENT","getCustomerCartQuery","getCart","cartId","isGuest","query","variables","MissingCart","dispatchApiCall","addCheckoutEventListeners","events","initializeCheckout","resetCheckout","synchronizeCheckout","initialize","Initializer","_config","cart","getStoreConfig","initialData"],"mappings":"kOAmBa,MAAAA,EAAuB,MAA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OAAS,KACRqD,EAAA,KAAK,mBAAoB,IAAI,CACtC,ECFaG,EAAsB,MAAOI,GAAsB,CAC9D,GAAI,CAAC5D,EAAM,YAAa,OAAOsD,EAAmBM,CAAI,EAChD,MAAAd,EAASc,EAAOA,EAAK,GAAK,KAChC5D,EAAM,OAAS8C,EACf,MAAMrC,EAAOqC,EAAS,MAAMD,EAAY,EAAA,KACjCQ,EAAA,KAAK,mBAAoB5C,GAAQ,IAAI,CAC9C"}
|
|
1
|
+
{"version":3,"file":"synchronizeCheckout.js","sources":["/@dropins/storefront-checkout/src/api/authenticateCustomer/authenticateCustomer.ts","/@dropins/storefront-checkout/src/data/transforms/transform-payment-methods.ts","/@dropins/storefront-checkout/src/data/transforms/transform-cart.ts","/@dropins/storefront-checkout/src/data/transforms/transform-quote-address.ts","/@dropins/storefront-checkout/src/data/transforms/transform-negotiable-quote.ts","/@dropins/storefront-checkout/src/api/getCart/graphql/getCart.graphql.ts","/@dropins/storefront-checkout/src/api/getCart/getCart.ts","/@dropins/storefront-checkout/src/api/getNegotiableQuote/graphql/getNegotiableQuote.graphql.ts","/@dropins/storefront-checkout/src/api/getNegotiableQuote/getNegotiableQuote.ts","/@dropins/storefront-checkout/src/api/initialize/listeners.ts","/@dropins/storefront-checkout/src/api/initialize/initialize.ts","/@dropins/storefront-checkout/src/types/guards.ts","/@dropins/storefront-checkout/src/api/initializeCheckout/initializeCheckout.ts","/@dropins/storefront-checkout/src/api/resetCheckout/resetCheckout.ts","/@dropins/storefront-checkout/src/api/synchronizeCheckout/synchronizeCheckout.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 { state } from '@/checkout/lib/state';\n\nexport const authenticateCustomer = async (authenticated = false) => {\n state.authenticated = authenticated;\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 { PaymentMethod } from '@/checkout/data/models/payment-method';\nimport { GetCartQuery } from '@/checkout/__generated__/types';\n\ntype SelectedPaymentMethod = NonNullable<\n GetCartQuery['cart']\n>['selected_payment_method'];\n\ntype AvailablePaymentMethods = NonNullable<\n GetCartQuery['cart']\n>['available_payment_methods'];\n\ntype AvailablePaymentMethod = NonNullable<AvailablePaymentMethods>[number];\n\ntype NonNullabePaymentMethod = NonNullable<AvailablePaymentMethod>;\n\nconst transformSelectedPaymentMethod = (\n data: SelectedPaymentMethod\n): PaymentMethod | undefined => {\n if (!data) return;\n return { code: data.code, title: data.title };\n};\n\nconst transformAvailablePaymentMethods = (\n data: AvailablePaymentMethods\n): PaymentMethod[] | undefined => {\n if (!data) return;\n\n return data\n .filter((method) => !!method)\n .map((method) => {\n const { code, title } = method as NonNullabePaymentMethod;\n return { code, title };\n });\n};\n\nexport { transformAvailablePaymentMethods, transformSelectedPaymentMethod };\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 { Cart as CartModel } from '@/checkout/data/models';\nimport {\n transformAvailablePaymentMethods,\n transformSelectedPaymentMethod,\n} from '@/checkout/data/transforms/transform-payment-methods';\nimport { GetCartQuery } from '@/checkout/__generated__/types';\nimport { merge } from '@adobe-commerce/elsie/lib';\n\nimport {\n transformCartBillingAddress,\n transformCartShippingAddress,\n} from '@/checkout/data/transforms/transform-cart-address';\nimport { state } from '@/checkout/lib/state';\n\ntype Cart = GetCartQuery['cart'];\n\nconst transformCart = (data: Cart): CartModel | undefined => {\n if (!data) return;\n\n const model = {\n availablePaymentMethods: transformAvailablePaymentMethods(\n data.available_payment_methods\n ),\n billingAddress: transformCartBillingAddress(data.billing_address),\n email: data.email ?? undefined,\n id: data.id,\n isEmpty: data.total_quantity === 0,\n isVirtual: data.is_virtual,\n selectedPaymentMethod: transformSelectedPaymentMethod(\n data.selected_payment_method\n ),\n shippingAddresses: transformCartShippingAddress(data.shipping_addresses),\n isGuest: !state.authenticated,\n };\n\n // Extend the model merging custom transformer, if provided\n return merge(\n model, // default transformer\n config.getConfig().models?.CartModel?.transformer?.(data) // custom transformer\n );\n};\n\nexport { Cart, transformCart };\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 {\n Address as AddressModel,\n ShippingAddress as ShippingAddressModel,\n} from '@/checkout/data/models';\n\nimport {\n transformAddressCountry,\n transformAddressRegion,\n transformCustomAttributes,\n transformSelectedShippingMethod,\n transformShippingMethods,\n} from '@/checkout/data/transforms';\nimport { GetNegotiableQuoteQuery } from '@/checkout/__generated__/types';\n\ntype QuoteShippingAddresses = NonNullable<\n GetNegotiableQuoteQuery['negotiableQuote']\n>['shipping_addresses'];\ntype QuoteShippingAddress = QuoteShippingAddresses[0];\ntype NonNullableShippingAddress = NonNullable<QuoteShippingAddress>;\n\ntype QuoteBillingAddress = NonNullable<\n GetNegotiableQuoteQuery['negotiableQuote']\n>['billing_address'];\ntype NonNullableBillingAddress = NonNullable<QuoteBillingAddress>;\n\nconst transformAddress = (\n data: NonNullableShippingAddress | NonNullableBillingAddress\n): AddressModel => {\n const street = data.street.filter(Boolean) as string[];\n\n return {\n city: data.city,\n company: data.company || undefined,\n country: transformAddressCountry(data.country),\n customAttributes: transformCustomAttributes(data.custom_attributes),\n fax: data.fax || undefined,\n firstName: data.firstname,\n lastName: data.lastname,\n middleName: data.middlename || undefined,\n postCode: data.postcode || undefined,\n prefix: data.prefix || undefined,\n region: transformAddressRegion(data.region),\n street,\n suffix: data.suffix || undefined,\n telephone: data.telephone || undefined,\n uid: data.uid,\n vatId: data.vat_id || undefined,\n };\n};\n\nconst transformQuoteBillingAddress = (\n data: QuoteBillingAddress\n): AddressModel | undefined => {\n if (!data) return;\n return transformAddress(data);\n};\n\nconst transformQuoteShippingAddress = (\n data: QuoteShippingAddresses\n): ShippingAddressModel[] => {\n return data\n .filter((address) => !!address)\n .map((address) => {\n const {\n available_shipping_methods,\n selected_shipping_method,\n ...baseData\n } = address as NonNullableShippingAddress;\n\n return {\n ...transformAddress(baseData as NonNullableShippingAddress),\n availableShippingMethods: transformShippingMethods(\n available_shipping_methods\n ),\n selectedShippingMethod: transformSelectedShippingMethod(\n selected_shipping_method\n ),\n };\n });\n};\n\nexport {\n QuoteBillingAddress,\n QuoteShippingAddress,\n transformQuoteBillingAddress,\n transformQuoteShippingAddress,\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 { NegotiableQuote as NegotiableQuoteModel } from '@/checkout/data/models/';\nimport { GetNegotiableQuoteQuery } from '@/checkout/__generated__/types';\n\nimport {\n transformAvailablePaymentMethods,\n transformQuoteBillingAddress,\n transformQuoteShippingAddress,\n transformSelectedPaymentMethod,\n} from '@/checkout/data/transforms';\n\ntype NegotiableQuote = GetNegotiableQuoteQuery['negotiableQuote'];\n\nexport const transformNegotiableQuote = (\n data: NegotiableQuote | undefined\n): NegotiableQuoteModel | null => {\n if (!data) return null;\n\n return {\n availablePaymentMethods: transformAvailablePaymentMethods(\n data.available_payment_methods\n ),\n billingAddress: transformQuoteBillingAddress(data.billing_address),\n email: data.email ?? '',\n isEmpty: data.total_quantity === 0,\n isVirtual: data.is_virtual,\n name: data.name,\n selectedPaymentMethod: transformSelectedPaymentMethod(\n data.selected_payment_method\n ),\n shippingAddresses: transformQuoteShippingAddress(data.shipping_addresses),\n status: data.status,\n uid: data.uid,\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 getCartQuery = /* GraphQL */ `\n query getCart($cartId: String!) {\n cart(cart_id: $cartId) {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n\nexport const getCustomerCartQuery = /* GraphQL */ `\n query getCustomerCart {\n cart: customerCart {\n ...CHECKOUT_DATA_FRAGMENT\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 {\n getCartQuery,\n getCustomerCartQuery,\n} from '@/checkout/api/getCart/graphql';\nimport { transformCart } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { state } from '@/checkout/lib';\nimport { MissingCart } from '@/checkout/lib/errors';\n\nexport const getCart = async () => {\n const cartId = state.cartId;\n const isGuest = state.authenticated === false;\n const query = isGuest ? getCartQuery : getCustomerCartQuery;\n const variables = isGuest ? { cartId } : {};\n\n if (isGuest && !cartId) throw new MissingCart();\n\n return await dispatchApiCall({\n type: 'query',\n query,\n options: { method: 'POST', cache: 'no-cache', variables },\n path: 'cart',\n transformer: transformCart,\n });\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 getNegotiableQuoteQuery = /* GraphQL */ `\n query getNegotiableQuote($quoteId: ID!) {\n negotiableQuote(uid: $quoteId) {\n ...NEGOTIABLE_QUOTE_FRAGMENT\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 { getNegotiableQuoteQuery } from '@/checkout/api/getNegotiableQuote/graphql';\nimport { transformNegotiableQuote as transformer } from '@/checkout/data/transforms';\nimport { state } from '@/checkout/lib';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport {\n MissingNegotiableQuoteId,\n Unauthenticated,\n} from '@/checkout/lib/errors';\n\ntype GetNegotiableQuoteInput = {\n uid?: string;\n};\n\nexport const getNegotiableQuote = async (\n input: GetNegotiableQuoteInput = {}\n) => {\n const quoteId = input.uid ?? state.quoteId;\n const isGuest = state.authenticated === false;\n\n if (isGuest) throw new Unauthenticated();\n if (!quoteId) throw new MissingNegotiableQuoteId();\n\n const variables = { quoteId };\n\n return await dispatchApiCall({\n type: 'query',\n query: getNegotiableQuoteQuery,\n options: { method: 'GET', cache: 'no-cache', variables },\n path: 'negotiableQuote',\n transformer,\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 {\n authenticateCustomer,\n initializeCheckout,\n resetCheckout,\n synchronizeCheckout,\n} from '@/checkout/api';\nimport { events } from '@adobe-commerce/event-bus';\n\nconst asEager = { eager: true };\n\nexport const addCheckoutEventListeners = () => {\n return [\n events.on('authenticated', authenticateCustomer, asEager),\n events.on('cart/initialized', initializeCheckout, asEager),\n events.on('cart/reset', resetCheckout),\n events.on('cart/updated', synchronizeCheckout),\n events.on('quote-management/quote-data', initializeCheckout, asEager),\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 { addCheckoutEventListeners } from '@/checkout/api/initialize/listeners';\nimport {\n Cart as CartModel,\n Customer as CustomerModel,\n} from '@/checkout/data/models';\nimport { state } from '@/checkout/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { Initializer, Model } from '@adobe-commerce/elsie/lib';\n\nconst url = new URL(window.location.href);\nconst quoteId = url.searchParams.get('quoteId');\nstate.quoteId = quoteId;\n\nexport type ConfigProps = {\n defaults?: {\n isBillToShipping?: boolean;\n };\n langDefinitions?: Lang;\n models?: {\n CartModel?: Model<CartModel>;\n CustomerModel?: Model<CustomerModel>;\n };\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (_config) => {\n initialize.config.setConfig({\n defaults: { isBillToShipping: true, ..._config?.defaults },\n ..._config,\n });\n },\n listeners: addCheckoutEventListeners,\n});\n\nexport const config = initialize.config;\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 {\n CartModel,\n InitializeInput,\n NegotiableQuoteModel,\n SynchronizeInput,\n} from '@/checkout/types';\n\nexport const isCartInput = (\n input: NonNullable<InitializeInput | SynchronizeInput>\n): input is CartModel => {\n return 'id' in input;\n};\n\nexport const isNegotiableQuoteInput = (\n input: NonNullable<InitializeInput | SynchronizeInput>\n): input is NegotiableQuoteModel => {\n return 'uid' in input;\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 getCart,\n getNegotiableQuote,\n getStoreConfig,\n synchronizeCheckout,\n} from '@/checkout/api';\nimport { state } from '@/checkout/lib';\nimport { InitializeInput, isCartInput } from '@/checkout/types';\nimport { events } from '@adobe-commerce/event-bus';\n\nconst getInitialData = async (input: NonNullable<InitializeInput>) => {\n try {\n if (isCartInput(input)) {\n state.cartId = input.id;\n state.quoteId = null;\n return (await getCart()) ?? null;\n }\n state.cartId = null;\n state.quoteId = input.uid;\n return (await getNegotiableQuote()) ?? null;\n } catch (error) {\n console.error('Checkout initialization failed:', error);\n return null;\n }\n};\n\nexport const initializeCheckout = async (input: InitializeInput) => {\n if (state.initialized) {\n await synchronizeCheckout(input);\n return;\n }\n\n if (!state.config) {\n state.config = await getStoreConfig();\n }\n\n const initialData = input ? await getInitialData(input) : null;\n\n state.initialized = true;\n events.emit('checkout/initialized', initialData);\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 { state } from '@/checkout/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const resetCheckout = () => {\n if (!state.initialized) return;\n state.cartId = null;\n state.quoteId = null;\n events.emit('checkout/updated', null);\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 getCart,\n getNegotiableQuote,\n initializeCheckout,\n resetCheckout,\n} from '@/checkout/api';\nimport { state } from '@/checkout/lib/state';\nimport { isCartInput, SynchronizeInput } from '@/checkout/types';\nimport { events } from '@adobe-commerce/event-bus';\n\nconst getSynchronizedData = async (input: NonNullable<SynchronizeInput>) => {\n try {\n if (isCartInput(input)) {\n state.cartId = input.id;\n state.quoteId = null;\n return (await getCart()) ?? null;\n }\n state.cartId = null;\n state.quoteId = input.uid;\n return (await getNegotiableQuote()) ?? null;\n } catch (error) {\n console.error('Checkout synchronization failed:', error);\n return null;\n }\n};\n\nexport const synchronizeCheckout = async (data: SynchronizeInput) => {\n if (!state.initialized) return initializeCheckout(data);\n\n if (data === null) {\n resetCheckout();\n return;\n }\n\n const update = await getSynchronizedData(data);\n\n events.emit('checkout/updated', update);\n};\n"],"names":["authenticateCustomer","authenticated","state","transformSelectedPaymentMethod","data","transformAvailablePaymentMethods","method","code","title","transformCart","model","transformCartBillingAddress","transformCartShippingAddress","merge","_c","_b","_a","config","transformAddress","street","transformAddressCountry","transformCustomAttributes","transformAddressRegion","transformQuoteBillingAddress","transformQuoteShippingAddress","address","available_shipping_methods","selected_shipping_method","baseData","transformShippingMethods","transformSelectedShippingMethod","transformNegotiableQuote","getCartQuery","CHECKOUT_DATA_FRAGMENT","getCustomerCartQuery","getCart","cartId","isGuest","query","variables","MissingCart","dispatchApiCall","getNegotiableQuoteQuery","NEGOTIABLE_QUOTE_FRAGMENT","getNegotiableQuote","input","quoteId","Unauthenticated","MissingNegotiableQuoteId","transformer","asEager","addCheckoutEventListeners","events","initializeCheckout","resetCheckout","synchronizeCheckout","url","initialize","Initializer","_config","isCartInput","getInitialData","error","getStoreConfig","initialData","getSynchronizedData","update"],"mappings":"oXAmBa,MAAAA,EAAuB,MAAOC,EAAgB,KAAU,CACnEC,EAAM,cAAgBD,CACxB,ECWME,EACJC,GAC8B,CAC9B,GAAKA,EACL,MAAO,CAAE,KAAMA,EAAK,KAAM,MAAOA,EAAK,KAAM,CAC9C,EAEMC,EACJD,GACgC,CAChC,GAAKA,EAEE,OAAAA,EACJ,OAAQE,GAAW,CAAC,CAACA,CAAM,EAC3B,IAAKA,GAAW,CACT,KAAA,CAAE,KAAAC,EAAM,MAAAC,CAAA,EAAUF,EACjB,MAAA,CAAE,KAAAC,EAAM,MAAAC,CAAM,CAAA,CACtB,CACL,EChBMC,EAAiBL,GAAsC,WAC3D,GAAI,CAACA,EAAM,OAEX,MAAMM,EAAQ,CACZ,wBAAyBL,EACvBD,EAAK,yBACP,EACA,eAAgBO,EAA4BP,EAAK,eAAe,EAChE,MAAOA,EAAK,OAAS,OACrB,GAAIA,EAAK,GACT,QAASA,EAAK,iBAAmB,EACjC,UAAWA,EAAK,WAChB,sBAAuBD,EACrBC,EA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C,EAAM,OAAS,KACfA,EAAM,QAAU2C,EAAM,IACd,MAAMD,KAAyB,YAChCkB,EAAO,CACN,eAAA,MAAM,mCAAoCA,CAAK,EAChD,IAAA,CAEX,EAEaP,EAAsB,MAAOnD,GAA2B,CACnE,GAAI,CAACF,EAAM,YAAa,OAAOmD,EAAmBjD,CAAI,EAEtD,GAAIA,IAAS,KAAM,CACHkD,EAAA,EACd,MAAA,CAGI,MAAAY,EAAS,MAAMD,EAAoB7D,CAAI,EAEtCgD,EAAA,KAAK,mBAAoBc,CAAM,CACxC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
const r=o=>({countryCode:o.country_id,postCode:o.postcode||"",...o.region_id?{regionId:Number(o.region_id)}:{...o.region?{region:o.region}:{}}}),n=o=>({carrierCode:o.carrier.code||"",methodCode:o.code||"",amount:o.amount,amountExclTax:o.amountExclTax,amountInclTax:o.amountInclTax});export{r as a,n as t};
|
|
4
|
+
//# sourceMappingURL=transform-shipping-estimate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-shipping-estimate.js","sources":["/@dropins/storefront-checkout/src/data/transforms/transform-shipping-estimate.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 {\n PartialShippingAddress,\n ShippingEstimateShippingMethod,\n ShippingMethod,\n} from '@/checkout/data/models';\n\ntype TransformShippingEstimatePartialAddressInput = {\n country_id: string;\n postcode?: string;\n region_id?: number;\n region?: string;\n};\n\nexport const transformShippingEstimatePartialAddress = (\n data: TransformShippingEstimatePartialAddressInput\n): PartialShippingAddress => {\n return {\n countryCode: data.country_id,\n postCode: data.postcode || '',\n ...(data.region_id\n ? { regionId: Number(data.region_id) }\n : { ...(data.region ? { region: data.region } : {}) }),\n };\n};\n\nexport const transformShippingEstimateShippingMethod = (\n data: ShippingMethod\n): ShippingEstimateShippingMethod => {\n return {\n carrierCode: data.carrier.code || '',\n methodCode: data.code || '',\n amount: data.amount,\n amountExclTax: data.amountExclTax,\n amountInclTax: data.amountInclTax,\n };\n};\n"],"names":["transformShippingEstimatePartialAddress","data","transformShippingEstimateShippingMethod"],"mappings":"AA8Ba,MAAAA,EACXC,IAEO,CACL,YAAaA,EAAK,WAClB,SAAUA,EAAK,UAAY,GAC3B,GAAIA,EAAK,UACL,CAAE,SAAU,OAAOA,EAAK,SAAS,CAAE,EACnC,CAAE,GAAIA,EAAK,OAAS,CAAE,OAAQA,EAAK,MAAO,EAAI,CAAI,CAAA,CACxD,GAGWC,EACXD,IAEO,CACL,YAAaA,EAAK,QAAQ,MAAQ,GAClC,WAAYA,EAAK,MAAQ,GACzB,OAAQA,EAAK,OACb,cAAeA,EAAK,cACpB,cAAeA,EAAK,aACtB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import"./fetch-graphql.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";const s=e=>e?"code"in e&&"value"in e:!1,m=e=>e?e.filter(s).map(r=>{const{code:i,value:o}=r;return{code:i,value:o}}):[],n=e=>{const r=e.street.filter(Boolean);return{city:e.city,company:e.company||void 0,country:f(e.country),customAttributes:m(e.custom_attributes),fax:e.fax||void 0,firstName:e.firstname,id:(e==null?void 0:e.id)||void 0,lastName:e.lastname,middleName:e.middlename||void 0,postCode:e.postcode||void 0,prefix:e.prefix||void 0,region:p(e.region),street:r,suffix:e.suffix||void 0,telephone:e.telephone||void 0,uid:e.uid,vatId:e.vat_id||void 0}},A=e=>{if(e)return n(e)},N=e=>e.filter(r=>!!r).map(r=>{const{available_shipping_methods:i,selected_shipping_method:o,same_as_billing:u,...l}=r;return{...n(l),availableShippingMethods:h(i),selectedShippingMethod:x(o),sameAsBilling:u}}),C=e=>{var r,i;if(e)return{city:e.city,company:e.company,countryCode:e.country.code,customAttributes:e.customAttributes||[],firstName:e.firstName,lastName:e.lastName,postcode:e.postCode,region:(r=e.region)==null?void 0:r.code,regionId:(i=e.region)==null?void 0:i.id,street:e.street,telephone:e.telephone,vatId:e.vatId,prefix:e.prefix,suffix:e.suffix,middleName:e.middleName,fax:e.fax}},f=e=>({code:(e==null?void 0:e.code)??"",label:(e==null?void 0:e.label)??""}),p=e=>{if(!(!(e!=null&&e.code)||!(e!=null&&e.label)))return{code:e.code,name:e.label,id:e.region_id??void 0}},_=(e,r)=>e.amount.value-r.amount.value,v=e=>e==null,t=e=>!(!e||!e.method_code||!e.method_title||v(e.amount.value)||!e.amount.currency),c=e=>({amount:{value:e.amount.value,currency:e.amount.currency},title:e.method_title,code:e.method_code,carrier:{code:e.carrier_code,title:e.carrier_title},value:`${e.carrier_code} - ${e.method_code}`,...e.price_excl_tax&&{amountExclTax:{value:e.price_excl_tax.value,currency:e.price_excl_tax.currency}},...e.price_incl_tax&&{amountInclTax:{value:e.price_incl_tax.value,currency:e.price_incl_tax.currency}}}),x=e=>{if(t(e))return c(e)},h=e=>e?e.filter(t).map(r=>c(r)).sort(_):[];export{h as a,N as b,A as c,x as d,p as e,m as f,f as g,C as t};
|
|
4
|
+
//# sourceMappingURL=transform-shipping-methods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-shipping-methods.js","sources":["/@dropins/storefront-checkout/src/data/transforms/transform-custom-attributes.ts","/@dropins/storefront-checkout/src/data/transforms/transform-cart-address.ts","/@dropins/storefront-checkout/src/data/transforms/transform-country.ts","/@dropins/storefront-checkout/src/data/transforms/transform-region.ts","/@dropins/storefront-checkout/src/data/transforms/transform-shipping-methods.ts"],"sourcesContent":["/********************************************************************\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 { CustomAttribute as CustomAttributeModel } from '@/checkout/data/models/custom-attribute';\nimport { AttributeValue } from '@/checkout/__generated__/types';\n\nconst isAttributeValue = (attribute: any): attribute is AttributeValue => {\n if (!attribute) return false;\n return 'code' in attribute && 'value' in attribute;\n};\n\nexport const transformCustomAttributes = (\n data: Array<AttributeValue | any | null> | null | undefined\n): CustomAttributeModel[] => {\n if (!data) return [];\n return data.filter(isAttributeValue).map((attribute) => {\n const { code, value } = attribute;\n return { code, value };\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 {\n AddressInput as AddressInputModel,\n CartAddress as CartAddressModel,\n CartShippingAddress as CartShippingAddressModel,\n} from '@/checkout/data/models';\n\nimport {\n transformAddressCountry,\n transformAddressRegion,\n transformCustomAttributes,\n transformSelectedShippingMethod,\n transformShippingMethods,\n} from '@/checkout/data/transforms';\n\nimport { GetCartQuery } from '@/checkout/__generated__/types';\n\ntype ShippingAddresses = NonNullable<\n GetCartQuery['cart']\n>['shipping_addresses'];\ntype CartShippingAddress = ShippingAddresses[0];\ntype NonNullableShippingAddress = NonNullable<CartShippingAddress>;\n\ntype CartBillingAddress = NonNullable<GetCartQuery['cart']>['billing_address'];\ntype NonNullableBillingAddress = NonNullable<CartBillingAddress>;\n\nconst transformBaseCartAddress = (\n data: NonNullableShippingAddress | NonNullableBillingAddress\n): CartAddressModel => {\n const street = data.street.filter(Boolean) as string[];\n\n return {\n city: data.city,\n company: data.company || undefined,\n country: transformAddressCountry(data.country),\n customAttributes: transformCustomAttributes(data.custom_attributes),\n fax: data.fax || undefined,\n firstName: data.firstname,\n id: data?.id || undefined,\n lastName: data.lastname,\n middleName: data.middlename || undefined,\n postCode: data.postcode || undefined,\n prefix: data.prefix || undefined,\n region: transformAddressRegion(data.region),\n street,\n suffix: data.suffix || undefined,\n telephone: data.telephone || undefined,\n uid: data.uid,\n vatId: data.vat_id || undefined,\n };\n};\n\nconst transformCartBillingAddress = (\n data: CartBillingAddress\n): CartAddressModel | undefined => {\n if (!data) return;\n return transformBaseCartAddress(data);\n};\n\nconst transformCartShippingAddress = (\n data: ShippingAddresses\n): CartShippingAddressModel[] => {\n return data\n .filter((address) => !!address)\n .map((address) => {\n const {\n available_shipping_methods,\n selected_shipping_method,\n same_as_billing,\n ...baseData\n } = address as NonNullableShippingAddress;\n\n return {\n ...transformBaseCartAddress(baseData as NonNullableShippingAddress),\n availableShippingMethods: transformShippingMethods(\n available_shipping_methods\n ),\n selectedShippingMethod: transformSelectedShippingMethod(\n selected_shipping_method\n ),\n sameAsBilling: same_as_billing,\n };\n });\n};\n\nconst transformAddressToCartAddressInput = <T extends CartAddressModel>(\n address?: T | null\n): AddressInputModel | undefined => {\n if (!address) return;\n return {\n city: address.city,\n company: address.company,\n countryCode: address.country.code,\n customAttributes: address.customAttributes || [],\n firstName: address.firstName,\n lastName: address.lastName,\n postcode: address.postCode,\n region: address.region?.code,\n regionId: address.region?.id,\n street: address.street,\n telephone: address.telephone,\n vatId: address.vatId,\n prefix: address.prefix,\n suffix: address.suffix,\n middleName: address.middleName,\n fax: address.fax,\n };\n};\n\nexport {\n CartBillingAddress,\n CartShippingAddress,\n transformAddressToCartAddressInput,\n transformCartBillingAddress,\n transformCartShippingAddress,\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 {\n CartAddressCountry,\n NegotiableQuoteAddressCountry,\n} from '@/checkout/__generated__/types';\n\nimport { Country as CountryModel } from '@/checkout/data/models';\n\ntype AddressCountry = CartAddressCountry | NegotiableQuoteAddressCountry;\ntype OptionalAddressCountry = AddressCountry | undefined | null;\n\nexport const transformAddressCountry = (\n data: OptionalAddressCountry\n): CountryModel => ({\n code: data?.code ?? '',\n label: data?.label ?? '',\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 { Region as RegionModel } from '@/checkout/data/models';\nimport {\n CartAddressRegion,\n NegotiableQuoteAddressRegion,\n} from '@/checkout/__generated__/types';\n\ntype AddressRegion = CartAddressRegion | NegotiableQuoteAddressRegion;\ntype OptionalAddressRegion = AddressRegion | undefined | null;\n\nexport const transformAddressRegion = (\n data: OptionalAddressRegion\n): RegionModel | undefined => {\n if (!data?.code || !data?.label) return;\n return {\n code: data.code,\n name: data.label,\n id: data.region_id ?? undefined,\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 { ShippingMethod } from '@/checkout/data/models/shipping-method';\nimport { GetCartQuery } from '@/checkout/__generated__/types';\n\ntype Cart = NonNullable<GetCartQuery['cart']>;\ntype ShippingAddresses = Cart['shipping_addresses'];\ntype ShippingAddress = NonNullable<NonNullable<ShippingAddresses>[number]>;\ntype AvailableShippingMethods = ShippingAddress['available_shipping_methods'];\ntype AvailableShippingMethod = NonNullable<AvailableShippingMethods>[number];\ntype SelectedShippingMethod = ShippingAddress['selected_shipping_method'];\n\ntype FilteredShippingMethod = Omit<\n NonNullable<AvailableShippingMethod>,\n | 'method_code'\n | 'method_title'\n | 'amount'\n | 'price_excl_tax'\n | 'price_incl_tax'\n> & {\n method_code: string;\n method_title: string;\n amount: {\n value: number;\n currency: string;\n };\n price_excl_tax: {\n value: number;\n currency: string;\n };\n price_incl_tax: {\n value: number;\n currency: string;\n };\n};\n\nconst byPrice = (a: ShippingMethod, b: ShippingMethod) =>\n a.amount.value - b.amount.value;\n\nexport const isNullish = (value: any): boolean =>\n value === null || value === undefined;\n\nconst isValid = (method: AvailableShippingMethod | SelectedShippingMethod) => {\n if (!method) return false;\n if (!method.method_code || !method.method_title) return false;\n if (isNullish(method.amount.value) || !method.amount.currency) return false;\n return true;\n};\n\nconst buildShippingMethod = (data: FilteredShippingMethod): ShippingMethod => {\n return {\n amount: {\n value: data.amount.value,\n currency: data.amount.currency,\n },\n title: data.method_title,\n code: data.method_code,\n carrier: {\n code: data.carrier_code,\n title: data.carrier_title,\n },\n value: `${data.carrier_code} - ${data.method_code}`,\n ...(data.price_excl_tax && {\n amountExclTax: {\n value: data.price_excl_tax.value,\n currency: data.price_excl_tax.currency,\n },\n }),\n ...(data.price_incl_tax && {\n amountInclTax: {\n value: data.price_incl_tax.value,\n currency: data.price_incl_tax.currency,\n },\n }),\n };\n};\n\nexport const transformSelectedShippingMethod = (\n data: SelectedShippingMethod\n): ShippingMethod | undefined => {\n if (!isValid(data)) return;\n return buildShippingMethod(data as FilteredShippingMethod);\n};\n\nexport const transformAvailableShippingMethod = (\n data: AvailableShippingMethod\n): ShippingMethod | undefined => {\n if (!isValid(data)) return;\n return buildShippingMethod(data as FilteredShippingMethod);\n};\n\nexport const transformShippingMethods = (\n data: AvailableShippingMethods\n): ShippingMethod[] => {\n if (!data) return [];\n\n return data\n .filter(isValid)\n .map((method) => buildShippingMethod(method as FilteredShippingMethod))\n .sort(byPrice);\n};\n"],"names":["isAttributeValue","attribute","transformCustomAttributes","data","code","value","transformBaseCartAddress","street","transformAddressCountry","transformAddressRegion","transformCartBillingAddress","transformCartShippingAddress","address","available_shipping_methods","selected_shipping_method","same_as_billing","baseData","transformShippingMethods","transformSelectedShippingMethod","transformAddressToCartAddressInput","_a","_b","byPrice","a","b","isNullish","isValid","method","buildShippingMethod"],"mappings":"6FAoBA,MAAMA,EAAoBC,GACnBA,EACE,SAAUA,GAAa,UAAWA,EADlB,GAIZC,EACXC,GAEKA,EACEA,EAAK,OAAOH,CAAgB,EAAE,IAAKC,GAAc,CAChD,KAAA,CAAE,KAAAG,EAAM,MAAAC,CAAA,EAAUJ,EACjB,MAAA,CAAE,KAAAG,EAAM,MAAAC,CAAM,CAAA,CACtB,EAJiB,CAAC,ECcfC,EACJH,GACqB,CACrB,MAAMI,EAASJ,EAAK,OAAO,OAAO,OAAO,EAElC,MAAA,CACL,KAAMA,EAAK,KACX,QAASA,EAAK,SAAW,OACzB,QAASK,EAAwBL,EAAK,OAAO,EAC7C,iBAAkBD,EAA0BC,EAAK,i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A,EAAM,QAAS,EACxB,GCNaM,EACXN,GAC4B,CAC5B,GAAI,IAACA,GAAA,MAAAA,EAAM,OAAQ,EAACA,GAAA,MAAAA,EAAM,QACnB,MAAA,CACL,KAAMA,EAAK,KACX,KAAMA,EAAK,MACX,GAAIA,EAAK,WAAa,MACxB,CACF,ECgBMmB,EAAU,CAACC,EAAmBC,IAClCD,EAAE,OAAO,MAAQC,EAAE,OAAO,MAEfC,EAAapB,GACxBA,GAAU,KAENqB,EAAWC,GACX,GAACA,GACD,CAACA,EAAO,aAAe,CAACA,EAAO,cAC/BF,EAAUE,EAAO,OAAO,KAAK,GAAK,CAACA,EAAO,OAAO,UAIjDC,EAAuBzB,IACpB,CACL,OAAQ,CACN,MAAOA,EAAK,OAAO,MACnB,SAAUA,EAAK,OAAO,QACxB,EACA,MAAOA,EAAK,aACZ,KAAMA,EAAK,YACX,QAAS,CACP,KAAMA,EAAK,aACX,MAAOA,EAAK,aACd,EACA,MAAO,GAAGA,EAAK,YAAY,MAAMA,EAAK,WAAW,GACjD,GAAIA,EAAK,gBAAkB,CACzB,cAAe,CACb,MAAOA,EAAK,eAAe,MAC3B,SAAUA,EAAK,eAAe,QAAA,CAElC,EACA,GAAIA,EAAK,gBAAkB,CACzB,cAAe,CACb,MAAOA,EAAK,eAAe,MAC3B,SAAUA,EAAK,eAAe,QAAA,CAChC,CAEJ,GAGWe,EACXf,GAC+B,CAC3B,GAACuB,EAAQvB,CAAI,EACjB,OAAOyB,EAAoBzB,CAA8B,CAC3D,EASac,EACXd,GAEKA,EAEEA,EACJ,OAAOuB,CAAO,EACd,IAAKC,GAAWC,EAAoBD,CAAgC,CAAC,EACrE,KAAKL,CAAO,EALG,CAAC"}
|
package/chunks/values.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{events as l}from"@dropins/tools/event-bus.js";const
|
|
3
|
+
import{events as l}from"@dropins/tools/event-bus.js";const o={email:"",isBillToShipping:void 0,selectedPaymentMethod:null,selectedShippingMethod:null};function s(e){const n={...l.lastPayload("checkout/values")??o,...e};l.emit("checkout/values",n)}function i(e){const t=l.lastPayload("checkout/values");return t&&e in t?t[e]:null}export{i as g,s as n};
|
|
4
4
|
//# sourceMappingURL=values.js.map
|
package/chunks/values.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"values.js","sources":["/@dropins/storefront-checkout/src/lib/values.ts"],"sourcesContent":["/********************************************************************\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 { ValuesModel } from '@/checkout/data/models';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const initialValues: ValuesModel = {\n email: '',\n isBillToShipping:
|
|
1
|
+
{"version":3,"file":"values.js","sources":["/@dropins/storefront-checkout/src/lib/values.ts"],"sourcesContent":["/********************************************************************\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 { ValuesModel } from '@/checkout/data/models';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const initialValues: ValuesModel = {\n email: '',\n isBillToShipping: undefined,\n selectedPaymentMethod: null,\n selectedShippingMethod: null,\n};\n\n/**\n * Emits a checkout/values event with the provided values\n * Merges with previous values if they exist\n *\n * @param values - Partial values to be emitted or merged with existing values\n */\nexport function notifyValues(values: Partial<ValuesModel>): void {\n const prev = events.lastPayload('checkout/values') ?? initialValues;\n const next = { ...prev, ...values };\n events.emit('checkout/values', next);\n}\n\n/**\n * Retrieves a specific value from the ValuesModel by key\n * @param key - The key of the ValuesModel to retrieve\n * @returns The value for the specified key or null if not defined/found\n */\nexport function getValue<K extends keyof ValuesModel>(\n key: K\n): ValuesModel[K] | null {\n const values = events.lastPayload('checkout/values');\n return values && key in values ? values[key] : null;\n}\n"],"names":["initialValues","notifyValues","values","next","events","getValue","key"],"mappings":"qDAoBO,MAAMA,EAA6B,CACxC,MAAO,GACP,iBAAkB,OAClB,sBAAuB,KACvB,uBAAwB,IAC1B,EAQO,SAASC,EAAaC,EAAoC,CAE/D,MAAMC,EAAO,CAAE,GADFC,EAAO,YAAY,iBAAiB,GAAKJ,EAC9B,GAAGE,CAAO,EAC3BE,EAAA,KAAK,kBAAmBD,CAAI,CACrC,CAOO,SAASE,EACdC,EACuB,CACjB,MAAAJ,EAASE,EAAO,YAAY,iBAAiB,EACnD,OAAOF,GAAUI,KAAOJ,EAASA,EAAOI,CAAG,EAAI,IACjD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AddressInput } from '../../data/models';
|
|
2
|
+
import { FunctionComponent } from 'preact';
|
|
3
|
+
import { HTMLAttributes } from 'preact/compat';
|
|
4
|
+
|
|
5
|
+
export interface AddressValidationProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
busy?: boolean;
|
|
7
|
+
currentAddress: AddressInput | null | undefined;
|
|
8
|
+
selection: 'suggested' | 'original' | null;
|
|
9
|
+
suggestedAddress: AddressInput | null;
|
|
10
|
+
onSelectionChange: (selection: 'suggested' | 'original') => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function formatAddressLine(address: AddressInput | null | undefined): string[];
|
|
13
|
+
export declare const AddressValidation: FunctionComponent<AddressValidationProps>;
|
|
14
|
+
//# sourceMappingURL=AddressValidation.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export * from './AddressValidation';
|
|
18
|
+
export { AddressValidation as default } from './AddressValidation';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PaymentMethodConfig } from '../../containers';
|
|
2
2
|
import { PaymentMethod } from '../../data/models/payment-method';
|
|
3
|
-
import { UIComponentType } from '../../types
|
|
3
|
+
import { UIComponentType } from '../../types';
|
|
4
4
|
import { FunctionComponent, VNode } from 'preact';
|
|
5
5
|
import { HTMLAttributes } from 'preact/compat';
|
|
6
6
|
|
package/components/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
+
export * from './AddressValidation';
|
|
17
18
|
export * from './BillToShippingAddress';
|
|
18
19
|
export * from './ConditionalWrapper/index';
|
|
19
20
|
export * from './EstimateShipping';
|