@zappie/sdk 0.1.11 → 0.1.13

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +22 -6
  3. package/dist/cart/branch.d.ts +1 -1
  4. package/dist/cart/branch.js +6 -2
  5. package/dist/cart/branch.js.map +2 -2
  6. package/dist/cart/item.d.ts +1 -1
  7. package/dist/cart/quote.d.ts +1 -1
  8. package/dist/checkout-defaults/index.d.ts +17 -11
  9. package/dist/checkout-defaults/index.js +17 -2
  10. package/dist/checkout-defaults/index.js.map +2 -2
  11. package/dist/config/index.d.ts +10 -0
  12. package/dist/customer/navigation.js +2 -7
  13. package/dist/customer/navigation.js.map +2 -2
  14. package/dist/debug.d.ts +1 -1
  15. package/dist/debug.js +1 -1
  16. package/dist/index.d.ts +43 -43
  17. package/dist/index.js +6 -6
  18. package/dist/index.js.map +2 -2
  19. package/dist/integrations/index.d.ts +1 -1
  20. package/dist/internal/return-path.js +17 -0
  21. package/dist/internal/return-path.js.map +7 -0
  22. package/dist/internal.d.ts +1 -1
  23. package/dist/persist/catalogue.d.ts +1 -1
  24. package/dist/react/index.d.ts +1 -1
  25. package/dist/redirect/index.d.ts +15 -0
  26. package/dist/redirect/index.js +22 -0
  27. package/dist/redirect/index.js.map +7 -0
  28. package/dist/server/index.d.ts +87 -2
  29. package/dist/server/index.js +8 -0
  30. package/dist/server/index.js.map +2 -2
  31. package/dist/server/security.js +136 -0
  32. package/dist/server/security.js.map +7 -0
  33. package/dist/server/storefront-url/parse-v2.js +13 -5
  34. package/dist/server/storefront-url/parse-v2.js.map +2 -2
  35. package/dist/server/storefront-url/url.js +3 -1
  36. package/dist/server/storefront-url/url.js.map +2 -2
  37. package/dist/site-config/helpers.js +1 -1
  38. package/dist/site-config/helpers.js.map +2 -2
  39. package/dist/site-config/types.js.map +1 -1
  40. package/dist/site-config/validate.js +25 -9
  41. package/dist/site-config/validate.js.map +2 -2
  42. package/dist/testing/index.d.ts +1 -1
  43. package/dist/transport/search.d.ts +1 -1
  44. package/dist/transport/selected-menu.d.ts +1 -1
  45. package/package.json +9 -5
  46. package/dist/{client-DzUauU-b.d.ts → client-CSOZOwQW.d.ts} +24 -24
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/site-config/validate.ts"],
4
- "sourcesContent": ["import {\n globallyAllowed,\n hostname,\n nonblank,\n packageName,\n record,\n unknownKeys,\n} from \"./helpers\";\nimport { analytics, budgets, nested } from \"./sections\";\nimport type { ConfigIssue, ConfigValidation } from \"./types\";\n\nconst rootKeys = [\n \"store\",\n \"branches\",\n \"theme\",\n \"prerender\",\n \"menu\",\n \"packages\",\n \"audit\",\n \"outbound\",\n \"budgets\",\n \"readiness\",\n \"analytics\",\n] as const;\n\n/**\n * Validate a site configuration and collect errors and warnings without changing it.\n * Checks required fields, unknown keys, allowlists, budgets and analytics settings.\n *\n * @param input - The configuration value to inspect.\n * @returns Diagnostics and a valid flag that is true when there are no errors.\n */\nexport function validateConfig(input: unknown): ConfigValidation {\n const issues: ConfigIssue[] = [];\n const issue = (value: ConfigIssue) => issues.push(value);\n const error = (path: string, code: ConfigIssue[\"code\"], message: string) =>\n issue({ path, code, message, severity: \"error\" });\n if (!record(input)) {\n return {\n valid: false,\n issues: [\n {\n path: \"$\",\n code: \"invalid_type\",\n message:\n \"Expected a configuration object. Export an object from zappie.config.ts.\",\n severity: \"error\",\n },\n ],\n };\n }\n unknownKeys(input, rootKeys, \"\", issue);\n requiredSlug(input.store, \"store\", error);\n theme(input.theme, error);\n stringList(input.branches, \"branches\", error, {\n nonempty: true,\n unique: true,\n slug: true,\n });\n paths(input.prerender, error);\n nested(input.menu, \"menu\", [\"hiddenCategories\"], issue, (value) => {\n stringList(value.hiddenCategories, \"menu.hiddenCategories\", error);\n });\n nested(input.packages, \"packages\", [\"allow\"], issue, (value) => {\n const allow = stringList(value.allow, \"packages.allow\", error);\n allow?.forEach((name, index) => {\n if (globallyAllowed(name)) {\n issue({\n path: `packages.allow[${index}]`,\n code: \"redundant_allowlist\",\n message: `${name} is already globally allowed. Remove it from packages.allow.`,\n severity: \"warning\",\n });\n } else if (!packageName(name)) {\n error(\n `packages.allow[${index}]`,\n \"invalid_format\",\n \"Expected a lowercase npm package name. Use a package name such as lucide-react or @scope/name.\",\n );\n }\n });\n });\n nested(input.outbound, \"outbound\", [\"allow\"], issue, (value) => {\n const allow = stringList(value.allow, \"outbound.allow\", error);\n allow?.forEach((host, index) => {\n if (!hostname(host)) {\n error(\n `outbound.allow[${index}]`,\n \"invalid_format\",\n \"Expected a hostname or leading *. subdomain pattern without a scheme, path, port or IP. Use a value such as api.example.com.\",\n );\n }\n });\n });\n budgets(input.budgets, issue, error);\n nested(\n input.readiness,\n \"readiness\",\n [\"routeDiscovery\"],\n issue,\n (readiness) => {\n nested(\n readiness.routeDiscovery,\n \"readiness.routeDiscovery\",\n [\"optOut\"],\n issue,\n (routeDiscovery) => {\n nested(\n routeDiscovery.optOut,\n \"readiness.routeDiscovery.optOut\",\n [\"reason\"],\n issue,\n (optOut) => {\n if (typeof optOut.reason !== \"string\" || !optOut.reason.trim()) {\n error(\n \"readiness.routeDiscovery.optOut.reason\",\n \"invalid_format\",\n \"Expected a non-blank reason. Explain why the site disables initial route discovery.\",\n );\n }\n },\n );\n },\n );\n },\n );\n analytics(input.analytics, issue, error);\n return {\n valid: !issues.some((entry) => entry.severity === \"error\"),\n issues,\n };\n}\n\ntype AddError = (\n path: string,\n code: ConfigIssue[\"code\"],\n message: string,\n) => void;\n\nfunction requiredSlug(value: unknown, path: string, error: AddError) {\n if (!nonblank(value)) {\n error(\n path,\n value === undefined ? \"missing_required\" : \"invalid_type\",\n `Expected a non-empty storefront slug. Set ${path} to the slug used by createZappie().`,\n );\n }\n}\n\nfunction theme(value: unknown, error: AddError) {\n if (typeof value !== \"string\") {\n error(\n \"theme\",\n value === undefined ? \"missing_required\" : \"invalid_type\",\n \"Expected a relative .json path. Set theme to a value such as ./theme.json.\",\n );\n } else if (\n !/\\.json$/.test(value) ||\n /^(?:[a-z][a-z\\d+.-]*:|\\/|\\\\)/i.test(value) ||\n value.includes(\"\\\\\")\n ) {\n error(\n \"theme\",\n \"invalid_format\",\n \"Expected a relative .json path. Use a value such as ./theme.json.\",\n );\n }\n}\n\nfunction stringList(\n value: unknown,\n path: string,\n error: AddError,\n options: { nonempty?: boolean; unique?: boolean; slug?: boolean } = {},\n) {\n if (value === undefined) {\n return undefined;\n }\n if (\n !Array.isArray(value) ||\n value.some((entry) => typeof entry !== \"string\")\n ) {\n error(\n path,\n \"invalid_type\",\n `Expected an array of strings. Set ${path} to string values.`,\n );\n return undefined;\n }\n if (options.nonempty && value.length === 0) {\n error(\n path,\n \"invalid_format\",\n `Expected at least one value. Add a value to ${path} or remove the field.`,\n );\n }\n value.forEach((entry, index) => {\n if (options.slug && !nonblank(entry)) {\n error(\n `${path}[${index}]`,\n \"invalid_format\",\n \"Expected a non-empty branch slug. Remove the empty value or use a branch slug.\",\n );\n }\n });\n if (options.unique && new Set(value).size !== value.length) {\n error(\n path,\n \"duplicate\",\n `Expected unique values. Remove duplicates from ${path}.`,\n );\n }\n return value;\n}\n\nfunction paths(value: unknown, error: AddError) {\n const values = stringList(value, \"prerender\", error, { unique: true });\n values?.forEach((path, index) => {\n if (!path.startsWith(\"/\")) {\n error(\n `prerender[${index}]`,\n \"invalid_format\",\n \"Expected a route starting with /. Prefix the route with /.\",\n );\n }\n });\n}\n"],
5
- "mappings": ";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,WAAW,SAAS,cAAc;AAG3C,IAAM,WAAW;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AASO,SAAS,eAAe,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n globallyAllowed,\n hostname,\n nonblank,\n packageName,\n record,\n unknownKeys,\n} from \"./helpers\";\nimport { analytics, budgets, nested } from \"./sections\";\nimport type { ConfigIssue, ConfigValidation } from \"./types\";\n\nconst rootKeys = [\n \"store\",\n \"branches\",\n \"theme\",\n \"prerender\",\n \"menu\",\n \"packages\",\n \"audit\",\n \"outbound\",\n \"security\",\n \"budgets\",\n \"readiness\",\n \"analytics\",\n] as const;\n\n/**\n * Validate a site configuration and collect errors and warnings without changing it.\n * Checks required fields, unknown keys, allowlists, budgets and analytics settings.\n *\n * @param input - The configuration value to inspect.\n * @returns Diagnostics and a valid flag that is true when there are no errors.\n */\nexport function validateConfig(input: unknown): ConfigValidation {\n const issues: ConfigIssue[] = [];\n const issue = (value: ConfigIssue) => issues.push(value);\n const error = (path: string, code: ConfigIssue[\"code\"], message: string) =>\n issue({ path, code, message, severity: \"error\" });\n if (!record(input)) {\n return {\n valid: false,\n issues: [\n {\n path: \"$\",\n code: \"invalid_type\",\n message:\n \"Expected a configuration object. Export an object from zappie.config.ts.\",\n severity: \"error\",\n },\n ],\n };\n }\n unknownKeys(input, rootKeys, \"\", issue);\n requiredSlug(input.store, \"store\", error);\n theme(input.theme, error);\n stringList(input.branches, \"branches\", error, {\n nonempty: true,\n unique: true,\n slug: true,\n });\n paths(input.prerender, error);\n nested(input.menu, \"menu\", [\"hiddenCategories\"], issue, (value) => {\n stringList(value.hiddenCategories, \"menu.hiddenCategories\", error);\n });\n nested(input.packages, \"packages\", [\"allow\"], issue, (value) => {\n const allow = stringList(value.allow, \"packages.allow\", error);\n allow?.forEach((name, index) => {\n if (globallyAllowed(name)) {\n issue({\n path: `packages.allow[${index}]`,\n code: \"redundant_allowlist\",\n message: `${name} is already globally allowed. Remove it from packages.allow.`,\n severity: \"warning\",\n });\n } else if (!packageName(name)) {\n error(\n `packages.allow[${index}]`,\n \"invalid_format\",\n \"Expected a lowercase npm package name. Use a package name such as lucide-react or @scope/name.\",\n );\n }\n });\n });\n nested(input.outbound, \"outbound\", [\"allow\"], issue, (value) => {\n hostList(value.allow, \"outbound.allow\", error);\n });\n nested(input.security, \"security\", [\"csp\"], issue, (security) => {\n nested(\n security.csp,\n \"security.csp\",\n [\"imgSrc\", \"connectSrc\", \"fontSrc\", \"styleSrc\", \"frameSrc\"],\n issue,\n (csp) => {\n for (const [name, value] of Object.entries(csp)) {\n hostList(value, `security.csp.${name}`, error);\n }\n },\n );\n });\n budgets(input.budgets, issue, error);\n nested(\n input.readiness,\n \"readiness\",\n [\"routeDiscovery\"],\n issue,\n (readiness) => {\n nested(\n readiness.routeDiscovery,\n \"readiness.routeDiscovery\",\n [\"optOut\"],\n issue,\n (routeDiscovery) => {\n nested(\n routeDiscovery.optOut,\n \"readiness.routeDiscovery.optOut\",\n [\"reason\"],\n issue,\n (optOut) => {\n if (typeof optOut.reason !== \"string\" || !optOut.reason.trim()) {\n error(\n \"readiness.routeDiscovery.optOut.reason\",\n \"invalid_format\",\n \"Expected a non-blank reason. Explain why the site disables initial route discovery.\",\n );\n }\n },\n );\n },\n );\n },\n );\n analytics(input.analytics, issue, error);\n return {\n valid: !issues.some((entry) => entry.severity === \"error\"),\n issues,\n };\n}\n\ntype AddError = (\n path: string,\n code: ConfigIssue[\"code\"],\n message: string,\n) => void;\n\nfunction requiredSlug(value: unknown, path: string, error: AddError) {\n if (!nonblank(value)) {\n error(\n path,\n value === undefined ? \"missing_required\" : \"invalid_type\",\n `Expected a non-empty storefront slug. Set ${path} to the slug used by createZappie().`,\n );\n }\n}\n\nfunction theme(value: unknown, error: AddError) {\n if (typeof value !== \"string\") {\n error(\n \"theme\",\n value === undefined ? \"missing_required\" : \"invalid_type\",\n \"Expected a relative .json path. Set theme to a value such as ./theme.json.\",\n );\n } else if (\n !/\\.json$/.test(value) ||\n /^(?:[a-z][a-z\\d+.-]*:|\\/|\\\\)/i.test(value) ||\n value.includes(\"\\\\\")\n ) {\n error(\n \"theme\",\n \"invalid_format\",\n \"Expected a relative .json path. Use a value such as ./theme.json.\",\n );\n }\n}\n\nfunction stringList(\n value: unknown,\n path: string,\n error: AddError,\n options: { nonempty?: boolean; unique?: boolean; slug?: boolean } = {},\n) {\n if (value === undefined) {\n return undefined;\n }\n if (\n !Array.isArray(value) ||\n value.some((entry) => typeof entry !== \"string\")\n ) {\n error(\n path,\n \"invalid_type\",\n `Expected an array of strings. Set ${path} to string values.`,\n );\n return undefined;\n }\n if (options.nonempty && value.length === 0) {\n error(\n path,\n \"invalid_format\",\n `Expected at least one value. Add a value to ${path} or remove the field.`,\n );\n }\n value.forEach((entry, index) => {\n if (options.slug && !nonblank(entry)) {\n error(\n `${path}[${index}]`,\n \"invalid_format\",\n \"Expected a non-empty branch slug. Remove the empty value or use a branch slug.\",\n );\n }\n });\n if (options.unique && new Set(value).size !== value.length) {\n error(\n path,\n \"duplicate\",\n `Expected unique values. Remove duplicates from ${path}.`,\n );\n }\n return value;\n}\n\nfunction hostList(value: unknown, path: string, error: AddError) {\n stringList(value, path, error)?.forEach((host, index) => {\n if (!hostname(host)) {\n error(\n `${path}[${index}]`,\n \"invalid_format\",\n \"Expected a hostname or leading *. subdomain pattern without a scheme, path, port or IP. Use a value such as api.example.com.\",\n );\n }\n });\n}\n\nfunction paths(value: unknown, error: AddError) {\n const values = stringList(value, \"prerender\", error, { unique: true });\n values?.forEach((path, index) => {\n if (!path.startsWith(\"/\")) {\n error(\n `prerender[${index}]`,\n \"invalid_format\",\n \"Expected a route starting with /. Prefix the route with /.\",\n );\n }\n });\n}\n"],
5
+ "mappings": ";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,WAAW,SAAS,cAAc;AAG3C,IAAM,WAAW;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AASO,SAAS,eAAe,OA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ACnB;AAAA,QACE,GAAG,IAAI,IAAI,KAAK;AAAA,QAChB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEA,SAAS,MAAM,OAAgB,OAAiB;AAC9C,QAAM,SAAS,WAAW,OAAO,aAAa,OAAO,EAAE,QAAQ,KAAK,CAAC;AACrE,UAAQ,QAAQ,CAAC,MAAM,UAAU;AAC/B,QAAI,CAAC,KAAK,WAAW,GAAG,GAAG;AACzB;AAAA,QACE,aAAa,KAAK;AAAA,QAClB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- import { T as Transport, e as ZappieErrorCode, S as StorageLike, c as StoreResource, M as MenuResource, d as ZappieEvents, C as Cache } from '../client-DzUauU-b.js';
1
+ import { T as Transport, e as ZappieErrorCode, S as StorageLike, c as StoreResource, M as MenuResource, d as ZappieEvents, C as Cache } from '../client-CSOZOwQW.js';
2
2
  import { S as Store, a as Menu, F as Formatters } from '../models-D__QbqEd.js';
3
3
  export { VERSION } from '../index.js';
4
4
  import { d as CartModule, b as CartLineInput } from '../types-gQXU2gEA.js';
@@ -1,5 +1,5 @@
1
1
  import { a as Menu } from '../models-D__QbqEd.js';
2
- import { j as SearchRequest, k as SearchPage } from '../client-DzUauU-b.js';
2
+ import { j as SearchRequest, k as SearchPage } from '../client-CSOZOwQW.js';
3
3
  import '../types-gQXU2gEA.js';
4
4
 
5
5
  /** Loaded only when search is used; request authentication/retries stay in REST. */
@@ -1,3 +1,3 @@
1
- export { z as SelectedMenu, h as SelectedMenuRequest, i as SelectedMenuResponse, B as SelectedMenuTransport, D as createSelectedMenuReader, F as selectedMenu, G as selectedMenuKey } from '../client-DzUauU-b.js';
1
+ export { z as SelectedMenu, h as SelectedMenuRequest, i as SelectedMenuResponse, B as SelectedMenuTransport, D as createSelectedMenuReader, F as selectedMenu, G as selectedMenuKey } from '../client-CSOZOwQW.js';
2
2
  import '../models-D__QbqEd.js';
3
3
  import '../types-gQXU2gEA.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zappie/sdk",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Typed, framework-agnostic client for Zappie menus, carts, checkout, auth and events.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -29,6 +29,10 @@
29
29
  "types": "./dist/url/index.d.ts",
30
30
  "import": "./dist/url/index.js"
31
31
  },
32
+ "./redirect": {
33
+ "types": "./dist/redirect/index.d.ts",
34
+ "import": "./dist/redirect/index.js"
35
+ },
32
36
  "./testing": {
33
37
  "types": "./dist/testing/index.d.ts",
34
38
  "import": "./dist/testing/index.js"
@@ -108,16 +112,16 @@
108
112
  },
109
113
  "repository": {
110
114
  "type": "git",
111
- "url": "git+https://github.com/zappie/storefront.git",
115
+ "url": "git+https://github.com/zappie/storefront-packages.git",
112
116
  "directory": "packages/sdk"
113
117
  },
114
118
  "license": "MIT",
115
- "homepage": "https://github.com/zappie/storefront#readme",
119
+ "homepage": "https://github.com/zappie/storefront-packages#readme",
116
120
  "bugs": {
117
- "url": "https://github.com/zappie/storefront/issues"
121
+ "url": "https://github.com/zappie/storefront-packages/issues"
118
122
  },
119
123
  "scripts": {
120
- "build": "tsup && tsup --config tsup.checkout.config.ts && tsup --config tsup.checkout-defaults.config.ts && tsup --config tsup.customer.config.ts && tsup --config tsup.places.config.ts && tsup --config tsup.url.config.ts && tsup --config tsup.visits.config.ts && tsup --config tsup.pricing.config.ts && tsup --config tsup.site-config.config.ts && tsup --config tsup.template.config.ts && node ../../scripts/release-packages/build-modules.mjs",
124
+ "build": "tsup && tsup --config tsup.checkout.config.ts && tsup --config tsup.checkout-defaults.config.ts && tsup --config tsup.customer.config.ts && tsup --config tsup.places.config.ts && tsup --config tsup.url.config.ts && tsup --config tsup.redirect.config.ts && tsup --config tsup.visits.config.ts && tsup --config tsup.pricing.config.ts && tsup --config tsup.site-config.config.ts && tsup --config tsup.template.config.ts && node ../../scripts/release-packages/build-modules.mjs",
121
125
  "test": "vitest run --root ../.. packages/sdk/test",
122
126
  "size": "node ../../scripts/release-packages/size-sdk.mjs && size-limit"
123
127
  }
@@ -1,6 +1,30 @@
1
1
  import { a as Menu, C as CategoryPage, S as Store, I as Item, M as Money, F as Formatters } from './models-D__QbqEd.js';
2
2
  import { Q as QuoteRequest, g as WireQuote, i as CartIssueCode, d as CartModule, b as CartLineInput } from './types-gQXU2gEA.js';
3
3
 
4
+ /** Stable public error codes. */
5
+ type ZappieErrorCode = "network_error" | "timeout" | "rate_limited" | "unauthorized" | "forbidden_origin" | "not_found" | "store_not_found" | "branch_not_found" | "item_not_found" | "cart_invalid" | "invalid_request" | "version_unsupported" | "server_error";
6
+ /** Context attached to an SDK failure. */
7
+ type ErrorDetails = {
8
+ status?: number;
9
+ param?: string;
10
+ docUrl?: string;
11
+ requestId?: string;
12
+ retryable?: boolean;
13
+ cause?: unknown;
14
+ };
15
+ /** An SDK error you can handle by its stable code. */
16
+ declare class ZappieError extends Error {
17
+ readonly code: ZappieErrorCode;
18
+ readonly status?: number;
19
+ readonly param?: string;
20
+ readonly docUrl: string;
21
+ readonly requestId?: string;
22
+ readonly retryable: boolean;
23
+ constructor(code: ZappieErrorCode, message: string, details?: ErrorDetails);
24
+ }
25
+ /** Check whether a thrown value is a ZappieError. */
26
+ declare function isZappieError(error: unknown): error is ZappieError;
27
+
4
28
  /**
5
29
  * The store, branch, order context and source menu that identify a saved catalogue.
6
30
  */
@@ -198,30 +222,6 @@ type ZappieConfig = {
198
222
  };
199
223
  declare function validateConfig(config: ZappieConfig, secret?: boolean): "test" | "live";
200
224
 
201
- /** Stable public error codes. */
202
- type ZappieErrorCode = "network_error" | "timeout" | "rate_limited" | "unauthorized" | "forbidden_origin" | "not_found" | "store_not_found" | "branch_not_found" | "item_not_found" | "cart_invalid" | "invalid_request" | "version_unsupported" | "server_error";
203
- /** Context attached to an SDK failure. */
204
- type ErrorDetails = {
205
- status?: number;
206
- param?: string;
207
- docUrl?: string;
208
- requestId?: string;
209
- retryable?: boolean;
210
- cause?: unknown;
211
- };
212
- /** An SDK error you can handle by its stable code. */
213
- declare class ZappieError extends Error {
214
- readonly code: ZappieErrorCode;
215
- readonly status?: number;
216
- readonly param?: string;
217
- readonly docUrl: string;
218
- readonly requestId?: string;
219
- readonly retryable: boolean;
220
- constructor(code: ZappieErrorCode, message: string, details?: ErrorDetails);
221
- }
222
- /** Check whether a thrown value is a ZappieError. */
223
- declare function isZappieError(error: unknown): error is ZappieError;
224
-
225
225
  type CacheEntry<T> = {
226
226
  value?: T;
227
227
  fetchedAt: number;