@nicia-ai/typegraph 0.18.0 → 0.19.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/dist/index.cjs +48 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +48 -20
- package/dist/index.js.map +1 -1
- package/dist/interchange/index.d.cts +1 -1
- package/dist/interchange/index.d.ts +1 -1
- package/dist/profiler/index.d.cts +1 -1
- package/dist/profiler/index.d.ts +1 -1
- package/dist/{store-B_JzzHwb.d.cts → store-BnUu4qo5.d.cts} +33 -16
- package/dist/{store-DkY1pDfu.d.ts → store-CCOwNft_.d.ts} +33 -16
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -3,8 +3,8 @@ import { N as NodeType, E as EdgeType } from './types-DMzKq0d5.cjs';
|
|
|
3
3
|
export { A as AnyEdgeType, C as Cardinality, a as Collation, D as DeleteBehavior, b as EdgeId, c as EdgeProps, d as EdgeRegistration, e as EdgeTypeWithEndpoints, f as EndpointExistence, G as GraphDefaults, g as NodeId, h as NodeProps, i as NodeRegistration, S as SqlDialect, T as TemporalMode, U as UniqueConstraint, j as UniquenessScope, k as isEdgeType, l as isEdgeTypeWithEndpoints, m as isNodeType } from './types-DMzKq0d5.cjs';
|
|
4
4
|
import { I as InferenceType, M as MetaEdge, O as OntologyRelation } from './types-B3mmOMJV.cjs';
|
|
5
5
|
export { D as DEFAULT_SQL_SCHEMA, G as GraphBackend, a as MetaEdgeProperties, S as SqlSchema, b as SqlTableNames, T as TransactionBackend, c as createSqlSchema, i as isMetaEdge } from './types-B3mmOMJV.cjs';
|
|
6
|
-
import { A as AliasMap, E as EdgeAliasMap, Q as QueryBuilder, T as TraversalBuilder, C as CreateQueryBuilderOptions } from './store-
|
|
7
|
-
export { a as AggregateResult, b as AnyEdge, c as AnyNode, B as BatchResults, d as BatchableQuery, e as ConstraintNames, f as CreateEdgeInput, g as CreateNodeInput, D as DynamicEdgeCollection, h as DynamicNodeCollection, i as Edge, j as EdgeAccessor, k as EdgeCollection, l as EdgeFindByEndpointsOptions, m as EdgeGetOrCreateByEndpointsOptions, n as EdgeGetOrCreateByEndpointsResult, o as EmbeddingSchema, p as EmbeddingValue, q as ExecutableAggregateQuery, r as ExecutableQuery, F as FieldAccessor, G as GetOrCreateAction, s as GraphEdgeCollections, t as GraphNodeCollections, H as HookContext, I as IfExistsMode, N as Node, u as NodeAccessor, v as NodeAlias, w as NodeCollection, x as NodeGetOrCreateByConstraintOptions, y as NodeGetOrCreateByConstraintResult, z as NodeRef, O as OperationHookContext, P as PaginateOptions, J as PaginatedResult, K as Predicate, L as PreparedQuery, M as PropsAccessor, R as QueryHookContext, S as QueryOptions, U as RecursiveTraversalOptions, V as SelectContext, W as SelectableEdge, X as SelectableNode, Y as Store, Z as StoreHooks, _ as StoreOptions, $ as StoreProjection, a0 as StreamOptions, a1 as
|
|
6
|
+
import { A as AliasMap, E as EdgeAliasMap, Q as QueryBuilder, T as TraversalBuilder, C as CreateQueryBuilderOptions } from './store-BnUu4qo5.cjs';
|
|
7
|
+
export { a as AggregateResult, b as AnyEdge, c as AnyNode, B as BatchResults, d as BatchableQuery, e as ConstraintNames, f as CreateEdgeInput, g as CreateNodeInput, D as DynamicEdgeCollection, h as DynamicNodeCollection, i as Edge, j as EdgeAccessor, k as EdgeCollection, l as EdgeFindByEndpointsOptions, m as EdgeGetOrCreateByEndpointsOptions, n as EdgeGetOrCreateByEndpointsResult, o as EmbeddingSchema, p as EmbeddingValue, q as ExecutableAggregateQuery, r as ExecutableQuery, F as FieldAccessor, G as GetOrCreateAction, s as GraphEdgeCollections, t as GraphNodeCollections, H as HookContext, I as IfExistsMode, N as Node, u as NodeAccessor, v as NodeAlias, w as NodeCollection, x as NodeGetOrCreateByConstraintOptions, y as NodeGetOrCreateByConstraintResult, z as NodeRef, O as OperationHookContext, P as PaginateOptions, J as PaginatedResult, K as Predicate, L as PreparedQuery, M as PropsAccessor, R as QueryHookContext, S as QueryOptions, U as RecursiveTraversalOptions, V as SelectContext, W as SelectableEdge, X as SelectableNode, Y as Store, Z as StoreHooks, _ as StoreOptions, $ as StoreProjection, a0 as StreamOptions, a1 as SubgraphEdgeResult, a2 as SubgraphNodeResult, a3 as SubgraphOptions, a4 as SubgraphResult, a5 as SubsetEdge, a6 as SubsetNode, a7 as TransactionContext, a8 as TypedEdgeCollection, a9 as UnionableQuery, aa as UpdateEdgeInput, ab as UpdateNodeInput, ac as createStore, ad as createStoreWithSchema, ae as defineSubgraphProject, af as embedding, ag as exists, ah as fieldRef, ai as getEmbeddingDimensions, aj as inSubquery, ak as isEmbeddingSchema, al as isParameterRef, am as notExists, an as notInSubquery, ao as param } from './store-BnUu4qo5.cjs';
|
|
8
8
|
import { G as GraphDef, K as KindRegistry } from './manager-Bj1UEnhE.cjs';
|
|
9
9
|
export { A as AllEdgeTypes, a as AllNodeTypes, E as EdgeKinds, b as GetEdgeType, c as GetNodeType, N as NodeKinds, S as SchemaManagerOptions, d as SchemaValidationResult, e as defineGraph, g as getEdgeKinds, f as getNodeKinds, i as isGraphDef } from './manager-Bj1UEnhE.cjs';
|
|
10
10
|
export { B as BackendDisposedError, C as CardinalityError, a as CompilerInvariantError, b as ConfigurationError, D as DatabaseOperationError, c as DisjointError, E as EdgeNotFoundError, d as EndpointError, e as EndpointNotFoundError, f as ErrorCategory, K as KindNotFoundError, M as MigrationError, N as NodeConstraintNotFoundError, g as NodeNotFoundError, R as RestrictedDeleteError, S as SchemaMismatchError, T as TypeGraphError, h as TypeGraphErrorOptions, U as UniquenessError, i as UnsupportedPredicateError, V as ValidationError, j as ValidationErrorDetails, k as ValidationIssue, l as VersionConflictError, m as getErrorSuggestion, n as isConstraintError, o as isSystemError, p as isTypeGraphError, q as isUserRecoverable } from './index-DXkEXpNz.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { N as NodeType, E as EdgeType } from './types-DMzKq0d5.js';
|
|
|
3
3
|
export { A as AnyEdgeType, C as Cardinality, a as Collation, D as DeleteBehavior, b as EdgeId, c as EdgeProps, d as EdgeRegistration, e as EdgeTypeWithEndpoints, f as EndpointExistence, G as GraphDefaults, g as NodeId, h as NodeProps, i as NodeRegistration, S as SqlDialect, T as TemporalMode, U as UniqueConstraint, j as UniquenessScope, k as isEdgeType, l as isEdgeTypeWithEndpoints, m as isNodeType } from './types-DMzKq0d5.js';
|
|
4
4
|
import { I as InferenceType, M as MetaEdge, O as OntologyRelation } from './types-ThB4cFLp.js';
|
|
5
5
|
export { D as DEFAULT_SQL_SCHEMA, G as GraphBackend, a as MetaEdgeProperties, S as SqlSchema, b as SqlTableNames, T as TransactionBackend, c as createSqlSchema, i as isMetaEdge } from './types-ThB4cFLp.js';
|
|
6
|
-
import { A as AliasMap, E as EdgeAliasMap, Q as QueryBuilder, T as TraversalBuilder, C as CreateQueryBuilderOptions } from './store-
|
|
7
|
-
export { a as AggregateResult, b as AnyEdge, c as AnyNode, B as BatchResults, d as BatchableQuery, e as ConstraintNames, f as CreateEdgeInput, g as CreateNodeInput, D as DynamicEdgeCollection, h as DynamicNodeCollection, i as Edge, j as EdgeAccessor, k as EdgeCollection, l as EdgeFindByEndpointsOptions, m as EdgeGetOrCreateByEndpointsOptions, n as EdgeGetOrCreateByEndpointsResult, o as EmbeddingSchema, p as EmbeddingValue, q as ExecutableAggregateQuery, r as ExecutableQuery, F as FieldAccessor, G as GetOrCreateAction, s as GraphEdgeCollections, t as GraphNodeCollections, H as HookContext, I as IfExistsMode, N as Node, u as NodeAccessor, v as NodeAlias, w as NodeCollection, x as NodeGetOrCreateByConstraintOptions, y as NodeGetOrCreateByConstraintResult, z as NodeRef, O as OperationHookContext, P as PaginateOptions, J as PaginatedResult, K as Predicate, L as PreparedQuery, M as PropsAccessor, R as QueryHookContext, S as QueryOptions, U as RecursiveTraversalOptions, V as SelectContext, W as SelectableEdge, X as SelectableNode, Y as Store, Z as StoreHooks, _ as StoreOptions, $ as StoreProjection, a0 as StreamOptions, a1 as
|
|
6
|
+
import { A as AliasMap, E as EdgeAliasMap, Q as QueryBuilder, T as TraversalBuilder, C as CreateQueryBuilderOptions } from './store-CCOwNft_.js';
|
|
7
|
+
export { a as AggregateResult, b as AnyEdge, c as AnyNode, B as BatchResults, d as BatchableQuery, e as ConstraintNames, f as CreateEdgeInput, g as CreateNodeInput, D as DynamicEdgeCollection, h as DynamicNodeCollection, i as Edge, j as EdgeAccessor, k as EdgeCollection, l as EdgeFindByEndpointsOptions, m as EdgeGetOrCreateByEndpointsOptions, n as EdgeGetOrCreateByEndpointsResult, o as EmbeddingSchema, p as EmbeddingValue, q as ExecutableAggregateQuery, r as ExecutableQuery, F as FieldAccessor, G as GetOrCreateAction, s as GraphEdgeCollections, t as GraphNodeCollections, H as HookContext, I as IfExistsMode, N as Node, u as NodeAccessor, v as NodeAlias, w as NodeCollection, x as NodeGetOrCreateByConstraintOptions, y as NodeGetOrCreateByConstraintResult, z as NodeRef, O as OperationHookContext, P as PaginateOptions, J as PaginatedResult, K as Predicate, L as PreparedQuery, M as PropsAccessor, R as QueryHookContext, S as QueryOptions, U as RecursiveTraversalOptions, V as SelectContext, W as SelectableEdge, X as SelectableNode, Y as Store, Z as StoreHooks, _ as StoreOptions, $ as StoreProjection, a0 as StreamOptions, a1 as SubgraphEdgeResult, a2 as SubgraphNodeResult, a3 as SubgraphOptions, a4 as SubgraphResult, a5 as SubsetEdge, a6 as SubsetNode, a7 as TransactionContext, a8 as TypedEdgeCollection, a9 as UnionableQuery, aa as UpdateEdgeInput, ab as UpdateNodeInput, ac as createStore, ad as createStoreWithSchema, ae as defineSubgraphProject, af as embedding, ag as exists, ah as fieldRef, ai as getEmbeddingDimensions, aj as inSubquery, ak as isEmbeddingSchema, al as isParameterRef, am as notExists, an as notInSubquery, ao as param } from './store-CCOwNft_.js';
|
|
8
8
|
import { G as GraphDef, K as KindRegistry } from './manager-Chhrq1vl.js';
|
|
9
9
|
export { A as AllEdgeTypes, a as AllNodeTypes, E as EdgeKinds, b as GetEdgeType, c as GetNodeType, N as NodeKinds, S as SchemaManagerOptions, d as SchemaValidationResult, e as defineGraph, g as getEdgeKinds, f as getNodeKinds, i as isGraphDef } from './manager-Chhrq1vl.js';
|
|
10
10
|
export { B as BackendDisposedError, C as CardinalityError, a as CompilerInvariantError, b as ConfigurationError, D as DatabaseOperationError, c as DisjointError, E as EdgeNotFoundError, d as EndpointError, e as EndpointNotFoundError, f as ErrorCategory, K as KindNotFoundError, M as MigrationError, N as NodeConstraintNotFoundError, g as NodeNotFoundError, R as RestrictedDeleteError, S as SchemaMismatchError, T as TypeGraphError, h as TypeGraphErrorOptions, U as UniquenessError, i as UnsupportedPredicateError, V as ValidationError, j as ValidationErrorDetails, k as ValidationIssue, l as VersionConflictError, m as getErrorSuggestion, n as isConstraintError, o as isSystemError, p as isTypeGraphError, q as isUserRecoverable } from './index-DXkEXpNz.js';
|
package/dist/index.js
CHANGED
|
@@ -3528,9 +3528,6 @@ function defineSubgraphProject(_graph) {
|
|
|
3528
3528
|
}
|
|
3529
3529
|
async function executeSubgraph(params) {
|
|
3530
3530
|
const { options } = params;
|
|
3531
|
-
if (options.edges.length === 0) {
|
|
3532
|
-
return { nodes: [], edges: [] };
|
|
3533
|
-
}
|
|
3534
3531
|
const maxDepth = Math.min(
|
|
3535
3532
|
options.maxDepth ?? DEFAULT_SUBGRAPH_MAX_DEPTH,
|
|
3536
3533
|
MAX_EXPLICIT_RECURSIVE_DEPTH
|
|
@@ -3567,15 +3564,29 @@ async function executeSubgraph(params) {
|
|
|
3567
3564
|
fetchSubgraphNodes(ctx, reachableCte, includedIdsCte, nodeProjectionPlan),
|
|
3568
3565
|
fetchSubgraphEdges(ctx, reachableCte, includedIdsCte, edgeProjectionPlan)
|
|
3569
3566
|
]);
|
|
3570
|
-
const
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
);
|
|
3567
|
+
const nodesMap = /* @__PURE__ */ new Map();
|
|
3568
|
+
for (const row of nodeRows) {
|
|
3569
|
+
const node = mapSubgraphNodeRow(row, nodeProjectionPlan);
|
|
3570
|
+
nodesMap.set(node.id, node);
|
|
3571
|
+
}
|
|
3572
|
+
const adjacency = /* @__PURE__ */ new Map();
|
|
3573
|
+
const reverseAdjacency = /* @__PURE__ */ new Map();
|
|
3574
|
+
for (const row of edgeRows) {
|
|
3575
|
+
const edge = mapSubgraphEdgeRow(row, edgeProjectionPlan);
|
|
3576
|
+
insertAdjacencyEntry(adjacency, edge.fromId, edge.kind, edge);
|
|
3577
|
+
insertAdjacencyEntry(
|
|
3578
|
+
reverseAdjacency,
|
|
3579
|
+
edge.toId,
|
|
3580
|
+
edge.kind,
|
|
3581
|
+
edge
|
|
3582
|
+
);
|
|
3583
|
+
}
|
|
3584
|
+
const root = nodesMap.get(ctx.rootId);
|
|
3576
3585
|
return {
|
|
3577
|
-
|
|
3578
|
-
|
|
3586
|
+
root,
|
|
3587
|
+
nodes: nodesMap,
|
|
3588
|
+
adjacency,
|
|
3589
|
+
reverseAdjacency
|
|
3579
3590
|
};
|
|
3580
3591
|
}
|
|
3581
3592
|
var introspectorCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -3815,6 +3826,19 @@ function buildProjectedPropertyColumns(alias, plan, dialect) {
|
|
|
3815
3826
|
}
|
|
3816
3827
|
return columns;
|
|
3817
3828
|
}
|
|
3829
|
+
function insertAdjacencyEntry(index, nodeId, edgeKind, edge) {
|
|
3830
|
+
let kindMap = index.get(nodeId);
|
|
3831
|
+
if (kindMap === void 0) {
|
|
3832
|
+
kindMap = /* @__PURE__ */ new Map();
|
|
3833
|
+
index.set(nodeId, kindMap);
|
|
3834
|
+
}
|
|
3835
|
+
const edges = kindMap.get(edgeKind);
|
|
3836
|
+
if (edges === void 0) {
|
|
3837
|
+
kindMap.set(edgeKind, [edge]);
|
|
3838
|
+
} else {
|
|
3839
|
+
edges.push(edge);
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3818
3842
|
function applyProjectedFields(target, row, kindPlan) {
|
|
3819
3843
|
for (const fieldPlan of kindPlan.propertyFields) {
|
|
3820
3844
|
target[fieldPlan.field] = decodeSelectedValue(
|
|
@@ -11926,22 +11950,26 @@ var Store = class {
|
|
|
11926
11950
|
* Extracts a typed subgraph by traversing from a root node.
|
|
11927
11951
|
*
|
|
11928
11952
|
* Performs a BFS traversal from `rootId` following the specified edge kinds,
|
|
11929
|
-
*
|
|
11953
|
+
* returning an indexed result with adjacency maps for immediate traversal.
|
|
11930
11954
|
*
|
|
11931
11955
|
* @example
|
|
11932
11956
|
* ```typescript
|
|
11933
|
-
* const
|
|
11957
|
+
* const sg = await store.subgraph(run.id, {
|
|
11934
11958
|
* edges: ["has_task", "runs_agent", "uses_skill"],
|
|
11935
11959
|
* maxDepth: 4,
|
|
11936
|
-
* includeKinds: ["Run", "Task", "Agent", "Skill"],
|
|
11937
11960
|
* });
|
|
11938
11961
|
*
|
|
11939
|
-
*
|
|
11940
|
-
*
|
|
11941
|
-
*
|
|
11942
|
-
*
|
|
11943
|
-
*
|
|
11944
|
-
*
|
|
11962
|
+
* // Root node (the traversal starting point)
|
|
11963
|
+
* console.log(sg.root?.kind);
|
|
11964
|
+
*
|
|
11965
|
+
* // Lookup by ID
|
|
11966
|
+
* const task = sg.nodes.get(taskId);
|
|
11967
|
+
*
|
|
11968
|
+
* // Forward adjacency: edges of a kind from a node
|
|
11969
|
+
* const taskEdges = sg.adjacency.get(run.id)?.get("has_task") ?? [];
|
|
11970
|
+
*
|
|
11971
|
+
* // Reverse adjacency: edges of a kind pointing to a node
|
|
11972
|
+
* const parentEdges = sg.reverseAdjacency.get(taskId)?.get("has_task") ?? [];
|
|
11945
11973
|
* ```
|
|
11946
11974
|
*/
|
|
11947
11975
|
async subgraph(rootId, options) {
|