@zappie/sdk 0.1.4 → 0.1.6
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 +12 -0
- package/dist/cart/branch.d.ts +26 -0
- package/dist/cart/branch.js +79 -0
- package/dist/cart/branch.js.map +7 -0
- package/dist/cart/index.js +1 -1
- package/dist/cart/index.js.map +2 -2
- package/dist/cart/item.d.ts +2 -1
- package/dist/cart/quote-client.js +48 -3
- package/dist/cart/quote-client.js.map +2 -2
- package/dist/cart/quote.d.ts +7 -2
- package/dist/client-Bm2cCYea.d.ts +400 -0
- package/dist/client.js +4 -2
- package/dist/client.js.map +2 -2
- package/dist/config/index.d.ts +11 -0
- package/dist/config.js.map +2 -2
- package/dist/debug.d.ts +2 -1
- package/dist/debug.js +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/dist/integrations/index.d.ts +2 -1
- package/dist/internal.d.ts +2 -2
- package/dist/persist/catalogue.d.ts +2 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/server/index.d.ts +3 -1
- package/dist/site-config/types.js.map +1 -1
- package/dist/site-config/validate.js +32 -0
- package/dist/site-config/validate.js.map +2 -2
- package/dist/testing/index.d.ts +3 -1
- package/dist/transport/rest.js +6 -1
- package/dist/transport/rest.js.map +2 -2
- package/dist/transport/search.d.ts +2 -1
- package/dist/transport/selected-menu.d.ts +2 -1
- package/dist/types-CuDvfW9g.d.ts +380 -0
- package/package.json +5 -1
- package/dist/client-RFcLoZ04.d.ts +0 -764
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { a as Menu, C as CategoryPage, S as Store, I as Item, M as Money, F as Formatters } from './models-Rg5kQUkv.js';
|
|
2
|
+
import { Q as QuoteRequest, g as WireQuote, i as CartIssueCode, d as CartModule, b as CartLineInput } from './types-CuDvfW9g.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The store, branch, order context and source menu that identify a saved catalogue.
|
|
6
|
+
*/
|
|
7
|
+
type CatalogueScope = {
|
|
8
|
+
store: string;
|
|
9
|
+
branchId: string;
|
|
10
|
+
orderContext: "delivery" | "pickup" | "dineIn";
|
|
11
|
+
menuId: string;
|
|
12
|
+
};
|
|
13
|
+
/** The saved coverage. A complete source menu still covers only part of the branch. */
|
|
14
|
+
type SavedCatalogue = {
|
|
15
|
+
scope: CatalogueScope;
|
|
16
|
+
menu: Menu;
|
|
17
|
+
coverage: {
|
|
18
|
+
menuIds: string[];
|
|
19
|
+
complete: boolean;
|
|
20
|
+
};
|
|
21
|
+
pages: {
|
|
22
|
+
categoryId: string;
|
|
23
|
+
cursor?: string;
|
|
24
|
+
page: CategoryPage;
|
|
25
|
+
}[];
|
|
26
|
+
etag: string;
|
|
27
|
+
savedAt: number;
|
|
28
|
+
/**
|
|
29
|
+
* The host's catalogue revision when saved. An unchanged revision means the
|
|
30
|
+
* saved copy is current and needs no background refresh.
|
|
31
|
+
*/
|
|
32
|
+
revision?: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Default saved-catalogue lifetime in milliseconds: 24 hours.
|
|
36
|
+
*/
|
|
37
|
+
declare const CATALOGUE_MAX_AGE_MS: number;
|
|
38
|
+
/**
|
|
39
|
+
* Default per-store catalogue storage budget in serialized bytes: 16 MiB.
|
|
40
|
+
*/
|
|
41
|
+
declare const CATALOGUE_MAX_BYTES: number;
|
|
42
|
+
/**
|
|
43
|
+
* Build a versioned JSON storage key from the store, branch, order context and menu ID.
|
|
44
|
+
*/
|
|
45
|
+
declare function catalogueKey(scope: CatalogueScope): string;
|
|
46
|
+
/** Opt-in browser persistence. Storage failures never escape into shopper UI. */
|
|
47
|
+
declare function createCatalogueStorage(store: string, options?: {
|
|
48
|
+
maxAgeMs?: number;
|
|
49
|
+
maxBytes?: number;
|
|
50
|
+
}): {
|
|
51
|
+
read(scope: CatalogueScope): Promise<SavedCatalogue | undefined>;
|
|
52
|
+
save(value: SavedCatalogue): void;
|
|
53
|
+
};
|
|
54
|
+
/** Digest excludes transport versions: publication follows shopper-visible content. */
|
|
55
|
+
declare function catalogueDigest(menu: Menu): Promise<string>;
|
|
56
|
+
/** A saved source menu that stays separate from the complete branch catalogue. */
|
|
57
|
+
declare function createSavedCatalogue(client: Zappie, scope: CatalogueScope): {
|
|
58
|
+
restore(): Promise<SavedCatalogue | undefined>;
|
|
59
|
+
/** Save in the background and return whether the content changed. */
|
|
60
|
+
publish(value: SavedCatalogue): Promise<boolean>;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** Complete for the named source, never complete for the branch. */
|
|
64
|
+
type SelectedMenu = {
|
|
65
|
+
menu: Menu & {
|
|
66
|
+
completeness: "partial";
|
|
67
|
+
};
|
|
68
|
+
coverage: {
|
|
69
|
+
menuIds: [string];
|
|
70
|
+
complete: true;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* A source menu with its ETag, or an unchanged response carrying the matching ETag.
|
|
75
|
+
*/
|
|
76
|
+
type SelectedMenuResponse = (SelectedMenu & {
|
|
77
|
+
etag: string;
|
|
78
|
+
}) | {
|
|
79
|
+
notModified: true;
|
|
80
|
+
etag: string;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* A branch-scoped source-menu request with order context and an optional conditional ETag.
|
|
84
|
+
*/
|
|
85
|
+
type SelectedMenuRequest = RequestCtx & {
|
|
86
|
+
branchId: string;
|
|
87
|
+
menuId: string;
|
|
88
|
+
orderContext: CatalogueScope["orderContext"];
|
|
89
|
+
ifNoneMatch?: string;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* A transport that reads one complete source menu without claiming branch-wide coverage.
|
|
93
|
+
*/
|
|
94
|
+
type SelectedMenuTransport = {
|
|
95
|
+
getSelectedMenu(request: SelectedMenuRequest): Promise<SelectedMenuResponse>;
|
|
96
|
+
};
|
|
97
|
+
/** Dependencies are passed by REST to avoid splitting core shared chunks. */
|
|
98
|
+
declare function selectedMenu(ctx: SelectedMenuRequest, request: (path: string) => Promise<Response>, json: (response: Response) => Promise<unknown>, mapMenu: (value: unknown, branchId: string) => Menu, invalid: () => Error): Promise<SelectedMenuResponse>;
|
|
99
|
+
/**
|
|
100
|
+
* Build a versioned cache key for a source menu within a store, branch and order context.
|
|
101
|
+
*/
|
|
102
|
+
declare function selectedMenuKey(scope: CatalogueScope): string;
|
|
103
|
+
/** Dedicated lazy resource: deliberately does not call menu.hydrate(). */
|
|
104
|
+
declare function createSelectedMenuReader(client: Zappie): {
|
|
105
|
+
read(scope: CatalogueScope, options?: {
|
|
106
|
+
signal?: AbortSignal;
|
|
107
|
+
ifNoneMatch?: string;
|
|
108
|
+
}): Promise<SelectedMenuResponse>;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/** Per-request credentials and cancellation. Never shared across clients. */
|
|
112
|
+
type RequestCtx = {
|
|
113
|
+
key: string;
|
|
114
|
+
version: string;
|
|
115
|
+
signal?: AbortSignal;
|
|
116
|
+
idempotencyKey?: string;
|
|
117
|
+
};
|
|
118
|
+
/** Full menu response or a conditional-cache hit. */
|
|
119
|
+
type MenuResponse = {
|
|
120
|
+
menu: Menu;
|
|
121
|
+
etag?: string;
|
|
122
|
+
} | {
|
|
123
|
+
notModified: true;
|
|
124
|
+
etag?: string;
|
|
125
|
+
};
|
|
126
|
+
/** Opaque content and availability versions. */
|
|
127
|
+
type MenuVersion = {
|
|
128
|
+
version: string;
|
|
129
|
+
availabilityHash: string;
|
|
130
|
+
};
|
|
131
|
+
/** Replaceable read-only backend for the storefront SDK. */
|
|
132
|
+
interface Transport {
|
|
133
|
+
getSelectedMenu?(ctx: SelectedMenuRequest): Promise<SelectedMenuResponse>;
|
|
134
|
+
search?(ctx: SearchRequest): Promise<SearchPage>;
|
|
135
|
+
quote(ctx: RequestCtx, body: QuoteRequest): Promise<WireQuote>;
|
|
136
|
+
getStore(ctx: RequestCtx): Promise<Store>;
|
|
137
|
+
getMenu(ctx: RequestCtx & {
|
|
138
|
+
branchId: string;
|
|
139
|
+
ifNoneMatch?: string;
|
|
140
|
+
metadataOnly?: boolean;
|
|
141
|
+
fulfilment?: MenuFulfilment | undefined;
|
|
142
|
+
}): Promise<MenuResponse>;
|
|
143
|
+
getCategoryPage?(ctx: RequestCtx & {
|
|
144
|
+
branchId: string;
|
|
145
|
+
menuId: string;
|
|
146
|
+
categoryId: string;
|
|
147
|
+
cursor?: string;
|
|
148
|
+
}): Promise<CategoryPage>;
|
|
149
|
+
getMenuVersion(ctx: RequestCtx & {
|
|
150
|
+
branchId: string;
|
|
151
|
+
fulfilment?: MenuFulfilment | undefined;
|
|
152
|
+
}): Promise<MenuVersion>;
|
|
153
|
+
getItem(ctx: RequestCtx & {
|
|
154
|
+
branchId: string;
|
|
155
|
+
itemId: string;
|
|
156
|
+
}): Promise<Item>;
|
|
157
|
+
}
|
|
158
|
+
/** Bounded search across eligible source menus in the current order context. */
|
|
159
|
+
type SearchRequest = RequestCtx & {
|
|
160
|
+
branchId: string;
|
|
161
|
+
query: string;
|
|
162
|
+
cursor?: string;
|
|
163
|
+
};
|
|
164
|
+
/** Matching items with their source menus and categories. This is a partial catalogue. */
|
|
165
|
+
type SearchPage = {
|
|
166
|
+
menu: Menu;
|
|
167
|
+
nextCursor?: string;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/** Release-pinned REST contract version, independent of the package version. */
|
|
171
|
+
declare const API_VERSION = "2026-10-01";
|
|
172
|
+
/** A storage adapter you can supply to save carts. */
|
|
173
|
+
interface StorageLike {
|
|
174
|
+
getItem(key: string): string | null;
|
|
175
|
+
setItem(key: string, value: string): void;
|
|
176
|
+
removeItem(key: string): void;
|
|
177
|
+
/** Provide length and key to let the SDK remove expired carts for this store. */
|
|
178
|
+
readonly length?: number;
|
|
179
|
+
key?(index: number): string | null;
|
|
180
|
+
}
|
|
181
|
+
/** Settings for your storefront client. Each client keeps its own credentials and caches. */
|
|
182
|
+
type ZappieConfig = {
|
|
183
|
+
store: string;
|
|
184
|
+
key: string;
|
|
185
|
+
branch?: string;
|
|
186
|
+
transport?: Transport;
|
|
187
|
+
baseUrl?: string;
|
|
188
|
+
version?: string;
|
|
189
|
+
fetch?: typeof fetch;
|
|
190
|
+
/** Route cart quotes through the same-origin customer channel when set. */
|
|
191
|
+
customerBase?: string;
|
|
192
|
+
storage?: StorageLike;
|
|
193
|
+
telemetry?: boolean;
|
|
194
|
+
cart?: {
|
|
195
|
+
ttl?: number;
|
|
196
|
+
storageScope?: string;
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
declare function validateConfig(config: ZappieConfig, secret?: boolean): "test" | "live";
|
|
200
|
+
|
|
201
|
+
/** Stable public error codes. */
|
|
202
|
+
type ZappieErrorCode = "network_error" | "timeout" | "rate_limited" | "unauthorized" | "forbidden_origin" | "not_found" | "store_not_found" | "branch_not_found" | "item_not_found" | "cart_invalid" | "invalid_request" | "version_unsupported" | "server_error";
|
|
203
|
+
/** Context attached to an SDK failure. */
|
|
204
|
+
type ErrorDetails = {
|
|
205
|
+
status?: number;
|
|
206
|
+
param?: string;
|
|
207
|
+
docUrl?: string;
|
|
208
|
+
requestId?: string;
|
|
209
|
+
retryable?: boolean;
|
|
210
|
+
cause?: unknown;
|
|
211
|
+
};
|
|
212
|
+
/** An SDK error you can handle by its stable code. */
|
|
213
|
+
declare class ZappieError extends Error {
|
|
214
|
+
readonly code: ZappieErrorCode;
|
|
215
|
+
readonly status?: number;
|
|
216
|
+
readonly param?: string;
|
|
217
|
+
readonly docUrl: string;
|
|
218
|
+
readonly requestId?: string;
|
|
219
|
+
readonly retryable: boolean;
|
|
220
|
+
constructor(code: ZappieErrorCode, message: string, details?: ErrorDetails);
|
|
221
|
+
}
|
|
222
|
+
/** Check whether a thrown value is a ZappieError. */
|
|
223
|
+
declare function isZappieError(error: unknown): error is ZappieError;
|
|
224
|
+
|
|
225
|
+
type CacheEntry<T> = {
|
|
226
|
+
value?: T;
|
|
227
|
+
fetchedAt: number;
|
|
228
|
+
etag?: string;
|
|
229
|
+
error?: ZappieError;
|
|
230
|
+
failedAt?: number;
|
|
231
|
+
loading: boolean;
|
|
232
|
+
};
|
|
233
|
+
type Loaded<T> = {
|
|
234
|
+
value: T;
|
|
235
|
+
etag?: string;
|
|
236
|
+
onStored?: () => void;
|
|
237
|
+
};
|
|
238
|
+
/** Client-local SWR storage. Subscribers receive stable snapshots until an entry changes. */
|
|
239
|
+
declare class Cache {
|
|
240
|
+
private onError;
|
|
241
|
+
private entries;
|
|
242
|
+
private listeners;
|
|
243
|
+
private flights;
|
|
244
|
+
constructor(onError: (error: ZappieError) => void);
|
|
245
|
+
snapshot<T>(key: string): CacheEntry<T>;
|
|
246
|
+
subscribe: (fn: () => void) => () => void;
|
|
247
|
+
private notify;
|
|
248
|
+
set<T>(key: string, value: T, etag?: string): void;
|
|
249
|
+
stale(key: string): boolean;
|
|
250
|
+
get<T>(key: string, loader: (signal: AbortSignal, entry: CacheEntry<T>) => Promise<Loaded<T>>, signal?: AbortSignal): Promise<T>;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** Events currently emitted by the read-only SDK. */
|
|
254
|
+
type ZappieEvents = {
|
|
255
|
+
search: {
|
|
256
|
+
query: string;
|
|
257
|
+
resultCount: number;
|
|
258
|
+
};
|
|
259
|
+
warning: {
|
|
260
|
+
message: string;
|
|
261
|
+
};
|
|
262
|
+
cart_expired: {
|
|
263
|
+
branchId: string;
|
|
264
|
+
};
|
|
265
|
+
add_to_cart: {
|
|
266
|
+
itemId: string;
|
|
267
|
+
quantity: number;
|
|
268
|
+
value: Money;
|
|
269
|
+
};
|
|
270
|
+
remove_from_cart: {
|
|
271
|
+
itemId: string;
|
|
272
|
+
quantity: number;
|
|
273
|
+
value: Money;
|
|
274
|
+
};
|
|
275
|
+
update_cart_line: {
|
|
276
|
+
lineId: string;
|
|
277
|
+
itemId: string;
|
|
278
|
+
quantity: number;
|
|
279
|
+
};
|
|
280
|
+
view_cart: Record<string, never>;
|
|
281
|
+
cart_issue: {
|
|
282
|
+
code: CartIssueCode;
|
|
283
|
+
};
|
|
284
|
+
quote_failed: {
|
|
285
|
+
code: string;
|
|
286
|
+
};
|
|
287
|
+
"menu:updated": {
|
|
288
|
+
branchId: string;
|
|
289
|
+
version: string;
|
|
290
|
+
};
|
|
291
|
+
error: {
|
|
292
|
+
error: ZappieError;
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
/** A catalogue fulfilment mode accepted by menu reads. */
|
|
297
|
+
type MenuFulfilment = "delivery" | "pickup" | "dineIn";
|
|
298
|
+
/** Optional branch selection and cancellation for resource reads. */
|
|
299
|
+
type ReadOptions = {
|
|
300
|
+
branch?: string;
|
|
301
|
+
signal?: AbortSignal;
|
|
302
|
+
};
|
|
303
|
+
/** Optional branch and fulfilment selection for catalogue reads. */
|
|
304
|
+
type MenuReadOptions = ReadOptions & {
|
|
305
|
+
fulfilment?: MenuFulfilment;
|
|
306
|
+
};
|
|
307
|
+
/** Read-only store resource. */
|
|
308
|
+
interface StoreResource {
|
|
309
|
+
get(opts?: {
|
|
310
|
+
signal?: AbortSignal;
|
|
311
|
+
}): Promise<Store>;
|
|
312
|
+
peek(): Store | undefined;
|
|
313
|
+
}
|
|
314
|
+
/** Read-only branch catalogue and item resources. */
|
|
315
|
+
interface MenuResource {
|
|
316
|
+
search(query: string, opts?: ReadOptions & {
|
|
317
|
+
cursor?: string;
|
|
318
|
+
}): Promise<SearchPage>;
|
|
319
|
+
get(opts?: MenuReadOptions & {
|
|
320
|
+
metadataOnly?: boolean;
|
|
321
|
+
}): Promise<Menu>;
|
|
322
|
+
page(menuId: string, categoryId: string, opts?: ReadOptions & {
|
|
323
|
+
cursor?: string;
|
|
324
|
+
}): Promise<CategoryPage>;
|
|
325
|
+
peek(branch?: string): Menu | undefined;
|
|
326
|
+
version(opts?: MenuReadOptions): Promise<MenuVersion>;
|
|
327
|
+
item(id: string, opts?: ReadOptions): Promise<Item>;
|
|
328
|
+
hydrate(menu: Menu): void;
|
|
329
|
+
}
|
|
330
|
+
/** A storefront client and its isolated resource state. */
|
|
331
|
+
type Zappie = ReturnType<typeof buildClient>;
|
|
332
|
+
declare function buildClient(input: ZappieConfig, secret?: boolean): Readonly<{
|
|
333
|
+
cart: Readonly<CartModule>;
|
|
334
|
+
config: Readonly<{
|
|
335
|
+
version: string;
|
|
336
|
+
telemetry: boolean;
|
|
337
|
+
store: string;
|
|
338
|
+
key: string;
|
|
339
|
+
branch?: string;
|
|
340
|
+
transport?: Transport;
|
|
341
|
+
baseUrl?: string;
|
|
342
|
+
fetch?: typeof fetch;
|
|
343
|
+
customerBase?: string;
|
|
344
|
+
storage?: StorageLike;
|
|
345
|
+
cart?: {
|
|
346
|
+
ttl?: number;
|
|
347
|
+
storageScope?: string;
|
|
348
|
+
};
|
|
349
|
+
}>;
|
|
350
|
+
mode: "test" | "live";
|
|
351
|
+
store: StoreResource;
|
|
352
|
+
menu: MenuResource;
|
|
353
|
+
format: Formatters;
|
|
354
|
+
on: <E extends keyof ZappieEvents>(event: E, fn: (payload: ZappieEvents[E]) => void) => () => void;
|
|
355
|
+
_internal: {
|
|
356
|
+
cartCatalogue: () => Menu | undefined;
|
|
357
|
+
setLegacyReader: (reader: NonNullable<((read: (key: string) => string | null) => CartLineInput[]) | undefined>) => void;
|
|
358
|
+
transport: Transport;
|
|
359
|
+
cache: Cache;
|
|
360
|
+
emit: <E extends keyof ZappieEvents>(event: E, payload: ZappieEvents[E]) => void;
|
|
361
|
+
menuKey: (requested?: string) => string;
|
|
362
|
+
hydrateStore: (value: Store) => void;
|
|
363
|
+
};
|
|
364
|
+
}>;
|
|
365
|
+
/** Create a client with your publishable key. Requests start when you read a resource. */
|
|
366
|
+
declare function createZappie(config: ZappieConfig): Readonly<{
|
|
367
|
+
cart: Readonly<CartModule>;
|
|
368
|
+
config: Readonly<{
|
|
369
|
+
version: string;
|
|
370
|
+
telemetry: boolean;
|
|
371
|
+
store: string;
|
|
372
|
+
key: string;
|
|
373
|
+
branch?: string;
|
|
374
|
+
transport?: Transport;
|
|
375
|
+
baseUrl?: string;
|
|
376
|
+
fetch?: typeof fetch;
|
|
377
|
+
customerBase?: string;
|
|
378
|
+
storage?: StorageLike;
|
|
379
|
+
cart?: {
|
|
380
|
+
ttl?: number;
|
|
381
|
+
storageScope?: string;
|
|
382
|
+
};
|
|
383
|
+
}>;
|
|
384
|
+
mode: "test" | "live";
|
|
385
|
+
store: StoreResource;
|
|
386
|
+
menu: MenuResource;
|
|
387
|
+
format: Formatters;
|
|
388
|
+
on: <E extends keyof ZappieEvents>(event: E, fn: (payload: ZappieEvents[E]) => void) => () => void;
|
|
389
|
+
_internal: {
|
|
390
|
+
cartCatalogue: () => Menu | undefined;
|
|
391
|
+
setLegacyReader: (reader: NonNullable<((read: (key: string) => string | null) => CartLineInput[]) | undefined>) => void;
|
|
392
|
+
transport: Transport;
|
|
393
|
+
cache: Cache;
|
|
394
|
+
emit: <E extends keyof ZappieEvents>(event: E, payload: ZappieEvents[E]) => void;
|
|
395
|
+
menuKey: (requested?: string) => string;
|
|
396
|
+
hydrateStore: (value: Store) => void;
|
|
397
|
+
};
|
|
398
|
+
}>;
|
|
399
|
+
|
|
400
|
+
export { API_VERSION as A, type SelectedMenuTransport as B, Cache as C, createSelectedMenuReader as D, type ErrorDetails as E, selectedMenu as F, selectedMenuKey as G, type MenuResource as M, type RequestCtx as R, type StorageLike as S, type Transport as T, type Zappie as Z, ZappieError as a, type ZappieConfig as b, type StoreResource as c, type ZappieEvents as d, type ZappieErrorCode as e, type MenuFulfilment as f, type MenuResponse as g, type SelectedMenuRequest as h, type SelectedMenuResponse as i, type SearchRequest as j, type SearchPage as k, type MenuVersion as l, type MenuReadOptions as m, type ReadOptions as n, createZappie as o, isZappieError as p, CATALOGUE_MAX_AGE_MS as q, CATALOGUE_MAX_BYTES as r, type CatalogueScope as s, type SavedCatalogue as t, catalogueDigest as u, validateConfig as v, catalogueKey as w, createCatalogueStorage as x, createSavedCatalogue as y, type SelectedMenu as z };
|
package/dist/client.js
CHANGED
|
@@ -77,11 +77,12 @@ function buildClient(input, secret = false) {
|
|
|
77
77
|
async get(opts = {}) {
|
|
78
78
|
const branch = resolveBranch(await store.get(opts), opts.branch);
|
|
79
79
|
return cache.get(
|
|
80
|
-
|
|
80
|
+
`${menuKey(branch.id)}${opts.fulfilment ? `:${opts.fulfilment}` : ""}${opts.metadataOnly ? ":partial" : ""}`,
|
|
81
81
|
async (signal, entry) => {
|
|
82
82
|
const response = await transport.getMenu({
|
|
83
83
|
...ctx(signal),
|
|
84
84
|
branchId: branch.id,
|
|
85
|
+
fulfilment: opts.fulfilment,
|
|
85
86
|
...opts.metadataOnly ? { metadataOnly: true } : {},
|
|
86
87
|
...entry.etag ? { ifNoneMatch: entry.etag } : {}
|
|
87
88
|
});
|
|
@@ -146,7 +147,8 @@ function buildClient(input, secret = false) {
|
|
|
146
147
|
const branch = resolveBranch(await store.get(opts), opts.branch);
|
|
147
148
|
return transport.getMenuVersion({
|
|
148
149
|
...ctx(opts.signal),
|
|
149
|
-
branchId: branch.id
|
|
150
|
+
branchId: branch.id,
|
|
151
|
+
fulfilment: opts.fulfilment
|
|
150
152
|
});
|
|
151
153
|
},
|
|
152
154
|
async item(id, opts = {}) {
|
package/dist/client.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/client.ts"],
|
|
4
|
-
"sourcesContent": ["import { createCart } from \"./cart\";\nimport { createWorkingSet } from \"./cart/working-set\";\nimport type { ZappieConfig } from \"./config\";\nimport { API_VERSION, validateConfig } from \"./config\";\nimport { ZappieError } from \"./errors\";\nimport { Cache } from \"./internal/cache\";\nimport type { ZappieEvents } from \"./internal/emitter\";\nimport { createEmitter } from \"./internal/emitter\";\nimport type { Branch, CategoryPage, Item, Menu, Store } from \"./models\";\nimport { format } from \"./money\";\nimport { RestTransport } from \"./transport/rest\";\nimport type { MenuVersion, SearchPage } from \"./transport/types\";\n/** Optional branch selection and cancellation for resource reads. */\nexport type ReadOptions = { branch?: string; signal?: AbortSignal };\n/** Read-only store resource. */\nexport interface StoreResource {\n get(opts?: { signal?: AbortSignal }): Promise<Store>;\n peek(): Store | undefined;\n}\n/** Read-only branch catalogue and item resources. */\nexport interface MenuResource {\n search(\n query: string,\n opts?: ReadOptions & { cursor?: string },\n ): Promise<SearchPage>;\n get(opts?: ReadOptions & { metadataOnly?: boolean }): Promise<Menu>;\n page(\n menuId: string,\n categoryId: string,\n opts?: ReadOptions & { cursor?: string },\n ): Promise<CategoryPage>;\n peek(branch?: string): Menu | undefined;\n version(opts?: ReadOptions): Promise<MenuVersion>;\n item(id: string, opts?: ReadOptions): Promise<Item>;\n hydrate(menu: Menu): void;\n}\n/** A storefront client and its isolated resource state. */\nexport type Zappie = ReturnType<typeof buildClient>;\nexport function buildClient(input: ZappieConfig, secret = false) {\n const mode = validateConfig(input, secret);\n const config = Object.freeze({\n ...input,\n version: input.version ?? API_VERSION,\n telemetry: input.telemetry ?? true,\n });\n const transport =\n input.transport ??\n new RestTransport({\n ...(input.baseUrl ? { baseUrl: input.baseUrl } : {}),\n ...(input.fetch ? { fetch: input.fetch } : {}),\n });\n const events = createEmitter();\n const cache = new Cache((error) => events.emit(\"error\", { error }));\n const ctx = (signal?: AbortSignal) => ({\n key: config.key,\n version: config.version,\n ...(signal ? { signal } : {}),\n });\n const store: StoreResource = {\n get: (opts = {}) =>\n cache.get(\n \"store\",\n async (signal) => ({ value: await transport.getStore(ctx(signal)) }),\n opts.signal,\n ),\n peek: () => cache.snapshot<Store>(\"store\").value,\n };\n const resolveBranch = (value: Store, requested?: string): Branch => {\n const selected = requested ?? config.branch;\n const branch = selected\n ? value.branches.find((b) => b.id === selected || b.slug === selected)\n : (value.branches.find((b) => b.isDefault) ?? value.branches[0]);\n if (!branch) {\n throw new ZappieError(\n \"branch_not_found\",\n \"No matching storefront branch\",\n { param: \"branch\" },\n );\n }\n return branch;\n };\n let hydratedBranch: string | undefined;\n const branchKey = (requested?: string) => {\n const value = store.peek();\n if (value) {\n return resolveBranch(value, requested).id;\n }\n // A slug can't be resolved without the store. A hydrated menu is the configured\n // branch's, so a read for that branch (by slug or id) uses it rather than missing.\n const selected = requested ?? config.branch;\n if (\n hydratedBranch &&\n (selected === undefined ||\n selected === config.branch ||\n selected === hydratedBranch)\n ) {\n return hydratedBranch;\n }\n return selected ?? \"default\";\n };\n const menuKey = (requested?: string) => `menu:${branchKey(requested)}`;\n const menu: MenuResource = {\n async search(query, opts = {}) {\n if (!transport.search) {\n throw new ZappieError(\n \"invalid_request\",\n \"Transport does not support search\",\n );\n }\n const branch = resolveBranch(await store.get(opts), opts.branch);\n return transport.search({\n ...ctx(opts.signal),\n branchId: branch.id,\n query,\n ...(opts.cursor ? { cursor: opts.cursor } : {}),\n });\n },\n async get(opts = {}) {\n const branch = resolveBranch(await store.get(opts), opts.branch);\n return cache.get<Menu>(\n `menu:${branch.id}${opts.metadataOnly ? \":partial\" : \"\"}`,\n async (signal, entry) => {\n const response = await transport.getMenu({\n ...ctx(signal),\n branchId: branch.id,\n ...(opts.metadataOnly ? { metadataOnly: true } : {}),\n ...(entry.etag ? { ifNoneMatch: entry.etag } : {}),\n });\n if (\"notModified\" in response) {\n if (!entry.value) {\n throw new ZappieError(\n \"server_error\",\n \"Received 304 without a cached menu\",\n );\n }\n return {\n value: entry.value,\n ...((response.etag ?? entry.etag)\n ? { etag: response.etag ?? entry.etag }\n : {}),\n };\n }\n if (!opts.metadataOnly && response.menu.completeness === \"partial\") {\n throw new ZappieError(\n \"server_error\",\n \"Partial catalogue cannot satisfy a complete read\",\n );\n }\n if (response.menu.branchId !== branch.id) {\n throw new ZappieError(\n \"server_error\",\n \"Menu belongs to a different branch\",\n );\n }\n return {\n value: response.menu,\n etag: response.etag ?? response.menu.version,\n onStored: () => {\n if (\n entry.value &&\n entry.value.version !== response.menu.version\n ) {\n events.emit(\"menu:updated\", {\n branchId: branch.id,\n version: response.menu.version,\n });\n }\n },\n };\n },\n opts.signal,\n );\n },\n peek: (branch) =>\n cache.snapshot<Menu>(menuKey(branch)).value ??\n cache.snapshot<Menu>(`${menuKey(branch)}:partial`).value,\n async page(menuId, categoryId, opts = {}) {\n if (!transport.getCategoryPage) {\n throw new ZappieError(\n \"invalid_request\",\n \"Transport does not support category pages\",\n );\n }\n const branch = resolveBranch(await store.get(opts), opts.branch);\n return transport.getCategoryPage({\n ...ctx(opts.signal),\n branchId: branch.id,\n menuId,\n categoryId,\n ...(opts.cursor ? { cursor: opts.cursor } : {}),\n });\n },\n async version(opts = {}) {\n const branch = resolveBranch(await store.get(opts), opts.branch);\n return transport.getMenuVersion({\n ...ctx(opts.signal),\n branchId: branch.id,\n });\n },\n async item(id, opts = {}) {\n const branch = resolveBranch(await store.get(opts), opts.branch);\n if (\n !menu.peek(branch.id) ||\n menu.peek(branch.id)?.completeness === \"partial\"\n ) {\n await menu.get({ ...opts, metadataOnly: true });\n }\n return readItem(id, branch.id, false, opts.signal);\n },\n hydrate(value) {\n hydratedBranch ??= value.branchId;\n const previous = cache.snapshot<Menu>(`menu:${value.branchId}`).value;\n cache.set(\n `menu:${value.branchId}${value.completeness === \"partial\" ? \":partial\" : \"\"}`,\n value,\n value.version,\n );\n if (previous && previous.version !== value.version) {\n events.emit(\"menu:updated\", {\n branchId: value.branchId,\n version: value.version,\n });\n }\n },\n };\n const itemValues = new Map<string, Item>();\n const peekItem = (id: string, branch: string) =>\n itemValues.get(`${branch}:${id}`);\n const readItem = async (\n id: string,\n branch: string,\n fresh = false,\n signal?: AbortSignal,\n ) => {\n const complete = cache.snapshot<Menu>(`menu:${branch}`).value;\n if (!fresh && complete && Object.hasOwn(complete.items, id)) {\n return complete.items[id]!;\n }\n const load = (requestSignal = signal) =>\n transport.getItem({\n ...ctx(requestSignal),\n branchId: branch,\n itemId: id,\n });\n try {\n const value = fresh\n ? await load()\n : await cache.get(\n `item:${branch}:${id}`,\n async (requestSignal) => ({ value: await load(requestSignal) }),\n signal,\n );\n if (fresh) {\n cache.set(`item:${branch}:${id}`, value);\n }\n itemValues.set(`${branch}:${id}`, value);\n return value;\n } catch (error) {\n if ((error as { code?: string }).code === \"item_not_found\") {\n itemValues.delete(`${branch}:${id}`);\n cache.set(`item:${branch}:${id}`, undefined);\n }\n throw error;\n }\n };\n const workingSet = createWorkingSet({\n menu,\n store,\n transport,\n context: ctx,\n peekItem,\n readItem,\n });\n const { cart, setLegacyReader, cartCatalogue } = createCart({\n workingSet,\n config,\n menu,\n store,\n transport,\n context: ctx,\n events,\n });\n return Object.freeze({\n cart,\n config,\n mode,\n store,\n menu,\n format,\n on: events.on,\n _internal: {\n cartCatalogue,\n setLegacyReader,\n transport,\n cache,\n emit: events.emit,\n menuKey,\n hydrateStore: (value: Store) => cache.set(\"store\", value),\n },\n });\n}\n/** Create a client with your publishable key. Requests start when you read a resource. */\nexport function createZappie(config: ZappieConfig) {\n const client = buildClient(config);\n if (client.mode === \"test\" && typeof window !== \"undefined\") {\n void import(\"./debug\").then(({ installDebug }) => installDebug(client));\n }\n return client;\n}\nexport type { ZappieEvents };\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AAEjC,SAAS,aAAa,sBAAsB;AAC5C,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AAEtB,SAAS,qBAAqB;AAE9B,SAAS,cAAc;AACvB,SAAS,qBAAqB;
|
|
4
|
+
"sourcesContent": ["import { createCart } from \"./cart\";\nimport { createWorkingSet } from \"./cart/working-set\";\nimport type { ZappieConfig } from \"./config\";\nimport { API_VERSION, validateConfig } from \"./config\";\nimport { ZappieError } from \"./errors\";\nimport { Cache } from \"./internal/cache\";\nimport type { ZappieEvents } from \"./internal/emitter\";\nimport { createEmitter } from \"./internal/emitter\";\nimport type { Branch, CategoryPage, Item, Menu, Store } from \"./models\";\nimport { format } from \"./money\";\nimport { RestTransport } from \"./transport/rest\";\nimport type { MenuVersion, SearchPage } from \"./transport/types\";\n/** A catalogue fulfilment mode accepted by menu reads. */\nexport type MenuFulfilment = \"delivery\" | \"pickup\" | \"dineIn\";\n/** Optional branch selection and cancellation for resource reads. */\nexport type ReadOptions = { branch?: string; signal?: AbortSignal };\n/** Optional branch and fulfilment selection for catalogue reads. */\nexport type MenuReadOptions = ReadOptions & { fulfilment?: MenuFulfilment };\n/** Read-only store resource. */\nexport interface StoreResource {\n get(opts?: { signal?: AbortSignal }): Promise<Store>;\n peek(): Store | undefined;\n}\n/** Read-only branch catalogue and item resources. */\nexport interface MenuResource {\n search(\n query: string,\n opts?: ReadOptions & { cursor?: string },\n ): Promise<SearchPage>;\n get(opts?: MenuReadOptions & { metadataOnly?: boolean }): Promise<Menu>;\n page(\n menuId: string,\n categoryId: string,\n opts?: ReadOptions & { cursor?: string },\n ): Promise<CategoryPage>;\n peek(branch?: string): Menu | undefined;\n version(opts?: MenuReadOptions): Promise<MenuVersion>;\n item(id: string, opts?: ReadOptions): Promise<Item>;\n hydrate(menu: Menu): void;\n}\n/** A storefront client and its isolated resource state. */\nexport type Zappie = ReturnType<typeof buildClient>;\nexport function buildClient(input: ZappieConfig, secret = false) {\n const mode = validateConfig(input, secret);\n const config = Object.freeze({\n ...input,\n version: input.version ?? API_VERSION,\n telemetry: input.telemetry ?? true,\n });\n const transport =\n input.transport ??\n new RestTransport({\n ...(input.baseUrl ? { baseUrl: input.baseUrl } : {}),\n ...(input.fetch ? { fetch: input.fetch } : {}),\n });\n const events = createEmitter();\n const cache = new Cache((error) => events.emit(\"error\", { error }));\n const ctx = (signal?: AbortSignal) => ({\n key: config.key,\n version: config.version,\n ...(signal ? { signal } : {}),\n });\n const store: StoreResource = {\n get: (opts = {}) =>\n cache.get(\n \"store\",\n async (signal) => ({ value: await transport.getStore(ctx(signal)) }),\n opts.signal,\n ),\n peek: () => cache.snapshot<Store>(\"store\").value,\n };\n const resolveBranch = (value: Store, requested?: string): Branch => {\n const selected = requested ?? config.branch;\n const branch = selected\n ? value.branches.find((b) => b.id === selected || b.slug === selected)\n : (value.branches.find((b) => b.isDefault) ?? value.branches[0]);\n if (!branch) {\n throw new ZappieError(\n \"branch_not_found\",\n \"No matching storefront branch\",\n { param: \"branch\" },\n );\n }\n return branch;\n };\n let hydratedBranch: string | undefined;\n const branchKey = (requested?: string) => {\n const value = store.peek();\n if (value) {\n return resolveBranch(value, requested).id;\n }\n // A slug can't be resolved without the store. A hydrated menu is the configured\n // branch's, so a read for that branch (by slug or id) uses it rather than missing.\n const selected = requested ?? config.branch;\n if (\n hydratedBranch &&\n (selected === undefined ||\n selected === config.branch ||\n selected === hydratedBranch)\n ) {\n return hydratedBranch;\n }\n return selected ?? \"default\";\n };\n const menuKey = (requested?: string) => `menu:${branchKey(requested)}`;\n const menu: MenuResource = {\n async search(query, opts = {}) {\n if (!transport.search) {\n throw new ZappieError(\n \"invalid_request\",\n \"Transport does not support search\",\n );\n }\n const branch = resolveBranch(await store.get(opts), opts.branch);\n return transport.search({\n ...ctx(opts.signal),\n branchId: branch.id,\n query,\n ...(opts.cursor ? { cursor: opts.cursor } : {}),\n });\n },\n async get(opts = {}) {\n const branch = resolveBranch(await store.get(opts), opts.branch);\n return cache.get<Menu>(\n `${menuKey(branch.id)}${opts.fulfilment ? `:${opts.fulfilment}` : \"\"}${opts.metadataOnly ? \":partial\" : \"\"}`,\n async (signal, entry) => {\n const response = await transport.getMenu({\n ...ctx(signal),\n branchId: branch.id,\n fulfilment: opts.fulfilment,\n ...(opts.metadataOnly ? { metadataOnly: true } : {}),\n ...(entry.etag ? { ifNoneMatch: entry.etag } : {}),\n });\n if (\"notModified\" in response) {\n if (!entry.value) {\n throw new ZappieError(\n \"server_error\",\n \"Received 304 without a cached menu\",\n );\n }\n return {\n value: entry.value,\n ...((response.etag ?? entry.etag)\n ? { etag: response.etag ?? entry.etag }\n : {}),\n };\n }\n if (!opts.metadataOnly && response.menu.completeness === \"partial\") {\n throw new ZappieError(\n \"server_error\",\n \"Partial catalogue cannot satisfy a complete read\",\n );\n }\n if (response.menu.branchId !== branch.id) {\n throw new ZappieError(\n \"server_error\",\n \"Menu belongs to a different branch\",\n );\n }\n return {\n value: response.menu,\n etag: response.etag ?? response.menu.version,\n onStored: () => {\n if (\n entry.value &&\n entry.value.version !== response.menu.version\n ) {\n events.emit(\"menu:updated\", {\n branchId: branch.id,\n version: response.menu.version,\n });\n }\n },\n };\n },\n opts.signal,\n );\n },\n peek: (branch) =>\n cache.snapshot<Menu>(menuKey(branch)).value ??\n cache.snapshot<Menu>(`${menuKey(branch)}:partial`).value,\n async page(menuId, categoryId, opts = {}) {\n if (!transport.getCategoryPage) {\n throw new ZappieError(\n \"invalid_request\",\n \"Transport does not support category pages\",\n );\n }\n const branch = resolveBranch(await store.get(opts), opts.branch);\n return transport.getCategoryPage({\n ...ctx(opts.signal),\n branchId: branch.id,\n menuId,\n categoryId,\n ...(opts.cursor ? { cursor: opts.cursor } : {}),\n });\n },\n async version(opts = {}) {\n const branch = resolveBranch(await store.get(opts), opts.branch);\n return transport.getMenuVersion({\n ...ctx(opts.signal),\n branchId: branch.id,\n fulfilment: opts.fulfilment,\n });\n },\n async item(id, opts = {}) {\n const branch = resolveBranch(await store.get(opts), opts.branch);\n if (\n !menu.peek(branch.id) ||\n menu.peek(branch.id)?.completeness === \"partial\"\n ) {\n await menu.get({ ...opts, metadataOnly: true });\n }\n return readItem(id, branch.id, false, opts.signal);\n },\n hydrate(value) {\n hydratedBranch ??= value.branchId;\n const previous = cache.snapshot<Menu>(`menu:${value.branchId}`).value;\n cache.set(\n `menu:${value.branchId}${value.completeness === \"partial\" ? \":partial\" : \"\"}`,\n value,\n value.version,\n );\n if (previous && previous.version !== value.version) {\n events.emit(\"menu:updated\", {\n branchId: value.branchId,\n version: value.version,\n });\n }\n },\n };\n const itemValues = new Map<string, Item>();\n const peekItem = (id: string, branch: string) =>\n itemValues.get(`${branch}:${id}`);\n const readItem = async (\n id: string,\n branch: string,\n fresh = false,\n signal?: AbortSignal,\n ) => {\n const complete = cache.snapshot<Menu>(`menu:${branch}`).value;\n if (!fresh && complete && Object.hasOwn(complete.items, id)) {\n return complete.items[id]!;\n }\n const load = (requestSignal = signal) =>\n transport.getItem({\n ...ctx(requestSignal),\n branchId: branch,\n itemId: id,\n });\n try {\n const value = fresh\n ? await load()\n : await cache.get(\n `item:${branch}:${id}`,\n async (requestSignal) => ({ value: await load(requestSignal) }),\n signal,\n );\n if (fresh) {\n cache.set(`item:${branch}:${id}`, value);\n }\n itemValues.set(`${branch}:${id}`, value);\n return value;\n } catch (error) {\n if ((error as { code?: string }).code === \"item_not_found\") {\n itemValues.delete(`${branch}:${id}`);\n cache.set(`item:${branch}:${id}`, undefined);\n }\n throw error;\n }\n };\n const workingSet = createWorkingSet({\n menu,\n store,\n transport,\n context: ctx,\n peekItem,\n readItem,\n });\n const { cart, setLegacyReader, cartCatalogue } = createCart({\n workingSet,\n config,\n menu,\n store,\n transport,\n context: ctx,\n events,\n });\n return Object.freeze({\n cart,\n config,\n mode,\n store,\n menu,\n format,\n on: events.on,\n _internal: {\n cartCatalogue,\n setLegacyReader,\n transport,\n cache,\n emit: events.emit,\n menuKey,\n hydrateStore: (value: Store) => cache.set(\"store\", value),\n },\n });\n}\n/** Create a client with your publishable key. Requests start when you read a resource. */\nexport function createZappie(config: ZappieConfig) {\n const client = buildClient(config);\n if (client.mode === \"test\" && typeof window !== \"undefined\") {\n void import(\"./debug\").then(({ installDebug }) => installDebug(client));\n }\n return client;\n}\nexport type { ZappieEvents };\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AAEjC,SAAS,aAAa,sBAAsB;AAC5C,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AAEtB,SAAS,qBAAqB;AAE9B,SAAS,cAAc;AACvB,SAAS,qBAAqB;AAgCvB,SAAS,YAAY,OAAqB,SAAS,OAAO;AAC/D,QAAM,OAAO,eAAe,OAAO,MAAM;AACzC,QAAM,SAAS,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IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,IAAI,OAAO;AAAA,IACX,WAAW;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,OAAO;AAAA,MACb;AAAA,MACA,cAAc,CAAC,UAAiB,MAAM,IAAI,SAAS,KAAK;AAAA,IAC1D;AAAA,EACF,CAAC;AACH;AAEO,SAAS,aAAa,QAAsB;AACjD,QAAM,SAAS,YAAY,MAAM;AACjC,MAAI,OAAO,SAAS,UAAU,OAAO,WAAW,aAAa;AAC3D,SAAK,OAAO,YAAS,EAAE,KAAK,CAAC,EAAE,aAAa,MAAM,aAAa,MAAM,CAAC;AAAA,EACxE;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -36,6 +36,17 @@ type ZappieSiteConfig = {
|
|
|
36
36
|
reason: string;
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
|
+
/** Records explained exceptions to storefront readiness checks. */
|
|
40
|
+
readiness?: {
|
|
41
|
+
/** Lets this site skip the initial route discovery requirement. */
|
|
42
|
+
routeDiscovery?: {
|
|
43
|
+
/** Explains why this site does not use initial route discovery. */
|
|
44
|
+
optOut: {
|
|
45
|
+
/** States the constraint that prevents initial route discovery. */
|
|
46
|
+
reason: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
39
50
|
analytics?: {
|
|
40
51
|
forward?: {
|
|
41
52
|
ga4?: string;
|
package/dist/config.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/config.ts"],
|
|
4
|
-
"sourcesContent": ["import { ZappieError } from \"./errors\";\nimport type { Transport } from \"./transport/types\";\n/** Release-pinned REST contract version, independent of the package version. */\nexport const API_VERSION = \"2026-10-01\";\n/** A storage adapter you can supply to save carts. */\nexport interface StorageLike {\n getItem(key: string): string | null;\n setItem(key: string, value: string): void;\n removeItem(key: string): void;\n /** Provide length and key to let the SDK remove expired carts for this store. */\n readonly length?: number;\n key?(index: number): string | null;\n}\n/** Settings for your storefront client. Each client keeps its own credentials and caches. */\nexport type ZappieConfig = {\n store: string;\n key: string;\n branch?: string;\n transport?: Transport;\n baseUrl?: string;\n version?: string;\n fetch?: typeof fetch;\n storage?: StorageLike;\n telemetry?: boolean;\n cart?: { ttl?: number; storageScope?: string };\n};\nexport function validateConfig(config: ZappieConfig, secret = false) {\n if (!config.store?.trim()) {\n throw new ZappieError(\"invalid_request\", \"A storefront slug is required\");\n }\n if (secret && typeof window !== \"undefined\") {\n throw new ZappieError(\n \"invalid_request\",\n \"Secret keys cannot be used in a browser\",\n );\n }\n const pattern = secret ? /^sk_(test|live)_.+$/ : /^pk_(test|live)_.+$/;\n const match = pattern.exec(config.key);\n if (!match) {\n throw new ZappieError(\n \"invalid_request\",\n secret\n ? \"A secret sk_test_ or sk_live_ key is required\"\n : \"Use a publishable pk_test_ or pk_live_ key; secret keys are never accepted by createZappie\",\n );\n }\n return match[1] as \"test\" | \"live\";\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,mBAAmB;AAGrB,IAAM,cAAc;
|
|
4
|
+
"sourcesContent": ["import { ZappieError } from \"./errors\";\nimport type { Transport } from \"./transport/types\";\n/** Release-pinned REST contract version, independent of the package version. */\nexport const API_VERSION = \"2026-10-01\";\n/** A storage adapter you can supply to save carts. */\nexport interface StorageLike {\n getItem(key: string): string | null;\n setItem(key: string, value: string): void;\n removeItem(key: string): void;\n /** Provide length and key to let the SDK remove expired carts for this store. */\n readonly length?: number;\n key?(index: number): string | null;\n}\n/** Settings for your storefront client. Each client keeps its own credentials and caches. */\nexport type ZappieConfig = {\n store: string;\n key: string;\n branch?: string;\n transport?: Transport;\n baseUrl?: string;\n version?: string;\n fetch?: typeof fetch;\n /** Route cart quotes through the same-origin customer channel when set. */\n customerBase?: string;\n storage?: StorageLike;\n telemetry?: boolean;\n cart?: { ttl?: number; storageScope?: string };\n};\nexport function validateConfig(config: ZappieConfig, secret = false) {\n if (!config.store?.trim()) {\n throw new ZappieError(\"invalid_request\", \"A storefront slug is required\");\n }\n if (secret && typeof window !== \"undefined\") {\n throw new ZappieError(\n \"invalid_request\",\n \"Secret keys cannot be used in a browser\",\n );\n }\n const pattern = secret ? /^sk_(test|live)_.+$/ : /^pk_(test|live)_.+$/;\n const match = pattern.exec(config.key);\n if (!match) {\n throw new ZappieError(\n \"invalid_request\",\n secret\n ? \"A secret sk_test_ or sk_live_ key is required\"\n : \"Use a publishable pk_test_ or pk_live_ key; secret keys are never accepted by createZappie\",\n );\n }\n return match[1] as \"test\" | \"live\";\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,mBAAmB;AAGrB,IAAM,cAAc;AAyBpB,SAAS,eAAe,QAAsB,SAAS,OAAO;AACnE,MAAI,CAAC,OAAO,OAAO,KAAK,GAAG;AACzB,UAAM,IAAI,YAAY,mBAAmB,+BAA+B;AAAA,EAC1E;AACA,MAAI,UAAU,OAAO,WAAW,aAAa;AAC3C,UAAM,IAAI;AAAA,MACR;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,QAAM,UAAU,SAAS,wBAAwB;AACjD,QAAM,QAAQ,QAAQ,KAAK,OAAO,GAAG;AACrC,MAAI,CAAC,OAAO;AACV,UAAM,IAAI;AAAA,MACR;AAAA,MACA,SACI,kDACA;AAAA,IACN;AAAA,EACF;AACA,SAAO,MAAM,CAAC;AAChB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/debug.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as CartLineInput, a as Quote } from './types-CuDvfW9g.js';
|
|
2
2
|
import { M as Money, a as Menu, B as Branch } from './models-Rg5kQUkv.js';
|
|
3
|
+
import { Z as Zappie } from './client-Bm2cCYea.js';
|
|
3
4
|
|
|
4
5
|
type StoredLine = CartLineInput & {
|
|
5
6
|
id: string;
|
package/dist/debug.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { T as Transport, R as RequestCtx,
|
|
2
|
-
export { A as API_VERSION,
|
|
1
|
+
import { T as Transport, R as RequestCtx, f as MenuFulfilment, g as MenuResponse, h as SelectedMenuRequest, i as SelectedMenuResponse, j as SearchRequest, k as SearchPage, l as MenuVersion, a as ZappieError } from './client-Bm2cCYea.js';
|
|
2
|
+
export { A as API_VERSION, E as ErrorDetails, m as MenuReadOptions, M as MenuResource, n as ReadOptions, S as StorageLike, c as StoreResource, Z as Zappie, b as ZappieClientOptions, b as ZappieConfig, e as ZappieErrorCode, d as ZappieEvents, o as createZappie, p as isZappieError } from './client-Bm2cCYea.js';
|
|
3
3
|
import { S as Store, C as CategoryPage, I as Item, O as OptionGroup, M as Money, a as Menu, B as Branch } from './models-Rg5kQUkv.js';
|
|
4
4
|
export { b as Category, c as Choice, d as Currency, F as Formatters, e as Fulfilment, f as MenuSchedule, g as MenuSection, h as MoneyFormatOptions, i as OpeningTime, j as OptionCondition, P as PaymentMethodKind, k as SpecialHours, V as Variant, l as format, m as money } from './models-Rg5kQUkv.js';
|
|
5
|
+
import { Q as QuoteRequest, g as WireQuote, f as CartIssue, b as CartLineInput, C as CartLine } from './types-CuDvfW9g.js';
|
|
6
|
+
export { h as CartFix, c as CartFulfilment, i as CartIssueCode, d as CartModule, j as CartSnapshot, e as CartState, k as CartSyncAdapter, l as CartSyncDocument, D as DeliveryAddress, a as Quote, m as WireFix, W as WireFulfilment, n as WireIssue, o as WireLine, p as WireMoney } from './types-CuDvfW9g.js';
|
|
5
7
|
|
|
6
8
|
/** REST connection options. A custom fetch can provide tracing or mock responses. */
|
|
7
9
|
type RestTransportOptions = {
|
|
@@ -21,6 +23,7 @@ declare class RestTransport implements Transport {
|
|
|
21
23
|
branchId: string;
|
|
22
24
|
ifNoneMatch?: string;
|
|
23
25
|
metadataOnly?: boolean;
|
|
26
|
+
fulfilment?: MenuFulfilment;
|
|
24
27
|
}): Promise<MenuResponse>;
|
|
25
28
|
getSelectedMenu(ctx: SelectedMenuRequest): Promise<SelectedMenuResponse>;
|
|
26
29
|
search(ctx: SearchRequest): Promise<SearchPage>;
|
|
@@ -32,6 +35,7 @@ declare class RestTransport implements Transport {
|
|
|
32
35
|
}): Promise<CategoryPage>;
|
|
33
36
|
getMenuVersion(ctx: RequestCtx & {
|
|
34
37
|
branchId: string;
|
|
38
|
+
fulfilment?: MenuFulfilment;
|
|
35
39
|
}): Promise<MenuVersion>;
|
|
36
40
|
getItem(ctx: RequestCtx & {
|
|
37
41
|
branchId: string;
|
|
@@ -81,4 +85,4 @@ declare function validateLine(item: Item | undefined, raw: CartLineInput, ctx: {
|
|
|
81
85
|
/** The installed @zappie/sdk version. */
|
|
82
86
|
declare const VERSION: string;
|
|
83
87
|
|
|
84
|
-
export { Branch, CartIssue, CartLine, CartLineInput, CategoryPage, Item, Menu, MenuResponse, MenuVersion, Money, OptionGroup, QuoteRequest, RequestCtx, RestTransport, type RestTransportOptions, SearchPage, SearchRequest, Store, Transport, VERSION, WireQuote, ZappieCartError, ZappieError, estimateUnitPrice, previewItem, resolveSourceMenu, validateLine };
|
|
88
|
+
export { Branch, CartIssue, CartLine, CartLineInput, CategoryPage, Item, Menu, MenuFulfilment, MenuResponse, MenuVersion, Money, OptionGroup, QuoteRequest, RequestCtx, RestTransport, type RestTransportOptions, SearchPage, SearchRequest, Store, Transport, VERSION, WireQuote, ZappieCartError, ZappieError, estimateUnitPrice, previewItem, resolveSourceMenu, validateLine };
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { previewItem } from "./cart/preview.js";
|
|
|
10
10
|
import { estimateUnitPrice } from "./cart/price.js";
|
|
11
11
|
import { resolveSourceMenu } from "./cart/source-menu.js";
|
|
12
12
|
import { validateLine } from "./cart/validate.js";
|
|
13
|
-
var VERSION = true ? "0.1.
|
|
13
|
+
var VERSION = true ? "0.1.6" : "0.0.0-development";
|
|
14
14
|
export {
|
|
15
15
|
API_VERSION,
|
|
16
16
|
RestTransport,
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["// tsup replaces __ZAPPIE_SDK_VERSION__ with package.json's version. Source run\n// without a build, as in a plain Node script, gets the development label.\n// Kept inline, not in a shared module, so the core chunks don't split differently.\ndeclare const __ZAPPIE_SDK_VERSION__: string | undefined;\n\n/** The installed @zappie/sdk version. */\nexport const VERSION: string =\n typeof __ZAPPIE_SDK_VERSION__ === \"string\"\n ? __ZAPPIE_SDK_VERSION__\n : \"0.0.0-development\";\nexport { createZappie } from \"./client\";\nexport type {\n MenuResource,\n ReadOptions,\n StoreResource,\n Zappie,\n ZappieEvents,\n} from \"./client\";\nexport { API_VERSION } from \"./config\";\nexport type {\n StorageLike,\n ZappieConfig as ZappieClientOptions,\n ZappieConfig,\n} from \"./config\";\nexport { ZappieError, isZappieError } from \"./errors\";\nexport type { ErrorDetails, ZappieErrorCode } from \"./errors\";\nexport * from \"./models\";\nexport { format, money } from \"./money\";\nexport type { Currency, Formatters, Money, MoneyFormatOptions } from \"./money\";\nexport { RestTransport } from \"./transport/rest\";\nexport type { RestTransportOptions } from \"./transport/rest\";\nexport type {\n MenuResponse,\n MenuVersion,\n RequestCtx,\n SearchPage,\n SearchRequest,\n Transport,\n} from \"./transport/types\";\n\nexport { ZappieCartError } from \"./cart/errors\";\nexport { previewItem } from \"./cart/preview\";\nexport { estimateUnitPrice } from \"./cart/price\";\nexport { resolveSourceMenu } from \"./cart/source-menu\";\nexport type * from \"./cart/types\";\nexport { validateLine } from \"./cart/validate\";\n"],
|
|
5
|
-
"mappings": ";AAUA,SAAS,oBAAoB;
|
|
4
|
+
"sourcesContent": ["// tsup replaces __ZAPPIE_SDK_VERSION__ with package.json's version. Source run\n// without a build, as in a plain Node script, gets the development label.\n// Kept inline, not in a shared module, so the core chunks don't split differently.\ndeclare const __ZAPPIE_SDK_VERSION__: string | undefined;\n\n/** The installed @zappie/sdk version. */\nexport const VERSION: string =\n typeof __ZAPPIE_SDK_VERSION__ === \"string\"\n ? __ZAPPIE_SDK_VERSION__\n : \"0.0.0-development\";\nexport { createZappie } from \"./client\";\nexport type {\n MenuFulfilment,\n MenuReadOptions,\n MenuResource,\n ReadOptions,\n StoreResource,\n Zappie,\n ZappieEvents,\n} from \"./client\";\nexport { API_VERSION } from \"./config\";\nexport type {\n StorageLike,\n ZappieConfig as ZappieClientOptions,\n ZappieConfig,\n} from \"./config\";\nexport { ZappieError, isZappieError } from \"./errors\";\nexport type { ErrorDetails, ZappieErrorCode } from \"./errors\";\nexport * from \"./models\";\nexport { format, money } from \"./money\";\nexport type { Currency, Formatters, Money, MoneyFormatOptions } from \"./money\";\nexport { RestTransport } from \"./transport/rest\";\nexport type { RestTransportOptions } from \"./transport/rest\";\nexport type {\n MenuResponse,\n MenuVersion,\n RequestCtx,\n SearchPage,\n SearchRequest,\n Transport,\n} from \"./transport/types\";\n\nexport { ZappieCartError } from \"./cart/errors\";\nexport { previewItem } from \"./cart/preview\";\nexport { estimateUnitPrice } from \"./cart/price\";\nexport { resolveSourceMenu } from \"./cart/source-menu\";\nexport type * from \"./cart/types\";\nexport { validateLine } from \"./cart/validate\";\n"],
|
|
5
|
+
"mappings": ";AAUA,SAAS,oBAAoB;AAU7B,SAAS,mBAAmB;AAM5B,SAAS,aAAa,qBAAqB;AAE3C,cAAc;AACd,SAAS,QAAQ,aAAa;AAE9B,SAAS,qBAAqB;AAW9B,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAElC,SAAS,oBAAoB;AAzCtB,IAAM,UACX,OACI,UACA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { R as RequestCtx } from '../client-
|
|
1
|
+
import { R as RequestCtx } from '../client-Bm2cCYea.js';
|
|
2
2
|
import '../models-Rg5kQUkv.js';
|
|
3
|
+
import '../types-CuDvfW9g.js';
|
|
3
4
|
|
|
4
5
|
/** Public tracking IDs. Your app decides when consent allows it to load scripts. */
|
|
5
6
|
type Integrations = {
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { v as validateConfig } from './client-
|
|
1
|
+
import { c as CartFulfilment, W as WireFulfilment } from './types-CuDvfW9g.js';
|
|
2
|
+
export { v as validateConfig } from './client-Bm2cCYea.js';
|
|
3
3
|
import './models-Rg5kQUkv.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
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-Bm2cCYea.js';
|
|
2
2
|
import '../models-Rg5kQUkv.js';
|
|
3
|
+
import '../types-CuDvfW9g.js';
|