@vtex/faststore 0.0.7 → 0.0.10
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/CHANGELOG.md +102 -0
- package/dist/actions.json +194 -1
- package/dist/catalog.json +3449 -1612
- package/dist/cli/index.d.ts +512 -63
- package/dist/cli/index.js +2098 -686
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/server-runtime.js +44 -24
- package/dist/cli/server-runtime.js.map +1 -1
- package/dist/client.d.ts +5 -1
- package/dist/client.js +5 -1
- package/dist/components.d.ts +42 -10
- package/dist/components.js +47 -15
- package/dist/content-types.json +823 -0
- package/dist/core/dist/define-component.d.ts +12 -2
- package/dist/docs/account-access-gate.md +4 -4
- package/dist/docs/account-address-book.md +519 -0
- package/dist/docs/account-entry-point.md +5 -5
- package/dist/docs/account-menu.md +7 -7
- package/dist/docs/account-saved-cards.md +301 -0
- package/dist/docs/alert-dialog.md +2 -2
- package/dist/docs/billing-address.md +17 -9
- package/dist/docs/binding-switcher.md +154 -0
- package/dist/docs/card-entry.md +38 -7
- package/dist/docs/card-summary.md +175 -0
- package/dist/docs/cardholder-document.md +16 -14
- package/dist/docs/cart-destination.md +238 -0
- package/dist/docs/cart-item.md +22 -4
- package/dist/docs/cart-totalizer.md +1 -1
- package/dist/docs/cart.md +126 -19
- package/dist/docs/client-profile-fieldset.md +7 -5
- package/dist/docs/copy-text.md +84 -0
- package/dist/docs/document-field.md +8 -8
- package/dist/docs/footer-link-group.md +2 -2
- package/dist/docs/footer-social.md +1 -1
- package/dist/docs/free-shipping-progress.md +13 -9
- package/dist/docs/header-root.md +1 -1
- package/dist/docs/incentives.md +4 -4
- package/dist/docs/logo.md +6 -6
- package/dist/docs/my-account-profile.md +4 -4
- package/dist/docs/navigation-link-list.md +2 -2
- package/dist/docs/navigation-link.md +3 -3
- package/dist/docs/order-cancel.md +52 -0
- package/dist/docs/order-delivery-address.md +63 -0
- package/dist/docs/order-delivery-group.md +83 -0
- package/dist/docs/order-details-back.md +41 -0
- package/dist/docs/order-details-header.md +48 -0
- package/dist/docs/order-list-row.md +46 -0
- package/dist/docs/order-list-search.md +101 -0
- package/dist/docs/order-list-views.md +97 -0
- package/dist/docs/order-list.md +94 -0
- package/dist/docs/order-payment.md +94 -0
- package/dist/docs/order-placed-date.md +49 -0
- package/dist/docs/order-placed-payment-summary.md +13 -15
- package/dist/docs/order-placed.md +225 -0
- package/dist/docs/order-progress.md +88 -0
- package/dist/docs/order-status-badge.md +91 -0
- package/dist/docs/order-summary.md +53 -0
- package/dist/docs/payment-method-badges.md +16 -5
- package/dist/docs/payment-methods.md +1 -1
- package/dist/docs/place-order.md +13 -9
- package/dist/docs/product-information.md +2 -2
- package/dist/docs/product-shelf.md +7 -0
- package/dist/docs/saved-cards.md +2 -2
- package/dist/docs/select.md +22 -10
- package/dist/docs/session.md +1 -1
- package/dist/docs/shipping-address.md +1 -1
- package/dist/docs/sign-in-redirect.md +7 -7
- package/dist/docs/toast.md +35 -13
- package/dist/index.d.ts +7 -2
- package/dist/index.js +2 -1
- package/dist/internal/client.d.ts +9 -1
- package/dist/internal/client.js +10 -2
- package/dist/internal/server.d.ts +8 -2
- package/dist/internal/server.js +8 -2
- package/dist/matter/account-access-gate/account-access-gate.d.ts +2 -1
- package/dist/matter/account-access-gate/account-access-gate.js +19 -16
- package/dist/matter/account-access-gate/account-access-gate.js.map +1 -1
- package/dist/matter/account-address-book/account-address-book-delete.d.ts +60 -0
- package/dist/matter/account-address-book/account-address-book-delete.js +184 -0
- package/dist/matter/account-address-book/account-address-book-delete.js.map +1 -0
- package/dist/matter/account-address-book/account-address-book-deliverability.d.ts +19 -0
- package/dist/matter/account-address-book/account-address-book-deliverability.js +50 -0
- package/dist/matter/account-address-book/account-address-book-deliverability.js.map +1 -0
- package/dist/matter/account-address-book/account-address-book-form-parts.d.ts +42 -0
- package/dist/matter/account-address-book/account-address-book-form-parts.js +146 -0
- package/dist/matter/account-address-book/account-address-book-form-parts.js.map +1 -0
- package/dist/matter/account-address-book/account-address-book-profile-notice.d.ts +25 -0
- package/dist/matter/account-address-book/account-address-book-profile-notice.js +72 -0
- package/dist/matter/account-address-book/account-address-book-profile-notice.js.map +1 -0
- package/dist/matter/account-address-book/account-address-book.d.ts +120 -0
- package/dist/matter/account-address-book/account-address-book.js +469 -0
- package/dist/matter/account-address-book/account-address-book.js.map +1 -0
- package/dist/matter/account-address-book/account-address-country-switch.js +59 -0
- package/dist/matter/account-address-book/account-address-country-switch.js.map +1 -0
- package/dist/matter/account-address-book/account-address-country.d.ts +36 -0
- package/dist/matter/account-address-book/account-address-country.js +151 -0
- package/dist/matter/account-address-book/account-address-country.js.map +1 -0
- package/dist/matter/account-address-book/account-address-first-line.js +11 -0
- package/dist/matter/account-address-book/account-address-first-line.js.map +1 -0
- package/dist/matter/account-address-book/account-address-form-context.d.ts +55 -0
- package/dist/matter/account-address-book/account-address-form-context.js +14 -0
- package/dist/matter/account-address-book/account-address-form-context.js.map +1 -0
- package/dist/matter/account-address-book/account-address-form.d.ts +85 -0
- package/dist/matter/account-address-book/account-address-form.js +946 -0
- package/dist/matter/account-address-book/account-address-form.js.map +1 -0
- package/dist/matter/account-address-book/account-address-postal-autofill.js +189 -0
- package/dist/matter/account-address-book/account-address-postal-autofill.js.map +1 -0
- package/dist/matter/account-address-book/account-address-record.d.ts +26 -0
- package/dist/matter/account-address-book/account-address-record.js +138 -0
- package/dist/matter/account-address-book/account-address-record.js.map +1 -0
- package/dist/matter/account-entry-point/account-entry-point.js +11 -11
- package/dist/matter/account-entry-point/account-entry-point.js.map +1 -1
- package/dist/matter/account-menu/account-menu.d.ts +7 -3
- package/dist/matter/account-menu/account-menu.js +69 -28
- package/dist/matter/account-menu/account-menu.js.map +1 -1
- package/dist/matter/account-saved-cards/account-saved-cards.d.ts +383 -0
- package/dist/matter/account-saved-cards/account-saved-cards.js +956 -0
- package/dist/matter/account-saved-cards/account-saved-cards.js.map +1 -0
- package/dist/matter/billing-address/billing-address.d.ts +30 -17
- package/dist/matter/billing-address/billing-address.js +128 -33
- package/dist/matter/billing-address/billing-address.js.map +1 -1
- package/dist/matter/breadcrumb/breadcrumb.js +2 -2
- package/dist/matter/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/matter/card-entry/card-capture.js +4 -3
- package/dist/matter/card-entry/card-capture.js.map +1 -1
- package/dist/matter/card-entry/card-entry.d.ts +5 -3
- package/dist/matter/card-entry/card-entry.js +77 -27
- package/dist/matter/card-entry/card-entry.js.map +1 -1
- package/dist/matter/cardholder-document/cardholder-document.d.ts +10 -9
- package/dist/matter/cardholder-document/cardholder-document.js +36 -16
- package/dist/matter/cardholder-document/cardholder-document.js.map +1 -1
- package/dist/matter/cart/cart-namespace.d.ts +5 -1
- package/dist/matter/cart/cart-namespace.js +5 -1
- package/dist/matter/cart/cart-namespace.js.map +1 -1
- package/dist/matter/cart/cart.d.ts +41 -6
- package/dist/matter/cart/cart.js +267 -54
- package/dist/matter/cart/cart.js.map +1 -1
- package/dist/matter/cart-destination/cart-destination.d.ts +222 -0
- package/dist/matter/cart-destination/cart-destination.js +613 -0
- package/dist/matter/cart-destination/cart-destination.js.map +1 -0
- package/dist/matter/cart-item/cart-item.d.ts +4 -2
- package/dist/matter/cart-item/cart-item.js +76 -17
- package/dist/matter/cart-item/cart-item.js.map +1 -1
- package/dist/matter/cart-totalizer/cart-totalizer.js +3 -2
- package/dist/matter/cart-totalizer/cart-totalizer.js.map +1 -1
- package/dist/matter/client-preferences/client-preferences-fieldset.js +1 -1
- package/dist/matter/client-profile-form/client-profile-fieldset.js +8 -5
- package/dist/matter/client-profile-form/client-profile-fieldset.js.map +1 -1
- package/dist/matter/free-shipping-progress/free-shipping-progress.d.ts +6 -3
- package/dist/matter/free-shipping-progress/free-shipping-progress.js +76 -33
- package/dist/matter/free-shipping-progress/free-shipping-progress.js.map +1 -1
- package/dist/matter/identity-edit/identity-edit.js +3 -3
- package/dist/matter/identity-edit/identity-edit.js.map +1 -1
- package/dist/matter/identity-summary/identity-summary.js +2 -2
- package/dist/matter/identity-summary/identity-summary.js.map +1 -1
- package/dist/matter/my-account-profile/my-account-profile.d.ts +3 -3
- package/dist/matter/my-account-profile/my-account-profile.js +4 -4
- package/dist/matter/my-account-profile/my-account-profile.js.map +1 -1
- package/dist/matter/order-cancel/order-cancel.d.ts +110 -0
- package/dist/matter/order-cancel/order-cancel.js +344 -0
- package/dist/matter/order-cancel/order-cancel.js.map +1 -0
- package/dist/matter/order-delivery-address/order-delivery-address.d.ts +73 -0
- package/dist/matter/order-delivery-address/order-delivery-address.js +172 -0
- package/dist/matter/order-delivery-address/order-delivery-address.js.map +1 -0
- package/dist/matter/order-delivery-group/order-delivery-group.d.ts +128 -0
- package/dist/matter/order-delivery-group/order-delivery-group.js +408 -0
- package/dist/matter/order-delivery-group/order-delivery-group.js.map +1 -0
- package/dist/matter/order-details-header/order-details-header.d.ts +104 -0
- package/dist/matter/order-details-header/order-details-header.js +190 -0
- package/dist/matter/order-details-header/order-details-header.js.map +1 -0
- package/dist/matter/order-list/customer-orders-filter.d.ts +12 -0
- package/dist/matter/order-list/customer-orders-filter.js +30 -0
- package/dist/matter/order-list/customer-orders-filter.js.map +1 -0
- package/dist/matter/order-list/order-list.d.ts +121 -0
- package/dist/matter/order-list/order-list.js +395 -0
- package/dist/matter/order-list/order-list.js.map +1 -0
- package/dist/matter/order-list-row/order-list-row.d.ts +44 -0
- package/dist/matter/order-list-row/order-list-row.js +127 -0
- package/dist/matter/order-list-row/order-list-row.js.map +1 -0
- package/dist/matter/order-list-search/order-list-search.d.ts +72 -0
- package/dist/matter/order-list-search/order-list-search.js +296 -0
- package/dist/matter/order-list-search/order-list-search.js.map +1 -0
- package/dist/matter/order-list-views/order-list-views.d.ts +65 -0
- package/dist/matter/order-list-views/order-list-views.js +154 -0
- package/dist/matter/order-list-views/order-list-views.js.map +1 -0
- package/dist/matter/order-payment/order-payment.d.ts +83 -0
- package/dist/matter/order-payment/order-payment.js +258 -0
- package/dist/matter/order-payment/order-payment.js.map +1 -0
- package/dist/matter/order-placed/order-placed-deliveries.d.ts +145 -0
- package/dist/matter/order-placed/order-placed-deliveries.js +380 -0
- package/dist/matter/order-placed/order-placed-deliveries.js.map +1 -0
- package/dist/matter/order-placed/order-placed.d.ts +122 -0
- package/dist/matter/order-placed/order-placed.js +452 -0
- package/dist/matter/order-placed/order-placed.js.map +1 -0
- package/dist/matter/order-placed-date/order-placed-date.d.ts +45 -0
- package/dist/matter/order-placed-date/order-placed-date.js +92 -0
- package/dist/matter/order-placed-date/order-placed-date.js.map +1 -0
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.d.ts +5 -8
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js +29 -81
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js.map +1 -1
- package/dist/matter/order-progress/order-progress.d.ts +85 -0
- package/dist/matter/order-progress/order-progress.js +203 -0
- package/dist/matter/order-progress/order-progress.js.map +1 -0
- package/dist/matter/order-summary/order-summary.d.ts +81 -0
- package/dist/matter/order-summary/order-summary.js +192 -0
- package/dist/matter/order-summary/order-summary.js.map +1 -0
- package/dist/matter/payment/cardholder-document-rule.d.ts +35 -0
- package/dist/matter/payment/cardholder-document-rule.js +35 -0
- package/dist/matter/payment/cardholder-document-rule.js.map +1 -0
- package/dist/matter/payment/payment-card-capture.js +38 -23
- package/dist/matter/payment/payment-card-capture.js.map +1 -1
- package/dist/matter/payment/payment-controller.js +11 -0
- package/dist/matter/payment/payment-controller.js.map +1 -1
- package/dist/matter/payment/payment-method-badges.js +4 -2
- package/dist/matter/payment/payment-method-badges.js.map +1 -1
- package/dist/matter/payment/payment.js +11 -0
- package/dist/matter/payment/payment.js.map +1 -1
- package/dist/matter/payment/use-payment-method-selection.d.ts +39 -0
- package/dist/matter/payment/use-payment-method-selection.js +30 -2
- package/dist/matter/payment/use-payment-method-selection.js.map +1 -1
- package/dist/matter/payment/use-payment-submit-gate.d.ts +16 -2
- package/dist/matter/payment/use-payment-submit-gate.js +42 -14
- package/dist/matter/payment/use-payment-submit-gate.js.map +1 -1
- package/dist/matter/place-order/place-order.d.ts +12 -7
- package/dist/matter/place-order/place-order.js +126 -103
- package/dist/matter/place-order/place-order.js.map +1 -1
- package/dist/matter/pricing/pricing.js +5 -5
- package/dist/matter/pricing/pricing.js.map +1 -1
- package/dist/matter/product-shelf/product-shelf.d.ts +7 -0
- package/dist/matter/product-shelf/product-shelf.js +115 -1
- package/dist/matter/product-shelf/product-shelf.js.map +1 -1
- package/dist/matter/region/region.js +1 -1
- package/dist/matter/saved-cards/saved-cards.js +26 -15
- package/dist/matter/saved-cards/saved-cards.js.map +1 -1
- package/dist/matter/session/session.js +2 -2
- package/dist/matter/session/session.js.map +1 -1
- package/dist/matter/shipping-address/country-descriptors.d.ts +1 -0
- package/dist/matter/shipping-address/country-descriptors.js +23 -1
- package/dist/matter/shipping-address/country-descriptors.js.map +1 -1
- package/dist/matter/shipping-address/shipping-address.js +62 -14
- package/dist/matter/shipping-address/shipping-address.js.map +1 -1
- package/dist/matter/shipping-simulator/shipping-simulator.d.ts +2 -2
- package/dist/matter/shipping-simulator/shipping-simulator.js +6 -2
- package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -1
- package/dist/matter/sign-in-redirect/sign-in-redirect.js +48 -10
- package/dist/matter/sign-in-redirect/sign-in-redirect.js.map +1 -1
- package/dist/matter/variant-selector/variant-selector.js +2 -2
- package/dist/matter/variant-selector/variant-selector.js.map +1 -1
- package/dist/particles/address-summary/address-summary.js +2 -2
- package/dist/particles/address-summary/address-summary.js.map +1 -1
- package/dist/particles/alert-dialog/alert-dialog.d.ts +5 -1
- package/dist/particles/alert-dialog/alert-dialog.js +5 -2
- package/dist/particles/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/particles/binding-switcher/binding-switcher.d.ts +38 -0
- package/dist/particles/binding-switcher/binding-switcher.js +183 -0
- package/dist/particles/binding-switcher/binding-switcher.js.map +1 -0
- package/dist/particles/card-summary/card-network.d.ts +17 -0
- package/dist/particles/card-summary/card-network.js +25 -0
- package/dist/particles/card-summary/card-network.js.map +1 -0
- package/dist/particles/card-summary/card-summary.d.ts +83 -0
- package/dist/particles/card-summary/card-summary.js +188 -0
- package/dist/particles/card-summary/card-summary.js.map +1 -0
- package/dist/particles/copy-text/copy-text.d.ts +28 -0
- package/dist/particles/copy-text/copy-text.js +140 -0
- package/dist/particles/copy-text/copy-text.js.map +1 -0
- package/dist/particles/document-field/document-field.d.ts +34 -5
- package/dist/particles/document-field/document-field.js +115 -19
- package/dist/particles/document-field/document-field.js.map +1 -1
- package/dist/particles/field/field.js +1 -1
- package/dist/particles/field/field.js.map +1 -1
- package/dist/particles/footer-link-group/footer-link-group.d.ts +6 -2
- package/dist/particles/footer-link-group/footer-link-group.js +18 -7
- package/dist/particles/footer-link-group/footer-link-group.js.map +1 -1
- package/dist/particles/footer-social/footer-social.d.ts +1 -1
- package/dist/particles/footer-social/footer-social.js +1 -1
- package/dist/particles/footer-social/footer-social.js.map +1 -1
- package/dist/particles/incentives/incentives.d.ts +7 -3
- package/dist/particles/incentives/incentives.js +8 -3
- package/dist/particles/incentives/incentives.js.map +1 -1
- package/dist/particles/logo/logo.d.ts +3 -2
- package/dist/particles/logo/logo.js +20 -8
- package/dist/particles/logo/logo.js.map +1 -1
- package/dist/particles/navigation-link/navigation-link.d.ts +2 -3
- package/dist/particles/navigation-link/navigation-link.js +4 -4
- package/dist/particles/navigation-link/navigation-link.js.map +1 -1
- package/dist/particles/navigation-link-list/navigation-link-list.d.ts +6 -2
- package/dist/particles/navigation-link-list/navigation-link-list.js +18 -7
- package/dist/particles/navigation-link-list/navigation-link-list.js.map +1 -1
- package/dist/particles/order-details-back/order-details-back.d.ts +28 -0
- package/dist/particles/order-details-back/order-details-back.js +52 -0
- package/dist/particles/order-details-back/order-details-back.js.map +1 -0
- package/dist/particles/order-status-badge/order-status-badge.d.ts +19 -0
- package/dist/particles/order-status-badge/order-status-badge.js +50 -0
- package/dist/particles/order-status-badge/order-status-badge.js.map +1 -0
- package/dist/particles/payment-methods/payment-methods.d.ts +1 -1
- package/dist/particles/payment-methods/payment-methods.js +1 -1
- package/dist/particles/payment-methods/payment-methods.js.map +1 -1
- package/dist/particles/phone-field/phone-field.js +2 -2
- package/dist/particles/phone-field/phone-field.js.map +1 -1
- package/dist/particles/select/select.js +6 -6
- package/dist/particles/select/select.js.map +1 -1
- package/dist/particles/toast/toast.d.ts +21 -7
- package/dist/particles/toast/toast.js +76 -8
- package/dist/particles/toast/toast.js.map +1 -1
- package/dist/schema.graphql +1376 -126
- package/dist/sdk/actions/address-action-provider.d.ts +16 -0
- package/dist/sdk/actions/address-action-provider.js +20 -0
- package/dist/sdk/actions/address-action-provider.js.map +1 -0
- package/dist/sdk/actions/analytics-action-provider.js +1 -1
- package/dist/sdk/actions/index.d.ts +5 -1
- package/dist/sdk/actions/index.js +5 -1
- package/dist/sdk/actions/locale-action-provider.d.ts +16 -0
- package/dist/sdk/actions/locale-action-provider.js +20 -0
- package/dist/sdk/actions/locale-action-provider.js.map +1 -0
- package/dist/sdk/actions/order-action-provider.d.ts +12 -0
- package/dist/sdk/actions/order-action-provider.js +16 -0
- package/dist/sdk/actions/order-action-provider.js.map +1 -0
- package/dist/sdk/actions/saved-card-action-provider.d.ts +12 -0
- package/dist/sdk/actions/saved-card-action-provider.js +16 -0
- package/dist/sdk/actions/saved-card-action-provider.js.map +1 -0
- package/dist/sdk/actions/types.d.ts +10 -2
- package/dist/sdk/address/address-fields.js +38 -0
- package/dist/sdk/address/address-fields.js.map +1 -0
- package/dist/sdk/address/checkout-readiness.js +17 -0
- package/dist/sdk/address/checkout-readiness.js.map +1 -0
- package/dist/sdk/address/constants.js +60 -0
- package/dist/sdk/address/constants.js.map +1 -0
- package/dist/sdk/address/country-display.js +19 -0
- package/dist/sdk/address/country-display.js.map +1 -0
- package/dist/sdk/address/country-rules.js +30 -0
- package/dist/sdk/address/country-rules.js.map +1 -0
- package/dist/sdk/address/format-address.js +18 -0
- package/dist/sdk/address/format-address.js.map +1 -0
- package/dist/sdk/address/iso-countries.js +262 -0
- package/dist/sdk/address/iso-countries.js.map +1 -0
- package/dist/sdk/address/layouts.js +56 -0
- package/dist/sdk/address/layouts.js.map +1 -0
- package/dist/sdk/address/messages.js +97 -0
- package/dist/sdk/address/messages.js.map +1 -0
- package/dist/sdk/address/operations.d.ts +54 -0
- package/dist/sdk/address/operations.js +83 -0
- package/dist/sdk/address/operations.js.map +1 -0
- package/dist/sdk/address/postal-code-lookup-operations.js +23 -0
- package/dist/sdk/address/postal-code-lookup-operations.js.map +1 -0
- package/dist/sdk/address/postal-code.js +11 -0
- package/dist/sdk/address/postal-code.js.map +1 -0
- package/dist/sdk/address/schema.js +14 -0
- package/dist/sdk/address/schema.js.map +1 -0
- package/dist/sdk/address/server-fields.js +25 -0
- package/dist/sdk/address/server-fields.js.map +1 -0
- package/dist/sdk/address/switch-country.js +57 -0
- package/dist/sdk/address/switch-country.js.map +1 -0
- package/dist/sdk/address/types.d.ts +26 -0
- package/dist/sdk/address/use-address-actions.d.ts +29 -0
- package/dist/sdk/address/use-address-actions.js +247 -0
- package/dist/sdk/address/use-address-actions.js.map +1 -0
- package/dist/sdk/address/use-address-by-postal-code.js +57 -0
- package/dist/sdk/address/use-address-by-postal-code.js.map +1 -0
- package/dist/sdk/address/validate-address.js +62 -0
- package/dist/sdk/address/validate-address.js.map +1 -0
- package/dist/sdk/cache/storefront-cache.js +30 -4
- package/dist/sdk/cache/storefront-cache.js.map +1 -1
- package/dist/sdk/cart/operations.d.ts +2 -1
- package/dist/sdk/cart/operations.js +55 -1
- package/dist/sdk/cart/operations.js.map +1 -1
- package/dist/sdk/cart/optimistic.d.ts +30 -7
- package/dist/sdk/cart/optimistic.js +78 -41
- package/dist/sdk/cart/optimistic.js.map +1 -1
- package/dist/sdk/cart/use-cart-actions.d.ts +7 -0
- package/dist/sdk/cart/use-cart-actions.js +61 -15
- package/dist/sdk/cart/use-cart-actions.js.map +1 -1
- package/dist/sdk/cart/use-cart-sync-sales-channel.js +70 -0
- package/dist/sdk/cart/use-cart-sync-sales-channel.js.map +1 -0
- package/dist/sdk/client/fetch-page-data.d.ts +11 -0
- package/dist/sdk/client/fetch-page-data.js +12 -1
- package/dist/sdk/client/fetch-page-data.js.map +1 -1
- package/dist/sdk/content/create-content-runtime.js +1 -8
- package/dist/sdk/content/create-content-runtime.js.map +1 -1
- package/dist/sdk/data/failed-fields.js +23 -0
- package/dist/sdk/data/failed-fields.js.map +1 -0
- package/dist/sdk/data/index.js +2 -2
- package/dist/sdk/data/page-reactive-data-root.d.ts +45 -7
- package/dist/sdk/data/page-reactive-data-root.js +88 -12
- package/dist/sdk/data/page-reactive-data-root.js.map +1 -1
- package/dist/sdk/data/reactive-list-item-data-provider.js +2 -2
- package/dist/sdk/generated/fragment-types.js +2 -0
- package/dist/sdk/generated/fragment-types.js.map +1 -1
- package/dist/sdk/generated/gql.js +17 -11
- package/dist/sdk/generated/gql.js.map +1 -1
- package/dist/sdk/generated/graphql.d.ts +185 -46
- package/dist/sdk/generated/graphql.js +2587 -155
- package/dist/sdk/generated/graphql.js.map +1 -1
- package/dist/sdk/i18n/messages/en-US.js +157 -1
- package/dist/sdk/i18n/messages/en-US.json +157 -1
- package/dist/sdk/i18n/messages/en-US.json.d.ts +156 -0
- package/dist/sdk/i18n/messages/es-ES.js +157 -1
- package/dist/sdk/i18n/messages/es-ES.json +157 -1
- package/dist/sdk/i18n/messages/pt-BR.js +157 -1
- package/dist/sdk/i18n/messages/pt-BR.json +157 -1
- package/dist/sdk/i18n/provider.js +1 -1
- package/dist/sdk/i18n/provider.js.map +1 -1
- package/dist/sdk/locale/binding-switch-provider.d.ts +13 -0
- package/dist/sdk/locale/binding-switch-provider.js +20 -0
- package/dist/sdk/locale/binding-switch-provider.js.map +1 -0
- package/dist/sdk/locale/use-locale-actions.d.ts +16 -0
- package/dist/sdk/locale/use-locale-actions.js +70 -0
- package/dist/sdk/locale/use-locale-actions.js.map +1 -0
- package/dist/sdk/navigation/binding-switch.d.ts +39 -0
- package/dist/sdk/navigation/binding-switch.js +129 -0
- package/dist/sdk/navigation/binding-switch.js.map +1 -0
- package/dist/sdk/navigation/current-page.js +30 -0
- package/dist/sdk/navigation/current-page.js.map +1 -0
- package/dist/sdk/navigation/decode-route-params.d.ts +11 -0
- package/dist/sdk/navigation/decode-route-params.js +32 -0
- package/dist/sdk/navigation/decode-route-params.js.map +1 -0
- package/dist/sdk/navigation/not-found-log.d.ts +28 -0
- package/dist/sdk/navigation/not-found-log.js +133 -0
- package/dist/sdk/navigation/not-found-log.js.map +1 -0
- package/dist/sdk/navigation/path.js +25 -0
- package/dist/sdk/navigation/path.js.map +1 -0
- package/dist/sdk/navigation/redirect.d.ts +11 -0
- package/dist/sdk/navigation/redirect.js +22 -0
- package/dist/sdk/navigation/redirect.js.map +1 -0
- package/dist/sdk/navigation/report.js +70 -0
- package/dist/sdk/navigation/report.js.map +1 -0
- package/dist/sdk/navigation/resolve-storefront-href.d.ts +12 -0
- package/dist/sdk/navigation/resolve-storefront-href.js +214 -0
- package/dist/sdk/navigation/resolve-storefront-href.js.map +1 -0
- package/dist/sdk/navigation/route-identity-provider.d.ts +11 -0
- package/dist/sdk/navigation/route-identity-provider.js +20 -0
- package/dist/sdk/navigation/route-identity-provider.js.map +1 -0
- package/dist/sdk/navigation/route-map-provider.d.ts +19 -0
- package/dist/sdk/navigation/route-map-provider.js +29 -0
- package/dist/sdk/navigation/route-map-provider.js.map +1 -0
- package/dist/sdk/navigation/storefront-link.d.ts +16 -0
- package/dist/sdk/navigation/storefront-link.js +66 -0
- package/dist/sdk/navigation/storefront-link.js.map +1 -0
- package/dist/sdk/navigation/types.d.ts +45 -0
- package/dist/sdk/navigation/use-storefront-navigation.d.ts +26 -0
- package/dist/sdk/navigation/use-storefront-navigation.js +73 -0
- package/dist/sdk/navigation/use-storefront-navigation.js.map +1 -0
- package/dist/sdk/navigation/use-storefront-route.d.ts +26 -0
- package/dist/sdk/navigation/use-storefront-route.js +87 -0
- package/dist/sdk/navigation/use-storefront-route.js.map +1 -0
- package/dist/sdk/navigation/use-storefront-search-params.d.ts +11 -0
- package/dist/sdk/navigation/use-storefront-search-params.js +16 -0
- package/dist/sdk/navigation/use-storefront-search-params.js.map +1 -0
- package/dist/sdk/orders/completion-badge.d.ts +8 -0
- package/dist/sdk/orders/completion-badge.js +47 -0
- package/dist/sdk/orders/completion-badge.js.map +1 -0
- package/dist/sdk/orders/order-operations.d.ts +19 -0
- package/dist/sdk/orders/order-operations.js +21 -0
- package/dist/sdk/orders/order-operations.js.map +1 -0
- package/dist/sdk/orders/use-order-actions.d.ts +23 -0
- package/dist/sdk/orders/use-order-actions.js +62 -0
- package/dist/sdk/orders/use-order-actions.js.map +1 -0
- package/dist/sdk/payment/gateway-origin.js +26 -13
- package/dist/sdk/payment/gateway-origin.js.map +1 -1
- package/dist/sdk/payment/gateway.d.ts +14 -2
- package/dist/sdk/payment/gateway.js +32 -14
- package/dist/sdk/payment/gateway.js.map +1 -1
- package/dist/sdk/payment/operations.js +11 -0
- package/dist/sdk/payment/operations.js.map +1 -1
- package/dist/sdk/payment/submission-registry.d.ts +2 -1
- package/dist/sdk/payment/submission-registry.js +12 -8
- package/dist/sdk/payment/submission-registry.js.map +1 -1
- package/dist/sdk/payment/use-payment-actions.d.ts +5 -3
- package/dist/sdk/payment/use-payment-actions.js +5 -2
- package/dist/sdk/payment/use-payment-actions.js.map +1 -1
- package/dist/sdk/payment/use-place-order.d.ts +6 -3
- package/dist/sdk/payment/use-place-order.js +333 -143
- package/dist/sdk/payment/use-place-order.js.map +1 -1
- package/dist/sdk/saved-cards/operations.d.ts +16 -0
- package/dist/sdk/saved-cards/operations.js +41 -0
- package/dist/sdk/saved-cards/operations.js.map +1 -0
- package/dist/sdk/saved-cards/use-saved-card-actions.d.ts +26 -0
- package/dist/sdk/saved-cards/use-saved-card-actions.js +86 -0
- package/dist/sdk/saved-cards/use-saved-card-actions.js.map +1 -0
- package/dist/sdk/seo/page-alternates.d.ts +57 -0
- package/dist/sdk/seo/page-alternates.js +127 -0
- package/dist/sdk/seo/page-alternates.js.map +1 -0
- package/dist/sdk/shipping/shipping-operations.d.ts +1 -1
- package/dist/sdk/shipping/shipping-operations.js +13 -0
- package/dist/sdk/shipping/shipping-operations.js.map +1 -1
- package/dist/sdk/state/cart.d.ts +9 -2
- package/dist/sdk/state/cart.js +9 -2
- package/dist/sdk/state/cart.js.map +1 -1
- package/dist/utils/own-value.js +19 -0
- package/dist/utils/own-value.js.map +1 -0
- package/dist/utils/safe-href.d.ts +4 -4
- package/dist/utils/safe-href.js +31 -22
- package/dist/utils/safe-href.js.map +1 -1
- package/package.json +5 -1
- package/skills/storefront-asset/SKILL.md +111 -0
- package/skills/storefront-asset/references/api-side.md +153 -0
- package/skills/storefront-asset/references/findings.md +40 -0
- package/skills/storefront-asset/references/ui-side.md +94 -0
- package/src/styles/tailwind.css +28 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storefront-cache.js","names":[],"sources":["../../../src/sdk/cache/storefront-cache.ts"],"sourcesContent":["import { InMemoryCache, type InMemoryCacheConfig, type TypePolicies } from '@apollo/client';\nimport { possibleTypes } from '../generated/fragment-types.js';\n\n/**\n * Per-entity normalization and field-merge rules for the Storefront cache.\n *\n *
|
|
1
|
+
{"version":3,"file":"storefront-cache.js","names":[],"sources":["../../../src/sdk/cache/storefront-cache.ts"],"sourcesContent":["import { InMemoryCache, type InMemoryCacheConfig, type TypePolicies } from '@apollo/client';\nimport { possibleTypes } from '../generated/fragment-types.js';\n\n/**\n * Per-entity normalization and field-merge rules for the Storefront cache.\n *\n * The cart and the order share three types whose ids neither can scope\n * (docs/features/order-placed/rfc.md, 3.4): a totalizer's id is its category\n * (\"Items\"), which the cart's totalizer line selects by; an address's id is the\n * saved address itself, masked on the order and not on the cart; and a\n * customization's id is the assembly (\"Engraving\"), which two lines of one cart\n * already share. Normalized, one record would overwrite the other, so each is\n * stored inside the record that holds it, and replaced on every write: safe\n * while every fragment selects the same subfields of each.\n *\n * The lists that hold them are the server's whole answer, so each write\n * replaces the list (`merge: false`). Apollo does the same by default, but warns\n * that data may be lost whenever such a list shrinks, as when a discount line\n * leaves the cart's totalizers; a merge by id would keep that stale line.\n *\n * Other domain entries arrive with the particles that need them — see\n * docs/storefront-core/reference-free-particle-model.md § Typed documents and the shared cache.\n */\nconst replaceList = { merge: false } as const;\n\nexport const typePolicies: TypePolicies = {\n CartTotalizer: { keyFields: false },\n Address: { keyFields: false },\n CartItemCustomization: { keyFields: false },\n Cart: { fields: { totalizers: replaceList } },\n CartItem: { fields: { customizations: replaceList } },\n CartItemComposition: { fields: { customizations: replaceList } },\n Shipping: { fields: { savedAddresses: replaceList } },\n Order: { fields: { totals: replaceList } },\n SellerOrder: { fields: { totals: replaceList } },\n OrderItem: { fields: { customizations: replaceList } },\n // A card network's id is the platform's payment-system id and is empty when a saved card has none,\n // so two networks would collide on one entry. Each stays embedded in its own card.\n CardNetwork: { keyFields: false },\n};\n\nexport { possibleTypes };\n\n/**\n * The single source of truth for InMemoryCache configuration. Both the\n * server-side `createClient` and the client-side `StorefrontProvider`\n * consume this so SSR and CSR normalize entities identically.\n */\nexport function getCacheConfig(): InMemoryCacheConfig {\n return {\n typePolicies,\n possibleTypes,\n };\n}\n\n/**\n * The only place an `InMemoryCache` is constructed on the server path.\n * The client-side provider builds its cache from `getCacheConfig()` so the\n * config is shared verbatim without coupling to a specific InMemoryCache\n * subclass (the Next.js integration ships its own SSR-aware variant).\n */\nexport function buildCache(): InMemoryCache {\n return new InMemoryCache(getCacheConfig());\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,cAAc,EAAE,OAAO,MAAM;AAEnC,MAAa,eAA6B;CACxC,eAAe,EAAE,WAAW,MAAM;CAClC,SAAS,EAAE,WAAW,MAAM;CAC5B,uBAAuB,EAAE,WAAW,MAAM;CAC1C,MAAM,EAAE,QAAQ,EAAE,YAAY,YAAY,EAAE;CAC5C,UAAU,EAAE,QAAQ,EAAE,gBAAgB,YAAY,EAAE;CACpD,qBAAqB,EAAE,QAAQ,EAAE,gBAAgB,YAAY,EAAE;CAC/D,UAAU,EAAE,QAAQ,EAAE,gBAAgB,YAAY,EAAE;CACpD,OAAO,EAAE,QAAQ,EAAE,QAAQ,YAAY,EAAE;CACzC,aAAa,EAAE,QAAQ,EAAE,QAAQ,YAAY,EAAE;CAC/C,WAAW,EAAE,QAAQ,EAAE,gBAAgB,YAAY,EAAE;CAGrD,aAAa,EAAE,WAAW,MAAM;AAClC;;;;;;AASA,SAAgB,iBAAsC;CACpD,OAAO;EACL;EACA;CACF;AACF;;;;;;;AAQA,SAAgB,aAA4B;CAC1C,OAAO,IAAI,cAAc,eAAe,CAAC;AAC3C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CartFragmentFragment, CartItemFragmentFragment, CartItemQuantityDecreaseMutation, CartItemQuantityIncreaseMutation, CartItemRemoveMutation, MoneyFragmentFragment } from "../generated/graphql.js";
|
|
1
|
+
import { CartFragmentFragment, CartFreeShippingProgressFragmentFragment, CartItemFragmentFragment, CartItemQuantityDecreaseMutation, CartItemQuantityIncreaseMutation, CartItemRemoveMutation, MoneyFragmentFragment } from "../generated/graphql.js";
|
|
2
2
|
import "./operations.js";
|
|
3
3
|
import { TypedDocumentNode } from "@apollo/client";
|
|
4
4
|
//#region src/sdk/cart/operations.d.ts
|
|
@@ -20,6 +20,7 @@ export type Money = MoneyFragmentFragment;
|
|
|
20
20
|
export type CartItemEntity = CartItemFragmentFragment;
|
|
21
21
|
export type CartEntity = CartFragmentFragment;
|
|
22
22
|
export type CartTotalizer = CartFragmentFragment['totalizers'][number];
|
|
23
|
+
export type CartFreeShippingProgress = CartFreeShippingProgressFragmentFragment['freeShippingProgress'];
|
|
23
24
|
export type CartUserError = Readonly<{
|
|
24
25
|
code: string;
|
|
25
26
|
message: string;
|
|
@@ -10,6 +10,7 @@ graphql(`
|
|
|
10
10
|
fragment CartItemFragment on CartItem {
|
|
11
11
|
__typename
|
|
12
12
|
id
|
|
13
|
+
lineId
|
|
13
14
|
quantity
|
|
14
15
|
price {
|
|
15
16
|
...MoneyFragment
|
|
@@ -87,6 +88,36 @@ const CartFragment = graphql(`
|
|
|
87
88
|
code
|
|
88
89
|
isUnmatchedCondition
|
|
89
90
|
}
|
|
91
|
+
discounts {
|
|
92
|
+
name
|
|
93
|
+
value {
|
|
94
|
+
...MoneyFragment
|
|
95
|
+
}
|
|
96
|
+
kind
|
|
97
|
+
}
|
|
98
|
+
salesChannelMismatch {
|
|
99
|
+
cartSalesChannel
|
|
100
|
+
activeSalesChannel
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
`);
|
|
104
|
+
/**
|
|
105
|
+
* The free-shipping progress slice of a cart. The four line writes and the coupon removal spread it, and
|
|
106
|
+
* the shipping address update selects it inline. On the coupon removal the server answers it with an
|
|
107
|
+
* extra order-form read; on the address update it costs nothing upstream. It stays out of `CartFragment`
|
|
108
|
+
* (which every cart write and the page read of the cart share).
|
|
109
|
+
*/
|
|
110
|
+
const CartFreeShippingProgressFragment = graphql(`
|
|
111
|
+
fragment CartFreeShippingProgressFragment on Cart {
|
|
112
|
+
freeShippingProgress {
|
|
113
|
+
threshold {
|
|
114
|
+
...MoneyFragment
|
|
115
|
+
}
|
|
116
|
+
remaining {
|
|
117
|
+
...MoneyFragment
|
|
118
|
+
}
|
|
119
|
+
qualified
|
|
120
|
+
}
|
|
90
121
|
}
|
|
91
122
|
`);
|
|
92
123
|
const CART_ITEM_ADD = graphql(`
|
|
@@ -109,6 +140,7 @@ const CART_ITEM_REMOVE = graphql(`
|
|
|
109
140
|
__typename
|
|
110
141
|
cart {
|
|
111
142
|
...CartFragment
|
|
143
|
+
...CartFreeShippingProgressFragment
|
|
112
144
|
}
|
|
113
145
|
userErrors {
|
|
114
146
|
code
|
|
@@ -123,6 +155,7 @@ const CART_ITEMS_REMOVE = graphql(`
|
|
|
123
155
|
__typename
|
|
124
156
|
cart {
|
|
125
157
|
...CartFragment
|
|
158
|
+
...CartFreeShippingProgressFragment
|
|
126
159
|
}
|
|
127
160
|
userErrors {
|
|
128
161
|
code
|
|
@@ -137,6 +170,7 @@ const CART_ITEM_QUANTITY_INCREASE = graphql(`
|
|
|
137
170
|
__typename
|
|
138
171
|
cart {
|
|
139
172
|
...CartFragment
|
|
173
|
+
...CartFreeShippingProgressFragment
|
|
140
174
|
}
|
|
141
175
|
userErrors {
|
|
142
176
|
code
|
|
@@ -151,6 +185,7 @@ const CART_ITEM_QUANTITY_DECREASE = graphql(`
|
|
|
151
185
|
__typename
|
|
152
186
|
cart {
|
|
153
187
|
...CartFragment
|
|
188
|
+
...CartFreeShippingProgressFragment
|
|
154
189
|
}
|
|
155
190
|
userErrors {
|
|
156
191
|
code
|
|
@@ -179,6 +214,7 @@ const CART_COUPON_REMOVE = graphql(`
|
|
|
179
214
|
__typename
|
|
180
215
|
cart {
|
|
181
216
|
...CartFragment
|
|
217
|
+
...CartFreeShippingProgressFragment
|
|
182
218
|
}
|
|
183
219
|
userErrors {
|
|
184
220
|
code
|
|
@@ -209,7 +245,25 @@ const CART_VALIDATE = graphql(`
|
|
|
209
245
|
}
|
|
210
246
|
}
|
|
211
247
|
`);
|
|
248
|
+
/**
|
|
249
|
+
* Move the active cart onto the request's sales channel and reconcile its locale. No variables —
|
|
250
|
+
* the channel is the request's. No optimistic response: Checkout decides which lines remain.
|
|
251
|
+
*/
|
|
252
|
+
const CART_SALES_CHANNEL_SYNC = graphql(`
|
|
253
|
+
mutation CartSalesChannelSync {
|
|
254
|
+
cartSalesChannelSync {
|
|
255
|
+
__typename
|
|
256
|
+
cart {
|
|
257
|
+
...CartFragment
|
|
258
|
+
}
|
|
259
|
+
userErrors {
|
|
260
|
+
code
|
|
261
|
+
message
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
`);
|
|
212
266
|
//#endregion
|
|
213
|
-
export { CART_COUPON_APPLY, CART_COUPON_REMOVE, CART_ITEMS_REMOVE, CART_ITEM_ADD, CART_ITEM_QUANTITY_DECREASE, CART_ITEM_QUANTITY_INCREASE, CART_ITEM_REMOVE, CART_VALIDATE, CartFragment };
|
|
267
|
+
export { CART_COUPON_APPLY, CART_COUPON_REMOVE, CART_ITEMS_REMOVE, CART_ITEM_ADD, CART_ITEM_QUANTITY_DECREASE, CART_ITEM_QUANTITY_INCREASE, CART_ITEM_REMOVE, CART_SALES_CHANNEL_SYNC, CART_VALIDATE, CartFragment, CartFreeShippingProgressFragment };
|
|
214
268
|
|
|
215
269
|
//# sourceMappingURL=operations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.js","names":[],"sources":["../../../src/sdk/cart/operations.ts"],"sourcesContent":["import type { TypedDocumentNode } from '@apollo/client';\nimport { graphql } from '../generated/gql.js';\nimport type {\n CartCouponApplyMutation,\n CartCouponApplyMutationVariables,\n CartCouponRemoveMutation,\n CartCouponRemoveMutationVariables,\n CartFragmentFragment,\n CartItemAddMutation,\n CartItemAddMutationVariables,\n CartItemFragmentFragment,\n CartItemQuantityDecreaseMutation,\n CartItemQuantityDecreaseMutationVariables,\n CartItemQuantityIncreaseMutation,\n CartItemQuantityIncreaseMutationVariables,\n CartItemRemoveMutation,\n CartItemRemoveMutationVariables,\n CartItemsRemoveMutation,\n CartItemsRemoveMutationVariables,\n CartValidateMutation,\n CartValidateMutationVariables,\n MoneyFragmentFragment,\n} from '../generated/graphql.js';\n\n/**\n * Cart-related GraphQL operations and shared fragments (T6 / mutation-contract.md (archived at the specs-archive tag)).\n *\n * The `CartFragment` is the canonical Cart selection set: every mutation operation spreads it so\n * the cache normalisation reaches every reactive subscriber (CartTotal, CartCount, CartItems, …)\n * through a single response. The contract regression test (`contract.test.ts`) parses these\n * documents and asserts the spread is present — see mutation-contract.md (archived at the specs-archive tag).\n *\n * T7 ([Typed documents and the shared cache][T7]) routes the domain types and the operation factory\n * through @graphql-codegen. Public type names (`CartEntity`, `CartItemEntity`, `Money`, payload\n * + input aliases) are preserved as re-exports / aliases so consumer call sites do not change.\n *\n * [T7]: ../../../../../docs/storefront-core/reference-free-particle-model.md#typed-documents-and-the-shared-cache\n */\n\n// ---------------------------------------------------------------------------\n// Domain type aliases — re-exports from codegen artifacts (T7)\n// ---------------------------------------------------------------------------\n\nexport type Money = MoneyFragmentFragment;\nexport type CartItemEntity = CartItemFragmentFragment;\nexport type CartEntity = CartFragmentFragment;\nexport type CartTotalizer = CartFragmentFragment['totalizers'][number];\nexport type CartMessage = CartFragmentFragment['messages'][number];\nexport type AppliedCoupon = CartFragmentFragment['appliedCoupons'][number];\n\nexport type CartUserError = Readonly<{ code: string; message: string }>;\n\n// ---------------------------------------------------------------------------\n// Mutation input types — direct re-exports from codegen\n// ---------------------------------------------------------------------------\n\nexport type {\n CartCouponApplyInput,\n CartCouponRemoveInput,\n CartItemAddInput,\n CartItemQuantityDecreaseInput,\n CartItemQuantityIncreaseInput,\n CartItemRemoveInput,\n CartItemsRemoveInput,\n} from '../generated/graphql.js';\n\n// ---------------------------------------------------------------------------\n// Mutation payload types — derived from operation result types\n// ---------------------------------------------------------------------------\n\nexport type CartItemAddPayload = CartItemAddMutation['cartItemAdd'];\nexport type CartItemRemovePayload = CartItemRemoveMutation['cartItemRemove'];\nexport type CartItemsRemovePayload = CartItemsRemoveMutation['cartItemsRemove'];\nexport type CartItemQuantityIncreasePayload = CartItemQuantityIncreaseMutation['cartItemQuantityIncrease'];\nexport type CartItemQuantityDecreasePayload = CartItemQuantityDecreaseMutation['cartItemQuantityDecrease'];\nexport type CartCouponApplyPayload = CartCouponApplyMutation['cartCouponApply'];\nexport type CartCouponRemovePayload = CartCouponRemoveMutation['cartCouponRemove'];\nexport type CartValidatePayload = CartValidateMutation['cartValidate'];\n\n// ---------------------------------------------------------------------------\n// Shared fragments — authored via the codegen `graphql()` factory so codegen can scan and type\n// every operation that spreads them.\n// ---------------------------------------------------------------------------\n\nexport const MoneyFragment: TypedDocumentNode<MoneyFragmentFragment, never> = graphql(`\n fragment MoneyFragment on Money {\n __typename\n amount\n currencyCode\n }\n`);\n\nexport const CartItemFragment: TypedDocumentNode<CartItemFragmentFragment, never> = graphql(`\n fragment CartItemFragment on CartItem {\n __typename\n id\n quantity\n price {\n ...MoneyFragment\n }\n listPrice {\n ...MoneyFragment\n }\n sellingPrice {\n ...MoneyFragment\n }\n gift\n ownTotal {\n ...MoneyFragment\n }\n total {\n ...MoneyFragment\n }\n variant {\n __typename\n variantId\n sku\n name\n image {\n url\n altText\n }\n availability\n }\n product {\n __typename\n productId\n title\n detailUrl\n categories {\n categoryId\n name\n }\n brand {\n brandId\n name\n }\n }\n }\n`);\n\n/**\n * Canonical Cart selection set. Every cart mutation MUST spread this fragment so the cache\n * receives the entity slices that all subscribers depend on (id + items + totalizers + total +\n * messages). The regression test in contract.test.ts enforces this.\n */\nexport const CartFragment: TypedDocumentNode<CartFragmentFragment, never> = graphql(`\n fragment CartFragment on Cart {\n __typename\n id\n items {\n ...CartItemFragment\n }\n totalizers {\n __typename\n id\n name\n value {\n ...MoneyFragment\n }\n }\n total {\n ...MoneyFragment\n }\n messages {\n __typename\n code\n text\n status\n }\n appliedCoupons {\n code\n isUnmatchedCondition\n }\n }\n`);\n\n// ---------------------------------------------------------------------------\n// Mutation operations — authored via `graphql()`, typed via the codegen-derived\n// TypedDocumentNode generic so Apollo's `useMutation` infers TData / TVariables correctly.\n// ---------------------------------------------------------------------------\n\nexport const CART_ITEM_ADD: TypedDocumentNode<CartItemAddMutation, CartItemAddMutationVariables> = graphql(`\n mutation CartItemAdd($input: CartItemAddInput!) {\n cartItemAdd(input: $input) {\n __typename\n cart {\n ...CartFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\nexport const CART_ITEM_REMOVE: TypedDocumentNode<CartItemRemoveMutation, CartItemRemoveMutationVariables> = graphql(`\n mutation CartItemRemove($input: CartItemRemoveInput!) {\n cartItemRemove(input: $input) {\n __typename\n cart {\n ...CartFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\nexport const CART_ITEMS_REMOVE: TypedDocumentNode<CartItemsRemoveMutation, CartItemsRemoveMutationVariables> = graphql(`\n mutation CartItemsRemove($input: CartItemsRemoveInput!) {\n cartItemsRemove(input: $input) {\n __typename\n cart {\n ...CartFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\nexport const CART_ITEM_QUANTITY_INCREASE: TypedDocumentNode<\n CartItemQuantityIncreaseMutation,\n CartItemQuantityIncreaseMutationVariables\n> = graphql(`\n mutation CartItemQuantityIncrease($input: CartItemQuantityIncreaseInput!) {\n cartItemQuantityIncrease(input: $input) {\n __typename\n cart {\n ...CartFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\nexport const CART_ITEM_QUANTITY_DECREASE: TypedDocumentNode<\n CartItemQuantityDecreaseMutation,\n CartItemQuantityDecreaseMutationVariables\n> = graphql(`\n mutation CartItemQuantityDecrease($input: CartItemQuantityDecreaseInput!) {\n cartItemQuantityDecrease(input: $input) {\n __typename\n cart {\n ...CartFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\nexport const CART_COUPON_APPLY: TypedDocumentNode<CartCouponApplyMutation, CartCouponApplyMutationVariables> = graphql(`\n mutation CartCouponApply($input: CartCouponApplyInput!) {\n cartCouponApply(input: $input) {\n __typename\n cart {\n ...CartFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\nexport const CART_COUPON_REMOVE: TypedDocumentNode<CartCouponRemoveMutation, CartCouponRemoveMutationVariables> =\n graphql(`\n mutation CartCouponRemove($input: CartCouponRemoveInput!) {\n cartCouponRemove(input: $input) {\n __typename\n cart {\n ...CartFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\n/**\n * Re-check the active cart against the platform and adopt corrected availability. Read-only upstream\n * (docs/storefront-api-core/CONTEXT.md § Language, Cart Validation): the payload is the cart with each line's\n * `variant.availability` refreshed, shaped like every other cart mutation so the correction lands in\n * the normalized cache. Takes no arguments — the cart resolves from the request context. Spreading\n * `CartFragment` is what makes the guard, the per-line alert, and the badge re-render as subscribers,\n * so T13 needs no fragment or codegen change beyond registering this document.\n */\nexport const CART_VALIDATE: TypedDocumentNode<CartValidateMutation, CartValidateMutationVariables> = graphql(`\n mutation CartValidate {\n cartValidate {\n __typename\n cart {\n ...CartFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\n/**\n * Canonical list of cart mutation documents. Used by the contract regression test to iterate\n * over every shipped operation without hard-coding names.\n */\nexport const CART_MUTATIONS = [\n { name: 'CartItemAdd', document: CART_ITEM_ADD },\n { name: 'CartItemRemove', document: CART_ITEM_REMOVE },\n { name: 'CartItemsRemove', document: CART_ITEMS_REMOVE },\n { name: 'CartItemQuantityIncrease', document: CART_ITEM_QUANTITY_INCREASE },\n { name: 'CartItemQuantityDecrease', document: CART_ITEM_QUANTITY_DECREASE },\n { name: 'CartCouponApply', document: CART_COUPON_APPLY },\n { name: 'CartCouponRemove', document: CART_COUPON_REMOVE },\n { name: 'CartValidate', document: CART_VALIDATE },\n] as const;\n"],"mappings":";AAoF8E,QAAQ;;;;;;CAMrF;AAEmF,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+C3F;;;;;;AAOD,MAAa,eAA+D,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BnF;AAOD,MAAa,gBAAsF,QAAQ;;;;;;;;;;;;;CAa1G;AAED,MAAa,mBAA+F,QAAQ;;;;;;;;;;;;;CAanH;AAED,MAAa,oBAAkG,QAAQ;;;;;;;;;;;;;CAatH;AAED,MAAa,8BAGT,QAAQ;;;;;;;;;;;;;CAaX;AAED,MAAa,8BAGT,QAAQ;;;;;;;;;;;;;CAaX;AAED,MAAa,oBAAkG,QAAQ;;;;;;;;;;;;;CAatH;AAED,MAAa,qBACX,QAAQ;;;;;;;;;;;;;CAaT;;;;;;;;;AAUD,MAAa,gBAAwF,QAAQ;;;;;;;;;;;;;CAa5G"}
|
|
1
|
+
{"version":3,"file":"operations.js","names":[],"sources":["../../../src/sdk/cart/operations.ts"],"sourcesContent":["import type { TypedDocumentNode } from '@apollo/client';\nimport { graphql } from '../generated/gql.js';\nimport type {\n CartCouponApplyMutation,\n CartCouponApplyMutationVariables,\n CartCouponRemoveMutation,\n CartCouponRemoveMutationVariables,\n CartFragmentFragment,\n CartFreeShippingProgressFragmentFragment,\n CartItemAddMutation,\n CartItemAddMutationVariables,\n CartItemFragmentFragment,\n CartItemQuantityDecreaseMutation,\n CartItemQuantityDecreaseMutationVariables,\n CartItemQuantityIncreaseMutation,\n CartItemQuantityIncreaseMutationVariables,\n CartItemRemoveMutation,\n CartItemRemoveMutationVariables,\n CartItemsRemoveMutation,\n CartItemsRemoveMutationVariables,\n CartSalesChannelSyncMutation,\n CartSalesChannelSyncMutationVariables,\n CartValidateMutation,\n CartValidateMutationVariables,\n MoneyFragmentFragment,\n} from '../generated/graphql.js';\n\n/**\n * Cart-related GraphQL operations and shared fragments (T6 / mutation-contract.md (archived at the specs-archive tag)).\n *\n * The `CartFragment` is the canonical Cart selection set: every mutation operation spreads it so\n * the cache normalisation reaches every reactive subscriber (CartTotal, CartCount, CartItems, …)\n * through a single response. The contract regression test (`contract.test.ts`) parses these\n * documents and asserts the spread is present — see mutation-contract.md (archived at the specs-archive tag).\n *\n * T7 ([Typed documents and the shared cache][T7]) routes the domain types and the operation factory\n * through @graphql-codegen. Public type names (`CartEntity`, `CartItemEntity`, `Money`, payload\n * + input aliases) are preserved as re-exports / aliases so consumer call sites do not change.\n *\n * [T7]: ../../../../../docs/storefront-core/reference-free-particle-model.md#typed-documents-and-the-shared-cache\n */\n\n// ---------------------------------------------------------------------------\n// Domain type aliases — re-exports from codegen artifacts (T7)\n// ---------------------------------------------------------------------------\n\nexport type Money = MoneyFragmentFragment;\nexport type CartItemEntity = CartItemFragmentFragment;\nexport type CartEntity = CartFragmentFragment;\nexport type CartTotalizer = CartFragmentFragment['totalizers'][number];\nexport type CartMessage = CartFragmentFragment['messages'][number];\nexport type AppliedCoupon = CartFragmentFragment['appliedCoupons'][number];\nexport type CartDiscount = CartFragmentFragment['discounts'][number];\nexport type CartFreeShippingProgress = CartFreeShippingProgressFragmentFragment['freeShippingProgress'];\n\nexport type CartUserError = Readonly<{ code: string; message: string }>;\n\n// ---------------------------------------------------------------------------\n// Mutation input types — direct re-exports from codegen\n// ---------------------------------------------------------------------------\n\nexport type {\n CartCouponApplyInput,\n CartCouponRemoveInput,\n CartItemAddInput,\n CartItemQuantityDecreaseInput,\n CartItemQuantityIncreaseInput,\n CartItemRemoveInput,\n CartItemsRemoveInput,\n} from '../generated/graphql.js';\n\n// ---------------------------------------------------------------------------\n// Mutation payload types — derived from operation result types\n// ---------------------------------------------------------------------------\n\nexport type CartItemAddPayload = CartItemAddMutation['cartItemAdd'];\nexport type CartItemRemovePayload = CartItemRemoveMutation['cartItemRemove'];\nexport type CartItemsRemovePayload = CartItemsRemoveMutation['cartItemsRemove'];\nexport type CartItemQuantityIncreasePayload = CartItemQuantityIncreaseMutation['cartItemQuantityIncrease'];\nexport type CartItemQuantityDecreasePayload = CartItemQuantityDecreaseMutation['cartItemQuantityDecrease'];\nexport type CartCouponApplyPayload = CartCouponApplyMutation['cartCouponApply'];\nexport type CartCouponRemovePayload = CartCouponRemoveMutation['cartCouponRemove'];\nexport type CartValidatePayload = CartValidateMutation['cartValidate'];\nexport type CartSalesChannelSyncPayload = CartSalesChannelSyncMutation['cartSalesChannelSync'];\n\n// ---------------------------------------------------------------------------\n// Shared fragments — authored via the codegen `graphql()` factory so codegen can scan and type\n// every operation that spreads them.\n// ---------------------------------------------------------------------------\n\nexport const MoneyFragment: TypedDocumentNode<MoneyFragmentFragment, never> = graphql(`\n fragment MoneyFragment on Money {\n __typename\n amount\n currencyCode\n }\n`);\n\nexport const CartItemFragment: TypedDocumentNode<CartItemFragmentFragment, never> = graphql(`\n fragment CartItemFragment on CartItem {\n __typename\n id\n lineId\n quantity\n price {\n ...MoneyFragment\n }\n listPrice {\n ...MoneyFragment\n }\n sellingPrice {\n ...MoneyFragment\n }\n gift\n ownTotal {\n ...MoneyFragment\n }\n total {\n ...MoneyFragment\n }\n variant {\n __typename\n variantId\n sku\n name\n image {\n url\n altText\n }\n availability\n }\n product {\n __typename\n productId\n title\n detailUrl\n categories {\n categoryId\n name\n }\n brand {\n brandId\n name\n }\n }\n }\n`);\n\n/**\n * Canonical Cart selection set. Every cart mutation MUST spread this fragment so the cache\n * receives the entity slices that all subscribers depend on (id + items + totalizers + total +\n * messages). The regression test in contract.test.ts enforces this.\n */\nexport const CartFragment: TypedDocumentNode<CartFragmentFragment, never> = graphql(`\n fragment CartFragment on Cart {\n __typename\n id\n items {\n ...CartItemFragment\n }\n totalizers {\n __typename\n id\n name\n value {\n ...MoneyFragment\n }\n }\n total {\n ...MoneyFragment\n }\n messages {\n __typename\n code\n text\n status\n }\n appliedCoupons {\n code\n isUnmatchedCondition\n }\n discounts {\n name\n value {\n ...MoneyFragment\n }\n kind\n }\n salesChannelMismatch {\n cartSalesChannel\n activeSalesChannel\n }\n }\n`);\n\n/**\n * The free-shipping progress slice of a cart. The four line writes and the coupon removal spread it, and\n * the shipping address update selects it inline. On the coupon removal the server answers it with an\n * extra order-form read; on the address update it costs nothing upstream. It stays out of `CartFragment`\n * (which every cart write and the page read of the cart share).\n */\nexport const CartFreeShippingProgressFragment: TypedDocumentNode<CartFreeShippingProgressFragmentFragment, never> =\n graphql(`\n fragment CartFreeShippingProgressFragment on Cart {\n freeShippingProgress {\n threshold {\n ...MoneyFragment\n }\n remaining {\n ...MoneyFragment\n }\n qualified\n }\n }\n`);\n\n// ---------------------------------------------------------------------------\n// Mutation operations — authored via `graphql()`, typed via the codegen-derived\n// TypedDocumentNode generic so Apollo's `useMutation` infers TData / TVariables correctly.\n// ---------------------------------------------------------------------------\n\nexport const CART_ITEM_ADD: TypedDocumentNode<CartItemAddMutation, CartItemAddMutationVariables> = graphql(`\n mutation CartItemAdd($input: CartItemAddInput!) {\n cartItemAdd(input: $input) {\n __typename\n cart {\n ...CartFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\nexport const CART_ITEM_REMOVE: TypedDocumentNode<CartItemRemoveMutation, CartItemRemoveMutationVariables> = graphql(`\n mutation CartItemRemove($input: CartItemRemoveInput!) {\n cartItemRemove(input: $input) {\n __typename\n cart {\n ...CartFragment\n ...CartFreeShippingProgressFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\nexport const CART_ITEMS_REMOVE: TypedDocumentNode<CartItemsRemoveMutation, CartItemsRemoveMutationVariables> = graphql(`\n mutation CartItemsRemove($input: CartItemsRemoveInput!) {\n cartItemsRemove(input: $input) {\n __typename\n cart {\n ...CartFragment\n ...CartFreeShippingProgressFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\nexport const CART_ITEM_QUANTITY_INCREASE: TypedDocumentNode<\n CartItemQuantityIncreaseMutation,\n CartItemQuantityIncreaseMutationVariables\n> = graphql(`\n mutation CartItemQuantityIncrease($input: CartItemQuantityIncreaseInput!) {\n cartItemQuantityIncrease(input: $input) {\n __typename\n cart {\n ...CartFragment\n ...CartFreeShippingProgressFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\nexport const CART_ITEM_QUANTITY_DECREASE: TypedDocumentNode<\n CartItemQuantityDecreaseMutation,\n CartItemQuantityDecreaseMutationVariables\n> = graphql(`\n mutation CartItemQuantityDecrease($input: CartItemQuantityDecreaseInput!) {\n cartItemQuantityDecrease(input: $input) {\n __typename\n cart {\n ...CartFragment\n ...CartFreeShippingProgressFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\nexport const CART_COUPON_APPLY: TypedDocumentNode<CartCouponApplyMutation, CartCouponApplyMutationVariables> = graphql(`\n mutation CartCouponApply($input: CartCouponApplyInput!) {\n cartCouponApply(input: $input) {\n __typename\n cart {\n ...CartFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\nexport const CART_COUPON_REMOVE: TypedDocumentNode<CartCouponRemoveMutation, CartCouponRemoveMutationVariables> =\n graphql(`\n mutation CartCouponRemove($input: CartCouponRemoveInput!) {\n cartCouponRemove(input: $input) {\n __typename\n cart {\n ...CartFragment\n ...CartFreeShippingProgressFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\n/**\n * Re-check the active cart against the platform and adopt corrected availability. Read-only upstream\n * (docs/storefront-api-core/CONTEXT.md § Language, Cart Validation): the payload is the cart with each line's\n * `variant.availability` refreshed, shaped like every other cart mutation so the correction lands in\n * the normalized cache. Takes no arguments — the cart resolves from the request context. Spreading\n * `CartFragment` is what makes the guard, the per-line alert, and the badge re-render as subscribers,\n * so T13 needs no fragment or codegen change beyond registering this document.\n */\nexport const CART_VALIDATE: TypedDocumentNode<CartValidateMutation, CartValidateMutationVariables> = graphql(`\n mutation CartValidate {\n cartValidate {\n __typename\n cart {\n ...CartFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\n/**\n * Move the active cart onto the request's sales channel and reconcile its locale. No variables —\n * the channel is the request's. No optimistic response: Checkout decides which lines remain.\n */\nexport const CART_SALES_CHANNEL_SYNC: TypedDocumentNode<\n CartSalesChannelSyncMutation,\n CartSalesChannelSyncMutationVariables\n> = graphql(`\n mutation CartSalesChannelSync {\n cartSalesChannelSync {\n __typename\n cart {\n ...CartFragment\n }\n userErrors {\n code\n message\n }\n }\n }\n`);\n\n/**\n * Canonical list of cart mutation documents. Used by the contract regression test to iterate\n * over every shipped operation without hard-coding names.\n */\nexport const CART_MUTATIONS = [\n { name: 'CartItemAdd', document: CART_ITEM_ADD },\n { name: 'CartItemRemove', document: CART_ITEM_REMOVE },\n { name: 'CartItemsRemove', document: CART_ITEMS_REMOVE },\n { name: 'CartItemQuantityIncrease', document: CART_ITEM_QUANTITY_INCREASE },\n { name: 'CartItemQuantityDecrease', document: CART_ITEM_QUANTITY_DECREASE },\n { name: 'CartCouponApply', document: CART_COUPON_APPLY },\n { name: 'CartCouponRemove', document: CART_COUPON_REMOVE },\n { name: 'CartValidate', document: CART_VALIDATE },\n { name: 'CartSalesChannelSync', document: CART_SALES_CHANNEL_SYNC },\n] as const;\n"],"mappings":";AA0F8E,QAAQ;;;;;;CAMrF;AAEmF,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgD3F;;;;;;AAOD,MAAa,eAA+D,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCnF;;;;;;;AAQD,MAAa,mCACX,QAAQ;;;;;;;;;;;;CAYT;AAOD,MAAa,gBAAsF,QAAQ;;;;;;;;;;;;;CAa1G;AAED,MAAa,mBAA+F,QAAQ;;;;;;;;;;;;;;CAcnH;AAED,MAAa,oBAAkG,QAAQ;;;;;;;;;;;;;;CActH;AAED,MAAa,8BAGT,QAAQ;;;;;;;;;;;;;;CAcX;AAED,MAAa,8BAGT,QAAQ;;;;;;;;;;;;;;CAcX;AAED,MAAa,oBAAkG,QAAQ;;;;;;;;;;;;;CAatH;AAED,MAAa,qBACX,QAAQ;;;;;;;;;;;;;;CAcT;;;;;;;;;AAUD,MAAa,gBAAwF,QAAQ;;;;;;;;;;;;;CAa5G;;;;;AAMD,MAAa,0BAGT,QAAQ;;;;;;;;;;;;;CAaX"}
|
|
@@ -1,23 +1,46 @@
|
|
|
1
|
-
import { CartEntity, CartItemEntity, CartItemQuantityDecreasePayload, CartItemQuantityIncreasePayload, CartItemRemovePayload } from "./operations.js";
|
|
1
|
+
import { CartEntity, CartFreeShippingProgress, CartItemEntity, CartItemQuantityDecreasePayload, CartItemQuantityIncreasePayload, CartItemRemovePayload } from "./operations.js";
|
|
2
2
|
//#region src/sdk/cart/optimistic.d.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Pure optimistic-response builders for the three cache-propagating cart mutations
|
|
5
|
+
* (mutation-contract.md (archived at the specs-archive tag)).
|
|
6
|
+
*
|
|
7
|
+
* Each builder takes the current `CartEntity` and the affected `CartItemEntity` and returns the
|
|
8
|
+
* predicted post-mutation `Cart` carrying every field the canonical `CartFragment` selects:
|
|
9
|
+
* `id`, `items`, `totalizers`, `total`. The shape MUST match Apollo's normalised cache slot for
|
|
10
|
+
* the entity, so `__typename` and the same `id` are preserved.
|
|
11
|
+
*
|
|
12
|
+
* Lines are matched by their opaque `id` (Base64("CartItem:<orderFormId>:<uniqueId>")).
|
|
13
|
+
*
|
|
14
|
+
* Recomputation rules (kept simple — server reconciles drift on response):
|
|
15
|
+
* - `Items` totalizer (matched by `id === 'Items'`) is adjusted by `item.sellingPrice * delta`.
|
|
16
|
+
* - `total` (the cart's grand total) is adjusted by the same delta.
|
|
17
|
+
* - All other totalizers (Shipping, Discounts, …) stay as-is until the server response lands.
|
|
18
|
+
* - `freeShippingProgress` (the four line writes select it) keeps its last known value, except that a
|
|
19
|
+
* qualified value, whose threshold is unknown, becomes `null` when the predicted `Items` total
|
|
20
|
+
* drops, and an emptied cart carries `null`; the server's answer replaces it.
|
|
21
|
+
*/
|
|
22
|
+
/** The cart the builders read: the canonical entity plus the free-shipping slice the line writes select. */
|
|
23
|
+
type CartWithProgress = CartEntity & {
|
|
24
|
+
freeShippingProgress?: CartFreeShippingProgress | null;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Predicts the cart after `cartItemQuantityIncrease(input: { lineId, quantityToAdd })`.
|
|
5
28
|
*/
|
|
6
|
-
export declare function buildOptimisticIncrease(cart:
|
|
29
|
+
export declare function buildOptimisticIncrease(cart: CartWithProgress, item: CartItemEntity, by?: number): {
|
|
7
30
|
cartItemQuantityIncrease: CartItemQuantityIncreasePayload;
|
|
8
31
|
};
|
|
9
32
|
/**
|
|
10
|
-
* Predicts the cart after `cartItemQuantityDecrease(input: {
|
|
33
|
+
* Predicts the cart after `cartItemQuantityDecrease(input: { lineId, quantityToRemove })`.
|
|
11
34
|
*
|
|
12
35
|
* If the resulting quantity would be `<= 0`, the line is removed entirely.
|
|
13
36
|
*/
|
|
14
|
-
export declare function buildOptimisticDecrease(cart:
|
|
37
|
+
export declare function buildOptimisticDecrease(cart: CartWithProgress, item: CartItemEntity, by?: number): {
|
|
15
38
|
cartItemQuantityDecrease: CartItemQuantityDecreasePayload;
|
|
16
39
|
};
|
|
17
40
|
/**
|
|
18
|
-
* Predicts the cart after `cartItemRemove(input: {
|
|
41
|
+
* Predicts the cart after `cartItemRemove(input: { lineId })`.
|
|
19
42
|
*/
|
|
20
|
-
export declare function buildOptimisticRemove(cart:
|
|
43
|
+
export declare function buildOptimisticRemove(cart: CartWithProgress, item: CartItemEntity): {
|
|
21
44
|
cartItemRemove: CartItemRemovePayload;
|
|
22
45
|
};
|
|
23
46
|
//#endregion
|
|
@@ -1,24 +1,8 @@
|
|
|
1
1
|
//#region src/sdk/cart/optimistic.ts
|
|
2
|
-
/**
|
|
3
|
-
* Pure optimistic-response builders for the three cache-propagating cart mutations
|
|
4
|
-
* (mutation-contract.md (archived at the specs-archive tag)).
|
|
5
|
-
*
|
|
6
|
-
* Each builder takes the current `CartEntity` and the affected `CartItemEntity` and returns the
|
|
7
|
-
* predicted post-mutation `Cart` carrying every field the canonical `CartFragment` selects:
|
|
8
|
-
* `id`, `items`, `totalizers`, `total`. The shape MUST match Apollo's normalised cache slot for
|
|
9
|
-
* the entity, so `__typename` and the same `id` are preserved.
|
|
10
|
-
*
|
|
11
|
-
* Lines are matched by their opaque `id` (Base64("CartItem:<orderFormId>:<uniqueId>")).
|
|
12
|
-
*
|
|
13
|
-
* Recomputation rules (kept simple — server reconciles drift on response):
|
|
14
|
-
* - `Items` totalizer (matched by `id === 'Items'`) is adjusted by `item.sellingPrice * delta`.
|
|
15
|
-
* - `total` (the cart's grand total) is adjusted by the same delta.
|
|
16
|
-
* - All other totalizers (Shipping, Discounts, …) stay as-is until the server response lands.
|
|
17
|
-
*/
|
|
18
2
|
function moneyAdd(money, delta) {
|
|
19
3
|
return {
|
|
20
4
|
__typename: "Money",
|
|
21
|
-
amount: Number(money.amount) + delta,
|
|
5
|
+
amount: (Number(money.amount) + delta).toFixed(2),
|
|
22
6
|
currencyCode: money.currencyCode
|
|
23
7
|
};
|
|
24
8
|
}
|
|
@@ -28,110 +12,155 @@ function adjustItemsTotalizer(totalizers, delta) {
|
|
|
28
12
|
value: moneyAdd(t.value, delta)
|
|
29
13
|
} : t);
|
|
30
14
|
}
|
|
15
|
+
function itemsAmount(totalizers) {
|
|
16
|
+
return Number(totalizers.find((t) => t.id === "Items")?.value.amount ?? 0);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The `freeShippingProgress` the predicted cart carries. A qualified value has no threshold (the
|
|
20
|
+
* promotion teaser is gone once met), so the client cannot tell "still above the goal" from "below"
|
|
21
|
+
* after a drop: it hides the field until the server answers rather than claim a state it cannot know.
|
|
22
|
+
*/
|
|
23
|
+
function predictProgress(cart, predictedItems, predictedTotalizers) {
|
|
24
|
+
const current = cart.freeShippingProgress ?? null;
|
|
25
|
+
if (current === null || predictedItems.length === 0) return null;
|
|
26
|
+
if (!current.qualified) return current;
|
|
27
|
+
const before = itemsAmount(cart.totalizers);
|
|
28
|
+
const after = itemsAmount(predictedTotalizers);
|
|
29
|
+
if (!Number.isFinite(before) || !Number.isFinite(after) || after < before) return null;
|
|
30
|
+
return current;
|
|
31
|
+
}
|
|
31
32
|
function emptyUserErrors() {
|
|
32
33
|
return [];
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
|
-
* Predicts the cart after `cartItemQuantityIncrease(input: {
|
|
36
|
+
* Predicts the cart after `cartItemQuantityIncrease(input: { lineId, quantityToAdd })`.
|
|
36
37
|
*/
|
|
37
38
|
function buildOptimisticIncrease(cart, item, by = 1) {
|
|
38
39
|
if (by <= 0) return { cartItemQuantityIncrease: {
|
|
39
40
|
__typename: "CartItemQuantityIncreasePayload",
|
|
40
|
-
cart
|
|
41
|
+
cart: {
|
|
42
|
+
...cart,
|
|
43
|
+
freeShippingProgress: predictProgress(cart, cart.items, cart.totalizers)
|
|
44
|
+
},
|
|
41
45
|
userErrors: emptyUserErrors()
|
|
42
46
|
} };
|
|
43
47
|
const currentItem = cart.items.find((i) => i.id === item.id);
|
|
44
48
|
if (!currentItem) return { cartItemQuantityIncrease: {
|
|
45
49
|
__typename: "CartItemQuantityIncreasePayload",
|
|
46
|
-
cart
|
|
50
|
+
cart: {
|
|
51
|
+
...cart,
|
|
52
|
+
freeShippingProgress: predictProgress(cart, cart.items, cart.totalizers)
|
|
53
|
+
},
|
|
47
54
|
userErrors: emptyUserErrors()
|
|
48
55
|
} };
|
|
49
56
|
const newQuantity = currentItem.quantity + by;
|
|
50
|
-
const delta = currentItem.sellingPrice.amount * by;
|
|
57
|
+
const delta = Number(currentItem.sellingPrice.amount) * by;
|
|
51
58
|
const updatedItems = cart.items.map((i) => i.id === item.id ? {
|
|
52
59
|
...i,
|
|
53
60
|
quantity: newQuantity
|
|
54
61
|
} : i);
|
|
62
|
+
const totalizers = adjustItemsTotalizer(cart.totalizers, delta);
|
|
55
63
|
return { cartItemQuantityIncrease: {
|
|
56
64
|
__typename: "CartItemQuantityIncreasePayload",
|
|
57
65
|
cart: {
|
|
58
66
|
__typename: "Cart",
|
|
59
67
|
id: cart.id,
|
|
60
68
|
items: updatedItems,
|
|
61
|
-
totalizers
|
|
69
|
+
totalizers,
|
|
62
70
|
total: moneyAdd(cart.total, delta),
|
|
63
71
|
messages: cart.messages,
|
|
64
|
-
appliedCoupons: cart.appliedCoupons
|
|
72
|
+
appliedCoupons: cart.appliedCoupons,
|
|
73
|
+
discounts: cart.discounts,
|
|
74
|
+
freeShippingProgress: predictProgress(cart, updatedItems, totalizers),
|
|
75
|
+
salesChannelMismatch: cart.salesChannelMismatch
|
|
65
76
|
},
|
|
66
77
|
userErrors: emptyUserErrors()
|
|
67
78
|
} };
|
|
68
79
|
}
|
|
69
80
|
/**
|
|
70
|
-
* Predicts the cart after `cartItemQuantityDecrease(input: {
|
|
81
|
+
* Predicts the cart after `cartItemQuantityDecrease(input: { lineId, quantityToRemove })`.
|
|
71
82
|
*
|
|
72
83
|
* If the resulting quantity would be `<= 0`, the line is removed entirely.
|
|
73
84
|
*/
|
|
74
85
|
function buildOptimisticDecrease(cart, item, by = 1) {
|
|
75
86
|
if (by <= 0) return { cartItemQuantityDecrease: {
|
|
76
87
|
__typename: "CartItemQuantityDecreasePayload",
|
|
77
|
-
cart
|
|
88
|
+
cart: {
|
|
89
|
+
...cart,
|
|
90
|
+
freeShippingProgress: predictProgress(cart, cart.items, cart.totalizers)
|
|
91
|
+
},
|
|
78
92
|
userErrors: emptyUserErrors()
|
|
79
93
|
} };
|
|
80
94
|
const currentItem = cart.items.find((i) => i.id === item.id);
|
|
81
95
|
if (!currentItem) return { cartItemQuantityDecrease: {
|
|
82
96
|
__typename: "CartItemQuantityDecreasePayload",
|
|
83
|
-
cart
|
|
97
|
+
cart: {
|
|
98
|
+
...cart,
|
|
99
|
+
freeShippingProgress: predictProgress(cart, cart.items, cart.totalizers)
|
|
100
|
+
},
|
|
84
101
|
userErrors: emptyUserErrors()
|
|
85
102
|
} };
|
|
86
103
|
const requestedQuantity = currentItem.quantity - by;
|
|
87
104
|
const removed = requestedQuantity <= 0;
|
|
88
105
|
const actualDelta = removed ? currentItem.quantity : by;
|
|
89
|
-
const priceDelta = -currentItem.sellingPrice.amount * actualDelta;
|
|
106
|
+
const priceDelta = -Number(currentItem.sellingPrice.amount) * actualDelta;
|
|
90
107
|
const updatedItems = removed ? cart.items.filter((i) => i.id !== item.id) : cart.items.map((i) => i.id === item.id ? {
|
|
91
108
|
...i,
|
|
92
109
|
quantity: requestedQuantity
|
|
93
110
|
} : i);
|
|
111
|
+
const totalizers = adjustItemsTotalizer(cart.totalizers, priceDelta);
|
|
94
112
|
return { cartItemQuantityDecrease: {
|
|
95
113
|
__typename: "CartItemQuantityDecreasePayload",
|
|
96
114
|
cart: {
|
|
97
115
|
__typename: "Cart",
|
|
98
116
|
id: cart.id,
|
|
99
117
|
items: updatedItems,
|
|
100
|
-
totalizers
|
|
118
|
+
totalizers,
|
|
101
119
|
total: moneyAdd(cart.total, priceDelta),
|
|
102
120
|
messages: cart.messages,
|
|
103
|
-
appliedCoupons: cart.appliedCoupons
|
|
121
|
+
appliedCoupons: cart.appliedCoupons,
|
|
122
|
+
discounts: cart.discounts,
|
|
123
|
+
freeShippingProgress: predictProgress(cart, updatedItems, totalizers),
|
|
124
|
+
salesChannelMismatch: cart.salesChannelMismatch
|
|
104
125
|
},
|
|
105
126
|
userErrors: emptyUserErrors()
|
|
106
127
|
} };
|
|
107
128
|
}
|
|
108
129
|
/**
|
|
109
|
-
* Predicts the cart after `cartItemRemove(input: {
|
|
130
|
+
* Predicts the cart after `cartItemRemove(input: { lineId })`.
|
|
110
131
|
*/
|
|
111
132
|
function buildOptimisticRemove(cart, item) {
|
|
112
133
|
const currentItem = cart.items.find((i) => i.id === item.id);
|
|
113
134
|
if (!currentItem) return { cartItemRemove: {
|
|
114
135
|
__typename: "CartItemRemovePayload",
|
|
115
|
-
cart
|
|
136
|
+
cart: {
|
|
137
|
+
...cart,
|
|
138
|
+
freeShippingProgress: predictProgress(cart, cart.items, cart.totalizers)
|
|
139
|
+
},
|
|
116
140
|
userErrors: emptyUserErrors()
|
|
117
141
|
} };
|
|
118
|
-
const priceDelta = -currentItem.sellingPrice.amount * currentItem.quantity;
|
|
142
|
+
const priceDelta = -Number(currentItem.sellingPrice.amount) * currentItem.quantity;
|
|
143
|
+
const remainingItems = cart.items.filter((i) => i.id !== item.id);
|
|
144
|
+
const totalizers = adjustItemsTotalizer(cart.totalizers, priceDelta);
|
|
119
145
|
return { cartItemRemove: {
|
|
120
146
|
__typename: "CartItemRemovePayload",
|
|
121
147
|
cart: {
|
|
122
148
|
__typename: "Cart",
|
|
123
149
|
id: cart.id,
|
|
124
|
-
items:
|
|
125
|
-
totalizers
|
|
150
|
+
items: remainingItems,
|
|
151
|
+
totalizers,
|
|
126
152
|
total: moneyAdd(cart.total, priceDelta),
|
|
127
153
|
messages: cart.messages,
|
|
128
|
-
appliedCoupons: cart.appliedCoupons
|
|
154
|
+
appliedCoupons: cart.appliedCoupons,
|
|
155
|
+
discounts: cart.discounts,
|
|
156
|
+
freeShippingProgress: predictProgress(cart, remainingItems, totalizers),
|
|
157
|
+
salesChannelMismatch: cart.salesChannelMismatch
|
|
129
158
|
},
|
|
130
159
|
userErrors: emptyUserErrors()
|
|
131
160
|
} };
|
|
132
161
|
}
|
|
133
162
|
/**
|
|
134
|
-
* Predicts the cart after `cartItemsRemove(input: {
|
|
163
|
+
* Predicts the cart after `cartItemsRemove(input: { lineIds })` — the N-line generalisation of
|
|
135
164
|
* `buildOptimisticRemove`. Lines absent from the cart are ignored; the summed price delta of the
|
|
136
165
|
* matched lines adjusts the `Items` totalizer and the grand total.
|
|
137
166
|
*/
|
|
@@ -140,20 +169,28 @@ function buildOptimisticRemoveItems(cart, items) {
|
|
|
140
169
|
const removedLines = cart.items.filter((i) => removedIds.has(i.id));
|
|
141
170
|
if (removedLines.length === 0) return { cartItemsRemove: {
|
|
142
171
|
__typename: "CartItemsRemovePayload",
|
|
143
|
-
cart
|
|
172
|
+
cart: {
|
|
173
|
+
...cart,
|
|
174
|
+
freeShippingProgress: predictProgress(cart, cart.items, cart.totalizers)
|
|
175
|
+
},
|
|
144
176
|
userErrors: emptyUserErrors()
|
|
145
177
|
} };
|
|
146
|
-
const priceDelta = removedLines.reduce((sum, line) => sum - line.sellingPrice.amount * line.quantity, 0);
|
|
178
|
+
const priceDelta = removedLines.reduce((sum, line) => sum - Number(line.sellingPrice.amount) * line.quantity, 0);
|
|
179
|
+
const remainingItems = cart.items.filter((i) => !removedIds.has(i.id));
|
|
180
|
+
const totalizers = adjustItemsTotalizer(cart.totalizers, priceDelta);
|
|
147
181
|
return { cartItemsRemove: {
|
|
148
182
|
__typename: "CartItemsRemovePayload",
|
|
149
183
|
cart: {
|
|
150
184
|
__typename: "Cart",
|
|
151
185
|
id: cart.id,
|
|
152
|
-
items:
|
|
153
|
-
totalizers
|
|
186
|
+
items: remainingItems,
|
|
187
|
+
totalizers,
|
|
154
188
|
total: moneyAdd(cart.total, priceDelta),
|
|
155
189
|
messages: cart.messages,
|
|
156
|
-
appliedCoupons: cart.appliedCoupons
|
|
190
|
+
appliedCoupons: cart.appliedCoupons,
|
|
191
|
+
discounts: cart.discounts,
|
|
192
|
+
freeShippingProgress: predictProgress(cart, remainingItems, totalizers),
|
|
193
|
+
salesChannelMismatch: cart.salesChannelMismatch
|
|
157
194
|
},
|
|
158
195
|
userErrors: emptyUserErrors()
|
|
159
196
|
} };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimistic.js","names":[],"sources":["../../../src/sdk/cart/optimistic.ts"],"sourcesContent":["import type {\n CartEntity,\n CartItemEntity,\n CartItemQuantityDecreasePayload,\n CartItemQuantityIncreasePayload,\n CartItemRemovePayload,\n CartItemsRemovePayload,\n CartTotalizer,\n Money,\n} from './operations.js';\n\n/**\n * Pure optimistic-response builders for the three cache-propagating cart mutations\n * (mutation-contract.md (archived at the specs-archive tag)).\n *\n * Each builder takes the current `CartEntity` and the affected `CartItemEntity` and returns the\n * predicted post-mutation `Cart` carrying every field the canonical `CartFragment` selects:\n * `id`, `items`, `totalizers`, `total`. The shape MUST match Apollo's normalised cache slot for\n * the entity, so `__typename` and the same `id` are preserved.\n *\n * Lines are matched by their opaque `id` (Base64(\"CartItem:<orderFormId>:<uniqueId>\")).\n *\n * Recomputation rules (kept simple — server reconciles drift on response):\n * - `Items` totalizer (matched by `id === 'Items'`) is adjusted by `item.sellingPrice * delta`.\n * - `total` (the cart's grand total) is adjusted by the same delta.\n * - All other totalizers (Shipping, Discounts, …) stay as-is until the server response lands.\n */\n\nfunction moneyAdd(money: Money, delta: number): Money {\n // `Money.amount` is typed as `number` by codegen but arrives over the wire as a decimal *string*\n // (the server's `Decimal` scalar = `(cents / 100).toFixed(2)`). Without coercing, `string + number`\n // concatenates (e.g. \"49.99\" + 49.99 → \"49.9949.99\"), which formats to NaN during the optimistic\n // window until the server response replaces it. Number() restores numeric addition.\n return { __typename: 'Money', amount: Number(money.amount) + delta, currencyCode: money.currencyCode };\n}\n\nfunction adjustItemsTotalizer(totalizers: readonly CartTotalizer[], delta: number): CartTotalizer[] {\n return totalizers.map((t) => (t.id === 'Items' ? { ...t, value: moneyAdd(t.value, delta) } : t));\n}\n\nfunction emptyUserErrors<T>(): T[] {\n return [];\n}\n\n/**\n * Predicts the cart after `cartItemQuantityIncrease(input: { variantId, quantityToAdd })`.\n */\nexport function buildOptimisticIncrease(\n cart: CartEntity,\n item: CartItemEntity,\n by = 1,\n): { cartItemQuantityIncrease: CartItemQuantityIncreasePayload } {\n if (by <= 0) {\n return {\n cartItemQuantityIncrease: {\n __typename: 'CartItemQuantityIncreasePayload',\n cart,\n userErrors: emptyUserErrors(),\n },\n };\n }\n\n const currentItem = cart.items.find((i) => i.id === item.id);\n if (!currentItem) {\n return {\n cartItemQuantityIncrease: {\n __typename: 'CartItemQuantityIncreasePayload',\n cart,\n userErrors: emptyUserErrors(),\n },\n };\n }\n\n const newQuantity = currentItem.quantity + by;\n const delta = currentItem.sellingPrice.amount * by;\n\n const updatedItems = cart.items.map((i) => (i.id === item.id ? { ...i, quantity: newQuantity } : i));\n\n return {\n cartItemQuantityIncrease: {\n __typename: 'CartItemQuantityIncreasePayload',\n cart: {\n __typename: 'Cart',\n id: cart.id,\n items: updatedItems,\n totalizers: adjustItemsTotalizer(cart.totalizers, delta),\n total: moneyAdd(cart.total, delta),\n messages: cart.messages,\n appliedCoupons: cart.appliedCoupons,\n },\n userErrors: emptyUserErrors(),\n },\n };\n}\n\n/**\n * Predicts the cart after `cartItemQuantityDecrease(input: { variantId, quantityToRemove })`.\n *\n * If the resulting quantity would be `<= 0`, the line is removed entirely.\n */\nexport function buildOptimisticDecrease(\n cart: CartEntity,\n item: CartItemEntity,\n by = 1,\n): { cartItemQuantityDecrease: CartItemQuantityDecreasePayload } {\n if (by <= 0) {\n return {\n cartItemQuantityDecrease: {\n __typename: 'CartItemQuantityDecreasePayload',\n cart,\n userErrors: emptyUserErrors(),\n },\n };\n }\n\n const currentItem = cart.items.find((i) => i.id === item.id);\n if (!currentItem) {\n return {\n cartItemQuantityDecrease: {\n __typename: 'CartItemQuantityDecreasePayload',\n cart,\n userErrors: emptyUserErrors(),\n },\n };\n }\n\n const requestedQuantity = currentItem.quantity - by;\n const removed = requestedQuantity <= 0;\n const actualDelta = removed ? currentItem.quantity : by;\n const priceDelta = -currentItem.sellingPrice.amount * actualDelta;\n\n const updatedItems = removed\n ? cart.items.filter((i) => i.id !== item.id)\n : cart.items.map((i) => (i.id === item.id ? { ...i, quantity: requestedQuantity } : i));\n\n return {\n cartItemQuantityDecrease: {\n __typename: 'CartItemQuantityDecreasePayload',\n cart: {\n __typename: 'Cart',\n id: cart.id,\n items: updatedItems,\n totalizers: adjustItemsTotalizer(cart.totalizers, priceDelta),\n total: moneyAdd(cart.total, priceDelta),\n messages: cart.messages,\n appliedCoupons: cart.appliedCoupons,\n },\n userErrors: emptyUserErrors(),\n },\n };\n}\n\n/**\n * Predicts the cart after `cartItemRemove(input: { variantId })`.\n */\nexport function buildOptimisticRemove(\n cart: CartEntity,\n item: CartItemEntity,\n): { cartItemRemove: CartItemRemovePayload } {\n const currentItem = cart.items.find((i) => i.id === item.id);\n if (!currentItem) {\n return {\n cartItemRemove: {\n __typename: 'CartItemRemovePayload',\n cart,\n userErrors: emptyUserErrors(),\n },\n };\n }\n\n const priceDelta = -currentItem.sellingPrice.amount * currentItem.quantity;\n\n return {\n cartItemRemove: {\n __typename: 'CartItemRemovePayload',\n cart: {\n __typename: 'Cart',\n id: cart.id,\n items: cart.items.filter((i) => i.id !== item.id),\n totalizers: adjustItemsTotalizer(cart.totalizers, priceDelta),\n total: moneyAdd(cart.total, priceDelta),\n messages: cart.messages,\n appliedCoupons: cart.appliedCoupons,\n },\n userErrors: emptyUserErrors(),\n },\n };\n}\n\n/**\n * Predicts the cart after `cartItemsRemove(input: { variantIds })` — the N-line generalisation of\n * `buildOptimisticRemove`. Lines absent from the cart are ignored; the summed price delta of the\n * matched lines adjusts the `Items` totalizer and the grand total.\n */\nexport function buildOptimisticRemoveItems(\n cart: CartEntity,\n items: readonly CartItemEntity[],\n): { cartItemsRemove: CartItemsRemovePayload } {\n const removedIds = new Set(items.map((item) => item.id));\n const removedLines = cart.items.filter((i) => removedIds.has(i.id));\n if (removedLines.length === 0) {\n return {\n cartItemsRemove: {\n __typename: 'CartItemsRemovePayload',\n cart,\n userErrors: emptyUserErrors(),\n },\n };\n }\n\n const priceDelta = removedLines.reduce((sum, line) => sum - line.sellingPrice.amount * line.quantity, 0);\n\n return {\n cartItemsRemove: {\n __typename: 'CartItemsRemovePayload',\n cart: {\n __typename: 'Cart',\n id: cart.id,\n items: cart.items.filter((i) => !removedIds.has(i.id)),\n totalizers: adjustItemsTotalizer(cart.totalizers, priceDelta),\n total: moneyAdd(cart.total, priceDelta),\n messages: cart.messages,\n appliedCoupons: cart.appliedCoupons,\n },\n userErrors: emptyUserErrors(),\n },\n };\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"optimistic.js","names":[],"sources":["../../../src/sdk/cart/optimistic.ts"],"sourcesContent":["import type {\n CartEntity,\n CartFreeShippingProgress,\n CartItemEntity,\n CartItemQuantityDecreasePayload,\n CartItemQuantityIncreasePayload,\n CartItemRemovePayload,\n CartItemsRemovePayload,\n CartTotalizer,\n Money,\n} from './operations.js';\n\n/**\n * Pure optimistic-response builders for the three cache-propagating cart mutations\n * (mutation-contract.md (archived at the specs-archive tag)).\n *\n * Each builder takes the current `CartEntity` and the affected `CartItemEntity` and returns the\n * predicted post-mutation `Cart` carrying every field the canonical `CartFragment` selects:\n * `id`, `items`, `totalizers`, `total`. The shape MUST match Apollo's normalised cache slot for\n * the entity, so `__typename` and the same `id` are preserved.\n *\n * Lines are matched by their opaque `id` (Base64(\"CartItem:<orderFormId>:<uniqueId>\")).\n *\n * Recomputation rules (kept simple — server reconciles drift on response):\n * - `Items` totalizer (matched by `id === 'Items'`) is adjusted by `item.sellingPrice * delta`.\n * - `total` (the cart's grand total) is adjusted by the same delta.\n * - All other totalizers (Shipping, Discounts, …) stay as-is until the server response lands.\n * - `freeShippingProgress` (the four line writes select it) keeps its last known value, except that a\n * qualified value, whose threshold is unknown, becomes `null` when the predicted `Items` total\n * drops, and an emptied cart carries `null`; the server's answer replaces it.\n */\n\n/** The cart the builders read: the canonical entity plus the free-shipping slice the line writes select. */\ntype CartWithProgress = CartEntity & { freeShippingProgress?: CartFreeShippingProgress | null };\n\nfunction moneyAdd(money: Money, delta: number): Money {\n // `Money.amount` is the decimal *string* the server's `Decimal` scalar sends (`(cents / 100).toFixed(2)`).\n // Without coercing, `string + number` concatenates (e.g. \"49.99\" + 49.99 → \"49.9949.99\"), which formats\n // to NaN during the optimistic window until the server response replaces it. Number() restores numeric\n // addition and toFixed(2) writes the result back in the wire shape, with no float noise.\n return { __typename: 'Money', amount: (Number(money.amount) + delta).toFixed(2), currencyCode: money.currencyCode };\n}\n\nfunction adjustItemsTotalizer(totalizers: readonly CartTotalizer[], delta: number): CartTotalizer[] {\n return totalizers.map((t) => (t.id === 'Items' ? { ...t, value: moneyAdd(t.value, delta) } : t));\n}\n\nfunction itemsAmount(totalizers: readonly CartTotalizer[]): number {\n return Number(totalizers.find((t) => t.id === 'Items')?.value.amount ?? 0);\n}\n\n/**\n * The `freeShippingProgress` the predicted cart carries. A qualified value has no threshold (the\n * promotion teaser is gone once met), so the client cannot tell \"still above the goal\" from \"below\"\n * after a drop: it hides the field until the server answers rather than claim a state it cannot know.\n */\nfunction predictProgress(\n cart: CartWithProgress,\n predictedItems: readonly CartItemEntity[],\n predictedTotalizers: readonly CartTotalizer[],\n): CartFreeShippingProgress {\n const current = cart.freeShippingProgress ?? null;\n if (current === null || predictedItems.length === 0) return null;\n if (!current.qualified) return current;\n\n const before = itemsAmount(cart.totalizers);\n const after = itemsAmount(predictedTotalizers);\n if (!Number.isFinite(before) || !Number.isFinite(after) || after < before) return null;\n return current;\n}\n\nfunction emptyUserErrors<T>(): T[] {\n return [];\n}\n\n/**\n * Predicts the cart after `cartItemQuantityIncrease(input: { lineId, quantityToAdd })`.\n */\nexport function buildOptimisticIncrease(\n cart: CartWithProgress,\n item: CartItemEntity,\n by = 1,\n): { cartItemQuantityIncrease: CartItemQuantityIncreasePayload } {\n if (by <= 0) {\n return {\n cartItemQuantityIncrease: {\n __typename: 'CartItemQuantityIncreasePayload',\n cart: { ...cart, freeShippingProgress: predictProgress(cart, cart.items, cart.totalizers) },\n userErrors: emptyUserErrors(),\n },\n };\n }\n\n const currentItem = cart.items.find((i) => i.id === item.id);\n if (!currentItem) {\n return {\n cartItemQuantityIncrease: {\n __typename: 'CartItemQuantityIncreasePayload',\n cart: { ...cart, freeShippingProgress: predictProgress(cart, cart.items, cart.totalizers) },\n userErrors: emptyUserErrors(),\n },\n };\n }\n\n const newQuantity = currentItem.quantity + by;\n const delta = Number(currentItem.sellingPrice.amount) * by;\n\n const updatedItems = cart.items.map((i) => (i.id === item.id ? { ...i, quantity: newQuantity } : i));\n\n const totalizers = adjustItemsTotalizer(cart.totalizers, delta);\n return {\n cartItemQuantityIncrease: {\n __typename: 'CartItemQuantityIncreasePayload',\n cart: {\n __typename: 'Cart',\n id: cart.id,\n items: updatedItems,\n totalizers,\n total: moneyAdd(cart.total, delta),\n messages: cart.messages,\n appliedCoupons: cart.appliedCoupons,\n discounts: cart.discounts,\n freeShippingProgress: predictProgress(cart, updatedItems, totalizers),\n salesChannelMismatch: cart.salesChannelMismatch,\n },\n userErrors: emptyUserErrors(),\n },\n };\n}\n\n/**\n * Predicts the cart after `cartItemQuantityDecrease(input: { lineId, quantityToRemove })`.\n *\n * If the resulting quantity would be `<= 0`, the line is removed entirely.\n */\nexport function buildOptimisticDecrease(\n cart: CartWithProgress,\n item: CartItemEntity,\n by = 1,\n): { cartItemQuantityDecrease: CartItemQuantityDecreasePayload } {\n if (by <= 0) {\n return {\n cartItemQuantityDecrease: {\n __typename: 'CartItemQuantityDecreasePayload',\n cart: { ...cart, freeShippingProgress: predictProgress(cart, cart.items, cart.totalizers) },\n userErrors: emptyUserErrors(),\n },\n };\n }\n\n const currentItem = cart.items.find((i) => i.id === item.id);\n if (!currentItem) {\n return {\n cartItemQuantityDecrease: {\n __typename: 'CartItemQuantityDecreasePayload',\n cart: { ...cart, freeShippingProgress: predictProgress(cart, cart.items, cart.totalizers) },\n userErrors: emptyUserErrors(),\n },\n };\n }\n\n const requestedQuantity = currentItem.quantity - by;\n const removed = requestedQuantity <= 0;\n const actualDelta = removed ? currentItem.quantity : by;\n const priceDelta = -Number(currentItem.sellingPrice.amount) * actualDelta;\n\n const updatedItems = removed\n ? cart.items.filter((i) => i.id !== item.id)\n : cart.items.map((i) => (i.id === item.id ? { ...i, quantity: requestedQuantity } : i));\n\n const totalizers = adjustItemsTotalizer(cart.totalizers, priceDelta);\n return {\n cartItemQuantityDecrease: {\n __typename: 'CartItemQuantityDecreasePayload',\n cart: {\n __typename: 'Cart',\n id: cart.id,\n items: updatedItems,\n totalizers,\n total: moneyAdd(cart.total, priceDelta),\n messages: cart.messages,\n appliedCoupons: cart.appliedCoupons,\n discounts: cart.discounts,\n freeShippingProgress: predictProgress(cart, updatedItems, totalizers),\n salesChannelMismatch: cart.salesChannelMismatch,\n },\n userErrors: emptyUserErrors(),\n },\n };\n}\n\n/**\n * Predicts the cart after `cartItemRemove(input: { lineId })`.\n */\nexport function buildOptimisticRemove(\n cart: CartWithProgress,\n item: CartItemEntity,\n): { cartItemRemove: CartItemRemovePayload } {\n const currentItem = cart.items.find((i) => i.id === item.id);\n if (!currentItem) {\n return {\n cartItemRemove: {\n __typename: 'CartItemRemovePayload',\n cart: { ...cart, freeShippingProgress: predictProgress(cart, cart.items, cart.totalizers) },\n userErrors: emptyUserErrors(),\n },\n };\n }\n\n const priceDelta = -Number(currentItem.sellingPrice.amount) * currentItem.quantity;\n const remainingItems = cart.items.filter((i) => i.id !== item.id);\n\n const totalizers = adjustItemsTotalizer(cart.totalizers, priceDelta);\n return {\n cartItemRemove: {\n __typename: 'CartItemRemovePayload',\n cart: {\n __typename: 'Cart',\n id: cart.id,\n items: remainingItems,\n totalizers,\n total: moneyAdd(cart.total, priceDelta),\n messages: cart.messages,\n appliedCoupons: cart.appliedCoupons,\n discounts: cart.discounts,\n freeShippingProgress: predictProgress(cart, remainingItems, totalizers),\n salesChannelMismatch: cart.salesChannelMismatch,\n },\n userErrors: emptyUserErrors(),\n },\n };\n}\n\n/**\n * Predicts the cart after `cartItemsRemove(input: { lineIds })` — the N-line generalisation of\n * `buildOptimisticRemove`. Lines absent from the cart are ignored; the summed price delta of the\n * matched lines adjusts the `Items` totalizer and the grand total.\n */\nexport function buildOptimisticRemoveItems(\n cart: CartWithProgress,\n items: readonly CartItemEntity[],\n): { cartItemsRemove: CartItemsRemovePayload } {\n const removedIds = new Set(items.map((item) => item.id));\n const removedLines = cart.items.filter((i) => removedIds.has(i.id));\n if (removedLines.length === 0) {\n return {\n cartItemsRemove: {\n __typename: 'CartItemsRemovePayload',\n cart: { ...cart, freeShippingProgress: predictProgress(cart, cart.items, cart.totalizers) },\n userErrors: emptyUserErrors(),\n },\n };\n }\n\n const priceDelta = removedLines.reduce((sum, line) => sum - Number(line.sellingPrice.amount) * line.quantity, 0);\n const remainingItems = cart.items.filter((i) => !removedIds.has(i.id));\n\n const totalizers = adjustItemsTotalizer(cart.totalizers, priceDelta);\n return {\n cartItemsRemove: {\n __typename: 'CartItemsRemovePayload',\n cart: {\n __typename: 'Cart',\n id: cart.id,\n items: remainingItems,\n totalizers,\n total: moneyAdd(cart.total, priceDelta),\n messages: cart.messages,\n appliedCoupons: cart.appliedCoupons,\n discounts: cart.discounts,\n freeShippingProgress: predictProgress(cart, remainingItems, totalizers),\n salesChannelMismatch: cart.salesChannelMismatch,\n },\n userErrors: emptyUserErrors(),\n },\n };\n}\n"],"mappings":"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"}
|
|
@@ -51,6 +51,13 @@ export type CartActions = Readonly<{
|
|
|
51
51
|
* `cartUserErrorsVar` — a speculative open-time failure must raise no error banner (Decision 6).
|
|
52
52
|
*/
|
|
53
53
|
validate: () => Promise<readonly CartUserError[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Move the active cart onto the request's sales channel and reconcile its locale. Async (no
|
|
56
|
+
* optimistic). Returns userErrors (empty on success) and stamps the freshness window on success.
|
|
57
|
+
* Does not publish to `cartUserErrorsVar`: a background failure must raise no error banner.
|
|
58
|
+
* Registers as an in-flight write so a stock check skips while it runs.
|
|
59
|
+
*/
|
|
60
|
+
syncSalesChannel: () => Promise<readonly CartUserError[]>;
|
|
54
61
|
}>;
|
|
55
62
|
//#endregion
|
|
56
63
|
//# sourceMappingURL=use-cart-actions.d.ts.map
|