@ecomiq/storefront 1.0.1 → 1.1.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 (47) hide show
  1. package/README.md +32 -21
  2. package/dist/{chunk-PDK2VYWD.js → chunk-3C4ZLHSU.js} +7 -321
  3. package/dist/chunk-3C4ZLHSU.js.map +1 -0
  4. package/dist/{chunk-Q762YXCQ.js → chunk-3URTJY6X.js} +4 -5
  5. package/dist/chunk-3URTJY6X.js.map +1 -0
  6. package/dist/chunk-ASFU32ZM.js +236 -0
  7. package/dist/chunk-ASFU32ZM.js.map +1 -0
  8. package/dist/{chunk-PCTSWSTB.js → chunk-EADDSNJS.js} +4 -144
  9. package/dist/chunk-EADDSNJS.js.map +1 -0
  10. package/dist/chunk-S7CPZ4UE.js +6 -0
  11. package/dist/chunk-S7CPZ4UE.js.map +1 -0
  12. package/dist/chunk-W372BFMG.js +159 -0
  13. package/dist/chunk-W372BFMG.js.map +1 -0
  14. package/dist/chunks/client.d.ts +1 -643
  15. package/dist/chunks/client.js +2 -21
  16. package/dist/chunks/client.js.map +1 -1
  17. package/dist/chunks/config.js +2 -1
  18. package/dist/chunks/core-public.d.ts +130 -0
  19. package/dist/chunks/core-public.js +98 -0
  20. package/dist/chunks/core-public.js.map +1 -0
  21. package/dist/chunks/server-nextjs.d.ts +3 -2
  22. package/dist/chunks/server-nextjs.js +7 -4
  23. package/dist/chunks/server-nextjs.js.map +1 -1
  24. package/dist/chunks/server-tanstack.d.ts +3 -2
  25. package/dist/chunks/server-tanstack.js +7 -4
  26. package/dist/chunks/server-tanstack.js.map +1 -1
  27. package/dist/collection-BHD4hhQa.d.ts +3609 -0
  28. package/dist/{format-currency-oJD9jGYW.d.ts → ecomiq-oauth-password-plugin-DJCOOij3.d.ts} +165 -3299
  29. package/dist/index.d.ts +1 -12
  30. package/dist/index.js +1 -11
  31. package/dist/index.server.d.ts +1 -0
  32. package/dist/index.server.js +1 -0
  33. package/dist/nextjs/api.js +2 -1
  34. package/dist/nextjs/api.js.map +1 -1
  35. package/dist/nextjs.d.ts +1 -13
  36. package/dist/nextjs.js +2 -11
  37. package/dist/react.d.ts +1 -0
  38. package/dist/react.js +2 -0
  39. package/dist/react.js.map +1 -0
  40. package/dist/tanstack/api.js +3 -2
  41. package/dist/tanstack/api.js.map +1 -1
  42. package/dist/tanstack.d.ts +1 -13
  43. package/dist/tanstack.js +2 -11
  44. package/package.json +5 -5
  45. package/dist/chunk-PCTSWSTB.js.map +0 -1
  46. package/dist/chunk-PDK2VYWD.js.map +0 -1
  47. package/dist/chunk-Q762YXCQ.js.map +0 -1
package/README.md CHANGED
@@ -61,17 +61,18 @@ Si defines `slugStore`, `getPublicStore` usa ese slug (útil en localhost). Si n
61
61
 
62
62
  | Import | Uso |
63
63
  |--------|-----|
64
- | `@ecomiq/storefront` | **Client:** `EcomiqProvider`, hooks (`useStoreProducts`, …). **Server** (`react-server`): config (`loadEcomiqConfig`, …) |
65
- | `@ecomiq/storefront/nextjs` | **Server** (`react-server`): `getPublicStore`, cliente BFF server, auth helpers. **Client:** `EcomiqProvider`, hooks |
64
+ | `@ecomiq/storefront` | Tipos, schemas Zod, utilidades vanilla (`formatCurrency`, …). **Server** (`react-server`): config (`loadEcomiqConfig`, …) |
65
+ | `@ecomiq/storefront/react` | **Client** (`"use client"`): `EcomiqProvider`, hooks BFF, componentes reutilizables |
66
+ | `@ecomiq/storefront/nextjs` | **Server** (`react-server`): `getPublicStore`, cliente BFF server, auth helpers. **Client:** reexport de `/react` |
66
67
  | `@ecomiq/storefront/nextjs/api` | Proxy `/api/store/*` (App Router) |
67
68
  | `@ecomiq/storefront/nextjs/css` | Tailwind mínimo (opcional) |
68
69
  | `@ecomiq/storefront/nextjs/postcss` | PostCSS de referencia |
69
70
  | `@ecomiq/storefront/tanstack` | TanStack server + reexport client (misma API client que `/nextjs`) |
70
71
  | `@ecomiq/storefront/tanstack/api` | Proxy `/api/store/*` (server routes) |
71
72
 
72
- Importa hooks desde `@ecomiq/storefront` o desde `@ecomiq/storefront/nextjs`. El build npm separa internamente server y client para App Router — **no necesitas** subpaths `/server` ni `/client`.
73
+ Importa hooks y `EcomiqProvider` desde `@ecomiq/storefront/react`. El build npm separa server (`react-server`), vanilla (raíz) y React (`/react`) para App Router.
73
74
 
74
- Los hooks (`useStoreProducts`, `useStoreCart`, …) tienen **una sola implementación** reexportada por ambos adapters; solo cambia el bootstrap server (`getPublicStore`, handler del proxy).
75
+ Los hooks (`useStoreProducts`, `useStoreCart`, …) viven en `/react`; `/nextjs` y `/tanstack` los reexportan en client por compatibilidad.
75
76
 
76
77
  ### Peers
77
78
 
@@ -80,7 +81,8 @@ Los hooks (`useStoreProducts`, `useStoreCart`, …) tienen **una sola implementa
80
81
  | `react`, `react-dom` | Siempre |
81
82
  | `next` | Solo si usas `/nextjs` |
82
83
  | `@tanstack/react-start` | Solo si usas `/tanstack` |
83
- | `@opennextjs/cloudflare` | Opcional (settings vía KV) |
84
+
85
+ **Cloudflare:** el SDK no incluye `@opennextjs/cloudflare`. Si despliegas en Cloudflare con settings vía KV (`PUBLIC_STORE_SETTINGS_SOURCE=kv`), instálalo y configura wrangler en **tu** proyecto.
84
86
 
85
87
  ## Arquitectura
86
88
 
@@ -96,7 +98,7 @@ Los hooks (`useStoreProducts`, `useStoreCart`, …) tienen **una sola implementa
96
98
  │ │
97
99
  └─────────────────────────┬─────────────────────────┘
98
100
  ▼
99
- Capa React compartida (hooks, EcomiqProvider, cliente BFF, auth)
101
+ Capa React (`/react`) — hooks, EcomiqProvider, cliente BFF browser, auth
100
102
  │
101
103
  ▼
102
104
  core/server — fetchPublicStoreSettings · handleStoreProxyRequest
@@ -131,8 +133,8 @@ Los hooks y `EcomiqProvider` son **Client Components** (`"use client"`). En el l
131
133
  // app/ecomiq-provider.tsx
132
134
  "use client";
133
135
 
134
- import { EcomiqProvider } from "@ecomiq/storefront";
135
- import type { StorefrontSettings } from "@ecomiq/storefront/nextjs";
136
+ import { EcomiqProvider } from "@ecomiq/storefront/react";
137
+ import type { StorefrontSettings } from "@ecomiq/storefront";
136
138
 
137
139
  export function EcomiqRootProvider({
138
140
  store,
@@ -169,12 +171,12 @@ export default async function RootLayout({ children }: { children: React.ReactNo
169
171
 
170
172
  ### 3. Catálogo con hooks
171
173
 
172
- Puedes importar hooks desde el paquete raíz o desde `/nextjs`:
174
+ Importa hooks desde `@ecomiq/storefront/react`:
173
175
 
174
176
  ```tsx
175
177
  "use client";
176
178
 
177
- import { useStoreProducts } from "@ecomiq/storefront";
179
+ import { useStoreProducts } from "@ecomiq/storefront/react";
178
180
 
179
181
  export function ProductList() {
180
182
  const { useStorefrontProductsList } = useStoreProducts();
@@ -230,7 +232,7 @@ export const Route = createFileRoute("/api/store/$")({
230
232
  // src/components/ecomiq-provider.tsx
231
233
  "use client";
232
234
 
233
- import { EcomiqProvider } from "@ecomiq/storefront";
235
+ import { EcomiqProvider } from "@ecomiq/storefront/react";
234
236
  import type { StorefrontSettings } from "@ecomiq/storefront/tanstack";
235
237
 
236
238
  export function EcomiqRootProvider({
@@ -270,7 +272,7 @@ function RootComponent() {
270
272
  ```tsx
271
273
  "use client";
272
274
 
273
- import { useStoreProducts, useStoreCart } from "@ecomiq/storefront";
275
+ import { useStoreProducts, useStoreCart } from "@ecomiq/storefront/react";
274
276
  ```
275
277
 
276
278
  ---
@@ -372,28 +374,37 @@ export function AccountActions() {
372
374
  }
373
375
  ```
374
376
 
375
- En TanStack, cambia el import a `@ecomiq/storefront/tanstack`.
377
+ En TanStack, cambia el import server a `@ecomiq/storefront/tanstack` y los hooks a `@ecomiq/storefront/react`.
376
378
 
377
379
  ---
378
380
 
379
- ## Qué incluye cada adapter
381
+ ## Qué incluye cada entry
382
+
383
+ Desde `/nextjs` o `/tanstack` (**server**, condición `react-server`):
384
+
385
+ - `getPublicStore`, `getHostname`, `fetchPublicStoreSettings`
386
+ - Cliente BFF server: `getStorefrontProducts`, `registerCustomer`, carrito/cuenta, etc.
387
+ - Auth server: `ecomiqOAuthPassword`
380
388
 
381
- Desde `/nextjs` o `/tanstack` obtienes:
389
+ Desde `@ecomiq/storefront/react` (**client**, `"use client"`):
382
390
 
383
- - **Server:** `getPublicStore`, `getHostname`, `fetchPublicStoreSettings` (agnóstico)
384
391
  - **Provider:** `EcomiqProvider`, `useStore`, `usePublicStore`
385
392
  - **Hooks BFF:** `useStoreProducts`, `useStoreCollections`, `useStorePages`, `useStoreCart`
386
- - **Cliente:** `getStorefrontProducts`, `registerCustomer`, servicios de carrito/cuenta, etc.
387
- - **Auth:** `ecomiqOAuthPassword`, `ecomiqOAuthPasswordClient`, `signInWithEcomiqCredentials`, `useStorefrontSession`
388
- - **Tipos y Zod:** `StorefrontSettings`, `StorefrontProduct`, schemas, `formatCurrency`
389
- - **Utilidades:** `findStorefrontCmsPageBySlug`, selector de variantes de producto
393
+ - **Auth client:** `ecomiqOAuthPasswordClient`, `signInWithEcomiqCredentials`, `useStorefrontSession`
394
+ - **Componentes:** selector de variantes de producto (más en futuras versiones)
395
+
396
+ Desde `@ecomiq/storefront` (raíz — vanilla, server o client):
397
+
398
+ - **Tipos y Zod:** `StorefrontSettings`, `StorefrontProduct`, schemas
399
+ - **Utilidades:** `formatCurrency`, `countryCurrency`, `sanitizeHtml`, `stripHtml`, labels de pedidos, `findStorefrontCmsPageBySlug`
400
+ - **Config** (solo server): `loadEcomiqConfig`, `EcomiqConfigSchema`, …
390
401
 
391
402
  ## Variables de entorno
392
403
 
393
404
  | Variable | Descripción |
394
405
  |----------|-------------|
395
406
  | `STOREFRONT_API_URL` | URL base de la API de tienda (proxy) |
396
- | `PUBLIC_STORE_SETTINGS_SOURCE` | `api` (default) o `kv` (Cloudflare KV vía `@opennextjs/cloudflare`) |
407
+ | `PUBLIC_STORE_SETTINGS_SOURCE` | `api` (default) o `kv` (Cloudflare KV; requiere `@opennextjs/cloudflare` en tu proyecto, no en el SDK) |
397
408
 
398
409
  **Identificador de tienda:** `slugStore` en `ecomiq.config.*` si existe; si no, header `Host`.
399
410
 
@@ -1,11 +1,12 @@
1
- import { StorefrontSettingsSchema, resolvePublicStoreKey, getStorefrontSettingsFromKvByStoreKey } from './chunk-PCTSWSTB.js';
2
- import { STOREFRONT_ECOMIQ_OAUTH_COOKIE_NAME, STOREFRONT_ECOMIQ_OAUTH_COOKIE_PATH } from './chunk-Q762YXCQ.js';
1
+ import { resolvePublicStoreKey, getStorefrontSettingsFromKvByStoreKey } from './chunk-W372BFMG.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';
3
5
  import { z } from 'zod';
4
6
  import { createAuthMiddleware, createAuthEndpoint, formCsrfMiddleware } from 'better-auth/api';
5
7
  import { APIError } from 'better-auth';
6
8
  import { setSessionCookie } from 'better-auth/cookies';
7
9
  import { parseUserOutput } from 'better-auth/db';
8
- import axios from 'axios';
9
10
 
10
11
  // src/core/client/store-api-client.ts
11
12
  var STORE_API_PATH = "/api/store";
@@ -214,188 +215,6 @@ function isCartNotActiveApiError(error) {
214
215
  const keys = body?.errors ? Object.keys(body.errors) : [];
215
216
  return keys.includes("Carts.NotActive");
216
217
  }
217
- var ProductVariantSchema = z.object({
218
- id: z.coerce.string(),
219
- name: z.string(),
220
- storeId: z.string(),
221
- productId: z.coerce.string(),
222
- basePrice: z.number().positive().optional().nullable(),
223
- comparePrice: z.number().positive().optional().nullable(),
224
- //TODO: remove this field
225
- originalPrice: z.number().positive().optional().nullable(),
226
- costPrice: z.number().positive().optional().nullable(),
227
- isDefault: z.boolean().optional().nullable(),
228
- reserveStock: z.number().nonnegative().optional().nullable(),
229
- weight: z.number().nonnegative().optional().nullable().default(0),
230
- width: z.number().nonnegative().optional().nullable(),
231
- height: z.number().nonnegative().optional().nullable(),
232
- unitOfMeasure: z.string().optional().nullable(),
233
- order: z.number().nonnegative().optional().nullable().default(0),
234
- sku: z.string().optional().nullable(),
235
- stock: z.number().nonnegative().optional().nullable(),
236
- leadTime: z.string().optional().nullable(),
237
- barCode: z.string().optional().nullable(),
238
- shippingWeight: z.number().nonnegative().optional().nullable(),
239
- images: z.array(z.string()).optional().nullable(),
240
- attributes: z.array(z.string()).optional().nullable(),
241
- variantStatus: z.string().optional().nullable(),
242
- status: z.string().optional().nullable(),
243
- createdOn: z.string().optional().nullable(),
244
- updatedOn: z.string().optional().nullable(),
245
- deletedOn: z.string().optional().nullable()
246
- });
247
- var ProductSchema = z.object({
248
- id: z.coerce.string(),
249
- name: z.string(),
250
- images: z.array(z.object({
251
- url: z.string().url(),
252
- name: z.string().optional(),
253
- isPrimary: z.boolean().optional()
254
- })),
255
- basePrice: z.number().positive().optional(),
256
- salePrice: z.number().positive().optional(),
257
- slug: z.string(),
258
- description: z.string().optional(),
259
- categories: z.array(z.object({
260
- id: z.coerce.string(),
261
- name: z.string(),
262
- slug: z.string(),
263
- logo: z.string().optional(),
264
- icon: z.string().optional()
265
- })).optional(),
266
- tags: z.array(z.string()).optional(),
267
- inStock: z.boolean().optional(),
268
- variants: z.array(ProductVariantSchema).optional()
269
- });
270
- z.object({
271
- items: z.array(ProductSchema),
272
- meta: z.object({
273
- total: z.number().int().positive(),
274
- page: z.number().int().positive(),
275
- pageSize: z.number().int().positive(),
276
- hasNextPage: z.boolean()
277
- })
278
- });
279
- z.object({
280
- category: z.string().optional(),
281
- search: z.string().optional(),
282
- minPrice: z.number().positive().optional(),
283
- maxPrice: z.number().positive().optional(),
284
- inStock: z.boolean().optional(),
285
- sortBy: z.enum(["name", "price", "createdAt"]).optional(),
286
- sortOrder: z.enum(["asc", "desc"]).optional(),
287
- page: z.number().int().positive().optional(),
288
- limit: z.number().int().positive().optional()
289
- });
290
- var StorefrontProductSchema = z.object({
291
- id: z.coerce.string(),
292
- name: z.string(),
293
- slug: z.string(),
294
- productType: z.string().optional().nullable(),
295
- imageUrl: z.string().optional().nullable(),
296
- price: z.number().nonnegative(),
297
- compareAtPrice: z.number().nonnegative().optional().nullable(),
298
- variantCount: z.number().int().nonnegative().optional().default(0),
299
- isAvailable: z.boolean(),
300
- totalInventory: z.number().int().nonnegative(),
301
- bundleItemsCount: z.number().int().nonnegative().optional().default(0),
302
- brand: z.string().optional().nullable(),
303
- category: z.string().optional().nullable(),
304
- status: z.string().optional().nullable(),
305
- tags: z.array(z.string()).optional().nullable()
306
- });
307
- var StorefrontFacetSchema = z.object({
308
- value: z.string(),
309
- count: z.number().int().nonnegative()
310
- });
311
- var StorefrontProductsResponseSchema = z.object({
312
- pageIndex: z.number().int().positive(),
313
- pageSize: z.number().int().positive(),
314
- totalCount: z.number().int().nonnegative(),
315
- totalPages: z.number().int().nonnegative(),
316
- products: z.array(StorefrontProductSchema),
317
- categories: z.array(StorefrontFacetSchema).optional().default([]),
318
- brands: z.array(StorefrontFacetSchema).optional().default([]),
319
- minPrice: z.number().nonnegative().optional().nullable(),
320
- maxPrice: z.number().nonnegative().optional().nullable()
321
- });
322
- var StorefrontProductsParamsSchema = z.object({
323
- page: z.number().int().positive().optional().default(1),
324
- pageSize: z.number().int().positive().optional().default(20),
325
- sort: z.enum(["price_asc", "price_desc", "name_asc", "name_desc", "newest"]).optional().default("price_asc"),
326
- sellerId: z.string().optional(),
327
- search: z.string().optional(),
328
- collection: z.string().optional(),
329
- category: z.string().optional(),
330
- brand: z.string().optional(),
331
- productType: z.string().optional(),
332
- inStock: z.boolean().optional(),
333
- minPrice: z.number().nonnegative().optional(),
334
- maxPrice: z.number().nonnegative().optional()
335
- });
336
- var StorefrontVariantOptionSchema = z.object({
337
- key: z.string(),
338
- name: z.string(),
339
- value: z.string()
340
- });
341
- var StorefrontProductImageSchema = z.object({
342
- url: z.string(),
343
- name: z.string().optional().nullable(),
344
- order: z.number().int().nonnegative().optional()
345
- });
346
- var StorefrontVariantSchema = z.object({
347
- id: z.coerce.string().optional().default(""),
348
- sku: z.string(),
349
- status: z.string().optional().nullable(),
350
- price: z.number().nonnegative(),
351
- compareAtPrice: z.number().nonnegative().optional().nullable(),
352
- quantity: z.number().int().nonnegative(),
353
- options: z.array(StorefrontVariantOptionSchema).optional().default([]),
354
- images: z.array(StorefrontProductImageSchema).optional().default([])
355
- });
356
- var StorefrontPriceTierSchema = z.object({
357
- variantId: z.coerce.string(),
358
- minQuantity: z.number().int().positive(),
359
- maxQuantity: z.number().int().positive().optional().nullable(),
360
- unitPrice: z.number().nonnegative()
361
- });
362
- var StorefrontBundleItemSchema = z.object({
363
- productId: z.coerce.string(),
364
- variantId: z.coerce.string(),
365
- productName: z.string(),
366
- variantName: z.string().optional().nullable(),
367
- sku: z.string().optional().nullable(),
368
- brand: z.string().optional().nullable(),
369
- imageUrl: z.string().optional().nullable(),
370
- quantity: z.number().int(),
371
- availableStock: z.number().int().optional().default(0),
372
- allowBackorders: z.boolean().optional().default(false),
373
- requiresShipping: z.boolean().optional().default(true)
374
- });
375
- var StorefrontProductDetailSchema = z.object({
376
- id: z.coerce.string(),
377
- name: z.string(),
378
- slug: z.string(),
379
- description: z.string().optional().nullable(),
380
- productType: z.string().optional().nullable(),
381
- status: z.string().optional().nullable(),
382
- imageUrl: z.string().optional().nullable(),
383
- price: z.number().nonnegative(),
384
- compareAtPrice: z.number().nonnegative().optional().nullable(),
385
- isAvailable: z.boolean(),
386
- totalInventory: z.number().int().nonnegative(),
387
- brand: z.string().optional().nullable(),
388
- category: z.string().optional().nullable(),
389
- categoryId: z.coerce.string().optional().nullable(),
390
- tags: z.array(z.string()).optional().nullable(),
391
- specifications: z.array(z.record(z.string(), z.unknown())).optional().default([]),
392
- variants: z.array(StorefrontVariantSchema).optional().default([]),
393
- images: z.array(StorefrontProductImageSchema).optional().default([]),
394
- bundleItems: z.array(StorefrontBundleItemSchema).optional().default([]),
395
- priceTiers: z.array(StorefrontPriceTierSchema).optional().default([]),
396
- createdAt: z.string().optional().nullable(),
397
- updatedAt: z.string().optional().nullable()
398
- });
399
218
 
400
219
  // src/core/client/store-api-product.service.ts
401
220
  async function getStorefrontProducts(params, cacheKey) {
@@ -426,17 +245,6 @@ async function getStorefrontProductBySlug(slug) {
426
245
  const response = await client.get(path);
427
246
  return StorefrontProductDetailSchema.parse(response);
428
247
  }
429
- var StorefrontCollectionSchema = z.object({
430
- id: z.coerce.string(),
431
- slug: z.string(),
432
- name: z.string(),
433
- description: z.string().nullable().optional(),
434
- imageUrl: z.string().nullable().optional(),
435
- type: z.string(),
436
- productCount: z.number().int().nonnegative()
437
- });
438
- var StorefrontCollectionsResponseSchema = z.array(StorefrontCollectionSchema);
439
- var StorefrontCollectionDetailSchema = StorefrontCollectionSchema;
440
248
 
441
249
  // src/core/client/store-api-collection.service.ts
442
250
  async function getStorefrontCollections() {
@@ -451,42 +259,6 @@ async function getStorefrontCollectionBySlug(slug) {
451
259
  );
452
260
  return StorefrontCollectionDetailSchema.parse(response);
453
261
  }
454
- var StorefrontPageListItemSchema = z.object({
455
- id: z.string(),
456
- name: z.string(),
457
- slug: z.string(),
458
- layout: z.string()
459
- });
460
- var StorefrontPageSeoSchema = z.object({
461
- title: z.string().optional(),
462
- description: z.string().optional()
463
- }).optional();
464
- var StorefrontPageSettingsSchema = z.object({
465
- seo: StorefrontPageSeoSchema,
466
- html: z.string().optional(),
467
- title: z.string().optional()
468
- }).catchall(z.unknown());
469
- var StorefrontPageBlockSchema = z.object({
470
- id: z.string(),
471
- type: z.string(),
472
- order: z.number(),
473
- settings: z.record(z.unknown()).optional()
474
- });
475
- var StorefrontPageSectionSchema = z.object({
476
- id: z.string(),
477
- type: z.string(),
478
- order: z.number(),
479
- settings: z.record(z.unknown()).optional(),
480
- blocks: z.array(StorefrontPageBlockSchema).optional().default([])
481
- });
482
- var StorefrontPageDetailSchema = z.object({
483
- id: z.string(),
484
- name: z.string(),
485
- slug: z.string(),
486
- layout: z.string(),
487
- settings: StorefrontPageSettingsSchema.optional(),
488
- sections: z.array(StorefrontPageSectionSchema).optional()
489
- });
490
262
  async function getStorefrontPages() {
491
263
  const client = await getStoreApiClient();
492
264
  const response = await client.get("pages");
@@ -1507,92 +1279,6 @@ function collectNetworkErrorCodes(e) {
1507
1279
  return out;
1508
1280
  }
1509
1281
 
1510
- // src/react/shell/lib/find-storefront-cms-page.ts
1511
- function isRenderableCmsPage(p) {
1512
- if (!p.status) return true;
1513
- return p.status === "published";
1514
- }
1515
- function findStorefrontCmsPageBySlug(settings, slug) {
1516
- const pages = settings?.cms?.pages;
1517
- if (!pages?.length) return null;
1518
- const raw = pages.find(
1519
- (p) => p.slug === slug && isRenderableCmsPage(p)
1520
- );
1521
- if (!raw) return null;
1522
- const parsed = StorefrontPageDetailSchema.safeParse(raw);
1523
- return parsed.success ? parsed.data : null;
1524
- }
1525
-
1526
- // src/core/constants/currency.ts
1527
- var countryCurrency = {
1528
- "PEN": "es-PE",
1529
- "USD": "en-US",
1530
- "COP": "es-CO",
1531
- "MXN": "es-MX"
1532
- };
1533
-
1534
- // src/core/utils/format-currency.ts
1535
- function formatCurrency(amount, currency = "USD") {
1536
- const locale = countryCurrency[currency] ?? "en-US";
1537
- return new Intl.NumberFormat(locale, {
1538
- style: "currency",
1539
- currency
1540
- }).format(amount);
1541
- }
1542
- var ApiClient = class {
1543
- client;
1544
- storeId;
1545
- storeDomain;
1546
- constructor(baseURL = "https://storefront.ecomiq.pe") {
1547
- this.client = axios.create({
1548
- baseURL,
1549
- timeout: 1e4,
1550
- headers: {
1551
- "Content-Type": "application/json"
1552
- }
1553
- });
1554
- this.client.interceptors.request.use(
1555
- (config) => {
1556
- if (config.headers) {
1557
- if (this.storeId) config.headers["X-Store-Id"] = this.storeId;
1558
- if (this.storeDomain) config.headers["X-Store-Domain"] = this.storeDomain;
1559
- }
1560
- return config;
1561
- }
1562
- );
1563
- this.client.interceptors.response.use(
1564
- (response) => response,
1565
- (error) => {
1566
- console.error("API Error:", error);
1567
- return Promise.reject(error);
1568
- }
1569
- );
1570
- }
1571
- setStoreId(storeId) {
1572
- this.storeId = storeId;
1573
- }
1574
- /** Subdominio para endpoints que usan X-Store-Domain (ej. GET /v1/storefront/settings) */
1575
- setStoreDomain(domain) {
1576
- this.storeDomain = domain;
1577
- }
1578
- get(url, config) {
1579
- return this.client.get(url, config).then((response) => response.data);
1580
- }
1581
- post(url, data, config) {
1582
- return this.client.post(url, data, config).then((response) => response.data);
1583
- }
1584
- put(url, data, config) {
1585
- return this.client.put(url, data, config).then((response) => response.data);
1586
- }
1587
- patch(url, data, config) {
1588
- return this.client.patch(url, data, config).then((response) => response.data);
1589
- }
1590
- delete(url, config) {
1591
- return this.client.delete(url, config).then((response) => response.data);
1592
- }
1593
- };
1594
- new ApiClient();
1595
-
1596
- export { CustomerAddressSchema, CustomerAddressUpsertSchema, CustomerMeSchema, CustomerOrderDetailSchema, CustomerOrderListItemSchema, CustomerProfilePatchSchema, CustomerRegisterRequestSchema, StoreApiClient, StorefrontProductSchema, StorefrontProductsResponseSchema, addCartCoupon, applyServerRequestOriginFromHeaders, checkoutCart, createCart, createCustomerAddress, createStoreApiClient, customerMeToProfilePatch, deleteCustomerAddress, ecomiqOAuthPassword, fetchPublicStoreSettings, findStorefrontCmsPageBySlug, formatCurrency, 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 };
1597
- //# sourceMappingURL=chunk-PDK2VYWD.js.map
1598
- //# sourceMappingURL=chunk-PDK2VYWD.js.map
1282
+ 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 };
1283
+ //# sourceMappingURL=chunk-3C4ZLHSU.js.map
1284
+ //# sourceMappingURL=chunk-3C4ZLHSU.js.map