@onlistify/storefront 0.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.
- package/README.md +41 -0
- package/dist/index.cjs +787 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +164 -0
- package/dist/index.d.ts +164 -0
- package/dist/index.js +758 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# ONlistify Storefront
|
|
2
|
+
|
|
3
|
+
App y SDK para mostrar el storefront de un tenant (tema, bloques, listado de propiedades).
|
|
4
|
+
|
|
5
|
+
## SDK
|
|
6
|
+
|
|
7
|
+
Build de la librería: `pnpm run build:sdk`. Salida en `dist/` (ESM, CJS y `.d.ts`).
|
|
8
|
+
|
|
9
|
+
### Uso rápido
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { bootSiteRuntime } from 'onlistify-storefront';
|
|
13
|
+
|
|
14
|
+
const app = document.getElementById('app');
|
|
15
|
+
if (app) {
|
|
16
|
+
await bootSiteRuntime(app);
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
La URL debe ser `/tienda/:slug` (ej. `/tienda/mi-inmobiliaria`). El SDK obtiene el slug del pathname.
|
|
21
|
+
|
|
22
|
+
### Configuración
|
|
23
|
+
|
|
24
|
+
- **API base:** variable de entorno `VITE_PUBLIC_API_URL` o `bootSiteRuntime(app, { baseUrl: 'https://api.ejemplo.com' })`. También `setApiBase(url)` antes de cualquier `fetch*`.
|
|
25
|
+
- **Entorno:** `bootSiteRuntime(app, { environment: 'draft' | 'live' })`. Por defecto usa `?environment=draft` en la URL o `live`.
|
|
26
|
+
- **Slug custom:** `bootSiteRuntime(app, { getSlugFromPath: (pathname) => 'mi-tenant' })`.
|
|
27
|
+
- **Errores:** `bootSiteRuntime(app, { onError: (err) => console.error(err) })`.
|
|
28
|
+
|
|
29
|
+
### API pública
|
|
30
|
+
|
|
31
|
+
- `bootSiteRuntime(app, options?)` — monta la UI en el elemento.
|
|
32
|
+
- `fetchSiteConfig(slug, environment?)` — configuración del sitio.
|
|
33
|
+
- `fetchProperties(slug, params?)` — listado de propiedades.
|
|
34
|
+
- `fetchPlugins(slug)` — plugins/bloques.
|
|
35
|
+
- `setApiBase(url)` — define la base de la API.
|
|
36
|
+
- Tipos: `SiteConfig`, `BlockDef`, `PageDef`, `PublicPropertySummary`, `ListPropertiesParams`, `BootSiteRuntimeOptions`, `StorefrontConfigError`, `StorefrontNetworkError`, etc.
|
|
37
|
+
|
|
38
|
+
### Errores
|
|
39
|
+
|
|
40
|
+
- `StorefrontConfigError`: fallo HTTP de configuración o propiedades (`status` opcional).
|
|
41
|
+
- `StorefrontNetworkError`: fallo de red (`cause` con el error original).
|