@vtex/faststore 0.0.6 → 0.0.8
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 +99 -0
- package/dist/actions.json +152 -1
- package/dist/catalog.json +2541 -1278
- package/dist/cli/UnreachableCaseError-Crd168Vu.js +10 -0
- package/dist/cli/UnreachableCaseError-Crd168Vu.js.map +1 -0
- package/dist/cli/cacheControl-CEojH_TM.js +158 -0
- package/dist/cli/cacheControl-CEojH_TM.js.map +1 -0
- package/dist/cli/cachePolicy-m2vASMRW.js +26 -0
- package/dist/cli/cachePolicy-m2vASMRW.js.map +1 -0
- package/dist/cli/computeCoreSchemaHash-DPJZj-qJ.js +10 -0
- package/dist/cli/computeCoreSchemaHash-DPJZj-qJ.js.map +1 -0
- package/dist/cli/default-BCQHcwbL.js +253 -0
- package/dist/cli/default-BCQHcwbL.js.map +1 -0
- package/dist/cli/disableSuggestions-yO9UqiWn.js +21 -0
- package/dist/cli/disableSuggestions-yO9UqiWn.js.map +1 -0
- package/dist/cli/dist-C1JhdHfo.js +2001 -0
- package/dist/cli/dist-C1JhdHfo.js.map +1 -0
- package/dist/cli/graphql-DG9thCDG.js +14589 -0
- package/dist/cli/graphql-DG9thCDG.js.map +1 -0
- package/dist/cli/index.d.ts +799 -0
- package/dist/cli/index.js +36459 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/index.min-BsIHDfFK.js +613 -0
- package/dist/cli/index.min-BsIHDfFK.js.map +1 -0
- package/dist/cli/inlineTrace-uLgOJ3TH.js +52 -0
- package/dist/cli/inlineTrace-uLgOJ3TH.js.map +1 -0
- package/dist/cli/internalPlugin-DnuwN4_4.js +11 -0
- package/dist/cli/internalPlugin-DnuwN4_4.js.map +1 -0
- package/dist/cli/packageVersion-DQAnIEil.js +6 -0
- package/dist/cli/packageVersion-DQAnIEil.js.map +1 -0
- package/dist/cli/rolldown-runtime-BMI-E3GI.js +44 -0
- package/dist/cli/schemaIsSubgraph-DoGh3OYj.js +17 -0
- package/dist/cli/schemaIsSubgraph-DoGh3OYj.js.map +1 -0
- package/dist/cli/schemaReporting-K-me-3-v.js +199 -0
- package/dist/cli/schemaReporting-K-me-3-v.js.map +1 -0
- package/dist/cli/server-runtime.js +49879 -0
- package/dist/cli/server-runtime.js.map +1 -0
- package/dist/cli/traceTreeBuilder-BIcV2U7b.js +9118 -0
- package/dist/cli/traceTreeBuilder-BIcV2U7b.js.map +1 -0
- package/dist/cli/usageReporting-Bpl8vSZX.js +10201 -0
- package/dist/cli/usageReporting-Bpl8vSZX.js.map +1 -0
- package/dist/cli/v4-CBhFvC49.js +42 -0
- package/dist/cli/v4-CBhFvC49.js.map +1 -0
- package/dist/client.d.ts +5 -1
- package/dist/client.js +5 -1
- package/dist/components.d.ts +38 -9
- package/dist/components.js +42 -13
- package/dist/content-types.json +616 -0
- package/dist/core/dist/define-component.d.ts +43 -1
- package/dist/core/dist/index.d.ts +2 -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 +1 -1
- package/dist/docs/account-menu-identity.md +160 -0
- package/dist/docs/account-menu.md +107 -24
- package/dist/docs/alert-dialog.md +2 -2
- package/dist/docs/avatar.md +103 -0
- package/dist/docs/billing-address.md +17 -9
- package/dist/docs/card-entry.md +37 -6
- package/dist/docs/cardholder-document.md +16 -14
- package/dist/docs/cart-item.md +1 -1
- package/dist/docs/cart.md +8 -8
- 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/header-root.md +1 -1
- package/dist/docs/incentives.md +2 -2
- package/dist/docs/logo.md +5 -5
- package/dist/docs/my-account-profile.md +5 -5
- 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 +14 -3
- package/dist/docs/place-order.md +13 -9
- package/dist/docs/product-shelf.md +20 -13
- package/dist/docs/saved-cards.md +2 -2
- package/dist/docs/select.md +19 -6
- package/dist/docs/session.md +1 -1
- package/dist/docs/shipping-address.md +1 -1
- package/dist/docs/sign-in-redirect.md +6 -6
- package/dist/docs/toast.md +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +2 -1
- package/dist/internal/client.d.ts +6 -1
- package/dist/internal/client.js +8 -3
- package/dist/internal/content.d.ts +2 -2
- package/dist/internal/server.d.ts +8 -1
- package/dist/internal/server.js +8 -1
- 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 +77 -3
- package/dist/matter/account-menu/account-menu.js +252 -19
- package/dist/matter/account-menu/account-menu.js.map +1 -1
- package/dist/matter/account-menu/sign-out-failure.js +50 -0
- package/dist/matter/account-menu/sign-out-failure.js.map +1 -0
- package/dist/matter/account-menu-identity/account-menu-identity.d.ts +21 -0
- package/dist/matter/account-menu-identity/account-menu-identity.js +88 -0
- package/dist/matter/account-menu-identity/account-menu-identity.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 +78 -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.d.ts +7 -2
- package/dist/matter/cart/cart.js +29 -26
- package/dist/matter/cart/cart.js.map +1 -1
- package/dist/matter/cart-item/cart-item.js +2 -2
- package/dist/matter/cart-item/cart-item.js.map +1 -1
- package/dist/matter/client-preferences/client-preferences-fieldset.js +2 -2
- package/dist/matter/client-profile-form/client-profile-fieldset.js +9 -6
- package/dist/matter/client-profile-form/client-profile-fieldset.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 +4 -3
- package/dist/matter/identity-summary/identity-summary.js.map +1 -1
- package/dist/matter/my-account-profile/my-account-profile.d.ts +6 -3
- package/dist/matter/my-account-profile/my-account-profile.js +6 -5
- 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 +12 -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 +12 -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 +61 -31
- package/dist/matter/product-shelf/product-shelf.js +157 -57
- 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 +27 -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 +63 -15
- package/dist/matter/shipping-address/shipping-address.js.map +1 -1
- package/dist/matter/shipping-simulator/shipping-simulator.d.ts +1 -1
- 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/avatar/avatar.d.ts +17 -0
- package/dist/particles/avatar/avatar.js +65 -0
- package/dist/particles/avatar/avatar.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/incentives/incentives.d.ts +6 -2
- package/dist/particles/incentives/incentives.js +7 -2
- 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/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 +1 -1
- package/dist/particles/toast/toast.js +32 -6
- package/dist/particles/toast/toast.js.map +1 -1
- package/dist/schema.graphql +1079 -54
- 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 +3 -1
- package/dist/sdk/actions/index.js +3 -1
- 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/types.d.ts +6 -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/analytics/use-analytics-actions.js +2 -1
- package/dist/sdk/analytics/use-analytics-actions.js.map +1 -1
- package/dist/sdk/cache/storefront-cache.js +29 -4
- package/dist/sdk/cache/storefront-cache.js.map +1 -1
- package/dist/sdk/cart/use-cart-actions.js +9 -8
- package/dist/sdk/cart/use-cart-actions.js.map +1 -1
- package/dist/sdk/cart/use-cart-validate-on-open.js +2 -1
- package/dist/sdk/cart/use-cart-validate-on-open.js.map +1 -1
- 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.d.ts +22 -1
- package/dist/sdk/content/create-content-runtime.js +90 -9
- package/dist/sdk/content/create-content-runtime.js.map +1 -1
- package/dist/sdk/data/empty-content-value.js +16 -0
- package/dist/sdk/data/empty-content-value.js.map +1 -0
- package/dist/sdk/data/failed-fields.js +23 -0
- package/dist/sdk/data/failed-fields.js.map +1 -0
- package/dist/sdk/data/hot-data-provider.js +2 -1
- package/dist/sdk/data/hot-data-provider.js.map +1 -1
- package/dist/sdk/data/index.js +1 -1
- 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/variables-from-content.d.ts +43 -0
- package/dist/sdk/data/variables-from-content.js +57 -0
- package/dist/sdk/data/variables-from-content.js.map +1 -0
- 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 +4 -1
- package/dist/sdk/generated/gql.js.map +1 -1
- package/dist/sdk/generated/graphql.d.ts +8 -0
- package/dist/sdk/generated/graphql.js +296 -1
- package/dist/sdk/generated/graphql.js.map +1 -1
- package/dist/sdk/i18n/messages/en-US.js +138 -1
- package/dist/sdk/i18n/messages/en-US.json +138 -1
- package/dist/sdk/i18n/messages/en-US.json.d.ts +137 -0
- package/dist/sdk/i18n/messages/es-ES.js +138 -1
- package/dist/sdk/i18n/messages/es-ES.json +138 -1
- package/dist/sdk/i18n/messages/pt-BR.js +138 -1
- package/dist/sdk/i18n/messages/pt-BR.json +138 -1
- package/dist/sdk/identity/use-identity-actions.js +5 -4
- package/dist/sdk/identity/use-identity-actions.js.map +1 -1
- package/dist/sdk/navigation/current-page.js +30 -0
- package/dist/sdk/navigation/current-page.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 +6 -3
- 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 +334 -144
- package/dist/sdk/payment/use-place-order.js.map +1 -1
- package/dist/sdk/region/use-region-actions.js +2 -1
- package/dist/sdk/region/use-region-actions.js.map +1 -1
- package/dist/sdk/seo/page-alternates.d.ts +55 -0
- package/dist/sdk/seo/page-alternates.js +132 -0
- package/dist/sdk/seo/page-alternates.js.map +1 -0
- package/dist/sdk/session/read-server-session.d.ts +21 -0
- package/dist/sdk/session/read-server-session.js +61 -0
- package/dist/sdk/session/read-server-session.js.map +1 -0
- package/dist/sdk/session/use-session-actions.js +5 -4
- package/dist/sdk/session/use-session-actions.js.map +1 -1
- package/dist/sdk/session/use-session-revalidation.js +2 -1
- package/dist/sdk/session/use-session-revalidation.js.map +1 -1
- package/dist/sdk/shipping/use-shipping-actions.js +3 -2
- package/dist/sdk/shipping/use-shipping-actions.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 +11 -0
- package/dist/utils/safe-href.js +31 -22
- package/dist/utils/safe-href.js.map +1 -1
- package/package.json +17 -2
- 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 +27 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { loggableErrorName } from "../../utils/loggable-error-name.js";
|
|
2
3
|
import { usePaymentSubmission } from "./submission-registry.js";
|
|
3
4
|
import { PAYMENT_NETWORK_ERROR_CODE } from "./operations.js";
|
|
4
|
-
import { loggableErrorName } from "../../utils/loggable-error-name.js";
|
|
5
5
|
import { isTrustedGatewayOrigin } from "./gateway-origin.js";
|
|
6
6
|
import { useCallback, useMemo, useRef, useState } from "react";
|
|
7
7
|
//#region src/sdk/payment/use-place-order.ts
|
|
@@ -128,23 +128,59 @@ function toMinorUnits(amount) {
|
|
|
128
128
|
return Math.round(Number(amount) * 100);
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
|
-
* The one call into holder-owned code. A holder's continuation is specified to resolve
|
|
132
|
-
* `sendPayments` already collapses every gateway outcome to one — so a throw
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* property. See `loggableErrorName()`.
|
|
131
|
+
* The one call into holder-owned code. A holder's continuation is specified to resolve a
|
|
132
|
+
* `PaymentSubmissionResult` — `sendPayments` already collapses every gateway outcome to one — so a throw,
|
|
133
|
+
* or a result that is not that shape, means its contract broke. Only a sanitised error *name* is logged
|
|
134
|
+
* (T160): the closure that threw holds the card, and a message or stack could echo it — and so,
|
|
135
|
+
* unsanitised, could `.name` itself, since it is a writable own property. See `loggableErrorName()`.
|
|
136
|
+
*
|
|
137
|
+
* T112 (Decision 6): the result is totalled here and fails closed. Anything that is not an object with an
|
|
138
|
+
* array `userErrors` — a nullish resolution, or the bare array the contract returned before this change —
|
|
139
|
+
* collapses to `{ reachedGateway: true, userErrors: [NETWORK_ERROR] }`, and a `reachedGateway` that is not
|
|
140
|
+
* a boolean is read as `true`: only a literal `false` may free the attempt, so a holder that omits the
|
|
141
|
+
* signal locks it rather than inviting a second payment. An empty `userErrors` is a success whatever the
|
|
142
|
+
* flag says. Each field is read once, into a local, and the result handed back is a fresh object — a
|
|
143
|
+
* getter that answers differently across reads has no second read to answer differently on.
|
|
136
144
|
*/
|
|
137
145
|
async function invokeSubmission(submit, transaction) {
|
|
138
146
|
try {
|
|
139
147
|
const result = await submit(transaction);
|
|
140
148
|
if (result == null) {
|
|
141
149
|
console.error("[payment.placeOrder] the registered submission resolved with no result");
|
|
142
|
-
return
|
|
150
|
+
return {
|
|
151
|
+
reachedGateway: true,
|
|
152
|
+
userErrors: [NETWORK_ERROR]
|
|
153
|
+
};
|
|
143
154
|
}
|
|
144
|
-
|
|
155
|
+
const { reachedGateway, userErrors } = result;
|
|
156
|
+
if (!Array.isArray(userErrors)) {
|
|
157
|
+
console.error("[payment.placeOrder] the registered submission resolved a result with no userErrors list");
|
|
158
|
+
return {
|
|
159
|
+
reachedGateway: true,
|
|
160
|
+
userErrors: [NETWORK_ERROR]
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (userErrors.length === 0) return {
|
|
164
|
+
reachedGateway: true,
|
|
165
|
+
userErrors: []
|
|
166
|
+
};
|
|
167
|
+
if (typeof reachedGateway !== "boolean") {
|
|
168
|
+
console.error("[payment.placeOrder] the registered submission resolved a non-boolean reachedGateway");
|
|
169
|
+
return {
|
|
170
|
+
reachedGateway: true,
|
|
171
|
+
userErrors
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
reachedGateway,
|
|
176
|
+
userErrors
|
|
177
|
+
};
|
|
145
178
|
} catch (error) {
|
|
146
179
|
console.error("[payment.placeOrder] the registered submission threw", loggableErrorName(error));
|
|
147
|
-
return
|
|
180
|
+
return {
|
|
181
|
+
reachedGateway: true,
|
|
182
|
+
userErrors: [NETWORK_ERROR]
|
|
183
|
+
};
|
|
148
184
|
}
|
|
149
185
|
}
|
|
150
186
|
/**
|
|
@@ -161,6 +197,26 @@ function runPreflight(check) {
|
|
|
161
197
|
}
|
|
162
198
|
}
|
|
163
199
|
/**
|
|
200
|
+
* Asks the registered missing-method explainer (T47) why nothing is selected. A hint, never a check
|
|
201
|
+
* (Decision 5): a throw, a non-object, or an object whose `code` or `message` is not a string all answer
|
|
202
|
+
* `null`, so the caller keeps the generic refusal. A throw logs only the sanitised error name — the
|
|
203
|
+
* closure that throws can see the typed number, so never its message.
|
|
204
|
+
*/
|
|
205
|
+
function runMissingMethodExplainer(explain) {
|
|
206
|
+
try {
|
|
207
|
+
const explained = explain();
|
|
208
|
+
if (typeof explained !== "object" || explained === null) return null;
|
|
209
|
+
const { code, message } = explained;
|
|
210
|
+
return typeof code === "string" && typeof message === "string" ? {
|
|
211
|
+
code,
|
|
212
|
+
message
|
|
213
|
+
} : null;
|
|
214
|
+
} catch (error) {
|
|
215
|
+
console.error("[payment.placeOrder] the registered explainer threw", loggableErrorName(error));
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
164
220
|
* The `startTransaction` counterpart of `invokeSubmission`/`runPreflight` (fix pass, Medium finding):
|
|
165
221
|
* before this, `run()` awaited `startTransaction()` directly, so a **rejection** — as opposed to a
|
|
166
222
|
* resolved payload carrying `userErrors` — escaped past every one of `run()`'s own outcome branches
|
|
@@ -277,6 +333,49 @@ async function invokeGatewayCallback(gatewayCallback, orderGroup, attemptId) {
|
|
|
277
333
|
};
|
|
278
334
|
}
|
|
279
335
|
/**
|
|
336
|
+
* The two codes the server sends today on `gatewayCallback`. Neither is a verdict on the order, so
|
|
337
|
+
* `callbackFreesAttempt` never frees an attempt that carries either (T110, Decision 3):
|
|
338
|
+
* `REDIRECT_REQUIRED` is a bank challenge, and `MISSING_TRANSACTION_COOKIES` means the card POST was
|
|
339
|
+
* already accepted while the callback never reached VTEX, so a second POST could authorize the card twice.
|
|
340
|
+
*/
|
|
341
|
+
const REDIRECT_REQUIRED_CODE = "REDIRECT_REQUIRED";
|
|
342
|
+
const MISSING_TRANSACTION_COOKIES_CODE = "MISSING_TRANSACTION_COOKIES";
|
|
343
|
+
/** The entry's `code`, or `undefined` when it cannot be read (a `null` entry, a getter that throws). */
|
|
344
|
+
function readCode(userError) {
|
|
345
|
+
try {
|
|
346
|
+
return userError.code;
|
|
347
|
+
} catch {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
/** True when the entry carries a string `code` other than this package's own `NETWORK_ERROR`. Never throws. */
|
|
352
|
+
function carriesServerCode(userError) {
|
|
353
|
+
const code = readCode(userError);
|
|
354
|
+
return typeof code === "string" && code !== "NETWORK_ERROR";
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* T110: whether a `gatewayCallback` that reported `userErrors` frees the attempt for a fresh run. It does
|
|
358
|
+
* when the server sent a string `code`, none of the entries is a locked code (`REDIRECT_REQUIRED`,
|
|
359
|
+
* `MISSING_TRANSACTION_COOKIES`), and the result carries no `orderId`: an order the callback confirmed is
|
|
360
|
+
* never freed. Everything else keeps the attempt resume-only, because a payment that may have gone through
|
|
361
|
+
* must never be paid twice. Total, and never throws: a non-array, an empty list or an entry nobody can read
|
|
362
|
+
* frees nothing.
|
|
363
|
+
*
|
|
364
|
+
* Dormant today: the server sends only the two locked codes, so no real callback frees an attempt yet.
|
|
365
|
+
* The rule fires for a server-coded error the server does not send yet (task T225 will). It fails open on
|
|
366
|
+
* a code it does not know (spec AC-5: no per-code table); a future allowlist of the codes that really are
|
|
367
|
+
* declines belongs to T225, not to this hook.
|
|
368
|
+
*/
|
|
369
|
+
function callbackFreesAttempt(callback) {
|
|
370
|
+
const { orderId, userErrors } = callback;
|
|
371
|
+
if (orderId != null) return false;
|
|
372
|
+
if (!Array.isArray(userErrors)) return false;
|
|
373
|
+
return userErrors.some((userError) => carriesServerCode(userError)) && !userErrors.some((userError) => {
|
|
374
|
+
const code = readCode(userError);
|
|
375
|
+
return code === REDIRECT_REQUIRED_CODE || code === MISSING_TRANSACTION_COOKIES_CODE;
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
280
379
|
* T176 (FR-2, FR-3): what the caller reads from a `gatewayCallback` that reported `userErrors`, on both
|
|
281
380
|
* paths that issue it. The gateway already accepted the card POST by then, so a result made only of this
|
|
282
381
|
* package's own collapse — `PAYMENT_NETWORK_ERROR_CODE`, which `usePaymentActions` and
|
|
@@ -292,14 +391,7 @@ function reconcileCallbackUserErrors(userErrors) {
|
|
|
292
391
|
try {
|
|
293
392
|
if (!Array.isArray(userErrors)) return [PLACE_ORDER_UNCONFIRMED_ERROR];
|
|
294
393
|
if (userErrors.length === 0) return userErrors;
|
|
295
|
-
return userErrors.some((userError) =>
|
|
296
|
-
try {
|
|
297
|
-
const code = userError.code;
|
|
298
|
-
return typeof code === "string" && code !== "NETWORK_ERROR";
|
|
299
|
-
} catch {
|
|
300
|
-
return false;
|
|
301
|
-
}
|
|
302
|
-
}) ? userErrors : [PLACE_ORDER_UNCONFIRMED_ERROR];
|
|
394
|
+
return userErrors.some((userError) => carriesServerCode(userError)) ? userErrors : [PLACE_ORDER_UNCONFIRMED_ERROR];
|
|
303
395
|
} catch {
|
|
304
396
|
return [PLACE_ORDER_UNCONFIRMED_ERROR];
|
|
305
397
|
}
|
|
@@ -332,6 +424,165 @@ function generateAttemptId() {
|
|
|
332
424
|
function writeAttemptIfCurrent(setAttempt, attemptId, next) {
|
|
333
425
|
setAttempt?.((prev) => prev !== null && prev.attemptId === attemptId && prev.phase !== "settled" ? next : prev);
|
|
334
426
|
}
|
|
427
|
+
/** The record an attempt carries once nothing was paid: a fresh full sequence is legal next time. */
|
|
428
|
+
function refusedRecord(attemptId) {
|
|
429
|
+
return {
|
|
430
|
+
attemptId,
|
|
431
|
+
phase: "refused",
|
|
432
|
+
orderGroup: null,
|
|
433
|
+
orderId: null
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* The record `resume()` writes once its one `gatewayCallback` answered: `refused` when the retry rule
|
|
438
|
+
* freed the attempt, `unresolved` for any other error, `settled` with the order id on success.
|
|
439
|
+
*/
|
|
440
|
+
function resumedRecord(current, callback, failed, freed) {
|
|
441
|
+
if (freed) return refusedRecord(current.attemptId);
|
|
442
|
+
if (failed) return {
|
|
443
|
+
...current,
|
|
444
|
+
phase: "unresolved"
|
|
445
|
+
};
|
|
446
|
+
return {
|
|
447
|
+
...current,
|
|
448
|
+
phase: "settled",
|
|
449
|
+
orderId: callback.orderId
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* The terminal record `run()`'s `catch` re-asserts: the `settled` one a throw may have interrupted, else
|
|
454
|
+
* `unresolved` once the card was handed over, else `refused`. A failed leg writes the same pair, with
|
|
455
|
+
* no placed attempt: `refused` when it freed the attempt, `unresolved` (keeping the order group) otherwise.
|
|
456
|
+
*/
|
|
457
|
+
function recoveryRecord(attemptId, placedAttempt, handedOver, settledOrderGroup) {
|
|
458
|
+
if (placedAttempt !== null) return placedAttempt;
|
|
459
|
+
return handedOver ? {
|
|
460
|
+
attemptId,
|
|
461
|
+
phase: "unresolved",
|
|
462
|
+
orderGroup: settledOrderGroup,
|
|
463
|
+
orderId: null
|
|
464
|
+
} : refusedRecord(attemptId);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* `run()`'s recovery write, guarded because it goes through the same caller-supplied `setAttempt` that
|
|
468
|
+
* may be what threw in the first place: nothing further can be tried once the writer itself is broken, so
|
|
469
|
+
* it is logged (name only, FR-7) and the caller returns its result either way.
|
|
470
|
+
*/
|
|
471
|
+
function writeRecoveryRecord(setAttempt, attemptId, record) {
|
|
472
|
+
try {
|
|
473
|
+
writeAttemptIfCurrent(setAttempt, attemptId, record);
|
|
474
|
+
} catch (writeError) {
|
|
475
|
+
console.error("[payment.placeOrder] the place-order recovery write threw", attemptId, loggableErrorName(writeError));
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
/** `run()`'s refusal before any request: nothing was paid and the card never left the browser. */
|
|
479
|
+
function refusalBeforeOpening(userErrors) {
|
|
480
|
+
return {
|
|
481
|
+
orderId: null,
|
|
482
|
+
userErrors,
|
|
483
|
+
reachedGateway: false
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
function refused(userErrors) {
|
|
487
|
+
return {
|
|
488
|
+
kind: "refused",
|
|
489
|
+
result: refusalBeforeOpening(userErrors)
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* T47 (Decision 2/4/5): the holder may know a more specific reason than "choose a method". Asked only
|
|
494
|
+
* with nothing selected, and never before the checks that follow, so the order of checks cannot change.
|
|
495
|
+
* Only the opaque refusal comes back, and only its code is logged.
|
|
496
|
+
*/
|
|
497
|
+
function refuseMissingMethod({ path, resolveMissingMethodExplainer }) {
|
|
498
|
+
const explain = path === null ? null : resolveMissingMethodExplainer(path);
|
|
499
|
+
const explained = explain === null ? null : runMissingMethodExplainer(explain);
|
|
500
|
+
if (explained !== null) {
|
|
501
|
+
console.error("[payment.placeOrder] no payment method is selected, and the registered explainer named why", explained.code);
|
|
502
|
+
return refused([explained]);
|
|
503
|
+
}
|
|
504
|
+
console.error("[payment.placeOrder] no payment method is selected");
|
|
505
|
+
return refused([MISSING_METHOD_ERROR]);
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Every synchronous refusal `run()` resolves before anything is opened, in their original order: no
|
|
509
|
+
* registered submission, no selected method, the submit gate, then the holder's own pre-flight. A
|
|
510
|
+
* transaction nothing can complete is dangling state on the order form. The first two causes are one
|
|
511
|
+
* state to a shopper and differ only in the log.
|
|
512
|
+
*/
|
|
513
|
+
function checkSubmissionPreconditions({ channel, selectedMethod, submitGate }) {
|
|
514
|
+
const { path, resolve, resolvePreflight } = channel;
|
|
515
|
+
const submit = path === null ? null : resolve(path);
|
|
516
|
+
if (submit === null) {
|
|
517
|
+
console.error("[payment.placeOrder] no submission is registered for the entry path", path ?? "none");
|
|
518
|
+
return refused([MISSING_SUBMISSION_ERROR]);
|
|
519
|
+
}
|
|
520
|
+
if (selectedMethod === null) return refuseMissingMethod(channel);
|
|
521
|
+
if (submitGate) {
|
|
522
|
+
console.error("[payment.placeOrder] a client-side gate refused the submission", submitGate.code);
|
|
523
|
+
return refused([submitGate]);
|
|
524
|
+
}
|
|
525
|
+
const preflight = path === null ? null : resolvePreflight(path);
|
|
526
|
+
if (preflight) {
|
|
527
|
+
const refusals = runPreflight(preflight);
|
|
528
|
+
if (refusals.length > 0) {
|
|
529
|
+
console.error("[payment.placeOrder] the registered pre-flight refused the submission", refusals[0]?.code);
|
|
530
|
+
return refused(refusals);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return {
|
|
534
|
+
kind: "ready",
|
|
535
|
+
submit,
|
|
536
|
+
method: selectedMethod
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* `run()`'s first backend leg: opens the transaction and settles its payload. Either refusal records
|
|
541
|
+
* `refused` — nothing was paid, so a fresh full sequence stays legal next time — through
|
|
542
|
+
* `writeAttemptIfCurrent`, not a plain write: the caller's closure may be running after its own CTA
|
|
543
|
+
* unmounted (NFR-3), so a newer completion for the same attempt must win instead.
|
|
544
|
+
*/
|
|
545
|
+
async function openTransaction(startTransaction, setAttempt, attemptId) {
|
|
546
|
+
const payload = await invokeStartTransaction(startTransaction);
|
|
547
|
+
if (payload.userErrors.length > 0) {
|
|
548
|
+
writeAttemptIfCurrent(setAttempt, attemptId, refusedRecord(attemptId));
|
|
549
|
+
return {
|
|
550
|
+
kind: "refused",
|
|
551
|
+
result: refusalBeforeOpening(payload.userErrors)
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
const settled = settleTransaction(payload);
|
|
555
|
+
if (settled === null) {
|
|
556
|
+
writeAttemptIfCurrent(setAttempt, attemptId, refusedRecord(attemptId));
|
|
557
|
+
return {
|
|
558
|
+
kind: "refused",
|
|
559
|
+
result: refusalBeforeOpening([INVALID_TRANSACTION_ERROR])
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
return {
|
|
563
|
+
kind: "opened",
|
|
564
|
+
settled
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
/** The descriptor `run()` hands to the registered submission. Nothing in it is sensitive. */
|
|
568
|
+
function buildTransaction({ settled, method, selectedInstallment, billingAddressDifferent }) {
|
|
569
|
+
return {
|
|
570
|
+
gatewayUrl: settled.gatewayUrl,
|
|
571
|
+
transactionId: settled.transactionId,
|
|
572
|
+
merchantName: settled.merchantName,
|
|
573
|
+
orderGroup: settled.orderGroup,
|
|
574
|
+
userProfileId: settled.userProfileId,
|
|
575
|
+
paymentSystem: method.id,
|
|
576
|
+
groupName: method.groupName,
|
|
577
|
+
currencyCode: settled.value.currencyCode,
|
|
578
|
+
valueInCents: settled.valueInCents,
|
|
579
|
+
referenceValueInCents: settled.referenceValueInCents,
|
|
580
|
+
installments: selectedInstallment?.count ?? 1,
|
|
581
|
+
installmentsValueInCents: selectedInstallment && selectedInstallment.count !== 1 ? toMinorUnits(selectedInstallment.value.amount) : settled.valueInCents,
|
|
582
|
+
interestRate: selectedInstallment?.interestRate ?? 0,
|
|
583
|
+
...billingAddressDifferent == null ? {} : { billingAddressDifferent }
|
|
584
|
+
};
|
|
585
|
+
}
|
|
335
586
|
/**
|
|
336
587
|
* T29 (Decision 3, FR-3): the only path back into a `sent`/`unresolved` attempt — `gatewayCallback` is
|
|
337
588
|
* the sole call it ever issues. Module scope, not a `useCallback` inside the hook (fix pass, Low
|
|
@@ -342,13 +593,17 @@ function writeAttemptIfCurrent(setAttempt, attemptId, next) {
|
|
|
342
593
|
* still have read. Hoisting here makes the claim actually true: none of those three is even
|
|
343
594
|
* *importable* from a bare module-level function that takes only `gatewayCallback`/`setAttempt`/
|
|
344
595
|
* `setPlacing`/`current` as arguments — a resume is safe by construction, not by convention.
|
|
596
|
+
*
|
|
597
|
+
* T110: a callback the retry rule frees records `refused`, as `run()` does, so the next click is a fresh
|
|
598
|
+
* full run. This function still issues nothing but `gatewayCallback`.
|
|
345
599
|
*/
|
|
346
600
|
async function resume(gatewayCallback, setAttempt, setPlacing, current) {
|
|
347
601
|
if (!gatewayCallback || current.orderGroup === null) {
|
|
348
602
|
console.error("[payment.placeOrder] cannot resume an attempt with no order group");
|
|
349
603
|
return {
|
|
350
604
|
orderId: null,
|
|
351
|
-
userErrors: [NETWORK_ERROR]
|
|
605
|
+
userErrors: [NETWORK_ERROR],
|
|
606
|
+
reachedGateway: true
|
|
352
607
|
};
|
|
353
608
|
}
|
|
354
609
|
writeAttemptIfCurrent(setAttempt, current.attemptId, {
|
|
@@ -360,30 +615,27 @@ async function resume(gatewayCallback, setAttempt, setPlacing, current) {
|
|
|
360
615
|
const failed = callback.userErrors.length > 0;
|
|
361
616
|
const result = failed ? {
|
|
362
617
|
orderId: null,
|
|
363
|
-
userErrors: reconcileCallbackUserErrors(callback.userErrors)
|
|
618
|
+
userErrors: reconcileCallbackUserErrors(callback.userErrors),
|
|
619
|
+
reachedGateway: true
|
|
364
620
|
} : {
|
|
365
621
|
orderId: callback.orderId,
|
|
366
|
-
userErrors: []
|
|
622
|
+
userErrors: [],
|
|
623
|
+
reachedGateway: true
|
|
367
624
|
};
|
|
625
|
+
const freed = failed && callbackFreesAttempt(callback);
|
|
368
626
|
try {
|
|
369
|
-
writeAttemptIfCurrent(setAttempt, current.attemptId, failed
|
|
370
|
-
...current,
|
|
371
|
-
phase: "unresolved"
|
|
372
|
-
} : {
|
|
373
|
-
...current,
|
|
374
|
-
phase: "settled",
|
|
375
|
-
orderId: callback.orderId
|
|
376
|
-
});
|
|
627
|
+
writeAttemptIfCurrent(setAttempt, current.attemptId, resumedRecord(current, callback, failed, freed));
|
|
377
628
|
} catch (error) {
|
|
378
629
|
console.error("[payment.placeOrder] the resume record write threw", current.attemptId, loggableErrorName(error));
|
|
379
630
|
}
|
|
380
631
|
return result;
|
|
381
632
|
}
|
|
382
633
|
function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDifferent, submitGate }) {
|
|
383
|
-
const { path, resolve, resolvePreflight } = usePaymentSubmission();
|
|
634
|
+
const { path, resolve, resolvePreflight, resolveMissingMethodExplainer } = usePaymentSubmission();
|
|
384
635
|
const [placing, setPlacing] = useState(false);
|
|
385
636
|
const [userErrors, setUserErrors] = useState([]);
|
|
386
637
|
const [orderId, setOrderId] = useState(null);
|
|
638
|
+
const [reachedGateway, setReachedGateway] = useState(null);
|
|
387
639
|
const inFlight = useRef(null);
|
|
388
640
|
const startTransaction = $actions?.payment?.startTransaction;
|
|
389
641
|
const gatewayCallback = $actions?.payment?.gatewayCallback;
|
|
@@ -397,42 +649,22 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
|
|
|
397
649
|
console.error("[payment.placeOrder] the payment action namespace is not injected");
|
|
398
650
|
return {
|
|
399
651
|
orderId: null,
|
|
400
|
-
userErrors: [NETWORK_ERROR]
|
|
401
|
-
|
|
402
|
-
}
|
|
403
|
-
const submit = path === null ? null : resolve(path);
|
|
404
|
-
if (submit === null) {
|
|
405
|
-
console.error("[payment.placeOrder] no submission is registered for the entry path", path ?? "none");
|
|
406
|
-
return {
|
|
407
|
-
orderId: null,
|
|
408
|
-
userErrors: [MISSING_SUBMISSION_ERROR]
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
if (selectedMethod === null) {
|
|
412
|
-
console.error("[payment.placeOrder] no payment method is selected");
|
|
413
|
-
return {
|
|
414
|
-
orderId: null,
|
|
415
|
-
userErrors: [MISSING_METHOD_ERROR]
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
if (submitGate) {
|
|
419
|
-
console.error("[payment.placeOrder] a client-side gate refused the submission", submitGate.code);
|
|
420
|
-
return {
|
|
421
|
-
orderId: null,
|
|
422
|
-
userErrors: [submitGate]
|
|
652
|
+
userErrors: [NETWORK_ERROR],
|
|
653
|
+
reachedGateway: false
|
|
423
654
|
};
|
|
424
655
|
}
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
656
|
+
const verdict = checkSubmissionPreconditions({
|
|
657
|
+
channel: {
|
|
658
|
+
path,
|
|
659
|
+
resolve,
|
|
660
|
+
resolvePreflight,
|
|
661
|
+
resolveMissingMethodExplainer
|
|
662
|
+
},
|
|
663
|
+
selectedMethod,
|
|
664
|
+
submitGate
|
|
665
|
+
});
|
|
666
|
+
if (verdict.kind === "refused") return verdict.result;
|
|
667
|
+
const { submit, method } = verdict;
|
|
436
668
|
let handedOver = false;
|
|
437
669
|
let settledOrderGroup = null;
|
|
438
670
|
let placedAttempt = null;
|
|
@@ -446,32 +678,9 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
|
|
|
446
678
|
});
|
|
447
679
|
try {
|
|
448
680
|
setPlacing(true);
|
|
449
|
-
const
|
|
450
|
-
if (
|
|
451
|
-
|
|
452
|
-
attemptId,
|
|
453
|
-
phase: "refused",
|
|
454
|
-
orderGroup: null,
|
|
455
|
-
orderId: null
|
|
456
|
-
});
|
|
457
|
-
return {
|
|
458
|
-
orderId: null,
|
|
459
|
-
userErrors: payload.userErrors
|
|
460
|
-
};
|
|
461
|
-
}
|
|
462
|
-
const settled = settleTransaction(payload);
|
|
463
|
-
if (settled === null) {
|
|
464
|
-
writeAttemptIfCurrent(setAttempt, attemptId, {
|
|
465
|
-
attemptId,
|
|
466
|
-
phase: "refused",
|
|
467
|
-
orderGroup: null,
|
|
468
|
-
orderId: null
|
|
469
|
-
});
|
|
470
|
-
return {
|
|
471
|
-
orderId: null,
|
|
472
|
-
userErrors: [INVALID_TRANSACTION_ERROR]
|
|
473
|
-
};
|
|
474
|
-
}
|
|
681
|
+
const opened = await openTransaction(startTransaction, setAttempt, attemptId);
|
|
682
|
+
if (opened.kind === "refused") return opened.result;
|
|
683
|
+
const { settled } = opened;
|
|
475
684
|
settledOrderGroup = settled.orderGroup;
|
|
476
685
|
writeAttemptIfCurrent(setAttempt, attemptId, {
|
|
477
686
|
attemptId,
|
|
@@ -479,35 +688,23 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
|
|
|
479
688
|
orderGroup: settled.orderGroup,
|
|
480
689
|
orderId: null
|
|
481
690
|
});
|
|
482
|
-
const transaction = {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
paymentSystem: selectedMethod.id,
|
|
489
|
-
groupName: selectedMethod.groupName,
|
|
490
|
-
currencyCode: settled.value.currencyCode,
|
|
491
|
-
valueInCents: settled.valueInCents,
|
|
492
|
-
referenceValueInCents: settled.referenceValueInCents,
|
|
493
|
-
installments: selectedInstallment?.count ?? 1,
|
|
494
|
-
installmentsValueInCents: selectedInstallment && selectedInstallment.count !== 1 ? toMinorUnits(selectedInstallment.value.amount) : settled.valueInCents,
|
|
495
|
-
interestRate: selectedInstallment?.interestRate ?? 0,
|
|
496
|
-
...billingAddressDifferent != null ? { billingAddressDifferent } : {}
|
|
497
|
-
};
|
|
691
|
+
const transaction = buildTransaction({
|
|
692
|
+
settled,
|
|
693
|
+
method,
|
|
694
|
+
selectedInstallment,
|
|
695
|
+
billingAddressDifferent
|
|
696
|
+
});
|
|
498
697
|
handedOver = true;
|
|
499
698
|
const submissionErrors = await invokeSubmission(submit, transaction);
|
|
500
|
-
if (submissionErrors.length > 0) {
|
|
699
|
+
if (submissionErrors.userErrors.length > 0) {
|
|
700
|
+
const freed = submissionErrors.reachedGateway === false;
|
|
701
|
+
handedOver = !freed;
|
|
501
702
|
outcome = {
|
|
502
703
|
orderId: null,
|
|
503
|
-
userErrors: submissionErrors
|
|
704
|
+
userErrors: submissionErrors.userErrors,
|
|
705
|
+
reachedGateway: !freed
|
|
504
706
|
};
|
|
505
|
-
writeAttemptIfCurrent(setAttempt, attemptId,
|
|
506
|
-
attemptId,
|
|
507
|
-
phase: "unresolved",
|
|
508
|
-
orderGroup: settled.orderGroup,
|
|
509
|
-
orderId: null
|
|
510
|
-
});
|
|
707
|
+
writeAttemptIfCurrent(setAttempt, attemptId, recoveryRecord(attemptId, null, handedOver, settled.orderGroup));
|
|
511
708
|
return outcome;
|
|
512
709
|
}
|
|
513
710
|
writeAttemptIfCurrent(setAttempt, attemptId, {
|
|
@@ -520,14 +717,11 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
|
|
|
520
717
|
if (callback.userErrors.length > 0) {
|
|
521
718
|
outcome = {
|
|
522
719
|
orderId: null,
|
|
523
|
-
userErrors: reconcileCallbackUserErrors(callback.userErrors)
|
|
720
|
+
userErrors: reconcileCallbackUserErrors(callback.userErrors),
|
|
721
|
+
reachedGateway: true
|
|
524
722
|
};
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
phase: "unresolved",
|
|
528
|
-
orderGroup: settled.orderGroup,
|
|
529
|
-
orderId: null
|
|
530
|
-
});
|
|
723
|
+
handedOver = !callbackFreesAttempt(callback);
|
|
724
|
+
writeAttemptIfCurrent(setAttempt, attemptId, recoveryRecord(attemptId, null, handedOver, settled.orderGroup));
|
|
531
725
|
return outcome;
|
|
532
726
|
}
|
|
533
727
|
placedAttempt = {
|
|
@@ -538,7 +732,8 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
|
|
|
538
732
|
};
|
|
539
733
|
outcome = {
|
|
540
734
|
orderId: callback.orderId,
|
|
541
|
-
userErrors: []
|
|
735
|
+
userErrors: [],
|
|
736
|
+
reachedGateway: true
|
|
542
737
|
};
|
|
543
738
|
track?.({
|
|
544
739
|
name: "purchase",
|
|
@@ -552,24 +747,11 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
|
|
|
552
747
|
return outcome;
|
|
553
748
|
} catch (error) {
|
|
554
749
|
console.error("[payment.placeOrder] the place-order sequence threw", attemptId, loggableErrorName(error));
|
|
555
|
-
|
|
556
|
-
writeAttemptIfCurrent(setAttempt, attemptId, placedAttempt ?? (handedOver ? {
|
|
557
|
-
attemptId,
|
|
558
|
-
phase: "unresolved",
|
|
559
|
-
orderGroup: settledOrderGroup,
|
|
560
|
-
orderId: null
|
|
561
|
-
} : {
|
|
562
|
-
attemptId,
|
|
563
|
-
phase: "refused",
|
|
564
|
-
orderGroup: null,
|
|
565
|
-
orderId: null
|
|
566
|
-
}));
|
|
567
|
-
} catch (writeError) {
|
|
568
|
-
console.error("[payment.placeOrder] the place-order recovery write threw", attemptId, loggableErrorName(writeError));
|
|
569
|
-
}
|
|
750
|
+
writeRecoveryRecord(setAttempt, attemptId, recoveryRecord(attemptId, placedAttempt, handedOver, settledOrderGroup));
|
|
570
751
|
return outcome ?? {
|
|
571
752
|
orderId: null,
|
|
572
|
-
userErrors: [NETWORK_ERROR]
|
|
753
|
+
userErrors: [NETWORK_ERROR],
|
|
754
|
+
reachedGateway: handedOver
|
|
573
755
|
};
|
|
574
756
|
}
|
|
575
757
|
}, [
|
|
@@ -579,6 +761,7 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
|
|
|
579
761
|
path,
|
|
580
762
|
resolve,
|
|
581
763
|
resolvePreflight,
|
|
764
|
+
resolveMissingMethodExplainer,
|
|
582
765
|
selectedMethod,
|
|
583
766
|
selectedInstallment,
|
|
584
767
|
billingAddressDifferent,
|
|
@@ -590,28 +773,33 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
|
|
|
590
773
|
const settleSequence = (sequence) => {
|
|
591
774
|
setUserErrors([]);
|
|
592
775
|
setOrderId(null);
|
|
776
|
+
setReachedGateway(null);
|
|
593
777
|
const settle = (result) => {
|
|
594
778
|
inFlight.current = null;
|
|
595
779
|
setPlacing(false);
|
|
596
780
|
setUserErrors(result.userErrors);
|
|
597
781
|
setOrderId(result.orderId);
|
|
782
|
+
setReachedGateway(result.reachedGateway);
|
|
598
783
|
return result;
|
|
599
784
|
};
|
|
600
785
|
const outcome = sequence.then(settle, () => settle({
|
|
601
786
|
orderId: null,
|
|
602
|
-
userErrors: [NETWORK_ERROR]
|
|
787
|
+
userErrors: [NETWORK_ERROR],
|
|
788
|
+
reachedGateway: true
|
|
603
789
|
}));
|
|
604
790
|
inFlight.current = outcome;
|
|
605
791
|
return outcome;
|
|
606
792
|
};
|
|
607
793
|
if (attempt) {
|
|
608
|
-
if (attempt.phase === "settled") return Promise.resolve({
|
|
794
|
+
if (attempt.phase === "settled") return settleSequence(Promise.resolve({
|
|
609
795
|
orderId: attempt.orderId,
|
|
610
|
-
userErrors: []
|
|
611
|
-
|
|
796
|
+
userErrors: [],
|
|
797
|
+
reachedGateway: true
|
|
798
|
+
}));
|
|
612
799
|
if (attempt.phase === "opening" || attempt.phase === "finalizing") return settleSequence(Promise.resolve({
|
|
613
800
|
orderId: attempt.orderId,
|
|
614
|
-
userErrors: [PLACE_ORDER_IN_FLIGHT_ERROR]
|
|
801
|
+
userErrors: [PLACE_ORDER_IN_FLIGHT_ERROR],
|
|
802
|
+
reachedGateway: true
|
|
615
803
|
}));
|
|
616
804
|
if (attempt.phase === "sent" || attempt.phase === "unresolved") return settleSequence(resume(gatewayCallback, setAttempt, setPlacing, attempt));
|
|
617
805
|
}
|
|
@@ -626,12 +814,14 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
|
|
|
626
814
|
placeOrder,
|
|
627
815
|
placing,
|
|
628
816
|
userErrors,
|
|
629
|
-
orderId
|
|
817
|
+
orderId,
|
|
818
|
+
reachedGateway
|
|
630
819
|
}), [
|
|
631
820
|
placeOrder,
|
|
632
821
|
placing,
|
|
633
822
|
userErrors,
|
|
634
|
-
orderId
|
|
823
|
+
orderId,
|
|
824
|
+
reachedGateway
|
|
635
825
|
]);
|
|
636
826
|
}
|
|
637
827
|
//#endregion
|