@zappie/sdk 0.10.10 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/README.md +99 -19
- package/dist/cart/item.d.ts +1 -1
- package/dist/{client-CtDaenmW.d.ts → client-C47e44tl.d.ts} +1 -1
- package/dist/customer/client.js +8 -8
- package/dist/customer/client.js.map +1 -1
- package/dist/customer/index.d.ts +4 -2
- package/dist/debug.js +1 -1
- package/dist/debug.js.map +1 -1
- package/dist/error-pages/art.js +11 -0
- package/dist/error-pages/art.js.map +6 -0
- package/dist/error-pages/index.d.ts +58 -0
- package/dist/error-pages/index.js +122 -0
- package/dist/error-pages/index.js.map +6 -0
- package/dist/error-pages/react.d.ts +20 -0
- package/dist/error-pages/react.js +66 -0
- package/dist/error-pages/react.js.map +6 -0
- package/dist/in-venue/bill.js +70 -0
- package/dist/in-venue/bill.js.map +6 -0
- package/dist/in-venue/client.js +120 -0
- package/dist/in-venue/client.js.map +6 -0
- package/dist/in-venue/error.js +19 -0
- package/dist/in-venue/error.js.map +6 -0
- package/dist/in-venue/index.d.ts +338 -0
- package/dist/in-venue/index.js +24 -0
- package/dist/in-venue/index.js.map +6 -0
- package/dist/in-venue/react/bill-page.js +351 -0
- package/dist/in-venue/react/bill-page.js.map +6 -0
- package/dist/in-venue/react/in-venue-page.js +103 -0
- package/dist/in-venue/react/in-venue-page.js.map +6 -0
- package/dist/in-venue/react/order-panel.js +284 -0
- package/dist/in-venue/react/order-panel.js.map +6 -0
- package/dist/in-venue/react/pay-point-page.js +51 -0
- package/dist/in-venue/react/pay-point-page.js.map +6 -0
- package/dist/in-venue/react/shared.js +202 -0
- package/dist/in-venue/react/shared.js.map +6 -0
- package/dist/in-venue/react/table-menus-page.js +152 -0
- package/dist/in-venue/react/table-menus-page.js.map +6 -0
- package/dist/in-venue/react.d.ts +120 -0
- package/dist/in-venue/react.js +15 -0
- package/dist/in-venue/react.js.map +6 -0
- package/dist/in-venue/table.js +63 -0
- package/dist/in-venue/table.js.map +6 -0
- package/dist/in-venue/types.js +1 -0
- package/dist/in-venue/types.js.map +6 -0
- package/dist/in-venue/watch.js +83 -0
- package/dist/in-venue/watch.js.map +6 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/index.d.ts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/persist/catalogue.d.ts +2 -2
- package/dist/receipts/index.d.ts +23 -0
- package/dist/receipts/index.js +49 -0
- package/dist/receipts/index.js.map +6 -0
- package/dist/server/index.d.ts +1 -1
- package/dist/site-error/index.d.ts +45 -0
- package/dist/site-error/index.js +33 -0
- package/dist/site-error/index.js.map +6 -0
- package/dist/site-error/react.d.ts +18 -0
- package/dist/site-error/react.js +15 -0
- package/dist/site-error/react.js.map +6 -0
- package/dist/testing/index.d.ts +1 -1
- package/dist/transport/search.d.ts +1 -1
- package/dist/transport/selected-menu.d.ts +2 -2
- package/dist/{types-DMMeyB5d.d.ts → types-ooHA0lwH.d.ts} +2 -0
- package/package.json +30 -2
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two error pages a storefront draws itself. `not-found` is a page, item or table that doesn't exist (404 or
|
|
3
|
+
* 410). `went-wrong` is anything else a route threw.
|
|
4
|
+
*/
|
|
5
|
+
type SiteErrorKind = "not-found" | "went-wrong";
|
|
6
|
+
/** A page's heading and the sentence under it. */
|
|
7
|
+
type SiteErrorCopy = {
|
|
8
|
+
title: string;
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
/** Options for `siteError`. */
|
|
12
|
+
type SiteErrorOptions = {
|
|
13
|
+
/** The address Try again reloads. Pass the current path and query when rendering on a server. */
|
|
14
|
+
url?: string;
|
|
15
|
+
/** The storefront's home page. Default `/`. */
|
|
16
|
+
home?: string;
|
|
17
|
+
/** Your own words for either page. Never pass the thrown error's message, which can hold internal details. */
|
|
18
|
+
copy?: Partial<Record<SiteErrorKind, Partial<SiteErrorCopy>>>;
|
|
19
|
+
};
|
|
20
|
+
/** A link on the error page. */
|
|
21
|
+
type SiteErrorLink = {
|
|
22
|
+
label: string;
|
|
23
|
+
href: string;
|
|
24
|
+
};
|
|
25
|
+
/** What a storefront's error page shows, for the template to style. */
|
|
26
|
+
type SiteError = SiteErrorCopy & {
|
|
27
|
+
kind: SiteErrorKind;
|
|
28
|
+
/** The HTTP status the page stands for: 404 or 410 for `not-found`, 500 for `went-wrong`. */
|
|
29
|
+
status: number;
|
|
30
|
+
/** Load the page again. Only `went-wrong` has it. */
|
|
31
|
+
retry?: SiteErrorLink;
|
|
32
|
+
home: SiteErrorLink;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Turn what a route threw into the page a storefront shows: which page it is, a safe heading and message, Try again
|
|
36
|
+
* and a link home. A thrown 404 or 410, such as React Router's `isRouteErrorResponse` with that status, is
|
|
37
|
+
* `not-found`. Anything else is `went-wrong`. The thrown error's own message is never shown.
|
|
38
|
+
*
|
|
39
|
+
* @param error - What the route threw, such as React Router's `useRouteError()`.
|
|
40
|
+
* @param options - The address to reload, the home page and your own words.
|
|
41
|
+
*/
|
|
42
|
+
declare function siteError(error: unknown, { url, home, copy }?: SiteErrorOptions): SiteError;
|
|
43
|
+
|
|
44
|
+
export { siteError };
|
|
45
|
+
export type { SiteError, SiteErrorCopy, SiteErrorKind, SiteErrorLink, SiteErrorOptions };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/site-error/index.ts
|
|
2
|
+
var COPY = {
|
|
3
|
+
"not-found": {
|
|
4
|
+
title: "Page not found",
|
|
5
|
+
message: "This page doesn't exist or has moved."
|
|
6
|
+
},
|
|
7
|
+
"went-wrong": {
|
|
8
|
+
title: "Something went wrong",
|
|
9
|
+
message: "This page didn't load. Try again in a moment."
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
function siteError(error, { url, home = "/", copy } = {}) {
|
|
13
|
+
const thrown = error?.status;
|
|
14
|
+
const kind = thrown === 404 || thrown === 410 ? "not-found" : "went-wrong";
|
|
15
|
+
const location = globalThis.location;
|
|
16
|
+
return {
|
|
17
|
+
kind,
|
|
18
|
+
status: kind === "not-found" ? thrown : 500,
|
|
19
|
+
...COPY[kind],
|
|
20
|
+
...copy?.[kind],
|
|
21
|
+
...kind === "went-wrong" ? {
|
|
22
|
+
retry: {
|
|
23
|
+
label: "Try again",
|
|
24
|
+
href: url ?? (location ? location.pathname + location.search : home)
|
|
25
|
+
}
|
|
26
|
+
} : {},
|
|
27
|
+
home: { label: "Go to the home page", href: home }
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
siteError
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/site-error/index.ts"],
|
|
4
|
+
"mappings": ";AAgCA,IAAM,OAA6C;AAAA,EACjD,aAAa;AAAA,IACX,OAAO;AAAA,IACP,SAAS;AAAA,EACX;AAAA,EACA,cAAc;AAAA,IACZ,OAAO;AAAA,IACP,SAAS;AAAA,EACX;AACF;AAUO,SAAS,UACd,OACA,EAAE,KAAK,OAAO,KAAK,KAAK,IAAsB,CAAC,GACpC;AACX,QAAM,SAAU,OAAuC;AACvD,QAAM,OACJ,WAAW,OAAO,WAAW,MAAM,cAAc;AACnD,QAAM,WAAW,WAAW;AAC5B,SAAO;AAAA,IACL;AAAA,IACA,QAAQ,SAAS,cAAe,SAAoB;AAAA,IACpD,GAAG,KAAK,IAAI;AAAA,IACZ,GAAG,OAAO,IAAI;AAAA,IACd,GAAI,SAAS,eACT;AAAA,MACE,OAAO;AAAA,QACL,OAAO;AAAA,QACP,MACE,QAAQ,WAAW,SAAS,WAAW,SAAS,SAAS;AAAA,MAC7D;AAAA,IACF,IACA,CAAC;AAAA,IACL,MAAM,EAAE,OAAO,uBAAuB,MAAM,KAAK;AAAA,EACnD;AACF;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SiteErrorOptions, SiteError } from '@zappie/sdk/site-error';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/** Props for `SiteErrorPage`. */
|
|
5
|
+
type SiteErrorPageProps = SiteErrorOptions & {
|
|
6
|
+
/** What the route threw, such as React Router's `useRouteError()`. */
|
|
7
|
+
error: unknown;
|
|
8
|
+
/** Draw the page in your own look from what `siteError` gives. */
|
|
9
|
+
children: (page: SiteError) => ReactNode;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Your storefront's own 404 and error page. It adds no markup or styles: it picks the page for `error` and hands you
|
|
13
|
+
* its kind, a safe heading and message, Try again and the home link. Render it from your root error boundary.
|
|
14
|
+
*/
|
|
15
|
+
declare function SiteErrorPage({ error, children, ...options }: SiteErrorPageProps): ReactNode;
|
|
16
|
+
|
|
17
|
+
export { SiteErrorPage };
|
|
18
|
+
export type { SiteErrorPageProps };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/site-error/react.tsx
|
|
2
|
+
import {
|
|
3
|
+
siteError
|
|
4
|
+
} from "@zappie/sdk/site-error";
|
|
5
|
+
function SiteErrorPage({
|
|
6
|
+
error,
|
|
7
|
+
children,
|
|
8
|
+
...options
|
|
9
|
+
}) {
|
|
10
|
+
return children(siteError(error, options));
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
SiteErrorPage
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=react.js.map
|
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-C47e44tl.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-ooHA0lwH.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-
|
|
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-C47e44tl.js';
|
|
2
2
|
import '../models-asoc6fS3.js';
|
|
3
|
-
import '../types-
|
|
3
|
+
import '../types-ooHA0lwH.js';
|
|
@@ -69,6 +69,8 @@ type CartFulfilment = {
|
|
|
69
69
|
type: "dine_in";
|
|
70
70
|
branchId: string;
|
|
71
71
|
table?: string;
|
|
72
|
+
/** The table the guest scanned. It stays with the saved cart. Quotes price the cart at its branch. */
|
|
73
|
+
payPointId?: string;
|
|
72
74
|
};
|
|
73
75
|
/**
|
|
74
76
|
* Stable identifiers for cart validation and quote issues you can handle in your UI.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zappie/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Typed, framework-agnostic client for Zappie menus, carts, checkout, auth and events.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -81,6 +81,14 @@
|
|
|
81
81
|
"types": "./dist/customer/react.d.ts",
|
|
82
82
|
"import": "./dist/customer/react.js"
|
|
83
83
|
},
|
|
84
|
+
"./in-venue": {
|
|
85
|
+
"types": "./dist/in-venue/index.d.ts",
|
|
86
|
+
"import": "./dist/in-venue/index.js"
|
|
87
|
+
},
|
|
88
|
+
"./in-venue/react": {
|
|
89
|
+
"types": "./dist/in-venue/react.d.ts",
|
|
90
|
+
"import": "./dist/in-venue/react.js"
|
|
91
|
+
},
|
|
84
92
|
"./account": {
|
|
85
93
|
"types": "./dist/account/index.d.ts",
|
|
86
94
|
"import": "./dist/account/index.js"
|
|
@@ -117,6 +125,26 @@
|
|
|
117
125
|
"types": "./dist/uploads/index.d.ts",
|
|
118
126
|
"import": "./dist/uploads/index.js"
|
|
119
127
|
},
|
|
128
|
+
"./error-pages": {
|
|
129
|
+
"types": "./dist/error-pages/index.d.ts",
|
|
130
|
+
"import": "./dist/error-pages/index.js"
|
|
131
|
+
},
|
|
132
|
+
"./error-pages/react": {
|
|
133
|
+
"types": "./dist/error-pages/react.d.ts",
|
|
134
|
+
"import": "./dist/error-pages/react.js"
|
|
135
|
+
},
|
|
136
|
+
"./site-error": {
|
|
137
|
+
"types": "./dist/site-error/index.d.ts",
|
|
138
|
+
"import": "./dist/site-error/index.js"
|
|
139
|
+
},
|
|
140
|
+
"./site-error/react": {
|
|
141
|
+
"types": "./dist/site-error/react.d.ts",
|
|
142
|
+
"import": "./dist/site-error/react.js"
|
|
143
|
+
},
|
|
144
|
+
"./receipts": {
|
|
145
|
+
"types": "./dist/receipts/index.d.ts",
|
|
146
|
+
"import": "./dist/receipts/index.js"
|
|
147
|
+
},
|
|
120
148
|
"./template/react": {
|
|
121
149
|
"types": "./dist/template/react.d.ts",
|
|
122
150
|
"import": "./dist/template/react.js"
|
|
@@ -176,7 +204,7 @@
|
|
|
176
204
|
"vite": "8.3.5"
|
|
177
205
|
},
|
|
178
206
|
"scripts": {
|
|
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",
|
|
207
|
+
"build": "tsup && tsup --config tsup.checkout.config.ts && tsup --config tsup.checkout-defaults.config.ts && tsup --config tsup.customer.config.ts && tsup --config tsup.in-venue.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 && tsup --config tsup.error-pages.config.ts && tsup --config tsup.site-error.config.ts && tsup --config 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",
|
|
180
208
|
"test": "vitest run --root ../.. packages/sdk/test",
|
|
181
209
|
"size": "node ../../scripts/release-packages/size-sdk.mjs && size-limit"
|
|
182
210
|
}
|