@zappie/sdk 0.28.2 → 0.29.1
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 +18 -0
- package/dist/account/index.d.ts +16 -2
- package/dist/account/index.js +0 -1
- package/dist/account/url.js +0 -1
- package/dist/branches/index.d.ts +2 -0
- package/dist/branches/index.js +0 -1
- package/dist/cart/branch.d.ts +18 -0
- package/dist/cart/branch.js +0 -1
- package/dist/cart/errors.js +0 -1
- package/dist/cart/held.js +0 -1
- package/dist/cart/index.js +1 -2
- package/dist/cart/item.d.ts +1 -1
- package/dist/cart/item.js +0 -1
- package/dist/cart/preview.js +0 -1
- package/dist/cart/price.js +0 -1
- package/dist/cart/quote-client.js +0 -1
- package/dist/cart/quote-response.js +1 -2
- package/dist/cart/quote.d.ts +1 -1
- package/dist/cart/reconcile.js +0 -1
- package/dist/cart/source-menu.js +0 -1
- package/dist/cart/storage.js +0 -1
- package/dist/cart/types.js +0 -1
- package/dist/cart/validate.js +0 -1
- package/dist/cart/wire.js +0 -1
- package/dist/cart/working-set.js +0 -1
- package/dist/checkout/client.js +0 -1
- package/dist/checkout/embed.d.ts +67 -2
- package/dist/checkout/embed.js +0 -1
- package/dist/checkout/error.js +0 -1
- package/dist/checkout/index.d.ts +74 -3
- package/dist/checkout/index.js +0 -1
- package/dist/checkout/react.d.ts +67 -2
- package/dist/checkout/react.js +0 -1
- package/dist/checkout/readiness.js +0 -1
- package/dist/checkout/sdk.js +0 -1
- package/dist/checkout/session.js +0 -1
- package/dist/checkout/types.js +0 -1
- package/dist/checkout-defaults/index.d.ts +10 -1
- package/dist/checkout-defaults/index.js +0 -1
- package/dist/{client-B89-aNcl.d.ts → client-CW_OWZ0l.d.ts} +229 -5
- package/dist/client.js +0 -1
- package/dist/config/index.d.ts +38 -3
- package/dist/config/index.js +0 -1
- package/dist/config.js +0 -1
- package/dist/customer/client.js +0 -1
- package/dist/customer/error.js +0 -1
- package/dist/customer/index.d.ts +180 -5
- package/dist/customer/index.js +0 -1
- package/dist/customer/navigation.js +0 -1
- package/dist/customer/react.js +0 -1
- package/dist/customer/reorder.d.ts +8 -0
- package/dist/customer/reorder.js +0 -1
- package/dist/customer/request.js +0 -1
- package/dist/customer/types.js +0 -1
- package/dist/customer/watch-order.js +0 -1
- package/dist/debug.js +1 -2
- package/dist/display/index.d.ts +5 -1
- package/dist/display/index.js +0 -1
- package/dist/error-pages/art.js +0 -1
- package/dist/error-pages/index.d.ts +12 -1
- package/dist/error-pages/index.js +0 -1
- package/dist/error-pages/react.js +0 -1
- package/dist/errors.js +1 -2
- package/dist/in-venue/bill.js +0 -1
- package/dist/in-venue/client.js +0 -1
- package/dist/in-venue/error.js +0 -1
- package/dist/in-venue/index.d.ts +110 -2
- package/dist/in-venue/index.js +0 -1
- package/dist/in-venue/react/bill-page.js +0 -1
- package/dist/in-venue/react/in-venue-page.js +0 -1
- package/dist/in-venue/react/order-panel.js +0 -1
- package/dist/in-venue/react/pay-point-page.js +0 -1
- package/dist/in-venue/react/shared.js +0 -1
- package/dist/in-venue/react/table-menus-page.js +0 -1
- package/dist/in-venue/react.js +0 -1
- package/dist/in-venue/table.js +0 -1
- package/dist/in-venue/types.js +0 -1
- package/dist/in-venue/watch.js +0 -1
- package/dist/index.d.ts +32 -8
- package/dist/index.js +1 -2
- package/dist/integrations/index.d.ts +15 -2
- package/dist/integrations/index.js +0 -1
- package/dist/internal/abort.js +0 -1
- package/dist/internal/cache.js +0 -1
- package/dist/internal/customer-http.js +1 -2
- package/dist/internal/emitter.js +0 -1
- package/dist/internal/image-widths.js +0 -1
- package/dist/internal/money-math.js +0 -1
- package/dist/internal/perk-hold.js +0 -1
- package/dist/internal/remembered-address.js +0 -1
- package/dist/internal/return-path.js +0 -1
- package/dist/internal/service-url.js +0 -1
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +0 -1
- package/dist/loyalty/cart.js +0 -1
- package/dist/loyalty/client.js +0 -1
- package/dist/loyalty/index.d.ts +410 -2
- package/dist/loyalty/index.js +0 -1
- package/dist/loyalty/react.d.ts +15 -1
- package/dist/loyalty/react.js +0 -1
- package/dist/loyalty/release.js +0 -1
- package/dist/loyalty/types.js +0 -1
- package/dist/menu/index.d.ts +5 -1
- package/dist/menu/index.js +0 -1
- package/dist/models-C77LjkK8.d.ts +540 -0
- package/dist/models.js +0 -1
- package/dist/money.js +0 -1
- package/dist/navigation/index.d.ts +8 -0
- package/dist/navigation/index.js +0 -1
- package/dist/navigation/react.js +0 -1
- package/dist/navigation-progress/index.js +0 -1
- package/dist/options/index.d.ts +5 -1
- package/dist/options/index.js +0 -1
- package/dist/persist/catalogue.d.ts +3 -3
- package/dist/persist/catalogue.js +0 -1
- package/dist/places/client.js +0 -1
- package/dist/places/error.js +0 -1
- package/dist/places/index.d.ts +41 -1
- package/dist/places/index.js +0 -1
- package/dist/places/request.js +0 -1
- package/dist/places/sdk.js +0 -1
- package/dist/places/search.js +0 -1
- package/dist/places/types.js +0 -1
- package/dist/pricing/index.js +0 -1
- package/dist/react/cart.js +0 -1
- package/dist/react/changes.js +0 -1
- package/dist/react/hooks.js +0 -1
- package/dist/react/index.js +0 -1
- package/dist/react/provider.js +0 -1
- package/dist/react/rollback.js +0 -1
- package/dist/receipts/index.js +1 -2
- package/dist/redirect/index.js +0 -1
- package/dist/rich-text/index.d.ts +4 -0
- package/dist/rich-text/index.js +0 -1
- package/dist/server/auth/crypto.js +0 -1
- package/dist/server/auth/jwt.js +0 -1
- package/dist/server/auth/session-store.js +0 -1
- package/dist/server/chosen-branch.js +0 -1
- package/dist/server/edge-cache.js +0 -1
- package/dist/server/edge-snapshot.js +0 -1
- package/dist/server/index.d.ts +179 -8
- package/dist/server/index.js +0 -1
- package/dist/server/legacy-order.js +0 -1
- package/dist/server/page-cache.js +0 -1
- package/dist/server/security.js +0 -1
- package/dist/server/sign-in.js +0 -1
- package/dist/server/site-seo.js +0 -1
- package/dist/server/site-worker.js +0 -1
- package/dist/server/storefront-url/build-v1.js +0 -1
- package/dist/server/storefront-url/build-v2.js +0 -1
- package/dist/server/storefront-url/build.js +0 -1
- package/dist/server/storefront-url/canonical.js +0 -1
- package/dist/server/storefront-url/contract.js +0 -1
- package/dist/server/storefront-url/index.js +0 -1
- package/dist/server/storefront-url/installation.js +0 -1
- package/dist/server/storefront-url/params.js +0 -1
- package/dist/server/storefront-url/parse-v1.js +0 -1
- package/dist/server/storefront-url/parse-v2.js +0 -1
- package/dist/server/storefront-url/parse.js +0 -1
- package/dist/server/storefront-url/public-id.js +0 -1
- package/dist/server/storefront-url/redirect.js +0 -1
- package/dist/server/storefront-url/sign-in.js +0 -1
- package/dist/server/storefront-url/types.js +0 -1
- package/dist/server/storefront-url/url.js +0 -1
- package/dist/server/webhook.js +0 -1
- package/dist/services/index.d.ts +5 -1
- package/dist/services/index.js +0 -1
- package/dist/site-closed/index.d.ts +3 -0
- package/dist/site-closed/index.js +0 -1
- package/dist/site-config/helpers.js +0 -1
- package/dist/site-config/sections.js +0 -1
- package/dist/site-config/types.js +0 -1
- package/dist/site-config/validate.js +0 -1
- package/dist/site-error/index.d.ts +9 -1
- package/dist/site-error/index.js +0 -1
- package/dist/site-error/react.js +0 -1
- package/dist/studio/index.d.ts +2 -0
- package/dist/template/index.d.ts +7 -1
- package/dist/template/index.js +0 -1
- package/dist/template/react.js +0 -1
- package/dist/testing/index.d.ts +28 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/loyalty.js +0 -1
- package/dist/transport/category-page.js +0 -1
- package/dist/transport/mappers.js +0 -1
- package/dist/transport/presentation.js +0 -1
- package/dist/transport/quote-body.js +0 -1
- package/dist/transport/rest.js +0 -1
- package/dist/transport/search.d.ts +1 -1
- package/dist/transport/search.js +0 -1
- package/dist/transport/selected-menu.d.ts +3 -3
- package/dist/transport/selected-menu.js +0 -1
- package/dist/transport/store.js +0 -1
- package/dist/transport/types.js +0 -1
- package/dist/types-CuPaBf6k.d.ts +838 -0
- package/dist/uploads/index.js +0 -1
- package/dist/url/index.d.ts +31 -0
- package/dist/url/index.js +0 -1
- package/dist/visits/index.d.ts +26 -1
- package/dist/visits/index.js +0 -1
- package/dist/visits/page-views.js +0 -1
- package/dist/vite/index.d.ts +2 -0
- package/package.json +2 -2
- package/dist/account/index.js.map +0 -6
- package/dist/account/url.js.map +0 -6
- package/dist/branches/index.js.map +0 -6
- package/dist/cart/branch.js.map +0 -6
- package/dist/cart/errors.js.map +0 -6
- package/dist/cart/held.js.map +0 -6
- package/dist/cart/index.js.map +0 -6
- package/dist/cart/item.js.map +0 -6
- package/dist/cart/preview.js.map +0 -6
- package/dist/cart/price.js.map +0 -6
- package/dist/cart/quote-client.js.map +0 -6
- package/dist/cart/quote-response.js.map +0 -6
- package/dist/cart/reconcile.js.map +0 -6
- package/dist/cart/source-menu.js.map +0 -6
- package/dist/cart/storage.js.map +0 -6
- package/dist/cart/types.js.map +0 -6
- package/dist/cart/validate.js.map +0 -6
- package/dist/cart/wire.js.map +0 -6
- package/dist/cart/working-set.js.map +0 -6
- package/dist/checkout/client.js.map +0 -6
- package/dist/checkout/embed.js.map +0 -6
- package/dist/checkout/error.js.map +0 -6
- package/dist/checkout/index.js.map +0 -6
- package/dist/checkout/react.js.map +0 -6
- package/dist/checkout/readiness.js.map +0 -6
- package/dist/checkout/sdk.js.map +0 -6
- package/dist/checkout/session.js.map +0 -6
- package/dist/checkout/types.js.map +0 -6
- package/dist/checkout-defaults/index.js.map +0 -6
- package/dist/client.js.map +0 -6
- package/dist/config/index.js.map +0 -6
- package/dist/config.js.map +0 -6
- package/dist/customer/client.js.map +0 -6
- package/dist/customer/error.js.map +0 -6
- package/dist/customer/index.js.map +0 -6
- package/dist/customer/navigation.js.map +0 -6
- package/dist/customer/react.js.map +0 -6
- package/dist/customer/reorder.js.map +0 -6
- package/dist/customer/request.js.map +0 -6
- package/dist/customer/types.js.map +0 -6
- package/dist/customer/watch-order.js.map +0 -6
- package/dist/debug.js.map +0 -6
- package/dist/display/index.js.map +0 -6
- package/dist/error-pages/art.js.map +0 -6
- package/dist/error-pages/index.js.map +0 -6
- package/dist/error-pages/react.js.map +0 -6
- package/dist/errors.js.map +0 -6
- package/dist/in-venue/bill.js.map +0 -6
- package/dist/in-venue/client.js.map +0 -6
- package/dist/in-venue/error.js.map +0 -6
- package/dist/in-venue/index.js.map +0 -6
- package/dist/in-venue/react/bill-page.js.map +0 -6
- package/dist/in-venue/react/in-venue-page.js.map +0 -6
- package/dist/in-venue/react/order-panel.js.map +0 -6
- package/dist/in-venue/react/pay-point-page.js.map +0 -6
- package/dist/in-venue/react/shared.js.map +0 -6
- package/dist/in-venue/react/table-menus-page.js.map +0 -6
- package/dist/in-venue/react.js.map +0 -6
- package/dist/in-venue/table.js.map +0 -6
- package/dist/in-venue/types.js.map +0 -6
- package/dist/in-venue/watch.js.map +0 -6
- package/dist/index.js.map +0 -6
- package/dist/integrations/index.js.map +0 -6
- package/dist/internal/abort.js.map +0 -6
- package/dist/internal/cache.js.map +0 -6
- package/dist/internal/customer-http.js.map +0 -6
- package/dist/internal/emitter.js.map +0 -6
- package/dist/internal/image-widths.js.map +0 -6
- package/dist/internal/money-math.js.map +0 -6
- package/dist/internal/perk-hold.js.map +0 -6
- package/dist/internal/remembered-address.js.map +0 -6
- package/dist/internal/return-path.js.map +0 -6
- package/dist/internal/service-url.js.map +0 -6
- package/dist/internal.js.map +0 -6
- package/dist/loyalty/cart.js.map +0 -6
- package/dist/loyalty/client.js.map +0 -6
- package/dist/loyalty/index.js.map +0 -6
- package/dist/loyalty/react.js.map +0 -6
- package/dist/loyalty/release.js.map +0 -6
- package/dist/loyalty/types.js.map +0 -6
- package/dist/menu/index.js.map +0 -6
- package/dist/models-DLGs3UI2.d.ts +0 -307
- package/dist/models.js.map +0 -6
- package/dist/money.js.map +0 -6
- package/dist/navigation/index.js.map +0 -6
- package/dist/navigation/react.js.map +0 -6
- package/dist/navigation-progress/index.js.map +0 -6
- package/dist/options/index.js.map +0 -6
- package/dist/persist/catalogue.js.map +0 -6
- package/dist/places/client.js.map +0 -6
- package/dist/places/error.js.map +0 -6
- package/dist/places/index.js.map +0 -6
- package/dist/places/request.js.map +0 -6
- package/dist/places/sdk.js.map +0 -6
- package/dist/places/search.js.map +0 -6
- package/dist/places/types.js.map +0 -6
- package/dist/pricing/index.js.map +0 -6
- package/dist/react/cart.js.map +0 -6
- package/dist/react/changes.js.map +0 -6
- package/dist/react/hooks.js.map +0 -6
- package/dist/react/index.js.map +0 -6
- package/dist/react/provider.js.map +0 -6
- package/dist/react/rollback.js.map +0 -6
- package/dist/receipts/index.js.map +0 -6
- package/dist/redirect/index.js.map +0 -6
- package/dist/rich-text/index.js.map +0 -6
- package/dist/server/auth/crypto.js.map +0 -6
- package/dist/server/auth/jwt.js.map +0 -6
- package/dist/server/auth/session-store.js.map +0 -6
- package/dist/server/chosen-branch.js.map +0 -6
- package/dist/server/edge-cache.js.map +0 -6
- package/dist/server/edge-snapshot.js.map +0 -6
- package/dist/server/index.js.map +0 -6
- package/dist/server/legacy-order.js.map +0 -6
- package/dist/server/page-cache.js.map +0 -6
- package/dist/server/security.js.map +0 -6
- package/dist/server/sign-in.js.map +0 -6
- package/dist/server/site-seo.js.map +0 -6
- package/dist/server/site-worker.js.map +0 -6
- package/dist/server/storefront-url/build-v1.js.map +0 -6
- package/dist/server/storefront-url/build-v2.js.map +0 -6
- package/dist/server/storefront-url/build.js.map +0 -6
- package/dist/server/storefront-url/canonical.js.map +0 -6
- package/dist/server/storefront-url/contract.js.map +0 -6
- package/dist/server/storefront-url/index.js.map +0 -6
- package/dist/server/storefront-url/installation.js.map +0 -6
- package/dist/server/storefront-url/params.js.map +0 -6
- package/dist/server/storefront-url/parse-v1.js.map +0 -6
- package/dist/server/storefront-url/parse-v2.js.map +0 -6
- package/dist/server/storefront-url/parse.js.map +0 -6
- package/dist/server/storefront-url/public-id.js.map +0 -6
- package/dist/server/storefront-url/redirect.js.map +0 -6
- package/dist/server/storefront-url/sign-in.js.map +0 -6
- package/dist/server/storefront-url/types.js.map +0 -6
- package/dist/server/storefront-url/url.js.map +0 -6
- package/dist/server/webhook.js.map +0 -6
- package/dist/services/index.js.map +0 -6
- package/dist/site-closed/index.js.map +0 -6
- package/dist/site-config/helpers.js.map +0 -6
- package/dist/site-config/sections.js.map +0 -6
- package/dist/site-config/types.js.map +0 -6
- package/dist/site-config/validate.js.map +0 -6
- package/dist/site-error/index.js.map +0 -6
- package/dist/site-error/react.js.map +0 -6
- package/dist/template/index.js.map +0 -6
- package/dist/template/react.js.map +0 -6
- package/dist/testing/loyalty.js.map +0 -6
- package/dist/transport/category-page.js.map +0 -6
- package/dist/transport/mappers.js.map +0 -6
- package/dist/transport/presentation.js.map +0 -6
- package/dist/transport/quote-body.js.map +0 -6
- package/dist/transport/rest.js.map +0 -6
- package/dist/transport/search.js.map +0 -6
- package/dist/transport/selected-menu.js.map +0 -6
- package/dist/transport/store.js.map +0 -6
- package/dist/transport/types.js.map +0 -6
- package/dist/types-8HB4-7D9.d.ts +0 -457
- package/dist/uploads/index.js.map +0 -6
- package/dist/url/index.js.map +0 -6
- package/dist/visits/index.js.map +0 -6
- package/dist/visits/page-views.js.map +0 -6
package/dist/checkout/index.d.ts
CHANGED
|
@@ -5,31 +5,54 @@ export { wireFulfilment as checkoutFulfilment } from '@zappie/sdk/internal';
|
|
|
5
5
|
* Address fields you can send with a delivery checkout request.
|
|
6
6
|
*/
|
|
7
7
|
type CheckoutAddress = {
|
|
8
|
+
/** The street address, such as "12 Admiralty Way". */
|
|
8
9
|
line1?: string;
|
|
10
|
+
/** The city, such as "Lagos". */
|
|
9
11
|
city?: string;
|
|
12
|
+
/** A place id from `@zappie/sdk/places`. Delivery is priced to that place. */
|
|
10
13
|
place_id?: string;
|
|
14
|
+
/** The latitude in decimal degrees. */
|
|
11
15
|
lat?: number;
|
|
16
|
+
/** The longitude in decimal degrees. */
|
|
12
17
|
lng?: number;
|
|
13
18
|
};
|
|
14
19
|
/**
|
|
15
20
|
* Pickup or delivery details for a checkout session, including an optional schedule.
|
|
16
21
|
*/
|
|
17
22
|
type CheckoutFulfilment = {
|
|
18
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* How the customer gets the order. `pickup` means the customer collects it at the branch.
|
|
25
|
+
* `delivery` takes it to `address`. Dine-in orders are not checked out through a session.
|
|
26
|
+
*/
|
|
19
27
|
type: "pickup" | "delivery";
|
|
28
|
+
/** Where to deliver. A delivery checkout also needs a contact phone number from the branch's country. */
|
|
20
29
|
address?: CheckoutAddress;
|
|
30
|
+
/** When the order is for, RFC 3339 in UTC. Null or absent for as soon as possible. */
|
|
21
31
|
scheduled_for?: string | null;
|
|
32
|
+
/** The delivery region the shopper picked when the zone check or the quote asked for one. */
|
|
22
33
|
delivery_region_id?: string;
|
|
34
|
+
/**
|
|
35
|
+
* A note for the rider or the counter. Pricing ignores it. When you leave it out, the client
|
|
36
|
+
* sends the address's `instructions` here instead.
|
|
37
|
+
*/
|
|
23
38
|
instructions?: string;
|
|
24
39
|
};
|
|
25
40
|
/**
|
|
26
41
|
* Cart lines, branch, fulfilment and return URLs you send to open checkout.
|
|
27
42
|
*/
|
|
28
43
|
type CheckoutRequest = {
|
|
44
|
+
/** The branch the order is for. */
|
|
29
45
|
branch_id: string;
|
|
46
|
+
/** The menu version the cart was built against. */
|
|
30
47
|
menu_version: string;
|
|
48
|
+
/** The cart's lines, 1 to 100. A line that sends a price is refused. */
|
|
31
49
|
lines: WireLine[];
|
|
50
|
+
/** Pickup or delivery, with the address and the schedule. */
|
|
32
51
|
fulfilment: CheckoutFulfilment;
|
|
52
|
+
/**
|
|
53
|
+
* The phone number on the order: digits with an optional leading `+`. Without one, checkout uses
|
|
54
|
+
* the signed-in customer's verified number.
|
|
55
|
+
*/
|
|
33
56
|
contact_phone?: string;
|
|
34
57
|
/**
|
|
35
58
|
* Who collects or receives a pickup or delivery when the shopper orders for someone else. Send
|
|
@@ -38,25 +61,45 @@ type CheckoutRequest = {
|
|
|
38
61
|
contact_name?: string;
|
|
39
62
|
/** What the shopper typed for the store's checkout fields, from `cart.setCustomer`. */
|
|
40
63
|
customer?: CheckoutCustomer;
|
|
64
|
+
/** A promo code to apply. A code the quote refuses doesn't stop checkout. The order is placed without it, at the quoted total. */
|
|
41
65
|
promo_code?: string;
|
|
42
66
|
/** The perks in the bag, from `cart.perks`. The payment spends them. */
|
|
43
67
|
perk_redemption_ids?: string[];
|
|
68
|
+
/**
|
|
69
|
+
* Where the customer lands after paying, with `?session=` added. Use an https address on one of
|
|
70
|
+
* the storefront's own hosts, or an app redirect URI. A test key also takes a localhost address.
|
|
71
|
+
*/
|
|
44
72
|
return_url: string;
|
|
73
|
+
/** Where the customer goes back without paying. The same rules as `return_url` apply. */
|
|
45
74
|
cancel_url?: string;
|
|
75
|
+
/** Where the shopper's visit came from: the referrer address or `utm_source`. It counts the order toward that source in the business's analytics. */
|
|
46
76
|
source?: string;
|
|
77
|
+
/** The visit's `utm_campaign`, if any. */
|
|
47
78
|
campaign?: string;
|
|
48
79
|
};
|
|
49
80
|
/**
|
|
50
81
|
* A checkout session returned by the service, with its amount, expiry and order status.
|
|
51
82
|
*/
|
|
52
83
|
type CheckoutSession = {
|
|
84
|
+
/** The session's id, starting `cs_`. */
|
|
53
85
|
id: string;
|
|
86
|
+
/**
|
|
87
|
+
* Where the session stands. `open` means it is waiting for payment. `completed` means the order
|
|
88
|
+
* is placed, and `order_id` is set. `expired` means nobody paid before `expires_at`. `cancelled`
|
|
89
|
+
* is reserved. The API doesn't set it today.
|
|
90
|
+
*/
|
|
54
91
|
status: "open" | "completed" | "expired" | "cancelled";
|
|
92
|
+
/** The payment page. Only the session `open` returns has it. A read of the session leaves it out. */
|
|
55
93
|
url?: string;
|
|
94
|
+
/** What the customer pays. */
|
|
56
95
|
amount: WireMoney;
|
|
96
|
+
/** The placed order's id. Null until the session has completed. */
|
|
57
97
|
order_id: string | null;
|
|
98
|
+
/** Where the customer lands after paying. */
|
|
58
99
|
return_url: string;
|
|
100
|
+
/** Where the customer goes back without paying. Absent when the session has none. */
|
|
59
101
|
cancel_url?: string;
|
|
102
|
+
/** 30 minutes after the session opened, RFC 3339 in UTC. An open session expires within a minute after this time. */
|
|
60
103
|
expires_at: string;
|
|
61
104
|
};
|
|
62
105
|
/**
|
|
@@ -78,14 +121,22 @@ type CheckoutCompletion = (CheckoutSession & {
|
|
|
78
121
|
* Optional customer API base URL and fetch implementation for the checkout client.
|
|
79
122
|
*/
|
|
80
123
|
type CheckoutClientOptions = {
|
|
124
|
+
/** The base path of the customer API. Defaults to "/_zappie/api". */
|
|
81
125
|
customerBase?: string;
|
|
126
|
+
/** The fetch the client calls. Defaults to the global `fetch`. */
|
|
82
127
|
fetch?: typeof fetch;
|
|
83
128
|
};
|
|
84
129
|
/**
|
|
85
130
|
* Cancellation signal and polling interval in milliseconds for awaiting checkout completion.
|
|
86
131
|
*/
|
|
87
132
|
type AwaitCompletionOptions = {
|
|
133
|
+
/**
|
|
134
|
+
* Stops waiting when it aborts, and the promise rejects with the signal's reason. There is no
|
|
135
|
+
* timeout of its own. It waits until the session completes or expires, which an open session does
|
|
136
|
+
* within a minute after its `expires_at`.
|
|
137
|
+
*/
|
|
88
138
|
signal?: AbortSignal;
|
|
139
|
+
/** How long to wait between reads of the session, in milliseconds. Defaults to 3000. A negative value throws `invalid_request`. */
|
|
89
140
|
intervalMs?: number;
|
|
90
141
|
};
|
|
91
142
|
|
|
@@ -111,15 +162,35 @@ type CheckoutClient = ReturnType<typeof createCheckout>;
|
|
|
111
162
|
* Statuses 409, 429 and 5xx are marked retryable.
|
|
112
163
|
*/
|
|
113
164
|
declare class CheckoutError extends ZappieError {
|
|
165
|
+
/** The API's own error code, such as `parameter_invalid` or `idempotency_conflict`. `code` maps it to the SDK's stable codes. "server_error" when the body named none. */
|
|
114
166
|
readonly apiCode: string;
|
|
167
|
+
/** The `issues` array of the API's error body, as it came. On `quote_issues` it holds the blocking issues that stopped the checkout. Absent when the body has none. */
|
|
115
168
|
readonly issues?: unknown;
|
|
116
|
-
constructor(status: number,
|
|
169
|
+
constructor(status: number,
|
|
170
|
+
/** The API's own error code, such as `parameter_invalid` or `idempotency_conflict`. `code` maps it to the SDK's stable codes. "server_error" when the body named none. */
|
|
171
|
+
apiCode: string, message: string, param?: string, issues?: unknown);
|
|
117
172
|
}
|
|
118
173
|
|
|
119
174
|
/**
|
|
120
175
|
* The next action your payment UI should present, from fixing an address to paying.
|
|
121
176
|
*/
|
|
122
|
-
type PayReadiness =
|
|
177
|
+
type PayReadiness =
|
|
178
|
+
/** The delivery address is not valid yet. Ask for it. */
|
|
179
|
+
"address"
|
|
180
|
+
/** The quote is loading. */
|
|
181
|
+
| "quoting"
|
|
182
|
+
/** The quote failed. Offer to ask for it again. */
|
|
183
|
+
| "retry"
|
|
184
|
+
/** The quote needs a delivery region. Ask the shopper to pick one. */
|
|
185
|
+
| "choose_area"
|
|
186
|
+
/** A blocking issue stops checkout. Show the issues. */
|
|
187
|
+
| "fix_issues"
|
|
188
|
+
/** The cart is ready but needs a signed-in customer. */
|
|
189
|
+
| "sign_in"
|
|
190
|
+
/** The contact phone is not valid. Ask for it again. */
|
|
191
|
+
| "phone"
|
|
192
|
+
/** Everything is ready. Show the pay button. */
|
|
193
|
+
| "pay";
|
|
123
194
|
/**
|
|
124
195
|
* The quote loading state and, when ready, the quote used to decide payment readiness.
|
|
125
196
|
*/
|
package/dist/checkout/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
1
|
import{createCheckout}from"./client.js";import{CheckoutError}from"./error.js";import{isContactPhoneValid,payReadiness}from"./readiness.js";import{checkoutFulfilment}from"./sdk.js";export{CheckoutError,checkoutFulfilment,createCheckout,isContactPhoneValid,payReadiness};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/dist/checkout/react.d.ts
CHANGED
|
@@ -4,31 +4,54 @@ import { WireLine, CheckoutCustomer, WireMoney } from '@zappie/sdk';
|
|
|
4
4
|
* Address fields you can send with a delivery checkout request.
|
|
5
5
|
*/
|
|
6
6
|
type CheckoutAddress = {
|
|
7
|
+
/** The street address, such as "12 Admiralty Way". */
|
|
7
8
|
line1?: string;
|
|
9
|
+
/** The city, such as "Lagos". */
|
|
8
10
|
city?: string;
|
|
11
|
+
/** A place id from `@zappie/sdk/places`. Delivery is priced to that place. */
|
|
9
12
|
place_id?: string;
|
|
13
|
+
/** The latitude in decimal degrees. */
|
|
10
14
|
lat?: number;
|
|
15
|
+
/** The longitude in decimal degrees. */
|
|
11
16
|
lng?: number;
|
|
12
17
|
};
|
|
13
18
|
/**
|
|
14
19
|
* Pickup or delivery details for a checkout session, including an optional schedule.
|
|
15
20
|
*/
|
|
16
21
|
type CheckoutFulfilment = {
|
|
17
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* How the customer gets the order. `pickup` means the customer collects it at the branch.
|
|
24
|
+
* `delivery` takes it to `address`. Dine-in orders are not checked out through a session.
|
|
25
|
+
*/
|
|
18
26
|
type: "pickup" | "delivery";
|
|
27
|
+
/** Where to deliver. A delivery checkout also needs a contact phone number from the branch's country. */
|
|
19
28
|
address?: CheckoutAddress;
|
|
29
|
+
/** When the order is for, RFC 3339 in UTC. Null or absent for as soon as possible. */
|
|
20
30
|
scheduled_for?: string | null;
|
|
31
|
+
/** The delivery region the shopper picked when the zone check or the quote asked for one. */
|
|
21
32
|
delivery_region_id?: string;
|
|
33
|
+
/**
|
|
34
|
+
* A note for the rider or the counter. Pricing ignores it. When you leave it out, the client
|
|
35
|
+
* sends the address's `instructions` here instead.
|
|
36
|
+
*/
|
|
22
37
|
instructions?: string;
|
|
23
38
|
};
|
|
24
39
|
/**
|
|
25
40
|
* Cart lines, branch, fulfilment and return URLs you send to open checkout.
|
|
26
41
|
*/
|
|
27
42
|
type CheckoutRequest = {
|
|
43
|
+
/** The branch the order is for. */
|
|
28
44
|
branch_id: string;
|
|
45
|
+
/** The menu version the cart was built against. */
|
|
29
46
|
menu_version: string;
|
|
47
|
+
/** The cart's lines, 1 to 100. A line that sends a price is refused. */
|
|
30
48
|
lines: WireLine[];
|
|
49
|
+
/** Pickup or delivery, with the address and the schedule. */
|
|
31
50
|
fulfilment: CheckoutFulfilment;
|
|
51
|
+
/**
|
|
52
|
+
* The phone number on the order: digits with an optional leading `+`. Without one, checkout uses
|
|
53
|
+
* the signed-in customer's verified number.
|
|
54
|
+
*/
|
|
32
55
|
contact_phone?: string;
|
|
33
56
|
/**
|
|
34
57
|
* Who collects or receives a pickup or delivery when the shopper orders for someone else. Send
|
|
@@ -37,25 +60,45 @@ type CheckoutRequest = {
|
|
|
37
60
|
contact_name?: string;
|
|
38
61
|
/** What the shopper typed for the store's checkout fields, from `cart.setCustomer`. */
|
|
39
62
|
customer?: CheckoutCustomer;
|
|
63
|
+
/** A promo code to apply. A code the quote refuses doesn't stop checkout. The order is placed without it, at the quoted total. */
|
|
40
64
|
promo_code?: string;
|
|
41
65
|
/** The perks in the bag, from `cart.perks`. The payment spends them. */
|
|
42
66
|
perk_redemption_ids?: string[];
|
|
67
|
+
/**
|
|
68
|
+
* Where the customer lands after paying, with `?session=` added. Use an https address on one of
|
|
69
|
+
* the storefront's own hosts, or an app redirect URI. A test key also takes a localhost address.
|
|
70
|
+
*/
|
|
43
71
|
return_url: string;
|
|
72
|
+
/** Where the customer goes back without paying. The same rules as `return_url` apply. */
|
|
44
73
|
cancel_url?: string;
|
|
74
|
+
/** Where the shopper's visit came from: the referrer address or `utm_source`. It counts the order toward that source in the business's analytics. */
|
|
45
75
|
source?: string;
|
|
76
|
+
/** The visit's `utm_campaign`, if any. */
|
|
46
77
|
campaign?: string;
|
|
47
78
|
};
|
|
48
79
|
/**
|
|
49
80
|
* A checkout session returned by the service, with its amount, expiry and order status.
|
|
50
81
|
*/
|
|
51
82
|
type CheckoutSession = {
|
|
83
|
+
/** The session's id, starting `cs_`. */
|
|
52
84
|
id: string;
|
|
85
|
+
/**
|
|
86
|
+
* Where the session stands. `open` means it is waiting for payment. `completed` means the order
|
|
87
|
+
* is placed, and `order_id` is set. `expired` means nobody paid before `expires_at`. `cancelled`
|
|
88
|
+
* is reserved. The API doesn't set it today.
|
|
89
|
+
*/
|
|
53
90
|
status: "open" | "completed" | "expired" | "cancelled";
|
|
91
|
+
/** The payment page. Only the session `open` returns has it. A read of the session leaves it out. */
|
|
54
92
|
url?: string;
|
|
93
|
+
/** What the customer pays. */
|
|
55
94
|
amount: WireMoney;
|
|
95
|
+
/** The placed order's id. Null until the session has completed. */
|
|
56
96
|
order_id: string | null;
|
|
97
|
+
/** Where the customer lands after paying. */
|
|
57
98
|
return_url: string;
|
|
99
|
+
/** Where the customer goes back without paying. Absent when the session has none. */
|
|
58
100
|
cancel_url?: string;
|
|
101
|
+
/** 30 minutes after the session opened, RFC 3339 in UTC. An open session expires within a minute after this time. */
|
|
59
102
|
expires_at: string;
|
|
60
103
|
};
|
|
61
104
|
/**
|
|
@@ -77,14 +120,22 @@ type CheckoutCompletion = (CheckoutSession & {
|
|
|
77
120
|
* Optional customer API base URL and fetch implementation for the checkout client.
|
|
78
121
|
*/
|
|
79
122
|
type CheckoutClientOptions = {
|
|
123
|
+
/** The base path of the customer API. Defaults to "/_zappie/api". */
|
|
80
124
|
customerBase?: string;
|
|
125
|
+
/** The fetch the client calls. Defaults to the global `fetch`. */
|
|
81
126
|
fetch?: typeof fetch;
|
|
82
127
|
};
|
|
83
128
|
/**
|
|
84
129
|
* Cancellation signal and polling interval in milliseconds for awaiting checkout completion.
|
|
85
130
|
*/
|
|
86
131
|
type AwaitCompletionOptions = {
|
|
132
|
+
/**
|
|
133
|
+
* Stops waiting when it aborts, and the promise rejects with the signal's reason. There is no
|
|
134
|
+
* timeout of its own. It waits until the session completes or expires, which an open session does
|
|
135
|
+
* within a minute after its `expires_at`.
|
|
136
|
+
*/
|
|
87
137
|
signal?: AbortSignal;
|
|
138
|
+
/** How long to wait between reads of the session, in milliseconds. Defaults to 3000. A negative value throws `invalid_request`. */
|
|
88
139
|
intervalMs?: number;
|
|
89
140
|
};
|
|
90
141
|
|
|
@@ -106,18 +157,32 @@ declare function createCheckout(options?: CheckoutClientOptions): {
|
|
|
106
157
|
type CheckoutClient = ReturnType<typeof createCheckout>;
|
|
107
158
|
|
|
108
159
|
/** How checkout opens. Auto redirects in in-app browsers and framed pages, else a modal on desktop and a sheet on mobile. */
|
|
109
|
-
type CheckoutPresentation =
|
|
160
|
+
type CheckoutPresentation =
|
|
161
|
+
/** Picks one of the others for this browser, as `checkoutPresentation` does. */
|
|
162
|
+
"auto"
|
|
163
|
+
/** A panel in the middle of the page, up to 480px wide, over a dimmed backdrop. */
|
|
164
|
+
| "modal"
|
|
165
|
+
/** A panel that slides up from the bottom to 92% of the viewport's height. The shopper drags its handle down to close it, except while paying. */
|
|
166
|
+
| "sheet"
|
|
167
|
+
/** A panel that fills the whole window. */
|
|
168
|
+
| "fullscreen"
|
|
169
|
+
/** Leaves the page for the checkout's own address, and `embedCheckout` resolves with the status `redirected`. */
|
|
170
|
+
| "redirect";
|
|
110
171
|
/**
|
|
111
172
|
* Why checkout can't go on. `code` is `session_expired`, `session_invalid` or `internal`. When `retryable` is true,
|
|
112
173
|
* checkout stays open and offers to try again.
|
|
113
174
|
*/
|
|
114
175
|
type CheckoutEmbedError = {
|
|
176
|
+
/** Why checkout can't go on: `session_expired`, `session_invalid` or `internal`. */
|
|
115
177
|
code: string;
|
|
178
|
+
/** A message from the checkout that says what went wrong. */
|
|
116
179
|
message: string;
|
|
180
|
+
/** True when checkout stays open and offers to try again. False when it closes. */
|
|
117
181
|
retryable: boolean;
|
|
118
182
|
};
|
|
119
183
|
/** Presentation, step and error reporting for an embedded checkout. The checkout always draws in Zappie's own design. */
|
|
120
184
|
type EmbedOptions = {
|
|
185
|
+
/** How checkout opens. Defaults to `auto`. */
|
|
121
186
|
presentation?: CheckoutPresentation;
|
|
122
187
|
/** Called with each checkout step, and whether a payment has started. */
|
|
123
188
|
onStep?: (step: string, paying: boolean) => void;
|
package/dist/checkout/react.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
1
|
"use client";import{usePendingNavigation}from"@zappie/sdk/navigation/react";import{useCallback,useState}from"react";import{closeCheckout,embedCheckout}from"./embed.js";function useCheckout(checkout){const{pending,start,end}=usePendingNavigation();const[status,setStatus]=useState("idle");const[step,setStep]=useState();const open=useCallback((body,key,options={})=>start(async()=>{setStatus("opening");const session=await checkout.open(body,key);setStatus("open");const result=await embedCheckout(checkout,session,{...options,onStep:(next,paying)=>{setStep(next);options.onStep?.(next,paying)}});setStatus(result.status);if(result.status!=="redirected"){end()}return result}),[checkout,start,end]);return{open,close:closeCheckout,status:pending||status==="completed"||status==="cancelled"?status:"idle",step,pending}}export{useCheckout};
|
|
2
|
-
//# sourceMappingURL=react.js.map
|
|
@@ -1,2 +1 @@
|
|
|
1
1
|
function isContactPhoneValid(phone){return phone.trim()===""||/^\+?[0-9]{7,15}$/.test(phone.replace(/\s+/g,""))}function payReadiness(state,contactPhoneValid,addressValid=true){if(!addressValid){return"address"}switch(state.status){case"idle":case"loading":return"quoting";case"error":return"retry"}if(state.quote.issues.some(issue=>issue.code==="delivery_region_required")){return"choose_area"}if(!state.quote.canCheckout||state.quote.checkout.reason==="issues"){return"fix_issues"}if(state.quote.checkout.reason==="customer_required"){return"sign_in"}if(!contactPhoneValid){return"phone"}return"pay"}export{isContactPhoneValid,payReadiness};
|
|
2
|
-
//# sourceMappingURL=readiness.js.map
|
package/dist/checkout/sdk.js
CHANGED
package/dist/checkout/session.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
1
|
import{money,ZappieError}from"./sdk.js";function object(value){if(!value||typeof value!=="object"||Array.isArray(value)){throw new ZappieError("server_error","Invalid checkout session response")}return value}function string(value){if(typeof value!=="string"){throw new ZappieError("server_error","Invalid checkout session response")}return value}function currency(value){try{return money(0,string(value)).currency}catch{throw new ZappieError("server_error","Invalid checkout session response")}}function mapCheckoutSession(value){const session=object(value);const amount=object(session.amount);const status=string(session.status);if(!["open","completed","expired","cancelled"].includes(status)){throw new ZappieError("server_error","Invalid checkout session response")}const expiresAt=string(session.expires_at);if(!Number.isFinite(Date.parse(expiresAt))){throw new ZappieError("server_error","Invalid checkout session response")}if(!Number.isSafeInteger(amount.amount_minor)){throw new ZappieError("server_error","Invalid checkout session response")}if(session.order_id!==null&&typeof session.order_id!=="string"){throw new ZappieError("server_error","Invalid checkout session response")}return{id:string(session.id),status,...typeof session.url==="string"?{url:session.url}:{},amount:{amount_minor:amount.amount_minor,currency:currency(amount.currency)},order_id:session.order_id,return_url:string(session.return_url),...typeof session.cancel_url==="string"?{cancel_url:session.cancel_url}:{},expires_at:expiresAt}}export{mapCheckoutSession};
|
|
2
|
-
//# sourceMappingURL=session.js.map
|
package/dist/checkout/types.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -17,7 +17,13 @@ declare global {
|
|
|
17
17
|
/**
|
|
18
18
|
* How the branch prices delivery. Only `"fixed"` lets an address without a place ID stand.
|
|
19
19
|
*/
|
|
20
|
-
type DeliveryFeeType =
|
|
20
|
+
type DeliveryFeeType =
|
|
21
|
+
/** The fee comes from the delivery region the address falls in. An address needs a place ID. */
|
|
22
|
+
"region"
|
|
23
|
+
/** The fee depends on how far the address is. An address needs a place ID. */
|
|
24
|
+
| "distance"
|
|
25
|
+
/** One fee for every address. An address without a place ID still stands. */
|
|
26
|
+
| "fixed";
|
|
21
27
|
|
|
22
28
|
/**
|
|
23
29
|
* The phone a checkout shows, and the `contact_phone` to send.
|
|
@@ -34,9 +40,11 @@ type PhoneDefault = {
|
|
|
34
40
|
* What the defaults are worked out from.
|
|
35
41
|
*/
|
|
36
42
|
type CheckoutDefaultsInput = {
|
|
43
|
+
/** The branch the shopper is ordering from. Its only delivery region becomes the default, and a schedule is kept only when it belongs to this branch. */
|
|
37
44
|
branch: Branch;
|
|
38
45
|
/** The cart's fulfilment. Its type and its address are the shopper's choice and are kept. */
|
|
39
46
|
fulfilment: CartFulfilment | null;
|
|
47
|
+
/** The signed-in customer, whose masked phone and remembered address apply. Leave it out or pass null for a guest. */
|
|
40
48
|
customer?: SessionCustomer | null;
|
|
41
49
|
/** The signed-in customer's saved addresses, in the order `/me/addresses` returns them. */
|
|
42
50
|
savedAddresses?: readonly SavedAddress[];
|
|
@@ -51,6 +59,7 @@ type CheckoutDefaultsInput = {
|
|
|
51
59
|
* The contact details a checkout starts from.
|
|
52
60
|
*/
|
|
53
61
|
type CheckoutDefaults = {
|
|
62
|
+
/** The phone to show, and the `contact_phone` to send with it. */
|
|
54
63
|
phone: PhoneDefault;
|
|
55
64
|
/** The cart's delivery address, else the last one this shopper used on this device, else the first saved one. */
|
|
56
65
|
address?: DeliveryAddress;
|
|
@@ -1,2 +1 @@
|
|
|
1
1
|
import{ADDRESS_KEY,addressStorage,forgetRememberedAddress,knownShopper,ownerOf,readStored,settleShopper}from"../internal/remembered-address.js";function text(value){return typeof value==="string"&&value.trim()?value:void 0}function point(lat,lng){return typeof lat==="number"&&typeof lng==="number"&&Number.isFinite(lat)&&Number.isFinite(lng)?{coordinates:{lat,lng}}:{}}function address(line1,placeId,lat,lng){return line1?{line1,...placeId?{placeId}:{},...point(lat,lng)}:void 0}function defaultPhone(typed,customer){const value=typed?.trim();if(value){return{display:value,contactPhone:value,fromAccount:false}}const masked=customer?.phone_masked;return masked?{display:masked,fromAccount:true}:{display:"",fromAccount:false}}function shopper(customerId){return customerId===null?null:customerId||knownShopper()}function rememberedAddress(options={}){const storage=addressStorage(options.storage);const stored=readStored(storage);if(!stored){return void 0}const owner=ownerOf(stored);if(owner===void 0){forgetRememberedAddress(storage);return void 0}const reader=shopper(options.customerId);if(reader===void 0||owner!==reader){if(typeof reader==="string"&&typeof owner==="string"){forgetRememberedAddress(storage)}return void 0}const placeId=text(stored.placeId);if(!placeId&&options.feeType!=="fixed"){forgetRememberedAddress(storage);return void 0}return address(text(stored.address),placeId,stored.latitude,stored.longitude)}function rememberAddress(value,storage,customerId){const target=addressStorage(storage);if(!target){return}if(!value?.line1.trim()){forgetRememberedAddress(target);return}const owner=shopper(customerId);if(owner===void 0){return}try{target.setItem(ADDRESS_KEY,JSON.stringify({...owner?{customerId:owner}:{guest:true},address:value.line1,placeId:value.placeId??"",latitude:value.coordinates?.lat,longitude:value.coordinates?.lng}))}catch{}}function defaultAddress(options={}){const remembered=rememberedAddress(options);if(remembered){return remembered}const first=options.savedAddresses?.[0];const placeId=text(first?.place_id);if(!first||!placeId&&options.feeType!=="fixed"){return void 0}return address(text(first.line1),placeId,first.lat,first.lng)}function defaultRegion(branch,chosen){if(chosen){return chosen}const regions=branch.deliveryRegions??[];return regions.length===1?regions[0]?.id:void 0}function restoreSchedule(fulfilment,branchId){const at=fulfilment&&fulfilment.type!=="dine_in"?fulfilment.scheduledFor:void 0;return at&&fulfilment?.branchId===branchId&&Number.isFinite(Date.parse(at))?at:void 0}function checkoutDefaults(input){const delivery=input.fulfilment?.type==="delivery"?input.fulfilment:void 0;const address2=delivery?.address??defaultAddress({...input,customerId:input.customer?.id??null});const deliveryRegionId=defaultRegion(input.branch,delivery?.deliveryRegionId);const scheduledFor=restoreSchedule(input.fulfilment,input.branch.id);return{phone:defaultPhone(input.typedPhone,input.customer),...address2?{address:address2}:{},...deliveryRegionId?{deliveryRegionId}:{},...scheduledFor?{scheduledFor}:{}}}function prefillFulfilment(fulfilment,branch){if(!fulfilment||fulfilment.type==="dine_in"){return fulfilment}const scheduledFor=restoreSchedule(fulfilment,branch.id);const regionId=fulfilment.type==="delivery"?defaultRegion(branch,fulfilment.deliveryRegionId):void 0;const dropSchedule=fulfilment.scheduledFor!==void 0&&!scheduledFor;const addRegion=fulfilment.type==="delivery"&®ionId!==fulfilment.deliveryRegionId;if(!dropSchedule&&!addRegion){return fulfilment}const next={...fulfilment};if(dropSchedule){delete next.scheduledFor}if(addRegion&&next.type==="delivery"&®ionId){next.deliveryRegionId=regionId}return next}function watchCheckoutDefaults(customer,read,listener){let run=0;let stopped=false;let signedIn;const publish=savedAddresses=>{listener(checkoutDefaults({...read(),customer:customer.customer,...savedAddresses?{savedAddresses}:{}}))};const refresh=()=>{const current=++run;const id=customer.state==="authenticated"?customer.customer?.id:void 0;if(customer.state!=="unknown"){settleShopper(id??null,read().storage)}signedIn=id;if(!id){publish(void 0);return}void customer.addresses().then(saved=>{if(!stopped&¤t===run){publish(saved)}},()=>{if(!stopped&¤t===run){publish(void 0)}})};const off=customer.onChange((state,next)=>{const id=state==="authenticated"?next?.id:void 0;if(id!==signedIn){refresh()}});refresh();return()=>{stopped=true;off()}}export{checkoutDefaults,defaultAddress,defaultPhone,defaultRegion,prefillFulfilment,rememberAddress,rememberedAddress,restoreSchedule,watchCheckoutDefaults};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|