@nicia-ai/typegraph 0.16.1 → 0.17.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 (53) hide show
  1. package/dist/backend/postgres/index.cjs +28 -28
  2. package/dist/backend/postgres/index.js +3 -3
  3. package/dist/backend/sqlite/index.cjs +13 -13
  4. package/dist/backend/sqlite/index.js +3 -3
  5. package/dist/backend/sqlite/local.cjs +10 -10
  6. package/dist/backend/sqlite/local.cjs.map +1 -1
  7. package/dist/backend/sqlite/local.js +6 -6
  8. package/dist/backend/sqlite/local.js.map +1 -1
  9. package/dist/{chunk-CRMN2NOM.cjs → chunk-2UTJRP4F.cjs} +14 -14
  10. package/dist/{chunk-CRMN2NOM.cjs.map → chunk-2UTJRP4F.cjs.map} +1 -1
  11. package/dist/{chunk-NI2GV74U.cjs → chunk-5GZMPJOP.cjs} +6 -6
  12. package/dist/{chunk-NI2GV74U.cjs.map → chunk-5GZMPJOP.cjs.map} +1 -1
  13. package/dist/{chunk-56RQFK7U.cjs → chunk-5H74QKKF.cjs} +50 -26
  14. package/dist/chunk-5H74QKKF.cjs.map +1 -0
  15. package/dist/{chunk-HWWF3FOP.js → chunk-7ZVPFJLQ.js} +3 -3
  16. package/dist/{chunk-HWWF3FOP.js.map → chunk-7ZVPFJLQ.js.map} +1 -1
  17. package/dist/{chunk-IRFD3MEU.js → chunk-G5CYWKRF.js} +3 -3
  18. package/dist/{chunk-IRFD3MEU.js.map → chunk-G5CYWKRF.js.map} +1 -1
  19. package/dist/{chunk-XZBAGJJH.js → chunk-IRS2C6GN.js} +36 -12
  20. package/dist/chunk-IRS2C6GN.js.map +1 -0
  21. package/dist/{chunk-44SXEVF4.cjs → chunk-O5PST6TB.cjs} +17 -2
  22. package/dist/chunk-O5PST6TB.cjs.map +1 -0
  23. package/dist/{chunk-L4ON6RJF.js → chunk-W6M7XWKX.js} +4 -4
  24. package/dist/{chunk-L4ON6RJF.js.map → chunk-W6M7XWKX.js.map} +1 -1
  25. package/dist/{chunk-SJ2QMDXY.js → chunk-WFMTAEEN.js} +17 -3
  26. package/dist/chunk-WFMTAEEN.js.map +1 -0
  27. package/dist/{chunk-3HQLOKS5.cjs → chunk-X33WV2UF.cjs} +14 -14
  28. package/dist/{chunk-3HQLOKS5.cjs.map → chunk-X33WV2UF.cjs.map} +1 -1
  29. package/dist/{index-QTnQwakS.d.cts → index-DXkEXpNz.d.cts} +13 -1
  30. package/dist/{index-QTnQwakS.d.ts → index-DXkEXpNz.d.ts} +13 -1
  31. package/dist/index.cjs +283 -240
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +3 -3
  34. package/dist/index.d.ts +3 -3
  35. package/dist/index.js +69 -30
  36. package/dist/index.js.map +1 -1
  37. package/dist/interchange/index.cjs +7 -7
  38. package/dist/interchange/index.d.cts +1 -1
  39. package/dist/interchange/index.d.ts +1 -1
  40. package/dist/interchange/index.js +2 -2
  41. package/dist/profiler/index.d.cts +1 -1
  42. package/dist/profiler/index.d.ts +1 -1
  43. package/dist/schema/index.cjs +22 -22
  44. package/dist/schema/index.d.cts +1 -1
  45. package/dist/schema/index.d.ts +1 -1
  46. package/dist/schema/index.js +4 -4
  47. package/dist/{store-BZ7BexR1.d.cts → store-B_JzzHwb.d.cts} +2 -2
  48. package/dist/{store--7Nft1Ii.d.ts → store-DkY1pDfu.d.ts} +2 -2
  49. package/package.json +1 -1
  50. package/dist/chunk-44SXEVF4.cjs.map +0 -1
  51. package/dist/chunk-56RQFK7U.cjs.map +0 -1
  52. package/dist/chunk-SJ2QMDXY.js.map +0 -1
  53. package/dist/chunk-XZBAGJJH.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunk3HQLOKS5_cjs = require('./chunk-3HQLOKS5.cjs');
4
- var chunkNI2GV74U_cjs = require('./chunk-NI2GV74U.cjs');
5
- var chunk44SXEVF4_cjs = require('./chunk-44SXEVF4.cjs');
3
+ var chunkX33WV2UF_cjs = require('./chunk-X33WV2UF.cjs');
4
+ var chunk5GZMPJOP_cjs = require('./chunk-5GZMPJOP.cjs');
5
+ var chunkO5PST6TB_cjs = require('./chunk-O5PST6TB.cjs');
6
6
  var chunkMME3H4ZF_cjs = require('./chunk-MME3H4ZF.cjs');
7
7
  var chunkP5CNM325_cjs = require('./chunk-P5CNM325.cjs');
8
8
  var zod = require('zod');
@@ -32,7 +32,7 @@ var PROTOTYPE_POLLUTION_KEYS = /* @__PURE__ */ new Set([
32
32
  function validateProjectionField(field2, entityType, kind) {
33
33
  const reserved = entityType === "node" ? RESERVED_NODE_KEYS : RESERVED_EDGE_KEYS;
34
34
  if (reserved.has(field2)) {
35
- throw new chunk44SXEVF4_cjs.ConfigurationError(
35
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
36
36
  `Projection field "${field2}" on ${entityType} kind "${kind}" conflicts with a reserved structural key`,
37
37
  { field: field2, kind, entityType, reservedKeys: [...reserved] },
38
38
  {
@@ -41,7 +41,7 @@ function validateProjectionField(field2, entityType, kind) {
41
41
  );
42
42
  }
43
43
  if (PROTOTYPE_POLLUTION_KEYS.has(field2)) {
44
- throw new chunk44SXEVF4_cjs.ConfigurationError(
44
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
45
45
  `Projection field "${field2}" on ${entityType} kind "${kind}" is not allowed`,
46
46
  { field: field2, kind, entityType },
47
47
  {
@@ -67,7 +67,7 @@ function validateSchemaKeys(schema, name) {
67
67
  (key) => RESERVED_NODE_KEYS.has(key)
68
68
  );
69
69
  if (conflicts.length > 0) {
70
- throw new chunk44SXEVF4_cjs.ConfigurationError(
70
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
71
71
  `Node "${name}" schema contains reserved property names: ${conflicts.join(", ")}`,
72
72
  { nodeType: name, conflicts, reservedKeys: [...RESERVED_NODE_KEYS] },
73
73
  {
@@ -79,7 +79,7 @@ function validateSchemaKeys(schema, name) {
79
79
  function defineNode(name, options) {
80
80
  validateSchemaKeys(options.schema, name);
81
81
  return Object.freeze({
82
- [chunkNI2GV74U_cjs.NODE_TYPE_BRAND]: true,
82
+ [chunk5GZMPJOP_cjs.NODE_TYPE_BRAND]: true,
83
83
  kind: name,
84
84
  schema: options.schema,
85
85
  description: options.description
@@ -92,7 +92,7 @@ function validateSchemaKeys2(schema, name) {
92
92
  (key) => RESERVED_EDGE_KEYS.has(key)
93
93
  );
94
94
  if (conflicts.length > 0) {
95
- throw new chunk44SXEVF4_cjs.ConfigurationError(
95
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
96
96
  `Edge "${name}" schema contains reserved property names: ${conflicts.join(", ")}`,
97
97
  { edgeType: name, conflicts, reservedKeys: [...RESERVED_EDGE_KEYS] },
98
98
  {
@@ -105,7 +105,7 @@ function defineEdge(name, options) {
105
105
  const schema = options?.schema ?? EMPTY_SCHEMA;
106
106
  validateSchemaKeys2(schema, name);
107
107
  return Object.freeze({
108
- [chunkNI2GV74U_cjs.EDGE_TYPE_BRAND]: true,
108
+ [chunk5GZMPJOP_cjs.EDGE_TYPE_BRAND]: true,
109
109
  kind: name,
110
110
  schema,
111
111
  description: options?.description,
@@ -125,7 +125,7 @@ function metaEdge(name, options = {}) {
125
125
  description: options.description
126
126
  };
127
127
  return Object.freeze({
128
- [chunk3HQLOKS5_cjs.META_EDGE_BRAND]: true,
128
+ [chunkX33WV2UF_cjs.META_EDGE_BRAND]: true,
129
129
  name,
130
130
  properties
131
131
  });
@@ -161,7 +161,7 @@ function createExternalRef(table) {
161
161
  // src/ontology/core-meta-edges.ts
162
162
  function createMetaEdge(name, properties) {
163
163
  return Object.freeze({
164
- [chunk3HQLOKS5_cjs.META_EDGE_BRAND]: true,
164
+ [chunkX33WV2UF_cjs.META_EDGE_BRAND]: true,
165
165
  name,
166
166
  properties: {
167
167
  transitive: properties.transitive ?? false,
@@ -173,7 +173,7 @@ function createMetaEdge(name, properties) {
173
173
  }
174
174
  });
175
175
  }
176
- var subClassOfMetaEdge = createMetaEdge(chunk3HQLOKS5_cjs.META_EDGE_SUB_CLASS_OF, {
176
+ var subClassOfMetaEdge = createMetaEdge(chunkX33WV2UF_cjs.META_EDGE_SUB_CLASS_OF, {
177
177
  transitive: true,
178
178
  inference: "subsumption",
179
179
  description: "Type inheritance (Podcast subClassOf Media)"
@@ -185,9 +185,9 @@ function subClassOf(child, parent) {
185
185
  to: parent
186
186
  };
187
187
  }
188
- var broaderMetaEdge = createMetaEdge(chunk3HQLOKS5_cjs.META_EDGE_BROADER, {
188
+ var broaderMetaEdge = createMetaEdge(chunkX33WV2UF_cjs.META_EDGE_BROADER, {
189
189
  transitive: true,
190
- inverse: chunk3HQLOKS5_cjs.META_EDGE_NARROWER,
190
+ inverse: chunkX33WV2UF_cjs.META_EDGE_NARROWER,
191
191
  inference: "hierarchy",
192
192
  description: "Broader concept (ML broader AI)"
193
193
  });
@@ -198,9 +198,9 @@ function broader(narrowerConcept, broaderConcept) {
198
198
  to: broaderConcept
199
199
  };
200
200
  }
201
- var narrowerMetaEdge = createMetaEdge(chunk3HQLOKS5_cjs.META_EDGE_NARROWER, {
201
+ var narrowerMetaEdge = createMetaEdge(chunkX33WV2UF_cjs.META_EDGE_NARROWER, {
202
202
  transitive: true,
203
- inverse: chunk3HQLOKS5_cjs.META_EDGE_BROADER,
203
+ inverse: chunkX33WV2UF_cjs.META_EDGE_BROADER,
204
204
  inference: "hierarchy",
205
205
  description: "Narrower concept (AI narrower ML)"
206
206
  });
@@ -211,7 +211,7 @@ function narrower(broaderConcept, narrowerConcept) {
211
211
  to: narrowerConcept
212
212
  };
213
213
  }
214
- var relatedToMetaEdge = createMetaEdge(chunk3HQLOKS5_cjs.META_EDGE_RELATED_TO, {
214
+ var relatedToMetaEdge = createMetaEdge(chunkX33WV2UF_cjs.META_EDGE_RELATED_TO, {
215
215
  symmetric: true,
216
216
  inference: "association",
217
217
  description: "Non-hierarchical association"
@@ -223,7 +223,7 @@ function relatedTo(conceptA, conceptB) {
223
223
  to: conceptB
224
224
  };
225
225
  }
226
- var equivalentToMetaEdge = createMetaEdge(chunk3HQLOKS5_cjs.META_EDGE_EQUIVALENT_TO, {
226
+ var equivalentToMetaEdge = createMetaEdge(chunkX33WV2UF_cjs.META_EDGE_EQUIVALENT_TO, {
227
227
  symmetric: true,
228
228
  transitive: true,
229
229
  inference: "substitution",
@@ -236,7 +236,7 @@ function equivalentTo(kindA, kindBOrIri) {
236
236
  to: kindBOrIri
237
237
  };
238
238
  }
239
- var sameAsMetaEdge = createMetaEdge(chunk3HQLOKS5_cjs.META_EDGE_SAME_AS, {
239
+ var sameAsMetaEdge = createMetaEdge(chunkX33WV2UF_cjs.META_EDGE_SAME_AS, {
240
240
  symmetric: true,
241
241
  transitive: true,
242
242
  inference: "substitution",
@@ -249,7 +249,7 @@ function sameAs(kindA, kindBOrIri) {
249
249
  to: kindBOrIri
250
250
  };
251
251
  }
252
- var differentFromMetaEdge = createMetaEdge(chunk3HQLOKS5_cjs.META_EDGE_DIFFERENT_FROM, {
252
+ var differentFromMetaEdge = createMetaEdge(chunkX33WV2UF_cjs.META_EDGE_DIFFERENT_FROM, {
253
253
  symmetric: true,
254
254
  inference: "constraint",
255
255
  description: "Explicitly different individuals"
@@ -261,7 +261,7 @@ function differentFrom(kindA, kindB) {
261
261
  to: kindB
262
262
  };
263
263
  }
264
- var disjointWithMetaEdge = createMetaEdge(chunk3HQLOKS5_cjs.META_EDGE_DISJOINT_WITH, {
264
+ var disjointWithMetaEdge = createMetaEdge(chunkX33WV2UF_cjs.META_EDGE_DISJOINT_WITH, {
265
265
  symmetric: true,
266
266
  inference: "constraint",
267
267
  description: "Mutually exclusive types"
@@ -273,9 +273,9 @@ function disjointWith(kindA, kindB) {
273
273
  to: kindB
274
274
  };
275
275
  }
276
- var partOfMetaEdge = createMetaEdge(chunk3HQLOKS5_cjs.META_EDGE_PART_OF, {
276
+ var partOfMetaEdge = createMetaEdge(chunkX33WV2UF_cjs.META_EDGE_PART_OF, {
277
277
  transitive: true,
278
- inverse: chunk3HQLOKS5_cjs.META_EDGE_HAS_PART,
278
+ inverse: chunkX33WV2UF_cjs.META_EDGE_HAS_PART,
279
279
  inference: "composition",
280
280
  description: "X is part of Y"
281
281
  });
@@ -286,9 +286,9 @@ function partOf(part, whole) {
286
286
  to: whole
287
287
  };
288
288
  }
289
- var hasPartMetaEdge = createMetaEdge(chunk3HQLOKS5_cjs.META_EDGE_HAS_PART, {
289
+ var hasPartMetaEdge = createMetaEdge(chunkX33WV2UF_cjs.META_EDGE_HAS_PART, {
290
290
  transitive: true,
291
- inverse: chunk3HQLOKS5_cjs.META_EDGE_PART_OF,
291
+ inverse: chunkX33WV2UF_cjs.META_EDGE_PART_OF,
292
292
  inference: "composition",
293
293
  description: "Y has part X"
294
294
  });
@@ -299,12 +299,12 @@ function hasPart(whole, part) {
299
299
  to: part
300
300
  };
301
301
  }
302
- var inverseOfMetaEdge = createMetaEdge(chunk3HQLOKS5_cjs.META_EDGE_INVERSE_OF, {
302
+ var inverseOfMetaEdge = createMetaEdge(chunkX33WV2UF_cjs.META_EDGE_INVERSE_OF, {
303
303
  symmetric: true,
304
304
  inference: "none",
305
305
  description: "Edge A is inverse of edge B"
306
306
  });
307
- var impliesMetaEdge = createMetaEdge(chunk3HQLOKS5_cjs.META_EDGE_IMPLIES, {
307
+ var impliesMetaEdge = createMetaEdge(chunkX33WV2UF_cjs.META_EDGE_IMPLIES, {
308
308
  transitive: true,
309
309
  inference: "none",
310
310
  description: "Edge A implies edge B exists"
@@ -817,7 +817,7 @@ function notInSubquery(field2, subquery) {
817
817
  function assertSingleColumnSubquery(subquery) {
818
818
  const columnCount = getSubqueryColumnCount(subquery);
819
819
  if (columnCount === 1) return;
820
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
820
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
821
821
  `IN/NOT IN subquery must project exactly 1 column, but got ${columnCount}`,
822
822
  { subqueryColumnCount: columnCount },
823
823
  {
@@ -830,7 +830,7 @@ function assertCompatibleSubqueryValueTypes(field2, subquery) {
830
830
  const subqueryValueType = getSingleSubqueryColumnValueType(subquery);
831
831
  const resolvedValueType = fieldValueType ?? subqueryValueType;
832
832
  if (isUnsupportedInSubqueryValueType(resolvedValueType)) {
833
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
833
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
834
834
  `IN/NOT IN subquery does not support ${String(resolvedValueType)} values`,
835
835
  { valueType: resolvedValueType },
836
836
  {
@@ -841,7 +841,7 @@ function assertCompatibleSubqueryValueTypes(field2, subquery) {
841
841
  if (isInSubqueryTypeCompatible(fieldValueType, subqueryValueType)) {
842
842
  return;
843
843
  }
844
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
844
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
845
845
  `IN/NOT IN type mismatch: field type "${String(fieldValueType)}" does not match subquery column type "${String(subqueryValueType)}"`,
846
846
  {
847
847
  fieldValueType,
@@ -967,7 +967,7 @@ function resolveLiteralValueTypes(literals) {
967
967
  }
968
968
  }
969
969
  if (resolved.size > 1) {
970
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
970
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
971
971
  "Mixed literal value types are not supported in predicates",
972
972
  { valueTypes: [...resolved] }
973
973
  );
@@ -1093,7 +1093,7 @@ function compilePredicateExpression(expr, ctx) {
1093
1093
  if (!upperIsParam) boundsForType.push(expr.upper);
1094
1094
  const valueType = boundsForType.length > 0 ? resolveComparisonValueType(expr.field, boundsForType) : normalizeValueType2(expr.field.valueType);
1095
1095
  if (valueType === "array" || valueType === "object") {
1096
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1096
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
1097
1097
  "Between comparisons are not supported for JSON arrays or objects"
1098
1098
  );
1099
1099
  }
@@ -1158,7 +1158,7 @@ function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
1158
1158
  );
1159
1159
  const opSql2 = COMPARISON_OP_SQL[expr.op];
1160
1160
  if (!opSql2) {
1161
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1161
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
1162
1162
  `Comparison operation "${expr.op}" is not supported for parameterized predicates`
1163
1163
  );
1164
1164
  }
@@ -1166,7 +1166,7 @@ function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
1166
1166
  }
1167
1167
  const valueType = resolveComparisonValueType(expr.left, expr.right);
1168
1168
  if (valueType === "array" || valueType === "object") {
1169
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1169
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
1170
1170
  `Comparison operation "${expr.op}" is not supported for ${valueType} values`
1171
1171
  );
1172
1172
  }
@@ -1194,7 +1194,7 @@ function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
1194
1194
  const convertedRight = convertValueForSql(rightValue.value, dialect);
1195
1195
  const opSql = COMPARISON_OP_SQL[expr.op];
1196
1196
  if (!opSql) {
1197
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1197
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
1198
1198
  `Comparison operation "${expr.op}" is not supported`
1199
1199
  );
1200
1200
  }
@@ -1257,13 +1257,13 @@ function compileObjectPredicate(expr, dialect, cteColumnPrefix) {
1257
1257
  }
1258
1258
  case "pathEquals": {
1259
1259
  if (!expr.value) {
1260
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1260
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
1261
1261
  "pathEquals requires a comparison value"
1262
1262
  );
1263
1263
  }
1264
1264
  const valueType = resolvePredicateValueType(expr.valueType, expr.value);
1265
1265
  if (valueType === "array" || valueType === "object") {
1266
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1266
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
1267
1267
  "pathEquals is not supported for JSON arrays or objects"
1268
1268
  );
1269
1269
  }
@@ -1279,7 +1279,7 @@ function compileObjectPredicate(expr, dialect, cteColumnPrefix) {
1279
1279
  }
1280
1280
  case "pathContains": {
1281
1281
  if (!expr.value) {
1282
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1282
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
1283
1283
  "pathContains requires a comparison value"
1284
1284
  );
1285
1285
  }
@@ -1307,7 +1307,7 @@ function compileAggregatePredicate(expr, dialect) {
1307
1307
  const aggregate = compileAggregateExpr(expr.aggregate, dialect);
1308
1308
  const op = COMPARISON_OP_SQL[expr.op];
1309
1309
  if (!op) {
1310
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1310
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
1311
1311
  `Comparison operation "${expr.op}" is not supported for aggregate predicates`
1312
1312
  );
1313
1313
  }
@@ -1342,7 +1342,7 @@ function compileAggregateExpr(expr, dialect) {
1342
1342
  return drizzleOrm.sql`MAX(${field2})`;
1343
1343
  }
1344
1344
  default: {
1345
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1345
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
1346
1346
  `Unknown aggregate function: ${expr.function}`
1347
1347
  );
1348
1348
  }
@@ -1350,7 +1350,7 @@ function compileAggregateExpr(expr, dialect) {
1350
1350
  }
1351
1351
  function compileExistsSubquery(expr, ctx) {
1352
1352
  if (expr.subquery.graphId === void 0) {
1353
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError("EXISTS subquery must have a graphId");
1353
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError("EXISTS subquery must have a graphId");
1354
1354
  }
1355
1355
  const subSql = ctx.compileQuery(expr.subquery, expr.subquery.graphId);
1356
1356
  return expr.negated ? drizzleOrm.sql`NOT EXISTS (${subSql})` : drizzleOrm.sql`EXISTS (${subSql})`;
@@ -1358,7 +1358,7 @@ function compileExistsSubquery(expr, ctx) {
1358
1358
  function compileInSubquery(expr, ctx) {
1359
1359
  const subqueryColumnCount = getSubqueryColumnCount(expr.subquery);
1360
1360
  if (subqueryColumnCount !== 1) {
1361
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1361
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
1362
1362
  `IN/NOT IN subquery must project exactly 1 column, but got ${subqueryColumnCount}`,
1363
1363
  { subqueryColumnCount }
1364
1364
  );
@@ -1367,13 +1367,13 @@ function compileInSubquery(expr, ctx) {
1367
1367
  const subqueryValueType = getSingleSubqueryColumnValueType(expr.subquery);
1368
1368
  const resolvedValueType = fieldValueType ?? subqueryValueType;
1369
1369
  if (isUnsupportedInSubqueryValueType(resolvedValueType)) {
1370
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1370
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
1371
1371
  `IN/NOT IN subquery does not support ${String(resolvedValueType)} values`,
1372
1372
  { valueType: resolvedValueType }
1373
1373
  );
1374
1374
  }
1375
1375
  if (!isInSubqueryTypeCompatible(fieldValueType, subqueryValueType)) {
1376
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1376
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
1377
1377
  `IN/NOT IN type mismatch: field type "${String(fieldValueType)}" does not match subquery column type "${String(subqueryValueType)}"`,
1378
1378
  {
1379
1379
  fieldValueType,
@@ -1383,7 +1383,7 @@ function compileInSubquery(expr, ctx) {
1383
1383
  }
1384
1384
  const valueType = fieldValueType ?? subqueryValueType;
1385
1385
  if (expr.subquery.graphId === void 0) {
1386
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1386
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
1387
1387
  "IN/NOT IN subquery must have a graphId"
1388
1388
  );
1389
1389
  }
@@ -1407,7 +1407,7 @@ function extractVectorSimilarityPredicates(predicates) {
1407
1407
  switch (expr.__type) {
1408
1408
  case "vector_similarity": {
1409
1409
  if (inDisallowedBranch) {
1410
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
1410
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
1411
1411
  "Vector similarity predicates cannot be nested under OR or NOT. Use top-level AND combinations instead."
1412
1412
  );
1413
1413
  }
@@ -1493,7 +1493,7 @@ function getNodeKindsForAlias(ast, alias) {
1493
1493
  return traversal.nodeKinds;
1494
1494
  }
1495
1495
  }
1496
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(`Unknown traversal source alias: ${alias}`);
1496
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(`Unknown traversal source alias: ${alias}`);
1497
1497
  }
1498
1498
 
1499
1499
  // src/query/compiler/emitter/plan-inspector.ts
@@ -1548,7 +1548,7 @@ function findUnaryNodeInProjectChain(rootNode, op) {
1548
1548
  }
1549
1549
  function inspectProjectPlan(logicalPlan) {
1550
1550
  if (logicalPlan.root.op !== "project") {
1551
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1551
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1552
1552
  `SQL emitter expected logical plan root to be "project", got "${logicalPlan.root.op}"`,
1553
1553
  { component: "plan-inspector" }
1554
1554
  );
@@ -1578,13 +1578,13 @@ function inspectProjectPlan(logicalPlan) {
1578
1578
  function inspectStandardProjectPlan(logicalPlan) {
1579
1579
  const shape = inspectProjectPlan(logicalPlan);
1580
1580
  if (shape.hasSetOperation) {
1581
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1581
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1582
1582
  'Standard SQL emitter does not support plans containing "set_op" nodes',
1583
1583
  { component: "plan-inspector" }
1584
1584
  );
1585
1585
  }
1586
1586
  if (shape.hasRecursiveExpand) {
1587
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1587
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1588
1588
  'Standard SQL emitter does not support plans containing "recursive_expand" nodes',
1589
1589
  { component: "plan-inspector" }
1590
1590
  );
@@ -1594,13 +1594,13 @@ function inspectStandardProjectPlan(logicalPlan) {
1594
1594
  function inspectRecursiveProjectPlan(logicalPlan) {
1595
1595
  const shape = inspectProjectPlan(logicalPlan);
1596
1596
  if (!shape.hasRecursiveExpand) {
1597
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1597
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1598
1598
  'Recursive SQL emitter expected logical plan to contain a "recursive_expand" node',
1599
1599
  { component: "plan-inspector" }
1600
1600
  );
1601
1601
  }
1602
1602
  if (shape.hasSetOperation) {
1603
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1603
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1604
1604
  'Recursive SQL emitter does not support plans containing "set_op" nodes',
1605
1605
  { component: "plan-inspector" }
1606
1606
  );
@@ -1659,7 +1659,7 @@ function inspectSetOperationPlan(logicalPlan) {
1659
1659
  const operations = /* @__PURE__ */ new Set();
1660
1660
  collectPlanOperations(logicalPlan.root, operations);
1661
1661
  if (!operations.has("set_op")) {
1662
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1662
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1663
1663
  'Set-operation SQL emitter expected logical plan to contain a "set_op" node',
1664
1664
  { component: "plan-inspector" }
1665
1665
  );
@@ -1677,25 +1677,25 @@ function inspectSetOperationPlan(logicalPlan) {
1677
1677
  function assertRecursiveEmitterClauseAlignment(logicalPlan, input) {
1678
1678
  const planShape = inspectRecursiveProjectPlan(logicalPlan);
1679
1679
  if (planShape.hasSort && input.orderBy === void 0) {
1680
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1680
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1681
1681
  "Recursive SQL emitter expected ORDER BY clause for plan containing a sort node",
1682
1682
  { component: "recursive-emitter" }
1683
1683
  );
1684
1684
  }
1685
1685
  if (!planShape.hasSort && input.orderBy !== void 0) {
1686
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1686
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1687
1687
  "Recursive SQL emitter received ORDER BY clause for a plan without sort nodes",
1688
1688
  { component: "recursive-emitter" }
1689
1689
  );
1690
1690
  }
1691
1691
  if (planShape.hasLimitOffset && input.limitOffset === void 0) {
1692
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1692
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1693
1693
  "Recursive SQL emitter expected LIMIT/OFFSET clause for plan containing a limit_offset node",
1694
1694
  { component: "recursive-emitter" }
1695
1695
  );
1696
1696
  }
1697
1697
  if (!planShape.hasLimitOffset && input.limitOffset !== void 0) {
1698
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1698
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1699
1699
  "Recursive SQL emitter received LIMIT/OFFSET clause for a plan without limit_offset nodes",
1700
1700
  { component: "recursive-emitter" }
1701
1701
  );
@@ -1722,14 +1722,14 @@ function assertSetOperationEmitterClauseAlignment(logicalPlan, suffixClauses) {
1722
1722
  const shape = inspectSetOperationPlan(logicalPlan);
1723
1723
  const hasSuffixClauses = suffixClauses !== void 0 && suffixClauses.length > 0;
1724
1724
  if (!shape.hasSort && !shape.hasLimitOffset && hasSuffixClauses) {
1725
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1725
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1726
1726
  "Set-operation SQL emitter received suffix clauses for a plan without top-level sort or limit_offset nodes",
1727
1727
  { component: "set-operation-emitter" }
1728
1728
  );
1729
1729
  }
1730
1730
  if (!hasSuffixClauses) {
1731
1731
  if (shape.hasSort || shape.hasLimitOffset) {
1732
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1732
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1733
1733
  "Set-operation SQL emitter expected suffix clauses for plan containing top-level sort or limit_offset nodes",
1734
1734
  { component: "set-operation-emitter" }
1735
1735
  );
@@ -1739,7 +1739,7 @@ function assertSetOperationEmitterClauseAlignment(logicalPlan, suffixClauses) {
1739
1739
  const limitOffsetClauseCount = shape.limitOffsetNode === void 0 ? 0 : (shape.limitOffsetNode.limit === void 0 ? 0 : 1) + (shape.limitOffsetNode.offset === void 0 ? 0 : 1);
1740
1740
  const expectedClauseCount = (shape.sortNode === void 0 ? 0 : 1) + limitOffsetClauseCount;
1741
1741
  if (suffixClauses.length !== expectedClauseCount) {
1742
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1742
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1743
1743
  `Set-operation SQL emitter expected ${String(expectedClauseCount)} top-level suffix clause(s) from logical plan, got ${String(suffixClauses.length)}`,
1744
1744
  { component: "set-operation-emitter" }
1745
1745
  );
@@ -1763,38 +1763,38 @@ function emitSetOperationQuerySql(input) {
1763
1763
  function assertStandardEmitterClauseAlignment(logicalPlan, input) {
1764
1764
  const planShape = inspectStandardProjectPlan(logicalPlan);
1765
1765
  if (input.groupBy !== void 0 && !planShape.hasAggregate) {
1766
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1766
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1767
1767
  "Standard SQL emitter received GROUP BY clause for a plan without aggregate nodes",
1768
1768
  { component: "standard-emitter" }
1769
1769
  );
1770
1770
  }
1771
1771
  if (input.having !== void 0 && !planShape.hasAggregate) {
1772
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1772
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1773
1773
  "Standard SQL emitter received HAVING clause for a plan without aggregate nodes",
1774
1774
  { component: "standard-emitter" }
1775
1775
  );
1776
1776
  }
1777
1777
  const expectsOrderBy = planShape.hasSort || planShape.hasVectorKnn;
1778
1778
  if (expectsOrderBy && input.orderBy === void 0) {
1779
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1779
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1780
1780
  "Standard SQL emitter expected ORDER BY clause for plan containing a sort or vector_knn node",
1781
1781
  { component: "standard-emitter" }
1782
1782
  );
1783
1783
  }
1784
1784
  if (!expectsOrderBy && input.orderBy !== void 0) {
1785
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1785
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1786
1786
  "Standard SQL emitter received ORDER BY clause for a plan without sort or vector_knn nodes",
1787
1787
  { component: "standard-emitter" }
1788
1788
  );
1789
1789
  }
1790
1790
  if (planShape.hasLimitOffset && input.limitOffset === void 0) {
1791
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1791
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1792
1792
  "Standard SQL emitter expected LIMIT/OFFSET clause for plan containing a limit_offset node",
1793
1793
  { component: "standard-emitter" }
1794
1794
  );
1795
1795
  }
1796
1796
  if (!planShape.hasLimitOffset && input.limitOffset !== void 0) {
1797
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
1797
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
1798
1798
  "Standard SQL emitter received LIMIT/OFFSET clause for a plan without limit_offset nodes",
1799
1799
  { component: "standard-emitter" }
1800
1800
  );
@@ -2147,7 +2147,7 @@ function compileAggregateExprFromSource(expr, dialect) {
2147
2147
  return drizzleOrm.sql`${drizzleOrm.sql.raw(fn.toUpperCase())}(${column})`;
2148
2148
  }
2149
2149
  default: {
2150
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
2150
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
2151
2151
  `Unknown aggregate function: ${String(fn)}`
2152
2152
  );
2153
2153
  }
@@ -2185,14 +2185,18 @@ function buildStandardProjection(input) {
2185
2185
  });
2186
2186
  return drizzleOrm.sql.join(projectedFields, drizzleOrm.sql`, `);
2187
2187
  }
2188
- function compileSelectiveProjection(fields, dialect, ast, collapsedTraversalCteAlias) {
2189
- const aliasToCte = /* @__PURE__ */ new Map([
2188
+ function buildAliasToCteMap(ast) {
2189
+ const map = /* @__PURE__ */ new Map([
2190
2190
  [ast.start.alias, `cte_${ast.start.alias}`]
2191
2191
  ]);
2192
2192
  for (const traversal of ast.traversals) {
2193
- aliasToCte.set(traversal.nodeAlias, `cte_${traversal.nodeAlias}`);
2194
- aliasToCte.set(traversal.edgeAlias, `cte_${traversal.nodeAlias}`);
2193
+ map.set(traversal.nodeAlias, `cte_${traversal.nodeAlias}`);
2194
+ map.set(traversal.edgeAlias, `cte_${traversal.nodeAlias}`);
2195
2195
  }
2196
+ return map;
2197
+ }
2198
+ function compileSelectiveProjection(fields, dialect, ast, collapsedTraversalCteAlias) {
2199
+ const aliasToCte = buildAliasToCteMap(ast);
2196
2200
  const columns = fields.map((field2) => {
2197
2201
  const cteAlias = collapsedTraversalCteAlias ?? aliasToCte.get(field2.alias) ?? `cte_${field2.alias}`;
2198
2202
  if (field2.isSystemField) {
@@ -2241,15 +2245,16 @@ function buildStandardOrderBy(input) {
2241
2245
  if (!ast.orderBy || ast.orderBy.length === 0) {
2242
2246
  return void 0;
2243
2247
  }
2248
+ const aliasToCte = buildAliasToCteMap(ast);
2244
2249
  const parts = [];
2245
2250
  for (const orderSpec of ast.orderBy) {
2246
2251
  const valueType = orderSpec.field.valueType;
2247
2252
  if (valueType === "array" || valueType === "object") {
2248
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
2253
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
2249
2254
  "Ordering by JSON arrays or objects is not supported"
2250
2255
  );
2251
2256
  }
2252
- const cteAlias = collapsedTraversalCteAlias ?? `cte_${orderSpec.field.alias}`;
2257
+ const cteAlias = collapsedTraversalCteAlias ?? aliasToCte.get(orderSpec.field.alias) ?? `cte_${orderSpec.field.alias}`;
2253
2258
  const field2 = compileFieldValue(
2254
2259
  orderSpec.field,
2255
2260
  dialect,
@@ -2296,8 +2301,14 @@ function buildStandardGroupBy(input) {
2296
2301
  if (allFields.length === 0) {
2297
2302
  return void 0;
2298
2303
  }
2304
+ const aliasToCte = buildAliasToCteMap(ast);
2299
2305
  const parts = allFields.map(
2300
- (field2) => compileFieldValue(field2, dialect, field2.valueType, `cte_${field2.alias}`)
2306
+ (field2) => compileFieldValue(
2307
+ field2,
2308
+ dialect,
2309
+ field2.valueType,
2310
+ aliasToCte.get(field2.alias) ?? `cte_${field2.alias}`
2311
+ )
2301
2312
  );
2302
2313
  return drizzleOrm.sql`GROUP BY ${drizzleOrm.sql.join(parts, drizzleOrm.sql`, `)}`;
2303
2314
  }
@@ -2372,14 +2383,15 @@ function buildStandardVectorOrderBy(input) {
2372
2383
  const distanceOrder = drizzleOrm.sql`cte_embeddings.distance ASC`;
2373
2384
  const additionalOrders = [];
2374
2385
  if (ast.orderBy && ast.orderBy.length > 0) {
2386
+ const aliasToCte = buildAliasToCteMap(ast);
2375
2387
  for (const orderSpec of ast.orderBy) {
2376
2388
  const valueType = orderSpec.field.valueType;
2377
2389
  if (valueType === "array" || valueType === "object") {
2378
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
2390
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
2379
2391
  "Ordering by JSON arrays or objects is not supported"
2380
2392
  );
2381
2393
  }
2382
- const cteAlias = `cte_${orderSpec.field.alias}`;
2394
+ const cteAlias = aliasToCte.get(orderSpec.field.alias) ?? `cte_${orderSpec.field.alias}`;
2383
2395
  const field2 = compileFieldValue(
2384
2396
  orderSpec.field,
2385
2397
  dialect,
@@ -2416,10 +2428,10 @@ function runRecursiveTraversalSelectionPass(ast) {
2416
2428
  (traversal) => traversal.variableLength !== void 0
2417
2429
  );
2418
2430
  if (variableLengthTraversal === void 0) {
2419
- throw new chunk44SXEVF4_cjs.CompilerInvariantError("No variable-length traversal found");
2431
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError("No variable-length traversal found");
2420
2432
  }
2421
2433
  if (ast.traversals.length > 1) {
2422
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
2434
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
2423
2435
  "Variable-length traversals with multiple traversals are not yet supported. Please use a single variable-length traversal."
2424
2436
  );
2425
2437
  }
@@ -2483,7 +2495,7 @@ function createTemporalFilterPass(ast, currentTimestamp) {
2483
2495
  function runVectorPredicatePass(ast, dialect) {
2484
2496
  const vectorPredicates = extractVectorSimilarityPredicates(ast.predicates);
2485
2497
  if (vectorPredicates.length > 1) {
2486
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
2498
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
2487
2499
  "Multiple vector similarity predicates in a single query are not supported"
2488
2500
  );
2489
2501
  }
@@ -2493,29 +2505,29 @@ function runVectorPredicatePass(ast, dialect) {
2493
2505
  }
2494
2506
  const vectorStrategy = dialect.capabilities.vectorPredicateStrategy;
2495
2507
  if (vectorStrategy === "unsupported" || !dialect.supportsVectors) {
2496
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
2508
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
2497
2509
  `Vector similarity predicates are not supported for dialect "${dialect.name}"`
2498
2510
  );
2499
2511
  }
2500
2512
  if (!dialect.capabilities.vectorMetrics.includes(vectorPredicate.metric)) {
2501
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
2513
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
2502
2514
  `Vector metric "${vectorPredicate.metric}" is not supported for dialect "${dialect.name}"`
2503
2515
  );
2504
2516
  }
2505
2517
  if (!Number.isFinite(vectorPredicate.limit) || vectorPredicate.limit <= 0) {
2506
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
2518
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
2507
2519
  `Vector predicate limit must be a positive finite number, got ${String(vectorPredicate.limit)}`
2508
2520
  );
2509
2521
  }
2510
2522
  const { minScore } = vectorPredicate;
2511
2523
  if (minScore !== void 0) {
2512
2524
  if (!Number.isFinite(minScore)) {
2513
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
2525
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
2514
2526
  `Vector minScore must be a finite number, got ${String(minScore)}`
2515
2527
  );
2516
2528
  }
2517
2529
  if (vectorPredicate.metric === "cosine" && (minScore < -1 || minScore > 1)) {
2518
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
2530
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
2519
2531
  `Cosine minScore must be between -1 and 1, got ${String(minScore)}`
2520
2532
  );
2521
2533
  }
@@ -2609,7 +2621,7 @@ function appendAggregateSortLimitAndProjectNodes(currentNode, ast, nextPlanNodeI
2609
2621
  } else if (hasOffset) {
2610
2622
  node = { ...limitOffsetNodeBase, offset: ast.offset };
2611
2623
  } else {
2612
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2624
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
2613
2625
  "limit_offset node requires limit or offset to be present"
2614
2626
  );
2615
2627
  }
@@ -2902,7 +2914,7 @@ function runRecursiveQueryPassPipeline(ast, graphId, ctx) {
2902
2914
  execute(currentState) {
2903
2915
  const traversal = currentState.traversal;
2904
2916
  if (traversal === void 0) {
2905
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2917
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
2906
2918
  "Recursive traversal pass did not select traversal"
2907
2919
  );
2908
2920
  }
@@ -2955,17 +2967,17 @@ function compileVariableLengthQueryWithRecursiveCteStrategy(ast, graphId, ctx) {
2955
2967
  traversal: vlTraversal
2956
2968
  } = passState;
2957
2969
  if (temporalFilterPass === void 0) {
2958
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2970
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
2959
2971
  "Temporal filter pass did not initialize temporal state"
2960
2972
  );
2961
2973
  }
2962
2974
  if (logicalPlan === void 0) {
2963
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2975
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
2964
2976
  "Logical plan pass did not initialize plan state"
2965
2977
  );
2966
2978
  }
2967
2979
  if (vlTraversal === void 0) {
2968
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
2980
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
2969
2981
  "Recursive traversal pass did not select traversal"
2970
2982
  );
2971
2983
  }
@@ -3057,7 +3069,7 @@ function compileRecursiveCte(ast, traversal, graphId, ctx, requiredColumnsByAlia
3057
3069
  targetContext
3058
3070
  );
3059
3071
  if (vl.maxDepth > MAX_EXPLICIT_RECURSIVE_DEPTH) {
3060
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
3072
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
3061
3073
  `Recursive traversal maxHops(${vl.maxDepth}) exceeds maximum explicit depth of ${MAX_EXPLICIT_RECURSIVE_DEPTH}`
3062
3074
  );
3063
3075
  }
@@ -3284,7 +3296,7 @@ function compileRecursiveSelectiveProjection(fields, ast, traversal, dialect) {
3284
3296
  const allowedAliases = /* @__PURE__ */ new Set([ast.start.alias, traversal.nodeAlias]);
3285
3297
  const columns = fields.map((field2) => {
3286
3298
  if (!allowedAliases.has(field2.alias)) {
3287
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
3299
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
3288
3300
  `Selective projection for recursive traversals does not support alias "${field2.alias}"`
3289
3301
  );
3290
3302
  }
@@ -3318,7 +3330,7 @@ function compileRecursiveOrderBy(ast, dialect) {
3318
3330
  for (const orderSpec of ast.orderBy) {
3319
3331
  const valueType = orderSpec.field.valueType;
3320
3332
  if (valueType === "array" || valueType === "object") {
3321
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
3333
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
3322
3334
  "Ordering by JSON arrays or objects is not supported"
3323
3335
  );
3324
3336
  }
@@ -3351,15 +3363,15 @@ var DEFAULT_TABLE_NAMES = {
3351
3363
  var VALID_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/i;
3352
3364
  function validateTableName(name, label) {
3353
3365
  if (!name || name.length === 0) {
3354
- throw new chunk44SXEVF4_cjs.ConfigurationError(`${label} table name cannot be empty`);
3366
+ throw new chunkO5PST6TB_cjs.ConfigurationError(`${label} table name cannot be empty`);
3355
3367
  }
3356
3368
  if (name.length > chunkMME3H4ZF_cjs.MAX_PG_IDENTIFIER_LENGTH) {
3357
- throw new chunk44SXEVF4_cjs.ConfigurationError(
3369
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
3358
3370
  `${label} table name exceeds maximum length of ${chunkMME3H4ZF_cjs.MAX_PG_IDENTIFIER_LENGTH} characters`
3359
3371
  );
3360
3372
  }
3361
3373
  if (!VALID_IDENTIFIER_PATTERN.test(name)) {
3362
- throw new chunk44SXEVF4_cjs.ConfigurationError(
3374
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
3363
3375
  `${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.`
3364
3376
  );
3365
3377
  }
@@ -3849,6 +3861,16 @@ function mapSubgraphEdgeRow(row, projectionPlan) {
3849
3861
  applyProjectedFields(projectedEdge, row, kindPlan);
3850
3862
  return projectedEdge;
3851
3863
  }
3864
+
3865
+ // src/query/ast.ts
3866
+ function mergeEdgeKinds(traversal) {
3867
+ const inverse = traversal.inverseEdgeKinds;
3868
+ if (inverse === void 0 || inverse.length === 0) return traversal.edgeKinds;
3869
+ return [
3870
+ ...traversal.edgeKinds,
3871
+ ...inverse.filter((kind) => !traversal.edgeKinds.includes(kind))
3872
+ ];
3873
+ }
3852
3874
  var OPERATOR_MAP = {
3853
3875
  union: "UNION",
3854
3876
  unionAll: "UNION ALL",
@@ -3907,7 +3929,7 @@ function compileSetOperation(op, graphId, dialect, schema, compileQuery2) {
3907
3929
  const passState = runSetOperationPassPipeline(op, graphId, dialect);
3908
3930
  const { logicalPlan } = passState;
3909
3931
  if (logicalPlan === void 0) {
3910
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
3932
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
3911
3933
  "Logical plan pass did not initialize plan state"
3912
3934
  );
3913
3935
  }
@@ -3971,7 +3993,7 @@ function compileSetOperationForSqlite(op, graphId, dialect, logicalPlan, schema)
3971
3993
  dialect,
3972
3994
  schema,
3973
3995
  compileQuery: () => {
3974
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
3996
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
3975
3997
  "compileQuery is not available in set-operation CTE compilation"
3976
3998
  );
3977
3999
  }
@@ -4023,7 +4045,7 @@ function validateSqliteSetOpLeaf(ast) {
4023
4045
  unsupported.push("per-query OFFSET (use set operation's offset instead)");
4024
4046
  }
4025
4047
  if (unsupported.length > 0) {
4026
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
4048
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
4027
4049
  `SQLite set operations (UNION/INTERSECT/EXCEPT) do not support: ${unsupported.join(", ")}. Use PostgreSQL for complex set operations, or refactor to separate queries.`
4028
4050
  );
4029
4051
  }
@@ -4179,7 +4201,7 @@ function compileFieldValueForSetOp(source, prefix, alias, dialect) {
4179
4201
  return drizzleOrm.sql`${drizzleOrm.sql.raw(fn.toUpperCase())}(${column})`;
4180
4202
  }
4181
4203
  default: {
4182
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
4204
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
4183
4205
  `Unknown aggregate function: ${String(fn)}`
4184
4206
  );
4185
4207
  }
@@ -4233,7 +4255,7 @@ function buildCompoundSelectRecursive(query, leaves, prefixToSelect) {
4233
4255
  if (!("__type" in query)) {
4234
4256
  const leaf = leaves.find((l) => l.ast === query);
4235
4257
  if (!leaf) {
4236
- throw new chunk44SXEVF4_cjs.CompilerInvariantError("Leaf query not found in leaves array");
4258
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError("Leaf query not found in leaves array");
4237
4259
  }
4238
4260
  return prefixToSelect.get(leaf.prefix);
4239
4261
  }
@@ -4277,7 +4299,7 @@ function buildSetOperationSuffixClauses(op, dialect) {
4277
4299
  if (op.orderBy && op.orderBy.length > 0) {
4278
4300
  const projection = getLeftmostProjection(op);
4279
4301
  if (projection.fields.length === 0) {
4280
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
4302
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
4281
4303
  "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."
4282
4304
  );
4283
4305
  }
@@ -4287,7 +4309,7 @@ function buildSetOperationSuffixClauses(op, dialect) {
4287
4309
  if (!projected) {
4288
4310
  const fieldDesc = orderSpec.field.jsonPointer ? `${orderSpec.field.alias}.props${orderSpec.field.jsonPointer}` : `${orderSpec.field.alias}.${orderSpec.field.path.join(".")}`;
4289
4311
  const availableFields = projection.fields.map((f) => f.outputName).join(", ");
4290
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
4312
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
4291
4313
  `Set operation ORDER BY field "${fieldDesc}" is not in the projection. ORDER BY for UNION/INTERSECT/EXCEPT must reference projected columns. Available columns: ${availableFields}`
4292
4314
  );
4293
4315
  }
@@ -4894,13 +4916,13 @@ function compileStandardQueryWithCteStrategy(ast, graphId, ctx) {
4894
4916
  vectorPredicate
4895
4917
  } = runStandardQueryPassPipeline(ast, graphId, ctx);
4896
4918
  if (temporalFilterPass === void 0) {
4897
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
4919
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
4898
4920
  "Temporal filter pass did not initialize temporal state",
4899
4921
  { phase: "standard-pass-pipeline" }
4900
4922
  );
4901
4923
  }
4902
4924
  if (logicalPlan === void 0) {
4903
- throw new chunk44SXEVF4_cjs.CompilerInvariantError(
4925
+ throw new chunkO5PST6TB_cjs.CompilerInvariantError(
4904
4926
  "Logical plan pass did not initialize plan state",
4905
4927
  { phase: "standard-pass-pipeline" }
4906
4928
  );
@@ -5001,7 +5023,7 @@ function decodeCursor(cursor) {
5001
5023
  const json = atob(base64);
5002
5024
  const raw = JSON.parse(json);
5003
5025
  if (typeof raw.v !== "number" || raw.v > CURSOR_VERSION) {
5004
- throw new chunk44SXEVF4_cjs.ValidationError(
5026
+ throw new chunkO5PST6TB_cjs.ValidationError(
5005
5027
  `Unsupported cursor version: ${String(raw.v)}. Maximum supported: ${CURSOR_VERSION}`,
5006
5028
  {
5007
5029
  issues: [
@@ -5017,7 +5039,7 @@ function decodeCursor(cursor) {
5017
5039
  );
5018
5040
  }
5019
5041
  if (raw.d !== "f" && raw.d !== "b") {
5020
- throw new chunk44SXEVF4_cjs.ValidationError(`Invalid cursor direction: ${String(raw.d)}`, {
5042
+ throw new chunkO5PST6TB_cjs.ValidationError(`Invalid cursor direction: ${String(raw.d)}`, {
5021
5043
  issues: [
5022
5044
  {
5023
5045
  path: "cursor",
@@ -5027,7 +5049,7 @@ function decodeCursor(cursor) {
5027
5049
  });
5028
5050
  }
5029
5051
  if (!Array.isArray(raw.vals) || !Array.isArray(raw.cols)) {
5030
- throw new chunk44SXEVF4_cjs.ValidationError("Invalid cursor structure", {
5052
+ throw new chunkO5PST6TB_cjs.ValidationError("Invalid cursor structure", {
5031
5053
  issues: [
5032
5054
  {
5033
5055
  path: "cursor",
@@ -5037,7 +5059,7 @@ function decodeCursor(cursor) {
5037
5059
  });
5038
5060
  }
5039
5061
  if (raw.vals.length !== raw.cols.length) {
5040
- throw new chunk44SXEVF4_cjs.ValidationError("Cursor column count mismatch", {
5062
+ throw new chunkO5PST6TB_cjs.ValidationError("Cursor column count mismatch", {
5041
5063
  issues: [
5042
5064
  {
5043
5065
  path: "cursor",
@@ -5053,10 +5075,10 @@ function decodeCursor(cursor) {
5053
5075
  cols: raw.cols
5054
5076
  };
5055
5077
  } catch (error) {
5056
- if (error instanceof chunk44SXEVF4_cjs.ValidationError) {
5078
+ if (error instanceof chunkO5PST6TB_cjs.ValidationError) {
5057
5079
  throw error;
5058
5080
  }
5059
- throw new chunk44SXEVF4_cjs.ValidationError(
5081
+ throw new chunkO5PST6TB_cjs.ValidationError(
5060
5082
  "Invalid cursor format",
5061
5083
  {
5062
5084
  issues: [{ path: "cursor", message: "Failed to decode cursor" }]
@@ -5120,7 +5142,7 @@ function buildCursorFromRow(row, orderSpecs, direction) {
5120
5142
  function validateCursorColumns(cursorData, orderSpecs) {
5121
5143
  const expectedCols = orderSpecs.map((spec) => buildColumnId(spec));
5122
5144
  if (cursorData.cols.length !== expectedCols.length) {
5123
- throw new chunk44SXEVF4_cjs.ValidationError(
5145
+ throw new chunkO5PST6TB_cjs.ValidationError(
5124
5146
  `Cursor has ${cursorData.cols.length} columns but query has ${expectedCols.length} ORDER BY columns`,
5125
5147
  {
5126
5148
  issues: [
@@ -5137,7 +5159,7 @@ function validateCursorColumns(cursorData, orderSpecs) {
5137
5159
  }
5138
5160
  for (const [index, expectedCol] of expectedCols.entries()) {
5139
5161
  if (cursorData.cols[index] !== expectedCol) {
5140
- throw new chunk44SXEVF4_cjs.ValidationError(
5162
+ throw new chunkO5PST6TB_cjs.ValidationError(
5141
5163
  `Cursor column mismatch at position ${index}: expected "${expectedCol}", got "${cursorData.cols[index]}"`,
5142
5164
  {
5143
5165
  issues: [
@@ -5431,16 +5453,6 @@ function getStreamBatchSize(options) {
5431
5453
  return options?.batchSize ?? chunkMME3H4ZF_cjs.DEFAULT_STREAM_BATCH_SIZE;
5432
5454
  }
5433
5455
 
5434
- // src/query/ast.ts
5435
- function mergeEdgeKinds(traversal) {
5436
- const inverse = traversal.inverseEdgeKinds;
5437
- if (inverse === void 0 || inverse.length === 0) return traversal.edgeKinds;
5438
- return [
5439
- ...traversal.edgeKinds,
5440
- ...inverse.filter((kind) => !traversal.edgeKinds.includes(kind))
5441
- ];
5442
- }
5443
-
5444
5456
  // src/query/execution/field-tracker.ts
5445
5457
  var OBJECT_PROTOTYPE_PROPERTIES = /* @__PURE__ */ new Set([
5446
5458
  "__proto__",
@@ -5951,7 +5963,7 @@ var SQL_RESERVED_KEYWORDS = /* @__PURE__ */ new Set([
5951
5963
  ]);
5952
5964
  function validateSqlIdentifier(alias) {
5953
5965
  if (!SQL_IDENTIFIER_PATTERN.test(alias)) {
5954
- throw new chunk44SXEVF4_cjs.ValidationError(
5966
+ throw new chunkO5PST6TB_cjs.ValidationError(
5955
5967
  `Invalid alias "${alias}": must start with a letter or underscore, contain only letters, digits, and underscores, and be at most 63 characters`,
5956
5968
  {
5957
5969
  issues: [
@@ -5967,7 +5979,7 @@ function validateSqlIdentifier(alias) {
5967
5979
  );
5968
5980
  }
5969
5981
  if (alias.toLowerCase().startsWith("cte_")) {
5970
- throw new chunk44SXEVF4_cjs.ValidationError(
5982
+ throw new chunkO5PST6TB_cjs.ValidationError(
5971
5983
  `Invalid alias "${alias}": aliases starting with "cte_" are reserved for internal use`,
5972
5984
  {
5973
5985
  issues: [
@@ -5983,7 +5995,7 @@ function validateSqlIdentifier(alias) {
5983
5995
  );
5984
5996
  }
5985
5997
  if (SQL_RESERVED_KEYWORDS.has(alias.toLowerCase())) {
5986
- throw new chunk44SXEVF4_cjs.ValidationError(
5998
+ throw new chunkO5PST6TB_cjs.ValidationError(
5987
5999
  `Invalid alias "${alias}": "${alias}" is a reserved SQL keyword`,
5988
6000
  {
5989
6001
  issues: [
@@ -5997,7 +6009,7 @@ function validateSqlIdentifier(alias) {
5997
6009
  }
5998
6010
  }
5999
6011
  function throwInvalidVectorPredicatePlacement(path) {
6000
- throw new chunk44SXEVF4_cjs.ValidationError(
6012
+ throw new chunkO5PST6TB_cjs.ValidationError(
6001
6013
  "Vector similarity predicates cannot be nested under OR or NOT. Use top-level AND combinations instead.",
6002
6014
  {
6003
6015
  issues: [
@@ -6108,7 +6120,7 @@ function buildQueryAst(config, state) {
6108
6120
  }
6109
6121
  function toLiteral(value) {
6110
6122
  if (value === null) {
6111
- throw new chunk44SXEVF4_cjs.ConfigurationError(
6123
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
6112
6124
  "Parameter value must not be null (use undefined-based patterns instead)",
6113
6125
  { parameterName: "value", valueType: "null" }
6114
6126
  );
@@ -6125,7 +6137,7 @@ function toLiteral(value) {
6125
6137
  if (typeof value === "boolean") {
6126
6138
  return { __type: "literal", value, valueType: "boolean" };
6127
6139
  }
6128
- throw new chunk44SXEVF4_cjs.ConfigurationError(
6140
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
6129
6141
  `Unsupported parameter value type: ${typeof value}`,
6130
6142
  { parameterName: "value", actualType: typeof value }
6131
6143
  );
@@ -6136,7 +6148,7 @@ function substitutePredicateExpression(expr, bindings) {
6136
6148
  if (isParameterRef(expr.right)) {
6137
6149
  const value = bindings[expr.right.name];
6138
6150
  if (value === void 0) {
6139
- throw new chunk44SXEVF4_cjs.ConfigurationError(
6151
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
6140
6152
  `Missing binding for parameter "${expr.right.name}"`,
6141
6153
  { parameterName: expr.right.name }
6142
6154
  );
@@ -6152,13 +6164,13 @@ function substitutePredicateExpression(expr, bindings) {
6152
6164
  if (isParameterRef(expr.pattern)) {
6153
6165
  const value = bindings[expr.pattern.name];
6154
6166
  if (value === void 0) {
6155
- throw new chunk44SXEVF4_cjs.ConfigurationError(
6167
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
6156
6168
  `Missing binding for parameter "${expr.pattern.name}"`,
6157
6169
  { parameterName: expr.pattern.name }
6158
6170
  );
6159
6171
  }
6160
6172
  if (typeof value !== "string") {
6161
- throw new chunk44SXEVF4_cjs.ConfigurationError(
6173
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
6162
6174
  `Parameter "${expr.pattern.name}" must be a string for string operations`,
6163
6175
  { parameterName: expr.pattern.name, actualType: typeof value }
6164
6176
  );
@@ -6225,7 +6237,7 @@ function substitutePredicateExpression(expr, bindings) {
6225
6237
  function resolveBinding(bindings, name) {
6226
6238
  const value = bindings[name];
6227
6239
  if (value === void 0) {
6228
- throw new chunk44SXEVF4_cjs.ConfigurationError(`Missing binding for parameter "${name}"`, {
6240
+ throw new chunkO5PST6TB_cjs.ConfigurationError(`Missing binding for parameter "${name}"`, {
6229
6241
  parameterName: name
6230
6242
  });
6231
6243
  }
@@ -6250,7 +6262,7 @@ function fillPlaceholders(params, bindings, dialect) {
6250
6262
  const name = parameter.name;
6251
6263
  const value = bindings[name];
6252
6264
  if (value === void 0) {
6253
- throw new chunk44SXEVF4_cjs.ConfigurationError(
6265
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
6254
6266
  `Missing binding for parameter "${name}"`,
6255
6267
  { parameterName: name }
6256
6268
  );
@@ -6317,7 +6329,7 @@ var PreparedQuery = class {
6317
6329
  this.#selectFn
6318
6330
  );
6319
6331
  } catch (error) {
6320
- if (error instanceof MissingSelectiveFieldError || error instanceof chunk44SXEVF4_cjs.UnsupportedPredicateError) {
6332
+ if (error instanceof MissingSelectiveFieldError || error instanceof chunkO5PST6TB_cjs.UnsupportedPredicateError) {
6321
6333
  return this.#executeUnoptimized(bindings);
6322
6334
  }
6323
6335
  throw error;
@@ -6487,7 +6499,7 @@ function validateBindings(bindings, metadata) {
6487
6499
  }
6488
6500
  }
6489
6501
  if (missing.length > 0) {
6490
- throw new chunk44SXEVF4_cjs.ConfigurationError(
6502
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
6491
6503
  `Missing bindings for parameter${missing.length === 1 ? "" : "s"}: ${missing.map((name) => `"${name}"`).join(", ")}`,
6492
6504
  { missingParameters: missing }
6493
6505
  );
@@ -6496,7 +6508,7 @@ function validateBindings(bindings, metadata) {
6496
6508
  (name) => !expectedNames.has(name)
6497
6509
  );
6498
6510
  if (unexpected.length > 0) {
6499
- throw new chunk44SXEVF4_cjs.ConfigurationError(
6511
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
6500
6512
  `Unexpected bindings provided: ${unexpected.map((name) => `"${name}"`).join(", ")}`,
6501
6513
  { unexpectedParameters: unexpected }
6502
6514
  );
@@ -6508,14 +6520,14 @@ function validateBindings(bindings, metadata) {
6508
6520
  }
6509
6521
  function validateBindingValue(name, value, isStringOp) {
6510
6522
  if (value === null) {
6511
- throw new chunk44SXEVF4_cjs.ConfigurationError(
6523
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
6512
6524
  "Parameter value must not be null (use undefined-based patterns instead)",
6513
6525
  { parameterName: name, valueType: "null" }
6514
6526
  );
6515
6527
  }
6516
6528
  if (isStringOp) {
6517
6529
  if (typeof value !== "string") {
6518
- throw new chunk44SXEVF4_cjs.ConfigurationError(
6530
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
6519
6531
  `Parameter "${name}" must be a string for string operations`,
6520
6532
  { parameterName: name, actualType: typeof value }
6521
6533
  );
@@ -6525,7 +6537,7 @@ function validateBindingValue(name, value, isStringOp) {
6525
6537
  if (value instanceof Date || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
6526
6538
  return;
6527
6539
  }
6528
- throw new chunk44SXEVF4_cjs.ConfigurationError(
6540
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
6529
6541
  `Unsupported parameter value type: ${typeof value}`,
6530
6542
  { parameterName: name, actualType: typeof value }
6531
6543
  );
@@ -6560,11 +6572,33 @@ var ExecutableQuery = class _ExecutableQuery {
6560
6572
  * Orders results.
6561
6573
  */
6562
6574
  orderBy(alias, field2, direction = "asc") {
6563
- const kindNames = alias === this.#state.startAlias ? this.#state.startKinds : this.#state.traversals.find(
6564
- (traversal) => traversal.nodeAlias === alias
6565
- )?.nodeKinds;
6566
- const typeInfo = kindNames ? this.#config.schemaIntrospector.getSharedFieldTypeInfo(kindNames, field2) : void 0;
6567
- const orderSpec = {
6575
+ const edgeTraversal = this.#state.traversals.find(
6576
+ (traversal) => traversal.edgeAlias === alias
6577
+ );
6578
+ const isEdge = edgeTraversal !== void 0;
6579
+ const isSystem = field2 === "id" || field2 === "kind" || isEdge && (field2 === "from_id" || field2 === "to_id");
6580
+ let typeInfo;
6581
+ if (!isSystem) {
6582
+ if (isEdge) {
6583
+ const edgeKindNames = mergeEdgeKinds(edgeTraversal);
6584
+ typeInfo = this.#config.schemaIntrospector.getSharedEdgeFieldTypeInfo(
6585
+ edgeKindNames,
6586
+ field2
6587
+ );
6588
+ } else {
6589
+ const kindNames = alias === this.#state.startAlias ? this.#state.startKinds : this.#state.traversals.find(
6590
+ (traversal) => traversal.nodeAlias === alias
6591
+ )?.nodeKinds;
6592
+ typeInfo = kindNames ? this.#config.schemaIntrospector.getSharedFieldTypeInfo(
6593
+ kindNames,
6594
+ field2
6595
+ ) : void 0;
6596
+ }
6597
+ }
6598
+ const orderSpec = isSystem ? {
6599
+ field: fieldRef(alias, [field2], { valueType: "string" }),
6600
+ direction
6601
+ } : {
6568
6602
  field: fieldRef(alias, ["props"], {
6569
6603
  jsonPointer: chunkP5CNM325_cjs.jsonPointer([field2]),
6570
6604
  valueType: typeInfo?.valueType,
@@ -6912,7 +6946,7 @@ var ExecutableQuery = class _ExecutableQuery {
6912
6946
  this.#cachedOptimizedCompiled = NOT_COMPUTED;
6913
6947
  return void 0;
6914
6948
  }
6915
- if (error instanceof chunk44SXEVF4_cjs.UnsupportedPredicateError) {
6949
+ if (error instanceof chunkO5PST6TB_cjs.UnsupportedPredicateError) {
6916
6950
  this.#cachedSelectiveFieldsForExecute = void 0;
6917
6951
  this.#cachedOptimizedCompiled = NOT_COMPUTED;
6918
6952
  return void 0;
@@ -6962,7 +6996,7 @@ var ExecutableQuery = class _ExecutableQuery {
6962
6996
  this.#cachedOptimizedCompiled = NOT_COMPUTED;
6963
6997
  return void 0;
6964
6998
  }
6965
- if (error instanceof chunk44SXEVF4_cjs.UnsupportedPredicateError) {
6999
+ if (error instanceof chunkO5PST6TB_cjs.UnsupportedPredicateError) {
6966
7000
  this.#cachedSelectiveFieldsForExecute = void 0;
6967
7001
  this.#cachedOptimizedCompiled = NOT_COMPUTED;
6968
7002
  return void 0;
@@ -7096,7 +7130,7 @@ var ExecutableQuery = class _ExecutableQuery {
7096
7130
  selectiveFields
7097
7131
  });
7098
7132
  } catch (error) {
7099
- if (error instanceof chunk44SXEVF4_cjs.UnsupportedPredicateError) {
7133
+ if (error instanceof chunkO5PST6TB_cjs.UnsupportedPredicateError) {
7100
7134
  this.#cachedSelectiveFieldsForPagination = void 0;
7101
7135
  return void 0;
7102
7136
  }
@@ -7122,7 +7156,7 @@ var ExecutableQuery = class _ExecutableQuery {
7122
7156
  this.#cachedSelectiveFieldsForPagination = void 0;
7123
7157
  return void 0;
7124
7158
  }
7125
- if (error instanceof chunk44SXEVF4_cjs.UnsupportedPredicateError) {
7159
+ if (error instanceof chunkO5PST6TB_cjs.UnsupportedPredicateError) {
7126
7160
  this.#cachedSelectiveFieldsForPagination = void 0;
7127
7161
  return void 0;
7128
7162
  }
@@ -7147,7 +7181,7 @@ var ExecutableQuery = class _ExecutableQuery {
7147
7181
  this.#cachedSelectiveFieldsForPagination = void 0;
7148
7182
  return void 0;
7149
7183
  }
7150
- if (error instanceof chunk44SXEVF4_cjs.UnsupportedPredicateError) {
7184
+ if (error instanceof chunkO5PST6TB_cjs.UnsupportedPredicateError) {
7151
7185
  this.#cachedSelectiveFieldsForPagination = void 0;
7152
7186
  return void 0;
7153
7187
  }
@@ -7303,7 +7337,7 @@ var ExecutableQuery = class _ExecutableQuery {
7303
7337
  );
7304
7338
  }
7305
7339
  if (this.#state.orderBy.length === 0) {
7306
- throw new chunk44SXEVF4_cjs.ValidationError(
7340
+ throw new chunkO5PST6TB_cjs.ValidationError(
7307
7341
  "Cursor pagination requires ORDER BY. Add .orderBy() before .paginate()",
7308
7342
  {
7309
7343
  issues: [
@@ -7379,7 +7413,7 @@ var ExecutableQuery = class _ExecutableQuery {
7379
7413
  */
7380
7414
  stream(options) {
7381
7415
  if (this.#state.orderBy.length === 0) {
7382
- throw new chunk44SXEVF4_cjs.ValidationError(
7416
+ throw new chunkO5PST6TB_cjs.ValidationError(
7383
7417
  "Streaming requires ORDER BY. Add .orderBy() before .stream()",
7384
7418
  {
7385
7419
  issues: [
@@ -8108,8 +8142,13 @@ var QueryBuilder = class _QueryBuilder {
8108
8142
  * Orders results.
8109
8143
  */
8110
8144
  orderBy(alias, field2, direction = "asc") {
8111
- const isSystem = field2 === "id" || field2 === "kind";
8112
- const typeInfo = isSystem ? void 0 : this.#getOrderByTypeInfo(alias, field2);
8145
+ const edgeKindNames = this.#getEdgeKindNamesForAlias(alias);
8146
+ const isEdge = edgeKindNames !== void 0;
8147
+ const isSystem = field2 === "id" || field2 === "kind" || isEdge && (field2 === "from_id" || field2 === "to_id");
8148
+ const typeInfo = isSystem ? void 0 : isEdge ? this.#config.schemaIntrospector.getSharedEdgeFieldTypeInfo(
8149
+ edgeKindNames,
8150
+ field2
8151
+ ) : this.#getOrderByTypeInfo(alias, field2);
8113
8152
  const orderSpec = isSystem ? {
8114
8153
  field: fieldRef(alias, [field2], { valueType: "string" }),
8115
8154
  direction
@@ -8158,7 +8197,7 @@ var QueryBuilder = class _QueryBuilder {
8158
8197
  */
8159
8198
  temporal(mode, asOf) {
8160
8199
  if (mode === "asOf" && asOf === void 0) {
8161
- throw new chunk44SXEVF4_cjs.ValidationError(
8200
+ throw new chunkO5PST6TB_cjs.ValidationError(
8162
8201
  'Temporal mode "asOf" requires a timestamp',
8163
8202
  {
8164
8203
  issues: [
@@ -8837,12 +8876,12 @@ function createQueryBuilder(graphId, registry, options) {
8837
8876
  function buildKindRegistry(graph) {
8838
8877
  const nodeTypes = extractNodeTypes(graph);
8839
8878
  const edgeTypes = extractEdgeTypes(graph);
8840
- const closures = graph.ontology.length > 0 ? chunk3HQLOKS5_cjs.computeClosuresFromOntology(graph.ontology) : chunk3HQLOKS5_cjs.createEmptyClosures();
8841
- return new chunk3HQLOKS5_cjs.KindRegistry(nodeTypes, edgeTypes, closures);
8879
+ const closures = graph.ontology.length > 0 ? chunkX33WV2UF_cjs.computeClosuresFromOntology(graph.ontology) : chunkX33WV2UF_cjs.createEmptyClosures();
8880
+ return new chunkX33WV2UF_cjs.KindRegistry(nodeTypes, edgeTypes, closures);
8842
8881
  }
8843
8882
  function extractNodeTypes(graph) {
8844
8883
  const result = /* @__PURE__ */ new Map();
8845
- for (const typeName of chunkNI2GV74U_cjs.getNodeKinds(graph)) {
8884
+ for (const typeName of chunk5GZMPJOP_cjs.getNodeKinds(graph)) {
8846
8885
  const registration = graph.nodes[typeName];
8847
8886
  result.set(typeName, registration.type);
8848
8887
  }
@@ -8850,7 +8889,7 @@ function extractNodeTypes(graph) {
8850
8889
  }
8851
8890
  function extractEdgeTypes(graph) {
8852
8891
  const result = /* @__PURE__ */ new Map();
8853
- for (const typeName of chunkNI2GV74U_cjs.getEdgeKinds(graph)) {
8892
+ for (const typeName of chunk5GZMPJOP_cjs.getEdgeKinds(graph)) {
8854
8893
  const registration = graph.edges[typeName];
8855
8894
  result.set(typeName, registration.type);
8856
8895
  }
@@ -9024,7 +9063,7 @@ function createEdgeCollection(config) {
9024
9063
  async find(options) {
9025
9064
  const untypedOptions = options;
9026
9065
  if (untypedOptions?.where !== void 0) {
9027
- throw new chunk44SXEVF4_cjs.UnsupportedPredicateError(
9066
+ throw new chunkO5PST6TB_cjs.UnsupportedPredicateError(
9028
9067
  `store.edges.${kind}.find({ where }) is not supported. Use store.query().traverse(...).whereEdge(...) for edge property filters.`,
9029
9068
  { kind, operation: "find" }
9030
9069
  );
@@ -9037,7 +9076,7 @@ function createEdgeCollection(config) {
9037
9076
  temporalMode: mode
9038
9077
  };
9039
9078
  if (mode === "current" || mode === "asOf") {
9040
- params.asOf = options?.asOf ?? chunkNI2GV74U_cjs.nowIso();
9079
+ params.asOf = options?.asOf ?? chunk5GZMPJOP_cjs.nowIso();
9041
9080
  }
9042
9081
  if (options?.from?.kind !== void 0)
9043
9082
  params.fromKind = options.from.kind;
@@ -9058,7 +9097,7 @@ function createEdgeCollection(config) {
9058
9097
  temporalMode: mode
9059
9098
  };
9060
9099
  if (mode === "current" || mode === "asOf") {
9061
- params.asOf = options?.asOf ?? chunkNI2GV74U_cjs.nowIso();
9100
+ params.asOf = options?.asOf ?? chunk5GZMPJOP_cjs.nowIso();
9062
9101
  }
9063
9102
  if (options?.from?.kind !== void 0)
9064
9103
  params.fromKind = options.from.kind;
@@ -9344,7 +9383,7 @@ function createNodeCollection(config) {
9344
9383
  },
9345
9384
  async find(options) {
9346
9385
  if (options?.where !== void 0 && createQuery === void 0) {
9347
- throw new chunk44SXEVF4_cjs.ConfigurationError(
9386
+ throw new chunkO5PST6TB_cjs.ConfigurationError(
9348
9387
  `store.nodes.${kind}.find({ where }) requires a query-capable store`,
9349
9388
  { kind, operation: "find" }
9350
9389
  );
@@ -9353,7 +9392,7 @@ function createNodeCollection(config) {
9353
9392
  const mode2 = options.temporalMode ?? defaultTemporalMode;
9354
9393
  let query = createQuery().from(kind, "_n").temporal(
9355
9394
  mode2,
9356
- mode2 === "asOf" ? options.asOf ?? chunkNI2GV74U_cjs.nowIso() : void 0
9395
+ mode2 === "asOf" ? options.asOf ?? chunk5GZMPJOP_cjs.nowIso() : void 0
9357
9396
  ).whereNode("_n", options.where).select((ctx) => ctx._n);
9358
9397
  if (options.limit !== void 0) query = query.limit(options.limit);
9359
9398
  if (options.offset !== void 0) query = query.offset(options.offset);
@@ -9368,7 +9407,7 @@ function createNodeCollection(config) {
9368
9407
  temporalMode: mode
9369
9408
  };
9370
9409
  if (mode === "current" || mode === "asOf") {
9371
- params.asOf = options?.asOf ?? chunkNI2GV74U_cjs.nowIso();
9410
+ params.asOf = options?.asOf ?? chunk5GZMPJOP_cjs.nowIso();
9372
9411
  }
9373
9412
  if (options?.limit !== void 0) params.limit = options.limit;
9374
9413
  if (options?.offset !== void 0) params.offset = options.offset;
@@ -9384,7 +9423,7 @@ function createNodeCollection(config) {
9384
9423
  temporalMode: mode
9385
9424
  };
9386
9425
  if (mode === "current" || mode === "asOf") {
9387
- params.asOf = options?.asOf ?? chunkNI2GV74U_cjs.nowIso();
9426
+ params.asOf = options?.asOf ?? chunk5GZMPJOP_cjs.nowIso();
9388
9427
  }
9389
9428
  return backend.countNodesByKind(params);
9390
9429
  },
@@ -9594,7 +9633,7 @@ function createNodeCollectionsProxy(graph, graphId, registry, backend, operation
9594
9633
  return new Proxy({}, {
9595
9634
  get: (_, kind) => {
9596
9635
  if (!Object.hasOwn(graph.nodes, kind)) {
9597
- throw new chunk44SXEVF4_cjs.KindNotFoundError(kind, "node");
9636
+ throw new chunkO5PST6TB_cjs.KindNotFoundError(kind, "node");
9598
9637
  }
9599
9638
  const cached = collectionCache.get(kind);
9600
9639
  if (cached !== void 0) {
@@ -9616,7 +9655,7 @@ function createEdgeCollectionsProxy(graph, graphId, registry, backend, operation
9616
9655
  return new Proxy({}, {
9617
9656
  get: (_, kind) => {
9618
9657
  if (!Object.hasOwn(graph.edges, kind)) {
9619
- throw new chunk44SXEVF4_cjs.KindNotFoundError(kind, "edge");
9658
+ throw new chunkO5PST6TB_cjs.KindNotFoundError(kind, "edge");
9620
9659
  }
9621
9660
  const cached = collectionCache.get(kind);
9622
9661
  if (cached !== void 0) {
@@ -9715,7 +9754,7 @@ function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeC
9715
9754
  }
9716
9755
  case "one": {
9717
9756
  if (existingEdgeCount > 0) {
9718
- return new chunk44SXEVF4_cjs.CardinalityError({
9757
+ return new chunkO5PST6TB_cjs.CardinalityError({
9719
9758
  edgeKind,
9720
9759
  fromKind,
9721
9760
  fromId,
@@ -9730,7 +9769,7 @@ function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeC
9730
9769
  }
9731
9770
  case "oneActive": {
9732
9771
  if (hasActiveEdge) {
9733
- return new chunk44SXEVF4_cjs.CardinalityError({
9772
+ return new chunkO5PST6TB_cjs.CardinalityError({
9734
9773
  edgeKind,
9735
9774
  fromKind,
9736
9775
  fromId,
@@ -9744,7 +9783,7 @@ function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeC
9744
9783
  }
9745
9784
  function checkUniqueEdge(edgeKind, fromKind, fromId, _toKind, _toId, existingCount) {
9746
9785
  if (existingCount > 0) {
9747
- return new chunk44SXEVF4_cjs.CardinalityError({
9786
+ return new chunkO5PST6TB_cjs.CardinalityError({
9748
9787
  edgeKind,
9749
9788
  fromKind,
9750
9789
  fromId,
@@ -9760,7 +9799,7 @@ function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registr
9760
9799
  (validKind) => registry.isAssignableTo(fromKind, validKind)
9761
9800
  );
9762
9801
  if (!fromValid) {
9763
- return new chunk44SXEVF4_cjs.EndpointError({
9802
+ return new chunkO5PST6TB_cjs.EndpointError({
9764
9803
  edgeKind,
9765
9804
  endpoint: "from",
9766
9805
  actualKind: fromKind,
@@ -9772,7 +9811,7 @@ function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registr
9772
9811
  (validKind) => registry.isAssignableTo(toKind, validKind)
9773
9812
  );
9774
9813
  if (!toValid) {
9775
- return new chunk44SXEVF4_cjs.EndpointError({
9814
+ return new chunkO5PST6TB_cjs.EndpointError({
9776
9815
  edgeKind,
9777
9816
  endpoint: "to",
9778
9817
  actualKind: toKind,
@@ -9784,7 +9823,7 @@ function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registr
9784
9823
  function checkDisjointness(nodeId, nodeKind, existingKinds, registry) {
9785
9824
  for (const existingKind of existingKinds) {
9786
9825
  if (registry.areDisjoint(nodeKind, existingKind)) {
9787
- return new chunk44SXEVF4_cjs.DisjointError({
9826
+ return new chunkO5PST6TB_cjs.DisjointError({
9788
9827
  nodeId,
9789
9828
  attemptedKind: nodeKind,
9790
9829
  conflictingKind: existingKind
@@ -9876,7 +9915,7 @@ async function checkCardinalityConstraint(ctx, edgeKind, cardinality, fromKind,
9876
9915
  // src/store/operations/edge-operations.ts
9877
9916
  function getEdgeRegistration(graph, kind) {
9878
9917
  const registration = graph.edges[kind];
9879
- if (registration === void 0) throw new chunk44SXEVF4_cjs.KindNotFoundError(kind, "edge");
9918
+ if (registration === void 0) throw new chunkO5PST6TB_cjs.KindNotFoundError(kind, "edge");
9880
9919
  return registration;
9881
9920
  }
9882
9921
  function buildEdgeEndpointCacheKey(graphId, kind, id) {
@@ -10018,7 +10057,7 @@ async function validateAndPrepareEdgeCreate(ctx, input, id, backend) {
10018
10057
  if (endpointError) throw endpointError;
10019
10058
  const fromNode = await backend.getNode(ctx.graphId, fromKind, input.fromId);
10020
10059
  if (!fromNode || fromNode.deleted_at) {
10021
- throw new chunk44SXEVF4_cjs.EndpointNotFoundError({
10060
+ throw new chunkO5PST6TB_cjs.EndpointNotFoundError({
10022
10061
  edgeKind: kind,
10023
10062
  endpoint: "from",
10024
10063
  nodeKind: fromKind,
@@ -10027,19 +10066,19 @@ async function validateAndPrepareEdgeCreate(ctx, input, id, backend) {
10027
10066
  }
10028
10067
  const toNode = await backend.getNode(ctx.graphId, toKind, input.toId);
10029
10068
  if (!toNode || toNode.deleted_at) {
10030
- throw new chunk44SXEVF4_cjs.EndpointNotFoundError({
10069
+ throw new chunkO5PST6TB_cjs.EndpointNotFoundError({
10031
10070
  edgeKind: kind,
10032
10071
  endpoint: "to",
10033
10072
  nodeKind: toKind,
10034
10073
  nodeId: input.toId
10035
10074
  });
10036
10075
  }
10037
- const validatedProps = chunk3HQLOKS5_cjs.validateEdgeProps(edgeKind.schema, input.props, {
10076
+ const validatedProps = chunkX33WV2UF_cjs.validateEdgeProps(edgeKind.schema, input.props, {
10038
10077
  kind,
10039
10078
  operation: "create"
10040
10079
  });
10041
- const validFrom = chunkNI2GV74U_cjs.validateOptionalIsoDate(input.validFrom, "validFrom");
10042
- const validTo = chunkNI2GV74U_cjs.validateOptionalIsoDate(input.validTo, "validTo");
10080
+ const validFrom = chunk5GZMPJOP_cjs.validateOptionalIsoDate(input.validFrom, "validFrom");
10081
+ const validTo = chunk5GZMPJOP_cjs.validateOptionalIsoDate(input.validTo, "validTo");
10043
10082
  const cardinality = registration.cardinality ?? "many";
10044
10083
  const constraintContext = {
10045
10084
  graphId: ctx.graphId,
@@ -10094,7 +10133,7 @@ async function executeEdgeCreateInternal(ctx, input, backend, options) {
10094
10133
  async function executeEdgeCreate(ctx, input, backend) {
10095
10134
  const result = await executeEdgeCreateInternal(ctx, input, backend);
10096
10135
  if (!result) {
10097
- throw new chunk44SXEVF4_cjs.DatabaseOperationError(
10136
+ throw new chunkO5PST6TB_cjs.DatabaseOperationError(
10098
10137
  "Edge create failed: expected created edge row",
10099
10138
  { operation: "insert", entity: "edge" }
10100
10139
  );
@@ -10171,7 +10210,7 @@ async function executeEdgeUpdate(ctx, input, backend) {
10171
10210
  const id = input.id;
10172
10211
  const existing = await backend.getEdge(ctx.graphId, id);
10173
10212
  if (!existing || existing.deleted_at) {
10174
- throw new chunk44SXEVF4_cjs.EdgeNotFoundError("unknown", id);
10213
+ throw new chunkO5PST6TB_cjs.EdgeNotFoundError("unknown", id);
10175
10214
  }
10176
10215
  const opContext = ctx.createOperationContext(
10177
10216
  "update",
@@ -10184,12 +10223,12 @@ async function executeEdgeUpdate(ctx, input, backend) {
10184
10223
  const edgeKind = registration.type;
10185
10224
  const existingProps = JSON.parse(existing.props);
10186
10225
  const mergedProps = { ...existingProps, ...input.props };
10187
- const validatedProps = chunk3HQLOKS5_cjs.validateEdgeProps(edgeKind.schema, mergedProps, {
10226
+ const validatedProps = chunkX33WV2UF_cjs.validateEdgeProps(edgeKind.schema, mergedProps, {
10188
10227
  kind: existing.kind,
10189
10228
  operation: "update",
10190
10229
  id
10191
10230
  });
10192
- const validTo = chunkNI2GV74U_cjs.validateOptionalIsoDate(input.validTo, "validTo");
10231
+ const validTo = chunk5GZMPJOP_cjs.validateOptionalIsoDate(input.validTo, "validTo");
10193
10232
  const updateParams = {
10194
10233
  graphId: ctx.graphId,
10195
10234
  id,
@@ -10204,18 +10243,18 @@ async function executeEdgeUpsertUpdate(ctx, input, backend, options) {
10204
10243
  const id = input.id;
10205
10244
  const existing = await backend.getEdge(ctx.graphId, id);
10206
10245
  if (!existing) {
10207
- throw new chunk44SXEVF4_cjs.EdgeNotFoundError("unknown", id);
10246
+ throw new chunkO5PST6TB_cjs.EdgeNotFoundError("unknown", id);
10208
10247
  }
10209
10248
  const registration = getEdgeRegistration(ctx.graph, existing.kind);
10210
10249
  const edgeKind = registration.type;
10211
10250
  const existingProps = JSON.parse(existing.props);
10212
10251
  const mergedProps = { ...existingProps, ...input.props };
10213
- const validatedProps = chunk3HQLOKS5_cjs.validateEdgeProps(edgeKind.schema, mergedProps, {
10252
+ const validatedProps = chunkX33WV2UF_cjs.validateEdgeProps(edgeKind.schema, mergedProps, {
10214
10253
  kind: existing.kind,
10215
10254
  operation: "update",
10216
10255
  id
10217
10256
  });
10218
- const validTo = chunkNI2GV74U_cjs.validateOptionalIsoDate(input.validTo, "validTo");
10257
+ const validTo = chunk5GZMPJOP_cjs.validateOptionalIsoDate(input.validTo, "validTo");
10219
10258
  const updateParams = {
10220
10259
  graphId: ctx.graphId,
10221
10260
  id,
@@ -10269,7 +10308,7 @@ function validateMatchOnFields(schema, matchOn, edgeKind) {
10269
10308
  if (matchOn.length === 0) return;
10270
10309
  const shape = schema.shape;
10271
10310
  if (shape === void 0) {
10272
- throw new chunk44SXEVF4_cjs.ValidationError(
10311
+ throw new chunkO5PST6TB_cjs.ValidationError(
10273
10312
  `Edge kind "${edgeKind}" has no schema shape to validate matchOn fields against`,
10274
10313
  {
10275
10314
  kind: edgeKind,
@@ -10283,7 +10322,7 @@ function validateMatchOnFields(schema, matchOn, edgeKind) {
10283
10322
  }
10284
10323
  const invalidFields = matchOn.filter((field2) => !(field2 in shape));
10285
10324
  if (invalidFields.length > 0) {
10286
- throw new chunk44SXEVF4_cjs.ValidationError(
10325
+ throw new chunkO5PST6TB_cjs.ValidationError(
10287
10326
  `Invalid matchOn fields for edge kind "${edgeKind}": ${invalidFields.join(", ")}`,
10288
10327
  {
10289
10328
  kind: edgeKind,
@@ -10367,7 +10406,7 @@ async function executeEdgeGetOrCreateByEndpoints(ctx, kind, fromKind, fromId, to
10367
10406
  const matchOn = options?.matchOn ?? [];
10368
10407
  const registration = getEdgeRegistration(ctx.graph, kind);
10369
10408
  const edgeKind = registration.type;
10370
- const validatedProps = chunk3HQLOKS5_cjs.validateEdgeProps(edgeKind.schema, props, {
10409
+ const validatedProps = chunkX33WV2UF_cjs.validateEdgeProps(edgeKind.schema, props, {
10371
10410
  kind,
10372
10411
  operation: "create"
10373
10412
  });
@@ -10449,7 +10488,7 @@ async function executeEdgeBulkGetOrCreateByEndpoints(ctx, kind, items, backend,
10449
10488
  validateMatchOnFields(edgeKind.schema, matchOn, kind);
10450
10489
  const validated = [];
10451
10490
  for (const item of items) {
10452
- const validatedProps = chunk3HQLOKS5_cjs.validateEdgeProps(edgeKind.schema, item.props, {
10491
+ const validatedProps = chunkX33WV2UF_cjs.validateEdgeProps(edgeKind.schema, item.props, {
10453
10492
  kind,
10454
10493
  operation: "create"
10455
10494
  });
@@ -10726,7 +10765,7 @@ async function checkUniquenessConstraints(ctx, kind, id, props, constraints) {
10726
10765
  key
10727
10766
  });
10728
10767
  if (existing && existing.node_id !== id) {
10729
- throw new chunk44SXEVF4_cjs.UniquenessError({
10768
+ throw new chunkO5PST6TB_cjs.UniquenessError({
10730
10769
  constraintName: constraint.name,
10731
10770
  kind: kindToCheck,
10732
10771
  existingId: existing.node_id,
@@ -10809,7 +10848,7 @@ async function updateUniquenessEntries(ctx, kind, id, oldProps, newProps, constr
10809
10848
  key: newKey
10810
10849
  });
10811
10850
  if (existing && existing.node_id !== id) {
10812
- throw new chunk44SXEVF4_cjs.UniquenessError({
10851
+ throw new chunkO5PST6TB_cjs.UniquenessError({
10813
10852
  constraintName: constraint.name,
10814
10853
  kind: kindToCheck,
10815
10854
  existingId: existing.node_id,
@@ -10833,7 +10872,7 @@ async function updateUniquenessEntries(ctx, kind, id, oldProps, newProps, constr
10833
10872
  // src/store/operations/node-operations.ts
10834
10873
  function getNodeRegistration(graph, kind) {
10835
10874
  const registration = graph.nodes[kind];
10836
- if (registration === void 0) throw new chunk44SXEVF4_cjs.KindNotFoundError(kind, "node");
10875
+ if (registration === void 0) throw new chunkO5PST6TB_cjs.KindNotFoundError(kind, "node");
10837
10876
  return registration;
10838
10877
  }
10839
10878
  var CACHE_KEY_SEPARATOR = "\0";
@@ -10844,7 +10883,7 @@ function buildUniqueCacheKey(graphId, nodeKind, constraintName, key) {
10844
10883
  return `${graphId}${CACHE_KEY_SEPARATOR}${nodeKind}${CACHE_KEY_SEPARATOR}${constraintName}${CACHE_KEY_SEPARATOR}${key}`;
10845
10884
  }
10846
10885
  function createNodeAlreadyExistsError(kind, id) {
10847
- return new chunk44SXEVF4_cjs.ValidationError(
10886
+ return new chunkO5PST6TB_cjs.ValidationError(
10848
10887
  `Node already exists: ${kind}/${id}`,
10849
10888
  {
10850
10889
  entityType: "node",
@@ -10885,7 +10924,7 @@ function resolveConstraint(graph, kind, constraintName) {
10885
10924
  (candidate) => candidate.name === constraintName
10886
10925
  );
10887
10926
  if (constraint === void 0) {
10888
- throw new chunk44SXEVF4_cjs.NodeConstraintNotFoundError(constraintName, kind);
10927
+ throw new chunkO5PST6TB_cjs.NodeConstraintNotFoundError(constraintName, kind);
10889
10928
  }
10890
10929
  return constraint;
10891
10930
  }
@@ -10994,12 +11033,12 @@ async function validateAndPrepareNodeCreate(ctx, input, id, backend) {
10994
11033
  const kind = input.kind;
10995
11034
  const registration = getNodeRegistration(ctx.graph, kind);
10996
11035
  const nodeKind = registration.type;
10997
- const validatedProps = chunk3HQLOKS5_cjs.validateNodeProps(nodeKind.schema, input.props, {
11036
+ const validatedProps = chunkX33WV2UF_cjs.validateNodeProps(nodeKind.schema, input.props, {
10998
11037
  kind,
10999
11038
  operation: "create"
11000
11039
  });
11001
- const validFrom = chunkNI2GV74U_cjs.validateOptionalIsoDate(input.validFrom, "validFrom");
11002
- const validTo = chunkNI2GV74U_cjs.validateOptionalIsoDate(input.validTo, "validTo");
11040
+ const validFrom = chunk5GZMPJOP_cjs.validateOptionalIsoDate(input.validFrom, "validFrom");
11041
+ const validTo = chunk5GZMPJOP_cjs.validateOptionalIsoDate(input.validTo, "validTo");
11003
11042
  const existingNode = await backend.getNode(ctx.graphId, kind, id);
11004
11043
  if (existingNode && !existingNode.deleted_at) {
11005
11044
  throw createNodeAlreadyExistsError(kind, id);
@@ -11058,17 +11097,17 @@ async function performNodeUpdate(ctx, input, backend, options) {
11058
11097
  const registration = getNodeRegistration(ctx.graph, kind);
11059
11098
  const existing = await backend.getNode(ctx.graphId, kind, id);
11060
11099
  if (!existing || existing.deleted_at && !options?.clearDeleted) {
11061
- throw new chunk44SXEVF4_cjs.NodeNotFoundError(kind, id);
11100
+ throw new chunkO5PST6TB_cjs.NodeNotFoundError(kind, id);
11062
11101
  }
11063
11102
  const existingProps = JSON.parse(existing.props);
11064
11103
  const mergedProps = { ...existingProps, ...input.props };
11065
11104
  const nodeKind = registration.type;
11066
- const validatedProps = chunk3HQLOKS5_cjs.validateNodeProps(nodeKind.schema, mergedProps, {
11105
+ const validatedProps = chunkX33WV2UF_cjs.validateNodeProps(nodeKind.schema, mergedProps, {
11067
11106
  kind,
11068
11107
  operation: "update",
11069
11108
  id
11070
11109
  });
11071
- const validTo = chunkNI2GV74U_cjs.validateOptionalIsoDate(input.validTo, "validTo");
11110
+ const validTo = chunk5GZMPJOP_cjs.validateOptionalIsoDate(input.validTo, "validTo");
11072
11111
  await updateUniquenessEntries(
11073
11112
  createUniquenessContext(ctx.graphId, ctx.registry, backend),
11074
11113
  kind,
@@ -11105,7 +11144,7 @@ async function enforceDeleteBehavior(ctx, kind, id, mode, backend, registration)
11105
11144
  switch (deleteBehavior) {
11106
11145
  case "restrict": {
11107
11146
  const edgeKinds = [...new Set(connectedEdges.map((edge) => edge.kind))];
11108
- throw new chunk44SXEVF4_cjs.RestrictedDeleteError({
11147
+ throw new chunkO5PST6TB_cjs.RestrictedDeleteError({
11109
11148
  nodeKind: kind,
11110
11149
  nodeId: id,
11111
11150
  edgeCount: connectedEdges.length,
@@ -11226,7 +11265,7 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
11226
11265
  async function executeNodeCreate(ctx, input, backend) {
11227
11266
  const result = await executeNodeCreateInternal(ctx, input, backend);
11228
11267
  if (!result) {
11229
- throw new chunk44SXEVF4_cjs.DatabaseOperationError(
11268
+ throw new chunkO5PST6TB_cjs.DatabaseOperationError(
11230
11269
  "Node create failed: expected created node row",
11231
11270
  { operation: "insert", entity: "node" }
11232
11271
  );
@@ -11327,7 +11366,7 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
11327
11366
  const ifExists = options?.ifExists ?? "return";
11328
11367
  const registration = getNodeRegistration(ctx.graph, kind);
11329
11368
  const nodeKind = registration.type;
11330
- const validatedProps = chunk3HQLOKS5_cjs.validateNodeProps(nodeKind.schema, props, {
11369
+ const validatedProps = chunkX33WV2UF_cjs.validateNodeProps(nodeKind.schema, props, {
11331
11370
  kind,
11332
11371
  operation: "create"
11333
11372
  });
@@ -11399,7 +11438,7 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
11399
11438
  async function executeNodeFindByConstraint(ctx, kind, constraintName, props, backend) {
11400
11439
  const registration = getNodeRegistration(ctx.graph, kind);
11401
11440
  const nodeKind = registration.type;
11402
- const validatedProps = chunk3HQLOKS5_cjs.validateNodeProps(nodeKind.schema, props, {
11441
+ const validatedProps = chunkX33WV2UF_cjs.validateNodeProps(nodeKind.schema, props, {
11403
11442
  kind,
11404
11443
  operation: "create"
11405
11444
  });
@@ -11436,7 +11475,7 @@ async function executeNodeFindByConstraint(ctx, kind, constraintName, props, bac
11436
11475
  function validateAndComputeKeys(nodeKind, kind, constraint, items) {
11437
11476
  const validated = [];
11438
11477
  for (const item of items) {
11439
- const validatedProps = chunk3HQLOKS5_cjs.validateNodeProps(nodeKind.schema, item.props, {
11478
+ const validatedProps = chunkX33WV2UF_cjs.validateNodeProps(nodeKind.schema, item.props, {
11440
11479
  kind,
11441
11480
  operation: "create"
11442
11481
  });
@@ -12048,7 +12087,7 @@ var Store = class {
12048
12087
  // === Internal: Temporal Filtering ===
12049
12088
  #matchesTemporalMode(row, options) {
12050
12089
  const mode = options?.temporalMode ?? this.#graph.defaults.temporalMode;
12051
- const asOf = options?.asOf ?? chunkNI2GV74U_cjs.nowIso();
12090
+ const asOf = options?.asOf ?? chunk5GZMPJOP_cjs.nowIso();
12052
12091
  switch (mode) {
12053
12092
  case "current":
12054
12093
  case "asOf": {
@@ -12081,137 +12120,141 @@ function createStore(graph, backend, options) {
12081
12120
  }
12082
12121
  async function createStoreWithSchema(graph, backend, options) {
12083
12122
  const store = createStore(graph, backend, options);
12084
- const result = await chunk3HQLOKS5_cjs.ensureSchema(backend, graph, options);
12123
+ const result = await chunkX33WV2UF_cjs.ensureSchema(backend, graph, options);
12085
12124
  return [store, result];
12086
12125
  }
12087
12126
 
12088
12127
  Object.defineProperty(exports, "isMetaEdge", {
12089
12128
  enumerable: true,
12090
- get: function () { return chunk3HQLOKS5_cjs.isMetaEdge; }
12129
+ get: function () { return chunkX33WV2UF_cjs.isMetaEdge; }
12091
12130
  });
12092
12131
  Object.defineProperty(exports, "defineGraph", {
12093
12132
  enumerable: true,
12094
- get: function () { return chunkNI2GV74U_cjs.defineGraph; }
12133
+ get: function () { return chunk5GZMPJOP_cjs.defineGraph; }
12095
12134
  });
12096
12135
  Object.defineProperty(exports, "getEdgeKinds", {
12097
12136
  enumerable: true,
12098
- get: function () { return chunkNI2GV74U_cjs.getEdgeKinds; }
12137
+ get: function () { return chunk5GZMPJOP_cjs.getEdgeKinds; }
12099
12138
  });
12100
12139
  Object.defineProperty(exports, "getNodeKinds", {
12101
12140
  enumerable: true,
12102
- get: function () { return chunkNI2GV74U_cjs.getNodeKinds; }
12141
+ get: function () { return chunk5GZMPJOP_cjs.getNodeKinds; }
12103
12142
  });
12104
12143
  Object.defineProperty(exports, "isEdgeType", {
12105
12144
  enumerable: true,
12106
- get: function () { return chunkNI2GV74U_cjs.isEdgeType; }
12145
+ get: function () { return chunk5GZMPJOP_cjs.isEdgeType; }
12107
12146
  });
12108
12147
  Object.defineProperty(exports, "isEdgeTypeWithEndpoints", {
12109
12148
  enumerable: true,
12110
- get: function () { return chunkNI2GV74U_cjs.isEdgeTypeWithEndpoints; }
12149
+ get: function () { return chunk5GZMPJOP_cjs.isEdgeTypeWithEndpoints; }
12111
12150
  });
12112
12151
  Object.defineProperty(exports, "isGraphDef", {
12113
12152
  enumerable: true,
12114
- get: function () { return chunkNI2GV74U_cjs.isGraphDef; }
12153
+ get: function () { return chunk5GZMPJOP_cjs.isGraphDef; }
12115
12154
  });
12116
12155
  Object.defineProperty(exports, "isNodeType", {
12117
12156
  enumerable: true,
12118
- get: function () { return chunkNI2GV74U_cjs.isNodeType; }
12157
+ get: function () { return chunk5GZMPJOP_cjs.isNodeType; }
12158
+ });
12159
+ Object.defineProperty(exports, "BackendDisposedError", {
12160
+ enumerable: true,
12161
+ get: function () { return chunkO5PST6TB_cjs.BackendDisposedError; }
12119
12162
  });
12120
12163
  Object.defineProperty(exports, "CardinalityError", {
12121
12164
  enumerable: true,
12122
- get: function () { return chunk44SXEVF4_cjs.CardinalityError; }
12165
+ get: function () { return chunkO5PST6TB_cjs.CardinalityError; }
12123
12166
  });
12124
12167
  Object.defineProperty(exports, "CompilerInvariantError", {
12125
12168
  enumerable: true,
12126
- get: function () { return chunk44SXEVF4_cjs.CompilerInvariantError; }
12169
+ get: function () { return chunkO5PST6TB_cjs.CompilerInvariantError; }
12127
12170
  });
12128
12171
  Object.defineProperty(exports, "ConfigurationError", {
12129
12172
  enumerable: true,
12130
- get: function () { return chunk44SXEVF4_cjs.ConfigurationError; }
12173
+ get: function () { return chunkO5PST6TB_cjs.ConfigurationError; }
12131
12174
  });
12132
12175
  Object.defineProperty(exports, "DatabaseOperationError", {
12133
12176
  enumerable: true,
12134
- get: function () { return chunk44SXEVF4_cjs.DatabaseOperationError; }
12177
+ get: function () { return chunkO5PST6TB_cjs.DatabaseOperationError; }
12135
12178
  });
12136
12179
  Object.defineProperty(exports, "DisjointError", {
12137
12180
  enumerable: true,
12138
- get: function () { return chunk44SXEVF4_cjs.DisjointError; }
12181
+ get: function () { return chunkO5PST6TB_cjs.DisjointError; }
12139
12182
  });
12140
12183
  Object.defineProperty(exports, "EdgeNotFoundError", {
12141
12184
  enumerable: true,
12142
- get: function () { return chunk44SXEVF4_cjs.EdgeNotFoundError; }
12185
+ get: function () { return chunkO5PST6TB_cjs.EdgeNotFoundError; }
12143
12186
  });
12144
12187
  Object.defineProperty(exports, "EndpointError", {
12145
12188
  enumerable: true,
12146
- get: function () { return chunk44SXEVF4_cjs.EndpointError; }
12189
+ get: function () { return chunkO5PST6TB_cjs.EndpointError; }
12147
12190
  });
12148
12191
  Object.defineProperty(exports, "EndpointNotFoundError", {
12149
12192
  enumerable: true,
12150
- get: function () { return chunk44SXEVF4_cjs.EndpointNotFoundError; }
12193
+ get: function () { return chunkO5PST6TB_cjs.EndpointNotFoundError; }
12151
12194
  });
12152
12195
  Object.defineProperty(exports, "KindNotFoundError", {
12153
12196
  enumerable: true,
12154
- get: function () { return chunk44SXEVF4_cjs.KindNotFoundError; }
12197
+ get: function () { return chunkO5PST6TB_cjs.KindNotFoundError; }
12155
12198
  });
12156
12199
  Object.defineProperty(exports, "MigrationError", {
12157
12200
  enumerable: true,
12158
- get: function () { return chunk44SXEVF4_cjs.MigrationError; }
12201
+ get: function () { return chunkO5PST6TB_cjs.MigrationError; }
12159
12202
  });
12160
12203
  Object.defineProperty(exports, "NodeConstraintNotFoundError", {
12161
12204
  enumerable: true,
12162
- get: function () { return chunk44SXEVF4_cjs.NodeConstraintNotFoundError; }
12205
+ get: function () { return chunkO5PST6TB_cjs.NodeConstraintNotFoundError; }
12163
12206
  });
12164
12207
  Object.defineProperty(exports, "NodeNotFoundError", {
12165
12208
  enumerable: true,
12166
- get: function () { return chunk44SXEVF4_cjs.NodeNotFoundError; }
12209
+ get: function () { return chunkO5PST6TB_cjs.NodeNotFoundError; }
12167
12210
  });
12168
12211
  Object.defineProperty(exports, "RestrictedDeleteError", {
12169
12212
  enumerable: true,
12170
- get: function () { return chunk44SXEVF4_cjs.RestrictedDeleteError; }
12213
+ get: function () { return chunkO5PST6TB_cjs.RestrictedDeleteError; }
12171
12214
  });
12172
12215
  Object.defineProperty(exports, "SchemaMismatchError", {
12173
12216
  enumerable: true,
12174
- get: function () { return chunk44SXEVF4_cjs.SchemaMismatchError; }
12217
+ get: function () { return chunkO5PST6TB_cjs.SchemaMismatchError; }
12175
12218
  });
12176
12219
  Object.defineProperty(exports, "TypeGraphError", {
12177
12220
  enumerable: true,
12178
- get: function () { return chunk44SXEVF4_cjs.TypeGraphError; }
12221
+ get: function () { return chunkO5PST6TB_cjs.TypeGraphError; }
12179
12222
  });
12180
12223
  Object.defineProperty(exports, "UniquenessError", {
12181
12224
  enumerable: true,
12182
- get: function () { return chunk44SXEVF4_cjs.UniquenessError; }
12225
+ get: function () { return chunkO5PST6TB_cjs.UniquenessError; }
12183
12226
  });
12184
12227
  Object.defineProperty(exports, "UnsupportedPredicateError", {
12185
12228
  enumerable: true,
12186
- get: function () { return chunk44SXEVF4_cjs.UnsupportedPredicateError; }
12229
+ get: function () { return chunkO5PST6TB_cjs.UnsupportedPredicateError; }
12187
12230
  });
12188
12231
  Object.defineProperty(exports, "ValidationError", {
12189
12232
  enumerable: true,
12190
- get: function () { return chunk44SXEVF4_cjs.ValidationError; }
12233
+ get: function () { return chunkO5PST6TB_cjs.ValidationError; }
12191
12234
  });
12192
12235
  Object.defineProperty(exports, "VersionConflictError", {
12193
12236
  enumerable: true,
12194
- get: function () { return chunk44SXEVF4_cjs.VersionConflictError; }
12237
+ get: function () { return chunkO5PST6TB_cjs.VersionConflictError; }
12195
12238
  });
12196
12239
  Object.defineProperty(exports, "getErrorSuggestion", {
12197
12240
  enumerable: true,
12198
- get: function () { return chunk44SXEVF4_cjs.getErrorSuggestion; }
12241
+ get: function () { return chunkO5PST6TB_cjs.getErrorSuggestion; }
12199
12242
  });
12200
12243
  Object.defineProperty(exports, "isConstraintError", {
12201
12244
  enumerable: true,
12202
- get: function () { return chunk44SXEVF4_cjs.isConstraintError; }
12245
+ get: function () { return chunkO5PST6TB_cjs.isConstraintError; }
12203
12246
  });
12204
12247
  Object.defineProperty(exports, "isSystemError", {
12205
12248
  enumerable: true,
12206
- get: function () { return chunk44SXEVF4_cjs.isSystemError; }
12249
+ get: function () { return chunkO5PST6TB_cjs.isSystemError; }
12207
12250
  });
12208
12251
  Object.defineProperty(exports, "isTypeGraphError", {
12209
12252
  enumerable: true,
12210
- get: function () { return chunk44SXEVF4_cjs.isTypeGraphError; }
12253
+ get: function () { return chunkO5PST6TB_cjs.isTypeGraphError; }
12211
12254
  });
12212
12255
  Object.defineProperty(exports, "isUserRecoverable", {
12213
12256
  enumerable: true,
12214
- get: function () { return chunk44SXEVF4_cjs.isUserRecoverable; }
12257
+ get: function () { return chunkO5PST6TB_cjs.isUserRecoverable; }
12215
12258
  });
12216
12259
  Object.defineProperty(exports, "MAX_JSON_POINTER_DEPTH", {
12217
12260
  enumerable: true,