@x12i/catalox 2.2.0 → 2.2.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 (2) hide show
  1. package/README.md +32 -8
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -62,6 +62,9 @@ Example `.env` (do not commit secrets):
62
62
  ```bash
63
63
  MONGO_URI=mongodb://127.0.0.1:27017
64
64
  GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
65
+ # Or (used by the packaged CLI migration + live integration tests):
66
+ FIREBASE_SERVICE_ACCOUNT_PATH=/path/to/service-account.json
67
+ FIREBASE_PROJECT_ID=your-project-id
65
68
  FIRESTORE_LIVE_TESTS=1
66
69
  ```
67
70
 
@@ -199,6 +202,10 @@ export type CatalogDescriptor = {
199
202
  queryCapabilities?: Record<string, unknown>;
200
203
  filterSpec?: Record<string, unknown>;
201
204
  presentationSpec?: Record<string, unknown>;
205
+ /**
206
+ * Optional UI escape hatch: registry components and/or stored snippet refs per role.
207
+ * See `CatalogCustomRenderer` in the published types (`renderers[]` with `role` + optional `mode`).
208
+ */
202
209
  customRenderer?: Record<string, unknown>;
203
210
  identity: CatalogIdentityDescriptor;
204
211
  metadata?: Record<string, unknown>;
@@ -211,27 +218,30 @@ Catalog descriptors can include optional UI metadata for generic presentation la
211
218
 
212
219
  - `filterSpec`: declarative filter configuration (built on `FieldSource`)
213
220
  - `presentationSpec`: declarative layout + view/edit semantics (grid/list/cards/form)
214
- - `customRenderer`: escape hatch that assigns either:
215
- - a host-resolved JSX component (by registry key), or
216
- - a separately-stored renderer snippet reference (`snippetRef`) (TSX/JSX/HTML)
221
+ - `customRenderer`: escape hatch with a **`renderers[]`** list. Each entry has a **`role`** (`core|list|grid|item|report|dashboard`) and optional **`mode`** (`readonly|editable`, only for `list|grid|item`). An entry may set either:
222
+ - a host-resolved component (**`component`**: registry key), or
223
+ - a separately-stored renderer snippet (**`snippetRef`**), plus optional **`syntax`** (`html|jsx|tsx`), **`props`**, and **`receiveMap`** (`full|minimal`).
224
+
225
+ Use **`role: "core"`** for defaults shared across roles; merge with **`resolveCustomRendererEntry(...)`** (exported from `@x12i/catalox`).
217
226
 
218
227
  Custom renderer contracts:
219
228
 
220
229
  - [`docs/catalog-list-render-map.md`](docs/catalog-list-render-map.md)
221
230
  - [`docs/catalog-item-render-map.md`](docs/catalog-item-render-map.md)
231
+ - [`docs/custom-renderer-snippets-io.md`](docs/custom-renderer-snippets-io.md) — **snippet default export, `map` I/O, `actions`, roles, and `receiveMap`**
222
232
 
223
233
  Important: host presentation layers are responsible for resolving `FieldSource` lookups (cross-catalog enums/refs) and populating `resolvedSources` for renderers.
224
234
 
225
- #### Stored JSX/TSX renderer snippets (optional)
226
-
227
- In addition to `customRenderer.{list|item}.component`, descriptors may specify:
235
+ #### Stored renderer snippets (optional)
228
236
 
229
- - `customRenderer.renderers[].snippetRef`
237
+ Descriptors reference snippets via **`customRenderer.renderers[].snippetRef`**.
230
238
 
231
- Snippets are stored separately in Firestore:
239
+ Snippet documents (Firestore, default layout) live at:
232
240
 
233
241
  - `catalogRendererSnippets/{catalogId}:{role}[:{mode}]` where `role` is `core|list|grid|item|report|dashboard` and `mode` is optional (`readonly|editable`)
234
242
 
243
+ Snippet record fields include **`rendererSource`** + optional **`syntax`** (`html|jsx|tsx`). Fetch via **`catalox.getCatalogRendererSnippet(ctx, catalogId, role, mode?)`** when `rendererSnippets` is wired on `Catalox`.
244
+
235
245
  This package includes a small set of opt-in helpers for snippet compilation/validation:
236
246
 
237
247
  - `transpileRendererSourceToModuleSource(...)`: TSX/JSX → ESM module source (string)
@@ -239,6 +249,20 @@ This package includes a small set of opt-in helpers for snippet compilation/vali
239
249
  - `unsafeCreateRendererFunction(...)`: **UNSAFE** runtime evaluation of transpiled code
240
250
  - `renderRendererToHtml(...)`: best-effort HTML rendering if `react` + `react-dom` are installed
241
251
 
252
+ **CLI: migrating legacy snippet/descriptor shapes** (old `surface`/`jsxSource` and `customRenderer.list` / `customRenderer.item`):
253
+
254
+ ```bash
255
+ # Uses FIREBASE_SERVICE_ACCOUNT_PATH + FIREBASE_PROJECT_ID from .env (or env)
256
+ npx catalox migrate renderers --dry-run
257
+ npx catalox migrate renderers --write
258
+ ```
259
+
260
+ Optional **`--app <appId>`** also scans `apps/<appId>/catalogRendererSnippets` and `apps/<appId>/catalogDescriptors`.
261
+
262
+ Programmatic conversion (no Firestore): import **`convertLegacySnippetRecordToRoleModel`**, **`migrateDescriptorCustomRendererInPlace`**, etc. from `@x12i/catalox`.
263
+
264
+ **Worked example (catalog viewer + Catalox `map`)**: [`docs/new-feature/USAGE.md`](docs/new-feature/USAGE.md)
265
+
242
266
  ### What you need persisted for “generic consumption”
243
267
 
244
268
  To let consumers operate *purely* from `appId` with no hardcoded catalog registrations, Catalox relies on these being present in Firestore:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x12i/catalox",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Catalox: Firebase-native catalog metadata + unification package.",
5
5
  "license": "MIT",
6
6
  "private": false,