@zappie/sdk 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +90 -26
- package/dist/debug.js +1 -1
- package/dist/index.js +1 -1
- package/dist/menu/index.d.ts +39 -0
- package/dist/menu/index.js +2 -0
- package/dist/menu/index.js.map +6 -0
- package/dist/rich-text/index.d.ts +18 -0
- package/dist/rich-text/index.js +2 -0
- package/dist/rich-text/index.js.map +6 -0
- package/dist/server/index.d.ts +305 -3
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/legacy-order.js +2 -0
- package/dist/server/legacy-order.js.map +6 -0
- package/dist/server/page-cache.js +2 -0
- package/dist/server/page-cache.js.map +6 -0
- package/dist/server/site-seo.js +4 -0
- package/dist/server/site-seo.js.map +6 -0
- package/dist/server/site-worker.js +2 -0
- package/dist/server/site-worker.js.map +6 -0
- package/package.json +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @zappie/sdk
|
|
2
2
|
|
|
3
|
+
## 0.21.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 50fb80a: `@zappie/sdk/menu` reads a menu the way a menu page lists it: `sectionsOf`, `categoriesOf` (categories with items, counted, each once), `itemsOf`, `categoryOfItem`, `sectionOfCategory`, `itemHref`, `menuHref`, `orderTypesOf` and `directionsHref`, with the `Section`, `CategoryView` and `OrderType` types.
|
|
8
|
+
|
|
9
|
+
The starter's menu lists its menus and categories with them, so a menu or category with nothing to sell no longer shows.
|
|
10
|
+
|
|
11
|
+
- e93e157: `@zappie/sdk/rich-text` reads merchant rich text without a DOM, so it runs in a loader, a Worker or SSR: `parseRichText` gives its nodes with the entities decoded, and `plainText` its text on one line. `@zappie/foundations/rich-text` re-exports both and adds `sanitizeRichText`, the shared sanitizer on that parser. `zappie/no-unsafe-html` accepts HTML passed through the imported `sanitizeRichText`.
|
|
12
|
+
|
|
13
|
+
The starter's item sheet shows a description's formatting, and the About page shows descriptions as text, never as tags.
|
|
14
|
+
|
|
15
|
+
## 0.20.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- bc9580f: `@zappie/sdk/server` holds the server side every site repeats. `pageCacheRules({ menu })` returns the page cache rules and headers for the pages you name. `siteWorker` is the whole site Worker: the closed page, an early redirect, the edge page cache and the error page. `robotsResponse` and `sitemapResponse` answer robots and the sitemap, `allMenus` reads each branch's menu for it, `storeRedirect` reads the merchant's own redirects, `originFetch` names the shopper's origin on each API call, and `legacyRedirects({ business })` moves the classic storefront's addresses onto your site.
|
|
20
|
+
|
|
21
|
+
`@zappie/foundations/site/server` holds what needs React Router: `siteContext`, `createServerClient`, `siteEnv`, `siteMode`, `isPreview`, `requestOrigin`, `documentHandler` (the whole of `entry.server.tsx`) and `closedPageData`. `@zappie/foundations/site` has `PageViews`, `useAtTable`, `IN_VENUE_HANDLE`, `pageTitle` and `isClosedPage`. `@zappie/foundations/site/customer` has `CustomerGate` and `useCheckoutReturn`.
|
|
22
|
+
|
|
23
|
+
The starter's cache rules, server client, `entry.server.tsx`, Worker, robots, sitemap, customer gate, checkout return and page views use them, and its copies are gone.
|
|
24
|
+
|
|
3
25
|
## 0.19.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -50,32 +50,34 @@ Prices always come from Zappie. The cart shows a local estimate while it waits,
|
|
|
50
50
|
|
|
51
51
|
## Entry points
|
|
52
52
|
|
|
53
|
-
| Import | For
|
|
54
|
-
| -------------------------------------------------- |
|
|
55
|
-
| `@zappie/sdk` | The client, the cart, money formatting and errors
|
|
56
|
-
| `@zappie/sdk/react` | `ZappieProvider` and hooks such as `useStore`, `useMenu` and `useCart`
|
|
57
|
-
| `@zappie/sdk/checkout` | Opening Zappie's hosted checkout and checking it completed
|
|
58
|
-
| `@zappie/sdk/checkout-defaults` | The phone, address, region and time a signed-in checkout starts from
|
|
59
|
-
| `@zappie/sdk/customer` and `/customer/react` | Signed-in customers, their orders and saved addresses
|
|
60
|
-
| `@zappie/sdk/in-venue` and `/in-venue/react` | Tables: the scanned table, its menus, the shared bill, and the pages that serve them
|
|
61
|
-
| `@zappie/sdk/loyalty` and `/loyalty/react` | A signed-in shopper's points, perks in the bag, the order's points and store credit
|
|
62
|
-
| `@zappie/sdk/account` | `accountsUrl`, a link to the shopper's Zappie account on the accounts portal
|
|
63
|
-
| `@zappie/sdk/integrations` | Public integration IDs and browser keys
|
|
64
|
-
| `@zappie/sdk/places` | Address search and delivery-zone checks
|
|
65
|
-
| `@zappie/sdk/pricing` | An item's starting price, its price with given choices, and whether to show it as "From"
|
|
66
|
-
| `@zappie/sdk/display` | Phone numbers spaced for reading, and what a branch calls an in-person order
|
|
67
|
-
| `@zappie/sdk/
|
|
68
|
-
| `@zappie/sdk/
|
|
69
|
-
| `@zappie/sdk/
|
|
70
|
-
| `@zappie/sdk/
|
|
71
|
-
| `@zappie/sdk/
|
|
72
|
-
| `@zappie/sdk/
|
|
73
|
-
| `@zappie/sdk/
|
|
74
|
-
| `@zappie/sdk/
|
|
75
|
-
| `@zappie/sdk/
|
|
76
|
-
| `@zappie/sdk/
|
|
77
|
-
| `@zappie/sdk/
|
|
78
|
-
| `@zappie/sdk/
|
|
53
|
+
| Import | For |
|
|
54
|
+
| -------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
55
|
+
| `@zappie/sdk` | The client, the cart, money formatting and errors |
|
|
56
|
+
| `@zappie/sdk/react` | `ZappieProvider` and hooks such as `useStore`, `useMenu` and `useCart` |
|
|
57
|
+
| `@zappie/sdk/checkout` | Opening Zappie's hosted checkout and checking it completed |
|
|
58
|
+
| `@zappie/sdk/checkout-defaults` | The phone, address, region and time a signed-in checkout starts from |
|
|
59
|
+
| `@zappie/sdk/customer` and `/customer/react` | Signed-in customers, their orders and saved addresses |
|
|
60
|
+
| `@zappie/sdk/in-venue` and `/in-venue/react` | Tables: the scanned table, its menus, the shared bill, and the pages that serve them |
|
|
61
|
+
| `@zappie/sdk/loyalty` and `/loyalty/react` | A signed-in shopper's points, perks in the bag, the order's points and store credit |
|
|
62
|
+
| `@zappie/sdk/account` | `accountsUrl`, a link to the shopper's Zappie account on the accounts portal |
|
|
63
|
+
| `@zappie/sdk/integrations` | Public integration IDs and browser keys |
|
|
64
|
+
| `@zappie/sdk/places` | Address search and delivery-zone checks |
|
|
65
|
+
| `@zappie/sdk/pricing` | An item's starting price, its price with given choices, and whether to show it as "From" |
|
|
66
|
+
| `@zappie/sdk/display` | Phone numbers spaced for reading, and what a branch calls an in-person order |
|
|
67
|
+
| `@zappie/sdk/rich-text` | Merchant rich text read without a DOM: its nodes and its plain text |
|
|
68
|
+
| `@zappie/sdk/menu` | A menu's sections and categories, its items once each, item and menu links, order types and directions |
|
|
69
|
+
| `@zappie/sdk/branches` | The nearest branch to a shopper, and each branch's distance from them |
|
|
70
|
+
| `@zappie/sdk/options` | Option group rules: radio or checkbox, the group's limit, its labels and the note limit |
|
|
71
|
+
| `@zappie/sdk/server` | Server-side reads, storefront URLs, `verifyWebhook()`, menu snapshots, sign-in crypto and a site's Worker, cache rules, robots, sitemap and old-address redirects |
|
|
72
|
+
| `@zappie/sdk/template` and `/template/react` | Template settings and responsive images for template authors |
|
|
73
|
+
| `@zappie/sdk/error-pages` and `/error-pages/react` | Zappie's page not found and something went wrong pages, for the site host's fallback |
|
|
74
|
+
| `@zappie/sdk/site-error` and `/site-error/react` | Your own 404 and error pages: which page, safe words, Try again and the home link |
|
|
75
|
+
| `@zappie/sdk/site-closed` | Your own closed page while the merchant has switched the storefront off |
|
|
76
|
+
| `@zappie/sdk/navigation-progress` | A line along the top of the page while a slow navigation runs, and the pressed state |
|
|
77
|
+
| `@zappie/sdk/receipts` | Receipt PDFs as files, and whether the device can share them |
|
|
78
|
+
| `@zappie/sdk/testing` | A mock client for your tests |
|
|
79
|
+
| `@zappie/sdk/url` | Storefront URL parsing and canonical redirects |
|
|
80
|
+
| `@zappie/sdk/redirect` | Same-origin validation for untrusted redirect targets |
|
|
79
81
|
|
|
80
82
|
Customer sign-in runs through Zappie's site host, so `@zappie/sdk/customer` works on sites Zappie hosts. Sign-in for a site you host yourself isn't available yet.
|
|
81
83
|
|
|
@@ -321,6 +323,23 @@ written without a country code.
|
|
|
321
323
|
`inVenueLabel(branch)` says what an order placed at the branch is called:
|
|
322
324
|
"Walk-in" when `branch.category` is `"RETAIL"`, and "Dine-in" otherwise.
|
|
323
325
|
|
|
326
|
+
### Menu model
|
|
327
|
+
|
|
328
|
+
`@zappie/sdk/menu` reads a `Menu` the way a menu page lists it, with no React:
|
|
329
|
+
`sectionsOf(menu)` (its menus, or the whole menu as one), `categoriesOf(menu,
|
|
330
|
+
section?)` (categories with items, counted, each once), `itemsOf(menu,
|
|
331
|
+
categories)` (each item once), `categoryOfItem`, `sectionOfCategory`,
|
|
332
|
+
`itemHref(itemId, menuId?)`, `menuHref(menuId?, categoryId?)`,
|
|
333
|
+
`orderTypesOf(branch, menu)` (the order types the branch and its menus both
|
|
334
|
+
take) and `directionsHref(store, branch)`.
|
|
335
|
+
|
|
336
|
+
### Rich text without a DOM
|
|
337
|
+
|
|
338
|
+
`parseRichText(html)` from `@zappie/sdk/rich-text` reads a description into
|
|
339
|
+
nodes in a loader, a Worker or SSR, and decodes its entities. `plainText(html)`
|
|
340
|
+
is the same text on one line, for a card or a meta description. To render
|
|
341
|
+
HTML, sanitize it with `sanitizeRichText` from `@zappie/foundations/rich-text`.
|
|
342
|
+
|
|
324
343
|
### Tables and bills
|
|
325
344
|
|
|
326
345
|
A guest who scans a table code lands on one of three pages the platform owns:
|
|
@@ -538,3 +557,48 @@ const stop = watchCheckoutDefaults(
|
|
|
538
557
|
// When the shopper picks a delivery address:
|
|
539
558
|
rememberAddress(address, undefined, customer.customer?.id);
|
|
540
559
|
```
|
|
560
|
+
|
|
561
|
+
### Site plumbing
|
|
562
|
+
|
|
563
|
+
`@zappie/sdk/server` holds the server side every React Router site repeats. Each piece takes the site's own
|
|
564
|
+
choices as options, so a site keeps only those.
|
|
565
|
+
|
|
566
|
+
- **Page cache rules.** `pageCacheRules({ menu })` takes the pages that read only public data and returns
|
|
567
|
+
`pageCacheFor`, `pageCacheControl`, `documentCacheRule` and `documentCacheHeaders`. A menu page is shared for 30
|
|
568
|
+
seconds and served stale for five minutes, with a weak ETag of its menu, its store details and the deploy. The
|
|
569
|
+
cart, checkout, orders, account, sign-in and `/_zappie` pages are never shared, and nor is an unknown page.
|
|
570
|
+
`PAGE_CACHE_CONTROL`, `sharedCacheControl` and `deferredDataFailed` are there for your own headers.
|
|
571
|
+
- **The Worker.** `siteWorker({ render, deployId, cacheControl, branchCookie, redirect })` answers the site host's
|
|
572
|
+
closed page from `/`, then `redirect`, then the page through `cachePage`. It renders afresh with
|
|
573
|
+
`ZAPPIE_EDGE_CACHE=off` and behind a proxy, and answers a handler that throws with Zappie's error page.
|
|
574
|
+
- **Robots and the sitemap.** `robotsResponse({ origin, preview, store })` hides a preview and a store the merchant
|
|
575
|
+
hid from search. `sitemapResponse({ origin, store, menus, pages, preview })` lists the home page, your pages,
|
|
576
|
+
each branch's menu and every item. `branchMenus` and `items` change which menu pages and items it lists.
|
|
577
|
+
`allMenus(client, store)` reads up to eight branches' menus for it.
|
|
578
|
+
- **Merchant redirects.** `storeRedirect(store, pathname)` reads the redirects the merchant set in search settings.
|
|
579
|
+
- **The shopper's origin.** `originFetch(origin)` is a fetch for `createZappie` that names the shopper's origin on
|
|
580
|
+
each API call. Wrap it in `cachedApiFetch({ fetch })` for the edge cache.
|
|
581
|
+
- **Old addresses.** `legacyRedirects({ business })` moves the classic Zappie storefront's `/order/…`,
|
|
582
|
+
`/<business>/…` and `/profile/…` addresses onto your site with a 301, keeping the ad click IDs and `utm_*`.
|
|
583
|
+
`menuPath`, `pages`, `dropQuery` and `homeCatalogue` fit it to your pages. Throw `response(request)` from the
|
|
584
|
+
route's loader, and pass `classicHome` to the Worker as `redirect`.
|
|
585
|
+
|
|
586
|
+
```ts
|
|
587
|
+
// app/cache.ts
|
|
588
|
+
export const pageCache = pageCacheRules({
|
|
589
|
+
menu: [/^\/$/, /^\/menu\/?$/, /^\/item\/[^/]+\/?$/],
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
// workers/app.ts
|
|
593
|
+
const legacy = legacyRedirects({ business: "my-shop" });
|
|
594
|
+
export default siteWorker<SiteEnv>({
|
|
595
|
+
render: (request, env, ctx) => handle(request, siteContext(env, ctx)),
|
|
596
|
+
deployId: async () => deployId((await build()).assets.version),
|
|
597
|
+
cacheControl: pageCache.pageCacheControl,
|
|
598
|
+
branchCookie: BRANCH_COOKIE,
|
|
599
|
+
redirect: legacy.classicHome,
|
|
600
|
+
});
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
`siteContext`, the server client and the document handler come from `@zappie/foundations/site/server`, because
|
|
604
|
+
they need React Router.
|
package/dist/debug.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var VERSION=true?"0.
|
|
1
|
+
var VERSION=true?"0.21.0":"0.0.0-development";function installDebug(client){if(typeof window==="undefined"||client.mode!=="test"){return}const events=[];let quote;const emit=(name,detail)=>{const event={name,detail,at:new Date().toISOString()};events.push(event);window.dispatchEvent(new CustomEvent("zappie:event",{detail:event}))};globalThis.__zappieEmit=emit;window.__zappie={version:VERSION,store:client.config.store,async catalogue(){await client.cart.hydrate();const branch=(await client.store.get()).branches.find(value=>value.id===client.cart.getSnapshot().branchId);return{branch,menu:await client.menu.get({branch:branch.id})}},cart:Object.assign(()=>client.cart.getSnapshot(),{async inject(input){await client.cart.hydrate();if(input.lines.length>100||input.lines.some(line=>!Number.isInteger(line.quantity??1)||(line.quantity??1)<1||(line.quantity??1)>99)){throw new Error("Use up to 100 cart lines with whole quantities from 1 to 99.")}const snapshot=client.cart.getSnapshot();const value={v:1,menuVersion:client._internal.cartCatalogue().version,updatedAt:Date.now(),fulfilment:snapshot.fulfilment,promoCode:snapshot.promoCode,lines:input.lines.map((line,index)=>({...line,id:`debug_${index}`,name:line.itemId,quantity:line.quantity??1,choices:(line.choices??[]).map(choice=>({...choice,quantity:choice.quantity??1})),inputs:line.inputs??{},addedAt:new Date().toISOString()}))};const scope=client.config.cart?.storageScope;(client.config.storage??window.localStorage).setItem(`zappie:cart:v1:${client.config.store}:${snapshot.branchId}${scope?`:${scope}`:""}`,JSON.stringify(value))}}),quote:()=>quote,events};client.on("add_to_cart",detail=>emit("add_to_cart",detail));client.cart.subscribe(()=>{const state=client.cart.state;const next="quote"in state?state.quote:void 0;if(next&&next!==quote){quote=next;emit("quote",next)}})}export{installDebug};
|
|
2
2
|
//# sourceMappingURL=debug.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ZappieCartError}from"./cart/errors.js";import{holdsForLater,isHeldQuote}from"./cart/held.js";import{previewItem}from"./cart/preview.js";import{estimateUnitPrice}from"./cart/price.js";import{resolveSourceMenu}from"./cart/source-menu.js";import{validateLine}from"./cart/validate.js";import{createZappie}from"./client.js";import{API_VERSION}from"./config.js";import{ZappieError,isZappieError}from"./errors.js";export*from"./models.js";import{format,money}from"./money.js";import{RestTransport}from"./transport/rest.js";var VERSION=true?"0.
|
|
1
|
+
import{ZappieCartError}from"./cart/errors.js";import{holdsForLater,isHeldQuote}from"./cart/held.js";import{previewItem}from"./cart/preview.js";import{estimateUnitPrice}from"./cart/price.js";import{resolveSourceMenu}from"./cart/source-menu.js";import{validateLine}from"./cart/validate.js";import{createZappie}from"./client.js";import{API_VERSION}from"./config.js";import{ZappieError,isZappieError}from"./errors.js";export*from"./models.js";import{format,money}from"./money.js";import{RestTransport}from"./transport/rest.js";var VERSION=true?"0.21.0":"0.0.0-development";export{API_VERSION,RestTransport,VERSION,ZappieCartError,ZappieError,createZappie,estimateUnitPrice,format,holdsForLater,isHeldQuote,isZappieError,money,previewItem,resolveSourceMenu,validateLine};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Category, MenuSection, Menu, Branch, Item } from '@zappie/sdk';
|
|
2
|
+
|
|
3
|
+
/** One of the branch's menus (Food, Drinks) with its categories, or the whole menu when it has none. */
|
|
4
|
+
type Section = Pick<MenuSection, "id" | "name" | "categoryIds"> & Partial<MenuSection>;
|
|
5
|
+
/** A category with the number of its items the menu has. */
|
|
6
|
+
type CategoryView = Category & {
|
|
7
|
+
itemCount: number;
|
|
8
|
+
};
|
|
9
|
+
/** An order type a site's switch offers. */
|
|
10
|
+
type OrderType = "delivery" | "pickup";
|
|
11
|
+
/** The branch's menus that list a category, or the whole menu as one section when it lists no menus. */
|
|
12
|
+
declare function sectionsOf(menu: Menu): Section[];
|
|
13
|
+
/**
|
|
14
|
+
* The categories with something to sell, in a section's order, or across every section in the order the menus list
|
|
15
|
+
* them, each once.
|
|
16
|
+
*/
|
|
17
|
+
declare function categoriesOf(menu: Menu, section?: Pick<Section, "categoryIds">): CategoryView[];
|
|
18
|
+
/** Each item of the categories once, in the order they list them. */
|
|
19
|
+
declare function itemsOf(menu: Menu, categories: readonly Pick<Category, "itemIds">[]): Item[];
|
|
20
|
+
/** The first category that lists the item. */
|
|
21
|
+
declare function categoryOfItem(menu: Menu, itemId: string): Category | undefined;
|
|
22
|
+
/** The first section that lists the category. */
|
|
23
|
+
declare function sectionOfCategory<S extends Pick<Section, "categoryIds">>(sections: readonly S[], categoryId: string | undefined): S | undefined;
|
|
24
|
+
/** An item's page, opened from the menu it is on (`?menu=`), so it is ordered by the rules of the one shown. */
|
|
25
|
+
declare const itemHref: (itemId: string, menuId?: string) => string;
|
|
26
|
+
/** The menu page, at a menu (`?menu=`) and a category (`?category=`). */
|
|
27
|
+
declare function menuHref(sectionId?: string, categoryId?: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* The order types the branch offers that its menus take. A menu may list its own; when none lists any, the branch's
|
|
30
|
+
* stand.
|
|
31
|
+
*/
|
|
32
|
+
declare function orderTypesOf(branch: Pick<Branch, "fulfilment">, menu: Menu | undefined): OrderType[];
|
|
33
|
+
/** Directions to the branch in Google Maps: to its pin, or a search for its address, then the store's name. */
|
|
34
|
+
declare function directionsHref(store: {
|
|
35
|
+
name: string;
|
|
36
|
+
}, branch: Pick<Branch, "coordinates" | "address">): string;
|
|
37
|
+
|
|
38
|
+
export { categoriesOf, categoryOfItem, directionsHref, itemHref, itemsOf, menuHref, orderTypesOf, sectionOfCategory, sectionsOf };
|
|
39
|
+
export type { CategoryView, OrderType, Section };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function sectionsOf(menu){return menu.menus?.length?menu.menus.filter(section=>section.categoryIds.length>0):[{id:menu.id,name:menu.name,categoryIds:menu.categories.map(category=>category.id)}]}function categoriesOf(menu,section){const ids=section?.categoryIds??sectionsOf(menu).flatMap(entry=>entry.categoryIds);return[...new Set(ids)].map(id=>menu.categories.find(category=>category.id===id)).filter(category=>Boolean(category)).map(category=>({...category,itemCount:category.itemIds.filter(itemId=>menu.items[itemId]).length})).filter(category=>category.itemCount>0)}function itemsOf(menu,categories){const ids=new Set(categories.flatMap(category=>category.itemIds));return[...ids].flatMap(id=>menu.items[id]??[])}function categoryOfItem(menu,itemId){return menu.categories.find(category=>category.itemIds.includes(itemId))}function sectionOfCategory(sections,categoryId){return categoryId?sections.find(section=>section.categoryIds.includes(categoryId)):void 0}var itemHref=(itemId,menuId)=>`/item/${encodeURIComponent(itemId)}${menuId?`?menu=${encodeURIComponent(menuId)}`:""}`;function menuHref(sectionId,categoryId){const query=new URLSearchParams;if(sectionId){query.set("menu",sectionId)}if(categoryId){query.set("category",categoryId)}const search=query.toString();return search?`/menu?${search}`:"/menu"}function orderTypesOf(branch,menu){const listed=menu?.menus?.flatMap(section=>section.fulfilment??[]);const offers=["delivery","pickup"].filter(type=>branch.fulfilment[type]);return listed?.length?offers.filter(type=>listed.includes(type)):offers}function directionsHref(store,branch){return branch.coordinates?`https://www.google.com/maps/dir/?api=1&destination=${branch.coordinates.lat},${branch.coordinates.lng}`:`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(branch.address??store.name)}`}export{categoriesOf,categoryOfItem,directionsHref,itemHref,itemsOf,menuHref,orderTypesOf,sectionOfCategory,sectionsOf};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/menu/index.ts"],
|
|
4
|
+
"mappings": "AAeO,SAAS,WAAW,KAAuB,CAChD,OAAO,KAAK,OAAO,OACf,KAAK,MAAM,OAAQ,SAAY,QAAQ,YAAY,OAAS,CAAC,EAC7D,CACE,CACE,GAAI,KAAK,GACT,KAAM,KAAK,KACX,YAAa,KAAK,WAAW,IAAK,UAAa,SAAS,EAAE,CAC5D,CACF,CACN,CAMO,SAAS,aACd,KACA,QACgB,CAChB,MAAM,IACJ,SAAS,aACT,WAAW,IAAI,EAAE,QAAS,OAAU,MAAM,WAAW,EACvD,MAAO,CAAC,GAAG,IAAI,IAAI,GAAG,CAAC,EACpB,IAAK,IAAO,KAAK,WAAW,KAAM,UAAa,SAAS,KAAO,EAAE,CAAC,EAClE,OAAQ,UAAmC,QAAQ,QAAQ,CAAC,EAC5D,IAAK,WAAc,CAClB,GAAG,SACH,UAAW,SAAS,QAAQ,OAAQ,QAAW,KAAK,MAAM,MAAM,CAAC,EAAE,MACrE,EAAE,EACD,OAAQ,UAAa,SAAS,UAAY,CAAC,CAChD,CAGO,SAAS,QACd,KACA,WACQ,CACR,MAAM,IAAM,IAAI,IAAI,WAAW,QAAS,UAAa,SAAS,OAAO,CAAC,EACtE,MAAO,CAAC,GAAG,GAAG,EAAE,QAAS,IAAO,KAAK,MAAM,EAAE,GAAK,CAAC,CAAC,CACtD,CAGO,SAAS,eACd,KACA,OACsB,CACtB,OAAO,KAAK,WAAW,KAAM,UAAa,SAAS,QAAQ,SAAS,MAAM,CAAC,CAC7E,CAGO,SAAS,kBACd,SACA,WACe,CACf,OAAO,WACH,SAAS,KAAM,SAAY,QAAQ,YAAY,SAAS,UAAU,CAAC,EACnE,MACN,CAGO,IAAM,SAAW,CAAC,OAAgB,SACvC,SAAS,mBAAmB,MAAM,CAAC,GAAG,OAAS,SAAS,mBAAmB,MAAM,CAAC,GAAK,EAAE,GAGpF,SAAS,SAAS,UAAoB,WAAqB,CAChE,MAAM,MAAQ,IAAI,gBAClB,GAAI,UAAW,CACb,MAAM,IAAI,OAAQ,SAAS,CAC7B,CACA,GAAI,WAAY,CACd,MAAM,IAAI,WAAY,UAAU,CAClC,CACA,MAAM,OAAS,MAAM,SAAS,EAC9B,OAAO,OAAS,SAAS,MAAM,GAAK,OACtC,CAMO,SAAS,aACd,OACA,KACa,CACb,MAAM,OAAS,MAAM,OAAO,QAAS,SAAY,QAAQ,YAAc,CAAC,CAAC,EACzE,MAAM,OAAU,CAAC,WAAY,QAAQ,EAAY,OAC9C,MAAS,OAAO,WAAW,IAAI,CAClC,EACA,OAAO,QAAQ,OACX,OAAO,OAAQ,MAAS,OAAO,SAAS,IAAI,CAAC,EAC7C,MACN,CAGO,SAAS,eACd,MACA,OACA,CACA,OAAO,OAAO,YACV,sDAAsD,OAAO,YAAY,GAAG,IAAI,OAAO,YAAY,GAAG,GACtG,mDAAmD,mBAAmB,OAAO,SAAW,MAAM,IAAI,CAAC,EACzG",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** A node of merchant rich text: a tag with its children, or text. Attributes are not kept. */
|
|
2
|
+
type RichTextNode = {
|
|
3
|
+
type: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
data?: string;
|
|
6
|
+
children?: RichTextNode[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Parse merchant rich text into nodes without a DOM, so it runs in a loader, a Worker or SSR. Pair it with
|
|
10
|
+
* `createSanitizeRichText` from `@zappie/foundations/rich-text` before you render HTML.
|
|
11
|
+
* Decodes numeric entities, Latin-1 names and the typographic marks menus use; leaves unknown names as text.
|
|
12
|
+
*/
|
|
13
|
+
declare function parseRichText(html: string): RichTextNode[];
|
|
14
|
+
/** Merchant rich text as plain text, for a card's lines, a search or a meta description: tags dropped, entities decoded, spaces collapsed. */
|
|
15
|
+
declare function plainText(html: string): string;
|
|
16
|
+
|
|
17
|
+
export { parseRichText, plainText };
|
|
18
|
+
export type { RichTextNode };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var tag=/<(\/?)\s*([a-zA-Z][a-zA-Z0-9]*)\b[^>]*>/g;var voidTags=new Set(["br","hr","img","input","meta","link"]);var latin1="iexcl cent pound curren yen brvbar sect uml copy ordf laquo not shy reg macr deg plusmn sup2 sup3 acute micro para middot cedil sup1 ordm raquo frac14 frac12 frac34 iquest Agrave Aacute Acirc Atilde Auml Aring AElig Ccedil Egrave Eacute Ecirc Euml Igrave Iacute Icirc Iuml ETH Ntilde Ograve Oacute Ocirc Otilde Ouml times Oslash Ugrave Uacute Ucirc Uuml Yacute THORN szlig agrave aacute acirc atilde auml aring aelig ccedil egrave eacute ecirc euml igrave iacute icirc iuml eth ntilde ograve oacute ocirc otilde ouml divide oslash ugrave uacute ucirc uuml yacute thorn yuml";var marks="OElig 152 oelig 153 Scaron 160 scaron 161 Yuml 178 fnof 192 circ 2c6 tilde 2dc ensp 2002 emsp 2003 thinsp 2009 ndash 2013 mdash 2014 lsquo 2018 rsquo 2019 sbquo 201a ldquo 201c rdquo 201d bdquo 201e dagger 2020 Dagger 2021 bull 2022 hellip 2026 permil 2030 prime 2032 Prime 2033 lsaquo 2039 rsaquo 203a euro 20ac trade 2122 larr 2190 rarr 2192 minus 2212 check 2713";var named;var entities=()=>{if(!named){named={amp:"&",AMP:"&",apos:"'",gt:">",GT:">",lt:"<",LT:"<",nbsp:"\xA0",quot:'"',QUOT:'"'};latin1.split(" ").forEach((name,index)=>{named[name]=String.fromCodePoint(161+index)});const pairs=marks.split(" ");for(let index=0;index<pairs.length;index+=2){named[pairs[index]]=String.fromCodePoint(Number.parseInt(pairs[index+1],16))}}return named};var decodeEntities=value=>value.replace(/&(?:#([0-9]+)|#x([0-9a-f]+)|([a-z][a-z0-9]*));/gi,(entity,decimal,hexadecimal,name)=>{if(name){return entities()[name]??entity}const code=Number.parseInt(decimal||hexadecimal,hexadecimal?16:10);return code>0&&code<=1114111&&!(code>=55296&&code<=57343)?String.fromCodePoint(code):"\uFFFD"});function parseRichText(html){const root={type:"root",children:[]};const stack=[root];let last=0;const appendText=value=>{if(value){stack.at(-1)?.children?.push({type:"text",data:decodeEntities(value)})}};for(const match of html.matchAll(tag)){appendText(html.slice(last,match.index));last=match.index+match[0].length;const name=match[2].toLowerCase();if(match[1]){let position=stack.length-1;while(position>0&&stack[position].name!==name){position--}if(position>0){stack.length=position}continue}const node={type:"tag",name,children:[]};stack.at(-1)?.children?.push(node);if(!voidTags.has(name)&&!match[0].endsWith("/>")){stack.push(node)}}appendText(html.slice(last));return root.children}function plainText(html){const text=[];const walk=nodes=>{for(const node of nodes){if(node.type==="text"){text.push(node.data)}else{walk(node.children);text.push(" ")}}};walk(parseRichText(html));return text.join("").replace(/\s+/g," ").trim()}export{parseRichText,plainText};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/rich-text/index.ts"],
|
|
4
|
+
"mappings": "AAQA,IAAM,IAAM,2CACZ,IAAM,SAAW,IAAI,IAAI,CAAC,KAAM,KAAM,MAAO,QAAS,OAAQ,MAAM,CAAC,EAGrE,IAAM,OACJ,gkBACF,IAAM,MACJ,gXACF,IAAI,MAEJ,IAAM,SAAW,IAAM,CACrB,GAAI,CAAC,MAAO,CACV,MAAQ,CACN,IAAK,IACL,IAAK,IACL,KAAM,IACN,GAAI,IACJ,GAAI,IACJ,G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AAQ,EAAG,OAAS,KAAM,CACrD,UACF,CACA,GAAI,SAAW,EAAG,CAChB,MAAM,OAAS,QACjB,CACA,QACF,CACA,MAAM,KAAqB,CAAE,KAAM,MAAO,KAAM,SAAU,CAAC,CAAE,EAC7D,MAAM,GAAG,EAAE,GAAG,UAAU,KAAK,IAAI,EACjC,GAAI,CAAC,SAAS,IAAI,IAAI,GAAK,CAAC,MAAM,CAAC,EAAE,SAAS,IAAI,EAAG,CACnD,MAAM,KAAK,IAAI,CACjB,CACF,CACA,WAAW,KAAK,MAAM,IAAI,CAAC,EAC3B,OAAO,KAAK,QACd,CAGO,SAAS,UAAU,KAAc,CACtC,MAAM,KAAiB,CAAC,EACxB,MAAM,KAAQ,OAA0B,CACtC,UAAW,QAAQ,MAAO,CACxB,GAAI,KAAK,OAAS,OAAQ,CACxB,KAAK,KAAK,KAAK,IAAK,CACtB,KAAO,CACL,KAAK,KAAK,QAAS,EACnB,KAAK,KAAK,GAAG,CACf,CACF,CACF,EACA,KAAK,cAAc,IAAI,CAAC,EACxB,OAAO,KAAK,KAAK,EAAE,EAAE,QAAQ,OAAQ,GAAG,EAAE,KAAK,CACjD",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Branch, Store, Menu, Formatters } from '../index.js';
|
|
1
|
+
import { Branch, Store, Menu, Item, Formatters } from '../index.js';
|
|
2
2
|
import { C as Cache } from '../client-uRLLtZJU.js';
|
|
3
3
|
import { ZappieError, Zappie, ZappieConfig, Transport, StorageLike, StoreResource, MenuResource, ZappieEvents, MenuReadOptions } from '../index.js';
|
|
4
4
|
export { VERSION } from '../index.js';
|
|
@@ -709,6 +709,155 @@ declare function applyAvailability(snapshot: MenuSnapshot, patch: AvailabilityPa
|
|
|
709
709
|
/** Check that a value read from the edge is a MenuSnapshot this SDK can use. */
|
|
710
710
|
declare function isMenuSnapshot(value: unknown): value is MenuSnapshot;
|
|
711
711
|
|
|
712
|
+
/** The classic storefront's own query keys, which the URL contract replaces and a fallback drops. */
|
|
713
|
+
declare const CLASSIC_QUERY_KEYS: readonly string[];
|
|
714
|
+
/** Options for {@link legacyRedirects}. */
|
|
715
|
+
type LegacyRedirectsOptions = {
|
|
716
|
+
/** The business's slug, as the classic storefront's paths name it. */
|
|
717
|
+
business: string;
|
|
718
|
+
/** The site's menu page, where a branch's catalogue opens. Defaults to `/menu`. */
|
|
719
|
+
menuPath?: string;
|
|
720
|
+
/**
|
|
721
|
+
* Where an old content page (`/pages/<slug>`) goes. `"home"`, the default, opens the home page, for a site with no
|
|
722
|
+
* content pages. `"keep"` keeps `/pages/<slug>`. A record maps each slug to a path, which may end in a `#hash`; a
|
|
723
|
+
* slug it doesn't name opens the home page.
|
|
724
|
+
*/
|
|
725
|
+
pages?: "home" | "keep" | Readonly<Record<string, string>>;
|
|
726
|
+
/** More classic query keys to drop, on top of {@link CLASSIC_QUERY_KEYS}. */
|
|
727
|
+
dropQuery?: readonly string[];
|
|
728
|
+
/**
|
|
729
|
+
* Whether a URL contract catalogue link on the home page (`/?branch=…&menu=…`) moves to the menu page, for a site
|
|
730
|
+
* whose home page isn't the menu. Defaults to false.
|
|
731
|
+
*/
|
|
732
|
+
homeCatalogue?: boolean;
|
|
733
|
+
};
|
|
734
|
+
/** The redirects {@link legacyRedirects} returns. */
|
|
735
|
+
type LegacyRedirects = {
|
|
736
|
+
/** The classic query keys this site drops. */
|
|
737
|
+
classicKeys: readonly string[];
|
|
738
|
+
/** Where an old address moves to, as a path with its query. */
|
|
739
|
+
destination(request: Request | URL | string): string;
|
|
740
|
+
/** A URL contract address on this site: the contract's catalogue (`/?branch=&menu=#c-cat_…`) is the menu page. */
|
|
741
|
+
siteDestination(contract: string): string;
|
|
742
|
+
/**
|
|
743
|
+
* A 301 for an old home page link (`/?menu_id=`, `/?modal_id=product_…`, and with `homeCatalogue` a contract
|
|
744
|
+
* catalogue link), or `undefined`. Only an address from outside carries them, so answer them in the Worker, before
|
|
745
|
+
* the page cache, and the home page needs no loader.
|
|
746
|
+
*/
|
|
747
|
+
classicHome(request: Request): Response | undefined;
|
|
748
|
+
/** The 301 to {@link LegacyRedirects.destination}, for the legacy route's loader to throw. */
|
|
749
|
+
response(request: Request | URL | string): Response;
|
|
750
|
+
};
|
|
751
|
+
/**
|
|
752
|
+
* The permanent redirects from the classic Zappie storefront's addresses to this site. They arrive as
|
|
753
|
+
* `app.zappie.ai/order/<business>/…`, as `order.zappie.ai/<business>/…` and as the installation host's
|
|
754
|
+
* `/order/…`, which the redirect Worker forwards with the path kept. The SDK's `storefrontRedirect` maps them to the
|
|
755
|
+
* URL contract and keeps the attribution parameters (`utm_*`, `fbclid` and the other click IDs). Then:
|
|
756
|
+
*
|
|
757
|
+
* - `/order[/<business>]`, `/<business>` go to `/`;
|
|
758
|
+
* - `/order[/<business>]/<branch>` goes to the menu page with `?branch=<branch>` and the menu and category;
|
|
759
|
+
* - `/order[/<business>][/<branch>]/products/<id>` and `?modal_id=product_<id>` go to `/item/item_<id>`, keeping
|
|
760
|
+
* the branch the old address named;
|
|
761
|
+
* - `/profile/orders/<id>` goes to `/orders/ord_<id>`, and `/profile/…` to `/account`;
|
|
762
|
+
* - `/pages/<slug>` goes where `pages` says;
|
|
763
|
+
* - anything else under a branch opens that branch's menu, and anything else opens the home page.
|
|
764
|
+
*
|
|
765
|
+
* Route `order`, `order/*`, `profile`, `profile/*`, `<business>` and `<business>/*` to a loader that throws
|
|
766
|
+
* `response(request)`.
|
|
767
|
+
*
|
|
768
|
+
* @example
|
|
769
|
+
* ```ts
|
|
770
|
+
* const legacy = legacyRedirects({ business: "my-shop" });
|
|
771
|
+
* export function loader({ request }: LoaderFunctionArgs) {
|
|
772
|
+
* throw legacy.response(request);
|
|
773
|
+
* }
|
|
774
|
+
* ```
|
|
775
|
+
*/
|
|
776
|
+
declare function legacyRedirects({ business, menuPath, pages, dropQuery, homeCatalogue, }: LegacyRedirectsOptions): LegacyRedirects;
|
|
777
|
+
|
|
778
|
+
/** How a site page may be cached: shared as a menu page, shared as a static file, or never shared. */
|
|
779
|
+
type PageCache = "menu" | "static" | "private";
|
|
780
|
+
/**
|
|
781
|
+
* The `Cache-Control` for each page rule. A menu page renders no customer data, so a shared cache keeps it for 30
|
|
782
|
+
* seconds and serves it stale for five minutes while it refreshes. Robots and the sitemap keep for five minutes and
|
|
783
|
+
* a day. The customer's name and orders load in the browser.
|
|
784
|
+
*/
|
|
785
|
+
declare const PAGE_CACHE_CONTROL: Readonly<Record<PageCache, string>>;
|
|
786
|
+
/**
|
|
787
|
+
* The request headers that turn a page into a draft or review preview. A shared page varies on them, so a preview
|
|
788
|
+
* is never answered from the cache.
|
|
789
|
+
*/
|
|
790
|
+
declare const PREVIEW_HEADERS: readonly string[];
|
|
791
|
+
/**
|
|
792
|
+
* The pages that show a customer, a cart or an order, which are never shared. Everything under `/_zappie` is
|
|
793
|
+
* Zappie's own sign-in and API proxy.
|
|
794
|
+
*/
|
|
795
|
+
declare const PRIVATE_PAGES: readonly RegExp[];
|
|
796
|
+
/** What a server-rendered document reports for its cache headers. */
|
|
797
|
+
type DocumentCacheInput = {
|
|
798
|
+
pathname: string;
|
|
799
|
+
status: number;
|
|
800
|
+
/** Draft and review previews are never shared. */
|
|
801
|
+
preview: boolean;
|
|
802
|
+
/** True when rendering reported an error or deferred loader data rejected. */
|
|
803
|
+
failed?: boolean;
|
|
804
|
+
/** True when the response sets a cookie. */
|
|
805
|
+
setsCookie?: boolean;
|
|
806
|
+
/** The menu version the page rendered. */
|
|
807
|
+
menuVersion?: string;
|
|
808
|
+
/** A hash of the store details the page rendered. */
|
|
809
|
+
storeVersion?: string;
|
|
810
|
+
/** Changes with every build, so a deploy never serves an old page's ETag. */
|
|
811
|
+
deployId?: string;
|
|
812
|
+
};
|
|
813
|
+
/** The site's page cache rules, from {@link pageCacheRules}. */
|
|
814
|
+
type PageCacheRules = {
|
|
815
|
+
/** The rule for a page path. A private page, and any path no pattern names, is `private`. */
|
|
816
|
+
pageCacheFor(pathname: string): PageCache;
|
|
817
|
+
/**
|
|
818
|
+
* The `Cache-Control` for a menu page's `.data`, which React Router answers without one, so the Worker's page
|
|
819
|
+
* cache keeps it as long as the page. Any other `.data`, and any other URL, gets `undefined`. Pass it to
|
|
820
|
+
* `cachePage` as `cacheControl`.
|
|
821
|
+
*/
|
|
822
|
+
pageCacheControl(url: URL): string | undefined;
|
|
823
|
+
/** How a server-rendered document may be cached: `private` unless it is a 200 that isn't a preview, didn't fail and sets no cookie. */
|
|
824
|
+
documentCacheRule(input: DocumentCacheInput): PageCache;
|
|
825
|
+
/** The `cache-control`, `vary` and, for a menu page, weak `etag` headers for a server-rendered document. */
|
|
826
|
+
documentCacheHeaders(input: DocumentCacheInput): Record<string, string>;
|
|
827
|
+
};
|
|
828
|
+
/** Options for {@link pageCacheRules}. */
|
|
829
|
+
type PageCacheRulesOptions = {
|
|
830
|
+
/**
|
|
831
|
+
* The pages that read only public data (the store, its menus and the branch the link or the branch cookie names),
|
|
832
|
+
* which a shared cache keeps as menu pages. For example `[/^\/$/, /^\/menu\/?$/, /^\/item\/[^/]+\/?$/]`.
|
|
833
|
+
*/
|
|
834
|
+
menu: readonly RegExp[];
|
|
835
|
+
/** The pages that are never shared. Defaults to {@link PRIVATE_PAGES}, which wins over `menu`. */
|
|
836
|
+
private?: readonly RegExp[];
|
|
837
|
+
};
|
|
838
|
+
/**
|
|
839
|
+
* The site's page cache rules: which pages a shared cache may keep, and the headers a document and its `.data` get.
|
|
840
|
+
* Unknown paths are private.
|
|
841
|
+
*
|
|
842
|
+
* @example
|
|
843
|
+
* ```ts
|
|
844
|
+
* export const { pageCacheControl, documentCacheHeaders, documentCacheRule } = pageCacheRules({
|
|
845
|
+
* menu: [/^\/$/, /^\/menu\/?$/, /^\/item\/[^/]+\/?$/],
|
|
846
|
+
* });
|
|
847
|
+
* ```
|
|
848
|
+
*/
|
|
849
|
+
declare function pageCacheRules(options: PageCacheRulesOptions): PageCacheRules;
|
|
850
|
+
/** Whether a `Cache-Control` value lets a shared cache keep the response. */
|
|
851
|
+
declare function sharedCacheControl(value: string): boolean;
|
|
852
|
+
/**
|
|
853
|
+
* Whether any deferred value a loader returned rejected or is still pending. A rejected promise renders its error
|
|
854
|
+
* element without a render error, so the status alone can't tell that the page shows an error. A promise still
|
|
855
|
+
* pending can't be proven to succeed, so it counts as failed.
|
|
856
|
+
*
|
|
857
|
+
* @param loaderData - Each route's loader data, by route ID.
|
|
858
|
+
*/
|
|
859
|
+
declare function deferredDataFailed(loaderData: Record<string, unknown>): Promise<boolean>;
|
|
860
|
+
|
|
712
861
|
/** `budgets.routeCssKbGz`: one limit in KiB for every route, or a limit for each route keyed by its route id. */
|
|
713
862
|
type RouteCssBudget = number | Record<string, number>;
|
|
714
863
|
/**
|
|
@@ -857,6 +1006,159 @@ declare function securityHeaders(options?: SecurityHeadersOptions): Headers;
|
|
|
857
1006
|
*/
|
|
858
1007
|
declare function signInRedirect(returnTo: Request | URL | string | null | undefined, init?: ResponseInit): Response;
|
|
859
1008
|
|
|
1009
|
+
/**
|
|
1010
|
+
* Where a merchant's own redirect sends a path, from the store's search settings, or `undefined`. A trailing slash
|
|
1011
|
+
* is ignored. Serve it as a permanent redirect (301) from the root loader.
|
|
1012
|
+
*
|
|
1013
|
+
* @param store - The store, with its `seo.redirects`.
|
|
1014
|
+
* @param pathname - The requested path.
|
|
1015
|
+
*/
|
|
1016
|
+
declare function storeRedirect(store: Pick<Store, "seo">, pathname: string): string | undefined;
|
|
1017
|
+
/** Options for {@link allMenus}. */
|
|
1018
|
+
type AllMenusOptions = {
|
|
1019
|
+
/** The most branches to read. Defaults to 8. */
|
|
1020
|
+
limit?: number;
|
|
1021
|
+
};
|
|
1022
|
+
/**
|
|
1023
|
+
* Every branch's menu, up to `limit` branches, for the sitemap. A branch whose menu fails to load is `null`.
|
|
1024
|
+
*
|
|
1025
|
+
* @param client - A server client.
|
|
1026
|
+
* @param store - The store, whose branches are read in order.
|
|
1027
|
+
*/
|
|
1028
|
+
declare function allMenus(client: Pick<Zappie, "menu">, store: Pick<Store, "branches">, { limit }?: AllMenusOptions): Promise<(Menu | null)[]>;
|
|
1029
|
+
/** The paths a search engine is asked to skip, besides Zappie's own `/_zappie/`. */
|
|
1030
|
+
declare const ROBOTS_DISALLOW: readonly string[];
|
|
1031
|
+
/** Options for {@link robotsText}. */
|
|
1032
|
+
type RobotsTextOptions = {
|
|
1033
|
+
/** The site's origin, for the sitemap's address. */
|
|
1034
|
+
origin: string;
|
|
1035
|
+
/** True when the merchant hid the store from search, or the page is a preview: every path is disallowed. */
|
|
1036
|
+
hidden: boolean;
|
|
1037
|
+
/** The paths to disallow. Defaults to {@link ROBOTS_DISALLOW}. `/_zappie/` is always disallowed. */
|
|
1038
|
+
disallow?: readonly string[];
|
|
1039
|
+
};
|
|
1040
|
+
/** The site's `robots.txt`. */
|
|
1041
|
+
declare function robotsText({ origin, hidden, disallow, }: RobotsTextOptions): string;
|
|
1042
|
+
/** Options for {@link robotsResponse}. */
|
|
1043
|
+
type RobotsResponseOptions = Omit<RobotsTextOptions, "hidden"> & {
|
|
1044
|
+
/** True for a draft or review: hidden, never shared, and the store is never read. */
|
|
1045
|
+
preview: boolean;
|
|
1046
|
+
/** Reads the store, to ask whether the merchant hid it from search. Called only when `preview` is false. */
|
|
1047
|
+
store: () => Promise<Pick<Store, "seo">>;
|
|
1048
|
+
};
|
|
1049
|
+
/**
|
|
1050
|
+
* The `robots.txt` response for a route loader. A preview is always hidden and private. The live site asks only
|
|
1051
|
+
* whether the merchant hid the store, and a shared cache keeps the answer as a static file.
|
|
1052
|
+
*
|
|
1053
|
+
* @example
|
|
1054
|
+
* ```ts
|
|
1055
|
+
* export function loader({ request, context }: LoaderFunctionArgs) {
|
|
1056
|
+
* const { client, env, origin } = serverClient(context, request);
|
|
1057
|
+
* return robotsResponse({ origin, preview: isPreview(env), store: () => client.store.get() });
|
|
1058
|
+
* }
|
|
1059
|
+
* ```
|
|
1060
|
+
*/
|
|
1061
|
+
declare function robotsResponse({ preview, store, ...options }: RobotsResponseOptions): Promise<Response>;
|
|
1062
|
+
/** Options for {@link sitemapUrls}. */
|
|
1063
|
+
type SitemapOptions = {
|
|
1064
|
+
/** The site's origin. */
|
|
1065
|
+
origin: string;
|
|
1066
|
+
store: Store;
|
|
1067
|
+
/** Each branch's menu, as {@link allMenus} reads them. A `null` is skipped. */
|
|
1068
|
+
menus: readonly (Menu | null)[];
|
|
1069
|
+
/** Whether the home page, `origin + "/"`, comes first. Defaults to true. */
|
|
1070
|
+
home?: boolean;
|
|
1071
|
+
/** The site's own pages, as paths such as `/about` or full URLs. */
|
|
1072
|
+
pages?: Iterable<string>;
|
|
1073
|
+
/**
|
|
1074
|
+
* Each branch's menu page. `true`, the default, lists the URL contract's catalogue for each branch. A function
|
|
1075
|
+
* gives the site's own path for a branch. `false` lists none, for a site that lists its menu in `pages`.
|
|
1076
|
+
*/
|
|
1077
|
+
branchMenus?: boolean | ((branch: Store["branches"][number]) => string);
|
|
1078
|
+
/** Which items get an item page. Defaults to every item. */
|
|
1079
|
+
items?: (item: Item) => boolean;
|
|
1080
|
+
};
|
|
1081
|
+
/** Every URL a sitemap lists, in order, each once. */
|
|
1082
|
+
declare function sitemapUrls({ origin, store, menus, home, pages, branchMenus, items, }: SitemapOptions): string[];
|
|
1083
|
+
/** A sitemap's XML for a list of URLs. */
|
|
1084
|
+
declare function sitemapXml(urls: Iterable<string>): string;
|
|
1085
|
+
/**
|
|
1086
|
+
* The `sitemap.xml` response for a route loader: {@link sitemapUrls} as XML. A shared cache keeps it as a static
|
|
1087
|
+
* file, except for a preview.
|
|
1088
|
+
*
|
|
1089
|
+
* @example
|
|
1090
|
+
* ```ts
|
|
1091
|
+
* export async function loader({ request, context }: LoaderFunctionArgs) {
|
|
1092
|
+
* const { client, env, origin } = serverClient(context, request);
|
|
1093
|
+
* const store = await client.store.get();
|
|
1094
|
+
* return sitemapResponse({ origin, store, menus: await allMenus(client, store), pages: ["/about"], preview: isPreview(env) });
|
|
1095
|
+
* }
|
|
1096
|
+
* ```
|
|
1097
|
+
*/
|
|
1098
|
+
declare function sitemapResponse({ preview, ...options }: SitemapOptions & {
|
|
1099
|
+
preview: boolean;
|
|
1100
|
+
}): Response;
|
|
1101
|
+
|
|
1102
|
+
/** The Worker's own variables that {@link siteWorker} reads. */
|
|
1103
|
+
type SiteWorkerEnv = {
|
|
1104
|
+
/** `off` renders every page afresh, as an end-to-end test's own Worker does. */
|
|
1105
|
+
ZAPPIE_EDGE_CACHE?: string;
|
|
1106
|
+
};
|
|
1107
|
+
/** Options for {@link siteWorker}. */
|
|
1108
|
+
type SiteWorkerOptions<Env extends SiteWorkerEnv> = {
|
|
1109
|
+
/** Renders a request with the app, such as React Router's request handler with the site's load context. */
|
|
1110
|
+
render(request: Request, env: Env, ctx: EdgeContext): Promise<Response>;
|
|
1111
|
+
/**
|
|
1112
|
+
* The page cache's deploy ID, read once a page may be cached. Make it change with every build, such as the
|
|
1113
|
+
* build's asset version and `import.meta.env.ZAPPIE_DEPLOY_ID`.
|
|
1114
|
+
*/
|
|
1115
|
+
deployId(): string | Promise<string>;
|
|
1116
|
+
/** The `Cache-Control` for a response that has none, such as a menu page's `.data`. Pass `pageCacheRules(…).pageCacheControl`. */
|
|
1117
|
+
cacheControl?: (url: URL) => string | undefined;
|
|
1118
|
+
/** The cookie that remembers the shopper's branch, so a page without `?branch=` keys apart by it. */
|
|
1119
|
+
branchCookie?: string;
|
|
1120
|
+
/** Answers a request before anything renders, such as `legacyRedirects(…).classicHome`. */
|
|
1121
|
+
redirect?: (request: Request) => Response | undefined;
|
|
1122
|
+
};
|
|
1123
|
+
/**
|
|
1124
|
+
* A site's Worker. It answers, in order:
|
|
1125
|
+
*
|
|
1126
|
+
* - the site host's request for the closed page: the root at `/` renders it for every address, so no route runs,
|
|
1127
|
+
* redirects or answers a 404 while the store is off. Only a page that rendered is marked as the closed page;
|
|
1128
|
+
* - `redirect`, when it answers;
|
|
1129
|
+
* - a page through the edge page cache (`cachePage`), so shoppers who aren't signed in share the menu pages, their
|
|
1130
|
+
* `.data`, robots and the sitemap at each location for as long as each one's `Cache-Control` says. It renders
|
|
1131
|
+
* afresh with `ZAPPIE_EDGE_CACHE=off`, and for a request with `x-forwarded-host`: a page drawn behind a proxy names
|
|
1132
|
+
* the proxy's host in its links, so it is never shared. A new build starts with an empty cache.
|
|
1133
|
+
*
|
|
1134
|
+
* A handler that throws answers with Zappie's own "Something went wrong" page.
|
|
1135
|
+
*
|
|
1136
|
+
* @example
|
|
1137
|
+
* ```ts
|
|
1138
|
+
* const build = () => import("virtual:react-router/server-build");
|
|
1139
|
+
* const handle = createRequestHandler(build, import.meta.env.MODE);
|
|
1140
|
+
*
|
|
1141
|
+
* export default siteWorker<Env>({
|
|
1142
|
+
* render: (request, env, ctx) => handle(request, siteContext(env, ctx)),
|
|
1143
|
+
* deployId: async () => `${(await build()).assets.version}-${import.meta.env.ZAPPIE_DEPLOY_ID}`,
|
|
1144
|
+
* cacheControl: pageCacheControl,
|
|
1145
|
+
* branchCookie: BRANCH_COOKIE,
|
|
1146
|
+
* });
|
|
1147
|
+
* ```
|
|
1148
|
+
*/
|
|
1149
|
+
declare function siteWorker<Env extends SiteWorkerEnv>({ render, deployId, cacheControl, branchCookie, redirect, }: SiteWorkerOptions<Env>): {
|
|
1150
|
+
fetch(request: Request, env: Env, ctx: EdgeContext): Promise<Response>;
|
|
1151
|
+
};
|
|
1152
|
+
/**
|
|
1153
|
+
* A fetch for `createZappie` on the server that names the shopper's origin on each API call, unless the call already
|
|
1154
|
+
* names one. Wrap it in `cachedApiFetch({ fetch })` for the edge cache: a cached read passes a `Request` and no
|
|
1155
|
+
* `init`, and its headers, the key among them, are kept.
|
|
1156
|
+
*
|
|
1157
|
+
* @param origin - The origin the shopper opened, such as `https://my-shop.zappie.shop`.
|
|
1158
|
+
* @param fetcher - The fetch to call. Defaults to the global one.
|
|
1159
|
+
*/
|
|
1160
|
+
declare function originFetch(origin: string, fetcher?: typeof fetch): typeof fetch;
|
|
1161
|
+
|
|
860
1162
|
/** Event names sent by the Zappie webhook API. */
|
|
861
1163
|
type WebhookEventType = "menu.updated" | "branch.hours_changed" | "store.updated" | "checkout.session.completed" | "checkout.session.expired" | "order.created" | "order.paid" | "order.status_changed" | "customer.signed_in" | "payout.initiated" | "payout.paid" | "payout.failed" | "payout_request.created" | "payout_request.approved" | "payout_request.rejected" | "payment.received";
|
|
862
1164
|
/** The event envelope sent in a Zappie webhook request. */
|
|
@@ -935,5 +1237,5 @@ declare function createZappieServer({ secretKey, ...config }: ZappieServerConfig
|
|
|
935
1237
|
};
|
|
936
1238
|
}>;
|
|
937
1239
|
|
|
938
|
-
export { EDGE_CACHE_HEADER, STOREFRONT_QUERY_PARAMETERS, STOREFRONT_V1_QUERY_PARAMETERS, ZappieTokenError, ZappieWebhookSignatureError, apiCacheBypass, apiCacheKey, applyAvailability, buildStorefrontUrl, cachePage, cachedApiFetch, canonicalJson, cookieSessionStore, createAvailabilityPatch, createMenuSnapshot, createPkce, createSecurityNonce, createStoreSnapshot, createTokenVerifier, createZappieServer, inlineScriptHashes, isMenuSnapshot, loadStoreAndMenu, menuSnapshotFromPayload, openEdgeCache, openSealedValue, pageCacheBypass, pageCacheKey, pageStoreBypass, parseStorefrontUrl, randomToken, requestedBranch, resolveBranch, rotatePageNonce, sealValue, securityHeaders, sharedFreshness, signInRedirect, snapshotHash, snapshotKeys, storefrontRedirect, verifyWebhook };
|
|
939
|
-
export type { AvailabilityPatch, AvailabilityPatchInput, CachedApiFetchOptions, CookieSessionStoreOptions, EdgeCache, EdgeCacheStatus, EdgeContext, EdgeSnapshotReader, Freshness, IdTokenChecks, IdTokenClaims, MenuSnapshot, MenuSnapshotInput, MenuSnapshotPayloadInput, PageCacheOptions, PkcePair, ResolveBranchOptions, ResolvedBranch, SealOptions, SealSecret, SecurityHeadersOptions, SessionData, SessionStore, SnapshotVersionRecord, StoreAndMenu, StoreSnapshot, StorefrontInstallation, StorefrontPageState, StorefrontQuery, StorefrontRoute, StorefrontUrlInput, StorefrontUrlOptions, TokenAlgorithm, TokenClaims, TokenErrorReason, TokenVerifier, TokenVerifierOptions, VerifyTokenChecks, VerifyWebhookOptions, WebhookEvent, WebhookEventType, ZappieServerConfig };
|
|
1240
|
+
export { CLASSIC_QUERY_KEYS, EDGE_CACHE_HEADER, PAGE_CACHE_CONTROL, PREVIEW_HEADERS, PRIVATE_PAGES, ROBOTS_DISALLOW, STOREFRONT_QUERY_PARAMETERS, STOREFRONT_V1_QUERY_PARAMETERS, ZappieTokenError, ZappieWebhookSignatureError, allMenus, apiCacheBypass, apiCacheKey, applyAvailability, buildStorefrontUrl, cachePage, cachedApiFetch, canonicalJson, cookieSessionStore, createAvailabilityPatch, createMenuSnapshot, createPkce, createSecurityNonce, createStoreSnapshot, createTokenVerifier, createZappieServer, deferredDataFailed, inlineScriptHashes, isMenuSnapshot, legacyRedirects, loadStoreAndMenu, menuSnapshotFromPayload, openEdgeCache, openSealedValue, originFetch, pageCacheBypass, pageCacheKey, pageCacheRules, pageStoreBypass, parseStorefrontUrl, randomToken, requestedBranch, resolveBranch, robotsResponse, robotsText, rotatePageNonce, sealValue, securityHeaders, sharedCacheControl, sharedFreshness, signInRedirect, siteWorker, sitemapResponse, sitemapUrls, sitemapXml, snapshotHash, snapshotKeys, storeRedirect, storefrontRedirect, verifyWebhook };
|
|
1241
|
+
export type { AllMenusOptions, AvailabilityPatch, AvailabilityPatchInput, CachedApiFetchOptions, CookieSessionStoreOptions, DocumentCacheInput, EdgeCache, EdgeCacheStatus, EdgeContext, EdgeSnapshotReader, Freshness, IdTokenChecks, IdTokenClaims, LegacyRedirects, LegacyRedirectsOptions, MenuSnapshot, MenuSnapshotInput, MenuSnapshotPayloadInput, PageCache, PageCacheOptions, PageCacheRules, PageCacheRulesOptions, PkcePair, ResolveBranchOptions, ResolvedBranch, RobotsResponseOptions, RobotsTextOptions, SealOptions, SealSecret, SecurityHeadersOptions, SessionData, SessionStore, SiteWorkerEnv, SiteWorkerOptions, SitemapOptions, SnapshotVersionRecord, StoreAndMenu, StoreSnapshot, StorefrontInstallation, StorefrontPageState, StorefrontQuery, StorefrontRoute, StorefrontUrlInput, StorefrontUrlOptions, TokenAlgorithm, TokenClaims, TokenErrorReason, TokenVerifier, TokenVerifierOptions, VerifyTokenChecks, VerifyWebhookOptions, WebhookEvent, WebhookEventType, ZappieServerConfig };
|
package/dist/server/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{buildClient}from"../client.js";import{VERSION}from"../index.js";import{buildStorefrontUrl,parseStorefrontUrl,STOREFRONT_QUERY_PARAMETERS,STOREFRONT_V1_QUERY_PARAMETERS,storefrontRedirect}from"../url/index.js";import{createPkce,openSealedValue,randomToken,sealValue}from"./auth/crypto.js";import{createTokenVerifier,ZappieTokenError}from"./auth/jwt.js";import{cookieSessionStore}from"./auth/session-store.js";import{loadStoreAndMenu,requestedBranch,resolveBranch}from"./chosen-branch.js";import{apiCacheBypass,apiCacheKey,cachedApiFetch,cachePage,EDGE_CACHE_HEADER,openEdgeCache,pageCacheBypass,pageCacheKey,pageStoreBypass,rotatePageNonce,sharedFreshness}from"./edge-cache.js";import{applyAvailability,canonicalJson,createAvailabilityPatch,createMenuSnapshot,createStoreSnapshot,isMenuSnapshot,menuSnapshotFromPayload,snapshotHash,snapshotKeys}from"./edge-snapshot.js";import{createSecurityNonce,inlineScriptHashes,securityHeaders}from"./security.js";import{signInRedirect}from"./sign-in.js";import{verifyWebhook,ZappieWebhookSignatureError}from"./webhook.js";function createZappieServer({secretKey,...config}){return buildClient({...config,key:secretKey},true)}export{EDGE_CACHE_HEADER,STOREFRONT_QUERY_PARAMETERS,STOREFRONT_V1_QUERY_PARAMETERS,VERSION,ZappieTokenError,ZappieWebhookSignatureError,apiCacheBypass,apiCacheKey,applyAvailability,buildStorefrontUrl,cachePage,cachedApiFetch,canonicalJson,cookieSessionStore,createAvailabilityPatch,createMenuSnapshot,createPkce,createSecurityNonce,createStoreSnapshot,createTokenVerifier,createZappieServer,inlineScriptHashes,isMenuSnapshot,loadStoreAndMenu,menuSnapshotFromPayload,openEdgeCache,openSealedValue,pageCacheBypass,pageCacheKey,pageStoreBypass,parseStorefrontUrl,randomToken,requestedBranch,resolveBranch,rotatePageNonce,sealValue,securityHeaders,sharedFreshness,signInRedirect,snapshotHash,snapshotKeys,storefrontRedirect,verifyWebhook};
|
|
1
|
+
import{buildClient}from"../client.js";import{VERSION}from"../index.js";import{buildStorefrontUrl,parseStorefrontUrl,STOREFRONT_QUERY_PARAMETERS,STOREFRONT_V1_QUERY_PARAMETERS,storefrontRedirect}from"../url/index.js";import{createPkce,openSealedValue,randomToken,sealValue}from"./auth/crypto.js";import{createTokenVerifier,ZappieTokenError}from"./auth/jwt.js";import{cookieSessionStore}from"./auth/session-store.js";import{loadStoreAndMenu,requestedBranch,resolveBranch}from"./chosen-branch.js";import{apiCacheBypass,apiCacheKey,cachedApiFetch,cachePage,EDGE_CACHE_HEADER,openEdgeCache,pageCacheBypass,pageCacheKey,pageStoreBypass,rotatePageNonce,sharedFreshness}from"./edge-cache.js";import{applyAvailability,canonicalJson,createAvailabilityPatch,createMenuSnapshot,createStoreSnapshot,isMenuSnapshot,menuSnapshotFromPayload,snapshotHash,snapshotKeys}from"./edge-snapshot.js";import{CLASSIC_QUERY_KEYS,legacyRedirects}from"./legacy-order.js";import{deferredDataFailed,PAGE_CACHE_CONTROL,pageCacheRules,PREVIEW_HEADERS,PRIVATE_PAGES,sharedCacheControl}from"./page-cache.js";import{createSecurityNonce,inlineScriptHashes,securityHeaders}from"./security.js";import{signInRedirect}from"./sign-in.js";import{allMenus,ROBOTS_DISALLOW,robotsResponse,robotsText,sitemapResponse,sitemapUrls,sitemapXml,storeRedirect}from"./site-seo.js";import{originFetch,siteWorker}from"./site-worker.js";import{verifyWebhook,ZappieWebhookSignatureError}from"./webhook.js";function createZappieServer({secretKey,...config}){return buildClient({...config,key:secretKey},true)}export{CLASSIC_QUERY_KEYS,EDGE_CACHE_HEADER,PAGE_CACHE_CONTROL,PREVIEW_HEADERS,PRIVATE_PAGES,ROBOTS_DISALLOW,STOREFRONT_QUERY_PARAMETERS,STOREFRONT_V1_QUERY_PARAMETERS,VERSION,ZappieTokenError,ZappieWebhookSignatureError,allMenus,apiCacheBypass,apiCacheKey,applyAvailability,buildStorefrontUrl,cachePage,cachedApiFetch,canonicalJson,cookieSessionStore,createAvailabilityPatch,createMenuSnapshot,createPkce,createSecurityNonce,createStoreSnapshot,createTokenVerifier,createZappieServer,deferredDataFailed,inlineScriptHashes,isMenuSnapshot,legacyRedirects,loadStoreAndMenu,menuSnapshotFromPayload,openEdgeCache,openSealedValue,originFetch,pageCacheBypass,pageCacheKey,pageCacheRules,pageStoreBypass,parseStorefrontUrl,randomToken,requestedBranch,resolveBranch,robotsResponse,robotsText,rotatePageNonce,sealValue,securityHeaders,sharedCacheControl,sharedFreshness,signInRedirect,siteWorker,sitemapResponse,sitemapUrls,sitemapXml,snapshotHash,snapshotKeys,storeRedirect,storefrontRedirect,verifyWebhook};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/server/index.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/server/index.ts"],
|
|
4
|
-
"mappings": "AAAA,OAAS,gBAAmB,eAG5B,OAAS,YAAe,cACxB,OACE,mBACA,mBACA,4BACA,+BACA,uBAOK,kBACP,OACE,WACA,gBACA,YACA,cAIK,mBACP,OACE,oBACA,qBASK,gBACP,OACE,uBAIK,0BACP,OACE,iBACA,gBACA,kBAIK,qBACP,OACE,eACA,YACA,eACA,UACA,kBACA,cACA,gBACA,aACA,gBACA,gBACA,oBAOK,kBACP,OACE,kBACA,cACA,wBACA,mBACA,oBACA,eACA,wBACA,aACA,iBAQK,qBACP,OACE,oBACA,mBACA,oBAEK,gBACP,OAAS,mBAAsB,eAC/B,OACE,cACA,gCAIK,eAUA,SAAS,mBAAmB,CACjC,UACA,GAAG,MACL,EAAuB,CACrB,OAAO,YAAY,CAAE,GAAG,OAAQ,IAAK,SAAU,EAAG,IAAI,CACxD",
|
|
4
|
+
"mappings": "AAAA,OAAS,gBAAmB,eAG5B,OAAS,YAAe,cACxB,OACE,mBACA,mBACA,4BACA,+BACA,uBAOK,kBACP,OACE,WACA,gBACA,YACA,cAIK,mBACP,OACE,oBACA,qBASK,gBACP,OACE,uBAIK,0BACP,OACE,iBACA,gBACA,kBAIK,qBACP,OACE,eACA,YACA,eACA,UACA,kBACA,cACA,gBACA,aACA,gBACA,gBACA,oBAOK,kBACP,OACE,kBACA,cACA,wBACA,mBACA,oBACA,eACA,wBACA,aACA,iBAQK,qBACP,OACE,mBACA,oBAGK,oBACP,OACE,mBACA,mBACA,eACA,gBACA,cACA,uBAKK,kBACP,OACE,oBACA,mBACA,oBAEK,gBACP,OAAS,mBAAsB,eAC/B,OACE,SACA,gBACA,eACA,WACA,gBACA,YACA,WACA,kBAKK,gBACP,OACE,YACA,eAGK,mBACP,OACE,cACA,gCAIK,eAUA,SAAS,mBAAmB,CACjC,UACA,GAAG,MACL,EAAuB,CACrB,OAAO,YAAY,CAAE,GAAG,OAAQ,IAAK,SAAU,EAAG,IAAI,CACxD",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{parseStorefrontUrl,storefrontRedirect}from"./storefront-url/index.js";var CLASSIC_QUERY_KEYS=Object.freeze(["modal_id","auth_modal_id","menu_id","category_id","pickup","menu_layout"]);var moved=location=>new Response(null,{status:301,headers:{location}});function withQuery(pathname,query){const search=new URLSearchParams(Object.entries(query)).toString();return search?`${pathname}?${search}`:pathname}function withSearch(target,search){const[path,hash]=target.split("#");return`${path}${search}${hash?`#${hash}`:""}`}function legacyRedirects({business,menuPath="/menu",pages="home",dropQuery=[],homeCatalogue=false}){const installation={installation:{business}};const classicKeys=Object.freeze([...CLASSIC_QUERY_KEYS,...dropQuery]);const pagePath=slug=>pages==="keep"?`/pages/${slug}`:pages==="home"?"/":pages[slug]??"/";const siteDestination=contract=>{const url=new URL(contract,"https://storefront.invalid");const category=/^#c-(.+)$/.exec(url.hash)?.[1];if(category){url.searchParams.set("category",decodeURIComponent(category))}if(url.pathname==="/"&&(url.searchParams.has("branch")||url.searchParams.has("menu")||url.searchParams.has("category"))){return`${menuPath}${url.search}`}return`${url.pathname}${url.search}`};const branchOf=pathname=>{const parts=pathname.split("/").filter(Boolean);if(parts[0]!=="order"&&parts[0]!==business){return void 0}const rest=parts[0]===business?parts.slice(1):parts[1]===business?parts.slice(2):parts.slice(1);return rest[0]&&rest[0]!=="products"&&rest[0]!=="pages"?decodeURIComponent(rest[0]):void 0};const slugOf=pathname=>/\/pages\/([^/]+)/.exec(pathname)?.[1]??"";const destination=request=>{const given=new URL(typeof request==="string"?request:request instanceof URL?request.href:request.url);const url=given.pathname===`/${business}`||given.pathname.startsWith(`/${business}/`)?new URL(`/order${given.pathname}${given.search}`,given):given;const branch=branchOf(url.pathname);const mapped=storefrontRedirect(url,installation);if(mapped){const target=new URL(siteDestination(mapped),"https://storefront.invalid");if(branch&&!target.searchParams.has("branch")){target.searchParams.set("branch",branch)}for(const key of dropQuery){target.searchParams.delete(key)}if(pages!=="keep"&&target.pathname.startsWith("/pages/")){target.searchParams.delete("branch");return withSearch(pagePath(slugOf(target.pathname)),target.search)}return`${target.pathname}${target.search}`}const kept=Object.fromEntries(Object.entries(parseStorefrontUrl(url,installation).state.query??{}).filter(([key,value])=>typeof value==="string"&&!classicKeys.includes(key)));const product=new RegExp(`^/order(?:/${business.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})?/products/([^/]+)`).exec(url.pathname)?.[1];if(/\/pages\//.test(url.pathname)){const[path="/",hash]=pagePath(slugOf(url.pathname)).split("#");return`${withQuery(path,kept)}${hash?`#${hash}`:""}`}if(product){return withQuery(`/item/item_${product}`,kept)}if(url.pathname==="/profile"||url.pathname.startsWith("/profile/")){return withQuery("/account",kept)}if(branch){return withQuery(menuPath,{branch,...kept})}return withQuery("/",kept)};return{classicKeys,destination,siteDestination,classicHome(request){const url=new URL(request.url);if(url.pathname!=="/"){return void 0}if(classicKeys.some(key=>url.searchParams.has(key))){return moved(destination(url))}if(homeCatalogue&&(url.searchParams.has("branch")||url.searchParams.has("menu"))){return moved(siteDestination(`${url.pathname}${url.search}`))}return void 0},response:request=>moved(destination(request))}}export{CLASSIC_QUERY_KEYS,legacyRedirects};
|
|
2
|
+
//# sourceMappingURL=legacy-order.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/server/legacy-order.ts"],
|
|
4
|
+
"mappings": "AAAA,OAAS,mBAAoB,uBAA0B,4BAGhD,IAAM,mBAAwC,OAAO,OAAO,CACjE,WACA,gBACA,UACA,cACA,SACA,aACF,CAAC,EAyCD,IAAM,MAAS,UACb,IAAI,SAAS,KAAM,CAAE,OAAQ,IAAK,QAAS,CAAE,QAAS,CAAE,CAAC,EAE3D,SAAS,UAAU,SAAkB,MAA+B,CAClE,MAAM,OAAS,IAAI,gBAAgB,OAAO,QAAQ,KAAK,CAAC,EAAE,SAAS,EACnE,OAAO,OAAS,GAAG,QAAQ,IAAI,MAAM,GAAK,QAC5C,CAGA,SAAS,WAAW,OAAgB,OAAgB,CAClD,KAAM,CAAC,KAAM,IAAI,EAAI,OAAO,MAAM,GAAG,EACrC,MAAO,GAAG,IAAI,GAAG,MAAM,GAAG,KAAO,IAAI,IAAI,GAAK,EAAE,EAClD,CA2BO,SAAS,gBAAgB,CAC9B,SACA,SAAW,QACX,MAAQ,OACR,UAAY,CAAC,EACb,cAAgB,KAClB,EAA4C,CAC1C,MAAM,aAAe,CAAE,aAAc,CAAE,QAAS,CAAE,EAClD,MAAM,YAAc,OAAO,OAAO,CAAC,GAAG,mBAAoB,GAAG,SAAS,CAAC,EACvE,MAAM,SAAY,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,OAAO,UAAU,SAAU,CAAE,OAAQ,GAAG,IAAK,CAAC,CAChD,CACA,OAAO,UAAU,IAAK,IAAI,CAC5B,EAEA,MAAO,CACL,YACA,YACA,gBACA,YAAY,QAAS,CACnB,MAAM,IAAM,IAAI,IAAI,QAAQ,GAAG,EAC/B,GAAI,IAAI,WAAa,IAAK,CACxB,OAAO,MACT,CACA,GAAI,YAAY,KAAM,KAAQ,IAAI,aAAa,IAAI,GAAG,CAAC,EAAG,CACxD,OAAO,MAAM,YAAY,GAAG,CAAC,CAC/B,CACA,GACE,gBACC,IAAI,aAAa,IAAI,QAAQ,GAAK,IAAI,aAAa,IAAI,MAAM,GAC9D,CACA,OAAO,MAAM,gBAAgB,GAAG,IAAI,QAAQ,GAAG,IAAI,MAAM,EAAE,CAAC,CAC9D,CACA,OAAO,MACT,EACA,SAAW,SAAY,MAAM,YAAY,OAAO,CAAC,CACnD,CACF",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var PAGE_CACHE_CONTROL=Object.freeze({menu:"public, s-maxage=30, stale-while-revalidate=300",static:"public, s-maxage=300, stale-while-revalidate=86400",private:"private, no-store"});var PREVIEW_HEADERS=Object.freeze(["X-Zappie-Draft","X-Zappie-Review"]);var PRIVATE_PAGES=Object.freeze([/^\/_zappie(?:\/|$)/,/^\/cart\/?$/,/^\/checkout(?:\/|$)/,/^\/orders?(?:\/|$)/,/^\/account(?:\/|$)/,/^\/sign-in\/?$/]);function pageCacheRules(options){const menu=[...options.menu];const privatePages=[...options.private??PRIVATE_PAGES];const pageCacheFor=pathname=>{if(privatePages.some(pattern=>pattern.test(pathname))){return"private"}if(menu.some(pattern=>pattern.test(pathname))){return"menu"}return"private"};const documentCacheRule=input=>input.status!==200||input.preview||input.failed||input.setsCookie?"private":pageCacheFor(input.pathname);return{pageCacheFor,pageCacheControl(url){if(!url.pathname.endsWith(".data")){return void 0}const page=url.pathname.slice(0,-".data".length).replace(/^\/_(?:root)?$/,"/");const rule=pageCacheFor(page||"/");return rule==="private"?void 0:PAGE_CACHE_CONTROL[rule]},documentCacheRule,documentCacheHeaders(input){const rule=documentCacheRule(input);const headers={"cache-control":PAGE_CACHE_CONTROL[rule]};if(rule!=="private"){headers.vary=["Accept-Encoding",...PREVIEW_HEADERS].join(", ")}if(rule==="menu"&&input.menuVersion&&input.storeVersion){headers.etag=`W/"${input.menuVersion}-${input.storeVersion}-${input.deployId??"dev"}"`}return headers}}}function sharedCacheControl(value){return!/\b(?:private|no-store)\b/i.test(value)}var thenable=value=>typeof value?.then==="function";async function deferredDataFailed(loaderData){const deferred=Object.values(loaderData).flatMap(data=>data&&typeof data==="object"&&!thenable(data)?Object.values(data):[data]).filter(thenable);if(!deferred.length){return false}const settled=Promise.allSettled(deferred).then(results=>results.some(result=>result.status==="rejected"));return Promise.race([settled,new Promise(resolve=>setTimeout(resolve,0,true))])}export{PAGE_CACHE_CONTROL,PREVIEW_HEADERS,PRIVATE_PAGES,deferredDataFailed,pageCacheRules,sharedCacheControl};
|
|
2
|
+
//# sourceMappingURL=page-cache.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/server/page-cache.ts"],
|
|
4
|
+
"mappings": "AAQO,IAAM,mBACX,OAAO,OAAO,CACZ,KAAM,kDACN,OAAQ,qDACR,QAAS,mBACX,CAAC,EAMI,IAAM,gBAAqC,OAAO,OAAO,CAC9D,iBACA,iBACF,CAAC,EAMM,IAAM,cAAmC,OAAO,OAAO,CAC5D,qBACA,cACA,sBACA,qBACA,qBACA,gBACF,CAAC,EA0DM,SAAS,eAAe,QAAgD,CAC7E,MAAM,KAAO,CAAC,GAAG,QAAQ,IAAI,EAC7B,MAAM,aAAe,CAAC,GAAI,QAAQ,SAAW,aAAc,EAC3D,MAAM,aAAgB,UAAgC,CACpD,GAAI,aAAa,KAAM,SAAY,QAAQ,KAAK,QAAQ,CAAC,EAA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,QAAQ,WAAW,QAAQ,EAAE,KAAM,SACjD,QAAQ,KAAM,QAAW,OAAO,SAAW,UAAU,CACvD,EAEA,OAAO,QAAQ,KAAK,CAClB,QACA,IAAI,QAAkB,SAAY,WAAW,QAAS,EAAG,IAAI,CAAC,CAChE,CAAC,CACH",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{PAGE_CACHE_CONTROL}from"./page-cache.js";import{buildStorefrontUrl}from"./storefront-url/index.js";function storeRedirect(store,pathname){const clean=pathname.length>1?pathname.replace(/\/+$/,""):pathname;return store.seo?.redirects.find(entry=>entry.from===clean)?.to}function allMenus(client,store,{limit=8}={}){return Promise.all(store.branches.slice(0,limit).map(branch=>client.menu.get({branch:branch.id}).catch(()=>null)))}var ROBOTS_DISALLOW=Object.freeze(["/checkout","/account","/orders"]);function robotsText({origin,hidden,disallow=ROBOTS_DISALLOW}){if(hidden){return"User-agent: *\nDisallow: /\n"}const lines=["User-agent: *","Allow: /",...disallow.map(path=>`Disallow: ${path}`),"Disallow: /_zappie/",`Sitemap: ${origin}/sitemap.xml`];return`${lines.join("\n")}
|
|
2
|
+
`}async function robotsResponse({preview,store,...options}){const hidden=preview||(await store()).seo?.hidden===true;return new Response(robotsText({...options,hidden}),{headers:{"content-type":"text/plain; charset=utf-8","cache-control":PAGE_CACHE_CONTROL[preview?"private":"static"]}})}function sitemapUrls({origin,store,menus,home=true,pages=[],branchMenus=true,items=()=>true}){const defaultBranch=store.branches.find(branch=>branch.isDefault)?.slug;const installation={business:store.slug,...defaultBranch?{defaultBranch}:{}};const urls=new Set;if(home){urls.add(`${origin}/`)}for(const page of pages){urls.add(new URL(page,origin).href)}if(branchMenus){for(const branch of store.branches){urls.add(typeof branchMenus==="function"?new URL(branchMenus(branch),origin).href:buildStorefrontUrl({type:"order-menu",business:store.slug,branch:branch.slug,state:{query:{}}},{contract:"v2",installation,origin}))}}for(const menu of menus){if(!menu){continue}const branch=store.branches.find(entry=>entry.id===menu.branchId);for(const item of Object.values(menu.items)){if(!items(item)){continue}urls.add(buildStorefrontUrl({type:"item",business:store.slug,...branch?{branch:branch.slug}:{},item:item.id,state:{query:{}}},{contract:"v2",installation,origin}))}}return[...urls]}var escapeXml=value=>value.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""");function sitemapXml(urls){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
3
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">${[...urls].map(url=>`<url><loc>${escapeXml(url)}</loc></url>`).join("")}</urlset>`}function sitemapResponse({preview,...options}){return new Response(sitemapXml(sitemapUrls(options)),{headers:{"content-type":"application/xml; charset=utf-8","cache-control":PAGE_CACHE_CONTROL[preview?"private":"static"]}})}export{ROBOTS_DISALLOW,allMenus,robotsResponse,robotsText,sitemapResponse,sitemapUrls,sitemapXml,storeRedirect};
|
|
4
|
+
//# sourceMappingURL=site-seo.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/server/site-seo.ts"],
|
|
4
|
+
"mappings": "AAEA,OAAS,uBAA0B,kBACnC,OAAS,uBAA0B,4BAS5B,SAAS,cACd,MACA,SACoB,CACpB,MAAM,MAAQ,SAAS,OAAS,EAAI,SAAS,QAAQ,OAAQ,EAAE,EAAI,SACnE,OAAO,MAAM,KAAK,UAAU,KAAM,OAAU,MAAM,OAAS,KAAK,GAAG,EACrE,CAcO,SAAS,SACd,OACA,MACA,CAAE,MAAQ,CAAE,EAAqB,CAAC,EACR,CAC1B,OAAO,QAAQ,IACb,MAAM,SACH,MAAM,EAAG,KAAK,EACd,IAAK,QACJ,OAAO,KAAK,IAAI,CAAE,OAAQ,OAAO,EAAG,CAAC,EAAE,MAAM,IAAM,IAAI,CACzD,CACJ,CACF,CAGO,IAAM,gBAAqC,OAAO,OAAO,CAC9D,YACA,WACA,SACF,CAAC,EAaM,SAAS,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ACxB,GAAI,CAAC,KAAM,CACT,QACF,CACA,MAAM,OAAS,MAAM,SAAS,KAAM,OAAU,MAAM,KAAO,KAAK,QAAQ,EACxE,UAAW,QAAQ,OAAO,OAAO,KAAK,KAAK,EAAG,CAC5C,GAAI,CAAC,MAAM,IAAI,EAAG,CAChB,QACF,CACA,KAAK,IACH,mBACE,CACE,KAAM,OACN,SAAU,MAAM,KAChB,GAAI,OAAS,CAAE,OAAQ,OAAO,IAAK,EAAI,CAAC,EACxC,KAAM,KAAK,GACX,MAAO,CAAE,MAAO,CAAC,CAAE,CACrB,EACA,CAAE,SAAU,KAAM,aAAc,MAAO,CACzC,CACF,CACF,CACF,CACA,MAAO,CAAC,GAAG,IAAI,CACjB,CAEA,IAAM,UAAa,OACjB,MACG,WAAW,IAAK,OAAO,EACvB,WAAW,IAAK,MAAM,EACtB,WAAW,IAAK,MAAM,EACtB,WAAW,IAAK,QAAQ,EAGtB,SAAS,WAAW,KAAgC,CACzD,MAAO;AAAA,8DAAuG,CAAC,GAAG,IAAI,EAAE,IAAK,KAAQ,aAAa,UAAU,GAAG,CAAC,cAAc,EAAE,KAAK,EAAE,CAAC,WAC1L,CAeO,SAAS,gBAAgB,CAC9B,QACA,GAAG,OACL,EAAoD,CAClD,OAAO,IAAI,SAAS,WAAW,YAAY,OAAO,CAAC,EAAG,CACpD,QAAS,CACP,eAAgB,iCAChB,gBAAiB,mBAAmB,QAAU,UAAY,QAAQ,CACpE,CACF,CAAC,CACH",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{platformErrorResponse}from"../error-pages/index.js";import{markClosedPage,siteClosed}from"../site-closed/index.js";import{cachePage}from"./edge-cache.js";function siteWorker({render,deployId,cacheControl,branchCookie,redirect}){return{async fetch(request,env,ctx){try{if(siteClosed(request)){const response=await render(new Request(new URL("/",request.url),request),env,ctx);return response.ok?markClosedPage(response):response}const early=redirect?.(request);if(early){return early}const fresh=next=>render(next,env,ctx);if(env.ZAPPIE_EDGE_CACHE==="off"||request.headers.has("x-forwarded-host")){return await fresh(request)}return await cachePage(request,fresh,{ctx,deployId:await deployId(),...cacheControl?{cacheControl}:{},...branchCookie?{branchCookie}:{}})}catch(error){console.error(error);return platformErrorResponse("went-wrong")}}}}function originFetch(origin,fetcher=(input,init)=>globalThis.fetch(input,init)){return(input,init)=>{const headers=new Headers(init?.headers??(input instanceof Request?input.headers:void 0));if(!headers.has("origin")){headers.set("origin",origin)}return fetcher(input,{...init,headers})}}export{originFetch,siteWorker};
|
|
2
|
+
//# sourceMappingURL=site-worker.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/server/site-worker.ts"],
|
|
4
|
+
"mappings": "AAAA,OAAS,0BAA6B,0BACtC,OAAS,eAAgB,eAAkB,0BAC3C,OAAS,cAAmC,kBAmDrC,SAAS,WAAsC,CACpD,OACA,SACA,aACA,aACA,QACF,EAEE,CACA,MAAO,CACL,MAAM,MAAM,QAAS,IAAK,IAAK,CAC7B,GAAI,CACF,GAAI,WAAW,OAAO,EAAG,CACvB,MAAM,SAAW,MAAM,OACrB,IAAI,QAAQ,IAAI,IAAI,IAAK,QAAQ,GAAG,EAAG,OAAO,EAC9C,IACA,GACF,EACA,OAAO,SAAS,GAAK,eAAe,QAAQ,EAAI,QAClD,CACA,MAAM,MAAQ,WAAW,OAAO,EAChC,GAAI,MAAO,CACT,OAAO,KACT,CACA,MAAM,MAAS,MAAkB,OAAO,KAAM,IAAK,GAAG,EACtD,GACE,IAAI,oBAAsB,OAC1B,QAAQ,QAAQ,IAAI,kBAAkB,EACtC,CACA,OAAO,MAAM,MAAM,OAAO,CAC5B,CACA,OAAO,MAAM,UAAU,QAAS,MAAO,CACrC,IACA,SAAU,MAAM,SAAS,EACzB,GAAI,aAAe,CAAE,YAAa,EAAI,CAAC,EACvC,GAAI,aAAe,CAAE,YAAa,EAAI,CAAC,CACzC,CAAC,CACH,OAAS,MAAO,CAGd,QAAQ,MAAM,KAAK,EACnB,OAAO,sBAAsB,YAAY,CAC3C,CACF,CACF,CACF,CAUO,SAAS,YACd,OACA,QAAwB,CAAC,MAAO,OAAS,WAAW,MAAM,MAAO,IAAI,EACvD,CACd,MAAO,CAAC,MAAO,OAAS,CACtB,MAAM,QAAU,IAAI,QAClB,MAAM,UAAY,iBAAiB,QAAU,MAAM,QAAU,OAC/D,EACA,GAAI,CAAC,QAAQ,IAAI,QAAQ,EAAG,CAC1B,QAAQ,IAAI,SAAU,MAAM,CAC9B,CACA,OAAO,QAAQ,MAAO,CAAE,GAAG,KAAM,OAAQ,CAAC,CAC5C,CACF",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zappie/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Typed, framework-agnostic client for Zappie menus, carts, checkout, auth and events.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -123,6 +123,14 @@
|
|
|
123
123
|
"types": "./dist/display/index.d.ts",
|
|
124
124
|
"import": "./dist/display/index.js"
|
|
125
125
|
},
|
|
126
|
+
"./rich-text": {
|
|
127
|
+
"types": "./dist/rich-text/index.d.ts",
|
|
128
|
+
"import": "./dist/rich-text/index.js"
|
|
129
|
+
},
|
|
130
|
+
"./menu": {
|
|
131
|
+
"types": "./dist/menu/index.d.ts",
|
|
132
|
+
"import": "./dist/menu/index.js"
|
|
133
|
+
},
|
|
126
134
|
"./branches": {
|
|
127
135
|
"types": "./dist/branches/index.d.ts",
|
|
128
136
|
"import": "./dist/branches/index.js"
|
|
@@ -227,7 +235,7 @@
|
|
|
227
235
|
"vite": "8.3.5"
|
|
228
236
|
},
|
|
229
237
|
"scripts": {
|
|
230
|
-
"build": "node ../../scripts/release-packages/build-declarations.mjs tsup.config.ts tsup.checkout.config.ts tsup.checkout-defaults.config.ts tsup.customer.config.ts tsup.loyalty.config.ts tsup.in-venue.config.ts tsup.account.config.ts tsup.places.config.ts tsup.url.config.ts tsup.redirect.config.ts tsup.navigation.config.ts tsup.services.config.ts tsup.visits.config.ts tsup.pricing.config.ts tsup.display.config.ts tsup.branches.config.ts tsup.options.config.ts tsup.site-config.config.ts tsup.template.config.ts tsup.error-pages.config.ts tsup.site-error.config.ts tsup.site-closed.config.ts tsup.navigation-progress.config.ts tsup.receipts.config.ts && node ../../scripts/release-packages/build-modules.mjs --no-sources-content --unmapped=studio/index.js --unmapped=testing/index.js --unmapped=vite/index.js",
|
|
238
|
+
"build": "node ../../scripts/release-packages/build-declarations.mjs tsup.config.ts tsup.checkout.config.ts tsup.checkout-defaults.config.ts tsup.customer.config.ts tsup.loyalty.config.ts tsup.in-venue.config.ts tsup.account.config.ts tsup.places.config.ts tsup.url.config.ts tsup.redirect.config.ts tsup.navigation.config.ts tsup.services.config.ts tsup.visits.config.ts tsup.pricing.config.ts tsup.display.config.ts tsup.rich-text.config.ts tsup.menu.config.ts tsup.branches.config.ts tsup.options.config.ts tsup.site-config.config.ts tsup.template.config.ts tsup.error-pages.config.ts tsup.site-error.config.ts tsup.site-closed.config.ts tsup.navigation-progress.config.ts tsup.receipts.config.ts && node ../../scripts/release-packages/build-modules.mjs --no-sources-content --unmapped=studio/index.js --unmapped=testing/index.js --unmapped=vite/index.js",
|
|
231
239
|
"test": "vitest run --root ../.. packages/sdk/test",
|
|
232
240
|
"size": "node ../../scripts/release-packages/size-sdk.mjs && size-limit"
|
|
233
241
|
}
|