@zappie/sdk 0.28.0 → 0.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/debug.js +1 -1
- package/dist/index.js +1 -1
- package/dist/menu/index.d.ts +1 -1
- package/dist/rich-text/index.d.ts +1 -1
- package/dist/server/index.d.ts +9 -9
- package/dist/services/index.d.ts +1 -1
- package/dist/uploads/index.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/debug.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var VERSION=true?"0.28.
|
|
1
|
+
var VERSION=true?"0.28.1":"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,withDefaultMenu}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.28.
|
|
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,withDefaultMenu}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.28.1":"0.0.0-development";export{API_VERSION,RestTransport,VERSION,ZappieCartError,ZappieError,createZappie,estimateUnitPrice,format,holdsForLater,isHeldQuote,isZappieError,money,previewItem,resolveSourceMenu,validateLine,withDefaultMenu};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/menu/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ declare const itemHref: (itemId: string, menuId?: string) => string;
|
|
|
26
26
|
/** The menu page, at a menu (`?menu=`) and a category (`?category=`). */
|
|
27
27
|
declare function menuHref(sectionId?: string, categoryId?: string): string;
|
|
28
28
|
/**
|
|
29
|
-
* The order types the branch offers that its menus take. A menu may list its own
|
|
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
30
|
* stand.
|
|
31
31
|
*/
|
|
32
32
|
declare function orderTypesOf(branch: Pick<Branch, "fulfilment">, menu: Menu | undefined): OrderType[];
|
|
@@ -8,7 +8,7 @@ type RichTextNode = {
|
|
|
8
8
|
/**
|
|
9
9
|
* Parse merchant rich text into nodes without a DOM, so it runs in a loader, a Worker or SSR. Pair it with
|
|
10
10
|
* `createSanitizeRichText` from `@zappie/foundations/rich-text` before you render HTML.
|
|
11
|
-
* Decodes numeric entities, Latin-1 names and the typographic marks menus use
|
|
11
|
+
* Decodes numeric entities, Latin-1 names and the typographic marks menus use, and leaves unknown names as text.
|
|
12
12
|
*/
|
|
13
13
|
declare function parseRichText(html: string): RichTextNode[];
|
|
14
14
|
/** Merchant rich text as plain text, for a card's lines, a search or a meta description: tags dropped, entities decoded, spaces collapsed. */
|
package/dist/server/index.d.ts
CHANGED
|
@@ -452,7 +452,7 @@ declare const EDGE_CACHE_HEADER = "x-zappie-edge-cache";
|
|
|
452
452
|
declare const DATA_VERSION_HEADER = "x-zappie-data-version";
|
|
453
453
|
/**
|
|
454
454
|
* Remember the data version the host sent with a request, so the store reads made while it renders are kept under
|
|
455
|
-
* it too. {@link cachePage} and `siteWorker` call it
|
|
455
|
+
* it too. {@link cachePage} and `siteWorker` call it. A Worker that renders some other way calls it first.
|
|
456
456
|
*
|
|
457
457
|
* @param request - The request the Worker received.
|
|
458
458
|
* @param ctx - The Worker's execution context for that request.
|
|
@@ -737,7 +737,7 @@ type LegacyRedirectsOptions = {
|
|
|
737
737
|
menuPath?: string;
|
|
738
738
|
/**
|
|
739
739
|
* Where an old content page (`/pages/<slug>`) goes. `"home"`, the default, opens the home page, for a site with no
|
|
740
|
-
* content pages. `"keep"` keeps `/pages/<slug>`. A record maps each slug to a path, which may end in a `#hash
|
|
740
|
+
* content pages. `"keep"` keeps `/pages/<slug>`. A record maps each slug to a path, which may end in a `#hash`. A
|
|
741
741
|
* slug it doesn't name opens the home page.
|
|
742
742
|
*/
|
|
743
743
|
pages?: "home" | "keep" | Readonly<Record<string, string>>;
|
|
@@ -772,12 +772,12 @@ type LegacyRedirects = {
|
|
|
772
772
|
* `/order/…`, which the redirect Worker forwards with the path kept. The SDK's `storefrontRedirect` maps them to the
|
|
773
773
|
* URL contract and keeps the attribution parameters (`utm_*`, `fbclid` and the other click IDs). Then:
|
|
774
774
|
*
|
|
775
|
-
* - `/order[/<business>]`, `/<business>` go to
|
|
776
|
-
* - `/order[/<business>]/<branch>` goes to the menu page with `?branch=<branch>` and the menu and category
|
|
775
|
+
* - `/order[/<business>]`, `/<business>` go to `/`.
|
|
776
|
+
* - `/order[/<business>]/<branch>` goes to the menu page with `?branch=<branch>` and the menu and category.
|
|
777
777
|
* - `/order[/<business>][/<branch>]/products/<id>` and `?modal_id=product_<id>` go to `/item/item_<id>`, keeping
|
|
778
|
-
* the branch the old address named
|
|
779
|
-
* - `/profile/orders/<id>` goes to `/orders/ord_<id>`, and `/profile/…` to `/account
|
|
780
|
-
* - `/pages/<slug>` goes where `pages` says
|
|
778
|
+
* the branch the old address named.
|
|
779
|
+
* - `/profile/orders/<id>` goes to `/orders/ord_<id>`, and `/profile/…` to `/account`.
|
|
780
|
+
* - `/pages/<slug>` goes where `pages` says.
|
|
781
781
|
* - anything else under a branch opens that branch's menu, and anything else opens the home page.
|
|
782
782
|
*
|
|
783
783
|
* Route `order`, `order/*`, `profile`, `profile/*`, `<business>` and `<business>/*` to a loader that throws
|
|
@@ -1168,8 +1168,8 @@ type SiteWorkerOptions<Env extends SiteWorkerEnv> = {
|
|
|
1168
1168
|
* A site's Worker. It answers, in order:
|
|
1169
1169
|
*
|
|
1170
1170
|
* - the site host's request for the closed page: the root at `/` renders it for every address, so no route runs,
|
|
1171
|
-
* redirects or answers a 404 while the store is off. Only a page that rendered is marked as the closed page
|
|
1172
|
-
* - `redirect`, when it answers
|
|
1171
|
+
* redirects or answers a 404 while the store is off. Only a page that rendered is marked as the closed page.
|
|
1172
|
+
* - `redirect`, when it answers.
|
|
1173
1173
|
* - a page through the edge page cache (`cachePage`), so shoppers who aren't signed in share the menu pages, their
|
|
1174
1174
|
* `.data`, robots and the sitemap at each location for as long as each one's `Cache-Control` says. It renders
|
|
1175
1175
|
* afresh with `ZAPPIE_EDGE_CACHE=off`, and for a request with `x-forwarded-host`: a page drawn behind a proxy names
|
package/dist/services/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ declare const checkoutUrl: (path: string, environment?: ZappieEnvironment) => st
|
|
|
17
17
|
* @returns The absolute app URL. A path that could leave the app throws a TypeError.
|
|
18
18
|
*/
|
|
19
19
|
declare const appUrl: (path: string, environment?: ZappieEnvironment) => string;
|
|
20
|
-
/** Zappie's support
|
|
20
|
+
/** Zappie's support chat number, the same one the classic storefront opens. */
|
|
21
21
|
declare const ZAPPIE_SUPPORT_WHATSAPP = "15558956471";
|
|
22
22
|
|
|
23
23
|
export { ZAPPIE_SUPPORT_WHATSAPP, appUrl, checkoutUrl };
|
package/dist/uploads/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Where the host serves a site's uploads, on the site's own address. */
|
|
2
2
|
declare const UPLOADS_PATH = "/_zappie/assets/";
|
|
3
|
-
/** The qualities the uploads route accepts
|
|
3
|
+
/** The qualities the uploads route accepts. {@link uploadResized} asks for the nearest. */
|
|
4
4
|
declare const UPLOAD_QUALITIES: readonly [60, 75, 80, 90];
|
|
5
5
|
/** The path the host serves an upload at, from its name. */
|
|
6
6
|
declare function uploadPath(name: string): string;
|