@zappie/sdk 0.1.14 → 0.1.15
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 +9 -2
- package/dist/debug.js +1 -1
- package/dist/index.js +1 -1
- package/dist/server/index.d.ts +7 -1
- package/dist/site-config/sections.js +13 -6
- package/dist/site-config/sections.js.map +2 -2
- package/dist/site-config/types.js +2 -1
- package/dist/site-config/types.js.map +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @zappie/sdk
|
|
2
2
|
|
|
3
|
+
## 0.1.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b0b2a59: Let a site raise V15's first-card tappable limit to 5000 ms with an explained site budget, and record the applied limit in the verify report. A site that adds `budgets.tappableMs` must upgrade `@zappie/check` and `@zappie/sdk` in the same change.
|
|
8
|
+
|
|
3
9
|
## 0.1.14
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Default site budgets: 200 KB gzipped JavaScript, 50 KB gzipped CSS and
|
|
2
|
+
* Default site budgets: 200 KB gzipped JavaScript, 50 KB gzipped CSS, 2500 ms LCP and 3000 ms until the first product card is tappable.
|
|
3
3
|
*/
|
|
4
4
|
declare const DEFAULT_BUDGETS: {
|
|
5
5
|
readonly jsKbGz: 200;
|
|
6
6
|
readonly cssKbGz: 50;
|
|
7
7
|
readonly lcpMs: 2500;
|
|
8
|
+
readonly tappableMs: 3000;
|
|
8
9
|
};
|
|
9
10
|
/**
|
|
10
11
|
* Package names and patterns allowed globally without a site-specific allowlist entry.
|
|
@@ -50,6 +51,8 @@ type ZappieSiteConfig = {
|
|
|
50
51
|
jsKbGz?: number;
|
|
51
52
|
cssKbGz?: number;
|
|
52
53
|
lcpMs?: number;
|
|
54
|
+
/** V15's limit for the first product card to become tappable. Values below 3000 use 3000. */
|
|
55
|
+
tappableMs?: number;
|
|
53
56
|
override?: {
|
|
54
57
|
reason: string;
|
|
55
58
|
};
|
|
@@ -73,7 +76,11 @@ type ZappieSiteConfig = {
|
|
|
73
76
|
};
|
|
74
77
|
/** Where `zappie verify` opens the storefront and finds each catalogue. */
|
|
75
78
|
verify?: {
|
|
76
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* The route verify opens as the menu, such as /menu. It must list items. Defaults to /.
|
|
81
|
+
* `{menu}` stands for the first menu that holds items and `{branch}` for the default branch,
|
|
82
|
+
* such as `/menu?menu={menu}`.
|
|
83
|
+
*/
|
|
77
84
|
startPath?: string;
|
|
78
85
|
/**
|
|
79
86
|
* The page for each menu, with `{menu}` where its id goes and, optionally, `{branch}` for the
|
package/dist/debug.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { ZappieError, isZappieError } from "./errors.js";
|
|
|
10
10
|
export * from "./models.js";
|
|
11
11
|
import { format, money } from "./money.js";
|
|
12
12
|
import { RestTransport } from "./transport/rest.js";
|
|
13
|
-
var VERSION = true ? "0.1.
|
|
13
|
+
var VERSION = true ? "0.1.15" : "0.0.0-development";
|
|
14
14
|
export {
|
|
15
15
|
API_VERSION,
|
|
16
16
|
RestTransport,
|
package/dist/server/index.d.ts
CHANGED
|
@@ -202,6 +202,8 @@ type ZappieSiteConfig = {
|
|
|
202
202
|
jsKbGz?: number;
|
|
203
203
|
cssKbGz?: number;
|
|
204
204
|
lcpMs?: number;
|
|
205
|
+
/** V15's limit for the first product card to become tappable. Values below 3000 use 3000. */
|
|
206
|
+
tappableMs?: number;
|
|
205
207
|
override?: {
|
|
206
208
|
reason: string;
|
|
207
209
|
};
|
|
@@ -225,7 +227,11 @@ type ZappieSiteConfig = {
|
|
|
225
227
|
};
|
|
226
228
|
/** Where `zappie verify` opens the storefront and finds each catalogue. */
|
|
227
229
|
verify?: {
|
|
228
|
-
/**
|
|
230
|
+
/**
|
|
231
|
+
* The route verify opens as the menu, such as /menu. It must list items. Defaults to /.
|
|
232
|
+
* `{menu}` stands for the first menu that holds items and `{branch}` for the default branch,
|
|
233
|
+
* such as `/menu?menu={menu}`.
|
|
234
|
+
*/
|
|
229
235
|
startPath?: string;
|
|
230
236
|
/**
|
|
231
237
|
* The page for each menu, with `{menu}` where its id goes and, optionally, `{branch}` for the
|
|
@@ -21,7 +21,7 @@ function budgets(value, issue, error) {
|
|
|
21
21
|
nested(
|
|
22
22
|
value,
|
|
23
23
|
"budgets",
|
|
24
|
-
[
|
|
24
|
+
[...Object.keys(DEFAULT_BUDGETS), "override"],
|
|
25
25
|
issue,
|
|
26
26
|
(budget) => {
|
|
27
27
|
nested(
|
|
@@ -39,28 +39,35 @@ function budgets(value, issue, error) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
);
|
|
42
|
-
for (const key of
|
|
42
|
+
for (const key of Object.keys(DEFAULT_BUDGETS)) {
|
|
43
43
|
const amount = budget[key];
|
|
44
|
+
const path = `budgets.${key}`;
|
|
44
45
|
if (amount === void 0) {
|
|
45
46
|
continue;
|
|
46
47
|
}
|
|
47
48
|
if (typeof amount !== "number" || !Number.isFinite(amount) || amount <= 0) {
|
|
48
49
|
error(
|
|
49
|
-
|
|
50
|
+
path,
|
|
50
51
|
"invalid_type",
|
|
51
|
-
`Expected a positive finite number. Set
|
|
52
|
+
`Expected a positive finite number. Set ${path} to a number greater than zero.`
|
|
53
|
+
);
|
|
54
|
+
} else if (key === "tappableMs" && amount > 5e3) {
|
|
55
|
+
error(
|
|
56
|
+
path,
|
|
57
|
+
"invalid_format",
|
|
58
|
+
"The tappableMs budget cannot exceed 5000. Set budgets.tappableMs to 5000 or less."
|
|
52
59
|
);
|
|
53
60
|
} else if (amount > DEFAULT_BUDGETS[key]) {
|
|
54
61
|
const message = `The ${key} budget exceeds the ${DEFAULT_BUDGETS[key]} default.`;
|
|
55
62
|
if (budget.override === void 0) {
|
|
56
63
|
error(
|
|
57
|
-
|
|
64
|
+
path,
|
|
58
65
|
"budget_override",
|
|
59
66
|
`${message} Add budgets.override.reason to explain the increase.`
|
|
60
67
|
);
|
|
61
68
|
} else {
|
|
62
69
|
issue({
|
|
63
|
-
path
|
|
70
|
+
path,
|
|
64
71
|
code: "budget_override",
|
|
65
72
|
message: `${message} Lower it to the default when the exception is no longer needed.`,
|
|
66
73
|
severity: "warning"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/site-config/sections.ts"],
|
|
4
|
-
"sourcesContent": ["import { record, unknownKeys } from \"./helpers\";\nimport { DEFAULT_BUDGETS, type ConfigIssue } from \"./types\";\n\ntype AddIssue = (value: ConfigIssue) => void;\ntype AddError = (\n path: string,\n code: ConfigIssue[\"code\"],\n message: string,\n) => void;\n\nexport function nested(\n value: unknown,\n path: string,\n keys: readonly string[],\n issue: AddIssue,\n validate: (value: Record<string, unknown>) => void,\n) {\n if (value === undefined) {\n return;\n }\n if (!record(value)) {\n issue({\n path,\n code: \"invalid_type\",\n message: `Expected an object. Set ${path} to an object or remove it.`,\n severity: \"error\",\n });\n return;\n }\n unknownKeys(value, keys, path, issue);\n validate(value);\n}\n\nexport function budgets(value: unknown, issue: AddIssue, error: AddError) {\n nested(\n value,\n \"budgets\",\n [
|
|
5
|
-
"mappings": ";AAAA,SAAS,QAAQ,mBAAmB;AACpC,SAAS,uBAAyC;AAS3C,SAAS,OACd,OACA,MACA,MACA,OACA,UACA;AACA,MAAI,UAAU,QAAW;AACvB;AAAA,EACF;AACA,MAAI,CAAC,OAAO,KAAK,GAAG;AAClB,UAAM;AAAA,MACJ;AAAA,MACA,MAAM;AAAA,MACN,SAAS,2BAA2B,IAAI;AAAA,MACxC,UAAU;AAAA,IACZ,CAAC;AACD;AAAA,EACF;AACA,cAAY,OAAO,MAAM,MAAM,KAAK;AACpC,WAAS,KAAK;AAChB;AAEO,SAAS,QAAQ,OAAgB,OAAiB,OAAiB;AACxE;AAAA,IACE;AAAA,IACA;AAAA,IACA,CAAC,
|
|
4
|
+
"sourcesContent": ["import { record, unknownKeys } from \"./helpers\";\nimport { DEFAULT_BUDGETS, type ConfigIssue } from \"./types\";\n\ntype AddIssue = (value: ConfigIssue) => void;\ntype AddError = (\n path: string,\n code: ConfigIssue[\"code\"],\n message: string,\n) => void;\n\nexport function nested(\n value: unknown,\n path: string,\n keys: readonly string[],\n issue: AddIssue,\n validate: (value: Record<string, unknown>) => void,\n) {\n if (value === undefined) {\n return;\n }\n if (!record(value)) {\n issue({\n path,\n code: \"invalid_type\",\n message: `Expected an object. Set ${path} to an object or remove it.`,\n severity: \"error\",\n });\n return;\n }\n unknownKeys(value, keys, path, issue);\n validate(value);\n}\n\nexport function budgets(value: unknown, issue: AddIssue, error: AddError) {\n nested(\n value,\n \"budgets\",\n [...Object.keys(DEFAULT_BUDGETS), \"override\"],\n issue,\n (budget) => {\n nested(\n budget.override,\n \"budgets.override\",\n [\"reason\"],\n issue,\n (override) => {\n if (typeof override.reason !== \"string\" || !override.reason.trim()) {\n error(\n \"budgets.override.reason\",\n \"invalid_format\",\n \"Expected a non-blank reason. Explain why the default budget must be raised.\",\n );\n }\n },\n );\n for (const key of Object.keys(DEFAULT_BUDGETS) as Array<\n keyof typeof DEFAULT_BUDGETS\n >) {\n const amount = budget[key];\n const path = `budgets.${key}`;\n if (amount === undefined) {\n continue;\n }\n if (\n typeof amount !== \"number\" ||\n !Number.isFinite(amount) ||\n amount <= 0\n ) {\n error(\n path,\n \"invalid_type\",\n `Expected a positive finite number. Set ${path} to a number greater than zero.`,\n );\n } else if (key === \"tappableMs\" && amount > 5_000) {\n error(\n path,\n \"invalid_format\",\n \"The tappableMs budget cannot exceed 5000. Set budgets.tappableMs to 5000 or less.\",\n );\n } else if (amount > DEFAULT_BUDGETS[key]) {\n const message = `The ${key} budget exceeds the ${DEFAULT_BUDGETS[key]} default.`;\n if (budget.override === undefined) {\n error(\n path,\n \"budget_override\",\n `${message} Add budgets.override.reason to explain the increase.`,\n );\n } else {\n issue({\n path,\n code: \"budget_override\",\n message: `${message} Lower it to the default when the exception is no longer needed.`,\n severity: \"warning\",\n });\n }\n }\n }\n },\n );\n}\n\nexport function analytics(value: unknown, issue: AddIssue, error: AddError) {\n nested(value, \"analytics\", [\"forward\"], issue, (analyticsValue) => {\n nested(\n analyticsValue.forward,\n \"analytics.forward\",\n [\"ga4\", \"metaPixel\"],\n issue,\n (forward) => {\n if (\n forward.ga4 !== undefined &&\n (typeof forward.ga4 !== \"string\" ||\n !/^G-[A-Z0-9]+$/.test(forward.ga4))\n ) {\n error(\n \"analytics.forward.ga4\",\n \"invalid_format\",\n \"Expected a GA4 measurement id beginning with G-. Use a value such as G-XXXXXXXXXX.\",\n );\n }\n if (\n forward.metaPixel !== undefined &&\n (typeof forward.metaPixel !== \"string\" ||\n !/^\\d+$/.test(forward.metaPixel))\n ) {\n error(\n \"analytics.forward.metaPixel\",\n \"invalid_format\",\n \"Expected a numeric Meta Pixel id. Use digits only.\",\n );\n }\n },\n );\n });\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,QAAQ,mBAAmB;AACpC,SAAS,uBAAyC;AAS3C,SAAS,OACd,OACA,MACA,MACA,OACA,UACA;AACA,MAAI,UAAU,QAAW;AACvB;AAAA,EACF;AACA,MAAI,CAAC,OAAO,KAAK,GAAG;AAClB,UAAM;AAAA,MACJ;AAAA,MACA,MAAM;AAAA,MACN,SAAS,2BAA2B,IAAI;AAAA,MACxC,UAAU;AAAA,IACZ,CAAC;AACD;AAAA,EACF;AACA,cAAY,OAAO,MAAM,MAAM,KAAK;AACpC,WAAS,KAAK;AAChB;AAEO,SAAS,QAAQ,OAAgB,OAAiB,OAAiB;AACxE;AAAA,IACE;AAAA,IACA;AAAA,IACA,CAAC,GAAG,OAAO,KAAK,eAAe,GAAG,UAAU;AAAA,IAC5C;AAAA,IACA,CAAC,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Q,QAAQ,YACtB,CAAC,gBAAgB,KAAK,QAAQ,GAAG,IACnC;AACA;AAAA,YACE;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AACA,YACE,QAAQ,cAAc,WACrB,OAAO,QAAQ,cAAc,YAC5B,CAAC,QAAQ,KAAK,QAAQ,SAAS,IACjC;AACA;AAAA,YACE;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/site-config/types.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Default site budgets: 200 KB gzipped JavaScript, 50 KB gzipped CSS and
|
|
5
|
-
"mappings": ";AAGO,IAAM,kBAAkB;AAAA,EAC7B,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;
|
|
4
|
+
"sourcesContent": ["/**\n * Default site budgets: 200 KB gzipped JavaScript, 50 KB gzipped CSS, 2500 ms LCP and 3000 ms until the first product card is tappable.\n */\nexport const DEFAULT_BUDGETS = {\n jsKbGz: 200,\n cssKbGz: 50,\n lcpMs: 2500,\n tappableMs: 3000,\n} as const;\n\n/**\n * Package names and patterns allowed globally without a site-specific allowlist entry.\n */\nexport const GLOBAL_PACKAGE_ALLOWLIST = [\n \"react\",\n \"react-dom\",\n \"react-router\",\n \"@react-router/*\",\n \"@zappie/*\",\n \"tailwindcss\",\n \"@tailwindcss/*\",\n \"clsx\",\n \"tailwind-merge\",\n \"class-variance-authority\",\n \"lucide-react\",\n \"date-fns\",\n \"embla-carousel-react\",\n \"framer-motion/motion\",\n \"zod\",\n \"@radix-ui/*\",\n \"sonner\",\n \"vaul\",\n] as const;\n\n/**\n * The store, theme and optional build policies you export from zappie.config.ts.\n */\nexport type ZappieSiteConfig = {\n store: string;\n branches?: string[];\n theme: string;\n prerender?: string[];\n menu?: { hiddenCategories?: string[] };\n packages?: { allow?: string[] };\n /** Time-bounded acknowledgements for advisories that have no fixed version. */\n audit?: {\n ignore?: { id: string; reason: string; until: string }[];\n };\n outbound?: { allow?: string[] };\n /** Add sources to the fixed storefront Content Security Policy. */\n security?: {\n csp?: {\n imgSrc?: string[];\n connectSrc?: string[];\n fontSrc?: string[];\n styleSrc?: string[];\n frameSrc?: string[];\n };\n };\n /** Each budget left out uses DEFAULT_BUDGETS. */\n budgets?: {\n jsKbGz?: number;\n cssKbGz?: number;\n lcpMs?: number;\n /** V15's limit for the first product card to become tappable. Values below 3000 use 3000. */\n tappableMs?: number;\n override?: { reason: string };\n };\n /** Records explained exceptions to storefront readiness checks. */\n readiness?: {\n /** Lets this site skip the initial route discovery requirement. */\n routeDiscovery?: {\n /** Explains why this site does not use initial route discovery. */\n optOut: {\n /** States the constraint that prevents initial route discovery. */\n reason: string;\n };\n };\n };\n analytics?: { forward?: { ga4?: string; metaPixel?: string } };\n /** Where `zappie verify` opens the storefront and finds each catalogue. */\n verify?: {\n /**\n * The route verify opens as the menu, such as /menu. It must list items. Defaults to /.\n * `{menu}` stands for the first menu that holds items and `{branch}` for the default branch,\n * such as `/menu?menu={menu}`.\n */\n startPath?: string;\n /**\n * The page for each menu, with `{menu}` where its id goes and, optionally, `{branch}` for the\n * branch id, such as `/menu?menu={menu}`. Verify then judges each menu on its own page.\n */\n cataloguePath?: string;\n };\n};\n\n/**\n * A configuration diagnostic with its field path, stable code, message and severity.\n */\nexport type ConfigIssue = {\n path: string;\n code:\n | \"invalid_type\"\n | \"missing_required\"\n | \"unknown_key\"\n | \"invalid_format\"\n | \"duplicate\"\n | \"redundant_allowlist\"\n | \"budget_override\";\n message: string;\n severity: \"error\" | \"warning\";\n};\n\n/**\n * Configuration validation results. Warnings alone do not make valid false.\n */\nexport type ConfigValidation = { valid: boolean; issues: ConfigIssue[] };\n"],
|
|
5
|
+
"mappings": ";AAGO,IAAM,kBAAkB;AAAA,EAC7B,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;AAAA,EACP,YAAY;AACd;AAKO,IAAM,2BAA2B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|