@x12i/catalox 4.1.0 → 4.2.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 +7 -0
- package/dist/src/catalox/catalog-snapshot-export.d.ts +46 -0
- package/dist/src/catalox/catalog-snapshot-export.d.ts.map +1 -0
- package/dist/src/catalox/catalog-snapshot-export.js +103 -0
- package/dist/src/catalox/catalog-snapshot-export.js.map +1 -0
- package/dist/src/catalox/catalox-bound.d.ts +3 -1
- package/dist/src/catalox/catalox-bound.d.ts.map +1 -1
- package/dist/src/catalox/catalox-bound.js +6 -0
- package/dist/src/catalox/catalox-bound.js.map +1 -1
- package/dist/src/catalox/catalox.d.ts +23 -6
- package/dist/src/catalox/catalox.d.ts.map +1 -1
- package/dist/src/catalox/catalox.js +232 -5
- package/dist/src/catalox/catalox.js.map +1 -1
- package/dist/src/catalox/create-catalox.d.ts.map +1 -1
- package/dist/src/catalox/create-catalox.js +3 -0
- package/dist/src/catalox/create-catalox.js.map +1 -1
- package/dist/src/catalox/seed-preset.d.ts +15 -0
- package/dist/src/catalox/seed-preset.d.ts.map +1 -1
- package/dist/src/catalox/seed-preset.js +35 -0
- package/dist/src/catalox/seed-preset.js.map +1 -1
- package/dist/src/cli/index.js +116 -6
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/contracts/catalog-snapshot-export.d.ts +55 -0
- package/dist/src/contracts/catalog-snapshot-export.d.ts.map +1 -0
- package/dist/src/contracts/catalog-snapshot-export.js +3 -0
- package/dist/src/contracts/catalog-snapshot-export.js.map +1 -0
- package/dist/src/contracts/catalog-types.d.ts +13 -1
- package/dist/src/contracts/catalog-types.d.ts.map +1 -1
- package/dist/src/contracts/index.d.ts +2 -0
- package/dist/src/contracts/index.d.ts.map +1 -1
- package/dist/src/contracts/index.js +1 -0
- package/dist/src/contracts/index.js.map +1 -1
- package/dist/src/contracts/inputs.d.ts +2 -0
- package/dist/src/contracts/inputs.d.ts.map +1 -1
- package/dist/src/contracts/validation.d.ts +2 -1
- package/dist/src/contracts/validation.d.ts.map +1 -1
- package/dist/src/embedder.d.ts +3 -1
- package/dist/src/embedder.d.ts.map +1 -1
- package/dist/src/embedder.js +3 -1
- package/dist/src/embedder.js.map +1 -1
- package/dist/src/validation/index.d.ts +2 -0
- package/dist/src/validation/index.d.ts.map +1 -1
- package/dist/src/validation/index.js +2 -0
- package/dist/src/validation/index.js.map +1 -1
- package/dist/src/validation/payload-schema-registry.d.ts +20 -0
- package/dist/src/validation/payload-schema-registry.d.ts.map +1 -0
- package/dist/src/validation/payload-schema-registry.js +76 -0
- package/dist/src/validation/payload-schema-registry.js.map +1 -0
- package/dist/src/validation/payload-schema.d.ts +30 -0
- package/dist/src/validation/payload-schema.d.ts.map +1 -0
- package/dist/src/validation/payload-schema.js +160 -0
- package/dist/src/validation/payload-schema.js.map +1 -0
- package/docs/cli-items.md +94 -93
- package/docs/cli-snapshot-export.md +65 -0
- package/package.json +3 -1
- package/presets/native-map-v1.json +14 -2
- package/schemas/native-map-item/v1.json +10 -0
- package/schemas/registry.json +3 -0
package/docs/cli-items.md
CHANGED
|
@@ -1,93 +1,94 @@
|
|
|
1
|
-
# `catalox items` — catalog item operators
|
|
2
|
-
|
|
3
|
-
Operator-focused commands over the same [`Catalox`](../src/catalox/catalox.ts) APIs your app uses. Environment matches other CLIs (see [`docs/environment.md`](environment.md)): `FIREBASE_PROJECT_ID`, credentials, optional `CATALOX_STORE_ID`, **`CATALOX_APP_ID`** (or pass `--app` per command), optional `CATALOX_USER_ID` for actor attribution.
|
|
4
|
-
|
|
5
|
-
Connectivity smoke test:
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
catalox firestore probe
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Auth and binding
|
|
12
|
-
|
|
13
|
-
- Reads (`get`, `list`, `export`, `validate` with item) require a **read** binding for `--app` + catalog.
|
|
14
|
-
- Writes (`upsert`, `patch`, `delete`, `batch-upsert`, `relation upsert/delete`) require **write** access where the underlying API enforces it.
|
|
15
|
-
- **`--god`** sets `superAdmin` on the Catalox context (inventory-style bypass where the library allows it; **non-global native scopes still require super-admin** per `assertSuperAdminForNonGlobalScope`).
|
|
16
|
-
- **`--store <storeId>`** overrides `CATALOX_STORE_ID` when your deployment is store-scoped.
|
|
17
|
-
|
|
18
|
-
## JSON body shapes (`upsert`, `patch`, `relation`)
|
|
19
|
-
|
|
20
|
-
Native upsert/patch accept the same logical shape as seed manifest rows:
|
|
21
|
-
|
|
22
|
-
- **Preferred (matches `seed` `items[]`):** `{ "data": { /* identity + fields */ }, "scope": { ... }, "relations": [ ... ] }` — the CLI flattens this to what [`stripReservedWriteFields`](../src/catalox/catalox.ts) expects.
|
|
23
|
-
- **Alternate:** put catalog field keys at the **top level** together with optional `scope`, `relations`, `indexed`, `references`.
|
|
24
|
-
|
|
25
|
-
`items relation upsert` / `delete` expect JSON matching [`UpsertCatalogItemRelationInput` / `DeleteCatalogItemRelationInput`](../src/contracts/inputs.ts) (see also `items relation delete` for `referenceId` form).
|
|
26
|
-
|
|
27
|
-
## Commands
|
|
28
|
-
|
|
29
|
-
| Command | Purpose |
|
|
30
|
-
|--------|---------|
|
|
31
|
-
| `items validate` | `validateCatalog` (catalog
|
|
32
|
-
| `items get` | `getCatalogItem`. Exit **1** if `not_found` or `mapping_blocked`. |
|
|
33
|
-
| `items list` | `listCatalogItemsWithOutcome`. Exit **1** unless outcome is `ok` or `empty`. Optional `--filter-json`, `--cursor` (mapped API catalogs). |
|
|
34
|
-
| `items upsert` | `upsertNativeCatalogItem`. Body from `--file` or **stdin**. |
|
|
35
|
-
| `items patch` | `updateNativeCatalogItem`. Requires `--item`. |
|
|
36
|
-
| `items delete` | `deleteNativeCatalogItem`. Requires **`--confirm`**. |
|
|
37
|
-
| `items batch-upsert` | `batchUpsertNativeCatalogItems`. Input is a **JSON array** or **NDJSON** (one object per line). Firestore batches internally in chunks of 450 writes. |
|
|
38
|
-
| `items export` | Stable `{ catalogId, exportedCount, truncated, items }` JSON. Paginates with **`nextCursor`** when the mapped API adapter returns it; otherwise uses **`offset`** (native + mongo). Cap with `--max-total` (default 10000). |
|
|
39
|
-
|
|
40
|
-
### Examples
|
|
41
|
-
|
|
42
|
-
Validate relation rules for one item:
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
catalox items validate --app my-app --catalog entities --item some-id
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Upsert from a file:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
catalox items upsert --app my-app --catalog entities --file ./row.json
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Batch from NDJSON:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
catalox items batch-upsert --app my-app --catalog entities --file ./rows.ndjson
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Export (pretty-printed):
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
catalox items export --app my-app --catalog entities --pretty --out entities-items.json
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## `catalox seed validate`
|
|
67
|
-
|
|
68
|
-
Parse and AJV-validate a manifest the same way `seed apply` loads it (`--file` or `--preset`). **No Firestore writes.** Prints counts and exits **0** on success.
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
catalox seed validate --preset builtin:native-map-v1
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## When to use `seed apply` vs `items batch-upsert`
|
|
75
|
-
|
|
76
|
-
- **`seed apply`** — one manifest: create catalogs if missing, optional descriptors/bindings, then items. Idempotent catalog **creation** path.
|
|
77
|
-
- **`items batch-upsert`** — fast native-only bulk upsert for an **existing** catalog with descriptor already present; no binding/catalog provisioning.
|
|
78
|
-
|
|
79
|
-
##
|
|
80
|
-
|
|
81
|
-
- **`catalox export`** ([`
|
|
82
|
-
- **`catalox
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
- [`docs/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
1
|
+
# `catalox items` — catalog item operators
|
|
2
|
+
|
|
3
|
+
Operator-focused commands over the same [`Catalox`](../src/catalox/catalox.ts) APIs your app uses. Environment matches other CLIs (see [`docs/environment.md`](environment.md)): `FIREBASE_PROJECT_ID`, credentials, optional `CATALOX_STORE_ID`, **`CATALOX_APP_ID`** (or pass `--app` per command), optional `CATALOX_USER_ID` for actor attribution.
|
|
4
|
+
|
|
5
|
+
Connectivity smoke test:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
catalox firestore probe
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Auth and binding
|
|
12
|
+
|
|
13
|
+
- Reads (`get`, `list`, `export`, `validate` with item) require a **read** binding for `--app` + catalog.
|
|
14
|
+
- Writes (`upsert`, `patch`, `delete`, `batch-upsert`, `relation upsert/delete`) require **write** access where the underlying API enforces it.
|
|
15
|
+
- **`--god`** sets `superAdmin` on the Catalox context (inventory-style bypass where the library allows it; **non-global native scopes still require super-admin** per `assertSuperAdminForNonGlobalScope`).
|
|
16
|
+
- **`--store <storeId>`** overrides `CATALOX_STORE_ID` when your deployment is store-scoped.
|
|
17
|
+
|
|
18
|
+
## JSON body shapes (`upsert`, `patch`, `relation`)
|
|
19
|
+
|
|
20
|
+
Native upsert/patch accept the same logical shape as seed manifest rows:
|
|
21
|
+
|
|
22
|
+
- **Preferred (matches `seed` `items[]`):** `{ "data": { /* identity + fields */ }, "scope": { ... }, "relations": [ ... ] }` — the CLI flattens this to what [`stripReservedWriteFields`](../src/catalox/catalox.ts) expects.
|
|
23
|
+
- **Alternate:** put catalog field keys at the **top level** together with optional `scope`, `relations`, `indexed`, `references`.
|
|
24
|
+
|
|
25
|
+
`items relation upsert` / `delete` expect JSON matching [`UpsertCatalogItemRelationInput` / `DeleteCatalogItemRelationInput`](../src/contracts/inputs.ts) (see also `items relation delete` for `referenceId` form).
|
|
26
|
+
|
|
27
|
+
## Commands
|
|
28
|
+
|
|
29
|
+
| Command | Purpose |
|
|
30
|
+
|--------|---------|
|
|
31
|
+
| `items validate` | `validateCatalog` (catalog config, mapping, catalogType registry) or `validateCatalogItem` (`--item`: relations + payload schema). Offline: `--file` with `--catalog-type` or `--catalog` + `--app`. Exit **1** on errors. See [`cli-validate-payload.md`](./cli-validate-payload.md). |
|
|
32
|
+
| `items get` | `getCatalogItem`. Exit **1** if `not_found` or `mapping_blocked`. |
|
|
33
|
+
| `items list` | `listCatalogItemsWithOutcome`. Exit **1** unless outcome is `ok` or `empty`. Optional `--filter-json`, `--cursor` (mapped API catalogs). |
|
|
34
|
+
| `items upsert` | `upsertNativeCatalogItem`. Body from `--file` or **stdin**. |
|
|
35
|
+
| `items patch` | `updateNativeCatalogItem`. Requires `--item`. |
|
|
36
|
+
| `items delete` | `deleteNativeCatalogItem`. Requires **`--confirm`**. |
|
|
37
|
+
| `items batch-upsert` | `batchUpsertNativeCatalogItems`. Input is a **JSON array** or **NDJSON** (one object per line). Firestore batches internally in chunks of 450 writes. |
|
|
38
|
+
| `items export` | Stable `{ catalogId, exportedCount, truncated, items }` JSON. Paginates with **`nextCursor`** when the mapped API adapter returns it; otherwise uses **`offset`** (native + mongo). Cap with `--max-total` (default 10000). |
|
|
39
|
+
|
|
40
|
+
### Examples
|
|
41
|
+
|
|
42
|
+
Validate relation rules for one item:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
catalox items validate --app my-app --catalog entities --item some-id
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Upsert from a file:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
catalox items upsert --app my-app --catalog entities --file ./row.json
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Batch from NDJSON:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
catalox items batch-upsert --app my-app --catalog entities --file ./rows.ndjson
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Export (pretty-printed):
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
catalox items export --app my-app --catalog entities --pretty --out entities-items.json
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## `catalox seed validate`
|
|
67
|
+
|
|
68
|
+
Parse and AJV-validate a manifest the same way `seed apply` loads it (`--file` or `--preset`). **No Firestore writes.** Also validates `items[]` payloads when a schema resolves for the target catalog. Prints counts and exits **0** on success.
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
catalox seed validate --preset builtin:native-map-v1
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## When to use `seed apply` vs `items batch-upsert`
|
|
75
|
+
|
|
76
|
+
- **`seed apply`** — one manifest: create catalogs if missing, optional descriptors/bindings, then items. Idempotent catalog **creation** path.
|
|
77
|
+
- **`items batch-upsert`** — fast native-only bulk upsert for an **existing** catalog with descriptor already present; no binding/catalog provisioning.
|
|
78
|
+
|
|
79
|
+
## Export commands
|
|
80
|
+
|
|
81
|
+
- **`catalox snapshot export`** ([`docs/cli-snapshot-export.md`](cli-snapshot-export.md)) — **`catalox-export/v1`**: multi-catalog, full pagination, deterministic ordering. Default **native** catalogs; use for backup and drift.
|
|
82
|
+
- **`catalox export`** ([`src/cli/index.ts`](../src/cli/index.ts)) — Legacy **inventory** JSON; optional `--include-items` with `--limit-per-catalog`. Reports and shallow snapshots.
|
|
83
|
+
- **`catalox items export`** — One **`--catalog`**, `{ catalogId, items }` shape; `--max-total`, `--page-size`. Single-catalog round-trip.
|
|
84
|
+
|
|
85
|
+
## Related
|
|
86
|
+
|
|
87
|
+
- [`docs/cli-toolbox.md`](cli-toolbox.md) — `check-access`, `ensure-binding`, `repair-binding`, **`unbind-catalog`**.
|
|
88
|
+
- [`docs/onboarding-happy-path.md`](onboarding-happy-path.md) — seed presets including bindings.
|
|
89
|
+
|
|
90
|
+
## Smoke checklist (manual)
|
|
91
|
+
|
|
92
|
+
1. `catalox seed validate --preset builtin:native-map-v1` → `ok: true`.
|
|
93
|
+
2. `catalox items list --app <app> --catalog <id> --limit 5` → outcome `ok` or `empty`.
|
|
94
|
+
3. `catalox items export --app <app> --catalog <id> --max-total 20 --pretty` → JSON with `items` array.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# `catalox snapshot export` — catalog backup and drift
|
|
2
|
+
|
|
3
|
+
Operator command for a **versioned**, **deterministic** JSON snapshot of Catalox catalog state. Output format: **`catalox-export/v1`**. Intended for disaster recovery artifacts, environment drift diff, and release audits — not for execution-matrix row state or Memorix corpora (see product FR scope).
|
|
4
|
+
|
|
5
|
+
## Auth (read-only)
|
|
6
|
+
|
|
7
|
+
- Requires **read** access on each exported catalog (`catalogBindings` + `canRead`).
|
|
8
|
+
- No write, admin, or seed permissions are required.
|
|
9
|
+
- **`--god`** sets `superAdmin` on the Catalox context and, by default, **super-lists all native physical rows** (every scope layer). Use for platform backups when the operator account is super-admin.
|
|
10
|
+
- **`--no-all-native-scopes`** keeps listing scoped to the default tenant/global merge even with `--god`.
|
|
11
|
+
|
|
12
|
+
Environment: same as other CLIs ([`environment.md`](environment.md)) — `FIREBASE_PROJECT_ID`, credentials, `CATALOX_APP_ID` or `--app`, optional `CATALOX_STORE_ID` / `--store`.
|
|
13
|
+
|
|
14
|
+
## Scope
|
|
15
|
+
|
|
16
|
+
| Flag | Effect |
|
|
17
|
+
|------|--------|
|
|
18
|
+
| _(default)_ | All **native** catalogs visible to `--app` |
|
|
19
|
+
| `--catalog <id>...` | Subset of catalog ids |
|
|
20
|
+
| `--catalog-type <type>...` | Filter `catalogType` |
|
|
21
|
+
| `--include-mapped` | Also export mapped catalogs (mongo/api adapters) |
|
|
22
|
+
| `--include-disabled` / `--include-hidden` | Include non-active or hidden catalogs |
|
|
23
|
+
| `--no-item-data` | Items without `data` (metadata-only) |
|
|
24
|
+
| `--page-size <n>` | Pagination chunk size (default 200, max 500) |
|
|
25
|
+
| `--max-items-per-catalog <n>` | Stop after N items per catalog (`truncated: true`) |
|
|
26
|
+
|
|
27
|
+
## Output shape (`catalox-export/v1`)
|
|
28
|
+
|
|
29
|
+
- `format`: `"catalox-export/v1"`
|
|
30
|
+
- `exportedAt`: ISO timestamp
|
|
31
|
+
- `consistency`: `"best-effort"` (no cross-catalog transaction; suitable for structural diff, not strict point-in-time isolation)
|
|
32
|
+
- `context`: `appId`, optional `storeId`, `userId`, `superAdmin`
|
|
33
|
+
- `catalogs[]`: sorted by `catalogId`; each block has `catalog` metadata, `items[]` sorted by `itemId`, `itemCount`, optional `truncated`, `listOutcome`, `issues`
|
|
34
|
+
|
|
35
|
+
Stable field names and ordering are preserved across patch releases for this format version.
|
|
36
|
+
|
|
37
|
+
## Examples
|
|
38
|
+
|
|
39
|
+
All native catalogs to a file (typical pre-migration backup):
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
catalox snapshot export --app "$CATALOX_APP_ID" --god --pretty --out "./backup-$(date -u +%Y%m%d).json"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Staging vs production drift (same flags, then `diff`):
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
catalox snapshot export --app my-app --catalog graphs execution-matrix --out staging.json
|
|
49
|
+
catalox snapshot export --app my-app --catalog graphs execution-matrix --out prod.json
|
|
50
|
+
diff -u staging.json prod.json
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Related commands
|
|
54
|
+
|
|
55
|
+
| Command | When to use |
|
|
56
|
+
|---------|-------------|
|
|
57
|
+
| **`catalox snapshot export`** | Product-owned **multi-catalog** backup/drift contract |
|
|
58
|
+
| `catalox items export` | Single catalog, `{ catalogId, items }` shape |
|
|
59
|
+
| `catalox export` | Legacy **inventory** report JSON (`--include-items` + per-catalog limits) |
|
|
60
|
+
| `catalox firestore backup` | Raw Firestore NDJSON + GCS manifest (infra-level) |
|
|
61
|
+
|
|
62
|
+
## Verification matrix
|
|
63
|
+
|
|
64
|
+
1. **Unit:** `npm run test:unit` — `catalog-snapshot-export.test.ts`
|
|
65
|
+
2. **Live Firestore** (`FIRESTORE_LIVE_TESTS=1`): integration test exercises `exportCatalogSnapshot` with multiple upserted items and pagination-sized `pageSize`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x12i/catalox",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Platform infrastructure for reusable, interoperable catalogs across apps and data sources.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -51,8 +51,10 @@
|
|
|
51
51
|
"dist",
|
|
52
52
|
"docs/catalox-ui-contract.md",
|
|
53
53
|
"docs/cli-items.md",
|
|
54
|
+
"docs/cli-snapshot-export.md",
|
|
54
55
|
"docs/cli-toolbox.md",
|
|
55
56
|
"presets",
|
|
57
|
+
"schemas",
|
|
56
58
|
"README.md",
|
|
57
59
|
"LICENSE",
|
|
58
60
|
"firestore.indexes.json"
|
|
@@ -7,9 +7,21 @@
|
|
|
7
7
|
{
|
|
8
8
|
"catalogId": "catalox_native_map",
|
|
9
9
|
"name": "Native map",
|
|
10
|
-
"catalogType": "generic",
|
|
10
|
+
"catalogType": "generic-map",
|
|
11
|
+
"schemaVersion": "catalox.payload.generic-map/v1",
|
|
11
12
|
"sourceMode": "native",
|
|
12
|
-
"native": {
|
|
13
|
+
"native": {
|
|
14
|
+
"itemSchema": {
|
|
15
|
+
"$id": "catalox.payload.generic-map/v1",
|
|
16
|
+
"type": "object",
|
|
17
|
+
"additionalProperties": true,
|
|
18
|
+
"required": ["key"],
|
|
19
|
+
"properties": {
|
|
20
|
+
"key": { "type": "string", "minLength": 1 },
|
|
21
|
+
"value": {}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
13
25
|
}
|
|
14
26
|
],
|
|
15
27
|
"descriptors": [
|