@zappie/sdk 0.1.6 → 0.1.7
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 +7 -0
- package/README.md +21 -1
- package/dist/cart/branch.d.ts +2 -2
- package/dist/cart/item.d.ts +3 -3
- package/dist/cart/quote.d.ts +3 -3
- package/dist/{client-Bm2cCYea.d.ts → client-iVMHfAFn.d.ts} +2 -2
- package/dist/debug.d.ts +3 -3
- package/dist/debug.js +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/dist/integrations/index.d.ts +9 -6
- package/dist/integrations/index.js +1 -0
- package/dist/integrations/index.js.map +2 -2
- package/dist/internal.d.ts +3 -3
- package/dist/{models-Rg5kQUkv.d.ts → models-D__QbqEd.d.ts} +14 -1
- package/dist/persist/catalogue.d.ts +3 -3
- package/dist/react/index.d.ts +3 -3
- package/dist/server/index.d.ts +7 -4
- package/dist/server/storefront-url/build-v1.js +8 -17
- package/dist/server/storefront-url/build-v1.js.map +2 -2
- package/dist/server/storefront-url/build-v2.js +13 -41
- package/dist/server/storefront-url/build-v2.js.map +2 -2
- package/dist/server/storefront-url/canonical.js +36 -0
- package/dist/server/storefront-url/canonical.js.map +7 -0
- package/dist/server/storefront-url/contract.js +2 -2
- package/dist/server/storefront-url/contract.js.map +2 -2
- package/dist/server/storefront-url/params.js +35 -18
- package/dist/server/storefront-url/params.js.map +2 -2
- package/dist/server/storefront-url/parse-v1.js +15 -12
- package/dist/server/storefront-url/parse-v1.js.map +2 -2
- package/dist/server/storefront-url/parse-v2.js +17 -79
- package/dist/server/storefront-url/parse-v2.js.map +2 -2
- package/dist/server/storefront-url/public-id.js +8 -0
- package/dist/server/storefront-url/public-id.js.map +7 -0
- package/dist/server/storefront-url/redirect.js +20 -6
- package/dist/server/storefront-url/redirect.js.map +2 -2
- package/dist/server/storefront-url/sign-in.js +2 -1
- package/dist/server/storefront-url/sign-in.js.map +2 -2
- package/dist/server/storefront-url/types.js +1 -0
- package/dist/server/storefront-url/types.js.map +2 -2
- package/dist/server/storefront-url/url.js +34 -23
- package/dist/server/storefront-url/url.js.map +2 -2
- package/dist/testing/index.d.ts +3 -3
- package/dist/transport/category-page.d.ts +2 -2
- package/dist/transport/category-page.js +6 -2
- package/dist/transport/category-page.js.map +2 -2
- package/dist/transport/presentation.d.ts +7 -0
- package/dist/transport/presentation.js +68 -0
- package/dist/transport/presentation.js.map +7 -0
- package/dist/transport/rest.js +15 -3
- package/dist/transport/rest.js.map +2 -2
- package/dist/transport/search.d.ts +3 -3
- package/dist/transport/search.js +6 -1
- package/dist/transport/search.js.map +2 -2
- package/dist/transport/selected-menu.d.ts +3 -3
- package/dist/transport/selected-menu.js +7 -2
- package/dist/transport/selected-menu.js.map +2 -2
- package/dist/transport/store.d.ts +1 -2
- package/dist/transport/store.js.map +1 -1
- package/dist/{types-CuDvfW9g.d.ts → types-B-iTMrVV.d.ts} +1 -1
- package/dist/url/index.d.ts +4 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @zappie/sdk
|
|
2
2
|
|
|
3
|
+
## 0.1.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4bfb1b2: Read the optional Maps browser key from storefront integrations. Map legacy URLs to public item, menu, category and order IDs, preserve attribution parameters.
|
|
8
|
+
- 666ba1c: Read selected-menu coverage from `menu_ids`. Expose menu layout and availability, separate plain-text and HTML banners, branch promotions, and order-ahead days. Preserve omitted descriptions and phone numbers as absent fields.
|
|
9
|
+
|
|
3
10
|
## 0.1.6
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ Prices always come from Zappie. The cart shows a local estimate while it waits,
|
|
|
56
56
|
| `@zappie/sdk/react` | `ZappieProvider` and hooks such as `useStore`, `useMenu` and `useCart` |
|
|
57
57
|
| `@zappie/sdk/checkout` | Opening Zappie's hosted checkout and checking it completed |
|
|
58
58
|
| `@zappie/sdk/customer` and `/customer/react` | Signed-in customers, their orders and saved addresses |
|
|
59
|
-
| `@zappie/sdk/integrations` | Public
|
|
59
|
+
| `@zappie/sdk/integrations` | Public integration IDs and browser keys |
|
|
60
60
|
| `@zappie/sdk/places` | Address search and delivery-zone checks |
|
|
61
61
|
| `@zappie/sdk/server` | Server-side reads, storefront URLs and `verifyWebhook()` |
|
|
62
62
|
| `@zappie/sdk/template` and `/template/react` | Template settings and responsive images for template authors |
|
|
@@ -79,3 +79,23 @@ The SDK is at `0.x`. Its API can change in a minor release while it settles. Eac
|
|
|
79
79
|
## License
|
|
80
80
|
|
|
81
81
|
MIT
|
|
82
|
+
|
|
83
|
+
### Maps browser key
|
|
84
|
+
|
|
85
|
+
`createIntegrations().get()` from `@zappie/sdk/integrations` returns optional
|
|
86
|
+
`googleMaps: { browserKey: string }`. The REST field is
|
|
87
|
+
`google_maps: { browser_key: string } | null`. An absent or null field returns
|
|
88
|
+
`googleMaps: undefined`, so apps can use this before the API field is deployed.
|
|
89
|
+
The SDK does not load Maps scripts.
|
|
90
|
+
|
|
91
|
+
### Legacy redirects
|
|
92
|
+
|
|
93
|
+
`storefrontRedirect(input, { installation })` from `@zappie/sdk/url` returns
|
|
94
|
+
`string | null`. Callers choose the HTTP status when they serve the redirect.
|
|
95
|
+
Zappie's templates use temporary redirects (302) for now.
|
|
96
|
+
|
|
97
|
+
V2 URLs use `item_` and `ord_` public IDs, `menu=menu_<id>`, and category
|
|
98
|
+
anchors `#c-cat_<id>`. Already-prefixed IDs stay unchanged. Legacy cart,
|
|
99
|
+
checkout and sign-in overlays become routes. Unsupported legacy UI parameters
|
|
100
|
+
are dropped. Ad click IDs, `ref`, and every `utm_*` parameter retain their values.
|
|
101
|
+
Payment-return and printed QR routes retain their existing parameters.
|
package/dist/cart/branch.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as Money, I as Item, a as Menu } from '../models-
|
|
2
|
-
import { C as CartLine } from '../types-
|
|
1
|
+
import { M as Money, I as Item, a as Menu } from '../models-D__QbqEd.js';
|
|
2
|
+
import { C as CartLine } from '../types-B-iTMrVV.js';
|
|
3
3
|
|
|
4
4
|
/** A line that can move to the destination branch, with its old and new estimates. */
|
|
5
5
|
type BranchSwitchKeptLine = {
|
package/dist/cart/item.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Z as Zappie } from '../client-
|
|
2
|
-
import { I as Item } from '../models-
|
|
3
|
-
import '../types-
|
|
1
|
+
import { Z as Zappie } from '../client-iVMHfAFn.js';
|
|
2
|
+
import { I as Item } from '../models-D__QbqEd.js';
|
|
3
|
+
import '../types-B-iTMrVV.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,6 +1,6 @@
|
|
|
1
|
-
import { T as Transport, R as RequestCtx } from '../client-
|
|
2
|
-
import { Q as QuoteRequest, a as Quote } from '../types-
|
|
3
|
-
import '../models-
|
|
1
|
+
import { T as Transport, R as RequestCtx } from '../client-iVMHfAFn.js';
|
|
2
|
+
import { Q as QuoteRequest, a as Quote } from '../types-B-iTMrVV.js';
|
|
3
|
+
import '../models-D__QbqEd.js';
|
|
4
4
|
|
|
5
5
|
type QuoteClientOptions = {
|
|
6
6
|
customerBase?: string | undefined;
|
|
@@ -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, g as WireQuote, i 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-D__QbqEd.js';
|
|
2
|
+
import { Q as QuoteRequest, g as WireQuote, i as CartIssueCode, d as CartModule, b as CartLineInput } from './types-B-iTMrVV.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The store, branch, order context and source menu that identify a saved catalogue.
|
package/dist/debug.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { b as CartLineInput, a as Quote } from './types-
|
|
2
|
-
import { M as Money, a as Menu, B as Branch } from './models-
|
|
3
|
-
import { Z as Zappie } from './client-
|
|
1
|
+
import { b as CartLineInput, a as Quote } from './types-B-iTMrVV.js';
|
|
2
|
+
import { M as Money, a as Menu, B as Branch } from './models-D__QbqEd.js';
|
|
3
|
+
import { Z as Zappie } from './client-iVMHfAFn.js';
|
|
4
4
|
|
|
5
5
|
type StoredLine = CartLineInput & {
|
|
6
6
|
id: string;
|
package/dist/debug.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
5
|
-
import { Q as QuoteRequest, g as WireQuote, f as CartIssue, b as CartLineInput, C as CartLine } from './types-
|
|
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-
|
|
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-iVMHfAFn.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-iVMHfAFn.js';
|
|
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-D__QbqEd.js';
|
|
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-D__QbqEd.js';
|
|
5
|
+
import { Q as QuoteRequest, g as WireQuote, f as CartIssue, b as CartLineInput, C as CartLine } from './types-B-iTMrVV.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-B-iTMrVV.js';
|
|
7
7
|
|
|
8
8
|
/** REST connection options. A custom fetch can provide tracing or mock responses. */
|
|
9
9
|
type RestTransportOptions = {
|
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.7" : "0.0.0-development";
|
|
14
14
|
export {
|
|
15
15
|
API_VERSION,
|
|
16
16
|
RestTransport,
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { R as RequestCtx } from '../client-
|
|
2
|
-
import '../models-
|
|
3
|
-
import '../types-
|
|
1
|
+
import { R as RequestCtx } from '../client-iVMHfAFn.js';
|
|
2
|
+
import '../models-D__QbqEd.js';
|
|
3
|
+
import '../types-B-iTMrVV.js';
|
|
4
4
|
|
|
5
|
-
/** Public
|
|
5
|
+
/** Public integration IDs and browser keys. Your app decides when to load scripts. */
|
|
6
6
|
type Integrations = {
|
|
7
|
+
googleMaps?: {
|
|
8
|
+
browserKey: string;
|
|
9
|
+
};
|
|
7
10
|
googleAnalytics?: {
|
|
8
11
|
measurementId: string;
|
|
9
12
|
};
|
|
@@ -11,7 +14,7 @@ type Integrations = {
|
|
|
11
14
|
pixelId: string;
|
|
12
15
|
};
|
|
13
16
|
};
|
|
14
|
-
/** A backend that supplies public
|
|
17
|
+
/** A backend that supplies public integration IDs and browser keys without loading scripts. */
|
|
15
18
|
type IntegrationsTransport = {
|
|
16
19
|
getIntegrations(ctx: RequestCtx): Promise<Integrations>;
|
|
17
20
|
};
|
|
@@ -24,7 +27,7 @@ type IntegrationsOptions = {
|
|
|
24
27
|
transport?: IntegrationsTransport;
|
|
25
28
|
};
|
|
26
29
|
/**
|
|
27
|
-
* Create a client that reads public
|
|
30
|
+
* Create a client that reads public integration IDs and browser keys. It never loads tracking scripts.
|
|
28
31
|
* Import this entry when your app needs the IDs, then apply your consent policy.
|
|
29
32
|
*/
|
|
30
33
|
declare function createIntegrations(options: IntegrationsOptions): {
|
|
@@ -62,6 +62,7 @@ function createIntegrations(options) {
|
|
|
62
62
|
return result;
|
|
63
63
|
};
|
|
64
64
|
return {
|
|
65
|
+
...raw.google_maps != null ? { googleMaps: { browserKey: id(raw.google_maps, "browser_key") } } : {},
|
|
65
66
|
...raw.google_analytics != null ? {
|
|
66
67
|
googleAnalytics: {
|
|
67
68
|
measurementId: id(raw.google_analytics, "measurement_id")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/integrations/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { requestWithRetry } from \"../internal/customer-http\";\nimport {\n API_VERSION,\n RestTransport,\n validateConfig,\n ZappieError,\n} from \"../places/sdk\";\nimport type { RequestCtx } from \"../transport/types\";\n\n/** Public
|
|
5
|
-
"mappings": ";AAAA,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;
|
|
4
|
+
"sourcesContent": ["import { requestWithRetry } from \"../internal/customer-http\";\nimport {\n API_VERSION,\n RestTransport,\n validateConfig,\n ZappieError,\n} from \"../places/sdk\";\nimport type { RequestCtx } from \"../transport/types\";\n\n/** Public integration IDs and browser keys. Your app decides when to load scripts. */\nexport type Integrations = {\n googleMaps?: { browserKey: string };\n googleAnalytics?: { measurementId: string };\n metaPixel?: { pixelId: string };\n};\n\n/** A backend that supplies public integration IDs and browser keys without loading scripts. */\nexport type IntegrationsTransport = {\n getIntegrations(ctx: RequestCtx): Promise<Integrations>;\n};\n\n/** Credentials and optional connection settings for the integrations read. */\nexport type IntegrationsOptions = {\n key: string;\n baseUrl?: string;\n version?: string;\n fetch?: typeof fetch;\n transport?: IntegrationsTransport;\n};\n\n/**\n * Create a client that reads public integration IDs and browser keys. It never loads tracking scripts.\n * Import this entry when your app needs the IDs, then apply your consent policy.\n */\nexport function createIntegrations(options: IntegrationsOptions) {\n validateConfig({ store: \"integrations\", key: options.key });\n const base = new RestTransport(options).baseUrl;\n return {\n /** Read enabled integrations. An absent integration has no public ID to use. */\n async get(read: { signal?: AbortSignal } = {}): Promise<Integrations> {\n const ctx = {\n key: options.key,\n version: options.version ?? API_VERSION,\n ...read,\n };\n if (options.transport) {\n return options.transport.getIntegrations(ctx);\n }\n const response = await requestWithRetry(\n options.fetch ?? ((input, init) => globalThis.fetch(input, init)),\n `${base}/store/integrations`,\n {\n redirect: \"manual\",\n headers: {\n Authorization: `Bearer ${ctx.key}`,\n \"Zappie-Version\": ctx.version,\n },\n ...read,\n },\n \"Could not read storefront integrations\",\n );\n if (!response.ok) {\n throw new ZappieError(\n \"server_error\",\n \"Could not read storefront integrations\",\n { status: response.status },\n );\n }\n const value: unknown = await response.json();\n const record = (value: unknown): Record<string, unknown> => {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n throw new ZappieError(\n \"server_error\",\n \"Invalid storefront integrations\",\n );\n }\n return value as Record<string, unknown>;\n };\n const raw = record(value);\n const id = (value: unknown, key: string): string => {\n const result = record(value)[key];\n if (typeof result !== \"string\" || !result) {\n throw new ZappieError(\n \"server_error\",\n \"Invalid storefront integration ID\",\n );\n }\n return result;\n };\n return {\n ...(raw.google_maps != null\n ? { googleMaps: { browserKey: id(raw.google_maps, \"browser_key\") } }\n : {}),\n ...(raw.google_analytics != null\n ? {\n googleAnalytics: {\n measurementId: id(raw.google_analytics, \"measurement_id\"),\n },\n }\n : {}),\n ...(raw.meta_pixel != null\n ? { metaPixel: { pixelId: id(raw.meta_pixel, \"pixel_id\") } }\n : {}),\n };\n },\n };\n}\n\n/** The integrations read returned by createIntegrations. */\nexport type IntegrationsClient = ReturnType<typeof createIntegrations>;\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA4BA,SAAS,mBAAmB,SAA8B;AAC/D,iBAAe,EAAE,OAAO,gBAAgB,KAAK,QAAQ,IAAI,CAAC;AAC1D,QAAM,OAAO,IAAI,cAAc,OAAO,EAAE;AACxC,SAAO;AAAA;AAAA,IAEL,MAAM,IAAI,OAAiC,CAAC,GAA0B;AACpE,YAAM,MAAM;AAAA,QACV,KAAK,QAAQ;AAAA,QACb,SAAS,QAAQ,WAAW;AAAA,QAC5B,GAAG;AAAA,MACL;AACA,UAAI,QAAQ,WAAW;AACrB,eAAO,QAAQ,UAAU,gBAAgB,GAAG;AAAA,MAC9C;AACA,YAAM,WAAW,MAAM;AAAA,QACrB,QAAQ,UAAU,CAAC,OAAO,SAAS,WAAW,MAAM,OAAO,IAAI;AAAA,QAC/D,GAAG,IAAI;AAAA,QACP;AAAA,UACE,UAAU;AAAA,UACV,SAAS;AAAA,YACP,eAAe,UAAU,IAAI,GAAG;AAAA,YAChC,kBAAkB,IAAI;AAAA,UACxB;AAAA,UACA,GAAG;AAAA,QACL;AAAA,QACA;AAAA,MACF;AACA,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,IAAI;AAAA,UACR;AAAA,UACA;AAAA,UACA,EAAE,QAAQ,SAAS,OAAO;AAAA,QAC5B;AAAA,MACF;AACA,YAAM,QAAiB,MAAM,SAAS,KAAK;AAC3C,YAAM,SAAS,CAACA,WAA4C;AAC1D,YAAI,CAACA,UAAS,OAAOA,WAAU,YAAY,MAAM,QAAQA,MAAK,GAAG;AAC/D,gBAAM,IAAI;AAAA,YACR;AAAA,YACA;AAAA,UACF;AAAA,QACF;AACA,eAAOA;AAAA,MACT;AACA,YAAM,MAAM,OAAO,KAAK;AACxB,YAAM,KAAK,CAACA,QAAgB,QAAwB;AAClD,cAAM,SAAS,OAAOA,MAAK,EAAE,GAAG;AAChC,YAAI,OAAO,WAAW,YAAY,CAAC,QAAQ;AACzC,gBAAM,IAAI;AAAA,YACR;AAAA,YACA;AAAA,UACF;AAAA,QACF;AACA,eAAO;AAAA,MACT;AACA,aAAO;AAAA,QACL,GAAI,IAAI,eAAe,OACnB,EAAE,YAAY,EAAE,YAAY,GAAG,IAAI,aAAa,aAAa,EAAE,EAAE,IACjE,CAAC;AAAA,QACL,GAAI,IAAI,oBAAoB,OACxB;AAAA,UACE,iBAAiB;AAAA,YACf,eAAe,GAAG,IAAI,kBAAkB,gBAAgB;AAAA,UAC1D;AAAA,QACF,IACA,CAAC;AAAA,QACL,GAAI,IAAI,cAAc,OAClB,EAAE,WAAW,EAAE,SAAS,GAAG,IAAI,YAAY,UAAU,EAAE,EAAE,IACzD,CAAC;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["value"]
|
|
7
7
|
}
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as CartFulfilment, W as WireFulfilment } from './types-
|
|
2
|
-
export { v as validateConfig } from './client-
|
|
3
|
-
import './models-
|
|
1
|
+
import { c as CartFulfilment, W as WireFulfilment } from './types-B-iTMrVV.js';
|
|
2
|
+
export { v as validateConfig } from './client-iVMHfAFn.js';
|
|
3
|
+
import './models-D__QbqEd.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Convert a cart fulfilment selection to the API field names used by quotes and checkout.
|
|
@@ -74,6 +74,14 @@ type Branch = {
|
|
|
74
74
|
lng: number;
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
|
+
/** Automatic promotions to display. The quote decides whether an order qualifies. */
|
|
78
|
+
promos?: {
|
|
79
|
+
id: string;
|
|
80
|
+
name: string;
|
|
81
|
+
description: string;
|
|
82
|
+
}[];
|
|
83
|
+
/** How many days ahead this branch accepts scheduled orders. */
|
|
84
|
+
orderAheadDays?: number;
|
|
77
85
|
socialLinks?: {
|
|
78
86
|
type: string;
|
|
79
87
|
url: string;
|
|
@@ -135,8 +143,13 @@ type MenuSection = {
|
|
|
135
143
|
id: string;
|
|
136
144
|
name: string;
|
|
137
145
|
categoryIds: string[];
|
|
138
|
-
|
|
146
|
+
layout?: "LIST" | "GRID" | "CARD";
|
|
147
|
+
/** Whether this menu is available now at the selected branch. */
|
|
148
|
+
isActive?: boolean;
|
|
149
|
+
/** Plain-text merchant banner. */
|
|
139
150
|
infoBanner?: string;
|
|
151
|
+
/** Sanitized rich-text banner supplied by the service. */
|
|
152
|
+
infoBannerHtml?: string;
|
|
140
153
|
schedule?: MenuSchedule;
|
|
141
154
|
};
|
|
142
155
|
/** A branch catalogue that stores each item once across categories. */
|
|
@@ -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-iVMHfAFn.js';
|
|
2
|
+
import '../models-D__QbqEd.js';
|
|
3
|
+
import '../types-B-iTMrVV.js';
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { VERSION } from '../index.js';
|
|
2
|
-
import { I as Item, a as Menu, S as Store, M as Money } from '../models-
|
|
3
|
-
import { a as ZappieError, Z as Zappie } from '../client-
|
|
2
|
+
import { I as Item, a as Menu, S as Store, M as Money } from '../models-D__QbqEd.js';
|
|
3
|
+
import { a as ZappieError, Z as Zappie } from '../client-iVMHfAFn.js';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
|
-
import { d as CartModule, C as CartLine, c as CartFulfilment, e as CartState, f as CartIssue } from '../types-
|
|
6
|
+
import { d as CartModule, C as CartLine, c as CartFulfilment, e as CartState, f as CartIssue } from '../types-B-iTMrVV.js';
|
|
7
7
|
|
|
8
8
|
/** Subscribe to storefront identity and branch-directory data. */
|
|
9
9
|
declare function useStore(): {
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as Menu, F as Formatters, S as Store } from '../models-
|
|
2
|
-
import { a as ZappieError, b as ZappieConfig, T as Transport, S as StorageLike, c as StoreResource, M as MenuResource, d as ZappieEvents, C as Cache } from '../client-
|
|
1
|
+
import { a as Menu, F as Formatters, S as Store } from '../models-D__QbqEd.js';
|
|
2
|
+
import { a as ZappieError, b as ZappieConfig, T as Transport, S as StorageLike, c as StoreResource, M as MenuResource, d as ZappieEvents, C as Cache } from '../client-iVMHfAFn.js';
|
|
3
3
|
export { VERSION } from '../index.js';
|
|
4
|
-
import { d as CartModule, b as CartLineInput } from '../types-
|
|
4
|
+
import { d as CartModule, b as CartLineInput } from '../types-B-iTMrVV.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* A URL string, URL object or Request you can parse as a storefront route.
|
|
@@ -28,7 +28,7 @@ declare const STOREFRONT_V1_QUERY_PARAMETERS: readonly ["ref", "utm_source", "pa
|
|
|
28
28
|
/**
|
|
29
29
|
* Recognized storefront query keys, including the v1 keys and checkout return and session keys.
|
|
30
30
|
*/
|
|
31
|
-
declare const STOREFRONT_QUERY_PARAMETERS: readonly ["ref", "utm_source", "payment_id", "context", "prefetch", "business_tag", "pay_point_id", "dine_in_order_id", "no_context", "payment_context_id", "ws", "preview", "device", "auto_scroll", "pickup", "branch_closed", "order_id", "modal_id", "lightbox", "menu_id", "payment_method", "beacon_id", "menu_group_id", "category_id", "menu_layout", "can_schedule", "refresh", "success", "grant", "portal", "can_download_receipt", "auth_modal_id", "experimental_otp", "branch", "business", "env", "switched_branch", "from", "template", "catalog_rendering", "catalogue_search", "catalogue_categories", "return", "session"];
|
|
31
|
+
declare const STOREFRONT_QUERY_PARAMETERS: readonly ["ref", "utm_source", "payment_id", "context", "prefetch", "business_tag", "pay_point_id", "dine_in_order_id", "no_context", "payment_context_id", "ws", "preview", "device", "auto_scroll", "pickup", "branch_closed", "order_id", "modal_id", "lightbox", "menu_id", "payment_method", "beacon_id", "menu_group_id", "category_id", "menu_layout", "can_schedule", "refresh", "success", "grant", "portal", "can_download_receipt", "auth_modal_id", "experimental_otp", "branch", "business", "env", "switched_branch", "from", "template", "catalog_rendering", "catalogue_search", "catalogue_categories", "menu", "return", "session"];
|
|
32
32
|
/**
|
|
33
33
|
* Readonly query parameter names and string values carried by storefront page state.
|
|
34
34
|
*/
|
|
@@ -155,6 +155,9 @@ declare const parseStorefrontUrl: (input: StorefrontUrlInput, options?: Storefro
|
|
|
155
155
|
* Find the canonical v2 URL for a recognized storefront route.
|
|
156
156
|
* Compares normalized paths and sorted query parameters to avoid unnecessary redirects.
|
|
157
157
|
*
|
|
158
|
+
* Callers choose the HTTP status when serving the redirect.
|
|
159
|
+
* Zappie templates use temporary redirects (302) for now.
|
|
160
|
+
*
|
|
158
161
|
* @returns A redirect target, or null for v1, an unknown route, a parse/build failure or an equivalent URL.
|
|
159
162
|
*/
|
|
160
163
|
declare const storefrontRedirect: (input: StorefrontUrlInput, options?: StorefrontUrlOptions) => string | null;
|
|
@@ -21,20 +21,12 @@ var routePathV1 = (route, options = {}) => {
|
|
|
21
21
|
return `/order/${encode(route.business)}${route.branch ? `/${encode(route.branch)}` : ""}/pages/${encode(route.slug)}`;
|
|
22
22
|
case "dine-in":
|
|
23
23
|
return `/dine-in/${encode(route.order)}`;
|
|
24
|
-
case "dine-in-menus":
|
|
25
|
-
return "/dine-in/menus";
|
|
26
|
-
case "self-service-menus":
|
|
27
|
-
return "/self-service/menus";
|
|
28
24
|
case "pay-point":
|
|
29
25
|
return `/pay-point/${encode(route.payPoint)}`;
|
|
30
26
|
case "beacon":
|
|
31
27
|
return `/beacons/${encode(route.beacon)}`;
|
|
32
28
|
case "link":
|
|
33
29
|
return `/links/${encode(route.link)}`;
|
|
34
|
-
case "collect-payment":
|
|
35
|
-
return "/collect-payment";
|
|
36
|
-
case "reservation":
|
|
37
|
-
return "/reservation";
|
|
38
30
|
case "pay-session":
|
|
39
31
|
return `/pay/${encode(route.session)}`;
|
|
40
32
|
case "payment-step":
|
|
@@ -47,6 +39,13 @@ var routePathV1 = (route, options = {}) => {
|
|
|
47
39
|
return route.home ? "/" : "/explore";
|
|
48
40
|
case "unknown":
|
|
49
41
|
return route.pathname || "/";
|
|
42
|
+
case "dine-in-menus":
|
|
43
|
+
return "/dine-in/menus";
|
|
44
|
+
case "self-service-menus":
|
|
45
|
+
return "/self-service/menus";
|
|
46
|
+
case "collect-payment":
|
|
47
|
+
case "reservation":
|
|
48
|
+
return `/${route.type}`;
|
|
50
49
|
}
|
|
51
50
|
};
|
|
52
51
|
var buildV1 = (route, options = {}) => {
|
|
@@ -58,15 +57,7 @@ var buildV1 = (route, options = {}) => {
|
|
|
58
57
|
options.installation
|
|
59
58
|
);
|
|
60
59
|
const query = v1Params(route).toString();
|
|
61
|
-
|
|
62
|
-
if (!options.origin) {
|
|
63
|
-
return value;
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
return new URL(value, options.origin).toString();
|
|
67
|
-
} catch {
|
|
68
|
-
return value;
|
|
69
|
-
}
|
|
60
|
+
return `${pathname}${query ? `?${query}` : ""}`;
|
|
70
61
|
};
|
|
71
62
|
export {
|
|
72
63
|
buildV1,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/server/storefront-url/build-v1.ts"],
|
|
4
|
-
"sourcesContent": ["import { menuRoute } from \"./contract\";\nimport { publicInstallationPath } from \"./installation\";\nimport { v1Params } from \"./params\";\nimport { type StorefrontRoute, type StorefrontUrlOptions } from \"./types\";\nimport { encode } from \"./url\";\n\nexport const routePathV1 = (\n route: StorefrontRoute,\n options: StorefrontUrlOptions = {},\n): string => {\n switch (route.type) {\n case \"order-menu\":\n return `/order/${encode(route.business)}${route.branch ? `/${encode(route.branch)}` : \"\"}${route.cataloguePath ? \"/products\" : \"\"}`;\n case \"item\": {\n const branch = route.branch ?? options.installation?.defaultBranch;\n return branch\n ? `/order/${encode(route.business)}/${encode(branch)}/products/${encode(route.item)}`\n : `/order/${encode(route.business)}`;\n }\n case \"cart\":\n case \"checkout\":\n case \"checkout-return\":\n case \"sign-in\":\n return routePathV1(menuRoute(route), options);\n case \"content-page\":\n return `/order/${encode(route.business)}${route.branch ? `/${encode(route.branch)}` : \"\"}/pages/${encode(route.slug)}`;\n case \"dine-in\":\n return `/dine-in/${encode(route.order)}`;\n case \"
|
|
5
|
-
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,8BAA8B;AACvC,SAAS,gBAAgB;AACzB,OAAgE;AAChE,SAAS,cAAc;AAEhB,IAAM,cAAc,CACzB,OACA,UAAgC,CAAC,MACtB;AACX,UAAQ,MAAM,MAAM;AAAA,IAClB,KAAK;AACH,aAAO,UAAU,OAAO,MAAM,QAAQ,CAAC,GAAG,MAAM,SAAS,IAAI,OAAO,MAAM,MAAM,CAAC,KAAK,EAAE,GAAG,MAAM,gBAAgB,cAAc,EAAE;AAAA,IACnI,KAAK,QAAQ;AACX,YAAM,SAAS,MAAM,UAAU,QAAQ,cAAc;AACrD,aAAO,SACH,UAAU,OAAO,MAAM,QAAQ,CAAC,IAAI,OAAO,MAAM,CAAC,aAAa,OAAO,MAAM,IAAI,CAAC,KACjF,UAAU,OAAO,MAAM,QAAQ,CAAC;AAAA,IACtC;AAAA,IACA,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO,YAAY,UAAU,KAAK,GAAG,OAAO;AAAA,IAC9C,KAAK;AACH,aAAO,UAAU,OAAO,MAAM,QAAQ,CAAC,GAAG,MAAM,SAAS,IAAI,OAAO,MAAM,MAAM,CAAC,KAAK,EAAE,UAAU,OAAO,MAAM,IAAI,CAAC;AAAA,IACtH,KAAK;AACH,aAAO,YAAY,OAAO,MAAM,KAAK,CAAC;AAAA,IACxC,KAAK;AACH,aAAO
|
|
4
|
+
"sourcesContent": ["import { menuRoute } from \"./contract\";\nimport { publicInstallationPath } from \"./installation\";\nimport { v1Params } from \"./params\";\nimport { type StorefrontRoute, type StorefrontUrlOptions } from \"./types\";\nimport { encode } from \"./url\";\n\nexport const routePathV1 = (\n route: StorefrontRoute,\n options: StorefrontUrlOptions = {},\n): string => {\n switch (route.type) {\n case \"order-menu\":\n return `/order/${encode(route.business)}${route.branch ? `/${encode(route.branch)}` : \"\"}${route.cataloguePath ? \"/products\" : \"\"}`;\n case \"item\": {\n const branch = route.branch ?? options.installation?.defaultBranch;\n return branch\n ? `/order/${encode(route.business)}/${encode(branch)}/products/${encode(route.item)}`\n : `/order/${encode(route.business)}`;\n }\n case \"cart\":\n case \"checkout\":\n case \"checkout-return\":\n case \"sign-in\":\n return routePathV1(menuRoute(route), options);\n case \"content-page\":\n return `/order/${encode(route.business)}${route.branch ? `/${encode(route.branch)}` : \"\"}/pages/${encode(route.slug)}`;\n case \"dine-in\":\n return `/dine-in/${encode(route.order)}`;\n case \"pay-point\":\n return `/pay-point/${encode(route.payPoint)}`;\n case \"beacon\":\n return `/beacons/${encode(route.beacon)}`;\n case \"link\":\n return `/links/${encode(route.link)}`;\n case \"pay-session\":\n return `/pay/${encode(route.session)}`;\n case \"payment-step\":\n return `/payment/${encode(route.payment)}${route.step === \"payment\" ? \"\" : `/${route.step}`}`;\n case \"payment-card\":\n return `/payment/card/${encode(route.transaction)}`;\n case \"profile\":\n return `/profile/${route.page}${route.order ? `/${encode(route.order)}` : \"\"}`;\n case \"explore\":\n return route.home ? \"/\" : \"/explore\";\n case \"unknown\":\n return route.pathname || \"/\";\n case \"dine-in-menus\":\n return \"/dine-in/menus\";\n case \"self-service-menus\":\n return \"/self-service/menus\";\n case \"collect-payment\":\n case \"reservation\":\n return `/${route.type}`;\n }\n};\n\nexport const buildV1 = (\n route: StorefrontRoute,\n options: StorefrontUrlOptions = {},\n) => {\n const internal = routePathV1(route, options);\n const publicRoute =\n route.type === \"item\" &&\n route.branch === undefined &&\n options.installation?.defaultBranch\n ? { ...route, branch: options.installation.defaultBranch }\n : route;\n const pathname = publicInstallationPath(\n internal,\n publicRoute,\n options.installation,\n );\n const query = v1Params(route).toString();\n return `${pathname}${query ? `?${query}` : \"\"}`;\n};\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,8BAA8B;AACvC,SAAS,gBAAgB;AACzB,OAAgE;AAChE,SAAS,cAAc;AAEhB,IAAM,cAAc,CACzB,OACA,UAAgC,CAAC,MACtB;AACX,UAAQ,MAAM,MAAM;AAAA,IAClB,KAAK;AACH,aAAO,UAAU,OAAO,MAAM,QAAQ,CAAC,GAAG,MAAM,SAAS,IAAI,OAAO,MAAM,MAAM,CAAC,KAAK,EAAE,GAAG,MAAM,gBAAgB,cAAc,EAAE;AAAA,IACnI,KAAK,QAAQ;AACX,YAAM,SAAS,MAAM,UAAU,QAAQ,cAAc;AACrD,aAAO,SACH,UAAU,OAAO,MAAM,QAAQ,CAAC,IAAI,OAAO,MAAM,CAAC,aAAa,OAAO,MAAM,IAAI,CAAC,KACjF,UAAU,OAAO,MAAM,QAAQ,CAAC;AAAA,IACtC;AAAA,IACA,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO,YAAY,UAAU,KAAK,GAAG,OAAO;AAAA,IAC9C,KAAK;AACH,aAAO,UAAU,OAAO,MAAM,QAAQ,CAAC,GAAG,MAAM,SAAS,IAAI,OAAO,MAAM,MAAM,CAAC,KAAK,EAAE,UAAU,OAAO,MAAM,IAAI,CAAC;AAAA,IACtH,KAAK;AACH,aAAO,YAAY,OAAO,MAAM,KAAK,CAAC;AAAA,IACxC,KAAK;AACH,aAAO,cAAc,OAAO,MAAM,QAAQ,CAAC;AAAA,IAC7C,KAAK;AACH,aAAO,YAAY,OAAO,MAAM,MAAM,CAAC;AAAA,IACzC,KAAK;AACH,aAAO,UAAU,OAAO,MAAM,IAAI,CAAC;AAAA,IACrC,KAAK;AACH,aAAO,QAAQ,OAAO,MAAM,OAAO,CAAC;AAAA,IACtC,KAAK;AACH,aAAO,YAAY,OAAO,MAAM,OAAO,CAAC,GAAG,MAAM,SAAS,YAAY,KAAK,IAAI,MAAM,IAAI,EAAE;AAAA,IAC7F,KAAK;AACH,aAAO,iBAAiB,OAAO,MAAM,WAAW,CAAC;AAAA,IACnD,KAAK;AACH,aAAO,YAAY,MAAM,IAAI,GAAG,MAAM,QAAQ,IAAI,OAAO,MAAM,KAAK,CAAC,KAAK,EAAE;AAAA,IAC9E,KAAK;AACH,aAAO,MAAM,OAAO,MAAM;AAAA,IAC5B,KAAK;AACH,aAAO,MAAM,YAAY;AAAA,IAC3B,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO,IAAI,MAAM,IAAI;AAAA,EACzB;AACF;AAEO,IAAM,UAAU,CACrB,OACA,UAAgC,CAAC,MAC9B;AACH,QAAM,WAAW,YAAY,OAAO,OAAO;AAC3C,QAAM,cACJ,MAAM,SAAS,UACf,MAAM,WAAW,UACjB,QAAQ,cAAc,gBAClB,EAAE,GAAG,OAAO,QAAQ,QAAQ,aAAa,cAAc,IACvD;AACN,QAAM,WAAW;AAAA,IACf;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,EACV;AACA,QAAM,QAAQ,SAAS,KAAK,EAAE,SAAS;AACvC,SAAO,GAAG,QAAQ,GAAG,QAAQ,IAAI,KAAK,KAAK,EAAE;AAC/C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,39 +1,12 @@
|
|
|
1
1
|
// src/server/storefront-url/build-v2.ts
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { buildV1 } from "./build-v1.js";
|
|
3
|
+
import { canonicalRoute } from "./canonical.js";
|
|
4
4
|
import { v2Params } from "./params.js";
|
|
5
|
-
import {
|
|
6
|
-
import { encode
|
|
7
|
-
var canonicalRoute = (route, installation) => {
|
|
8
|
-
if (route.type !== "order-menu") {
|
|
9
|
-
return route;
|
|
10
|
-
}
|
|
11
|
-
const common = {
|
|
12
|
-
business: route.business,
|
|
13
|
-
...route.branch !== void 0 ? { branch: route.branch } : {},
|
|
14
|
-
state: route.state
|
|
15
|
-
};
|
|
16
|
-
if (route.state.authModalId && SIGN_IN_MODALS.has(route.state.authModalId)) {
|
|
17
|
-
return signInFromOverlay(route, installation);
|
|
18
|
-
}
|
|
19
|
-
if (route.state.modalId?.startsWith(ITEM_MODAL_PREFIX)) {
|
|
20
|
-
return {
|
|
21
|
-
type: "item",
|
|
22
|
-
...common,
|
|
23
|
-
item: route.state.modalId.slice(ITEM_MODAL_PREFIX.length)
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
if (route.state.modalId === CART_MODAL) {
|
|
27
|
-
return { type: "cart", ...common };
|
|
28
|
-
}
|
|
29
|
-
if (route.state.modalId === CHECKOUT_MODAL) {
|
|
30
|
-
return { type: "checkout", ...common };
|
|
31
|
-
}
|
|
32
|
-
return route;
|
|
33
|
-
};
|
|
5
|
+
import { categoryHash, publicId } from "./public-id.js";
|
|
6
|
+
import { encode } from "./url.js";
|
|
34
7
|
var profilePath = (route) => {
|
|
35
8
|
if (route.page === "orders") {
|
|
36
|
-
return `/orders${route.order ? `/${encode(route.order)}` : ""}`;
|
|
9
|
+
return `/orders${route.order ? `/${encode(publicId(route.order, "ord"))}` : ""}`;
|
|
37
10
|
}
|
|
38
11
|
if (route.page === "edit") {
|
|
39
12
|
return "/account";
|
|
@@ -41,12 +14,12 @@ var profilePath = (route) => {
|
|
|
41
14
|
const page = route.page === "add-store-credit" ? "store-credit" : route.page;
|
|
42
15
|
return `/account/${page}`;
|
|
43
16
|
};
|
|
44
|
-
var routePathV2 = (route
|
|
17
|
+
var routePathV2 = (route) => {
|
|
45
18
|
switch (route.type) {
|
|
46
19
|
case "order-menu":
|
|
47
20
|
return "/";
|
|
48
21
|
case "item":
|
|
49
|
-
return `/item/${encode(route.item)}`;
|
|
22
|
+
return `/item/${encode(publicId(route.item, "item"))}`;
|
|
50
23
|
case "cart":
|
|
51
24
|
return "/cart";
|
|
52
25
|
case "checkout":
|
|
@@ -59,19 +32,18 @@ var routePathV2 = (route, options) => {
|
|
|
59
32
|
return `/pages/${encode(route.slug)}`;
|
|
60
33
|
case "profile":
|
|
61
34
|
return profilePath(route);
|
|
62
|
-
default:
|
|
63
|
-
return routePathV1(route, options);
|
|
64
35
|
}
|
|
65
36
|
};
|
|
66
37
|
var buildV2 = (route, options) => {
|
|
67
38
|
const installation = options.installation;
|
|
68
|
-
if (!installation) {
|
|
69
|
-
return "";
|
|
70
|
-
}
|
|
71
39
|
const canonical = canonicalRoute(route, installation);
|
|
72
|
-
|
|
40
|
+
if (!("business" in canonical) && canonical.type !== "profile") {
|
|
41
|
+
return buildV1(canonical, options);
|
|
42
|
+
}
|
|
43
|
+
const pathname = routePathV2(canonical);
|
|
73
44
|
const query = v2Params(canonical, installation).toString();
|
|
74
|
-
|
|
45
|
+
const hash = categoryHash(canonical.state.categoryId);
|
|
46
|
+
return `${pathname}${query ? `?${query}` : ""}${hash}`;
|
|
75
47
|
};
|
|
76
48
|
export {
|
|
77
49
|
buildV2
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/server/storefront-url/build-v2.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { buildV1 } from \"./build-v1\";\nimport { canonicalRoute } from \"./canonical\";\nimport { v2Params } from \"./params\";\nimport { categoryHash, publicId } from \"./public-id\";\nimport type {\n StorefrontInstallation,\n StorefrontRoute,\n StorefrontUrlOptions,\n} from \"./types\";\nimport { encode } from \"./url\";\n\nconst profilePath = (route: Extract<StorefrontRoute, { type: \"profile\" }>) => {\n if (route.page === \"orders\") {\n return `/orders${route.order ? `/${encode(publicId(route.order, \"ord\"))}` : \"\"}`;\n }\n if (route.page === \"edit\") {\n return \"/account\";\n }\n const page = route.page === \"add-store-credit\" ? \"store-credit\" : route.page;\n return `/account/${page}`;\n};\n\nconst routePathV2 = (\n route: Extract<StorefrontRoute, { business: string } | { type: \"profile\" }>,\n) => {\n switch (route.type) {\n case \"order-menu\":\n return \"/\";\n case \"item\":\n return `/item/${encode(publicId(route.item, \"item\"))}`;\n case \"cart\":\n return \"/cart\";\n case \"checkout\":\n return \"/checkout\";\n case \"checkout-return\":\n return \"/checkout/return\";\n case \"sign-in\":\n return \"/sign-in\";\n case \"content-page\":\n return `/pages/${encode(route.slug)}`;\n case \"profile\":\n return profilePath(route);\n }\n};\n\nexport const buildV2 = (\n route: StorefrontRoute,\n options: StorefrontUrlOptions & { installation: StorefrontInstallation },\n) => {\n const installation = options.installation;\n const canonical = canonicalRoute(route, installation);\n if (!(\"business\" in canonical) && canonical.type !== \"profile\") {\n return buildV1(canonical, options);\n }\n const pathname = routePathV2(canonical);\n const query = v2Params(canonical, installation).toString();\n const hash = categoryHash(canonical.state.categoryId);\n return `${pathname}${query ? `?${query}` : \"\"}${hash}`;\n};\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,eAAe;AACxB,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AACzB,SAAS,cAAc,gBAAgB;AAMvC,SAAS,cAAc;AAEvB,IAAM,cAAc,CAAC,UAAyD;AAC5E,MAAI,MAAM,SAAS,UAAU;AAC3B,WAAO,UAAU,MAAM,QAAQ,IAAI,OAAO,SAAS,MAAM,OAAO,KAAK,CAAC,CAAC,KAAK,EAAE;AAAA,EAChF;AACA,MAAI,MAAM,SAAS,QAAQ;AACzB,WAAO;AAAA,EACT;AACA,QAAM,OAAO,MAAM,SAAS,qBAAqB,iBAAiB,MAAM;AACxE,SAAO,YAAY,IAAI;AACzB;AAEA,IAAM,cAAc,CAClB,UACG;AACH,UAAQ,MAAM,MAAM;AAAA,IAClB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,SAAS,OAAO,SAAS,MAAM,MAAM,MAAM,CAAC,CAAC;AAAA,IACtD,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,UAAU,OAAO,MAAM,IAAI,CAAC;AAAA,IACrC,KAAK;AACH,aAAO,YAAY,KAAK;AAAA,EAC5B;AACF;AAEO,IAAM,UAAU,CACrB,OACA,YACG;AACH,QAAM,eAAe,QAAQ;AAC7B,QAAM,YAAY,eAAe,OAAO,YAAY;AACpD,MAAI,EAAE,cAAc,cAAc,UAAU,SAAS,WAAW;AAC9D,WAAO,QAAQ,WAAW,OAAO;AAAA,EACnC;AACA,QAAM,WAAW,YAAY,SAAS;AACtC,QAAM,QAAQ,SAAS,WAAW,YAAY,EAAE,SAAS;AACzD,QAAM,OAAO,aAAa,UAAU,MAAM,UAAU;AACpD,SAAO,GAAG,QAAQ,GAAG,QAAQ,IAAI,KAAK,KAAK,EAAE,GAAG,IAAI;AACtD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/server/storefront-url/canonical.ts
|
|
2
|
+
import { CART_MODAL, CHECKOUT_MODAL, SIGN_IN_MODALS } from "./contract.js";
|
|
3
|
+
import { signInFromOverlay } from "./sign-in.js";
|
|
4
|
+
import { ITEM_MODAL_PREFIX } from "./url.js";
|
|
5
|
+
var canonicalRoute = (route, installation) => {
|
|
6
|
+
if (route.type !== "order-menu") {
|
|
7
|
+
return route;
|
|
8
|
+
}
|
|
9
|
+
const { authModalId, modalId } = route.state;
|
|
10
|
+
if (authModalId && SIGN_IN_MODALS.includes(authModalId)) {
|
|
11
|
+
return signInFromOverlay(route, installation);
|
|
12
|
+
}
|
|
13
|
+
const common = {
|
|
14
|
+
business: route.business,
|
|
15
|
+
...route.branch !== void 0 ? { branch: route.branch } : {},
|
|
16
|
+
state: route.state
|
|
17
|
+
};
|
|
18
|
+
if (modalId?.startsWith(ITEM_MODAL_PREFIX)) {
|
|
19
|
+
return {
|
|
20
|
+
type: "item",
|
|
21
|
+
...common,
|
|
22
|
+
item: modalId.slice(ITEM_MODAL_PREFIX.length)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
if (modalId === CART_MODAL || modalId === CHECKOUT_MODAL) {
|
|
26
|
+
return {
|
|
27
|
+
type: modalId === CART_MODAL ? "cart" : "checkout",
|
|
28
|
+
...common
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return route;
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
canonicalRoute
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=canonical.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/server/storefront-url/canonical.ts"],
|
|
4
|
+
"sourcesContent": ["import { CART_MODAL, CHECKOUT_MODAL, SIGN_IN_MODALS } from \"./contract\";\nimport { signInFromOverlay } from \"./sign-in\";\nimport type { StorefrontRoute, StorefrontUrlOptions } from \"./types\";\nimport { ITEM_MODAL_PREFIX } from \"./url\";\n\nexport const canonicalRoute = (\n route: StorefrontRoute,\n installation: NonNullable<StorefrontUrlOptions[\"installation\"]>,\n): StorefrontRoute => {\n if (route.type !== \"order-menu\") {\n return route;\n }\n const { authModalId, modalId } = route.state;\n if (authModalId && SIGN_IN_MODALS.includes(authModalId)) {\n return signInFromOverlay(route, installation);\n }\n const common = {\n business: route.business,\n ...(route.branch !== undefined ? { branch: route.branch } : {}),\n state: route.state,\n };\n if (modalId?.startsWith(ITEM_MODAL_PREFIX)) {\n return {\n type: \"item\",\n ...common,\n item: modalId.slice(ITEM_MODAL_PREFIX.length),\n };\n }\n if (modalId === CART_MODAL || modalId === CHECKOUT_MODAL) {\n return {\n type: modalId === CART_MODAL ? \"cart\" : \"checkout\",\n ...common,\n };\n }\n return route;\n};\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,YAAY,gBAAgB,sBAAsB;AAC3D,SAAS,yBAAyB;AAElC,SAAS,yBAAyB;AAE3B,IAAM,iBAAiB,CAC5B,OACA,iBACoB;AACpB,MAAI,MAAM,SAAS,cAAc;AAC/B,WAAO;AAAA,EACT;AACA,QAAM,EAAE,aAAa,QAAQ,IAAI,MAAM;AACvC,MAAI,eAAe,eAAe,SAAS,WAAW,GAAG;AACvD,WAAO,kBAAkB,OAAO,YAAY;AAAA,EAC9C;AACA,QAAM,SAAS;AAAA,IACb,UAAU,MAAM;AAAA,IAChB,GAAI,MAAM,WAAW,SAAY,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;AAAA,IAC7D,OAAO,MAAM;AAAA,EACf;AACA,MAAI,SAAS,WAAW,iBAAiB,GAAG;AAC1C,WAAO;AAAA,MACL,MAAM;AAAA,MACN,GAAG;AAAA,MACH,MAAM,QAAQ,MAAM,kBAAkB,MAAM;AAAA,IAC9C;AAAA,EACF;AACA,MAAI,YAAY,cAAc,YAAY,gBAAgB;AACxD,WAAO;AAAA,MACL,MAAM,YAAY,aAAa,SAAS;AAAA,MACxC,GAAG;AAAA,IACL;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
var CART_MODAL = "review-menu";
|
|
3
3
|
var CHECKOUT_MODAL = "payment";
|
|
4
4
|
var SIGN_IN_MODAL = "send-otp";
|
|
5
|
-
var SIGN_IN_MODALS =
|
|
5
|
+
var SIGN_IN_MODALS = [
|
|
6
6
|
SIGN_IN_MODAL,
|
|
7
7
|
"verify-otp",
|
|
8
8
|
"update-profile"
|
|
9
|
-
]
|
|
9
|
+
];
|
|
10
10
|
var usesV2 = (options) => options.contract !== "v1" && options.installation !== void 0;
|
|
11
11
|
var menuRoute = (route) => ({
|
|
12
12
|
type: "order-menu",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/server/storefront-url/contract.ts"],
|
|
4
|
-
"sourcesContent": ["import type {
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import type {\n StorefrontInstallation,\n StorefrontRoute,\n StorefrontUrlOptions,\n} from \"./types\";\n\nexport const CART_MODAL = \"review-menu\";\nexport const CHECKOUT_MODAL = \"payment\";\nexport const SIGN_IN_MODAL = \"send-otp\";\nexport const SIGN_IN_MODALS: readonly string[] = [\n SIGN_IN_MODAL,\n \"verify-otp\",\n \"update-profile\",\n];\n\nexport const usesV2 = (\n options: StorefrontUrlOptions,\n): options is StorefrontUrlOptions & { installation: StorefrontInstallation } =>\n options.contract !== \"v1\" && options.installation !== undefined;\n\nexport const menuRoute = (\n route: Extract<\n StorefrontRoute,\n { type: \"cart\" | \"checkout\" | \"checkout-return\" | \"sign-in\" }\n >,\n): Extract<StorefrontRoute, { type: \"order-menu\" }> => ({\n type: \"order-menu\",\n business: route.business,\n ...(route.branch !== undefined ? { branch: route.branch } : {}),\n state: route.state,\n});\n"],
|
|
5
|
+
"mappings": ";AAMO,IAAM,aAAa;AACnB,IAAM,iBAAiB;AACvB,IAAM,gBAAgB;AACtB,IAAM,iBAAoC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,SAAS,CACpB,YAEA,QAAQ,aAAa,QAAQ,QAAQ,iBAAiB;AAEjD,IAAM,YAAY,CACvB,WAIsD;AAAA,EACtD,MAAM;AAAA,EACN,UAAU,MAAM;AAAA,EAChB,GAAI,MAAM,WAAW,SAAY,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;AAAA,EAC7D,OAAO,MAAM;AACf;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|