@nicia-ai/typegraph 0.4.0 → 0.6.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 +2 -2
- package/dist/{ast-CXFx6bF6.d.ts → ast-CG87Zr6p.d.ts} +2 -2
- package/dist/{ast-D-3bOanX.d.cts → ast-Cq9qrnNP.d.cts} +2 -2
- package/dist/backend/postgres/index.cjs +295 -23
- package/dist/backend/postgres/index.cjs.map +1 -1
- package/dist/backend/postgres/index.d.cts +33 -10
- package/dist/backend/postgres/index.d.ts +33 -10
- package/dist/backend/postgres/index.js +285 -5
- package/dist/backend/postgres/index.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +21 -90
- package/dist/backend/sqlite/index.cjs.map +1 -1
- package/dist/backend/sqlite/index.d.cts +22 -58
- package/dist/backend/sqlite/index.d.ts +22 -58
- package/dist/backend/sqlite/index.js +3 -78
- package/dist/backend/sqlite/index.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +83 -0
- package/dist/backend/sqlite/local.cjs.map +1 -0
- package/dist/backend/sqlite/local.d.cts +66 -0
- package/dist/backend/sqlite/local.d.ts +66 -0
- package/dist/backend/sqlite/local.js +77 -0
- package/dist/backend/sqlite/local.js.map +1 -0
- package/dist/chunk-23NGZHUN.cjs +2132 -0
- package/dist/chunk-23NGZHUN.cjs.map +1 -0
- package/dist/{chunk-ZO2FRJ2U.js → chunk-2DKSQNPW.js} +3 -4
- package/dist/chunk-2DKSQNPW.js.map +1 -0
- package/dist/chunk-JPO7W262.js +2093 -0
- package/dist/chunk-JPO7W262.js.map +1 -0
- package/dist/{chunk-NYDXJGA3.cjs → chunk-K5O7TOJO.cjs} +15 -16
- package/dist/chunk-K5O7TOJO.cjs.map +1 -0
- package/dist/{backend/drizzle/schema/postgres.d.ts → ddl-Bcyb4DW1.d.cts} +17 -17
- package/dist/{backend/drizzle/schema/postgres.d.cts → ddl-D7DQx8w8.d.ts} +17 -17
- package/dist/{index-DyrR_d-H.d.cts → index-QTnQwakS.d.cts} +1 -1
- package/dist/{index-DyrR_d-H.d.ts → index-QTnQwakS.d.ts} +1 -1
- package/dist/index.cjs +238 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -12
- package/dist/index.d.ts +11 -12
- package/dist/index.js +238 -1
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.d.cts +5 -6
- package/dist/indexes/index.d.ts +5 -6
- package/dist/interchange/index.d.cts +5 -6
- package/dist/interchange/index.d.ts +5 -6
- package/dist/{manager-0NysX4s6.d.cts → manager-BImRiYwz.d.cts} +3 -3
- package/dist/{manager-DFKe7ql3.d.ts → manager-DGQ9UF18.d.ts} +3 -3
- package/dist/profiler/index.d.cts +7 -8
- package/dist/profiler/index.d.ts +7 -8
- package/dist/schema/index.d.cts +6 -7
- package/dist/schema/index.d.ts +6 -7
- package/dist/{backend/drizzle/schema/sqlite.d.ts → sqlite-CSJ-fgIm.d.ts} +2 -25
- package/dist/{backend/drizzle/schema/sqlite.d.cts → sqlite-FWGZLwDd.d.cts} +2 -25
- package/dist/{store-SiovWEYA.d.ts → store-CscQUG-S.d.ts} +57 -6
- package/dist/{store-DhoA5uRc.d.cts → store-DNv1yd3n.d.cts} +57 -6
- package/dist/{types-DHRsi6j9.d.cts → types-BbMn2Ycv.d.cts} +2 -2
- package/dist/{types-ZT5mlism.d.ts → types-C2rhqkg7.d.ts} +2 -2
- package/dist/{types-6EKrWTs9.d.ts → types-D5ggX07j.d.ts} +7 -3
- package/dist/{types-BL1GyVku.d.cts → types-DEMAqkA1.d.cts} +1 -1
- package/dist/{types-DCGa53O2.d.ts → types-DJZoHy5R.d.ts} +1 -1
- package/dist/{types-DTJEu_-h.d.ts → types-DolHw9pJ.d.cts} +14 -1
- package/dist/{types-DTJEu_-h.d.cts → types-DolHw9pJ.d.ts} +14 -1
- package/dist/{types-BUy-pHKH.d.cts → types-SVDEKnU6.d.cts} +7 -3
- package/package.json +6 -46
- package/dist/backend/drizzle/index.cjs +0 -40
- package/dist/backend/drizzle/index.cjs.map +0 -1
- package/dist/backend/drizzle/index.d.cts +0 -13
- package/dist/backend/drizzle/index.d.ts +0 -13
- package/dist/backend/drizzle/index.js +0 -11
- package/dist/backend/drizzle/index.js.map +0 -1
- package/dist/backend/drizzle/postgres.cjs +0 -26
- package/dist/backend/drizzle/postgres.cjs.map +0 -1
- package/dist/backend/drizzle/postgres.d.cts +0 -35
- package/dist/backend/drizzle/postgres.d.ts +0 -35
- package/dist/backend/drizzle/postgres.js +0 -9
- package/dist/backend/drizzle/postgres.js.map +0 -1
- package/dist/backend/drizzle/schema/postgres.cjs +0 -39
- package/dist/backend/drizzle/schema/postgres.cjs.map +0 -1
- package/dist/backend/drizzle/schema/postgres.js +0 -6
- package/dist/backend/drizzle/schema/postgres.js.map +0 -1
- package/dist/backend/drizzle/schema/sqlite.cjs +0 -39
- package/dist/backend/drizzle/schema/sqlite.cjs.map +0 -1
- package/dist/backend/drizzle/schema/sqlite.js +0 -6
- package/dist/backend/drizzle/schema/sqlite.js.map +0 -1
- package/dist/backend/drizzle/sqlite.cjs +0 -26
- package/dist/backend/drizzle/sqlite.cjs.map +0 -1
- package/dist/backend/drizzle/sqlite.d.cts +0 -35
- package/dist/backend/drizzle/sqlite.d.ts +0 -35
- package/dist/backend/drizzle/sqlite.js +0 -9
- package/dist/backend/drizzle/sqlite.js.map +0 -1
- package/dist/chunk-3PURVEA4.js +0 -193
- package/dist/chunk-3PURVEA4.js.map +0 -1
- package/dist/chunk-7RVSDXT3.cjs +0 -1509
- package/dist/chunk-7RVSDXT3.cjs.map +0 -1
- package/dist/chunk-LUARLSYT.cjs +0 -289
- package/dist/chunk-LUARLSYT.cjs.map +0 -1
- package/dist/chunk-NU2XNMVI.cjs +0 -201
- package/dist/chunk-NU2XNMVI.cjs.map +0 -1
- package/dist/chunk-NYDXJGA3.cjs.map +0 -1
- package/dist/chunk-OGGLFYFA.js +0 -177
- package/dist/chunk-OGGLFYFA.js.map +0 -1
- package/dist/chunk-Q6PXIKRQ.js +0 -287
- package/dist/chunk-Q6PXIKRQ.js.map +0 -1
- package/dist/chunk-SMLIWLS7.js +0 -236
- package/dist/chunk-SMLIWLS7.js.map +0 -1
- package/dist/chunk-UYMT4LO2.cjs +0 -241
- package/dist/chunk-UYMT4LO2.cjs.map +0 -1
- package/dist/chunk-XZL6MCZJ.cjs +0 -185
- package/dist/chunk-XZL6MCZJ.cjs.map +0 -1
- package/dist/chunk-ZO2FRJ2U.js.map +0 -1
- package/dist/chunk-ZQGOBVXZ.js +0 -1488
- package/dist/chunk-ZQGOBVXZ.js.map +0 -1
- package/dist/test-helpers-CIq1Hhj1.d.ts +0 -26
- package/dist/test-helpers-DPRFVky4.d.cts +0 -26
- package/dist/types-BRzHlhKC.d.cts +0 -14
- package/dist/types-BRzHlhKC.d.ts +0 -14
package/dist/index.d.cts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { N as NodeType, E as EdgeType } from './types-
|
|
3
|
-
export { A as AnyEdgeType,
|
|
4
|
-
import { I as InferenceType, M as MetaEdge, O as OntologyRelation } from './types-
|
|
5
|
-
export { D as DEFAULT_SQL_SCHEMA, G as GraphBackend,
|
|
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 CreateEdgeInput, c as CreateNodeInput, d as Edge, e as EdgeAccessor, f as EdgeCollection, g as
|
|
8
|
-
import { G as GraphDef, K as KindRegistry } from './manager-
|
|
9
|
-
export { A as AllEdgeTypes,
|
|
10
|
-
export { C as CardinalityError,
|
|
11
|
-
import { A as AggregateExpr, F as FieldRef, C as ComparisonOp,
|
|
12
|
-
export { J as JsonPointer,
|
|
13
|
-
export { S as SqlDialect } from './types-BRzHlhKC.cjs';
|
|
2
|
+
import { N as NodeType, E as EdgeType } from './types-DolHw9pJ.cjs';
|
|
3
|
+
export { A as AnyEdgeType, C as Cardinality, a as Collation, D as DeleteBehavior, b as EdgeProps, c as EdgeRegistration, d as EdgeTypeWithEndpoints, e as EndpointExistence, G as GraphDefaults, f as NodeId, g as NodeProps, h as NodeRegistration, S as SqlDialect, T as TemporalMode, U as UniqueConstraint, i as UniquenessScope, j as isEdgeType, k as isEdgeTypeWithEndpoints, l as isNodeType } from './types-DolHw9pJ.cjs';
|
|
4
|
+
import { I as InferenceType, M as MetaEdge, O as OntologyRelation } from './types-SVDEKnU6.cjs';
|
|
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-SVDEKnU6.cjs';
|
|
6
|
+
import { A as AliasMap, E as EdgeAliasMap, Q as QueryBuilder, T as TraversalBuilder, C as CreateQueryBuilderOptions } from './store-DNv1yd3n.cjs';
|
|
7
|
+
export { a as AggregateResult, b as CreateEdgeInput, c as CreateNodeInput, d as Edge, e as EdgeAccessor, f as EdgeCollection, g as EdgeFindByEndpointsOptions, h as EdgeGetOrCreateByEndpointsOptions, i as EdgeGetOrCreateByEndpointsResult, j as EmbeddingSchema, k as EmbeddingValue, l as ExecutableAggregateQuery, m as ExecutableQuery, F as FieldAccessor, G as GetOrCreateAction, H as HookContext, I as IfExistsMode, N as Node, n as NodeAccessor, o as NodeAlias, p as NodeCollection, q as NodeGetOrCreateByConstraintOptions, r as NodeGetOrCreateByConstraintResult, s as NodeRef, O as OperationHookContext, P as PaginateOptions, t as PaginatedResult, u as Predicate, v as PreparedQuery, w as PropsAccessor, x as QueryHookContext, y as QueryOptions, R as RecursiveTraversalOptions, S as SelectContext, z as SelectableEdge, B as SelectableNode, D as Store, J as StoreHooks, K as StoreOptions, L as StreamOptions, M as TransactionContext, U as TypedEdgeCollection, V as TypedNodeRef, W as UnionableQuery, X as UpdateEdgeInput, Y as UpdateNodeInput, Z as createStore, _ as createStoreWithSchema, $ as embedding, a0 as exists, a1 as fieldRef, a2 as getEmbeddingDimensions, a3 as inSubquery, a4 as isEmbeddingSchema, a5 as isParameterRef, a6 as notExists, a7 as notInSubquery, a8 as param } from './store-DNv1yd3n.cjs';
|
|
8
|
+
import { G as GraphDef, K as KindRegistry } from './manager-BImRiYwz.cjs';
|
|
9
|
+
export { A as AllEdgeTypes, a as AllNodeTypes, E as EdgeKinds, b as GetEdgeType, c as GetNodeType, N as NodeKinds, d as defineGraph, g as getEdgeKinds, e as getNodeKinds, i as isGraphDef } from './manager-BImRiYwz.cjs';
|
|
10
|
+
export { 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-QTnQwakS.cjs';
|
|
11
|
+
import { A as AggregateExpr, F as FieldRef, C as ComparisonOp, a as AggregateComparisonPredicate } from './ast-Cq9qrnNP.cjs';
|
|
12
|
+
export { J as JsonPointer, b as JsonPointerFor, c as JsonPointerInput, d as JsonPointerSegment, e as JsonPointerSegments, f as JsonPointerSegmentsFor, M as MAX_JSON_POINTER_DEPTH, O as OrderSpec, P as ParameterRef, R as ResolveJsonPointer, g as ResolveJsonPointerSegments, S as SortDirection, T as TraversalExpansion, j as joinJsonPointers, h as jsonPointer, n as normalizeJsonPointer, p as parseJsonPointer } from './ast-Cq9qrnNP.cjs';
|
|
14
13
|
import 'drizzle-orm';
|
|
15
14
|
|
|
16
15
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { N as NodeType, E as EdgeType } from './types-
|
|
3
|
-
export { A as AnyEdgeType,
|
|
4
|
-
import { I as InferenceType, M as MetaEdge, O as OntologyRelation } from './types-
|
|
5
|
-
export { D as DEFAULT_SQL_SCHEMA, G as GraphBackend,
|
|
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 CreateEdgeInput, c as CreateNodeInput, d as Edge, e as EdgeAccessor, f as EdgeCollection, g as
|
|
8
|
-
import { G as GraphDef, K as KindRegistry } from './manager-
|
|
9
|
-
export { A as AllEdgeTypes,
|
|
10
|
-
export { C as CardinalityError,
|
|
11
|
-
import { A as AggregateExpr, F as FieldRef, C as ComparisonOp,
|
|
12
|
-
export { J as JsonPointer,
|
|
13
|
-
export { S as SqlDialect } from './types-BRzHlhKC.js';
|
|
2
|
+
import { N as NodeType, E as EdgeType } from './types-DolHw9pJ.js';
|
|
3
|
+
export { A as AnyEdgeType, C as Cardinality, a as Collation, D as DeleteBehavior, b as EdgeProps, c as EdgeRegistration, d as EdgeTypeWithEndpoints, e as EndpointExistence, G as GraphDefaults, f as NodeId, g as NodeProps, h as NodeRegistration, S as SqlDialect, T as TemporalMode, U as UniqueConstraint, i as UniquenessScope, j as isEdgeType, k as isEdgeTypeWithEndpoints, l as isNodeType } from './types-DolHw9pJ.js';
|
|
4
|
+
import { I as InferenceType, M as MetaEdge, O as OntologyRelation } from './types-D5ggX07j.js';
|
|
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-D5ggX07j.js';
|
|
6
|
+
import { A as AliasMap, E as EdgeAliasMap, Q as QueryBuilder, T as TraversalBuilder, C as CreateQueryBuilderOptions } from './store-CscQUG-S.js';
|
|
7
|
+
export { a as AggregateResult, b as CreateEdgeInput, c as CreateNodeInput, d as Edge, e as EdgeAccessor, f as EdgeCollection, g as EdgeFindByEndpointsOptions, h as EdgeGetOrCreateByEndpointsOptions, i as EdgeGetOrCreateByEndpointsResult, j as EmbeddingSchema, k as EmbeddingValue, l as ExecutableAggregateQuery, m as ExecutableQuery, F as FieldAccessor, G as GetOrCreateAction, H as HookContext, I as IfExistsMode, N as Node, n as NodeAccessor, o as NodeAlias, p as NodeCollection, q as NodeGetOrCreateByConstraintOptions, r as NodeGetOrCreateByConstraintResult, s as NodeRef, O as OperationHookContext, P as PaginateOptions, t as PaginatedResult, u as Predicate, v as PreparedQuery, w as PropsAccessor, x as QueryHookContext, y as QueryOptions, R as RecursiveTraversalOptions, S as SelectContext, z as SelectableEdge, B as SelectableNode, D as Store, J as StoreHooks, K as StoreOptions, L as StreamOptions, M as TransactionContext, U as TypedEdgeCollection, V as TypedNodeRef, W as UnionableQuery, X as UpdateEdgeInput, Y as UpdateNodeInput, Z as createStore, _ as createStoreWithSchema, $ as embedding, a0 as exists, a1 as fieldRef, a2 as getEmbeddingDimensions, a3 as inSubquery, a4 as isEmbeddingSchema, a5 as isParameterRef, a6 as notExists, a7 as notInSubquery, a8 as param } from './store-CscQUG-S.js';
|
|
8
|
+
import { G as GraphDef, K as KindRegistry } from './manager-DGQ9UF18.js';
|
|
9
|
+
export { A as AllEdgeTypes, a as AllNodeTypes, E as EdgeKinds, b as GetEdgeType, c as GetNodeType, N as NodeKinds, d as defineGraph, g as getEdgeKinds, e as getNodeKinds, i as isGraphDef } from './manager-DGQ9UF18.js';
|
|
10
|
+
export { 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-QTnQwakS.js';
|
|
11
|
+
import { A as AggregateExpr, F as FieldRef, C as ComparisonOp, a as AggregateComparisonPredicate } from './ast-CG87Zr6p.js';
|
|
12
|
+
export { J as JsonPointer, b as JsonPointerFor, c as JsonPointerInput, d as JsonPointerSegment, e as JsonPointerSegments, f as JsonPointerSegmentsFor, M as MAX_JSON_POINTER_DEPTH, O as OrderSpec, P as ParameterRef, R as ResolveJsonPointer, g as ResolveJsonPointerSegments, S as SortDirection, T as TraversalExpansion, j as joinJsonPointers, h as jsonPointer, n as normalizeJsonPointer, p as parseJsonPointer } from './ast-CG87Zr6p.js';
|
|
14
13
|
import 'drizzle-orm';
|
|
15
14
|
|
|
16
15
|
/**
|
package/dist/index.js
CHANGED
|
@@ -8549,6 +8549,23 @@ function createEdgeCollection(config) {
|
|
|
8549
8549
|
}
|
|
8550
8550
|
await deleteAll(backend);
|
|
8551
8551
|
},
|
|
8552
|
+
async findByEndpoints(from, to, options) {
|
|
8553
|
+
const findOptions = {};
|
|
8554
|
+
if (options?.matchOn !== void 0)
|
|
8555
|
+
findOptions.matchOn = options.matchOn;
|
|
8556
|
+
if (options?.props !== void 0)
|
|
8557
|
+
findOptions.props = options.props;
|
|
8558
|
+
const result = await config.executeFindByEndpoints(
|
|
8559
|
+
kind,
|
|
8560
|
+
from.kind,
|
|
8561
|
+
from.id,
|
|
8562
|
+
to.kind,
|
|
8563
|
+
to.id,
|
|
8564
|
+
backend,
|
|
8565
|
+
findOptions
|
|
8566
|
+
);
|
|
8567
|
+
return result === void 0 ? void 0 : narrowEdge(result);
|
|
8568
|
+
},
|
|
8552
8569
|
async getOrCreateByEndpoints(from, to, props, options) {
|
|
8553
8570
|
const getOrCreateOptions = {};
|
|
8554
8571
|
if (options?.matchOn !== void 0)
|
|
@@ -8639,7 +8656,9 @@ function createNodeCollection(config) {
|
|
|
8639
8656
|
matchesTemporalMode,
|
|
8640
8657
|
createQuery,
|
|
8641
8658
|
executeGetOrCreateByConstraint,
|
|
8642
|
-
executeBulkGetOrCreateByConstraint
|
|
8659
|
+
executeBulkGetOrCreateByConstraint,
|
|
8660
|
+
executeFindByConstraint,
|
|
8661
|
+
executeBulkFindByConstraint
|
|
8643
8662
|
} = config;
|
|
8644
8663
|
return {
|
|
8645
8664
|
async create(props, options) {
|
|
@@ -8888,6 +8907,30 @@ function createNodeCollection(config) {
|
|
|
8888
8907
|
}
|
|
8889
8908
|
await deleteAll(backend);
|
|
8890
8909
|
},
|
|
8910
|
+
async findByConstraint(constraintName, props) {
|
|
8911
|
+
const result = await executeFindByConstraint(
|
|
8912
|
+
kind,
|
|
8913
|
+
constraintName,
|
|
8914
|
+
props,
|
|
8915
|
+
backend
|
|
8916
|
+
);
|
|
8917
|
+
return result === void 0 ? void 0 : narrowNode(result);
|
|
8918
|
+
},
|
|
8919
|
+
async bulkFindByConstraint(constraintName, items) {
|
|
8920
|
+
if (items.length === 0) return [];
|
|
8921
|
+
const mappedItems = items.map((item) => ({
|
|
8922
|
+
props: item.props
|
|
8923
|
+
}));
|
|
8924
|
+
const results = await executeBulkFindByConstraint(
|
|
8925
|
+
kind,
|
|
8926
|
+
constraintName,
|
|
8927
|
+
mappedItems,
|
|
8928
|
+
backend
|
|
8929
|
+
);
|
|
8930
|
+
return results.map(
|
|
8931
|
+
(result) => result === void 0 ? void 0 : narrowNode(result)
|
|
8932
|
+
);
|
|
8933
|
+
},
|
|
8891
8934
|
async getOrCreateByConstraint(constraintName, props, options) {
|
|
8892
8935
|
const execute = async (target) => {
|
|
8893
8936
|
const result = await executeGetOrCreateByConstraint(
|
|
@@ -9748,6 +9791,28 @@ function findMatchingEdge(rows, matchOn, inputProps) {
|
|
|
9748
9791
|
}
|
|
9749
9792
|
return { liveRow, deletedRow };
|
|
9750
9793
|
}
|
|
9794
|
+
async function executeEdgeFindByEndpoints(ctx, kind, fromKind, fromId, toKind, toId, backend, options) {
|
|
9795
|
+
const matchOn = options?.matchOn ?? [];
|
|
9796
|
+
const props = options?.props ?? {};
|
|
9797
|
+
const registration = getEdgeRegistration(ctx.graph, kind);
|
|
9798
|
+
const edgeKind = registration.type;
|
|
9799
|
+
if (matchOn.length > 0) {
|
|
9800
|
+
validateMatchOnFields(edgeKind.schema, matchOn, kind);
|
|
9801
|
+
}
|
|
9802
|
+
const candidateRows = await backend.findEdgesByKind({
|
|
9803
|
+
graphId: ctx.graphId,
|
|
9804
|
+
kind,
|
|
9805
|
+
fromKind,
|
|
9806
|
+
fromId,
|
|
9807
|
+
toKind,
|
|
9808
|
+
toId,
|
|
9809
|
+
excludeDeleted: true
|
|
9810
|
+
});
|
|
9811
|
+
if (candidateRows.length === 0) return void 0;
|
|
9812
|
+
if (matchOn.length === 0) return rowToEdge(candidateRows[0]);
|
|
9813
|
+
const { liveRow } = findMatchingEdge(candidateRows, matchOn, props);
|
|
9814
|
+
return liveRow === void 0 ? void 0 : rowToEdge(liveRow);
|
|
9815
|
+
}
|
|
9751
9816
|
async function executeEdgeGetOrCreateByEndpoints(ctx, kind, fromKind, fromId, toKind, toId, props, backend, options) {
|
|
9752
9817
|
const ifExists = options?.ifExists ?? "return";
|
|
9753
9818
|
const matchOn = options?.matchOn ?? [];
|
|
@@ -10846,6 +10911,142 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
|
|
|
10846
10911
|
}
|
|
10847
10912
|
return { node: rowToNode(existingRow), action: "found" };
|
|
10848
10913
|
}
|
|
10914
|
+
async function executeNodeFindByConstraint(ctx, kind, constraintName, props, backend) {
|
|
10915
|
+
const registration = getNodeRegistration(ctx.graph, kind);
|
|
10916
|
+
const nodeKind = registration.type;
|
|
10917
|
+
const validatedProps = validateNodeProps(nodeKind.schema, props, {
|
|
10918
|
+
kind,
|
|
10919
|
+
operation: "create"
|
|
10920
|
+
});
|
|
10921
|
+
const constraint = resolveConstraint(ctx.graph, kind, constraintName);
|
|
10922
|
+
if (!checkWherePredicate(constraint, validatedProps)) return void 0;
|
|
10923
|
+
const key = computeUniqueKey(
|
|
10924
|
+
validatedProps,
|
|
10925
|
+
constraint.fields,
|
|
10926
|
+
constraint.collation
|
|
10927
|
+
);
|
|
10928
|
+
const kindsToCheck = getKindsForUniquenessCheck(
|
|
10929
|
+
kind,
|
|
10930
|
+
constraint.scope,
|
|
10931
|
+
ctx.registry
|
|
10932
|
+
);
|
|
10933
|
+
let existingUniqueRow;
|
|
10934
|
+
for (const kindToCheck of kindsToCheck) {
|
|
10935
|
+
const row = await backend.checkUnique({
|
|
10936
|
+
graphId: ctx.graphId,
|
|
10937
|
+
nodeKind: kindToCheck,
|
|
10938
|
+
constraintName: constraint.name,
|
|
10939
|
+
key,
|
|
10940
|
+
includeDeleted: false
|
|
10941
|
+
});
|
|
10942
|
+
if (row !== void 0) {
|
|
10943
|
+
existingUniqueRow = row;
|
|
10944
|
+
break;
|
|
10945
|
+
}
|
|
10946
|
+
}
|
|
10947
|
+
if (existingUniqueRow === void 0) return void 0;
|
|
10948
|
+
const existingRow = await backend.getNode(
|
|
10949
|
+
ctx.graphId,
|
|
10950
|
+
existingUniqueRow.concrete_kind,
|
|
10951
|
+
existingUniqueRow.node_id
|
|
10952
|
+
);
|
|
10953
|
+
if (existingRow === void 0 || existingRow.deleted_at !== void 0)
|
|
10954
|
+
return void 0;
|
|
10955
|
+
return rowToNode(existingRow);
|
|
10956
|
+
}
|
|
10957
|
+
async function executeNodeBulkFindByConstraint(ctx, kind, constraintName, items, backend) {
|
|
10958
|
+
if (items.length === 0) return [];
|
|
10959
|
+
const registration = getNodeRegistration(ctx.graph, kind);
|
|
10960
|
+
const nodeKind = registration.type;
|
|
10961
|
+
const constraint = resolveConstraint(ctx.graph, kind, constraintName);
|
|
10962
|
+
const validated = [];
|
|
10963
|
+
for (const item of items) {
|
|
10964
|
+
const validatedProps = validateNodeProps(nodeKind.schema, item.props, {
|
|
10965
|
+
kind,
|
|
10966
|
+
operation: "create"
|
|
10967
|
+
});
|
|
10968
|
+
const applies = checkWherePredicate(constraint, validatedProps);
|
|
10969
|
+
const key = applies ? computeUniqueKey(
|
|
10970
|
+
validatedProps,
|
|
10971
|
+
constraint.fields,
|
|
10972
|
+
constraint.collation
|
|
10973
|
+
) : void 0;
|
|
10974
|
+
validated.push({ validatedProps, key });
|
|
10975
|
+
}
|
|
10976
|
+
const uniqueKeys = [
|
|
10977
|
+
...new Set(
|
|
10978
|
+
validated.map((v) => v.key).filter((k) => k !== void 0)
|
|
10979
|
+
)
|
|
10980
|
+
];
|
|
10981
|
+
const kindsToCheck = getKindsForUniquenessCheck(
|
|
10982
|
+
kind,
|
|
10983
|
+
constraint.scope,
|
|
10984
|
+
ctx.registry
|
|
10985
|
+
);
|
|
10986
|
+
const existingByKey = /* @__PURE__ */ new Map();
|
|
10987
|
+
if (uniqueKeys.length > 0) {
|
|
10988
|
+
for (const kindToCheck of kindsToCheck) {
|
|
10989
|
+
if (backend.checkUniqueBatch === void 0) {
|
|
10990
|
+
for (const key of uniqueKeys) {
|
|
10991
|
+
if (existingByKey.has(key)) continue;
|
|
10992
|
+
const row = await backend.checkUnique({
|
|
10993
|
+
graphId: ctx.graphId,
|
|
10994
|
+
nodeKind: kindToCheck,
|
|
10995
|
+
constraintName: constraint.name,
|
|
10996
|
+
key,
|
|
10997
|
+
includeDeleted: false
|
|
10998
|
+
});
|
|
10999
|
+
if (row !== void 0) {
|
|
11000
|
+
existingByKey.set(row.key, row);
|
|
11001
|
+
}
|
|
11002
|
+
}
|
|
11003
|
+
} else {
|
|
11004
|
+
const rows = await backend.checkUniqueBatch({
|
|
11005
|
+
graphId: ctx.graphId,
|
|
11006
|
+
nodeKind: kindToCheck,
|
|
11007
|
+
constraintName: constraint.name,
|
|
11008
|
+
keys: uniqueKeys,
|
|
11009
|
+
includeDeleted: false
|
|
11010
|
+
});
|
|
11011
|
+
for (const row of rows) {
|
|
11012
|
+
if (!existingByKey.has(row.key)) {
|
|
11013
|
+
existingByKey.set(row.key, row);
|
|
11014
|
+
}
|
|
11015
|
+
}
|
|
11016
|
+
}
|
|
11017
|
+
}
|
|
11018
|
+
}
|
|
11019
|
+
const results = Array.from({ length: items.length });
|
|
11020
|
+
const seenKeys = /* @__PURE__ */ new Map();
|
|
11021
|
+
for (const [index, { key }] of validated.entries()) {
|
|
11022
|
+
if (key === void 0) {
|
|
11023
|
+
results[index] = void 0;
|
|
11024
|
+
continue;
|
|
11025
|
+
}
|
|
11026
|
+
const previousIndex = seenKeys.get(key);
|
|
11027
|
+
if (previousIndex !== void 0) {
|
|
11028
|
+
results[index] = results[previousIndex];
|
|
11029
|
+
continue;
|
|
11030
|
+
}
|
|
11031
|
+
seenKeys.set(key, index);
|
|
11032
|
+
const existing = existingByKey.get(key);
|
|
11033
|
+
if (existing === void 0) {
|
|
11034
|
+
results[index] = void 0;
|
|
11035
|
+
continue;
|
|
11036
|
+
}
|
|
11037
|
+
const existingRow = await backend.getNode(
|
|
11038
|
+
ctx.graphId,
|
|
11039
|
+
existing.concrete_kind,
|
|
11040
|
+
existing.node_id
|
|
11041
|
+
);
|
|
11042
|
+
if (existingRow === void 0 || existingRow.deleted_at !== void 0) {
|
|
11043
|
+
results[index] = void 0;
|
|
11044
|
+
continue;
|
|
11045
|
+
}
|
|
11046
|
+
results[index] = rowToNode(existingRow);
|
|
11047
|
+
}
|
|
11048
|
+
return results;
|
|
11049
|
+
}
|
|
10849
11050
|
async function executeNodeBulkGetOrCreateByConstraint(ctx, kind, constraintName, items, backend, options) {
|
|
10850
11051
|
if (items.length === 0) return [];
|
|
10851
11052
|
const ifExists = options?.ifExists ?? "return";
|
|
@@ -11125,6 +11326,14 @@ var Store = class {
|
|
|
11125
11326
|
items,
|
|
11126
11327
|
backend,
|
|
11127
11328
|
options
|
|
11329
|
+
),
|
|
11330
|
+
executeFindByConstraint: (kind, constraintName, props, backend) => executeNodeFindByConstraint(ctx, kind, constraintName, props, backend),
|
|
11331
|
+
executeBulkFindByConstraint: (kind, constraintName, items, backend) => executeNodeBulkFindByConstraint(
|
|
11332
|
+
ctx,
|
|
11333
|
+
kind,
|
|
11334
|
+
constraintName,
|
|
11335
|
+
items,
|
|
11336
|
+
backend
|
|
11128
11337
|
)
|
|
11129
11338
|
};
|
|
11130
11339
|
}
|
|
@@ -11162,6 +11371,16 @@ var Store = class {
|
|
|
11162
11371
|
items,
|
|
11163
11372
|
backend,
|
|
11164
11373
|
options
|
|
11374
|
+
),
|
|
11375
|
+
executeFindByEndpoints: (kind, fromKind, fromId, toKind, toId, backend, options) => executeEdgeFindByEndpoints(
|
|
11376
|
+
ctx,
|
|
11377
|
+
kind,
|
|
11378
|
+
fromKind,
|
|
11379
|
+
fromId,
|
|
11380
|
+
toKind,
|
|
11381
|
+
toId,
|
|
11382
|
+
backend,
|
|
11383
|
+
options
|
|
11165
11384
|
)
|
|
11166
11385
|
};
|
|
11167
11386
|
}
|
|
@@ -11229,6 +11448,24 @@ var Store = class {
|
|
|
11229
11448
|
return fn({ nodes, edges });
|
|
11230
11449
|
});
|
|
11231
11450
|
}
|
|
11451
|
+
// === Graph Lifecycle ===
|
|
11452
|
+
/**
|
|
11453
|
+
* Hard-deletes all data for this graph from the database.
|
|
11454
|
+
*
|
|
11455
|
+
* Removes all nodes, edges, uniqueness entries, embeddings, and schema versions
|
|
11456
|
+
* for this graph's ID. No hooks, no per-row logic. Wrapped in a transaction
|
|
11457
|
+
* when the backend supports it.
|
|
11458
|
+
*
|
|
11459
|
+
* The store is usable after clearing — new data can be created immediately.
|
|
11460
|
+
*/
|
|
11461
|
+
async clear() {
|
|
11462
|
+
const doClear = async (target) => {
|
|
11463
|
+
await target.clearGraph(this.graphId);
|
|
11464
|
+
};
|
|
11465
|
+
await (this.#backend.capabilities.transactions ? this.#backend.transaction(async (tx) => doClear(tx)) : doClear(this.#backend));
|
|
11466
|
+
this.#nodeCollections = void 0;
|
|
11467
|
+
this.#edgeCollections = void 0;
|
|
11468
|
+
}
|
|
11232
11469
|
// === Lifecycle ===
|
|
11233
11470
|
/**
|
|
11234
11471
|
* Closes the store and releases underlying resources.
|