@ecomweb/storefront-kit 0.2.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.
Files changed (165) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +55 -0
  3. package/dist/api/client.js +162 -0
  4. package/dist/api/client.js.map +1 -0
  5. package/dist/api/index.js +7 -0
  6. package/dist/api/index.js.map +1 -0
  7. package/dist/api/proxy.js +145 -0
  8. package/dist/api/proxy.js.map +1 -0
  9. package/dist/api/response.js +55 -0
  10. package/dist/api/response.js.map +1 -0
  11. package/dist/api/server-client.js +159 -0
  12. package/dist/api/server-client.js.map +1 -0
  13. package/dist/auth/client-ip.js +44 -0
  14. package/dist/auth/client-ip.js.map +1 -0
  15. package/dist/auth/context.js +125 -0
  16. package/dist/auth/context.js.map +1 -0
  17. package/dist/auth/cookies.js +97 -0
  18. package/dist/auth/cookies.js.map +1 -0
  19. package/dist/auth/error-copy.js +49 -0
  20. package/dist/auth/error-copy.js.map +1 -0
  21. package/dist/auth/password-policy.js +29 -0
  22. package/dist/auth/password-policy.js.map +1 -0
  23. package/dist/auth/route-handlers.js +337 -0
  24. package/dist/auth/route-handlers.js.map +1 -0
  25. package/dist/auth/safe-redirect.js +20 -0
  26. package/dist/auth/safe-redirect.js.map +1 -0
  27. package/dist/auth/sdk.js +76 -0
  28. package/dist/auth/sdk.js.map +1 -0
  29. package/dist/auth/session-refresh.js +81 -0
  30. package/dist/auth/session-refresh.js.map +1 -0
  31. package/dist/auth/session.js +26 -0
  32. package/dist/auth/session.js.map +1 -0
  33. package/dist/auth/use-public-auth-config.js +29 -0
  34. package/dist/auth/use-public-auth-config.js.map +1 -0
  35. package/dist/cart/api.js +60 -0
  36. package/dist/cart/api.js.map +1 -0
  37. package/dist/cart/server-context.js +279 -0
  38. package/dist/cart/server-context.js.map +1 -0
  39. package/dist/cart/types.js +1 -0
  40. package/dist/cart/types.js.map +1 -0
  41. package/dist/cart/utils.js +49 -0
  42. package/dist/cart/utils.js.map +1 -0
  43. package/dist/checkout/get-payment-state.js +15 -0
  44. package/dist/checkout/get-payment-state.js.map +1 -0
  45. package/dist/checkout/initiate-gateway-payment.js +13 -0
  46. package/dist/checkout/initiate-gateway-payment.js.map +1 -0
  47. package/dist/checkout/order-handoff.js +61 -0
  48. package/dist/checkout/order-handoff.js.map +1 -0
  49. package/dist/checkout/payment-redirect.js +11 -0
  50. package/dist/checkout/payment-redirect.js.map +1 -0
  51. package/dist/checkout/payment-state-poll.js +45 -0
  52. package/dist/checkout/payment-state-poll.js.map +1 -0
  53. package/dist/checkout/start-gateway-redirect.js +16 -0
  54. package/dist/checkout/start-gateway-redirect.js.map +1 -0
  55. package/dist/checkout/stock-issues.js +35 -0
  56. package/dist/checkout/stock-issues.js.map +1 -0
  57. package/dist/checkout/success-state.js +15 -0
  58. package/dist/checkout/success-state.js.map +1 -0
  59. package/dist/checkout/types.js +1 -0
  60. package/dist/checkout/types.js.map +1 -0
  61. package/dist/checkout/use-checkout.js +256 -0
  62. package/dist/checkout/use-checkout.js.map +1 -0
  63. package/dist/checkout/utils.js +7 -0
  64. package/dist/checkout/utils.js.map +1 -0
  65. package/dist/config/index.js +7 -0
  66. package/dist/config/index.js.map +1 -0
  67. package/dist/config/log-level.js +8 -0
  68. package/dist/config/log-level.js.map +1 -0
  69. package/dist/config/mode.js +18 -0
  70. package/dist/config/mode.js.map +1 -0
  71. package/dist/config/public.js +115 -0
  72. package/dist/config/public.js.map +1 -0
  73. package/dist/config/schema.js +70 -0
  74. package/dist/config/schema.js.map +1 -0
  75. package/dist/config/server.js +68 -0
  76. package/dist/config/server.js.map +1 -0
  77. package/dist/config.d.ts +16 -0
  78. package/dist/config.js +15 -0
  79. package/dist/config.js.map +1 -0
  80. package/dist/currency.js +68 -0
  81. package/dist/currency.js.map +1 -0
  82. package/dist/index.d.ts +968 -0
  83. package/dist/index.js +146 -0
  84. package/dist/index.js.map +1 -0
  85. package/dist/interfaces/api.types.js +1 -0
  86. package/dist/interfaces/api.types.js.map +1 -0
  87. package/dist/interfaces/index.js +2 -0
  88. package/dist/interfaces/index.js.map +1 -0
  89. package/dist/logging.js +42 -0
  90. package/dist/logging.js.map +1 -0
  91. package/dist/middleware/create-storefront-middleware.js +175 -0
  92. package/dist/middleware/create-storefront-middleware.js.map +1 -0
  93. package/dist/middleware.d.ts +24 -0
  94. package/dist/middleware.js +9 -0
  95. package/dist/middleware.js.map +1 -0
  96. package/dist/mode-1ZKDELPZ.d.ts +16 -0
  97. package/dist/notices.js +31 -0
  98. package/dist/notices.js.map +1 -0
  99. package/dist/orders/api-client.js +32 -0
  100. package/dist/orders/api-client.js.map +1 -0
  101. package/dist/orders/derive-progress.js +36 -0
  102. package/dist/orders/derive-progress.js.map +1 -0
  103. package/dist/orders/index.js +6 -0
  104. package/dist/orders/index.js.map +1 -0
  105. package/dist/orders/types.js +13 -0
  106. package/dist/orders/types.js.map +1 -0
  107. package/dist/orders/use-order-status.js +137 -0
  108. package/dist/orders/use-order-status.js.map +1 -0
  109. package/dist/promotions/use-promotion-validation.js +106 -0
  110. package/dist/promotions/use-promotion-validation.js.map +1 -0
  111. package/dist/promotions/utils.js +40 -0
  112. package/dist/promotions/utils.js.map +1 -0
  113. package/dist/provider.js +25 -0
  114. package/dist/provider.js.map +1 -0
  115. package/dist/redirects/index.js +2 -0
  116. package/dist/redirects/index.js.map +1 -0
  117. package/dist/redirects/lookup-redirect.js +13 -0
  118. package/dist/redirects/lookup-redirect.js.map +1 -0
  119. package/dist/request/public-url.js +20 -0
  120. package/dist/request/public-url.js.map +1 -0
  121. package/dist/schema-CEMKsCwh.d.ts +52 -0
  122. package/dist/sdk.js +33 -0
  123. package/dist/sdk.js.map +1 -0
  124. package/dist/server/routes.js +56 -0
  125. package/dist/server/routes.js.map +1 -0
  126. package/dist/server.d.ts +58 -0
  127. package/dist/server.js +19 -0
  128. package/dist/server.js.map +1 -0
  129. package/dist/shipping/format-shipping-option.js +12 -0
  130. package/dist/shipping/format-shipping-option.js.map +1 -0
  131. package/dist/shipping/location-areas.js +104 -0
  132. package/dist/shipping/location-areas.js.map +1 -0
  133. package/dist/shipping/messages.js +19 -0
  134. package/dist/shipping/messages.js.map +1 -0
  135. package/dist/shipping/shipping-calculation-reducer.js +75 -0
  136. package/dist/shipping/shipping-calculation-reducer.js.map +1 -0
  137. package/dist/shipping/use-shipping-calculation.js +84 -0
  138. package/dist/shipping/use-shipping-calculation.js.map +1 -0
  139. package/dist/shipping/utils.js +18 -0
  140. package/dist/shipping/utils.js.map +1 -0
  141. package/dist/storage.js +116 -0
  142. package/dist/storage.js.map +1 -0
  143. package/dist/store/store-context.js +72 -0
  144. package/dist/store/store-context.js.map +1 -0
  145. package/dist/store-scope/index.js +33 -0
  146. package/dist/store-scope/index.js.map +1 -0
  147. package/dist/store-scope/root.js +15 -0
  148. package/dist/store-scope/root.js.map +1 -0
  149. package/dist/store-scope/store-url.js +45 -0
  150. package/dist/store-scope/store-url.js.map +1 -0
  151. package/dist/stores/basic-settings.js +67 -0
  152. package/dist/stores/basic-settings.js.map +1 -0
  153. package/dist/stores/cached.js +20 -0
  154. package/dist/stores/cached.js.map +1 -0
  155. package/dist/stores/get-store-by-host.js +38 -0
  156. package/dist/stores/get-store-by-host.js.map +1 -0
  157. package/dist/stores/index.js +7 -0
  158. package/dist/stores/index.js.map +1 -0
  159. package/dist/stores/metadata.js +19 -0
  160. package/dist/stores/metadata.js.map +1 -0
  161. package/dist/stores/store-path.js +9 -0
  162. package/dist/stores/store-path.js.map +1 -0
  163. package/dist/stores/store-suspension.js +14 -0
  164. package/dist/stores/store-suspension.js.map +1 -0
  165. package/package.json +64 -0
@@ -0,0 +1,33 @@
1
+ import { publicConfig } from "../config/public.js";
2
+ const isSingle = () => publicConfig().mode === "single";
3
+ async function resolveStoreRef(params) {
4
+ if (isSingle()) return publicConfig().storeRef;
5
+ const { storeRef } = await params ?? {};
6
+ return storeRef;
7
+ }
8
+ function normalize(path) {
9
+ if (!path) return "";
10
+ return path.startsWith("/") || path.startsWith("?") || path.startsWith("#") ? path : `/${path}`;
11
+ }
12
+ function multiTenantStorePath(storeRef, path = "") {
13
+ return `/store/${encodeURIComponent(storeRef)}${normalize(path)}`;
14
+ }
15
+ function storePath(storeRef, path = "") {
16
+ if (isSingle()) {
17
+ const p = normalize(path);
18
+ return p.startsWith("/") ? p : `/${p}`;
19
+ }
20
+ return multiTenantStorePath(storeRef, path);
21
+ }
22
+ function storeApiPath(storeRef, subpath) {
23
+ const rest = subpath.replace(/^\/+/, "");
24
+ if (isSingle()) return `/api/${rest}`;
25
+ return `/store/${encodeURIComponent(storeRef)}/api/${rest}`;
26
+ }
27
+ export {
28
+ multiTenantStorePath,
29
+ resolveStoreRef,
30
+ storeApiPath,
31
+ storePath
32
+ };
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/store-scope/index.ts"],"sourcesContent":["import { publicConfig } from \"../config/public\";\n\n/**\n * The one place that knows which store a request serves and what its URLs look\n * like.\n * - multi: every store lives under /store/<ref>, the ref comes from the route.\n * - single: the store (ECOMWEB_STORE_REF) is the whole site, so pages live at\n * the root and same-origin API routes under /api.\n */\n\nconst isSingle = () => publicConfig().mode === \"single\";\n\nexport async function resolveStoreRef(\n params?: Promise<{ storeRef?: string }>\n): Promise<string> {\n if (isSingle()) return publicConfig().storeRef as string;\n const { storeRef } = (await params) ?? {};\n return storeRef as string;\n}\n\nfunction normalize(path: string): string {\n if (!path) return \"\";\n return path.startsWith(\"/\") || path.startsWith(\"?\") || path.startsWith(\"#\")\n ? path\n : `/${path}`;\n}\n\n/** The multi-tenant path, whatever the configured mode (middleware uses it). */\nexport function multiTenantStorePath(storeRef: string, path = \"\"): string {\n return `/store/${encodeURIComponent(storeRef)}${normalize(path)}`;\n}\n\nexport function storePath(storeRef: string, path = \"\"): string {\n if (isSingle()) {\n const p = normalize(path);\n return p.startsWith(\"/\") ? p : `/${p}`;\n }\n return multiTenantStorePath(storeRef, path);\n}\n\nexport function storeApiPath(storeRef: string, subpath: string): string {\n const rest = subpath.replace(/^\\/+/, \"\");\n if (isSingle()) return `/api/${rest}`;\n return `/store/${encodeURIComponent(storeRef)}/api/${rest}`;\n}\n"],"mappings":"AAAA,SAAS,oBAAoB;AAU7B,MAAM,WAAW,MAAM,aAAa,EAAE,SAAS;AAE/C,eAAsB,gBACpB,QACiB;AACjB,MAAI,SAAS,EAAG,QAAO,aAAa,EAAE;AACtC,QAAM,EAAE,SAAS,IAAK,MAAM,UAAW,CAAC;AACxC,SAAO;AACT;AAEA,SAAS,UAAU,MAAsB;AACvC,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG,IACtE,OACA,IAAI,IAAI;AACd;AAGO,SAAS,qBAAqB,UAAkB,OAAO,IAAY;AACxE,SAAO,UAAU,mBAAmB,QAAQ,CAAC,GAAG,UAAU,IAAI,CAAC;AACjE;AAEO,SAAS,UAAU,UAAkB,OAAO,IAAY;AAC7D,MAAI,SAAS,GAAG;AACd,UAAM,IAAI,UAAU,IAAI;AACxB,WAAO,EAAE,WAAW,GAAG,IAAI,IAAI,IAAI,CAAC;AAAA,EACtC;AACA,SAAO,qBAAqB,UAAU,IAAI;AAC5C;AAEO,SAAS,aAAa,UAAkB,SAAyB;AACtE,QAAM,OAAO,QAAQ,QAAQ,QAAQ,EAAE;AACvC,MAAI,SAAS,EAAG,QAAO,QAAQ,IAAI;AACnC,SAAO,UAAU,mBAAmB,QAAQ,CAAC,QAAQ,IAAI;AAC3D;","names":[]}
@@ -0,0 +1,15 @@
1
+ import "server-only";
2
+ import { headers } from "next/headers";
3
+ import { publicConfig } from "../config/public.js";
4
+ import { getStoreByHost } from "../stores/get-store-by-host.js";
5
+ async function resolveRootStoreRef() {
6
+ const config = publicConfig();
7
+ if (config.mode === "single") return config.storeRef;
8
+ const host = (await headers()).get("host") || "";
9
+ const { storeRef } = await getStoreByHost(host);
10
+ return storeRef;
11
+ }
12
+ export {
13
+ resolveRootStoreRef
14
+ };
15
+ //# sourceMappingURL=root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/store-scope/root.ts"],"sourcesContent":["import \"server-only\";\nimport { headers } from \"next/headers\";\nimport { publicConfig } from \"../config/public\";\nimport { getStoreByHost } from \"../stores/get-store-by-host\";\n\n/**\n * The store for routes outside /store/<ref> (robots, sitemap, icons, manifest,\n * root /api/auth). Single-store: the configured store. Multi-tenant: only the\n * Host can name it.\n */\nexport async function resolveRootStoreRef(): Promise<string | null> {\n const config = publicConfig();\n if (config.mode === \"single\") return config.storeRef;\n const host = (await headers()).get(\"host\") || \"\";\n const { storeRef } = await getStoreByHost(host);\n return storeRef;\n}\n"],"mappings":"AAAA,OAAO;AACP,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAO/B,eAAsB,sBAA8C;AAClE,QAAM,SAAS,aAAa;AAC5B,MAAI,OAAO,SAAS,SAAU,QAAO,OAAO;AAC5C,QAAM,QAAQ,MAAM,QAAQ,GAAG,IAAI,MAAM,KAAK;AAC9C,QAAM,EAAE,SAAS,IAAI,MAAM,eAAe,IAAI;AAC9C,SAAO;AACT;","names":[]}
@@ -0,0 +1,45 @@
1
+ import { publicConfig } from "../config/public.js";
2
+ function buildStoreUrl(store, path) {
3
+ const config = publicConfig();
4
+ if (config.mode === "single") {
5
+ if (!path) return config.appUrl;
6
+ return `${config.appUrl}/${path.replace(/^\/+/, "")}`;
7
+ }
8
+ const isLocal = config.appBaseUrlFlag === "local";
9
+ let subdomain = "";
10
+ let custom_domain = "";
11
+ let store_ref = "";
12
+ if ("ref" in store && "subdomain" in store && "custom_domain" in store) {
13
+ subdomain = store.subdomain || "";
14
+ custom_domain = store.custom_domain || "";
15
+ store_ref = store.ref || "";
16
+ } else if ("config" in store && store.config) {
17
+ subdomain = store.config.subdomain || "";
18
+ custom_domain = store.config.custom_domain || "";
19
+ store_ref = store.ref || "";
20
+ } else if ("subdomain" in store && "custom_domain" in store) {
21
+ subdomain = store.subdomain || "";
22
+ custom_domain = store.custom_domain || "";
23
+ store_ref = store.ref || "";
24
+ }
25
+ if (isLocal) {
26
+ const origin = typeof window === "undefined" && process.env.APP_BASE_URL?.trim() || "http://localhost:3002";
27
+ const baseUrl2 = `${origin}/store/${store_ref}`;
28
+ return path ? `${baseUrl2}/${path}` : baseUrl2;
29
+ }
30
+ if (custom_domain) {
31
+ const baseUrl2 = `https://${custom_domain}`;
32
+ return path ? `${baseUrl2}/${path}` : baseUrl2;
33
+ }
34
+ if (subdomain) {
35
+ const platformDomain = config.platformDomainSuffix ?? "ecomsite.app";
36
+ const baseUrl2 = `https://${subdomain}.${platformDomain}`;
37
+ return path ? `${baseUrl2}/${path}` : baseUrl2;
38
+ }
39
+ const baseUrl = `/store/${store_ref}`;
40
+ return path ? `${baseUrl}/${path}` : baseUrl;
41
+ }
42
+ export {
43
+ buildStoreUrl
44
+ };
45
+ //# sourceMappingURL=store-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/store-scope/store-url.ts"],"sourcesContent":["import type { StoreConfig, StoreConfigurationInfo } from \"@ecomweb/sdk\";\nimport { publicConfig } from \"../config/public\";\n\n/**\n * Build store URL based on environment and store configuration\n * @param store - Store object with subdomain and custom_domain\n * @param path - Optional path to append to the store URL\n * @returns Complete store URL\n *\n * @example\n * // Local development\n * buildStoreUrl({ id: 1, subdomain: 'mystore', custom_domain: null })\n * // Returns: 'http://localhost:3000/store/1'\n *\n * // Production with subdomain\n * buildStoreUrl({ id: 1, subdomain: 'mystore', custom_domain: null })\n * // Returns: 'https://mystore.{NEXT_PUBLIC_PLATFORM_DOMAIN_SUFFIX}'\n *\n * // Production with custom domain\n * buildStoreUrl({ id: 1, subdomain: 'mystore', custom_domain: 'mystore.com' })\n * // Returns: 'https://mystore.com'\n *\n * // With path\n * buildStoreUrl({ id: 1, subdomain: 'mystore', custom_domain: null }, 'about')\n * // Returns: 'https://mystore.{NEXT_PUBLIC_PLATFORM_DOMAIN_SUFFIX}/about'\n */\nexport function buildStoreUrl(\n store:\n | { ref: string; subdomain: string | null; custom_domain: string | null }\n | StoreConfig\n | StoreConfigurationInfo,\n path?: string\n): string {\n const config = publicConfig();\n // Single-store: an absolute URL on this site; `store` is ignored.\n if (config.mode === \"single\") {\n if (!path) return config.appUrl;\n return `${config.appUrl}/${path.replace(/^\\/+/, \"\")}`;\n }\n\n const isLocal = config.appBaseUrlFlag === \"local\";\n let subdomain = \"\";\n let custom_domain = \"\";\n let store_ref = \"\";\n\n if (\"ref\" in store && \"subdomain\" in store && \"custom_domain\" in store) {\n subdomain = store.subdomain || \"\";\n custom_domain = store.custom_domain || \"\";\n store_ref = (store as any).ref || \"\";\n } else if (\"config\" in store && store.config) {\n subdomain = store.config.subdomain || \"\";\n custom_domain = store.config.custom_domain || \"\";\n store_ref = (store as any).ref || \"\";\n } else if (\"subdomain\" in store && \"custom_domain\" in store) {\n subdomain = store.subdomain || \"\";\n custom_domain = store.custom_domain || \"\";\n store_ref = (store as any).ref || \"\";\n }\n\n if (isLocal) {\n // Server-only var, so the browser always gets the dev default (as before).\n const origin =\n (typeof window === \"undefined\" && process.env.APP_BASE_URL?.trim()) ||\n \"http://localhost:3002\";\n const baseUrl = `${origin}/store/${store_ref}`;\n return path ? `${baseUrl}/${path}` : baseUrl;\n }\n\n if (custom_domain) {\n const baseUrl = `https://${custom_domain}`;\n return path ? `${baseUrl}/${path}` : baseUrl;\n }\n\n if (subdomain) {\n const platformDomain = config.platformDomainSuffix ?? \"ecomsite.app\";\n const baseUrl = `https://${subdomain}.${platformDomain}`;\n return path ? `${baseUrl}/${path}` : baseUrl;\n }\n\n // Fallback: use store ref format\n const baseUrl = `/store/${store_ref}`;\n return path ? `${baseUrl}/${path}` : baseUrl;\n}\n"],"mappings":"AACA,SAAS,oBAAoB;AAyBtB,SAAS,cACd,OAIA,MACQ;AACR,QAAM,SAAS,aAAa;AAE5B,MAAI,OAAO,SAAS,UAAU;AAC5B,QAAI,CAAC,KAAM,QAAO,OAAO;AACzB,WAAO,GAAG,OAAO,MAAM,IAAI,KAAK,QAAQ,QAAQ,EAAE,CAAC;AAAA,EACrD;AAEA,QAAM,UAAU,OAAO,mBAAmB;AAC1C,MAAI,YAAY;AAChB,MAAI,gBAAgB;AACpB,MAAI,YAAY;AAEhB,MAAI,SAAS,SAAS,eAAe,SAAS,mBAAmB,OAAO;AACtE,gBAAY,MAAM,aAAa;AAC/B,oBAAgB,MAAM,iBAAiB;AACvC,gBAAa,MAAc,OAAO;AAAA,EACpC,WAAW,YAAY,SAAS,MAAM,QAAQ;AAC5C,gBAAY,MAAM,OAAO,aAAa;AACtC,oBAAgB,MAAM,OAAO,iBAAiB;AAC9C,gBAAa,MAAc,OAAO;AAAA,EACpC,WAAW,eAAe,SAAS,mBAAmB,OAAO;AAC3D,gBAAY,MAAM,aAAa;AAC/B,oBAAgB,MAAM,iBAAiB;AACvC,gBAAa,MAAc,OAAO;AAAA,EACpC;AAEA,MAAI,SAAS;AAEX,UAAM,SACH,OAAO,WAAW,eAAe,QAAQ,IAAI,cAAc,KAAK,KACjE;AACF,UAAMA,WAAU,GAAG,MAAM,UAAU,SAAS;AAC5C,WAAO,OAAO,GAAGA,QAAO,IAAI,IAAI,KAAKA;AAAA,EACvC;AAEA,MAAI,eAAe;AACjB,UAAMA,WAAU,WAAW,aAAa;AACxC,WAAO,OAAO,GAAGA,QAAO,IAAI,IAAI,KAAKA;AAAA,EACvC;AAEA,MAAI,WAAW;AACb,UAAM,iBAAiB,OAAO,wBAAwB;AACtD,UAAMA,WAAU,WAAW,SAAS,IAAI,cAAc;AACtD,WAAO,OAAO,GAAGA,QAAO,IAAI,IAAI,KAAKA;AAAA,EACvC;AAGA,QAAM,UAAU,UAAU,SAAS;AACnC,SAAO,OAAO,GAAG,OAAO,IAAI,IAAI,KAAK;AACvC;","names":["baseUrl"]}
@@ -0,0 +1,67 @@
1
+ function str(v) {
2
+ return typeof v === "string" && v.trim() !== "" ? v.trim() : null;
3
+ }
4
+ const HEX_COLOR = /^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
5
+ function color(v) {
6
+ const s = str(v);
7
+ return s && HEX_COLOR.test(s) ? s : null;
8
+ }
9
+ function first(...values) {
10
+ for (const v of values) if (v !== null) return v;
11
+ return null;
12
+ }
13
+ function readBasicSettings(store) {
14
+ const settings = store.settings ?? {};
15
+ const theme = store.theme_config ?? settings.theme_config ?? {};
16
+ const nav = settings.navigation ?? {};
17
+ const legal = settings.legal_links ?? {};
18
+ return {
19
+ brandColor: first(color(settings.brand_color), color(theme.theme_color)),
20
+ backgroundColor: color(theme.background_color),
21
+ navigation: {
22
+ mainMenuRef: first(
23
+ str(nav.main_menu_ref),
24
+ str(theme.header?.main_menu_ref),
25
+ str(theme.menu?.main_menu)
26
+ ),
27
+ topbarMessage: first(
28
+ str(nav.topbar_message),
29
+ str(theme.header?.topbar_message),
30
+ str(theme.topbar?.message)
31
+ ),
32
+ customerSupportMenuRef: first(
33
+ str(nav.customer_support_menu_ref),
34
+ str(theme.footer?.customer_support_menu_ref),
35
+ str(theme.menu?.customer_support_menu)
36
+ ),
37
+ aboutUsMenuRef: first(
38
+ str(nav.about_us_menu_ref),
39
+ str(theme.footer?.about_us_menu_ref),
40
+ str(theme.menu?.about_us_menu)
41
+ ),
42
+ copyrightText: first(
43
+ str(nav.copyright_text),
44
+ str(theme.footer?.copyright_text)
45
+ )
46
+ },
47
+ legalLinks: {
48
+ termsLink: first(str(legal.terms), str(theme.checkout?.term_link)),
49
+ policyLink: first(str(legal.privacy), str(theme.checkout?.policy_link))
50
+ },
51
+ homepageCollectionSlug: first(
52
+ str(settings.homepage_collection_slug),
53
+ str(theme.homepage?.collection_slug)
54
+ )
55
+ };
56
+ }
57
+ function resolveLegalHref(link, fallbackPath, toStoreUrl) {
58
+ const target = link ?? fallbackPath;
59
+ if (!target) return "#";
60
+ if (/^https?:\/\//i.test(target)) return target;
61
+ return toStoreUrl(target.startsWith("/") ? target : `/${target}`);
62
+ }
63
+ export {
64
+ readBasicSettings,
65
+ resolveLegalHref
66
+ };
67
+ //# sourceMappingURL=basic-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/stores/basic-settings.ts"],"sourcesContent":["/**\n * The store settings that survive the page-builder retirement, read from their\n * new `settings.*` homes with a fallback to the legacy `theme_config` paths.\n * The fallbacks go once the API migration (spec §6) has run everywhere.\n */\n\ntype Loose = Record<string, any>;\n\nexport interface StoreLike {\n settings?: Loose | null;\n theme_config?: Loose | null;\n}\n\nexport interface BasicSettings {\n brandColor: string | null;\n backgroundColor: string | null;\n navigation: {\n mainMenuRef: string | null;\n topbarMessage: string | null;\n customerSupportMenuRef: string | null;\n aboutUsMenuRef: string | null;\n copyrightText: string | null;\n };\n legalLinks: { termsLink: string | null; policyLink: string | null };\n homepageCollectionSlug: string | null;\n}\n\nfunction str(v: unknown): string | null {\n return typeof v === \"string\" && v.trim() !== \"\" ? v.trim() : null;\n}\n\nconst HEX_COLOR = /^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;\n\n/** Only hex colors: the value is interpolated into a <style> tag. */\nfunction color(v: unknown): string | null {\n const s = str(v);\n return s && HEX_COLOR.test(s) ? s : null;\n}\n\nfunction first<T>(...values: (T | null)[]): T | null {\n for (const v of values) if (v !== null) return v;\n return null;\n}\n\nexport function readBasicSettings(store: StoreLike): BasicSettings {\n const settings: Loose = store.settings ?? {};\n const theme: Loose = store.theme_config ?? settings.theme_config ?? {};\n const nav: Loose = settings.navigation ?? {};\n const legal: Loose = settings.legal_links ?? {};\n\n return {\n brandColor: first(color(settings.brand_color), color(theme.theme_color)),\n backgroundColor: color(theme.background_color),\n navigation: {\n mainMenuRef: first(\n str(nav.main_menu_ref),\n str(theme.header?.main_menu_ref),\n str(theme.menu?.main_menu)\n ),\n topbarMessage: first(\n str(nav.topbar_message),\n str(theme.header?.topbar_message),\n str(theme.topbar?.message)\n ),\n customerSupportMenuRef: first(\n str(nav.customer_support_menu_ref),\n str(theme.footer?.customer_support_menu_ref),\n str(theme.menu?.customer_support_menu)\n ),\n aboutUsMenuRef: first(\n str(nav.about_us_menu_ref),\n str(theme.footer?.about_us_menu_ref),\n str(theme.menu?.about_us_menu)\n ),\n copyrightText: first(\n str(nav.copyright_text),\n str(theme.footer?.copyright_text)\n ),\n },\n legalLinks: {\n termsLink: first(str(legal.terms), str(theme.checkout?.term_link)),\n policyLink: first(str(legal.privacy), str(theme.checkout?.policy_link)),\n },\n homepageCollectionSlug: first(\n str(settings.homepage_collection_slug),\n str(theme.homepage?.collection_slug)\n ),\n };\n}\n\nexport function resolveLegalHref(\n link: string | null,\n fallbackPath: string | null,\n toStoreUrl: (path: string) => string\n): string {\n const target = link ?? fallbackPath;\n if (!target) return \"#\";\n if (/^https?:\\/\\//i.test(target)) return target;\n return toStoreUrl(target.startsWith(\"/\") ? target : `/${target}`);\n}\n"],"mappings":"AA2BA,SAAS,IAAI,GAA2B;AACtC,SAAO,OAAO,MAAM,YAAY,EAAE,KAAK,MAAM,KAAK,EAAE,KAAK,IAAI;AAC/D;AAEA,MAAM,YAAY;AAGlB,SAAS,MAAM,GAA2B;AACxC,QAAM,IAAI,IAAI,CAAC;AACf,SAAO,KAAK,UAAU,KAAK,CAAC,IAAI,IAAI;AACtC;AAEA,SAAS,SAAY,QAAgC;AACnD,aAAW,KAAK,OAAQ,KAAI,MAAM,KAAM,QAAO;AAC/C,SAAO;AACT;AAEO,SAAS,kBAAkB,OAAiC;AACjE,QAAM,WAAkB,MAAM,YAAY,CAAC;AAC3C,QAAM,QAAe,MAAM,gBAAgB,SAAS,gBAAgB,CAAC;AACrE,QAAM,MAAa,SAAS,cAAc,CAAC;AAC3C,QAAM,QAAe,SAAS,eAAe,CAAC;AAE9C,SAAO;AAAA,IACL,YAAY,MAAM,MAAM,SAAS,WAAW,GAAG,MAAM,MAAM,WAAW,CAAC;AAAA,IACvE,iBAAiB,MAAM,MAAM,gBAAgB;AAAA,IAC7C,YAAY;AAAA,MACV,aAAa;AAAA,QACX,IAAI,IAAI,aAAa;AAAA,QACrB,IAAI,MAAM,QAAQ,aAAa;AAAA,QAC/B,IAAI,MAAM,MAAM,SAAS;AAAA,MAC3B;AAAA,MACA,eAAe;AAAA,QACb,IAAI,IAAI,cAAc;AAAA,QACtB,IAAI,MAAM,QAAQ,cAAc;AAAA,QAChC,IAAI,MAAM,QAAQ,OAAO;AAAA,MAC3B;AAAA,MACA,wBAAwB;AAAA,QACtB,IAAI,IAAI,yBAAyB;AAAA,QACjC,IAAI,MAAM,QAAQ,yBAAyB;AAAA,QAC3C,IAAI,MAAM,MAAM,qBAAqB;AAAA,MACvC;AAAA,MACA,gBAAgB;AAAA,QACd,IAAI,IAAI,iBAAiB;AAAA,QACzB,IAAI,MAAM,QAAQ,iBAAiB;AAAA,QACnC,IAAI,MAAM,MAAM,aAAa;AAAA,MAC/B;AAAA,MACA,eAAe;AAAA,QACb,IAAI,IAAI,cAAc;AAAA,QACtB,IAAI,MAAM,QAAQ,cAAc;AAAA,MAClC;AAAA,IACF;AAAA,IACA,YAAY;AAAA,MACV,WAAW,MAAM,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,UAAU,SAAS,CAAC;AAAA,MACjE,YAAY,MAAM,IAAI,MAAM,OAAO,GAAG,IAAI,MAAM,UAAU,WAAW,CAAC;AAAA,IACxE;AAAA,IACA,wBAAwB;AAAA,MACtB,IAAI,SAAS,wBAAwB;AAAA,MACrC,IAAI,MAAM,UAAU,eAAe;AAAA,IACrC;AAAA,EACF;AACF;AAEO,SAAS,iBACd,MACA,cACA,YACQ;AACR,QAAM,SAAS,QAAQ;AACvB,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,gBAAgB,KAAK,MAAM,EAAG,QAAO;AACzC,SAAO,WAAW,OAAO,WAAW,GAAG,IAAI,SAAS,IAAI,MAAM,EAAE;AAClE;","names":[]}
@@ -0,0 +1,20 @@
1
+ import { sdk } from "../sdk.js";
2
+ import { cache } from "react";
3
+ const getCachedStoreInternal = cache(
4
+ async (storeRef) => {
5
+ return sdk.stores.getById(storeRef, {
6
+ includeConfig: true,
7
+ includeSettings: true,
8
+ includeEmbeddedScripts: true
9
+ });
10
+ }
11
+ );
12
+ const getCachedStore = cache(
13
+ async (storeRef, options) => {
14
+ return getCachedStoreInternal(storeRef);
15
+ }
16
+ );
17
+ export {
18
+ getCachedStore
19
+ };
20
+ //# sourceMappingURL=cached.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/stores/cached.ts"],"sourcesContent":["import type { StoreConfigurationInfo } from \"@ecomweb/sdk\";\nimport { sdk } from \"../sdk\";\nimport { cache } from \"react\";\n\nconst getCachedStoreInternal = cache(\n async (storeRef: string): Promise<StoreConfigurationInfo | null> => {\n return sdk.stores.getById(storeRef, {\n includeConfig: true,\n includeSettings: true,\n includeEmbeddedScripts: true,\n });\n }\n);\n\nexport const getCachedStore = cache(\n async (\n storeRef: string,\n options?: {\n includeConfig?: boolean;\n includeSettings?: boolean;\n includeBlogSettings?: boolean;\n }\n ): Promise<StoreConfigurationInfo | null> => {\n return getCachedStoreInternal(storeRef);\n }\n);\n"],"mappings":"AACA,SAAS,WAAW;AACpB,SAAS,aAAa;AAEtB,MAAM,yBAAyB;AAAA,EAC7B,OAAO,aAA6D;AAClE,WAAO,IAAI,OAAO,QAAQ,UAAU;AAAA,MAClC,eAAe;AAAA,MACf,iBAAiB;AAAA,MACjB,wBAAwB;AAAA,IAC1B,CAAC;AAAA,EACH;AACF;AAEO,MAAM,iBAAiB;AAAA,EAC5B,OACE,UACA,YAK2C;AAC3C,WAAO,uBAAuB,QAAQ;AAAA,EACxC;AACF;","names":[]}
@@ -0,0 +1,38 @@
1
+ import { sdk } from "../sdk.js";
2
+ import { isStoreSuspendedError } from "./store-suspension.js";
3
+ import { publicConfig } from "../config.js";
4
+ async function getStoreByHost(host) {
5
+ if (host.includes("localhost") || host.includes("127.0.0.1")) {
6
+ return {
7
+ storeRef: null,
8
+ domain: null,
9
+ isSubDomain: false,
10
+ suspended: false
11
+ };
12
+ }
13
+ let storeRef = null;
14
+ let domain = null;
15
+ let suspended = false;
16
+ const parts = host.split(".");
17
+ const platformDomain = publicConfig().platformDomainSuffix ?? "ecomsite.app";
18
+ const isSubDomain = host.indexOf(platformDomain) >= 0 && parts.length === 3;
19
+ try {
20
+ const lookupValue = isSubDomain ? parts[0] : host;
21
+ const foundStore = await sdk.stores.getByDomain(lookupValue);
22
+ if (foundStore?.ref) {
23
+ storeRef = foundStore.ref;
24
+ domain = foundStore.config?.custom_domain || null;
25
+ }
26
+ } catch (error) {
27
+ if (isStoreSuspendedError(error)) {
28
+ suspended = true;
29
+ } else {
30
+ console.error("Store not found for host:", host);
31
+ }
32
+ }
33
+ return { storeRef, domain, isSubDomain, suspended };
34
+ }
35
+ export {
36
+ getStoreByHost
37
+ };
38
+ //# sourceMappingURL=get-store-by-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/stores/get-store-by-host.ts"],"sourcesContent":["import { sdk } from \"../sdk\";\nimport { isStoreSuspendedError } from \"./store-suspension\";\nimport { publicConfig } from \"../config\";\n\n/**\n * Get store ref and domain info from host\n * Used by middleware and API routes to determine which store is being accessed\n */\nexport async function getStoreByHost(host: string): Promise<{\n storeRef: string | null;\n domain: string | null;\n isSubDomain: boolean;\n // True when the backend identified a store for this host but rejected it\n // with STORE_SUSPENDED. There is no `ref` to route on in that case — the\n // 403 response carries no store-identifying payload — so the caller must\n // handle this without a storeRef (see proxy.ts, which rewrites to a\n // platform-level suspended page rather than `/store/<ref>`).\n suspended: boolean;\n}> {\n if (host.includes(\"localhost\") || host.includes(\"127.0.0.1\")) {\n return {\n storeRef: null,\n domain: null,\n isSubDomain: false,\n suspended: false,\n };\n }\n\n let storeRef: string | null = null;\n let domain: string | null = null;\n let suspended = false;\n\n const parts = host.split(\".\");\n const platformDomain =\n publicConfig().platformDomainSuffix ?? \"ecomsite.app\";\n const isSubDomain = host.indexOf(platformDomain) >= 0 && parts.length === 3;\n\n try {\n const lookupValue = isSubDomain ? parts[0] : host;\n const foundStore = await sdk.stores.getByDomain(lookupValue);\n\n if (foundStore?.ref) {\n storeRef = foundStore.ref;\n domain = foundStore.config?.custom_domain || null;\n }\n } catch (error) {\n if (isStoreSuspendedError(error)) {\n suspended = true;\n } else {\n console.error(\"Store not found for host:\", host);\n }\n }\n\n return { storeRef, domain, isSubDomain, suspended };\n}\n"],"mappings":"AAAA,SAAS,WAAW;AACpB,SAAS,6BAA6B;AACtC,SAAS,oBAAoB;AAM7B,eAAsB,eAAe,MAUlC;AACD,MAAI,KAAK,SAAS,WAAW,KAAK,KAAK,SAAS,WAAW,GAAG;AAC5D,WAAO;AAAA,MACL,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,WAAW;AAAA,IACb;AAAA,EACF;AAEA,MAAI,WAA0B;AAC9B,MAAI,SAAwB;AAC5B,MAAI,YAAY;AAEhB,QAAM,QAAQ,KAAK,MAAM,GAAG;AAC5B,QAAM,iBACJ,aAAa,EAAE,wBAAwB;AACzC,QAAM,cAAc,KAAK,QAAQ,cAAc,KAAK,KAAK,MAAM,WAAW;AAE1E,MAAI;AACF,UAAM,cAAc,cAAc,MAAM,CAAC,IAAI;AAC7C,UAAM,aAAa,MAAM,IAAI,OAAO,YAAY,WAAW;AAE3D,QAAI,YAAY,KAAK;AACnB,iBAAW,WAAW;AACtB,eAAS,WAAW,QAAQ,iBAAiB;AAAA,IAC/C;AAAA,EACF,SAAS,OAAO;AACd,QAAI,sBAAsB,KAAK,GAAG;AAChC,kBAAY;AAAA,IACd,OAAO;AACL,cAAQ,MAAM,6BAA6B,IAAI;AAAA,IACjD;AAAA,EACF;AAEA,SAAO,EAAE,UAAU,QAAQ,aAAa,UAAU;AACpD;","names":[]}
@@ -0,0 +1,7 @@
1
+ import { getCachedStore } from "./cached.js";
2
+ import { getStoreByHost } from "./get-store-by-host.js";
3
+ export {
4
+ getCachedStore,
5
+ getStoreByHost
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/stores/index.ts"],"sourcesContent":["// Store API - Pure API Client Architecture\n// All operations use backend API exclusively - no direct database calls\n// Supabase used only for auth and storage\n\nexport { getCachedStore } from \"./cached\";\nexport { getStoreByHost } from \"./get-store-by-host\";\n"],"mappings":"AAIA,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;","names":[]}
@@ -0,0 +1,19 @@
1
+ import { isStoreSuspendedError } from "./store-suspension.js";
2
+ const SUSPENDED_STORE_METADATA = {
3
+ title: "Store suspended",
4
+ description: "This store is temporarily unavailable. If you are the store owner, contact support.",
5
+ robots: "noindex, nofollow"
6
+ };
7
+ async function withSuspendedStoreMetadataFallback(fn) {
8
+ try {
9
+ return await fn();
10
+ } catch (error) {
11
+ if (isStoreSuspendedError(error)) return SUSPENDED_STORE_METADATA;
12
+ throw error;
13
+ }
14
+ }
15
+ export {
16
+ SUSPENDED_STORE_METADATA,
17
+ withSuspendedStoreMetadataFallback
18
+ };
19
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/stores/metadata.ts"],"sourcesContent":["import type { Metadata } from \"next\";\nimport { isStoreSuspendedError } from \"./store-suspension\";\n\n/**\n * The metadata Next.js shows for a store's suspended pages. Never includes\n * `platform_suspension_reason` -- it's internal, written by an admin for\n * other admins.\n */\nexport const SUSPENDED_STORE_METADATA: Metadata = {\n title: \"Store suspended\",\n description:\n \"This store is temporarily unavailable. If you are the store owner, contact support.\",\n robots: \"noindex, nofollow\",\n};\n\n/**\n * Wraps a leaf page's `generateMetadata` body so a STORE_SUSPENDED lookup\n * doesn't crash the whole route.\n *\n * Next.js resolves every matched segment's `generateMetadata` unconditionally\n * to build <head> -- this happens independently of whatever the parent\n * `StoreLayout` eventually renders (it can skip rendering `children` for a\n * suspended store, but that doesn't stop Next from having already awaited\n * this segment's own `generateMetadata`). So each page that calls\n * `getCachedStore` in its own `generateMetadata` needs this, not just the\n * layout's.\n */\nexport async function withSuspendedStoreMetadataFallback(\n fn: () => Promise<Metadata>\n): Promise<Metadata> {\n try {\n return await fn();\n } catch (error) {\n if (isStoreSuspendedError(error)) return SUSPENDED_STORE_METADATA;\n throw error;\n }\n}\n"],"mappings":"AACA,SAAS,6BAA6B;AAO/B,MAAM,2BAAqC;AAAA,EAChD,OAAO;AAAA,EACP,aACE;AAAA,EACF,QAAQ;AACV;AAcA,eAAsB,mCACpB,IACmB;AACnB,MAAI;AACF,WAAO,MAAM,GAAG;AAAA,EAClB,SAAS,OAAO;AACd,QAAI,sBAAsB,KAAK,EAAG,QAAO;AACzC,UAAM;AAAA,EACR;AACF;","names":[]}
@@ -0,0 +1,9 @@
1
+ function refFromPathname(pathname) {
2
+ if (typeof pathname !== "string") return null;
3
+ const match = /^\/store\/([^/?#]+)/.exec(pathname);
4
+ return match ? match[1] : null;
5
+ }
6
+ export {
7
+ refFromPathname
8
+ };
9
+ //# sourceMappingURL=store-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/stores/store-path.ts"],"sourcesContent":["// Recovering a store's ref from a platform-host URL.\n//\n// Lives in lib/ rather than beside the hook that uses it for a practical\n// reason: vitest.config.ts collects only \"lib/**\" spec files (plus root-level\n// ones), so a spec anywhere under hooks/ would never run — it would pass by\n// never executing.\n\n/**\n * The `<ref>` in `/store/<ref>/...`, or null anywhere else.\n *\n * Used only as a fallback for navigation callers that did not pass a storeRef\n * explicitly. An explicit ref always wins, since a caller may legitimately\n * link to a different store than the one currently being viewed.\n */\nexport function refFromPathname(pathname: string): string | null {\n if (typeof pathname !== \"string\") return null;\n const match = /^\\/store\\/([^/?#]+)/.exec(pathname);\n return match ? match[1] : null;\n}\n"],"mappings":"AAcO,SAAS,gBAAgB,UAAiC;AAC/D,MAAI,OAAO,aAAa,SAAU,QAAO;AACzC,QAAM,QAAQ,sBAAsB,KAAK,QAAQ;AACjD,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC5B;","names":[]}
@@ -0,0 +1,14 @@
1
+ import { ApiClientError } from "@ecomweb/sdk";
2
+ function isStoreSuspendedError(error) {
3
+ return error instanceof ApiClientError && error.code === "STORE_SUSPENDED";
4
+ }
5
+ const STORE_SUSPENDED_REDIRECT_PATH = "/store-suspended";
6
+ function isStoreSuspendedResponseBody(data) {
7
+ return typeof data === "object" && data !== null && data.code === "STORE_SUSPENDED";
8
+ }
9
+ export {
10
+ STORE_SUSPENDED_REDIRECT_PATH,
11
+ isStoreSuspendedError,
12
+ isStoreSuspendedResponseBody
13
+ };
14
+ //# sourceMappingURL=store-suspension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/stores/store-suspension.ts"],"sourcesContent":["import { ApiClientError } from \"@ecomweb/sdk\";\n\n/**\n * True when `error` is the backend's signal that a PLATFORM admin suspended\n * this store (`STORE_SUSPENDED`, 403) — distinct from the store simply not\n * existing or not being active (`STORE_UNAVAILABLE`, 404), which the SDK's\n * `unwrapOrNull` already collapses to a plain `null` return, no throw.\n *\n * Both `getCachedStore` (path-based `/store/<ref>` resolution) and\n * `getStoreByHost` (custom-domain / subdomain resolution) call\n * `sdk.stores.getById` / `getByDomain`, which throw an `ApiClientError` for\n * any non-2xx, non-404 response — so this is the single place that decides\n * \"was that a suspension\" for both entry points.\n */\nexport function isStoreSuspendedError(error: unknown): boolean {\n return error instanceof ApiClientError && error.code === \"STORE_SUSPENDED\";\n}\n\n/**\n * Where the axios interceptor (lib/api/client.ts) sends the browser when a\n * client-side call discovers mid-session that the store was suspended.\n */\nexport const STORE_SUSPENDED_REDIRECT_PATH = \"/store-suspended\";\n\n/**\n * True when a raw HTTP error body — shaped the way `ecomweb`'s\n * `BusinessException` serialises it, `{ code, message, details, timestamp }`\n * — is a STORE_SUSPENDED response.\n *\n * `isStoreSuspendedError` above classifies an already-thrown\n * `ApiClientError` from the SDK's own `stores.getById`/`getByDomain` calls.\n * This is the raw-response-body twin used by the axios interceptor, which\n * sees the error before the SDK has had a chance to construct one — and\n * which runs for *every* store-scoped call (cart, orders, products, ...),\n * not just store resolution. A suspension surfacing from an in-browser\n * interaction after the initial page load (add-to-cart, checkout, a review\n * submission) isn't covered by the one-time check in\n * `app/store/[storeRef]/layout.tsx`; this is what catches that.\n */\nexport function isStoreSuspendedResponseBody(data: unknown): boolean {\n return (\n typeof data === \"object\" &&\n data !== null &&\n (data as { code?: unknown }).code === \"STORE_SUSPENDED\"\n );\n}\n"],"mappings":"AAAA,SAAS,sBAAsB;AAcxB,SAAS,sBAAsB,OAAyB;AAC7D,SAAO,iBAAiB,kBAAkB,MAAM,SAAS;AAC3D;AAMO,MAAM,gCAAgC;AAiBtC,SAAS,6BAA6B,MAAwB;AACnE,SACE,OAAO,SAAS,YAChB,SAAS,QACR,KAA4B,SAAS;AAE1C;","names":[]}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@ecomweb/storefront-kit",
3
+ "version": "0.2.0",
4
+ "description": "Headless storefront logic for ecomweb: auth, cart, checkout, API proxy",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/travistech20/ecomweb-storefront.git",
11
+ "directory": "packages/storefront-kit"
12
+ },
13
+ "main": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
19
+ },
20
+ "./server": {
21
+ "types": "./dist/server.d.ts",
22
+ "import": "./dist/server.js"
23
+ },
24
+ "./middleware": {
25
+ "types": "./dist/middleware.d.ts",
26
+ "import": "./dist/middleware.js"
27
+ },
28
+ "./config": {
29
+ "types": "./dist/config.d.ts",
30
+ "import": "./dist/config.js"
31
+ }
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "files": [
37
+ "dist",
38
+ "README.md",
39
+ "LICENSE"
40
+ ],
41
+ "dependencies": {
42
+ "axios": "^1.11.0",
43
+ "currency.js": "^2.0.4",
44
+ "server-only": "^0.0.1",
45
+ "zod": "^4.1.12",
46
+ "@ecomweb/sdk": "^0.2.0"
47
+ },
48
+ "peerDependencies": {
49
+ "next": ">=16",
50
+ "react": ">=19"
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^24.10.1",
54
+ "@types/react": "19.2.2",
55
+ "next": "16.0.11",
56
+ "react": "19.2.8",
57
+ "tsup": "^8.5.0",
58
+ "typescript": "^5.9.3"
59
+ },
60
+ "scripts": {
61
+ "build": "tsup && node scripts/add-js-extensions.mjs",
62
+ "typecheck": "tsc --noEmit"
63
+ }
64
+ }