@zappie/sdk 0.23.1 → 0.24.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 +6 -0
- package/dist/config/index.d.ts +14 -0
- package/dist/debug.js +1 -1
- package/dist/index.js +1 -1
- package/dist/server/index.d.ts +14 -0
- package/dist/site-config/validate.js +1 -1
- package/dist/site-config/validate.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @zappie/sdk
|
|
2
2
|
|
|
3
|
+
## 0.24.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1d7831f: `zappie check` names a corner radius written as a number in the screens every storefront shares: the account, orders and order pages, sign-in, the checkout, the bag drawer, the cart notice, and the closed and not-found pages. `css/literal-radius` flags `rounded-full`, `rounded-2xl`, `rounded-[12px]` and the other sized `rounded-*` utilities, `border-radius` with a length no `var()` gives, and an inline `borderRadius` number. Radius tokens, sizes your own CSS defines as `--radius-<name>`, square corners and a circle whose class list makes a square box pass. A comment with `zappie-allow-radius: <reason>` keeps any other true circle. It warns. Set `corners: { fail: true }` in `zappie.config.ts` to fail the step on it, and `corners.files` to name your own shared screens. `validateConfig` checks the new key.
|
|
8
|
+
|
|
3
9
|
## 0.23.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/config/index.d.ts
CHANGED
|
@@ -121,6 +121,20 @@ type ZappieSiteConfig = {
|
|
|
121
121
|
/** Fails the check when it finds an unused file or export. */
|
|
122
122
|
fail?: boolean;
|
|
123
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* How `zappie check` treats a corner radius written as a number, not a token, in the screens every storefront
|
|
126
|
+
* shares: the account, orders and order pages, sign-in, the checkout, the bag, the cart notice, and the closed and
|
|
127
|
+
* not-found pages. It warns unless `fail` is true.
|
|
128
|
+
*/
|
|
129
|
+
corners?: {
|
|
130
|
+
/** Fails the check when a shared screen has a literal corner radius. */
|
|
131
|
+
fail?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Globs of the shared screens' files, relative to the project, such as `app/account/**`. They replace the
|
|
134
|
+
* default list. An empty list checks no file.
|
|
135
|
+
*/
|
|
136
|
+
files?: string[];
|
|
137
|
+
};
|
|
124
138
|
};
|
|
125
139
|
/**
|
|
126
140
|
* A configuration diagnostic with its field path, stable code, message and severity.
|
package/dist/debug.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var VERSION=true?"0.
|
|
1
|
+
var VERSION=true?"0.24.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.24.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
|
package/dist/server/index.d.ts
CHANGED
|
@@ -986,6 +986,20 @@ type ZappieSiteConfig = {
|
|
|
986
986
|
/** Fails the check when it finds an unused file or export. */
|
|
987
987
|
fail?: boolean;
|
|
988
988
|
};
|
|
989
|
+
/**
|
|
990
|
+
* How `zappie check` treats a corner radius written as a number, not a token, in the screens every storefront
|
|
991
|
+
* shares: the account, orders and order pages, sign-in, the checkout, the bag, the cart notice, and the closed and
|
|
992
|
+
* not-found pages. It warns unless `fail` is true.
|
|
993
|
+
*/
|
|
994
|
+
corners?: {
|
|
995
|
+
/** Fails the check when a shared screen has a literal corner radius. */
|
|
996
|
+
fail?: boolean;
|
|
997
|
+
/**
|
|
998
|
+
* Globs of the shared screens' files, relative to the project, such as `app/account/**`. They replace the
|
|
999
|
+
* default list. An empty list checks no file.
|
|
1000
|
+
*/
|
|
1001
|
+
files?: string[];
|
|
1002
|
+
};
|
|
989
1003
|
};
|
|
990
1004
|
|
|
991
1005
|
/** Inputs for a storefront document's report-only security headers. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{globallyAllowed,hostname,nonblank,packageName,record,unknownKeys}from"./helpers.js";import{analytics,budgets,nested}from"./sections.js";var rootKeys=["store","branches","theme","prerender","menu","packages","audit","outbound","security","budgets","readiness","analytics","verify","unused"];function validateConfig(input){const issues=[];const issue=value=>issues.push(value);const error=(path,code,message)=>issue({path,code,message,severity:"error"});if(!record(input)){return{valid:false,issues:[{path:"$",code:"invalid_type",message:"Expected a configuration object. Export an object from zappie.config.ts.",severity:"error"}]}}unknownKeys(input,rootKeys,"",issue);if(!nonblank(input.store)){error("store",input.store===void 0?"missing_required":"invalid_type","Expected a non-empty storefront slug. Set store to the slug used by createZappie().")}theme(input.theme,error);stringList(input.branches,"branches",error,
|
|
1
|
+
import{globallyAllowed,hostname,nonblank,packageName,record,unknownKeys}from"./helpers.js";import{analytics,budgets,nested}from"./sections.js";var rootKeys=["store","branches","theme","prerender","menu","packages","audit","outbound","security","budgets","readiness","analytics","verify","unused","corners"];function validateConfig(input){const issues=[];const issue=value=>issues.push(value);const error=(path,code,message)=>issue({path,code,message,severity:"error"});if(!record(input)){return{valid:false,issues:[{path:"$",code:"invalid_type",message:"Expected a configuration object. Export an object from zappie.config.ts.",severity:"error"}]}}unknownKeys(input,rootKeys,"",issue);if(!nonblank(input.store)){error("store",input.store===void 0?"missing_required":"invalid_type","Expected a non-empty storefront slug. Set store to the slug used by createZappie().")}theme(input.theme,error);branchList(stringList(input.branches,"branches",error),error);if(input.prerender!==void 0){issue({path:"prerender",code:"unused_setting",message:"Zappie hosting prerenders no page, so prerender does nothing. Remove it.",severity:"warning"})}nested(input.menu,"menu",["hiddenCategories"],issue,value=>{stringList(value.hiddenCategories,"menu.hiddenCategories",error)});nested(input.packages,"packages",["allow"],issue,value=>{const allow=stringList(value.allow,"packages.allow",error);allow?.forEach((name,index)=>{if(globallyAllowed(name)){issue({path:`packages.allow[${index}]`,code:"redundant_allowlist",message:`${name} is already globally allowed. Remove it from packages.allow.`,severity:"warning"})}else if(!packageName(name)){error(`packages.allow[${index}]`,"invalid_format","Expected a lowercase npm package name. Use a package name such as lucide-react or @scope/name.")}})});nested(input.outbound,"outbound",["allow"],issue,value=>{hostList(value.allow,"outbound.allow",error)});nested(input.security,"security",["csp","links"],issue,security=>{hostList(security.links,"security.links",error);nested(security.csp,"security.csp",["imgSrc","connectSrc","fontSrc","styleSrc","frameSrc"],issue,csp=>{for(const[name,value]of Object.entries(csp)){hostList(value,`security.csp.${name}`,error)}})});budgets(input.budgets,issue,error);nested(input.readiness,"readiness",["routeDiscovery"],issue,readiness=>{nested(readiness.routeDiscovery,"readiness.routeDiscovery",["optOut"],issue,routeDiscovery=>{nested(routeDiscovery.optOut,"readiness.routeDiscovery.optOut",["reason"],issue,optOut=>{if(!nonblank(optOut.reason)){error("readiness.routeDiscovery.optOut.reason","invalid_format","Expected a non-blank reason. Explain why the site disables initial route discovery.")}})})});analytics(input.analytics,issue,error);nested(input.verify,"verify",["startPath","cataloguePath"],issue,()=>{});for(const key of["unused","corners"]){nested(input[key],key,key==="unused"?["fail"]:["fail","files"],issue,value=>{if(value.fail!==void 0&&typeof value.fail!=="boolean"){error(`${key}.fail`,"invalid_type",`Expected a boolean. Set ${key}.fail to true or remove it.`)}stringList(value.files,`${key}.files`,error)})}return{valid:!issues.some(entry=>entry.severity==="error"),issues}}function theme(value,error){if(typeof value!=="string"||!/\.json$/.test(value)||/^(?:[a-z][a-z\d+.-]*:|\/)|\\/i.test(value)){error("theme",typeof value==="string"?"invalid_format":value===void 0?"missing_required":"invalid_type","Expected a relative .json path. Use a value such as ./theme.json.")}}function stringList(value,path,error){if(value===void 0){return void 0}if(!Array.isArray(value)||value.some(entry=>typeof entry!=="string")){error(path,"invalid_type",`Expected an array of strings. Set ${path} to string values.`);return void 0}return value}function branchList(value,error){if(!value){return}if(value.length===0){error("branches","invalid_format","Expected at least one value. Add a value to branches or remove the field.")}value.forEach((entry,index)=>{if(!nonblank(entry)){error(`branches[${index}]`,"invalid_format","Expected a non-empty branch slug. Remove the empty value or use a branch slug.")}});if(new Set(value).size!==value.length){error("branches","duplicate","Expected unique values. Remove duplicates from branches.")}}function hostList(value,path,error){stringList(value,path,error)?.forEach((host,index)=>{if(!hostname(host)){error(`${path}[${index}]`,"invalid_format","Expected a hostname or leading *. subdomain pattern without a scheme, path, port or IP. Use a value such as api.example.com.")}})}export{validateConfig};
|
|
2
2
|
//# sourceMappingURL=validate.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/site-config/validate.ts"],
|
|
4
|
-
"mappings": "AAAA,OACE,gBACA,SACA,SACA,YACA,OACA,gBACK,eACP,OAAS,UAAW,QAAS,WAAc,gBAG3C,IAAM,SAAW,CACf,QACA,WACA,QACA,YACA,OACA,WACA,QACA,WACA,WACA,UACA,YACA,YACA,SACA,
|
|
4
|
+
"mappings": "AAAA,OACE,gBACA,SACA,SACA,YACA,OACA,gBACK,eACP,OAAS,UAAW,QAAS,WAAc,gBAG3C,IAAM,SAAW,CACf,QACA,WACA,QACA,YACA,OACA,WACA,QACA,WACA,WACA,UACA,YACA,YACA,SACA,SACA,SACF,EASO,SAAS,eAAe,MAAkC,CAC/D,MAAM,OAAwB,CAAC,EAC/B,MAAM,MAAS,OAAuB,OAAO,KAAK,KAAK,EACvD,MAAM,MAAQ,CAAC,KAAc,KAA2B,UACtD,MAAM,CAAE,KA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