@nicia-ai/typegraph 0.24.1 → 0.25.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 (159) hide show
  1. package/dist/backend/postgres/index.cjs +178 -55
  2. package/dist/backend/postgres/index.cjs.map +1 -1
  3. package/dist/backend/postgres/index.d.cts +6 -7
  4. package/dist/backend/postgres/index.d.ts +6 -7
  5. package/dist/backend/postgres/index.js +151 -28
  6. package/dist/backend/postgres/index.js.map +1 -1
  7. package/dist/backend/sqlite/index.cjs +19 -17
  8. package/dist/backend/sqlite/index.d.cts +6 -7
  9. package/dist/backend/sqlite/index.d.ts +6 -7
  10. package/dist/backend/sqlite/index.js +9 -7
  11. package/dist/backend/sqlite/libsql.cjs +12 -10
  12. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  13. package/dist/backend/sqlite/libsql.d.cts +4 -5
  14. package/dist/backend/sqlite/libsql.d.ts +4 -5
  15. package/dist/backend/sqlite/libsql.js +9 -7
  16. package/dist/backend/sqlite/libsql.js.map +1 -1
  17. package/dist/backend/sqlite/local.cjs +14 -12
  18. package/dist/backend/sqlite/local.cjs.map +1 -1
  19. package/dist/backend/sqlite/local.d.cts +4 -5
  20. package/dist/backend/sqlite/local.d.ts +4 -5
  21. package/dist/backend/sqlite/local.js +9 -7
  22. package/dist/backend/sqlite/local.js.map +1 -1
  23. package/dist/chunk-4BOWVUGQ.js +2029 -0
  24. package/dist/chunk-4BOWVUGQ.js.map +1 -0
  25. package/dist/{chunk-SUHW2UYL.cjs → chunk-7CDXX3QZ.cjs} +2 -2
  26. package/dist/chunk-7CDXX3QZ.cjs.map +1 -0
  27. package/dist/chunk-7V335GHG.cjs +112 -0
  28. package/dist/chunk-7V335GHG.cjs.map +1 -0
  29. package/dist/chunk-7W3KAMVQ.cjs +2678 -0
  30. package/dist/chunk-7W3KAMVQ.cjs.map +1 -0
  31. package/dist/chunk-CTHNVU6K.cjs +551 -0
  32. package/dist/chunk-CTHNVU6K.cjs.map +1 -0
  33. package/dist/chunk-D2GO3RBL.cjs +12 -0
  34. package/dist/chunk-D2GO3RBL.cjs.map +1 -0
  35. package/dist/{chunk-WFMTAEEN.js → chunk-DOTEN2FG.js} +81 -7
  36. package/dist/chunk-DOTEN2FG.js.map +1 -0
  37. package/dist/chunk-E5JZSEGJ.cjs +301 -0
  38. package/dist/chunk-E5JZSEGJ.cjs.map +1 -0
  39. package/dist/chunk-EG6TJ3I5.js +286 -0
  40. package/dist/chunk-EG6TJ3I5.js.map +1 -0
  41. package/dist/chunk-EJCDOA37.js +537 -0
  42. package/dist/chunk-EJCDOA37.js.map +1 -0
  43. package/dist/{chunk-UVZHTBZ5.cjs → chunk-EK6RJ373.cjs} +7 -150
  44. package/dist/chunk-EK6RJ373.cjs.map +1 -0
  45. package/dist/{chunk-GUTQTMOV.js → chunk-FPCOUJSL.js} +2 -2
  46. package/dist/chunk-FPCOUJSL.js.map +1 -0
  47. package/dist/{chunk-3JK66E3I.cjs → chunk-JTI5WT4P.cjs} +630 -59
  48. package/dist/chunk-JTI5WT4P.cjs.map +1 -0
  49. package/dist/chunk-LVCSL6A3.js +2626 -0
  50. package/dist/chunk-LVCSL6A3.js.map +1 -0
  51. package/dist/chunk-NHQWXSTS.js +10 -0
  52. package/dist/chunk-NHQWXSTS.js.map +1 -0
  53. package/dist/chunk-NZ5PMBTG.js +105 -0
  54. package/dist/chunk-NZ5PMBTG.js.map +1 -0
  55. package/dist/{chunk-5HVDOPZU.cjs → chunk-O2P3KAUT.cjs} +416 -93
  56. package/dist/chunk-O2P3KAUT.cjs.map +1 -0
  57. package/dist/{chunk-QOLTW7OZ.js → chunk-OJ6IQVZG.js} +151 -13
  58. package/dist/chunk-OJ6IQVZG.js.map +1 -0
  59. package/dist/{chunk-EYELZHKY.js → chunk-OOS2RKRH.js} +5 -140
  60. package/dist/chunk-OOS2RKRH.js.map +1 -0
  61. package/dist/chunk-RCAJZG67.cjs +2069 -0
  62. package/dist/chunk-RCAJZG67.cjs.map +1 -0
  63. package/dist/{chunk-O5PST6TB.cjs → chunk-W5MTHMTE.cjs} +83 -6
  64. package/dist/chunk-W5MTHMTE.cjs.map +1 -0
  65. package/dist/{chunk-EY4LBX3F.js → chunk-WI5VRP3X.js} +337 -26
  66. package/dist/chunk-WI5VRP3X.js.map +1 -0
  67. package/dist/chunk-WVQXAFP3.js +79 -0
  68. package/dist/chunk-WVQXAFP3.js.map +1 -0
  69. package/dist/chunk-X3244EKP.cjs +84 -0
  70. package/dist/chunk-X3244EKP.cjs.map +1 -0
  71. package/dist/{chunk-753F33CV.js → chunk-YZZBDCLV.js} +617 -44
  72. package/dist/chunk-YZZBDCLV.js.map +1 -0
  73. package/dist/{chunk-OVJ2BE5Q.cjs → chunk-ZEMNF3QK.cjs} +171 -33
  74. package/dist/chunk-ZEMNF3QK.cjs.map +1 -0
  75. package/dist/{ddl-B_H8JM-E.d.cts → ddl-B2jjLjpR.d.cts} +762 -99
  76. package/dist/{ddl-1tFIvt9V.d.ts → ddl-DpaeAKPp.d.ts} +762 -99
  77. package/dist/extension-types-D07e_NTw.d.cts +543 -0
  78. package/dist/extension-types-D07e_NTw.d.ts +543 -0
  79. package/dist/graph-extension/index.cjs +71 -0
  80. package/dist/graph-extension/index.cjs.map +1 -0
  81. package/dist/graph-extension/index.d.cts +278 -0
  82. package/dist/graph-extension/index.d.ts +278 -0
  83. package/dist/graph-extension/index.js +6 -0
  84. package/dist/graph-extension/index.js.map +1 -0
  85. package/dist/{index-DXkEXpNz.d.ts → index-CT6nvtxL.d.cts} +114 -5
  86. package/dist/{index-DXkEXpNz.d.cts → index-DQheiVQV.d.ts} +114 -5
  87. package/dist/index.cjs +2672 -901
  88. package/dist/index.cjs.map +1 -1
  89. package/dist/index.d.cts +29 -10
  90. package/dist/index.d.ts +29 -10
  91. package/dist/index.js +2248 -598
  92. package/dist/index.js.map +1 -1
  93. package/dist/indexes/index.cjs +25 -23
  94. package/dist/indexes/index.d.cts +40 -22
  95. package/dist/indexes/index.d.ts +40 -22
  96. package/dist/indexes/index.js +5 -3
  97. package/dist/interchange/index.cjs +8 -7
  98. package/dist/interchange/index.cjs.map +1 -1
  99. package/dist/interchange/index.d.cts +5 -4
  100. package/dist/interchange/index.d.ts +5 -4
  101. package/dist/interchange/index.js +3 -2
  102. package/dist/interchange/index.js.map +1 -1
  103. package/dist/{manager-nIhmttD-.d.ts → manager-BKaPQbns.d.ts} +189 -6
  104. package/dist/{manager-Vkz28eAC.d.cts → manager-BpjBW1JK.d.cts} +189 -6
  105. package/dist/materialize-indexes-BB9N5uQl.d.cts +68 -0
  106. package/dist/materialize-indexes-BYpU2RKh.d.ts +68 -0
  107. package/dist/profiler/index.cjs +10 -8
  108. package/dist/profiler/index.cjs.map +1 -1
  109. package/dist/profiler/index.d.cts +8 -7
  110. package/dist/profiler/index.d.ts +8 -7
  111. package/dist/profiler/index.js +3 -1
  112. package/dist/profiler/index.js.map +1 -1
  113. package/dist/schema/index.cjs +43 -22
  114. package/dist/schema/index.cjs.map +1 -1
  115. package/dist/schema/index.d.cts +17 -8
  116. package/dist/schema/index.d.ts +17 -8
  117. package/dist/schema/index.js +9 -4
  118. package/dist/schema/index.js.map +1 -1
  119. package/dist/{sqlite-D0aceIe0.d.cts → sqlite-CU3j6rc7.d.ts} +837 -120
  120. package/dist/{sqlite-SUxbZqfy.d.ts → sqlite-Myo8e3Lr.d.cts} +837 -120
  121. package/dist/{store-U3i2tUch.d.ts → store-BAGuOHDh.d.cts} +659 -23
  122. package/dist/{store-CpvwTMxV.d.cts → store-De98Lod4.d.ts} +659 -23
  123. package/dist/types--0EslBx5.d.cts +2123 -0
  124. package/dist/{types-qYFZ9SqD.d.ts → types-BLmJq4wI.d.ts} +3 -2
  125. package/dist/types-BNWYZ-0-.d.ts +2123 -0
  126. package/dist/{types-yH4_p0XB.d.cts → types-CYga3lZp.d.cts} +3 -2
  127. package/dist/where-CluR73rs.d.ts +11 -0
  128. package/dist/where-m1uWsdua.d.cts +11 -0
  129. package/package.json +33 -73
  130. package/dist/ast-C8S37w1A.d.ts +0 -497
  131. package/dist/ast-dgLhLOg0.d.cts +0 -497
  132. package/dist/chunk-3JK66E3I.cjs.map +0 -1
  133. package/dist/chunk-3PPEHLGK.js +0 -1116
  134. package/dist/chunk-3PPEHLGK.js.map +0 -1
  135. package/dist/chunk-5HVDOPZU.cjs.map +0 -1
  136. package/dist/chunk-753F33CV.js.map +0 -1
  137. package/dist/chunk-EY4LBX3F.js.map +0 -1
  138. package/dist/chunk-EYELZHKY.js.map +0 -1
  139. package/dist/chunk-GFGVREHH.js +0 -1381
  140. package/dist/chunk-GFGVREHH.js.map +0 -1
  141. package/dist/chunk-GUTQTMOV.js.map +0 -1
  142. package/dist/chunk-LBORRUNJ.js +0 -135
  143. package/dist/chunk-LBORRUNJ.js.map +0 -1
  144. package/dist/chunk-O5PST6TB.cjs.map +0 -1
  145. package/dist/chunk-OLROXS2S.cjs +0 -147
  146. package/dist/chunk-OLROXS2S.cjs.map +0 -1
  147. package/dist/chunk-OVJ2BE5Q.cjs.map +0 -1
  148. package/dist/chunk-PAUN562Y.cjs +0 -1417
  149. package/dist/chunk-PAUN562Y.cjs.map +0 -1
  150. package/dist/chunk-PEE4EWXZ.cjs +0 -1131
  151. package/dist/chunk-PEE4EWXZ.cjs.map +0 -1
  152. package/dist/chunk-QOLTW7OZ.js.map +0 -1
  153. package/dist/chunk-SUHW2UYL.cjs.map +0 -1
  154. package/dist/chunk-UVZHTBZ5.cjs.map +0 -1
  155. package/dist/chunk-WFMTAEEN.js.map +0 -1
  156. package/dist/types-C-zfYDJB.d.ts +0 -159
  157. package/dist/types-CQx4iW5Y.d.cts +0 -159
  158. package/dist/types-Qk2l3IkQ.d.cts +0 -1254
  159. package/dist/types-Qk2l3IkQ.d.ts +0 -1254
@@ -0,0 +1,543 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Which side of the bipartite graph a kind lives on. Used everywhere a
5
+ * function takes "the entity that owns a kind" — error metadata,
6
+ * extension classifiers, removal queues, schema diffs.
7
+ */
8
+ type KindEntity = "node" | "edge";
9
+ /**
10
+ * Which physical surface an index targets. Vector indexes don't own a
11
+ * kind directly (they're partial indexes on `typegraph_node_embeddings`
12
+ * scoped by node-kind), but they participate in the same materialization
13
+ * and diff pipelines, so they share this discriminator.
14
+ */
15
+ type IndexEntity = "node" | "edge" | "vector";
16
+ /**
17
+ * Field-level null-check operations that round-trip through persisted
18
+ * documents (unique-constraint where clauses, index where clauses,
19
+ * graph-extension where clauses, IsNullPredicate). Consolidated so a
20
+ * single rename or extension touches one site.
21
+ */
22
+ type NullCheckOp = "isNull" | "isNotNull";
23
+ /** Brand key for NodeType */
24
+ declare const NODE_TYPE_BRAND: "__nodeType";
25
+ /** Brand key for EdgeType */
26
+ declare const EDGE_TYPE_BRAND: "__edgeType";
27
+ /** Brand symbol for NodeId */
28
+ declare const __nodeId: unique symbol;
29
+ /** Brand symbol for EdgeId */
30
+ declare const __edgeId: unique symbol;
31
+ /**
32
+ * Any JSON-serializable value.
33
+ *
34
+ * Mirrors the JSON wire format: primitives, arrays, and string-keyed objects.
35
+ * `null` is included because the JSON spec requires it for "no value here";
36
+ * this is the one place in the public API that uses `null` over `undefined`.
37
+ */
38
+ type JsonValue = null | string | number | boolean | readonly JsonValue[] | Readonly<{
39
+ [key: string]: JsonValue;
40
+ }>;
41
+ /**
42
+ * Consumer-owned per-kind annotations.
43
+ *
44
+ * Stable labels attached to a node or edge kind at definition time — UI hints,
45
+ * audit policy, provenance pointers, tooling annotations.
46
+ *
47
+ * **Consumer-owned, fully.** TypeGraph never reads, validates, or interprets
48
+ * values in this field. Consumers own the entire namespace; there are no
49
+ * reserved keys or extension prefixes. Future library-owned per-kind state,
50
+ * if needed, will use a separate sibling field rather than carving out keys
51
+ * here.
52
+ *
53
+ * **Annotations participate in schema hashing.** Any change to an annotation
54
+ * value (or adding/removing an annotation key) bumps the canonical schema
55
+ * hash and is reported as a `safe`-severity diff by `getSchemaChanges`. If
56
+ * you don't want versioning for a piece of state, do not put it here.
57
+ *
58
+ * Values must be JSON-serializable — `bigint`, `function`, `symbol`, `undefined`,
59
+ * `Date`, and other class instances are rejected at definition time so they can
60
+ * never silently break schema hashing or storage round-trips.
61
+ */
62
+ type KindAnnotations = Readonly<Record<string, JsonValue>>;
63
+ /**
64
+ * A node type definition.
65
+ *
66
+ * Created via `defineNode()`. Represents a type of node in the graph
67
+ * with an associated Zod schema for properties.
68
+ */
69
+ type NodeType<K extends string = string, S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>> = Readonly<{
70
+ [NODE_TYPE_BRAND]: true;
71
+ kind: K;
72
+ schema: S;
73
+ description: string | undefined;
74
+ annotations: KindAnnotations | undefined;
75
+ }>;
76
+ /**
77
+ * Branded node ID type.
78
+ *
79
+ * Prevents mixing IDs from different node types at compile time.
80
+ */
81
+ type NodeId<N extends NodeType> = string & Readonly<{
82
+ [__nodeId]: N;
83
+ }>;
84
+ /**
85
+ * Infer the props type from a NodeType.
86
+ */
87
+ type NodeProps<N extends NodeType> = z.infer<N["schema"]>;
88
+ /**
89
+ * An edge type definition.
90
+ *
91
+ * Created via `defineEdge()`. Represents a type of edge in the graph
92
+ * with an optional Zod schema for properties.
93
+ *
94
+ * Optionally includes `from` and `to` arrays that define the allowed
95
+ * source and target node types (domain and range constraints).
96
+ */
97
+ 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<{
98
+ [EDGE_TYPE_BRAND]: true;
99
+ kind: K;
100
+ schema: S;
101
+ description: string | undefined;
102
+ annotations: KindAnnotations | undefined;
103
+ from: From;
104
+ to: To;
105
+ }>;
106
+ /**
107
+ * Base edge type for use in constraints - accepts any from/to configuration.
108
+ */
109
+ type AnyEdgeType = EdgeType<string, z.ZodObject<z.ZodRawShape>, readonly NodeType[] | undefined, readonly NodeType[] | undefined>;
110
+ /**
111
+ * An edge type that has both from and to constraints defined.
112
+ * Can be used directly in defineGraph without an EdgeRegistration wrapper.
113
+ */
114
+ type EdgeTypeWithEndpoints = EdgeType<string, z.ZodObject<z.ZodRawShape>, readonly NodeType[], readonly NodeType[]>;
115
+ /**
116
+ * Branded edge ID type.
117
+ *
118
+ * Prevents mixing IDs from different edge types at compile time.
119
+ */
120
+ type EdgeId<E extends AnyEdgeType = AnyEdgeType> = string & Readonly<{
121
+ [__edgeId]: E;
122
+ }>;
123
+ /**
124
+ * Infer the props type from an EdgeType.
125
+ */
126
+ type EdgeProps<E extends AnyEdgeType> = z.infer<E["schema"]>;
127
+ /**
128
+ * Delete behaviors for nodes.
129
+ */
130
+ type DeleteBehavior = "restrict" | "cascade" | "disconnect";
131
+ /**
132
+ * Edge cardinality constraints.
133
+ */
134
+ type Cardinality = "many" | "one" | "unique" | "oneActive";
135
+ /**
136
+ * Endpoint existence modes for edge validation.
137
+ */
138
+ type EndpointExistence = "notDeleted" | "currentlyValid" | "ever";
139
+ /**
140
+ * Temporal query modes.
141
+ */
142
+ type TemporalMode = "current" | "asOf" | "includeEnded" | "includeTombstones";
143
+ /**
144
+ * Uniqueness constraint scope.
145
+ */
146
+ type UniquenessScope = "kind" | "kindWithSubClasses";
147
+ /**
148
+ * Collation for uniqueness constraints.
149
+ */
150
+ type Collation = "binary" | "caseInsensitive";
151
+ /**
152
+ * Uniqueness constraint definition.
153
+ */
154
+ type UniqueConstraint<S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>> = Readonly<{
155
+ name: string;
156
+ fields: readonly (keyof z.infer<S> & string)[];
157
+ where?: (props: UniqueConstraintPredicateBuilder<S>) => UniqueConstraintPredicate;
158
+ scope: UniquenessScope;
159
+ collation: Collation;
160
+ }>;
161
+ /**
162
+ * Predicate builder for uniqueness constraint where clause.
163
+ * Uses -? to make all fields required in the builder, even if optional in the schema.
164
+ */
165
+ type UniqueConstraintPredicateBuilder<S extends z.ZodObject<z.ZodRawShape>> = Readonly<{
166
+ [K in keyof z.infer<S>]-?: UniqueConstraintField;
167
+ }>;
168
+ /**
169
+ * Field operations for uniqueness constraint predicates.
170
+ */
171
+ type UniqueConstraintField = Readonly<{
172
+ isNull: () => UniqueConstraintPredicate;
173
+ isNotNull: () => UniqueConstraintPredicate;
174
+ }>;
175
+ /**
176
+ * A uniqueness constraint predicate (internal representation).
177
+ */
178
+ type UniqueConstraintPredicate = Readonly<{
179
+ __type: "unique_predicate";
180
+ field: string;
181
+ op: NullCheckOp;
182
+ }>;
183
+ /**
184
+ * Node registration in a graph definition.
185
+ */
186
+ type NodeRegistration<N extends NodeType = NodeType> = Readonly<{
187
+ type: N;
188
+ unique?: readonly UniqueConstraint<N["schema"]>[];
189
+ onDelete?: DeleteBehavior;
190
+ }>;
191
+ /**
192
+ * Edge registration in a graph definition.
193
+ */
194
+ type EdgeRegistration<E extends AnyEdgeType = AnyEdgeType, FromTypes extends NodeType = NodeType, ToTypes extends NodeType = NodeType> = Readonly<{
195
+ type: E;
196
+ from: readonly FromTypes[];
197
+ to: readonly ToTypes[];
198
+ cardinality?: Cardinality;
199
+ endpointExistence?: EndpointExistence;
200
+ }>;
201
+ /**
202
+ * Default settings for a graph.
203
+ */
204
+ type GraphDefaults = Readonly<{
205
+ onNodeDelete?: DeleteBehavior;
206
+ temporalMode?: TemporalMode;
207
+ }>;
208
+ /**
209
+ * Checks if a value is a NodeType.
210
+ */
211
+ declare function isNodeType(value: unknown): value is NodeType;
212
+ /**
213
+ * Checks if a value is an EdgeType.
214
+ */
215
+ declare function isEdgeType(value: unknown): value is AnyEdgeType;
216
+ /**
217
+ * Checks if a value is an EdgeType with both from and to constraints defined.
218
+ * Such edges can be used directly in defineGraph without an EdgeRegistration wrapper.
219
+ */
220
+ declare function isEdgeTypeWithEndpoints(value: unknown): value is EdgeTypeWithEndpoints;
221
+
222
+ declare const ALL_META_EDGE_NAMES: readonly ["subClassOf", "broader", "narrower", "relatedTo", "equivalentTo", "sameAs", "differentFrom", "disjointWith", "partOf", "hasPart", "inverseOf", "implies"];
223
+ type MetaEdgeName = (typeof ALL_META_EDGE_NAMES)[number];
224
+
225
+ /**
226
+ * Pure-value document format for graph extensions.
227
+ *
228
+ * A `GraphExtension` is a plain JSON-serializable description of
229
+ * additional node kinds, edge kinds, and ontology relations that should
230
+ * be merged into a graph at runtime. The document is the canonical
231
+ * artifact: every restart re-compiles it back to the same Zod-bearing
232
+ * `NodeType` / `EdgeType` / `OntologyRelation` shapes.
233
+ *
234
+ * The supported property-type subset is intentionally narrower than full
235
+ * JSON Schema — only what compiles cleanly to Zod and what real
236
+ * agent-induced schemas use in practice. Anything outside this set fails
237
+ * loudly at `defineGraphExtension(...)`.
238
+ */
239
+
240
+ /**
241
+ * Per-property modifier: tag the field as fulltext-searchable.
242
+ *
243
+ * Compiles to a `searchable({ language })`-wrapped Zod string when applied
244
+ * to a `string` property. Rejected on any other property type at validation
245
+ * time.
246
+ */
247
+ type ExtensionSearchableModifier = Readonly<{
248
+ language?: string;
249
+ }>;
250
+ /**
251
+ * Per-property modifier: declare a vector embedding with the given
252
+ * dimensionality. Compiles to `embedding(dimensions)` and is only valid on
253
+ * `array` properties whose item type is `number`. Rejected elsewhere.
254
+ */
255
+ type ExtensionEmbeddingModifier = Readonly<{
256
+ dimensions: number;
257
+ }>;
258
+ /**
259
+ * Modifiers shared by every graph-extension property type.
260
+ *
261
+ * `optional: true` flips the field from required-with-graph-extension-validation
262
+ * to `.optional()` and removes it from the parent object's `required`
263
+ * list. `searchable` and `embedding` only apply to specific underlying
264
+ * types — see the per-modifier docs.
265
+ */
266
+ type ExtensionPropertyModifiers = Readonly<{
267
+ optional?: boolean;
268
+ searchable?: ExtensionSearchableModifier;
269
+ embedding?: ExtensionEmbeddingModifier;
270
+ description?: string;
271
+ }>;
272
+ /**
273
+ * String property. Compiles to `z.string()` plus the requested refinements.
274
+ * `format` accepts the two formats motivated by induced schemas in
275
+ * practice — covers ISO datetimes, URIs, email addresses, UUIDs, and
276
+ * date-only strings. Each format routes to the corresponding Zod
277
+ * factory (`z.iso.datetime()`, `z.url()`, `z.email()`, `z.uuid()`,
278
+ * `z.iso.date()`); other JSON-Schema formats are deliberately not
279
+ * supported in v1.
280
+ */
281
+ type ExtensionStringProperty = Readonly<{
282
+ type: "string";
283
+ minLength?: number;
284
+ maxLength?: number;
285
+ pattern?: string;
286
+ format?: "datetime" | "uri" | "email" | "uuid" | "date";
287
+ }> & ExtensionPropertyModifiers;
288
+ /**
289
+ * Number property. `int: true` requires whole numbers; `min` / `max` are
290
+ * inclusive bounds. Compiles to `z.number().int()?.min(...)?.max(...)`.
291
+ */
292
+ type ExtensionNumberProperty = Readonly<{
293
+ type: "number";
294
+ min?: number;
295
+ max?: number;
296
+ int?: boolean;
297
+ }> & ExtensionPropertyModifiers;
298
+ /**
299
+ * Boolean property. Compiles to `z.boolean()`.
300
+ */
301
+ type ExtensionBooleanProperty = Readonly<{
302
+ type: "boolean";
303
+ }> & ExtensionPropertyModifiers;
304
+ /**
305
+ * Closed-set string enum. Compiles to `z.enum([...values])`. Must contain
306
+ * at least one value; duplicate values are rejected at validation time.
307
+ */
308
+ type ExtensionEnumProperty = Readonly<{
309
+ type: "enum";
310
+ values: readonly string[];
311
+ }> & ExtensionPropertyModifiers;
312
+ /**
313
+ * Array property. `items` is any of the scalar property types or an
314
+ * object property — nested arrays are forbidden in v1. Compiles to
315
+ * `z.array(<items>)`. The `embedding` modifier turns this into a
316
+ * vector embedding instead of a generic array.
317
+ */
318
+ type ExtensionArrayProperty = Readonly<{
319
+ type: "array";
320
+ items: ExtensionArrayItemType;
321
+ }> & ExtensionPropertyModifiers;
322
+ /**
323
+ * Element types allowed inside an array — every leaf property type plus
324
+ * single-level object. Nesting an array inside an array is rejected at
325
+ * validation time so the v1 surface stays a flat tree.
326
+ */
327
+ type ExtensionArrayItemType = ExtensionStringProperty | ExtensionNumberProperty | ExtensionBooleanProperty | ExtensionEnumProperty | ExtensionObjectProperty;
328
+ /**
329
+ * Object property. `properties` is a single nesting level; deeper objects
330
+ * are rejected at validation time so the v1 surface is auditable at a
331
+ * glance.
332
+ */
333
+ type ExtensionObjectProperty = Readonly<{
334
+ type: "object";
335
+ properties: Readonly<Record<string, ExtensionObjectFieldProperty>>;
336
+ }> & ExtensionPropertyModifiers;
337
+ /**
338
+ * Property types allowed inside an `object`'s `properties` — leaf scalars
339
+ * and arrays only. Nested objects are blocked here to enforce the
340
+ * single-nesting-level rule.
341
+ */
342
+ type ExtensionObjectFieldProperty = ExtensionStringProperty | ExtensionNumberProperty | ExtensionBooleanProperty | ExtensionEnumProperty | ExtensionArrayProperty;
343
+ /**
344
+ * Top-level property descriptor for a node or edge field.
345
+ *
346
+ * The discriminated union covers every type in the v1 subset; arbitrary
347
+ * `unknown` inputs are validated against this set at
348
+ * `defineGraphExtension(...)` time.
349
+ */
350
+ type ExtensionPropertyType = ExtensionStringProperty | ExtensionNumberProperty | ExtensionBooleanProperty | ExtensionEnumProperty | ExtensionArrayProperty | ExtensionObjectProperty;
351
+ /**
352
+ * Document-side `where` clause for a unique constraint.
353
+ *
354
+ * Mirrors `serializeWherePredicate`'s capability — the only operations
355
+ * round-trippable through the persisted form are `isNull` and `isNotNull`.
356
+ * Anything richer (equality, `in`, etc.) is rejected at validation time.
357
+ */
358
+ type ExtensionUniqueWhere = Readonly<{
359
+ field: string;
360
+ op: NullCheckOp;
361
+ }>;
362
+ /**
363
+ * Unique constraint declaration. `fields` must reference declared
364
+ * properties on the kind. Defaults match the existing `UniqueConstraint`:
365
+ * `scope: "kind"`, `collation: "binary"`.
366
+ */
367
+ type ExtensionUniqueConstraint = Readonly<{
368
+ name: string;
369
+ fields: readonly string[];
370
+ scope?: "kind" | "kindWithSubClasses";
371
+ collation?: "binary" | "caseInsensitive";
372
+ where?: ExtensionUniqueWhere;
373
+ }>;
374
+ /**
375
+ * Graph-extension declaration of a node kind.
376
+ *
377
+ * Property names follow the same reserved-key rules as compile-time
378
+ * `defineNode` (`id`, `kind`, `meta`, and the `$`-prefix accessor
379
+ * namespace are forbidden). Annotation values must be JSON.
380
+ */
381
+ type ExtensionNodeDef = Readonly<{
382
+ description?: string;
383
+ annotations?: KindAnnotations;
384
+ properties: Readonly<Record<string, ExtensionPropertyType>>;
385
+ unique?: readonly ExtensionUniqueConstraint[];
386
+ }>;
387
+ /**
388
+ * Graph-extension declaration of an edge kind.
389
+ *
390
+ * `from` / `to` reference node kind names — either kinds declared in this
391
+ * same document or compile-time kinds the document is being merged into.
392
+ * Endpoints that resolve to nothing within the document are flagged as
393
+ * soft references at validation time but not rejected; the final
394
+ * cross-graph check happens when the document is merged into a host
395
+ * `GraphDef`.
396
+ */
397
+ type ExtensionEdgeDef = Readonly<{
398
+ description?: string;
399
+ annotations?: KindAnnotations;
400
+ from: readonly string[];
401
+ to: readonly string[];
402
+ properties?: Readonly<Record<string, ExtensionPropertyType>>;
403
+ }>;
404
+ /**
405
+ * Document-level analogue of compile-time `defineNodeIndex` /
406
+ * `defineEdgeIndex`. Mirrors `serializeWherePredicate`'s persistence-
407
+ * round-trippable subset: only `isNull` / `isNotNull` predicates are
408
+ * supported in v1, matching `ExtensionUniqueWhere`.
409
+ */
410
+ type ExtensionIndexWhere = Readonly<{
411
+ field: string;
412
+ op: NullCheckOp;
413
+ }>;
414
+ /**
415
+ * Graph-extension-declared node index. `kind` references either a kind
416
+ * declared in this same document or a compile-time host kind resolved
417
+ * at merge time. `fields` and `coveringFields` are top-level property
418
+ * names — JSON-pointer paths are not supported in v1, matching the
419
+ * `ExtensionUniqueConstraint` v1 surface.
420
+ */
421
+ type ExtensionNodeIndex = Readonly<{
422
+ entity: "node";
423
+ kind: string;
424
+ name?: string;
425
+ fields: readonly string[];
426
+ coveringFields?: readonly string[];
427
+ unique?: boolean;
428
+ scope?: "graphAndKind" | "graph" | "none";
429
+ where?: ExtensionIndexWhere;
430
+ }>;
431
+ /**
432
+ * Graph-extension-declared edge index. `direction` mirrors
433
+ * `EdgeIndexDirection`; `kind` references a graph-extension or compile-time
434
+ * edge kind.
435
+ */
436
+ type ExtensionEdgeIndex = Readonly<{
437
+ entity: "edge";
438
+ kind: string;
439
+ name?: string;
440
+ direction?: "out" | "in" | "none";
441
+ fields: readonly string[];
442
+ coveringFields?: readonly string[];
443
+ unique?: boolean;
444
+ scope?: "graphAndKind" | "graph" | "none";
445
+ where?: ExtensionIndexWhere;
446
+ }>;
447
+ type ExtensionIndex = ExtensionNodeIndex | ExtensionEdgeIndex;
448
+ /**
449
+ * Graph-extension ontology relation. `metaEdge` is one of the built-in
450
+ * meta-edge names (subClassOf, broader, disjointWith, etc.).
451
+ *
452
+ * `from` / `to` are either node-kind names declared in this document or
453
+ * external IRI strings. The pure-value document does not distinguish the
454
+ * two — the compiler treats endpoints that match a declared kind as
455
+ * `NodeType` references and falls back to passing the raw string for
456
+ * IRIs (matching the existing `OntologyRelation` shape, where
457
+ * `from`/`to` are `NodeType | EdgeType | string`).
458
+ */
459
+ type ExtensionOntologyRelation = Readonly<{
460
+ metaEdge: MetaEdgeName;
461
+ from: string;
462
+ to: string;
463
+ }>;
464
+ /**
465
+ * Stable default major used when a stored document omits `version`.
466
+ *
467
+ * Pinned to `1` permanently. Pre-versioning documents (those persisted
468
+ * before the field existed) and documents that explicitly omit
469
+ * `version` are interpreted as `1` regardless of which major the
470
+ * library currently supports. Splitting this from
471
+ * `CURRENT_GRAPH_EXTENSION_VERSION` is load-bearing for future major
472
+ * bumps: when v2 ships, `CURRENT` becomes `2` but `LEGACY` stays at
473
+ * `1`, so a v1-era stored document still parses as v1 (and the
474
+ * version-mismatch path can route it through a migration) rather than
475
+ * being silently misinterpreted as v2.
476
+ */
477
+ declare const LEGACY_GRAPH_EXTENSION_VERSION: 1;
478
+ /**
479
+ * Current major version of the `GraphExtension` format.
480
+ *
481
+ * Documents with a higher major version than this constant are
482
+ * rejected with `GRAPH_EXTENSION_VERSION_UNSUPPORTED` — there is no
483
+ * automatic downgrade path. Minor / additive changes ride forward-
484
+ * compat via `.loose()` on every nested object schema.
485
+ */
486
+ declare const CURRENT_GRAPH_EXTENSION_VERSION: 1;
487
+ /**
488
+ * Type of the `GraphExtension.version` field. Stays `number`
489
+ * rather than `typeof CURRENT_GRAPH_EXTENSION_VERSION` because the
490
+ * field can carry any major across the library version range a
491
+ * stored document might have been written by — the
492
+ * document-vs-supported check happens in the validator, not at the
493
+ * type level. Pinning to the current literal would prevent a v1
494
+ * v1 library from typing a v2 document at all, which is the wrong
495
+ * relationship: we WANT a v1 library to receive v2 documents and
496
+ * report `GRAPH_EXTENSION_VERSION_UNSUPPORTED` cleanly.
497
+ */
498
+ type GraphExtensionVersion = number;
499
+ /**
500
+ * The canonical pure-value graph-extension document.
501
+ *
502
+ * Frozen at construction. Round-trips losslessly through `JSON.stringify`
503
+ * / `JSON.parse`; the `GraphExtension → CompiledExtension` direction
504
+ * is provided by `compileGraphExtension(...)`. There is no
505
+ * `Zod → GraphExtension` direction because graph-extension kinds always
506
+ * originate as documents.
507
+ *
508
+ * `version` is the major-version tag for the document format. The
509
+ * compiler accepts documents whose version is equal to the current
510
+ * supported major (today: 1) or absent (the canonical persisted form
511
+ * omits `version` when it equals the legacy default — see
512
+ * `serializer.ts` — so the round-trip default is "absent means legacy
513
+ * major"). Higher majors surface as
514
+ * `GRAPH_EXTENSION_VERSION_UNSUPPORTED` so a newer-version extension
515
+ * committed by a future writer can't be silently misread by an older
516
+ * runtime. See `graph-extensions.md` for the format-versioning policy.
517
+ */
518
+ type GraphExtension = Readonly<{
519
+ version?: GraphExtensionVersion;
520
+ nodes?: Readonly<Record<string, ExtensionNodeDef>>;
521
+ edges?: Readonly<Record<string, ExtensionEdgeDef>>;
522
+ ontology?: readonly ExtensionOntologyRelation[];
523
+ /**
524
+ * Graph-extension-declared relational indexes. Each entry references a
525
+ * node or edge kind by name — either declared in this document or
526
+ * a compile-time host kind that the document is being merged into.
527
+ * Vector indexes auto-derive from `embedding()` modifiers on
528
+ * graph-extension kinds; this slot is for explicit relational indexes
529
+ * (analogue of compile-time `defineGraph({ indexes: [...] })`).
530
+ */
531
+ indexes?: readonly ExtensionIndex[];
532
+ }>;
533
+ /**
534
+ * Top-level v1 slots a `GraphExtension` document may carry. Single
535
+ * source of truth for both the strict-authoring validator (typo rejection
536
+ * via `defineGraphExtension`) and the persistence Zod schema (which
537
+ * leaves the field set loose for forward compatibility but uses this
538
+ * list to drive the Zod object shape).
539
+ */
540
+ declare const GRAPH_EXTENSION_TOP_LEVEL_KEYS: readonly ["version", "nodes", "edges", "ontology", "indexes"];
541
+ type GraphExtensionTopLevelKey = (typeof GRAPH_EXTENSION_TOP_LEVEL_KEYS)[number];
542
+
543
+ export { type AnyEdgeType as A, type ExtensionIndexWhere as B, type Collation as C, type DeleteBehavior as D, type EdgeRegistration as E, type ExtensionNodeDef as F, type GraphExtension as G, type ExtensionNodeIndex as H, type IndexEntity as I, type JsonValue as J, type KindEntity as K, LEGACY_GRAPH_EXTENSION_VERSION as L, type ExtensionNumberProperty as M, type NodeType as N, type ExtensionObjectFieldProperty as O, type ExtensionObjectProperty as P, type ExtensionOntologyRelation as Q, type ExtensionPropertyType as R, type ExtensionSearchableModifier as S, type TemporalMode as T, type UniquenessScope as U, type ExtensionStringProperty as V, type ExtensionUniqueConstraint as W, type ExtensionUniqueWhere as X, GRAPH_EXTENSION_TOP_LEVEL_KEYS as Y, type GraphExtensionTopLevelKey as Z, type NullCheckOp as a, type NodeRegistration as b, type GraphDefaults as c, type EdgeType as d, type KindAnnotations as e, type Cardinality as f, type EndpointExistence as g, CURRENT_GRAPH_EXTENSION_VERSION as h, type EdgeId as i, type EdgeProps as j, type EdgeTypeWithEndpoints as k, type GraphExtensionVersion as l, type NodeId as m, type NodeProps as n, type UniqueConstraint as o, isEdgeType as p, isEdgeTypeWithEndpoints as q, isNodeType as r, type ExtensionArrayItemType as s, type ExtensionArrayProperty as t, type ExtensionBooleanProperty as u, type ExtensionEdgeDef as v, type ExtensionEdgeIndex as w, type ExtensionEmbeddingModifier as x, type ExtensionEnumProperty as y, type ExtensionIndex as z };