@ecomiq/storefront 0.1.0 → 0.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.
- package/README.md +94 -86
- package/dist/core.d.ts +3 -12
- package/dist/find-storefront-cms-page-c8CktSz7.d.ts +164 -0
- package/dist/nextjs/globals.css +3 -4
- package/dist/nextjs.d.ts +102 -105
- package/dist/nextjs.js +580 -1485
- package/dist/nextjs.js.map +1 -1
- package/dist/react.d.ts +57 -138
- package/dist/react.js +427 -1060
- package/dist/react.js.map +1 -1
- package/dist/{store-CYBCpY6v.d.ts → store-to_vuWRF.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/find-storefront-cms-page-Bo0-G1FK.d.ts +0 -119
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @ecomiq/storefront
|
|
2
2
|
|
|
3
|
-
SDK
|
|
3
|
+
SDK **headless** para construir tu propia tienda con **Next.js** y **React** sobre Ecomiq.
|
|
4
4
|
|
|
5
|
-
Incluye
|
|
5
|
+
Incluye capa de **datos y API**: tipos, schemas Zod, cliente BFF (`/api/store`), hooks y utilidades server. **No** incluye UI precargada (checkout, CMS renderer, temas, `ShellRouter`, etc.): diseñas e implementas la interfaz en tu proyecto.
|
|
6
6
|
|
|
7
7
|
## Requisitos
|
|
8
8
|
|
|
@@ -19,8 +19,6 @@ npm install @ecomiq/storefront
|
|
|
19
19
|
pnpm add @ecomiq/storefront
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
En `next.config.js` (o `.mjs`), transpila el SDK:
|
|
23
|
-
|
|
24
22
|
```js
|
|
25
23
|
/** @type {import('next').NextConfig} */
|
|
26
24
|
const nextConfig = {
|
|
@@ -30,20 +28,18 @@ const nextConfig = {
|
|
|
30
28
|
export default nextConfig;
|
|
31
29
|
```
|
|
32
30
|
|
|
33
|
-
##
|
|
34
|
-
|
|
35
|
-
### 1. Estilos
|
|
31
|
+
## Arquitectura
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
@import "tailwindcss";
|
|
41
|
-
@import "@ecomiq/storefront/nextjs/css";
|
|
33
|
+
```
|
|
34
|
+
Navegador → /api/store/* (proxy en tu Next.js) → API Ecomiq
|
|
35
|
+
↑ X-Store-Id (cookie / header tras getPublicStore)
|
|
42
36
|
```
|
|
43
37
|
|
|
44
|
-
|
|
38
|
+
El SDK **no** llama al upstream desde el browser; todas las peticiones van al proxy que tú montas con `toNextJsStoreApiHandler`.
|
|
45
39
|
|
|
46
|
-
|
|
40
|
+
## Inicio rápido
|
|
41
|
+
|
|
42
|
+
### 1. Proxy BFF
|
|
47
43
|
|
|
48
44
|
```ts
|
|
49
45
|
// app/api/store/[...path]/route.ts
|
|
@@ -54,124 +50,136 @@ export const { GET, POST, PUT, PATCH, DELETE } = toNextJsStoreApiHandler({
|
|
|
54
50
|
});
|
|
55
51
|
```
|
|
56
52
|
|
|
57
|
-
###
|
|
53
|
+
### 2. Resolver la tienda (server)
|
|
58
54
|
|
|
59
55
|
```tsx
|
|
60
|
-
// app/
|
|
61
|
-
import {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
// app/layout.tsx (Server Component)
|
|
57
|
+
import { getPublicStore, EcomiqProvider } from "@ecomiq/storefront/nextjs";
|
|
58
|
+
import { authClient } from "./auth-client";
|
|
59
|
+
|
|
60
|
+
export default async function RootLayout({ children }: { children: React.ReactNode }) {
|
|
61
|
+
const { data: store, error } = await getPublicStore();
|
|
62
|
+
if (error) {
|
|
63
|
+
// tu página de error / tienda no encontrada
|
|
64
|
+
}
|
|
66
65
|
return (
|
|
67
|
-
<EcomiqProvider store={
|
|
68
|
-
<ThemeComponentLoader themeName="default" componentName="header" props={{ /* logo, etc. */ }} />
|
|
66
|
+
<EcomiqProvider store={store} authClient={authClient}>
|
|
69
67
|
{children}
|
|
70
|
-
<ThemeComponentLoader themeName="default" componentName="footer" props={{ /* … */ }} />
|
|
71
68
|
</EcomiqProvider>
|
|
72
69
|
);
|
|
73
70
|
}
|
|
74
71
|
```
|
|
75
72
|
|
|
76
|
-
|
|
73
|
+
`EcomiqProvider` es un Client Component: puedes importarlo desde un layout servidor como en el ejemplo. Hidrata la tienda (`useStore`, `setClientStoreId`), React Query y la sesión (`authClient` de Better Auth).
|
|
77
74
|
|
|
78
|
-
|
|
75
|
+
### 3. Catálogo con hooks
|
|
79
76
|
|
|
80
77
|
```tsx
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
params: Promise<{ route?: string[] }>;
|
|
89
|
-
searchParams: Record<string, string | string[] | undefined>;
|
|
90
|
-
}) {
|
|
91
|
-
return <ShellRouter {...props} getServerSession={yourGetSession} />;
|
|
92
|
-
}
|
|
78
|
+
"use client";
|
|
79
|
+
|
|
80
|
+
import { useStoreProducts } from "@ecomiq/storefront/nextjs";
|
|
81
|
+
|
|
82
|
+
export function ProductList() {
|
|
83
|
+
const { useStorefrontProductsList } = useStoreProducts();
|
|
84
|
+
const { data, isLoading } = useStorefrontProductsList({ page: 1, pageSize: 24 });
|
|
93
85
|
|
|
94
|
-
|
|
95
|
-
return
|
|
86
|
+
if (isLoading) return <p>Cargando…</p>;
|
|
87
|
+
return (
|
|
88
|
+
<ul>
|
|
89
|
+
{data?.products.map((p) => (
|
|
90
|
+
<li key={p.id}>{p.name}</li>
|
|
91
|
+
))}
|
|
92
|
+
</ul>
|
|
93
|
+
);
|
|
96
94
|
}
|
|
97
95
|
```
|
|
98
96
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
## Puntos de entrada
|
|
97
|
+
### 4. Datos en Server Components
|
|
102
98
|
|
|
103
|
-
|
|
99
|
+
```tsx
|
|
100
|
+
import { getStorefrontProducts } from "@ecomiq/storefront/nextjs";
|
|
104
101
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
| `@ecomiq/storefront/react` | Componentes, hooks, tipos y utilidades para UI personalizada |
|
|
111
|
-
| `@ecomiq/storefront/client` | Llamadas a la API de tienda (catálogo, carrito, pedidos, cliente) sin componentes |
|
|
112
|
-
| `@ecomiq/storefront/core` | Tipos y schemas Zod (módulos sin React) |
|
|
102
|
+
export default async function CatalogPage() {
|
|
103
|
+
const { products } = await getStorefrontProducts({ page: 1, pageSize: 24 });
|
|
104
|
+
return <YourGrid products={products} />;
|
|
105
|
+
}
|
|
106
|
+
```
|
|
113
107
|
|
|
114
|
-
|
|
108
|
+
### 5. Estilos (opcional)
|
|
115
109
|
|
|
116
|
-
|
|
110
|
+
```css
|
|
111
|
+
@import "tailwindcss";
|
|
112
|
+
@import "@ecomiq/storefront/nextjs/css";
|
|
113
|
+
```
|
|
117
114
|
|
|
118
|
-
|
|
119
|
-
|----------|-------------|
|
|
120
|
-
| `STOREFRONT_API_URL` | URL base de la API de tienda Ecomiq (usada en el proxy) |
|
|
115
|
+
El CSS publicado es **mínimo**. Tu design system y componentes viven en la app.
|
|
121
116
|
|
|
122
|
-
|
|
117
|
+
## Puntos de entrada (npm)
|
|
123
118
|
|
|
124
|
-
|
|
119
|
+
| Import | Uso |
|
|
120
|
+
|--------|-----|
|
|
121
|
+
| `@ecomiq/storefront/core` | Tipos, Zod, utilidades, servicios axios legacy |
|
|
122
|
+
| `@ecomiq/storefront/react` | `EcomiqProvider`, hooks, stores, auth OAuth, `findStorefrontCmsPageBySlug`, selector de variantes |
|
|
123
|
+
| `@ecomiq/storefront/nextjs` | `getPublicStore`, `EcomiqProvider`, cliente BFF, hooks `useStore*` |
|
|
124
|
+
| `@ecomiq/storefront/nextjs/api` | Handler del proxy `/api/store/*` |
|
|
125
|
+
| `@ecomiq/storefront/nextjs/css` | Tailwind base opcional |
|
|
126
|
+
| `@ecomiq/storefront/nextjs/postcss` | PostCSS de referencia |
|
|
125
127
|
|
|
126
|
-
|
|
128
|
+
No hay subpath `./client` en npm: las funciones del cliente BFF se importan desde **`/nextjs`**.
|
|
127
129
|
|
|
128
|
-
|
|
130
|
+
## Auth (Better Auth)
|
|
129
131
|
|
|
130
|
-
|
|
131
|
-
import { ThemeComponentLoader } from "@ecomiq/storefront/nextjs";
|
|
132
|
+
Plugins para OAuth password grant de Ecomiq:
|
|
132
133
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
```ts
|
|
135
|
+
import {
|
|
136
|
+
ecomiqOAuthPassword,
|
|
137
|
+
ecomiqOAuthPasswordClient,
|
|
138
|
+
} from "@ecomiq/storefront/react";
|
|
138
139
|
```
|
|
139
140
|
|
|
140
|
-
|
|
141
|
+
## Variables de entorno
|
|
141
142
|
|
|
142
|
-
|
|
143
|
+
| Variable | Descripción |
|
|
144
|
+
|----------|-------------|
|
|
145
|
+
| `STOREFRONT_API_URL` | URL base de la API de tienda (proxy) |
|
|
146
|
+
| `PUBLIC_STORE_SETTINGS_SOURCE` | `api` (default) o `kv` (OpenNext / Cloudflare) |
|
|
143
147
|
|
|
144
|
-
|
|
145
|
-
import { useProducts, ProductsSection, type StorefrontProduct } from "@ecomiq/storefront/react";
|
|
146
|
-
```
|
|
148
|
+
Tras `getPublicStore`, el SDK fija `X-Store-Id` en el servidor para las llamadas al proxy.
|
|
147
149
|
|
|
148
|
-
|
|
149
|
-
import { setClientStoreId, getStorefrontProducts } from "@ecomiq/storefront/client";
|
|
150
|
+
## Qué no viene en el paquete npm
|
|
150
151
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
Pensado para que **tú** construyas la UI:
|
|
153
|
+
|
|
154
|
+
- `ShellRouter`, páginas exportadas
|
|
155
|
+
- Checkout, carrito drawer, cuenta, formularios precargados
|
|
156
|
+
- `CmsSectionsRenderer`, `DefaultCmsSectionsRenderer`, `SafeThemeInjector`
|
|
157
|
+
- `ThemeComponentLoader` y temas `default` / `ana` / `sony`
|
|
158
|
+
- Dependencia de `@ecomiq/ui`
|
|
159
|
+
|
|
160
|
+
Esa capa completa existe en el **monorepo Ecomiq** (`workspace:*` sobre `src/`), no en el tarball npm.
|
|
154
161
|
|
|
155
|
-
|
|
162
|
+
## Desarrollo en el monorepo Ecomiq
|
|
156
163
|
|
|
157
|
-
|
|
164
|
+
Si trabajas dentro del repo `ecomiq`, el paquete se consume por fuente con exports amplios (`./react/components/*`, `./nextjs/export-pages/*`, etc.) y UI con `@ecomiq/ui`.
|
|
158
165
|
|
|
159
|
-
|
|
166
|
+
Para empaquetar o publicar en npm: ver [PUBLISHING.md](./PUBLISHING.md).
|
|
167
|
+
|
|
168
|
+
## Dependencias recomendadas en tu app
|
|
160
169
|
|
|
161
170
|
```json
|
|
162
171
|
{
|
|
163
172
|
"dependencies": {
|
|
164
173
|
"@ecomiq/storefront": "^0.1.0",
|
|
174
|
+
"@tanstack/react-query": "^5.66.0",
|
|
175
|
+
"better-auth": "^1.6.0",
|
|
165
176
|
"next": "^15.3.0",
|
|
166
177
|
"react": "^19.0.0",
|
|
167
|
-
"react-dom": "^19.0.0"
|
|
168
|
-
"tailwindcss": "^4.0.0"
|
|
178
|
+
"react-dom": "^19.0.0"
|
|
169
179
|
}
|
|
170
180
|
}
|
|
171
181
|
```
|
|
172
182
|
|
|
173
183
|
## Soporte
|
|
174
184
|
|
|
175
|
-
Documentación
|
|
176
|
-
|
|
177
|
-
Para incidencias del SDK, abre un issue en el repositorio del paquete o contacta al equipo Ecomiq.
|
|
185
|
+
Documentación y credenciales: [ecomiq.pe](https://ecomiq.pe) (o el portal de tu organización).
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as ProductsFilters,
|
|
2
|
-
export { t as ProductSchema,
|
|
1
|
+
import { P as ProductsFilters, d as ProductsResponse, b as Product, a as StorefrontProductsParamsInput, f as StorefrontProductsResponse, g as StorefrontProductDetail, m as StorefrontCollection, o as StorefrontCollectionDetail, S as StorefrontSettings } from './store-to_vuWRF.js';
|
|
2
|
+
export { t as ProductSchema, c as ProductVariant, u as ProductVariantSchema, w as ProductsFiltersSchema, v as ProductsResponseSchema, l as StorefrontBundleItem, C as StorefrontBundleItemSchema, I as StorefrontCheckoutSettingsSchema, r as StorefrontCmsPage, q as StorefrontCmsSettings, F as StorefrontCollectionDetailSchema, D as StorefrontCollectionSchema, n as StorefrontCollectionsResponse, E as StorefrontCollectionsResponseSchema, k as StorefrontPriceTier, B as StorefrontPriceTierSchema, e as StorefrontProduct, A as StorefrontProductDetailSchema, j as StorefrontProductImage, x as StorefrontProductSchema, z as StorefrontProductsParamsSchema, y as StorefrontProductsResponseSchema, s as StorefrontSettingsLegacyFlat, J as StorefrontSettingsLegacyFlatSchema, G as StorefrontSettingsSchema, p as StorefrontStore, H as StorefrontStoreSchema, h as StorefrontVariant, i as StorefrontVariantOption, N as normalizeStorefrontSettingsPayload, L as storefrontFaviconUrl, M as storefrontOgImageUrl, K as storefrontStoreRecord } from './store-to_vuWRF.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { AxiosRequestConfig } from 'axios';
|
|
5
5
|
|
|
@@ -3191,15 +3191,6 @@ declare class ApiClient {
|
|
|
3191
3191
|
}
|
|
3192
3192
|
declare const apiClient: ApiClient;
|
|
3193
3193
|
|
|
3194
|
-
interface ThemeComponentsMap {
|
|
3195
|
-
header: React.ComponentType<any>;
|
|
3196
|
-
footer: React.ComponentType<any>;
|
|
3197
|
-
buttonCart: React.ComponentType<any>;
|
|
3198
|
-
productCard: React.ComponentType<any>;
|
|
3199
|
-
}
|
|
3200
|
-
type ThemeComponentName = keyof ThemeComponentsMap;
|
|
3201
|
-
type ThemeName = 'ana' | 'sony' | 'default';
|
|
3202
|
-
|
|
3203
3194
|
interface ThemeColors {
|
|
3204
3195
|
primary: string;
|
|
3205
3196
|
secondary: string;
|
|
@@ -3397,4 +3388,4 @@ type CustomerProfile = {
|
|
|
3397
3388
|
dateOfBirth: string | null;
|
|
3398
3389
|
};
|
|
3399
3390
|
|
|
3400
|
-
export { type CartAddressesRequest, CartAddressesRequestSchema, type CartBuyerRequest, CartBuyerRequestSchema, type CartCheckoutPayment, type CartCheckoutPaymentAction, CartCheckoutPaymentActionSchema, CartCheckoutPaymentSchema, type CartCheckoutReadResponse, CartCheckoutReadResponseSchema, type CartCheckoutRequest, CartCheckoutRequestSchema, type CartCheckoutResponse, CartCheckoutResponseSchema, type CartCouponRequest, CartCouponRequestSchema, type CartCreateRequest, CartCreateRequestSchema, type CartItemModifierRequest, CartItemModifierRequestSchema, type CartItemRequest, CartItemRequestSchema, type CartPaymentMethod, CartPaymentMethodSchema, type CartPaymentMethodsResponse, CartPaymentMethodsResponseSchema, type CartPaymentReceiptResponse, CartPaymentReceiptResponseSchema, type CartResponse, CartResponseBundleItemSchema, CartResponseItemSchema, CartResponseSchema, type CartShippingMethodPutRequest, CartShippingMethodPutRequestSchema, type CustomerAddressUpsertInput, type CustomerOrderDetail, type CustomerOrderLineItem, type CustomerOrderListItem, type CustomerOrderShippingAddress, type CustomerProfile, type CustomerProfilePatch, type CustomerSavedAddress, type GeoItem, Product, ProductsFilters, ProductsResponse, STOREFRONT_API_PATH_PREFIX, STOREFRONT_ECOMIQ_OAUTH_COOKIE_NAME, STOREFRONT_ECOMIQ_OAUTH_COOKIE_PATH, type ShippingOptionGroup, ShippingOptionGroupSchema, type ShippingOptionsResponse, ShippingOptionsResponseSchema, type ShippingRate, ShippingRateSchema, type StoreTheme, StorefrontCollection, StorefrontCollectionDetail, type StorefrontPageBlock, type StorefrontPageDetail, StorefrontPageDetailSchema, type StorefrontPageListItem, StorefrontPageListItemSchema, type StorefrontPageSection, StorefrontProductDetail, StorefrontProductsParamsInput, StorefrontProductsResponse, StorefrontSettings,
|
|
3391
|
+
export { type CartAddressesRequest, CartAddressesRequestSchema, type CartBuyerRequest, CartBuyerRequestSchema, type CartCheckoutPayment, type CartCheckoutPaymentAction, CartCheckoutPaymentActionSchema, CartCheckoutPaymentSchema, type CartCheckoutReadResponse, CartCheckoutReadResponseSchema, type CartCheckoutRequest, CartCheckoutRequestSchema, type CartCheckoutResponse, CartCheckoutResponseSchema, type CartCouponRequest, CartCouponRequestSchema, type CartCreateRequest, CartCreateRequestSchema, type CartItemModifierRequest, CartItemModifierRequestSchema, type CartItemRequest, CartItemRequestSchema, type CartPaymentMethod, CartPaymentMethodSchema, type CartPaymentMethodsResponse, CartPaymentMethodsResponseSchema, type CartPaymentReceiptResponse, CartPaymentReceiptResponseSchema, type CartResponse, CartResponseBundleItemSchema, CartResponseItemSchema, CartResponseSchema, type CartShippingMethodPutRequest, CartShippingMethodPutRequestSchema, type CustomerAddressUpsertInput, type CustomerOrderDetail, type CustomerOrderLineItem, type CustomerOrderListItem, type CustomerOrderShippingAddress, type CustomerProfile, type CustomerProfilePatch, type CustomerSavedAddress, type GeoItem, Product, ProductsFilters, ProductsResponse, STOREFRONT_API_PATH_PREFIX, STOREFRONT_ECOMIQ_OAUTH_COOKIE_NAME, STOREFRONT_ECOMIQ_OAUTH_COOKIE_PATH, type ShippingOptionGroup, ShippingOptionGroupSchema, type ShippingOptionsResponse, ShippingOptionsResponseSchema, type ShippingRate, ShippingRateSchema, type StoreTheme, StorefrontCollection, StorefrontCollectionDetail, type StorefrontPageBlock, type StorefrontPageDetail, StorefrontPageDetailSchema, type StorefrontPageListItem, StorefrontPageListItemSchema, type StorefrontPageSection, StorefrontProductDetail, StorefrontProductsParamsInput, StorefrontProductsResponse, StorefrontSettings, apiClient, cartService, collectionService, countryCurrency, customerOrderStatusTone, fetchStorefrontGeoDistricts, fetchStorefrontGeoProvinces, formatCurrency, formatCustomerOrderStatus, formatOrderDate, formatOrderDateTime, loadStorefrontGeoDepartments, pageService, productService, resolveIneiCodesFromLabels, storeService, toGeoItems };
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import * as zustand from 'zustand';
|
|
2
|
+
import { S as StorefrontSettings } from './store-to_vuWRF.js';
|
|
3
|
+
import * as React$1 from 'react';
|
|
4
|
+
import React__default from 'react';
|
|
5
|
+
import * as better_auth_react from 'better-auth/react';
|
|
6
|
+
import { createAuthClient } from 'better-auth/react';
|
|
7
|
+
import * as better_auth from 'better-auth';
|
|
8
|
+
import { StorefrontProductDetail, StorefrontVariant, StorefrontSettings as StorefrontSettings$1, StorefrontPageDetail } from '@ecomiq/storefront/react';
|
|
9
|
+
|
|
10
|
+
/** Instancia de `createAuthClient` (better-auth/react) con los plugins de la app. */
|
|
11
|
+
type StorefrontAuthClientInstance = ReturnType<typeof createAuthClient>;
|
|
12
|
+
declare function StorefrontAuthProvider({ authClient, children, }: {
|
|
13
|
+
authClient: StorefrontAuthClientInstance;
|
|
14
|
+
children: React__default.ReactNode;
|
|
15
|
+
}): React__default.JSX.Element;
|
|
16
|
+
declare function useStorefrontAuthClient(): StorefrontAuthClientInstance;
|
|
17
|
+
type StorefrontSessionUser = {
|
|
18
|
+
id: string;
|
|
19
|
+
email: string;
|
|
20
|
+
firstName: string;
|
|
21
|
+
lastName: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
phone?: string;
|
|
24
|
+
};
|
|
25
|
+
/** Caducidad alineada con OAuth/`expires_in` (skew en ms). El bearer ya no viene en JSON de sesión. */
|
|
26
|
+
declare function storefrontSessionEndsSoon(expiresAt: Date | undefined, skewMs?: number): boolean;
|
|
27
|
+
/** @deprecated Usar `storefrontSessionEndsSoon` */
|
|
28
|
+
declare const storefrontAccessTokenNeedsRefresh: typeof storefrontSessionEndsSoon;
|
|
29
|
+
/**
|
|
30
|
+
* Sesión Better Auth + usuario mapeado para UI (headers, drawer).
|
|
31
|
+
*/
|
|
32
|
+
declare function useStorefrontSession(): {
|
|
33
|
+
session: {
|
|
34
|
+
data: {
|
|
35
|
+
user: better_auth.StripEmptyObjects<{
|
|
36
|
+
id: string;
|
|
37
|
+
createdAt: Date;
|
|
38
|
+
updatedAt: Date;
|
|
39
|
+
email: string;
|
|
40
|
+
emailVerified: boolean;
|
|
41
|
+
name: string;
|
|
42
|
+
image?: string | null | undefined;
|
|
43
|
+
}>;
|
|
44
|
+
session: better_auth.StripEmptyObjects<{
|
|
45
|
+
id: string;
|
|
46
|
+
createdAt: Date;
|
|
47
|
+
updatedAt: Date;
|
|
48
|
+
userId: string;
|
|
49
|
+
expiresAt: Date;
|
|
50
|
+
token: string;
|
|
51
|
+
ipAddress?: string | null | undefined;
|
|
52
|
+
userAgent?: string | null | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
} | null;
|
|
55
|
+
isPending: boolean;
|
|
56
|
+
isRefetching: boolean;
|
|
57
|
+
error: better_auth_react.BetterFetchError | null;
|
|
58
|
+
refetch: (queryParams?: {
|
|
59
|
+
query?: better_auth.SessionQueryParams;
|
|
60
|
+
} | undefined) => Promise<void>;
|
|
61
|
+
};
|
|
62
|
+
user: StorefrontSessionUser | null;
|
|
63
|
+
sessionExpiresAt: Date | undefined;
|
|
64
|
+
isAuthenticated: boolean;
|
|
65
|
+
isPending: boolean;
|
|
66
|
+
error: better_auth_react.BetterFetchError | null;
|
|
67
|
+
refetch: (queryParams?: {
|
|
68
|
+
query?: better_auth.SessionQueryParams;
|
|
69
|
+
} | undefined) => Promise<void>;
|
|
70
|
+
signOut: () => Promise<{
|
|
71
|
+
data: {
|
|
72
|
+
success: boolean;
|
|
73
|
+
};
|
|
74
|
+
error: null;
|
|
75
|
+
} | {
|
|
76
|
+
data: null;
|
|
77
|
+
error: {
|
|
78
|
+
code?: string | undefined | undefined;
|
|
79
|
+
message?: string | undefined | undefined;
|
|
80
|
+
status: number;
|
|
81
|
+
statusText: string;
|
|
82
|
+
};
|
|
83
|
+
}>;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
type Drawers = {
|
|
87
|
+
cart: boolean;
|
|
88
|
+
search: boolean;
|
|
89
|
+
menu: boolean;
|
|
90
|
+
filter: boolean;
|
|
91
|
+
[key: string]: boolean;
|
|
92
|
+
};
|
|
93
|
+
type Modals = {
|
|
94
|
+
login: boolean;
|
|
95
|
+
signup: boolean;
|
|
96
|
+
[key: string]: boolean;
|
|
97
|
+
};
|
|
98
|
+
type StoreState = {
|
|
99
|
+
data: StorefrontSettings | null;
|
|
100
|
+
drawers: Drawers;
|
|
101
|
+
modals: Modals;
|
|
102
|
+
openDrawer: (drawer: keyof Drawers) => void;
|
|
103
|
+
closeDrawer: (drawer: keyof Drawers) => void;
|
|
104
|
+
toggleDrawer: (drawer: keyof Drawers) => void;
|
|
105
|
+
closeAllDrawers: () => void;
|
|
106
|
+
openModal: (modal: keyof Modals) => void;
|
|
107
|
+
closeModal: (modal: keyof Modals) => void;
|
|
108
|
+
toggleModal: (modal: keyof Modals) => void;
|
|
109
|
+
closeAllModals: () => void;
|
|
110
|
+
};
|
|
111
|
+
declare const useStore: zustand.UseBoundStore<zustand.StoreApi<StoreState>>;
|
|
112
|
+
|
|
113
|
+
type EcomiqProviderProps = {
|
|
114
|
+
store: StorefrontSettings | null;
|
|
115
|
+
authClient: StorefrontAuthClientInstance;
|
|
116
|
+
children: React__default.ReactNode;
|
|
117
|
+
/**
|
|
118
|
+
* Modales de login/registro y toasts del shell Ecomiq (requiere `@ecomiq/ui` en el monorepo).
|
|
119
|
+
* En npm / tiendas custom deja `false` y monta tu propia UI.
|
|
120
|
+
*/
|
|
121
|
+
withShellUi?: boolean;
|
|
122
|
+
};
|
|
123
|
+
declare function EcomiqProvider({ store, authClient, children, withShellUi, }: EcomiqProviderProps): React__default.JSX.Element;
|
|
124
|
+
|
|
125
|
+
/** Option group derived from variants (e.g. Color: [Black, White], Size: [6x8, 8x11]) */
|
|
126
|
+
type OptionGroup = {
|
|
127
|
+
key: string;
|
|
128
|
+
name: string;
|
|
129
|
+
values: string[];
|
|
130
|
+
};
|
|
131
|
+
/** Selected options per group (e.g. { Color: "Black", Size: "8 x 11 inch" }) */
|
|
132
|
+
type SelectedOptions = Record<string, string>;
|
|
133
|
+
type ProductVariantSelectorRenderProps = {
|
|
134
|
+
product: StorefrontProductDetail;
|
|
135
|
+
selectedVariant: StorefrontVariant | null;
|
|
136
|
+
displayPrice: number;
|
|
137
|
+
compareAtPrice: number | null | undefined;
|
|
138
|
+
isAvailable: boolean;
|
|
139
|
+
selectedOptions: SelectedOptions;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
type ProductVariantSelectorProps = {
|
|
143
|
+
product: StorefrontProductDetail;
|
|
144
|
+
currency?: string;
|
|
145
|
+
features?: string[];
|
|
146
|
+
onVariantChange?: (variant: StorefrontVariant | null, price: number) => void;
|
|
147
|
+
children?: (props: {
|
|
148
|
+
product: StorefrontProductDetail;
|
|
149
|
+
selectedVariant: StorefrontVariant | null;
|
|
150
|
+
displayPrice: number;
|
|
151
|
+
compareAtPrice: number | null | undefined;
|
|
152
|
+
isAvailable: boolean;
|
|
153
|
+
selectedOptions: SelectedOptions;
|
|
154
|
+
}) => React.ReactNode;
|
|
155
|
+
};
|
|
156
|
+
declare function ProductVariantSelector({ product, currency, features, onVariantChange, children, }: ProductVariantSelectorProps): React$1.JSX.Element;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Busca una página CMS en `settings.cms.pages` (payload de `getPublicStore` / settings)
|
|
160
|
+
* y la valida como `StorefrontPageDetail` para `DynamicPage`.
|
|
161
|
+
*/
|
|
162
|
+
declare function findStorefrontCmsPageBySlug(settings: StorefrontSettings$1 | null | undefined, slug: string): StorefrontPageDetail | null;
|
|
163
|
+
|
|
164
|
+
export { EcomiqProvider as E, type OptionGroup as O, ProductVariantSelector as P, StorefrontAuthProvider as S, storefrontSessionEndsSoon as a, useStorefrontSession as b, type StorefrontAuthClientInstance as c, type StorefrontSessionUser as d, type EcomiqProviderProps as e, findStorefrontCmsPageBySlug as f, useStore as g, type ProductVariantSelectorProps as h, type SelectedOptions as i, type ProductVariantSelectorRenderProps as j, storefrontAccessTokenNeedsRefresh as s, useStorefrontAuthClient as u };
|
package/dist/nextjs/globals.css
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Estilos
|
|
3
|
-
* La app
|
|
2
|
+
* Estilos mínimos para consumidores npm.
|
|
3
|
+
* La app define su propio design system y componentes.
|
|
4
4
|
*/
|
|
5
5
|
@import "tailwindcss";
|
|
6
6
|
|
|
7
|
-
@source "../react/";
|
|
8
|
-
@source "../react/components/cms-sections-renderer.tsx";
|
|
7
|
+
@source "../react/shell/components/product-variant-selector/";
|
|
9
8
|
|
|
10
9
|
@layer base {
|
|
11
10
|
* {
|