@vtex/faststore 0.0.7 → 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 +43 -0
- package/dist/actions.json +152 -1
- package/dist/catalog.json +1264 -142
- 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 +34 -7
- package/dist/components.js +38 -11
- package/dist/content-types.json +523 -0
- package/dist/core/dist/define-component.d.ts +6 -1
- 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.md +5 -5
- package/dist/docs/alert-dialog.md +2 -2
- 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 +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 +14 -3
- package/dist/docs/place-order.md +13 -9
- 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 +6 -2
- package/dist/index.js +2 -1
- package/dist/internal/client.d.ts +6 -1
- package/dist/internal/client.js +7 -2
- package/dist/internal/server.d.ts +6 -2
- package/dist/internal/server.js +6 -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/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.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 +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/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/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 +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/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 +1014 -28
- 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/cache/storefront-cache.js +29 -4
- package/dist/sdk/cache/storefront-cache.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.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 +3 -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 +212 -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/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 +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/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/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 +27 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { isCountryField } from "./constants.js";
|
|
2
|
+
//#region src/sdk/address/layouts.ts
|
|
3
|
+
/**
|
|
4
|
+
* A line is written as it prints, with each field in braces: `{city}, {state} {postalCode}`. The
|
|
5
|
+
* text before a field is its separator. Only the first field of a line has none.
|
|
6
|
+
*/
|
|
7
|
+
function parseLine(line) {
|
|
8
|
+
const parts = [];
|
|
9
|
+
let cursor = 0;
|
|
10
|
+
for (const match of line.matchAll(/\{(\w+)\}/g)) {
|
|
11
|
+
const field = match[1] ?? "";
|
|
12
|
+
const separator = line.slice(cursor, match.index);
|
|
13
|
+
cursor = match.index + match[0].length;
|
|
14
|
+
if (!isCountryField(field)) throw new Error(`Unknown address field "${field}" in layout line "${line}"`);
|
|
15
|
+
parts.push(separator === "" ? { field } : {
|
|
16
|
+
field,
|
|
17
|
+
separator
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return parts;
|
|
21
|
+
}
|
|
22
|
+
function layout(...lines) {
|
|
23
|
+
return lines.map(parseLine);
|
|
24
|
+
}
|
|
25
|
+
const NORTH_AMERICA = layout("{number} {street}", "{complement}", "{neighborhood}", "{city}, {state} {postalCode}");
|
|
26
|
+
const ISLES = layout("{number} {street}", "{complement}", "{neighborhood}", "{city}", "{state}", "{postalCode}");
|
|
27
|
+
function withStateLine(street, locality) {
|
|
28
|
+
return layout(street, "{complement}", "{neighborhood}", locality, "{state}");
|
|
29
|
+
}
|
|
30
|
+
/** Used for every country the library does not cover. */
|
|
31
|
+
const DEFAULT_LAYOUT = layout("{street}, {number}", "{complement}", "{neighborhood}", "{city}, {state} {postalCode}");
|
|
32
|
+
/**
|
|
33
|
+
* How each covered country prints an address. The library's field order is the form's, not the
|
|
34
|
+
* mail's, so it cannot stand in for this. Every layout places each of the seven fields once.
|
|
35
|
+
*/
|
|
36
|
+
const ADDRESS_LAYOUTS = {
|
|
37
|
+
BRA: layout("{street}, {number} - {complement}", "{neighborhood}", "{city} - {state}", "{postalCode}"),
|
|
38
|
+
USA: NORTH_AMERICA,
|
|
39
|
+
CAN: NORTH_AMERICA,
|
|
40
|
+
GBR: ISLES,
|
|
41
|
+
IRL: ISLES,
|
|
42
|
+
FRA: withStateLine("{number} {street}", "{postalCode} {city}"),
|
|
43
|
+
ITA: layout("{street}, {number}", "{complement}", "{neighborhood}", "{postalCode} {city} {state}"),
|
|
44
|
+
DEU: withStateLine("{street} {number}", "{postalCode} {city}"),
|
|
45
|
+
ARG: withStateLine("{street} {number}", "{postalCode} {city}"),
|
|
46
|
+
ESP: withStateLine("{street}, {number}", "{postalCode} {city}"),
|
|
47
|
+
MEX: layout("{street} {number}", "{complement}", "{neighborhood}", "{postalCode} {city}, {state}"),
|
|
48
|
+
COL: layout("{street} {number}", "{complement}", "{neighborhood}", "{city}, {state}", "{postalCode}"),
|
|
49
|
+
CHL: layout("{street} {number}", "{complement}", "{neighborhood}, {city}", "{state}", "{postalCode}"),
|
|
50
|
+
PER: layout("{street} {number}", "{complement}", "{neighborhood}, {city}", "{state} {postalCode}"),
|
|
51
|
+
ECU: layout("{street} {number}", "{complement}", "{neighborhood}", "{city} {postalCode}", "{state}")
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
|
54
|
+
export { ADDRESS_LAYOUTS, DEFAULT_LAYOUT };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=layouts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layouts.js","names":[],"sources":["../../../src/sdk/address/layouts.ts"],"sourcesContent":["import { isCountryField } from './constants.js';\nimport type { AddressDisplayLine, AddressDisplayPart } from './types.js';\n\n/**\n * A line is written as it prints, with each field in braces: `{city}, {state} {postalCode}`. The\n * text before a field is its separator. Only the first field of a line has none.\n */\nfunction parseLine(line: string): AddressDisplayLine {\n const parts: AddressDisplayPart[] = [];\n let cursor = 0;\n for (const match of line.matchAll(/\\{(\\w+)\\}/g)) {\n const field = match[1] ?? '';\n const separator = line.slice(cursor, match.index);\n cursor = match.index + match[0].length;\n if (!isCountryField(field)) {\n throw new Error(`Unknown address field \"${field}\" in layout line \"${line}\"`);\n }\n parts.push(separator === '' ? { field } : { field, separator });\n }\n return parts;\n}\n\nfunction layout(...lines: string[]): readonly AddressDisplayLine[] {\n return lines.map(parseLine);\n}\n\nconst NORTH_AMERICA = layout('{number} {street}', '{complement}', '{neighborhood}', '{city}, {state} {postalCode}');\n\nconst ISLES = layout('{number} {street}', '{complement}', '{neighborhood}', '{city}', '{state}', '{postalCode}');\n\nfunction withStateLine(street: string, locality: string): readonly AddressDisplayLine[] {\n return layout(street, '{complement}', '{neighborhood}', locality, '{state}');\n}\n\n/** Used for every country the library does not cover. */\nexport const DEFAULT_LAYOUT = layout(\n '{street}, {number}',\n '{complement}',\n '{neighborhood}',\n '{city}, {state} {postalCode}',\n);\n\n/**\n * How each covered country prints an address. The library's field order is the form's, not the\n * mail's, so it cannot stand in for this. Every layout places each of the seven fields once.\n */\nexport const ADDRESS_LAYOUTS: Readonly<Record<string, readonly AddressDisplayLine[]>> = {\n BRA: layout('{street}, {number} - {complement}', '{neighborhood}', '{city} - {state}', '{postalCode}'),\n USA: NORTH_AMERICA,\n CAN: NORTH_AMERICA,\n GBR: ISLES,\n IRL: ISLES,\n FRA: withStateLine('{number} {street}', '{postalCode} {city}'),\n ITA: layout('{street}, {number}', '{complement}', '{neighborhood}', '{postalCode} {city} {state}'),\n DEU: withStateLine('{street} {number}', '{postalCode} {city}'),\n ARG: withStateLine('{street} {number}', '{postalCode} {city}'),\n ESP: withStateLine('{street}, {number}', '{postalCode} {city}'),\n MEX: layout('{street} {number}', '{complement}', '{neighborhood}', '{postalCode} {city}, {state}'),\n COL: layout('{street} {number}', '{complement}', '{neighborhood}', '{city}, {state}', '{postalCode}'),\n CHL: layout('{street} {number}', '{complement}', '{neighborhood}, {city}', '{state}', '{postalCode}'),\n PER: layout('{street} {number}', '{complement}', '{neighborhood}, {city}', '{state} {postalCode}'),\n ECU: layout('{street} {number}', '{complement}', '{neighborhood}', '{city} {postalCode}', '{state}'),\n};\n"],"mappings":";;;;;;AAOA,SAAS,UAAU,MAAkC;CACnD,MAAM,QAA8B,CAAC;CACrC,IAAI,SAAS;CACb,KAAK,MAAM,SAAS,KAAK,SAAS,YAAY,GAAG;EAC/C,MAAM,QAAQ,MAAM,MAAM;EAC1B,MAAM,YAAY,KAAK,MAAM,QAAQ,MAAM,KAAK;EAChD,SAAS,MAAM,QAAQ,MAAM,EAAE,CAAC;EAChC,IAAI,CAAC,eAAe,KAAK,GACvB,MAAM,IAAI,MAAM,0BAA0B,MAAM,oBAAoB,KAAK,EAAE;EAE7E,MAAM,KAAK,cAAc,KAAK,EAAE,MAAM,IAAI;GAAE;GAAO;EAAU,CAAC;CAChE;CACA,OAAO;AACT;AAEA,SAAS,OAAO,GAAG,OAAgD;CACjE,OAAO,MAAM,IAAI,SAAS;AAC5B;AAEA,MAAM,gBAAgB,OAAO,qBAAqB,gBAAgB,kBAAkB,8BAA8B;AAElH,MAAM,QAAQ,OAAO,qBAAqB,gBAAgB,kBAAkB,UAAU,WAAW,cAAc;AAE/G,SAAS,cAAc,QAAgB,UAAiD;CACtF,OAAO,OAAO,QAAQ,gBAAgB,kBAAkB,UAAU,SAAS;AAC7E;;AAGA,MAAa,iBAAiB,OAC5B,sBACA,gBACA,kBACA,8BACF;;;;;AAMA,MAAa,kBAA2E;CACtF,KAAK,OAAO,qCAAqC,kBAAkB,oBAAoB,cAAc;CACrG,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK,cAAc,qBAAqB,qBAAqB;CAC7D,KAAK,OAAO,sBAAsB,gBAAgB,kBAAkB,6BAA6B;CACjG,KAAK,cAAc,qBAAqB,qBAAqB;CAC7D,KAAK,cAAc,qBAAqB,qBAAqB;CAC7D,KAAK,cAAc,sBAAsB,qBAAqB;CAC9D,KAAK,OAAO,qBAAqB,gBAAgB,kBAAkB,8BAA8B;CACjG,KAAK,OAAO,qBAAqB,gBAAgB,kBAAkB,mBAAmB,cAAc;CACpG,KAAK,OAAO,qBAAqB,gBAAgB,0BAA0B,WAAW,cAAc;CACpG,KAAK,OAAO,qBAAqB,gBAAgB,0BAA0B,sBAAsB;CACjG,KAAK,OAAO,qBAAqB,gBAAgB,kBAAkB,uBAAuB,SAAS;AACrG"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
//#region src/sdk/address/messages.ts
|
|
2
|
+
const POSTAL_CODE_PLACEHOLDER_PREFIX = "country-forms.address.postalCode.placeholder.";
|
|
3
|
+
const POSTAL_CODE_ERROR_PREFIX = "country-forms.validation.postalCode.";
|
|
4
|
+
/** The library's label key for a field, mapped by meaning: `state.label.COL` and `department.label` agree. */
|
|
5
|
+
const LABEL_IDS = {
|
|
6
|
+
"country-forms.address.postalCode.label": "fs/address.field.postal-code",
|
|
7
|
+
"country-forms.address.postalCode.label.GBR": "fs/address.field.postcode",
|
|
8
|
+
"country-forms.address.street.label": "fs/address.field.street",
|
|
9
|
+
"country-forms.address.number.label": "fs/address.field.number",
|
|
10
|
+
"country-forms.address.complement.label": "fs/address.field.complement",
|
|
11
|
+
"country-forms.address.neighborhood.label": "fs/address.field.neighborhood",
|
|
12
|
+
"country-forms.address.neighborhood.label.CHL": "fs/address.field.commune",
|
|
13
|
+
"country-forms.address.neighborhood.label.PER": "fs/address.field.district",
|
|
14
|
+
"country-forms.address.city.label": "fs/address.field.city",
|
|
15
|
+
"country-forms.address.city.label.ECU": "fs/address.field.city",
|
|
16
|
+
"country-forms.address.city.label.GBR": "fs/address.field.town",
|
|
17
|
+
"country-forms.address.city.label.COL": "fs/address.field.municipality",
|
|
18
|
+
"country-forms.address.city.label.PER": "fs/address.field.province",
|
|
19
|
+
"country-forms.address.state.label": "fs/address.field.state",
|
|
20
|
+
"country-forms.address.state.label.CHL": "fs/address.field.region",
|
|
21
|
+
"country-forms.address.state.label.COL": "fs/address.field.department",
|
|
22
|
+
"country-forms.address.state.label.PER": "fs/address.field.department",
|
|
23
|
+
"country-forms.address.state.label.ECU": "fs/address.field.province",
|
|
24
|
+
"country-forms.address.state.label.ITA": "fs/address.field.province",
|
|
25
|
+
"country-forms.address.state.label.GBR": "fs/address.field.county",
|
|
26
|
+
"country-forms.address.state.label.IRL": "fs/address.field.county",
|
|
27
|
+
"country-forms.address.department.label": "fs/address.field.department"
|
|
28
|
+
};
|
|
29
|
+
/** The label of a field whose library key this module does not know. */
|
|
30
|
+
const FIELD_LABEL_IDS = {
|
|
31
|
+
postalCode: "fs/address.field.postal-code",
|
|
32
|
+
street: "fs/address.field.street",
|
|
33
|
+
number: "fs/address.field.number",
|
|
34
|
+
complement: "fs/address.field.complement",
|
|
35
|
+
neighborhood: "fs/address.field.neighborhood",
|
|
36
|
+
state: "fs/address.field.state",
|
|
37
|
+
city: "fs/address.field.city"
|
|
38
|
+
};
|
|
39
|
+
const STREET_PLACEHOLDER_KEY = "country-forms.address.street.placeholder";
|
|
40
|
+
/** Examples in the stored, masked form. The library's own placeholders, one per country. */
|
|
41
|
+
const POSTAL_CODE_EXAMPLES = {
|
|
42
|
+
ARG: "C1425ABC",
|
|
43
|
+
BRA: "01310-100",
|
|
44
|
+
CAN: "K1A 0A9",
|
|
45
|
+
CHL: "8320000",
|
|
46
|
+
COL: "110111",
|
|
47
|
+
DEU: "10115",
|
|
48
|
+
ECU: "170150",
|
|
49
|
+
ESP: "28001",
|
|
50
|
+
FRA: "75001",
|
|
51
|
+
GBR: "SW1A 1AA",
|
|
52
|
+
IRL: "D02 AF30",
|
|
53
|
+
ITA: "00118",
|
|
54
|
+
MEX: "06600",
|
|
55
|
+
PER: "15074",
|
|
56
|
+
USA: "10001-1234"
|
|
57
|
+
};
|
|
58
|
+
function resolveLabelId(key, field, country) {
|
|
59
|
+
if (country === "BRA" && field === "postalCode") return "fs/address.field.cep";
|
|
60
|
+
return LABEL_IDS[key] ?? FIELD_LABEL_IDS[field];
|
|
61
|
+
}
|
|
62
|
+
function resolvePlaceholder(key, country) {
|
|
63
|
+
if (key === "country-forms.address.street.placeholder") return {
|
|
64
|
+
id: "fs/address.placeholder.street",
|
|
65
|
+
values: {}
|
|
66
|
+
};
|
|
67
|
+
const example = POSTAL_CODE_EXAMPLES[country];
|
|
68
|
+
if (key?.startsWith(POSTAL_CODE_PLACEHOLDER_PREFIX) && example !== void 0) return {
|
|
69
|
+
id: "fs/address.placeholder.postal-code",
|
|
70
|
+
values: { example }
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function error(code, messageId, values) {
|
|
74
|
+
return values === void 0 ? {
|
|
75
|
+
code,
|
|
76
|
+
messageId
|
|
77
|
+
} : {
|
|
78
|
+
code,
|
|
79
|
+
messageId,
|
|
80
|
+
values
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Turns the message key the library returned for a field into an error. A key this module does not
|
|
85
|
+
* know is `invalid`, so a newer library never produces an error the form cannot word.
|
|
86
|
+
*/
|
|
87
|
+
function resolveLibraryError(key, { country, maxLength }) {
|
|
88
|
+
if (key === "country-forms.validation.required") return error("required", "fs/address.error.required");
|
|
89
|
+
if (key === "country-forms.validation.maxLength" && maxLength !== void 0) return error("tooLong", "fs/address.error.too-long", { maxLength });
|
|
90
|
+
const example = POSTAL_CODE_EXAMPLES[country];
|
|
91
|
+
if (key.startsWith(POSTAL_CODE_ERROR_PREFIX) && example !== void 0) return error("invalid", country === "BRA" ? "fs/address.error.cep" : "fs/address.error.postal-code", { example });
|
|
92
|
+
return error("invalid", "fs/address.error.invalid");
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
export { LABEL_IDS, POSTAL_CODE_EXAMPLES, STREET_PLACEHOLDER_KEY, resolveLabelId, resolveLibraryError, resolvePlaceholder };
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","names":[],"sources":["../../../src/sdk/address/messages.ts"],"sourcesContent":["import type { MessageId } from '../i18n/client.js';\nimport type { AddressErrorCode, AddressFieldError, CountryFieldName } from './types.js';\n\nconst POSTAL_CODE_PLACEHOLDER_PREFIX = 'country-forms.address.postalCode.placeholder.';\nconst POSTAL_CODE_ERROR_PREFIX = 'country-forms.validation.postalCode.';\n\n/** The library's label key for a field, mapped by meaning: `state.label.COL` and `department.label` agree. */\nexport const LABEL_IDS: Readonly<Record<string, MessageId>> = {\n 'country-forms.address.postalCode.label': 'fs/address.field.postal-code',\n 'country-forms.address.postalCode.label.GBR': 'fs/address.field.postcode',\n 'country-forms.address.street.label': 'fs/address.field.street',\n 'country-forms.address.number.label': 'fs/address.field.number',\n 'country-forms.address.complement.label': 'fs/address.field.complement',\n 'country-forms.address.neighborhood.label': 'fs/address.field.neighborhood',\n 'country-forms.address.neighborhood.label.CHL': 'fs/address.field.commune',\n 'country-forms.address.neighborhood.label.PER': 'fs/address.field.district',\n 'country-forms.address.city.label': 'fs/address.field.city',\n 'country-forms.address.city.label.ECU': 'fs/address.field.city',\n 'country-forms.address.city.label.GBR': 'fs/address.field.town',\n 'country-forms.address.city.label.COL': 'fs/address.field.municipality',\n 'country-forms.address.city.label.PER': 'fs/address.field.province',\n 'country-forms.address.state.label': 'fs/address.field.state',\n 'country-forms.address.state.label.CHL': 'fs/address.field.region',\n 'country-forms.address.state.label.COL': 'fs/address.field.department',\n 'country-forms.address.state.label.PER': 'fs/address.field.department',\n 'country-forms.address.state.label.ECU': 'fs/address.field.province',\n 'country-forms.address.state.label.ITA': 'fs/address.field.province',\n 'country-forms.address.state.label.GBR': 'fs/address.field.county',\n 'country-forms.address.state.label.IRL': 'fs/address.field.county',\n 'country-forms.address.department.label': 'fs/address.field.department',\n};\n\n/** The label of a field whose library key this module does not know. */\nconst FIELD_LABEL_IDS: Readonly<Record<CountryFieldName, MessageId>> = {\n postalCode: 'fs/address.field.postal-code',\n street: 'fs/address.field.street',\n number: 'fs/address.field.number',\n complement: 'fs/address.field.complement',\n neighborhood: 'fs/address.field.neighborhood',\n state: 'fs/address.field.state',\n city: 'fs/address.field.city',\n};\n\nexport const STREET_PLACEHOLDER_KEY = 'country-forms.address.street.placeholder';\n\n/** Examples in the stored, masked form. The library's own placeholders, one per country. */\nexport const POSTAL_CODE_EXAMPLES: Readonly<Record<string, string>> = {\n ARG: 'C1425ABC',\n BRA: '01310-100',\n CAN: 'K1A 0A9',\n CHL: '8320000',\n COL: '110111',\n DEU: '10115',\n ECU: '170150',\n ESP: '28001',\n FRA: '75001',\n GBR: 'SW1A 1AA',\n IRL: 'D02 AF30',\n ITA: '00118',\n MEX: '06600',\n PER: '15074',\n USA: '10001-1234',\n};\n\nexport function resolveLabelId(key: string, field: CountryFieldName, country: string): MessageId {\n if (country === 'BRA' && field === 'postalCode') {\n return 'fs/address.field.cep';\n }\n return LABEL_IDS[key] ?? FIELD_LABEL_IDS[field];\n}\n\nexport function resolvePlaceholder(\n key: string | undefined,\n country: string,\n): Readonly<{ id: MessageId; values: Readonly<Record<string, string>> }> | undefined {\n if (key === STREET_PLACEHOLDER_KEY) {\n return { id: 'fs/address.placeholder.street', values: {} };\n }\n const example = POSTAL_CODE_EXAMPLES[country];\n if (key?.startsWith(POSTAL_CODE_PLACEHOLDER_PREFIX) && example !== undefined) {\n return { id: 'fs/address.placeholder.postal-code', values: { example } };\n }\n return undefined;\n}\n\nfunction error(code: AddressErrorCode, messageId: MessageId, values?: Record<string, string | number>) {\n return values === undefined ? { code, messageId } : { code, messageId, values };\n}\n\n/**\n * Turns the message key the library returned for a field into an error. A key this module does not\n * know is `invalid`, so a newer library never produces an error the form cannot word.\n */\nexport function resolveLibraryError(\n key: string,\n { country, maxLength }: Readonly<{ country: string; maxLength?: number }>,\n): AddressFieldError {\n if (key === 'country-forms.validation.required') {\n return error('required', 'fs/address.error.required');\n }\n if (key === 'country-forms.validation.maxLength' && maxLength !== undefined) {\n return error('tooLong', 'fs/address.error.too-long', { maxLength });\n }\n const example = POSTAL_CODE_EXAMPLES[country];\n if (key.startsWith(POSTAL_CODE_ERROR_PREFIX) && example !== undefined) {\n return error('invalid', country === 'BRA' ? 'fs/address.error.cep' : 'fs/address.error.postal-code', { example });\n }\n return error('invalid', 'fs/address.error.invalid');\n}\n"],"mappings":";AAGA,MAAM,iCAAiC;AACvC,MAAM,2BAA2B;;AAGjC,MAAa,YAAiD;CAC5D,0CAA0C;CAC1C,8CAA8C;CAC9C,sCAAsC;CACtC,sCAAsC;CACtC,0CAA0C;CAC1C,4CAA4C;CAC5C,gDAAgD;CAChD,gDAAgD;CAChD,oCAAoC;CACpC,wCAAwC;CACxC,wCAAwC;CACxC,wCAAwC;CACxC,wCAAwC;CACxC,qCAAqC;CACrC,yCAAyC;CACzC,yCAAyC;CACzC,yCAAyC;CACzC,yCAAyC;CACzC,yCAAyC;CACzC,yCAAyC;CACzC,yCAAyC;CACzC,0CAA0C;AAC5C;;AAGA,MAAM,kBAAiE;CACrE,YAAY;CACZ,QAAQ;CACR,QAAQ;CACR,YAAY;CACZ,cAAc;CACd,OAAO;CACP,MAAM;AACR;AAEA,MAAa,yBAAyB;;AAGtC,MAAa,uBAAyD;CACpE,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;AACP;AAEA,SAAgB,eAAe,KAAa,OAAyB,SAA4B;CAC/F,IAAI,YAAY,SAAS,UAAU,cACjC,OAAO;CAET,OAAO,UAAU,QAAQ,gBAAgB;AAC3C;AAEA,SAAgB,mBACd,KACA,SACmF;CACnF,IAAI,QAAA,4CACF,OAAO;EAAE,IAAI;EAAiC,QAAQ,CAAC;CAAE;CAE3D,MAAM,UAAU,qBAAqB;CACrC,IAAI,KAAK,WAAW,8BAA8B,KAAK,YAAY,KAAA,GACjE,OAAO;EAAE,IAAI;EAAsC,QAAQ,EAAE,QAAQ;CAAE;AAG3E;AAEA,SAAS,MAAM,MAAwB,WAAsB,QAA0C;CACrG,OAAO,WAAW,KAAA,IAAY;EAAE;EAAM;CAAU,IAAI;EAAE;EAAM;EAAW;CAAO;AAChF;;;;;AAMA,SAAgB,oBACd,KACA,EAAE,SAAS,aACQ;CACnB,IAAI,QAAQ,qCACV,OAAO,MAAM,YAAY,2BAA2B;CAEtD,IAAI,QAAQ,wCAAwC,cAAc,KAAA,GAChE,OAAO,MAAM,WAAW,6BAA6B,EAAE,UAAU,CAAC;CAEpE,MAAM,UAAU,qBAAqB;CACrC,IAAI,IAAI,WAAW,wBAAwB,KAAK,YAAY,KAAA,GAC1D,OAAO,MAAM,WAAW,YAAY,QAAQ,yBAAyB,gCAAgC,EAAE,QAAQ,CAAC;CAElH,OAAO,MAAM,WAAW,0BAA0B;AACpD"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { TypedDocumentNode } from "@apollo/client";
|
|
2
|
+
//#region src/sdk/address/operations.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The saved-address write documents and the cache-only lookup of the address book.
|
|
5
|
+
*
|
|
6
|
+
* Authored with the hand `gql` tag and excluded from the codegen `documents` glob (see
|
|
7
|
+
* `codegen.ts`), like the identity and region writes: the `gql` tag alone is still plucked by
|
|
8
|
+
* `graphql-codegen`, which would emit duplicates of these hand-written types in `sdk/generated/`.
|
|
9
|
+
*
|
|
10
|
+
* The create and update payloads select every field the list item reads, `__typename` and `id`
|
|
11
|
+
* included, so the response merges into the normalized cache and every subscriber of the entity
|
|
12
|
+
* re-renders with no refetch. A create still needs the list edit the action performs: a new entity
|
|
13
|
+
* is in no list until something appends it.
|
|
14
|
+
*
|
|
15
|
+
* Failures follow ADR-00007's two paths: a refused address arrives as payload `userErrors`, and
|
|
16
|
+
* transport or top-level GraphQL failures are infrastructure, which the handlers map to one
|
|
17
|
+
* client-synthesized code.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* A refused write or a client-synthesized failure. `code` is the server's `CustomerAddressErrorCode`
|
|
21
|
+
* (`NOT_FOUND`, `MISSING_REQUIRED_FIELD`, `INVALID_VALUE`, `UNSUPPORTED_COUNTRY`) or one of the two
|
|
22
|
+
* the client adds, `NETWORK_ERROR` and `UNAUTHORIZED`. `field` is a `CustomerAddressField` such as
|
|
23
|
+
* `POSTAL_CODE`, and null when the failure is about the address as a whole.
|
|
24
|
+
*/
|
|
25
|
+
export type CustomerAddressUserError = Readonly<{
|
|
26
|
+
code: string;
|
|
27
|
+
message: string;
|
|
28
|
+
field: string | null;
|
|
29
|
+
}>;
|
|
30
|
+
/** The fields an address carries besides its country. */
|
|
31
|
+
export type CustomerAddressFields = Readonly<{
|
|
32
|
+
recipientName?: string;
|
|
33
|
+
street?: string;
|
|
34
|
+
number?: string;
|
|
35
|
+
complement?: string;
|
|
36
|
+
neighborhood?: string;
|
|
37
|
+
city?: string;
|
|
38
|
+
state?: string;
|
|
39
|
+
postalCode?: string;
|
|
40
|
+
reference?: string;
|
|
41
|
+
}>;
|
|
42
|
+
/** Mirrors `CustomerAddressCreateInput`. An omitted or empty field is not written. */
|
|
43
|
+
export type AddressCreatePayload = CustomerAddressFields & Readonly<{
|
|
44
|
+
country: string;
|
|
45
|
+
}>;
|
|
46
|
+
/** Mirrors `CustomerAddressUpdateInput` plus the id. Omit a field to keep it; `''` erases it. */
|
|
47
|
+
export type AddressUpdatePayload = CustomerAddressFields & Readonly<{
|
|
48
|
+
id: string;
|
|
49
|
+
}>;
|
|
50
|
+
export type AddressRemovePayload = Readonly<{
|
|
51
|
+
id: string;
|
|
52
|
+
}>;
|
|
53
|
+
//#endregion
|
|
54
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { gql } from "../graphql-tag.js";
|
|
2
|
+
//#region src/sdk/address/operations.ts
|
|
3
|
+
const CUSTOMER_ADDRESS_CREATE = gql`
|
|
4
|
+
mutation CustomerAddressCreate($input: CustomerAddressCreateInput!) {
|
|
5
|
+
customerAddressCreate(input: $input) {
|
|
6
|
+
__typename
|
|
7
|
+
customerAddress {
|
|
8
|
+
__typename
|
|
9
|
+
id
|
|
10
|
+
country
|
|
11
|
+
recipientName
|
|
12
|
+
street
|
|
13
|
+
number
|
|
14
|
+
complement
|
|
15
|
+
neighborhood
|
|
16
|
+
city
|
|
17
|
+
state
|
|
18
|
+
postalCode
|
|
19
|
+
reference
|
|
20
|
+
}
|
|
21
|
+
userErrors {
|
|
22
|
+
code
|
|
23
|
+
message
|
|
24
|
+
field
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
const CUSTOMER_ADDRESS_UPDATE = gql`
|
|
30
|
+
mutation CustomerAddressUpdate($id: ID!, $input: CustomerAddressUpdateInput!) {
|
|
31
|
+
customerAddressUpdate(id: $id, input: $input) {
|
|
32
|
+
__typename
|
|
33
|
+
customerAddress {
|
|
34
|
+
__typename
|
|
35
|
+
id
|
|
36
|
+
country
|
|
37
|
+
recipientName
|
|
38
|
+
street
|
|
39
|
+
number
|
|
40
|
+
complement
|
|
41
|
+
neighborhood
|
|
42
|
+
city
|
|
43
|
+
state
|
|
44
|
+
postalCode
|
|
45
|
+
reference
|
|
46
|
+
}
|
|
47
|
+
userErrors {
|
|
48
|
+
code
|
|
49
|
+
message
|
|
50
|
+
field
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
const CUSTOMER_ADDRESS_DELETE = gql`
|
|
56
|
+
mutation CustomerAddressDelete($id: ID!) {
|
|
57
|
+
customerAddressDelete(id: $id) {
|
|
58
|
+
__typename
|
|
59
|
+
deletedCustomerAddressId
|
|
60
|
+
userErrors {
|
|
61
|
+
code
|
|
62
|
+
message
|
|
63
|
+
field
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
/**
|
|
69
|
+
* Read from the cache only (`cache.readQuery`), never sent: it names the cached address book so a
|
|
70
|
+
* create can append to its list. `null` when no list is mounted.
|
|
71
|
+
*/
|
|
72
|
+
const CUSTOMER_ADDRESS_BOOK_IDENTITY = gql`
|
|
73
|
+
query CustomerAddressBookIdentity {
|
|
74
|
+
customerAddressBook {
|
|
75
|
+
__typename
|
|
76
|
+
id
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
`;
|
|
80
|
+
//#endregion
|
|
81
|
+
export { CUSTOMER_ADDRESS_BOOK_IDENTITY, CUSTOMER_ADDRESS_CREATE, CUSTOMER_ADDRESS_DELETE, CUSTOMER_ADDRESS_UPDATE };
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.js","names":[],"sources":["../../../src/sdk/address/operations.ts"],"sourcesContent":["import type { TypedDocumentNode } from '@apollo/client';\nimport { gql } from '../graphql-tag.js';\n\n/**\n * The saved-address write documents and the cache-only lookup of the address book.\n *\n * Authored with the hand `gql` tag and excluded from the codegen `documents` glob (see\n * `codegen.ts`), like the identity and region writes: the `gql` tag alone is still plucked by\n * `graphql-codegen`, which would emit duplicates of these hand-written types in `sdk/generated/`.\n *\n * The create and update payloads select every field the list item reads, `__typename` and `id`\n * included, so the response merges into the normalized cache and every subscriber of the entity\n * re-renders with no refetch. A create still needs the list edit the action performs: a new entity\n * is in no list until something appends it.\n *\n * Failures follow ADR-00007's two paths: a refused address arrives as payload `userErrors`, and\n * transport or top-level GraphQL failures are infrastructure, which the handlers map to one\n * client-synthesized code.\n */\n\n/**\n * A refused write or a client-synthesized failure. `code` is the server's `CustomerAddressErrorCode`\n * (`NOT_FOUND`, `MISSING_REQUIRED_FIELD`, `INVALID_VALUE`, `UNSUPPORTED_COUNTRY`) or one of the two\n * the client adds, `NETWORK_ERROR` and `UNAUTHORIZED`. `field` is a `CustomerAddressField` such as\n * `POSTAL_CODE`, and null when the failure is about the address as a whole.\n */\nexport type CustomerAddressUserError = Readonly<{\n code: string;\n message: string;\n field: string | null;\n}>;\n\n/** The fields an address carries besides its country. */\nexport type CustomerAddressFields = Readonly<{\n recipientName?: string;\n street?: string;\n number?: string;\n complement?: string;\n neighborhood?: string;\n city?: string;\n state?: string;\n postalCode?: string;\n reference?: string;\n}>;\n\n/** Mirrors `CustomerAddressCreateInput`. An omitted or empty field is not written. */\nexport type AddressCreatePayload = CustomerAddressFields & Readonly<{ country: string }>;\n\n/** Mirrors `CustomerAddressUpdateInput` plus the id. Omit a field to keep it; `''` erases it. */\nexport type AddressUpdatePayload = CustomerAddressFields & Readonly<{ id: string }>;\n\nexport type AddressRemovePayload = Readonly<{ id: string }>;\n\n/** The `CustomerAddress` slice the create and update payloads select. */\nexport type CustomerAddressEntity = Readonly<{\n __typename?: 'CustomerAddress';\n id: string;\n country: string | null;\n recipientName: string | null;\n street: string | null;\n number: string | null;\n complement: string | null;\n neighborhood: string | null;\n city: string | null;\n state: string | null;\n postalCode: string | null;\n reference: string | null;\n}>;\n\ntype CustomerAddressWriteData<Key extends string> = {\n [K in Key]: Readonly<{\n __typename?: string;\n customerAddress: CustomerAddressEntity | null;\n userErrors: readonly CustomerAddressUserError[];\n }>;\n};\n\nexport type CustomerAddressDeleteData = {\n customerAddressDelete: Readonly<{\n __typename?: 'CustomerAddressDeletePayload';\n deletedCustomerAddressId: string | null;\n userErrors: readonly CustomerAddressUserError[];\n }>;\n};\n\nexport type CustomerAddressBookIdentityData = {\n customerAddressBook: Readonly<{ __typename: 'CustomerAddressBook'; id: string }> | null;\n};\n\nexport const CUSTOMER_ADDRESS_CREATE: TypedDocumentNode<\n CustomerAddressWriteData<'customerAddressCreate'>,\n { input: AddressCreatePayload }\n> = gql`\n mutation CustomerAddressCreate($input: CustomerAddressCreateInput!) {\n customerAddressCreate(input: $input) {\n __typename\n customerAddress {\n __typename\n id\n country\n recipientName\n street\n number\n complement\n neighborhood\n city\n state\n postalCode\n reference\n }\n userErrors {\n code\n message\n field\n }\n }\n }\n`;\n\nexport const CUSTOMER_ADDRESS_UPDATE: TypedDocumentNode<\n CustomerAddressWriteData<'customerAddressUpdate'>,\n { id: string; input: CustomerAddressFields }\n> = gql`\n mutation CustomerAddressUpdate($id: ID!, $input: CustomerAddressUpdateInput!) {\n customerAddressUpdate(id: $id, input: $input) {\n __typename\n customerAddress {\n __typename\n id\n country\n recipientName\n street\n number\n complement\n neighborhood\n city\n state\n postalCode\n reference\n }\n userErrors {\n code\n message\n field\n }\n }\n }\n`;\n\nexport const CUSTOMER_ADDRESS_DELETE: TypedDocumentNode<CustomerAddressDeleteData, { id: string }> = gql`\n mutation CustomerAddressDelete($id: ID!) {\n customerAddressDelete(id: $id) {\n __typename\n deletedCustomerAddressId\n userErrors {\n code\n message\n field\n }\n }\n }\n`;\n\n/**\n * Read from the cache only (`cache.readQuery`), never sent: it names the cached address book so a\n * create can append to its list. `null` when no list is mounted.\n */\nexport const CUSTOMER_ADDRESS_BOOK_IDENTITY: TypedDocumentNode<CustomerAddressBookIdentityData, never> = gql`\n query CustomerAddressBookIdentity {\n customerAddressBook {\n __typename\n id\n }\n }\n`;\n"],"mappings":";;AAyFA,MAAa,0BAGT,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BP,MAAa,0BAGT,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BP,MAAa,0BAAwF,GAAG;;;;;;;;;;;;;;;;;AAkBxG,MAAa,iCAA4F,GAAG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { graphql } from "../generated/gql.js";
|
|
2
|
+
//#region src/sdk/address/postal-code-lookup-operations.ts
|
|
3
|
+
/**
|
|
4
|
+
* Postal-code lookup GraphQL operation (specs/sfs-3430-address-by-postal-code.md).
|
|
5
|
+
*
|
|
6
|
+
* Authored via the codegen `graphql()` factory so codegen scans this document and generates
|
|
7
|
+
* `AddressByPostalCodeQuery` and its variables. The selection set is the four fields the platform
|
|
8
|
+
* resolves for a code; `useAddressByPostalCode` maps the result onto the lookup's three outcomes.
|
|
9
|
+
*/
|
|
10
|
+
const ADDRESS_BY_POSTAL_CODE = graphql(`
|
|
11
|
+
query AddressByPostalCode($country: String!, $postalCode: String!) {
|
|
12
|
+
addressByPostalCode(country: $country, postalCode: $postalCode) {
|
|
13
|
+
city
|
|
14
|
+
state
|
|
15
|
+
street
|
|
16
|
+
neighborhood
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`);
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ADDRESS_BY_POSTAL_CODE };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=postal-code-lookup-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postal-code-lookup-operations.js","names":[],"sources":["../../../src/sdk/address/postal-code-lookup-operations.ts"],"sourcesContent":["import type { TypedDocumentNode } from '@apollo/client';\nimport { graphql } from '../generated/gql.js';\nimport type { AddressByPostalCodeQuery, AddressByPostalCodeQueryVariables } from '../generated/graphql.js';\n\n/**\n * Postal-code lookup GraphQL operation (specs/sfs-3430-address-by-postal-code.md).\n *\n * Authored via the codegen `graphql()` factory so codegen scans this document and generates\n * `AddressByPostalCodeQuery` and its variables. The selection set is the four fields the platform\n * resolves for a code; `useAddressByPostalCode` maps the result onto the lookup's three outcomes.\n */\nexport const ADDRESS_BY_POSTAL_CODE: TypedDocumentNode<AddressByPostalCodeQuery, AddressByPostalCodeQueryVariables> =\n graphql(`\n query AddressByPostalCode($country: String!, $postalCode: String!) {\n addressByPostalCode(country: $country, postalCode: $postalCode) {\n city\n state\n street\n neighborhood\n }\n }\n`);\n"],"mappings":";;;;;;;;;AAWA,MAAa,yBACX,QAAQ;;;;;;;;;CAST"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { POSTAL_CODE_LOOKUP_COUNTRIES } from "./constants.js";
|
|
2
|
+
import "@vtex/country-forms";
|
|
3
|
+
//#region src/sdk/address/postal-code.ts
|
|
4
|
+
/** Whether the form offers to fill the address from the postal code for this country. */
|
|
5
|
+
function hasPostalCodeLookup(country) {
|
|
6
|
+
return POSTAL_CODE_LOOKUP_COUNTRIES.includes(country.trim().toUpperCase());
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { hasPostalCodeLookup };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=postal-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postal-code.js","names":[],"sources":["../../../src/sdk/address/postal-code.ts"],"sourcesContent":["import { formatValue, resolveFieldFormatRef, resolveFieldUnformatRef, unformatValue } from '@vtex/country-forms';\nimport { POSTAL_CODE_LOOKUP_COUNTRIES } from './constants.js';\nimport type { CountryRules } from './types.js';\n\n/**\n * The stored form of a postal code: the country's masked form, such as `01001-000`, `20500-0003`, or\n * `SW1A 1AA`. The library accepts most codes with or without the mask but refuses an unmasked US\n * ZIP+4, so the masked form is the one every country accepts. A country with no mask stores the\n * trimmed value. Apply it to a value that passed `validateAddress`.\n */\nexport function normalizePostalCode(value: string, rules: CountryRules): string {\n const trimmed = value.trim();\n const field = rules.schema.fields.find(({ name }) => name === 'postalCode');\n if (!field) {\n return trimmed;\n }\n const values = { postalCode: trimmed };\n return formatValue(\n resolveFieldFormatRef(field, values),\n unformatValue(resolveFieldUnformatRef(field, values), trimmed),\n );\n}\n\n/** Whether the form offers to fill the address from the postal code for this country. */\nexport function hasPostalCodeLookup(country: string): boolean {\n return POSTAL_CODE_LOOKUP_COUNTRIES.includes(country.trim().toUpperCase());\n}\n"],"mappings":";;;;AAwBA,SAAgB,oBAAoB,SAA0B;CAC5D,OAAO,6BAA6B,SAAS,QAAQ,KAAK,CAAC,CAAC,YAAY,CAAC;AAC3E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { COUNTRY_FIELDS } from "./constants.js";
|
|
2
|
+
//#region src/sdk/address/schema.ts
|
|
3
|
+
/** The library only knows the seven country fields. Its state holds strings, never `null`. */
|
|
4
|
+
function toFormValues(values) {
|
|
5
|
+
return Object.fromEntries(COUNTRY_FIELDS.map((name) => [name, values[name] ?? ""]));
|
|
6
|
+
}
|
|
7
|
+
/** The maximum length the library declares for a field, if it declares one. */
|
|
8
|
+
function declaredMaxLength({ validation, maxLength }) {
|
|
9
|
+
return validation?.maxLength?.value ?? maxLength;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { declaredMaxLength, toFormValues };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../../../src/sdk/address/schema.ts"],"sourcesContent":["import type { FieldDefinition, FormValues } from '@vtex/country-forms';\nimport { COUNTRY_FIELDS } from './constants.js';\nimport type { AddressValues } from './types.js';\n\n/** The library only knows the seven country fields. Its state holds strings, never `null`. */\nexport function toFormValues(values: AddressValues): FormValues {\n return Object.fromEntries(COUNTRY_FIELDS.map((name) => [name, values[name] ?? '']));\n}\n\n/** The maximum length the library declares for a field, if it declares one. */\nexport function declaredMaxLength({ validation, maxLength }: FieldDefinition): number | undefined {\n return validation?.maxLength?.value ?? maxLength;\n}\n"],"mappings":";;;AAKA,SAAgB,aAAa,QAAmC;CAC9D,OAAO,OAAO,YAAY,eAAe,KAAK,SAAS,CAAC,MAAM,OAAO,SAAS,EAAE,CAAC,CAAC;AACpF;;AAGA,SAAgB,kBAAkB,EAAE,YAAY,aAAkD;CAChG,OAAO,YAAY,WAAW,SAAS;AACzC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/sdk/address/server-fields.ts
|
|
2
|
+
/** The `CustomerAddressField` values the server names a refused field with, except `COUNTRY`. */
|
|
3
|
+
const FIELD_NAMES = /* @__PURE__ */ new Map([
|
|
4
|
+
["RECIPIENT_NAME", "recipientName"],
|
|
5
|
+
["STREET", "street"],
|
|
6
|
+
["NUMBER", "number"],
|
|
7
|
+
["COMPLEMENT", "complement"],
|
|
8
|
+
["NEIGHBORHOOD", "neighborhood"],
|
|
9
|
+
["CITY", "city"],
|
|
10
|
+
["STATE", "state"],
|
|
11
|
+
["POSTAL_CODE", "postalCode"],
|
|
12
|
+
["REFERENCE", "reference"]
|
|
13
|
+
]);
|
|
14
|
+
/**
|
|
15
|
+
* The form field a server `CustomerAddressUserError.field` refers to. `null` for `COUNTRY` (the
|
|
16
|
+
* form never edits it), for a failure about the address as a whole, and for a name this version
|
|
17
|
+
* does not know, so a caller treats all three the same way: no field to mark.
|
|
18
|
+
*/
|
|
19
|
+
function toAddressFieldName(field) {
|
|
20
|
+
return field === null ? null : FIELD_NAMES.get(field) ?? null;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { toAddressFieldName };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=server-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-fields.js","names":[],"sources":["../../../src/sdk/address/server-fields.ts"],"sourcesContent":["import type { AddressFieldName } from './types.js';\n\n/** The `CustomerAddressField` values the server names a refused field with, except `COUNTRY`. */\nconst FIELD_NAMES: ReadonlyMap<string, AddressFieldName> = new Map([\n ['RECIPIENT_NAME', 'recipientName'],\n ['STREET', 'street'],\n ['NUMBER', 'number'],\n ['COMPLEMENT', 'complement'],\n ['NEIGHBORHOOD', 'neighborhood'],\n ['CITY', 'city'],\n ['STATE', 'state'],\n ['POSTAL_CODE', 'postalCode'],\n ['REFERENCE', 'reference'],\n]);\n\n/**\n * The form field a server `CustomerAddressUserError.field` refers to. `null` for `COUNTRY` (the\n * form never edits it), for a failure about the address as a whole, and for a name this version\n * does not know, so a caller treats all three the same way: no field to mark.\n */\nexport function toAddressFieldName(field: string | null): AddressFieldName | null {\n return field === null ? null : (FIELD_NAMES.get(field) ?? null);\n}\n"],"mappings":";;AAGA,MAAM,8BAAqD,IAAI,IAAI;CACjE,CAAC,kBAAkB,eAAe;CAClC,CAAC,UAAU,QAAQ;CACnB,CAAC,UAAU,QAAQ;CACnB,CAAC,cAAc,YAAY;CAC3B,CAAC,gBAAgB,cAAc;CAC/B,CAAC,QAAQ,MAAM;CACf,CAAC,SAAS,OAAO;CACjB,CAAC,eAAe,YAAY;CAC5B,CAAC,aAAa,WAAW;AAC3B,CAAC;;;;;;AAOD,SAAgB,mBAAmB,OAA+C;CAChF,OAAO,UAAU,OAAO,OAAQ,YAAY,IAAI,KAAK,KAAK;AAC5D"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ACCOUNT_FIELDS, COUNTRY_FIELDS, isCountryField } from "./constants.js";
|
|
2
|
+
import { validateAddress } from "./validate-address.js";
|
|
3
|
+
//#region src/sdk/address/switch-country.ts
|
|
4
|
+
function isBlank(value) {
|
|
5
|
+
return value === null || value === void 0 || value.trim() === "";
|
|
6
|
+
}
|
|
7
|
+
/** The old country's field order, then any field it does not declare, in the default order. */
|
|
8
|
+
function fieldOrder({ schema }) {
|
|
9
|
+
const declared = schema.fields.flatMap(({ name }) => isCountryField(name) ? [name] : []);
|
|
10
|
+
return [...declared, ...COUNTRY_FIELDS.filter((field) => !declared.includes(field))];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Works out what a draft keeps when the shopper changes country. `recipientName`, `reference`, and
|
|
14
|
+
* `name` always stay. A country field stays when the new country declares it, its value passes the
|
|
15
|
+
* new country's rules, and the field it depends on (a city on its state) stays too. Any other
|
|
16
|
+
* non-empty value goes to `setAside`. To go back to the first country, pass `{ ...values, ...setAside }`
|
|
17
|
+
* as the draft: those values pass its rules again, so they return.
|
|
18
|
+
*/
|
|
19
|
+
function switchCountry(draft, from, to) {
|
|
20
|
+
const values = {};
|
|
21
|
+
const setAside = {};
|
|
22
|
+
for (const name of ACCOUNT_FIELDS) {
|
|
23
|
+
const value = draft[name];
|
|
24
|
+
if (!isBlank(value)) values[name] = value ?? "";
|
|
25
|
+
}
|
|
26
|
+
const declared = new Map(to.schema.fields.map((field) => [field.name, field]));
|
|
27
|
+
const present = fieldOrder(from).filter((name) => !isBlank(draft[name]));
|
|
28
|
+
const carried = present.filter((name) => declared.has(name));
|
|
29
|
+
const errors = validateAddress(Object.fromEntries(carried.map((name) => [name, draft[name]])), to);
|
|
30
|
+
const fitting = new Set(carried.filter((name) => !errors[name]));
|
|
31
|
+
let dropped = true;
|
|
32
|
+
while (dropped) {
|
|
33
|
+
dropped = false;
|
|
34
|
+
for (const name of fitting) {
|
|
35
|
+
const controller = declared.get(name)?.dependsOn;
|
|
36
|
+
if (controller !== void 0 && !fitting.has(controller)) {
|
|
37
|
+
fitting.delete(name);
|
|
38
|
+
dropped = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const notCarried = [];
|
|
43
|
+
for (const name of present) if (fitting.has(name)) values[name] = draft[name] ?? "";
|
|
44
|
+
else {
|
|
45
|
+
setAside[name] = draft[name] ?? "";
|
|
46
|
+
notCarried.push(name);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
values,
|
|
50
|
+
setAside,
|
|
51
|
+
notCarried
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { switchCountry };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=switch-country.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switch-country.js","names":[],"sources":["../../../src/sdk/address/switch-country.ts"],"sourcesContent":["import { ACCOUNT_FIELDS, COUNTRY_FIELDS, isCountryField } from './constants.js';\nimport type { AddressFieldName, AddressValues, CountryFieldName, CountryRules, CountrySwitch } from './types.js';\nimport { validateAddress } from './validate-address.js';\n\nfunction isBlank(value: string | null | undefined): boolean {\n return value === null || value === undefined || value.trim() === '';\n}\n\n/** The old country's field order, then any field it does not declare, in the default order. */\nfunction fieldOrder({ schema }: CountryRules): readonly CountryFieldName[] {\n const declared = schema.fields.flatMap(({ name }) => (isCountryField(name) ? [name] : []));\n return [...declared, ...COUNTRY_FIELDS.filter((field) => !declared.includes(field))];\n}\n\n/**\n * Works out what a draft keeps when the shopper changes country. `recipientName`, `reference`, and\n * `name` always stay. A country field stays when the new country declares it, its value passes the\n * new country's rules, and the field it depends on (a city on its state) stays too. Any other\n * non-empty value goes to `setAside`. To go back to the first country, pass `{ ...values, ...setAside }`\n * as the draft: those values pass its rules again, so they return.\n */\nexport function switchCountry(draft: AddressValues, from: CountryRules, to: CountryRules): CountrySwitch {\n const values: Partial<Record<AddressFieldName, string>> = {};\n const setAside: Partial<Record<AddressFieldName, string>> = {};\n\n for (const name of ACCOUNT_FIELDS) {\n const value = draft[name];\n if (!isBlank(value)) {\n values[name] = value ?? '';\n }\n }\n\n const declared = new Map(to.schema.fields.map((field) => [field.name, field]));\n const present = fieldOrder(from).filter((name) => !isBlank(draft[name]));\n const carried = present.filter((name) => declared.has(name));\n const errors = validateAddress(Object.fromEntries(carried.map((name) => [name, draft[name]])), to);\n\n const fitting = new Set<string>(carried.filter((name) => !errors[name]));\n let dropped = true;\n while (dropped) {\n dropped = false;\n for (const name of fitting) {\n const controller = declared.get(name)?.dependsOn;\n if (controller !== undefined && !fitting.has(controller)) {\n fitting.delete(name);\n dropped = true;\n }\n }\n }\n\n const notCarried: AddressFieldName[] = [];\n for (const name of present) {\n if (fitting.has(name)) {\n values[name] = draft[name] ?? '';\n } else {\n setAside[name] = draft[name] ?? '';\n notCarried.push(name);\n }\n }\n\n return { values, setAside, notCarried };\n}\n"],"mappings":";;;AAIA,SAAS,QAAQ,OAA2C;CAC1D,OAAO,UAAU,QAAQ,UAAU,KAAA,KAAa,MAAM,KAAK,MAAM;AACnE;;AAGA,SAAS,WAAW,EAAE,UAAqD;CACzE,MAAM,WAAW,OAAO,OAAO,SAAS,EAAE,WAAY,eAAe,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,CAAE;CACzF,OAAO,CAAC,GAAG,UAAU,GAAG,eAAe,QAAQ,UAAU,CAAC,SAAS,SAAS,KAAK,CAAC,CAAC;AACrF;;;;;;;;AASA,SAAgB,cAAc,OAAsB,MAAoB,IAAiC;CACvG,MAAM,SAAoD,CAAC;CAC3D,MAAM,WAAsD,CAAC;CAE7D,KAAK,MAAM,QAAQ,gBAAgB;EACjC,MAAM,QAAQ,MAAM;EACpB,IAAI,CAAC,QAAQ,KAAK,GAChB,OAAO,QAAQ,SAAS;CAE5B;CAEA,MAAM,WAAW,IAAI,IAAI,GAAG,OAAO,OAAO,KAAK,UAAU,CAAC,MAAM,MAAM,KAAK,CAAC,CAAC;CAC7E,MAAM,UAAU,WAAW,IAAI,CAAC,CAAC,QAAQ,SAAS,CAAC,QAAQ,MAAM,KAAK,CAAC;CACvE,MAAM,UAAU,QAAQ,QAAQ,SAAS,SAAS,IAAI,IAAI,CAAC;CAC3D,MAAM,SAAS,gBAAgB,OAAO,YAAY,QAAQ,KAAK,SAAS,CAAC,MAAM,MAAM,KAAK,CAAC,CAAC,GAAG,EAAE;CAEjG,MAAM,UAAU,IAAI,IAAY,QAAQ,QAAQ,SAAS,CAAC,OAAO,KAAK,CAAC;CACvE,IAAI,UAAU;CACd,OAAO,SAAS;EACd,UAAU;EACV,KAAK,MAAM,QAAQ,SAAS;GAC1B,MAAM,aAAa,SAAS,IAAI,IAAI,CAAC,EAAE;GACvC,IAAI,eAAe,KAAA,KAAa,CAAC,QAAQ,IAAI,UAAU,GAAG;IACxD,QAAQ,OAAO,IAAI;IACnB,UAAU;GACZ;EACF;CACF;CAEA,MAAM,aAAiC,CAAC;CACxC,KAAK,MAAM,QAAQ,SACjB,IAAI,QAAQ,IAAI,IAAI,GAClB,OAAO,QAAQ,MAAM,SAAS;MACzB;EACL,SAAS,QAAQ,MAAM,SAAS;EAChC,WAAW,KAAK,IAAI;CACtB;CAGF,OAAO;EAAE;EAAQ;EAAU;CAAW;AACxC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { MessageId } from "../i18n/locales.js";
|
|
2
|
+
import "../i18n/client.js";
|
|
3
|
+
import { FormSchema } from "@vtex/country-forms";
|
|
4
|
+
//#region src/sdk/address/types.d.ts
|
|
5
|
+
/** The seven fields `@vtex/country-forms` address schemas declare, spelled as on `CustomerAddress`. */
|
|
6
|
+
export type CountryFieldName = 'postalCode' | 'street' | 'number' | 'complement' | 'neighborhood' | 'state' | 'city';
|
|
7
|
+
/** Fields no country declares; the account's own rules cover them. `name` is the shopper's label. */
|
|
8
|
+
export type AccountFieldName = 'recipientName' | 'reference' | 'name';
|
|
9
|
+
export type AddressFieldName = CountryFieldName | AccountFieldName;
|
|
10
|
+
export type AddressErrorCode = 'required' | 'invalid' | 'tooLong';
|
|
11
|
+
export type AddressFieldError = Readonly<{
|
|
12
|
+
code: AddressErrorCode;
|
|
13
|
+
messageId: MessageId;
|
|
14
|
+
/** The values the message interpolates, such as `{ maxLength: 750 }` or `{ example: '01310-100' }`. */
|
|
15
|
+
values?: Readonly<Record<string, string | number>>;
|
|
16
|
+
}>;
|
|
17
|
+
export type CountryRules = Readonly<{
|
|
18
|
+
/** ISO 3166-1 alpha-3, upper case. */
|
|
19
|
+
country: string;
|
|
20
|
+
/** In the library's list of address countries. `false` means the library's fallback form. */
|
|
21
|
+
covered: boolean;
|
|
22
|
+
/** Read only by this module. */
|
|
23
|
+
schema: FormSchema;
|
|
24
|
+
}>;
|
|
25
|
+
//#endregion
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import "../../core/dist/index.js";
|
|
2
|
+
import { AddressCreatePayload, AddressRemovePayload, AddressUpdatePayload, CustomerAddressUserError } from "./operations.js";
|
|
3
|
+
//#region src/sdk/address/use-address-actions.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The `address` action namespace: the one sanctioned client write surface for the shopper's saved
|
|
6
|
+
* addresses (docs/storefront-core/adr-0010-actions-own-the-write-side.md,
|
|
7
|
+
* docs/features/my-account-address-book/rfc.md § Address actions).
|
|
8
|
+
*
|
|
9
|
+
* Every method is async and pessimistic: the cache changes only after the server answers. Each
|
|
10
|
+
* resolves to the payload's `userErrors` (empty on success), with their `field`, so the caller can
|
|
11
|
+
* mark the field. None rejects for an expected outcome. ADR-0010 has handlers surface `userErrors`
|
|
12
|
+
* through the `notifications` action; that action does not exist yet, so the caller presents them.
|
|
13
|
+
*/
|
|
14
|
+
export type AddressActions = Readonly<{
|
|
15
|
+
/** Save a new address. Appends it to the cached address book on success. Never rejects. */
|
|
16
|
+
create: (payload: AddressCreatePayload) => Promise<readonly CustomerAddressUserError[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Change a saved address. Omit a field to keep it; an empty string erases it. Subscribers update
|
|
19
|
+
* through the normalized cache. Never rejects.
|
|
20
|
+
*/
|
|
21
|
+
update: (payload: AddressUpdatePayload) => Promise<readonly CustomerAddressUserError[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Remove a saved address. The list changes only once the server confirms. A `NOT_FOUND` answer
|
|
24
|
+
* means the server no longer has it, so it leaves the cache too. Never rejects.
|
|
25
|
+
*/
|
|
26
|
+
remove: (payload: AddressRemovePayload) => Promise<readonly CustomerAddressUserError[]>;
|
|
27
|
+
}>;
|
|
28
|
+
//#endregion
|
|
29
|
+
//# sourceMappingURL=use-address-actions.d.ts.map
|