@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,278 @@
1
+ import { G as GraphExtension, K as KindEntity } from '../extension-types-D07e_NTw.cjs';
2
+ export { h as CURRENT_GRAPH_EXTENSION_VERSION, s as ExtensionArrayItemType, t as ExtensionArrayProperty, u as ExtensionBooleanProperty, v as ExtensionEdgeDef, w as ExtensionEdgeIndex, x as ExtensionEmbeddingModifier, y as ExtensionEnumProperty, z as ExtensionIndex, B as ExtensionIndexWhere, F as ExtensionNodeDef, H as ExtensionNodeIndex, M as ExtensionNumberProperty, O as ExtensionObjectFieldProperty, P as ExtensionObjectProperty, Q as ExtensionOntologyRelation, R as ExtensionPropertyType, S as ExtensionSearchableModifier, V as ExtensionStringProperty, W as ExtensionUniqueConstraint, X as ExtensionUniqueWhere, Y as GRAPH_EXTENSION_TOP_LEVEL_KEYS, Z as GraphExtensionTopLevelKey, l as GraphExtensionVersion, L as LEGACY_GRAPH_EXTENSION_VERSION } from '../extension-types-D07e_NTw.cjs';
3
+ import { T as TypeGraphError, h as ErrorCategory } from '../index-CT6nvtxL.cjs';
4
+ import 'zod';
5
+ import '../materialize-indexes-BB9N5uQl.cjs';
6
+
7
+ /**
8
+ * Validates and freezes a graph-extension document.
9
+ *
10
+ * Authoring entry point — runs validation in **strict** mode: unknown
11
+ * top-level keys (e.g. `node` instead of `nodes`) and unsupported
12
+ * string formats (e.g. `"date-time"` with a hyphen instead of
13
+ * `"datetime"`) fail loudly with `UNKNOWN_DOCUMENT_KEY` /
14
+ * `UNSUPPORTED_STRING_FORMAT`. The persistence-load path leaves both
15
+ * checks off so a document committed by a future v1.x writer with
16
+ * additive fields still parses on an older v1 reader. Callers
17
+ * accepting raw JSON from an untyped source (e.g. an LLM proposal)
18
+ * should validate first via `validateGraphExtension` and surface
19
+ * the structured issues, then pass the validated document here.
20
+ *
21
+ * @param input - Document describing additional node kinds, edge
22
+ * kinds, and ontology relations. Must satisfy the v1 property-type
23
+ * subset documented in `ExtensionPropertyType`.
24
+ *
25
+ * @returns The same document, deeply frozen and shape-checked.
26
+ *
27
+ * @throws {GraphExtensionValidationError} when the document violates
28
+ * the v1 property-type subset, references undeclared kinds, contains
29
+ * ontology cycles, etc. The thrown error's `details.issues` array
30
+ * carries every failure with a JSON-pointer path.
31
+ * @throws {GraphExtensionVersionUnsupportedError} when the document
32
+ * declares a future major version this library cannot safely decode.
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const extension = defineGraphExtension({
37
+ * nodes: {
38
+ * Paper: {
39
+ * properties: {
40
+ * doi: { type: "string" },
41
+ * title: { type: "string", searchable: { language: "english" } },
42
+ * },
43
+ * unique: [{ name: "paper_doi", fields: ["doi"] }],
44
+ * },
45
+ * },
46
+ * });
47
+ *
48
+ * const evolved = await store.evolve(extension);
49
+ * const papers = evolved.getNodeCollectionOrThrow("Paper");
50
+ * ```
51
+ */
52
+ declare function defineGraphExtension(input: GraphExtension): GraphExtension;
53
+
54
+ /**
55
+ * Errors raised across the graph-extension surface.
56
+ *
57
+ * Two flavours:
58
+ *
59
+ * - **Validation issues** (`GraphExtensionValidationError` +
60
+ * `GraphExtensionIssue` / `GraphExtensionIssueCode`) — produced by
61
+ * `validateGraphExtension`. The issue list batches every failure
62
+ * with a JSON-pointer `path` so a UI can highlight every offending
63
+ * field at once.
64
+ * - **Operation errors** (every other class in this file, all extending
65
+ * `GraphExtensionError`) — thrown one at a time from `evolve`,
66
+ * `removeKinds`, `materializeIndexes`, search, etc. Each carries a
67
+ * stable string `code` for logging / serialization PLUS a typed
68
+ * shape so consumers can `instanceof` for control flow.
69
+ */
70
+
71
+ /**
72
+ * One specific issue raised during graph-extension validation.
73
+ */
74
+ type GraphExtensionIssue = Readonly<{
75
+ /**
76
+ * JSON-pointer path to the offending value, rooted at the document
77
+ * (e.g. `/nodes/Paper/properties/title/pattern`). The empty string
78
+ * `""` means "the document itself".
79
+ */
80
+ path: string;
81
+ /** Human-readable explanation of the failure. */
82
+ message: string;
83
+ /**
84
+ * Stable machine-readable code so callers (and tests) can branch on
85
+ * specific failure modes without parsing messages. New codes are
86
+ * additive.
87
+ */
88
+ code: GraphExtensionIssueCode;
89
+ }>;
90
+ /**
91
+ * Stable machine codes for every validation failure produced by the
92
+ * document validator. New codes are additive — existing codes never
93
+ * change meaning.
94
+ *
95
+ * Note: codes here describe per-field validation problems. Operation-
96
+ * level errors (kind not found, version mismatch on persisted doc,
97
+ * compile-time-kind removal, etc.) surface as typed Error subclasses
98
+ * exported below — not as issue codes.
99
+ */
100
+ /**
101
+ * Every issue code emitted by `validateGraphExtension`. Const-array form
102
+ * so tests, codegen, and runtime introspection can iterate the full set
103
+ * without restating it.
104
+ */
105
+ declare const GRAPH_EXTENSION_ISSUE_CODES: readonly ["UNSUPPORTED_PROPERTY_TYPE", "INVALID_PROPERTY_REFINEMENT", "NESTED_ARRAY", "NESTED_OBJECT_TOO_DEEP", "INVALID_MODIFIER_TARGET", "INVALID_ENUM_VALUES", "INVALID_NUMBER_BOUNDS", "INVALID_LENGTH_BOUNDS", "INVALID_PATTERN", "INVALID_EMBEDDING_DIMENSIONS", "INVALID_SEARCHABLE_LANGUAGE", "RESERVED_PROPERTY_NAME", "INVALID_KIND_NAME", "DUPLICATE_KIND_NAME", "EMPTY_PROPERTIES", "EMPTY_FROM_OR_TO", "DUPLICATE_UNIQUE_CONSTRAINT", "EMPTY_UNIQUE_FIELDS", "DUPLICATE_UNIQUE_FIELD", "UNKNOWN_UNIQUE_FIELD", "INVALID_UNIQUE_WHERE_OP", "UNKNOWN_UNIQUE_WHERE_FIELD", "INVALID_ANNOTATION", "UNKNOWN_META_EDGE", "ONTOLOGY_CYCLE", "ONTOLOGY_SELF_LOOP", "ONTOLOGY_DISJOINT_CONFLICT", "DUPLICATE_ONTOLOGY_RELATION", "INVALID_DOCUMENT_SHAPE", "UNKNOWN_DOCUMENT_KEY", "UNSUPPORTED_STRING_FORMAT", "INVALID_INDEX_DECLARATION", "DUPLICATE_INDEX_NAME", "EMPTY_INDEX_FIELDS", "UNKNOWN_PROPERTY_KEY"];
106
+ type GraphExtensionIssueCode = (typeof GRAPH_EXTENSION_ISSUE_CODES)[number];
107
+ /**
108
+ * Base class for every graph-extension error. Consumers can catch
109
+ * the family with one `instanceof GraphExtensionError` check and
110
+ * branch on the concrete subclass beneath. Carries the same
111
+ * `code` / `category` / `details` slots as `TypeGraphError` so existing
112
+ * `isTypeGraphError` / `isUserRecoverable` helpers continue to apply.
113
+ */
114
+ declare abstract class GraphExtensionError extends TypeGraphError {
115
+ readonly code: string;
116
+ protected constructor(spec: {
117
+ message: string;
118
+ code: string;
119
+ details: Readonly<Record<string, unknown>>;
120
+ suggestion: string;
121
+ category?: ErrorCategory;
122
+ cause?: unknown;
123
+ });
124
+ }
125
+ /**
126
+ * Thrown when `validateGraphExtension` (or `defineGraphExtension`)
127
+ * rejects an input document for one or more shape/content reasons.
128
+ *
129
+ * The `issues` array carries every failure with a JSON-pointer
130
+ * `path`, so callers presenting the document to a human reviewer can
131
+ * highlight every offending field at once.
132
+ */
133
+ declare class GraphExtensionValidationError extends GraphExtensionError {
134
+ readonly code: "GRAPH_EXTENSION_INVALID";
135
+ readonly issues: readonly GraphExtensionIssue[];
136
+ readonly details: Readonly<{
137
+ issues: readonly GraphExtensionIssue[];
138
+ }>;
139
+ constructor(issues: readonly GraphExtensionIssue[], cause?: unknown);
140
+ }
141
+ /**
142
+ * Thrown when an extension declares a kind whose name collides with an
143
+ * existing compile-time kind. The graph-extension contract is
144
+ * additive: graph-extension-declared kinds cannot shadow compile-time kinds.
145
+ */
146
+ declare class KindCollisionError extends GraphExtensionError {
147
+ readonly code: "KIND_COLLISION";
148
+ readonly kindName: string;
149
+ readonly entity: KindEntity;
150
+ constructor(kindName: string, entity: KindEntity, graphId: string);
151
+ }
152
+ /**
153
+ * One classified delta in a `IncompatibleChangeError`.
154
+ *
155
+ * `field` is `undefined` for kind-level changes (e.g. tightening edge
156
+ * endpoints, adding a unique constraint to a populated kind). `detail`
157
+ * is human-readable and intended for surfaces showing the change to a
158
+ * reviewer (e.g. `"minLength: 5 → 10"`).
159
+ */
160
+ /**
161
+ * Every incompatible-change classification produced by `evolve`'s
162
+ * delta classifier. Const-array form so tests and reviewer UIs can
163
+ * enumerate the set without restating it.
164
+ */
165
+ declare const INCOMPATIBLE_CHANGE_TYPES: readonly ["REMOVE_PROPERTY", "ADD_REQUIRED_PROPERTY", "TIGHTEN_OPTIONALITY", "TIGHTEN_CONSTRAINT", "ADD_PATTERN", "CHANGE_PATTERN", "ADD_FORMAT", "CHANGE_FORMAT", "TIGHTEN_INT", "TIGHTEN_ENUM", "TYPE_CHANGE", "ADD_UNIQUE_ON_POPULATED", "TIGHTEN_EDGE_ENDPOINTS"];
166
+ type IncompatibleChangeType = (typeof INCOMPATIBLE_CHANGE_TYPES)[number];
167
+ type IncompatibleChange = Readonly<{
168
+ kind: string;
169
+ field?: string;
170
+ type: IncompatibleChangeType;
171
+ detail?: string;
172
+ }>;
173
+ /**
174
+ * Thrown when `evolve` rejects one or more deltas against an existing
175
+ * extension kind. Carries a structured `changes` list so a reviewer
176
+ * UI can show the incompatible deltas across every affected kind in
177
+ * one shot.
178
+ */
179
+ declare class IncompatibleChangeError extends GraphExtensionError {
180
+ readonly code: "INCOMPATIBLE_CHANGE";
181
+ readonly changes: readonly IncompatibleChange[];
182
+ constructor(changes: readonly IncompatibleChange[], graphId: string);
183
+ }
184
+ /**
185
+ * Thrown when an extension's edge or ontology endpoint references a
186
+ * kind that exists in neither the extension nor the host graph.
187
+ * Distinct from `KindNotFoundError` because the cause is a
188
+ * stale persisted extension (a compile-time kind was removed from
189
+ * source after the extension was committed) rather than a
190
+ * call-site typo.
191
+ */
192
+ declare class GraphExtensionUnresolvedEndpointError extends GraphExtensionError {
193
+ readonly code: "GRAPH_EXTENSION_UNRESOLVED_ENDPOINT";
194
+ readonly edgeKind: string;
195
+ readonly side: "from" | "to";
196
+ readonly endpoint: string;
197
+ constructor(edgeKind: string, side: "from" | "to", endpoint: string, graphId: string);
198
+ }
199
+ /**
200
+ * Thrown by `removeKinds` when the removal list contains a compile-
201
+ * time kind. Compile-time kinds are removed by recompiling and
202
+ * redeploying — persisting "removed-compile-time-kind" state in
203
+ * `schema_doc` is incoherent because the kind would resurrect on the
204
+ * next deploy.
205
+ */
206
+ declare class RemoveCompileTimeKindError extends GraphExtensionError {
207
+ readonly code: "REMOVE_COMPILE_TIME_KIND";
208
+ readonly kindName: string;
209
+ readonly entity: KindEntity;
210
+ constructor(kindName: string, entity: KindEntity, graphId: string);
211
+ }
212
+ /**
213
+ * Thrown by `removeKinds` when a compile-time edge or ontology
214
+ * relation references the graph-extension kind being removed. Removing the
215
+ * kind would orphan compile-time references — incoherent at the next
216
+ * deploy.
217
+ */
218
+ declare class KindHasReferentsError extends GraphExtensionError {
219
+ readonly code: "KIND_HAS_REFERENTS";
220
+ readonly kindName: string;
221
+ readonly referents: readonly KindReferent[];
222
+ constructor(kindName: string, referents: readonly KindReferent[], graphId: string);
223
+ }
224
+ type KindReferent = Readonly<{
225
+ type: "compile-time-edge" | "compile-time-ontology";
226
+ name: string;
227
+ }>;
228
+ /**
229
+ * Thrown when a persisted graph extension was authored against a
230
+ * higher major version of the graph-extension format than the
231
+ * current library supports. The library refuses to load it rather
232
+ * than risk silently misreading newer fields.
233
+ */
234
+ declare class GraphExtensionVersionUnsupportedError extends GraphExtensionError {
235
+ readonly code: "GRAPH_EXTENSION_VERSION_UNSUPPORTED";
236
+ readonly persistedVersion: number;
237
+ readonly currentVersion: number;
238
+ constructor(persistedVersion: number, currentVersion: number);
239
+ }
240
+
241
+ /**
242
+ * Result type for error handling without exceptions.
243
+ * Use at service boundaries and for operations that can fail.
244
+ */
245
+ type Result<T, E = Error> = Readonly<{
246
+ success: true;
247
+ data: T;
248
+ }> | Readonly<{
249
+ success: false;
250
+ error: E;
251
+ }>;
252
+
253
+ type ValidateGraphExtensionOptions = Readonly<{
254
+ /**
255
+ * Reject unknown top-level keys and unsupported string formats.
256
+ * Used by `defineGraphExtension`, where the document is being
257
+ * authored fresh against the current library version — typos in
258
+ * `nodes` / `format: "date-time"` etc. should fail loudly. The
259
+ * persistence-load path leaves this off so a document committed by
260
+ * a future v1.x writer with additive fields still parses on an
261
+ * older v1 reader.
262
+ */
263
+ strict?: boolean;
264
+ }>;
265
+ /**
266
+ * Validates a graph extension.
267
+ *
268
+ * Returns the (frozen, deeply normalized) extension on success, or a
269
+ * `GraphExtensionValidationError` carrying every issue on authoring
270
+ * failure. Unsupported future major versions throw
271
+ * `GraphExtensionVersionUnsupportedError` immediately because the
272
+ * current library cannot safely decode the rest of the document.
273
+ * Callers that prefer exceptions for validation failures wrap the
274
+ * returned `Result` with `unwrap()`.
275
+ */
276
+ declare function validateGraphExtension(input: unknown, options?: ValidateGraphExtensionOptions): Result<GraphExtension, GraphExtensionValidationError>;
277
+
278
+ export { GRAPH_EXTENSION_ISSUE_CODES, GraphExtension, GraphExtensionError, type GraphExtensionIssue, type GraphExtensionIssueCode, GraphExtensionUnresolvedEndpointError, GraphExtensionValidationError, GraphExtensionVersionUnsupportedError, INCOMPATIBLE_CHANGE_TYPES, type IncompatibleChange, IncompatibleChangeError, type IncompatibleChangeType, KindCollisionError, KindHasReferentsError, type KindReferent, RemoveCompileTimeKindError, defineGraphExtension, validateGraphExtension };
@@ -0,0 +1,278 @@
1
+ import { G as GraphExtension, K as KindEntity } from '../extension-types-D07e_NTw.js';
2
+ export { h as CURRENT_GRAPH_EXTENSION_VERSION, s as ExtensionArrayItemType, t as ExtensionArrayProperty, u as ExtensionBooleanProperty, v as ExtensionEdgeDef, w as ExtensionEdgeIndex, x as ExtensionEmbeddingModifier, y as ExtensionEnumProperty, z as ExtensionIndex, B as ExtensionIndexWhere, F as ExtensionNodeDef, H as ExtensionNodeIndex, M as ExtensionNumberProperty, O as ExtensionObjectFieldProperty, P as ExtensionObjectProperty, Q as ExtensionOntologyRelation, R as ExtensionPropertyType, S as ExtensionSearchableModifier, V as ExtensionStringProperty, W as ExtensionUniqueConstraint, X as ExtensionUniqueWhere, Y as GRAPH_EXTENSION_TOP_LEVEL_KEYS, Z as GraphExtensionTopLevelKey, l as GraphExtensionVersion, L as LEGACY_GRAPH_EXTENSION_VERSION } from '../extension-types-D07e_NTw.js';
3
+ import { T as TypeGraphError, h as ErrorCategory } from '../index-DQheiVQV.js';
4
+ import 'zod';
5
+ import '../materialize-indexes-BYpU2RKh.js';
6
+
7
+ /**
8
+ * Validates and freezes a graph-extension document.
9
+ *
10
+ * Authoring entry point — runs validation in **strict** mode: unknown
11
+ * top-level keys (e.g. `node` instead of `nodes`) and unsupported
12
+ * string formats (e.g. `"date-time"` with a hyphen instead of
13
+ * `"datetime"`) fail loudly with `UNKNOWN_DOCUMENT_KEY` /
14
+ * `UNSUPPORTED_STRING_FORMAT`. The persistence-load path leaves both
15
+ * checks off so a document committed by a future v1.x writer with
16
+ * additive fields still parses on an older v1 reader. Callers
17
+ * accepting raw JSON from an untyped source (e.g. an LLM proposal)
18
+ * should validate first via `validateGraphExtension` and surface
19
+ * the structured issues, then pass the validated document here.
20
+ *
21
+ * @param input - Document describing additional node kinds, edge
22
+ * kinds, and ontology relations. Must satisfy the v1 property-type
23
+ * subset documented in `ExtensionPropertyType`.
24
+ *
25
+ * @returns The same document, deeply frozen and shape-checked.
26
+ *
27
+ * @throws {GraphExtensionValidationError} when the document violates
28
+ * the v1 property-type subset, references undeclared kinds, contains
29
+ * ontology cycles, etc. The thrown error's `details.issues` array
30
+ * carries every failure with a JSON-pointer path.
31
+ * @throws {GraphExtensionVersionUnsupportedError} when the document
32
+ * declares a future major version this library cannot safely decode.
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const extension = defineGraphExtension({
37
+ * nodes: {
38
+ * Paper: {
39
+ * properties: {
40
+ * doi: { type: "string" },
41
+ * title: { type: "string", searchable: { language: "english" } },
42
+ * },
43
+ * unique: [{ name: "paper_doi", fields: ["doi"] }],
44
+ * },
45
+ * },
46
+ * });
47
+ *
48
+ * const evolved = await store.evolve(extension);
49
+ * const papers = evolved.getNodeCollectionOrThrow("Paper");
50
+ * ```
51
+ */
52
+ declare function defineGraphExtension(input: GraphExtension): GraphExtension;
53
+
54
+ /**
55
+ * Errors raised across the graph-extension surface.
56
+ *
57
+ * Two flavours:
58
+ *
59
+ * - **Validation issues** (`GraphExtensionValidationError` +
60
+ * `GraphExtensionIssue` / `GraphExtensionIssueCode`) — produced by
61
+ * `validateGraphExtension`. The issue list batches every failure
62
+ * with a JSON-pointer `path` so a UI can highlight every offending
63
+ * field at once.
64
+ * - **Operation errors** (every other class in this file, all extending
65
+ * `GraphExtensionError`) — thrown one at a time from `evolve`,
66
+ * `removeKinds`, `materializeIndexes`, search, etc. Each carries a
67
+ * stable string `code` for logging / serialization PLUS a typed
68
+ * shape so consumers can `instanceof` for control flow.
69
+ */
70
+
71
+ /**
72
+ * One specific issue raised during graph-extension validation.
73
+ */
74
+ type GraphExtensionIssue = Readonly<{
75
+ /**
76
+ * JSON-pointer path to the offending value, rooted at the document
77
+ * (e.g. `/nodes/Paper/properties/title/pattern`). The empty string
78
+ * `""` means "the document itself".
79
+ */
80
+ path: string;
81
+ /** Human-readable explanation of the failure. */
82
+ message: string;
83
+ /**
84
+ * Stable machine-readable code so callers (and tests) can branch on
85
+ * specific failure modes without parsing messages. New codes are
86
+ * additive.
87
+ */
88
+ code: GraphExtensionIssueCode;
89
+ }>;
90
+ /**
91
+ * Stable machine codes for every validation failure produced by the
92
+ * document validator. New codes are additive — existing codes never
93
+ * change meaning.
94
+ *
95
+ * Note: codes here describe per-field validation problems. Operation-
96
+ * level errors (kind not found, version mismatch on persisted doc,
97
+ * compile-time-kind removal, etc.) surface as typed Error subclasses
98
+ * exported below — not as issue codes.
99
+ */
100
+ /**
101
+ * Every issue code emitted by `validateGraphExtension`. Const-array form
102
+ * so tests, codegen, and runtime introspection can iterate the full set
103
+ * without restating it.
104
+ */
105
+ declare const GRAPH_EXTENSION_ISSUE_CODES: readonly ["UNSUPPORTED_PROPERTY_TYPE", "INVALID_PROPERTY_REFINEMENT", "NESTED_ARRAY", "NESTED_OBJECT_TOO_DEEP", "INVALID_MODIFIER_TARGET", "INVALID_ENUM_VALUES", "INVALID_NUMBER_BOUNDS", "INVALID_LENGTH_BOUNDS", "INVALID_PATTERN", "INVALID_EMBEDDING_DIMENSIONS", "INVALID_SEARCHABLE_LANGUAGE", "RESERVED_PROPERTY_NAME", "INVALID_KIND_NAME", "DUPLICATE_KIND_NAME", "EMPTY_PROPERTIES", "EMPTY_FROM_OR_TO", "DUPLICATE_UNIQUE_CONSTRAINT", "EMPTY_UNIQUE_FIELDS", "DUPLICATE_UNIQUE_FIELD", "UNKNOWN_UNIQUE_FIELD", "INVALID_UNIQUE_WHERE_OP", "UNKNOWN_UNIQUE_WHERE_FIELD", "INVALID_ANNOTATION", "UNKNOWN_META_EDGE", "ONTOLOGY_CYCLE", "ONTOLOGY_SELF_LOOP", "ONTOLOGY_DISJOINT_CONFLICT", "DUPLICATE_ONTOLOGY_RELATION", "INVALID_DOCUMENT_SHAPE", "UNKNOWN_DOCUMENT_KEY", "UNSUPPORTED_STRING_FORMAT", "INVALID_INDEX_DECLARATION", "DUPLICATE_INDEX_NAME", "EMPTY_INDEX_FIELDS", "UNKNOWN_PROPERTY_KEY"];
106
+ type GraphExtensionIssueCode = (typeof GRAPH_EXTENSION_ISSUE_CODES)[number];
107
+ /**
108
+ * Base class for every graph-extension error. Consumers can catch
109
+ * the family with one `instanceof GraphExtensionError` check and
110
+ * branch on the concrete subclass beneath. Carries the same
111
+ * `code` / `category` / `details` slots as `TypeGraphError` so existing
112
+ * `isTypeGraphError` / `isUserRecoverable` helpers continue to apply.
113
+ */
114
+ declare abstract class GraphExtensionError extends TypeGraphError {
115
+ readonly code: string;
116
+ protected constructor(spec: {
117
+ message: string;
118
+ code: string;
119
+ details: Readonly<Record<string, unknown>>;
120
+ suggestion: string;
121
+ category?: ErrorCategory;
122
+ cause?: unknown;
123
+ });
124
+ }
125
+ /**
126
+ * Thrown when `validateGraphExtension` (or `defineGraphExtension`)
127
+ * rejects an input document for one or more shape/content reasons.
128
+ *
129
+ * The `issues` array carries every failure with a JSON-pointer
130
+ * `path`, so callers presenting the document to a human reviewer can
131
+ * highlight every offending field at once.
132
+ */
133
+ declare class GraphExtensionValidationError extends GraphExtensionError {
134
+ readonly code: "GRAPH_EXTENSION_INVALID";
135
+ readonly issues: readonly GraphExtensionIssue[];
136
+ readonly details: Readonly<{
137
+ issues: readonly GraphExtensionIssue[];
138
+ }>;
139
+ constructor(issues: readonly GraphExtensionIssue[], cause?: unknown);
140
+ }
141
+ /**
142
+ * Thrown when an extension declares a kind whose name collides with an
143
+ * existing compile-time kind. The graph-extension contract is
144
+ * additive: graph-extension-declared kinds cannot shadow compile-time kinds.
145
+ */
146
+ declare class KindCollisionError extends GraphExtensionError {
147
+ readonly code: "KIND_COLLISION";
148
+ readonly kindName: string;
149
+ readonly entity: KindEntity;
150
+ constructor(kindName: string, entity: KindEntity, graphId: string);
151
+ }
152
+ /**
153
+ * One classified delta in a `IncompatibleChangeError`.
154
+ *
155
+ * `field` is `undefined` for kind-level changes (e.g. tightening edge
156
+ * endpoints, adding a unique constraint to a populated kind). `detail`
157
+ * is human-readable and intended for surfaces showing the change to a
158
+ * reviewer (e.g. `"minLength: 5 → 10"`).
159
+ */
160
+ /**
161
+ * Every incompatible-change classification produced by `evolve`'s
162
+ * delta classifier. Const-array form so tests and reviewer UIs can
163
+ * enumerate the set without restating it.
164
+ */
165
+ declare const INCOMPATIBLE_CHANGE_TYPES: readonly ["REMOVE_PROPERTY", "ADD_REQUIRED_PROPERTY", "TIGHTEN_OPTIONALITY", "TIGHTEN_CONSTRAINT", "ADD_PATTERN", "CHANGE_PATTERN", "ADD_FORMAT", "CHANGE_FORMAT", "TIGHTEN_INT", "TIGHTEN_ENUM", "TYPE_CHANGE", "ADD_UNIQUE_ON_POPULATED", "TIGHTEN_EDGE_ENDPOINTS"];
166
+ type IncompatibleChangeType = (typeof INCOMPATIBLE_CHANGE_TYPES)[number];
167
+ type IncompatibleChange = Readonly<{
168
+ kind: string;
169
+ field?: string;
170
+ type: IncompatibleChangeType;
171
+ detail?: string;
172
+ }>;
173
+ /**
174
+ * Thrown when `evolve` rejects one or more deltas against an existing
175
+ * extension kind. Carries a structured `changes` list so a reviewer
176
+ * UI can show the incompatible deltas across every affected kind in
177
+ * one shot.
178
+ */
179
+ declare class IncompatibleChangeError extends GraphExtensionError {
180
+ readonly code: "INCOMPATIBLE_CHANGE";
181
+ readonly changes: readonly IncompatibleChange[];
182
+ constructor(changes: readonly IncompatibleChange[], graphId: string);
183
+ }
184
+ /**
185
+ * Thrown when an extension's edge or ontology endpoint references a
186
+ * kind that exists in neither the extension nor the host graph.
187
+ * Distinct from `KindNotFoundError` because the cause is a
188
+ * stale persisted extension (a compile-time kind was removed from
189
+ * source after the extension was committed) rather than a
190
+ * call-site typo.
191
+ */
192
+ declare class GraphExtensionUnresolvedEndpointError extends GraphExtensionError {
193
+ readonly code: "GRAPH_EXTENSION_UNRESOLVED_ENDPOINT";
194
+ readonly edgeKind: string;
195
+ readonly side: "from" | "to";
196
+ readonly endpoint: string;
197
+ constructor(edgeKind: string, side: "from" | "to", endpoint: string, graphId: string);
198
+ }
199
+ /**
200
+ * Thrown by `removeKinds` when the removal list contains a compile-
201
+ * time kind. Compile-time kinds are removed by recompiling and
202
+ * redeploying — persisting "removed-compile-time-kind" state in
203
+ * `schema_doc` is incoherent because the kind would resurrect on the
204
+ * next deploy.
205
+ */
206
+ declare class RemoveCompileTimeKindError extends GraphExtensionError {
207
+ readonly code: "REMOVE_COMPILE_TIME_KIND";
208
+ readonly kindName: string;
209
+ readonly entity: KindEntity;
210
+ constructor(kindName: string, entity: KindEntity, graphId: string);
211
+ }
212
+ /**
213
+ * Thrown by `removeKinds` when a compile-time edge or ontology
214
+ * relation references the graph-extension kind being removed. Removing the
215
+ * kind would orphan compile-time references — incoherent at the next
216
+ * deploy.
217
+ */
218
+ declare class KindHasReferentsError extends GraphExtensionError {
219
+ readonly code: "KIND_HAS_REFERENTS";
220
+ readonly kindName: string;
221
+ readonly referents: readonly KindReferent[];
222
+ constructor(kindName: string, referents: readonly KindReferent[], graphId: string);
223
+ }
224
+ type KindReferent = Readonly<{
225
+ type: "compile-time-edge" | "compile-time-ontology";
226
+ name: string;
227
+ }>;
228
+ /**
229
+ * Thrown when a persisted graph extension was authored against a
230
+ * higher major version of the graph-extension format than the
231
+ * current library supports. The library refuses to load it rather
232
+ * than risk silently misreading newer fields.
233
+ */
234
+ declare class GraphExtensionVersionUnsupportedError extends GraphExtensionError {
235
+ readonly code: "GRAPH_EXTENSION_VERSION_UNSUPPORTED";
236
+ readonly persistedVersion: number;
237
+ readonly currentVersion: number;
238
+ constructor(persistedVersion: number, currentVersion: number);
239
+ }
240
+
241
+ /**
242
+ * Result type for error handling without exceptions.
243
+ * Use at service boundaries and for operations that can fail.
244
+ */
245
+ type Result<T, E = Error> = Readonly<{
246
+ success: true;
247
+ data: T;
248
+ }> | Readonly<{
249
+ success: false;
250
+ error: E;
251
+ }>;
252
+
253
+ type ValidateGraphExtensionOptions = Readonly<{
254
+ /**
255
+ * Reject unknown top-level keys and unsupported string formats.
256
+ * Used by `defineGraphExtension`, where the document is being
257
+ * authored fresh against the current library version — typos in
258
+ * `nodes` / `format: "date-time"` etc. should fail loudly. The
259
+ * persistence-load path leaves this off so a document committed by
260
+ * a future v1.x writer with additive fields still parses on an
261
+ * older v1 reader.
262
+ */
263
+ strict?: boolean;
264
+ }>;
265
+ /**
266
+ * Validates a graph extension.
267
+ *
268
+ * Returns the (frozen, deeply normalized) extension on success, or a
269
+ * `GraphExtensionValidationError` carrying every issue on authoring
270
+ * failure. Unsupported future major versions throw
271
+ * `GraphExtensionVersionUnsupportedError` immediately because the
272
+ * current library cannot safely decode the rest of the document.
273
+ * Callers that prefer exceptions for validation failures wrap the
274
+ * returned `Result` with `unwrap()`.
275
+ */
276
+ declare function validateGraphExtension(input: unknown, options?: ValidateGraphExtensionOptions): Result<GraphExtension, GraphExtensionValidationError>;
277
+
278
+ export { GRAPH_EXTENSION_ISSUE_CODES, GraphExtension, GraphExtensionError, type GraphExtensionIssue, type GraphExtensionIssueCode, GraphExtensionUnresolvedEndpointError, GraphExtensionValidationError, GraphExtensionVersionUnsupportedError, INCOMPATIBLE_CHANGE_TYPES, type IncompatibleChange, IncompatibleChangeError, type IncompatibleChangeType, KindCollisionError, KindHasReferentsError, type KindReferent, RemoveCompileTimeKindError, defineGraphExtension, validateGraphExtension };
@@ -0,0 +1,6 @@
1
+ export { defineGraphExtension } from '../chunk-NHQWXSTS.js';
2
+ export { CURRENT_GRAPH_EXTENSION_VERSION, GRAPH_EXTENSION_ISSUE_CODES, GRAPH_EXTENSION_TOP_LEVEL_KEYS, GraphExtensionError, GraphExtensionUnresolvedEndpointError, GraphExtensionValidationError, GraphExtensionVersionUnsupportedError, INCOMPATIBLE_CHANGE_TYPES, IncompatibleChangeError, KindCollisionError, KindHasReferentsError, LEGACY_GRAPH_EXTENSION_VERSION, RemoveCompileTimeKindError, validateGraphExtension } from '../chunk-4BOWVUGQ.js';
3
+ import '../chunk-DOTEN2FG.js';
4
+ import '../chunk-NZ5PMBTG.js';
5
+ //# sourceMappingURL=index.js.map
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}