@zappie/sdk 0.15.0 → 0.17.0
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 +20 -0
- package/README.md +52 -0
- package/dist/cart/index.js +30 -39
- package/dist/cart/index.js.map +1 -1
- package/dist/cart/item.d.ts +1 -1
- package/dist/cart/quote-client.js +4 -20
- package/dist/cart/quote-client.js.map +1 -1
- package/dist/cart/quote-response.js +10 -5
- package/dist/cart/quote-response.js.map +1 -1
- package/dist/cart/storage.js +2 -0
- package/dist/cart/storage.js.map +1 -1
- package/dist/checkout/embed.d.ts +2 -0
- package/dist/checkout/index.d.ts +2 -0
- package/dist/checkout/react.d.ts +2 -0
- package/dist/checkout-defaults/index.d.ts +3 -0
- package/dist/{client-C47e44tl.d.ts → client-uRLLtZJU.d.ts} +1 -1
- package/dist/customer/client.js +34 -12
- package/dist/customer/client.js.map +1 -1
- package/dist/customer/index.d.ts +181 -10
- package/dist/customer/reorder.d.ts +40 -0
- package/dist/customer/reorder.js +61 -0
- package/dist/customer/reorder.js.map +6 -0
- package/dist/debug.js +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/integrations/index.d.ts +1 -1
- package/dist/internal/perk-hold.js +35 -0
- package/dist/internal/perk-hold.js.map +6 -0
- package/dist/internal/remembered-address.js +8 -2
- package/dist/internal/remembered-address.js.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/loyalty/cart.js +56 -0
- package/dist/loyalty/cart.js.map +6 -0
- package/dist/loyalty/client.js +89 -0
- package/dist/loyalty/client.js.map +6 -0
- package/dist/loyalty/index.d.ts +526 -0
- package/dist/loyalty/index.js +13 -0
- package/dist/loyalty/index.js.map +6 -0
- package/dist/loyalty/react.d.ts +116 -0
- package/dist/loyalty/react.js +200 -0
- package/dist/loyalty/react.js.map +6 -0
- package/dist/loyalty/release.js +43 -0
- package/dist/loyalty/release.js.map +6 -0
- package/dist/loyalty/types.js +1 -0
- package/dist/loyalty/types.js.map +6 -0
- package/dist/persist/catalogue.d.ts +2 -2
- package/dist/react/index.d.ts +2 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/testing/index.d.ts +92 -4
- package/dist/testing/index.js +2 -0
- package/dist/testing/loyalty.js +110 -0
- package/dist/testing/loyalty.js.map +6 -0
- package/dist/transport/search.d.ts +1 -1
- package/dist/transport/selected-menu.d.ts +2 -2
- package/dist/{types-ooHA0lwH.d.ts → types-K01NHM_a.d.ts} +28 -3
- package/package.json +14 -2
|
@@ -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-
|
|
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-uRLLtZJU.js';
|
|
2
2
|
import '../models-asoc6fS3.js';
|
|
3
|
-
import '../types-
|
|
3
|
+
import '../types-K01NHM_a.js';
|
|
@@ -75,12 +75,12 @@ type CartFulfilment = {
|
|
|
75
75
|
/**
|
|
76
76
|
* Stable identifiers for cart validation and quote issues you can handle in your UI.
|
|
77
77
|
*/
|
|
78
|
-
type CartIssueCode = "item_unavailable" | "item_not_found" | "option_unavailable" | "option_required" | "option_limit" | "quantity_limit" | "price_changed" | "branch_closed" | "fulfilment_unavailable" | "outside_delivery_zone" | "delivery_region_required" | "schedule_invalid" | "promo_invalid" | "promo_min_spend" | "min_order" | "menu_version_stale";
|
|
78
|
+
type CartIssueCode = "item_unavailable" | "item_not_found" | "option_unavailable" | "option_required" | "option_limit" | "quantity_limit" | "price_changed" | "branch_closed" | "fulfilment_unavailable" | "outside_delivery_zone" | "delivery_region_required" | "schedule_invalid" | "promo_invalid" | "promo_min_spend" | "min_order" | "menu_version_stale" | "perk_invalid";
|
|
79
79
|
/**
|
|
80
80
|
* A suggested cart correction, including any option, quantity or fulfilment details it needs.
|
|
81
81
|
*/
|
|
82
82
|
type CartFix = {
|
|
83
|
-
action: "remove_line" | "accept_price" | "remove_promo" | "change_address" | "choose_region";
|
|
83
|
+
action: "remove_line" | "accept_price" | "remove_promo" | "change_address" | "choose_region" | "remove_perks";
|
|
84
84
|
} | {
|
|
85
85
|
action: "choose_option" | "choose_other_option";
|
|
86
86
|
groupId: string;
|
|
@@ -147,10 +147,12 @@ type Quote = {
|
|
|
147
147
|
/** The sum of `fees`, so you can show one fees line. Zero when there are none. Delivery is not included. */
|
|
148
148
|
feesTotal: Money;
|
|
149
149
|
delivery?: Money;
|
|
150
|
+
/** A perk's discount has code `perk` and the `redemptionId` it comes from. */
|
|
150
151
|
discounts: {
|
|
151
152
|
code: string;
|
|
152
153
|
label: string;
|
|
153
154
|
amount: Money;
|
|
155
|
+
redemptionId?: string;
|
|
154
156
|
}[];
|
|
155
157
|
total: Money;
|
|
156
158
|
issues: CartIssue[];
|
|
@@ -177,6 +179,19 @@ type CartState = {
|
|
|
177
179
|
quote?: Quote;
|
|
178
180
|
issues: readonly CartIssue[];
|
|
179
181
|
};
|
|
182
|
+
/**
|
|
183
|
+
* A loyalty perk the shopper redeemed into the bag. The quote prices it, and checkout spends it.
|
|
184
|
+
*/
|
|
185
|
+
type AppliedPerk = Readonly<{
|
|
186
|
+
redemptionId: string;
|
|
187
|
+
perkId: string;
|
|
188
|
+
name: string;
|
|
189
|
+
pointsSpent: number;
|
|
190
|
+
/** When the reservation gives its points back if no order uses it. */
|
|
191
|
+
expiresAt: string;
|
|
192
|
+
/** What the perk gives, when the perk was applied from the perk list. */
|
|
193
|
+
reward?: "order_discount" | "free_item";
|
|
194
|
+
}>;
|
|
180
195
|
/**
|
|
181
196
|
* The current readonly cart view, including lines, branch, fulfilment and hydration state.
|
|
182
197
|
*/
|
|
@@ -188,6 +203,8 @@ type CartSnapshot = {
|
|
|
188
203
|
readonly subtotal: Money | null;
|
|
189
204
|
readonly fulfilment: CartFulfilment | null;
|
|
190
205
|
readonly promoCode: string | null;
|
|
206
|
+
/** The perks redeemed into the bag, sent with each quote and checkout. Never on an in-venue order. */
|
|
207
|
+
readonly perks: readonly AppliedPerk[];
|
|
191
208
|
readonly state: CartState;
|
|
192
209
|
readonly issues: readonly CartIssue[];
|
|
193
210
|
readonly isHydrated: boolean;
|
|
@@ -208,6 +225,11 @@ interface CartModule extends CartSnapshot {
|
|
|
208
225
|
clear(): void;
|
|
209
226
|
setFulfilment(fulfilment: CartFulfilment): void;
|
|
210
227
|
setPromoCode(code: string | null): void;
|
|
228
|
+
/**
|
|
229
|
+
* Replace the perks the cart sends. Use `applyPerk` and `removePerk` from `@zappie/sdk/loyalty`,
|
|
230
|
+
* which redeem and cancel them with the API first.
|
|
231
|
+
*/
|
|
232
|
+
setPerks(perks: readonly AppliedPerk[]): void;
|
|
211
233
|
quote(opts?: {
|
|
212
234
|
force?: boolean;
|
|
213
235
|
}): Promise<Quote>;
|
|
@@ -224,6 +246,7 @@ interface CartModule extends CartSnapshot {
|
|
|
224
246
|
lines: WireLine[];
|
|
225
247
|
fulfilment: CartFulfilment;
|
|
226
248
|
promo_code?: string;
|
|
249
|
+
perk_redemption_ids?: string[];
|
|
227
250
|
menu_version: string;
|
|
228
251
|
};
|
|
229
252
|
}
|
|
@@ -273,6 +296,7 @@ type QuoteRequest = {
|
|
|
273
296
|
lines: WireLine[];
|
|
274
297
|
fulfilment?: WireFulfilment;
|
|
275
298
|
promo_code?: string;
|
|
299
|
+
perk_redemption_ids?: string[];
|
|
276
300
|
menu_version: string;
|
|
277
301
|
};
|
|
278
302
|
/**
|
|
@@ -338,6 +362,7 @@ type WireQuote = {
|
|
|
338
362
|
code: string;
|
|
339
363
|
label: string;
|
|
340
364
|
amount: WireMoney;
|
|
365
|
+
redemption_id?: string;
|
|
341
366
|
}[];
|
|
342
367
|
total: WireMoney;
|
|
343
368
|
issues: WireIssue[];
|
|
@@ -381,4 +406,4 @@ interface CartSyncAdapter {
|
|
|
381
406
|
}>;
|
|
382
407
|
}
|
|
383
408
|
|
|
384
|
-
export type { CartLine as C, DeliveryAddress as D, QuoteRequest as Q, WireFulfilment as W, Quote as a, CartLineInput as b, CartFulfilment as c, CartModule as d, CartIssueCode as e, CartState as f, CartIssue as g,
|
|
409
|
+
export type { AppliedPerk as A, CartLine as C, DeliveryAddress as D, QuoteRequest as Q, WireFulfilment as W, Quote as a, CartLineInput as b, CartFulfilment as c, CartModule as d, CartIssueCode as e, CartState as f, CartIssue as g, WireMoney as h, WireQuote as i, CartFix as j, CartSnapshot as k, CartSyncAdapter as l, CartSyncDocument as m, WireFix as n, WireIssue as o, WireLine as p };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zappie/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Typed, framework-agnostic client for Zappie menus, carts, checkout, auth and events.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -83,6 +83,18 @@
|
|
|
83
83
|
"types": "./dist/customer/react.d.ts",
|
|
84
84
|
"import": "./dist/customer/react.js"
|
|
85
85
|
},
|
|
86
|
+
"./customer/reorder": {
|
|
87
|
+
"types": "./dist/customer/reorder.d.ts",
|
|
88
|
+
"import": "./dist/customer/reorder.js"
|
|
89
|
+
},
|
|
90
|
+
"./loyalty": {
|
|
91
|
+
"types": "./dist/loyalty/index.d.ts",
|
|
92
|
+
"import": "./dist/loyalty/index.js"
|
|
93
|
+
},
|
|
94
|
+
"./loyalty/react": {
|
|
95
|
+
"types": "./dist/loyalty/react.d.ts",
|
|
96
|
+
"import": "./dist/loyalty/react.js"
|
|
97
|
+
},
|
|
86
98
|
"./in-venue": {
|
|
87
99
|
"types": "./dist/in-venue/index.d.ts",
|
|
88
100
|
"import": "./dist/in-venue/index.js"
|
|
@@ -215,7 +227,7 @@
|
|
|
215
227
|
"vite": "8.3.5"
|
|
216
228
|
},
|
|
217
229
|
"scripts": {
|
|
218
|
-
"build": "
|
|
230
|
+
"build": "node ../../scripts/release-packages/build-declarations.mjs tsup.config.ts tsup.checkout.config.ts tsup.checkout-defaults.config.ts tsup.customer.config.ts tsup.loyalty.config.ts tsup.in-venue.config.ts tsup.account.config.ts tsup.places.config.ts tsup.url.config.ts tsup.redirect.config.ts tsup.navigation.config.ts tsup.services.config.ts tsup.visits.config.ts tsup.pricing.config.ts tsup.display.config.ts tsup.branches.config.ts tsup.options.config.ts tsup.site-config.config.ts tsup.template.config.ts tsup.error-pages.config.ts tsup.site-error.config.ts tsup.site-closed.config.ts tsup.navigation-progress.config.ts tsup.receipts.config.ts && node ../../scripts/release-packages/build-modules.mjs --no-sources-content --unmapped=studio/index.js --unmapped=testing/index.js --unmapped=vite/index.js",
|
|
219
231
|
"test": "vitest run --root ../.. packages/sdk/test",
|
|
220
232
|
"size": "node ../../scripts/release-packages/size-sdk.mjs && size-limit"
|
|
221
233
|
}
|