@nicia-ai/typegraph 0.4.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.
Files changed (53) hide show
  1. package/dist/backend/drizzle/index.cjs +5 -5
  2. package/dist/backend/drizzle/index.d.cts +1 -1
  3. package/dist/backend/drizzle/index.d.ts +1 -1
  4. package/dist/backend/drizzle/index.js +3 -3
  5. package/dist/backend/drizzle/postgres.cjs +3 -3
  6. package/dist/backend/drizzle/postgres.d.cts +1 -1
  7. package/dist/backend/drizzle/postgres.d.ts +1 -1
  8. package/dist/backend/drizzle/postgres.js +2 -2
  9. package/dist/backend/drizzle/sqlite.cjs +3 -3
  10. package/dist/backend/drizzle/sqlite.d.cts +1 -1
  11. package/dist/backend/drizzle/sqlite.d.ts +1 -1
  12. package/dist/backend/drizzle/sqlite.js +2 -2
  13. package/dist/backend/postgres/index.cjs +3 -3
  14. package/dist/backend/postgres/index.d.cts +1 -1
  15. package/dist/backend/postgres/index.d.ts +1 -1
  16. package/dist/backend/postgres/index.js +2 -2
  17. package/dist/backend/sqlite/index.cjs +4 -4
  18. package/dist/backend/sqlite/index.d.cts +1 -1
  19. package/dist/backend/sqlite/index.d.ts +1 -1
  20. package/dist/backend/sqlite/index.js +3 -3
  21. package/dist/{chunk-ZO2FRJ2U.js → chunk-4MTYE6CF.js} +3 -3
  22. package/dist/{chunk-ZO2FRJ2U.js.map → chunk-4MTYE6CF.js.map} +1 -1
  23. package/dist/{chunk-ZQGOBVXZ.js → chunk-6HFWKZU5.js} +20 -2
  24. package/dist/chunk-6HFWKZU5.js.map +1 -0
  25. package/dist/{chunk-LUARLSYT.cjs → chunk-ENXM4W4M.cjs} +18 -18
  26. package/dist/{chunk-LUARLSYT.cjs.map → chunk-ENXM4W4M.cjs.map} +1 -1
  27. package/dist/{chunk-Q6PXIKRQ.js → chunk-KKFJJYCP.js} +3 -3
  28. package/dist/{chunk-Q6PXIKRQ.js.map → chunk-KKFJJYCP.js.map} +1 -1
  29. package/dist/{chunk-NYDXJGA3.cjs → chunk-KPU6TLUV.cjs} +14 -14
  30. package/dist/{chunk-NYDXJGA3.cjs.map → chunk-KPU6TLUV.cjs.map} +1 -1
  31. package/dist/{chunk-7RVSDXT3.cjs → chunk-PW5BSBZV.cjs} +20 -2
  32. package/dist/chunk-PW5BSBZV.cjs.map +1 -0
  33. package/dist/index.cjs +238 -1
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +6 -6
  36. package/dist/index.d.ts +6 -6
  37. package/dist/index.js +238 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/interchange/index.d.cts +3 -3
  40. package/dist/interchange/index.d.ts +3 -3
  41. package/dist/{manager-DFKe7ql3.d.ts → manager-DXC7CqKG.d.ts} +1 -1
  42. package/dist/{manager-0NysX4s6.d.cts → manager-DiPf-0GG.d.cts} +1 -1
  43. package/dist/profiler/index.d.cts +3 -3
  44. package/dist/profiler/index.d.ts +3 -3
  45. package/dist/schema/index.d.cts +4 -4
  46. package/dist/schema/index.d.ts +4 -4
  47. package/dist/{store-SiovWEYA.d.ts → store-DODIWZxC.d.ts} +55 -3
  48. package/dist/{store-DhoA5uRc.d.cts → store-nDW3GOFb.d.cts} +55 -3
  49. package/dist/{types-6EKrWTs9.d.ts → types-DpIoePMI.d.ts} +5 -0
  50. package/dist/{types-BUy-pHKH.d.cts → types-WX8V9dqn.d.cts} +5 -0
  51. package/package.json +1 -1
  52. package/dist/chunk-7RVSDXT3.cjs.map +0 -1
  53. package/dist/chunk-ZQGOBVXZ.js.map +0 -1
@@ -1,8 +1,8 @@
1
1
  import { z } from 'zod';
2
- import { G as GraphDef } from '../manager-0NysX4s6.cjs';
3
- import { S as Store } from '../store-DhoA5uRc.cjs';
2
+ import { G as GraphDef } from '../manager-DiPf-0GG.cjs';
3
+ import { S as Store } from '../store-nDW3GOFb.cjs';
4
4
  import '../types-DTJEu_-h.cjs';
5
- import '../types-BUy-pHKH.cjs';
5
+ import '../types-WX8V9dqn.cjs';
6
6
  import 'drizzle-orm';
7
7
  import '../types-BRzHlhKC.cjs';
8
8
  import '../ast-D-3bOanX.cjs';
@@ -1,8 +1,8 @@
1
1
  import { z } from 'zod';
2
- import { G as GraphDef } from '../manager-DFKe7ql3.js';
3
- import { S as Store } from '../store-SiovWEYA.js';
2
+ import { G as GraphDef } from '../manager-DXC7CqKG.js';
3
+ import { S as Store } from '../store-DODIWZxC.js';
4
4
  import '../types-DTJEu_-h.js';
5
- import '../types-6EKrWTs9.js';
5
+ import '../types-DpIoePMI.js';
6
6
  import 'drizzle-orm';
7
7
  import '../types-BRzHlhKC.js';
8
8
  import '../ast-CXFx6bF6.js';
@@ -1,5 +1,5 @@
1
1
  import { a as NodeRegistration, b as EdgeRegistration, D as DeleteBehavior, T as TemporalMode, N as NodeType, c as EdgeTypeWithEndpoints, G as GraphDefaults, A as AnyEdgeType } from './types-DTJEu_-h.js';
2
- import { O as OntologyRelation, S as SerializedNodeDef, a as SerializedEdgeDef, e as SerializedSchema, G as GraphBackend, i as SchemaVersionRow } from './types-6EKrWTs9.js';
2
+ import { O as OntologyRelation, S as SerializedNodeDef, a as SerializedEdgeDef, e as SerializedSchema, G as GraphBackend, i as SchemaVersionRow } from './types-DpIoePMI.js';
3
3
 
4
4
  /** Brand key for GraphDef */
5
5
  declare const GRAPH_DEF_BRAND: "__graphDef";
@@ -1,5 +1,5 @@
1
1
  import { a as NodeRegistration, b as EdgeRegistration, D as DeleteBehavior, T as TemporalMode, N as NodeType, c as EdgeTypeWithEndpoints, G as GraphDefaults, A as AnyEdgeType } from './types-DTJEu_-h.cjs';
2
- import { O as OntologyRelation, S as SerializedNodeDef, a as SerializedEdgeDef, e as SerializedSchema, G as GraphBackend, i as SchemaVersionRow } from './types-BUy-pHKH.cjs';
2
+ import { O as OntologyRelation, S as SerializedNodeDef, a as SerializedEdgeDef, e as SerializedSchema, G as GraphBackend, i as SchemaVersionRow } from './types-WX8V9dqn.cjs';
3
3
 
4
4
  /** Brand key for GraphDef */
5
5
  declare const GRAPH_DEF_BRAND: "__graphDef";
@@ -1,11 +1,11 @@
1
- import { G as GraphDef } from '../manager-0NysX4s6.cjs';
1
+ import { G as GraphDef } from '../manager-DiPf-0GG.cjs';
2
2
  import { Q as QueryAst } from '../ast-D-3bOanX.cjs';
3
- import { S as Store } from '../store-DhoA5uRc.cjs';
3
+ import { S as Store } from '../store-nDW3GOFb.cjs';
4
4
  import { P as ProfilerOptions, a as ProfileReport } from '../types-BL1GyVku.cjs';
5
5
  export { D as DeclaredIndex, I as IndexRecommendation, b as ProfileSummary, c as PropertyAccessStats, d as PropertyPath, R as RecommendationPriority, U as UsageContext } from '../types-BL1GyVku.cjs';
6
6
  import '../types-DTJEu_-h.cjs';
7
7
  import 'zod';
8
- import '../types-BUy-pHKH.cjs';
8
+ import '../types-WX8V9dqn.cjs';
9
9
  import 'drizzle-orm';
10
10
  import '../types-BRzHlhKC.cjs';
11
11
 
@@ -1,11 +1,11 @@
1
- import { G as GraphDef } from '../manager-DFKe7ql3.js';
1
+ import { G as GraphDef } from '../manager-DXC7CqKG.js';
2
2
  import { Q as QueryAst } from '../ast-CXFx6bF6.js';
3
- import { S as Store } from '../store-SiovWEYA.js';
3
+ import { S as Store } from '../store-DODIWZxC.js';
4
4
  import { P as ProfilerOptions, a as ProfileReport } from '../types-DCGa53O2.js';
5
5
  export { D as DeclaredIndex, I as IndexRecommendation, b as ProfileSummary, c as PropertyAccessStats, d as PropertyPath, R as RecommendationPriority, U as UsageContext } from '../types-DCGa53O2.js';
6
6
  import '../types-DTJEu_-h.js';
7
7
  import 'zod';
8
- import '../types-6EKrWTs9.js';
8
+ import '../types-DpIoePMI.js';
9
9
  import 'drizzle-orm';
10
10
  import '../types-BRzHlhKC.js';
11
11
 
@@ -1,7 +1,7 @@
1
- import { K as KindRegistry, G as GraphDef } from '../manager-0NysX4s6.cjs';
2
- export { C as ChangeSeverity, a as ChangeType, E as EdgeChange, M as MigrationHookContext, N as NodeChange, O as OntologyChange, S as SchemaDiff, b as SchemaManagerOptions, c as SchemaValidationResult, d as computeSchemaDiff, e as ensureSchema, g as getActiveSchema, f as getMigrationActions, h as getSchemaChanges, i as initializeSchema, j as isBackwardsCompatible, k as isSchemaInitialized, m as migrateSchema, r as rollbackSchema } from '../manager-0NysX4s6.cjs';
3
- import { S as SerializedNodeDef, a as SerializedEdgeDef, b as SerializedMetaEdge, c as SerializedOntologyRelation, d as SerializedClosures, e as SerializedSchema, f as SchemaHash } from '../types-BUy-pHKH.cjs';
4
- export { J as JsonSchema, g as SerializedOntology, h as SerializedUniqueConstraint } from '../types-BUy-pHKH.cjs';
1
+ import { K as KindRegistry, G as GraphDef } from '../manager-DiPf-0GG.cjs';
2
+ export { C as ChangeSeverity, a as ChangeType, E as EdgeChange, M as MigrationHookContext, N as NodeChange, O as OntologyChange, S as SchemaDiff, b as SchemaManagerOptions, c as SchemaValidationResult, d as computeSchemaDiff, e as ensureSchema, g as getActiveSchema, f as getMigrationActions, h as getSchemaChanges, i as initializeSchema, j as isBackwardsCompatible, k as isSchemaInitialized, m as migrateSchema, r as rollbackSchema } from '../manager-DiPf-0GG.cjs';
3
+ import { S as SerializedNodeDef, a as SerializedEdgeDef, b as SerializedMetaEdge, c as SerializedOntologyRelation, d as SerializedClosures, e as SerializedSchema, f as SchemaHash } from '../types-WX8V9dqn.cjs';
4
+ export { J as JsonSchema, g as SerializedOntology, h as SerializedUniqueConstraint } from '../types-WX8V9dqn.cjs';
5
5
  import { ZodType, ZodError } from 'zod';
6
6
  import { V as ValidationIssue, a as ValidationError } from '../index-DyrR_d-H.cjs';
7
7
  import '../types-DTJEu_-h.cjs';
@@ -1,7 +1,7 @@
1
- import { K as KindRegistry, G as GraphDef } from '../manager-DFKe7ql3.js';
2
- export { C as ChangeSeverity, a as ChangeType, E as EdgeChange, M as MigrationHookContext, N as NodeChange, O as OntologyChange, S as SchemaDiff, b as SchemaManagerOptions, c as SchemaValidationResult, d as computeSchemaDiff, e as ensureSchema, g as getActiveSchema, f as getMigrationActions, h as getSchemaChanges, i as initializeSchema, j as isBackwardsCompatible, k as isSchemaInitialized, m as migrateSchema, r as rollbackSchema } from '../manager-DFKe7ql3.js';
3
- import { S as SerializedNodeDef, a as SerializedEdgeDef, b as SerializedMetaEdge, c as SerializedOntologyRelation, d as SerializedClosures, e as SerializedSchema, f as SchemaHash } from '../types-6EKrWTs9.js';
4
- export { J as JsonSchema, g as SerializedOntology, h as SerializedUniqueConstraint } from '../types-6EKrWTs9.js';
1
+ import { K as KindRegistry, G as GraphDef } from '../manager-DXC7CqKG.js';
2
+ export { C as ChangeSeverity, a as ChangeType, E as EdgeChange, M as MigrationHookContext, N as NodeChange, O as OntologyChange, S as SchemaDiff, b as SchemaManagerOptions, c as SchemaValidationResult, d as computeSchemaDiff, e as ensureSchema, g as getActiveSchema, f as getMigrationActions, h as getSchemaChanges, i as initializeSchema, j as isBackwardsCompatible, k as isSchemaInitialized, m as migrateSchema, r as rollbackSchema } from '../manager-DXC7CqKG.js';
3
+ import { S as SerializedNodeDef, a as SerializedEdgeDef, b as SerializedMetaEdge, c as SerializedOntologyRelation, d as SerializedClosures, e as SerializedSchema, f as SchemaHash } from '../types-DpIoePMI.js';
4
+ export { J as JsonSchema, g as SerializedOntology, h as SerializedUniqueConstraint } from '../types-DpIoePMI.js';
5
5
  import { ZodType, ZodError } from 'zod';
6
6
  import { V as ValidationIssue, a as ValidationError } from '../index-DyrR_d-H.js';
7
7
  import '../types-DTJEu_-h.js';
@@ -1,5 +1,5 @@
1
- import { k as SqlSchema, G as GraphBackend } from './types-6EKrWTs9.js';
2
- import { K as KindRegistry, G as GraphDef, b as SchemaManagerOptions, c as SchemaValidationResult } from './manager-DFKe7ql3.js';
1
+ import { k as SqlSchema, G as GraphBackend } from './types-DpIoePMI.js';
2
+ import { K as KindRegistry, G as GraphDef, b as SchemaManagerOptions, c as SchemaValidationResult } from './manager-DXC7CqKG.js';
3
3
  import { N as NodeType, A as AnyEdgeType, T as TemporalMode, E as EdgeType, b as EdgeRegistration, g as NodeId } from './types-DTJEu_-h.js';
4
4
  import { V as ValueType, i as PredicateExpression, k as VectorMetricType, Q as QueryAst, J as JsonPointer, F as FieldRef, P as ParameterRef, d as JsonPointerInput, T as TraversalExpansion, l as Traversal, N as NodePredicate, m as ProjectedField, O as OrderSpec, G as GroupBySpec, o as RecursiveCyclePolicy, q as TraversalDirection, A as AggregateExpr, r as SelectiveField, s as ComposableQuery, t as SetOperationType, u as SetOperation, S as SortDirection } from './ast-CXFx6bF6.js';
5
5
  import { SQL } from 'drizzle-orm';
@@ -805,6 +805,18 @@ type EdgeGetOrCreateByEndpointsResult<E extends AnyEdgeType> = Readonly<{
805
805
  edge: Edge<E>;
806
806
  action: GetOrCreateAction;
807
807
  }>;
808
+ /**
809
+ * Options for edge findByEndpoints operations.
810
+ */
811
+ type EdgeFindByEndpointsOptions<E extends AnyEdgeType> = Readonly<{
812
+ /**
813
+ * Edge property fields to include in the match alongside the (from, to) endpoints.
814
+ * When omitted, matches on endpoints only (returns first live edge).
815
+ */
816
+ matchOn?: readonly (keyof z.input<E["schema"]>)[];
817
+ /** Property values to match against when matchOn is specified. */
818
+ props?: Partial<z.input<E["schema"]>>;
819
+ }>;
808
820
  /**
809
821
  * Options for edge getOrCreateByEndpoints operations.
810
822
  */
@@ -920,6 +932,25 @@ type NodeCollection<N extends NodeType> = Readonly<{
920
932
  * that don't exist.
921
933
  */
922
934
  bulkDelete: (ids: readonly NodeId<N>[]) => Promise<void>;
935
+ /**
936
+ * Find a node by uniqueness constraint.
937
+ *
938
+ * Looks up a live node by the named constraint key computed from `props`.
939
+ * Returns the node if found, or undefined. Soft-deleted nodes are excluded.
940
+ *
941
+ * @param constraintName - Name of the uniqueness constraint to match on
942
+ * @param props - Properties to compute the constraint key from
943
+ */
944
+ findByConstraint: (constraintName: string, props: z.input<N["schema"]>) => Promise<Node<N> | undefined>;
945
+ /**
946
+ * Batch version of findByConstraint.
947
+ *
948
+ * Results are returned in the same order as the input items.
949
+ * Returns undefined for entries that don't match.
950
+ */
951
+ bulkFindByConstraint: (constraintName: string, items: readonly Readonly<{
952
+ props: z.input<N["schema"]>;
953
+ }>[]) => Promise<(Node<N> | undefined)[]>;
923
954
  /**
924
955
  * Get an existing node by uniqueness constraint, or create a new one.
925
956
  *
@@ -1103,6 +1134,17 @@ type EdgeCollection<E extends AnyEdgeType, From extends NodeType = NodeType, To
1103
1134
  * that don't exist.
1104
1135
  */
1105
1136
  bulkDelete: (ids: readonly string[]) => Promise<void>;
1137
+ /**
1138
+ * Find a live edge by endpoints and optional property fields.
1139
+ *
1140
+ * Returns the first matching live edge, or undefined.
1141
+ * Soft-deleted edges are excluded.
1142
+ *
1143
+ * @param from - Source node
1144
+ * @param to - Target node
1145
+ * @param options - Match criteria (matchOn fields and property values)
1146
+ */
1147
+ findByEndpoints: (from: TypedNodeRef<From>, to: TypedNodeRef<To>, options?: EdgeFindByEndpointsOptions<E>) => Promise<Edge<E> | undefined>;
1106
1148
  /**
1107
1149
  * Get an existing edge by endpoints and optional property fields, or create a new one.
1108
1150
  *
@@ -1833,6 +1875,16 @@ declare class Store<G extends GraphDef> {
1833
1875
  * ```
1834
1876
  */
1835
1877
  transaction<T>(fn: (tx: TransactionContext<G>) => Promise<T>): Promise<T>;
1878
+ /**
1879
+ * Hard-deletes all data for this graph from the database.
1880
+ *
1881
+ * Removes all nodes, edges, uniqueness entries, embeddings, and schema versions
1882
+ * for this graph's ID. No hooks, no per-row logic. Wrapped in a transaction
1883
+ * when the backend supports it.
1884
+ *
1885
+ * The store is usable after clearing — new data can be created immediately.
1886
+ */
1887
+ clear(): Promise<void>;
1836
1888
  /**
1837
1889
  * Closes the store and releases underlying resources.
1838
1890
  *
@@ -1903,4 +1955,4 @@ declare function createStore<G extends GraphDef>(graph: G, backend: GraphBackend
1903
1955
  */
1904
1956
  declare function createStoreWithSchema<G extends GraphDef>(graph: G, backend: GraphBackend, options?: StoreOptions & SchemaManagerOptions): Promise<[Store<G>, SchemaValidationResult]>;
1905
1957
 
1906
- export { exists as $, type AliasMap as A, type SelectableNode as B, type CreateQueryBuilderOptions as C, type StoreHooks as D, type EdgeAliasMap as E, type FieldAccessor as F, type GetOrCreateAction as G, type HookContext as H, type IfExistsMode as I, type StoreOptions as J, type StreamOptions as K, type TransactionContext as L, type TypedEdgeCollection as M, type Node as N, type OperationHookContext as O, type PaginateOptions as P, QueryBuilder as Q, type RecursiveTraversalOptions as R, Store as S, TraversalBuilder as T, type TypedNodeRef as U, UnionableQuery as V, type UpdateEdgeInput as W, type UpdateNodeInput as X, createStore as Y, createStoreWithSchema as Z, embedding as _, type AggregateResult as a, fieldRef as a0, getEmbeddingDimensions as a1, inSubquery as a2, isEmbeddingSchema as a3, isParameterRef as a4, notExists as a5, notInSubquery as a6, param as a7, type CreateEdgeInput as b, type CreateNodeInput as c, type Edge as d, type EdgeAccessor as e, type EdgeCollection as f, type EdgeGetOrCreateByEndpointsOptions as g, type EdgeGetOrCreateByEndpointsResult as h, type EmbeddingSchema as i, type EmbeddingValue as j, ExecutableAggregateQuery as k, ExecutableQuery as l, type NodeAccessor as m, type NodeAlias as n, type NodeCollection as o, type NodeGetOrCreateByConstraintOptions as p, type NodeGetOrCreateByConstraintResult as q, type NodeRef as r, type PaginatedResult as s, type Predicate as t, PreparedQuery as u, type PropsAccessor as v, type QueryHookContext as w, type QueryOptions as x, type SelectContext as y, type SelectableEdge as z };
1958
+ export { embedding as $, type AliasMap as A, type SelectableEdge as B, type CreateQueryBuilderOptions as C, type SelectableNode as D, type EdgeAliasMap as E, type FieldAccessor as F, type GetOrCreateAction as G, type HookContext as H, type IfExistsMode as I, type StoreHooks as J, type StoreOptions as K, type StreamOptions as L, type TransactionContext as M, type Node as N, type OperationHookContext as O, type PaginateOptions as P, QueryBuilder as Q, type RecursiveTraversalOptions as R, Store as S, TraversalBuilder as T, type TypedEdgeCollection as U, type TypedNodeRef as V, UnionableQuery as W, type UpdateEdgeInput as X, type UpdateNodeInput as Y, createStore as Z, createStoreWithSchema as _, type AggregateResult as a, exists as a0, fieldRef as a1, getEmbeddingDimensions as a2, inSubquery as a3, isEmbeddingSchema as a4, isParameterRef as a5, notExists as a6, notInSubquery as a7, param as a8, type CreateEdgeInput as b, type CreateNodeInput as c, type Edge as d, type EdgeAccessor as e, type EdgeCollection as f, type EdgeFindByEndpointsOptions as g, type EdgeGetOrCreateByEndpointsOptions as h, type EdgeGetOrCreateByEndpointsResult as i, type EmbeddingSchema as j, type EmbeddingValue as k, ExecutableAggregateQuery as l, ExecutableQuery as m, type NodeAccessor as n, type NodeAlias as o, type NodeCollection as p, type NodeGetOrCreateByConstraintOptions as q, type NodeGetOrCreateByConstraintResult as r, type NodeRef as s, type PaginatedResult as t, type Predicate as u, PreparedQuery as v, type PropsAccessor as w, type QueryHookContext as x, type QueryOptions as y, type SelectContext as z };
@@ -1,5 +1,5 @@
1
- import { k as SqlSchema, G as GraphBackend } from './types-BUy-pHKH.cjs';
2
- import { K as KindRegistry, G as GraphDef, b as SchemaManagerOptions, c as SchemaValidationResult } from './manager-0NysX4s6.cjs';
1
+ import { k as SqlSchema, G as GraphBackend } from './types-WX8V9dqn.cjs';
2
+ import { K as KindRegistry, G as GraphDef, b as SchemaManagerOptions, c as SchemaValidationResult } from './manager-DiPf-0GG.cjs';
3
3
  import { N as NodeType, A as AnyEdgeType, T as TemporalMode, E as EdgeType, b as EdgeRegistration, g as NodeId } from './types-DTJEu_-h.cjs';
4
4
  import { V as ValueType, i as PredicateExpression, k as VectorMetricType, Q as QueryAst, J as JsonPointer, F as FieldRef, P as ParameterRef, d as JsonPointerInput, T as TraversalExpansion, l as Traversal, N as NodePredicate, m as ProjectedField, O as OrderSpec, G as GroupBySpec, o as RecursiveCyclePolicy, q as TraversalDirection, A as AggregateExpr, r as SelectiveField, s as ComposableQuery, t as SetOperationType, u as SetOperation, S as SortDirection } from './ast-D-3bOanX.cjs';
5
5
  import { SQL } from 'drizzle-orm';
@@ -805,6 +805,18 @@ type EdgeGetOrCreateByEndpointsResult<E extends AnyEdgeType> = Readonly<{
805
805
  edge: Edge<E>;
806
806
  action: GetOrCreateAction;
807
807
  }>;
808
+ /**
809
+ * Options for edge findByEndpoints operations.
810
+ */
811
+ type EdgeFindByEndpointsOptions<E extends AnyEdgeType> = Readonly<{
812
+ /**
813
+ * Edge property fields to include in the match alongside the (from, to) endpoints.
814
+ * When omitted, matches on endpoints only (returns first live edge).
815
+ */
816
+ matchOn?: readonly (keyof z.input<E["schema"]>)[];
817
+ /** Property values to match against when matchOn is specified. */
818
+ props?: Partial<z.input<E["schema"]>>;
819
+ }>;
808
820
  /**
809
821
  * Options for edge getOrCreateByEndpoints operations.
810
822
  */
@@ -920,6 +932,25 @@ type NodeCollection<N extends NodeType> = Readonly<{
920
932
  * that don't exist.
921
933
  */
922
934
  bulkDelete: (ids: readonly NodeId<N>[]) => Promise<void>;
935
+ /**
936
+ * Find a node by uniqueness constraint.
937
+ *
938
+ * Looks up a live node by the named constraint key computed from `props`.
939
+ * Returns the node if found, or undefined. Soft-deleted nodes are excluded.
940
+ *
941
+ * @param constraintName - Name of the uniqueness constraint to match on
942
+ * @param props - Properties to compute the constraint key from
943
+ */
944
+ findByConstraint: (constraintName: string, props: z.input<N["schema"]>) => Promise<Node<N> | undefined>;
945
+ /**
946
+ * Batch version of findByConstraint.
947
+ *
948
+ * Results are returned in the same order as the input items.
949
+ * Returns undefined for entries that don't match.
950
+ */
951
+ bulkFindByConstraint: (constraintName: string, items: readonly Readonly<{
952
+ props: z.input<N["schema"]>;
953
+ }>[]) => Promise<(Node<N> | undefined)[]>;
923
954
  /**
924
955
  * Get an existing node by uniqueness constraint, or create a new one.
925
956
  *
@@ -1103,6 +1134,17 @@ type EdgeCollection<E extends AnyEdgeType, From extends NodeType = NodeType, To
1103
1134
  * that don't exist.
1104
1135
  */
1105
1136
  bulkDelete: (ids: readonly string[]) => Promise<void>;
1137
+ /**
1138
+ * Find a live edge by endpoints and optional property fields.
1139
+ *
1140
+ * Returns the first matching live edge, or undefined.
1141
+ * Soft-deleted edges are excluded.
1142
+ *
1143
+ * @param from - Source node
1144
+ * @param to - Target node
1145
+ * @param options - Match criteria (matchOn fields and property values)
1146
+ */
1147
+ findByEndpoints: (from: TypedNodeRef<From>, to: TypedNodeRef<To>, options?: EdgeFindByEndpointsOptions<E>) => Promise<Edge<E> | undefined>;
1106
1148
  /**
1107
1149
  * Get an existing edge by endpoints and optional property fields, or create a new one.
1108
1150
  *
@@ -1833,6 +1875,16 @@ declare class Store<G extends GraphDef> {
1833
1875
  * ```
1834
1876
  */
1835
1877
  transaction<T>(fn: (tx: TransactionContext<G>) => Promise<T>): Promise<T>;
1878
+ /**
1879
+ * Hard-deletes all data for this graph from the database.
1880
+ *
1881
+ * Removes all nodes, edges, uniqueness entries, embeddings, and schema versions
1882
+ * for this graph's ID. No hooks, no per-row logic. Wrapped in a transaction
1883
+ * when the backend supports it.
1884
+ *
1885
+ * The store is usable after clearing — new data can be created immediately.
1886
+ */
1887
+ clear(): Promise<void>;
1836
1888
  /**
1837
1889
  * Closes the store and releases underlying resources.
1838
1890
  *
@@ -1903,4 +1955,4 @@ declare function createStore<G extends GraphDef>(graph: G, backend: GraphBackend
1903
1955
  */
1904
1956
  declare function createStoreWithSchema<G extends GraphDef>(graph: G, backend: GraphBackend, options?: StoreOptions & SchemaManagerOptions): Promise<[Store<G>, SchemaValidationResult]>;
1905
1957
 
1906
- export { exists as $, type AliasMap as A, type SelectableNode as B, type CreateQueryBuilderOptions as C, type StoreHooks as D, type EdgeAliasMap as E, type FieldAccessor as F, type GetOrCreateAction as G, type HookContext as H, type IfExistsMode as I, type StoreOptions as J, type StreamOptions as K, type TransactionContext as L, type TypedEdgeCollection as M, type Node as N, type OperationHookContext as O, type PaginateOptions as P, QueryBuilder as Q, type RecursiveTraversalOptions as R, Store as S, TraversalBuilder as T, type TypedNodeRef as U, UnionableQuery as V, type UpdateEdgeInput as W, type UpdateNodeInput as X, createStore as Y, createStoreWithSchema as Z, embedding as _, type AggregateResult as a, fieldRef as a0, getEmbeddingDimensions as a1, inSubquery as a2, isEmbeddingSchema as a3, isParameterRef as a4, notExists as a5, notInSubquery as a6, param as a7, type CreateEdgeInput as b, type CreateNodeInput as c, type Edge as d, type EdgeAccessor as e, type EdgeCollection as f, type EdgeGetOrCreateByEndpointsOptions as g, type EdgeGetOrCreateByEndpointsResult as h, type EmbeddingSchema as i, type EmbeddingValue as j, ExecutableAggregateQuery as k, ExecutableQuery as l, type NodeAccessor as m, type NodeAlias as n, type NodeCollection as o, type NodeGetOrCreateByConstraintOptions as p, type NodeGetOrCreateByConstraintResult as q, type NodeRef as r, type PaginatedResult as s, type Predicate as t, PreparedQuery as u, type PropsAccessor as v, type QueryHookContext as w, type QueryOptions as x, type SelectContext as y, type SelectableEdge as z };
1958
+ export { embedding as $, type AliasMap as A, type SelectableEdge as B, type CreateQueryBuilderOptions as C, type SelectableNode as D, type EdgeAliasMap as E, type FieldAccessor as F, type GetOrCreateAction as G, type HookContext as H, type IfExistsMode as I, type StoreHooks as J, type StoreOptions as K, type StreamOptions as L, type TransactionContext as M, type Node as N, type OperationHookContext as O, type PaginateOptions as P, QueryBuilder as Q, type RecursiveTraversalOptions as R, Store as S, TraversalBuilder as T, type TypedEdgeCollection as U, type TypedNodeRef as V, UnionableQuery as W, type UpdateEdgeInput as X, type UpdateNodeInput as Y, createStore as Z, createStoreWithSchema as _, type AggregateResult as a, exists as a0, fieldRef as a1, getEmbeddingDimensions as a2, inSubquery as a3, isEmbeddingSchema as a4, isParameterRef as a5, notExists as a6, notInSubquery as a7, param as a8, type CreateEdgeInput as b, type CreateNodeInput as c, type Edge as d, type EdgeAccessor as e, type EdgeCollection as f, type EdgeFindByEndpointsOptions as g, type EdgeGetOrCreateByEndpointsOptions as h, type EdgeGetOrCreateByEndpointsResult as i, type EmbeddingSchema as j, type EmbeddingValue as k, ExecutableAggregateQuery as l, ExecutableQuery as m, type NodeAccessor as n, type NodeAlias as o, type NodeCollection as p, type NodeGetOrCreateByConstraintOptions as q, type NodeGetOrCreateByConstraintResult as r, type NodeRef as s, type PaginatedResult as t, type Predicate as u, PreparedQuery as v, type PropsAccessor as w, type QueryHookContext as x, type QueryOptions as y, type SelectContext as z };
@@ -583,6 +583,11 @@ type GraphBackend = Readonly<{
583
583
  vectorSearch?: (params: VectorSearchParams) => Promise<readonly VectorSearchResult[]>;
584
584
  createVectorIndex?: (params: CreateVectorIndexParams) => Promise<void>;
585
585
  dropVectorIndex?: (params: DropVectorIndexParams) => Promise<void>;
586
+ /**
587
+ * Hard-deletes all data for a graph (nodes, edges, uniques, embeddings, schema versions).
588
+ * Intended for import-replacement workflows. No hooks, no per-row logic.
589
+ */
590
+ clearGraph: (graphId: string) => Promise<void>;
586
591
  execute: <T>(query: SQL) => Promise<readonly T[]>;
587
592
  /** Execute pre-compiled SQL text with bound parameters. Available on sync SQLite and pg backends. */
588
593
  executeRaw?: <T>(sqlText: string, params: readonly unknown[]) => Promise<readonly T[]>;
@@ -583,6 +583,11 @@ type GraphBackend = Readonly<{
583
583
  vectorSearch?: (params: VectorSearchParams) => Promise<readonly VectorSearchResult[]>;
584
584
  createVectorIndex?: (params: CreateVectorIndexParams) => Promise<void>;
585
585
  dropVectorIndex?: (params: DropVectorIndexParams) => Promise<void>;
586
+ /**
587
+ * Hard-deletes all data for a graph (nodes, edges, uniques, embeddings, schema versions).
588
+ * Intended for import-replacement workflows. No hooks, no per-row logic.
589
+ */
590
+ clearGraph: (graphId: string) => Promise<void>;
586
591
  execute: <T>(query: SQL) => Promise<readonly T[]>;
587
592
  /** Execute pre-compiled SQL text with bound parameters. Available on sync SQLite and pg backends. */
588
593
  executeRaw?: <T>(sqlText: string, params: readonly unknown[]) => Promise<readonly T[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nicia-ai/typegraph",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "TypeScript-first embedded knowledge graph library with ontological reasoning",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",