@ecomiq/storefront 1.1.4 → 1.1.9

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 (44) hide show
  1. package/README.md +3 -2
  2. package/dist/{chunk-EADDSNJS.js → chunk-64GLOWMJ.js} +14 -4
  3. package/dist/chunk-64GLOWMJ.js.map +1 -0
  4. package/dist/{chunk-3URTJY6X.js → chunk-AKD5IDEB.js} +16 -13
  5. package/dist/chunk-AKD5IDEB.js.map +1 -0
  6. package/dist/{chunk-YSD62KQM.js → chunk-EFEVJJWF.js} +102 -36
  7. package/dist/chunk-EFEVJJWF.js.map +1 -0
  8. package/dist/{chunk-6TMU4OXP.js → chunk-NAJQB5DN.js} +5 -7
  9. package/dist/chunk-NAJQB5DN.js.map +1 -0
  10. package/dist/{chunk-ASFU32ZM.js → chunk-OABDGTBI.js} +25 -8
  11. package/dist/chunk-OABDGTBI.js.map +1 -0
  12. package/dist/chunk-Q4U5OEUT.js +21 -0
  13. package/dist/chunk-Q4U5OEUT.js.map +1 -0
  14. package/dist/chunks/client.css +1 -1
  15. package/dist/chunks/client.css.map +1 -1
  16. package/dist/chunks/client.d.ts +1456 -228
  17. package/dist/chunks/client.js +559 -200
  18. package/dist/chunks/client.js.map +1 -1
  19. package/dist/chunks/config.js +3 -2
  20. package/dist/chunks/core-public.d.ts +2 -2
  21. package/dist/chunks/core-public.js +6 -12
  22. package/dist/chunks/core-public.js.map +1 -1
  23. package/dist/chunks/server-nextjs.d.ts +3 -3
  24. package/dist/chunks/server-nextjs.js +40 -14
  25. package/dist/chunks/server-nextjs.js.map +1 -1
  26. package/dist/chunks/server-tanstack.d.ts +3 -3
  27. package/dist/chunks/server-tanstack.js +15 -8
  28. package/dist/chunks/server-tanstack.js.map +1 -1
  29. package/dist/{collection-BHD4hhQa.d.ts → collection-DU7gREXS.d.ts} +491 -38
  30. package/dist/{ecomiq-oauth-password-plugin-gw2dPyYb.d.ts → ecomiq-oauth-password-plugin-B_gMdGuc.d.ts} +33 -31
  31. package/dist/nextjs/api.js +2 -1
  32. package/dist/nextjs/api.js.map +1 -1
  33. package/dist/nextjs.server.d.ts +17 -0
  34. package/dist/react/client.css +1 -1
  35. package/dist/tanstack/api.js +3 -2
  36. package/dist/tanstack/api.js.map +1 -1
  37. package/dist/tanstack.d.ts +0 -1
  38. package/dist/tanstack.server.d.ts +17 -0
  39. package/package.json +13 -3
  40. package/dist/chunk-3URTJY6X.js.map +0 -1
  41. package/dist/chunk-6TMU4OXP.js.map +0 -1
  42. package/dist/chunk-ASFU32ZM.js.map +0 -1
  43. package/dist/chunk-EADDSNJS.js.map +0 -1
  44. package/dist/chunk-YSD62KQM.js.map +0 -1
package/README.md CHANGED
@@ -67,7 +67,8 @@ Si defines `slugStore`, `getPublicStore` usa ese slug (útil en localhost). Si n
67
67
  | `@ecomiq/storefront/nextjs/api` | Proxy `/api/store/*` (App Router) |
68
68
  | `@ecomiq/storefront/nextjs/css` | Tailwind mínimo (opcional) |
69
69
  | `@ecomiq/storefront/nextjs/postcss` | PostCSS de referencia |
70
- | `@ecomiq/storefront/tanstack` | TanStack server + reexport client (misma API client que `/nextjs`) |
70
+ | `@ecomiq/storefront/tanstack` | **Client:** reexport `/react` (hooks, provider) |
71
+ | `@ecomiq/storefront/tanstack/server` | **Server:** `getPublicStore`, BFF, auth (loaders, `createServerFn`) |
71
72
  | `@ecomiq/storefront/tanstack/api` | Proxy `/api/store/*` (server routes) |
72
73
 
73
74
  Importa hooks y `EcomiqProvider` desde `@ecomiq/storefront/react`. El build npm separa server (`react-server`), vanilla (raíz) y React (`/react`) para App Router.
@@ -249,7 +250,7 @@ export function EcomiqRootProvider({
249
250
  ```tsx
250
251
  // src/routes/__root.tsx
251
252
  import { createRootRoute, Outlet } from "@tanstack/react-router";
252
- import { getPublicStore } from "@ecomiq/storefront/tanstack";
253
+ import { getPublicStore } from "@ecomiq/storefront/tanstack/server";
253
254
  import { EcomiqRootProvider } from "../components/ecomiq-provider";
254
255
 
255
256
  export const Route = createRootRoute({
@@ -1,6 +1,6 @@
1
+ import { DEFAULT_CURRENCY_CODE } from './chunk-Q4U5OEUT.js';
1
2
  import { z } from 'zod';
2
3
 
3
- // src/core/models/store.ts
4
4
  var StorefrontCheckoutSettingsSchema = z.object({
5
5
  allowGuestCheckout: z.boolean().optional(),
6
6
  identityScope: z.enum(["store", "tenant", "global"]).optional(),
@@ -54,8 +54,17 @@ var StorefrontCmsCustomScriptsSchema = z.object({
54
54
  head: z.string().nullable().optional(),
55
55
  bodyEnd: z.string().nullable().optional()
56
56
  });
57
+ var StorefrontCmsChannelsSchema = z.object({
58
+ storefront: z.object({
59
+ enabled: z.boolean().optional()
60
+ }).optional(),
61
+ pos: z.object({
62
+ enabled: z.boolean().optional()
63
+ }).optional()
64
+ });
57
65
  var StorefrontCmsSettingsSchema = z.object({
58
66
  themeKey: z.string().optional(),
67
+ channels: StorefrontCmsChannelsSchema.optional(),
59
68
  branding: StorefrontCmsBrandingSchema.optional(),
60
69
  seo: StorefrontCmsSeoSchema.optional(),
61
70
  contact: StorefrontCmsContactSchema.optional(),
@@ -67,6 +76,7 @@ var StorefrontCmsPageSchema = z.object({
67
76
  id: z.string(),
68
77
  name: z.string(),
69
78
  slug: z.string(),
79
+ channel: z.string().transform((value) => value.toLowerCase()).pipe(z.enum(["storefront", "pos"])).default("storefront"),
70
80
  layout: z.string().optional(),
71
81
  version: z.number().optional(),
72
82
  settings: z.record(z.string(), z.unknown()).optional().nullable(),
@@ -118,7 +128,7 @@ function normalizeStorefrontSettingsPayload(v) {
118
128
  const parsed = StorefrontSettingsLegacyFlatSchema.safeParse(raw);
119
129
  if (!parsed.success) return body;
120
130
  const l = parsed.data;
121
- const currency = l.currency?.trim() ? l.currency : "PEN";
131
+ const currency = l.currency?.trim() ? l.currency : DEFAULT_CURRENCY_CODE;
122
132
  const language = l.language?.trim() ? l.language : "es";
123
133
  const slug = l.slug?.trim() ? l.slug : l.id;
124
134
  return {
@@ -202,5 +212,5 @@ var StorefrontSettingsSchema = z.preprocess(
202
212
  );
203
213
 
204
214
  export { StorefrontSettingsSchema, StorefrontStoreSchema };
205
- //# sourceMappingURL=chunk-EADDSNJS.js.map
206
- //# sourceMappingURL=chunk-EADDSNJS.js.map
215
+ //# sourceMappingURL=chunk-64GLOWMJ.js.map
216
+ //# sourceMappingURL=chunk-64GLOWMJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/models/store.ts"],"names":[],"mappings":";;;AAGO,IAAM,gCAAA,GAAmC,EAAE,MAAA,CAAO;AAAA,EACvD,kBAAA,EAAoB,CAAA,CAAE,OAAA,EAAQ,CAAE,QAAA,EAAS;AAAA,EACzC,aAAA,EAAe,EAAE,IAAA,CAAK,CAAC,SAAS,QAAA,EAAU,QAAQ,CAAC,CAAA,CAAE,QAAA,EAAS;AAAA,EAC9D,eAAe,CAAA,CAAE,KAAA,CAAM,EAAE,MAAA,EAAQ,EAAE,QAAA;AACrC,CAAC,CAAA;AAMD,IAAM,WAAA,GAAc,EAAE,MAAA,CAAO,CAAA,CAAE,QAAO,EAAG,CAAA,CAAE,SAAS,CAAA;AAE7C,IAAM,2BAAA,GAA8B,EACxC,MAAA,CAAO;AAAA,EACN,MAAM,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,GAAW,QAAA,EAAS;AAAA,EACrC,MAAM,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,GAAW,QAAA,EAAS;AAAA,EACrC,MAAA,EAAQ,YAAY,QAAA,EAAS;AAAA,EAC7B,KAAA,EAAO,YAAY,QAAA,EAAS;AAAA,EAC5B,MAAA,EAAQ,YAAY,QAAA;AACtB,CAAC,EACA,WAAA,EAAY;AAER,IAAM,+BAAA,GAAkC,EAC5C,MAAA,CAAO;AAAA,EACN,KAAA,EAAO,YAAY,QAAA;AACrB,CAAC,EACA,WAAA,EAAY;AAER,IAAM,2BAAA,GAA8B,EAAE,MAAA,CAAO;AAAA,EAClD,SAAS,CAAA,CAAE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AA;AAChE,CAAC,EACA,WAAA;AAEH,IAAM,gCAAA,GAAmC,EACtC,MAAA,CAAO;AAAA,EACN,aAAA,EAAe,EAAE,MAAA,EAAO;AAAA,EACxB,WAAA,EAAa,EAAE,MAAA,EAAO;AAAA,EACtB,KAAA,EAAO,qBAAA;AAAA,EACP,GAAA,EAAK,EAAE,MAAA,CAAO;AAAA,IACZ,QAAA,EAAU,2BAAA;AAAA,IACV,KAAA,EAAO,CAAA,CAAE,KAAA,CAAM,uBAAuB;AAAA,GACvC;AACH,CAAC,EACA,WAAA,EAAY;AAGR,IAAM,2BAA2B,CAAA,CAAE,UAAA;AAAA,EACxC,kCAAA;AAAA,EACA;AACF","file":"chunk-64GLOWMJ.js","sourcesContent":["import { z } from \"zod\";\nimport { DEFAULT_CURRENCY_CODE } from \"../constants/currency\";\n\nexport const StorefrontCheckoutSettingsSchema = z.object({\n allowGuestCheckout: z.boolean().optional(),\n identityScope: z.enum([\"store\", \"tenant\", \"global\"]).optional(),\n signInMethods: z.array(z.string()).optional(),\n});\n\nexport type StorefrontCheckoutSettings = z.infer<\n typeof StorefrontCheckoutSettingsSchema\n>;\n\nconst looseRecord = z.record(z.string(), z.unknown());\n\nexport const StorefrontThemeConfigSchema = z\n .object({\n name: z.string().nullable().optional(),\n mode: z.string().nullable().optional(),\n colors: looseRecord.optional(),\n fonts: looseRecord.optional(),\n assets: looseRecord.optional(),\n })\n .passthrough();\n\nexport const StorefrontFeaturesEnabledSchema = z\n .object({\n flags: looseRecord.optional(),\n })\n .passthrough();\n\nexport const StorefrontCmsBrandingSchema = z.object({\n logoUrl: z.string().nullable().optional(),\n logoDarkUrl: z.string().nullable().optional(),\n faviconUrl: z.string().nullable().optional(),\n socialImageUrl: z.string().nullable().optional(),\n});\n\nexport const StorefrontCmsSeoSchema = z.object({\n siteName: z.string().nullable().optional(),\n metaTitle: z.string().nullable().optional(),\n metaDescription: z.string().nullable().optional(),\n titleTemplate: z.string().nullable().optional(),\n robotsIndex: z.boolean().optional(),\n});\n\nexport const StorefrontCmsSocialLinksSchema = z.object({\n instagram: z.string().nullable().optional(),\n facebook: z.string().nullable().optional(),\n tiktok: z.string().nullable().optional(),\n youtube: z.string().nullable().optional(),\n x: z.string().nullable().optional(),\n});\n\nexport const StorefrontCmsContactSchema = z.object({\n supportEmail: z.string().nullable().optional(),\n phone: z.string().nullable().optional(),\n whatsapp: z.string().nullable().optional(),\n address: z.string().nullable().optional(),\n socialLinks: StorefrontCmsSocialLinksSchema.optional(),\n});\n\nexport const StorefrontCmsTrackingSchema = z.object({\n googleAnalyticsMeasurementId: z.string().nullable().optional(),\n metaPixelId: z.string().nullable().optional(),\n googleTagManagerContainerId: z.string().nullable().optional(),\n});\n\nexport const StorefrontCmsCustomScriptsSchema = z.object({\n enabled: z.boolean().optional(),\n head: z.string().nullable().optional(),\n bodyEnd: z.string().nullable().optional(),\n});\n\nexport const StorefrontCmsChannelsSchema = z.object({\n storefront: z\n .object({\n enabled: z.boolean().optional(),\n })\n .optional(),\n pos: z\n .object({\n enabled: z.boolean().optional(),\n })\n .optional(),\n});\n\nexport const StorefrontCmsSettingsSchema = z.object({\n themeKey: z.string().optional(),\n channels: StorefrontCmsChannelsSchema.optional(),\n branding: StorefrontCmsBrandingSchema.optional(),\n seo: StorefrontCmsSeoSchema.optional(),\n contact: StorefrontCmsContactSchema.optional(),\n tracking: StorefrontCmsTrackingSchema.optional(),\n customScripts: StorefrontCmsCustomScriptsSchema.optional(),\n updatedOn: z.string().nullable().optional(),\n});\n\nexport const StorefrontCmsPageSchema = z\n .object({\n id: z.string(),\n name: z.string(),\n slug: z.string(),\n channel: z\n .string()\n .transform((value) => value.toLowerCase())\n .pipe(z.enum([\"storefront\", \"pos\"]))\n .default(\"storefront\"),\n layout: z.string().optional(),\n version: z.number().optional(),\n settings: z.record(z.string(), z.unknown()).optional().nullable(),\n sections: z.array(z.unknown()).optional(),\n status: z.string().optional(),\n hasPublishedVersion: z.boolean().optional(),\n publishedOn: z.string().nullable().optional(),\n publishedBy: z.string().nullable().optional(),\n createdOn: z.string().nullable().optional(),\n updatedOn: z.string().nullable().optional(),\n createdBy: z.string().nullable().optional(),\n updatedBy: z.string().nullable().optional(),\n lastModifiedBy: z.string().nullable().optional(),\n })\n .passthrough();\n\n/** Respuesta antigua GET /settings (objeto plano sin `store` / `cms`). */\nexport const StorefrontSettingsLegacyFlatSchema = z\n .object({\n id: z.coerce.string(),\n tenantId: z.string().nullable().optional(),\n name: z.string(),\n slug: z.coerce.string().optional(),\n description: z.string().nullable().optional(),\n visibility: z.string().nullable().optional(),\n logo: z.string().nullable().optional(),\n favicon: z.string().nullable().optional(),\n icon: z.string().nullable().optional(),\n currency: z.string().nullable().optional(),\n language: z.string().nullable().optional(),\n themeConfig: z.unknown().optional().nullable(),\n featuresEnabled: z.unknown().optional().nullable(),\n checkoutSettings: StorefrontCheckoutSettingsSchema.optional().nullable(),\n })\n .passthrough();\n\nexport type StorefrontSettingsLegacyFlat = z.infer<\n typeof StorefrontSettingsLegacyFlatSchema\n>;\n\nfunction unwrapSettingsResponseBody(v: unknown): unknown {\n if (!v || typeof v !== \"object\" || Array.isArray(v)) return v;\n const o = v as Record<string, unknown>;\n if (\n \"data\" in o &&\n o.data != null &&\n typeof o.data === \"object\" &&\n !Array.isArray(o.data)\n ) {\n return o.data;\n }\n return v;\n}\n\nfunction isLegacyFlatSettingsPayload(v: unknown): v is Record<string, unknown> {\n if (!v || typeof v !== \"object\" || Array.isArray(v)) return false;\n const o = v as Record<string, unknown>;\n if (\"store\" in o || \"schemaVersion\" in o || \"cms\" in o) return false;\n return (\n (typeof o.id === \"string\" || typeof o.id === \"number\") &&\n typeof o.name === \"string\"\n );\n}\n\n/** Convierte el JSON plano legacy al sobre actual (misma forma que el API nuevo). */\nexport function normalizeStorefrontSettingsPayload(v: unknown): unknown {\n const body = unwrapSettingsResponseBody(v);\n if (!isLegacyFlatSettingsPayload(body)) return body;\n const raw = body;\n const parsed = StorefrontSettingsLegacyFlatSchema.safeParse(raw);\n if (!parsed.success) return body;\n\n const l = parsed.data;\n const currency = l.currency?.trim() ? l.currency : DEFAULT_CURRENCY_CODE;\n const language = l.language?.trim() ? l.language : \"es\";\n const slug = l.slug?.trim() ? l.slug : l.id;\n\n return {\n schemaVersion: 0,\n generatedAt: new Date(0).toISOString(),\n store: {\n id: l.id,\n tenantId: l.tenantId ?? undefined,\n name: l.name,\n slug,\n description: l.description ?? null,\n logo: l.logo ?? null,\n icon: l.icon ?? null,\n visibility: l.visibility ?? undefined,\n currency,\n language,\n themeConfig: l.themeConfig ?? undefined,\n featuresEnabled: l.featuresEnabled ?? undefined,\n checkoutSettings: l.checkoutSettings ?? undefined,\n },\n cms: {\n settings: {\n branding: {\n faviconUrl: l.favicon ?? null,\n logoUrl: l.logo ?? null,\n logoDarkUrl: null,\n socialImageUrl: null,\n },\n },\n pages: [],\n },\n };\n}\n\nexport const StorefrontStoreSchema = z\n .object({\n id: z.string(),\n tenantId: z.string().optional(),\n sellerId: z.string().optional(),\n plan: z.string().optional(),\n storageLimitBytes: z.number().optional(),\n monthlyTransferLimitBytes: z.number().optional(),\n maxUploadSizeBytes: z.number().optional(),\n maxStores: z.number().optional(),\n maxMembers: z.number().optional(),\n maxProducts: z.number().optional(),\n maxCategories: z.number().optional(),\n maxBrands: z.number().optional(),\n maxAttributes: z.number().optional(),\n maxCollections: z.number().optional(),\n enableApi: z.boolean().optional(),\n isActive: z.boolean().optional(),\n name: z.string(),\n description: z.string().nullable().optional(),\n avatarUrl: z.string().nullable().optional(),\n logo: z.string().nullable().optional(),\n icon: z.string().nullable().optional(),\n slug: z.string(),\n domain: z.string().nullable().optional(),\n domains: z.array(z.string()).optional(),\n timeZone: z.string().nullable().optional(),\n currency: z.string(),\n language: z.string(),\n visibility: z.string().optional(),\n privateAccessHash: z.string().nullable().optional(),\n privateAccessVersion: z.number().optional(),\n themeConfig: StorefrontThemeConfigSchema.optional(),\n featuresEnabled: StorefrontFeaturesEnabledSchema.optional(),\n checkoutSettings: StorefrontCheckoutSettingsSchema.optional().nullable(),\n })\n .passthrough();\n\nconst StorefrontSettingsEnvelopeSchema = z\n .object({\n schemaVersion: z.number(),\n generatedAt: z.string(),\n store: StorefrontStoreSchema,\n cms: z.object({\n settings: StorefrontCmsSettingsSchema,\n pages: z.array(StorefrontCmsPageSchema),\n }),\n })\n .passthrough();\n\n/** Acepta sobre nuevo o JSON plano legacy; siempre valida contra el sobre normalizado. */\nexport const StorefrontSettingsSchema = z.preprocess(\n normalizeStorefrontSettingsPayload,\n StorefrontSettingsEnvelopeSchema,\n);\n\nexport type StorefrontSettings = z.infer<typeof StorefrontSettingsSchema>;\nexport type StorefrontStore = z.infer<typeof StorefrontStoreSchema>;\nexport type StorefrontCmsSettings = z.infer<typeof StorefrontCmsSettingsSchema>;\nexport type StorefrontCmsPage = z.infer<typeof StorefrontCmsPageSchema>;\n\n/** Nodo `store` del payload público (cookies, auth, moneda). */\nexport function storefrontStoreRecord(\n settings: StorefrontSettings | null | undefined,\n): StorefrontStore | null {\n return settings?.store ?? null;\n}\n\n/** Favicon: CMS branding, luego logo/icono de tienda. */\nexport function storefrontFaviconUrl(\n settings: StorefrontSettings | null | undefined,\n): string | null {\n const b = settings?.cms?.settings?.branding;\n return (\n b?.faviconUrl ?? settings?.store?.logo ?? settings?.store?.icon ?? null\n );\n}\n\n/** Imagen social / OG: branding, luego logo de tienda. */\nexport function storefrontOgImageUrl(\n settings: StorefrontSettings | null | undefined,\n): string | null {\n const b = settings?.cms?.settings?.branding;\n return b?.socialImageUrl ?? settings?.store?.logo ?? null;\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { STOREFRONT_API_PATH_PREFIX } from './chunk-S7CPZ4UE.js';
2
+ import { STOREFRONT_HEADERS } from './chunk-Q4U5OEUT.js';
2
3
 
3
4
  // src/core/constants/storefront-ecomiq-oauth-cookie.ts
4
5
  var STOREFRONT_ECOMIQ_OAUTH_COOKIE_NAME = "ecomiq_sf_oauth_at";
@@ -9,9 +10,9 @@ var DEFAULT_API_BASE_URL = "https://storefront.ecomiq.pe";
9
10
  function jsonError(status, message, error) {
10
11
  return Response.json({ error, message, status }, { status });
11
12
  }
12
- async function ensureStoreContext(request) {
13
- const xStoreId = request.headers.get("x-store-id")?.trim();
14
- const xStoreDomain = request.headers.get("x-store-domain")?.trim();
13
+ async function readStoreContext(request) {
14
+ const xStoreId = request.headers.get(STOREFRONT_HEADERS.storeIdLower)?.trim();
15
+ const xStoreDomain = request.headers.get(STOREFRONT_HEADERS.storeDomainLower)?.trim();
15
16
  if (xStoreDomain) {
16
17
  return {
17
18
  ok: true,
@@ -24,7 +25,7 @@ async function ensureStoreContext(request) {
24
25
  ok: false,
25
26
  response: jsonError(
26
27
  400,
27
- "X-Store-Id is required",
28
+ `${STOREFRONT_HEADERS.storeId} is required`,
28
29
  "Store context required"
29
30
  )
30
31
  };
@@ -40,8 +41,8 @@ var SKIP_FORWARD_HEADERS = /* @__PURE__ */ new Set([
40
41
  "connection",
41
42
  "content-length",
42
43
  "transfer-encoding",
43
- "x-store-id",
44
- "x-store-domain",
44
+ STOREFRONT_HEADERS.storeIdLower,
45
+ STOREFRONT_HEADERS.storeDomainLower,
45
46
  "authorization",
46
47
  "cookie",
47
48
  "cookie2",
@@ -100,9 +101,9 @@ function buildUpstreamRequest(request, pathSegments, config, storeId, storeDomai
100
101
  headers.set(key, value);
101
102
  }
102
103
  });
103
- headers.set("X-Store-Id", storeId);
104
+ headers.set(STOREFRONT_HEADERS.storeId, storeId);
104
105
  if (storeDomain) {
105
- headers.set("X-Store-domain", storeDomain);
106
+ headers.set(STOREFRONT_HEADERS.storeDomain, storeDomain);
106
107
  }
107
108
  const clientIp = getClientIp(request);
108
109
  if (clientIp) {
@@ -121,10 +122,10 @@ function buildUpstreamRequest(request, pathSegments, config, storeId, storeDomai
121
122
  } else if (storefrontOAuth) {
122
123
  headers.set("Authorization", `Bearer ${storefrontOAuth}`);
123
124
  }
124
- headers.set("Accept-Encoding", "identity");
125
125
  const init = {
126
126
  method: request.method,
127
- headers
127
+ headers,
128
+ cache: "no-store"
128
129
  };
129
130
  const bodyMethods = ["POST", "PUT", "PATCH"];
130
131
  if (bodyMethods.includes(request.method) && request.body) {
@@ -137,7 +138,7 @@ function isResponseBodyForbidden(status) {
137
138
  return status === 204 || status === 205 || status === 304;
138
139
  }
139
140
  async function handleStoreProxyRequest(request, pathSegments, config = {}) {
140
- const storeContext = await ensureStoreContext(request);
141
+ const storeContext = await readStoreContext(request);
141
142
  if (!storeContext.ok) {
142
143
  return storeContext.response;
143
144
  }
@@ -151,6 +152,8 @@ async function handleStoreProxyRequest(request, pathSegments, config = {}) {
151
152
  );
152
153
  const upstream = await fetch(url, init);
153
154
  const responseHeaders = new Headers(upstream.headers);
155
+ responseHeaders.delete("content-encoding");
156
+ responseHeaders.delete("content-length");
154
157
  const status = upstream.status;
155
158
  if (isResponseBodyForbidden(status)) {
156
159
  responseHeaders.delete("content-length");
@@ -170,5 +173,5 @@ async function handleStoreProxyRequest(request, pathSegments, config = {}) {
170
173
  }
171
174
 
172
175
  export { STOREFRONT_ECOMIQ_OAUTH_COOKIE_NAME, STOREFRONT_ECOMIQ_OAUTH_COOKIE_PATH, handleStoreProxyRequest };
173
- //# sourceMappingURL=chunk-3URTJY6X.js.map
174
- //# sourceMappingURL=chunk-3URTJY6X.js.map
176
+ //# sourceMappingURL=chunk-AKD5IDEB.js.map
177
+ //# sourceMappingURL=chunk-AKD5IDEB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/constants/storefront-ecomiq-oauth-cookie.ts","../src/core/server/store-proxy-handler.ts"],"names":[],"mappings":";;;;AACO,IAAM,mCAAA,GAAsC;AAG5C,IAAM,mCAAA,GAAsC;;;ACAnD,IAAM,oBAAA,GAAuB,8BAAA;AAe7B,SAAS,SAAA,CAAU,MAAA,EAAgB,OAAA,EAAiB,KAAA,EAAyB;AAC3E,EAAA,OAAO,QAAA,CAAS,KAAK,EAAE,KAAA,EAAO,SAAS,MA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,CAAA;AACrC,IAAA,OAAO,IAAI,SAAS,IAAA,EAAM;AAAA,MACxB,MAAA;AAAA,MACA,YAAY,QAAA,CAAS,UAAA;AAAA,MACrB,OAAA,EAAS;AAAA,KACV,CAAA;AAAA,EACH;AAEA,EAAA,MAAM,IAAA,GAAO,MAAM,QAAA,CAAS,IAAA,EAAK;AACjC,EAAA,OAAO,IAAI,SAAS,IAAA,EAAM;AAAA,IACxB,MAAA;AAAA,IACA,YAAY,QAAA,CAAS,UAAA;AAAA,IACrB,OAAA,EAAS;AAAA,GACV,CAAA;AACH","file":"chunk-AKD5IDEB.js","sourcesContent":["/** Cookie HttpOnly con el bearer OAuth storefront; solo path `/api/store` (no navega a todo el sitio). */\nexport const STOREFRONT_ECOMIQ_OAUTH_COOKIE_NAME = \"ecomiq_sf_oauth_at\";\n\n/** Debe coincidir con el prefijo de la ruta proxy en Next (`app/api/store/...`). */\nexport const STOREFRONT_ECOMIQ_OAUTH_COOKIE_PATH = \"/api/store\";\n","import { STOREFRONT_API_PATH_PREFIX } from \"../constants/api-paths\";\nimport { STOREFRONT_HEADERS } from \"../constants/currency\";\nimport { STOREFRONT_ECOMIQ_OAUTH_COOKIE_NAME } from \"../constants/storefront-ecomiq-oauth-cookie\";\n\nconst DEFAULT_API_BASE_URL = \"https://storefront.ecomiq.pe\";\n\nexport type StoreProxyHandlerConfig = {\n /** Base URL del API de storefront. Default: `https://storefront.ecomiq.pe` */\n apiBaseUrl?: string;\n};\n\ntype StoreContextResult =\n | {\n ok: true;\n storeId: string;\n storeDomain: string | null;\n }\n | { ok: false; response: Response };\n\nfunction jsonError(status: number, message: string, error: string): Response {\n return Response.json({ error, message, status }, { status });\n}\n\nasync function readStoreContext(request: Request): Promise<StoreContextResult> {\n const xStoreId = request.headers.get(STOREFRONT_HEADERS.storeIdLower)?.trim();\n const xStoreDomain = request.headers.get(STOREFRONT_HEADERS.storeDomainLower)?.trim();\n if (xStoreDomain) {\n return {\n ok: true,\n storeId: xStoreId || \"\",\n storeDomain: xStoreDomain || null,\n };\n }\n if (!xStoreId) {\n return {\n ok: false,\n response: jsonError(\n 400,\n `${STOREFRONT_HEADERS.storeId} is required`,\n \"Store context required\",\n ),\n };\n }\n\n return {\n ok: true,\n storeId: xStoreId || \"\",\n storeDomain: xStoreDomain || null,\n };\n}\n\nconst SKIP_FORWARD_HEADERS = new Set([\n \"host\",\n \"connection\",\n \"content-length\",\n \"transfer-encoding\",\n STOREFRONT_HEADERS.storeIdLower,\n STOREFRONT_HEADERS.storeDomainLower,\n \"authorization\",\n \"cookie\",\n \"cookie2\",\n \"set-cookie\",\n \"x-forwarded-for\",\n \"x-forwarded-proto\",\n \"x-forwarded-host\",\n \"x-real-ip\",\n \"forwarded\",\n \"cf-connecting-ip\",\n \"cf-connecting-ipv6\",\n \"true-client-ip\",\n \"cf-ipcountry\",\n \"cf-ray\",\n \"cf-visitor\",\n]);\n\nfunction getClientIp(request: Request): string | null {\n const candidates = [\n request.headers.get(\"cf-connecting-ip\"),\n request.headers.get(\"true-client-ip\"),\n request.headers.get(\"x-real-ip\"),\n ];\n for (const value of candidates) {\n const trimmed = value?.trim();\n if (trimmed) return trimmed;\n }\n const xff = request.headers.get(\"x-forwarded-for\");\n if (xff?.trim()) {\n const first = xff.split(\",\")[0]?.trim();\n if (first) return first;\n }\n return null;\n}\n\nfunction getCookieValue(request: Request, name: string): string | undefined {\n const cookieHeader = request.headers.get(\"cookie\");\n if (!cookieHeader) return undefined;\n for (const part of cookieHeader.split(\";\")) {\n const [rawKey, ...rest] = part.trim().split(\"=\");\n if (rawKey?.trim() === name) {\n return decodeURIComponent(rest.join(\"=\"));\n }\n }\n return undefined;\n}\n\nfunction buildUpstreamRequest(\n request: Request,\n pathSegments: string[],\n config: StoreProxyHandlerConfig,\n storeId: string,\n storeDomain: string | null,\n): { url: string; init: RequestInit & { duplex?: \"half\" } } {\n const requestUrl = new URL(request.url);\n const base = (config.apiBaseUrl ?? DEFAULT_API_BASE_URL).replace(/\\/$/, \"\");\n const userPath = pathSegments.length ? pathSegments.join(\"/\") : \"\";\n const path = userPath\n ? `${STOREFRONT_API_PATH_PREFIX}/${userPath}`\n : STOREFRONT_API_PATH_PREFIX;\n const search = requestUrl.searchParams.toString();\n const url = search ? `${base}/${path}?${search}` : `${base}/${path}`;\n\n const headers = new Headers();\n request.headers.forEach((value, key) => {\n const lower = key.toLowerCase();\n if (!SKIP_FORWARD_HEADERS.has(lower)) {\n headers.set(key, value);\n }\n });\n headers.set(STOREFRONT_HEADERS.storeId, storeId);\n if (storeDomain) {\n headers.set(STOREFRONT_HEADERS.storeDomain, storeDomain);\n }\n\n const clientIp = getClientIp(request);\n if (clientIp) {\n headers.set(\"X-Forwarded-For\", clientIp);\n }\n const forwardedProto =\n request.headers.get(\"cf-visitor\")?.match(/\"scheme\":\"(https?)\"/)?.[1] ??\n requestUrl.protocol.replace(\":\", \"\") ??\n \"https\";\n headers.set(\"X-Forwarded-Proto\", forwardedProto);\n const forwardedHost = request.headers.get(\"host\") ?? requestUrl.host;\n if (forwardedHost) {\n headers.set(\"X-Forwarded-Host\", forwardedHost);\n }\n\n const incomingAuth = request.headers.get(\"authorization\")?.trim();\n const storefrontOAuth = getCookieValue(request, STOREFRONT_ECOMIQ_OAUTH_COOKIE_NAME)?.trim();\n\n if (incomingAuth && /^Bearer\\s+\\S+/i.test(incomingAuth)) {\n headers.set(\"Authorization\", incomingAuth);\n } else if (storefrontOAuth) {\n headers.set(\"Authorization\", `Bearer ${storefrontOAuth}`);\n }\n\n const init: RequestInit & { duplex?: \"half\" } = {\n method: request.method,\n headers,\n cache: \"no-store\",\n };\n\n const bodyMethods = [\"POST\", \"PUT\", \"PATCH\"];\n if (bodyMethods.includes(request.method) && request.body) {\n init.body = request.body;\n init.duplex = \"half\";\n }\n\n return { url, init };\n}\n\nfunction isResponseBodyForbidden(status: number): boolean {\n return status === 204 || status === 205 || status === 304;\n}\n\n/**\n * Proxy BFF `/api/store/*` → upstream Ecomiq. Usa Web Fetch API (`Request` / `Response`).\n */\nexport async function handleStoreProxyRequest(\n request: Request,\n pathSegments: string[],\n config: StoreProxyHandlerConfig = {},\n): Promise<Response> {\n const storeContext = await readStoreContext(request);\n if (!storeContext.ok) {\n return storeContext.response;\n }\n\n const { storeId, storeDomain } = storeContext;\n const { url, init } = buildUpstreamRequest(\n request,\n pathSegments,\n config,\n storeId,\n storeDomain,\n );\n\n const upstream = await fetch(url, init);\n const responseHeaders = new Headers(upstream.headers);\n // El runtime descomprime el body (lo leemos como texto), pero `upstream.headers`\n // conserva content-encoding/content-length del payload comprimido: hay que\n // quitarlos o el cliente recibiría headers inconsistentes con el body.\n responseHeaders.delete(\"content-encoding\");\n responseHeaders.delete(\"content-length\");\n const status = upstream.status;\n\n if (isResponseBodyForbidden(status)) {\n responseHeaders.delete(\"content-length\");\n responseHeaders.delete(\"content-type\");\n return new Response(null, {\n status,\n statusText: upstream.statusText,\n headers: responseHeaders,\n });\n }\n\n const body = await upstream.text();\n return new Response(body, {\n status,\n statusText: upstream.statusText,\n headers: responseHeaders,\n });\n}\n"]}
@@ -1,7 +1,8 @@
1
- import { resolvePublicStoreKey, getStorefrontSettingsFromKvByStoreKey } from './chunk-6TMU4OXP.js';
2
- import { StorefrontProductsParamsSchema, StorefrontProductsResponseSchema, StorefrontProductDetailSchema, StorefrontCollectionsResponseSchema, StorefrontCollectionDetailSchema, StorefrontPageListItemSchema, StorefrontPageDetailSchema } from './chunk-ASFU32ZM.js';
3
- import { StorefrontSettingsSchema } from './chunk-EADDSNJS.js';
4
- import { STOREFRONT_ECOMIQ_OAUTH_COOKIE_NAME, STOREFRONT_ECOMIQ_OAUTH_COOKIE_PATH } from './chunk-3URTJY6X.js';
1
+ import { resolvePublicStoreKey, getStorefrontSettingsFromKvByStoreKey } from './chunk-NAJQB5DN.js';
2
+ import { StorefrontProductsParamsSchema, StorefrontProductsResponseSchema, StorefrontProductDetailSchema, StorefrontCollectionsResponseSchema, StorefrontCollectionDetailSchema, StorefrontPageListItemSchema, StorefrontPageDetailSchema } from './chunk-OABDGTBI.js';
3
+ import { StorefrontSettingsSchema } from './chunk-64GLOWMJ.js';
4
+ import { STOREFRONT_ECOMIQ_OAUTH_COOKIE_NAME, STOREFRONT_ECOMIQ_OAUTH_COOKIE_PATH } from './chunk-AKD5IDEB.js';
5
+ import { DEFAULT_CURRENCY_CODE, STOREFRONT_HEADERS, DEFAULT_COUNTRY_CODE } from './chunk-Q4U5OEUT.js';
5
6
  import { z } from 'zod';
6
7
  import { createAuthMiddleware, createAuthEndpoint, formCsrfMiddleware } from 'better-auth/api';
7
8
  import { APIError } from 'better-auth';
@@ -52,14 +53,13 @@ var StoreApiClient = class {
52
53
  if (!isFormData) {
53
54
  headers.set("Content-Type", "application/json");
54
55
  }
55
- headers.set("Accept-Encoding", "identity");
56
56
  const explicitStoreId = options?.xStoreId?.trim();
57
57
  const runtimeStoreId = explicitStoreId || (typeof window === "undefined" ? serverStoreIdGetter : clientStoreIdGetter);
58
- if (runtimeStoreId && !headers.has("x-store-id")) {
59
- headers.set("X-Store-Id", runtimeStoreId);
58
+ if (runtimeStoreId && !headers.has(STOREFRONT_HEADERS.storeIdLower)) {
59
+ headers.set(STOREFRONT_HEADERS.storeId, runtimeStoreId);
60
60
  }
61
61
  if (options?.xStoreDomain) {
62
- headers.set("X-Store-Domain", options.xStoreDomain);
62
+ headers.set(STOREFRONT_HEADERS.storeDomain, options.xStoreDomain);
63
63
  }
64
64
  if (options?.xCartId) {
65
65
  headers.set("X-Cart-Token", options.xCartId);
@@ -160,7 +160,7 @@ async function getStorefrontSettings(subdomain, cacheKey) {
160
160
  const response = await client.get("settings", {
161
161
  xStoreDomain: subdomain?.trim() || void 0,
162
162
  cacheKey,
163
- noStore: true
163
+ noStore: !cacheKey
164
164
  });
165
165
  return StorefrontSettingsSchema.parse(response);
166
166
  }
@@ -192,10 +192,17 @@ async function fetchPublicStoreSettings(options) {
192
192
  const source = options.source ?? resolvePublicStoreSettingsSource();
193
193
  try {
194
194
  setServerStoreId(null);
195
- const data = source === "kv" ? await getStorefrontSettingsFromKvByStoreKey(storeKey) : await getStorefrontSettings(
195
+ const fetchFromApi = () => getStorefrontSettings(
196
196
  storeKey,
197
197
  `storefront-settings-${storeKey}`
198
198
  );
199
+ const data = source === "kv" ? await getStorefrontSettingsFromKvByStoreKey(storeKey).catch((error) => {
200
+ console.warn(
201
+ `[ecomiq] Store settings KV lookup failed for "${storeKey}". Falling back to API.`,
202
+ error
203
+ );
204
+ return fetchFromApi();
205
+ }) : await fetchFromApi();
199
206
  setServerStoreId(data.store.id);
200
207
  return { data, error: null };
201
208
  } catch (error) {
@@ -213,16 +220,6 @@ async function fetchPublicStoreSettings(options) {
213
220
  }
214
221
  }
215
222
 
216
- // src/core/client/store-api-errors.ts
217
- function isCartNotActiveApiError(error) {
218
- if (!error || typeof error !== "object") return false;
219
- const e = error;
220
- if (e.status !== 400) return false;
221
- const body = e.body;
222
- const keys = body?.errors ? Object.keys(body.errors) : [];
223
- return keys.includes("Carts.NotActive");
224
- }
225
-
226
223
  // src/core/client/store-api-product.service.ts
227
224
  async function getStorefrontProducts(params, cacheKey) {
228
225
  const parsed = StorefrontProductsParamsSchema.parse(params ?? {});
@@ -233,25 +230,94 @@ async function getStorefrontProducts(params, cacheKey) {
233
230
  if (parsed.sellerId) searchParams.set("sellerId", parsed.sellerId);
234
231
  if (parsed.search) searchParams.set("search", parsed.search);
235
232
  if (parsed.collection) searchParams.set("collection", parsed.collection);
233
+ appendValues(searchParams, "collections", parsed.collections);
236
234
  if (parsed.category) searchParams.set("category", parsed.category);
235
+ appendValues(searchParams, "categories", parsed.categories);
237
236
  if (parsed.brand) searchParams.set("brand", parsed.brand);
237
+ appendValues(searchParams, "brands", parsed.brands);
238
238
  if (parsed.productType) searchParams.set("productType", parsed.productType);
239
+ appendValues(searchParams, "productTypes", parsed.productTypes);
240
+ if (parsed.tag) searchParams.set("tag", parsed.tag);
241
+ appendValues(searchParams, "tags", parsed.tags);
242
+ appendValues(searchParams, "filters", parsed.filters);
243
+ if (parsed.locationId) searchParams.set("locationId", parsed.locationId);
239
244
  if (parsed.inStock != null) searchParams.set("inStock", String(parsed.inStock));
240
245
  if (parsed.minPrice != null) searchParams.set("minPrice", String(parsed.minPrice));
241
246
  if (parsed.maxPrice != null) searchParams.set("maxPrice", String(parsed.maxPrice));
242
247
  const path = `products?${searchParams.toString()}`;
243
248
  const client = await getStoreApiClient();
244
249
  const response = await client.get(path, {
245
- cacheKey
250
+ cacheKey,
251
+ noStore: !cacheKey
246
252
  });
247
253
  return StorefrontProductsResponseSchema.parse(response);
248
254
  }
249
- async function getStorefrontProductBySlug(slug) {
255
+ async function getStorefrontProductBySlug(slug, options) {
250
256
  const path = `products/${encodeURIComponent(slug)}`;
251
257
  const client = await getStoreApiClient();
252
- const response = await client.get(path);
258
+ const response = await client.get(path, {
259
+ cacheKey: options?.cacheKey,
260
+ noStore: !options?.cacheKey
261
+ });
253
262
  return StorefrontProductDetailSchema.parse(response);
254
263
  }
264
+ function appendValues(searchParams, key, values) {
265
+ for (const value of values ?? []) {
266
+ if (value) searchParams.append(key, value);
267
+ }
268
+ }
269
+
270
+ // src/core/server/subdomain.ts
271
+ var reservedStoreSubdomains = [
272
+ "admin",
273
+ "api",
274
+ "blog",
275
+ "dashboard",
276
+ "dev",
277
+ "dev-ops",
278
+ "dev-ops-tools",
279
+ "dev-tool",
280
+ "dev-tools",
281
+ "developer",
282
+ "developers",
283
+ "development",
284
+ "develop",
285
+ "devops",
286
+ "devops-tools",
287
+ "devopstools",
288
+ "devtool",
289
+ "devtools",
290
+ "preview",
291
+ "prod",
292
+ "production",
293
+ "qa",
294
+ "quality",
295
+ "quality-assurance",
296
+ "qualityassurance",
297
+ "root",
298
+ "sandbox",
299
+ "stage",
300
+ "staging",
301
+ "stg",
302
+ "store",
303
+ "test",
304
+ "testing",
305
+ "tool",
306
+ "tools",
307
+ "uat",
308
+ "www"
309
+ ];
310
+ new Set(reservedStoreSubdomains);
311
+
312
+ // src/core/client/store-api-errors.ts
313
+ function isCartNotActiveApiError(error) {
314
+ if (!error || typeof error !== "object") return false;
315
+ const e = error;
316
+ if (e.status !== 400) return false;
317
+ const body = e.body;
318
+ const keys = body?.errors ? Object.keys(body.errors) : [];
319
+ return keys.includes("Carts.NotActive");
320
+ }
255
321
 
256
322
  // src/core/client/store-api-collection.service.ts
257
323
  async function getStorefrontCollections() {
@@ -298,7 +364,7 @@ var CartAddressSchema = z.object({
298
364
  name: z.string().min(1),
299
365
  address1: z.string().min(1),
300
366
  city: z.string().min(1),
301
- countryCode: z.string().min(2),
367
+ countryCode: z.string().min(2).max(2),
302
368
  company: z.string().nullable().optional(),
303
369
  address2: z.string().nullable().optional(),
304
370
  province: z.string().nullable().optional(),
@@ -343,7 +409,7 @@ z.object({
343
409
  name: z.string().nullable().optional(),
344
410
  address1: z.string(),
345
411
  city: z.string(),
346
- countryCode: z.string(),
412
+ countryCode: z.string().min(2).max(2),
347
413
  company: z.string().nullable().optional(),
348
414
  address2: z.string().nullable().optional(),
349
415
  province: z.string().nullable().optional(),
@@ -714,7 +780,7 @@ function customerMeToProfilePatch(me) {
714
780
  companyName: me.companyName,
715
781
  dateOfBirth: me.dateOfBirth,
716
782
  consent: me.consent,
717
- countryIsoCode: me.countryIsoCode || "PE"
783
+ countryIsoCode: me.countryIsoCode || DEFAULT_COUNTRY_CODE
718
784
  };
719
785
  }
720
786
  function customerAuthOptions(accessToken) {
@@ -777,7 +843,7 @@ var CustomerOrderShippingAddressSchema = z.object({
777
843
  address1: z.string(),
778
844
  address2: z.string().nullable().optional(),
779
845
  city: z.string().nullable().optional(),
780
- countryCode: z.string(),
846
+ countryCode: z.string().min(2).max(2),
781
847
  province: z.string().nullable().optional(),
782
848
  postalCode: z.string().nullable().optional(),
783
849
  district: z.string().nullable().optional(),
@@ -942,7 +1008,7 @@ var OrderDraftSchema = z.object({
942
1008
  customerId: z.coerce.string().nullable().optional(),
943
1009
  cartId: z.string().nullable().optional(),
944
1010
  draftNumber: z.string(),
945
- currencyCode: z.string().optional().default("PEN"),
1011
+ currencyCode: z.string().optional().default(DEFAULT_CURRENCY_CODE),
946
1012
  source: z.string().nullable().optional(),
947
1013
  notes: z.string().nullable().optional(),
948
1014
  email: z.string().nullable().optional(),
@@ -1060,9 +1126,9 @@ function ecomiqOAuthPassword() {
1060
1126
  async (ctx) => {
1061
1127
  const { email: loginEmail, password, callbackURL, rememberMe } = ctx.body;
1062
1128
  const tokens = await exchangePasswordGrant(loginEmail, password, {
1063
- identityScope: ctx.getHeader("x-Identity-Scope"),
1064
- tenantId: ctx.getHeader("x-Tenant-Id"),
1065
- storeId: ctx.getHeader("x-Store-Id")
1129
+ identityScope: ctx.getHeader(STOREFRONT_HEADERS.identityScope),
1130
+ tenantId: ctx.getHeader(STOREFRONT_HEADERS.tenantId),
1131
+ storeId: ctx.getHeader(STOREFRONT_HEADERS.storeId)
1066
1132
  });
1067
1133
  const profile = await fetchUserInfo(tokens.access_token);
1068
1134
  const profileEmail = profile.email?.toLowerCase().trim();
@@ -1186,13 +1252,13 @@ async function exchangePasswordGrant(username, password, context) {
1186
1252
  accept: "application/json"
1187
1253
  });
1188
1254
  if (identityScope?.trim()) {
1189
- headers.set("x-Identity-Scope", identityScope.trim());
1255
+ headers.set(STOREFRONT_HEADERS.identityScope, identityScope.trim());
1190
1256
  }
1191
1257
  if (tenantId?.trim()) {
1192
- headers.set("x-Tenant-Id", tenantId.trim());
1258
+ headers.set(STOREFRONT_HEADERS.tenantId, tenantId.trim());
1193
1259
  }
1194
1260
  if (storeId?.trim()) {
1195
- headers.set("x-Store-Id", storeId.trim());
1261
+ headers.set(STOREFRONT_HEADERS.storeId, storeId.trim());
1196
1262
  }
1197
1263
  let res;
1198
1264
  let text;
@@ -1275,5 +1341,5 @@ function collectNetworkErrorCodes(e) {
1275
1341
  }
1276
1342
 
1277
1343
  export { CustomerAddressSchema, CustomerAddressUpsertSchema, CustomerMeSchema, CustomerOrderDetailSchema, CustomerOrderListItemSchema, CustomerProfilePatchSchema, CustomerRegisterRequestSchema, StoreApiClient, addCartCoupon, applyServerRequestOriginFromHeaders, checkoutCart, createCart, createCustomerAddress, createStoreApiClient, customerMeToProfilePatch, deleteCustomerAddress, ecomiqOAuthPassword, fetchPublicStoreSettings, getCart, getCartCheckout, getCartPaymentMethods, getCustomerAddresses, getCustomerMe, getCustomerOrder, getCustomerOrders, getSharedOrderDraft, getShippingOptions, getStoreApiBaseUrl, getStoreApiClient, getStorefrontCollectionBySlug, getStorefrontCollections, getStorefrontPageBySlug, getStorefrontPagePreview, getStorefrontPages, getStorefrontProductBySlug, getStorefrontProducts, getStorefrontSettings, isCartNotActiveApiError, normalizeRequestHostname, patchCartAddresses, patchCartBuyer, patchCustomer, putCartShippingMethod, registerCustomer, removeCartCoupon, resolvePublicStoreSettingsSource, setClientStoreId, setServerRequestOrigin, setServerStoreId, storeApiClient, updateCustomerAddress, uploadPaymentReceipt };
1278
- //# sourceMappingURL=chunk-YSD62KQM.js.map
1279
- //# sourceMappingURL=chunk-YSD62KQM.js.map
1344
+ //# sourceMappingURL=chunk-EFEVJJWF.js.map
1345
+ //# sourceMappingURL=chunk-EFEVJJWF.js.map