@nicia-ai/typegraph 0.3.0 → 0.4.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 (75) hide show
  1. package/dist/backend/drizzle/index.cjs +6 -6
  2. package/dist/backend/drizzle/index.d.cts +1 -1
  3. package/dist/backend/drizzle/index.d.ts +1 -1
  4. package/dist/backend/drizzle/index.js +4 -4
  5. package/dist/backend/drizzle/postgres.cjs +4 -4
  6. package/dist/backend/drizzle/postgres.d.cts +2 -2
  7. package/dist/backend/drizzle/postgres.d.ts +2 -2
  8. package/dist/backend/drizzle/postgres.js +3 -3
  9. package/dist/backend/drizzle/sqlite.cjs +4 -4
  10. package/dist/backend/drizzle/sqlite.d.cts +1 -1
  11. package/dist/backend/drizzle/sqlite.d.ts +1 -1
  12. package/dist/backend/drizzle/sqlite.js +3 -3
  13. package/dist/backend/postgres/index.cjs +4 -4
  14. package/dist/backend/postgres/index.d.cts +1 -1
  15. package/dist/backend/postgres/index.d.ts +1 -1
  16. package/dist/backend/postgres/index.js +3 -3
  17. package/dist/backend/sqlite/index.cjs +6 -6
  18. package/dist/backend/sqlite/index.d.cts +1 -1
  19. package/dist/backend/sqlite/index.d.ts +1 -1
  20. package/dist/backend/sqlite/index.js +4 -4
  21. package/dist/{chunk-OYL2SGBD.cjs → chunk-44SXEVF4.cjs} +18 -2
  22. package/dist/chunk-44SXEVF4.cjs.map +1 -0
  23. package/dist/{chunk-SFY2PPOY.cjs → chunk-7RVSDXT3.cjs} +50 -10
  24. package/dist/chunk-7RVSDXT3.cjs.map +1 -0
  25. package/dist/{chunk-ZJHQZZT2.cjs → chunk-K2ROKOK3.cjs} +6 -6
  26. package/dist/{chunk-ZJHQZZT2.cjs.map → chunk-K2ROKOK3.cjs.map} +1 -1
  27. package/dist/{chunk-DD6ONEBN.cjs → chunk-LDM2AFKZ.cjs} +12 -12
  28. package/dist/{chunk-DD6ONEBN.cjs.map → chunk-LDM2AFKZ.cjs.map} +1 -1
  29. package/dist/{chunk-V7CS2MDB.cjs → chunk-LUARLSYT.cjs} +18 -18
  30. package/dist/chunk-LUARLSYT.cjs.map +1 -0
  31. package/dist/{chunk-NP4G4ZKM.js → chunk-M5SOQ7UV.js} +4 -4
  32. package/dist/{chunk-NP4G4ZKM.js.map → chunk-M5SOQ7UV.js.map} +1 -1
  33. package/dist/{chunk-CMHFS34N.cjs → chunk-NYDXJGA3.cjs} +16 -16
  34. package/dist/{chunk-CMHFS34N.cjs.map → chunk-NYDXJGA3.cjs.map} +1 -1
  35. package/dist/{chunk-WE5BKYNB.js → chunk-Q6PXIKRQ.js} +3 -3
  36. package/dist/chunk-Q6PXIKRQ.js.map +1 -0
  37. package/dist/{chunk-O5XPCJLF.js → chunk-SJ2QMDXY.js} +18 -3
  38. package/dist/chunk-SJ2QMDXY.js.map +1 -0
  39. package/dist/{chunk-XDTYTNYL.js → chunk-TGDFBLGS.js} +3 -3
  40. package/dist/{chunk-XDTYTNYL.js.map → chunk-TGDFBLGS.js.map} +1 -1
  41. package/dist/{chunk-F2BZSEFE.js → chunk-ZO2FRJ2U.js} +4 -4
  42. package/dist/{chunk-F2BZSEFE.js.map → chunk-ZO2FRJ2U.js.map} +1 -1
  43. package/dist/{chunk-4HARSV2G.js → chunk-ZQGOBVXZ.js} +43 -3
  44. package/dist/chunk-ZQGOBVXZ.js.map +1 -0
  45. package/dist/{index-Dkicw49A.d.ts → index-DyrR_d-H.d.cts} +9 -1
  46. package/dist/{index-Dkicw49A.d.cts → index-DyrR_d-H.d.ts} +9 -1
  47. package/dist/index.cjs +893 -218
  48. package/dist/index.cjs.map +1 -1
  49. package/dist/index.d.cts +7 -7
  50. package/dist/index.d.ts +7 -7
  51. package/dist/index.js +687 -16
  52. package/dist/index.js.map +1 -1
  53. package/dist/interchange/index.cjs +7 -7
  54. package/dist/interchange/index.d.cts +3 -3
  55. package/dist/interchange/index.d.ts +3 -3
  56. package/dist/interchange/index.js +2 -2
  57. package/dist/{manager-Jc5Btay9.d.cts → manager-0NysX4s6.d.cts} +1 -1
  58. package/dist/{manager-e9LXthrx.d.ts → manager-DFKe7ql3.d.ts} +1 -1
  59. package/dist/profiler/index.d.cts +3 -3
  60. package/dist/profiler/index.d.ts +3 -3
  61. package/dist/schema/index.cjs +22 -22
  62. package/dist/schema/index.d.cts +5 -5
  63. package/dist/schema/index.d.ts +5 -5
  64. package/dist/schema/index.js +4 -4
  65. package/dist/{store-nbBybLWP.d.cts → store-DhoA5uRc.d.cts} +93 -7
  66. package/dist/{store-DM3Tk3Pw.d.ts → store-SiovWEYA.d.ts} +93 -7
  67. package/dist/{types-Cdbi4hcx.d.ts → types-6EKrWTs9.d.ts} +14 -0
  68. package/dist/{types-DDP0MGBF.d.cts → types-BUy-pHKH.d.cts} +14 -0
  69. package/package.json +2 -2
  70. package/dist/chunk-4HARSV2G.js.map +0 -1
  71. package/dist/chunk-O5XPCJLF.js.map +0 -1
  72. package/dist/chunk-OYL2SGBD.cjs.map +0 -1
  73. package/dist/chunk-SFY2PPOY.cjs.map +0 -1
  74. package/dist/chunk-V7CS2MDB.cjs.map +0 -1
  75. package/dist/chunk-WE5BKYNB.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkDD6ONEBN_cjs = require('./chunk-DD6ONEBN.cjs');
4
- var chunkZJHQZZT2_cjs = require('./chunk-ZJHQZZT2.cjs');
5
- var chunkOYL2SGBD_cjs = require('./chunk-OYL2SGBD.cjs');
3
+ var chunkLDM2AFKZ_cjs = require('./chunk-LDM2AFKZ.cjs');
4
+ var chunkK2ROKOK3_cjs = require('./chunk-K2ROKOK3.cjs');
5
+ var chunk44SXEVF4_cjs = require('./chunk-44SXEVF4.cjs');
6
6
  var chunk2WVFEIHR_cjs = require('./chunk-2WVFEIHR.cjs');
7
7
  var chunkP5CNM325_cjs = require('./chunk-P5CNM325.cjs');
8
8
  var zod = require('zod');
@@ -17,7 +17,7 @@ function validateSchemaKeys(schema, name) {
17
17
  (key) => RESERVED_NODE_KEYS.has(key)
18
18
  );
19
19
  if (conflicts.length > 0) {
20
- throw new chunkOYL2SGBD_cjs.ConfigurationError(
20
+ throw new chunk44SXEVF4_cjs.ConfigurationError(
21
21
  `Node "${name}" schema contains reserved property names: ${conflicts.join(", ")}`,
22
22
  { nodeType: name, conflicts, reservedKeys: [...RESERVED_NODE_KEYS] },
23
23
  {
@@ -29,7 +29,7 @@ function validateSchemaKeys(schema, name) {
29
29
  function defineNode(name, options) {
30
30
  validateSchemaKeys(options.schema, name);
31
31
  return Object.freeze({
32
- [chunkZJHQZZT2_cjs.NODE_TYPE_BRAND]: true,
32
+ [chunkK2ROKOK3_cjs.NODE_TYPE_BRAND]: true,
33
33
  kind: name,
34
34
  schema: options.schema,
35
35
  description: options.description
@@ -51,7 +51,7 @@ function validateSchemaKeys2(schema, name) {
51
51
  (key) => RESERVED_EDGE_KEYS.has(key)
52
52
  );
53
53
  if (conflicts.length > 0) {
54
- throw new chunkOYL2SGBD_cjs.ConfigurationError(
54
+ throw new chunk44SXEVF4_cjs.ConfigurationError(
55
55
  `Edge "${name}" schema contains reserved property names: ${conflicts.join(", ")}`,
56
56
  { edgeType: name, conflicts, reservedKeys: [...RESERVED_EDGE_KEYS] },
57
57
  {
@@ -64,7 +64,7 @@ function defineEdge(name, options) {
64
64
  const schema = options?.schema ?? EMPTY_SCHEMA;
65
65
  validateSchemaKeys2(schema, name);
66
66
  return Object.freeze({
67
- [chunkZJHQZZT2_cjs.EDGE_TYPE_BRAND]: true,
67
+ [chunkK2ROKOK3_cjs.EDGE_TYPE_BRAND]: true,
68
68
  kind: name,
69
69
  schema,
70
70
  description: options?.description,
@@ -84,7 +84,7 @@ function metaEdge(name, options = {}) {
84
84
  description: options.description
85
85
  };
86
86
  return Object.freeze({
87
- [chunkDD6ONEBN_cjs.META_EDGE_BRAND]: true,
87
+ [chunkLDM2AFKZ_cjs.META_EDGE_BRAND]: true,
88
88
  name,
89
89
  properties
90
90
  });
@@ -120,7 +120,7 @@ function createExternalRef(table) {
120
120
  // src/ontology/core-meta-edges.ts
121
121
  function createMetaEdge(name, properties) {
122
122
  return Object.freeze({
123
- [chunkDD6ONEBN_cjs.META_EDGE_BRAND]: true,
123
+ [chunkLDM2AFKZ_cjs.META_EDGE_BRAND]: true,
124
124
  name,
125
125
  properties: {
126
126
  transitive: properties.transitive ?? false,
@@ -132,7 +132,7 @@ function createMetaEdge(name, properties) {
132
132
  }
133
133
  });
134
134
  }
135
- var subClassOfMetaEdge = createMetaEdge(chunkDD6ONEBN_cjs.META_EDGE_SUB_CLASS_OF, {
135
+ var subClassOfMetaEdge = createMetaEdge(chunkLDM2AFKZ_cjs.META_EDGE_SUB_CLASS_OF, {
136
136
  transitive: true,
137
137
  inference: "subsumption",
138
138
  description: "Type inheritance (Podcast subClassOf Media)"
@@ -144,9 +144,9 @@ function subClassOf(child, parent) {
144
144
  to: parent
145
145
  };
146
146
  }
147
- var broaderMetaEdge = createMetaEdge(chunkDD6ONEBN_cjs.META_EDGE_BROADER, {
147
+ var broaderMetaEdge = createMetaEdge(chunkLDM2AFKZ_cjs.META_EDGE_BROADER, {
148
148
  transitive: true,
149
- inverse: chunkDD6ONEBN_cjs.META_EDGE_NARROWER,
149
+ inverse: chunkLDM2AFKZ_cjs.META_EDGE_NARROWER,
150
150
  inference: "hierarchy",
151
151
  description: "Broader concept (ML broader AI)"
152
152
  });
@@ -157,9 +157,9 @@ function broader(narrowerConcept, broaderConcept) {
157
157
  to: broaderConcept
158
158
  };
159
159
  }
160
- var narrowerMetaEdge = createMetaEdge(chunkDD6ONEBN_cjs.META_EDGE_NARROWER, {
160
+ var narrowerMetaEdge = createMetaEdge(chunkLDM2AFKZ_cjs.META_EDGE_NARROWER, {
161
161
  transitive: true,
162
- inverse: chunkDD6ONEBN_cjs.META_EDGE_BROADER,
162
+ inverse: chunkLDM2AFKZ_cjs.META_EDGE_BROADER,
163
163
  inference: "hierarchy",
164
164
  description: "Narrower concept (AI narrower ML)"
165
165
  });
@@ -170,7 +170,7 @@ function narrower(broaderConcept, narrowerConcept) {
170
170
  to: narrowerConcept
171
171
  };
172
172
  }
173
- var relatedToMetaEdge = createMetaEdge(chunkDD6ONEBN_cjs.META_EDGE_RELATED_TO, {
173
+ var relatedToMetaEdge = createMetaEdge(chunkLDM2AFKZ_cjs.META_EDGE_RELATED_TO, {
174
174
  symmetric: true,
175
175
  inference: "association",
176
176
  description: "Non-hierarchical association"
@@ -182,7 +182,7 @@ function relatedTo(conceptA, conceptB) {
182
182
  to: conceptB
183
183
  };
184
184
  }
185
- var equivalentToMetaEdge = createMetaEdge(chunkDD6ONEBN_cjs.META_EDGE_EQUIVALENT_TO, {
185
+ var equivalentToMetaEdge = createMetaEdge(chunkLDM2AFKZ_cjs.META_EDGE_EQUIVALENT_TO, {
186
186
  symmetric: true,
187
187
  transitive: true,
188
188
  inference: "substitution",
@@ -195,7 +195,7 @@ function equivalentTo(kindA, kindBOrIri) {
195
195
  to: kindBOrIri
196
196
  };
197
197
  }
198
- var sameAsMetaEdge = createMetaEdge(chunkDD6ONEBN_cjs.META_EDGE_SAME_AS, {
198
+ var sameAsMetaEdge = createMetaEdge(chunkLDM2AFKZ_cjs.META_EDGE_SAME_AS, {
199
199
  symmetric: true,
200
200
  transitive: true,
201
201
  inference: "substitution",
@@ -208,7 +208,7 @@ function sameAs(kindA, kindBOrIri) {
208
208
  to: kindBOrIri
209
209
  };
210
210
  }
211
- var differentFromMetaEdge = createMetaEdge(chunkDD6ONEBN_cjs.META_EDGE_DIFFERENT_FROM, {
211
+ var differentFromMetaEdge = createMetaEdge(chunkLDM2AFKZ_cjs.META_EDGE_DIFFERENT_FROM, {
212
212
  symmetric: true,
213
213
  inference: "constraint",
214
214
  description: "Explicitly different individuals"
@@ -220,7 +220,7 @@ function differentFrom(kindA, kindB) {
220
220
  to: kindB
221
221
  };
222
222
  }
223
- var disjointWithMetaEdge = createMetaEdge(chunkDD6ONEBN_cjs.META_EDGE_DISJOINT_WITH, {
223
+ var disjointWithMetaEdge = createMetaEdge(chunkLDM2AFKZ_cjs.META_EDGE_DISJOINT_WITH, {
224
224
  symmetric: true,
225
225
  inference: "constraint",
226
226
  description: "Mutually exclusive types"
@@ -232,9 +232,9 @@ function disjointWith(kindA, kindB) {
232
232
  to: kindB
233
233
  };
234
234
  }
235
- var partOfMetaEdge = createMetaEdge(chunkDD6ONEBN_cjs.META_EDGE_PART_OF, {
235
+ var partOfMetaEdge = createMetaEdge(chunkLDM2AFKZ_cjs.META_EDGE_PART_OF, {
236
236
  transitive: true,
237
- inverse: chunkDD6ONEBN_cjs.META_EDGE_HAS_PART,
237
+ inverse: chunkLDM2AFKZ_cjs.META_EDGE_HAS_PART,
238
238
  inference: "composition",
239
239
  description: "X is part of Y"
240
240
  });
@@ -245,9 +245,9 @@ function partOf(part, whole) {
245
245
  to: whole
246
246
  };
247
247
  }
248
- var hasPartMetaEdge = createMetaEdge(chunkDD6ONEBN_cjs.META_EDGE_HAS_PART, {
248
+ var hasPartMetaEdge = createMetaEdge(chunkLDM2AFKZ_cjs.META_EDGE_HAS_PART, {
249
249
  transitive: true,
250
- inverse: chunkDD6ONEBN_cjs.META_EDGE_PART_OF,
250
+ inverse: chunkLDM2AFKZ_cjs.META_EDGE_PART_OF,
251
251
  inference: "composition",
252
252
  description: "Y has part X"
253
253
  });
@@ -258,12 +258,12 @@ function hasPart(whole, part) {
258
258
  to: part
259
259
  };
260
260
  }
261
- var inverseOfMetaEdge = createMetaEdge(chunkDD6ONEBN_cjs.META_EDGE_INVERSE_OF, {
261
+ var inverseOfMetaEdge = createMetaEdge(chunkLDM2AFKZ_cjs.META_EDGE_INVERSE_OF, {
262
262
  symmetric: true,
263
263
  inference: "none",
264
264
  description: "Edge A is inverse of edge B"
265
265
  });
266
- var impliesMetaEdge = createMetaEdge(chunkDD6ONEBN_cjs.META_EDGE_IMPLIES, {
266
+ var impliesMetaEdge = createMetaEdge(chunkLDM2AFKZ_cjs.META_EDGE_IMPLIES, {
267
267
  transitive: true,
268
268
  inference: "none",
269
269
  description: "Edge A implies edge B exists"
@@ -317,10 +317,10 @@ function runRecursiveTraversalSelectionPass(ast) {
317
317
  (traversal) => traversal.variableLength !== void 0
318
318
  );
319
319
  if (variableLengthTraversal === void 0) {
320
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError("No variable-length traversal found");
320
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError("No variable-length traversal found");
321
321
  }
322
322
  if (ast.traversals.length > 1) {
323
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
323
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
324
324
  "Variable-length traversals with multiple traversals are not yet supported. Please use a single variable-length traversal."
325
325
  );
326
326
  }
@@ -838,7 +838,7 @@ function notInSubquery(field2, subquery) {
838
838
  function assertSingleColumnSubquery(subquery) {
839
839
  const columnCount = getSubqueryColumnCount(subquery);
840
840
  if (columnCount === 1) return;
841
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
841
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
842
842
  `IN/NOT IN subquery must project exactly 1 column, but got ${columnCount}`,
843
843
  { subqueryColumnCount: columnCount },
844
844
  {
@@ -851,7 +851,7 @@ function assertCompatibleSubqueryValueTypes(field2, subquery) {
851
851
  const subqueryValueType = getSingleSubqueryColumnValueType(subquery);
852
852
  const resolvedValueType = fieldValueType ?? subqueryValueType;
853
853
  if (isUnsupportedInSubqueryValueType(resolvedValueType)) {
854
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
854
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
855
855
  `IN/NOT IN subquery does not support ${String(resolvedValueType)} values`,
856
856
  { valueType: resolvedValueType },
857
857
  {
@@ -862,7 +862,7 @@ function assertCompatibleSubqueryValueTypes(field2, subquery) {
862
862
  if (isInSubqueryTypeCompatible(fieldValueType, subqueryValueType)) {
863
863
  return;
864
864
  }
865
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
865
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
866
866
  `IN/NOT IN type mismatch: field type "${String(fieldValueType)}" does not match subquery column type "${String(subqueryValueType)}"`,
867
867
  {
868
868
  fieldValueType,
@@ -988,7 +988,7 @@ function resolveLiteralValueTypes(literals) {
988
988
  }
989
989
  }
990
990
  if (resolved.size > 1) {
991
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
991
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
992
992
  "Mixed literal value types are not supported in predicates",
993
993
  { valueTypes: [...resolved] }
994
994
  );
@@ -1114,7 +1114,7 @@ function compilePredicateExpression(expr, ctx) {
1114
1114
  if (!upperIsParam) boundsForType.push(expr.upper);
1115
1115
  const valueType = boundsForType.length > 0 ? resolveComparisonValueType(expr.field, boundsForType) : normalizeValueType2(expr.field.valueType);
1116
1116
  if (valueType === "array" || valueType === "object") {
1117
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1117
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1118
1118
  "Between comparisons are not supported for JSON arrays or objects"
1119
1119
  );
1120
1120
  }
@@ -1179,7 +1179,7 @@ function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
1179
1179
  );
1180
1180
  const opSql2 = COMPARISON_OP_SQL[expr.op];
1181
1181
  if (!opSql2) {
1182
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1182
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1183
1183
  `Comparison operation "${expr.op}" is not supported for parameterized predicates`
1184
1184
  );
1185
1185
  }
@@ -1187,7 +1187,7 @@ function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
1187
1187
  }
1188
1188
  const valueType = resolveComparisonValueType(expr.left, expr.right);
1189
1189
  if (valueType === "array" || valueType === "object") {
1190
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1190
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1191
1191
  `Comparison operation "${expr.op}" is not supported for ${valueType} values`
1192
1192
  );
1193
1193
  }
@@ -1215,7 +1215,7 @@ function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
1215
1215
  const convertedRight = convertValueForSql(rightValue.value, dialect);
1216
1216
  const opSql = COMPARISON_OP_SQL[expr.op];
1217
1217
  if (!opSql) {
1218
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1218
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1219
1219
  `Comparison operation "${expr.op}" is not supported`
1220
1220
  );
1221
1221
  }
@@ -1278,13 +1278,13 @@ function compileObjectPredicate(expr, dialect, cteColumnPrefix) {
1278
1278
  }
1279
1279
  case "pathEquals": {
1280
1280
  if (!expr.value) {
1281
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1281
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1282
1282
  "pathEquals requires a comparison value"
1283
1283
  );
1284
1284
  }
1285
1285
  const valueType = resolvePredicateValueType(expr.valueType, expr.value);
1286
1286
  if (valueType === "array" || valueType === "object") {
1287
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1287
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1288
1288
  "pathEquals is not supported for JSON arrays or objects"
1289
1289
  );
1290
1290
  }
@@ -1300,7 +1300,7 @@ function compileObjectPredicate(expr, dialect, cteColumnPrefix) {
1300
1300
  }
1301
1301
  case "pathContains": {
1302
1302
  if (!expr.value) {
1303
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1303
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1304
1304
  "pathContains requires a comparison value"
1305
1305
  );
1306
1306
  }
@@ -1328,7 +1328,7 @@ function compileAggregatePredicate(expr, dialect) {
1328
1328
  const aggregate = compileAggregateExpr(expr.aggregate, dialect);
1329
1329
  const op = COMPARISON_OP_SQL[expr.op];
1330
1330
  if (!op) {
1331
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1331
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1332
1332
  `Comparison operation "${expr.op}" is not supported for aggregate predicates`
1333
1333
  );
1334
1334
  }
@@ -1363,7 +1363,7 @@ function compileAggregateExpr(expr, dialect) {
1363
1363
  return drizzleOrm.sql`MAX(${field2})`;
1364
1364
  }
1365
1365
  default: {
1366
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1366
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1367
1367
  `Unknown aggregate function: ${expr.function}`
1368
1368
  );
1369
1369
  }
@@ -1371,7 +1371,7 @@ function compileAggregateExpr(expr, dialect) {
1371
1371
  }
1372
1372
  function compileExistsSubquery(expr, ctx) {
1373
1373
  if (expr.subquery.graphId === void 0) {
1374
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError("EXISTS subquery must have a graphId");
1374
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError("EXISTS subquery must have a graphId");
1375
1375
  }
1376
1376
  const subSql = ctx.compileQuery(expr.subquery, expr.subquery.graphId);
1377
1377
  return expr.negated ? drizzleOrm.sql`NOT EXISTS (${subSql})` : drizzleOrm.sql`EXISTS (${subSql})`;
@@ -1379,7 +1379,7 @@ function compileExistsSubquery(expr, ctx) {
1379
1379
  function compileInSubquery(expr, ctx) {
1380
1380
  const subqueryColumnCount = getSubqueryColumnCount(expr.subquery);
1381
1381
  if (subqueryColumnCount !== 1) {
1382
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1382
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1383
1383
  `IN/NOT IN subquery must project exactly 1 column, but got ${subqueryColumnCount}`,
1384
1384
  { subqueryColumnCount }
1385
1385
  );
@@ -1388,13 +1388,13 @@ function compileInSubquery(expr, ctx) {
1388
1388
  const subqueryValueType = getSingleSubqueryColumnValueType(expr.subquery);
1389
1389
  const resolvedValueType = fieldValueType ?? subqueryValueType;
1390
1390
  if (isUnsupportedInSubqueryValueType(resolvedValueType)) {
1391
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1391
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1392
1392
  `IN/NOT IN subquery does not support ${String(resolvedValueType)} values`,
1393
1393
  { valueType: resolvedValueType }
1394
1394
  );
1395
1395
  }
1396
1396
  if (!isInSubqueryTypeCompatible(fieldValueType, subqueryValueType)) {
1397
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1397
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1398
1398
  `IN/NOT IN type mismatch: field type "${String(fieldValueType)}" does not match subquery column type "${String(subqueryValueType)}"`,
1399
1399
  {
1400
1400
  fieldValueType,
@@ -1404,7 +1404,7 @@ function compileInSubquery(expr, ctx) {
1404
1404
  }
1405
1405
  const valueType = fieldValueType ?? subqueryValueType;
1406
1406
  if (expr.subquery.graphId === void 0) {
1407
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1407
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1408
1408
  "IN/NOT IN subquery must have a graphId"
1409
1409
  );
1410
1410
  }
@@ -1428,7 +1428,7 @@ function extractVectorSimilarityPredicates(predicates) {
1428
1428
  switch (expr.__type) {
1429
1429
  case "vector_similarity": {
1430
1430
  if (inDisallowedBranch) {
1431
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1431
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1432
1432
  "Vector similarity predicates cannot be nested under OR or NOT. Use top-level AND combinations instead."
1433
1433
  );
1434
1434
  }
@@ -1463,7 +1463,7 @@ function extractVectorSimilarityPredicates(predicates) {
1463
1463
  function runVectorPredicatePass(ast, dialect) {
1464
1464
  const vectorPredicates = extractVectorSimilarityPredicates(ast.predicates);
1465
1465
  if (vectorPredicates.length > 1) {
1466
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1466
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1467
1467
  "Multiple vector similarity predicates in a single query are not supported"
1468
1468
  );
1469
1469
  }
@@ -1473,29 +1473,29 @@ function runVectorPredicatePass(ast, dialect) {
1473
1473
  }
1474
1474
  const vectorStrategy = dialect.capabilities.vectorPredicateStrategy;
1475
1475
  if (vectorStrategy === "unsupported" || !dialect.supportsVectors) {
1476
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1476
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1477
1477
  `Vector similarity predicates are not supported for dialect "${dialect.name}"`
1478
1478
  );
1479
1479
  }
1480
1480
  if (!dialect.capabilities.vectorMetrics.includes(vectorPredicate.metric)) {
1481
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1481
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1482
1482
  `Vector metric "${vectorPredicate.metric}" is not supported for dialect "${dialect.name}"`
1483
1483
  );
1484
1484
  }
1485
1485
  if (!Number.isFinite(vectorPredicate.limit) || vectorPredicate.limit <= 0) {
1486
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1486
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1487
1487
  `Vector predicate limit must be a positive finite number, got ${String(vectorPredicate.limit)}`
1488
1488
  );
1489
1489
  }
1490
1490
  const { minScore } = vectorPredicate;
1491
1491
  if (minScore !== void 0) {
1492
1492
  if (!Number.isFinite(minScore)) {
1493
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1493
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1494
1494
  `Vector minScore must be a finite number, got ${String(minScore)}`
1495
1495
  );
1496
1496
  }
1497
1497
  if (vectorPredicate.metric === "cosine" && (minScore < -1 || minScore > 1)) {
1498
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
1498
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1499
1499
  `Cosine minScore must be between -1 and 1, got ${String(minScore)}`
1500
1500
  );
1501
1501
  }
@@ -1589,7 +1589,7 @@ function appendAggregateSortLimitAndProjectNodes(currentNode, ast, nextPlanNodeI
1589
1589
  } else if (hasOffset) {
1590
1590
  node = { ...limitOffsetNodeBase, offset: ast.offset };
1591
1591
  } else {
1592
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
1592
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1593
1593
  "limit_offset node requires limit or offset to be present"
1594
1594
  );
1595
1595
  }
@@ -1886,7 +1886,7 @@ function findUnaryNodeInProjectChain(rootNode, op) {
1886
1886
  }
1887
1887
  function inspectProjectPlan(logicalPlan) {
1888
1888
  if (logicalPlan.root.op !== "project") {
1889
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
1889
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1890
1890
  `SQL emitter expected logical plan root to be "project", got "${logicalPlan.root.op}"`,
1891
1891
  { component: "plan-inspector" }
1892
1892
  );
@@ -1916,13 +1916,13 @@ function inspectProjectPlan(logicalPlan) {
1916
1916
  function inspectStandardProjectPlan(logicalPlan) {
1917
1917
  const shape = inspectProjectPlan(logicalPlan);
1918
1918
  if (shape.hasSetOperation) {
1919
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
1919
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1920
1920
  'Standard SQL emitter does not support plans containing "set_op" nodes',
1921
1921
  { component: "plan-inspector" }
1922
1922
  );
1923
1923
  }
1924
1924
  if (shape.hasRecursiveExpand) {
1925
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
1925
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1926
1926
  'Standard SQL emitter does not support plans containing "recursive_expand" nodes',
1927
1927
  { component: "plan-inspector" }
1928
1928
  );
@@ -1932,13 +1932,13 @@ function inspectStandardProjectPlan(logicalPlan) {
1932
1932
  function inspectRecursiveProjectPlan(logicalPlan) {
1933
1933
  const shape = inspectProjectPlan(logicalPlan);
1934
1934
  if (!shape.hasRecursiveExpand) {
1935
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
1935
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1936
1936
  'Recursive SQL emitter expected logical plan to contain a "recursive_expand" node',
1937
1937
  { component: "plan-inspector" }
1938
1938
  );
1939
1939
  }
1940
1940
  if (shape.hasSetOperation) {
1941
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
1941
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1942
1942
  'Recursive SQL emitter does not support plans containing "set_op" nodes',
1943
1943
  { component: "plan-inspector" }
1944
1944
  );
@@ -1997,7 +1997,7 @@ function inspectSetOperationPlan(logicalPlan) {
1997
1997
  const operations = /* @__PURE__ */ new Set();
1998
1998
  collectPlanOperations(logicalPlan.root, operations);
1999
1999
  if (!operations.has("set_op")) {
2000
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2000
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2001
2001
  'Set-operation SQL emitter expected logical plan to contain a "set_op" node',
2002
2002
  { component: "plan-inspector" }
2003
2003
  );
@@ -2015,25 +2015,25 @@ function inspectSetOperationPlan(logicalPlan) {
2015
2015
  function assertRecursiveEmitterClauseAlignment(logicalPlan, input) {
2016
2016
  const planShape = inspectRecursiveProjectPlan(logicalPlan);
2017
2017
  if (planShape.hasSort && input.orderBy === void 0) {
2018
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2018
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2019
2019
  "Recursive SQL emitter expected ORDER BY clause for plan containing a sort node",
2020
2020
  { component: "recursive-emitter" }
2021
2021
  );
2022
2022
  }
2023
2023
  if (!planShape.hasSort && input.orderBy !== void 0) {
2024
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2024
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2025
2025
  "Recursive SQL emitter received ORDER BY clause for a plan without sort nodes",
2026
2026
  { component: "recursive-emitter" }
2027
2027
  );
2028
2028
  }
2029
2029
  if (planShape.hasLimitOffset && input.limitOffset === void 0) {
2030
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2030
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2031
2031
  "Recursive SQL emitter expected LIMIT/OFFSET clause for plan containing a limit_offset node",
2032
2032
  { component: "recursive-emitter" }
2033
2033
  );
2034
2034
  }
2035
2035
  if (!planShape.hasLimitOffset && input.limitOffset !== void 0) {
2036
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2036
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2037
2037
  "Recursive SQL emitter received LIMIT/OFFSET clause for a plan without limit_offset nodes",
2038
2038
  { component: "recursive-emitter" }
2039
2039
  );
@@ -2060,14 +2060,14 @@ function assertSetOperationEmitterClauseAlignment(logicalPlan, suffixClauses) {
2060
2060
  const shape = inspectSetOperationPlan(logicalPlan);
2061
2061
  const hasSuffixClauses = suffixClauses !== void 0 && suffixClauses.length > 0;
2062
2062
  if (!shape.hasSort && !shape.hasLimitOffset && hasSuffixClauses) {
2063
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2063
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2064
2064
  "Set-operation SQL emitter received suffix clauses for a plan without top-level sort or limit_offset nodes",
2065
2065
  { component: "set-operation-emitter" }
2066
2066
  );
2067
2067
  }
2068
2068
  if (!hasSuffixClauses) {
2069
2069
  if (shape.hasSort || shape.hasLimitOffset) {
2070
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2070
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2071
2071
  "Set-operation SQL emitter expected suffix clauses for plan containing top-level sort or limit_offset nodes",
2072
2072
  { component: "set-operation-emitter" }
2073
2073
  );
@@ -2077,7 +2077,7 @@ function assertSetOperationEmitterClauseAlignment(logicalPlan, suffixClauses) {
2077
2077
  const limitOffsetClauseCount = shape.limitOffsetNode === void 0 ? 0 : (shape.limitOffsetNode.limit === void 0 ? 0 : 1) + (shape.limitOffsetNode.offset === void 0 ? 0 : 1);
2078
2078
  const expectedClauseCount = (shape.sortNode === void 0 ? 0 : 1) + limitOffsetClauseCount;
2079
2079
  if (suffixClauses.length !== expectedClauseCount) {
2080
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2080
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2081
2081
  `Set-operation SQL emitter expected ${String(expectedClauseCount)} top-level suffix clause(s) from logical plan, got ${String(suffixClauses.length)}`,
2082
2082
  { component: "set-operation-emitter" }
2083
2083
  );
@@ -2101,38 +2101,38 @@ function emitSetOperationQuerySql(input) {
2101
2101
  function assertStandardEmitterClauseAlignment(logicalPlan, input) {
2102
2102
  const planShape = inspectStandardProjectPlan(logicalPlan);
2103
2103
  if (input.groupBy !== void 0 && !planShape.hasAggregate) {
2104
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2104
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2105
2105
  "Standard SQL emitter received GROUP BY clause for a plan without aggregate nodes",
2106
2106
  { component: "standard-emitter" }
2107
2107
  );
2108
2108
  }
2109
2109
  if (input.having !== void 0 && !planShape.hasAggregate) {
2110
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2110
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2111
2111
  "Standard SQL emitter received HAVING clause for a plan without aggregate nodes",
2112
2112
  { component: "standard-emitter" }
2113
2113
  );
2114
2114
  }
2115
2115
  const expectsOrderBy = planShape.hasSort || planShape.hasVectorKnn;
2116
2116
  if (expectsOrderBy && input.orderBy === void 0) {
2117
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2117
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2118
2118
  "Standard SQL emitter expected ORDER BY clause for plan containing a sort or vector_knn node",
2119
2119
  { component: "standard-emitter" }
2120
2120
  );
2121
2121
  }
2122
2122
  if (!expectsOrderBy && input.orderBy !== void 0) {
2123
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2123
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2124
2124
  "Standard SQL emitter received ORDER BY clause for a plan without sort or vector_knn nodes",
2125
2125
  { component: "standard-emitter" }
2126
2126
  );
2127
2127
  }
2128
2128
  if (planShape.hasLimitOffset && input.limitOffset === void 0) {
2129
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2129
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2130
2130
  "Standard SQL emitter expected LIMIT/OFFSET clause for plan containing a limit_offset node",
2131
2131
  { component: "standard-emitter" }
2132
2132
  );
2133
2133
  }
2134
2134
  if (!planShape.hasLimitOffset && input.limitOffset !== void 0) {
2135
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2135
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2136
2136
  "Standard SQL emitter received LIMIT/OFFSET clause for a plan without limit_offset nodes",
2137
2137
  { component: "standard-emitter" }
2138
2138
  );
@@ -2213,7 +2213,7 @@ function getNodeKindsForAlias(ast, alias) {
2213
2213
  return traversal.nodeKinds;
2214
2214
  }
2215
2215
  }
2216
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(`Unknown traversal source alias: ${alias}`);
2216
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(`Unknown traversal source alias: ${alias}`);
2217
2217
  }
2218
2218
 
2219
2219
  // src/query/compiler/typed-json-extract.ts
@@ -2544,7 +2544,7 @@ function compileAggregateExprFromSource(expr, dialect) {
2544
2544
  return drizzleOrm.sql`${drizzleOrm.sql.raw(fn.toUpperCase())}(${column})`;
2545
2545
  }
2546
2546
  default: {
2547
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
2547
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
2548
2548
  `Unknown aggregate function: ${String(fn)}`
2549
2549
  );
2550
2550
  }
@@ -2642,7 +2642,7 @@ function buildStandardOrderBy(input) {
2642
2642
  for (const orderSpec of ast.orderBy) {
2643
2643
  const valueType = orderSpec.field.valueType;
2644
2644
  if (valueType === "array" || valueType === "object") {
2645
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
2645
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
2646
2646
  "Ordering by JSON arrays or objects is not supported"
2647
2647
  );
2648
2648
  }
@@ -2772,7 +2772,7 @@ function buildStandardVectorOrderBy(input) {
2772
2772
  for (const orderSpec of ast.orderBy) {
2773
2773
  const valueType = orderSpec.field.valueType;
2774
2774
  if (valueType === "array" || valueType === "object") {
2775
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
2775
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
2776
2776
  "Ordering by JSON arrays or objects is not supported"
2777
2777
  );
2778
2778
  }
@@ -2855,7 +2855,7 @@ function runRecursiveQueryPassPipeline(ast, graphId, ctx) {
2855
2855
  execute(currentState) {
2856
2856
  const traversal = currentState.traversal;
2857
2857
  if (traversal === void 0) {
2858
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2858
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2859
2859
  "Recursive traversal pass did not select traversal"
2860
2860
  );
2861
2861
  }
@@ -2908,17 +2908,17 @@ function compileVariableLengthQueryWithRecursiveCteStrategy(ast, graphId, ctx) {
2908
2908
  traversal: vlTraversal
2909
2909
  } = passState;
2910
2910
  if (temporalFilterPass === void 0) {
2911
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2911
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2912
2912
  "Temporal filter pass did not initialize temporal state"
2913
2913
  );
2914
2914
  }
2915
2915
  if (logicalPlan === void 0) {
2916
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2916
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2917
2917
  "Logical plan pass did not initialize plan state"
2918
2918
  );
2919
2919
  }
2920
2920
  if (vlTraversal === void 0) {
2921
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
2921
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2922
2922
  "Recursive traversal pass did not select traversal"
2923
2923
  );
2924
2924
  }
@@ -3010,7 +3010,7 @@ function compileRecursiveCte(ast, traversal, graphId, ctx, requiredColumnsByAlia
3010
3010
  targetContext
3011
3011
  );
3012
3012
  if (vl.maxDepth > MAX_EXPLICIT_RECURSIVE_DEPTH) {
3013
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
3013
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
3014
3014
  `Recursive traversal maxHops(${vl.maxDepth}) exceeds maximum explicit depth of ${MAX_EXPLICIT_RECURSIVE_DEPTH}`
3015
3015
  );
3016
3016
  }
@@ -3237,7 +3237,7 @@ function compileRecursiveSelectiveProjection(fields, ast, traversal, dialect) {
3237
3237
  const allowedAliases = /* @__PURE__ */ new Set([ast.start.alias, traversal.nodeAlias]);
3238
3238
  const columns = fields.map((field2) => {
3239
3239
  if (!allowedAliases.has(field2.alias)) {
3240
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
3240
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
3241
3241
  `Selective projection for recursive traversals does not support alias "${field2.alias}"`
3242
3242
  );
3243
3243
  }
@@ -3271,7 +3271,7 @@ function compileRecursiveOrderBy(ast, dialect) {
3271
3271
  for (const orderSpec of ast.orderBy) {
3272
3272
  const valueType = orderSpec.field.valueType;
3273
3273
  if (valueType === "array" || valueType === "object") {
3274
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
3274
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
3275
3275
  "Ordering by JSON arrays or objects is not supported"
3276
3276
  );
3277
3277
  }
@@ -3305,15 +3305,15 @@ var MAX_IDENTIFIER_LENGTH = 63;
3305
3305
  var VALID_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/i;
3306
3306
  function validateTableName(name, label) {
3307
3307
  if (!name || name.length === 0) {
3308
- throw new chunkOYL2SGBD_cjs.ConfigurationError(`${label} table name cannot be empty`);
3308
+ throw new chunk44SXEVF4_cjs.ConfigurationError(`${label} table name cannot be empty`);
3309
3309
  }
3310
3310
  if (name.length > MAX_IDENTIFIER_LENGTH) {
3311
- throw new chunkOYL2SGBD_cjs.ConfigurationError(
3311
+ throw new chunk44SXEVF4_cjs.ConfigurationError(
3312
3312
  `${label} table name exceeds maximum length of ${MAX_IDENTIFIER_LENGTH} characters`
3313
3313
  );
3314
3314
  }
3315
3315
  if (!VALID_IDENTIFIER_PATTERN.test(name)) {
3316
- throw new chunkOYL2SGBD_cjs.ConfigurationError(
3316
+ throw new chunk44SXEVF4_cjs.ConfigurationError(
3317
3317
  `${label} table name "${name}" is not a valid SQL identifier. Table names must start with a letter or underscore and contain only letters, digits, underscores, or dollar signs.`
3318
3318
  );
3319
3319
  }
@@ -3392,7 +3392,7 @@ function compileSetOperation(op, graphId, dialect, schema, compileQuery2) {
3392
3392
  const passState = runSetOperationPassPipeline(op, graphId, dialect);
3393
3393
  const { logicalPlan } = passState;
3394
3394
  if (logicalPlan === void 0) {
3395
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
3395
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
3396
3396
  "Logical plan pass did not initialize plan state"
3397
3397
  );
3398
3398
  }
@@ -3456,7 +3456,7 @@ function compileSetOperationForSqlite(op, graphId, dialect, logicalPlan, schema)
3456
3456
  dialect,
3457
3457
  schema,
3458
3458
  compileQuery: () => {
3459
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
3459
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
3460
3460
  "compileQuery is not available in set-operation CTE compilation"
3461
3461
  );
3462
3462
  }
@@ -3508,7 +3508,7 @@ function validateSqliteSetOpLeaf(ast) {
3508
3508
  unsupported.push("per-query OFFSET (use set operation's offset instead)");
3509
3509
  }
3510
3510
  if (unsupported.length > 0) {
3511
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
3511
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
3512
3512
  `SQLite set operations (UNION/INTERSECT/EXCEPT) do not support: ${unsupported.join(", ")}. Use PostgreSQL for complex set operations, or refactor to separate queries.`
3513
3513
  );
3514
3514
  }
@@ -3666,7 +3666,7 @@ function compileFieldValueForSetOp(source, prefix, alias, dialect) {
3666
3666
  return drizzleOrm.sql`${drizzleOrm.sql.raw(fn.toUpperCase())}(${column})`;
3667
3667
  }
3668
3668
  default: {
3669
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
3669
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
3670
3670
  `Unknown aggregate function: ${String(fn)}`
3671
3671
  );
3672
3672
  }
@@ -3719,7 +3719,7 @@ function buildCompoundSelectRecursive(query, leaves, prefixToSelect) {
3719
3719
  if (!("__type" in query)) {
3720
3720
  const leaf = leaves.find((l) => l.ast === query);
3721
3721
  if (!leaf) {
3722
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError("Leaf query not found in leaves array");
3722
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError("Leaf query not found in leaves array");
3723
3723
  }
3724
3724
  return prefixToSelect.get(leaf.prefix);
3725
3725
  }
@@ -3763,7 +3763,7 @@ function buildSetOperationSuffixClauses(op, dialect) {
3763
3763
  if (op.orderBy && op.orderBy.length > 0) {
3764
3764
  const projection = getLeftmostProjection(op);
3765
3765
  if (projection.fields.length === 0) {
3766
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
3766
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
3767
3767
  "Set operation ORDER BY requires explicit field projection. SELECT * does not provide stable output column names for ordering. Use .select() to specify which fields to project."
3768
3768
  );
3769
3769
  }
@@ -3773,7 +3773,7 @@ function buildSetOperationSuffixClauses(op, dialect) {
3773
3773
  if (!projected) {
3774
3774
  const fieldDesc = o.field.jsonPointer ? `${o.field.alias}.props${o.field.jsonPointer}` : `${o.field.alias}.${o.field.path.join(".")}`;
3775
3775
  const availableFields = projection.fields.map((f) => f.outputName).join(", ");
3776
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
3776
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
3777
3777
  `Set operation ORDER BY field "${fieldDesc}" is not in the projection. ORDER BY for UNION/INTERSECT/EXCEPT must reference projected columns. Available columns: ${availableFields}`
3778
3778
  );
3779
3779
  }
@@ -4382,13 +4382,13 @@ function compileStandardQueryWithCteStrategy(ast, graphId, ctx) {
4382
4382
  vectorPredicate
4383
4383
  } = runStandardQueryPassPipeline(ast, graphId, ctx);
4384
4384
  if (temporalFilterPass === void 0) {
4385
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
4385
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
4386
4386
  "Temporal filter pass did not initialize temporal state",
4387
4387
  { phase: "standard-pass-pipeline" }
4388
4388
  );
4389
4389
  }
4390
4390
  if (logicalPlan === void 0) {
4391
- throw new chunkOYL2SGBD_cjs.CompilerInvariantError(
4391
+ throw new chunk44SXEVF4_cjs.CompilerInvariantError(
4392
4392
  "Logical plan pass did not initialize plan state",
4393
4393
  { phase: "standard-pass-pipeline" }
4394
4394
  );
@@ -4489,7 +4489,7 @@ function decodeCursor(cursor) {
4489
4489
  const json = atob(base64);
4490
4490
  const raw = JSON.parse(json);
4491
4491
  if (typeof raw.v !== "number" || raw.v > CURSOR_VERSION) {
4492
- throw new chunkOYL2SGBD_cjs.ValidationError(
4492
+ throw new chunk44SXEVF4_cjs.ValidationError(
4493
4493
  `Unsupported cursor version: ${String(raw.v)}. Maximum supported: ${CURSOR_VERSION}`,
4494
4494
  {
4495
4495
  issues: [
@@ -4505,7 +4505,7 @@ function decodeCursor(cursor) {
4505
4505
  );
4506
4506
  }
4507
4507
  if (raw.d !== "f" && raw.d !== "b") {
4508
- throw new chunkOYL2SGBD_cjs.ValidationError(`Invalid cursor direction: ${String(raw.d)}`, {
4508
+ throw new chunk44SXEVF4_cjs.ValidationError(`Invalid cursor direction: ${String(raw.d)}`, {
4509
4509
  issues: [
4510
4510
  {
4511
4511
  path: "cursor",
@@ -4515,7 +4515,7 @@ function decodeCursor(cursor) {
4515
4515
  });
4516
4516
  }
4517
4517
  if (!Array.isArray(raw.vals) || !Array.isArray(raw.cols)) {
4518
- throw new chunkOYL2SGBD_cjs.ValidationError("Invalid cursor structure", {
4518
+ throw new chunk44SXEVF4_cjs.ValidationError("Invalid cursor structure", {
4519
4519
  issues: [
4520
4520
  {
4521
4521
  path: "cursor",
@@ -4525,7 +4525,7 @@ function decodeCursor(cursor) {
4525
4525
  });
4526
4526
  }
4527
4527
  if (raw.vals.length !== raw.cols.length) {
4528
- throw new chunkOYL2SGBD_cjs.ValidationError("Cursor column count mismatch", {
4528
+ throw new chunk44SXEVF4_cjs.ValidationError("Cursor column count mismatch", {
4529
4529
  issues: [
4530
4530
  {
4531
4531
  path: "cursor",
@@ -4541,10 +4541,10 @@ function decodeCursor(cursor) {
4541
4541
  cols: raw.cols
4542
4542
  };
4543
4543
  } catch (error) {
4544
- if (error instanceof chunkOYL2SGBD_cjs.ValidationError) {
4544
+ if (error instanceof chunk44SXEVF4_cjs.ValidationError) {
4545
4545
  throw error;
4546
4546
  }
4547
- throw new chunkOYL2SGBD_cjs.ValidationError(
4547
+ throw new chunk44SXEVF4_cjs.ValidationError(
4548
4548
  "Invalid cursor format",
4549
4549
  {
4550
4550
  issues: [{ path: "cursor", message: "Failed to decode cursor" }]
@@ -4608,7 +4608,7 @@ function buildCursorFromRow(row, orderSpecs, direction) {
4608
4608
  function validateCursorColumns(cursorData, orderSpecs) {
4609
4609
  const expectedCols = orderSpecs.map((spec) => buildColumnId(spec));
4610
4610
  if (cursorData.cols.length !== expectedCols.length) {
4611
- throw new chunkOYL2SGBD_cjs.ValidationError(
4611
+ throw new chunk44SXEVF4_cjs.ValidationError(
4612
4612
  `Cursor has ${cursorData.cols.length} columns but query has ${expectedCols.length} ORDER BY columns`,
4613
4613
  {
4614
4614
  issues: [
@@ -4625,7 +4625,7 @@ function validateCursorColumns(cursorData, orderSpecs) {
4625
4625
  }
4626
4626
  for (const [index, expectedCol] of expectedCols.entries()) {
4627
4627
  if (cursorData.cols[index] !== expectedCol) {
4628
- throw new chunkOYL2SGBD_cjs.ValidationError(
4628
+ throw new chunk44SXEVF4_cjs.ValidationError(
4629
4629
  `Cursor column mismatch at position ${index}: expected "${expectedCol}", got "${cursorData.cols[index]}"`,
4630
4630
  {
4631
4631
  issues: [
@@ -5488,7 +5488,7 @@ var SQL_RESERVED_KEYWORDS = /* @__PURE__ */ new Set([
5488
5488
  ]);
5489
5489
  function validateSqlIdentifier(alias) {
5490
5490
  if (!SQL_IDENTIFIER_PATTERN.test(alias)) {
5491
- throw new chunkOYL2SGBD_cjs.ValidationError(
5491
+ throw new chunk44SXEVF4_cjs.ValidationError(
5492
5492
  `Invalid alias "${alias}": must start with a letter or underscore, contain only letters, digits, and underscores, and be at most 63 characters`,
5493
5493
  {
5494
5494
  issues: [
@@ -5504,7 +5504,7 @@ function validateSqlIdentifier(alias) {
5504
5504
  );
5505
5505
  }
5506
5506
  if (alias.toLowerCase().startsWith("cte_")) {
5507
- throw new chunkOYL2SGBD_cjs.ValidationError(
5507
+ throw new chunk44SXEVF4_cjs.ValidationError(
5508
5508
  `Invalid alias "${alias}": aliases starting with "cte_" are reserved for internal use`,
5509
5509
  {
5510
5510
  issues: [
@@ -5520,7 +5520,7 @@ function validateSqlIdentifier(alias) {
5520
5520
  );
5521
5521
  }
5522
5522
  if (SQL_RESERVED_KEYWORDS.has(alias.toLowerCase())) {
5523
- throw new chunkOYL2SGBD_cjs.ValidationError(
5523
+ throw new chunk44SXEVF4_cjs.ValidationError(
5524
5524
  `Invalid alias "${alias}": "${alias}" is a reserved SQL keyword`,
5525
5525
  {
5526
5526
  issues: [
@@ -5534,7 +5534,7 @@ function validateSqlIdentifier(alias) {
5534
5534
  }
5535
5535
  }
5536
5536
  function throwInvalidVectorPredicatePlacement(path) {
5537
- throw new chunkOYL2SGBD_cjs.ValidationError(
5537
+ throw new chunk44SXEVF4_cjs.ValidationError(
5538
5538
  "Vector similarity predicates cannot be nested under OR or NOT. Use top-level AND combinations instead.",
5539
5539
  {
5540
5540
  issues: [
@@ -5645,7 +5645,7 @@ function buildQueryAst(config, state) {
5645
5645
  }
5646
5646
  function toLiteral(value) {
5647
5647
  if (value === null) {
5648
- throw new chunkOYL2SGBD_cjs.ConfigurationError(
5648
+ throw new chunk44SXEVF4_cjs.ConfigurationError(
5649
5649
  "Parameter value must not be null (use undefined-based patterns instead)",
5650
5650
  { parameterName: "value", valueType: "null" }
5651
5651
  );
@@ -5662,7 +5662,7 @@ function toLiteral(value) {
5662
5662
  if (typeof value === "boolean") {
5663
5663
  return { __type: "literal", value, valueType: "boolean" };
5664
5664
  }
5665
- throw new chunkOYL2SGBD_cjs.ConfigurationError(
5665
+ throw new chunk44SXEVF4_cjs.ConfigurationError(
5666
5666
  `Unsupported parameter value type: ${typeof value}`,
5667
5667
  { parameterName: "value", actualType: typeof value }
5668
5668
  );
@@ -5673,7 +5673,7 @@ function substitutePredicateExpression(expr, bindings) {
5673
5673
  if (isParameterRef(expr.right)) {
5674
5674
  const value = bindings[expr.right.name];
5675
5675
  if (value === void 0) {
5676
- throw new chunkOYL2SGBD_cjs.ConfigurationError(
5676
+ throw new chunk44SXEVF4_cjs.ConfigurationError(
5677
5677
  `Missing binding for parameter "${expr.right.name}"`,
5678
5678
  { parameterName: expr.right.name }
5679
5679
  );
@@ -5689,13 +5689,13 @@ function substitutePredicateExpression(expr, bindings) {
5689
5689
  if (isParameterRef(expr.pattern)) {
5690
5690
  const value = bindings[expr.pattern.name];
5691
5691
  if (value === void 0) {
5692
- throw new chunkOYL2SGBD_cjs.ConfigurationError(
5692
+ throw new chunk44SXEVF4_cjs.ConfigurationError(
5693
5693
  `Missing binding for parameter "${expr.pattern.name}"`,
5694
5694
  { parameterName: expr.pattern.name }
5695
5695
  );
5696
5696
  }
5697
5697
  if (typeof value !== "string") {
5698
- throw new chunkOYL2SGBD_cjs.ConfigurationError(
5698
+ throw new chunk44SXEVF4_cjs.ConfigurationError(
5699
5699
  `Parameter "${expr.pattern.name}" must be a string for string operations`,
5700
5700
  { parameterName: expr.pattern.name, actualType: typeof value }
5701
5701
  );
@@ -5762,7 +5762,7 @@ function substitutePredicateExpression(expr, bindings) {
5762
5762
  function resolveBinding(bindings, name) {
5763
5763
  const value = bindings[name];
5764
5764
  if (value === void 0) {
5765
- throw new chunkOYL2SGBD_cjs.ConfigurationError(`Missing binding for parameter "${name}"`, {
5765
+ throw new chunk44SXEVF4_cjs.ConfigurationError(`Missing binding for parameter "${name}"`, {
5766
5766
  parameterName: name
5767
5767
  });
5768
5768
  }
@@ -5787,7 +5787,7 @@ function fillPlaceholders(params, bindings, dialect) {
5787
5787
  const name = parameter.name;
5788
5788
  const value = bindings[name];
5789
5789
  if (value === void 0) {
5790
- throw new chunkOYL2SGBD_cjs.ConfigurationError(
5790
+ throw new chunk44SXEVF4_cjs.ConfigurationError(
5791
5791
  `Missing binding for parameter "${name}"`,
5792
5792
  { parameterName: name }
5793
5793
  );
@@ -5854,7 +5854,7 @@ var PreparedQuery = class {
5854
5854
  this.#selectFn
5855
5855
  );
5856
5856
  } catch (error) {
5857
- if (error instanceof MissingSelectiveFieldError || error instanceof chunkOYL2SGBD_cjs.UnsupportedPredicateError) {
5857
+ if (error instanceof MissingSelectiveFieldError || error instanceof chunk44SXEVF4_cjs.UnsupportedPredicateError) {
5858
5858
  return this.#executeUnoptimized(bindings);
5859
5859
  }
5860
5860
  throw error;
@@ -6024,7 +6024,7 @@ function validateBindings(bindings, metadata) {
6024
6024
  }
6025
6025
  }
6026
6026
  if (missing.length > 0) {
6027
- throw new chunkOYL2SGBD_cjs.ConfigurationError(
6027
+ throw new chunk44SXEVF4_cjs.ConfigurationError(
6028
6028
  `Missing bindings for parameter${missing.length === 1 ? "" : "s"}: ${missing.map((name) => `"${name}"`).join(", ")}`,
6029
6029
  { missingParameters: missing }
6030
6030
  );
@@ -6033,7 +6033,7 @@ function validateBindings(bindings, metadata) {
6033
6033
  (name) => !expectedNames.has(name)
6034
6034
  );
6035
6035
  if (unexpected.length > 0) {
6036
- throw new chunkOYL2SGBD_cjs.ConfigurationError(
6036
+ throw new chunk44SXEVF4_cjs.ConfigurationError(
6037
6037
  `Unexpected bindings provided: ${unexpected.map((name) => `"${name}"`).join(", ")}`,
6038
6038
  { unexpectedParameters: unexpected }
6039
6039
  );
@@ -6045,14 +6045,14 @@ function validateBindings(bindings, metadata) {
6045
6045
  }
6046
6046
  function validateBindingValue(name, value, isStringOp) {
6047
6047
  if (value === null) {
6048
- throw new chunkOYL2SGBD_cjs.ConfigurationError(
6048
+ throw new chunk44SXEVF4_cjs.ConfigurationError(
6049
6049
  "Parameter value must not be null (use undefined-based patterns instead)",
6050
6050
  { parameterName: name, valueType: "null" }
6051
6051
  );
6052
6052
  }
6053
6053
  if (isStringOp) {
6054
6054
  if (typeof value !== "string") {
6055
- throw new chunkOYL2SGBD_cjs.ConfigurationError(
6055
+ throw new chunk44SXEVF4_cjs.ConfigurationError(
6056
6056
  `Parameter "${name}" must be a string for string operations`,
6057
6057
  { parameterName: name, actualType: typeof value }
6058
6058
  );
@@ -6062,7 +6062,7 @@ function validateBindingValue(name, value, isStringOp) {
6062
6062
  if (value instanceof Date || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
6063
6063
  return;
6064
6064
  }
6065
- throw new chunkOYL2SGBD_cjs.ConfigurationError(
6065
+ throw new chunk44SXEVF4_cjs.ConfigurationError(
6066
6066
  `Unsupported parameter value type: ${typeof value}`,
6067
6067
  { parameterName: name, actualType: typeof value }
6068
6068
  );
@@ -6421,7 +6421,7 @@ var ExecutableQuery = class _ExecutableQuery {
6421
6421
  this.#cachedOptimizedCompiled = NOT_COMPUTED;
6422
6422
  return void 0;
6423
6423
  }
6424
- if (error instanceof chunkOYL2SGBD_cjs.UnsupportedPredicateError) {
6424
+ if (error instanceof chunk44SXEVF4_cjs.UnsupportedPredicateError) {
6425
6425
  this.#cachedSelectiveFieldsForExecute = void 0;
6426
6426
  this.#cachedOptimizedCompiled = NOT_COMPUTED;
6427
6427
  return void 0;
@@ -6555,7 +6555,7 @@ var ExecutableQuery = class _ExecutableQuery {
6555
6555
  selectiveFields
6556
6556
  });
6557
6557
  } catch (error) {
6558
- if (error instanceof chunkOYL2SGBD_cjs.UnsupportedPredicateError) {
6558
+ if (error instanceof chunk44SXEVF4_cjs.UnsupportedPredicateError) {
6559
6559
  this.#cachedSelectiveFieldsForPagination = void 0;
6560
6560
  return void 0;
6561
6561
  }
@@ -6581,7 +6581,7 @@ var ExecutableQuery = class _ExecutableQuery {
6581
6581
  this.#cachedSelectiveFieldsForPagination = void 0;
6582
6582
  return void 0;
6583
6583
  }
6584
- if (error instanceof chunkOYL2SGBD_cjs.UnsupportedPredicateError) {
6584
+ if (error instanceof chunk44SXEVF4_cjs.UnsupportedPredicateError) {
6585
6585
  this.#cachedSelectiveFieldsForPagination = void 0;
6586
6586
  return void 0;
6587
6587
  }
@@ -6606,7 +6606,7 @@ var ExecutableQuery = class _ExecutableQuery {
6606
6606
  this.#cachedSelectiveFieldsForPagination = void 0;
6607
6607
  return void 0;
6608
6608
  }
6609
- if (error instanceof chunkOYL2SGBD_cjs.UnsupportedPredicateError) {
6609
+ if (error instanceof chunk44SXEVF4_cjs.UnsupportedPredicateError) {
6610
6610
  this.#cachedSelectiveFieldsForPagination = void 0;
6611
6611
  return void 0;
6612
6612
  }
@@ -6744,7 +6744,7 @@ var ExecutableQuery = class _ExecutableQuery {
6744
6744
  );
6745
6745
  }
6746
6746
  if (this.#state.orderBy.length === 0) {
6747
- throw new chunkOYL2SGBD_cjs.ValidationError(
6747
+ throw new chunk44SXEVF4_cjs.ValidationError(
6748
6748
  "Cursor pagination requires ORDER BY. Add .orderBy() before .paginate()",
6749
6749
  {
6750
6750
  issues: [
@@ -6820,7 +6820,7 @@ var ExecutableQuery = class _ExecutableQuery {
6820
6820
  */
6821
6821
  stream(options) {
6822
6822
  if (this.#state.orderBy.length === 0) {
6823
- throw new chunkOYL2SGBD_cjs.ValidationError(
6823
+ throw new chunk44SXEVF4_cjs.ValidationError(
6824
6824
  "Streaming requires ORDER BY. Add .orderBy() before .stream()",
6825
6825
  {
6826
6826
  issues: [
@@ -7591,7 +7591,7 @@ var QueryBuilder = class _QueryBuilder {
7591
7591
  */
7592
7592
  temporal(mode, asOf) {
7593
7593
  if (mode === "asOf" && asOf === void 0) {
7594
- throw new chunkOYL2SGBD_cjs.ValidationError(
7594
+ throw new chunk44SXEVF4_cjs.ValidationError(
7595
7595
  'Temporal mode "asOf" requires a timestamp',
7596
7596
  {
7597
7597
  issues: [
@@ -8247,12 +8247,12 @@ function createQueryBuilder(graphId, registry, options) {
8247
8247
  function buildKindRegistry(graph) {
8248
8248
  const nodeTypes = extractNodeTypes(graph);
8249
8249
  const edgeTypes = extractEdgeTypes(graph);
8250
- const closures = graph.ontology.length > 0 ? chunkDD6ONEBN_cjs.computeClosuresFromOntology(graph.ontology) : chunkDD6ONEBN_cjs.createEmptyClosures();
8251
- return new chunkDD6ONEBN_cjs.KindRegistry(nodeTypes, edgeTypes, closures);
8250
+ const closures = graph.ontology.length > 0 ? chunkLDM2AFKZ_cjs.computeClosuresFromOntology(graph.ontology) : chunkLDM2AFKZ_cjs.createEmptyClosures();
8251
+ return new chunkLDM2AFKZ_cjs.KindRegistry(nodeTypes, edgeTypes, closures);
8252
8252
  }
8253
8253
  function extractNodeTypes(graph) {
8254
8254
  const result = /* @__PURE__ */ new Map();
8255
- for (const typeName of chunkZJHQZZT2_cjs.getNodeKinds(graph)) {
8255
+ for (const typeName of chunkK2ROKOK3_cjs.getNodeKinds(graph)) {
8256
8256
  const registration = graph.nodes[typeName];
8257
8257
  result.set(typeName, registration.type);
8258
8258
  }
@@ -8260,7 +8260,7 @@ function extractNodeTypes(graph) {
8260
8260
  }
8261
8261
  function extractEdgeTypes(graph) {
8262
8262
  const result = /* @__PURE__ */ new Map();
8263
- for (const typeName of chunkZJHQZZT2_cjs.getEdgeKinds(graph)) {
8263
+ for (const typeName of chunkK2ROKOK3_cjs.getEdgeKinds(graph)) {
8264
8264
  const registration = graph.edges[typeName];
8265
8265
  result.set(typeName, registration.type);
8266
8266
  }
@@ -8393,7 +8393,7 @@ function createEdgeCollection(config) {
8393
8393
  async find(options) {
8394
8394
  const untypedOptions = options;
8395
8395
  if (untypedOptions?.where !== void 0) {
8396
- throw new chunkOYL2SGBD_cjs.UnsupportedPredicateError(
8396
+ throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
8397
8397
  `store.edges.${kind}.find({ where }) is not supported. Use store.query().traverse(...).whereEdge(...) for edge property filters.`,
8398
8398
  { kind, operation: "find" }
8399
8399
  );
@@ -8406,7 +8406,7 @@ function createEdgeCollection(config) {
8406
8406
  temporalMode: mode
8407
8407
  };
8408
8408
  if (mode === "current" || mode === "asOf") {
8409
- params.asOf = options?.asOf ?? chunkZJHQZZT2_cjs.nowIso();
8409
+ params.asOf = options?.asOf ?? chunkK2ROKOK3_cjs.nowIso();
8410
8410
  }
8411
8411
  if (options?.from?.kind !== void 0)
8412
8412
  params.fromKind = options.from.kind;
@@ -8427,7 +8427,7 @@ function createEdgeCollection(config) {
8427
8427
  temporalMode: mode
8428
8428
  };
8429
8429
  if (mode === "current" || mode === "asOf") {
8430
- params.asOf = options?.asOf ?? chunkZJHQZZT2_cjs.nowIso();
8430
+ params.asOf = options?.asOf ?? chunkK2ROKOK3_cjs.nowIso();
8431
8431
  }
8432
8432
  if (options?.from?.kind !== void 0)
8433
8433
  params.fromKind = options.from.kind;
@@ -8450,7 +8450,7 @@ function createEdgeCollection(config) {
8450
8450
  const results = await executeEdgeCreateBatch2(batchInputs, backend);
8451
8451
  return narrowEdges(results);
8452
8452
  },
8453
- async bulkUpsert(items) {
8453
+ async bulkUpsertById(items) {
8454
8454
  if (items.length === 0) return [];
8455
8455
  const upsertAll = async (target) => {
8456
8456
  const ids = items.map((item) => item.id);
@@ -8476,7 +8476,7 @@ function createEdgeCollection(config) {
8476
8476
  if (existing) {
8477
8477
  const input = {
8478
8478
  id: item.id,
8479
- props: item.props ?? {}
8479
+ props: item.props
8480
8480
  };
8481
8481
  if (item.validTo !== void 0) input.validTo = item.validTo;
8482
8482
  toUpdate.push({
@@ -8492,7 +8492,7 @@ function createEdgeCollection(config) {
8492
8492
  fromId: item.from.id,
8493
8493
  toKind: item.to.kind,
8494
8494
  toId: item.to.id,
8495
- props: item.props ?? {}
8495
+ props: item.props
8496
8496
  };
8497
8497
  if (item.validFrom !== void 0) input.validFrom = item.validFrom;
8498
8498
  if (item.validTo !== void 0) input.validTo = item.validTo;
@@ -8546,6 +8546,57 @@ function createEdgeCollection(config) {
8546
8546
  return;
8547
8547
  }
8548
8548
  await deleteAll(backend);
8549
+ },
8550
+ async getOrCreateByEndpoints(from, to, props, options) {
8551
+ const getOrCreateOptions = {};
8552
+ if (options?.matchOn !== void 0)
8553
+ getOrCreateOptions.matchOn = options.matchOn;
8554
+ if (options?.ifExists !== void 0)
8555
+ getOrCreateOptions.ifExists = options.ifExists;
8556
+ const result = await config.executeGetOrCreateByEndpoints(
8557
+ kind,
8558
+ from.kind,
8559
+ from.id,
8560
+ to.kind,
8561
+ to.id,
8562
+ props,
8563
+ backend,
8564
+ getOrCreateOptions
8565
+ );
8566
+ return { edge: narrowEdge(result.edge), action: result.action };
8567
+ },
8568
+ async bulkGetOrCreateByEndpoints(items, options) {
8569
+ if (items.length === 0) return [];
8570
+ const mappedItems = items.map((item) => ({
8571
+ fromKind: item.from.kind,
8572
+ fromId: item.from.id,
8573
+ toKind: item.to.kind,
8574
+ toId: item.to.id,
8575
+ props: item.props
8576
+ }));
8577
+ const getOrCreateOptions = {};
8578
+ if (options?.matchOn !== void 0)
8579
+ getOrCreateOptions.matchOn = options.matchOn;
8580
+ if (options?.ifExists !== void 0)
8581
+ getOrCreateOptions.ifExists = options.ifExists;
8582
+ const getOrCreateAll = async (target) => {
8583
+ const results = await config.executeBulkGetOrCreateByEndpoints(
8584
+ kind,
8585
+ mappedItems,
8586
+ target,
8587
+ getOrCreateOptions
8588
+ );
8589
+ return results.map((result) => ({
8590
+ edge: narrowEdge(result.edge),
8591
+ action: result.action
8592
+ }));
8593
+ };
8594
+ if (backend.capabilities.transactions && "transaction" in backend) {
8595
+ return backend.transaction(
8596
+ async (txBackend) => getOrCreateAll(txBackend)
8597
+ );
8598
+ }
8599
+ return getOrCreateAll(backend);
8549
8600
  }
8550
8601
  };
8551
8602
  }
@@ -8584,7 +8635,9 @@ function createNodeCollection(config) {
8584
8635
  executeDelete: executeNodeDelete2,
8585
8636
  executeHardDelete: executeNodeHardDelete2,
8586
8637
  matchesTemporalMode,
8587
- createQuery
8638
+ createQuery,
8639
+ executeGetOrCreateByConstraint,
8640
+ executeBulkGetOrCreateByConstraint
8588
8641
  } = config;
8589
8642
  return {
8590
8643
  async create(props, options) {
@@ -8650,7 +8703,7 @@ function createNodeCollection(config) {
8650
8703
  },
8651
8704
  async find(options) {
8652
8705
  if (options?.where !== void 0 && createQuery === void 0) {
8653
- throw new chunkOYL2SGBD_cjs.ConfigurationError(
8706
+ throw new chunk44SXEVF4_cjs.ConfigurationError(
8654
8707
  `store.nodes.${kind}.find({ where }) requires a query-capable store`,
8655
8708
  { kind, operation: "find" }
8656
8709
  );
@@ -8659,7 +8712,7 @@ function createNodeCollection(config) {
8659
8712
  const mode2 = options.temporalMode ?? defaultTemporalMode;
8660
8713
  let query = createQuery().from(kind, "_n").temporal(
8661
8714
  mode2,
8662
- mode2 === "asOf" ? options.asOf ?? chunkZJHQZZT2_cjs.nowIso() : void 0
8715
+ mode2 === "asOf" ? options.asOf ?? chunkK2ROKOK3_cjs.nowIso() : void 0
8663
8716
  ).whereNode("_n", options.where).select((ctx) => ctx._n);
8664
8717
  if (options.limit !== void 0) query = query.limit(options.limit);
8665
8718
  if (options.offset !== void 0) query = query.offset(options.offset);
@@ -8674,7 +8727,7 @@ function createNodeCollection(config) {
8674
8727
  temporalMode: mode
8675
8728
  };
8676
8729
  if (mode === "current" || mode === "asOf") {
8677
- params.asOf = options?.asOf ?? chunkZJHQZZT2_cjs.nowIso();
8730
+ params.asOf = options?.asOf ?? chunkK2ROKOK3_cjs.nowIso();
8678
8731
  }
8679
8732
  if (options?.limit !== void 0) params.limit = options.limit;
8680
8733
  if (options?.offset !== void 0) params.offset = options.offset;
@@ -8690,11 +8743,11 @@ function createNodeCollection(config) {
8690
8743
  temporalMode: mode
8691
8744
  };
8692
8745
  if (mode === "current" || mode === "asOf") {
8693
- params.asOf = options?.asOf ?? chunkZJHQZZT2_cjs.nowIso();
8746
+ params.asOf = options?.asOf ?? chunkK2ROKOK3_cjs.nowIso();
8694
8747
  }
8695
8748
  return backend.countNodesByKind(params);
8696
8749
  },
8697
- async upsert(id, props, options) {
8750
+ async upsertById(id, props, options) {
8698
8751
  const existing = await backend.getNode(graphId, kind, id);
8699
8752
  if (existing) {
8700
8753
  const input = {
@@ -8735,7 +8788,7 @@ function createNodeCollection(config) {
8735
8788
  const results = await executeNodeCreateBatch2(batchInputs, backend);
8736
8789
  return narrowNodes(results);
8737
8790
  },
8738
- async bulkUpsert(items) {
8791
+ async bulkUpsertById(items) {
8739
8792
  if (items.length === 0) return [];
8740
8793
  const upsertAll = async (target) => {
8741
8794
  const ids = items.map((item) => item.id);
@@ -8832,6 +8885,44 @@ function createNodeCollection(config) {
8832
8885
  return;
8833
8886
  }
8834
8887
  await deleteAll(backend);
8888
+ },
8889
+ async getOrCreateByConstraint(constraintName, props, options) {
8890
+ const execute = async (target) => {
8891
+ const result = await executeGetOrCreateByConstraint(
8892
+ kind,
8893
+ constraintName,
8894
+ props,
8895
+ target,
8896
+ options
8897
+ );
8898
+ return result;
8899
+ };
8900
+ if (backend.capabilities.transactions && "transaction" in backend) {
8901
+ return backend.transaction(async (txBackend) => execute(txBackend));
8902
+ }
8903
+ return execute(backend);
8904
+ },
8905
+ async bulkGetOrCreateByConstraint(constraintName, items, options) {
8906
+ if (items.length === 0) return [];
8907
+ const mappedItems = items.map((item) => ({
8908
+ props: item.props
8909
+ }));
8910
+ const getOrCreateAll = async (target) => {
8911
+ const results = await executeBulkGetOrCreateByConstraint(
8912
+ kind,
8913
+ constraintName,
8914
+ mappedItems,
8915
+ target,
8916
+ options
8917
+ );
8918
+ return results;
8919
+ };
8920
+ if (backend.capabilities.transactions && "transaction" in backend) {
8921
+ return backend.transaction(
8922
+ async (txBackend) => getOrCreateAll(txBackend)
8923
+ );
8924
+ }
8925
+ return getOrCreateAll(backend);
8835
8926
  }
8836
8927
  };
8837
8928
  }
@@ -8844,7 +8935,7 @@ function createNodeCollectionsProxy(graph, graphId, registry, backend, operation
8844
8935
  {
8845
8936
  get: (_, kind) => {
8846
8937
  if (!(kind in graph.nodes)) {
8847
- throw new chunkOYL2SGBD_cjs.KindNotFoundError(kind, "node");
8938
+ throw new chunk44SXEVF4_cjs.KindNotFoundError(kind, "node");
8848
8939
  }
8849
8940
  const cached = collectionCache.get(kind);
8850
8941
  if (cached !== void 0) {
@@ -8869,7 +8960,7 @@ function createEdgeCollectionsProxy(graph, graphId, registry, backend, operation
8869
8960
  {
8870
8961
  get: (_, kind) => {
8871
8962
  if (!(kind in graph.edges)) {
8872
- throw new chunkOYL2SGBD_cjs.KindNotFoundError(kind, "edge");
8963
+ throw new chunk44SXEVF4_cjs.KindNotFoundError(kind, "edge");
8873
8964
  }
8874
8965
  const cached = collectionCache.get(kind);
8875
8966
  if (cached !== void 0) {
@@ -8889,16 +8980,18 @@ function createEdgeCollectionsProxy(graph, graphId, registry, backend, operation
8889
8980
  }
8890
8981
 
8891
8982
  // src/constraints/index.ts
8983
+ var UNIQUE_KEY_SEPARATOR = "";
8984
+ var UNIQUE_KEY_NULL_MARKER = "";
8892
8985
  function computeUniqueKey(props, fields, collation) {
8893
8986
  const values = fields.map((field2) => {
8894
8987
  const value = props[field2];
8895
8988
  if (value === void 0 || value === null) {
8896
- return "\0";
8989
+ return UNIQUE_KEY_NULL_MARKER;
8897
8990
  }
8898
8991
  const stringValue = typeof value === "string" ? value : typeof value === "number" || typeof value === "boolean" ? value.toString() : JSON.stringify(value);
8899
8992
  return collation === "caseInsensitive" ? stringValue.toLowerCase() : stringValue;
8900
8993
  });
8901
- return values.join("\0");
8994
+ return values.join(UNIQUE_KEY_SEPARATOR);
8902
8995
  }
8903
8996
  function checkWherePredicate(constraint, props) {
8904
8997
  if (!constraint.where) {
@@ -8967,7 +9060,7 @@ function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeC
8967
9060
  }
8968
9061
  case "one": {
8969
9062
  if (existingEdgeCount > 0) {
8970
- return new chunkOYL2SGBD_cjs.CardinalityError({
9063
+ return new chunk44SXEVF4_cjs.CardinalityError({
8971
9064
  edgeKind,
8972
9065
  fromKind,
8973
9066
  fromId,
@@ -8982,7 +9075,7 @@ function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeC
8982
9075
  }
8983
9076
  case "oneActive": {
8984
9077
  if (hasActiveEdge) {
8985
- return new chunkOYL2SGBD_cjs.CardinalityError({
9078
+ return new chunk44SXEVF4_cjs.CardinalityError({
8986
9079
  edgeKind,
8987
9080
  fromKind,
8988
9081
  fromId,
@@ -8996,7 +9089,7 @@ function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeC
8996
9089
  }
8997
9090
  function checkUniqueEdge(edgeKind, fromKind, fromId, _toKind, _toId, existingCount) {
8998
9091
  if (existingCount > 0) {
8999
- return new chunkOYL2SGBD_cjs.CardinalityError({
9092
+ return new chunk44SXEVF4_cjs.CardinalityError({
9000
9093
  edgeKind,
9001
9094
  fromKind,
9002
9095
  fromId,
@@ -9012,7 +9105,7 @@ function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registr
9012
9105
  (validKind) => registry.isAssignableTo(fromKind, validKind)
9013
9106
  );
9014
9107
  if (!fromValid) {
9015
- return new chunkOYL2SGBD_cjs.EndpointError({
9108
+ return new chunk44SXEVF4_cjs.EndpointError({
9016
9109
  edgeKind,
9017
9110
  endpoint: "from",
9018
9111
  actualKind: fromKind,
@@ -9024,7 +9117,7 @@ function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registr
9024
9117
  (validKind) => registry.isAssignableTo(toKind, validKind)
9025
9118
  );
9026
9119
  if (!toValid) {
9027
- return new chunkOYL2SGBD_cjs.EndpointError({
9120
+ return new chunk44SXEVF4_cjs.EndpointError({
9028
9121
  edgeKind,
9029
9122
  endpoint: "to",
9030
9123
  actualKind: toKind,
@@ -9036,7 +9129,7 @@ function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registr
9036
9129
  function checkDisjointness(nodeId, nodeKind, existingKinds, registry) {
9037
9130
  for (const existingKind of existingKinds) {
9038
9131
  if (registry.areDisjoint(nodeKind, existingKind)) {
9039
- return new chunkOYL2SGBD_cjs.DisjointError({
9132
+ return new chunk44SXEVF4_cjs.DisjointError({
9040
9133
  nodeId,
9041
9134
  attemptedKind: nodeKind,
9042
9135
  conflictingKind: existingKind
@@ -9189,7 +9282,7 @@ function rowToEdge(row) {
9189
9282
  // src/store/operations/edge-operations.ts
9190
9283
  function getEdgeRegistration(graph, kind) {
9191
9284
  const registration = graph.edges[kind];
9192
- if (registration === void 0) throw new chunkOYL2SGBD_cjs.KindNotFoundError(kind, "edge");
9285
+ if (registration === void 0) throw new chunk44SXEVF4_cjs.KindNotFoundError(kind, "edge");
9193
9286
  return registration;
9194
9287
  }
9195
9288
  function buildEdgeEndpointCacheKey(graphId, kind, id) {
@@ -9331,7 +9424,7 @@ async function validateAndPrepareEdgeCreate(ctx, input, id, backend) {
9331
9424
  if (endpointError) throw endpointError;
9332
9425
  const fromNode = await backend.getNode(ctx.graphId, fromKind, input.fromId);
9333
9426
  if (!fromNode || fromNode.deleted_at) {
9334
- throw new chunkOYL2SGBD_cjs.EndpointNotFoundError({
9427
+ throw new chunk44SXEVF4_cjs.EndpointNotFoundError({
9335
9428
  edgeKind: kind,
9336
9429
  endpoint: "from",
9337
9430
  nodeKind: fromKind,
@@ -9340,19 +9433,19 @@ async function validateAndPrepareEdgeCreate(ctx, input, id, backend) {
9340
9433
  }
9341
9434
  const toNode = await backend.getNode(ctx.graphId, toKind, input.toId);
9342
9435
  if (!toNode || toNode.deleted_at) {
9343
- throw new chunkOYL2SGBD_cjs.EndpointNotFoundError({
9436
+ throw new chunk44SXEVF4_cjs.EndpointNotFoundError({
9344
9437
  edgeKind: kind,
9345
9438
  endpoint: "to",
9346
9439
  nodeKind: toKind,
9347
9440
  nodeId: input.toId
9348
9441
  });
9349
9442
  }
9350
- const validatedProps = chunkDD6ONEBN_cjs.validateEdgeProps(edgeKind.schema, input.props, {
9443
+ const validatedProps = chunkLDM2AFKZ_cjs.validateEdgeProps(edgeKind.schema, input.props, {
9351
9444
  kind,
9352
9445
  operation: "create"
9353
9446
  });
9354
- const validFrom = chunkZJHQZZT2_cjs.validateOptionalIsoDate(input.validFrom, "validFrom");
9355
- const validTo = chunkZJHQZZT2_cjs.validateOptionalIsoDate(input.validTo, "validTo");
9447
+ const validFrom = chunkK2ROKOK3_cjs.validateOptionalIsoDate(input.validFrom, "validFrom");
9448
+ const validTo = chunkK2ROKOK3_cjs.validateOptionalIsoDate(input.validTo, "validTo");
9356
9449
  const cardinality = registration.cardinality ?? "many";
9357
9450
  const constraintContext = {
9358
9451
  graphId: ctx.graphId,
@@ -9407,7 +9500,7 @@ async function executeEdgeCreateInternal(ctx, input, backend, options) {
9407
9500
  async function executeEdgeCreate(ctx, input, backend) {
9408
9501
  const result = await executeEdgeCreateInternal(ctx, input, backend);
9409
9502
  if (!result) {
9410
- throw new chunkOYL2SGBD_cjs.DatabaseOperationError(
9503
+ throw new chunk44SXEVF4_cjs.DatabaseOperationError(
9411
9504
  "Edge create failed: expected created edge row",
9412
9505
  { operation: "insert", entity: "edge" }
9413
9506
  );
@@ -9484,7 +9577,7 @@ async function executeEdgeUpdate(ctx, input, backend) {
9484
9577
  const id = input.id;
9485
9578
  const existing = await backend.getEdge(ctx.graphId, id);
9486
9579
  if (!existing || existing.deleted_at) {
9487
- throw new chunkOYL2SGBD_cjs.EdgeNotFoundError("unknown", id);
9580
+ throw new chunk44SXEVF4_cjs.EdgeNotFoundError("unknown", id);
9488
9581
  }
9489
9582
  const opContext = ctx.createOperationContext(
9490
9583
  "update",
@@ -9497,12 +9590,12 @@ async function executeEdgeUpdate(ctx, input, backend) {
9497
9590
  const edgeKind = registration.type;
9498
9591
  const existingProps = JSON.parse(existing.props);
9499
9592
  const mergedProps = { ...existingProps, ...input.props };
9500
- const validatedProps = chunkDD6ONEBN_cjs.validateEdgeProps(edgeKind.schema, mergedProps, {
9593
+ const validatedProps = chunkLDM2AFKZ_cjs.validateEdgeProps(edgeKind.schema, mergedProps, {
9501
9594
  kind: existing.kind,
9502
9595
  operation: "update",
9503
9596
  id
9504
9597
  });
9505
- const validTo = chunkZJHQZZT2_cjs.validateOptionalIsoDate(input.validTo, "validTo");
9598
+ const validTo = chunkK2ROKOK3_cjs.validateOptionalIsoDate(input.validTo, "validTo");
9506
9599
  const updateParams = {
9507
9600
  graphId: ctx.graphId,
9508
9601
  id,
@@ -9517,18 +9610,18 @@ async function executeEdgeUpsertUpdate(ctx, input, backend, options) {
9517
9610
  const id = input.id;
9518
9611
  const existing = await backend.getEdge(ctx.graphId, id);
9519
9612
  if (!existing) {
9520
- throw new chunkOYL2SGBD_cjs.EdgeNotFoundError("unknown", id);
9613
+ throw new chunk44SXEVF4_cjs.EdgeNotFoundError("unknown", id);
9521
9614
  }
9522
9615
  const registration = getEdgeRegistration(ctx.graph, existing.kind);
9523
9616
  const edgeKind = registration.type;
9524
9617
  const existingProps = JSON.parse(existing.props);
9525
9618
  const mergedProps = { ...existingProps, ...input.props };
9526
- const validatedProps = chunkDD6ONEBN_cjs.validateEdgeProps(edgeKind.schema, mergedProps, {
9619
+ const validatedProps = chunkLDM2AFKZ_cjs.validateEdgeProps(edgeKind.schema, mergedProps, {
9527
9620
  kind: existing.kind,
9528
9621
  operation: "update",
9529
9622
  id
9530
9623
  });
9531
- const validTo = chunkZJHQZZT2_cjs.validateOptionalIsoDate(input.validTo, "validTo");
9624
+ const validTo = chunkK2ROKOK3_cjs.validateOptionalIsoDate(input.validTo, "validTo");
9532
9625
  const updateParams = {
9533
9626
  graphId: ctx.graphId,
9534
9627
  id,
@@ -9575,6 +9668,321 @@ async function executeEdgeHardDelete(ctx, id, backend) {
9575
9668
  });
9576
9669
  });
9577
9670
  }
9671
+ var RECORD_SEP = "";
9672
+ var UNIT_SEP = "";
9673
+ var UNDEFINED_SENTINEL = "";
9674
+ function validateMatchOnFields(schema, matchOn, edgeKind) {
9675
+ if (matchOn.length === 0) return;
9676
+ const shape = schema.shape;
9677
+ if (shape === void 0) {
9678
+ throw new chunk44SXEVF4_cjs.ValidationError(
9679
+ `Edge kind "${edgeKind}" has no schema shape to validate matchOn fields against`,
9680
+ {
9681
+ kind: edgeKind,
9682
+ operation: "create",
9683
+ issues: matchOn.map((field2) => ({
9684
+ path: field2,
9685
+ message: `Field "${field2}" does not exist in edge schema`
9686
+ }))
9687
+ }
9688
+ );
9689
+ }
9690
+ const invalidFields = matchOn.filter((field2) => !(field2 in shape));
9691
+ if (invalidFields.length > 0) {
9692
+ throw new chunk44SXEVF4_cjs.ValidationError(
9693
+ `Invalid matchOn fields for edge kind "${edgeKind}": ${invalidFields.join(", ")}`,
9694
+ {
9695
+ kind: edgeKind,
9696
+ operation: "create",
9697
+ issues: invalidFields.map((field2) => ({
9698
+ path: field2,
9699
+ message: `Field "${field2}" does not exist in edge schema`
9700
+ }))
9701
+ }
9702
+ );
9703
+ }
9704
+ }
9705
+ function stableStringify(value) {
9706
+ if (value === void 0) return UNDEFINED_SENTINEL;
9707
+ if (value === null || typeof value !== "object") return JSON.stringify(value);
9708
+ if (Array.isArray(value)) {
9709
+ return `[${value.map((item) => stableStringify(item)).join(",")}]`;
9710
+ }
9711
+ const sorted = Object.keys(value).toSorted();
9712
+ const entries = sorted.map(
9713
+ (key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`
9714
+ );
9715
+ return `{${entries.join(",")}}`;
9716
+ }
9717
+ function buildEdgeCompositeKey(fromKind, fromId, toKind, toId, props, matchOn) {
9718
+ const endpointPart = `${fromKind}${RECORD_SEP}${fromId}${RECORD_SEP}${toKind}${RECORD_SEP}${toId}`;
9719
+ if (matchOn.length === 0) return endpointPart;
9720
+ const sortedFields = [...matchOn].toSorted();
9721
+ const propertyParts = sortedFields.map(
9722
+ (field2) => `${RECORD_SEP}${field2}${UNIT_SEP}${stableStringify(props[field2])}`
9723
+ );
9724
+ return endpointPart + propertyParts.join("");
9725
+ }
9726
+ function buildEndpointPairKey(fromKind, fromId, toKind, toId) {
9727
+ return `${fromKind}${RECORD_SEP}${fromId}${RECORD_SEP}${toKind}${RECORD_SEP}${toId}`;
9728
+ }
9729
+ function findMatchingEdge(rows, matchOn, inputProps) {
9730
+ let liveRow;
9731
+ let deletedRow;
9732
+ for (const row of rows) {
9733
+ if (matchOn.length > 0) {
9734
+ const rowProps = JSON.parse(row.props);
9735
+ const matches = matchOn.every(
9736
+ (field2) => stableStringify(rowProps[field2]) === stableStringify(inputProps[field2])
9737
+ );
9738
+ if (!matches) continue;
9739
+ }
9740
+ if (row.deleted_at === void 0) {
9741
+ liveRow ??= row;
9742
+ } else {
9743
+ deletedRow ??= row;
9744
+ }
9745
+ if (liveRow !== void 0) break;
9746
+ }
9747
+ return { liveRow, deletedRow };
9748
+ }
9749
+ async function executeEdgeGetOrCreateByEndpoints(ctx, kind, fromKind, fromId, toKind, toId, props, backend, options) {
9750
+ const ifExists = options?.ifExists ?? "return";
9751
+ const matchOn = options?.matchOn ?? [];
9752
+ const registration = getEdgeRegistration(ctx.graph, kind);
9753
+ const edgeKind = registration.type;
9754
+ const validatedProps = chunkLDM2AFKZ_cjs.validateEdgeProps(edgeKind.schema, props, {
9755
+ kind,
9756
+ operation: "create"
9757
+ });
9758
+ validateMatchOnFields(edgeKind.schema, matchOn, kind);
9759
+ const candidateRows = await backend.findEdgesByKind({
9760
+ graphId: ctx.graphId,
9761
+ kind,
9762
+ fromKind,
9763
+ fromId,
9764
+ toKind,
9765
+ toId,
9766
+ excludeDeleted: false,
9767
+ temporalMode: "includeTombstones"
9768
+ });
9769
+ const { liveRow, deletedRow } = findMatchingEdge(
9770
+ candidateRows,
9771
+ matchOn,
9772
+ validatedProps
9773
+ );
9774
+ if (liveRow === void 0 && deletedRow === void 0) {
9775
+ const input = {
9776
+ kind,
9777
+ fromKind,
9778
+ fromId,
9779
+ toKind,
9780
+ toId,
9781
+ props: validatedProps
9782
+ };
9783
+ const edge2 = await executeEdgeCreate(ctx, input, backend);
9784
+ return { edge: edge2, action: "created" };
9785
+ }
9786
+ if (liveRow !== void 0) {
9787
+ if (ifExists === "return") {
9788
+ return { edge: rowToEdge(liveRow), action: "found" };
9789
+ }
9790
+ const edge2 = await executeEdgeUpsertUpdate(
9791
+ ctx,
9792
+ { id: liveRow.id, props: validatedProps },
9793
+ backend
9794
+ );
9795
+ return { edge: edge2, action: "updated" };
9796
+ }
9797
+ const cardinality = registration.cardinality ?? "many";
9798
+ const matchedDeletedRow = deletedRow;
9799
+ const effectiveValidTo = matchedDeletedRow.valid_to;
9800
+ const constraintContext = {
9801
+ graphId: ctx.graphId,
9802
+ registry: ctx.registry,
9803
+ backend
9804
+ };
9805
+ await checkCardinalityConstraint(
9806
+ constraintContext,
9807
+ kind,
9808
+ cardinality,
9809
+ fromKind,
9810
+ fromId,
9811
+ toKind,
9812
+ toId,
9813
+ effectiveValidTo
9814
+ );
9815
+ const edge = await executeEdgeUpsertUpdate(
9816
+ ctx,
9817
+ { id: matchedDeletedRow.id, props: validatedProps },
9818
+ backend,
9819
+ { clearDeleted: true }
9820
+ );
9821
+ return { edge, action: "resurrected" };
9822
+ }
9823
+ async function executeEdgeBulkGetOrCreateByEndpoints(ctx, kind, items, backend, options) {
9824
+ if (items.length === 0) return [];
9825
+ const ifExists = options?.ifExists ?? "return";
9826
+ const matchOn = options?.matchOn ?? [];
9827
+ const registration = getEdgeRegistration(ctx.graph, kind);
9828
+ const edgeKind = registration.type;
9829
+ const cardinality = registration.cardinality ?? "many";
9830
+ validateMatchOnFields(edgeKind.schema, matchOn, kind);
9831
+ const validated = [];
9832
+ for (const item of items) {
9833
+ const validatedProps = chunkLDM2AFKZ_cjs.validateEdgeProps(edgeKind.schema, item.props, {
9834
+ kind,
9835
+ operation: "create"
9836
+ });
9837
+ const compositeKey = buildEdgeCompositeKey(
9838
+ item.fromKind,
9839
+ item.fromId,
9840
+ item.toKind,
9841
+ item.toId,
9842
+ validatedProps,
9843
+ matchOn
9844
+ );
9845
+ const endpointKey = buildEndpointPairKey(
9846
+ item.fromKind,
9847
+ item.fromId,
9848
+ item.toKind,
9849
+ item.toId
9850
+ );
9851
+ validated.push({
9852
+ fromKind: item.fromKind,
9853
+ fromId: item.fromId,
9854
+ toKind: item.toKind,
9855
+ toId: item.toId,
9856
+ validatedProps,
9857
+ compositeKey,
9858
+ endpointKey
9859
+ });
9860
+ }
9861
+ const uniqueEndpoints = /* @__PURE__ */ new Map();
9862
+ for (const entry of validated) {
9863
+ if (!uniqueEndpoints.has(entry.endpointKey)) {
9864
+ uniqueEndpoints.set(entry.endpointKey, {
9865
+ fromKind: entry.fromKind,
9866
+ fromId: entry.fromId,
9867
+ toKind: entry.toKind,
9868
+ toId: entry.toId
9869
+ });
9870
+ }
9871
+ }
9872
+ const rowsByEndpoint = /* @__PURE__ */ new Map();
9873
+ for (const [endpointKey, endpoint] of uniqueEndpoints) {
9874
+ const rows = await backend.findEdgesByKind({
9875
+ graphId: ctx.graphId,
9876
+ kind,
9877
+ fromKind: endpoint.fromKind,
9878
+ fromId: endpoint.fromId,
9879
+ toKind: endpoint.toKind,
9880
+ toId: endpoint.toId,
9881
+ excludeDeleted: false,
9882
+ temporalMode: "includeTombstones"
9883
+ });
9884
+ rowsByEndpoint.set(endpointKey, rows);
9885
+ }
9886
+ const toCreate = [];
9887
+ const toFetch = [];
9888
+ const duplicateOf = [];
9889
+ const seenKeys = /* @__PURE__ */ new Map();
9890
+ for (const [index, entry] of validated.entries()) {
9891
+ const previousIndex = seenKeys.get(entry.compositeKey);
9892
+ if (previousIndex !== void 0) {
9893
+ duplicateOf.push({ index, sourceIndex: previousIndex });
9894
+ continue;
9895
+ }
9896
+ seenKeys.set(entry.compositeKey, index);
9897
+ const candidateRows = rowsByEndpoint.get(entry.endpointKey) ?? [];
9898
+ const { liveRow, deletedRow } = findMatchingEdge(
9899
+ candidateRows,
9900
+ matchOn,
9901
+ entry.validatedProps
9902
+ );
9903
+ if (liveRow === void 0 && deletedRow === void 0) {
9904
+ toCreate.push({
9905
+ index,
9906
+ input: {
9907
+ kind,
9908
+ fromKind: entry.fromKind,
9909
+ fromId: entry.fromId,
9910
+ toKind: entry.toKind,
9911
+ toId: entry.toId,
9912
+ props: entry.validatedProps
9913
+ }
9914
+ });
9915
+ } else {
9916
+ const bestRow = liveRow ?? deletedRow;
9917
+ toFetch.push({
9918
+ index,
9919
+ row: bestRow,
9920
+ isDeleted: liveRow === void 0,
9921
+ validatedProps: entry.validatedProps,
9922
+ fromKind: entry.fromKind,
9923
+ fromId: entry.fromId,
9924
+ toKind: entry.toKind,
9925
+ toId: entry.toId
9926
+ });
9927
+ }
9928
+ }
9929
+ const results = Array.from({ length: items.length });
9930
+ if (toCreate.length > 0) {
9931
+ const createInputs = toCreate.map((entry) => entry.input);
9932
+ const createdEdges = await executeEdgeCreateBatch(
9933
+ ctx,
9934
+ createInputs,
9935
+ backend
9936
+ );
9937
+ for (const [batchIndex, entry] of toCreate.entries()) {
9938
+ results[entry.index] = {
9939
+ edge: createdEdges[batchIndex],
9940
+ action: "created"
9941
+ };
9942
+ }
9943
+ }
9944
+ for (const entry of toFetch) {
9945
+ if (entry.isDeleted) {
9946
+ const effectiveValidTo = entry.row.valid_to;
9947
+ const constraintContext = {
9948
+ graphId: ctx.graphId,
9949
+ registry: ctx.registry,
9950
+ backend
9951
+ };
9952
+ await checkCardinalityConstraint(
9953
+ constraintContext,
9954
+ kind,
9955
+ cardinality,
9956
+ entry.fromKind,
9957
+ entry.fromId,
9958
+ entry.toKind,
9959
+ entry.toId,
9960
+ effectiveValidTo
9961
+ );
9962
+ const edge = await executeEdgeUpsertUpdate(
9963
+ ctx,
9964
+ { id: entry.row.id, props: entry.validatedProps },
9965
+ backend,
9966
+ { clearDeleted: true }
9967
+ );
9968
+ results[entry.index] = { edge, action: "resurrected" };
9969
+ } else if (ifExists === "update") {
9970
+ const edge = await executeEdgeUpsertUpdate(
9971
+ ctx,
9972
+ { id: entry.row.id, props: entry.validatedProps },
9973
+ backend
9974
+ );
9975
+ results[entry.index] = { edge, action: "updated" };
9976
+ } else {
9977
+ results[entry.index] = { edge: rowToEdge(entry.row), action: "found" };
9978
+ }
9979
+ }
9980
+ for (const { index, sourceIndex } of duplicateOf) {
9981
+ const sourceResult = results[sourceIndex];
9982
+ results[index] = { edge: sourceResult.edge, action: "found" };
9983
+ }
9984
+ return results;
9985
+ }
9578
9986
 
9579
9987
  // src/store/embedding-sync.ts
9580
9988
  function getEmbeddingFields(schema) {
@@ -9696,7 +10104,7 @@ async function checkUniquenessConstraints(ctx, kind, id, props, constraints) {
9696
10104
  key
9697
10105
  });
9698
10106
  if (existing && existing.node_id !== id) {
9699
- throw new chunkOYL2SGBD_cjs.UniquenessError({
10107
+ throw new chunk44SXEVF4_cjs.UniquenessError({
9700
10108
  constraintName: constraint.name,
9701
10109
  kind: kindToCheck,
9702
10110
  existingId: existing.node_id,
@@ -9779,7 +10187,7 @@ async function updateUniquenessEntries(ctx, kind, id, oldProps, newProps, constr
9779
10187
  key: newKey
9780
10188
  });
9781
10189
  if (existing && existing.node_id !== id) {
9782
- throw new chunkOYL2SGBD_cjs.UniquenessError({
10190
+ throw new chunk44SXEVF4_cjs.UniquenessError({
9783
10191
  constraintName: constraint.name,
9784
10192
  kind: kindToCheck,
9785
10193
  existingId: existing.node_id,
@@ -9803,7 +10211,7 @@ async function updateUniquenessEntries(ctx, kind, id, oldProps, newProps, constr
9803
10211
  // src/store/operations/node-operations.ts
9804
10212
  function getNodeRegistration(graph, kind) {
9805
10213
  const registration = graph.nodes[kind];
9806
- if (registration === void 0) throw new chunkOYL2SGBD_cjs.KindNotFoundError(kind, "node");
10214
+ if (registration === void 0) throw new chunk44SXEVF4_cjs.KindNotFoundError(kind, "node");
9807
10215
  return registration;
9808
10216
  }
9809
10217
  function buildNodeCacheKey(graphId, kind, id) {
@@ -9813,7 +10221,7 @@ function buildUniqueCacheKey(graphId, nodeKind, constraintName, key) {
9813
10221
  return `${graphId}\0${nodeKind}\0${constraintName}\0${key}`;
9814
10222
  }
9815
10223
  function createNodeAlreadyExistsError(kind, id) {
9816
- return new chunkOYL2SGBD_cjs.ValidationError(
10224
+ return new chunk44SXEVF4_cjs.ValidationError(
9817
10225
  `Node already exists: ${kind}/${id}`,
9818
10226
  {
9819
10227
  entityType: "node",
@@ -9955,12 +10363,12 @@ async function validateAndPrepareNodeCreate(ctx, input, id, backend) {
9955
10363
  const kind = input.kind;
9956
10364
  const registration = getNodeRegistration(ctx.graph, kind);
9957
10365
  const nodeKind = registration.type;
9958
- const validatedProps = chunkDD6ONEBN_cjs.validateNodeProps(nodeKind.schema, input.props, {
10366
+ const validatedProps = chunkLDM2AFKZ_cjs.validateNodeProps(nodeKind.schema, input.props, {
9959
10367
  kind,
9960
10368
  operation: "create"
9961
10369
  });
9962
- const validFrom = chunkZJHQZZT2_cjs.validateOptionalIsoDate(input.validFrom, "validFrom");
9963
- const validTo = chunkZJHQZZT2_cjs.validateOptionalIsoDate(input.validTo, "validTo");
10370
+ const validFrom = chunkK2ROKOK3_cjs.validateOptionalIsoDate(input.validFrom, "validFrom");
10371
+ const validTo = chunkK2ROKOK3_cjs.validateOptionalIsoDate(input.validTo, "validTo");
9964
10372
  const existingNode = await backend.getNode(ctx.graphId, kind, id);
9965
10373
  if (existingNode && !existingNode.deleted_at) {
9966
10374
  throw createNodeAlreadyExistsError(kind, id);
@@ -10048,7 +10456,7 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
10048
10456
  async function executeNodeCreate(ctx, input, backend) {
10049
10457
  const result = await executeNodeCreateInternal(ctx, input, backend);
10050
10458
  if (!result) {
10051
- throw new chunkOYL2SGBD_cjs.DatabaseOperationError(
10459
+ throw new chunk44SXEVF4_cjs.DatabaseOperationError(
10052
10460
  "Node create failed: expected created node row",
10053
10461
  { operation: "insert", entity: "node" }
10054
10462
  );
@@ -10149,17 +10557,17 @@ async function executeNodeUpdate(ctx, input, backend, options) {
10149
10557
  const registration = getNodeRegistration(ctx.graph, kind);
10150
10558
  const existing = await backend.getNode(ctx.graphId, kind, id);
10151
10559
  if (!existing || existing.deleted_at && !options?.clearDeleted) {
10152
- throw new chunkOYL2SGBD_cjs.NodeNotFoundError(kind, id);
10560
+ throw new chunk44SXEVF4_cjs.NodeNotFoundError(kind, id);
10153
10561
  }
10154
10562
  const existingProps = JSON.parse(existing.props);
10155
10563
  const mergedProps = { ...existingProps, ...input.props };
10156
10564
  const nodeKind = registration.type;
10157
- const validatedProps = chunkDD6ONEBN_cjs.validateNodeProps(nodeKind.schema, mergedProps, {
10565
+ const validatedProps = chunkLDM2AFKZ_cjs.validateNodeProps(nodeKind.schema, mergedProps, {
10158
10566
  kind,
10159
10567
  operation: "update",
10160
10568
  id
10161
10569
  });
10162
- const validTo = chunkZJHQZZT2_cjs.validateOptionalIsoDate(input.validTo, "validTo");
10570
+ const validTo = chunkK2ROKOK3_cjs.validateOptionalIsoDate(input.validTo, "validTo");
10163
10571
  const uniquenessContext = {
10164
10572
  graphId: ctx.graphId,
10165
10573
  registry: ctx.registry,
@@ -10199,17 +10607,17 @@ async function executeNodeUpsertUpdate(ctx, input, backend, options) {
10199
10607
  const registration = getNodeRegistration(ctx.graph, kind);
10200
10608
  const existing = await backend.getNode(ctx.graphId, kind, id);
10201
10609
  if (!existing || existing.deleted_at && !options?.clearDeleted) {
10202
- throw new chunkOYL2SGBD_cjs.NodeNotFoundError(kind, id);
10610
+ throw new chunk44SXEVF4_cjs.NodeNotFoundError(kind, id);
10203
10611
  }
10204
10612
  const existingProps = JSON.parse(existing.props);
10205
10613
  const mergedProps = { ...existingProps, ...input.props };
10206
10614
  const nodeKind = registration.type;
10207
- const validatedProps = chunkDD6ONEBN_cjs.validateNodeProps(nodeKind.schema, mergedProps, {
10615
+ const validatedProps = chunkLDM2AFKZ_cjs.validateNodeProps(nodeKind.schema, mergedProps, {
10208
10616
  kind,
10209
10617
  operation: "update",
10210
10618
  id
10211
10619
  });
10212
- const validTo = chunkZJHQZZT2_cjs.validateOptionalIsoDate(input.validTo, "validTo");
10620
+ const validTo = chunkK2ROKOK3_cjs.validateOptionalIsoDate(input.validTo, "validTo");
10213
10621
  const uniquenessContext = {
10214
10622
  graphId: ctx.graphId,
10215
10623
  registry: ctx.registry,
@@ -10263,7 +10671,7 @@ async function executeNodeDelete(ctx, kind, id, backend) {
10263
10671
  const edgeKinds = [
10264
10672
  ...new Set(connectedEdges.map((edge) => edge.kind))
10265
10673
  ];
10266
- throw new chunkOYL2SGBD_cjs.RestrictedDeleteError({
10674
+ throw new chunk44SXEVF4_cjs.RestrictedDeleteError({
10267
10675
  nodeKind: kind,
10268
10676
  nodeId: id,
10269
10677
  edgeCount: connectedEdges.length,
@@ -10328,7 +10736,7 @@ async function executeNodeHardDelete(ctx, kind, id, backend) {
10328
10736
  const edgeKinds = [
10329
10737
  ...new Set(connectedEdges.map((edge) => edge.kind))
10330
10738
  ];
10331
- throw new chunkOYL2SGBD_cjs.RestrictedDeleteError({
10739
+ throw new chunk44SXEVF4_cjs.RestrictedDeleteError({
10332
10740
  nodeKind: kind,
10333
10741
  nodeId: id,
10334
10742
  edgeCount: connectedEdges.length,
@@ -10357,6 +10765,235 @@ async function executeNodeHardDelete(ctx, kind, id, backend) {
10357
10765
  await ("transaction" in backend && backend.capabilities.transactions ? backend.transaction(async (tx) => hardDelete(tx)) : hardDelete(backend));
10358
10766
  });
10359
10767
  }
10768
+ function resolveConstraint(graph, kind, constraintName) {
10769
+ const registration = getNodeRegistration(graph, kind);
10770
+ const constraints = registration.unique ?? [];
10771
+ const constraint = constraints.find((c) => c.name === constraintName);
10772
+ if (constraint === void 0) {
10773
+ throw new chunk44SXEVF4_cjs.NodeConstraintNotFoundError(constraintName, kind);
10774
+ }
10775
+ return constraint;
10776
+ }
10777
+ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, props, backend, options) {
10778
+ const ifExists = options?.ifExists ?? "return";
10779
+ const registration = getNodeRegistration(ctx.graph, kind);
10780
+ const nodeKind = registration.type;
10781
+ const validatedProps = chunkLDM2AFKZ_cjs.validateNodeProps(nodeKind.schema, props, {
10782
+ kind,
10783
+ operation: "create"
10784
+ });
10785
+ const constraint = resolveConstraint(ctx.graph, kind, constraintName);
10786
+ if (!checkWherePredicate(constraint, validatedProps)) {
10787
+ const input = { kind, props: validatedProps };
10788
+ const node = await executeNodeCreate(ctx, input, backend);
10789
+ return { node, action: "created" };
10790
+ }
10791
+ const key = computeUniqueKey(
10792
+ validatedProps,
10793
+ constraint.fields,
10794
+ constraint.collation
10795
+ );
10796
+ const kindsToCheck = getKindsForUniquenessCheck(
10797
+ kind,
10798
+ constraint.scope,
10799
+ ctx.registry
10800
+ );
10801
+ let existingUniqueRow;
10802
+ for (const kindToCheck of kindsToCheck) {
10803
+ const row = await backend.checkUnique({
10804
+ graphId: ctx.graphId,
10805
+ nodeKind: kindToCheck,
10806
+ constraintName: constraint.name,
10807
+ key,
10808
+ includeDeleted: true
10809
+ });
10810
+ if (row !== void 0) {
10811
+ existingUniqueRow = row;
10812
+ break;
10813
+ }
10814
+ }
10815
+ if (existingUniqueRow === void 0) {
10816
+ const input = { kind, props: validatedProps };
10817
+ const node = await executeNodeCreate(ctx, input, backend);
10818
+ return { node, action: "created" };
10819
+ }
10820
+ const existingRow = await backend.getNode(
10821
+ ctx.graphId,
10822
+ existingUniqueRow.concrete_kind,
10823
+ existingUniqueRow.node_id
10824
+ );
10825
+ if (existingRow === void 0) {
10826
+ const input = { kind, props: validatedProps };
10827
+ const node = await executeNodeCreate(ctx, input, backend);
10828
+ return { node, action: "created" };
10829
+ }
10830
+ const isSoftDeleted = existingRow.deleted_at !== void 0;
10831
+ if (isSoftDeleted || ifExists === "update") {
10832
+ const concreteKind = existingUniqueRow.concrete_kind;
10833
+ const node = await executeNodeUpsertUpdate(
10834
+ ctx,
10835
+ {
10836
+ kind: concreteKind,
10837
+ id: existingRow.id,
10838
+ props: validatedProps
10839
+ },
10840
+ backend,
10841
+ { clearDeleted: isSoftDeleted }
10842
+ );
10843
+ return { node, action: isSoftDeleted ? "resurrected" : "updated" };
10844
+ }
10845
+ return { node: rowToNode(existingRow), action: "found" };
10846
+ }
10847
+ async function executeNodeBulkGetOrCreateByConstraint(ctx, kind, constraintName, items, backend, options) {
10848
+ if (items.length === 0) return [];
10849
+ const ifExists = options?.ifExists ?? "return";
10850
+ const registration = getNodeRegistration(ctx.graph, kind);
10851
+ const nodeKind = registration.type;
10852
+ const constraint = resolveConstraint(ctx.graph, kind, constraintName);
10853
+ const validated = [];
10854
+ for (const item of items) {
10855
+ const validatedProps = chunkLDM2AFKZ_cjs.validateNodeProps(nodeKind.schema, item.props, {
10856
+ kind,
10857
+ operation: "create"
10858
+ });
10859
+ const applies = checkWherePredicate(constraint, validatedProps);
10860
+ const key = applies ? computeUniqueKey(
10861
+ validatedProps,
10862
+ constraint.fields,
10863
+ constraint.collation
10864
+ ) : void 0;
10865
+ validated.push({ validatedProps, key });
10866
+ }
10867
+ const uniqueKeys = [
10868
+ ...new Set(
10869
+ validated.map((v) => v.key).filter((k) => k !== void 0)
10870
+ )
10871
+ ];
10872
+ const kindsToCheck = getKindsForUniquenessCheck(
10873
+ kind,
10874
+ constraint.scope,
10875
+ ctx.registry
10876
+ );
10877
+ const existingByKey = /* @__PURE__ */ new Map();
10878
+ if (uniqueKeys.length > 0) {
10879
+ for (const kindToCheck of kindsToCheck) {
10880
+ if (backend.checkUniqueBatch === void 0) {
10881
+ for (const key of uniqueKeys) {
10882
+ if (existingByKey.has(key)) continue;
10883
+ const row = await backend.checkUnique({
10884
+ graphId: ctx.graphId,
10885
+ nodeKind: kindToCheck,
10886
+ constraintName: constraint.name,
10887
+ key,
10888
+ includeDeleted: true
10889
+ });
10890
+ if (row !== void 0) {
10891
+ existingByKey.set(row.key, row);
10892
+ }
10893
+ }
10894
+ } else {
10895
+ const rows = await backend.checkUniqueBatch({
10896
+ graphId: ctx.graphId,
10897
+ nodeKind: kindToCheck,
10898
+ constraintName: constraint.name,
10899
+ keys: uniqueKeys,
10900
+ includeDeleted: true
10901
+ });
10902
+ for (const row of rows) {
10903
+ if (!existingByKey.has(row.key)) {
10904
+ existingByKey.set(row.key, row);
10905
+ }
10906
+ }
10907
+ }
10908
+ }
10909
+ }
10910
+ const toCreate = [];
10911
+ const toFetch = [];
10912
+ const duplicateOf = [];
10913
+ const seenKeys = /* @__PURE__ */ new Map();
10914
+ for (const [index, { validatedProps, key }] of validated.entries()) {
10915
+ if (key === void 0) {
10916
+ toCreate.push({
10917
+ index,
10918
+ input: { kind, props: validatedProps }
10919
+ });
10920
+ continue;
10921
+ }
10922
+ const previousIndex = seenKeys.get(key);
10923
+ if (previousIndex !== void 0) {
10924
+ duplicateOf.push({ index, sourceIndex: previousIndex });
10925
+ continue;
10926
+ }
10927
+ seenKeys.set(key, index);
10928
+ const existing = existingByKey.get(key);
10929
+ if (existing === void 0) {
10930
+ toCreate.push({
10931
+ index,
10932
+ input: { kind, props: validatedProps }
10933
+ });
10934
+ } else {
10935
+ toFetch.push({
10936
+ index,
10937
+ nodeId: existing.node_id,
10938
+ concreteKind: existing.concrete_kind,
10939
+ validatedProps,
10940
+ isSoftDeleted: existing.deleted_at !== void 0
10941
+ });
10942
+ }
10943
+ }
10944
+ const results = Array.from({ length: items.length });
10945
+ if (toCreate.length > 0) {
10946
+ const createInputs = toCreate.map((entry) => entry.input);
10947
+ const createdNodes = await executeNodeCreateBatch(
10948
+ ctx,
10949
+ createInputs,
10950
+ backend
10951
+ );
10952
+ for (const [batchIndex, entry] of toCreate.entries()) {
10953
+ results[entry.index] = {
10954
+ node: createdNodes[batchIndex],
10955
+ action: "created"
10956
+ };
10957
+ }
10958
+ }
10959
+ for (const entry of toFetch) {
10960
+ const { index, concreteKind, validatedProps, isSoftDeleted, nodeId } = entry;
10961
+ const existingRow = await backend.getNode(
10962
+ ctx.graphId,
10963
+ concreteKind,
10964
+ nodeId
10965
+ );
10966
+ if (existingRow === void 0) {
10967
+ const input = { kind, props: validatedProps };
10968
+ const node = await executeNodeCreate(ctx, input, backend);
10969
+ results[index] = { node, action: "created" };
10970
+ continue;
10971
+ }
10972
+ if (isSoftDeleted || ifExists === "update") {
10973
+ const node = await executeNodeUpsertUpdate(
10974
+ ctx,
10975
+ {
10976
+ kind: concreteKind,
10977
+ id: existingRow.id,
10978
+ props: validatedProps
10979
+ },
10980
+ backend,
10981
+ { clearDeleted: isSoftDeleted }
10982
+ );
10983
+ results[index] = {
10984
+ node,
10985
+ action: isSoftDeleted ? "resurrected" : "updated"
10986
+ };
10987
+ } else {
10988
+ results[index] = { node: rowToNode(existingRow), action: "found" };
10989
+ }
10990
+ }
10991
+ for (const { index, sourceIndex } of duplicateOf) {
10992
+ const sourceResult = results[sourceIndex];
10993
+ results[index] = { node: sourceResult.node, action: "found" };
10994
+ }
10995
+ return results;
10996
+ }
10360
10997
 
10361
10998
  // src/store/store.ts
10362
10999
  var Store = class {
@@ -10470,7 +11107,23 @@ var Store = class {
10470
11107
  executeDelete: (kind, id, backend) => executeNodeDelete(ctx, kind, id, backend),
10471
11108
  executeHardDelete: (kind, id, backend) => executeNodeHardDelete(ctx, kind, id, backend),
10472
11109
  matchesTemporalMode: (row, options) => this.#matchesTemporalMode(row, options),
10473
- createQuery: () => this.query()
11110
+ createQuery: () => this.query(),
11111
+ executeGetOrCreateByConstraint: (kind, constraintName, props, backend, options) => executeNodeGetOrCreateByConstraint(
11112
+ ctx,
11113
+ kind,
11114
+ constraintName,
11115
+ props,
11116
+ backend,
11117
+ options
11118
+ ),
11119
+ executeBulkGetOrCreateByConstraint: (kind, constraintName, items, backend, options) => executeNodeBulkGetOrCreateByConstraint(
11120
+ ctx,
11121
+ kind,
11122
+ constraintName,
11123
+ items,
11124
+ backend,
11125
+ options
11126
+ )
10474
11127
  };
10475
11128
  }
10476
11129
  /**
@@ -10489,7 +11142,25 @@ var Store = class {
10489
11142
  executeDelete: (id, backend) => executeEdgeDelete(ctx, id, backend),
10490
11143
  executeHardDelete: (id, backend) => executeEdgeHardDelete(ctx, id, backend),
10491
11144
  matchesTemporalMode: (row, options) => this.#matchesTemporalMode(row, options),
10492
- createQuery: () => this.query()
11145
+ createQuery: () => this.query(),
11146
+ executeGetOrCreateByEndpoints: (kind, fromKind, fromId, toKind, toId, props, backend, options) => executeEdgeGetOrCreateByEndpoints(
11147
+ ctx,
11148
+ kind,
11149
+ fromKind,
11150
+ fromId,
11151
+ toKind,
11152
+ toId,
11153
+ props,
11154
+ backend,
11155
+ options
11156
+ ),
11157
+ executeBulkGetOrCreateByEndpoints: (kind, items, backend, options) => executeEdgeBulkGetOrCreateByEndpoints(
11158
+ ctx,
11159
+ kind,
11160
+ items,
11161
+ backend,
11162
+ options
11163
+ )
10493
11164
  };
10494
11165
  }
10495
11166
  // === Query Builder ===
@@ -10624,7 +11295,7 @@ var Store = class {
10624
11295
  // === Internal: Temporal Filtering ===
10625
11296
  #matchesTemporalMode(row, options) {
10626
11297
  const mode = options?.temporalMode ?? this.#graph.defaults.temporalMode;
10627
- const asOf = options?.asOf ?? chunkZJHQZZT2_cjs.nowIso();
11298
+ const asOf = options?.asOf ?? chunkK2ROKOK3_cjs.nowIso();
10628
11299
  switch (mode) {
10629
11300
  case "current":
10630
11301
  case "asOf": {
@@ -10657,133 +11328,137 @@ function createStore(graph, backend, options) {
10657
11328
  }
10658
11329
  async function createStoreWithSchema(graph, backend, options) {
10659
11330
  const store = createStore(graph, backend, options);
10660
- const result = await chunkDD6ONEBN_cjs.ensureSchema(backend, graph, options);
11331
+ const result = await chunkLDM2AFKZ_cjs.ensureSchema(backend, graph, options);
10661
11332
  return [store, result];
10662
11333
  }
10663
11334
 
10664
11335
  Object.defineProperty(exports, "isMetaEdge", {
10665
11336
  enumerable: true,
10666
- get: function () { return chunkDD6ONEBN_cjs.isMetaEdge; }
11337
+ get: function () { return chunkLDM2AFKZ_cjs.isMetaEdge; }
10667
11338
  });
10668
11339
  Object.defineProperty(exports, "defineGraph", {
10669
11340
  enumerable: true,
10670
- get: function () { return chunkZJHQZZT2_cjs.defineGraph; }
11341
+ get: function () { return chunkK2ROKOK3_cjs.defineGraph; }
10671
11342
  });
10672
11343
  Object.defineProperty(exports, "getEdgeKinds", {
10673
11344
  enumerable: true,
10674
- get: function () { return chunkZJHQZZT2_cjs.getEdgeKinds; }
11345
+ get: function () { return chunkK2ROKOK3_cjs.getEdgeKinds; }
10675
11346
  });
10676
11347
  Object.defineProperty(exports, "getNodeKinds", {
10677
11348
  enumerable: true,
10678
- get: function () { return chunkZJHQZZT2_cjs.getNodeKinds; }
11349
+ get: function () { return chunkK2ROKOK3_cjs.getNodeKinds; }
10679
11350
  });
10680
11351
  Object.defineProperty(exports, "isEdgeType", {
10681
11352
  enumerable: true,
10682
- get: function () { return chunkZJHQZZT2_cjs.isEdgeType; }
11353
+ get: function () { return chunkK2ROKOK3_cjs.isEdgeType; }
10683
11354
  });
10684
11355
  Object.defineProperty(exports, "isEdgeTypeWithEndpoints", {
10685
11356
  enumerable: true,
10686
- get: function () { return chunkZJHQZZT2_cjs.isEdgeTypeWithEndpoints; }
11357
+ get: function () { return chunkK2ROKOK3_cjs.isEdgeTypeWithEndpoints; }
10687
11358
  });
10688
11359
  Object.defineProperty(exports, "isGraphDef", {
10689
11360
  enumerable: true,
10690
- get: function () { return chunkZJHQZZT2_cjs.isGraphDef; }
11361
+ get: function () { return chunkK2ROKOK3_cjs.isGraphDef; }
10691
11362
  });
10692
11363
  Object.defineProperty(exports, "isNodeType", {
10693
11364
  enumerable: true,
10694
- get: function () { return chunkZJHQZZT2_cjs.isNodeType; }
11365
+ get: function () { return chunkK2ROKOK3_cjs.isNodeType; }
10695
11366
  });
10696
11367
  Object.defineProperty(exports, "CardinalityError", {
10697
11368
  enumerable: true,
10698
- get: function () { return chunkOYL2SGBD_cjs.CardinalityError; }
11369
+ get: function () { return chunk44SXEVF4_cjs.CardinalityError; }
10699
11370
  });
10700
11371
  Object.defineProperty(exports, "CompilerInvariantError", {
10701
11372
  enumerable: true,
10702
- get: function () { return chunkOYL2SGBD_cjs.CompilerInvariantError; }
11373
+ get: function () { return chunk44SXEVF4_cjs.CompilerInvariantError; }
10703
11374
  });
10704
11375
  Object.defineProperty(exports, "ConfigurationError", {
10705
11376
  enumerable: true,
10706
- get: function () { return chunkOYL2SGBD_cjs.ConfigurationError; }
11377
+ get: function () { return chunk44SXEVF4_cjs.ConfigurationError; }
10707
11378
  });
10708
11379
  Object.defineProperty(exports, "DatabaseOperationError", {
10709
11380
  enumerable: true,
10710
- get: function () { return chunkOYL2SGBD_cjs.DatabaseOperationError; }
11381
+ get: function () { return chunk44SXEVF4_cjs.DatabaseOperationError; }
10711
11382
  });
10712
11383
  Object.defineProperty(exports, "DisjointError", {
10713
11384
  enumerable: true,
10714
- get: function () { return chunkOYL2SGBD_cjs.DisjointError; }
11385
+ get: function () { return chunk44SXEVF4_cjs.DisjointError; }
10715
11386
  });
10716
11387
  Object.defineProperty(exports, "EdgeNotFoundError", {
10717
11388
  enumerable: true,
10718
- get: function () { return chunkOYL2SGBD_cjs.EdgeNotFoundError; }
11389
+ get: function () { return chunk44SXEVF4_cjs.EdgeNotFoundError; }
10719
11390
  });
10720
11391
  Object.defineProperty(exports, "EndpointError", {
10721
11392
  enumerable: true,
10722
- get: function () { return chunkOYL2SGBD_cjs.EndpointError; }
11393
+ get: function () { return chunk44SXEVF4_cjs.EndpointError; }
10723
11394
  });
10724
11395
  Object.defineProperty(exports, "EndpointNotFoundError", {
10725
11396
  enumerable: true,
10726
- get: function () { return chunkOYL2SGBD_cjs.EndpointNotFoundError; }
11397
+ get: function () { return chunk44SXEVF4_cjs.EndpointNotFoundError; }
10727
11398
  });
10728
11399
  Object.defineProperty(exports, "KindNotFoundError", {
10729
11400
  enumerable: true,
10730
- get: function () { return chunkOYL2SGBD_cjs.KindNotFoundError; }
11401
+ get: function () { return chunk44SXEVF4_cjs.KindNotFoundError; }
10731
11402
  });
10732
11403
  Object.defineProperty(exports, "MigrationError", {
10733
11404
  enumerable: true,
10734
- get: function () { return chunkOYL2SGBD_cjs.MigrationError; }
11405
+ get: function () { return chunk44SXEVF4_cjs.MigrationError; }
11406
+ });
11407
+ Object.defineProperty(exports, "NodeConstraintNotFoundError", {
11408
+ enumerable: true,
11409
+ get: function () { return chunk44SXEVF4_cjs.NodeConstraintNotFoundError; }
10735
11410
  });
10736
11411
  Object.defineProperty(exports, "NodeNotFoundError", {
10737
11412
  enumerable: true,
10738
- get: function () { return chunkOYL2SGBD_cjs.NodeNotFoundError; }
11413
+ get: function () { return chunk44SXEVF4_cjs.NodeNotFoundError; }
10739
11414
  });
10740
11415
  Object.defineProperty(exports, "RestrictedDeleteError", {
10741
11416
  enumerable: true,
10742
- get: function () { return chunkOYL2SGBD_cjs.RestrictedDeleteError; }
11417
+ get: function () { return chunk44SXEVF4_cjs.RestrictedDeleteError; }
10743
11418
  });
10744
11419
  Object.defineProperty(exports, "SchemaMismatchError", {
10745
11420
  enumerable: true,
10746
- get: function () { return chunkOYL2SGBD_cjs.SchemaMismatchError; }
11421
+ get: function () { return chunk44SXEVF4_cjs.SchemaMismatchError; }
10747
11422
  });
10748
11423
  Object.defineProperty(exports, "TypeGraphError", {
10749
11424
  enumerable: true,
10750
- get: function () { return chunkOYL2SGBD_cjs.TypeGraphError; }
11425
+ get: function () { return chunk44SXEVF4_cjs.TypeGraphError; }
10751
11426
  });
10752
11427
  Object.defineProperty(exports, "UniquenessError", {
10753
11428
  enumerable: true,
10754
- get: function () { return chunkOYL2SGBD_cjs.UniquenessError; }
11429
+ get: function () { return chunk44SXEVF4_cjs.UniquenessError; }
10755
11430
  });
10756
11431
  Object.defineProperty(exports, "UnsupportedPredicateError", {
10757
11432
  enumerable: true,
10758
- get: function () { return chunkOYL2SGBD_cjs.UnsupportedPredicateError; }
11433
+ get: function () { return chunk44SXEVF4_cjs.UnsupportedPredicateError; }
10759
11434
  });
10760
11435
  Object.defineProperty(exports, "ValidationError", {
10761
11436
  enumerable: true,
10762
- get: function () { return chunkOYL2SGBD_cjs.ValidationError; }
11437
+ get: function () { return chunk44SXEVF4_cjs.ValidationError; }
10763
11438
  });
10764
11439
  Object.defineProperty(exports, "VersionConflictError", {
10765
11440
  enumerable: true,
10766
- get: function () { return chunkOYL2SGBD_cjs.VersionConflictError; }
11441
+ get: function () { return chunk44SXEVF4_cjs.VersionConflictError; }
10767
11442
  });
10768
11443
  Object.defineProperty(exports, "getErrorSuggestion", {
10769
11444
  enumerable: true,
10770
- get: function () { return chunkOYL2SGBD_cjs.getErrorSuggestion; }
11445
+ get: function () { return chunk44SXEVF4_cjs.getErrorSuggestion; }
10771
11446
  });
10772
11447
  Object.defineProperty(exports, "isConstraintError", {
10773
11448
  enumerable: true,
10774
- get: function () { return chunkOYL2SGBD_cjs.isConstraintError; }
11449
+ get: function () { return chunk44SXEVF4_cjs.isConstraintError; }
10775
11450
  });
10776
11451
  Object.defineProperty(exports, "isSystemError", {
10777
11452
  enumerable: true,
10778
- get: function () { return chunkOYL2SGBD_cjs.isSystemError; }
11453
+ get: function () { return chunk44SXEVF4_cjs.isSystemError; }
10779
11454
  });
10780
11455
  Object.defineProperty(exports, "isTypeGraphError", {
10781
11456
  enumerable: true,
10782
- get: function () { return chunkOYL2SGBD_cjs.isTypeGraphError; }
11457
+ get: function () { return chunk44SXEVF4_cjs.isTypeGraphError; }
10783
11458
  });
10784
11459
  Object.defineProperty(exports, "isUserRecoverable", {
10785
11460
  enumerable: true,
10786
- get: function () { return chunkOYL2SGBD_cjs.isUserRecoverable; }
11461
+ get: function () { return chunk44SXEVF4_cjs.isUserRecoverable; }
10787
11462
  });
10788
11463
  Object.defineProperty(exports, "MAX_JSON_POINTER_DEPTH", {
10789
11464
  enumerable: true,