@objectstack/metadata 4.0.5 → 4.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 +69 -2
- package/dist/index.cjs +374 -357
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +120 -85
- package/dist/index.d.ts +120 -85
- package/dist/index.js +379 -364
- package/dist/index.js.map +1 -1
- package/dist/migrations/{migrate-env-id-to-project-id.cjs → index.cjs} +83 -11
- package/dist/migrations/index.cjs.map +1 -0
- package/dist/migrations/index.d.cts +103 -0
- package/dist/migrations/index.d.ts +103 -0
- package/dist/migrations/index.js +127 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/node.cjs +374 -357
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +379 -364
- package/dist/node.js.map +1 -1
- package/package.json +10 -10
- package/dist/migrations/migrate-env-id-to-project-id.cjs.map +0 -1
- package/dist/migrations/migrate-env-id-to-project-id.d.cts +0 -37
- package/dist/migrations/migrate-env-id-to-project-id.d.ts +0 -37
- package/dist/migrations/migrate-env-id-to-project-id.js +0 -59
- package/dist/migrations/migrate-env-id-to-project-id.js.map +0 -1
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ Loaders are pluggable data sources that know how to read/write metadata from dif
|
|
|
66
66
|
| `FilesystemLoader` | `file:` | ✅ | ✅ | ✅ | Implemented |
|
|
67
67
|
| `MemoryLoader` | `memory:` | ✅ | ✅ | ❌ | Implemented |
|
|
68
68
|
| `RemoteLoader` | `http:` | ✅ | ✅ | ❌ | Implemented |
|
|
69
|
-
| `DatabaseLoader` | `datasource:` | ✅ | ✅ | ❌ | Implemented
|
|
69
|
+
| `DatabaseLoader` | `datasource:` | ✅ | ✅ | ❌ | Implemented (read-through LRU cache) |
|
|
70
70
|
|
|
71
71
|
### 3. Serializers
|
|
72
72
|
|
|
@@ -74,7 +74,7 @@ Serializers convert metadata objects to/from different file formats:
|
|
|
74
74
|
|
|
75
75
|
- **JSONSerializer** — `.json` files with optional key sorting
|
|
76
76
|
- **YAMLSerializer** — `.yaml`/`.yml` files (JSON_SCHEMA for security)
|
|
77
|
-
- **TypeScriptSerializer** — `.ts`/`.js` module exports (for `
|
|
77
|
+
- **TypeScriptSerializer** — `.ts`/`.js` module exports (for `ObjectSchema.create()`, `defineView()`, etc.)
|
|
78
78
|
|
|
79
79
|
### 4. Overlay / Customization System
|
|
80
80
|
|
|
@@ -119,6 +119,73 @@ Integrates with the ObjectStack kernel plugin system:
|
|
|
119
119
|
- Supports YAML, JSON, TypeScript, and JavaScript metadata formats
|
|
120
120
|
- Keeps ObjectOS metadata read-only; database persistence is not auto-enabled
|
|
121
121
|
|
|
122
|
+
#### Bootstrap Modes
|
|
123
|
+
|
|
124
|
+
`MetadataPluginConfigSchema.bootstrap` controls how the plugin primes metadata
|
|
125
|
+
on `start()`. Pick the mode that matches the deployment target:
|
|
126
|
+
|
|
127
|
+
| Mode | When to use | Behavior |
|
|
128
|
+
|:-----|:------------|:---------|
|
|
129
|
+
| `eager` (default) | Local dev, traditional servers | Scans filesystem (or hydrates the artifact source if set) at boot. |
|
|
130
|
+
| `lazy` | Cold-start sensitive runtimes, on-demand workloads | Skips the filesystem priming pass — reads flow through `MetadataManager.load*` / `list*` and registered loaders (incl. the DatabaseLoader read-through cache). An `artifactSource` is still honored if provided. |
|
|
131
|
+
| `artifact-only` | **Edge / serverless / read-only production** | Refuses to touch the filesystem. Requires `artifactSource.mode = 'local-file'`. Throws if no artifact source is configured. |
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
// Edge / serverless: fail-fast if no artifact is wired
|
|
135
|
+
new MetadataPlugin({
|
|
136
|
+
config: { bootstrap: 'artifact-only' },
|
|
137
|
+
artifactSource: { mode: 'local-file', path: './dist/objectstack.json' },
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// On-demand reads via DatabaseLoader, no FS scan
|
|
141
|
+
new MetadataPlugin({
|
|
142
|
+
config: { bootstrap: 'lazy' },
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### Persistence Write Gates
|
|
147
|
+
|
|
148
|
+
`MetadataManagerConfigSchema.persistence` is a two-axis runtime gate that lets
|
|
149
|
+
you freeze metadata mutation in sealed deployments while leaving reads open.
|
|
150
|
+
Both flags default to `true` so dev / Studio flows are unaffected.
|
|
151
|
+
|
|
152
|
+
| Flag | Effect when `false` |
|
|
153
|
+
|:-----|:--------------------|
|
|
154
|
+
| `persistence.writable` | `MetadataManager.register()` becomes a no-op (or throws when `validation.throwOnError` is set). Use for read-only project kernels booted from a compiled artifact. |
|
|
155
|
+
| `persistence.overlayWritable` | `MetadataManager.saveOverlay()` is rejected. Use to disable Studio overlays in fully-frozen production deployments. |
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
new MetadataManager({
|
|
159
|
+
persistence: { writable: false, overlayWritable: false },
|
|
160
|
+
});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
#### DatabaseLoader Read-Through Cache
|
|
164
|
+
|
|
165
|
+
`DatabaseLoader` wraps `load` / `loadMany` / `list` / `stat` results in a
|
|
166
|
+
generic LRU cache (see `src/utils/lru-cache.ts`). Writes invalidate the
|
|
167
|
+
affected entries, so reads always observe writes made through the same loader
|
|
168
|
+
instance; out-of-band SQL writes are honored within `ttl` milliseconds.
|
|
169
|
+
|
|
170
|
+
Configuration lives under `cache.databaseLoader`:
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
new MetadataManager({
|
|
174
|
+
datasource: 'default',
|
|
175
|
+
cache: {
|
|
176
|
+
enabled: true,
|
|
177
|
+
databaseLoader: {
|
|
178
|
+
enabled: true,
|
|
179
|
+
maxSize: 500, // Max cached (type, name) entries
|
|
180
|
+
ttl: 60_000, // Cache TTL in milliseconds
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
The cache exposes diagnostic counters (`size` / `hits` / `misses` / `hitRate`)
|
|
187
|
+
through `LRUCache.stats()` for `metrics` endpoints.
|
|
188
|
+
|
|
122
189
|
## Metadata Types
|
|
123
190
|
|
|
124
191
|
The platform supports **26 built-in metadata types** across 6 protocol domains:
|