@nicia-ai/typegraph 0.13.0 → 0.15.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/backend/postgres/index.cjs +34 -28
- package/dist/backend/postgres/index.cjs.map +1 -1
- package/dist/backend/postgres/index.d.cts +5 -5
- package/dist/backend/postgres/index.d.ts +5 -5
- package/dist/backend/postgres/index.js +16 -10
- package/dist/backend/postgres/index.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +14 -14
- package/dist/backend/sqlite/index.d.cts +5 -5
- package/dist/backend/sqlite/index.d.ts +5 -5
- package/dist/backend/sqlite/index.js +4 -4
- package/dist/backend/sqlite/local.cjs +7 -7
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +7 -7
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/{chunk-7VITUTRA.cjs → chunk-3HQLOKS5.cjs} +163 -13
- package/dist/chunk-3HQLOKS5.cjs.map +1 -0
- package/dist/{chunk-NZMKJHE2.cjs → chunk-56RQFK7U.cjs} +22 -15
- package/dist/chunk-56RQFK7U.cjs.map +1 -0
- package/dist/{chunk-U3452TEU.js → chunk-6GWJH6AR.js} +15 -27
- package/dist/chunk-6GWJH6AR.js.map +1 -0
- package/dist/{chunk-2XPKLHHH.cjs → chunk-CRMN2NOM.cjs} +247 -208
- package/dist/chunk-CRMN2NOM.cjs.map +1 -0
- package/dist/{chunk-54WJF3DW.js → chunk-GNIYZKBI.js} +29 -3
- package/dist/chunk-GNIYZKBI.js.map +1 -0
- package/dist/{chunk-52WSY6G5.js → chunk-HWWF3FOP.js} +158 -119
- package/dist/chunk-HWWF3FOP.js.map +1 -0
- package/dist/{chunk-PYV4ADC6.js → chunk-L4ON6RJF.js} +164 -14
- package/dist/chunk-L4ON6RJF.js.map +1 -0
- package/dist/{chunk-JQDWEX6V.cjs → chunk-LELLOHJK.cjs} +22 -34
- package/dist/chunk-LELLOHJK.cjs.map +1 -0
- package/dist/{chunk-2WVFEIHR.cjs → chunk-MME3H4ZF.cjs} +40 -2
- package/dist/chunk-MME3H4ZF.cjs.map +1 -0
- package/dist/{chunk-J4SICP3X.js → chunk-XZBAGJJH.js} +15 -8
- package/dist/chunk-XZBAGJJH.js.map +1 -0
- package/dist/{ddl-BJg93HDN.d.cts → ddl-BBo2EcFc.d.cts} +2 -2
- package/dist/{ddl-CsfWcl_B.d.ts → ddl-D4jlcOH_.d.ts} +2 -2
- package/dist/index.cjs +473 -625
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -9
- package/dist/index.d.ts +12 -9
- package/dist/index.js +434 -586
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +16 -16
- package/dist/indexes/index.d.cts +2 -2
- package/dist/indexes/index.d.ts +2 -2
- package/dist/indexes/index.js +2 -2
- package/dist/interchange/index.d.cts +3 -3
- package/dist/interchange/index.d.ts +3 -3
- package/dist/{manager-DGSnJa1v.d.cts → manager-Bj1UEnhE.d.cts} +2 -2
- package/dist/{manager-BCLhWysp.d.ts → manager-Chhrq1vl.d.ts} +2 -2
- package/dist/profiler/index.cjs +6 -6
- package/dist/profiler/index.cjs.map +1 -1
- package/dist/profiler/index.d.cts +3 -3
- package/dist/profiler/index.d.ts +3 -3
- package/dist/profiler/index.js +6 -6
- package/dist/profiler/index.js.map +1 -1
- package/dist/schema/index.cjs +20 -20
- package/dist/schema/index.d.cts +4 -4
- package/dist/schema/index.d.ts +4 -4
- package/dist/schema/index.js +2 -2
- package/dist/{sqlite-H01wIXvB.d.ts → sqlite-Blq-AhmK.d.ts} +1 -1
- package/dist/{sqlite-DVca_IIy.d.cts → sqlite-DE-6NWtC.d.cts} +1 -1
- package/dist/{store-Bmdt_dS6.d.cts → store-BNercm8P.d.cts} +86 -31
- package/dist/{store-6-vH0ZIj.d.ts → store-CD_0yf2s.d.ts} +86 -31
- package/dist/{types-GLkwvQvS.d.cts → types-B3mmOMJV.d.cts} +20 -6
- package/dist/{types-C8Ra3ROE.d.cts → types-CZd2PEOc.d.cts} +8 -2
- package/dist/{types-CC8eB0PB.d.ts → types-Ceb01czq.d.ts} +8 -2
- package/dist/{types-1YJKodRv.d.ts → types-ThB4cFLp.d.ts} +20 -6
- package/package.json +1 -1
- package/dist/chunk-2WVFEIHR.cjs.map +0 -1
- package/dist/chunk-2XPKLHHH.cjs.map +0 -1
- package/dist/chunk-52WSY6G5.js.map +0 -1
- package/dist/chunk-54WJF3DW.js.map +0 -1
- package/dist/chunk-7VITUTRA.cjs.map +0 -1
- package/dist/chunk-J4SICP3X.js.map +0 -1
- package/dist/chunk-JQDWEX6V.cjs.map +0 -1
- package/dist/chunk-NZMKJHE2.cjs.map +0 -1
- package/dist/chunk-PYV4ADC6.js.map +0 -1
- package/dist/chunk-U3452TEU.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SqlSchema, G as GraphBackend, T as TransactionBackend } from './types-
|
|
2
|
-
import { K as KindRegistry, G as GraphDef, E as EdgeKinds, N as NodeKinds, a as AllNodeTypes, S as SchemaManagerOptions,
|
|
1
|
+
import { S as SqlSchema, G as GraphBackend, T as TransactionBackend, E as EdgeRow, N as NodeRow } from './types-B3mmOMJV.cjs';
|
|
2
|
+
import { K as KindRegistry, G as GraphDef, E as EdgeKinds, N as NodeKinds, a as AllNodeTypes, S as SchemaManagerOptions, d as SchemaValidationResult } from './manager-Bj1UEnhE.cjs';
|
|
3
3
|
import { S as SqlDialect, N as NodeType, A as AnyEdgeType, T as TemporalMode, E as EdgeType, d as EdgeRegistration, b as EdgeId, g as NodeId, i as NodeRegistration } from './types-DMzKq0d5.cjs';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { V as ValueType, i as PredicateExpression, k as VectorMetricType, Q as QueryAst, J as JsonPointer, F as FieldRef, P as ParameterRef, c 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-Bh2NDeaK.cjs';
|
|
@@ -610,16 +610,40 @@ type CreateQueryBuilderOptions = Readonly<{
|
|
|
610
610
|
* Store types for TypeGraph operations.
|
|
611
611
|
*/
|
|
612
612
|
|
|
613
|
+
/**
|
|
614
|
+
* Canonical mapping from snake_case row fields to camelCase meta fields.
|
|
615
|
+
*
|
|
616
|
+
* This is the single source of truth for which row columns become metadata.
|
|
617
|
+
* Both the Meta types and the row-to-meta functions in row-mappers.ts must
|
|
618
|
+
* stay in sync with this mapping. If you add a temporal/audit column to a
|
|
619
|
+
* row type, add the mapping here — the compiler will then force you to
|
|
620
|
+
* update the row mapper functions as well (since their return type is
|
|
621
|
+
* NodeMeta/EdgeMeta, which is derived from this mapping).
|
|
622
|
+
*/
|
|
623
|
+
type TemporalMetaFieldMap = Readonly<{
|
|
624
|
+
valid_from: "validFrom";
|
|
625
|
+
valid_to: "validTo";
|
|
626
|
+
created_at: "createdAt";
|
|
627
|
+
updated_at: "updatedAt";
|
|
628
|
+
deleted_at: "deletedAt";
|
|
629
|
+
}>;
|
|
630
|
+
/**
|
|
631
|
+
* Maps row fields to their camelCase meta counterparts, preserving types.
|
|
632
|
+
*/
|
|
633
|
+
type MapRowToMeta<R extends Readonly<Record<string, unknown>>, M extends Readonly<Record<string, string>>> = Readonly<{
|
|
634
|
+
[SnakeKey in keyof M as M[SnakeKey] & string]: SnakeKey extends keyof R ? R[SnakeKey] : never;
|
|
635
|
+
}>;
|
|
613
636
|
/**
|
|
614
637
|
* Metadata for a node instance.
|
|
638
|
+
* Derived from NodeRow via TemporalMetaFieldMap + version.
|
|
639
|
+
*
|
|
640
|
+
* Adding a new metadata column requires:
|
|
641
|
+
* 1. Add the column to NodeRow in backend/types.ts
|
|
642
|
+
* 2. Add the mapping to TemporalMetaFieldMap above
|
|
643
|
+
* 3. The compiler will error in rowToNodeMeta() until you add the field there
|
|
615
644
|
*/
|
|
616
|
-
type NodeMeta = Readonly<{
|
|
617
|
-
version:
|
|
618
|
-
validFrom: string | undefined;
|
|
619
|
-
validTo: string | undefined;
|
|
620
|
-
createdAt: string;
|
|
621
|
-
updatedAt: string;
|
|
622
|
-
deletedAt: string | undefined;
|
|
645
|
+
type NodeMeta = MapRowToMeta<NodeRow, TemporalMetaFieldMap> & Readonly<{
|
|
646
|
+
version: NodeRow["version"];
|
|
623
647
|
}>;
|
|
624
648
|
/**
|
|
625
649
|
* A node instance in the graph.
|
|
@@ -654,14 +678,9 @@ type UpdateNodeInput<N extends NodeType = NodeType> = Readonly<{
|
|
|
654
678
|
}>;
|
|
655
679
|
/**
|
|
656
680
|
* Metadata for an edge instance.
|
|
681
|
+
* Derived from EdgeRow via TemporalMetaFieldMap (edges have no version).
|
|
657
682
|
*/
|
|
658
|
-
type EdgeMeta =
|
|
659
|
-
validFrom: string | undefined;
|
|
660
|
-
validTo: string | undefined;
|
|
661
|
-
createdAt: string;
|
|
662
|
-
updatedAt: string;
|
|
663
|
-
deletedAt: string | undefined;
|
|
664
|
-
}>;
|
|
683
|
+
type EdgeMeta = MapRowToMeta<EdgeRow, TemporalMetaFieldMap>;
|
|
665
684
|
/**
|
|
666
685
|
* An edge instance in the graph.
|
|
667
686
|
*
|
|
@@ -1247,6 +1266,14 @@ type EdgeToTypes<R extends EdgeRegistration> = R["to"] extends readonly (infer N
|
|
|
1247
1266
|
* Extracts the edge type and from/to node types automatically.
|
|
1248
1267
|
*/
|
|
1249
1268
|
type TypedEdgeCollection<R extends EdgeRegistration> = EdgeCollection<R["type"], EdgeFromTypes<R> extends NodeType ? EdgeFromTypes<R> : NodeType, EdgeToTypes<R> extends NodeType ? EdgeToTypes<R> : NodeType>;
|
|
1269
|
+
/** Mapped type of all node collections for a graph. */
|
|
1270
|
+
type GraphNodeCollections<G extends GraphDef> = {
|
|
1271
|
+
[K in keyof G["nodes"] & string]-?: NodeCollection<G["nodes"][K]["type"], ConstraintNames<G["nodes"][K]>>;
|
|
1272
|
+
};
|
|
1273
|
+
/** Mapped type of all edge collections for a graph. */
|
|
1274
|
+
type GraphEdgeCollections<G extends GraphDef> = {
|
|
1275
|
+
[K in keyof G["edges"] & string]-?: TypedEdgeCollection<G["edges"][K]>;
|
|
1276
|
+
};
|
|
1250
1277
|
/**
|
|
1251
1278
|
* A typed transaction context with collection API.
|
|
1252
1279
|
*
|
|
@@ -1258,20 +1285,50 @@ type TypedEdgeCollection<R extends EdgeRegistration> = EdgeCollection<R["type"],
|
|
|
1258
1285
|
* await store.transaction(async (tx) => {
|
|
1259
1286
|
* const person = await tx.nodes.Person.create({ name: "Alice" });
|
|
1260
1287
|
* const company = await tx.nodes.Company.create({ name: "Acme" });
|
|
1261
|
-
* // Pass nodes directly - their kind and id properties are used
|
|
1262
1288
|
* await tx.edges.worksAt.create(person, company, { role: "Engineer" });
|
|
1263
1289
|
* });
|
|
1264
1290
|
* ```
|
|
1265
1291
|
*/
|
|
1266
1292
|
type TransactionContext<G extends GraphDef> = Readonly<{
|
|
1267
|
-
|
|
1293
|
+
nodes: GraphNodeCollections<G>;
|
|
1294
|
+
edges: GraphEdgeCollections<G>;
|
|
1295
|
+
}>;
|
|
1296
|
+
/**
|
|
1297
|
+
* A type-level projection of a store's surface onto a subset of its
|
|
1298
|
+
* node and edge collections.
|
|
1299
|
+
*
|
|
1300
|
+
* Node collections are projected with constraint names erased (`never`),
|
|
1301
|
+
* so constraint-based methods like `findByConstraint` become uncallable.
|
|
1302
|
+
* This is intentional: unique constraints are graph-registration-level
|
|
1303
|
+
* details that differ between graphs sharing the same node types.
|
|
1304
|
+
*
|
|
1305
|
+
* @example
|
|
1306
|
+
* ```typescript
|
|
1307
|
+
* type CoreStore = StoreProjection<
|
|
1308
|
+
* typeof myGraph,
|
|
1309
|
+
* "Document" | "Chunk",
|
|
1310
|
+
* "hasChunk"
|
|
1311
|
+
* >;
|
|
1312
|
+
*
|
|
1313
|
+
* async function ingestChunk(
|
|
1314
|
+
* store: CoreStore,
|
|
1315
|
+
* document: Node<typeof Document>,
|
|
1316
|
+
* text: string,
|
|
1317
|
+
* ) {
|
|
1318
|
+
* const chunk = await store.nodes.Chunk.create({ text });
|
|
1319
|
+
* await store.edges.hasChunk.create(document, chunk);
|
|
1320
|
+
* return chunk;
|
|
1321
|
+
* }
|
|
1322
|
+
* ```
|
|
1323
|
+
*
|
|
1324
|
+
* Both `Store<G>` and `TransactionContext<G>` are structurally assignable
|
|
1325
|
+
* to a `StoreProjection` whose keys are a subset of `G`.
|
|
1326
|
+
*/
|
|
1327
|
+
type StoreProjection<G extends GraphDef, N extends keyof G["nodes"] & string = never, E extends keyof G["edges"] & string = never> = Readonly<{
|
|
1268
1328
|
nodes: {
|
|
1269
|
-
[K in
|
|
1270
|
-
};
|
|
1271
|
-
/** Edge collections for the transaction */
|
|
1272
|
-
edges: {
|
|
1273
|
-
[K in keyof G["edges"] & string]-?: TypedEdgeCollection<G["edges"][K]>;
|
|
1329
|
+
[K in N]-?: NodeCollection<G["nodes"][K]["type"], never>;
|
|
1274
1330
|
};
|
|
1331
|
+
edges: Pick<GraphEdgeCollections<G>, E>;
|
|
1275
1332
|
}>;
|
|
1276
1333
|
|
|
1277
1334
|
/**
|
|
@@ -1756,7 +1813,8 @@ declare class TraversalBuilder<G extends GraphDef, Aliases extends AliasMap, Edg
|
|
|
1756
1813
|
constructor(config: QueryBuilderConfig, state: QueryBuilderState, edgeKinds: readonly string[], edgeAlias: EA, direction: Dir, fromAlias: string, inverseEdgeKinds?: readonly string[], optional?: Optional, variableLength?: VariableLengthState, pendingEdgePredicates?: readonly NodePredicate[]);
|
|
1757
1814
|
/**
|
|
1758
1815
|
* Enables variable-length (recursive) traversal.
|
|
1759
|
-
*
|
|
1816
|
+
* Defaults to MAX_RECURSIVE_DEPTH (10) hops with cycle prevention.
|
|
1817
|
+
* Use `maxHops` to override (up to MAX_EXPLICIT_RECURSIVE_DEPTH).
|
|
1760
1818
|
*/
|
|
1761
1819
|
recursive<const O extends RecursiveTraversalOptions = Record<string, never>>(options?: O): TraversalBuilder<G, Aliases, EdgeAliases, EK, EA, Dir, Optional, O extends {
|
|
1762
1820
|
depth: infer D extends boolean | string;
|
|
@@ -2027,9 +2085,7 @@ declare class Store<G extends GraphDef> {
|
|
|
2027
2085
|
* const people = await store.nodes.Person.find({ limit: 10 });
|
|
2028
2086
|
* ```
|
|
2029
2087
|
*/
|
|
2030
|
-
get nodes():
|
|
2031
|
-
[K in keyof G["nodes"] & string]-?: NodeCollection<G["nodes"][K]["type"], ConstraintNames<G["nodes"][K]>>;
|
|
2032
|
-
};
|
|
2088
|
+
get nodes(): GraphNodeCollections<G>;
|
|
2033
2089
|
/**
|
|
2034
2090
|
* Edge collections for ergonomic CRUD operations.
|
|
2035
2091
|
*
|
|
@@ -2046,9 +2102,7 @@ declare class Store<G extends GraphDef> {
|
|
|
2046
2102
|
* const edges = await store.edges.worksAt.findFrom({ kind: "Person", id: person.id });
|
|
2047
2103
|
* ```
|
|
2048
2104
|
*/
|
|
2049
|
-
get edges():
|
|
2050
|
-
[K in keyof G["edges"] & string]-?: TypedEdgeCollection<G["edges"][K]>;
|
|
2051
|
-
};
|
|
2105
|
+
get edges(): GraphEdgeCollections<G>;
|
|
2052
2106
|
/**
|
|
2053
2107
|
* Creates a query builder for this store.
|
|
2054
2108
|
*
|
|
@@ -2196,6 +2250,7 @@ declare function createStore<G extends GraphDef>(graph: G, backend: GraphBackend
|
|
|
2196
2250
|
*
|
|
2197
2251
|
* This is the recommended way to create a store in production.
|
|
2198
2252
|
* It automatically:
|
|
2253
|
+
* - Creates base tables on a fresh database (if the backend supports bootstrapTables)
|
|
2199
2254
|
* - Initializes the schema on first run (version 1)
|
|
2200
2255
|
* - Auto-migrates safe changes (additive changes)
|
|
2201
2256
|
* - Throws MigrationError for breaking changes
|
|
@@ -2220,4 +2275,4 @@ declare function createStore<G extends GraphDef>(graph: G, backend: GraphBackend
|
|
|
2220
2275
|
*/
|
|
2221
2276
|
declare function createStoreWithSchema<G extends GraphDef>(graph: G, backend: GraphBackend, options?: StoreOptions & SchemaManagerOptions): Promise<[Store<G>, SchemaValidationResult]>;
|
|
2222
2277
|
|
|
2223
|
-
export { type
|
|
2278
|
+
export { type SubgraphOptions as $, type AliasMap as A, type BatchResults as B, type CreateQueryBuilderOptions as C, type Predicate as D, type EdgeAliasMap as E, type FieldAccessor as F, type GetOrCreateAction as G, type HookContext as H, type IfExistsMode as I, PreparedQuery as J, type PropsAccessor as K, type QueryHookContext as L, type QueryOptions as M, type Node as N, type OperationHookContext as O, type PaginateOptions as P, QueryBuilder as Q, type RecursiveTraversalOptions as R, type SelectContext as S, TraversalBuilder as T, type SelectableEdge as U, type SelectableNode as V, Store as W, type StoreHooks as X, type StoreOptions as Y, type StoreProjection as Z, type StreamOptions as _, type AggregateResult as a, type SubgraphResult as a0, type SubsetEdge as a1, type SubsetNode as a2, type TransactionContext as a3, type TypedEdgeCollection as a4, UnionableQuery as a5, type UpdateEdgeInput as a6, type UpdateNodeInput as a7, createStore as a8, createStoreWithSchema as a9, defineSubgraphProject as aa, embedding as ab, exists as ac, fieldRef as ad, getEmbeddingDimensions as ae, inSubquery as af, isEmbeddingSchema as ag, isParameterRef as ah, notExists as ai, notInSubquery as aj, param as ak, type AnyEdge as b, type AnyNode as c, type BatchableQuery as d, type ConstraintNames as e, type CreateEdgeInput as f, type CreateNodeInput as g, type Edge as h, type EdgeAccessor as i, type EdgeCollection as j, type EdgeFindByEndpointsOptions as k, type EdgeGetOrCreateByEndpointsOptions as l, type EdgeGetOrCreateByEndpointsResult as m, type EmbeddingSchema as n, type EmbeddingValue as o, ExecutableAggregateQuery as p, ExecutableQuery as q, type GraphEdgeCollections as r, type GraphNodeCollections as s, type NodeAccessor as t, type NodeAlias as u, type NodeCollection as v, type NodeGetOrCreateByConstraintOptions as w, type NodeGetOrCreateByConstraintResult as x, type NodeRef as y, type PaginatedResult as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SqlSchema, G as GraphBackend, T as TransactionBackend } from './types-
|
|
2
|
-
import { K as KindRegistry, G as GraphDef, E as EdgeKinds, N as NodeKinds, a as AllNodeTypes, S as SchemaManagerOptions,
|
|
1
|
+
import { S as SqlSchema, G as GraphBackend, T as TransactionBackend, E as EdgeRow, N as NodeRow } from './types-ThB4cFLp.js';
|
|
2
|
+
import { K as KindRegistry, G as GraphDef, E as EdgeKinds, N as NodeKinds, a as AllNodeTypes, S as SchemaManagerOptions, d as SchemaValidationResult } from './manager-Chhrq1vl.js';
|
|
3
3
|
import { S as SqlDialect, N as NodeType, A as AnyEdgeType, T as TemporalMode, E as EdgeType, d as EdgeRegistration, b as EdgeId, g as NodeId, i as NodeRegistration } from './types-DMzKq0d5.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { V as ValueType, i as PredicateExpression, k as VectorMetricType, Q as QueryAst, J as JsonPointer, F as FieldRef, P as ParameterRef, c 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-COMyNeMn.js';
|
|
@@ -610,16 +610,40 @@ type CreateQueryBuilderOptions = Readonly<{
|
|
|
610
610
|
* Store types for TypeGraph operations.
|
|
611
611
|
*/
|
|
612
612
|
|
|
613
|
+
/**
|
|
614
|
+
* Canonical mapping from snake_case row fields to camelCase meta fields.
|
|
615
|
+
*
|
|
616
|
+
* This is the single source of truth for which row columns become metadata.
|
|
617
|
+
* Both the Meta types and the row-to-meta functions in row-mappers.ts must
|
|
618
|
+
* stay in sync with this mapping. If you add a temporal/audit column to a
|
|
619
|
+
* row type, add the mapping here — the compiler will then force you to
|
|
620
|
+
* update the row mapper functions as well (since their return type is
|
|
621
|
+
* NodeMeta/EdgeMeta, which is derived from this mapping).
|
|
622
|
+
*/
|
|
623
|
+
type TemporalMetaFieldMap = Readonly<{
|
|
624
|
+
valid_from: "validFrom";
|
|
625
|
+
valid_to: "validTo";
|
|
626
|
+
created_at: "createdAt";
|
|
627
|
+
updated_at: "updatedAt";
|
|
628
|
+
deleted_at: "deletedAt";
|
|
629
|
+
}>;
|
|
630
|
+
/**
|
|
631
|
+
* Maps row fields to their camelCase meta counterparts, preserving types.
|
|
632
|
+
*/
|
|
633
|
+
type MapRowToMeta<R extends Readonly<Record<string, unknown>>, M extends Readonly<Record<string, string>>> = Readonly<{
|
|
634
|
+
[SnakeKey in keyof M as M[SnakeKey] & string]: SnakeKey extends keyof R ? R[SnakeKey] : never;
|
|
635
|
+
}>;
|
|
613
636
|
/**
|
|
614
637
|
* Metadata for a node instance.
|
|
638
|
+
* Derived from NodeRow via TemporalMetaFieldMap + version.
|
|
639
|
+
*
|
|
640
|
+
* Adding a new metadata column requires:
|
|
641
|
+
* 1. Add the column to NodeRow in backend/types.ts
|
|
642
|
+
* 2. Add the mapping to TemporalMetaFieldMap above
|
|
643
|
+
* 3. The compiler will error in rowToNodeMeta() until you add the field there
|
|
615
644
|
*/
|
|
616
|
-
type NodeMeta = Readonly<{
|
|
617
|
-
version:
|
|
618
|
-
validFrom: string | undefined;
|
|
619
|
-
validTo: string | undefined;
|
|
620
|
-
createdAt: string;
|
|
621
|
-
updatedAt: string;
|
|
622
|
-
deletedAt: string | undefined;
|
|
645
|
+
type NodeMeta = MapRowToMeta<NodeRow, TemporalMetaFieldMap> & Readonly<{
|
|
646
|
+
version: NodeRow["version"];
|
|
623
647
|
}>;
|
|
624
648
|
/**
|
|
625
649
|
* A node instance in the graph.
|
|
@@ -654,14 +678,9 @@ type UpdateNodeInput<N extends NodeType = NodeType> = Readonly<{
|
|
|
654
678
|
}>;
|
|
655
679
|
/**
|
|
656
680
|
* Metadata for an edge instance.
|
|
681
|
+
* Derived from EdgeRow via TemporalMetaFieldMap (edges have no version).
|
|
657
682
|
*/
|
|
658
|
-
type EdgeMeta =
|
|
659
|
-
validFrom: string | undefined;
|
|
660
|
-
validTo: string | undefined;
|
|
661
|
-
createdAt: string;
|
|
662
|
-
updatedAt: string;
|
|
663
|
-
deletedAt: string | undefined;
|
|
664
|
-
}>;
|
|
683
|
+
type EdgeMeta = MapRowToMeta<EdgeRow, TemporalMetaFieldMap>;
|
|
665
684
|
/**
|
|
666
685
|
* An edge instance in the graph.
|
|
667
686
|
*
|
|
@@ -1247,6 +1266,14 @@ type EdgeToTypes<R extends EdgeRegistration> = R["to"] extends readonly (infer N
|
|
|
1247
1266
|
* Extracts the edge type and from/to node types automatically.
|
|
1248
1267
|
*/
|
|
1249
1268
|
type TypedEdgeCollection<R extends EdgeRegistration> = EdgeCollection<R["type"], EdgeFromTypes<R> extends NodeType ? EdgeFromTypes<R> : NodeType, EdgeToTypes<R> extends NodeType ? EdgeToTypes<R> : NodeType>;
|
|
1269
|
+
/** Mapped type of all node collections for a graph. */
|
|
1270
|
+
type GraphNodeCollections<G extends GraphDef> = {
|
|
1271
|
+
[K in keyof G["nodes"] & string]-?: NodeCollection<G["nodes"][K]["type"], ConstraintNames<G["nodes"][K]>>;
|
|
1272
|
+
};
|
|
1273
|
+
/** Mapped type of all edge collections for a graph. */
|
|
1274
|
+
type GraphEdgeCollections<G extends GraphDef> = {
|
|
1275
|
+
[K in keyof G["edges"] & string]-?: TypedEdgeCollection<G["edges"][K]>;
|
|
1276
|
+
};
|
|
1250
1277
|
/**
|
|
1251
1278
|
* A typed transaction context with collection API.
|
|
1252
1279
|
*
|
|
@@ -1258,20 +1285,50 @@ type TypedEdgeCollection<R extends EdgeRegistration> = EdgeCollection<R["type"],
|
|
|
1258
1285
|
* await store.transaction(async (tx) => {
|
|
1259
1286
|
* const person = await tx.nodes.Person.create({ name: "Alice" });
|
|
1260
1287
|
* const company = await tx.nodes.Company.create({ name: "Acme" });
|
|
1261
|
-
* // Pass nodes directly - their kind and id properties are used
|
|
1262
1288
|
* await tx.edges.worksAt.create(person, company, { role: "Engineer" });
|
|
1263
1289
|
* });
|
|
1264
1290
|
* ```
|
|
1265
1291
|
*/
|
|
1266
1292
|
type TransactionContext<G extends GraphDef> = Readonly<{
|
|
1267
|
-
|
|
1293
|
+
nodes: GraphNodeCollections<G>;
|
|
1294
|
+
edges: GraphEdgeCollections<G>;
|
|
1295
|
+
}>;
|
|
1296
|
+
/**
|
|
1297
|
+
* A type-level projection of a store's surface onto a subset of its
|
|
1298
|
+
* node and edge collections.
|
|
1299
|
+
*
|
|
1300
|
+
* Node collections are projected with constraint names erased (`never`),
|
|
1301
|
+
* so constraint-based methods like `findByConstraint` become uncallable.
|
|
1302
|
+
* This is intentional: unique constraints are graph-registration-level
|
|
1303
|
+
* details that differ between graphs sharing the same node types.
|
|
1304
|
+
*
|
|
1305
|
+
* @example
|
|
1306
|
+
* ```typescript
|
|
1307
|
+
* type CoreStore = StoreProjection<
|
|
1308
|
+
* typeof myGraph,
|
|
1309
|
+
* "Document" | "Chunk",
|
|
1310
|
+
* "hasChunk"
|
|
1311
|
+
* >;
|
|
1312
|
+
*
|
|
1313
|
+
* async function ingestChunk(
|
|
1314
|
+
* store: CoreStore,
|
|
1315
|
+
* document: Node<typeof Document>,
|
|
1316
|
+
* text: string,
|
|
1317
|
+
* ) {
|
|
1318
|
+
* const chunk = await store.nodes.Chunk.create({ text });
|
|
1319
|
+
* await store.edges.hasChunk.create(document, chunk);
|
|
1320
|
+
* return chunk;
|
|
1321
|
+
* }
|
|
1322
|
+
* ```
|
|
1323
|
+
*
|
|
1324
|
+
* Both `Store<G>` and `TransactionContext<G>` are structurally assignable
|
|
1325
|
+
* to a `StoreProjection` whose keys are a subset of `G`.
|
|
1326
|
+
*/
|
|
1327
|
+
type StoreProjection<G extends GraphDef, N extends keyof G["nodes"] & string = never, E extends keyof G["edges"] & string = never> = Readonly<{
|
|
1268
1328
|
nodes: {
|
|
1269
|
-
[K in
|
|
1270
|
-
};
|
|
1271
|
-
/** Edge collections for the transaction */
|
|
1272
|
-
edges: {
|
|
1273
|
-
[K in keyof G["edges"] & string]-?: TypedEdgeCollection<G["edges"][K]>;
|
|
1329
|
+
[K in N]-?: NodeCollection<G["nodes"][K]["type"], never>;
|
|
1274
1330
|
};
|
|
1331
|
+
edges: Pick<GraphEdgeCollections<G>, E>;
|
|
1275
1332
|
}>;
|
|
1276
1333
|
|
|
1277
1334
|
/**
|
|
@@ -1756,7 +1813,8 @@ declare class TraversalBuilder<G extends GraphDef, Aliases extends AliasMap, Edg
|
|
|
1756
1813
|
constructor(config: QueryBuilderConfig, state: QueryBuilderState, edgeKinds: readonly string[], edgeAlias: EA, direction: Dir, fromAlias: string, inverseEdgeKinds?: readonly string[], optional?: Optional, variableLength?: VariableLengthState, pendingEdgePredicates?: readonly NodePredicate[]);
|
|
1757
1814
|
/**
|
|
1758
1815
|
* Enables variable-length (recursive) traversal.
|
|
1759
|
-
*
|
|
1816
|
+
* Defaults to MAX_RECURSIVE_DEPTH (10) hops with cycle prevention.
|
|
1817
|
+
* Use `maxHops` to override (up to MAX_EXPLICIT_RECURSIVE_DEPTH).
|
|
1760
1818
|
*/
|
|
1761
1819
|
recursive<const O extends RecursiveTraversalOptions = Record<string, never>>(options?: O): TraversalBuilder<G, Aliases, EdgeAliases, EK, EA, Dir, Optional, O extends {
|
|
1762
1820
|
depth: infer D extends boolean | string;
|
|
@@ -2027,9 +2085,7 @@ declare class Store<G extends GraphDef> {
|
|
|
2027
2085
|
* const people = await store.nodes.Person.find({ limit: 10 });
|
|
2028
2086
|
* ```
|
|
2029
2087
|
*/
|
|
2030
|
-
get nodes():
|
|
2031
|
-
[K in keyof G["nodes"] & string]-?: NodeCollection<G["nodes"][K]["type"], ConstraintNames<G["nodes"][K]>>;
|
|
2032
|
-
};
|
|
2088
|
+
get nodes(): GraphNodeCollections<G>;
|
|
2033
2089
|
/**
|
|
2034
2090
|
* Edge collections for ergonomic CRUD operations.
|
|
2035
2091
|
*
|
|
@@ -2046,9 +2102,7 @@ declare class Store<G extends GraphDef> {
|
|
|
2046
2102
|
* const edges = await store.edges.worksAt.findFrom({ kind: "Person", id: person.id });
|
|
2047
2103
|
* ```
|
|
2048
2104
|
*/
|
|
2049
|
-
get edges():
|
|
2050
|
-
[K in keyof G["edges"] & string]-?: TypedEdgeCollection<G["edges"][K]>;
|
|
2051
|
-
};
|
|
2105
|
+
get edges(): GraphEdgeCollections<G>;
|
|
2052
2106
|
/**
|
|
2053
2107
|
* Creates a query builder for this store.
|
|
2054
2108
|
*
|
|
@@ -2196,6 +2250,7 @@ declare function createStore<G extends GraphDef>(graph: G, backend: GraphBackend
|
|
|
2196
2250
|
*
|
|
2197
2251
|
* This is the recommended way to create a store in production.
|
|
2198
2252
|
* It automatically:
|
|
2253
|
+
* - Creates base tables on a fresh database (if the backend supports bootstrapTables)
|
|
2199
2254
|
* - Initializes the schema on first run (version 1)
|
|
2200
2255
|
* - Auto-migrates safe changes (additive changes)
|
|
2201
2256
|
* - Throws MigrationError for breaking changes
|
|
@@ -2220,4 +2275,4 @@ declare function createStore<G extends GraphDef>(graph: G, backend: GraphBackend
|
|
|
2220
2275
|
*/
|
|
2221
2276
|
declare function createStoreWithSchema<G extends GraphDef>(graph: G, backend: GraphBackend, options?: StoreOptions & SchemaManagerOptions): Promise<[Store<G>, SchemaValidationResult]>;
|
|
2222
2277
|
|
|
2223
|
-
export { type
|
|
2278
|
+
export { type SubgraphOptions as $, type AliasMap as A, type BatchResults as B, type CreateQueryBuilderOptions as C, type Predicate as D, type EdgeAliasMap as E, type FieldAccessor as F, type GetOrCreateAction as G, type HookContext as H, type IfExistsMode as I, PreparedQuery as J, type PropsAccessor as K, type QueryHookContext as L, type QueryOptions as M, type Node as N, type OperationHookContext as O, type PaginateOptions as P, QueryBuilder as Q, type RecursiveTraversalOptions as R, type SelectContext as S, TraversalBuilder as T, type SelectableEdge as U, type SelectableNode as V, Store as W, type StoreHooks as X, type StoreOptions as Y, type StoreProjection as Z, type StreamOptions as _, type AggregateResult as a, type SubgraphResult as a0, type SubsetEdge as a1, type SubsetNode as a2, type TransactionContext as a3, type TypedEdgeCollection as a4, UnionableQuery as a5, type UpdateEdgeInput as a6, type UpdateNodeInput as a7, createStore as a8, createStoreWithSchema as a9, defineSubgraphProject as aa, embedding as ab, exists as ac, fieldRef as ad, getEmbeddingDimensions as ae, inSubquery as af, isEmbeddingSchema as ag, isParameterRef as ah, notExists as ai, notInSubquery as aj, param as ak, type AnyEdge as b, type AnyNode as c, type BatchableQuery as d, type ConstraintNames as e, type CreateEdgeInput as f, type CreateNodeInput as g, type Edge as h, type EdgeAccessor as i, type EdgeCollection as j, type EdgeFindByEndpointsOptions as k, type EdgeGetOrCreateByEndpointsOptions as l, type EdgeGetOrCreateByEndpointsResult as m, type EmbeddingSchema as n, type EmbeddingValue as o, ExecutableAggregateQuery as p, ExecutableQuery as q, type GraphEdgeCollections as r, type GraphNodeCollections as s, type NodeAccessor as t, type NodeAlias as u, type NodeCollection as v, type NodeGetOrCreateByConstraintOptions as w, type NodeGetOrCreateByConstraintResult as x, type NodeRef as y, type PaginatedResult as z };
|
|
@@ -118,6 +118,9 @@ declare const DEFAULT_SQL_SCHEMA: SqlSchema;
|
|
|
118
118
|
*
|
|
119
119
|
* These types represent the JSON-serializable format used for
|
|
120
120
|
* homoiconic schema storage in the database.
|
|
121
|
+
*
|
|
122
|
+
* The Zod schema (serializedSchemaZod) is the single source of truth.
|
|
123
|
+
* The TypeScript type (SerializedSchema) is inferred from it.
|
|
121
124
|
*/
|
|
122
125
|
|
|
123
126
|
/**
|
|
@@ -229,7 +232,10 @@ type SerializedEdgeDef = Readonly<{
|
|
|
229
232
|
* Complete serialized schema document.
|
|
230
233
|
*
|
|
231
234
|
* This is the format stored in the schema_doc column of
|
|
232
|
-
* typegraph_schema_versions.
|
|
235
|
+
* typegraph_schema_versions. The type is kept explicit rather than
|
|
236
|
+
* inferred from the Zod schema so that downstream code sees the
|
|
237
|
+
* precise literal union types (DeleteBehavior, TemporalMode, etc.)
|
|
238
|
+
* instead of the broader `string` type that Zod's passthrough schema uses.
|
|
233
239
|
*/
|
|
234
240
|
type SerializedSchema = Readonly<{
|
|
235
241
|
graphId: string;
|
|
@@ -375,7 +381,7 @@ type InsertNodeParams = Readonly<{
|
|
|
375
381
|
graphId: string;
|
|
376
382
|
kind: string;
|
|
377
383
|
id: string;
|
|
378
|
-
props: Record<string, unknown
|
|
384
|
+
props: Readonly<Record<string, unknown>>;
|
|
379
385
|
validFrom?: string;
|
|
380
386
|
validTo?: string;
|
|
381
387
|
}>;
|
|
@@ -386,7 +392,7 @@ type UpdateNodeParams = Readonly<{
|
|
|
386
392
|
graphId: string;
|
|
387
393
|
kind: string;
|
|
388
394
|
id: string;
|
|
389
|
-
props: Record<string, unknown
|
|
395
|
+
props: Readonly<Record<string, unknown>>;
|
|
390
396
|
validTo?: string;
|
|
391
397
|
incrementVersion?: boolean;
|
|
392
398
|
/** If true, clears deleted_at (un-deletes the node). Used by upsert. */
|
|
@@ -411,7 +417,7 @@ type InsertEdgeParams = Readonly<{
|
|
|
411
417
|
fromId: string;
|
|
412
418
|
toKind: string;
|
|
413
419
|
toId: string;
|
|
414
|
-
props: Record<string, unknown
|
|
420
|
+
props: Readonly<Record<string, unknown>>;
|
|
415
421
|
validFrom?: string;
|
|
416
422
|
validTo?: string;
|
|
417
423
|
}>;
|
|
@@ -421,7 +427,7 @@ type InsertEdgeParams = Readonly<{
|
|
|
421
427
|
type UpdateEdgeParams = Readonly<{
|
|
422
428
|
graphId: string;
|
|
423
429
|
id: string;
|
|
424
|
-
props: Record<string, unknown
|
|
430
|
+
props: Readonly<Record<string, unknown>>;
|
|
425
431
|
validTo?: string;
|
|
426
432
|
clearDeleted?: boolean;
|
|
427
433
|
}>;
|
|
@@ -587,6 +593,14 @@ type GraphBackend = Readonly<{
|
|
|
587
593
|
* Intended for import-replacement workflows. No hooks, no per-row logic.
|
|
588
594
|
*/
|
|
589
595
|
clearGraph: (graphId: string) => Promise<void>;
|
|
596
|
+
/**
|
|
597
|
+
* Creates the base TypeGraph tables if they don't already exist.
|
|
598
|
+
*
|
|
599
|
+
* Called automatically by `createStoreWithSchema()` when a fresh database
|
|
600
|
+
* is detected. Users who manage DDL themselves via `createStore()` never
|
|
601
|
+
* hit this path.
|
|
602
|
+
*/
|
|
603
|
+
bootstrapTables?: () => Promise<void>;
|
|
590
604
|
execute: <T>(query: SQL) => Promise<readonly T[]>;
|
|
591
605
|
/** Execute pre-compiled SQL text with bound parameters. Available on sync SQLite and pg backends. */
|
|
592
606
|
executeRaw?: <T>(sqlText: string, params: readonly unknown[]) => Promise<readonly T[]>;
|
|
@@ -745,4 +759,4 @@ type CountEdgesByKindParams = Readonly<{
|
|
|
745
759
|
asOf?: string;
|
|
746
760
|
}>;
|
|
747
761
|
|
|
748
|
-
export { DEFAULT_SQL_SCHEMA as D, type GraphBackend as G, type InferenceType as I, type JsonSchema as J, type MetaEdge as M, type OntologyRelation as O, type SqlSchema as S, type TransactionBackend as T, type MetaEdgeProperties as a, type SqlTableNames as b, createSqlSchema as c, type SerializedNodeDef as d, type SerializedEdgeDef as e, type SerializedMetaEdge as f, type SerializedOntologyRelation as g, type SerializedClosures as h, isMetaEdge as i, type SerializedSchema as j, type SchemaHash as k, type SerializedOntology as l, type SerializedUniqueConstraint as m, type SchemaVersionRow as n };
|
|
762
|
+
export { DEFAULT_SQL_SCHEMA as D, type EdgeRow as E, type GraphBackend as G, type InferenceType as I, type JsonSchema as J, type MetaEdge as M, type NodeRow as N, type OntologyRelation as O, type SqlSchema as S, type TransactionBackend as T, type MetaEdgeProperties as a, type SqlTableNames as b, createSqlSchema as c, type SerializedNodeDef as d, type SerializedEdgeDef as e, type SerializedMetaEdge as f, type SerializedOntologyRelation as g, type SerializedClosures as h, isMetaEdge as i, type SerializedSchema as j, type SchemaHash as k, type SerializedOntology as l, type SerializedUniqueConstraint as m, type SchemaVersionRow as n };
|
|
@@ -99,7 +99,10 @@ type NonEmptyJsonPointerFor<T> = Exclude<JsonPointerFor<T>, "">;
|
|
|
99
99
|
type NonEmptyJsonPointerSegmentsFor<T> = Exclude<JsonPointerSegmentsFor<T>, readonly []>;
|
|
100
100
|
type IndexFieldInput<T> = (keyof T & string) | NonEmptyJsonPointerFor<T> | NonEmptyJsonPointerSegmentsFor<T> | JsonPointer;
|
|
101
101
|
type NodeIndexConfig<N extends NodeType> = Readonly<{
|
|
102
|
-
fields: readonly
|
|
102
|
+
fields: readonly [
|
|
103
|
+
IndexFieldInput<z.infer<N["schema"]>>,
|
|
104
|
+
...IndexFieldInput<z.infer<N["schema"]>>[]
|
|
105
|
+
];
|
|
103
106
|
coveringFields?: readonly IndexFieldInput<z.infer<N["schema"]>>[] | undefined;
|
|
104
107
|
unique?: boolean | undefined;
|
|
105
108
|
name?: string | undefined;
|
|
@@ -108,7 +111,10 @@ type NodeIndexConfig<N extends NodeType> = Readonly<{
|
|
|
108
111
|
}>;
|
|
109
112
|
type EdgeIndexDirection = "out" | "in" | "none";
|
|
110
113
|
type EdgeIndexConfig<E extends AnyEdgeType> = Readonly<{
|
|
111
|
-
fields: readonly
|
|
114
|
+
fields: readonly [
|
|
115
|
+
IndexFieldInput<z.infer<E["schema"]>>,
|
|
116
|
+
...IndexFieldInput<z.infer<E["schema"]>>[]
|
|
117
|
+
];
|
|
112
118
|
coveringFields?: readonly IndexFieldInput<z.infer<E["schema"]>>[] | undefined;
|
|
113
119
|
unique?: boolean | undefined;
|
|
114
120
|
name?: string | undefined;
|
|
@@ -99,7 +99,10 @@ type NonEmptyJsonPointerFor<T> = Exclude<JsonPointerFor<T>, "">;
|
|
|
99
99
|
type NonEmptyJsonPointerSegmentsFor<T> = Exclude<JsonPointerSegmentsFor<T>, readonly []>;
|
|
100
100
|
type IndexFieldInput<T> = (keyof T & string) | NonEmptyJsonPointerFor<T> | NonEmptyJsonPointerSegmentsFor<T> | JsonPointer;
|
|
101
101
|
type NodeIndexConfig<N extends NodeType> = Readonly<{
|
|
102
|
-
fields: readonly
|
|
102
|
+
fields: readonly [
|
|
103
|
+
IndexFieldInput<z.infer<N["schema"]>>,
|
|
104
|
+
...IndexFieldInput<z.infer<N["schema"]>>[]
|
|
105
|
+
];
|
|
103
106
|
coveringFields?: readonly IndexFieldInput<z.infer<N["schema"]>>[] | undefined;
|
|
104
107
|
unique?: boolean | undefined;
|
|
105
108
|
name?: string | undefined;
|
|
@@ -108,7 +111,10 @@ type NodeIndexConfig<N extends NodeType> = Readonly<{
|
|
|
108
111
|
}>;
|
|
109
112
|
type EdgeIndexDirection = "out" | "in" | "none";
|
|
110
113
|
type EdgeIndexConfig<E extends AnyEdgeType> = Readonly<{
|
|
111
|
-
fields: readonly
|
|
114
|
+
fields: readonly [
|
|
115
|
+
IndexFieldInput<z.infer<E["schema"]>>,
|
|
116
|
+
...IndexFieldInput<z.infer<E["schema"]>>[]
|
|
117
|
+
];
|
|
112
118
|
coveringFields?: readonly IndexFieldInput<z.infer<E["schema"]>>[] | undefined;
|
|
113
119
|
unique?: boolean | undefined;
|
|
114
120
|
name?: string | undefined;
|
|
@@ -118,6 +118,9 @@ declare const DEFAULT_SQL_SCHEMA: SqlSchema;
|
|
|
118
118
|
*
|
|
119
119
|
* These types represent the JSON-serializable format used for
|
|
120
120
|
* homoiconic schema storage in the database.
|
|
121
|
+
*
|
|
122
|
+
* The Zod schema (serializedSchemaZod) is the single source of truth.
|
|
123
|
+
* The TypeScript type (SerializedSchema) is inferred from it.
|
|
121
124
|
*/
|
|
122
125
|
|
|
123
126
|
/**
|
|
@@ -229,7 +232,10 @@ type SerializedEdgeDef = Readonly<{
|
|
|
229
232
|
* Complete serialized schema document.
|
|
230
233
|
*
|
|
231
234
|
* This is the format stored in the schema_doc column of
|
|
232
|
-
* typegraph_schema_versions.
|
|
235
|
+
* typegraph_schema_versions. The type is kept explicit rather than
|
|
236
|
+
* inferred from the Zod schema so that downstream code sees the
|
|
237
|
+
* precise literal union types (DeleteBehavior, TemporalMode, etc.)
|
|
238
|
+
* instead of the broader `string` type that Zod's passthrough schema uses.
|
|
233
239
|
*/
|
|
234
240
|
type SerializedSchema = Readonly<{
|
|
235
241
|
graphId: string;
|
|
@@ -375,7 +381,7 @@ type InsertNodeParams = Readonly<{
|
|
|
375
381
|
graphId: string;
|
|
376
382
|
kind: string;
|
|
377
383
|
id: string;
|
|
378
|
-
props: Record<string, unknown
|
|
384
|
+
props: Readonly<Record<string, unknown>>;
|
|
379
385
|
validFrom?: string;
|
|
380
386
|
validTo?: string;
|
|
381
387
|
}>;
|
|
@@ -386,7 +392,7 @@ type UpdateNodeParams = Readonly<{
|
|
|
386
392
|
graphId: string;
|
|
387
393
|
kind: string;
|
|
388
394
|
id: string;
|
|
389
|
-
props: Record<string, unknown
|
|
395
|
+
props: Readonly<Record<string, unknown>>;
|
|
390
396
|
validTo?: string;
|
|
391
397
|
incrementVersion?: boolean;
|
|
392
398
|
/** If true, clears deleted_at (un-deletes the node). Used by upsert. */
|
|
@@ -411,7 +417,7 @@ type InsertEdgeParams = Readonly<{
|
|
|
411
417
|
fromId: string;
|
|
412
418
|
toKind: string;
|
|
413
419
|
toId: string;
|
|
414
|
-
props: Record<string, unknown
|
|
420
|
+
props: Readonly<Record<string, unknown>>;
|
|
415
421
|
validFrom?: string;
|
|
416
422
|
validTo?: string;
|
|
417
423
|
}>;
|
|
@@ -421,7 +427,7 @@ type InsertEdgeParams = Readonly<{
|
|
|
421
427
|
type UpdateEdgeParams = Readonly<{
|
|
422
428
|
graphId: string;
|
|
423
429
|
id: string;
|
|
424
|
-
props: Record<string, unknown
|
|
430
|
+
props: Readonly<Record<string, unknown>>;
|
|
425
431
|
validTo?: string;
|
|
426
432
|
clearDeleted?: boolean;
|
|
427
433
|
}>;
|
|
@@ -587,6 +593,14 @@ type GraphBackend = Readonly<{
|
|
|
587
593
|
* Intended for import-replacement workflows. No hooks, no per-row logic.
|
|
588
594
|
*/
|
|
589
595
|
clearGraph: (graphId: string) => Promise<void>;
|
|
596
|
+
/**
|
|
597
|
+
* Creates the base TypeGraph tables if they don't already exist.
|
|
598
|
+
*
|
|
599
|
+
* Called automatically by `createStoreWithSchema()` when a fresh database
|
|
600
|
+
* is detected. Users who manage DDL themselves via `createStore()` never
|
|
601
|
+
* hit this path.
|
|
602
|
+
*/
|
|
603
|
+
bootstrapTables?: () => Promise<void>;
|
|
590
604
|
execute: <T>(query: SQL) => Promise<readonly T[]>;
|
|
591
605
|
/** Execute pre-compiled SQL text with bound parameters. Available on sync SQLite and pg backends. */
|
|
592
606
|
executeRaw?: <T>(sqlText: string, params: readonly unknown[]) => Promise<readonly T[]>;
|
|
@@ -745,4 +759,4 @@ type CountEdgesByKindParams = Readonly<{
|
|
|
745
759
|
asOf?: string;
|
|
746
760
|
}>;
|
|
747
761
|
|
|
748
|
-
export { DEFAULT_SQL_SCHEMA as D, type GraphBackend as G, type InferenceType as I, type JsonSchema as J, type MetaEdge as M, type OntologyRelation as O, type SqlSchema as S, type TransactionBackend as T, type MetaEdgeProperties as a, type SqlTableNames as b, createSqlSchema as c, type SerializedNodeDef as d, type SerializedEdgeDef as e, type SerializedMetaEdge as f, type SerializedOntologyRelation as g, type SerializedClosures as h, isMetaEdge as i, type SerializedSchema as j, type SchemaHash as k, type SerializedOntology as l, type SerializedUniqueConstraint as m, type SchemaVersionRow as n };
|
|
762
|
+
export { DEFAULT_SQL_SCHEMA as D, type EdgeRow as E, type GraphBackend as G, type InferenceType as I, type JsonSchema as J, type MetaEdge as M, type NodeRow as N, type OntologyRelation as O, type SqlSchema as S, type TransactionBackend as T, type MetaEdgeProperties as a, type SqlTableNames as b, createSqlSchema as c, type SerializedNodeDef as d, type SerializedEdgeDef as e, type SerializedMetaEdge as f, type SerializedOntologyRelation as g, type SerializedClosures as h, isMetaEdge as i, type SerializedSchema as j, type SchemaHash as k, type SerializedOntology as l, type SerializedUniqueConstraint as m, type SchemaVersionRow as n };
|