@ecomiq/storefront 1.0.2 → 1.1.1

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 +29 -19
  2. package/dist/{chunk-TDQ53V3E.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-PCLA4TZF.js → chunk-EADDSNJS.js} +4 -157
  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 -12
  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 -12
  43. package/dist/tanstack.js +2 -11
  44. package/package.json +5 -1
  45. package/dist/chunk-PCLA4TZF.js.map +0 -1
  46. package/dist/chunk-Q762YXCQ.js.map +0 -1
  47. package/dist/chunk-TDQ53V3E.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
 
@@ -97,7 +98,7 @@ Los hooks (`useStoreProducts`, `useStoreCart`, …) tienen **una sola implementa
97
98
  │ │
98
99
  └─────────────────────────┬─────────────────────────┘
99
100
  ▼
100
- Capa React compartida (hooks, EcomiqProvider, cliente BFF, auth)
101
+ Capa React (`/react`) — hooks, EcomiqProvider, cliente BFF browser, auth
101
102
  │
102
103
  ▼
103
104
  core/server — fetchPublicStoreSettings · handleStoreProxyRequest
@@ -132,8 +133,8 @@ Los hooks y `EcomiqProvider` son **Client Components** (`"use client"`). En el l
132
133
  // app/ecomiq-provider.tsx
133
134
  "use client";
134
135
 
135
- import { EcomiqProvider } from "@ecomiq/storefront";
136
- import type { StorefrontSettings } from "@ecomiq/storefront/nextjs";
136
+ import { EcomiqProvider } from "@ecomiq/storefront/react";
137
+ import type { StorefrontSettings } from "@ecomiq/storefront";
137
138
 
138
139
  export function EcomiqRootProvider({
139
140
  store,
@@ -170,12 +171,12 @@ export default async function RootLayout({ children }: { children: React.ReactNo
170
171
 
171
172
  ### 3. Catálogo con hooks
172
173
 
173
- Puedes importar hooks desde el paquete raíz o desde `/nextjs`:
174
+ Importa hooks desde `@ecomiq/storefront/react`:
174
175
 
175
176
  ```tsx
176
177
  "use client";
177
178
 
178
- import { useStoreProducts } from "@ecomiq/storefront";
179
+ import { useStoreProducts } from "@ecomiq/storefront/react";
179
180
 
180
181
  export function ProductList() {
181
182
  const { useStorefrontProductsList } = useStoreProducts();
@@ -231,7 +232,7 @@ export const Route = createFileRoute("/api/store/$")({
231
232
  // src/components/ecomiq-provider.tsx
232
233
  "use client";
233
234
 
234
- import { EcomiqProvider } from "@ecomiq/storefront";
235
+ import { EcomiqProvider } from "@ecomiq/storefront/react";
235
236
  import type { StorefrontSettings } from "@ecomiq/storefront/tanstack";
236
237
 
237
238
  export function EcomiqRootProvider({
@@ -271,7 +272,7 @@ function RootComponent() {
271
272
  ```tsx
272
273
  "use client";
273
274
 
274
- import { useStoreProducts, useStoreCart } from "@ecomiq/storefront";
275
+ import { useStoreProducts, useStoreCart } from "@ecomiq/storefront/react";
275
276
  ```
276
277
 
277
278
  ---
@@ -373,21 +374,30 @@ export function AccountActions() {
373
374
  }
374
375
  ```
375
376
 
376
- 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`.
377
378
 
378
379
  ---
379
380
 
380
- ## Qué incluye cada adapter
381
+ ## Qué incluye cada entry
381
382
 
382
- Desde `/nextjs` o `/tanstack` obtienes:
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`
388
+
389
+ Desde `@ecomiq/storefront/react` (**client**, `"use client"`):
383
390
 
384
- - **Server:** `getPublicStore`, `getHostname`, `fetchPublicStoreSettings` (agnóstico)
385
391
  - **Provider:** `EcomiqProvider`, `useStore`, `usePublicStore`
386
392
  - **Hooks BFF:** `useStoreProducts`, `useStoreCollections`, `useStorePages`, `useStoreCart`
387
- - **Cliente:** `getStorefrontProducts`, `registerCustomer`, servicios de carrito/cuenta, etc.
388
- - **Auth:** `ecomiqOAuthPassword`, `ecomiqOAuthPasswordClient`, `signInWithEcomiqCredentials`, `useStorefrontSession`
389
- - **Tipos y Zod:** `StorefrontSettings`, `StorefrontProduct`, schemas, `formatCurrency`
390
- - **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`, …
391
401
 
392
402
  ## Variables de entorno
393
403
 
@@ -1,11 +1,12 @@
1
- import { StorefrontSettingsSchema, resolvePublicStoreKey, getStorefrontSettingsFromKvByStoreKey } from './chunk-PCLA4TZF.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-TDQ53V3E.js.map
1598
- //# sourceMappingURL=chunk-TDQ53V3E.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