@typicalday/firegraph 0.2.0 → 0.4.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 +254 -7
- package/dist/codegen/index.d.cts +1 -1
- package/dist/codegen/index.d.ts +1 -1
- package/dist/editor/server/index.mjs +140 -16
- package/dist/{index-wSlVH5Nv.d.cts → index-DR3jF5_b.d.cts} +72 -2
- package/dist/{index-wSlVH5Nv.d.ts → index-DR3jF5_b.d.ts} +72 -2
- package/dist/index.cjs +280 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +81 -6
- package/dist/index.d.ts +81 -6
- package/dist/index.js +277 -37
- package/dist/index.js.map +1 -1
- package/package.json +23 -25
|
@@ -199,12 +199,38 @@ interface RegistryEntry {
|
|
|
199
199
|
* - `'**/agents'` — `**` matches zero or more segments
|
|
200
200
|
*/
|
|
201
201
|
allowedIn?: string[];
|
|
202
|
+
/**
|
|
203
|
+
* Subgraph name where cross-graph edges of this type live.
|
|
204
|
+
*
|
|
205
|
+
* When set, forward traversal queries the named subgraph under each
|
|
206
|
+
* source node (e.g., `{collection}/{sourceUid}/{targetGraph}`) instead
|
|
207
|
+
* of the current collection. The subgraph contains both the edge
|
|
208
|
+
* documents and the target nodes they reference.
|
|
209
|
+
*
|
|
210
|
+
* Reverse traversal is unaffected — if you're already in the subgraph,
|
|
211
|
+
* the edges are local.
|
|
212
|
+
*
|
|
213
|
+
* Only applies to edge entries (not node self-loop entries).
|
|
214
|
+
* Must be a single segment (no `/`).
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* { aType: 'task', axbType: 'assignedTo', bType: 'agent', targetGraph: 'workflow' }
|
|
219
|
+
* // Forward traversal from task1: queries {collection}/task1/workflow
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
targetGraph?: string;
|
|
202
223
|
}
|
|
203
224
|
/** Topology declaration for an edge (from edge.json). */
|
|
204
225
|
interface EdgeTopology {
|
|
205
226
|
from: string | string[];
|
|
206
227
|
to: string | string[];
|
|
207
228
|
inverseLabel?: string;
|
|
229
|
+
/**
|
|
230
|
+
* Subgraph name where cross-graph edges of this type live.
|
|
231
|
+
* See `RegistryEntry.targetGraph` for full documentation.
|
|
232
|
+
*/
|
|
233
|
+
targetGraph?: string;
|
|
208
234
|
}
|
|
209
235
|
/** A discovered entity from the per-entity folder convention. */
|
|
210
236
|
interface DiscoveredEntity {
|
|
@@ -227,6 +253,8 @@ interface DiscoveredEntity {
|
|
|
227
253
|
sampleData?: Record<string, unknown>;
|
|
228
254
|
/** Scope patterns constraining where this type can exist in subgraphs. */
|
|
229
255
|
allowedIn?: string[];
|
|
256
|
+
/** Subgraph name where cross-graph edges of this type live. */
|
|
257
|
+
targetGraph?: string;
|
|
230
258
|
}
|
|
231
259
|
/** Result of scanning an entities directory. */
|
|
232
260
|
interface DiscoveryResult {
|
|
@@ -284,10 +312,20 @@ interface EdgeTypeData {
|
|
|
284
312
|
viewTemplate?: string;
|
|
285
313
|
viewCss?: string;
|
|
286
314
|
allowedIn?: string[];
|
|
315
|
+
targetGraph?: string;
|
|
287
316
|
}
|
|
288
317
|
type ScanProtection = 'error' | 'warn' | 'off';
|
|
289
318
|
interface GraphClientOptions {
|
|
290
|
-
/**
|
|
319
|
+
/**
|
|
320
|
+
* Static registry built from code/discovery.
|
|
321
|
+
*
|
|
322
|
+
* When provided alone, all writes are validated against this registry.
|
|
323
|
+
*
|
|
324
|
+
* When provided together with `registryMode`, operates in **merged mode**:
|
|
325
|
+
* static entries take priority and cannot be overridden by dynamic
|
|
326
|
+
* definitions. Dynamic definitions can only add new types. The merged
|
|
327
|
+
* client is returned as a `DynamicGraphClient`.
|
|
328
|
+
*/
|
|
291
329
|
registry?: GraphRegistry;
|
|
292
330
|
/** Dynamic registry mode — type definitions stored as graph data. */
|
|
293
331
|
registryMode?: DynamicRegistryConfig;
|
|
@@ -318,6 +356,8 @@ interface GraphClientOptions {
|
|
|
318
356
|
interface GraphRegistry {
|
|
319
357
|
validate(aType: string, axbType: string, bType: string, data: unknown, scopePath?: string): void;
|
|
320
358
|
lookup(aType: string, axbType: string, bType: string): RegistryEntry | undefined;
|
|
359
|
+
/** Return all entries matching the given axbType (edge relation name). */
|
|
360
|
+
lookupByAxbType(axbType: string): ReadonlyArray<RegistryEntry>;
|
|
321
361
|
entries(): ReadonlyArray<RegistryEntry>;
|
|
322
362
|
}
|
|
323
363
|
interface GraphReader {
|
|
@@ -356,6 +396,19 @@ interface GraphClient extends GraphReader, GraphWriter {
|
|
|
356
396
|
* @returns A `GraphClient` scoped to `{collectionPath}/{parentNodeUid}/{name}`
|
|
357
397
|
*/
|
|
358
398
|
subgraph(parentNodeUid: string, name?: string): GraphClient;
|
|
399
|
+
/**
|
|
400
|
+
* Find edges across all subgraphs using a Firestore collection group query.
|
|
401
|
+
*
|
|
402
|
+
* Queries all collections with the given name (defaults to `'graph'`) across
|
|
403
|
+
* the entire database. This is useful for cross-cutting reads that span
|
|
404
|
+
* multiple subgraphs.
|
|
405
|
+
*
|
|
406
|
+
* **Requires** a Firestore collection group index for the query pattern.
|
|
407
|
+
*
|
|
408
|
+
* @param params - Edge filter parameters (same as `findEdges`)
|
|
409
|
+
* @param collectionName - Collection name to query across (defaults to last segment of this client's collection path)
|
|
410
|
+
*/
|
|
411
|
+
findEdgesGlobal(params: FindEdgesParams, collectionName?: string): Promise<StoredGraphRecord[]>;
|
|
359
412
|
}
|
|
360
413
|
interface DynamicGraphClient extends GraphClient {
|
|
361
414
|
/** Define or update a node type in the dynamic registry. */
|
|
@@ -381,6 +434,23 @@ interface HopDefinition {
|
|
|
381
434
|
direction?: 'asc' | 'desc';
|
|
382
435
|
};
|
|
383
436
|
filter?: (edge: StoredGraphRecord) => boolean;
|
|
437
|
+
/**
|
|
438
|
+
* Subgraph name to cross into for this hop (forward traversal only).
|
|
439
|
+
*
|
|
440
|
+
* When set, the traversal queries the named subgraph under each source node
|
|
441
|
+
* instead of the current collection (`{collection}/{sourceUid}/{targetGraph}`).
|
|
442
|
+
*
|
|
443
|
+
* If omitted but the registry has a `targetGraph` for this `axbType`,
|
|
444
|
+
* the registry value is used automatically.
|
|
445
|
+
*
|
|
446
|
+
* **Context tracking:** Once a hop crosses into a subgraph, subsequent
|
|
447
|
+
* hops without `targetGraph` stay in that subgraph automatically. To
|
|
448
|
+
* cross into a different subgraph, set `targetGraph` explicitly on the
|
|
449
|
+
* next hop — explicit `targetGraph` always resolves relative to the
|
|
450
|
+
* root client, not the current subgraph. To return to the root graph,
|
|
451
|
+
* create a separate traversal from the root client.
|
|
452
|
+
*/
|
|
453
|
+
targetGraph?: string;
|
|
384
454
|
}
|
|
385
455
|
interface TraversalOptions {
|
|
386
456
|
maxReads?: number;
|
|
@@ -470,4 +540,4 @@ interface CodegenOptions {
|
|
|
470
540
|
*/
|
|
471
541
|
declare function generateTypes(discovery: DiscoveryResult, options?: CodegenOptions): Promise<string>;
|
|
472
542
|
|
|
473
|
-
export { type ViewResolverConfig 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, defineConfig as I, generateTypes as J, resolveView as K, type NodeTypeData as N, type QueryPlan as Q, type RegistryEntry as R, type ScanProtection as S, type TraversalBuilder as T, type ViewContext as V, type WhereClause as W, type DynamicGraphClient as a, type GraphClient as b, type
|
|
543
|
+
export { type ViewResolverConfig 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, defineConfig as I, generateTypes as J, resolveView as K, type NodeTypeData as N, type QueryPlan as Q, type RegistryEntry as R, type ScanProtection as S, type TraversalBuilder as T, 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 QueryFilter as h, type BulkOptions as i, type BulkProgress as j, type BulkResult as k, type CodegenOptions as l, type DefineTypeOptions as m, type DiscoveredEntity as n, type EdgeTypeData as o, type FiregraphConfig as p, type GraphBatch as q, type GraphTransaction as r, type GraphWriter as s, type HopResult as t, type QueryMode as u, type QueryOptions as v, type StoredGraphRecord as w, type TraversalOptions as x, type TraversalResult as y, type ViewDefaultsConfig as z };
|
|
@@ -199,12 +199,38 @@ interface RegistryEntry {
|
|
|
199
199
|
* - `'**/agents'` — `**` matches zero or more segments
|
|
200
200
|
*/
|
|
201
201
|
allowedIn?: string[];
|
|
202
|
+
/**
|
|
203
|
+
* Subgraph name where cross-graph edges of this type live.
|
|
204
|
+
*
|
|
205
|
+
* When set, forward traversal queries the named subgraph under each
|
|
206
|
+
* source node (e.g., `{collection}/{sourceUid}/{targetGraph}`) instead
|
|
207
|
+
* of the current collection. The subgraph contains both the edge
|
|
208
|
+
* documents and the target nodes they reference.
|
|
209
|
+
*
|
|
210
|
+
* Reverse traversal is unaffected — if you're already in the subgraph,
|
|
211
|
+
* the edges are local.
|
|
212
|
+
*
|
|
213
|
+
* Only applies to edge entries (not node self-loop entries).
|
|
214
|
+
* Must be a single segment (no `/`).
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* { aType: 'task', axbType: 'assignedTo', bType: 'agent', targetGraph: 'workflow' }
|
|
219
|
+
* // Forward traversal from task1: queries {collection}/task1/workflow
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
targetGraph?: string;
|
|
202
223
|
}
|
|
203
224
|
/** Topology declaration for an edge (from edge.json). */
|
|
204
225
|
interface EdgeTopology {
|
|
205
226
|
from: string | string[];
|
|
206
227
|
to: string | string[];
|
|
207
228
|
inverseLabel?: string;
|
|
229
|
+
/**
|
|
230
|
+
* Subgraph name where cross-graph edges of this type live.
|
|
231
|
+
* See `RegistryEntry.targetGraph` for full documentation.
|
|
232
|
+
*/
|
|
233
|
+
targetGraph?: string;
|
|
208
234
|
}
|
|
209
235
|
/** A discovered entity from the per-entity folder convention. */
|
|
210
236
|
interface DiscoveredEntity {
|
|
@@ -227,6 +253,8 @@ interface DiscoveredEntity {
|
|
|
227
253
|
sampleData?: Record<string, unknown>;
|
|
228
254
|
/** Scope patterns constraining where this type can exist in subgraphs. */
|
|
229
255
|
allowedIn?: string[];
|
|
256
|
+
/** Subgraph name where cross-graph edges of this type live. */
|
|
257
|
+
targetGraph?: string;
|
|
230
258
|
}
|
|
231
259
|
/** Result of scanning an entities directory. */
|
|
232
260
|
interface DiscoveryResult {
|
|
@@ -284,10 +312,20 @@ interface EdgeTypeData {
|
|
|
284
312
|
viewTemplate?: string;
|
|
285
313
|
viewCss?: string;
|
|
286
314
|
allowedIn?: string[];
|
|
315
|
+
targetGraph?: string;
|
|
287
316
|
}
|
|
288
317
|
type ScanProtection = 'error' | 'warn' | 'off';
|
|
289
318
|
interface GraphClientOptions {
|
|
290
|
-
/**
|
|
319
|
+
/**
|
|
320
|
+
* Static registry built from code/discovery.
|
|
321
|
+
*
|
|
322
|
+
* When provided alone, all writes are validated against this registry.
|
|
323
|
+
*
|
|
324
|
+
* When provided together with `registryMode`, operates in **merged mode**:
|
|
325
|
+
* static entries take priority and cannot be overridden by dynamic
|
|
326
|
+
* definitions. Dynamic definitions can only add new types. The merged
|
|
327
|
+
* client is returned as a `DynamicGraphClient`.
|
|
328
|
+
*/
|
|
291
329
|
registry?: GraphRegistry;
|
|
292
330
|
/** Dynamic registry mode — type definitions stored as graph data. */
|
|
293
331
|
registryMode?: DynamicRegistryConfig;
|
|
@@ -318,6 +356,8 @@ interface GraphClientOptions {
|
|
|
318
356
|
interface GraphRegistry {
|
|
319
357
|
validate(aType: string, axbType: string, bType: string, data: unknown, scopePath?: string): void;
|
|
320
358
|
lookup(aType: string, axbType: string, bType: string): RegistryEntry | undefined;
|
|
359
|
+
/** Return all entries matching the given axbType (edge relation name). */
|
|
360
|
+
lookupByAxbType(axbType: string): ReadonlyArray<RegistryEntry>;
|
|
321
361
|
entries(): ReadonlyArray<RegistryEntry>;
|
|
322
362
|
}
|
|
323
363
|
interface GraphReader {
|
|
@@ -356,6 +396,19 @@ interface GraphClient extends GraphReader, GraphWriter {
|
|
|
356
396
|
* @returns A `GraphClient` scoped to `{collectionPath}/{parentNodeUid}/{name}`
|
|
357
397
|
*/
|
|
358
398
|
subgraph(parentNodeUid: string, name?: string): GraphClient;
|
|
399
|
+
/**
|
|
400
|
+
* Find edges across all subgraphs using a Firestore collection group query.
|
|
401
|
+
*
|
|
402
|
+
* Queries all collections with the given name (defaults to `'graph'`) across
|
|
403
|
+
* the entire database. This is useful for cross-cutting reads that span
|
|
404
|
+
* multiple subgraphs.
|
|
405
|
+
*
|
|
406
|
+
* **Requires** a Firestore collection group index for the query pattern.
|
|
407
|
+
*
|
|
408
|
+
* @param params - Edge filter parameters (same as `findEdges`)
|
|
409
|
+
* @param collectionName - Collection name to query across (defaults to last segment of this client's collection path)
|
|
410
|
+
*/
|
|
411
|
+
findEdgesGlobal(params: FindEdgesParams, collectionName?: string): Promise<StoredGraphRecord[]>;
|
|
359
412
|
}
|
|
360
413
|
interface DynamicGraphClient extends GraphClient {
|
|
361
414
|
/** Define or update a node type in the dynamic registry. */
|
|
@@ -381,6 +434,23 @@ interface HopDefinition {
|
|
|
381
434
|
direction?: 'asc' | 'desc';
|
|
382
435
|
};
|
|
383
436
|
filter?: (edge: StoredGraphRecord) => boolean;
|
|
437
|
+
/**
|
|
438
|
+
* Subgraph name to cross into for this hop (forward traversal only).
|
|
439
|
+
*
|
|
440
|
+
* When set, the traversal queries the named subgraph under each source node
|
|
441
|
+
* instead of the current collection (`{collection}/{sourceUid}/{targetGraph}`).
|
|
442
|
+
*
|
|
443
|
+
* If omitted but the registry has a `targetGraph` for this `axbType`,
|
|
444
|
+
* the registry value is used automatically.
|
|
445
|
+
*
|
|
446
|
+
* **Context tracking:** Once a hop crosses into a subgraph, subsequent
|
|
447
|
+
* hops without `targetGraph` stay in that subgraph automatically. To
|
|
448
|
+
* cross into a different subgraph, set `targetGraph` explicitly on the
|
|
449
|
+
* next hop — explicit `targetGraph` always resolves relative to the
|
|
450
|
+
* root client, not the current subgraph. To return to the root graph,
|
|
451
|
+
* create a separate traversal from the root client.
|
|
452
|
+
*/
|
|
453
|
+
targetGraph?: string;
|
|
384
454
|
}
|
|
385
455
|
interface TraversalOptions {
|
|
386
456
|
maxReads?: number;
|
|
@@ -470,4 +540,4 @@ interface CodegenOptions {
|
|
|
470
540
|
*/
|
|
471
541
|
declare function generateTypes(discovery: DiscoveryResult, options?: CodegenOptions): Promise<string>;
|
|
472
542
|
|
|
473
|
-
export { type ViewResolverConfig 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, defineConfig as I, generateTypes as J, resolveView as K, type NodeTypeData as N, type QueryPlan as Q, type RegistryEntry as R, type ScanProtection as S, type TraversalBuilder as T, type ViewContext as V, type WhereClause as W, type DynamicGraphClient as a, type GraphClient as b, type
|
|
543
|
+
export { type ViewResolverConfig 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, defineConfig as I, generateTypes as J, resolveView as K, type NodeTypeData as N, type QueryPlan as Q, type RegistryEntry as R, type ScanProtection as S, type TraversalBuilder as T, 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 QueryFilter as h, type BulkOptions as i, type BulkProgress as j, type BulkResult as k, type CodegenOptions as l, type DefineTypeOptions as m, type DiscoveredEntity as n, type EdgeTypeData as o, type FiregraphConfig as p, type GraphBatch as q, type GraphTransaction as r, type GraphWriter as s, type HopResult as t, type QueryMode as u, type QueryOptions as v, type StoredGraphRecord as w, type TraversalOptions as x, type TraversalResult as y, type ViewDefaultsConfig as z };
|