@typicalday/firegraph 0.3.0 → 0.5.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 +115 -2
- package/dist/codegen/index.d.cts +1 -1
- package/dist/codegen/index.d.ts +1 -1
- package/dist/editor/server/index.mjs +831 -55
- package/dist/{index-CQkofEC_.d.cts → index-B9aodfYD.d.cts} +111 -2
- package/dist/{index-CQkofEC_.d.ts → index-B9aodfYD.d.ts} +111 -2
- package/dist/index.cjs +872 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +175 -4
- package/dist/index.d.ts +175 -4
- package/dist/index.js +853 -52
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
|
@@ -113,6 +113,8 @@ interface GraphRecord {
|
|
|
113
113
|
data: Record<string, unknown>;
|
|
114
114
|
createdAt: Timestamp | FieldValue;
|
|
115
115
|
updatedAt: Timestamp | FieldValue;
|
|
116
|
+
/** Schema version — set automatically when the registry entry has migrations. */
|
|
117
|
+
v?: number;
|
|
116
118
|
}
|
|
117
119
|
interface StoredGraphRecord {
|
|
118
120
|
aType: string;
|
|
@@ -123,6 +125,8 @@ interface StoredGraphRecord {
|
|
|
123
125
|
data: Record<string, unknown>;
|
|
124
126
|
createdAt: Timestamp;
|
|
125
127
|
updatedAt: Timestamp;
|
|
128
|
+
/** Schema version — set automatically when the registry entry has migrations. */
|
|
129
|
+
v?: number;
|
|
126
130
|
}
|
|
127
131
|
interface WhereClause {
|
|
128
132
|
field: string;
|
|
@@ -175,6 +179,45 @@ interface QueryFilter {
|
|
|
175
179
|
op: WhereFilterOp;
|
|
176
180
|
value: unknown;
|
|
177
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* An executable migration function that transforms data from one schema
|
|
184
|
+
* version to the next. Can be synchronous or asynchronous.
|
|
185
|
+
*/
|
|
186
|
+
type MigrationFn = (data: Record<string, unknown>) => Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
187
|
+
/**
|
|
188
|
+
* A single migration step in a registry entry.
|
|
189
|
+
* Transforms data from `fromVersion` to `toVersion`.
|
|
190
|
+
*/
|
|
191
|
+
interface MigrationStep {
|
|
192
|
+
fromVersion: number;
|
|
193
|
+
toVersion: number;
|
|
194
|
+
up: MigrationFn;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* A stored migration step for dynamic registry types.
|
|
198
|
+
* The `up` field is a source code string that will be compiled at runtime.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* { fromVersion: 0, toVersion: 1, up: "(data) => ({ ...data, status: 'draft' })" }
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
interface StoredMigrationStep {
|
|
206
|
+
fromVersion: number;
|
|
207
|
+
toVersion: number;
|
|
208
|
+
up: string;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Pluggable executor interface for compiling migration function source
|
|
212
|
+
* strings into executable functions. Used for dynamic registry migrations.
|
|
213
|
+
*
|
|
214
|
+
* The default executor uses SES (Secure ECMAScript) Compartments with
|
|
215
|
+
* JSON marshaling for isolation. Users can supply an alternative via
|
|
216
|
+
* `GraphClientOptions.migrationSandbox`.
|
|
217
|
+
*/
|
|
218
|
+
type MigrationExecutor = (source: string) => MigrationFn;
|
|
219
|
+
/** Write-back mode for auto-migrated records. */
|
|
220
|
+
type MigrationWriteBack = 'off' | 'eager' | 'background';
|
|
178
221
|
interface RegistryEntry {
|
|
179
222
|
aType: string;
|
|
180
223
|
axbType: string;
|
|
@@ -220,6 +263,24 @@ interface RegistryEntry {
|
|
|
220
263
|
* ```
|
|
221
264
|
*/
|
|
222
265
|
targetGraph?: string;
|
|
266
|
+
/**
|
|
267
|
+
* Schema version for this type's data payload.
|
|
268
|
+
* **Computed automatically** from `migrations` as `max(toVersion)`.
|
|
269
|
+
* Do not set directly — provide migrations instead.
|
|
270
|
+
*/
|
|
271
|
+
schemaVersion?: number;
|
|
272
|
+
/**
|
|
273
|
+
* Ordered list of migrations to transform data from older versions
|
|
274
|
+
* to the current version. The schema version is derived as the highest
|
|
275
|
+
* `toVersion` in this array.
|
|
276
|
+
*/
|
|
277
|
+
migrations?: MigrationStep[];
|
|
278
|
+
/**
|
|
279
|
+
* Per-entry write-back override for auto-migrated records.
|
|
280
|
+
* Takes precedence over `GraphClientOptions.migrationWriteBack`.
|
|
281
|
+
* Omit to inherit the global setting.
|
|
282
|
+
*/
|
|
283
|
+
migrationWriteBack?: MigrationWriteBack;
|
|
223
284
|
}
|
|
224
285
|
/** Topology declaration for an edge (from edge.json). */
|
|
225
286
|
interface EdgeTopology {
|
|
@@ -255,6 +316,10 @@ interface DiscoveredEntity {
|
|
|
255
316
|
allowedIn?: string[];
|
|
256
317
|
/** Subgraph name where cross-graph edges of this type live. */
|
|
257
318
|
targetGraph?: string;
|
|
319
|
+
/** Migration steps loaded from migrations.ts. */
|
|
320
|
+
migrations?: MigrationStep[];
|
|
321
|
+
/** Per-entity write-back override from meta.json. */
|
|
322
|
+
migrationWriteBack?: MigrationWriteBack;
|
|
258
323
|
}
|
|
259
324
|
/** Result of scanning an entities directory. */
|
|
260
325
|
interface DiscoveryResult {
|
|
@@ -287,6 +352,18 @@ interface DefineTypeOptions {
|
|
|
287
352
|
viewCss?: string;
|
|
288
353
|
/** Scope patterns constraining where this type can exist in subgraphs. */
|
|
289
354
|
allowedIn?: string[];
|
|
355
|
+
/**
|
|
356
|
+
* Migration steps. Accepts function objects (auto-serialized via .toString())
|
|
357
|
+
* or strings (stored as-is). The schema version is derived as the highest
|
|
358
|
+
* `toVersion` in this array.
|
|
359
|
+
*/
|
|
360
|
+
migrations?: Array<{
|
|
361
|
+
fromVersion: number;
|
|
362
|
+
toVersion: number;
|
|
363
|
+
up: MigrationFn | string;
|
|
364
|
+
}>;
|
|
365
|
+
/** Per-type write-back override for auto-migrated records. */
|
|
366
|
+
migrationWriteBack?: MigrationWriteBack;
|
|
290
367
|
}
|
|
291
368
|
/** Data shape stored in a `nodeType` meta-node. */
|
|
292
369
|
interface NodeTypeData {
|
|
@@ -298,6 +375,8 @@ interface NodeTypeData {
|
|
|
298
375
|
viewTemplate?: string;
|
|
299
376
|
viewCss?: string;
|
|
300
377
|
allowedIn?: string[];
|
|
378
|
+
migrations?: StoredMigrationStep[];
|
|
379
|
+
migrationWriteBack?: MigrationWriteBack;
|
|
301
380
|
}
|
|
302
381
|
/** Data shape stored in an `edgeType` meta-node. */
|
|
303
382
|
interface EdgeTypeData {
|
|
@@ -313,10 +392,21 @@ interface EdgeTypeData {
|
|
|
313
392
|
viewCss?: string;
|
|
314
393
|
allowedIn?: string[];
|
|
315
394
|
targetGraph?: string;
|
|
395
|
+
migrations?: StoredMigrationStep[];
|
|
396
|
+
migrationWriteBack?: MigrationWriteBack;
|
|
316
397
|
}
|
|
317
398
|
type ScanProtection = 'error' | 'warn' | 'off';
|
|
318
399
|
interface GraphClientOptions {
|
|
319
|
-
/**
|
|
400
|
+
/**
|
|
401
|
+
* Static registry built from code/discovery.
|
|
402
|
+
*
|
|
403
|
+
* When provided alone, all writes are validated against this registry.
|
|
404
|
+
*
|
|
405
|
+
* When provided together with `registryMode`, operates in **merged mode**:
|
|
406
|
+
* static entries take priority and cannot be overridden by dynamic
|
|
407
|
+
* definitions. Dynamic definitions can only add new types. The merged
|
|
408
|
+
* client is returned as a `DynamicGraphClient`.
|
|
409
|
+
*/
|
|
320
410
|
registry?: GraphRegistry;
|
|
321
411
|
/** Dynamic registry mode — type definitions stored as graph data. */
|
|
322
412
|
registryMode?: DynamicRegistryConfig;
|
|
@@ -343,6 +433,25 @@ interface GraphClientOptions {
|
|
|
343
433
|
* - `'off'` — No scan protection.
|
|
344
434
|
*/
|
|
345
435
|
scanProtection?: ScanProtection;
|
|
436
|
+
/**
|
|
437
|
+
* Global default for write-back of auto-migrated records on read.
|
|
438
|
+
*
|
|
439
|
+
* - `'off'` (default) — Migrated data is returned but NOT written back.
|
|
440
|
+
* - `'eager'` — Migrated data is written back immediately after migration.
|
|
441
|
+
* - `'background'` — Write-back happens asynchronously; errors are logged.
|
|
442
|
+
*
|
|
443
|
+
* Per-entry `migrationWriteBack` on `RegistryEntry` overrides this setting.
|
|
444
|
+
*/
|
|
445
|
+
migrationWriteBack?: MigrationWriteBack;
|
|
446
|
+
/**
|
|
447
|
+
* Custom executor for compiling dynamic registry migration source strings.
|
|
448
|
+
* Defaults to SES Compartments with JSON marshaling. Supply an
|
|
449
|
+
* alternative for custom sandboxing.
|
|
450
|
+
*
|
|
451
|
+
* Only used for dynamic registry migrations — static registry migrations
|
|
452
|
+
* are already in-memory functions and never go through this executor.
|
|
453
|
+
*/
|
|
454
|
+
migrationSandbox?: MigrationExecutor;
|
|
346
455
|
}
|
|
347
456
|
interface GraphRegistry {
|
|
348
457
|
validate(aType: string, axbType: string, bType: string, data: unknown, scopePath?: string): void;
|
|
@@ -531,4 +640,4 @@ interface CodegenOptions {
|
|
|
531
640
|
*/
|
|
532
641
|
declare function generateTypes(discovery: DiscoveryResult, options?: CodegenOptions): Promise<string>;
|
|
533
642
|
|
|
534
|
-
export { type
|
|
643
|
+
export { type ScanProtection as A, type BulkBatchError as B, type CascadeResult as C, type DynamicRegistryConfig as D, type EdgeTopology as E, type FindEdgesParams as F, type GraphClientOptions as G, type HopDefinition as H, type TraversalOptions as I, type TraversalResult as J, type ViewDefaultsConfig as K, type ViewResolverConfig as L, type MigrationExecutor as M, type NodeTypeData as N, defineConfig as O, generateTypes as P, type QueryPlan as Q, type RegistryEntry as R, type StoredMigrationStep as S, type TraversalBuilder as T, resolveView as U, type ViewContext as V, type WhereClause as W, type DynamicGraphClient as a, type GraphClient as b, type GraphRegistry as c, type DiscoveryResult as d, type GraphReader as e, type GraphRecord as f, type FindNodesParams as g, type MigrationFn as h, type MigrationStep as i, type StoredGraphRecord as j, type MigrationWriteBack as k, type QueryFilter as l, type BulkOptions as m, type BulkProgress as n, type BulkResult as o, type CodegenOptions as p, type DefineTypeOptions as q, type DiscoveredEntity as r, type EdgeTypeData as s, type FiregraphConfig as t, type GraphBatch as u, type GraphTransaction as v, type GraphWriter as w, type HopResult as x, type QueryMode as y, type QueryOptions as z };
|
|
@@ -113,6 +113,8 @@ interface GraphRecord {
|
|
|
113
113
|
data: Record<string, unknown>;
|
|
114
114
|
createdAt: Timestamp | FieldValue;
|
|
115
115
|
updatedAt: Timestamp | FieldValue;
|
|
116
|
+
/** Schema version — set automatically when the registry entry has migrations. */
|
|
117
|
+
v?: number;
|
|
116
118
|
}
|
|
117
119
|
interface StoredGraphRecord {
|
|
118
120
|
aType: string;
|
|
@@ -123,6 +125,8 @@ interface StoredGraphRecord {
|
|
|
123
125
|
data: Record<string, unknown>;
|
|
124
126
|
createdAt: Timestamp;
|
|
125
127
|
updatedAt: Timestamp;
|
|
128
|
+
/** Schema version — set automatically when the registry entry has migrations. */
|
|
129
|
+
v?: number;
|
|
126
130
|
}
|
|
127
131
|
interface WhereClause {
|
|
128
132
|
field: string;
|
|
@@ -175,6 +179,45 @@ interface QueryFilter {
|
|
|
175
179
|
op: WhereFilterOp;
|
|
176
180
|
value: unknown;
|
|
177
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* An executable migration function that transforms data from one schema
|
|
184
|
+
* version to the next. Can be synchronous or asynchronous.
|
|
185
|
+
*/
|
|
186
|
+
type MigrationFn = (data: Record<string, unknown>) => Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
187
|
+
/**
|
|
188
|
+
* A single migration step in a registry entry.
|
|
189
|
+
* Transforms data from `fromVersion` to `toVersion`.
|
|
190
|
+
*/
|
|
191
|
+
interface MigrationStep {
|
|
192
|
+
fromVersion: number;
|
|
193
|
+
toVersion: number;
|
|
194
|
+
up: MigrationFn;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* A stored migration step for dynamic registry types.
|
|
198
|
+
* The `up` field is a source code string that will be compiled at runtime.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* { fromVersion: 0, toVersion: 1, up: "(data) => ({ ...data, status: 'draft' })" }
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
interface StoredMigrationStep {
|
|
206
|
+
fromVersion: number;
|
|
207
|
+
toVersion: number;
|
|
208
|
+
up: string;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Pluggable executor interface for compiling migration function source
|
|
212
|
+
* strings into executable functions. Used for dynamic registry migrations.
|
|
213
|
+
*
|
|
214
|
+
* The default executor uses SES (Secure ECMAScript) Compartments with
|
|
215
|
+
* JSON marshaling for isolation. Users can supply an alternative via
|
|
216
|
+
* `GraphClientOptions.migrationSandbox`.
|
|
217
|
+
*/
|
|
218
|
+
type MigrationExecutor = (source: string) => MigrationFn;
|
|
219
|
+
/** Write-back mode for auto-migrated records. */
|
|
220
|
+
type MigrationWriteBack = 'off' | 'eager' | 'background';
|
|
178
221
|
interface RegistryEntry {
|
|
179
222
|
aType: string;
|
|
180
223
|
axbType: string;
|
|
@@ -220,6 +263,24 @@ interface RegistryEntry {
|
|
|
220
263
|
* ```
|
|
221
264
|
*/
|
|
222
265
|
targetGraph?: string;
|
|
266
|
+
/**
|
|
267
|
+
* Schema version for this type's data payload.
|
|
268
|
+
* **Computed automatically** from `migrations` as `max(toVersion)`.
|
|
269
|
+
* Do not set directly — provide migrations instead.
|
|
270
|
+
*/
|
|
271
|
+
schemaVersion?: number;
|
|
272
|
+
/**
|
|
273
|
+
* Ordered list of migrations to transform data from older versions
|
|
274
|
+
* to the current version. The schema version is derived as the highest
|
|
275
|
+
* `toVersion` in this array.
|
|
276
|
+
*/
|
|
277
|
+
migrations?: MigrationStep[];
|
|
278
|
+
/**
|
|
279
|
+
* Per-entry write-back override for auto-migrated records.
|
|
280
|
+
* Takes precedence over `GraphClientOptions.migrationWriteBack`.
|
|
281
|
+
* Omit to inherit the global setting.
|
|
282
|
+
*/
|
|
283
|
+
migrationWriteBack?: MigrationWriteBack;
|
|
223
284
|
}
|
|
224
285
|
/** Topology declaration for an edge (from edge.json). */
|
|
225
286
|
interface EdgeTopology {
|
|
@@ -255,6 +316,10 @@ interface DiscoveredEntity {
|
|
|
255
316
|
allowedIn?: string[];
|
|
256
317
|
/** Subgraph name where cross-graph edges of this type live. */
|
|
257
318
|
targetGraph?: string;
|
|
319
|
+
/** Migration steps loaded from migrations.ts. */
|
|
320
|
+
migrations?: MigrationStep[];
|
|
321
|
+
/** Per-entity write-back override from meta.json. */
|
|
322
|
+
migrationWriteBack?: MigrationWriteBack;
|
|
258
323
|
}
|
|
259
324
|
/** Result of scanning an entities directory. */
|
|
260
325
|
interface DiscoveryResult {
|
|
@@ -287,6 +352,18 @@ interface DefineTypeOptions {
|
|
|
287
352
|
viewCss?: string;
|
|
288
353
|
/** Scope patterns constraining where this type can exist in subgraphs. */
|
|
289
354
|
allowedIn?: string[];
|
|
355
|
+
/**
|
|
356
|
+
* Migration steps. Accepts function objects (auto-serialized via .toString())
|
|
357
|
+
* or strings (stored as-is). The schema version is derived as the highest
|
|
358
|
+
* `toVersion` in this array.
|
|
359
|
+
*/
|
|
360
|
+
migrations?: Array<{
|
|
361
|
+
fromVersion: number;
|
|
362
|
+
toVersion: number;
|
|
363
|
+
up: MigrationFn | string;
|
|
364
|
+
}>;
|
|
365
|
+
/** Per-type write-back override for auto-migrated records. */
|
|
366
|
+
migrationWriteBack?: MigrationWriteBack;
|
|
290
367
|
}
|
|
291
368
|
/** Data shape stored in a `nodeType` meta-node. */
|
|
292
369
|
interface NodeTypeData {
|
|
@@ -298,6 +375,8 @@ interface NodeTypeData {
|
|
|
298
375
|
viewTemplate?: string;
|
|
299
376
|
viewCss?: string;
|
|
300
377
|
allowedIn?: string[];
|
|
378
|
+
migrations?: StoredMigrationStep[];
|
|
379
|
+
migrationWriteBack?: MigrationWriteBack;
|
|
301
380
|
}
|
|
302
381
|
/** Data shape stored in an `edgeType` meta-node. */
|
|
303
382
|
interface EdgeTypeData {
|
|
@@ -313,10 +392,21 @@ interface EdgeTypeData {
|
|
|
313
392
|
viewCss?: string;
|
|
314
393
|
allowedIn?: string[];
|
|
315
394
|
targetGraph?: string;
|
|
395
|
+
migrations?: StoredMigrationStep[];
|
|
396
|
+
migrationWriteBack?: MigrationWriteBack;
|
|
316
397
|
}
|
|
317
398
|
type ScanProtection = 'error' | 'warn' | 'off';
|
|
318
399
|
interface GraphClientOptions {
|
|
319
|
-
/**
|
|
400
|
+
/**
|
|
401
|
+
* Static registry built from code/discovery.
|
|
402
|
+
*
|
|
403
|
+
* When provided alone, all writes are validated against this registry.
|
|
404
|
+
*
|
|
405
|
+
* When provided together with `registryMode`, operates in **merged mode**:
|
|
406
|
+
* static entries take priority and cannot be overridden by dynamic
|
|
407
|
+
* definitions. Dynamic definitions can only add new types. The merged
|
|
408
|
+
* client is returned as a `DynamicGraphClient`.
|
|
409
|
+
*/
|
|
320
410
|
registry?: GraphRegistry;
|
|
321
411
|
/** Dynamic registry mode — type definitions stored as graph data. */
|
|
322
412
|
registryMode?: DynamicRegistryConfig;
|
|
@@ -343,6 +433,25 @@ interface GraphClientOptions {
|
|
|
343
433
|
* - `'off'` — No scan protection.
|
|
344
434
|
*/
|
|
345
435
|
scanProtection?: ScanProtection;
|
|
436
|
+
/**
|
|
437
|
+
* Global default for write-back of auto-migrated records on read.
|
|
438
|
+
*
|
|
439
|
+
* - `'off'` (default) — Migrated data is returned but NOT written back.
|
|
440
|
+
* - `'eager'` — Migrated data is written back immediately after migration.
|
|
441
|
+
* - `'background'` — Write-back happens asynchronously; errors are logged.
|
|
442
|
+
*
|
|
443
|
+
* Per-entry `migrationWriteBack` on `RegistryEntry` overrides this setting.
|
|
444
|
+
*/
|
|
445
|
+
migrationWriteBack?: MigrationWriteBack;
|
|
446
|
+
/**
|
|
447
|
+
* Custom executor for compiling dynamic registry migration source strings.
|
|
448
|
+
* Defaults to SES Compartments with JSON marshaling. Supply an
|
|
449
|
+
* alternative for custom sandboxing.
|
|
450
|
+
*
|
|
451
|
+
* Only used for dynamic registry migrations — static registry migrations
|
|
452
|
+
* are already in-memory functions and never go through this executor.
|
|
453
|
+
*/
|
|
454
|
+
migrationSandbox?: MigrationExecutor;
|
|
346
455
|
}
|
|
347
456
|
interface GraphRegistry {
|
|
348
457
|
validate(aType: string, axbType: string, bType: string, data: unknown, scopePath?: string): void;
|
|
@@ -531,4 +640,4 @@ interface CodegenOptions {
|
|
|
531
640
|
*/
|
|
532
641
|
declare function generateTypes(discovery: DiscoveryResult, options?: CodegenOptions): Promise<string>;
|
|
533
642
|
|
|
534
|
-
export { type
|
|
643
|
+
export { type ScanProtection as A, type BulkBatchError as B, type CascadeResult as C, type DynamicRegistryConfig as D, type EdgeTopology as E, type FindEdgesParams as F, type GraphClientOptions as G, type HopDefinition as H, type TraversalOptions as I, type TraversalResult as J, type ViewDefaultsConfig as K, type ViewResolverConfig as L, type MigrationExecutor as M, type NodeTypeData as N, defineConfig as O, generateTypes as P, type QueryPlan as Q, type RegistryEntry as R, type StoredMigrationStep as S, type TraversalBuilder as T, resolveView as U, type ViewContext as V, type WhereClause as W, type DynamicGraphClient as a, type GraphClient as b, type GraphRegistry as c, type DiscoveryResult as d, type GraphReader as e, type GraphRecord as f, type FindNodesParams as g, type MigrationFn as h, type MigrationStep as i, type StoredGraphRecord as j, type MigrationWriteBack as k, type QueryFilter as l, type BulkOptions as m, type BulkProgress as n, type BulkResult as o, type CodegenOptions as p, type DefineTypeOptions as q, type DiscoveredEntity as r, type EdgeTypeData as s, type FiregraphConfig as t, type GraphBatch as u, type GraphTransaction as v, type GraphWriter as w, type HopResult as x, type QueryMode as y, type QueryOptions as z };
|