@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/customer/index.d.ts
CHANGED
|
@@ -3,13 +3,22 @@ import { WireIssue, ZappieError } from '@zappie/sdk';
|
|
|
3
3
|
/**
|
|
4
4
|
* Whether the customer session is unchecked, anonymous or authenticated.
|
|
5
5
|
*/
|
|
6
|
-
type AuthState =
|
|
6
|
+
type AuthState =
|
|
7
|
+
/** Nobody has checked the session yet. The client starts here when you pass no `initialCustomer`. */
|
|
8
|
+
"unknown"
|
|
9
|
+
/** Nobody is signed in. The session answered no customer, or a customer request answered 401. */
|
|
10
|
+
| "anonymous"
|
|
11
|
+
/** A customer is signed in, and `customer` holds them. */
|
|
12
|
+
| "authenticated";
|
|
7
13
|
/**
|
|
8
14
|
* The customer identity exposed by the session endpoint, with optional name and masked phone.
|
|
9
15
|
*/
|
|
10
16
|
type SessionCustomer = {
|
|
17
|
+
/** The customer's id, starting `cus_`. */
|
|
11
18
|
id: string;
|
|
19
|
+
/** The customer's first name. Absent when the account has none. */
|
|
12
20
|
given_name?: string;
|
|
21
|
+
/** The account's phone number with most digits hidden: the country code, five bullets and the last four digits, such as "+234•••••4567". */
|
|
13
22
|
phone_masked?: string;
|
|
14
23
|
};
|
|
15
24
|
/**
|
|
@@ -24,13 +33,21 @@ type CustomerProfile = SessionCustomer & {
|
|
|
24
33
|
* A customer address with its saved ID, optional coordinates and delivery instructions.
|
|
25
34
|
*/
|
|
26
35
|
type SavedAddress = {
|
|
36
|
+
/** The saved address's id, starting `adr_`. Pass it to `removeAddress`. */
|
|
27
37
|
id: string;
|
|
38
|
+
/** The street address, such as "12 Admiralty Way". */
|
|
28
39
|
line1: string;
|
|
40
|
+
/** A place nearby that helps the rider find the address. */
|
|
29
41
|
landmark?: string;
|
|
42
|
+
/** Tells the customer's addresses apart: `home`, `work` or `other`. Absent when the customer gave none. */
|
|
30
43
|
label?: "home" | "work" | "other";
|
|
44
|
+
/** A place id from `@zappie/sdk/places`. Absent when the address was saved without one. */
|
|
31
45
|
place_id?: string;
|
|
46
|
+
/** The latitude in decimal degrees. Absent when the address has no coordinates. */
|
|
32
47
|
lat?: number;
|
|
48
|
+
/** The longitude in decimal degrees. Absent when the address has no coordinates. */
|
|
33
49
|
lng?: number;
|
|
50
|
+
/** A note for whoever delivers to this address. */
|
|
34
51
|
instructions?: string;
|
|
35
52
|
};
|
|
36
53
|
/**
|
|
@@ -41,40 +58,68 @@ type CreateAddress = Omit<SavedAddress, "id">;
|
|
|
41
58
|
* A customer API amount in minor currency units, paired with its currency code.
|
|
42
59
|
*/
|
|
43
60
|
type Money = {
|
|
61
|
+
/** The amount in minor units of the currency, such as kobo for NGN. A whole number. */
|
|
44
62
|
amount_minor: number;
|
|
63
|
+
/** The ISO 4217 currency code, such as "NGN". */
|
|
45
64
|
currency: string;
|
|
46
65
|
};
|
|
47
66
|
/**
|
|
48
67
|
* A selected option recorded on an order line, including its group, name, quantity and price.
|
|
49
68
|
*/
|
|
50
69
|
type OrderChoice = {
|
|
70
|
+
/** The id of the option group the choice belongs to. */
|
|
51
71
|
group_id: string;
|
|
52
72
|
/** The option group's name, such as "Spread". */
|
|
53
73
|
group_name: string;
|
|
74
|
+
/** The id of the chosen option. */
|
|
54
75
|
choice_id: string;
|
|
76
|
+
/** The option's name, such as "Extra butter". */
|
|
55
77
|
name: string;
|
|
78
|
+
/** The option's price as the order recorded it. */
|
|
56
79
|
price: Money;
|
|
80
|
+
/** How many of the option the customer picked. */
|
|
57
81
|
quantity: number;
|
|
58
82
|
};
|
|
59
83
|
/**
|
|
60
84
|
* What the customer typed for one text group on an order line.
|
|
61
85
|
*/
|
|
62
86
|
type OrderText = {
|
|
87
|
+
/** The id of the text group. */
|
|
63
88
|
group_id: string;
|
|
89
|
+
/** The text group's name, such as "Message on the card". */
|
|
64
90
|
group_name: string;
|
|
91
|
+
/** What the customer typed. */
|
|
65
92
|
value: string;
|
|
66
93
|
};
|
|
67
94
|
/**
|
|
68
95
|
* The kind of a charge on an order.
|
|
69
96
|
*/
|
|
70
|
-
type OrderChargeCode =
|
|
97
|
+
type OrderChargeCode =
|
|
98
|
+
/** A service charge. */
|
|
99
|
+
"service_charge"
|
|
100
|
+
/** The delivery fee. */
|
|
101
|
+
| "delivery"
|
|
102
|
+
/** A packaging charge. */
|
|
103
|
+
| "packaging"
|
|
104
|
+
/** VAT. */
|
|
105
|
+
| "vat"
|
|
106
|
+
/** A fee on a small order. */
|
|
107
|
+
| "small_order"
|
|
108
|
+
/** A platform fee. */
|
|
109
|
+
| "platform_fee"
|
|
110
|
+
/** Any other charge the business adds. Its label names it. */
|
|
111
|
+
| "other";
|
|
71
112
|
/**
|
|
72
113
|
* A line's share of a charge on the order. An included share is already in the line's price.
|
|
73
114
|
*/
|
|
74
115
|
type OrderLineCharge = {
|
|
116
|
+
/** What the charge is for. */
|
|
75
117
|
code: OrderChargeCode;
|
|
118
|
+
/** The business's own name for the charge, such as "VAT". */
|
|
76
119
|
label: string;
|
|
120
|
+
/** The amount of the charge. */
|
|
77
121
|
amount: Money;
|
|
122
|
+
/** True when the charge is already in the price, so it adds nothing to the total. */
|
|
78
123
|
included: boolean;
|
|
79
124
|
};
|
|
80
125
|
/**
|
|
@@ -88,9 +133,11 @@ type OrderCharge = OrderLineCharge & {
|
|
|
88
133
|
* A discount on the order. The amount is positive, like the order's discount.
|
|
89
134
|
*/
|
|
90
135
|
type OrderDiscount = {
|
|
136
|
+
/** The discount's name, ready to show. */
|
|
91
137
|
label: string;
|
|
92
138
|
/** The code the customer entered, when the discount came with one. */
|
|
93
139
|
promo_code?: string;
|
|
140
|
+
/** How much the discount takes off, as a positive amount. */
|
|
94
141
|
amount: Money;
|
|
95
142
|
};
|
|
96
143
|
/**
|
|
@@ -98,9 +145,13 @@ type OrderDiscount = {
|
|
|
98
145
|
* reference.
|
|
99
146
|
*/
|
|
100
147
|
type OrderPayment = {
|
|
148
|
+
/** The payment method's name, ready to show, such as "Card" or "Bank transfer". */
|
|
101
149
|
method: string;
|
|
150
|
+
/** How much the payment was. */
|
|
102
151
|
amount: Money;
|
|
152
|
+
/** `successful` for a payment that went through, or `refunded` once it was refunded. */
|
|
103
153
|
status: "successful" | "refunded";
|
|
154
|
+
/** When it was paid, RFC 3339 in UTC. */
|
|
104
155
|
paid_at: string;
|
|
105
156
|
};
|
|
106
157
|
/**
|
|
@@ -108,76 +159,156 @@ type OrderPayment = {
|
|
|
108
159
|
* charge. `voided` is true only on a line in `voided_lines`.
|
|
109
160
|
*/
|
|
110
161
|
type OrderLine = {
|
|
162
|
+
/** The id of the item ordered. */
|
|
111
163
|
item_id: string;
|
|
164
|
+
/** The variant ordered. Absent for an item without variants. */
|
|
112
165
|
variant_id?: string;
|
|
166
|
+
/** The item's name as the order recorded it. */
|
|
113
167
|
name: string;
|
|
168
|
+
/** How many units the customer ordered. */
|
|
114
169
|
quantity: number;
|
|
170
|
+
/** The price of one unit as the order recorded it. */
|
|
115
171
|
unit_price: Money;
|
|
172
|
+
/** The line's total. */
|
|
116
173
|
total: Money;
|
|
174
|
+
/** The customer's note on the line. Absent when there is none. */
|
|
117
175
|
notes?: string;
|
|
176
|
+
/** True only on a line in `voided_lines`, one the business took off the order. */
|
|
118
177
|
voided: boolean;
|
|
178
|
+
/** The options picked on the line, attribute choices included. */
|
|
119
179
|
choices: OrderChoice[];
|
|
180
|
+
/** What the customer typed for each text group on the line. */
|
|
120
181
|
texts: OrderText[];
|
|
182
|
+
/** The line's share of each charge on the order. */
|
|
121
183
|
charges: OrderLineCharge[];
|
|
122
184
|
};
|
|
123
185
|
/**
|
|
124
186
|
* Where an order stands.
|
|
125
187
|
*/
|
|
126
|
-
type OrderStatus =
|
|
188
|
+
type OrderStatus =
|
|
189
|
+
/** Placed and waiting for the business to accept it. */
|
|
190
|
+
"pending"
|
|
191
|
+
/** The business accepted it and is preparing it. */
|
|
192
|
+
| "accepted"
|
|
193
|
+
/** Ready for pickup, or waiting for a rider. */
|
|
194
|
+
| "ready"
|
|
195
|
+
/** A rider has it. */
|
|
196
|
+
| "out_for_delivery"
|
|
197
|
+
/** The rider is at the drop-off. */
|
|
198
|
+
| "arrived"
|
|
199
|
+
/** The rider could not hand it over. */
|
|
200
|
+
| "delivery_failed"
|
|
201
|
+
/** The order is done. It ends the order. */
|
|
202
|
+
| "completed"
|
|
203
|
+
/** The order was cancelled. It ends the order. */
|
|
204
|
+
| "cancelled"
|
|
205
|
+
/** The business rejected the order. It ends the order. */
|
|
206
|
+
| "rejected";
|
|
127
207
|
/**
|
|
128
208
|
* A detailed step. `ready_for_pickup`, `ready_for_rider_pickup`, `searching_for_rider`,
|
|
129
209
|
* `rider_assigned` and `waiting_for_pickup` read as the `ready` status, `picked_up` and
|
|
130
210
|
* `on_the_way` as `out_for_delivery`. The rest match the status of the same name.
|
|
131
211
|
*/
|
|
132
|
-
type OrderStepCode =
|
|
212
|
+
type OrderStepCode =
|
|
213
|
+
/** Placed and waiting for the business to accept it. */
|
|
214
|
+
"pending"
|
|
215
|
+
/** The business accepted it and is preparing it. */
|
|
216
|
+
| "accepted"
|
|
217
|
+
/** Ready for the customer to collect. */
|
|
218
|
+
| "ready_for_pickup"
|
|
219
|
+
/** Ready for a rider to collect. */
|
|
220
|
+
| "ready_for_rider_pickup"
|
|
221
|
+
/** Ready, and a rider is being found. */
|
|
222
|
+
| "searching_for_rider"
|
|
223
|
+
/** Ready, and a rider has been assigned. */
|
|
224
|
+
| "rider_assigned"
|
|
225
|
+
/** Ready, and the rider is coming to collect it. */
|
|
226
|
+
| "waiting_for_pickup"
|
|
227
|
+
/** The rider has collected it. */
|
|
228
|
+
| "picked_up"
|
|
229
|
+
/** The rider is on the way to the customer. */
|
|
230
|
+
| "on_the_way"
|
|
231
|
+
/** The rider is at the drop-off. */
|
|
232
|
+
| "arrived"
|
|
233
|
+
/** The order is done. */
|
|
234
|
+
| "completed"
|
|
235
|
+
/** The order was cancelled. */
|
|
236
|
+
| "cancelled"
|
|
237
|
+
/** The business rejected the order. */
|
|
238
|
+
| "rejected"
|
|
239
|
+
/** The rider could not hand it over. */
|
|
240
|
+
| "delivery_failed";
|
|
133
241
|
/**
|
|
134
242
|
* A step the order took, with its name and one sentence on what it means, ready to show.
|
|
135
243
|
*/
|
|
136
244
|
type OrderTimelineStep = {
|
|
137
245
|
/** The public status the step reads as. Several steps can share one. */
|
|
138
246
|
status: string;
|
|
247
|
+
/** The detailed step. */
|
|
139
248
|
step: OrderStepCode;
|
|
249
|
+
/** The step's name, ready to show, such as "Rider assigned". */
|
|
140
250
|
title: string;
|
|
251
|
+
/** One sentence on what the step means, ready to show. */
|
|
141
252
|
description: string;
|
|
253
|
+
/** When the order reached the step, RFC 3339 in UTC. */
|
|
142
254
|
at: string;
|
|
143
255
|
};
|
|
144
256
|
/**
|
|
145
257
|
* The step the business moves the order to next.
|
|
146
258
|
*/
|
|
147
259
|
type OrderNextStep = {
|
|
260
|
+
/** The detailed step the order moves to next. */
|
|
148
261
|
step: OrderStepCode;
|
|
262
|
+
/** The step's name, ready to show, such as "Ready for rider pickup". */
|
|
149
263
|
title: string;
|
|
264
|
+
/** One sentence on what the step means, ready to show. */
|
|
150
265
|
description: string;
|
|
151
266
|
};
|
|
152
267
|
/**
|
|
153
268
|
* A customer order with its number, fulfilment, charges, discounts, payments, lines and timeline.
|
|
154
269
|
*/
|
|
155
270
|
type CustomerOrder = {
|
|
271
|
+
/** The order's id. Pass it to `order`, `watchOrder`, `payBalance` and `reorder`. */
|
|
156
272
|
id: string;
|
|
157
273
|
/** The order number the business and the customer know the order by, such as "#1042". Show it instead of the id. */
|
|
158
274
|
reference: string;
|
|
275
|
+
/** Where the order stands. `timeline` has the detailed step. */
|
|
159
276
|
status: OrderStatus;
|
|
277
|
+
/** How the customer gets the order. `delivery` takes it to the customer's address. `pickup` means the customer collects it at the branch. */
|
|
160
278
|
fulfilment: "delivery" | "pickup";
|
|
279
|
+
/** The order's branch. Absent when the branch has since been deleted. */
|
|
161
280
|
branch_id?: string;
|
|
281
|
+
/** The ISO 4217 currency code every amount on the order uses. */
|
|
162
282
|
currency: string;
|
|
283
|
+
/** The total of the order's lines, before charges and discounts. */
|
|
163
284
|
subtotal: Money;
|
|
285
|
+
/** The delivery fee. It also shows in `charges` with the code `delivery`. */
|
|
164
286
|
delivery_fee: Money;
|
|
287
|
+
/** The total of the order's discounts, as a positive amount. */
|
|
165
288
|
discount: Money;
|
|
289
|
+
/** What the order costs in all. */
|
|
166
290
|
total: Money;
|
|
291
|
+
/** True once the order is paid. */
|
|
167
292
|
paid: boolean;
|
|
293
|
+
/** How much the customer has paid toward the order. */
|
|
168
294
|
amount_paid: Money;
|
|
169
295
|
/** What the customer can still pay with `payBalance`. Zero once the order is paid or has ended. */
|
|
170
296
|
amount_due: Money;
|
|
297
|
+
/** The order's lines. Voided lines are in `voided_lines` instead. */
|
|
171
298
|
lines: OrderLine[];
|
|
172
299
|
/** Lines the business took off the order after it was placed. No total counts them. */
|
|
173
300
|
voided_lines: OrderLine[];
|
|
174
301
|
/** Each charge in the order it was added, the delivery fee among them. */
|
|
175
302
|
charges: OrderCharge[];
|
|
303
|
+
/** Each discount on the order. */
|
|
176
304
|
discounts: OrderDiscount[];
|
|
177
305
|
/** Successful and refunded payments, oldest first. */
|
|
178
306
|
payments: OrderPayment[];
|
|
307
|
+
/** When the order was placed, RFC 3339 in UTC. */
|
|
179
308
|
placed_at: string;
|
|
309
|
+
/** When the order last changed, RFC 3339 in UTC. */
|
|
180
310
|
updated_at: string;
|
|
311
|
+
/** When the order is scheduled for, RFC 3339 in UTC. Absent for an order as soon as possible. */
|
|
181
312
|
scheduled_at?: string;
|
|
182
313
|
/** When the business expects the order to be ready. It stays after that time passes. */
|
|
183
314
|
ready_at?: string;
|
|
@@ -185,15 +316,23 @@ type CustomerOrder = {
|
|
|
185
316
|
timeline: OrderTimelineStep[];
|
|
186
317
|
/** The step that comes next. Null once the order has ended and during the rider's steps. */
|
|
187
318
|
next_step: OrderNextStep | null;
|
|
319
|
+
/** Minutes until the business's own estimate. Absent once it has passed or the order has ended. */
|
|
188
320
|
eta_minutes?: number;
|
|
321
|
+
/** The phone number on the order. Absent when there is none. */
|
|
189
322
|
contact_phone?: string;
|
|
190
323
|
/** The customer's note for whoever brings the order. */
|
|
191
324
|
delivery_instructions?: string;
|
|
325
|
+
/** Where a delivery order goes: its street address and its latitude and longitude in decimal degrees. Absent for pickup. */
|
|
192
326
|
dropoff_address?: {
|
|
193
327
|
line1?: string;
|
|
194
328
|
lat?: number;
|
|
195
329
|
lng?: number;
|
|
196
330
|
};
|
|
331
|
+
/**
|
|
332
|
+
* Whether the order is paid. `status` is `paid` or `unpaid`, as `paid` says. `method` is the type
|
|
333
|
+
* of the latest successful payment in capitals, such as "CARD", and is absent before any payment.
|
|
334
|
+
* Show `payments[].method` instead.
|
|
335
|
+
*/
|
|
197
336
|
payment?: {
|
|
198
337
|
status: "paid" | "unpaid";
|
|
199
338
|
method?: string;
|
|
@@ -203,8 +342,11 @@ type CustomerOrder = {
|
|
|
203
342
|
* The payment `payBalance` raised. Send the customer to `url` to finish it.
|
|
204
343
|
*/
|
|
205
344
|
type OrderBalancePayment = {
|
|
345
|
+
/** The payment's own id, as the payment page takes it. */
|
|
206
346
|
payment_request_id: string;
|
|
347
|
+
/** How much the payment asks for. */
|
|
207
348
|
amount: Money;
|
|
349
|
+
/** The payment page for this payment. */
|
|
208
350
|
url: string;
|
|
209
351
|
};
|
|
210
352
|
/**
|
|
@@ -220,30 +362,44 @@ type PayBalanceOptions = {
|
|
|
220
362
|
* An order line rebuilt for the bag at today's prices, as POST /quote takes it.
|
|
221
363
|
*/
|
|
222
364
|
type ReorderLine = {
|
|
365
|
+
/** `l_` and the line's position on the original order, counting from 1, such as "l_2". */
|
|
223
366
|
line_id: string;
|
|
367
|
+
/** The id of the item to order. */
|
|
224
368
|
item_id: string;
|
|
369
|
+
/** The menu the item comes from. Absent when the reorder names none. */
|
|
225
370
|
menu_id?: string;
|
|
371
|
+
/** The variant to order. Absent for an item without variants. */
|
|
226
372
|
variant_id?: string;
|
|
373
|
+
/** How many units to order. */
|
|
227
374
|
quantity: number;
|
|
375
|
+
/** The choices picked in choice groups. `quantity` is how many of the choice, 1 when absent. */
|
|
228
376
|
options?: {
|
|
229
377
|
group_id: string;
|
|
230
378
|
choice_id: string;
|
|
231
379
|
quantity?: number;
|
|
232
380
|
}[];
|
|
381
|
+
/** What the customer typed, keyed by text group id. */
|
|
233
382
|
inputs?: Record<string, string>;
|
|
383
|
+
/** The customer's note on the line. */
|
|
234
384
|
note?: string;
|
|
385
|
+
/** The item's name. */
|
|
235
386
|
name: string;
|
|
387
|
+
/** Today's price of one unit. */
|
|
236
388
|
unit_price: Money;
|
|
389
|
+
/** Today's price of the line's options. */
|
|
237
390
|
options_total: Money;
|
|
391
|
+
/** `unit_price` plus the options, for the line's quantity. */
|
|
238
392
|
line_total: Money;
|
|
239
393
|
};
|
|
240
394
|
/**
|
|
241
395
|
* An order line the branch no longer sells as it was ordered, with the issues that say why.
|
|
242
396
|
*/
|
|
243
397
|
type ReorderDroppedLine = {
|
|
398
|
+
/** `l_` and the line's position on the original order, counting from 1, such as "l_2". */
|
|
244
399
|
line_id: string;
|
|
245
400
|
/** The name on the original order. */
|
|
246
401
|
name: string;
|
|
402
|
+
/** How many units the original order had. */
|
|
247
403
|
quantity: number;
|
|
248
404
|
/** Each issue as the quote words it. */
|
|
249
405
|
issues: WireIssue[];
|
|
@@ -252,18 +408,26 @@ type ReorderDroppedLine = {
|
|
|
252
408
|
* An order rebuilt as bag lines at the same branch, for the same fulfilment, priced at today's menu.
|
|
253
409
|
*/
|
|
254
410
|
type Reorder = {
|
|
411
|
+
/** The id of the original order. */
|
|
255
412
|
order_id: string;
|
|
413
|
+
/** The original order's branch. The lines are priced there. */
|
|
256
414
|
branch_id: string;
|
|
415
|
+
/** The original order's mode, `delivery` or `pickup`. */
|
|
257
416
|
fulfilment: "delivery" | "pickup";
|
|
417
|
+
/** The menu version the prices come from. Send it with the quote. */
|
|
258
418
|
menu_version: string;
|
|
419
|
+
/** The original lines you can order today, at today's menu prices. */
|
|
259
420
|
lines: ReorderLine[];
|
|
421
|
+
/** The lines you can't order again today, each with the issues a quote would give. */
|
|
260
422
|
dropped: ReorderDroppedLine[];
|
|
261
423
|
};
|
|
262
424
|
/**
|
|
263
425
|
* A page of customer orders and the cursor for the next page, or null at the end.
|
|
264
426
|
*/
|
|
265
427
|
type OrdersPage = {
|
|
428
|
+
/** The orders on this page. */
|
|
266
429
|
orders: CustomerOrder[];
|
|
430
|
+
/** Pass it as `cursor` to `orders` to get the next page. Treat it as opaque. Null on the last page. */
|
|
267
431
|
next_cursor: string | null;
|
|
268
432
|
};
|
|
269
433
|
/**
|
|
@@ -271,17 +435,24 @@ type OrdersPage = {
|
|
|
271
435
|
* Omit initialCustomer for an unknown session. Pass null for an anonymous session.
|
|
272
436
|
*/
|
|
273
437
|
type CustomerClientOptions = {
|
|
438
|
+
/** The base path of the customer API. Defaults to "/_zappie/api". */
|
|
274
439
|
customerBase?: string;
|
|
440
|
+
/** The path that answers the current session. Defaults to "/_zappie/session". */
|
|
275
441
|
sessionPath?: string;
|
|
442
|
+
/** The fetch the client calls. Defaults to the global `fetch`. */
|
|
276
443
|
fetch?: typeof fetch;
|
|
444
|
+
/** The customer the page already knows is signed in, or null when nobody is. Leave it out and the state starts `unknown`. */
|
|
277
445
|
initialCustomer?: SessionCustomer | null;
|
|
278
446
|
};
|
|
279
447
|
/**
|
|
280
448
|
* An order-update callback, optional cancellation signal and fallback polling interval in milliseconds.
|
|
281
449
|
*/
|
|
282
450
|
type WatchOrderOptions = {
|
|
451
|
+
/** Called with the order on each live update and on each poll. Watching stops after the order is `completed`, `cancelled` or `rejected`. */
|
|
283
452
|
onOrder(order: CustomerOrder): void;
|
|
453
|
+
/** Stops watching when it aborts. */
|
|
284
454
|
signal?: AbortSignal;
|
|
455
|
+
/** How often to read the order when live updates aren't available or fail twice, in milliseconds. Defaults to 15000. */
|
|
285
456
|
pollMs?: number;
|
|
286
457
|
};
|
|
287
458
|
/**
|
|
@@ -346,9 +517,13 @@ type CustomerClient = ReturnType<typeof createCustomer>;
|
|
|
346
517
|
* Statuses 429 and 5xx are marked retryable.
|
|
347
518
|
*/
|
|
348
519
|
declare class CustomerError extends ZappieError {
|
|
520
|
+
/** The API's own error code, such as `nothing_to_pay` or `order_closed`. `code` maps it to the SDK's stable codes. "server_error" when the body named none. */
|
|
349
521
|
readonly apiCode: string;
|
|
522
|
+
/** The `issues` array of the API's error body, as it came, such as the blocking issues of a quote. Absent when the body has none. */
|
|
350
523
|
readonly issues?: unknown;
|
|
351
|
-
constructor(status: number,
|
|
524
|
+
constructor(status: number,
|
|
525
|
+
/** The API's own error code, such as `nothing_to_pay` or `order_closed`. `code` maps it to the SDK's stable codes. "server_error" when the body named none. */
|
|
526
|
+
apiCode: string, message: string, param?: string, issues?: unknown);
|
|
352
527
|
}
|
|
353
528
|
|
|
354
529
|
export { CustomerError, createCustomer };
|
package/dist/customer/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
1
|
import{sameOriginPath}from"../internal/return-path.js";function safeReturnTo(value){return sameOriginPath(value)??"/"}function currentPath(){if(typeof location==="undefined"){return"/"}return location.pathname+location.search}function leaveTo(path,post){if(typeof document==="undefined"){return}const element=document.createElement(post?"form":"a");element.target="_top";if(post){element.method="POST";element.action=path;element.hidden=true}else{element.href=path}document.body.appendChild(element);if(post){element.submit()}else{element.click()}element.remove()}export{currentPath,leaveTo,safeReturnTo};
|
|
2
|
-
//# sourceMappingURL=navigation.js.map
|
package/dist/customer/react.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
1
|
"use client";import{createContext,useCallback,useContext,useEffect,useMemo,useSyncExternalStore}from"react";import{jsx}from"react/jsx-runtime";var CustomerContext=createContext(null);function CustomerProvider({client,children}){useEffect(()=>{if(client.state==="unknown"){void client.session().catch(()=>void 0)}},[client]);return jsx(CustomerContext.Provider,{value:client,children})}function useClient(){const client=useContext(CustomerContext);if(!client){throw new Error("CustomerProvider is missing")}return client}function key(client){const customer=client.customer;return[client.state,client.pending,customer?.id,customer?.given_name,customer?.phone_masked].join(":")}function useAuth(){const client=useClient();const subscribe=useCallback(notify=>client.onChange(()=>notify()),[client]);const snapshot=useCallback(()=>key(client),[client]);const value=useSyncExternalStore(subscribe,snapshot,snapshot);return useMemo(()=>({state:client.state,customer:client.customer,pending:client.pending,signIn:client.signIn,signOut:client.signOut,refresh:client.session}),[client,value])}function useCustomer(){return useAuth().customer}export{CustomerProvider,useAuth,useCustomer};
|
|
2
|
-
//# sourceMappingURL=react.js.map
|
|
@@ -5,10 +5,17 @@ import { Reorder } from '@zappie/sdk/customer';
|
|
|
5
5
|
* An order line that didn't make it into the bag, with the issues that say why.
|
|
6
6
|
*/
|
|
7
7
|
type DroppedReorderLine = {
|
|
8
|
+
/** The reorder line's `line_id`: `l_` and the line's position on the original order, such as "l_2". */
|
|
8
9
|
lineId: string;
|
|
9
10
|
/** The name on the original order. */
|
|
10
11
|
name: string;
|
|
12
|
+
/** How many units the original order had. */
|
|
11
13
|
quantity: number;
|
|
14
|
+
/**
|
|
15
|
+
* Why the line was left out, each with its code and a message to show. An issue from the API or
|
|
16
|
+
* the bag keeps its own code. A line that failed for another reason gets the error's code, else
|
|
17
|
+
* `item_unavailable`, with a message that the item isn't available right now.
|
|
18
|
+
*/
|
|
12
19
|
issues: {
|
|
13
20
|
code: string;
|
|
14
21
|
message: string;
|
|
@@ -18,6 +25,7 @@ type DroppedReorderLine = {
|
|
|
18
25
|
* What `addReorderToCart` put in the bag and what it left out.
|
|
19
26
|
*/
|
|
20
27
|
type ReorderResult = {
|
|
28
|
+
/** The cart lines this call added, in the reorder's order. */
|
|
21
29
|
added: CartLine[];
|
|
22
30
|
/** The lines the API dropped, then the lines the bag refused. Show them so the customer knows. */
|
|
23
31
|
dropped: DroppedReorderLine[];
|
package/dist/customer/reorder.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
1
|
async function addReorderToCart(zappie,reorder,options={}){const{cart}=zappie;const branch=reorder.branch_id;await cart.hydrate();if(cart.getSnapshot().branchId!==branch){await cart.moveTo(branch)}const added=[];const dropped=reorder.dropped.map(line=>({lineId:line.line_id,name:line.name,quantity:line.quantity,issues:line.issues.map(({code,message})=>({code,message}))}));for(const line of reorder.lines){options.signal?.throwIfAborted();try{const item=await zappie.menu.item(line.item_id,{branch,...options.signal?{signal:options.signal}:{}});added.push(cart.add(item,{quantity:line.quantity,choices:(line.options??[]).map(option=>({groupId:option.group_id,choiceId:option.choice_id,quantity:option.quantity??1})),...line.menu_id?{menuId:line.menu_id}:{},...line.variant_id?{variantId:line.variant_id}:{},...line.inputs?{inputs:line.inputs}:{},...line.note?{note:line.note}:{}}))}catch(error){options.signal?.throwIfAborted();const reasons=error.issues;dropped.push({lineId:line.line_id,name:line.name,quantity:line.quantity,issues:reasons?.length?reasons.map(({code,message})=>({code,message})):[{code:error.code??"item_unavailable",message:`${line.name} isn't available right now.`}]})}}if(reorder.fulfilment==="pickup"&&!cart.getSnapshot().fulfilment){cart.setFulfilment({type:"pickup",branchId:branch})}return{added,dropped}}export{addReorderToCart};
|
|
2
|
-
//# sourceMappingURL=reorder.js.map
|
package/dist/customer/request.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
1
|
import{apiError,requestWithRetry}from"../internal/customer-http.js";import{CustomerError}from"./error.js";async function readCustomerResponse(response,service){if(!response.ok){const value=await apiError(response,`The ${service} service answered ${response.status}`);throw new CustomerError(response.status,value.apiCode,value.message,value.param,value.issues)}return response.status===204?void 0:await response.json()}function createCustomerRequest(base,fetcher,unauthorized){return async(path,init={})=>{const response=await requestWithRetry(fetcher,base+path,init,"Could not reach the customer service");if(response.status===401){unauthorized()}return readCustomerResponse(response,"customer")}}export{createCustomerRequest,readCustomerResponse};
|
|
2
|
-
//# sourceMappingURL=request.js.map
|
package/dist/customer/types.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1,2 +1 @@
|
|
|
1
1
|
import{wait}from"../internal/customer-http.js";import{CustomerError}from"./error.js";var final=new Set(["completed","cancelled","rejected"]);function watchOrder(base,id,read,options){const controller=new AbortController;const pollMs=options.pollMs??15e3;let source;let failures=0;let stopped=false;const stop=()=>{if(stopped){return}stopped=true;source?.close();controller.abort();options.signal?.removeEventListener("abort",stop)};const publish=order=>{options.onOrder(order);if(final.has(order.status)){stop()}};const poll=async()=>{while(!stopped){try{publish(await read(id,controller.signal))}catch(failure){if(failure instanceof CustomerError&&failure.status!==void 0&&failure.status>=400&&failure.status<500){stop();return}}if(!stopped){await wait(pollMs,controller.signal).catch(()=>void 0)}}};const connect=()=>{if(stopped||typeof EventSource==="undefined"){void poll();return}source=new EventSource(`${base}/me/orders/${encodeURIComponent(id)}/events`);source.addEventListener("status",event=>{failures=0;let next;try{next=JSON.parse(event.data)}catch{return}publish(next)});source.onerror=()=>{source?.close();failures++;if(failures>=2){void poll()}else{connect()}}};options.signal?.addEventListener("abort",stop,{once:true});if(options.signal?.aborted){stop()}else{connect()}return stop}export{watchOrder};
|
|
2
|
-
//# sourceMappingURL=watch-order.js.map
|
package/dist/debug.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
var VERSION=true?"0.
|
|
2
|
-
//# sourceMappingURL=debug.js.map
|
|
1
|
+
var VERSION=true?"0.29.1":"0.0.0-development";function installDebug(client){if(typeof window==="undefined"||client.mode!=="test"){return}const events=[];let quote;const emit=(name,detail)=>{const event={name,detail,at:new Date().toISOString()};events.push(event);window.dispatchEvent(new CustomEvent("zappie:event",{detail:event}))};globalThis.__zappieEmit=emit;window.__zappie={version:VERSION,store:client.config.store,async catalogue(){await client.cart.hydrate();const branch=(await client.store.get()).branches.find(value=>value.id===client.cart.getSnapshot().branchId);return{branch,menu:await client.menu.get({branch:branch.id})}},cart:Object.assign(()=>client.cart.getSnapshot(),{async inject(input){await client.cart.hydrate();if(input.lines.length>100||input.lines.some(line=>!Number.isInteger(line.quantity??1)||(line.quantity??1)<1||(line.quantity??1)>99)){throw new Error("Use up to 100 cart lines with whole quantities from 1 to 99.")}const snapshot=client.cart.getSnapshot();const value={v:1,menuVersion:client._internal.cartCatalogue().version,updatedAt:Date.now(),fulfilment:snapshot.fulfilment,promoCode:snapshot.promoCode,lines:input.lines.map((line,index)=>({...line,id:`debug_${index}`,name:line.itemId,quantity:line.quantity??1,choices:(line.choices??[]).map(choice=>({...choice,quantity:choice.quantity??1})),inputs:line.inputs??{},addedAt:new Date().toISOString()}))};const scope=client.config.cart?.storageScope;(client.config.storage??window.localStorage).setItem(`zappie:cart:v1:${client.config.store}:${snapshot.branchId}${scope?`:${scope}`:""}`,JSON.stringify(value))}}),quote:()=>quote,events};client.on("add_to_cart",detail=>emit("add_to_cart",detail));client.cart.subscribe(()=>{const state=client.cart.state;const next="quote"in state?state.quote:void 0;if(next&&next!==quote){quote=next;emit("quote",next)}})}export{installDebug};
|
package/dist/display/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Branch } from '@zappie/sdk';
|
|
2
2
|
|
|
3
3
|
/** What an order placed at the branch is called. */
|
|
4
|
-
type InVenueLabel =
|
|
4
|
+
type InVenueLabel =
|
|
5
|
+
/** An order at a restaurant branch, or at a branch without a category. */
|
|
6
|
+
"Dine-in"
|
|
7
|
+
/** An order at a retail branch. */
|
|
8
|
+
| "Walk-in";
|
|
5
9
|
/**
|
|
6
10
|
* What to call an order placed at the branch: "Walk-in" for a retail branch and
|
|
7
11
|
* "Dine-in" otherwise. A branch without a category is a restaurant.
|
package/dist/display/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
1
|
function inVenueLabel(branch){return branch.category==="RETAIL"?"Walk-in":"Dine-in"}var PLANS={NG:["234",[3,3,4]],GH:["233",[2,3,4]]};function formatPhone(phone,options={}){const compact=phone.replace(/[\s().-]/g,"");const plan=compact[0]==="+"?Object.values(PLANS).find(([code2])=>compact.startsWith(code2,1)):PLANS[options.country?.toUpperCase()??""];if(!plan){return phone}const[code,groups]=plan;const length=groups.reduce((sum,size)=>sum+size,0);const national=(compact[0]==="+"?compact.slice(1+code.length):compact.length===code.length+length&&compact.startsWith(code)?compact.slice(code.length):compact).replace(/^0/,"");if(national.length!==length||!/^\d+$/.test(national)){return phone}let at=0;return[`+${code}`,...groups.map(size=>national.slice(at,at+=size))].join(" ")}export{formatPhone,inVenueLabel};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/dist/error-pages/art.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
1
|
var LOGO='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 153 31" width="118" height="24"><path d="M0 10.1L10.1 0H30.4V10.1L18 15.2L20.3 10.1H0Z" fill="#9FE870"/><path d="M30.4 20.3L20.3 30.4H0V20.3L12.4 15.2L10.1 20.3H30.4Z" fill="#9FE870"/><path d="M46.60 5.95H60.20V9.25L51.25 20.11H60.50V23.41H46.20V20.11L55.15 9.25H46.60Z" fill="{word}"/><path d="M63.21 18.4C63.21 15.7 65.1 13.6 69.8 13.6H76.2V12.4C76.2 9.8 74.7 8.6 71.6 8.6C68.9 8.6 67.4 9.6 67.4 11.6C67.4 11.7 67.4 12 67.4 12.3H63.8C63.8 12 63.7 11.6 63.7 11.3C63.7 7.7 66.7 5.7 71.7 5.7C77 5.7 80.1 8.2 80.1 12.8V23.4H76.2C76.3 22.6 76.4 21 76.4 19.6C75.8 22.1 73.7 23.7 69.8 23.7C65.9 23.7 63.2 21.8 63.2 18.4H63.21ZM76.2 16.4V16H70.1C67.8 16 66.9 16.8 66.9 18.2C66.9 19.8 68.3 20.7 70.7 20.7C74.1 20.7 76.2 19.1 76.2 16.4Z" fill="{word}"/><path d="M84.1 5.9H88L88 10C88.7 7.4 91 5.6 94.5 5.6C99.5 5.6 102.6 9.1 102.6 14.3C102.6 20 99.5 23.6 94.4 23.6C90.9 23.6 88.7 22.1 88 19.8C88 21 88.1 22.8 88.1 23.5V30.4H84.1V5.9L84.1 5.9ZM98.7 14.5C98.7 11.2 96.7 9 93.6 9C90.4 9 88.1 11.2 88 14.7V15.6C88 18.6 90.3 20.5 93.6 20.5C96.7 20.5 98.7 18.1 98.7 14.5Z" fill="{word}"/><path d="M106.18 5.9H110.1L110.1 10C110.8 7.4 113.1 5.6 116.6 5.6C121.6 5.6 124.7 9.1 124.7 14.3C124.7 20 121.6 23.6 116.5 23.6C113 23.6 110.8 22.1 110.1 19.8C110.1 21 110.2 22.8 110.2 23.5V30.4H106.2V5.9L106.18 5.9ZM120.8 14.5C120.8 11.2 118.8 9 115.7 9C112.5 9 110.2 11.2 110.1 14.7V15.6C110.1 18.6 112.4 20.5 115.74 20.5C118.8 20.5 120.8 18.1 120.8 14.5Z" fill="{word}"/><path d="M128.3 0H132.4V3.9H128.3V0ZM128.3 5.9H132.3V23.4H128.3V5.9Z" fill="{word}"/><path d="M153 15.5H139.9C140.1 18.8 142 20.6 144.96 20.6C147.5 20.6 149.25 19.5 149.4 17.5H153C152.9 21.4 149.7 23.7 144.9 23.7C139.4 23.7 135.9 20.3 135.9 14.8C135.9 9.3 139.4 5.7 144.9 5.7C149.8 5.7 153 8.6 153 14.1V15.5H153ZM149.4 12.8C149.4 10.2 147.8 8.8 144.9 8.8C142 8.8 140.4 10.2 140 13.1H149.4V12.9V12.8Z" fill="{word}"/></svg>';var ZEE={"not-found":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -8 120 128" width="112" height="120"><defs><linearGradient id="zpe-head" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#C2F3A3"/><stop offset=".55" stop-color="#9FE870"/><stop offset="1" stop-color="#86DB52"/></linearGradient><linearGradient id="zpe-hand" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#FAFAF8"/><stop offset="1" stop-color="#E4E6DC"/></linearGradient></defs><g><rect x="18" y="20" width="84" height="80" rx="28" fill="url(#zpe-head)"/><rect x="18" y="20" width="84" height="80" rx="28" fill="none" stroke="#FFFFFF" stroke-opacity=".35" stroke-width="2"/><path d="M60 24V12h10L50 2h20" fill="none" stroke="#86DB52" stroke-width="4.5" stroke-linecap="round" stroke-linejoin="round"/><ellipse cx="36" cy="79" rx="8" ry="4.5" fill="#FFFFFF"/><ellipse cx="84" cy="79" rx="8" ry="4.5" fill="#FFFFFF"/><g transform="translate(43.5 57) scale(1.08) translate(-43.5 -57)"><rect x="37" y="46" width="13" height="22" rx="6.5" fill="#121A0E"/><circle cx="41" cy="51" r="2.6" fill="#FFFFFF"/></g><g transform="translate(76.5 57) scale(1.08) translate(-76.5 -57)"><rect x="70" y="46" width="13" height="22" rx="6.5" fill="#121A0E"/><circle cx="74" cy="51" r="2.6" fill="#FFFFFF"/></g><ellipse cx="60" cy="81" rx="4.2" ry="5.5" fill="#121A0E"/><circle cx="15" cy="103" r="9.5" fill="url(#zpe-hand)"/><circle cx="105" cy="103" r="9.5" fill="url(#zpe-hand)"/></g></svg>',"went-wrong":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -8 120 128" width="112" height="120"><defs><linearGradient id="zpe-head" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#C2F3A3"/><stop offset=".55" stop-color="#9FE870"/><stop offset="1" stop-color="#86DB52"/></linearGradient><linearGradient id="zpe-hand" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#FAFAF8"/><stop offset="1" stop-color="#E4E6DC"/></linearGradient></defs><g><rect x="18" y="20" width="84" height="80" rx="28" fill="url(#zpe-head)"/><rect x="18" y="20" width="84" height="80" rx="28" fill="none" stroke="#FFFFFF" stroke-opacity=".35" stroke-width="2"/><path d="M60 24V12h10L50 2h20" fill="none" stroke="#86DB52" stroke-width="4.5" stroke-linecap="round" stroke-linejoin="round" transform="rotate(-20 60 24) translate(0 1)"/><ellipse cx="36" cy="79" rx="8" ry="4.5" fill="#FFFFFF"/><ellipse cx="84" cy="79" rx="8" ry="4.5" fill="#FFFFFF"/><g transform="translate(0 2)"><g><rect x="37" y="46" width="13" height="22" rx="6.5" fill="#121A0E"/><circle cx="41" cy="51" r="2.6" fill="#FFFFFF" transform="translate(0 2)"/></g><g><rect x="70" y="46" width="13" height="22" rx="6.5" fill="#121A0E"/><circle cx="74" cy="51" r="2.6" fill="#FFFFFF" transform="translate(0 2)"/></g></g><path d="M36 40l14 5" fill="none" stroke="#121A0E" stroke-width="3.4" stroke-linecap="round" transform="translate(0 -3) rotate(-38 43 42.5)"/><path d="M84 40l-14 5" fill="none" stroke="#121A0E" stroke-width="3.4" stroke-linecap="round" transform="translate(0 -3) rotate(38 77 42.5)"/><path d="M53 83q7-5.5 14 0" fill="none" stroke="#121A0E" stroke-width="3.6" stroke-linecap="round"/><circle cx="15" cy="103" r="9.5" fill="url(#zpe-hand)"/><circle cx="105" cy="103" r="9.5" fill="url(#zpe-hand)"/></g></svg>'};export{LOGO,ZEE};
|
|
2
|
-
//# sourceMappingURL=art.js.map
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
* store and credits Zappie in one line. Storefronts draw their own pages with `siteError` from
|
|
5
5
|
* `@zappie/sdk/site-error`.
|
|
6
6
|
*/
|
|
7
|
-
type PlatformErrorKind =
|
|
7
|
+
type PlatformErrorKind =
|
|
8
|
+
/** A page or table code that doesn't exist. The page answers with 404. */
|
|
9
|
+
"not-found"
|
|
10
|
+
/** A page the site could not render. The page answers with 500. */
|
|
11
|
+
| "went-wrong";
|
|
8
12
|
/** The store a page belongs to. */
|
|
9
13
|
type PlatformErrorStore = {
|
|
10
14
|
/** The store's name, shown over the heading and as the page's title. */
|
|
@@ -23,14 +27,20 @@ type PlatformErrorOptions = {
|
|
|
23
27
|
};
|
|
24
28
|
/** One of the page's links. An empty `href` reloads the address the guest is on. */
|
|
25
29
|
type PlatformErrorAction = {
|
|
30
|
+
/** The link's text, such as "Try again" or "Go to the home page". */
|
|
26
31
|
label: string;
|
|
32
|
+
/** Where the link leads. Empty for "Try again", which reloads the current address. */
|
|
27
33
|
href: string;
|
|
34
|
+
/** True for the page's main link, drawn as the filled button. */
|
|
28
35
|
primary: boolean;
|
|
29
36
|
};
|
|
30
37
|
/** Everything the page shows, for drawing it as HTML or in React. */
|
|
31
38
|
type PlatformErrorParts = {
|
|
39
|
+
/** Which page this is. */
|
|
32
40
|
kind: PlatformErrorKind;
|
|
41
|
+
/** The page's heading, such as "We couldn't find that page". */
|
|
33
42
|
title: string;
|
|
43
|
+
/** The sentence under the heading that says what happened and what to do. */
|
|
34
44
|
text: string;
|
|
35
45
|
/** The Zappie lockup as image sources, for light and dark pages. */
|
|
36
46
|
logo: {
|
|
@@ -39,6 +49,7 @@ type PlatformErrorParts = {
|
|
|
39
49
|
};
|
|
40
50
|
/** Zee as an image source: surprised for a missing page, sad for a failed one. */
|
|
41
51
|
zee: string;
|
|
52
|
+
/** The page's links. `went-wrong` has "Try again" first and a link home. `not-found` has only the link home. */
|
|
42
53
|
actions: PlatformErrorAction[];
|
|
43
54
|
/** The store the page belongs to, with its link resolved. Zappie's own page has none. */
|
|
44
55
|
store?: PlatformErrorStore & {
|
|
@@ -23,4 +23,3 @@ main.zpe[data-store]{grid-template-rows:1fr auto}
|
|
|
23
23
|
@media (prefers-reduced-motion:reduce){.zpe .zpe-body,.zpe .zpe-zee{animation:none}}
|
|
24
24
|
@keyframes zpe-enter{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
|
|
25
25
|
@keyframes zpe-float{0%,100%{transform:translateY(0)}50%{transform:translateY(-3px)}}`;var PLATFORM_ERROR_FONTS="https://fonts.googleapis.com/css2?family=Geist:wght@400;600&display=swap";var escape=text=>text.replace(/[&<>"]/g,character=>({"&":"&","<":"<",">":">",'"':"""})[character]??character);var PLATFORM_ERROR_CREDIT="https://zappie.ai";function platformErrorTree(kind,options={}){const parts=platformErrorParts(kind,options);const{store}=parts;const center=["div",{className:"zpe-center"},["div",{className:"zpe-body"},store?["a",{className:"zpe-store",href:store.href},store.logo?["img",{alt:store.name,src:store.logo}]:store.name]:["img",{className:"zpe-zee",alt:"",width:"112",height:"120",src:parts.zee}],["h1",{className:"zpe-title"},parts.title],["p",{className:"zpe-text"},parts.text],["div",{className:"zpe-actions"},...parts.actions.map(action=>["a",{className:action.primary?"zpe-button zpe-primary":"zpe-button",href:action.href},action.label])]]];return store?["main",{className:"zpe","data-kind":kind,"data-store":""},center,["p",{className:"zpe-credit"},"Powered by ",["a",{href:PLATFORM_ERROR_CREDIT,"data-zappie-attribution":""},"Zappie"]]]:["main",{className:"zpe","data-kind":kind},["div",{className:"zpe-brand"},["picture",{},["source",{srcSet:parts.logo.dark,media:"(prefers-color-scheme: dark)"}],["img",{alt:"Zappie",width:"118",height:"24",src:parts.logo.light}]]],center]}var html=node=>{if(typeof node==="string"){return escape(node)}const[tag,attributes,...children]=node;const open=`<${tag}${Object.entries(attributes).map(([name,value])=>` ${name==="className"?"class":name.toLowerCase()}="${escape(value)}"`).join("")}>`;return tag==="img"||tag==="source"?open:`${open}${children.map(html).join("")}</${tag}>`};function platformErrorMarkup(kind,options={}){return html(platformErrorTree(kind,options))}function platformErrorDocument(kind,options={}){const store=platformErrorParts(kind,options).store;return`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="robots" content="noindex"><title>${escape(COPY[kind].title)}${store?` | ${escape(store.name)}`:""}</title><link rel="stylesheet" href="${escape(PLATFORM_ERROR_FONTS)}"><style>${PLATFORM_ERROR_STYLES}</style></head><body style="margin:0">${platformErrorMarkup(kind,options)}</body></html>`}function withPlatformErrorPage(response,options={}){const status=response.status;const kind=status===404||status===410?"not-found":status>=500?"went-wrong":void 0;if(!kind||!/^text\/html/i.test(response.headers.get("content-type")??"")){return response}response.body?.cancel().catch(()=>void 0);const headers=new Headers(response.headers);for(const name of["content-length","content-encoding","etag"]){headers.delete(name)}headers.set("content-type","text/html; charset=utf-8");headers.set("cache-control","no-store");return new Response(platformErrorDocument(kind,options),{status,statusText:response.statusText,headers})}function platformErrorResponse(kind,options={}){return new Response(platformErrorDocument(kind,options),{status:STATUS[kind],headers:{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}})}export{PLATFORM_ERROR_CREDIT,PLATFORM_ERROR_FONTS,PLATFORM_ERROR_STYLES,platformErrorDocument,platformErrorKind,platformErrorMarkup,platformErrorParts,platformErrorResponse,platformErrorStatus,platformErrorTree,withPlatformErrorPage};
|
|
26
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1 @@
|
|
|
1
1
|
import{PLATFORM_ERROR_FONTS,PLATFORM_ERROR_STYLES,platformErrorKind,platformErrorTree}from"@zappie/sdk/error-pages";import{createElement,Fragment}from"react";import{platformErrorKind as platformErrorKind2}from"@zappie/sdk/error-pages";import{jsx,jsxs}from"react/jsx-runtime";var draw=node=>{if(typeof node==="string"){return node}const[tag,attributes,...children]=node;return createElement(tag,attributes,...children.map(draw))};function PlatformErrorPage({kind,error,home,store}){return jsxs(Fragment,{children:[jsx("link",{rel:"stylesheet",href:PLATFORM_ERROR_FONTS}),jsx("style",{children:PLATFORM_ERROR_STYLES}),draw(platformErrorTree(kind??platformErrorKind(error),{...home===void 0?{}:{home},...store===void 0?{}:{store}}))]})}export{PlatformErrorPage,platformErrorKind2 as platformErrorKind};
|
|
2
|
-
//# sourceMappingURL=react.js.map
|
package/dist/errors.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
var codes=["network_error","timeout","rate_limited","unauthorized","forbidden","forbidden_origin","scope_required","not_found","store_not_found","branch_not_found","item_not_found","cart_invalid","invalid_request","version_unsupported","server_error"];var ZappieError=class extends Error{constructor(code,message,details={}){super(message,{cause:details.cause});this.code=code;this.name="ZappieError";
|
|
2
|
-
//# sourceMappingURL=errors.js.map
|
|
1
|
+
var codes=["network_error","timeout","rate_limited","unauthorized","forbidden","forbidden_origin","scope_required","not_found","store_not_found","branch_not_found","item_not_found","cart_invalid","invalid_request","version_unsupported","server_error"];var ZappieError=class extends Error{constructor(code,message,details={}){super(message,{cause:details.cause});this.code=code;this.name="ZappieError";for(const key of["status","param","requestId","apiCode"]){if(details[key]!==void 0){Object.assign(this,{[key]:details[key]})}}this.docUrl=details.docUrl??`https://docs.zappie.ai/errors#${code}`;this.retryable=details.retryable??["network_error","timeout","rate_limited","server_error"].includes(code)}};function isZappieError(error){return error instanceof ZappieError}function asError(error){return isZappieError(error)?error:new ZappieError("network_error","The storefront request failed",{cause:error})}function wireError(value,status,requestId){const envelope=value&&typeof value==="object"?value:{};const e=envelope.error&&typeof envelope.error==="object"?envelope.error:{};const fallback=status===401?"unauthorized":status===403?"forbidden_origin":status===404?"not_found":status===429?"rate_limited":status>=500?"server_error":"invalid_request";const apiCode=typeof e.code==="string"&&e.code?e.code:void 0;const known=apiCode!==void 0&&codes.includes(apiCode);const code=known?apiCode:apiCode&&status===403?"forbidden":fallback;const message=typeof e.message==="string"?e.message:"The storefront request failed";return new ZappieError(code,message,{status,...requestId?{requestId}:{},...typeof e.param==="string"?{param:e.param}:{},...typeof e.doc_url==="string"?{docUrl:e.doc_url}:{},...apiCode?{apiCode}:{}})}export{ZappieError,asError,isZappieError,wireError};
|
package/dist/in-venue/bill.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
1
|
function publicId(prefix,id){return id.startsWith(`${prefix}_`)?id:`${prefix}_${id}`}function destinationPath(destination,payPointId){const query=ids2=>{const params=new URLSearchParams;for(const[key,value]of Object.entries(ids2)){if(value){params.set(key,value)}}params.set("pay_point_id",payPointId);return`?${params}`};const ids={menu_id:destination.menu_id,menu_group_id:destination.menu_group_id};switch(destination.type){case"dine_in_order":return destination.order_id?`/dine-in/${encodeURIComponent(destination.order_id)}${query({})}`:void 0;case"menu":case"menu_group":return`/dine-in/menus${query(ids)}`;default:return void 0}}function billScope(selected,diners){const everyone=diners.length>0&&diners.every(diner=>selected.includes(diner.id));return everyone?[]:[...selected]}function unassignedTotal(order){const assigned=order.diners.reduce((total,diner)=>total+diner.total.amount_minor,0);return Math.max(order.total.amount_minor-assigned,0)}function sortDiners(diners,me){if(!me){return[...diners].sort((left,right)=>left.id.localeCompare(right.id))}const mine=diners.filter(diner=>diner.id===me);return[...mine,...diners.filter(diner=>diner.id!==me)]}function scopeMessage(paying,scope,diners,me){if(scope.length===0||scope.length>=diners.length){return paying?"You're about to pay the whole bill.":"Viewing everyone's bill."}const[first]=scope;const name=diners.find(value=>value.id===first)?.first_name||"Guest";const n=scope.length-1;const rest=n?` and ${n} other${paying?n>1?" people":" person":n>1?"s":""}`:"";if(paying){return`You're about to pay for ${!n&&first===me?"yourself":name}${rest}.`}const owner=first===me?"your":name.endsWith("s")?`${name}'`:`${name}'s`;return`Viewing ${owner} bill${rest}.`}export{billScope,destinationPath,publicId,scopeMessage,sortDiners,unassignedTotal};
|
|
2
|
-
//# sourceMappingURL=bill.js.map
|