@zappie/sdk 0.10.6 → 0.10.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +36 -9
- package/dist/cart/item.d.ts +1 -1
- package/dist/cart/quote.d.ts +1 -1
- package/dist/checkout-defaults/index.d.ts +22 -10
- package/dist/checkout-defaults/index.js +44 -45
- package/dist/checkout-defaults/index.js.map +1 -1
- package/dist/{client-Bn7nRoy3.d.ts → client-CtDaenmW.d.ts} +2 -2
- package/dist/customer/client.js +19 -2
- package/dist/customer/client.js.map +1 -1
- package/dist/customer/index.d.ts +1 -1
- package/dist/debug.js +1 -1
- package/dist/display/index.d.ts +32 -0
- package/dist/display/index.js +31 -0
- package/dist/display/index.js.map +6 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/dist/integrations/index.d.ts +2 -2
- package/dist/internal/remembered-address.js +63 -0
- package/dist/internal/remembered-address.js.map +6 -0
- package/dist/internal.d.ts +2 -2
- package/dist/{models-C-kEg1Id.d.ts → models-asoc6fS3.d.ts} +10 -2
- package/dist/money.js +21 -32
- package/dist/money.js.map +1 -1
- package/dist/persist/catalogue.d.ts +3 -3
- package/dist/pricing/index.d.ts +22 -3
- package/dist/pricing/index.js +63 -12
- package/dist/pricing/index.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/transport/search.d.ts +1 -1
- package/dist/transport/selected-menu.d.ts +3 -3
- package/dist/transport/store.js +2 -0
- package/dist/transport/store.js.map +1 -1
- package/dist/{types-BzyzhqYz.d.ts → types-DMMeyB5d.d.ts} +1 -1
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @zappie/sdk
|
|
2
2
|
|
|
3
|
+
## 0.10.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0d3b8e8: A remembered delivery address is now offered only to the shopper who entered it. `rememberAddress()` stores whether a guest or which customer used it. Pass the signed-in customer's ID, or `null` for a guest. Without one, it uses the shopper the page's customer client last saw, and keeps nothing before the session answers. `rememberedAddress()` and `defaultAddress()` read it back the same way. An address stored before this release names no shopper, so it is dropped rather than offered to anyone. The customer client forgets the remembered address on `signOut()`, and whenever the session shows a guest or a different customer, so a sign-out on another page or an expired session counts too.
|
|
8
|
+
- 2feeb9a: `signOut()` takes the delivery address out of each bag saved on this device. The bag keeps its items and promo code and holds no fulfilment, so choosing delivery asks for an address again. A pickup bag is left as it is, and blocked storage still signs out.
|
|
9
|
+
|
|
10
|
+
## 0.10.7
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- a3f008f: `Branch` now has `category`, `"RESTAURANT"` or `"RETAIL"`, as the storefront API sends it. A branch without one is a restaurant.
|
|
15
|
+
|
|
16
|
+
New `@zappie/sdk/display` entry. `inVenueLabel(branch)` returns "Walk-in" for a retail branch and "Dine-in" otherwise. `formatPhone(phone, { country })` spaces a Nigerian or Ghanaian number for reading, such as "+234 809 822 6262", and returns any other number as given. Keep linking with the unspaced number.
|
|
17
|
+
|
|
18
|
+
`startingPrice()` now counts a required group's minimum. "Box of four rolls", where the shopper picks exactly four, starts at four of the cheapest roll plus the base price instead of one roll. A choice counts once unless the shopper can set its quantity. New `startingPriceWith(item, choices)` gives the starting price when the shopper picks from the given choices only, such as one plan length.
|
|
19
|
+
|
|
20
|
+
`format.money()` keeps one number formatter per currency and option set instead of building one on every call.
|
|
21
|
+
|
|
3
22
|
## 0.10.6
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -60,7 +60,8 @@ Prices always come from Zappie. The cart shows a local estimate while it waits,
|
|
|
60
60
|
| `@zappie/sdk/account` | `accountsUrl`, a link to the shopper's Zappie account on the accounts portal |
|
|
61
61
|
| `@zappie/sdk/integrations` | Public integration IDs and browser keys |
|
|
62
62
|
| `@zappie/sdk/places` | Address search and delivery-zone checks |
|
|
63
|
-
| `@zappie/sdk/pricing` | An item's starting price and whether to show it as "From"
|
|
63
|
+
| `@zappie/sdk/pricing` | An item's starting price, its price with given choices, and whether to show it as "From" |
|
|
64
|
+
| `@zappie/sdk/display` | Phone numbers spaced for reading, and what a branch calls an in-person order |
|
|
64
65
|
| `@zappie/sdk/branches` | The nearest branch to a shopper, and each branch's distance from them |
|
|
65
66
|
| `@zappie/sdk/options` | Option group rules: radio or checkbox, the group's limit, its labels and the note limit |
|
|
66
67
|
| `@zappie/sdk/server` | Server-side reads, storefront URLs, `verifyWebhook()`, menu snapshots and sign-in crypto |
|
|
@@ -133,16 +134,32 @@ MIT
|
|
|
133
134
|
### Starting price
|
|
134
135
|
|
|
135
136
|
`startingPrice(item)` from `@zappie/sdk/pricing` returns the price an item starts from: the cheapest
|
|
136
|
-
available variant plus the cheapest
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
add-on raises it. `item.price` is
|
|
137
|
+
available variant plus the cheapest valid choices of each required add-on group. A group that needs
|
|
138
|
+
exactly or at least four choices adds its four cheapest units, and a choice counts once unless the
|
|
139
|
+
shopper can set its quantity. It is the rule Zappie uses for a product's starting price. When no
|
|
140
|
+
variant is available, it uses the cheapest variant. `showsFromPrice(item)` says whether to show that
|
|
141
|
+
price as "From": available variants differ in price, or a required add-on raises it. `item.price` is
|
|
142
|
+
the branch price, not the starting price.
|
|
143
|
+
|
|
144
|
+
`startingPriceWith(item, choices)` is the starting price when the shopper picks from the given
|
|
145
|
+
choices only, such as one plan length: `[{ groupId: "length", choiceId: "4-weeks" }]`. An attribute
|
|
146
|
+
group narrows the variants, and an add-on group narrows its choices.
|
|
141
147
|
|
|
142
148
|
The API sends one `available` flag per item and variant, and a free-text
|
|
143
149
|
`stockLabel`. It doesn't say whether an item is sold out or unavailable for
|
|
144
150
|
another reason, so `isAvailable` covers both.
|
|
145
151
|
|
|
152
|
+
### Phone numbers and in-person orders
|
|
153
|
+
|
|
154
|
+
`formatPhone(phone)` from `@zappie/sdk/display` spaces a number for reading:
|
|
155
|
+
`formatPhone("+2348098226262")` is `"+234 809 822 6262"`. Link with the unspaced
|
|
156
|
+
number, as in `tel:+2348098226262`. It knows Nigerian and Ghanaian numbers and
|
|
157
|
+
returns any other number as given. Pass `{ country: "NG" }` to read a number
|
|
158
|
+
written without a country code.
|
|
159
|
+
|
|
160
|
+
`inVenueLabel(branch)` says what an order placed at the branch is called:
|
|
161
|
+
"Walk-in" when `branch.category` is `"RETAIL"`, and "Dine-in" otherwise.
|
|
162
|
+
|
|
146
163
|
### Place routes
|
|
147
164
|
|
|
148
165
|
`places.place(placeId, { branchId })` returns `route` with optional
|
|
@@ -211,10 +228,20 @@ default storefront does, so every template follows one rule.
|
|
|
211
228
|
type is `"fixed"`, an address without a place ID counts as none. The cart's
|
|
212
229
|
own delivery address always wins in `checkoutDefaults()`.
|
|
213
230
|
- **Remembering.** `rememberAddress(address, storage, customerId)` keeps the
|
|
214
|
-
address line, place ID, coordinates and
|
|
215
|
-
|
|
216
|
-
`
|
|
231
|
+
address line, place ID, coordinates and who used it in `localStorage`, on
|
|
232
|
+
this device only, for that shopper alone. Pass the signed-in customer's ID,
|
|
233
|
+
or `null` for a guest. Leave it out and the address belongs to whoever the
|
|
234
|
+
page's customer client last saw signed in, and nothing is kept before the
|
|
235
|
+
session answers. `rememberedAddress()` reads it back the same way. An
|
|
236
|
+
address stored before it named its shopper is dropped, not offered.
|
|
237
|
+
`rememberAddress(null)` forgets it. Both do nothing where storage is
|
|
217
238
|
blocked.
|
|
239
|
+
- **Sign-out.** The customer client forgets the remembered address on
|
|
240
|
+
`signOut()`, and whenever the session shows a guest or another customer,
|
|
241
|
+
so a sign-out on another page or an expired session counts too.
|
|
242
|
+
`signOut()` also takes the delivery address out of each bag saved on this
|
|
243
|
+
device. The bag keeps its items and promo code and holds no fulfilment, so
|
|
244
|
+
choosing delivery asks for an address again. A pickup bag is left as it is.
|
|
218
245
|
- **Region.** `defaultRegion(branch, chosen)` keeps a chosen region and
|
|
219
246
|
otherwise picks the branch's only one.
|
|
220
247
|
- **Time.** `restoreSchedule(fulfilment, branchId)` keeps the cart's scheduled
|
package/dist/cart/item.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Zappie } from '../index.js';
|
|
2
2
|
import { Item } from '../index.js';
|
|
3
|
-
import '../types-
|
|
3
|
+
import '../types-DMMeyB5d.js';
|
|
4
4
|
|
|
5
5
|
/** Register an item already read by a partial/selected catalogue, without fetching it again. */
|
|
6
6
|
declare function prepareItem(client: Zappie, item: Item, options: {
|
package/dist/cart/quote.d.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { DeliveryAddress, Branch, CartFulfilment } from '@zappie/sdk';
|
|
2
2
|
import { SessionCustomer, SavedAddress, CustomerClient } from '@zappie/sdk/customer';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* How the branch prices delivery. Only `"fixed"` lets an address without a place ID stand.
|
|
6
|
-
*/
|
|
7
|
-
type DeliveryFeeType = "region" | "distance" | "fixed";
|
|
8
4
|
/**
|
|
9
5
|
* The browser storage the remembered address uses. Pass `null` to remember nothing.
|
|
10
6
|
*/
|
|
11
7
|
type AddressStorage = Pick<Storage, "getItem" | "setItem" | "removeItem">;
|
|
8
|
+
declare global {
|
|
9
|
+
var __zappieShopper: {
|
|
10
|
+
id: string | null;
|
|
11
|
+
} | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* How the branch prices delivery. Only `"fixed"` lets an address without a place ID stand.
|
|
16
|
+
*/
|
|
17
|
+
type DeliveryFeeType = "region" | "distance" | "fixed";
|
|
18
|
+
|
|
12
19
|
/**
|
|
13
20
|
* The phone a checkout shows, and the `contact_phone` to send.
|
|
14
21
|
*/
|
|
@@ -60,9 +67,12 @@ declare function defaultPhone(typed: string | undefined, customer: SessionCustom
|
|
|
60
67
|
/**
|
|
61
68
|
* The last delivery address this shopper used on this device, or undefined. An address a guest
|
|
62
69
|
* used is offered only to a guest, and one a customer used only to that customer. Under
|
|
63
|
-
* distance or region fees, an entry without a place ID counts as none and is removed.
|
|
70
|
+
* distance or region fees, an entry without a place ID counts as none and is removed. So is an
|
|
71
|
+
* entry that names no shopper, written before addresses had one.
|
|
64
72
|
*
|
|
65
|
-
* @param options - The fee type, storage and signed-in customer's ID.
|
|
73
|
+
* @param options - The fee type, storage and signed-in customer's ID. Pass `customerId: null`
|
|
74
|
+
* for a guest. Without it, the shopper is the one the page's customer client last saw, and
|
|
75
|
+
* nothing is offered before it has seen one.
|
|
66
76
|
*/
|
|
67
77
|
declare function rememberedAddress(options?: {
|
|
68
78
|
feeType?: DeliveryFeeType;
|
|
@@ -70,13 +80,15 @@ declare function rememberedAddress(options?: {
|
|
|
70
80
|
customerId?: string | null;
|
|
71
81
|
}): DeliveryAddress | undefined;
|
|
72
82
|
/**
|
|
73
|
-
* Remember the delivery address the shopper used, on this device only
|
|
74
|
-
* line, place ID, coordinates and
|
|
75
|
-
* is blocked.
|
|
83
|
+
* Remember the delivery address the shopper used, on this device only, for that shopper alone.
|
|
84
|
+
* Stores the address line, place ID, coordinates and who used it, nothing else. Does nothing
|
|
85
|
+
* where storage is blocked, or when the shopper is unknown. The customer client forgets the
|
|
86
|
+
* address when its customer signs out.
|
|
76
87
|
*
|
|
77
88
|
* @param value - The address, or null to forget it.
|
|
78
89
|
* @param storage - Defaults to `localStorage`.
|
|
79
|
-
* @param customerId - The signed-in customer's ID
|
|
90
|
+
* @param customerId - The signed-in customer's ID, or null for a guest. Without it, the
|
|
91
|
+
* shopper is the one the page's customer client last saw.
|
|
80
92
|
*/
|
|
81
93
|
declare function rememberAddress(value: DeliveryAddress | null, storage?: AddressStorage | null, customerId?: string | null): void;
|
|
82
94
|
/**
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
// src/checkout-defaults/index.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
function attempt(fn) {
|
|
14
|
-
try {
|
|
15
|
-
return fn();
|
|
16
|
-
} catch {
|
|
17
|
-
return void 0;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
2
|
+
import {
|
|
3
|
+
ADDRESS_KEY,
|
|
4
|
+
addressStorage,
|
|
5
|
+
forgetRememberedAddress,
|
|
6
|
+
knownShopper,
|
|
7
|
+
ownerOf,
|
|
8
|
+
readStored,
|
|
9
|
+
settleShopper
|
|
10
|
+
} from "../internal/remembered-address.js";
|
|
20
11
|
function text(value) {
|
|
21
12
|
return typeof value === "string" && value.trim() ? value : void 0;
|
|
22
13
|
}
|
|
@@ -34,56 +25,64 @@ function defaultPhone(typed, customer) {
|
|
|
34
25
|
const masked = customer?.phone_masked;
|
|
35
26
|
return masked ? { display: masked, fromAccount: true } : { display: "", fromAccount: false };
|
|
36
27
|
}
|
|
28
|
+
function shopper(customerId) {
|
|
29
|
+
return customerId === null ? null : customerId || knownShopper();
|
|
30
|
+
}
|
|
37
31
|
function rememberedAddress(options = {}) {
|
|
38
|
-
const storage =
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
32
|
+
const storage = addressStorage(options.storage);
|
|
33
|
+
const stored = readStored(storage);
|
|
34
|
+
if (!stored) {
|
|
41
35
|
return void 0;
|
|
42
36
|
}
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
37
|
+
const owner = ownerOf(stored);
|
|
38
|
+
if (owner === void 0) {
|
|
39
|
+
forgetRememberedAddress(storage);
|
|
45
40
|
return void 0;
|
|
46
41
|
}
|
|
47
|
-
const
|
|
42
|
+
const reader = shopper(options.customerId);
|
|
43
|
+
if (reader === void 0 || owner !== reader) {
|
|
44
|
+
if (typeof reader === "string" && typeof owner === "string") {
|
|
45
|
+
forgetRememberedAddress(storage);
|
|
46
|
+
}
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
const placeId = text(stored.placeId);
|
|
48
50
|
if (!placeId && options.feeType !== "fixed") {
|
|
49
|
-
|
|
51
|
+
forgetRememberedAddress(storage);
|
|
50
52
|
return void 0;
|
|
51
53
|
}
|
|
52
54
|
return address(
|
|
53
|
-
text(stored
|
|
55
|
+
text(stored.address),
|
|
54
56
|
placeId,
|
|
55
|
-
stored
|
|
56
|
-
stored
|
|
57
|
+
stored.latitude,
|
|
58
|
+
stored.longitude
|
|
57
59
|
);
|
|
58
60
|
}
|
|
59
61
|
function rememberAddress(value, storage, customerId) {
|
|
60
|
-
const target =
|
|
62
|
+
const target = addressStorage(storage);
|
|
61
63
|
if (!target) {
|
|
62
64
|
return;
|
|
63
65
|
}
|
|
64
66
|
if (!value?.line1.trim()) {
|
|
65
|
-
|
|
67
|
+
forgetRememberedAddress(target);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const owner = shopper(customerId);
|
|
71
|
+
if (owner === void 0) {
|
|
66
72
|
return;
|
|
67
73
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
try {
|
|
75
|
+
target.setItem(
|
|
76
|
+
ADDRESS_KEY,
|
|
71
77
|
JSON.stringify({
|
|
72
|
-
...
|
|
78
|
+
...owner ? { customerId: owner } : { guest: true },
|
|
73
79
|
address: value.line1,
|
|
74
80
|
placeId: value.placeId ?? "",
|
|
75
81
|
latitude: value.coordinates?.lat,
|
|
76
82
|
longitude: value.coordinates?.lng
|
|
77
83
|
})
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
function forget(customerId, storage) {
|
|
82
|
-
const target = local(storage);
|
|
83
|
-
const raw = target ? attempt(() => target.getItem(KEY)) : void 0;
|
|
84
|
-
const stored = raw ? attempt(() => JSON.parse(raw)) : void 0;
|
|
85
|
-
if (text(stored?.customerId) === customerId) {
|
|
86
|
-
attempt(() => target?.removeItem(KEY));
|
|
84
|
+
);
|
|
85
|
+
} catch {
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
88
|
function defaultAddress(options = {}) {
|
|
@@ -160,8 +159,8 @@ function watchCheckoutDefaults(customer, read, listener) {
|
|
|
160
159
|
const refresh = () => {
|
|
161
160
|
const current = ++run;
|
|
162
161
|
const id = customer.state === "authenticated" ? customer.customer?.id : void 0;
|
|
163
|
-
if (
|
|
164
|
-
|
|
162
|
+
if (customer.state !== "unknown") {
|
|
163
|
+
settleShopper(id ?? null, read().storage);
|
|
165
164
|
}
|
|
166
165
|
signedIn = id;
|
|
167
166
|
if (!id) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/checkout-defaults/index.ts"],
|
|
4
|
-
"mappings": ";
|
|
4
|
+
"mappings": ";AASA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAoDP,SAAS,KAAK,OAAoC;AAChD,SAAO,OAAO,UAAU,YAAY,MAAM,KAAK,IAAI,QAAQ;AAC7D;AAEA,SAAS,MAAM,KAAc,KAAc;AACzC,SAAO,OAAO,QAAQ,YACpB,OAAO,QAAQ,YACf,OAAO,SAAS,GAAG,KACnB,OAAO,SAAS,GAAG,IACjB,EAAE,aAAa,EAAE,KAAK,IAAI,EAAE,IAC5B,CAAC;AACP;AAEA,SAAS,QACP,OACA,SACA,KACA,KAC6B;AAC7B,SAAO,QACH,EAAE,OAAO,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC,GAAI,GAAG,MAAM,KAAK,GAAG,EAAE,IAC7D;AACN;AASO,SAAS,aACd,OACA,UACc;AACd,QAAM,QAAQ,OAAO,KAAK;AAC1B,MAAI,OAAO;AACT,WAAO,EAAE,SAAS,OAAO,cAAc,OAAO,aAAa,MAAM;AAAA,EACnE;AACA,QAAM,SAAS,UAAU;AACzB,SAAO,SACH,EAAE,SAAS,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WAAW,YAAY,KAAK;AAC/B,kBAAQ,KAAK;AAAA,QACf;AAAA,MACF;AAAA,MACA,MAAM;AACJ,YAAI,CAAC,WAAW,YAAY,KAAK;AAC/B,kBAAQ,MAAS;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,QAAM,MAAM,SAAS,SAAS,CAAC,OAAO,SAAS;AAC7C,UAAM,KAAK,UAAU,kBAAkB,MAAM,KAAK;AAClD,QAAI,OAAO,UAAU;AACnB,cAAQ;AAAA,IACV;AAAA,EACF,CAAC;AACD,UAAQ;AACR,SAAO,MAAM;AACX,cAAU;AACV,QAAI;AAAA,EACN;AACF;",
|
|
5
5
|
"names": ["address"]
|
|
6
6
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as Menu, C as CategoryPage, S as Store, I as Item, M as Money, F as Formatters } from './models-
|
|
2
|
-
import { Q as QuoteRequest, h as WireQuote, e as CartIssueCode, d as CartModule, b as CartLineInput } from './types-
|
|
1
|
+
import { a as Menu, C as CategoryPage, S as Store, I as Item, M as Money, F as Formatters } from './models-asoc6fS3.js';
|
|
2
|
+
import { Q as QuoteRequest, h as WireQuote, e as CartIssueCode, d as CartModule, b as CartLineInput } from './types-DMMeyB5d.js';
|
|
3
3
|
|
|
4
4
|
/** Stable public error codes. */
|
|
5
5
|
type ZappieErrorCode = "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";
|
package/dist/customer/client.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// src/customer/client.ts
|
|
2
2
|
import { createPendingNavigation } from "@zappie/sdk/navigation";
|
|
3
3
|
import { requestWithRetry } from "../internal/customer-http.js";
|
|
4
|
+
import {
|
|
5
|
+
forgetBagAddresses,
|
|
6
|
+
forgetRememberedAddress,
|
|
7
|
+
settleShopper
|
|
8
|
+
} from "../internal/remembered-address.js";
|
|
4
9
|
import { currentPath, leaveTo, safeReturnTo } from "./navigation.js";
|
|
5
10
|
import { createCustomerRequest, readCustomerResponse } from "./request.js";
|
|
6
11
|
import { watchOrder } from "./watch-order.js";
|
|
@@ -18,6 +23,12 @@ function createCustomer(options = {}) {
|
|
|
18
23
|
const fetcher = options.fetch ?? globalThis.fetch;
|
|
19
24
|
let customer = options.initialCustomer ?? null;
|
|
20
25
|
let state = options.initialCustomer === void 0 ? "unknown" : customer ? "authenticated" : "anonymous";
|
|
26
|
+
const settle = () => {
|
|
27
|
+
if (state !== "unknown") {
|
|
28
|
+
settleShopper(customer?.id ?? null);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
settle();
|
|
21
32
|
const listeners = /* @__PURE__ */ new Set();
|
|
22
33
|
const notify = () => {
|
|
23
34
|
for (const listener of listeners) {
|
|
@@ -30,6 +41,7 @@ function createCustomer(options = {}) {
|
|
|
30
41
|
}
|
|
31
42
|
state = nextState;
|
|
32
43
|
customer = next;
|
|
44
|
+
settle();
|
|
33
45
|
globalThis.__zappieEmit?.("auth:changed", { state, customer });
|
|
34
46
|
notify();
|
|
35
47
|
};
|
|
@@ -101,9 +113,14 @@ function createCustomer(options = {}) {
|
|
|
101
113
|
)
|
|
102
114
|
);
|
|
103
115
|
},
|
|
104
|
-
/** Sign out through Zappie hosting. A call while pending does nothing. */
|
|
116
|
+
/** Sign out through Zappie hosting, forgetting the delivery address remembered on this device and the one in each saved bag, whose items stay. A call while pending does nothing. */
|
|
105
117
|
signOut() {
|
|
106
|
-
void leaving.start(() =>
|
|
118
|
+
void leaving.start(() => {
|
|
119
|
+
globalThis.__zappieShopper = void 0;
|
|
120
|
+
forgetRememberedAddress();
|
|
121
|
+
forgetBagAddresses();
|
|
122
|
+
return leaveTo("/_zappie/logout", true);
|
|
123
|
+
});
|
|
107
124
|
},
|
|
108
125
|
// Every read is a GET, fetch's default.
|
|
109
126
|
profile: () => request("/me"),
|
|
@@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,CAAC,OACd,QAAc,iBAAiB,mBAAmB,EAAE,CAAC,IAAI;AAAA,MACvD,QAAQ;AAAA,IACV,CAAC;AAAA,IACH,OAAOA,WAA+C,CAAC,GAAG;AACxD,YAAM,QAAQ,IAAI,gBAAgB;AAClC,iBAAW,OAAO,CAAC,SAAS,QAAQ,GAAY;AAC9C,YAAIA,SAAQ,GAAG,MAAM,QAAW;AAC9B,gBAAM,IAAI,KAAK,OAAOA,SAAQ,GAAG,CAAC,CAAC;AAAA,QACrC;AAAA,MACF;AACA,aAAO,QAAoB,aAAa,MAAM,OAAO,IAAI,KAAK,KAAK,EAAE,EAAE;AAAA,IACzE;AAAA,IACA,OAAO,CAAC,OAAe,UAAU,EAAE;AAAA,IACnC,WAAW,IAAY,cAAiC;AACtD,aAAO,WAAW,MAAM,IAAI,WAAW,YAAY;AAAA,IACrD;AAAA,EACF;AACF;",
|
|
5
5
|
"names": ["options"]
|
|
6
6
|
}
|
package/dist/customer/index.d.ts
CHANGED
|
@@ -148,7 +148,7 @@ declare function createCustomer(options?: CustomerClientOptions): {
|
|
|
148
148
|
onChange(listener: CustomerListener): () => void;
|
|
149
149
|
/** Go to sign-in and come back to `returnTo`, this page by default. A call while pending does nothing. */
|
|
150
150
|
signIn(returnTo?: string): void;
|
|
151
|
-
/** Sign out through Zappie hosting. A call while pending does nothing. */
|
|
151
|
+
/** Sign out through Zappie hosting, forgetting the delivery address remembered on this device and the one in each saved bag, whose items stay. A call while pending does nothing. */
|
|
152
152
|
signOut(): void;
|
|
153
153
|
profile: () => Promise<CustomerProfile>;
|
|
154
154
|
addresses(): Promise<SavedAddress[]>;
|
package/dist/debug.js
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Branch } from '@zappie/sdk';
|
|
2
|
+
|
|
3
|
+
/** What an order placed at the branch is called. */
|
|
4
|
+
type InVenueLabel = "Dine-in" | "Walk-in";
|
|
5
|
+
/**
|
|
6
|
+
* What to call an order placed at the branch: "Walk-in" for a retail branch and
|
|
7
|
+
* "Dine-in" otherwise. A branch without a category is a restaurant.
|
|
8
|
+
*
|
|
9
|
+
* @param branch - The branch the order is for.
|
|
10
|
+
*/
|
|
11
|
+
declare function inVenueLabel(branch: Pick<Branch, "category">): InVenueLabel;
|
|
12
|
+
/** Options for `formatPhone`. */
|
|
13
|
+
type FormatPhoneOptions = {
|
|
14
|
+
/**
|
|
15
|
+
* The two-letter country code to read a number without a leading "+" in,
|
|
16
|
+
* such as "NG" for "0809 822 6262".
|
|
17
|
+
*/
|
|
18
|
+
country?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* A phone number spaced for reading, such as "+234 809 822 6262" for
|
|
22
|
+
* "+2348098226262". Use the unspaced number in `tel:` links. A trunk "0"
|
|
23
|
+
* after the country code is dropped. A number from a country Zappie doesn't
|
|
24
|
+
* operate in, or one that doesn't read as a phone number, comes back as given.
|
|
25
|
+
*
|
|
26
|
+
* @param phone - The number, ideally in E.164 form such as "+2348098226262".
|
|
27
|
+
* @param options - The country to read a number without a "+" in.
|
|
28
|
+
*/
|
|
29
|
+
declare function formatPhone(phone: string, options?: FormatPhoneOptions): string;
|
|
30
|
+
|
|
31
|
+
export { formatPhone, inVenueLabel };
|
|
32
|
+
export type { FormatPhoneOptions, InVenueLabel };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/display/index.ts
|
|
2
|
+
function inVenueLabel(branch) {
|
|
3
|
+
return branch.category === "RETAIL" ? "Walk-in" : "Dine-in";
|
|
4
|
+
}
|
|
5
|
+
var PLANS = {
|
|
6
|
+
NG: ["234", [3, 3, 4]],
|
|
7
|
+
GH: ["233", [2, 3, 4]]
|
|
8
|
+
};
|
|
9
|
+
function formatPhone(phone, options = {}) {
|
|
10
|
+
const compact = phone.replace(/[\s().-]/g, "");
|
|
11
|
+
const plan = compact[0] === "+" ? Object.values(PLANS).find(([code2]) => compact.startsWith(code2, 1)) : PLANS[options.country?.toUpperCase() ?? ""];
|
|
12
|
+
if (!plan) {
|
|
13
|
+
return phone;
|
|
14
|
+
}
|
|
15
|
+
const [code, groups] = plan;
|
|
16
|
+
const length = groups.reduce((sum, size) => sum + size, 0);
|
|
17
|
+
const national = (compact[0] === "+" ? compact.slice(1 + code.length) : compact.length === code.length + length && compact.startsWith(code) ? compact.slice(code.length) : compact).replace(/^0/, "");
|
|
18
|
+
if (national.length !== length || !/^\d+$/.test(national)) {
|
|
19
|
+
return phone;
|
|
20
|
+
}
|
|
21
|
+
let at = 0;
|
|
22
|
+
return [
|
|
23
|
+
`+${code}`,
|
|
24
|
+
...groups.map((size) => national.slice(at, at += size))
|
|
25
|
+
].join(" ");
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
formatPhone,
|
|
29
|
+
inVenueLabel
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/display/index.ts"],
|
|
4
|
+
"mappings": ";AAaO,SAAS,aAAa,QAAgD;AAC3E,SAAO,OAAO,aAAa,WAAW,YAAY;AACpD;AAaA,IAAM,QAA0D;AAAA,EAC9D,IAAI,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC;AAAA,EACrB,IAAI,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC;AACvB;AAWO,SAAS,YACd,OACA,UAA8B,CAAC,GACvB;AACR,QAAM,UAAU,MAAM,QAAQ,aAAa,EAAE;AAC7C,QAAM,OACJ,QAAQ,CAAC,MAAM,MACX,OAAO,OAAO,KAAK,EAAE,KAAK,CAAC,CAACA,KAAI,MAAM,QAAQ,WAAWA,OAAM,CAAC,CAAC,IACjE,MAAM,QAAQ,SAAS,YAAY,KAAK,EAAE;AAChD,MAAI,CAAC,MAAM;AACT,WAAO;AAAA,EACT;AACA,QAAM,CAAC,MAAM,MAAM,IAAI;AACvB,QAAM,SAAS,OAAO,OAAO,CAAC,KAAK,SAAS,MAAM,MAAM,CAAC;AAEzD,QAAM,YACJ,QAAQ,CAAC,MAAM,MACX,QAAQ,MAAM,IAAI,KAAK,MAAM,IAC7B,QAAQ,WAAW,KAAK,SAAS,UAAU,QAAQ,WAAW,IAAI,IAChE,QAAQ,MAAM,KAAK,MAAM,IACzB,SACN,QAAQ,MAAM,EAAE;AAClB,MAAI,SAAS,WAAW,UAAU,CAAC,QAAQ,KAAK,QAAQ,GAAG;AACzD,WAAO;AAAA,EACT;AACA,MAAI,KAAK;AACT,SAAO;AAAA,IACL,IAAI,IAAI;AAAA,IACR,GAAG,OAAO,IAAI,CAAC,SAAS,SAAS,MAAM,IAAK,MAAM,IAAK,CAAC;AAAA,EAC1D,EAAE,KAAK,GAAG;AACZ;",
|
|
5
|
+
"names": ["code"]
|
|
6
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { a as ZappieError, T as Transport, R as RequestCtx, g as MenuFulfilment, h as MenuResponse, k as SearchRequest, l as SearchPage, m as MenuVersion } from './client-
|
|
1
|
+
import { a as ZappieError, T as Transport, R as RequestCtx, g as MenuFulfilment, h as MenuResponse, k as SearchRequest, l as SearchPage, m as MenuVersion } from './client-CtDaenmW.js';
|
|
2
2
|
import { SelectedMenuRequest, SelectedMenuResponse } from './transport/selected-menu.js';
|
|
3
|
-
export { A as API_VERSION, E as ErrorDetails, e as MenuReadOptions, M as MenuResource, n as ReadOptions, S as StorageLike, c as StoreResource, Z as Zappie, b as ZappieClientOptions, b as ZappieConfig, f as ZappieErrorCode, d as ZappieEvents, o as createZappie, p as isZappieError } from './client-
|
|
4
|
-
import { g as CartIssue, a as Quote, b as CartLineInput, C as CartLine, Q as QuoteRequest, h as WireQuote } from './types-
|
|
5
|
-
export { i as CartFix, c as CartFulfilment, e as CartIssueCode, d as CartModule, j as CartSnapshot, f as CartState, k as CartSyncAdapter, l as CartSyncDocument, D as DeliveryAddress, m as WireFix, W as WireFulfilment, n as WireIssue, o as WireLine, p as WireMoney } from './types-
|
|
6
|
-
import { I as Item, O as OptionGroup, M as Money, a as Menu, B as Branch, S as Store, C as CategoryPage } from './models-
|
|
7
|
-
export { b as
|
|
3
|
+
export { A as API_VERSION, E as ErrorDetails, e as MenuReadOptions, M as MenuResource, n as ReadOptions, S as StorageLike, c as StoreResource, Z as Zappie, b as ZappieClientOptions, b as ZappieConfig, f as ZappieErrorCode, d as ZappieEvents, o as createZappie, p as isZappieError } from './client-CtDaenmW.js';
|
|
4
|
+
import { g as CartIssue, a as Quote, b as CartLineInput, C as CartLine, Q as QuoteRequest, h as WireQuote } from './types-DMMeyB5d.js';
|
|
5
|
+
export { i as CartFix, c as CartFulfilment, e as CartIssueCode, d as CartModule, j as CartSnapshot, f as CartState, k as CartSyncAdapter, l as CartSyncDocument, D as DeliveryAddress, m as WireFix, W as WireFulfilment, n as WireIssue, o as WireLine, p as WireMoney } from './types-DMMeyB5d.js';
|
|
6
|
+
import { I as Item, O as OptionGroup, M as Money, a as Menu, B as Branch, S as Store, C as CategoryPage } from './models-asoc6fS3.js';
|
|
7
|
+
export { b as BranchCategory, c as Category, d as Choice, e as Currency, F as Formatters, f as Fulfilment, g as MenuSchedule, h as MenuSection, i as MoneyFormatOptions, j as OpeningTime, k as OptionCondition, P as PaymentMethodKind, l as SpecialHours, V as Variant, m as format, n as money } from './models-asoc6fS3.js';
|
|
8
8
|
|
|
9
9
|
declare class ZappieCartError extends ZappieError {
|
|
10
10
|
readonly issues: CartIssue[];
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { ZappieError, isZappieError } from "./errors.js";
|
|
|
11
11
|
export * from "./models.js";
|
|
12
12
|
import { format, money } from "./money.js";
|
|
13
13
|
import { RestTransport } from "./transport/rest.js";
|
|
14
|
-
var VERSION = true ? "0.10.
|
|
14
|
+
var VERSION = true ? "0.10.8" : "0.0.0-development";
|
|
15
15
|
export {
|
|
16
16
|
API_VERSION,
|
|
17
17
|
RestTransport,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RequestCtx } from '../index.js';
|
|
2
|
-
import '../models-
|
|
3
|
-
import '../types-
|
|
2
|
+
import '../models-asoc6fS3.js';
|
|
3
|
+
import '../types-DMMeyB5d.js';
|
|
4
4
|
|
|
5
5
|
/** Public integration IDs and browser keys. Your app decides when to load scripts. */
|
|
6
6
|
type Integrations = {
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// src/internal/remembered-address.ts
|
|
2
|
+
var ADDRESS_KEY = "zappie_delivery_address";
|
|
3
|
+
function ownerOf(stored) {
|
|
4
|
+
const id = stored?.customerId;
|
|
5
|
+
return typeof id === "string" && id ? id : stored?.guest === true ? null : void 0;
|
|
6
|
+
}
|
|
7
|
+
function addressStorage(storage) {
|
|
8
|
+
try {
|
|
9
|
+
return storage !== void 0 ? storage : typeof window === "undefined" ? null : window.localStorage;
|
|
10
|
+
} catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function readStored(storage) {
|
|
15
|
+
try {
|
|
16
|
+
const stored = JSON.parse(storage?.getItem(ADDRESS_KEY) ?? "0");
|
|
17
|
+
return stored && typeof stored === "object" ? stored : void 0;
|
|
18
|
+
} catch {
|
|
19
|
+
return void 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function forgetRememberedAddress(storage) {
|
|
23
|
+
try {
|
|
24
|
+
addressStorage(storage)?.removeItem(ADDRESS_KEY);
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function knownShopper() {
|
|
29
|
+
return globalThis.__zappieShopper?.id;
|
|
30
|
+
}
|
|
31
|
+
function settleShopper(id, storage) {
|
|
32
|
+
globalThis.__zappieShopper = { id };
|
|
33
|
+
const owner = ownerOf(readStored(addressStorage(storage)));
|
|
34
|
+
if (owner && owner !== id) {
|
|
35
|
+
forgetRememberedAddress(storage);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function forgetBagAddresses() {
|
|
39
|
+
try {
|
|
40
|
+
for (const key of Object.keys(localStorage)) {
|
|
41
|
+
try {
|
|
42
|
+
const bag = key.startsWith("zappie:cart:v1:") ? JSON.parse(localStorage[key]) : void 0;
|
|
43
|
+
if (bag?.fulfilment?.type == "delivery") {
|
|
44
|
+
bag.fulfilment = null;
|
|
45
|
+
localStorage[key] = JSON.stringify(bag);
|
|
46
|
+
}
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
ADDRESS_KEY,
|
|
55
|
+
addressStorage,
|
|
56
|
+
forgetBagAddresses,
|
|
57
|
+
forgetRememberedAddress,
|
|
58
|
+
knownShopper,
|
|
59
|
+
ownerOf,
|
|
60
|
+
readStored,
|
|
61
|
+
settleShopper
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=remembered-address.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/internal/remembered-address.ts"],
|
|
4
|
+
"mappings": ";AAiBO,IAAM,cAAc;AAcpB,SAAS,QACd,QAC2B;AAC3B,QAAM,KAAK,QAAQ;AACnB,SAAO,OAAO,OAAO,YAAY,KAC7B,KACA,QAAQ,UAAU,OAChB,OACA;AACR;AAGO,SAAS,eACd,SACuB;AACvB,MAAI;AACF,WAAO,YAAY,SACf,UACA,OAAO,WAAW,cAChB,OACA,OAAO;AAAA,EACf,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGO,SAAS,WACd,SAC2B;AAC3B,MAAI;AACF,UAAM,SAAS,KAAK,MAAM,SAAS,QAAQ,WAAW,KAAK,GAAG;AAC9D,WAAO,UAAU,OAAO,WAAW,WAC9B,SACD;AAAA,EACN,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGO,SAAS,wBAAwB,SAAiC;AACvE,MAAI;AACF,mBAAe,OAAO,GAAG,WAAW,WAAW;AAAA,EACjD,QAAQ;AAAA,EAER;AACF;AAGO,SAAS,eAA0C;AACxD,SAAO,WAAW,iBAAiB;AACrC;AAMO,SAAS,cACd,IACA,SACA;AACA,aAAW,kBAAkB,EAAE,GAAG;AAClC,QAAM,QAAQ,QAAQ,WAAW,eAAe,OAAO,CAAC,CAAC;AACzD,MAAI,SAAS,UAAU,IAAI;AACzB,4BAAwB,OAAO;AAAA,EACjC;AACF;AAMO,SAAS,qBAAqB;AACnC,MAAI;AACF,eAAW,OAAO,OAAO,KAAK,YAAY,GAAG;AAC3C,UAAI;AACF,cAAM,MAAM,IAAI,WAAW,iBAAiB,IACvC,KAAK,MAAM,aAAa,GAAG,CAAE,IAG9B;AACJ,YAAI,KAAK,YAAY,QAAQ,YAAY;AACvC,cAAI,aAAa;AACjB,uBAAa,GAAG,IAAI,KAAK,UAAU,GAAG;AAAA,QACxC;AAAA,MACF,QAAQ;AAAA,MAER;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AACF;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CartFulfilment, WireFulfilment } from './index.js';
|
|
2
|
-
export { v as validateConfig } from './client-
|
|
3
|
-
import './models-
|
|
2
|
+
export { v as validateConfig } from './client-CtDaenmW.js';
|
|
3
|
+
import './models-asoc6fS3.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Convert a cart fulfilment selection to the API field names used by quotes and checkout.
|
|
@@ -45,6 +45,8 @@ type SpecialHours = {
|
|
|
45
45
|
opens?: string;
|
|
46
46
|
closes?: string;
|
|
47
47
|
};
|
|
48
|
+
/** What kind of venue a branch is. */
|
|
49
|
+
type BranchCategory = "RESTAURANT" | "RETAIL";
|
|
48
50
|
/** Branch details, opening hours and fulfilment options. */
|
|
49
51
|
type Branch = {
|
|
50
52
|
/** Currency used for this branch's prices. */
|
|
@@ -63,6 +65,12 @@ type Branch = {
|
|
|
63
65
|
timezone?: string;
|
|
64
66
|
address?: string;
|
|
65
67
|
phone?: string;
|
|
68
|
+
/**
|
|
69
|
+
* What kind of venue the branch is. Absent when the API doesn't say, which
|
|
70
|
+
* reads as a restaurant. `inVenueLabel()` from `@zappie/sdk/display` names
|
|
71
|
+
* in-person orders by it.
|
|
72
|
+
*/
|
|
73
|
+
category?: BranchCategory;
|
|
66
74
|
coordinates?: {
|
|
67
75
|
lat: number;
|
|
68
76
|
lng: number;
|
|
@@ -271,5 +279,5 @@ type CategoryPage = {
|
|
|
271
279
|
nextCursor?: string;
|
|
272
280
|
};
|
|
273
281
|
|
|
274
|
-
export { format as
|
|
275
|
-
export type { Branch as B, CategoryPage as C, Formatters as F, Item as I, Money as M, OptionGroup as O, PaymentMethodKind as P, Store as S, Variant as V, Menu as a,
|
|
282
|
+
export { format as m, money as n };
|
|
283
|
+
export type { Branch as B, CategoryPage as C, Formatters as F, Item as I, Money as M, OptionGroup as O, PaymentMethodKind as P, Store as S, Variant as V, Menu as a, BranchCategory as b, Category as c, Choice as d, Currency as e, Fulfilment as f, MenuSchedule as g, MenuSection as h, MoneyFormatOptions as i, OpeningTime as j, OptionCondition as k, SpecialHours as l };
|
package/dist/money.js
CHANGED
|
@@ -4,27 +4,11 @@ var ZERO_DIGIT_CURRENCIES = " AFN ALL BIF CLP DJF GNF IQD IRR ISK JPY KMF KPW KR
|
|
|
4
4
|
var THREE_DIGIT_CURRENCIES = " BHD JOD KWD LYD OMR TND ";
|
|
5
5
|
var FOUR_DIGIT_CURRENCIES = " CLF UYW ";
|
|
6
6
|
var API_ONLY_CURRENCIES = " BOV CHE CHW CLF COU MXV USN UYI UYW VED ";
|
|
7
|
-
var contains = (codes, currency) => codes.includes(
|
|
7
|
+
var contains = (codes, currency) => codes.includes(currency);
|
|
8
8
|
var intlCurrencies;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
if (typeof Intl.supportedValuesOf !== "function") {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
intlCurrencies ?? (intlCurrencies = new Set(Intl.supportedValuesOf("currency")));
|
|
17
|
-
return contains(API_ONLY_CURRENCIES, code) || intlCurrencies.has(code);
|
|
18
|
-
}
|
|
19
|
-
function currencyDigits(currency) {
|
|
20
|
-
if (contains(ZERO_DIGIT_CURRENCIES, currency)) {
|
|
21
|
-
return 0;
|
|
22
|
-
}
|
|
23
|
-
if (contains(THREE_DIGIT_CURRENCIES, currency)) {
|
|
24
|
-
return 3;
|
|
25
|
-
}
|
|
26
|
-
return contains(FOUR_DIGIT_CURRENCIES, currency) ? 4 : 2;
|
|
27
|
-
}
|
|
9
|
+
var isCurrency = (code) => /^[A-Z]{3}$/.test(code) && // Runtimes without Intl.supportedValuesOf accept any three-letter code.
|
|
10
|
+
(!Intl.supportedValuesOf || contains(API_ONLY_CURRENCIES, code) || (intlCurrencies ?? (intlCurrencies = new Set(Intl.supportedValuesOf("currency")))).has(code));
|
|
11
|
+
var currencyDigits = (currency) => contains(ZERO_DIGIT_CURRENCIES, currency) ? 0 : contains(THREE_DIGIT_CURRENCIES, currency) ? 3 : contains(FOUR_DIGIT_CURRENCIES, currency) ? 4 : 2;
|
|
28
12
|
function money(amountMinor, currency) {
|
|
29
13
|
const normalized = typeof currency === "string" ? currency.trim().toUpperCase() : "";
|
|
30
14
|
if (!Number.isSafeInteger(amountMinor) || !isCurrency(normalized)) {
|
|
@@ -35,20 +19,25 @@ function money(amountMinor, currency) {
|
|
|
35
19
|
}
|
|
36
20
|
return Object.freeze({ amountMinor, currency: normalized });
|
|
37
21
|
}
|
|
22
|
+
var formatters = {};
|
|
38
23
|
var format = {
|
|
39
24
|
money(value, opts = {}) {
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
currency:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
25
|
+
const { amountMinor, currency } = money(value.amountMinor, value.currency);
|
|
26
|
+
const digits = currencyDigits(currency);
|
|
27
|
+
const fraction = opts.showZeroDecimals || amountMinor % 10 ** digits ? digits : 0;
|
|
28
|
+
const key = currency + fraction + opts.compact + opts.sign;
|
|
29
|
+
return (formatters[key] ?? (formatters[key] = new Intl.NumberFormat(
|
|
30
|
+
currency === "NGN" ? "en-NG" : "en",
|
|
31
|
+
{
|
|
32
|
+
style: "currency",
|
|
33
|
+
currency,
|
|
34
|
+
currencyDisplay: "narrowSymbol",
|
|
35
|
+
minimumFractionDigits: fraction,
|
|
36
|
+
maximumFractionDigits: digits,
|
|
37
|
+
notation: opts.compact ? "compact" : "standard",
|
|
38
|
+
signDisplay: opts.sign || "auto"
|
|
39
|
+
}
|
|
40
|
+
))).format(amountMinor / 10 ** digits);
|
|
52
41
|
}
|
|
53
42
|
};
|
|
54
43
|
export {
|
package/dist/money.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/money.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,mBAAmB;AAO5B,IAAM,wBACJ;AACF,IAAM,yBAAyB;AAC/B,IAAM,wBAAwB;AAE9B,IAAM,sBAAsB;
|
|
4
|
+
"mappings": ";AAAA,SAAS,mBAAmB;AAO5B,IAAM,wBACJ;AACF,IAAM,yBAAyB;AAC/B,IAAM,wBAAwB;AAE9B,IAAM,sBAAsB;AAE5B,IAAM,WAAW,CAAC,OAAe,aAAqB,MAAM,SAAS,QAAQ;AAC7E,IAAI;AACJ,IAAM,aAAa,CAAC,SAClB,aAAa,KAAK,IAAI;AAAA,CAErB,CAAC,KAAK,qBACL,SAAS,qBAAqB,IAAI,MACjC,oCAAmB,IAAI,IAAI,KAAK,kBAAkB,UAAU,CAAC,IAAG,IAAI,IAAI;AAC7E,IAAM,iBAAiB,CAAC,aACtB,SAAS,uBAAuB,QAAQ,IACpC,IACA,SAAS,wBAAwB,QAAQ,IACvC,IACA,SAAS,uBAAuB,QAAQ,IACtC,IACA;AAQH,SAAS,MAAM,aAAqB,UAA2B;AACpE,QAAM,aACJ,OAAO,aAAa,WAAW,SAAS,KAAK,EAAE,YAAY,IAAI;AACjE,MAAI,CAAC,OAAO,cAAc,WAAW,KAAK,CAAC,WAAW,UAAU,GAAG;AACjE,UAAM,IAAI;AAAA,MACR;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAO,OAAO,OAAO,EAAE,aAAa,UAAU,WAAW,CAAC;AAC5D;AAaA,IAAM,aAAgD,CAAC;AAEhD,IAAM,SAAqB;AAAA,EAChC,MAAM,OAAO,OAAO,CAAC,GAAG;AACtB,UAAM,EAAE,aAAa,SAAS,IAAI,MAAM,MAAM,aAAa,MAAM,QAAQ;AACzE,UAAM,SAAS,eAAe,QAAQ;AACtC,UAAM,WACJ,KAAK,oBAAoB,cAAc,MAAM,SAAS,SAAS;AACjE,UAAM,MAAM,WAAW,WAAW,KAAK,UAAU,KAAK;AACtD,YAAQ,sCAAoB,IAAI,KAAK;AAAA,MACnC,aAAa,QAAQ,UAAU;AAAA,MAC/B;AAAA,QACE,OAAO;AAAA,QACP;AAAA,QACA,iBAAiB;AAAA,QACjB,uBAAuB;AAAA,QACvB,uBAAuB;AAAA,QACvB,UAAU,KAAK,UAAU,YAAY;AAAA,QACrC,aAAa,KAAK,QAAQ;AAAA,MAC5B;AAAA,IACF,IAAG,OAAO,cAAc,MAAM,MAAM;AAAA,EACtC;AACF;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { q as CATALOGUE_MAX_AGE_MS, r as CATALOGUE_MAX_BYTES, s as CatalogueScope, t as SavedCatalogue, u as catalogueDigest, w as catalogueKey, x as createCatalogueStorage, y as createSavedCatalogue } from '../client-
|
|
2
|
-
import '../models-
|
|
3
|
-
import '../types-
|
|
1
|
+
export { q as CATALOGUE_MAX_AGE_MS, r as CATALOGUE_MAX_BYTES, s as CatalogueScope, t as SavedCatalogue, u as catalogueDigest, w as catalogueKey, x as createCatalogueStorage, y as createSavedCatalogue } from '../client-CtDaenmW.js';
|
|
2
|
+
import '../models-asoc6fS3.js';
|
|
3
|
+
import '../types-DMMeyB5d.js';
|
package/dist/pricing/index.d.ts
CHANGED
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
import { Item, Money } from '@zappie/sdk';
|
|
2
2
|
|
|
3
|
+
/** Choices to narrow an item to, as a cart line names them. */
|
|
4
|
+
type PricedChoices = readonly {
|
|
5
|
+
groupId: string;
|
|
6
|
+
choiceId: string;
|
|
7
|
+
}[];
|
|
3
8
|
/**
|
|
4
9
|
* The lowest price a shopper can pay for one of this item, by the same rule
|
|
5
10
|
* Zappie uses for a product's starting price: the cheapest available variant
|
|
6
|
-
* plus the cheapest
|
|
7
|
-
*
|
|
11
|
+
* plus the cheapest valid choices of each required add-on group. A group that
|
|
12
|
+
* needs exactly or at least four choices adds its four cheapest units. Available
|
|
13
|
+
* choices are used when they can fill the group. When no variant is available,
|
|
14
|
+
* the cheapest variant is used. Optional groups add nothing.
|
|
8
15
|
*
|
|
9
16
|
* @param item - The catalogue item.
|
|
10
17
|
* @returns A display price. Use a server quote for checkout totals.
|
|
11
18
|
*/
|
|
12
19
|
declare function startingPrice(item: Item): Money;
|
|
20
|
+
/**
|
|
21
|
+
* The starting price of this item when the shopper picks from the given choices only, such as
|
|
22
|
+
* the price of one plan length or one size. Each group named in `choices` is narrowed to the
|
|
23
|
+
* named choices, and an attribute group narrows the variants to the ones with that choice. Other
|
|
24
|
+
* groups count as `startingPrice` counts them.
|
|
25
|
+
*
|
|
26
|
+
* @param item - The catalogue item.
|
|
27
|
+
* @param choices - The choices to narrow to, by group and choice ID.
|
|
28
|
+
* @returns A display price. Use a server quote for checkout totals.
|
|
29
|
+
*/
|
|
30
|
+
declare function startingPriceWith(item: Item, choices: PricedChoices): Money;
|
|
13
31
|
/**
|
|
14
32
|
* Whether to show the starting price as "From": true when available variants
|
|
15
33
|
* have different prices, or a required add-on raises the starting price.
|
|
@@ -18,4 +36,5 @@ declare function startingPrice(item: Item): Money;
|
|
|
18
36
|
*/
|
|
19
37
|
declare function showsFromPrice(item: Item): boolean;
|
|
20
38
|
|
|
21
|
-
export { showsFromPrice, startingPrice };
|
|
39
|
+
export { showsFromPrice, startingPrice, startingPriceWith };
|
|
40
|
+
export type { PricedChoices };
|
package/dist/pricing/index.js
CHANGED
|
@@ -1,19 +1,69 @@
|
|
|
1
1
|
// src/pricing/index.ts
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
money,
|
|
4
|
+
ZappieError
|
|
5
|
+
} from "@zappie/sdk";
|
|
6
|
+
var byPrice = (a, b) => a.price.amountMinor - b.price.amountMinor;
|
|
7
|
+
function fill(group, choices) {
|
|
8
|
+
const need = Math.max(group.selection.min, 1);
|
|
9
|
+
const prices = [];
|
|
10
|
+
let count = 0;
|
|
11
|
+
for (const choice of choices.sort(byPrice)) {
|
|
12
|
+
const { min = 1, max = choice.quantity ? Infinity : 1 } = choice.quantity ?? {};
|
|
13
|
+
const units = Math.max(min, Math.min(need - count, max));
|
|
14
|
+
if (count < need && count + units <= (group.selection.max || Infinity)) {
|
|
15
|
+
prices.push(...Array(units).fill(choice.price));
|
|
16
|
+
count += units;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return [prices, count >= need];
|
|
20
|
+
}
|
|
4
21
|
function startingPrice(item) {
|
|
5
22
|
const available = item.variants.filter((variant) => variant.isAvailable);
|
|
6
|
-
const base =
|
|
7
|
-
|
|
8
|
-
|
|
23
|
+
const base = (available.length ? available : item.variants).filter((variant) => variant.price.amountMinor >= 0).sort(byPrice)[0]?.price ?? item.price;
|
|
24
|
+
const prices = item.optionGroups.flatMap((group) => {
|
|
25
|
+
if (group.isAttribute || !group.required || group.kind !== "select") {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
const priced = group.choices.filter(
|
|
29
|
+
(choice) => choice.price.amountMinor >= 0
|
|
30
|
+
);
|
|
31
|
+
const [taken, filled] = fill(
|
|
32
|
+
group,
|
|
33
|
+
priced.filter((choice) => choice.isAvailable)
|
|
34
|
+
);
|
|
35
|
+
return filled ? taken : fill(group, priced)[0];
|
|
36
|
+
});
|
|
37
|
+
let total = base.amountMinor;
|
|
38
|
+
for (const price of prices) {
|
|
39
|
+
if (price.currency !== base.currency) {
|
|
40
|
+
throw new ZappieError(
|
|
41
|
+
"invalid_request",
|
|
42
|
+
"Cannot combine different currencies"
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
total += price.amountMinor;
|
|
46
|
+
}
|
|
47
|
+
return money(total, base.currency);
|
|
48
|
+
}
|
|
49
|
+
function startingPriceWith(item, choices) {
|
|
50
|
+
const keeps = (groupId, choiceId) => !choices.some((picked) => picked.groupId === groupId) || choices.some(
|
|
51
|
+
(picked) => picked.groupId === groupId && picked.choiceId === choiceId
|
|
52
|
+
);
|
|
53
|
+
const variants = item.variants.filter(
|
|
54
|
+
(variant) => Object.entries(variant.attributeChoices).every(
|
|
55
|
+
([groupId, choiceId]) => keeps(groupId, choiceId)
|
|
9
56
|
)
|
|
10
|
-
) ?? item.price;
|
|
11
|
-
return sumMoney(
|
|
12
|
-
item.optionGroups.flatMap(
|
|
13
|
-
(group) => !group.isAttribute && group.required && group.kind === "select" ? cheapest(group.choices.map((choice) => choice.price)) ?? [] : []
|
|
14
|
-
),
|
|
15
|
-
base
|
|
16
57
|
);
|
|
58
|
+
return startingPrice({
|
|
59
|
+
...item,
|
|
60
|
+
// Choices no variant carries leave the variants as they are.
|
|
61
|
+
variants: variants.length ? variants : item.variants,
|
|
62
|
+
optionGroups: item.optionGroups.map((group) => ({
|
|
63
|
+
...group,
|
|
64
|
+
choices: group.choices.filter((choice) => keeps(group.id, choice.id))
|
|
65
|
+
}))
|
|
66
|
+
});
|
|
17
67
|
}
|
|
18
68
|
function showsFromPrice(item) {
|
|
19
69
|
const prices = [
|
|
@@ -25,6 +75,7 @@ function showsFromPrice(item) {
|
|
|
25
75
|
}
|
|
26
76
|
export {
|
|
27
77
|
showsFromPrice,
|
|
28
|
-
startingPrice
|
|
78
|
+
startingPrice,
|
|
79
|
+
startingPriceWith
|
|
29
80
|
};
|
|
30
81
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/pricing/index.ts"],
|
|
4
|
-
"mappings": ";AAAA,
|
|
4
|
+
"mappings": ";AAGA;AAAA,EACE;AAAA,EACA;AAAA,OAKK;AAKP,IAAM,UAAU,CAAC,GAAqB,MACpC,EAAE,MAAM,cAAc,EAAE,MAAM;AAMhC,SAAS,KAAK,OAAoB,SAAuC;AACvE,QAAM,OAAO,KAAK,IAAI,MAAM,UAAU,KAAK,CAAC;AAC5C,QAAM,SAAkB,CAAC;AACzB,MAAI,QAAQ;AACZ,aAAW,UAAU,QAAQ,KAAK,OAAO,GAAG;AAC1C,UAAM,EAAE,MAAM,GAAG,MAAM,OAAO,WAAW,WAAW,EAAE,IACpD,OAAO,YAAY,CAAC;AACtB,UAAM,QAAQ,KAAK,IAAI,KAAK,KAAK,IAAI,OAAO,OAAO,GAAG,CAAC;AACvD,QAAI,QAAQ,QAAQ,QAAQ,UAAU,MAAM,UAAU,OAAO,WAAW;AACtE,aAAO,KAAK,GAAG,MAAa,KAAK,EAAE,KAAK,OAAO,KAAK,CAAC;AACrD,eAAS;AAAA,IACX;AAAA,EACF;AACA,SAAO,CAAC,QAAQ,SAAS,IAAI;AAC/B;AAaO,SAAS,cAAc,MAAmB;AAC/C,QAAM,YAAY,KAAK,SAAS,OAAO,CAAC,YAAY,QAAQ,WAAW;AACvE,QAAM,QACH,UAAU,SAAS,YAAY,KAAK,UAClC,OAAO,CAAC,YAAY,QAAQ,MAAM,eAAe,CAAC,EAClD,KAAK,OA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,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;AAAA,IACtE,EAAE;AAAA,EACJ,CAAC;AACH;AAQO,SAAS,eAAe,MAAqB;AAClD,QAAM,SAAS;AAAA,IACb,GAAG,IAAI;AAAA,MACL,KAAK,SACF,OAAO,CAAC,YAAY,QAAQ,WAAW,EACvC,IAAI,CAAC,YAAY,QAAQ,MAAM,WAAW;AAAA,IAC/C;AAAA,EACF;AACA,SACE,OAAO,SAAS,KACf,OAAO,WAAW,KAAK,cAAc,IAAI,EAAE,cAAc,OAAO,CAAC;AAEtE;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Branch, Store, Menu, Formatters } from '../index.js';
|
|
2
|
-
import { C as Cache } from '../client-
|
|
2
|
+
import { C as Cache } from '../client-CtDaenmW.js';
|
|
3
3
|
import { ZappieError, Zappie, ZappieConfig, Transport, StorageLike, StoreResource, MenuResource, ZappieEvents, MenuReadOptions } from '../index.js';
|
|
4
4
|
export { VERSION } from '../index.js';
|
|
5
5
|
import { CartModule, CartLineInput } from '../index.js';
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Cache } from '../client-
|
|
1
|
+
import { C as Cache } from '../client-CtDaenmW.js';
|
|
2
2
|
import { Transport, ZappieErrorCode, StorageLike, StoreResource, MenuResource, ZappieEvents, MenuReadOptions } from '../index.js';
|
|
3
3
|
import { Store, Menu, Formatters } from '../index.js';
|
|
4
4
|
export { VERSION } from '../index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Menu } from '../index.js';
|
|
2
2
|
import { SearchRequest, SearchPage } from '../index.js';
|
|
3
|
-
import '../types-
|
|
3
|
+
import '../types-DMMeyB5d.js';
|
|
4
4
|
|
|
5
5
|
/** Loaded only when search is used; request authentication/retries stay in REST. */
|
|
6
6
|
declare function searchPage(ctx: SearchRequest, read: (path: string) => Promise<unknown>, mapMenu: (value: unknown, branchId: string) => Menu, invalid: () => Error): Promise<SearchPage>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { z as SelectedMenu, i as SelectedMenuRequest, j as SelectedMenuResponse, B as SelectedMenuTransport, D as createSelectedMenuReader, F as selectedMenu, G as selectedMenuKey } from '../client-
|
|
2
|
-
import '../models-
|
|
3
|
-
import '../types-
|
|
1
|
+
export { z as SelectedMenu, i as SelectedMenuRequest, j as SelectedMenuResponse, B as SelectedMenuTransport, D as createSelectedMenuReader, F as selectedMenu, G as selectedMenuKey } from '../client-CtDaenmW.js';
|
|
2
|
+
import '../models-asoc6fS3.js';
|
|
3
|
+
import '../types-DMMeyB5d.js';
|
package/dist/transport/store.js
CHANGED
|
@@ -47,6 +47,8 @@ function mapStore(value, record, text, list, hours, mapMoney, money, opt, isStri
|
|
|
47
47
|
fulfilment: fulfilment(branch.fulfilment),
|
|
48
48
|
...address !== void 0 ? { address } : {},
|
|
49
49
|
...isString(branch.phone) ? { phone: branch.phone.trim() } : {},
|
|
50
|
+
// A category the SDK doesn't know yet is left out, so it reads as a restaurant.
|
|
51
|
+
...branch.category === "RESTAURANT" || branch.category === "RETAIL" ? { category: branch.category } : {},
|
|
50
52
|
...opt("timezone", branch.timezone, isString),
|
|
51
53
|
...branchCoordinates ? { coordinates: branchCoordinates } : {},
|
|
52
54
|
...opt("closedUntil", branch.closed_until, isString),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/transport/store.ts"],
|
|
4
|
-
"mappings": ";AAWO,SAAS,SACd,OACA,QACA,MACA,MACA,OACA,UACA,OACA,KACA,UACA,WACA,QACO;AACP,QAAM,cAAc,CAAC,UAAmB;AACtC,UAAMA,eAAc,OAAO,SAAS,CAAC,CAAC;AACtC,WAAO,OAAOA,aAAY,QAAQ,YAChC,OAAOA,aAAY,QAAQ,WACzB,EAAE,KAAKA,aAAY,KA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Q;AAAA,MAC1C,GAAG,IAAI,iBAAiB,MAAM,iBAAiB,QAAQ;AAAA,IACzD;AAAA,IACA,YAAY,OAAO,aAAa,WAAW,OAAO,UAAU,IAAI;AAAA,IAChE;AAAA,IACA;AAAA,EACF;AACF;",
|
|
5
5
|
"names": ["coordinates", "value", "raw"]
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zappie/sdk",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.8",
|
|
4
4
|
"description": "Typed, framework-agnostic client for Zappie menus, carts, checkout, auth and events.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -97,6 +97,10 @@
|
|
|
97
97
|
"types": "./dist/pricing/index.d.ts",
|
|
98
98
|
"import": "./dist/pricing/index.js"
|
|
99
99
|
},
|
|
100
|
+
"./display": {
|
|
101
|
+
"types": "./dist/display/index.d.ts",
|
|
102
|
+
"import": "./dist/display/index.js"
|
|
103
|
+
},
|
|
100
104
|
"./branches": {
|
|
101
105
|
"types": "./dist/branches/index.d.ts",
|
|
102
106
|
"import": "./dist/branches/index.js"
|
|
@@ -172,7 +176,7 @@
|
|
|
172
176
|
"vite": "8.3.5"
|
|
173
177
|
},
|
|
174
178
|
"scripts": {
|
|
175
|
-
"build": "tsup && tsup --config tsup.checkout.config.ts && tsup --config tsup.checkout-defaults.config.ts && tsup --config tsup.customer.config.ts && tsup --config tsup.account.config.ts && tsup --config tsup.places.config.ts && tsup --config tsup.url.config.ts && tsup --config tsup.redirect.config.ts && tsup --config tsup.navigation.config.ts && tsup --config tsup.services.config.ts && tsup --config tsup.visits.config.ts && tsup --config tsup.pricing.config.ts && tsup --config tsup.branches.config.ts && tsup --config tsup.options.config.ts && tsup --config tsup.site-config.config.ts && tsup --config tsup.template.config.ts && node ../../scripts/release-packages/build-modules.mjs --no-sources-content --unmapped=studio/index.js --unmapped=testing/index.js --unmapped=vite/index.js",
|
|
179
|
+
"build": "tsup && tsup --config tsup.checkout.config.ts && tsup --config tsup.checkout-defaults.config.ts && tsup --config tsup.customer.config.ts && tsup --config tsup.account.config.ts && tsup --config tsup.places.config.ts && tsup --config tsup.url.config.ts && tsup --config tsup.redirect.config.ts && tsup --config tsup.navigation.config.ts && tsup --config tsup.services.config.ts && tsup --config tsup.visits.config.ts && tsup --config tsup.pricing.config.ts && tsup --config tsup.display.config.ts && tsup --config tsup.branches.config.ts && tsup --config tsup.options.config.ts && tsup --config tsup.site-config.config.ts && tsup --config tsup.template.config.ts && node ../../scripts/release-packages/build-modules.mjs --no-sources-content --unmapped=studio/index.js --unmapped=testing/index.js --unmapped=vite/index.js",
|
|
176
180
|
"test": "vitest run --root ../.. packages/sdk/test",
|
|
177
181
|
"size": "node ../../scripts/release-packages/size-sdk.mjs && size-limit"
|
|
178
182
|
}
|