@nicia-ai/typegraph 0.2.0 → 0.3.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 +23 -0
- package/dist/{ast-BVyihVbP.d.cts → ast-CXFx6bF6.d.ts} +45 -165
- package/dist/{ast-BVyihVbP.d.ts → ast-D-3bOanX.d.cts} +45 -165
- package/dist/backend/drizzle/index.cjs +20 -20
- package/dist/backend/drizzle/index.d.cts +6 -5
- package/dist/backend/drizzle/index.d.ts +6 -5
- package/dist/backend/drizzle/index.js +8 -8
- package/dist/backend/drizzle/postgres.cjs +9 -9
- package/dist/backend/drizzle/postgres.d.cts +9 -11
- package/dist/backend/drizzle/postgres.d.ts +9 -11
- package/dist/backend/drizzle/postgres.js +6 -6
- package/dist/backend/drizzle/schema/postgres.cjs +10 -10
- package/dist/backend/drizzle/schema/postgres.d.cts +6 -5
- package/dist/backend/drizzle/schema/postgres.d.ts +6 -5
- package/dist/backend/drizzle/schema/postgres.js +3 -3
- package/dist/backend/drizzle/schema/sqlite.cjs +10 -10
- package/dist/backend/drizzle/schema/sqlite.d.cts +6 -5
- package/dist/backend/drizzle/schema/sqlite.d.ts +6 -5
- package/dist/backend/drizzle/schema/sqlite.js +3 -3
- package/dist/backend/drizzle/sqlite.cjs +9 -9
- package/dist/backend/drizzle/sqlite.d.cts +17 -18
- package/dist/backend/drizzle/sqlite.d.ts +17 -18
- package/dist/backend/drizzle/sqlite.js +6 -6
- package/dist/backend/postgres/index.cjs +21 -17
- package/dist/backend/postgres/index.d.cts +8 -7
- package/dist/backend/postgres/index.d.ts +8 -7
- package/dist/backend/postgres/index.js +8 -8
- package/dist/backend/sqlite/index.cjs +27 -21
- package/dist/backend/sqlite/index.cjs.map +1 -1
- package/dist/backend/sqlite/index.d.cts +7 -6
- package/dist/backend/sqlite/index.d.ts +7 -6
- package/dist/backend/sqlite/index.js +18 -12
- package/dist/backend/sqlite/index.js.map +1 -1
- package/dist/{chunk-YM5AL65Y.cjs → chunk-2WVFEIHR.cjs} +29 -3
- package/dist/chunk-2WVFEIHR.cjs.map +1 -0
- package/dist/{chunk-4PIEL2VO.js → chunk-3PURVEA4.js} +36 -5
- package/dist/chunk-3PURVEA4.js.map +1 -0
- package/dist/chunk-4HARSV2G.js +1448 -0
- package/dist/chunk-4HARSV2G.js.map +1 -0
- package/dist/{chunk-IIAT36MI.js → chunk-54WJF3DW.js} +29 -3
- package/dist/chunk-54WJF3DW.js.map +1 -0
- package/dist/chunk-CMHFS34N.cjs +390 -0
- package/dist/chunk-CMHFS34N.cjs.map +1 -0
- package/dist/chunk-DD6ONEBN.cjs +1264 -0
- package/dist/chunk-DD6ONEBN.cjs.map +1 -0
- package/dist/chunk-F2BZSEFE.js +388 -0
- package/dist/chunk-F2BZSEFE.js.map +1 -0
- package/dist/{chunk-DDM2FZRJ.cjs → chunk-JQDWEX6V.cjs} +24 -24
- package/dist/{chunk-DDM2FZRJ.cjs.map → chunk-JQDWEX6V.cjs.map} +1 -1
- package/dist/chunk-NP4G4ZKM.js +1228 -0
- package/dist/chunk-NP4G4ZKM.js.map +1 -0
- package/dist/{chunk-UJAGXJDG.cjs → chunk-NU2XNMVI.cjs} +38 -7
- package/dist/chunk-NU2XNMVI.cjs.map +1 -0
- package/dist/{chunk-JKTO7TW3.js → chunk-O5XPCJLF.js} +25 -3
- package/dist/chunk-O5XPCJLF.js.map +1 -0
- package/dist/{chunk-2QHQ2C4P.js → chunk-OGGLFYFA.js} +36 -5
- package/dist/chunk-OGGLFYFA.js.map +1 -0
- package/dist/{chunk-SV5H3XM5.cjs → chunk-OYL2SGBD.cjs} +26 -2
- package/dist/chunk-OYL2SGBD.cjs.map +1 -0
- package/dist/chunk-SFY2PPOY.cjs +1469 -0
- package/dist/chunk-SFY2PPOY.cjs.map +1 -0
- package/dist/{chunk-JDAET5LO.js → chunk-SMLIWLS7.js} +9 -9
- package/dist/chunk-SMLIWLS7.js.map +1 -0
- package/dist/{chunk-VXRVGFCI.js → chunk-U3452TEU.js} +17 -17
- package/dist/{chunk-VXRVGFCI.js.map → chunk-U3452TEU.js.map} +1 -1
- package/dist/{chunk-MNO33ASC.cjs → chunk-UYMT4LO2.cjs} +9 -8
- package/dist/chunk-UYMT4LO2.cjs.map +1 -0
- package/dist/chunk-V7CS2MDB.cjs +289 -0
- package/dist/chunk-V7CS2MDB.cjs.map +1 -0
- package/dist/chunk-WE5BKYNB.js +287 -0
- package/dist/chunk-WE5BKYNB.js.map +1 -0
- package/dist/{chunk-L642L24T.js → chunk-XDTYTNYL.js} +14 -21
- package/dist/chunk-XDTYTNYL.js.map +1 -0
- package/dist/{chunk-N4AOJ3VF.cjs → chunk-XZL6MCZJ.cjs} +38 -7
- package/dist/chunk-XZL6MCZJ.cjs.map +1 -0
- package/dist/{chunk-DBFCKELK.cjs → chunk-ZJHQZZT2.cjs} +18 -27
- package/dist/chunk-ZJHQZZT2.cjs.map +1 -0
- package/dist/index-Dkicw49A.d.cts +373 -0
- package/dist/index-Dkicw49A.d.ts +373 -0
- package/dist/index.cjs +5915 -3377
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -664
- package/dist/index.d.ts +24 -664
- package/dist/index.js +5781 -3223
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +16 -16
- package/dist/indexes/index.d.cts +5 -4
- package/dist/indexes/index.d.ts +5 -4
- package/dist/indexes/index.js +2 -2
- package/dist/interchange/index.cjs +9 -9
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +5 -3
- package/dist/interchange/index.d.ts +5 -3
- package/dist/interchange/index.js +8 -8
- package/dist/interchange/index.js.map +1 -1
- package/dist/manager-Jc5Btay9.d.cts +493 -0
- package/dist/manager-e9LXthrx.d.ts +493 -0
- package/dist/profiler/index.cjs +2 -8
- package/dist/profiler/index.cjs.map +1 -1
- package/dist/profiler/index.d.cts +9 -161
- package/dist/profiler/index.d.ts +9 -161
- package/dist/profiler/index.js +4 -4
- package/dist/profiler/index.js.map +1 -1
- package/dist/schema/index.cjs +145 -0
- package/dist/schema/index.cjs.map +1 -0
- package/dist/schema/index.d.cts +237 -0
- package/dist/schema/index.d.ts +237 -0
- package/dist/schema/index.js +72 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/{store-BPhjw5S8.d.ts → store-DM3Tk3Pw.d.ts} +874 -1283
- package/dist/{store-DNOOQEm8.d.cts → store-nbBybLWP.d.cts} +874 -1283
- package/dist/{test-helpers-BjyRYJZX.d.ts → test-helpers-CIq1Hhj1.d.ts} +5 -1
- package/dist/{test-helpers-NoQXhleQ.d.cts → test-helpers-DPRFVky4.d.cts} +5 -1
- package/dist/{types-D_3mEv2y.d.ts → types-BL1GyVku.d.cts} +2 -2
- package/dist/{types-DsRfx0yk.d.ts → types-Cdbi4hcx.d.ts} +228 -4
- package/dist/{types-BrSfFSpW.d.cts → types-DCGa53O2.d.ts} +2 -2
- package/dist/{types-aapj0GLz.d.cts → types-DDP0MGBF.d.cts} +228 -4
- package/dist/{types-CX4cLd7M.d.ts → types-DHRsi6j9.d.cts} +4 -3
- package/dist/types-DTJEu_-h.d.cts +158 -0
- package/dist/types-DTJEu_-h.d.ts +158 -0
- package/dist/{types-a5rAxC92.d.cts → types-ZT5mlism.d.ts} +4 -3
- package/package.json +17 -2
- package/dist/chunk-2FURVVAX.cjs +0 -350
- package/dist/chunk-2FURVVAX.cjs.map +0 -1
- package/dist/chunk-2QHQ2C4P.js.map +0 -1
- package/dist/chunk-4PIEL2VO.js.map +0 -1
- package/dist/chunk-DBFCKELK.cjs.map +0 -1
- package/dist/chunk-H7THXVH6.cjs +0 -314
- package/dist/chunk-H7THXVH6.cjs.map +0 -1
- package/dist/chunk-HXAPXPZH.cjs +0 -680
- package/dist/chunk-HXAPXPZH.cjs.map +0 -1
- package/dist/chunk-IIAT36MI.js.map +0 -1
- package/dist/chunk-JDAET5LO.js.map +0 -1
- package/dist/chunk-JKTO7TW3.js.map +0 -1
- package/dist/chunk-L642L24T.js.map +0 -1
- package/dist/chunk-MNO33ASC.cjs.map +0 -1
- package/dist/chunk-N4AOJ3VF.cjs.map +0 -1
- package/dist/chunk-QB3WBMDT.js +0 -646
- package/dist/chunk-QB3WBMDT.js.map +0 -1
- package/dist/chunk-SV5H3XM5.cjs.map +0 -1
- package/dist/chunk-UJAGXJDG.cjs.map +0 -1
- package/dist/chunk-X4EVMBON.js +0 -312
- package/dist/chunk-X4EVMBON.js.map +0 -1
- package/dist/chunk-XZL4NLV6.js +0 -348
- package/dist/chunk-XZL4NLV6.js.map +0 -1
- package/dist/chunk-YM5AL65Y.cjs.map +0 -1
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
import { SQL } from 'drizzle-orm';
|
|
2
|
+
import { N as NodeType, E as EdgeType, U as UniquenessScope, C as Collation, D as DeleteBehavior, d as Cardinality, e as EndpointExistence, T as TemporalMode } from './types-DTJEu_-h.cjs';
|
|
2
3
|
import { S as SqlDialect } from './types-BRzHlhKC.cjs';
|
|
3
4
|
|
|
5
|
+
/** Brand key for MetaEdge */
|
|
6
|
+
declare const META_EDGE_BRAND: "__metaEdge";
|
|
7
|
+
/**
|
|
8
|
+
* How a meta-edge affects queries and validation.
|
|
9
|
+
*/
|
|
10
|
+
type InferenceType = "subsumption" | "hierarchy" | "substitution" | "constraint" | "composition" | "association" | "none";
|
|
11
|
+
/**
|
|
12
|
+
* Properties of a meta-edge.
|
|
13
|
+
*/
|
|
14
|
+
type MetaEdgeProperties = Readonly<{
|
|
15
|
+
transitive: boolean;
|
|
16
|
+
symmetric: boolean;
|
|
17
|
+
reflexive: boolean;
|
|
18
|
+
inverse: string | undefined;
|
|
19
|
+
inference: InferenceType;
|
|
20
|
+
description: string | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* A meta-edge definition.
|
|
24
|
+
*
|
|
25
|
+
* Meta-edges represent type-level relationships (between kinds),
|
|
26
|
+
* not instance-level relationships (between nodes).
|
|
27
|
+
*/
|
|
28
|
+
type MetaEdge<K extends string = string> = Readonly<{
|
|
29
|
+
[META_EDGE_BRAND]: true;
|
|
30
|
+
name: K;
|
|
31
|
+
properties: MetaEdgeProperties;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* A relation in the ontology (instance of meta-edge between types).
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // Podcast subClassOf Media
|
|
39
|
+
* subClassOf(Podcast, Media)
|
|
40
|
+
*
|
|
41
|
+
* // Person equivalentTo schema:Person
|
|
42
|
+
* equivalentTo(Person, "https://schema.org/Person")
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
type OntologyRelation = Readonly<{
|
|
46
|
+
metaEdge: MetaEdge;
|
|
47
|
+
from: NodeType | EdgeType | string;
|
|
48
|
+
to: NodeType | EdgeType | string;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Checks if a value is a MetaEdge.
|
|
52
|
+
*/
|
|
53
|
+
declare function isMetaEdge(value: unknown): value is MetaEdge;
|
|
54
|
+
|
|
4
55
|
/**
|
|
5
56
|
* SQL Schema Configuration for Query Compilation
|
|
6
57
|
*
|
|
@@ -63,6 +114,144 @@ declare function createSqlSchema(names?: Partial<SqlTableNames>): SqlSchema;
|
|
|
63
114
|
*/
|
|
64
115
|
declare const DEFAULT_SQL_SCHEMA: SqlSchema;
|
|
65
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Types for serialized schema storage.
|
|
119
|
+
*
|
|
120
|
+
* These types represent the JSON-serializable format used for
|
|
121
|
+
* homoiconic schema storage in the database.
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* JSON Schema type (subset used by Zod toJSONSchema).
|
|
126
|
+
*
|
|
127
|
+
* This is a simplified version - the actual JSON Schema has many more properties.
|
|
128
|
+
*/
|
|
129
|
+
type JsonSchema = Readonly<{
|
|
130
|
+
$schema?: string;
|
|
131
|
+
type?: string | readonly string[];
|
|
132
|
+
properties?: Record<string, JsonSchema>;
|
|
133
|
+
required?: readonly string[];
|
|
134
|
+
items?: JsonSchema;
|
|
135
|
+
additionalProperties?: boolean | JsonSchema;
|
|
136
|
+
enum?: readonly unknown[];
|
|
137
|
+
const?: unknown;
|
|
138
|
+
anyOf?: readonly JsonSchema[];
|
|
139
|
+
oneOf?: readonly JsonSchema[];
|
|
140
|
+
allOf?: readonly JsonSchema[];
|
|
141
|
+
not?: JsonSchema;
|
|
142
|
+
description?: string;
|
|
143
|
+
default?: unknown;
|
|
144
|
+
minimum?: number;
|
|
145
|
+
maximum?: number;
|
|
146
|
+
minLength?: number;
|
|
147
|
+
maxLength?: number;
|
|
148
|
+
pattern?: string;
|
|
149
|
+
format?: string;
|
|
150
|
+
[key: string]: unknown;
|
|
151
|
+
}>;
|
|
152
|
+
/**
|
|
153
|
+
* Serialized representation of a meta-edge.
|
|
154
|
+
*/
|
|
155
|
+
type SerializedMetaEdge = Readonly<{
|
|
156
|
+
name: string;
|
|
157
|
+
transitive: boolean;
|
|
158
|
+
symmetric: boolean;
|
|
159
|
+
reflexive: boolean;
|
|
160
|
+
inverse: string | undefined;
|
|
161
|
+
inference: InferenceType;
|
|
162
|
+
description: string | undefined;
|
|
163
|
+
}>;
|
|
164
|
+
/**
|
|
165
|
+
* Serialized representation of an ontology relation.
|
|
166
|
+
*/
|
|
167
|
+
type SerializedOntologyRelation = Readonly<{
|
|
168
|
+
metaEdge: string;
|
|
169
|
+
from: string;
|
|
170
|
+
to: string;
|
|
171
|
+
}>;
|
|
172
|
+
/**
|
|
173
|
+
* Precomputed closures stored in the schema for fast runtime lookup.
|
|
174
|
+
*/
|
|
175
|
+
type SerializedClosures = Readonly<{
|
|
176
|
+
subClassAncestors: Record<string, readonly string[]>;
|
|
177
|
+
subClassDescendants: Record<string, readonly string[]>;
|
|
178
|
+
broaderClosure: Record<string, readonly string[]>;
|
|
179
|
+
narrowerClosure: Record<string, readonly string[]>;
|
|
180
|
+
equivalenceSets: Record<string, readonly string[]>;
|
|
181
|
+
disjointPairs: readonly string[];
|
|
182
|
+
partOfClosure: Record<string, readonly string[]>;
|
|
183
|
+
hasPartClosure: Record<string, readonly string[]>;
|
|
184
|
+
iriToKind: Record<string, string>;
|
|
185
|
+
edgeInverses: Record<string, string>;
|
|
186
|
+
edgeImplicationsClosure: Record<string, readonly string[]>;
|
|
187
|
+
edgeImplyingClosure: Record<string, readonly string[]>;
|
|
188
|
+
}>;
|
|
189
|
+
/**
|
|
190
|
+
* Complete serialized ontology section.
|
|
191
|
+
*/
|
|
192
|
+
type SerializedOntology = Readonly<{
|
|
193
|
+
metaEdges: Record<string, SerializedMetaEdge>;
|
|
194
|
+
relations: readonly SerializedOntologyRelation[];
|
|
195
|
+
closures: SerializedClosures;
|
|
196
|
+
}>;
|
|
197
|
+
/**
|
|
198
|
+
* Serialized representation of a uniqueness constraint.
|
|
199
|
+
*/
|
|
200
|
+
type SerializedUniqueConstraint = Readonly<{
|
|
201
|
+
name: string;
|
|
202
|
+
fields: readonly string[];
|
|
203
|
+
where: string | undefined;
|
|
204
|
+
scope: UniquenessScope;
|
|
205
|
+
collation: Collation;
|
|
206
|
+
}>;
|
|
207
|
+
/**
|
|
208
|
+
* Serialized representation of a node kind.
|
|
209
|
+
*/
|
|
210
|
+
type SerializedNodeDef = Readonly<{
|
|
211
|
+
kind: string;
|
|
212
|
+
properties: JsonSchema;
|
|
213
|
+
uniqueConstraints: readonly SerializedUniqueConstraint[];
|
|
214
|
+
onDelete: DeleteBehavior;
|
|
215
|
+
description: string | undefined;
|
|
216
|
+
}>;
|
|
217
|
+
/**
|
|
218
|
+
* Serialized representation of an edge kind.
|
|
219
|
+
*/
|
|
220
|
+
type SerializedEdgeDef = Readonly<{
|
|
221
|
+
kind: string;
|
|
222
|
+
fromKinds: readonly string[];
|
|
223
|
+
toKinds: readonly string[];
|
|
224
|
+
properties: JsonSchema;
|
|
225
|
+
cardinality: Cardinality;
|
|
226
|
+
endpointExistence: EndpointExistence;
|
|
227
|
+
description: string | undefined;
|
|
228
|
+
}>;
|
|
229
|
+
/**
|
|
230
|
+
* Complete serialized schema document.
|
|
231
|
+
*
|
|
232
|
+
* This is the format stored in the schema_doc column of
|
|
233
|
+
* typegraph_schema_versions.
|
|
234
|
+
*/
|
|
235
|
+
type SerializedSchema = Readonly<{
|
|
236
|
+
graphId: string;
|
|
237
|
+
version: number;
|
|
238
|
+
generatedAt: string;
|
|
239
|
+
nodes: Record<string, SerializedNodeDef>;
|
|
240
|
+
edges: Record<string, SerializedEdgeDef>;
|
|
241
|
+
ontology: SerializedOntology;
|
|
242
|
+
defaults: Readonly<{
|
|
243
|
+
onNodeDelete: DeleteBehavior;
|
|
244
|
+
temporalMode: TemporalMode;
|
|
245
|
+
}>;
|
|
246
|
+
}>;
|
|
247
|
+
/**
|
|
248
|
+
* A schema hash for detecting changes.
|
|
249
|
+
*
|
|
250
|
+
* We hash the schema content (excluding version and generatedAt)
|
|
251
|
+
* to detect if the schema has actually changed.
|
|
252
|
+
*/
|
|
253
|
+
type SchemaHash = string;
|
|
254
|
+
|
|
66
255
|
/**
|
|
67
256
|
* Backend interface types for TypeGraph storage.
|
|
68
257
|
*
|
|
@@ -92,7 +281,6 @@ type VectorCapabilities = Readonly<{
|
|
|
92
281
|
maxDimensions: number;
|
|
93
282
|
}>;
|
|
94
283
|
|
|
95
|
-
type Dialect = SqlDialect;
|
|
96
284
|
/**
|
|
97
285
|
* Backend capabilities that vary by dialect.
|
|
98
286
|
*/
|
|
@@ -236,6 +424,7 @@ type UpdateEdgeParams = Readonly<{
|
|
|
236
424
|
id: string;
|
|
237
425
|
props: Record<string, unknown>;
|
|
238
426
|
validTo?: string;
|
|
427
|
+
clearDeleted?: boolean;
|
|
239
428
|
}>;
|
|
240
429
|
/**
|
|
241
430
|
* Parameters for deleting an edge (soft delete).
|
|
@@ -296,6 +485,10 @@ type VectorSearchParams = Readonly<{
|
|
|
296
485
|
*/
|
|
297
486
|
type VectorSearchResult = Readonly<{
|
|
298
487
|
nodeId: string;
|
|
488
|
+
/**
|
|
489
|
+
* Cosine metric returns similarity score (higher is better).
|
|
490
|
+
* L2 and inner_product return raw distance (lower is better).
|
|
491
|
+
*/
|
|
299
492
|
score: number;
|
|
300
493
|
}>;
|
|
301
494
|
/**
|
|
@@ -346,21 +539,29 @@ type TransactionBackend = Omit<GraphBackend, "transaction" | "close">;
|
|
|
346
539
|
*/
|
|
347
540
|
type GraphBackend = Readonly<{
|
|
348
541
|
/** The SQL dialect */
|
|
349
|
-
dialect:
|
|
542
|
+
dialect: SqlDialect;
|
|
350
543
|
/** Backend capabilities */
|
|
351
544
|
capabilities: BackendCapabilities;
|
|
352
545
|
/** Table names used by this backend (for query schema auto-derivation) */
|
|
353
546
|
tableNames?: SqlTableNames | undefined;
|
|
354
547
|
insertNode: (params: InsertNodeParams) => Promise<NodeRow>;
|
|
548
|
+
insertNodeNoReturn?: (params: InsertNodeParams) => Promise<void>;
|
|
549
|
+
insertNodesBatch?: (params: readonly InsertNodeParams[]) => Promise<void>;
|
|
550
|
+
insertNodesBatchReturning?: (params: readonly InsertNodeParams[]) => Promise<readonly NodeRow[]>;
|
|
355
551
|
updateNode: (params: UpdateNodeParams) => Promise<NodeRow>;
|
|
356
552
|
deleteNode: (params: DeleteNodeParams) => Promise<void>;
|
|
357
553
|
hardDeleteNode: (params: HardDeleteNodeParams) => Promise<void>;
|
|
358
554
|
getNode: (graphId: string, kind: string, id: string) => Promise<NodeRow | undefined>;
|
|
555
|
+
getNodes?: (graphId: string, kind: string, ids: readonly string[]) => Promise<readonly NodeRow[]>;
|
|
359
556
|
insertEdge: (params: InsertEdgeParams) => Promise<EdgeRow>;
|
|
557
|
+
insertEdgeNoReturn?: (params: InsertEdgeParams) => Promise<void>;
|
|
558
|
+
insertEdgesBatch?: (params: readonly InsertEdgeParams[]) => Promise<void>;
|
|
559
|
+
insertEdgesBatchReturning?: (params: readonly InsertEdgeParams[]) => Promise<readonly EdgeRow[]>;
|
|
360
560
|
updateEdge: (params: UpdateEdgeParams) => Promise<EdgeRow>;
|
|
361
561
|
deleteEdge: (params: DeleteEdgeParams) => Promise<void>;
|
|
362
562
|
hardDeleteEdge: (params: HardDeleteEdgeParams) => Promise<void>;
|
|
363
563
|
getEdge: (graphId: string, id: string) => Promise<EdgeRow | undefined>;
|
|
564
|
+
getEdges?: (graphId: string, ids: readonly string[]) => Promise<readonly EdgeRow[]>;
|
|
364
565
|
countEdgesFrom: (params: CountEdgesFromParams) => Promise<number>;
|
|
365
566
|
edgeExistsBetween: (params: EdgeExistsBetweenParams) => Promise<boolean>;
|
|
366
567
|
findEdgesConnectedTo: (params: FindEdgesConnectedToParams) => Promise<readonly EdgeRow[]>;
|
|
@@ -382,6 +583,13 @@ type GraphBackend = Readonly<{
|
|
|
382
583
|
createVectorIndex?: (params: CreateVectorIndexParams) => Promise<void>;
|
|
383
584
|
dropVectorIndex?: (params: DropVectorIndexParams) => Promise<void>;
|
|
384
585
|
execute: <T>(query: SQL) => Promise<readonly T[]>;
|
|
586
|
+
/** Execute pre-compiled SQL text with bound parameters. Available on sync SQLite and pg backends. */
|
|
587
|
+
executeRaw?: <T>(sqlText: string, params: readonly unknown[]) => Promise<readonly T[]>;
|
|
588
|
+
/** Compile a Drizzle SQL object to { sql, params } without executing. */
|
|
589
|
+
compileSql?: (query: SQL) => Readonly<{
|
|
590
|
+
sql: string;
|
|
591
|
+
params: readonly unknown[];
|
|
592
|
+
}>;
|
|
385
593
|
transaction: <T>(fn: (tx: TransactionBackend) => Promise<T>, options?: TransactionOptions) => Promise<T>;
|
|
386
594
|
close: () => Promise<void>;
|
|
387
595
|
}>;
|
|
@@ -421,7 +629,7 @@ type InsertSchemaParams = Readonly<{
|
|
|
421
629
|
graphId: string;
|
|
422
630
|
version: number;
|
|
423
631
|
schemaHash: string;
|
|
424
|
-
schemaDoc:
|
|
632
|
+
schemaDoc: SerializedSchema;
|
|
425
633
|
isActive: boolean;
|
|
426
634
|
}>;
|
|
427
635
|
/**
|
|
@@ -464,6 +672,10 @@ type FindNodesByKindParams = Readonly<{
|
|
|
464
672
|
offset?: number;
|
|
465
673
|
/** If true, exclude deleted nodes. Default true. */
|
|
466
674
|
excludeDeleted?: boolean;
|
|
675
|
+
/** Temporal mode for filtering by validity period. */
|
|
676
|
+
temporalMode?: TemporalMode;
|
|
677
|
+
/** Timestamp for "current" and "asOf" temporal modes. */
|
|
678
|
+
asOf?: string;
|
|
467
679
|
}>;
|
|
468
680
|
/**
|
|
469
681
|
* Parameters for counting nodes by kind.
|
|
@@ -473,6 +685,10 @@ type CountNodesByKindParams = Readonly<{
|
|
|
473
685
|
kind: string;
|
|
474
686
|
/** If true, exclude deleted nodes. Default true. */
|
|
475
687
|
excludeDeleted?: boolean;
|
|
688
|
+
/** Temporal mode for filtering by validity period. */
|
|
689
|
+
temporalMode?: TemporalMode;
|
|
690
|
+
/** Timestamp for "current" and "asOf" temporal modes. */
|
|
691
|
+
asOf?: string;
|
|
476
692
|
}>;
|
|
477
693
|
/**
|
|
478
694
|
* Parameters for finding edges by kind.
|
|
@@ -488,6 +704,10 @@ type FindEdgesByKindParams = Readonly<{
|
|
|
488
704
|
offset?: number;
|
|
489
705
|
/** If true, exclude deleted edges. Default true. */
|
|
490
706
|
excludeDeleted?: boolean;
|
|
707
|
+
/** Temporal mode for filtering by validity period. */
|
|
708
|
+
temporalMode?: TemporalMode;
|
|
709
|
+
/** Timestamp for "current" and "asOf" temporal modes. */
|
|
710
|
+
asOf?: string;
|
|
491
711
|
}>;
|
|
492
712
|
/**
|
|
493
713
|
* Parameters for counting edges by kind.
|
|
@@ -501,6 +721,10 @@ type CountEdgesByKindParams = Readonly<{
|
|
|
501
721
|
toId?: string;
|
|
502
722
|
/** If true, exclude deleted edges. Default true. */
|
|
503
723
|
excludeDeleted?: boolean;
|
|
724
|
+
/** Temporal mode for filtering by validity period. */
|
|
725
|
+
temporalMode?: TemporalMode;
|
|
726
|
+
/** Timestamp for "current" and "asOf" temporal modes. */
|
|
727
|
+
asOf?: string;
|
|
504
728
|
}>;
|
|
505
729
|
|
|
506
|
-
export { DEFAULT_SQL_SCHEMA as D, type GraphBackend as G, type
|
|
730
|
+
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 SerializedNodeDef as S, type TransactionBackend as T, type SerializedEdgeDef as a, type SerializedMetaEdge as b, type SerializedOntologyRelation as c, type SerializedClosures as d, type SerializedSchema as e, type SchemaHash as f, type SerializedOntology as g, type SerializedUniqueConstraint as h, type SchemaVersionRow as i, type MetaEdgeProperties as j, type SqlSchema as k, type SqlTableNames as l, createSqlSchema as m, isMetaEdge as n };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { A as AnyEdgeType, E as EdgeType,
|
|
2
|
+
import { A as AnyEdgeType, E as EdgeType, N as NodeType } from './types-DTJEu_-h.cjs';
|
|
3
|
+
import { J as JsonPointer, V as ValueType, a as JsonPointerFor, b as JsonPointerSegmentsFor } from './ast-D-3bOanX.cjs';
|
|
3
4
|
|
|
4
5
|
type IndexScope =
|
|
5
6
|
/**
|
|
@@ -122,7 +123,7 @@ type EdgeIndexConfig<E extends AnyEdgeType> = Readonly<{
|
|
|
122
123
|
type NodeIndex<N extends NodeType = NodeType> = Readonly<{
|
|
123
124
|
__type: "typegraph_node_index";
|
|
124
125
|
node: N;
|
|
125
|
-
nodeKind: N["
|
|
126
|
+
nodeKind: N["kind"];
|
|
126
127
|
fields: readonly JsonPointer[];
|
|
127
128
|
fieldValueTypes: readonly (ValueType | undefined)[];
|
|
128
129
|
coveringFields: readonly JsonPointer[];
|
|
@@ -135,7 +136,7 @@ type NodeIndex<N extends NodeType = NodeType> = Readonly<{
|
|
|
135
136
|
type EdgeIndex<E extends AnyEdgeType = EdgeType> = Readonly<{
|
|
136
137
|
__type: "typegraph_edge_index";
|
|
137
138
|
edge: E;
|
|
138
|
-
edgeKind: E["
|
|
139
|
+
edgeKind: E["kind"];
|
|
139
140
|
fields: readonly JsonPointer[];
|
|
140
141
|
fieldValueTypes: readonly (ValueType | undefined)[];
|
|
141
142
|
coveringFields: readonly JsonPointer[];
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/** Brand key for NodeType */
|
|
4
|
+
declare const NODE_TYPE_BRAND: "__nodeType";
|
|
5
|
+
/** Brand key for EdgeType */
|
|
6
|
+
declare const EDGE_TYPE_BRAND: "__edgeType";
|
|
7
|
+
/** Brand symbol for NodeId */
|
|
8
|
+
declare const __nodeId: unique symbol;
|
|
9
|
+
/**
|
|
10
|
+
* A node type definition.
|
|
11
|
+
*
|
|
12
|
+
* Created via `defineNode()`. Represents a type of node in the graph
|
|
13
|
+
* with an associated Zod schema for properties.
|
|
14
|
+
*/
|
|
15
|
+
type NodeType<K extends string = string, S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>> = Readonly<{
|
|
16
|
+
[NODE_TYPE_BRAND]: true;
|
|
17
|
+
kind: K;
|
|
18
|
+
schema: S;
|
|
19
|
+
description: string | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Branded node ID type.
|
|
23
|
+
*
|
|
24
|
+
* Prevents mixing IDs from different node types at compile time.
|
|
25
|
+
*/
|
|
26
|
+
type NodeId<N extends NodeType> = string & Readonly<{
|
|
27
|
+
[__nodeId]: N;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Infer the props type from a NodeType.
|
|
31
|
+
*/
|
|
32
|
+
type NodeProps<N extends NodeType> = z.infer<N["schema"]>;
|
|
33
|
+
/**
|
|
34
|
+
* An edge type definition.
|
|
35
|
+
*
|
|
36
|
+
* Created via `defineEdge()`. Represents a type of edge in the graph
|
|
37
|
+
* with an optional Zod schema for properties.
|
|
38
|
+
*
|
|
39
|
+
* Optionally includes `from` and `to` arrays that define the allowed
|
|
40
|
+
* source and target node types (domain and range constraints).
|
|
41
|
+
*/
|
|
42
|
+
type EdgeType<K extends string = string, S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, From extends readonly NodeType[] | undefined = undefined, To extends readonly NodeType[] | undefined = undefined> = Readonly<{
|
|
43
|
+
[EDGE_TYPE_BRAND]: true;
|
|
44
|
+
kind: K;
|
|
45
|
+
schema: S;
|
|
46
|
+
description: string | undefined;
|
|
47
|
+
from: From;
|
|
48
|
+
to: To;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Base edge type for use in constraints - accepts any from/to configuration.
|
|
52
|
+
*/
|
|
53
|
+
type AnyEdgeType = EdgeType<string, z.ZodObject<z.ZodRawShape>, readonly NodeType[] | undefined, readonly NodeType[] | undefined>;
|
|
54
|
+
/**
|
|
55
|
+
* An edge type that has both from and to constraints defined.
|
|
56
|
+
* Can be used directly in defineGraph without an EdgeRegistration wrapper.
|
|
57
|
+
*/
|
|
58
|
+
type EdgeTypeWithEndpoints = EdgeType<string, z.ZodObject<z.ZodRawShape>, readonly NodeType[], readonly NodeType[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Infer the props type from an EdgeType.
|
|
61
|
+
*/
|
|
62
|
+
type EdgeProps<E extends AnyEdgeType> = z.infer<E["schema"]>;
|
|
63
|
+
/**
|
|
64
|
+
* Delete behaviors for nodes.
|
|
65
|
+
*/
|
|
66
|
+
type DeleteBehavior = "restrict" | "cascade" | "disconnect";
|
|
67
|
+
/**
|
|
68
|
+
* Edge cardinality constraints.
|
|
69
|
+
*/
|
|
70
|
+
type Cardinality = "many" | "one" | "unique" | "oneActive";
|
|
71
|
+
/**
|
|
72
|
+
* Endpoint existence modes for edge validation.
|
|
73
|
+
*/
|
|
74
|
+
type EndpointExistence = "notDeleted" | "currentlyValid" | "ever";
|
|
75
|
+
/**
|
|
76
|
+
* Temporal query modes.
|
|
77
|
+
*/
|
|
78
|
+
type TemporalMode = "current" | "asOf" | "includeEnded" | "includeTombstones";
|
|
79
|
+
/**
|
|
80
|
+
* Uniqueness constraint scope.
|
|
81
|
+
*/
|
|
82
|
+
type UniquenessScope = "kind" | "kindWithSubClasses";
|
|
83
|
+
/**
|
|
84
|
+
* Collation for uniqueness constraints.
|
|
85
|
+
*/
|
|
86
|
+
type Collation = "binary" | "caseInsensitive";
|
|
87
|
+
/**
|
|
88
|
+
* Uniqueness constraint definition.
|
|
89
|
+
*/
|
|
90
|
+
type UniqueConstraint<S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>> = Readonly<{
|
|
91
|
+
name: string;
|
|
92
|
+
fields: readonly (keyof z.infer<S> & string)[];
|
|
93
|
+
where?: (props: UniqueConstraintPredicateBuilder<S>) => UniqueConstraintPredicate;
|
|
94
|
+
scope: UniquenessScope;
|
|
95
|
+
collation: Collation;
|
|
96
|
+
}>;
|
|
97
|
+
/**
|
|
98
|
+
* Predicate builder for uniqueness constraint where clause.
|
|
99
|
+
* Uses -? to make all fields required in the builder, even if optional in the schema.
|
|
100
|
+
*/
|
|
101
|
+
type UniqueConstraintPredicateBuilder<S extends z.ZodObject<z.ZodRawShape>> = Readonly<{
|
|
102
|
+
[K in keyof z.infer<S>]-?: UniqueConstraintField;
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Field operations for uniqueness constraint predicates.
|
|
106
|
+
*/
|
|
107
|
+
type UniqueConstraintField = Readonly<{
|
|
108
|
+
isNull: () => UniqueConstraintPredicate;
|
|
109
|
+
isNotNull: () => UniqueConstraintPredicate;
|
|
110
|
+
}>;
|
|
111
|
+
/**
|
|
112
|
+
* A uniqueness constraint predicate (internal representation).
|
|
113
|
+
*/
|
|
114
|
+
type UniqueConstraintPredicate = Readonly<{
|
|
115
|
+
__type: "unique_predicate";
|
|
116
|
+
field: string;
|
|
117
|
+
op: "isNull" | "isNotNull";
|
|
118
|
+
}>;
|
|
119
|
+
/**
|
|
120
|
+
* Node registration in a graph definition.
|
|
121
|
+
*/
|
|
122
|
+
type NodeRegistration<N extends NodeType = NodeType> = Readonly<{
|
|
123
|
+
type: N;
|
|
124
|
+
unique?: readonly UniqueConstraint<N["schema"]>[];
|
|
125
|
+
onDelete?: DeleteBehavior;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Edge registration in a graph definition.
|
|
129
|
+
*/
|
|
130
|
+
type EdgeRegistration<E extends AnyEdgeType = AnyEdgeType, FromTypes extends NodeType = NodeType, ToTypes extends NodeType = NodeType> = Readonly<{
|
|
131
|
+
type: E;
|
|
132
|
+
from: readonly FromTypes[];
|
|
133
|
+
to: readonly ToTypes[];
|
|
134
|
+
cardinality?: Cardinality;
|
|
135
|
+
endpointExistence?: EndpointExistence;
|
|
136
|
+
}>;
|
|
137
|
+
/**
|
|
138
|
+
* Default settings for a graph.
|
|
139
|
+
*/
|
|
140
|
+
type GraphDefaults = Readonly<{
|
|
141
|
+
onNodeDelete?: DeleteBehavior;
|
|
142
|
+
temporalMode?: TemporalMode;
|
|
143
|
+
}>;
|
|
144
|
+
/**
|
|
145
|
+
* Checks if a value is a NodeType.
|
|
146
|
+
*/
|
|
147
|
+
declare function isNodeType(value: unknown): value is NodeType;
|
|
148
|
+
/**
|
|
149
|
+
* Checks if a value is an EdgeType.
|
|
150
|
+
*/
|
|
151
|
+
declare function isEdgeType(value: unknown): value is AnyEdgeType;
|
|
152
|
+
/**
|
|
153
|
+
* Checks if a value is an EdgeType with both from and to constraints defined.
|
|
154
|
+
* Such edges can be used directly in defineGraph without an EdgeRegistration wrapper.
|
|
155
|
+
*/
|
|
156
|
+
declare function isEdgeTypeWithEndpoints(value: unknown): value is EdgeTypeWithEndpoints;
|
|
157
|
+
|
|
158
|
+
export { type AnyEdgeType as A, type Collation as C, type DeleteBehavior as D, type EdgeType as E, type GraphDefaults as G, type NodeType as N, type TemporalMode as T, type UniquenessScope as U, type NodeRegistration as a, type EdgeRegistration as b, type EdgeTypeWithEndpoints as c, type Cardinality as d, type EndpointExistence as e, type EdgeProps as f, type NodeId as g, type NodeProps as h, type UniqueConstraint as i, isEdgeType as j, isEdgeTypeWithEndpoints as k, isNodeType as l };
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/** Brand key for NodeType */
|
|
4
|
+
declare const NODE_TYPE_BRAND: "__nodeType";
|
|
5
|
+
/** Brand key for EdgeType */
|
|
6
|
+
declare const EDGE_TYPE_BRAND: "__edgeType";
|
|
7
|
+
/** Brand symbol for NodeId */
|
|
8
|
+
declare const __nodeId: unique symbol;
|
|
9
|
+
/**
|
|
10
|
+
* A node type definition.
|
|
11
|
+
*
|
|
12
|
+
* Created via `defineNode()`. Represents a type of node in the graph
|
|
13
|
+
* with an associated Zod schema for properties.
|
|
14
|
+
*/
|
|
15
|
+
type NodeType<K extends string = string, S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>> = Readonly<{
|
|
16
|
+
[NODE_TYPE_BRAND]: true;
|
|
17
|
+
kind: K;
|
|
18
|
+
schema: S;
|
|
19
|
+
description: string | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Branded node ID type.
|
|
23
|
+
*
|
|
24
|
+
* Prevents mixing IDs from different node types at compile time.
|
|
25
|
+
*/
|
|
26
|
+
type NodeId<N extends NodeType> = string & Readonly<{
|
|
27
|
+
[__nodeId]: N;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Infer the props type from a NodeType.
|
|
31
|
+
*/
|
|
32
|
+
type NodeProps<N extends NodeType> = z.infer<N["schema"]>;
|
|
33
|
+
/**
|
|
34
|
+
* An edge type definition.
|
|
35
|
+
*
|
|
36
|
+
* Created via `defineEdge()`. Represents a type of edge in the graph
|
|
37
|
+
* with an optional Zod schema for properties.
|
|
38
|
+
*
|
|
39
|
+
* Optionally includes `from` and `to` arrays that define the allowed
|
|
40
|
+
* source and target node types (domain and range constraints).
|
|
41
|
+
*/
|
|
42
|
+
type EdgeType<K extends string = string, S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, From extends readonly NodeType[] | undefined = undefined, To extends readonly NodeType[] | undefined = undefined> = Readonly<{
|
|
43
|
+
[EDGE_TYPE_BRAND]: true;
|
|
44
|
+
kind: K;
|
|
45
|
+
schema: S;
|
|
46
|
+
description: string | undefined;
|
|
47
|
+
from: From;
|
|
48
|
+
to: To;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Base edge type for use in constraints - accepts any from/to configuration.
|
|
52
|
+
*/
|
|
53
|
+
type AnyEdgeType = EdgeType<string, z.ZodObject<z.ZodRawShape>, readonly NodeType[] | undefined, readonly NodeType[] | undefined>;
|
|
54
|
+
/**
|
|
55
|
+
* An edge type that has both from and to constraints defined.
|
|
56
|
+
* Can be used directly in defineGraph without an EdgeRegistration wrapper.
|
|
57
|
+
*/
|
|
58
|
+
type EdgeTypeWithEndpoints = EdgeType<string, z.ZodObject<z.ZodRawShape>, readonly NodeType[], readonly NodeType[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Infer the props type from an EdgeType.
|
|
61
|
+
*/
|
|
62
|
+
type EdgeProps<E extends AnyEdgeType> = z.infer<E["schema"]>;
|
|
63
|
+
/**
|
|
64
|
+
* Delete behaviors for nodes.
|
|
65
|
+
*/
|
|
66
|
+
type DeleteBehavior = "restrict" | "cascade" | "disconnect";
|
|
67
|
+
/**
|
|
68
|
+
* Edge cardinality constraints.
|
|
69
|
+
*/
|
|
70
|
+
type Cardinality = "many" | "one" | "unique" | "oneActive";
|
|
71
|
+
/**
|
|
72
|
+
* Endpoint existence modes for edge validation.
|
|
73
|
+
*/
|
|
74
|
+
type EndpointExistence = "notDeleted" | "currentlyValid" | "ever";
|
|
75
|
+
/**
|
|
76
|
+
* Temporal query modes.
|
|
77
|
+
*/
|
|
78
|
+
type TemporalMode = "current" | "asOf" | "includeEnded" | "includeTombstones";
|
|
79
|
+
/**
|
|
80
|
+
* Uniqueness constraint scope.
|
|
81
|
+
*/
|
|
82
|
+
type UniquenessScope = "kind" | "kindWithSubClasses";
|
|
83
|
+
/**
|
|
84
|
+
* Collation for uniqueness constraints.
|
|
85
|
+
*/
|
|
86
|
+
type Collation = "binary" | "caseInsensitive";
|
|
87
|
+
/**
|
|
88
|
+
* Uniqueness constraint definition.
|
|
89
|
+
*/
|
|
90
|
+
type UniqueConstraint<S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>> = Readonly<{
|
|
91
|
+
name: string;
|
|
92
|
+
fields: readonly (keyof z.infer<S> & string)[];
|
|
93
|
+
where?: (props: UniqueConstraintPredicateBuilder<S>) => UniqueConstraintPredicate;
|
|
94
|
+
scope: UniquenessScope;
|
|
95
|
+
collation: Collation;
|
|
96
|
+
}>;
|
|
97
|
+
/**
|
|
98
|
+
* Predicate builder for uniqueness constraint where clause.
|
|
99
|
+
* Uses -? to make all fields required in the builder, even if optional in the schema.
|
|
100
|
+
*/
|
|
101
|
+
type UniqueConstraintPredicateBuilder<S extends z.ZodObject<z.ZodRawShape>> = Readonly<{
|
|
102
|
+
[K in keyof z.infer<S>]-?: UniqueConstraintField;
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Field operations for uniqueness constraint predicates.
|
|
106
|
+
*/
|
|
107
|
+
type UniqueConstraintField = Readonly<{
|
|
108
|
+
isNull: () => UniqueConstraintPredicate;
|
|
109
|
+
isNotNull: () => UniqueConstraintPredicate;
|
|
110
|
+
}>;
|
|
111
|
+
/**
|
|
112
|
+
* A uniqueness constraint predicate (internal representation).
|
|
113
|
+
*/
|
|
114
|
+
type UniqueConstraintPredicate = Readonly<{
|
|
115
|
+
__type: "unique_predicate";
|
|
116
|
+
field: string;
|
|
117
|
+
op: "isNull" | "isNotNull";
|
|
118
|
+
}>;
|
|
119
|
+
/**
|
|
120
|
+
* Node registration in a graph definition.
|
|
121
|
+
*/
|
|
122
|
+
type NodeRegistration<N extends NodeType = NodeType> = Readonly<{
|
|
123
|
+
type: N;
|
|
124
|
+
unique?: readonly UniqueConstraint<N["schema"]>[];
|
|
125
|
+
onDelete?: DeleteBehavior;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Edge registration in a graph definition.
|
|
129
|
+
*/
|
|
130
|
+
type EdgeRegistration<E extends AnyEdgeType = AnyEdgeType, FromTypes extends NodeType = NodeType, ToTypes extends NodeType = NodeType> = Readonly<{
|
|
131
|
+
type: E;
|
|
132
|
+
from: readonly FromTypes[];
|
|
133
|
+
to: readonly ToTypes[];
|
|
134
|
+
cardinality?: Cardinality;
|
|
135
|
+
endpointExistence?: EndpointExistence;
|
|
136
|
+
}>;
|
|
137
|
+
/**
|
|
138
|
+
* Default settings for a graph.
|
|
139
|
+
*/
|
|
140
|
+
type GraphDefaults = Readonly<{
|
|
141
|
+
onNodeDelete?: DeleteBehavior;
|
|
142
|
+
temporalMode?: TemporalMode;
|
|
143
|
+
}>;
|
|
144
|
+
/**
|
|
145
|
+
* Checks if a value is a NodeType.
|
|
146
|
+
*/
|
|
147
|
+
declare function isNodeType(value: unknown): value is NodeType;
|
|
148
|
+
/**
|
|
149
|
+
* Checks if a value is an EdgeType.
|
|
150
|
+
*/
|
|
151
|
+
declare function isEdgeType(value: unknown): value is AnyEdgeType;
|
|
152
|
+
/**
|
|
153
|
+
* Checks if a value is an EdgeType with both from and to constraints defined.
|
|
154
|
+
* Such edges can be used directly in defineGraph without an EdgeRegistration wrapper.
|
|
155
|
+
*/
|
|
156
|
+
declare function isEdgeTypeWithEndpoints(value: unknown): value is EdgeTypeWithEndpoints;
|
|
157
|
+
|
|
158
|
+
export { type AnyEdgeType as A, type Collation as C, type DeleteBehavior as D, type EdgeType as E, type GraphDefaults as G, type NodeType as N, type TemporalMode as T, type UniquenessScope as U, type NodeRegistration as a, type EdgeRegistration as b, type EdgeTypeWithEndpoints as c, type Cardinality as d, type EndpointExistence as e, type EdgeProps as f, type NodeId as g, type NodeProps as h, type UniqueConstraint as i, isEdgeType as j, isEdgeTypeWithEndpoints as k, isNodeType as l };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { A as AnyEdgeType, E as EdgeType,
|
|
2
|
+
import { A as AnyEdgeType, E as EdgeType, N as NodeType } from './types-DTJEu_-h.js';
|
|
3
|
+
import { J as JsonPointer, V as ValueType, a as JsonPointerFor, b as JsonPointerSegmentsFor } from './ast-CXFx6bF6.js';
|
|
3
4
|
|
|
4
5
|
type IndexScope =
|
|
5
6
|
/**
|
|
@@ -122,7 +123,7 @@ type EdgeIndexConfig<E extends AnyEdgeType> = Readonly<{
|
|
|
122
123
|
type NodeIndex<N extends NodeType = NodeType> = Readonly<{
|
|
123
124
|
__type: "typegraph_node_index";
|
|
124
125
|
node: N;
|
|
125
|
-
nodeKind: N["
|
|
126
|
+
nodeKind: N["kind"];
|
|
126
127
|
fields: readonly JsonPointer[];
|
|
127
128
|
fieldValueTypes: readonly (ValueType | undefined)[];
|
|
128
129
|
coveringFields: readonly JsonPointer[];
|
|
@@ -135,7 +136,7 @@ type NodeIndex<N extends NodeType = NodeType> = Readonly<{
|
|
|
135
136
|
type EdgeIndex<E extends AnyEdgeType = EdgeType> = Readonly<{
|
|
136
137
|
__type: "typegraph_edge_index";
|
|
137
138
|
edge: E;
|
|
138
|
-
edgeKind: E["
|
|
139
|
+
edgeKind: E["kind"];
|
|
139
140
|
fields: readonly JsonPointer[];
|
|
140
141
|
fieldValueTypes: readonly (ValueType | undefined)[];
|
|
141
142
|
coveringFields: readonly JsonPointer[];
|