@nicia-ai/typegraph 0.28.0 → 0.29.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 (174) hide show
  1. package/dist/backend/postgres/index.cjs +23 -761
  2. package/dist/backend/postgres/index.cjs.map +1 -1
  3. package/dist/backend/postgres/index.d.cts +24 -5
  4. package/dist/backend/postgres/index.d.ts +24 -5
  5. package/dist/backend/postgres/index.js +10 -752
  6. package/dist/backend/postgres/index.js.map +1 -1
  7. package/dist/backend/postgres/pglite.cjs +52 -0
  8. package/dist/backend/postgres/pglite.cjs.map +1 -0
  9. package/dist/backend/postgres/pglite.d.cts +116 -0
  10. package/dist/backend/postgres/pglite.d.ts +116 -0
  11. package/dist/backend/postgres/pglite.js +50 -0
  12. package/dist/backend/postgres/pglite.js.map +1 -0
  13. package/dist/backend/sqlite/index.cjs +22 -26
  14. package/dist/backend/sqlite/index.d.cts +17 -15
  15. package/dist/backend/sqlite/index.d.ts +17 -15
  16. package/dist/backend/sqlite/index.js +9 -9
  17. package/dist/backend/sqlite/libsql.cjs +17 -13
  18. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  19. package/dist/backend/sqlite/libsql.d.cts +3 -3
  20. package/dist/backend/sqlite/libsql.d.ts +3 -3
  21. package/dist/backend/sqlite/libsql.js +16 -12
  22. package/dist/backend/sqlite/libsql.js.map +1 -1
  23. package/dist/backend/sqlite/local.cjs +17 -16
  24. package/dist/backend/sqlite/local.cjs.map +1 -1
  25. package/dist/backend/sqlite/local.d.cts +3 -3
  26. package/dist/backend/sqlite/local.d.ts +3 -3
  27. package/dist/backend/sqlite/local.js +15 -14
  28. package/dist/backend/sqlite/local.js.map +1 -1
  29. package/dist/{chunk-DFHLG75V.js → chunk-3DTLDGIM.js} +386 -1093
  30. package/dist/chunk-3DTLDGIM.js.map +1 -0
  31. package/dist/{chunk-WVQXAFP3.js → chunk-454I6GDF.js} +46 -5
  32. package/dist/chunk-454I6GDF.js.map +1 -0
  33. package/dist/chunk-4K6IHUW6.cjs +183 -0
  34. package/dist/chunk-4K6IHUW6.cjs.map +1 -0
  35. package/dist/{chunk-ZTREJOGB.js → chunk-7KLVFWXR.js} +113 -68
  36. package/dist/chunk-7KLVFWXR.js.map +1 -0
  37. package/dist/{chunk-UKG7XHZ3.js → chunk-A4H6QMV4.js} +110 -102
  38. package/dist/chunk-A4H6QMV4.js.map +1 -0
  39. package/dist/{chunk-E5ROA3MN.js → chunk-BMDF2S7S.js} +3 -3
  40. package/dist/{chunk-E5ROA3MN.js.map → chunk-BMDF2S7S.js.map} +1 -1
  41. package/dist/{chunk-PN37HVAV.cjs → chunk-C2RWFIYP.cjs} +121 -67
  42. package/dist/chunk-C2RWFIYP.cjs.map +1 -0
  43. package/dist/chunk-CUZGBWFT.js +206 -0
  44. package/dist/chunk-CUZGBWFT.js.map +1 -0
  45. package/dist/chunk-F2Q76CQ4.cjs +266 -0
  46. package/dist/chunk-F2Q76CQ4.cjs.map +1 -0
  47. package/dist/{chunk-YEDQLNVE.cjs → chunk-G6P3OVDY.cjs} +14 -2
  48. package/dist/chunk-G6P3OVDY.cjs.map +1 -0
  49. package/dist/chunk-GPUNAJFH.js +181 -0
  50. package/dist/chunk-GPUNAJFH.js.map +1 -0
  51. package/dist/chunk-HKN622O4.js +254 -0
  52. package/dist/chunk-HKN622O4.js.map +1 -0
  53. package/dist/{chunk-PYJOBZR3.cjs → chunk-HM6XMR3E.cjs} +52 -52
  54. package/dist/chunk-HM6XMR3E.cjs.map +1 -0
  55. package/dist/chunk-IE2TPFBT.js +305 -0
  56. package/dist/chunk-IE2TPFBT.js.map +1 -0
  57. package/dist/chunk-KGAJ5HFO.cjs +319 -0
  58. package/dist/chunk-KGAJ5HFO.cjs.map +1 -0
  59. package/dist/chunk-M6OC455F.js +65 -0
  60. package/dist/chunk-M6OC455F.js.map +1 -0
  61. package/dist/{chunk-U5ROKVRF.js → chunk-MB363HT5.js} +14 -3
  62. package/dist/chunk-MB363HT5.js.map +1 -0
  63. package/dist/{chunk-X53YKGHR.js → chunk-MRMD7S7E.js} +9 -9
  64. package/dist/{chunk-X53YKGHR.js.map → chunk-MRMD7S7E.js.map} +1 -1
  65. package/dist/{chunk-OOS2RKRH.js → chunk-N3VVQDMA.js} +3 -3
  66. package/dist/{chunk-OOS2RKRH.js.map → chunk-N3VVQDMA.js.map} +1 -1
  67. package/dist/{chunk-EJCDOA37.js → chunk-OGUH56BB.js} +4 -4
  68. package/dist/{chunk-EJCDOA37.js.map → chunk-OGUH56BB.js.map} +1 -1
  69. package/dist/chunk-Q3ZZLU3O.cjs +12 -0
  70. package/dist/{chunk-4FJVSF3K.cjs.map → chunk-Q3ZZLU3O.cjs.map} +1 -1
  71. package/dist/chunk-Q5ASTPM4.cjs +208 -0
  72. package/dist/chunk-Q5ASTPM4.cjs.map +1 -0
  73. package/dist/{chunk-WFUN6DCM.cjs → chunk-R2LA6MKR.cjs} +11 -11
  74. package/dist/chunk-R2LA6MKR.cjs.map +1 -0
  75. package/dist/chunk-RP7YITHX.cjs +70 -0
  76. package/dist/chunk-RP7YITHX.cjs.map +1 -0
  77. package/dist/{chunk-33K3ZYFG.cjs → chunk-RU5BBUU2.cjs} +132 -124
  78. package/dist/chunk-RU5BBUU2.cjs.map +1 -0
  79. package/dist/{chunk-TSGBRPNE.js → chunk-SFNUHFON.js} +45 -45
  80. package/dist/chunk-SFNUHFON.js.map +1 -0
  81. package/dist/chunk-UP4QAJND.cjs +740 -0
  82. package/dist/chunk-UP4QAJND.cjs.map +1 -0
  83. package/dist/{chunk-CTHNVU6K.cjs → chunk-UPBXUOW7.cjs} +8 -8
  84. package/dist/{chunk-CTHNVU6K.cjs.map → chunk-UPBXUOW7.cjs.map} +1 -1
  85. package/dist/{chunk-EK6RJ373.cjs → chunk-VGU26WIU.cjs} +5 -5
  86. package/dist/{chunk-EK6RJ373.cjs.map → chunk-VGU26WIU.cjs.map} +1 -1
  87. package/dist/{chunk-ZGEMI7MJ.cjs → chunk-XTQHSOIC.cjs} +101 -101
  88. package/dist/{chunk-ZGEMI7MJ.cjs.map → chunk-XTQHSOIC.cjs.map} +1 -1
  89. package/dist/chunk-Y52UNT66.js +738 -0
  90. package/dist/chunk-Y52UNT66.js.map +1 -0
  91. package/dist/{chunk-OYLF3IC7.js → chunk-Z36W5WUM.js} +4 -4
  92. package/dist/chunk-Z36W5WUM.js.map +1 -0
  93. package/dist/{chunk-X3244EKP.cjs → chunk-ZFWNO3GE.cjs} +48 -4
  94. package/dist/chunk-ZFWNO3GE.cjs.map +1 -0
  95. package/dist/{chunk-2E4VTD2E.cjs → chunk-ZYQEXGYC.cjs} +423 -1139
  96. package/dist/chunk-ZYQEXGYC.cjs.map +1 -0
  97. package/dist/ddl-BwH00BB6.d.ts +38 -0
  98. package/dist/ddl-D3o-RmsV.d.cts +38 -0
  99. package/dist/{extension-types-B78CZfA5.d.ts → extension-types-CwHV-Uk4.d.cts} +4 -4
  100. package/dist/{extension-types-B78CZfA5.d.cts → extension-types-CwHV-Uk4.d.ts} +4 -4
  101. package/dist/graph-extension/index.cjs +18 -18
  102. package/dist/graph-extension/index.d.cts +4 -4
  103. package/dist/graph-extension/index.d.ts +4 -4
  104. package/dist/graph-extension/index.js +3 -3
  105. package/dist/{index-CWdBFWbI.d.ts → index-CapHwi1a.d.ts} +22 -3
  106. package/dist/{index-Bilw0pYm.d.cts → index-jPPexxM5.d.cts} +22 -3
  107. package/dist/index.cjs +1211 -945
  108. package/dist/index.cjs.map +1 -1
  109. package/dist/index.d.cts +142 -12
  110. package/dist/index.d.ts +142 -12
  111. package/dist/index.js +778 -544
  112. package/dist/index.js.map +1 -1
  113. package/dist/indexes/index.cjs +18 -18
  114. package/dist/indexes/index.d.cts +9 -9
  115. package/dist/indexes/index.d.ts +9 -9
  116. package/dist/indexes/index.js +4 -4
  117. package/dist/interchange/index.cjs +8 -14
  118. package/dist/interchange/index.cjs.map +1 -1
  119. package/dist/interchange/index.d.cts +5 -16
  120. package/dist/interchange/index.d.ts +5 -16
  121. package/dist/interchange/index.js +3 -9
  122. package/dist/interchange/index.js.map +1 -1
  123. package/dist/{manager-ehLTTNq0.d.ts → manager-BUugwCYz.d.ts} +2 -2
  124. package/dist/{manager-c1MGaVVR.d.cts → manager-DpIpn1HQ.d.cts} +2 -2
  125. package/dist/{materialize-indexes-DFavFQah.d.ts → materialize-indexes-lkawaDor.d.ts} +1 -1
  126. package/dist/{materialize-indexes-BQfaAZKA.d.cts → materialize-indexes-oanE3RU0.d.cts} +1 -1
  127. package/dist/{ddl-0Ooc2dpL.d.ts → postgres-CQL9UIn2.d.cts} +2 -471
  128. package/dist/{ddl-Dza3kDrI.d.cts → postgres-CcRLaxz0.d.ts} +2 -471
  129. package/dist/profiler/index.cjs +4 -4
  130. package/dist/profiler/index.d.cts +7 -7
  131. package/dist/profiler/index.d.ts +7 -7
  132. package/dist/profiler/index.js +2 -2
  133. package/dist/schema/index.cjs +32 -32
  134. package/dist/schema/index.d.cts +7 -7
  135. package/dist/schema/index.d.ts +7 -7
  136. package/dist/schema/index.js +9 -9
  137. package/dist/{sqlite-BxZUPbyD.d.ts → sqlite-CZDFUfHS.d.ts} +2 -468
  138. package/dist/{sqlite-mvpXjEeB.d.cts → sqlite-Rj3xu4It.d.cts} +2 -468
  139. package/dist/{store-Ufc1Eoey.d.ts → store-B43FpOVX.d.cts} +84 -5
  140. package/dist/{store-D7YEMg2v.d.cts → store-De0Y33wP.d.ts} +84 -5
  141. package/dist/{types-B-sJJ4GQ.d.ts → types-B5GSeE3t.d.ts} +2 -2
  142. package/dist/{types-CmUA9sal.d.cts → types-Bwlp_yvu.d.cts} +2 -2
  143. package/dist/{types-CMQymcwk.d.cts → types-CmAT-Z47.d.ts} +250 -46
  144. package/dist/{types-CQ7xXJMP.d.ts → types-DXCSyxac.d.cts} +250 -46
  145. package/dist/{where-5zf15aFZ.d.cts → where-2dsyYt3d.d.cts} +2 -2
  146. package/dist/{where-CtrLu1Zf.d.ts → where-CP4qGIHd.d.ts} +2 -2
  147. package/package.json +20 -5
  148. package/dist/chunk-2E4VTD2E.cjs.map +0 -1
  149. package/dist/chunk-33K3ZYFG.cjs.map +0 -1
  150. package/dist/chunk-3EUKJEQ3.js +0 -77
  151. package/dist/chunk-3EUKJEQ3.js.map +0 -1
  152. package/dist/chunk-4FJVSF3K.cjs +0 -12
  153. package/dist/chunk-5H3BAMTB.js +0 -32
  154. package/dist/chunk-5H3BAMTB.js.map +0 -1
  155. package/dist/chunk-DFHLG75V.js.map +0 -1
  156. package/dist/chunk-HTGDWIDE.cjs +0 -89
  157. package/dist/chunk-HTGDWIDE.cjs.map +0 -1
  158. package/dist/chunk-IUIWCFG3.cjs +0 -36
  159. package/dist/chunk-IUIWCFG3.cjs.map +0 -1
  160. package/dist/chunk-LYRUNG6E.cjs +0 -52
  161. package/dist/chunk-LYRUNG6E.cjs.map +0 -1
  162. package/dist/chunk-OYLF3IC7.js.map +0 -1
  163. package/dist/chunk-PCHTTG42.js +0 -47
  164. package/dist/chunk-PCHTTG42.js.map +0 -1
  165. package/dist/chunk-PN37HVAV.cjs.map +0 -1
  166. package/dist/chunk-PYJOBZR3.cjs.map +0 -1
  167. package/dist/chunk-TSGBRPNE.js.map +0 -1
  168. package/dist/chunk-U5ROKVRF.js.map +0 -1
  169. package/dist/chunk-UKG7XHZ3.js.map +0 -1
  170. package/dist/chunk-WFUN6DCM.cjs.map +0 -1
  171. package/dist/chunk-WVQXAFP3.js.map +0 -1
  172. package/dist/chunk-X3244EKP.cjs.map +0 -1
  173. package/dist/chunk-YEDQLNVE.cjs.map +0 -1
  174. package/dist/chunk-ZTREJOGB.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,17 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var chunkHTGDWIDE_cjs = require('./chunk-HTGDWIDE.cjs');
4
- var chunkZGEMI7MJ_cjs = require('./chunk-ZGEMI7MJ.cjs');
5
- var chunkWFUN6DCM_cjs = require('./chunk-WFUN6DCM.cjs');
6
- var chunk4FJVSF3K_cjs = require('./chunk-4FJVSF3K.cjs');
7
- var chunkPYJOBZR3_cjs = require('./chunk-PYJOBZR3.cjs');
8
- var chunkLYRUNG6E_cjs = require('./chunk-LYRUNG6E.cjs');
9
- var chunkIUIWCFG3_cjs = require('./chunk-IUIWCFG3.cjs');
10
- var chunkPN37HVAV_cjs = require('./chunk-PN37HVAV.cjs');
11
- var chunkCTHNVU6K_cjs = require('./chunk-CTHNVU6K.cjs');
12
- var chunkEK6RJ373_cjs = require('./chunk-EK6RJ373.cjs');
13
- var chunkX3244EKP_cjs = require('./chunk-X3244EKP.cjs');
14
- var chunkYEDQLNVE_cjs = require('./chunk-YEDQLNVE.cjs');
3
+ var chunkQ5ASTPM4_cjs = require('./chunk-Q5ASTPM4.cjs');
4
+ var chunkKGAJ5HFO_cjs = require('./chunk-KGAJ5HFO.cjs');
5
+ var chunkXTQHSOIC_cjs = require('./chunk-XTQHSOIC.cjs');
6
+ var chunkR2LA6MKR_cjs = require('./chunk-R2LA6MKR.cjs');
7
+ var chunkQ3ZZLU3O_cjs = require('./chunk-Q3ZZLU3O.cjs');
8
+ var chunkHM6XMR3E_cjs = require('./chunk-HM6XMR3E.cjs');
9
+ var chunk4K6IHUW6_cjs = require('./chunk-4K6IHUW6.cjs');
10
+ var chunkF2Q76CQ4_cjs = require('./chunk-F2Q76CQ4.cjs');
11
+ var chunkRP7YITHX_cjs = require('./chunk-RP7YITHX.cjs');
12
+ var chunkC2RWFIYP_cjs = require('./chunk-C2RWFIYP.cjs');
13
+ var chunkUPBXUOW7_cjs = require('./chunk-UPBXUOW7.cjs');
14
+ var chunkVGU26WIU_cjs = require('./chunk-VGU26WIU.cjs');
15
+ var chunkZFWNO3GE_cjs = require('./chunk-ZFWNO3GE.cjs');
16
+ var chunkG6P3OVDY_cjs = require('./chunk-G6P3OVDY.cjs');
15
17
  var chunk7V335GHG_cjs = require('./chunk-7V335GHG.cjs');
16
18
  var zod = require('zod');
17
19
  var drizzleOrm = require('drizzle-orm');
@@ -28,7 +30,7 @@ function metaEdge(name, options = {}) {
28
30
  description: options.description
29
31
  };
30
32
  return Object.freeze({
31
- [chunkZGEMI7MJ_cjs.META_EDGE_BRAND]: true,
33
+ [chunkXTQHSOIC_cjs.META_EDGE_BRAND]: true,
32
34
  name,
33
35
  properties
34
36
  });
@@ -60,6 +62,184 @@ function getExternalRefTable(schema) {
60
62
  function createExternalRef(table) {
61
63
  return (id) => ({ table, id });
62
64
  }
65
+ var DEFAULT_BATCH_SIZE = 500;
66
+ var DEFAULT_SLOT_METRIC = chunkZFWNO3GE_cjs.DEFAULT_EMBEDDING_METRIC;
67
+ var DEFAULT_SLOT_INDEX_TYPE = chunkZFWNO3GE_cjs.DEFAULT_EMBEDDING_INDEX_TYPE;
68
+ async function migrateLegacyEmbeddings(options) {
69
+ const {
70
+ backend,
71
+ graphId,
72
+ resolveSlotConfig,
73
+ batchSize = DEFAULT_BATCH_SIZE,
74
+ legacyTableName = chunkF2Q76CQ4_cjs.LEGACY_EMBEDDINGS_TABLE_NAME
75
+ } = options;
76
+ if (backend.vectorStrategy === void 0 || backend.upsertEmbedding === void 0) {
77
+ throw new Error(
78
+ "migrateLegacyEmbeddings requires a backend wired with a vectorStrategy (the destination per-field storage). Pass the post-cutover backend."
79
+ );
80
+ }
81
+ if (!Number.isInteger(batchSize) || batchSize <= 0) {
82
+ throw new RangeError(
83
+ `batchSize must be a positive integer, got: ${batchSize}`
84
+ );
85
+ }
86
+ const upsertEmbedding = backend.upsertEmbedding;
87
+ const perField = {};
88
+ const skippedDimensionMismatch = {};
89
+ const skippedDecodeError = {};
90
+ let migrated = 0;
91
+ let cursor;
92
+ for (; ; ) {
93
+ let batch;
94
+ try {
95
+ batch = await readLegacyBatch(backend, {
96
+ legacyTableName,
97
+ graphId,
98
+ batchSize,
99
+ after: cursor
100
+ });
101
+ } catch (error) {
102
+ if (cursor === void 0 && chunkRP7YITHX_cjs.isMissingTableError(error)) {
103
+ return {
104
+ migrated: 0,
105
+ perField: {},
106
+ skippedDimensionMismatch: {},
107
+ skippedDecodeError: {},
108
+ legacyTablePresent: false
109
+ };
110
+ }
111
+ throw error;
112
+ }
113
+ if (batch.length === 0) break;
114
+ for (const row of batch) {
115
+ const slotKey = `${row.node_kind}.${row.field_path}`;
116
+ let embedding2;
117
+ try {
118
+ embedding2 = decodeEmbeddingJson(row);
119
+ } catch {
120
+ skippedDecodeError[slotKey] = (skippedDecodeError[slotKey] ?? 0) + 1;
121
+ continue;
122
+ }
123
+ const config = resolveSlotConfig?.(row.node_kind, row.field_path);
124
+ try {
125
+ await upsertEmbedding({
126
+ graphId: row.graph_id,
127
+ nodeKind: row.node_kind,
128
+ nodeId: row.node_id,
129
+ fieldPath: row.field_path,
130
+ embedding: embedding2,
131
+ // The decoded length is the authoritative fixed dimension — the
132
+ // strategy provisions its column type (e.g. `F32_BLOB(N)`) from it.
133
+ dimensions: embedding2.length,
134
+ metric: config?.metric ?? DEFAULT_SLOT_METRIC,
135
+ indexType: config?.indexType ?? DEFAULT_SLOT_INDEX_TYPE
136
+ });
137
+ } catch (error) {
138
+ if (error instanceof chunkG6P3OVDY_cjs.EmbeddingDimensionChangedError) {
139
+ skippedDimensionMismatch[slotKey] = (skippedDimensionMismatch[slotKey] ?? 0) + 1;
140
+ continue;
141
+ }
142
+ throw error;
143
+ }
144
+ migrated += 1;
145
+ perField[slotKey] = (perField[slotKey] ?? 0) + 1;
146
+ }
147
+ if (batch.length < batchSize) break;
148
+ const last = batch.at(-1);
149
+ cursor = {
150
+ graphId: last.graph_id,
151
+ nodeKind: last.node_kind,
152
+ nodeId: last.node_id,
153
+ fieldPath: last.field_path
154
+ };
155
+ }
156
+ return {
157
+ migrated,
158
+ perField,
159
+ skippedDimensionMismatch,
160
+ skippedDecodeError,
161
+ legacyTablePresent: true
162
+ };
163
+ }
164
+ async function readLegacyBatch(backend, params) {
165
+ const table = chunkC2RWFIYP_cjs.quotedTableName(params.legacyTableName);
166
+ const embeddingJson = legacyEmbeddingDecodeExpression(backend);
167
+ const conditions = [];
168
+ if (params.graphId !== void 0) {
169
+ conditions.push(drizzleOrm.sql`"graph_id" = ${params.graphId}`);
170
+ }
171
+ if (params.after !== void 0) {
172
+ conditions.push(keysetAfterCondition(params.after));
173
+ }
174
+ const whereClause = conditions.length === 0 ? drizzleOrm.sql`` : drizzleOrm.sql` WHERE ${drizzleOrm.sql.join(conditions, drizzleOrm.sql` AND `)}`;
175
+ const query = drizzleOrm.sql`
176
+ SELECT
177
+ "graph_id" AS graph_id,
178
+ "node_kind" AS node_kind,
179
+ "node_id" AS node_id,
180
+ "field_path" AS field_path,
181
+ ${embeddingJson} AS embedding_json
182
+ FROM ${table}${whereClause}
183
+ ORDER BY "graph_id" ASC, "node_kind" ASC, "node_id" ASC, "field_path" ASC
184
+ LIMIT ${params.batchSize}
185
+ `;
186
+ return backend.execute(query);
187
+ }
188
+ function keysetAfterCondition(after) {
189
+ return drizzleOrm.sql`
190
+ (
191
+ "graph_id" > ${after.graphId}
192
+ OR ("graph_id" = ${after.graphId} AND "node_kind" > ${after.nodeKind})
193
+ OR ("graph_id" = ${after.graphId} AND "node_kind" = ${after.nodeKind} AND "node_id" > ${after.nodeId})
194
+ OR (
195
+ "graph_id" = ${after.graphId}
196
+ AND "node_kind" = ${after.nodeKind}
197
+ AND "node_id" = ${after.nodeId}
198
+ AND "field_path" > ${after.fieldPath}
199
+ )
200
+ )
201
+ `;
202
+ }
203
+ function legacyEmbeddingDecodeExpression(backend) {
204
+ switch (backend.dialect) {
205
+ case "sqlite": {
206
+ return drizzleOrm.sql`vec_to_json("embedding")`;
207
+ }
208
+ case "postgres": {
209
+ return drizzleOrm.sql`"embedding"::text`;
210
+ }
211
+ default: {
212
+ const _exhaustive = backend.dialect;
213
+ throw new Error(
214
+ `migrateLegacyEmbeddings does not support dialect: ${String(_exhaustive)}`
215
+ );
216
+ }
217
+ }
218
+ }
219
+ function decodeEmbeddingJson(row) {
220
+ let parsed;
221
+ try {
222
+ parsed = JSON.parse(row.embedding_json);
223
+ } catch (error) {
224
+ throw new Error(
225
+ `Failed to decode legacy embedding for ${row.node_kind}.${row.field_path} (graph ${row.graph_id}, node ${row.node_id}): not valid JSON.`,
226
+ { cause: error }
227
+ );
228
+ }
229
+ if (!Array.isArray(parsed) || parsed.length === 0) {
230
+ throw new Error(
231
+ `Legacy embedding for ${row.node_kind}.${row.field_path} (graph ${row.graph_id}, node ${row.node_id}) decoded to a non-array or empty value.`
232
+ );
233
+ }
234
+ for (const [index, value] of parsed.entries()) {
235
+ if (typeof value !== "number" || !Number.isFinite(value)) {
236
+ throw new TypeError(
237
+ `Legacy embedding for ${row.node_kind}.${row.field_path} (graph ${row.graph_id}, node ${row.node_id}) has a non-finite value at index ${index}: ${String(value)}.`
238
+ );
239
+ }
240
+ }
241
+ return parsed;
242
+ }
63
243
 
64
244
  // src/query/subquery-utils.ts
65
245
  function normalizeValueType(valueType) {
@@ -279,7 +459,7 @@ function createFulltextAccessor(alias, hasSearchableField) {
279
459
  return {
280
460
  matches: (query, k, options) => {
281
461
  if (!hasSearchableField()) {
282
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
462
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
283
463
  `Cannot call .$fulltext.matches() on alias "${alias}" \u2014 its node kind has no fields declared with searchable(). Add at least one: \`title: searchable({ language: "english" })\`.`
284
464
  );
285
465
  }
@@ -294,7 +474,7 @@ function createFulltextAccessor(alias, hasSearchableField) {
294
474
  }
295
475
  function fulltextMatch(field2, query, limit, options) {
296
476
  if (!Number.isFinite(limit) || limit <= 0) {
297
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
477
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
298
478
  `matches() limit must be a positive finite number, got ${String(limit)}`
299
479
  );
300
480
  }
@@ -364,7 +544,10 @@ function vectorSimilarity(field2, queryEmbedding, limit, options) {
364
544
  __type: "vector_similarity",
365
545
  field: field2,
366
546
  queryEmbedding,
367
- metric: options?.metric ?? "cosine",
547
+ // Leave metric unset when the caller didn't specify one, so the compiler
548
+ // resolves the field's declared metric per kind. Defaulting to "cosine"
549
+ // here would mis-rank l2/inner_product fields and bypass their ANN index.
550
+ ...options?.metric !== void 0 && { metric: options.metric },
368
551
  limit,
369
552
  ...options?.minScore !== void 0 && { minScore: options.minScore }
370
553
  };
@@ -408,7 +591,7 @@ function buildFieldBuilderForTypeInfo(field2, typeInfo) {
408
591
  }
409
592
  }
410
593
  function resolvePointerTypeInfo(typeInfo, pointer) {
411
- return chunkEK6RJ373_cjs.resolveFieldTypeInfoAtJsonPointer(typeInfo, pointer);
594
+ return chunkVGU26WIU_cjs.resolveFieldTypeInfoAtJsonPointer(typeInfo, pointer);
412
595
  }
413
596
  function objectOp(op, field2, pointer, value, options) {
414
597
  const expr = {
@@ -561,7 +744,7 @@ function notInSubquery(field2, subquery) {
561
744
  function assertSingleColumnSubquery(subquery) {
562
745
  const columnCount = getSubqueryColumnCount(subquery);
563
746
  if (columnCount === 1) return;
564
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
747
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
565
748
  `IN/NOT IN subquery must project exactly 1 column, but got ${columnCount}`,
566
749
  { subqueryColumnCount: columnCount },
567
750
  {
@@ -574,7 +757,7 @@ function assertCompatibleSubqueryValueTypes(field2, subquery) {
574
757
  const subqueryValueType = getSingleSubqueryColumnValueType(subquery);
575
758
  const resolvedValueType = fieldValueType ?? subqueryValueType;
576
759
  if (isUnsupportedInSubqueryValueType(resolvedValueType)) {
577
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
760
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
578
761
  `IN/NOT IN subquery does not support ${String(resolvedValueType)} values`,
579
762
  { valueType: resolvedValueType },
580
763
  {
@@ -585,7 +768,7 @@ function assertCompatibleSubqueryValueTypes(field2, subquery) {
585
768
  if (isInSubqueryTypeCompatible(fieldValueType, subqueryValueType)) {
586
769
  return;
587
770
  }
588
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
771
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
589
772
  `IN/NOT IN type mismatch: field type "${String(fieldValueType)}" does not match subquery column type "${String(subqueryValueType)}"`,
590
773
  {
591
774
  fieldValueType,
@@ -711,7 +894,7 @@ function resolveLiteralValueTypes(literals) {
711
894
  }
712
895
  }
713
896
  if (resolved.size > 1) {
714
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
897
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
715
898
  "Mixed literal value types are not supported in predicates",
716
899
  { valueTypes: [...resolved] }
717
900
  );
@@ -837,7 +1020,7 @@ function compilePredicateExpression(expr, ctx) {
837
1020
  if (!upperIsParam) boundsForType.push(expr.upper);
838
1021
  const valueType = boundsForType.length > 0 ? resolveComparisonValueType(expr.field, boundsForType) : normalizeValueType2(expr.field.valueType);
839
1022
  if (valueType === "array" || valueType === "object") {
840
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
1023
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
841
1024
  "Between comparisons are not supported for JSON arrays or objects"
842
1025
  );
843
1026
  }
@@ -904,7 +1087,7 @@ function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
904
1087
  );
905
1088
  const opSql2 = COMPARISON_OP_SQL[expr.op];
906
1089
  if (!opSql2) {
907
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
1090
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
908
1091
  `Comparison operation "${expr.op}" is not supported for parameterized predicates`
909
1092
  );
910
1093
  }
@@ -912,7 +1095,7 @@ function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
912
1095
  }
913
1096
  const valueType = resolveComparisonValueType(expr.left, expr.right);
914
1097
  if (valueType === "array" || valueType === "object") {
915
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
1098
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
916
1099
  `Comparison operation "${expr.op}" is not supported for ${valueType} values`
917
1100
  );
918
1101
  }
@@ -940,7 +1123,7 @@ function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
940
1123
  const convertedRight = convertValueForSql(rightValue.value, dialect);
941
1124
  const opSql = COMPARISON_OP_SQL[expr.op];
942
1125
  if (!opSql) {
943
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
1126
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
944
1127
  `Comparison operation "${expr.op}" is not supported`
945
1128
  );
946
1129
  }
@@ -1003,13 +1186,13 @@ function compileObjectPredicate(expr, dialect, cteColumnPrefix) {
1003
1186
  }
1004
1187
  case "pathEquals": {
1005
1188
  if (!expr.value) {
1006
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
1189
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
1007
1190
  "pathEquals requires a comparison value"
1008
1191
  );
1009
1192
  }
1010
1193
  const valueType = resolvePredicateValueType(expr.valueType, expr.value);
1011
1194
  if (valueType === "array" || valueType === "object") {
1012
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
1195
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
1013
1196
  "pathEquals is not supported for JSON arrays or objects"
1014
1197
  );
1015
1198
  }
@@ -1025,7 +1208,7 @@ function compileObjectPredicate(expr, dialect, cteColumnPrefix) {
1025
1208
  }
1026
1209
  case "pathContains": {
1027
1210
  if (!expr.value) {
1028
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
1211
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
1029
1212
  "pathContains requires a comparison value"
1030
1213
  );
1031
1214
  }
@@ -1053,7 +1236,7 @@ function compileAggregatePredicate(expr, dialect) {
1053
1236
  const aggregate = compileAggregateExpr(expr.aggregate, dialect);
1054
1237
  const op = COMPARISON_OP_SQL[expr.op];
1055
1238
  if (!op) {
1056
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
1239
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
1057
1240
  `Comparison operation "${expr.op}" is not supported for aggregate predicates`
1058
1241
  );
1059
1242
  }
@@ -1088,7 +1271,7 @@ function compileAggregateExpr(expr, dialect) {
1088
1271
  return drizzleOrm.sql`MAX(${field2})`;
1089
1272
  }
1090
1273
  default: {
1091
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
1274
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
1092
1275
  `Unknown aggregate function: ${expr.function}`
1093
1276
  );
1094
1277
  }
@@ -1096,7 +1279,7 @@ function compileAggregateExpr(expr, dialect) {
1096
1279
  }
1097
1280
  function compileExistsSubquery(expr, ctx) {
1098
1281
  if (expr.subquery.graphId === void 0) {
1099
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError("EXISTS subquery must have a graphId");
1282
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError("EXISTS subquery must have a graphId");
1100
1283
  }
1101
1284
  const subSql = ctx.compileQuery(expr.subquery, expr.subquery.graphId);
1102
1285
  return expr.negated ? drizzleOrm.sql`NOT EXISTS (${subSql})` : drizzleOrm.sql`EXISTS (${subSql})`;
@@ -1104,7 +1287,7 @@ function compileExistsSubquery(expr, ctx) {
1104
1287
  function compileInSubquery(expr, ctx) {
1105
1288
  const subqueryColumnCount = getSubqueryColumnCount(expr.subquery);
1106
1289
  if (subqueryColumnCount !== 1) {
1107
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
1290
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
1108
1291
  `IN/NOT IN subquery must project exactly 1 column, but got ${subqueryColumnCount}`,
1109
1292
  { subqueryColumnCount }
1110
1293
  );
@@ -1113,13 +1296,13 @@ function compileInSubquery(expr, ctx) {
1113
1296
  const subqueryValueType = getSingleSubqueryColumnValueType(expr.subquery);
1114
1297
  const resolvedValueType = fieldValueType ?? subqueryValueType;
1115
1298
  if (isUnsupportedInSubqueryValueType(resolvedValueType)) {
1116
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
1299
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
1117
1300
  `IN/NOT IN subquery does not support ${String(resolvedValueType)} values`,
1118
1301
  { valueType: resolvedValueType }
1119
1302
  );
1120
1303
  }
1121
1304
  if (!isInSubqueryTypeCompatible(fieldValueType, subqueryValueType)) {
1122
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
1305
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
1123
1306
  `IN/NOT IN type mismatch: field type "${String(fieldValueType)}" does not match subquery column type "${String(subqueryValueType)}"`,
1124
1307
  {
1125
1308
  fieldValueType,
@@ -1129,7 +1312,7 @@ function compileInSubquery(expr, ctx) {
1129
1312
  }
1130
1313
  const valueType = fieldValueType ?? subqueryValueType;
1131
1314
  if (expr.subquery.graphId === void 0) {
1132
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
1315
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
1133
1316
  "IN/NOT IN subquery must have a graphId"
1134
1317
  );
1135
1318
  }
@@ -1149,7 +1332,7 @@ function extractStructuralPredicates(predicates, isMatch, rejectionMessage) {
1149
1332
  function visit(expr, inDisallowedBranch) {
1150
1333
  if (isMatch(expr)) {
1151
1334
  if (inDisallowedBranch) {
1152
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(rejectionMessage);
1335
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(rejectionMessage);
1153
1336
  }
1154
1337
  results.push(expr);
1155
1338
  return;
@@ -1255,7 +1438,7 @@ function getNodeKindsForAlias(ast, alias) {
1255
1438
  return traversal.nodeKinds;
1256
1439
  }
1257
1440
  }
1258
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(`Unknown traversal source alias: ${alias}`);
1441
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(`Unknown traversal source alias: ${alias}`);
1259
1442
  }
1260
1443
  function getHybridTargetAlias(vectorPredicate, fulltextPredicate) {
1261
1444
  if (!vectorPredicate || !fulltextPredicate) return void 0;
@@ -1316,7 +1499,7 @@ function findUnaryNodeInProjectChain(rootNode, op) {
1316
1499
  }
1317
1500
  function inspectProjectPlan(logicalPlan) {
1318
1501
  if (logicalPlan.root.op !== "project") {
1319
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1502
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1320
1503
  `SQL emitter expected logical plan root to be "project", got "${logicalPlan.root.op}"`,
1321
1504
  { component: "plan-inspector" }
1322
1505
  );
@@ -1347,13 +1530,13 @@ function inspectProjectPlan(logicalPlan) {
1347
1530
  function inspectStandardProjectPlan(logicalPlan) {
1348
1531
  const shape = inspectProjectPlan(logicalPlan);
1349
1532
  if (shape.hasSetOperation) {
1350
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1533
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1351
1534
  'Standard SQL emitter does not support plans containing "set_op" nodes',
1352
1535
  { component: "plan-inspector" }
1353
1536
  );
1354
1537
  }
1355
1538
  if (shape.hasRecursiveExpand) {
1356
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1539
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1357
1540
  'Standard SQL emitter does not support plans containing "recursive_expand" nodes',
1358
1541
  { component: "plan-inspector" }
1359
1542
  );
@@ -1363,13 +1546,13 @@ function inspectStandardProjectPlan(logicalPlan) {
1363
1546
  function inspectRecursiveProjectPlan(logicalPlan) {
1364
1547
  const shape = inspectProjectPlan(logicalPlan);
1365
1548
  if (!shape.hasRecursiveExpand) {
1366
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1549
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1367
1550
  'Recursive SQL emitter expected logical plan to contain a "recursive_expand" node',
1368
1551
  { component: "plan-inspector" }
1369
1552
  );
1370
1553
  }
1371
1554
  if (shape.hasSetOperation) {
1372
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1555
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1373
1556
  'Recursive SQL emitter does not support plans containing "set_op" nodes',
1374
1557
  { component: "plan-inspector" }
1375
1558
  );
@@ -1430,7 +1613,7 @@ function inspectSetOperationPlan(logicalPlan) {
1430
1613
  const operations = /* @__PURE__ */ new Set();
1431
1614
  collectPlanOperations(logicalPlan.root, operations);
1432
1615
  if (!operations.has("set_op")) {
1433
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1616
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1434
1617
  'Set-operation SQL emitter expected logical plan to contain a "set_op" node',
1435
1618
  { component: "plan-inspector" }
1436
1619
  );
@@ -1448,25 +1631,25 @@ function inspectSetOperationPlan(logicalPlan) {
1448
1631
  function assertRecursiveEmitterClauseAlignment(logicalPlan, input) {
1449
1632
  const planShape = inspectRecursiveProjectPlan(logicalPlan);
1450
1633
  if (planShape.hasSort && input.orderBy === void 0) {
1451
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1634
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1452
1635
  "Recursive SQL emitter expected ORDER BY clause for plan containing a sort node",
1453
1636
  { component: "recursive-emitter" }
1454
1637
  );
1455
1638
  }
1456
1639
  if (!planShape.hasSort && input.orderBy !== void 0) {
1457
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1640
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1458
1641
  "Recursive SQL emitter received ORDER BY clause for a plan without sort nodes",
1459
1642
  { component: "recursive-emitter" }
1460
1643
  );
1461
1644
  }
1462
1645
  if (planShape.hasLimitOffset && input.limitOffset === void 0) {
1463
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1646
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1464
1647
  "Recursive SQL emitter expected LIMIT/OFFSET clause for plan containing a limit_offset node",
1465
1648
  { component: "recursive-emitter" }
1466
1649
  );
1467
1650
  }
1468
1651
  if (!planShape.hasLimitOffset && input.limitOffset !== void 0) {
1469
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1652
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1470
1653
  "Recursive SQL emitter received LIMIT/OFFSET clause for a plan without limit_offset nodes",
1471
1654
  { component: "recursive-emitter" }
1472
1655
  );
@@ -1493,14 +1676,14 @@ function assertSetOperationEmitterClauseAlignment(logicalPlan, suffixClauses) {
1493
1676
  const shape = inspectSetOperationPlan(logicalPlan);
1494
1677
  const hasSuffixClauses = suffixClauses !== void 0 && suffixClauses.length > 0;
1495
1678
  if (!shape.hasSort && !shape.hasLimitOffset && hasSuffixClauses) {
1496
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1679
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1497
1680
  "Set-operation SQL emitter received suffix clauses for a plan without top-level sort or limit_offset nodes",
1498
1681
  { component: "set-operation-emitter" }
1499
1682
  );
1500
1683
  }
1501
1684
  if (!hasSuffixClauses) {
1502
1685
  if (shape.hasSort || shape.hasLimitOffset) {
1503
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1686
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1504
1687
  "Set-operation SQL emitter expected suffix clauses for plan containing top-level sort or limit_offset nodes",
1505
1688
  { component: "set-operation-emitter" }
1506
1689
  );
@@ -1510,7 +1693,7 @@ function assertSetOperationEmitterClauseAlignment(logicalPlan, suffixClauses) {
1510
1693
  const limitOffsetClauseCount = shape.limitOffsetNode === void 0 ? 0 : (shape.limitOffsetNode.limit === void 0 ? 0 : 1) + (shape.limitOffsetNode.offset === void 0 ? 0 : 1);
1511
1694
  const expectedClauseCount = (shape.sortNode === void 0 ? 0 : 1) + limitOffsetClauseCount;
1512
1695
  if (suffixClauses.length !== expectedClauseCount) {
1513
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1696
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1514
1697
  `Set-operation SQL emitter expected ${String(expectedClauseCount)} top-level suffix clause(s) from logical plan, got ${String(suffixClauses.length)}`,
1515
1698
  { component: "set-operation-emitter" }
1516
1699
  );
@@ -1534,38 +1717,38 @@ function emitSetOperationQuerySql(input) {
1534
1717
  function assertStandardEmitterClauseAlignment(logicalPlan, input) {
1535
1718
  const planShape = inspectStandardProjectPlan(logicalPlan);
1536
1719
  if (input.groupBy !== void 0 && !planShape.hasAggregate) {
1537
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1720
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1538
1721
  "Standard SQL emitter received GROUP BY clause for a plan without aggregate nodes",
1539
1722
  { component: "standard-emitter" }
1540
1723
  );
1541
1724
  }
1542
1725
  if (input.having !== void 0 && !planShape.hasAggregate) {
1543
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1726
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1544
1727
  "Standard SQL emitter received HAVING clause for a plan without aggregate nodes",
1545
1728
  { component: "standard-emitter" }
1546
1729
  );
1547
1730
  }
1548
1731
  const expectsOrderBy = planShape.hasSort || planShape.hasVectorKnn || planShape.hasFulltextMatch;
1549
1732
  if (expectsOrderBy && input.orderBy === void 0) {
1550
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1733
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1551
1734
  "Standard SQL emitter expected ORDER BY clause for plan containing a sort, vector_knn, or fulltext_match node",
1552
1735
  { component: "standard-emitter" }
1553
1736
  );
1554
1737
  }
1555
1738
  if (!expectsOrderBy && input.orderBy !== void 0) {
1556
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1739
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1557
1740
  "Standard SQL emitter received ORDER BY clause for a plan without sort, vector_knn, or fulltext_match nodes",
1558
1741
  { component: "standard-emitter" }
1559
1742
  );
1560
1743
  }
1561
1744
  if (planShape.hasLimitOffset && input.limitOffset === void 0) {
1562
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1745
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1563
1746
  "Standard SQL emitter expected LIMIT/OFFSET clause for plan containing a limit_offset node",
1564
1747
  { component: "standard-emitter" }
1565
1748
  );
1566
1749
  }
1567
1750
  if (!planShape.hasLimitOffset && input.limitOffset !== void 0) {
1568
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
1751
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
1569
1752
  "Standard SQL emitter received LIMIT/OFFSET clause for a plan without limit_offset nodes",
1570
1753
  { component: "standard-emitter" }
1571
1754
  );
@@ -1607,22 +1790,21 @@ function mergeEdgeKinds(traversal) {
1607
1790
  var DEFAULT_TABLE_NAMES = {
1608
1791
  nodes: "typegraph_nodes",
1609
1792
  edges: "typegraph_edges",
1610
- embeddings: "typegraph_node_embeddings",
1611
1793
  fulltext: "typegraph_node_fulltext",
1612
1794
  uniques: "typegraph_node_uniques"
1613
1795
  };
1614
1796
  var VALID_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/i;
1615
1797
  function validateTableName(name, label) {
1616
1798
  if (!name || name.length === 0) {
1617
- throw new chunkYEDQLNVE_cjs.ConfigurationError(`${label} table name cannot be empty`);
1799
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(`${label} table name cannot be empty`);
1618
1800
  }
1619
- if (name.length > chunkCTHNVU6K_cjs.MAX_PG_IDENTIFIER_LENGTH) {
1620
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
1621
- `${label} table name exceeds maximum length of ${chunkCTHNVU6K_cjs.MAX_PG_IDENTIFIER_LENGTH} characters`
1801
+ if (name.length > chunkUPBXUOW7_cjs.MAX_PG_IDENTIFIER_LENGTH) {
1802
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
1803
+ `${label} table name exceeds maximum length of ${chunkUPBXUOW7_cjs.MAX_PG_IDENTIFIER_LENGTH} characters`
1622
1804
  );
1623
1805
  }
1624
1806
  if (!VALID_IDENTIFIER_PATTERN.test(name)) {
1625
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
1807
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
1626
1808
  `${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.`
1627
1809
  );
1628
1810
  }
@@ -1634,18 +1816,19 @@ function createSqlSchema(names = {}) {
1634
1816
  const tables = { ...DEFAULT_TABLE_NAMES, ...names };
1635
1817
  validateTableName(tables.nodes, "nodes");
1636
1818
  validateTableName(tables.edges, "edges");
1637
- validateTableName(tables.embeddings, "embeddings");
1638
1819
  validateTableName(tables.fulltext, "fulltext");
1639
1820
  validateTableName(tables.uniques, "uniques");
1640
1821
  return {
1641
1822
  tables,
1642
1823
  nodesTable: drizzleOrm.sql.raw(quoteIdentifier2(tables.nodes)),
1643
1824
  edgesTable: drizzleOrm.sql.raw(quoteIdentifier2(tables.edges)),
1644
- embeddingsTable: drizzleOrm.sql.raw(quoteIdentifier2(tables.embeddings)),
1645
1825
  fulltextTable: drizzleOrm.sql.raw(quoteIdentifier2(tables.fulltext))
1646
1826
  };
1647
1827
  }
1648
1828
  var DEFAULT_SQL_SCHEMA = createSqlSchema();
1829
+ function vectorSlotKey(nodeKind, fieldPath) {
1830
+ return `${nodeKind}\0${fieldPath}`;
1831
+ }
1649
1832
  var ALIAS_CTE_PREFIX = "cte_";
1650
1833
  var EMBEDDINGS_CTE_ALIAS = "cte_embeddings";
1651
1834
  var FULLTEXT_CTE_ALIAS = "cte_fulltext";
@@ -1689,7 +1872,7 @@ function compileColumnReference(tableAlias, column) {
1689
1872
  return drizzleOrm.sql`${drizzleOrm.sql.raw(tableAlias)}.${drizzleOrm.sql.raw(column)}`;
1690
1873
  }
1691
1874
  function qualifyColumn(owner, name) {
1692
- return drizzleOrm.sql`${chunkHTGDWIDE_cjs.quoteIdentifier(owner)}.${chunkHTGDWIDE_cjs.quoteIdentifier(name)}`;
1875
+ return drizzleOrm.sql`${chunkKGAJ5HFO_cjs.quoteIdentifier(owner)}.${chunkKGAJ5HFO_cjs.quoteIdentifier(name)}`;
1693
1876
  }
1694
1877
  var SCOPED_RELEVANCE_NODES_ALIAS = "scoped_relevance_nodes";
1695
1878
  function buildScopedNodeIdsSubquery(nodeAlias) {
@@ -1699,20 +1882,20 @@ function buildScopedNodeIdsSubquery(nodeAlias) {
1699
1882
  SELECT DISTINCT
1700
1883
  ${qualifyColumn(cteAlias, `${nodeAlias}_id`)} AS node_id,
1701
1884
  ${qualifyColumn(cteAlias, `${nodeAlias}_kind`)} AS node_kind
1702
- FROM ${chunkHTGDWIDE_cjs.quoteIdentifier(cteAlias)}
1885
+ FROM ${chunkKGAJ5HFO_cjs.quoteIdentifier(cteAlias)}
1703
1886
  ) AS ${drizzleOrm.sql.raw(SCOPED_RELEVANCE_NODES_ALIAS)}
1704
1887
  `;
1705
1888
  }
1706
1889
  function compileNodeSelectColumns(tableAlias, alias, requiredColumns) {
1707
- return chunkHTGDWIDE_cjs.NODE_COLUMNS.filter(
1708
- (column) => column === "id" || column === "kind" || chunkHTGDWIDE_cjs.shouldProjectColumn(requiredColumns, column)
1890
+ return chunkKGAJ5HFO_cjs.NODE_COLUMNS.filter(
1891
+ (column) => column === "id" || column === "kind" || chunkKGAJ5HFO_cjs.shouldProjectColumn(requiredColumns, column)
1709
1892
  ).map(
1710
1893
  (column) => drizzleOrm.sql`${compileColumnReference(tableAlias, column)} AS ${drizzleOrm.sql.raw(`${alias}_${column}`)}`
1711
1894
  );
1712
1895
  }
1713
1896
  function compileEdgeSelectColumns(tableAlias, alias, requiredColumns) {
1714
- return chunkHTGDWIDE_cjs.EDGE_COLUMNS.filter(
1715
- (column) => chunkHTGDWIDE_cjs.shouldProjectColumn(requiredColumns, column)
1897
+ return chunkKGAJ5HFO_cjs.EDGE_COLUMNS.filter(
1898
+ (column) => chunkKGAJ5HFO_cjs.shouldProjectColumn(requiredColumns, column)
1716
1899
  ).map(
1717
1900
  (column) => drizzleOrm.sql`${compileColumnReference(tableAlias, column)} AS ${drizzleOrm.sql.raw(`${alias}_${column}`)}`
1718
1901
  );
@@ -1735,7 +1918,7 @@ function buildStandardStartCte(input) {
1735
1918
  temporalFilter,
1736
1919
  ...predicateClauses
1737
1920
  ];
1738
- const effectiveRequiredColumns = requiredColumnsByAlias ? requiredColumnsByAlias.get(alias) ?? chunkHTGDWIDE_cjs.EMPTY_REQUIRED_COLUMNS : void 0;
1921
+ const effectiveRequiredColumns = requiredColumnsByAlias ? requiredColumnsByAlias.get(alias) ?? chunkKGAJ5HFO_cjs.EMPTY_REQUIRED_COLUMNS : void 0;
1739
1922
  const limitClause = input.limitOffset === void 0 ? drizzleOrm.sql`` : input.limitOffset.offset === void 0 ? drizzleOrm.sql`
1740
1923
  LIMIT ${input.limitOffset.limit}
1741
1924
  ` : drizzleOrm.sql`
@@ -1801,8 +1984,8 @@ function buildStandardTraversalCte(input) {
1801
1984
  const previousAlias = traversal.joinFromAlias;
1802
1985
  const edgeAlias = traversal.edgeAlias;
1803
1986
  const nodeAlias = traversal.nodeAlias;
1804
- const requiredNodeColumns = requiredColumnsByAlias ? requiredColumnsByAlias.get(nodeAlias) ?? chunkHTGDWIDE_cjs.EMPTY_REQUIRED_COLUMNS : void 0;
1805
- const requiredEdgeColumns = requiredColumnsByAlias ? requiredColumnsByAlias.get(edgeAlias) ?? chunkHTGDWIDE_cjs.EMPTY_REQUIRED_COLUMNS : void 0;
1987
+ const requiredNodeColumns = requiredColumnsByAlias ? requiredColumnsByAlias.get(nodeAlias) ?? chunkKGAJ5HFO_cjs.EMPTY_REQUIRED_COLUMNS : void 0;
1988
+ const requiredEdgeColumns = requiredColumnsByAlias ? requiredColumnsByAlias.get(edgeAlias) ?? chunkKGAJ5HFO_cjs.EMPTY_REQUIRED_COLUMNS : void 0;
1806
1989
  const previousRowColumns = carryForwardPreviousColumns ? [drizzleOrm.sql`cte_${drizzleOrm.sql.raw(previousAlias)}.*`] : [
1807
1990
  drizzleOrm.sql`cte_${drizzleOrm.sql.raw(previousAlias)}.${drizzleOrm.sql.raw(previousAlias)}_id AS ${drizzleOrm.sql.raw(previousAlias)}_id`,
1808
1991
  drizzleOrm.sql`cte_${drizzleOrm.sql.raw(previousAlias)}.${drizzleOrm.sql.raw(previousAlias)}_kind AS ${drizzleOrm.sql.raw(previousAlias)}_kind`
@@ -1927,14 +2110,14 @@ function compileAggregateExprFromSource(expr, dialect) {
1927
2110
  return drizzleOrm.sql`${drizzleOrm.sql.raw(fn.toUpperCase())}(${column})`;
1928
2111
  }
1929
2112
  default: {
1930
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2113
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
1931
2114
  `Unknown aggregate function: ${String(fn)}`
1932
2115
  );
1933
2116
  }
1934
2117
  }
1935
2118
  }
1936
2119
  function compileProjectedSource(field2, dialect) {
1937
- if (chunkHTGDWIDE_cjs.isAggregateExpr(field2.source)) {
2120
+ if (chunkKGAJ5HFO_cjs.isAggregateExpr(field2.source)) {
1938
2121
  return compileAggregateExprFromSource(field2.source, dialect);
1939
2122
  }
1940
2123
  const cteAlias = field2.cteAlias ?? `cte_${field2.source.alias}`;
@@ -1961,7 +2144,7 @@ function buildStandardProjection(input) {
1961
2144
  }
1962
2145
  const projectedFields = fields.map((field2) => {
1963
2146
  const source = compileProjectedSource(field2, dialect);
1964
- return drizzleOrm.sql`${source} AS ${chunkHTGDWIDE_cjs.quoteIdentifier(field2.outputName)}`;
2147
+ return drizzleOrm.sql`${source} AS ${chunkKGAJ5HFO_cjs.quoteIdentifier(field2.outputName)}`;
1965
2148
  });
1966
2149
  return drizzleOrm.sql.join(projectedFields, drizzleOrm.sql`, `);
1967
2150
  }
@@ -1980,8 +2163,8 @@ function compileSelectiveProjection(fields, dialect, ast, collapsedTraversalCteA
1980
2163
  const columns = fields.map((field2) => {
1981
2164
  const cteAlias = collapsedTraversalCteAlias ?? aliasToCte.get(field2.alias) ?? `cte_${field2.alias}`;
1982
2165
  if (field2.isSystemField) {
1983
- const dbColumn = chunkHTGDWIDE_cjs.mapSelectiveSystemFieldToColumn(field2.field);
1984
- return drizzleOrm.sql`${drizzleOrm.sql.raw(cteAlias)}.${drizzleOrm.sql.raw(`${field2.alias}_${dbColumn}`)} AS ${chunkHTGDWIDE_cjs.quoteIdentifier(field2.outputName)}`;
2166
+ const dbColumn = chunkKGAJ5HFO_cjs.mapSelectiveSystemFieldToColumn(field2.field);
2167
+ return drizzleOrm.sql`${drizzleOrm.sql.raw(cteAlias)}.${drizzleOrm.sql.raw(`${field2.alias}_${dbColumn}`)} AS ${chunkKGAJ5HFO_cjs.quoteIdentifier(field2.outputName)}`;
1985
2168
  }
1986
2169
  const propsColumn = `${field2.alias}_props`;
1987
2170
  const column = drizzleOrm.sql`${drizzleOrm.sql.raw(cteAlias)}.${drizzleOrm.sql.raw(propsColumn)}`;
@@ -1992,7 +2175,7 @@ function compileSelectiveProjection(fields, dialect, ast, collapsedTraversalCteA
1992
2175
  pointer,
1993
2176
  valueType: field2.valueType
1994
2177
  });
1995
- return drizzleOrm.sql`${extracted} AS ${chunkHTGDWIDE_cjs.quoteIdentifier(field2.outputName)}`;
2178
+ return drizzleOrm.sql`${extracted} AS ${chunkKGAJ5HFO_cjs.quoteIdentifier(field2.outputName)}`;
1996
2179
  });
1997
2180
  return drizzleOrm.sql.join(columns, drizzleOrm.sql`, `);
1998
2181
  }
@@ -2071,7 +2254,7 @@ function buildStandardOrderBy(input) {
2071
2254
  for (const orderSpec of ast.orderBy) {
2072
2255
  const valueType = orderSpec.field.valueType;
2073
2256
  if (valueType === "array" || valueType === "object") {
2074
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2257
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2075
2258
  "Ordering by JSON arrays or objects is not supported"
2076
2259
  );
2077
2260
  }
@@ -2152,35 +2335,61 @@ function buildStandardHaving(input) {
2152
2335
  }
2153
2336
  function buildStandardEmbeddingsCte(input) {
2154
2337
  const { ctx, graphId, nodeKinds, vectorPredicate } = input;
2155
- const { dialect } = ctx;
2156
2338
  const { field: field2, metric, minScore, queryEmbedding } = vectorPredicate;
2157
- const embeddingsTableName = ctx.schema.tables.embeddings;
2158
2339
  if (nodeKinds.length === 0) {
2159
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2340
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2160
2341
  "Vector predicate must resolve to at least one node kind"
2161
2342
  );
2162
2343
  }
2163
- const fieldPath = resolveEmbeddingFieldPath(field2);
2164
- const distanceExpr = dialect.vectorDistance(
2165
- qualifyColumn(embeddingsTableName, "embedding"),
2166
- queryEmbedding,
2167
- metric
2168
- );
2169
- const scopedNodes = buildScopedNodeIdsSubquery(field2.alias);
2170
- const conditions = [
2171
- drizzleOrm.sql`${qualifyColumn(embeddingsTableName, "graph_id")} = ${graphId}`,
2172
- compileKindFilter(
2173
- qualifyColumn(embeddingsTableName, "node_kind"),
2174
- nodeKinds
2175
- ),
2176
- drizzleOrm.sql`${qualifyColumn(embeddingsTableName, "field_path")} = ${fieldPath}`
2177
- ];
2178
- if (minScore !== void 0) {
2179
- conditions.push(
2180
- compileVectorMinScoreCondition(distanceExpr, metric, minScore)
2344
+ const { vectorStrategy } = ctx;
2345
+ if (vectorStrategy === void 0) {
2346
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2347
+ "Vector similarity predicate requires a backend with a vector strategy"
2181
2348
  );
2182
2349
  }
2183
- const scoreExpr = compileVectorScoreExpression(distanceExpr, metric);
2350
+ const fieldPath = resolveEmbeddingFieldPath(field2);
2351
+ const vectorSlots = ctx.vectorSlots;
2352
+ const scopedNodes = buildScopedNodeIdsSubquery(field2.alias);
2353
+ const declaringKinds = nodeKinds.filter(
2354
+ (kind) => vectorSlots?.has(vectorSlotKey(kind, fieldPath))
2355
+ );
2356
+ const branches = declaringKinds.map((kind) => {
2357
+ const tableName = vectorStrategy.tableName(graphId, kind, fieldPath);
2358
+ const branchMetric = metric ?? vectorSlots?.get(vectorSlotKey(kind, fieldPath))?.metric ?? "cosine";
2359
+ const distanceExpr = vectorStrategy.distanceExpression(
2360
+ qualifyColumn(tableName, "embedding"),
2361
+ queryEmbedding,
2362
+ branchMetric
2363
+ );
2364
+ const scoreExpr = chunkC2RWFIYP_cjs.vectorScoreExpression(distanceExpr, branchMetric);
2365
+ const conditions = [
2366
+ drizzleOrm.sql`${qualifyColumn(tableName, "graph_id")} = ${graphId}`
2367
+ ];
2368
+ if (minScore !== void 0) {
2369
+ conditions.push(
2370
+ chunkC2RWFIYP_cjs.vectorMinScoreCondition(distanceExpr, branchMetric, minScore)
2371
+ );
2372
+ }
2373
+ return drizzleOrm.sql`
2374
+ SELECT
2375
+ ${qualifyColumn(tableName, "node_id")} AS node_id,
2376
+ ${kind} AS node_kind,
2377
+ ${distanceExpr} AS distance,
2378
+ ${scoreExpr} AS score
2379
+ FROM ${chunkKGAJ5HFO_cjs.quoteIdentifier(tableName)}
2380
+ INNER JOIN ${scopedNodes}
2381
+ ON ${drizzleOrm.sql.raw(`${SCOPED_RELEVANCE_NODES_ALIAS}.node_id`)} =
2382
+ ${qualifyColumn(tableName, "node_id")}
2383
+ AND ${drizzleOrm.sql.raw(`${SCOPED_RELEVANCE_NODES_ALIAS}.node_kind`)} = ${kind}
2384
+ WHERE ${drizzleOrm.sql.join(conditions, drizzleOrm.sql` AND `)}
2385
+ `;
2386
+ });
2387
+ const unionBody = branches.length === 0 ? emptyEmbeddingsBody() : drizzleOrm.sql.join(
2388
+ branches,
2389
+ drizzleOrm.sql`
2390
+ UNION ALL
2391
+ `
2392
+ );
2184
2393
  return drizzleOrm.sql`
2185
2394
  ${drizzleOrm.sql.raw(EMBEDDINGS_CTE_ALIAS)} AS (
2186
2395
  SELECT
@@ -2190,56 +2399,29 @@ function buildStandardEmbeddingsCte(input) {
2190
2399
  score,
2191
2400
  ROW_NUMBER() OVER (ORDER BY distance ASC) AS ord
2192
2401
  FROM (
2193
- SELECT
2194
- ${qualifyColumn(embeddingsTableName, "node_id")} AS node_id,
2195
- ${qualifyColumn(embeddingsTableName, "node_kind")} AS node_kind,
2196
- ${distanceExpr} AS distance,
2197
- ${scoreExpr} AS score
2198
- FROM ${ctx.schema.embeddingsTable}
2199
- INNER JOIN ${scopedNodes}
2200
- ON ${drizzleOrm.sql.raw(`${SCOPED_RELEVANCE_NODES_ALIAS}.node_id`)} =
2201
- ${qualifyColumn(embeddingsTableName, "node_id")}
2202
- AND ${drizzleOrm.sql.raw(`${SCOPED_RELEVANCE_NODES_ALIAS}.node_kind`)} =
2203
- ${qualifyColumn(embeddingsTableName, "node_kind")}
2204
- WHERE ${drizzleOrm.sql.join(conditions, drizzleOrm.sql` AND `)}
2402
+ ${unionBody}
2205
2403
  ORDER BY distance ASC
2206
2404
  LIMIT ${vectorPredicate.limit}
2207
2405
  ) AS vec_inner
2208
2406
  )
2209
2407
  `;
2210
2408
  }
2211
- function compileVectorScoreExpression(distanceExpr, metric) {
2212
- switch (metric) {
2213
- case "cosine": {
2214
- return drizzleOrm.sql`(1.0 - ${distanceExpr})`;
2215
- }
2216
- case "l2":
2217
- case "inner_product": {
2218
- return distanceExpr;
2219
- }
2220
- }
2221
- }
2222
- function compileVectorMinScoreCondition(distanceExpr, metric, minScore) {
2223
- switch (metric) {
2224
- case "cosine": {
2225
- const threshold = 1 - minScore;
2226
- return drizzleOrm.sql`${distanceExpr} <= ${threshold}`;
2227
- }
2228
- case "l2": {
2229
- return drizzleOrm.sql`${distanceExpr} <= ${minScore}`;
2230
- }
2231
- case "inner_product": {
2232
- const negativeThreshold = -minScore;
2233
- return drizzleOrm.sql`${distanceExpr} <= ${negativeThreshold}`;
2234
- }
2235
- }
2409
+ function emptyEmbeddingsBody() {
2410
+ return drizzleOrm.sql`
2411
+ SELECT
2412
+ CAST(NULL AS TEXT) AS node_id,
2413
+ CAST(NULL AS TEXT) AS node_kind,
2414
+ CAST(NULL AS REAL) AS distance,
2415
+ CAST(NULL AS REAL) AS score
2416
+ WHERE 1 = 0
2417
+ `;
2236
2418
  }
2237
2419
  function buildStandardFulltextCte(input) {
2238
2420
  const { ctx, fulltextPredicate, graphId, nodeKinds } = input;
2239
2421
  const { dialect, schema } = ctx;
2240
2422
  const { query, mode, language, limit, minScore } = fulltextPredicate;
2241
2423
  if (nodeKinds.length === 0) {
2242
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2424
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2243
2425
  "Fulltext predicate must resolve to at least one node kind"
2244
2426
  );
2245
2427
  }
@@ -2247,7 +2429,7 @@ function buildStandardFulltextCte(input) {
2247
2429
  const scopedNodes = buildScopedNodeIdsSubquery(fulltextPredicate.field.alias);
2248
2430
  const fulltextStrategy = dialect.fulltext;
2249
2431
  if (fulltextStrategy === void 0) {
2250
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2432
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2251
2433
  `Fulltext match predicates are not supported for dialect "${dialect.name}"`
2252
2434
  );
2253
2435
  }
@@ -2312,7 +2494,7 @@ function compileUserOrderBy(ast, dialect) {
2312
2494
  for (const orderSpec of ast.orderBy) {
2313
2495
  const valueType = orderSpec.field.valueType;
2314
2496
  if (valueType === "array" || valueType === "object") {
2315
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2497
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2316
2498
  "Ordering by JSON arrays or objects is not supported"
2317
2499
  );
2318
2500
  }
@@ -2375,7 +2557,7 @@ function buildLimitOffsetClause(input) {
2375
2557
  function runFulltextPredicatePass(ast, dialect) {
2376
2558
  const fulltextPredicates = extractFulltextMatchPredicates(ast.predicates);
2377
2559
  if (fulltextPredicates.length > 1) {
2378
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2560
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2379
2561
  "Multiple fulltext match predicates in a single query are not supported"
2380
2562
  );
2381
2563
  }
@@ -2384,29 +2566,34 @@ function runFulltextPredicatePass(ast, dialect) {
2384
2566
  return { fulltextPredicate: void 0 };
2385
2567
  }
2386
2568
  if (!dialect.capabilities.supportsFulltext) {
2387
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2569
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2388
2570
  `Fulltext match predicates are not supported for dialect "${dialect.name}"`
2389
2571
  );
2390
2572
  }
2391
2573
  const strategy = dialect.fulltext;
2392
2574
  if (strategy === void 0) {
2393
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2575
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2394
2576
  `Dialect "${dialect.name}" advertises fulltext support but has no strategy configured`
2395
2577
  );
2396
2578
  }
2397
2579
  if (!strategy.supportedModes.includes(fulltextPredicate.mode)) {
2398
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2580
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2399
2581
  `Fulltext query mode "${fulltextPredicate.mode}" is not supported by the "${strategy.name}" strategy. Supported modes: ${strategy.supportedModes.join(", ")}.`
2400
2582
  );
2401
2583
  }
2584
+ if (fulltextPredicate.language !== void 0 && !strategy.supportsLanguageOverride) {
2585
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2586
+ `Fulltext strategy "${strategy.name}" does not honor a per-query \`language\` override (its tokenizer is fixed at table-create time). Drop the option, or use a strategy that advertises \`supportsLanguageOverride: true\`.`
2587
+ );
2588
+ }
2402
2589
  if (!Number.isFinite(fulltextPredicate.limit) || fulltextPredicate.limit <= 0) {
2403
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2590
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2404
2591
  `Fulltext match limit must be a positive finite number, got ${String(fulltextPredicate.limit)}`
2405
2592
  );
2406
2593
  }
2407
2594
  const { minScore } = fulltextPredicate;
2408
2595
  if (minScore !== void 0 && !Number.isFinite(minScore)) {
2409
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2596
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2410
2597
  `Fulltext minScore must be a finite number, got ${String(minScore)}`
2411
2598
  );
2412
2599
  }
@@ -2427,12 +2614,12 @@ function runFusionConfigPass(ast, vectorPredicate, fulltextPredicate) {
2427
2614
  const fusion = ast.fusion;
2428
2615
  if (fusion === void 0) return { fusion: void 0 };
2429
2616
  if (vectorPredicate === void 0 || fulltextPredicate === void 0) {
2430
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2617
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2431
2618
  `.fuseWith() requires both a .similarTo() and a .$fulltext.matches() predicate in the same query. Remove .fuseWith(), or add the missing predicate.`
2432
2619
  );
2433
2620
  }
2434
2621
  if (vectorPredicate.field.alias !== fulltextPredicate.field.alias) {
2435
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2622
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2436
2623
  `.fuseWith() requires .similarTo() and .$fulltext.matches() to target the same node alias. Got vector=${vectorPredicate.field.alias}, fulltext=${fulltextPredicate.field.alias}.`
2437
2624
  );
2438
2625
  }
@@ -2445,10 +2632,10 @@ function runRecursiveTraversalSelectionPass(ast) {
2445
2632
  (traversal) => traversal.variableLength !== void 0
2446
2633
  );
2447
2634
  if (variableLengthTraversal === void 0) {
2448
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError("No variable-length traversal found");
2635
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError("No variable-length traversal found");
2449
2636
  }
2450
2637
  if (ast.traversals.length > 1) {
2451
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2638
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2452
2639
  "Variable-length traversals with multiple traversals are not yet supported. Please use a single variable-length traversal."
2453
2640
  );
2454
2641
  }
@@ -2509,10 +2696,10 @@ function createTemporalFilterPass(ast, currentTimestamp) {
2509
2696
  }
2510
2697
 
2511
2698
  // src/query/compiler/passes/vector.ts
2512
- function runVectorPredicatePass(ast, dialect) {
2699
+ function runVectorPredicatePass(ast, dialect, vectorStrategy) {
2513
2700
  const vectorPredicates = extractVectorSimilarityPredicates(ast.predicates);
2514
2701
  if (vectorPredicates.length > 1) {
2515
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2702
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2516
2703
  "Multiple vector similarity predicates in a single query are not supported"
2517
2704
  );
2518
2705
  }
@@ -2520,31 +2707,34 @@ function runVectorPredicatePass(ast, dialect) {
2520
2707
  if (vectorPredicate === void 0) {
2521
2708
  return { vectorPredicate: void 0 };
2522
2709
  }
2523
- const vectorStrategy = dialect.capabilities.vectorPredicateStrategy;
2524
- if (vectorStrategy === "unsupported" || !dialect.supportsVectors) {
2525
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2710
+ const predicateStrategy = dialect.capabilities.vectorPredicateStrategy;
2711
+ if (predicateStrategy === "unsupported" || !dialect.supportsVectors) {
2712
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2526
2713
  `Vector similarity predicates are not supported for dialect "${dialect.name}"`
2527
2714
  );
2528
2715
  }
2529
- if (!dialect.capabilities.vectorMetrics.includes(vectorPredicate.metric)) {
2530
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2531
- `Vector metric "${vectorPredicate.metric}" is not supported for dialect "${dialect.name}"`
2532
- );
2716
+ if (vectorPredicate.metric !== void 0) {
2717
+ const supportedMetrics = vectorStrategy?.capabilities.metrics ?? dialect.capabilities.vectorMetrics;
2718
+ if (!supportedMetrics.includes(vectorPredicate.metric)) {
2719
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2720
+ vectorStrategy === void 0 ? `Vector metric "${vectorPredicate.metric}" is not supported for dialect "${dialect.name}"` : `Vector metric "${vectorPredicate.metric}" is not supported by vector strategy "${vectorStrategy.name}" (supported: ${supportedMetrics.join(", ")})`
2721
+ );
2722
+ }
2533
2723
  }
2534
2724
  if (!Number.isFinite(vectorPredicate.limit) || vectorPredicate.limit <= 0) {
2535
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2725
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2536
2726
  `Vector predicate limit must be a positive finite number, got ${String(vectorPredicate.limit)}`
2537
2727
  );
2538
2728
  }
2539
2729
  const { minScore } = vectorPredicate;
2540
2730
  if (minScore !== void 0) {
2541
2731
  if (!Number.isFinite(minScore)) {
2542
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2732
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2543
2733
  `Vector minScore must be a finite number, got ${String(minScore)}`
2544
2734
  );
2545
2735
  }
2546
2736
  if (vectorPredicate.metric === "cosine" && (minScore < -1 || minScore > 1)) {
2547
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
2737
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
2548
2738
  `Cosine minScore must be between -1 and 1, got ${String(minScore)}`
2549
2739
  );
2550
2740
  }
@@ -2638,7 +2828,7 @@ function appendAggregateSortLimitAndProjectNodes(currentNode, ast, nextPlanNodeI
2638
2828
  } else if (hasOffset) {
2639
2829
  node = { ...limitOffsetNodeBase, offset: ast.offset };
2640
2830
  } else {
2641
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
2831
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
2642
2832
  "limit_offset node requires limit or offset to be present"
2643
2833
  );
2644
2834
  }
@@ -2774,13 +2964,14 @@ function lowerRecursiveQueryToLogicalPlanNode(input) {
2774
2964
  ast.limit
2775
2965
  );
2776
2966
  }
2777
- function lowerComposableQueryToLogicalPlanNode(query, dialect, graphId, nextPlanNodeId) {
2967
+ function lowerComposableQueryToLogicalPlanNode(query, dialect, graphId, nextPlanNodeId, vectorStrategy) {
2778
2968
  if ("__type" in query) {
2779
2969
  return lowerSetOperationToLogicalPlanNode(
2780
2970
  query,
2781
2971
  graphId,
2782
2972
  dialect,
2783
- nextPlanNodeId
2973
+ nextPlanNodeId,
2974
+ vectorStrategy
2784
2975
  );
2785
2976
  }
2786
2977
  const hasVariableLengthTraversal2 = query.traversals.some(
@@ -2793,10 +2984,11 @@ function lowerComposableQueryToLogicalPlanNode(query, dialect, graphId, nextPlan
2793
2984
  nextPlanNodeId
2794
2985
  });
2795
2986
  }
2796
- const dialectAdapter = chunkPN37HVAV_cjs.getDialect(dialect);
2987
+ const dialectAdapter = chunkC2RWFIYP_cjs.getDialect(dialect);
2797
2988
  const vectorPredicate = runVectorPredicatePass(
2798
2989
  query,
2799
- dialectAdapter
2990
+ dialectAdapter,
2991
+ vectorStrategy
2800
2992
  ).vectorPredicate;
2801
2993
  const fulltextPredicate = runFulltextPredicatePass(
2802
2994
  query,
@@ -2820,14 +3012,15 @@ function lowerComposableQueryToLogicalPlanNode(query, dialect, graphId, nextPlan
2820
3012
  };
2821
3013
  return lowerStandardQueryToLogicalPlanNode(loweringInput);
2822
3014
  }
2823
- function lowerSetOperationToLogicalPlanNode(op, graphId, dialect, nextPlanNodeId) {
3015
+ function lowerSetOperationToLogicalPlanNode(op, graphId, dialect, nextPlanNodeId, vectorStrategy) {
2824
3016
  let currentNode = {
2825
3017
  id: nextPlanNodeId(),
2826
3018
  left: lowerComposableQueryToLogicalPlanNode(
2827
3019
  op.left,
2828
3020
  dialect,
2829
3021
  graphId,
2830
- nextPlanNodeId
3022
+ nextPlanNodeId,
3023
+ vectorStrategy
2831
3024
  ),
2832
3025
  op: "set_op",
2833
3026
  operator: op.operator,
@@ -2835,7 +3028,8 @@ function lowerSetOperationToLogicalPlanNode(op, graphId, dialect, nextPlanNodeId
2835
3028
  op.right,
2836
3029
  dialect,
2837
3030
  graphId,
2838
- nextPlanNodeId
3031
+ nextPlanNodeId,
3032
+ vectorStrategy
2839
3033
  )
2840
3034
  };
2841
3035
  if (op.orderBy !== void 0 && op.orderBy.length > 0) {
@@ -2899,7 +3093,8 @@ function lowerSetOperationToLogicalPlan(input) {
2899
3093
  input.op,
2900
3094
  input.graphId,
2901
3095
  input.dialect,
2902
- nextPlanNodeId
3096
+ nextPlanNodeId,
3097
+ input.vectorStrategy
2903
3098
  )
2904
3099
  };
2905
3100
  }
@@ -2952,7 +3147,7 @@ function runRecursiveQueryPassPipeline(ast, graphId, ctx) {
2952
3147
  execute(currentState) {
2953
3148
  const traversal = currentState.traversal;
2954
3149
  if (traversal === void 0) {
2955
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
3150
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
2956
3151
  "Recursive traversal pass did not select traversal"
2957
3152
  );
2958
3153
  }
@@ -3005,17 +3200,17 @@ function compileVariableLengthQueryWithRecursiveCteStrategy(ast, graphId, ctx) {
3005
3200
  traversal: vlTraversal
3006
3201
  } = passState;
3007
3202
  if (temporalFilterPass === void 0) {
3008
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
3203
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
3009
3204
  "Temporal filter pass did not initialize temporal state"
3010
3205
  );
3011
3206
  }
3012
3207
  if (logicalPlan === void 0) {
3013
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
3208
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
3014
3209
  "Logical plan pass did not initialize plan state"
3015
3210
  );
3016
3211
  }
3017
3212
  if (vlTraversal === void 0) {
3018
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
3213
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
3019
3214
  "Recursive traversal pass did not select traversal"
3020
3215
  );
3021
3216
  }
@@ -3062,8 +3257,8 @@ function compileRecursiveCte(ast, traversal, graphId, ctx, requiredColumnsByAlia
3062
3257
  if (previousNodeKinds.length > 1) {
3063
3258
  recursiveJoinRequiredColumns.add("kind");
3064
3259
  }
3065
- const requiredStartColumns = requiredColumnsByAlias ? requiredColumnsByAlias.get(startAlias) ?? chunkHTGDWIDE_cjs.EMPTY_REQUIRED_COLUMNS : void 0;
3066
- const requiredNodeColumns = requiredColumnsByAlias ? requiredColumnsByAlias.get(nodeAlias) ?? chunkHTGDWIDE_cjs.EMPTY_REQUIRED_COLUMNS : void 0;
3260
+ const requiredStartColumns = requiredColumnsByAlias ? requiredColumnsByAlias.get(startAlias) ?? chunkKGAJ5HFO_cjs.EMPTY_REQUIRED_COLUMNS : void 0;
3261
+ const requiredNodeColumns = requiredColumnsByAlias ? requiredColumnsByAlias.get(nodeAlias) ?? chunkKGAJ5HFO_cjs.EMPTY_REQUIRED_COLUMNS : void 0;
3067
3262
  const startColumnsFromBase = compileNodeSelectColumnsFromTable(
3068
3263
  "n0",
3069
3264
  startAlias,
@@ -3107,7 +3302,7 @@ function compileRecursiveCte(ast, traversal, graphId, ctx, requiredColumnsByAlia
3107
3302
  targetContext
3108
3303
  );
3109
3304
  if (vl.maxDepth > MAX_EXPLICIT_RECURSIVE_DEPTH) {
3110
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
3305
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
3111
3306
  `Recursive traversal maxHops(${vl.maxDepth}) exceeds maximum explicit depth of ${MAX_EXPLICIT_RECURSIVE_DEPTH}`
3112
3307
  );
3113
3308
  }
@@ -3259,30 +3454,30 @@ function collectRequiredColumnsByAlias(ast, traversal) {
3259
3454
  const previousNodeKinds = [
3260
3455
  .../* @__PURE__ */ new Set([...ast.start.kinds, ...traversal.nodeKinds])
3261
3456
  ];
3262
- chunkHTGDWIDE_cjs.addRequiredColumn(requiredColumnsByAlias, traversal.nodeAlias, "id");
3457
+ chunkKGAJ5HFO_cjs.addRequiredColumn(requiredColumnsByAlias, traversal.nodeAlias, "id");
3263
3458
  if (previousNodeKinds.length > 1) {
3264
- chunkHTGDWIDE_cjs.addRequiredColumn(requiredColumnsByAlias, traversal.nodeAlias, "kind");
3459
+ chunkKGAJ5HFO_cjs.addRequiredColumn(requiredColumnsByAlias, traversal.nodeAlias, "kind");
3265
3460
  }
3266
3461
  for (const field2 of selectiveFields) {
3267
- chunkHTGDWIDE_cjs.markSelectiveFieldAsRequired(requiredColumnsByAlias, field2);
3462
+ chunkKGAJ5HFO_cjs.markSelectiveFieldAsRequired(requiredColumnsByAlias, field2);
3268
3463
  }
3269
3464
  if (ast.orderBy) {
3270
3465
  for (const orderSpec of ast.orderBy) {
3271
- chunkHTGDWIDE_cjs.markFieldRefAsRequired(requiredColumnsByAlias, orderSpec.field);
3466
+ chunkKGAJ5HFO_cjs.markFieldRefAsRequired(requiredColumnsByAlias, orderSpec.field);
3272
3467
  }
3273
3468
  }
3274
3469
  return requiredColumnsByAlias;
3275
3470
  }
3276
3471
  function compileNodeSelectColumnsFromTable(tableAlias, alias, requiredColumns, alwaysRequiredColumns) {
3277
- return chunkHTGDWIDE_cjs.NODE_COLUMNS.filter(
3278
- (column) => chunkHTGDWIDE_cjs.shouldProjectColumn(requiredColumns, column, alwaysRequiredColumns)
3472
+ return chunkKGAJ5HFO_cjs.NODE_COLUMNS.filter(
3473
+ (column) => chunkKGAJ5HFO_cjs.shouldProjectColumn(requiredColumns, column, alwaysRequiredColumns)
3279
3474
  ).map(
3280
3475
  (column) => drizzleOrm.sql`${drizzleOrm.sql.raw(tableAlias)}.${drizzleOrm.sql.raw(column)} AS ${drizzleOrm.sql.raw(`${alias}_${column}`)}`
3281
3476
  );
3282
3477
  }
3283
3478
  function compileNodeSelectColumnsFromRecursiveRow(alias, requiredColumns, alwaysRequiredColumns) {
3284
- return chunkHTGDWIDE_cjs.NODE_COLUMNS.filter(
3285
- (column) => chunkHTGDWIDE_cjs.shouldProjectColumn(requiredColumns, column, alwaysRequiredColumns)
3479
+ return chunkKGAJ5HFO_cjs.NODE_COLUMNS.filter(
3480
+ (column) => chunkKGAJ5HFO_cjs.shouldProjectColumn(requiredColumns, column, alwaysRequiredColumns)
3286
3481
  ).map((column) => {
3287
3482
  const projected = `${alias}_${column}`;
3288
3483
  return drizzleOrm.sql`r.${drizzleOrm.sql.raw(projected)} AS ${drizzleOrm.sql.raw(projected)}`;
@@ -3323,10 +3518,10 @@ function compileRecursiveProjection(ast, traversal, dialect) {
3323
3518
  drizzleOrm.sql`${drizzleOrm.sql.raw(nodeAlias)}_deleted_at`
3324
3519
  ];
3325
3520
  if (vl.depthAlias !== void 0) {
3326
- fields.push(drizzleOrm.sql`depth AS ${chunkHTGDWIDE_cjs.quoteIdentifier(vl.depthAlias)}`);
3521
+ fields.push(drizzleOrm.sql`depth AS ${chunkKGAJ5HFO_cjs.quoteIdentifier(vl.depthAlias)}`);
3327
3522
  }
3328
3523
  if (vl.pathAlias !== void 0) {
3329
- fields.push(drizzleOrm.sql`path AS ${chunkHTGDWIDE_cjs.quoteIdentifier(vl.pathAlias)}`);
3524
+ fields.push(drizzleOrm.sql`path AS ${chunkKGAJ5HFO_cjs.quoteIdentifier(vl.pathAlias)}`);
3330
3525
  }
3331
3526
  return drizzleOrm.sql.join(fields, drizzleOrm.sql`, `);
3332
3527
  }
@@ -3334,13 +3529,13 @@ function compileRecursiveSelectiveProjection(fields, ast, traversal, dialect) {
3334
3529
  const allowedAliases = /* @__PURE__ */ new Set([ast.start.alias, traversal.nodeAlias]);
3335
3530
  const columns = fields.map((field2) => {
3336
3531
  if (!allowedAliases.has(field2.alias)) {
3337
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
3532
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
3338
3533
  `Selective projection for recursive traversals does not support alias "${field2.alias}"`
3339
3534
  );
3340
3535
  }
3341
3536
  if (field2.isSystemField) {
3342
- const dbColumn = chunkHTGDWIDE_cjs.mapSelectiveSystemFieldToColumn(field2.field);
3343
- return drizzleOrm.sql`${drizzleOrm.sql.raw(`${field2.alias}_${dbColumn}`)} AS ${chunkHTGDWIDE_cjs.quoteIdentifier(field2.outputName)}`;
3537
+ const dbColumn = chunkKGAJ5HFO_cjs.mapSelectiveSystemFieldToColumn(field2.field);
3538
+ return drizzleOrm.sql`${drizzleOrm.sql.raw(`${field2.alias}_${dbColumn}`)} AS ${chunkKGAJ5HFO_cjs.quoteIdentifier(field2.outputName)}`;
3344
3539
  }
3345
3540
  const column = drizzleOrm.sql.raw(`${field2.alias}_props`);
3346
3541
  const extracted = compileTypedJsonExtract({
@@ -3349,14 +3544,14 @@ function compileRecursiveSelectiveProjection(fields, ast, traversal, dialect) {
3349
3544
  pointer: chunk7V335GHG_cjs.jsonPointer([field2.field]),
3350
3545
  valueType: field2.valueType
3351
3546
  });
3352
- return drizzleOrm.sql`${extracted} AS ${chunkHTGDWIDE_cjs.quoteIdentifier(field2.outputName)}`;
3547
+ return drizzleOrm.sql`${extracted} AS ${chunkKGAJ5HFO_cjs.quoteIdentifier(field2.outputName)}`;
3353
3548
  });
3354
3549
  const vl = traversal.variableLength;
3355
3550
  if (vl.depthAlias !== void 0) {
3356
- columns.push(drizzleOrm.sql`depth AS ${chunkHTGDWIDE_cjs.quoteIdentifier(vl.depthAlias)}`);
3551
+ columns.push(drizzleOrm.sql`depth AS ${chunkKGAJ5HFO_cjs.quoteIdentifier(vl.depthAlias)}`);
3357
3552
  }
3358
3553
  if (vl.pathAlias !== void 0) {
3359
- columns.push(drizzleOrm.sql`path AS ${chunkHTGDWIDE_cjs.quoteIdentifier(vl.pathAlias)}`);
3554
+ columns.push(drizzleOrm.sql`path AS ${chunkKGAJ5HFO_cjs.quoteIdentifier(vl.pathAlias)}`);
3360
3555
  }
3361
3556
  return drizzleOrm.sql.join(columns, drizzleOrm.sql`, `);
3362
3557
  }
@@ -3368,7 +3563,7 @@ function compileRecursiveOrderBy(ast, dialect) {
3368
3563
  for (const orderSpec of ast.orderBy) {
3369
3564
  const valueType = orderSpec.field.valueType;
3370
3565
  if (valueType === "array" || valueType === "object") {
3371
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
3566
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
3372
3567
  "Ordering by JSON arrays or objects is not supported"
3373
3568
  );
3374
3569
  }
@@ -3567,7 +3762,7 @@ function nullToUndefined2(value) {
3567
3762
  }
3568
3763
  function rowToNode(row) {
3569
3764
  const rawProps = JSON.parse(row.props);
3570
- const props = chunkPYJOBZR3_cjs.filterReservedKeys(rawProps, chunkPYJOBZR3_cjs.RESERVED_NODE_KEYS);
3765
+ const props = chunkHM6XMR3E_cjs.filterReservedKeys(rawProps, chunkHM6XMR3E_cjs.RESERVED_NODE_KEYS);
3571
3766
  return {
3572
3767
  kind: row.kind,
3573
3768
  id: row.id,
@@ -3587,7 +3782,7 @@ function rowToNodeMeta(row) {
3587
3782
  }
3588
3783
  function rowToEdge(row) {
3589
3784
  const rawProps = JSON.parse(row.props);
3590
- const props = chunkPYJOBZR3_cjs.filterReservedKeys(rawProps, chunkPYJOBZR3_cjs.RESERVED_EDGE_KEYS);
3785
+ const props = chunkHM6XMR3E_cjs.filterReservedKeys(rawProps, chunkHM6XMR3E_cjs.RESERVED_EDGE_KEYS);
3591
3786
  return {
3592
3787
  id: row.id,
3593
3788
  kind: row.kind,
@@ -3623,9 +3818,9 @@ function truncateToBytes(value, maxBytes) {
3623
3818
  }
3624
3819
  function projectionAlias(entityPrefix, kind, field2) {
3625
3820
  const prefix = entityPrefix === "node" ? "sg_n" : "sg_e";
3626
- const hash = chunkCTHNVU6K_cjs.fnv1aBase36(`${kind}\0${field2}`);
3821
+ const hash = chunkUPBXUOW7_cjs.fnv1aBase36(`${kind}\0${field2}`);
3627
3822
  const fixedBytes = prefix.length + 1 + 1 + hash.length;
3628
- const maxKindBytes = chunkCTHNVU6K_cjs.MAX_PG_IDENTIFIER_LENGTH - fixedBytes;
3823
+ const maxKindBytes = chunkUPBXUOW7_cjs.MAX_PG_IDENTIFIER_LENGTH - fixedBytes;
3629
3824
  const truncatedKind = truncateToBytes(kind, maxKindBytes);
3630
3825
  return `${prefix}_${truncatedKind}_${hash}`;
3631
3826
  }
@@ -3723,7 +3918,7 @@ function getSubgraphSchemaIntrospector(graph) {
3723
3918
  { schema: definition.type.schema }
3724
3919
  ])
3725
3920
  );
3726
- const introspector = chunkEK6RJ373_cjs.createSchemaIntrospector(nodeKinds, edgeKinds);
3921
+ const introspector = chunkVGU26WIU_cjs.createSchemaIntrospector(nodeKinds, edgeKinds);
3727
3922
  introspectorCache.set(graph, introspector);
3728
3923
  return introspector;
3729
3924
  }
@@ -3751,7 +3946,7 @@ function buildKindProjectionPlan(kind, selection, resolveFieldType, entityPrefix
3751
3946
  includeMeta = true;
3752
3947
  continue;
3753
3948
  }
3754
- chunkPYJOBZR3_cjs.validateProjectionField(field2, entityPrefix, kind);
3949
+ chunkHM6XMR3E_cjs.validateProjectionField(field2, entityPrefix, kind);
3755
3950
  if (!propertyFields.has(field2)) {
3756
3951
  propertyFields.set(field2, {
3757
3952
  field: field2,
@@ -3871,7 +4066,7 @@ function buildProjectedPropertyColumns(alias, plan, dialect) {
3871
4066
  valueType: fieldPlan.typeInfo?.valueType
3872
4067
  });
3873
4068
  columns.push(
3874
- drizzleOrm.sql`CASE WHEN ${drizzleOrm.sql.raw(alias)}.kind = ${kind} THEN ${extracted} ELSE NULL END AS ${chunkHTGDWIDE_cjs.quoteIdentifier(fieldPlan.outputName)}`
4069
+ drizzleOrm.sql`CASE WHEN ${drizzleOrm.sql.raw(alias)}.kind = ${kind} THEN ${extracted} ELSE NULL END AS ${chunkKGAJ5HFO_cjs.quoteIdentifier(fieldPlan.outputName)}`
3875
4070
  );
3876
4071
  }
3877
4072
  }
@@ -3998,7 +4193,7 @@ function buildIncompatibleChangeError(classification, nonEmpty, graphId) {
3998
4193
  }
3999
4194
  const all = [...classification.incompatible, ...promoted];
4000
4195
  if (all.length === 0) return void 0;
4001
- return new chunkPYJOBZR3_cjs.IncompatibleChangeError(all, graphId);
4196
+ return new chunkHM6XMR3E_cjs.IncompatibleChangeError(all, graphId);
4002
4197
  }
4003
4198
  function classifyNode(kind, existing, next, recorders) {
4004
4199
  classifyProperties(kind, existing.properties, next.properties, recorders);
@@ -4281,7 +4476,7 @@ function classifyUnique(kind, existing, next, recorders) {
4281
4476
  if (newOne === void 0) continue;
4282
4477
  const { name: _existingName, ...existingShape } = constraint;
4283
4478
  const { name: _nextName, ...nextShape } = newOne;
4284
- if (!chunkIUIWCFG3_cjs.canonicalEqual(existingShape, nextShape)) {
4479
+ if (!chunkRP7YITHX_cjs.canonicalEqual(existingShape, nextShape)) {
4285
4480
  recorders.recordRequireEmpty({
4286
4481
  kind,
4287
4482
  type: "ADD_UNIQUE_ON_POPULATED",
@@ -4298,7 +4493,7 @@ function planRemovals(graph, names) {
4298
4493
  if (namesSet.size === 0) {
4299
4494
  return { document, removedNodeKinds: [], removedEdgeKinds: [] };
4300
4495
  }
4301
- const { nodes: runtimeNodeNames, edges: runtimeEdgeNames } = chunkZGEMI7MJ_cjs.extensionKindNames(document);
4496
+ const { nodes: runtimeNodeNames, edges: runtimeEdgeNames } = chunkXTQHSOIC_cjs.extensionKindNames(document);
4302
4497
  const compileTimeNodeNames = new Set(
4303
4498
  Object.keys(graph.nodes).filter((name) => !runtimeNodeNames.has(name))
4304
4499
  );
@@ -4307,10 +4502,10 @@ function planRemovals(graph, names) {
4307
4502
  );
4308
4503
  for (const name of namesSet) {
4309
4504
  if (compileTimeNodeNames.has(name)) {
4310
- throw new chunkPYJOBZR3_cjs.RemoveCompileTimeKindError(name, "node", graph.id);
4505
+ throw new chunkHM6XMR3E_cjs.RemoveCompileTimeKindError(name, "node", graph.id);
4311
4506
  }
4312
4507
  if (compileTimeEdgeNames.has(name)) {
4313
- throw new chunkPYJOBZR3_cjs.RemoveCompileTimeKindError(name, "edge", graph.id);
4508
+ throw new chunkHM6XMR3E_cjs.RemoveCompileTimeKindError(name, "edge", graph.id);
4314
4509
  }
4315
4510
  }
4316
4511
  const removedNodeKinds = [...namesSet].filter(
@@ -4326,7 +4521,7 @@ function planRemovals(graph, names) {
4326
4521
  for (const kindName of removedNodeKinds) {
4327
4522
  const referents = referentsByKind.get(kindName);
4328
4523
  if (referents !== void 0 && referents.length > 0) {
4329
- throw new chunkPYJOBZR3_cjs.KindHasReferentsError(kindName, referents, graph.id);
4524
+ throw new chunkHM6XMR3E_cjs.KindHasReferentsError(kindName, referents, graph.id);
4330
4525
  }
4331
4526
  }
4332
4527
  if (document === void 0) {
@@ -4398,8 +4593,8 @@ function planRemovals(graph, names) {
4398
4593
  function stripGraphExtension(graph) {
4399
4594
  const document = graph.extension;
4400
4595
  if (document === void 0) return graph;
4401
- const { nodes: runtimeNodeNames, edges: runtimeEdgeNames } = chunkZGEMI7MJ_cjs.extensionKindNames(document);
4402
- const runtimeOntologyKeys = chunkZGEMI7MJ_cjs.buildGraphExtensionOntologyKeySet(document);
4596
+ const { nodes: runtimeNodeNames, edges: runtimeEdgeNames } = chunkXTQHSOIC_cjs.extensionKindNames(document);
4597
+ const runtimeOntologyKeys = chunkXTQHSOIC_cjs.buildGraphExtensionOntologyKeySet(document);
4403
4598
  const compileNodes = {};
4404
4599
  for (const [name, registration] of Object.entries(graph.nodes)) {
4405
4600
  if (runtimeNodeNames.has(name)) continue;
@@ -4411,7 +4606,7 @@ function stripGraphExtension(graph) {
4411
4606
  compileEdges[name] = registration;
4412
4607
  }
4413
4608
  const compileOntology = graph.ontology.filter(
4414
- (relation) => !runtimeOntologyKeys.has(chunkZGEMI7MJ_cjs.compileTimeOntologyKey(relation))
4609
+ (relation) => !runtimeOntologyKeys.has(chunkXTQHSOIC_cjs.compileTimeOntologyKey(relation))
4415
4610
  );
4416
4611
  const compileIndexes = (graph.indexes ?? []).filter(
4417
4612
  (index) => index.origin !== "runtime"
@@ -4451,13 +4646,13 @@ function buildCompileTimeReferentIndex(graph, runtimeEdgeNames) {
4451
4646
  append(endpoint.kind, referent);
4452
4647
  }
4453
4648
  }
4454
- const runtimeOntologyKeys = chunkZGEMI7MJ_cjs.buildGraphExtensionOntologyKeySet(
4649
+ const runtimeOntologyKeys = chunkXTQHSOIC_cjs.buildGraphExtensionOntologyKeySet(
4455
4650
  graph.extension
4456
4651
  );
4457
4652
  for (const relation of graph.ontology) {
4458
- if (runtimeOntologyKeys.has(chunkZGEMI7MJ_cjs.compileTimeOntologyKey(relation))) continue;
4459
- const fromName = chunkZGEMI7MJ_cjs.getTypeName(relation.from);
4460
- const toName = chunkZGEMI7MJ_cjs.getTypeName(relation.to);
4653
+ if (runtimeOntologyKeys.has(chunkXTQHSOIC_cjs.compileTimeOntologyKey(relation))) continue;
4654
+ const fromName = chunkXTQHSOIC_cjs.getTypeName(relation.from);
4655
+ const toName = chunkXTQHSOIC_cjs.getTypeName(relation.to);
4461
4656
  const referent = {
4462
4657
  type: "compile-time-ontology",
4463
4658
  name: `${relation.metaEdge.name}(${fromName}, ${toName})`
@@ -4473,29 +4668,7 @@ var OPERATOR_MAP = {
4473
4668
  intersect: "INTERSECT",
4474
4669
  except: "EXCEPT"
4475
4670
  };
4476
- function compileSetOperationWithStandardParenthesizedStrategy(op, graphId, dialect, logicalPlan, _schema, compileQuery2) {
4477
- return compileSetOperationStandard(
4478
- op,
4479
- graphId,
4480
- dialect,
4481
- logicalPlan,
4482
- compileQuery2
4483
- );
4484
- }
4485
- function compileSetOperationWithSqliteCompoundStrategy(op, graphId, dialect, logicalPlan, schema, _compileQuery) {
4486
- return compileSetOperationForSqlite(
4487
- op,
4488
- graphId,
4489
- dialect,
4490
- logicalPlan,
4491
- schema
4492
- );
4493
- }
4494
- var SET_OPERATION_STRATEGY_HANDLERS = {
4495
- standard_parenthesized: compileSetOperationWithStandardParenthesizedStrategy,
4496
- sqlite_compound: compileSetOperationWithSqliteCompoundStrategy
4497
- };
4498
- function runSetOperationPassPipeline(op, graphId, dialect) {
4671
+ function runSetOperationPassPipeline(op, graphId, dialect, vectorStrategy) {
4499
4672
  let state = {
4500
4673
  dialect,
4501
4674
  graphId,
@@ -4508,7 +4681,8 @@ function runSetOperationPassPipeline(op, graphId, dialect) {
4508
4681
  return lowerSetOperationToLogicalPlan({
4509
4682
  dialect: currentState.dialect.name,
4510
4683
  graphId: currentState.graphId,
4511
- op: currentState.op
4684
+ op: currentState.op,
4685
+ ...vectorStrategy === void 0 ? {} : { vectorStrategy }
4512
4686
  });
4513
4687
  },
4514
4688
  update(currentState, logicalPlan) {
@@ -4521,25 +4695,20 @@ function runSetOperationPassPipeline(op, graphId, dialect) {
4521
4695
  state = logicalPlanPass.state;
4522
4696
  return state;
4523
4697
  }
4524
- function compileSetOperation(op, graphId, dialect, schema, compileQuery2) {
4525
- const passState = runSetOperationPassPipeline(op, graphId, dialect);
4698
+ function compileSetOperation(op, graphId, dialect, compileQuery2, vectorStrategy) {
4699
+ const passState = runSetOperationPassPipeline(
4700
+ op,
4701
+ graphId,
4702
+ dialect,
4703
+ vectorStrategy
4704
+ );
4526
4705
  const { logicalPlan } = passState;
4527
4706
  if (logicalPlan === void 0) {
4528
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
4707
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
4529
4708
  "Logical plan pass did not initialize plan state"
4530
4709
  );
4531
4710
  }
4532
- const strategy = dialect.capabilities.setOperationStrategy;
4533
- const handler = SET_OPERATION_STRATEGY_HANDLERS[strategy];
4534
- return handler(op, graphId, dialect, logicalPlan, schema, compileQuery2);
4535
- }
4536
- function compileSetOperationStandard(op, graphId, dialect, logicalPlan, compileQuery2) {
4537
- const coreSql = compileSetOperationCoreStandard(
4538
- op,
4539
- graphId,
4540
- dialect,
4541
- compileQuery2
4542
- );
4711
+ const coreSql = compileSetOperationCore(op, graphId, compileQuery2, dialect);
4543
4712
  const suffixClauses = buildSetOperationSuffixClauses(op, dialect);
4544
4713
  return emitSetOperationQuerySql({
4545
4714
  baseQuery: coreSql,
@@ -4547,361 +4716,28 @@ function compileSetOperationStandard(op, graphId, dialect, logicalPlan, compileQ
4547
4716
  ...suffixClauses.length === 0 ? {} : { suffixClauses }
4548
4717
  });
4549
4718
  }
4550
- function compileSetOperationCoreStandard(op, graphId, dialect, compileQuery2) {
4551
- const left = compileComposableQueryStandard(
4552
- op.left,
4553
- graphId,
4554
- dialect,
4555
- compileQuery2
4556
- );
4557
- const right = compileComposableQueryStandard(
4719
+ function compileSetOperationCore(op, graphId, compileQuery2, dialect) {
4720
+ const left = compileComposableQuery(op.left, graphId, compileQuery2, dialect);
4721
+ const right = compileComposableQuery(
4558
4722
  op.right,
4559
4723
  graphId,
4560
- dialect,
4561
- compileQuery2
4724
+ compileQuery2,
4725
+ dialect
4562
4726
  );
4563
4727
  const opSql = drizzleOrm.sql.raw(OPERATOR_MAP[op.operator]);
4564
- return drizzleOrm.sql`(${left}) ${opSql} (${right})`;
4728
+ return drizzleOrm.sql`${dialect.wrapSetOperationOperand(left)} ${opSql} ${dialect.wrapSetOperationOperand(right)}`;
4565
4729
  }
4566
- function compileComposableQueryStandard(query, graphId, dialect, compileQuery2) {
4730
+ function compileComposableQuery(query, graphId, compileQuery2, dialect) {
4567
4731
  if ("__type" in query) {
4568
- return compileSetOperationCoreStandard(
4569
- query,
4570
- graphId,
4571
- dialect,
4572
- compileQuery2
4573
- );
4732
+ return compileSetOperationCompound(query, graphId, compileQuery2, dialect);
4574
4733
  }
4575
4734
  return compileQuery2(query, graphId);
4576
4735
  }
4577
- function runSqliteSetOperationValidationPass(op) {
4578
- const leaves = [];
4579
- collectLeafQueries(op, leaves, "q");
4580
- for (const leaf of leaves) {
4581
- validateSqliteSetOpLeaf(leaf.ast);
4582
- }
4583
- return { leaves };
4584
- }
4585
- function compileSetOperationForSqlite(op, graphId, dialect, logicalPlan, schema) {
4586
- const { leaves } = runSqliteSetOperationValidationPass(op);
4587
- const allCtes = [];
4588
- const ctx = {
4589
- dialect,
4590
- schema,
4591
- compileQuery: () => {
4592
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
4593
- "compileQuery is not available in set-operation CTE compilation"
4594
- );
4595
- }
4596
- };
4597
- for (const leaf of leaves) {
4598
- const cte = compilePrefixedStartCte(leaf.ast, leaf.prefix, graphId, ctx);
4599
- allCtes.push(cte);
4600
- }
4601
- const selectStatements = [];
4602
- for (const leaf of leaves) {
4603
- const select = compilePrefixedSelect(leaf.ast, leaf.prefix, dialect);
4604
- selectStatements.push(select);
4605
- }
4606
- const compoundSelect = buildCompoundSelect(op, leaves, selectStatements);
4736
+ function compileSetOperationCompound(op, graphId, compileQuery2, dialect) {
4737
+ const core2 = compileSetOperationCore(op, graphId, compileQuery2, dialect);
4607
4738
  const suffixClauses = buildSetOperationSuffixClauses(op, dialect);
4608
- return emitSetOperationQuerySql({
4609
- baseQuery: compoundSelect,
4610
- ...allCtes.length === 0 ? {} : { ctes: allCtes },
4611
- logicalPlan,
4612
- ...suffixClauses.length === 0 ? {} : { suffixClauses }
4613
- });
4614
- }
4615
- function validateSqliteSetOpLeaf(ast) {
4616
- const unsupported = [];
4617
- if (ast.traversals.length > 0) {
4618
- unsupported.push("traversals");
4619
- }
4620
- if (hasSubqueryPredicates(ast)) {
4621
- unsupported.push("EXISTS/IN subqueries");
4622
- }
4623
- if (hasVectorSimilarityPredicates(ast)) {
4624
- unsupported.push("vector similarity predicates");
4625
- }
4626
- if (hasFulltextMatchPredicates(ast)) {
4627
- unsupported.push("fulltext match predicates");
4628
- }
4629
- if (ast.groupBy !== void 0) {
4630
- unsupported.push("GROUP BY");
4631
- }
4632
- if (ast.having !== void 0) {
4633
- unsupported.push("HAVING");
4634
- }
4635
- if (ast.orderBy !== void 0 && ast.orderBy.length > 0) {
4636
- unsupported.push(
4637
- "per-query ORDER BY (use set operation's orderBy instead)"
4638
- );
4639
- }
4640
- if (ast.limit !== void 0) {
4641
- unsupported.push("per-query LIMIT (use set operation's limit instead)");
4642
- }
4643
- if (ast.offset !== void 0) {
4644
- unsupported.push("per-query OFFSET (use set operation's offset instead)");
4645
- }
4646
- if (unsupported.length > 0) {
4647
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
4648
- `SQLite set operations (UNION/INTERSECT/EXCEPT) do not support: ${unsupported.join(", ")}. Use PostgreSQL for complex set operations, or refactor to separate queries.`
4649
- );
4650
- }
4651
- }
4652
- function hasVectorSimilarityPredicates(ast) {
4653
- return ast.predicates.some(
4654
- (predicate2) => hasVectorSimilarityInExpression(predicate2.expression)
4655
- );
4656
- }
4657
- function hasVectorSimilarityInExpression(expr) {
4658
- if ("__type" in expr) {
4659
- switch (expr.__type) {
4660
- case "and":
4661
- case "or": {
4662
- return expr.predicates.some((p) => hasVectorSimilarityInExpression(p));
4663
- }
4664
- case "not": {
4665
- return hasVectorSimilarityInExpression(expr.predicate);
4666
- }
4667
- case "vector_similarity": {
4668
- return true;
4669
- }
4670
- case "exists":
4671
- case "in_subquery":
4672
- case "comparison":
4673
- case "string_op":
4674
- case "null_check":
4675
- case "between":
4676
- case "array_op":
4677
- case "object_op":
4678
- case "aggregate_comparison":
4679
- case "fulltext_match": {
4680
- return false;
4681
- }
4682
- }
4683
- }
4684
- return false;
4685
- }
4686
- function hasFulltextMatchPredicates(ast) {
4687
- return ast.predicates.some(
4688
- (predicate2) => hasFulltextMatchInExpression(predicate2.expression)
4689
- );
4690
- }
4691
- function hasFulltextMatchInExpression(expr) {
4692
- if ("__type" in expr) {
4693
- switch (expr.__type) {
4694
- case "and":
4695
- case "or": {
4696
- return expr.predicates.some((p) => hasFulltextMatchInExpression(p));
4697
- }
4698
- case "not": {
4699
- return hasFulltextMatchInExpression(expr.predicate);
4700
- }
4701
- case "fulltext_match": {
4702
- return true;
4703
- }
4704
- case "exists":
4705
- case "in_subquery":
4706
- case "comparison":
4707
- case "string_op":
4708
- case "null_check":
4709
- case "between":
4710
- case "array_op":
4711
- case "object_op":
4712
- case "aggregate_comparison":
4713
- case "vector_similarity": {
4714
- return false;
4715
- }
4716
- }
4717
- }
4718
- return false;
4719
- }
4720
- function hasSubqueryPredicates(ast) {
4721
- return ast.predicates.some(
4722
- (predicate2) => hasSubqueryInExpression(predicate2.expression)
4723
- );
4724
- }
4725
- function hasSubqueryInExpression(expr) {
4726
- if ("__type" in expr) {
4727
- switch (expr.__type) {
4728
- case "and":
4729
- case "or": {
4730
- return expr.predicates.some((p) => hasSubqueryInExpression(p));
4731
- }
4732
- case "not": {
4733
- return hasSubqueryInExpression(expr.predicate);
4734
- }
4735
- case "exists": {
4736
- return true;
4737
- }
4738
- case "in_subquery": {
4739
- return true;
4740
- }
4741
- // These expression types don't contain subqueries
4742
- case "comparison":
4743
- case "string_op":
4744
- case "null_check":
4745
- case "between":
4746
- case "array_op":
4747
- case "object_op":
4748
- case "aggregate_comparison":
4749
- case "vector_similarity":
4750
- case "fulltext_match": {
4751
- return false;
4752
- }
4753
- }
4754
- }
4755
- return false;
4756
- }
4757
- function collectLeafQueries(query, leaves, basePrefix) {
4758
- if ("__type" in query) {
4759
- collectLeafQueries(query.left, leaves, basePrefix);
4760
- collectLeafQueries(query.right, leaves, basePrefix);
4761
- } else {
4762
- const index = leaves.length;
4763
- leaves.push({ ast: query, prefix: `${basePrefix}${index}` });
4764
- }
4765
- }
4766
- function compilePrefixedStartCte(ast, prefix, graphId, ctx) {
4767
- const temporalFilterPass = createTemporalFilterPass(
4768
- ast,
4769
- ctx.dialect.currentTimestamp()
4770
- );
4771
- const alias = ast.start.alias;
4772
- const kinds = ast.start.kinds;
4773
- const kindFilter = kinds.length === 1 ? drizzleOrm.sql`kind = ${kinds[0]}` : drizzleOrm.sql`kind IN (${drizzleOrm.sql.join(
4774
- kinds.map((k) => drizzleOrm.sql`${k}`),
4775
- drizzleOrm.sql`, `
4776
- )})`;
4777
- const temporalFilter = temporalFilterPass.forAlias();
4778
- const cteContext = { ...ctx, cteColumnPrefix: "" };
4779
- const predicateClauses = ast.predicates.filter((p) => p.targetAlias === alias).map((p) => compilePredicateExpression(p.expression, cteContext));
4780
- const whereClauses = [
4781
- drizzleOrm.sql`graph_id = ${graphId}`,
4782
- kindFilter,
4783
- temporalFilter,
4784
- ...predicateClauses
4785
- ];
4786
- const cteName = `cte_${prefix}_${alias}`;
4787
- return drizzleOrm.sql`
4788
- ${drizzleOrm.sql.raw(cteName)} AS (
4789
- SELECT
4790
- id AS ${drizzleOrm.sql.raw(alias)}_id,
4791
- kind AS ${drizzleOrm.sql.raw(alias)}_kind,
4792
- props AS ${drizzleOrm.sql.raw(alias)}_props,
4793
- version AS ${drizzleOrm.sql.raw(alias)}_version,
4794
- valid_from AS ${drizzleOrm.sql.raw(alias)}_valid_from,
4795
- valid_to AS ${drizzleOrm.sql.raw(alias)}_valid_to,
4796
- created_at AS ${drizzleOrm.sql.raw(alias)}_created_at,
4797
- updated_at AS ${drizzleOrm.sql.raw(alias)}_updated_at,
4798
- deleted_at AS ${drizzleOrm.sql.raw(alias)}_deleted_at
4799
- FROM ${ctx.schema.nodesTable}
4800
- WHERE ${drizzleOrm.sql.join(whereClauses, drizzleOrm.sql` AND `)}
4801
- )
4802
- `;
4803
- }
4804
- function compilePrefixedSelect(ast, prefix, dialect) {
4805
- const alias = ast.start.alias;
4806
- const cteName = `cte_${prefix}_${alias}`;
4807
- const fields = ast.projection.fields;
4808
- const projection = fields.length === 0 ? drizzleOrm.sql.raw("*") : drizzleOrm.sql.join(
4809
- fields.map((f) => {
4810
- const source = compileFieldValueForSetOp(
4811
- f.source,
4812
- prefix,
4813
- alias,
4814
- dialect
4815
- );
4816
- return drizzleOrm.sql`${source} AS ${drizzleOrm.sql.raw(dialect.quoteIdentifier(f.outputName))}`;
4817
- }),
4818
- drizzleOrm.sql`, `
4819
- );
4820
- return drizzleOrm.sql`SELECT ${projection} FROM ${drizzleOrm.sql.raw(cteName)}`;
4821
- }
4822
- function compileFieldValueForSetOp(source, prefix, alias, dialect) {
4823
- if ("__type" in source && source.__type === "aggregate") {
4824
- const { field: field2, function: fn } = source;
4825
- switch (fn) {
4826
- case "count":
4827
- case "countDistinct":
4828
- case "sum":
4829
- case "avg":
4830
- case "min":
4831
- case "max": {
4832
- const column = compileFieldColumnForSetOp(field2, prefix, dialect);
4833
- if (fn === "countDistinct") {
4834
- return drizzleOrm.sql`COUNT(DISTINCT ${column})`;
4835
- }
4836
- return drizzleOrm.sql`${drizzleOrm.sql.raw(fn.toUpperCase())}(${column})`;
4837
- }
4838
- default: {
4839
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
4840
- `Unknown aggregate function: ${String(fn)}`
4841
- );
4842
- }
4843
- }
4844
- }
4845
- return compileFieldColumnForSetOp(source, prefix, dialect);
4846
- }
4847
- function compileFieldColumnForSetOp(field2, prefix, dialect) {
4848
- const cteName = `cte_${prefix}_${field2.alias}`;
4849
- const alias = field2.alias;
4850
- if (field2.path.length === 1) {
4851
- const columnName = field2.path[0];
4852
- const columnMap = {
4853
- id: "_id",
4854
- kind: "_kind",
4855
- props: "_props",
4856
- version: "_version",
4857
- valid_from: "_valid_from",
4858
- valid_to: "_valid_to",
4859
- created_at: "_created_at",
4860
- updated_at: "_updated_at",
4861
- deleted_at: "_deleted_at"
4862
- };
4863
- if (columnName === void 0) return drizzleOrm.sql.raw(`${cteName}.${alias}_props`);
4864
- const suffix = columnMap[columnName];
4865
- if (suffix) {
4866
- return drizzleOrm.sql.raw(`${cteName}.${alias}${suffix}`);
4867
- }
4868
- }
4869
- const column = drizzleOrm.sql.raw(`${cteName}.${alias}_props`);
4870
- const pointer = field2.jsonPointer;
4871
- if (!pointer) {
4872
- return column;
4873
- }
4874
- return compileTypedJsonExtract({
4875
- column,
4876
- dialect,
4877
- fallback: "text",
4878
- pointer,
4879
- valueType: field2.valueType
4880
- });
4881
- }
4882
- function buildCompoundSelect(op, leaves, selectStatements) {
4883
- const prefixToSelect = /* @__PURE__ */ new Map();
4884
- for (const [index, leaf] of leaves.entries()) {
4885
- prefixToSelect.set(leaf.prefix, selectStatements[index]);
4886
- }
4887
- return buildCompoundSelectRecursive(op, leaves, prefixToSelect);
4888
- }
4889
- function buildCompoundSelectRecursive(query, leaves, prefixToSelect) {
4890
- if (!("__type" in query)) {
4891
- const leaf = leaves.find((l) => l.ast === query);
4892
- if (!leaf) {
4893
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError("Leaf query not found in leaves array");
4894
- }
4895
- return prefixToSelect.get(leaf.prefix);
4896
- }
4897
- const left = buildCompoundSelectRecursive(query.left, leaves, prefixToSelect);
4898
- const right = buildCompoundSelectRecursive(
4899
- query.right,
4900
- leaves,
4901
- prefixToSelect
4902
- );
4903
- const opSql = drizzleOrm.sql.raw(OPERATOR_MAP[query.operator]);
4904
- return drizzleOrm.sql`${left} ${opSql} ${right}`;
4739
+ if (suffixClauses.length === 0) return core2;
4740
+ return drizzleOrm.sql.join([core2, ...suffixClauses], drizzleOrm.sql` `);
4905
4741
  }
4906
4742
  function getLeftmostProjection(op) {
4907
4743
  let current = op.left;
@@ -4934,7 +4770,7 @@ function buildSetOperationSuffixClauses(op, dialect) {
4934
4770
  if (op.orderBy && op.orderBy.length > 0) {
4935
4771
  const projection = getLeftmostProjection(op);
4936
4772
  if (projection.fields.length === 0) {
4937
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
4773
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
4938
4774
  "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."
4939
4775
  );
4940
4776
  }
@@ -4944,7 +4780,7 @@ function buildSetOperationSuffixClauses(op, dialect) {
4944
4780
  if (!projected) {
4945
4781
  const fieldDesc = orderSpec.field.jsonPointer ? `${orderSpec.field.alias}.props${orderSpec.field.jsonPointer}` : `${orderSpec.field.alias}.${orderSpec.field.path.join(".")}`;
4946
4782
  const availableFields = projection.fields.map((f) => f.outputName).join(", ");
4947
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
4783
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
4948
4784
  `Set operation ORDER BY field "${fieldDesc}" is not in the projection. ORDER BY for UNION/INTERSECT/EXCEPT must reference projected columns. Available columns: ${availableFields}`
4949
4785
  );
4950
4786
  }
@@ -4985,7 +4821,7 @@ function isColumnPruningEnabled(ast) {
4985
4821
  function markPredicateFieldsAsRequired(requiredColumnsByAlias, expression) {
4986
4822
  switch (expression.__type) {
4987
4823
  case "comparison": {
4988
- chunkHTGDWIDE_cjs.markFieldRefAsRequired(requiredColumnsByAlias, expression.left);
4824
+ chunkKGAJ5HFO_cjs.markFieldRefAsRequired(requiredColumnsByAlias, expression.left);
4989
4825
  return;
4990
4826
  }
4991
4827
  case "string_op":
@@ -4993,7 +4829,7 @@ function markPredicateFieldsAsRequired(requiredColumnsByAlias, expression) {
4993
4829
  case "between":
4994
4830
  case "array_op":
4995
4831
  case "object_op": {
4996
- chunkHTGDWIDE_cjs.markFieldRefAsRequired(requiredColumnsByAlias, expression.field);
4832
+ chunkKGAJ5HFO_cjs.markFieldRefAsRequired(requiredColumnsByAlias, expression.field);
4997
4833
  return;
4998
4834
  }
4999
4835
  case "and":
@@ -5011,22 +4847,22 @@ function markPredicateFieldsAsRequired(requiredColumnsByAlias, expression) {
5011
4847
  return;
5012
4848
  }
5013
4849
  case "aggregate_comparison": {
5014
- chunkHTGDWIDE_cjs.markFieldRefAsRequired(
4850
+ chunkKGAJ5HFO_cjs.markFieldRefAsRequired(
5015
4851
  requiredColumnsByAlias,
5016
4852
  expression.aggregate.field
5017
4853
  );
5018
4854
  return;
5019
4855
  }
5020
4856
  case "in_subquery": {
5021
- chunkHTGDWIDE_cjs.markFieldRefAsRequired(requiredColumnsByAlias, expression.field);
4857
+ chunkKGAJ5HFO_cjs.markFieldRefAsRequired(requiredColumnsByAlias, expression.field);
5022
4858
  return;
5023
4859
  }
5024
4860
  case "vector_similarity": {
5025
- chunkHTGDWIDE_cjs.markFieldRefAsRequired(requiredColumnsByAlias, expression.field);
4861
+ chunkKGAJ5HFO_cjs.markFieldRefAsRequired(requiredColumnsByAlias, expression.field);
5026
4862
  return;
5027
4863
  }
5028
4864
  case "fulltext_match": {
5029
- chunkHTGDWIDE_cjs.markFieldRefAsRequired(requiredColumnsByAlias, expression.field);
4865
+ chunkKGAJ5HFO_cjs.markFieldRefAsRequired(requiredColumnsByAlias, expression.field);
5030
4866
  return;
5031
4867
  }
5032
4868
  case "exists": {
@@ -5036,33 +4872,33 @@ function markPredicateFieldsAsRequired(requiredColumnsByAlias, expression) {
5036
4872
  }
5037
4873
  function collectRequiredColumnsByAlias2(ast) {
5038
4874
  const requiredColumnsByAlias = /* @__PURE__ */ new Map();
5039
- chunkHTGDWIDE_cjs.addRequiredColumn(requiredColumnsByAlias, ast.start.alias, "id");
4875
+ chunkKGAJ5HFO_cjs.addRequiredColumn(requiredColumnsByAlias, ast.start.alias, "id");
5040
4876
  for (const traversal of ast.traversals) {
5041
- chunkHTGDWIDE_cjs.addRequiredColumn(requiredColumnsByAlias, traversal.nodeAlias, "id");
4877
+ chunkKGAJ5HFO_cjs.addRequiredColumn(requiredColumnsByAlias, traversal.nodeAlias, "id");
5042
4878
  }
5043
4879
  if (ast.selectiveFields && ast.selectiveFields.length > 0) {
5044
4880
  for (const field2 of ast.selectiveFields) {
5045
- chunkHTGDWIDE_cjs.markSelectiveFieldAsRequired(requiredColumnsByAlias, field2);
4881
+ chunkKGAJ5HFO_cjs.markSelectiveFieldAsRequired(requiredColumnsByAlias, field2);
5046
4882
  }
5047
4883
  } else {
5048
4884
  for (const projectedField of ast.projection.fields) {
5049
4885
  const source = projectedField.source;
5050
4886
  if (source.__type === "field_ref") {
5051
- chunkHTGDWIDE_cjs.markFieldRefAsRequired(requiredColumnsByAlias, source);
4887
+ chunkKGAJ5HFO_cjs.markFieldRefAsRequired(requiredColumnsByAlias, source);
5052
4888
  } else {
5053
- chunkHTGDWIDE_cjs.addRequiredColumn(requiredColumnsByAlias, source.field.alias, "id");
5054
- chunkHTGDWIDE_cjs.markFieldRefAsRequired(requiredColumnsByAlias, source.field);
4889
+ chunkKGAJ5HFO_cjs.addRequiredColumn(requiredColumnsByAlias, source.field.alias, "id");
4890
+ chunkKGAJ5HFO_cjs.markFieldRefAsRequired(requiredColumnsByAlias, source.field);
5055
4891
  }
5056
4892
  }
5057
4893
  }
5058
4894
  if (ast.groupBy) {
5059
4895
  for (const field2 of ast.groupBy.fields) {
5060
- chunkHTGDWIDE_cjs.markFieldRefAsRequired(requiredColumnsByAlias, field2);
4896
+ chunkKGAJ5HFO_cjs.markFieldRefAsRequired(requiredColumnsByAlias, field2);
5061
4897
  }
5062
4898
  }
5063
4899
  if (ast.orderBy) {
5064
4900
  for (const orderSpec of ast.orderBy) {
5065
- chunkHTGDWIDE_cjs.markFieldRefAsRequired(requiredColumnsByAlias, orderSpec.field);
4901
+ chunkKGAJ5HFO_cjs.markFieldRefAsRequired(requiredColumnsByAlias, orderSpec.field);
5066
4902
  }
5067
4903
  }
5068
4904
  if (ast.having) {
@@ -5076,7 +4912,7 @@ function collectRequiredColumnsByAlias2(ast) {
5076
4912
  function hasIdEqualityPredicate(expression, alias) {
5077
4913
  switch (expression.__type) {
5078
4914
  case "comparison": {
5079
- return expression.op === "eq" && expression.left.alias === alias && chunkHTGDWIDE_cjs.isIdFieldRef(expression.left);
4915
+ return expression.op === "eq" && expression.left.alias === alias && chunkKGAJ5HFO_cjs.isIdFieldRef(expression.left);
5080
4916
  }
5081
4917
  case "and": {
5082
4918
  return expression.predicates.some(
@@ -5194,7 +5030,11 @@ function runStandardQueryPassPipeline(ast, graphId, ctx) {
5194
5030
  const vectorPass = runCompilerPass(state, {
5195
5031
  name: "vector_predicate",
5196
5032
  execute(currentState) {
5197
- return runVectorPredicatePass(currentState.ast, currentState.ctx.dialect).vectorPredicate;
5033
+ return runVectorPredicatePass(
5034
+ currentState.ast,
5035
+ currentState.ctx.dialect,
5036
+ currentState.ctx.vectorStrategy
5037
+ ).vectorPredicate;
5198
5038
  },
5199
5039
  update(currentState, vectorPredicate) {
5200
5040
  return {
@@ -5351,7 +5191,9 @@ function compileQuery(ast, graphId, options = "sqlite") {
5351
5191
  const ctx = {
5352
5192
  dialect: adapter,
5353
5193
  schema,
5354
- compileQuery: (subAst, subGraphId) => compileQuery(subAst, subGraphId, propagateOptions(options_))
5194
+ compileQuery: (subAst, subGraphId) => compileQuery(subAst, subGraphId, propagateOptions(options_)),
5195
+ ...options_.vectorStrategy === void 0 ? {} : { vectorStrategy: options_.vectorStrategy },
5196
+ ...options_.vectorSlots === void 0 ? {} : { vectorSlots: options_.vectorSlots }
5355
5197
  };
5356
5198
  if (hasVariableLengthTraversal(ast)) {
5357
5199
  const lowered = tryLowerSingleHopRecursiveTraversal(ast);
@@ -5386,18 +5228,17 @@ function tryLowerSingleHopRecursiveTraversal(ast) {
5386
5228
  function compileSetOperation2(op, graphId, options = "sqlite") {
5387
5229
  const options_ = typeof options === "string" ? { dialect: options } : options;
5388
5230
  const dialect = options_.dialect ?? "sqlite";
5389
- const schema = options_.schema ?? DEFAULT_SQL_SCHEMA;
5390
5231
  const adapter = resolveDialectAdapter(dialect, options_.fulltextStrategy);
5391
5232
  return compileSetOperation(
5392
5233
  op,
5393
5234
  graphId,
5394
5235
  adapter,
5395
- schema,
5396
- (ast, gid) => compileQuery(ast, gid, propagateOptions(options_))
5236
+ (ast, gid) => compileQuery(ast, gid, propagateOptions(options_)),
5237
+ options_.vectorStrategy
5397
5238
  );
5398
5239
  }
5399
5240
  function resolveDialectAdapter(dialect, fulltextStrategy) {
5400
- const baseAdapter = chunkPN37HVAV_cjs.getDialect(dialect);
5241
+ const baseAdapter = chunkC2RWFIYP_cjs.getDialect(dialect);
5401
5242
  if (fulltextStrategy === void 0 || fulltextStrategy === baseAdapter.fulltext) {
5402
5243
  return baseAdapter;
5403
5244
  }
@@ -5407,7 +5248,9 @@ function propagateOptions(options_) {
5407
5248
  return {
5408
5249
  dialect: options_.dialect ?? "sqlite",
5409
5250
  ...options_.schema === void 0 ? {} : { schema: options_.schema },
5410
- ...options_.fulltextStrategy === void 0 ? {} : { fulltextStrategy: options_.fulltextStrategy }
5251
+ ...options_.fulltextStrategy === void 0 ? {} : { fulltextStrategy: options_.fulltextStrategy },
5252
+ ...options_.vectorStrategy === void 0 ? {} : { vectorStrategy: options_.vectorStrategy },
5253
+ ...options_.vectorSlots === void 0 ? {} : { vectorSlots: options_.vectorSlots }
5411
5254
  };
5412
5255
  }
5413
5256
  function resolveCountAggregateFastPath(ast) {
@@ -5428,7 +5271,7 @@ function resolveCountAggregateFastPath(ast) {
5428
5271
  return void 0;
5429
5272
  }
5430
5273
  const groupField = ast.groupBy.fields[0];
5431
- if (groupField.alias !== ast.start.alias || !chunkHTGDWIDE_cjs.isIdFieldRef(groupField)) {
5274
+ if (groupField.alias !== ast.start.alias || !chunkKGAJ5HFO_cjs.isIdFieldRef(groupField)) {
5432
5275
  return void 0;
5433
5276
  }
5434
5277
  let requiresNodeCount = false;
@@ -5437,13 +5280,13 @@ function resolveCountAggregateFastPath(ast) {
5437
5280
  let requiresEdgeCountDistinct = false;
5438
5281
  for (const projectedField of ast.projection.fields) {
5439
5282
  const source = projectedField.source;
5440
- if (!chunkHTGDWIDE_cjs.isAggregateExpr(source)) {
5283
+ if (!chunkKGAJ5HFO_cjs.isAggregateExpr(source)) {
5441
5284
  if (source.alias !== ast.start.alias) {
5442
5285
  return void 0;
5443
5286
  }
5444
5287
  continue;
5445
5288
  }
5446
- if (!chunkHTGDWIDE_cjs.isIdFieldRef(source.field)) {
5289
+ if (!chunkKGAJ5HFO_cjs.isIdFieldRef(source.field)) {
5447
5290
  return void 0;
5448
5291
  }
5449
5292
  const isNodeTarget = source.field.alias === traversal.nodeAlias;
@@ -5608,19 +5451,19 @@ function compileCountAggregateFastPath(ast, graphId, ctx, logicalPlan, requiredC
5608
5451
  const projection = drizzleOrm.sql.join(
5609
5452
  ast.projection.fields.map((projectedField) => {
5610
5453
  const source = projectedField.source;
5611
- if (!chunkHTGDWIDE_cjs.isAggregateExpr(source)) {
5454
+ if (!chunkKGAJ5HFO_cjs.isAggregateExpr(source)) {
5612
5455
  const value = compileFieldValue(
5613
5456
  source,
5614
5457
  dialect,
5615
5458
  source.valueType,
5616
5459
  `cte_${source.alias}`
5617
5460
  );
5618
- return drizzleOrm.sql`${value} AS ${chunkHTGDWIDE_cjs.quoteIdentifier(projectedField.outputName)}`;
5461
+ return drizzleOrm.sql`${value} AS ${chunkKGAJ5HFO_cjs.quoteIdentifier(projectedField.outputName)}`;
5619
5462
  }
5620
5463
  const projectedCountColumn = resolveCountColumn(source);
5621
5464
  const countValue = drizzleOrm.sql`${drizzleOrm.sql.raw(countCteAlias)}.${drizzleOrm.sql.raw(projectedCountColumn)}`;
5622
5465
  const aggregateValue = traversal.optional ? drizzleOrm.sql`COALESCE(${countValue}, 0)` : countValue;
5623
- return drizzleOrm.sql`${aggregateValue} AS ${chunkHTGDWIDE_cjs.quoteIdentifier(projectedField.outputName)}`;
5466
+ return drizzleOrm.sql`${aggregateValue} AS ${chunkKGAJ5HFO_cjs.quoteIdentifier(projectedField.outputName)}`;
5624
5467
  }),
5625
5468
  drizzleOrm.sql`, `
5626
5469
  );
@@ -5703,13 +5546,13 @@ function compileStandardQueryWithCteStrategy(ast, graphId, ctx) {
5703
5546
  vectorPredicate
5704
5547
  } = runStandardQueryPassPipeline(ast, graphId, ctx);
5705
5548
  if (temporalFilterPass === void 0) {
5706
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
5549
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
5707
5550
  "Temporal filter pass did not initialize temporal state",
5708
5551
  { phase: "standard-pass-pipeline" }
5709
5552
  );
5710
5553
  }
5711
5554
  if (logicalPlan === void 0) {
5712
- throw new chunkYEDQLNVE_cjs.CompilerInvariantError(
5555
+ throw new chunkG6P3OVDY_cjs.CompilerInvariantError(
5713
5556
  "Logical plan pass did not initialize plan state",
5714
5557
  { phase: "standard-pass-pipeline" }
5715
5558
  );
@@ -5836,7 +5679,7 @@ function decodeCursor(cursor) {
5836
5679
  const json = atob(base64);
5837
5680
  const raw = JSON.parse(json);
5838
5681
  if (typeof raw.v !== "number" || raw.v > CURSOR_VERSION) {
5839
- throw new chunkYEDQLNVE_cjs.ValidationError(
5682
+ throw new chunkG6P3OVDY_cjs.ValidationError(
5840
5683
  `Unsupported cursor version: ${String(raw.v)}. Maximum supported: ${CURSOR_VERSION}`,
5841
5684
  {
5842
5685
  issues: [
@@ -5852,7 +5695,7 @@ function decodeCursor(cursor) {
5852
5695
  );
5853
5696
  }
5854
5697
  if (raw.d !== "f" && raw.d !== "b") {
5855
- throw new chunkYEDQLNVE_cjs.ValidationError(`Invalid cursor direction: ${String(raw.d)}`, {
5698
+ throw new chunkG6P3OVDY_cjs.ValidationError(`Invalid cursor direction: ${String(raw.d)}`, {
5856
5699
  issues: [
5857
5700
  {
5858
5701
  path: "cursor",
@@ -5862,7 +5705,7 @@ function decodeCursor(cursor) {
5862
5705
  });
5863
5706
  }
5864
5707
  if (!Array.isArray(raw.vals) || !Array.isArray(raw.cols)) {
5865
- throw new chunkYEDQLNVE_cjs.ValidationError("Invalid cursor structure", {
5708
+ throw new chunkG6P3OVDY_cjs.ValidationError("Invalid cursor structure", {
5866
5709
  issues: [
5867
5710
  {
5868
5711
  path: "cursor",
@@ -5872,7 +5715,7 @@ function decodeCursor(cursor) {
5872
5715
  });
5873
5716
  }
5874
5717
  if (raw.vals.length !== raw.cols.length) {
5875
- throw new chunkYEDQLNVE_cjs.ValidationError("Cursor column count mismatch", {
5718
+ throw new chunkG6P3OVDY_cjs.ValidationError("Cursor column count mismatch", {
5876
5719
  issues: [
5877
5720
  {
5878
5721
  path: "cursor",
@@ -5888,10 +5731,10 @@ function decodeCursor(cursor) {
5888
5731
  cols: raw.cols
5889
5732
  };
5890
5733
  } catch (error) {
5891
- if (error instanceof chunkYEDQLNVE_cjs.ValidationError) {
5734
+ if (error instanceof chunkG6P3OVDY_cjs.ValidationError) {
5892
5735
  throw error;
5893
5736
  }
5894
- throw new chunkYEDQLNVE_cjs.ValidationError(
5737
+ throw new chunkG6P3OVDY_cjs.ValidationError(
5895
5738
  "Invalid cursor format",
5896
5739
  {
5897
5740
  issues: [{ path: "cursor", message: "Failed to decode cursor" }]
@@ -5955,7 +5798,7 @@ function buildCursorFromRow(row, orderSpecs, direction) {
5955
5798
  function validateCursorColumns(cursorData, orderSpecs) {
5956
5799
  const expectedCols = orderSpecs.map((spec) => buildColumnId(spec));
5957
5800
  if (cursorData.cols.length !== expectedCols.length) {
5958
- throw new chunkYEDQLNVE_cjs.ValidationError(
5801
+ throw new chunkG6P3OVDY_cjs.ValidationError(
5959
5802
  `Cursor has ${cursorData.cols.length} columns but query has ${expectedCols.length} ORDER BY columns`,
5960
5803
  {
5961
5804
  issues: [
@@ -5972,7 +5815,7 @@ function validateCursorColumns(cursorData, orderSpecs) {
5972
5815
  }
5973
5816
  for (const [index, expectedCol] of expectedCols.entries()) {
5974
5817
  if (cursorData.cols[index] !== expectedCol) {
5975
- throw new chunkYEDQLNVE_cjs.ValidationError(
5818
+ throw new chunkG6P3OVDY_cjs.ValidationError(
5976
5819
  `Cursor column mismatch at position ${index}: expected "${expectedCol}", got "${cursorData.cols[index]}"`,
5977
5820
  {
5978
5821
  issues: [
@@ -5995,14 +5838,14 @@ function generateId() {
5995
5838
 
5996
5839
  // src/utils/path.ts
5997
5840
  function parseSqlitePath(path) {
5998
- const emptyPath = `${chunkCTHNVU6K_cjs.SQLITE_PATH_DELIMITER}${chunkCTHNVU6K_cjs.SQLITE_PATH_DELIMITER}`;
5841
+ const emptyPath = `${chunkUPBXUOW7_cjs.SQLITE_PATH_DELIMITER}${chunkUPBXUOW7_cjs.SQLITE_PATH_DELIMITER}`;
5999
5842
  if (!path || path === emptyPath) return [];
6000
5843
  const trimmed = path.slice(1, -1);
6001
5844
  if (trimmed === "") return [];
6002
- return trimmed.split(chunkCTHNVU6K_cjs.SQLITE_PATH_DELIMITER);
5845
+ return trimmed.split(chunkUPBXUOW7_cjs.SQLITE_PATH_DELIMITER);
6003
5846
  }
6004
5847
  function isSqlitePath(value) {
6005
- return typeof value === "string" && value.startsWith(chunkCTHNVU6K_cjs.SQLITE_PATH_DELIMITER) && value.endsWith(chunkCTHNVU6K_cjs.SQLITE_PATH_DELIMITER);
5848
+ return typeof value === "string" && value.startsWith(chunkUPBXUOW7_cjs.SQLITE_PATH_DELIMITER) && value.endsWith(chunkUPBXUOW7_cjs.SQLITE_PATH_DELIMITER);
6006
5849
  }
6007
5850
  function normalizePath(value) {
6008
5851
  if (Array.isArray(value)) {
@@ -6017,12 +5860,12 @@ function normalizePath(value) {
6017
5860
  return [];
6018
5861
  }
6019
5862
  function isPostgresTextArray(value) {
6020
- return typeof value === "string" && value.startsWith(chunkCTHNVU6K_cjs.PG_ARRAY_START) && value.endsWith(chunkCTHNVU6K_cjs.PG_ARRAY_END);
5863
+ return typeof value === "string" && value.startsWith(chunkUPBXUOW7_cjs.PG_ARRAY_START) && value.endsWith(chunkUPBXUOW7_cjs.PG_ARRAY_END);
6021
5864
  }
6022
5865
  function parsePostgresTextArray(value) {
6023
5866
  const inner = value.slice(1, -1);
6024
5867
  if (inner === "") return [];
6025
- return inner.split(chunkCTHNVU6K_cjs.PG_PATH_ELEMENT_SEPARATOR);
5868
+ return inner.split(chunkUPBXUOW7_cjs.PG_PATH_ELEMENT_SEPARATOR);
6026
5869
  }
6027
5870
 
6028
5871
  // src/query/execution/result-mapper.ts
@@ -6259,7 +6102,7 @@ async function* createStreamIterable(batchSize, paginate) {
6259
6102
  }
6260
6103
  }
6261
6104
  function getStreamBatchSize(options) {
6262
- return options?.batchSize ?? chunkCTHNVU6K_cjs.DEFAULT_STREAM_BATCH_SIZE;
6105
+ return options?.batchSize ?? chunkUPBXUOW7_cjs.DEFAULT_STREAM_BATCH_SIZE;
6263
6106
  }
6264
6107
 
6265
6108
  // src/query/execution/field-tracker.ts
@@ -6341,7 +6184,7 @@ function createNodeTrackingProxy(alias, kindNames, tracker, options) {
6341
6184
  return getPlaceholderForSystemField(property, options.mode);
6342
6185
  }
6343
6186
  if (property === "meta") {
6344
- for (const key of chunkCTHNVU6K_cjs.NODE_META_KEYS) {
6187
+ for (const key of chunkUPBXUOW7_cjs.NODE_META_KEYS) {
6345
6188
  tracker.record(alias, `meta.${key}`, true);
6346
6189
  }
6347
6190
  return buildNodeMetaPlaceholder(options.mode);
@@ -6374,7 +6217,7 @@ function createEdgeTrackingProxy(alias, edgeKindNames, tracker, options) {
6374
6217
  return getPlaceholderForSystemField(property, options.mode);
6375
6218
  }
6376
6219
  if (property === "meta") {
6377
- for (const key of chunkCTHNVU6K_cjs.EDGE_META_KEYS) {
6220
+ for (const key of chunkUPBXUOW7_cjs.EDGE_META_KEYS) {
6378
6221
  tracker.record(alias, `meta.${key}`, true);
6379
6222
  }
6380
6223
  return buildEdgeMetaPlaceholder(options.mode);
@@ -6772,7 +6615,7 @@ var SQL_RESERVED_KEYWORDS = /* @__PURE__ */ new Set([
6772
6615
  ]);
6773
6616
  function validateSqlIdentifier(alias) {
6774
6617
  if (!SQL_IDENTIFIER_PATTERN.test(alias)) {
6775
- throw new chunkYEDQLNVE_cjs.ValidationError(
6618
+ throw new chunkG6P3OVDY_cjs.ValidationError(
6776
6619
  `Invalid alias "${alias}": must start with a letter or underscore, contain only letters, digits, and underscores, and be at most 63 characters`,
6777
6620
  {
6778
6621
  issues: [
@@ -6788,7 +6631,7 @@ function validateSqlIdentifier(alias) {
6788
6631
  );
6789
6632
  }
6790
6633
  if (alias.toLowerCase().startsWith("cte_")) {
6791
- throw new chunkYEDQLNVE_cjs.ValidationError(
6634
+ throw new chunkG6P3OVDY_cjs.ValidationError(
6792
6635
  `Invalid alias "${alias}": aliases starting with "cte_" are reserved for internal use`,
6793
6636
  {
6794
6637
  issues: [
@@ -6804,7 +6647,7 @@ function validateSqlIdentifier(alias) {
6804
6647
  );
6805
6648
  }
6806
6649
  if (SQL_RESERVED_KEYWORDS.has(alias.toLowerCase())) {
6807
- throw new chunkYEDQLNVE_cjs.ValidationError(
6650
+ throw new chunkG6P3OVDY_cjs.ValidationError(
6808
6651
  `Invalid alias "${alias}": "${alias}" is a reserved SQL keyword`,
6809
6652
  {
6810
6653
  issues: [
@@ -6873,7 +6716,7 @@ function validateStructuralPredicatePlacement(expression, matchType, buildError,
6873
6716
  }
6874
6717
  }
6875
6718
  function throwInvalidVectorPredicatePlacement(path) {
6876
- throw new chunkYEDQLNVE_cjs.ValidationError(
6719
+ throw new chunkG6P3OVDY_cjs.ValidationError(
6877
6720
  "Vector similarity predicates cannot be nested under OR or NOT. Use top-level AND combinations instead.",
6878
6721
  {
6879
6722
  issues: [
@@ -6889,7 +6732,7 @@ function throwInvalidVectorPredicatePlacement(path) {
6889
6732
  );
6890
6733
  }
6891
6734
  function throwInvalidFulltextPredicatePlacement(path) {
6892
- throw new chunkYEDQLNVE_cjs.ValidationError(
6735
+ throw new chunkG6P3OVDY_cjs.ValidationError(
6893
6736
  "Fulltext match predicates (.matches()) cannot be nested under OR or NOT. Use top-level AND combinations instead.",
6894
6737
  {
6895
6738
  issues: [
@@ -6929,13 +6772,13 @@ function validateFulltextPredicatePlacement(predicates) {
6929
6772
  function validateHybridFusionOptions(options) {
6930
6773
  const method = options.method;
6931
6774
  if (method !== void 0 && method !== "rrf") {
6932
- throw new chunkYEDQLNVE_cjs.ValidationError(`Unsupported fusion method: ${method}`, {
6775
+ throw new chunkG6P3OVDY_cjs.ValidationError(`Unsupported fusion method: ${method}`, {
6933
6776
  issues: [{ path: "fusion.method", message: `Only "rrf" is supported.` }]
6934
6777
  });
6935
6778
  }
6936
6779
  const { k } = options;
6937
6780
  if (k !== void 0 && (!Number.isFinite(k) || k <= 0)) {
6938
- throw new chunkYEDQLNVE_cjs.ValidationError(
6781
+ throw new chunkG6P3OVDY_cjs.ValidationError(
6939
6782
  `Fusion k must be a positive finite number, got: ${String(k)}`,
6940
6783
  {
6941
6784
  issues: [{ path: "fusion.k", message: "Must be a positive number." }]
@@ -6947,7 +6790,7 @@ function validateHybridFusionOptions(options) {
6947
6790
  for (const key of ["vector", "fulltext"]) {
6948
6791
  const weight = weights[key];
6949
6792
  if (weight !== void 0 && (!Number.isFinite(weight) || weight < 0)) {
6950
- throw new chunkYEDQLNVE_cjs.ValidationError(
6793
+ throw new chunkG6P3OVDY_cjs.ValidationError(
6951
6794
  `Fusion weight for "${key}" must be a non-negative finite number, got: ${String(weight)}`,
6952
6795
  {
6953
6796
  issues: [
@@ -6998,15 +6841,34 @@ function buildQueryAst(config, state) {
6998
6841
  // src/query/builder/compile-options.ts
6999
6842
  function buildCompileOptions(config) {
7000
6843
  const fulltextStrategy = config.backend?.fulltextStrategy;
6844
+ const vectorStrategy = config.backend?.vectorStrategy;
7001
6845
  return {
7002
6846
  dialect: config.dialect ?? "sqlite",
7003
6847
  schema: config.schema,
7004
- ...fulltextStrategy === void 0 ? {} : { fulltextStrategy }
6848
+ ...fulltextStrategy === void 0 ? {} : { fulltextStrategy },
6849
+ ...vectorStrategy === void 0 ? {} : { vectorStrategy, vectorSlots: buildVectorSlots(config.registry) }
7005
6850
  };
7006
6851
  }
6852
+ var vectorSlotsCache = /* @__PURE__ */ new WeakMap();
6853
+ function buildVectorSlots(registry) {
6854
+ const cached = vectorSlotsCache.get(registry);
6855
+ if (cached !== void 0) return cached;
6856
+ const slots = /* @__PURE__ */ new Map();
6857
+ for (const [nodeKind, nodeType] of registry.nodeKinds) {
6858
+ for (const field2 of chunkZFWNO3GE_cjs.resolveEmbeddingFields(nodeType.schema)) {
6859
+ slots.set(vectorSlotKey(nodeKind, field2.fieldPath), {
6860
+ dimensions: field2.dimensions,
6861
+ metric: field2.metric,
6862
+ indexType: field2.indexType
6863
+ });
6864
+ }
6865
+ }
6866
+ vectorSlotsCache.set(registry, slots);
6867
+ return slots;
6868
+ }
7007
6869
  function toLiteral(value) {
7008
6870
  if (value === null) {
7009
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
6871
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
7010
6872
  "Parameter value must not be null (use undefined-based patterns instead)",
7011
6873
  { parameterName: "value", valueType: "null" }
7012
6874
  );
@@ -7023,7 +6885,7 @@ function toLiteral(value) {
7023
6885
  if (typeof value === "boolean") {
7024
6886
  return { __type: "literal", value, valueType: "boolean" };
7025
6887
  }
7026
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
6888
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
7027
6889
  `Unsupported parameter value type: ${typeof value}`,
7028
6890
  { parameterName: "value", actualType: typeof value }
7029
6891
  );
@@ -7034,7 +6896,7 @@ function substitutePredicateExpression(expr, bindings) {
7034
6896
  if (isParameterRef(expr.right)) {
7035
6897
  const value = bindings[expr.right.name];
7036
6898
  if (value === void 0) {
7037
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
6899
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
7038
6900
  `Missing binding for parameter "${expr.right.name}"`,
7039
6901
  { parameterName: expr.right.name }
7040
6902
  );
@@ -7050,13 +6912,13 @@ function substitutePredicateExpression(expr, bindings) {
7050
6912
  if (isParameterRef(expr.pattern)) {
7051
6913
  const value = bindings[expr.pattern.name];
7052
6914
  if (value === void 0) {
7053
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
6915
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
7054
6916
  `Missing binding for parameter "${expr.pattern.name}"`,
7055
6917
  { parameterName: expr.pattern.name }
7056
6918
  );
7057
6919
  }
7058
6920
  if (typeof value !== "string") {
7059
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
6921
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
7060
6922
  `Parameter "${expr.pattern.name}" must be a string for string operations`,
7061
6923
  { parameterName: expr.pattern.name, actualType: typeof value }
7062
6924
  );
@@ -7124,7 +6986,7 @@ function substitutePredicateExpression(expr, bindings) {
7124
6986
  function resolveBinding(bindings, name) {
7125
6987
  const value = bindings[name];
7126
6988
  if (value === void 0) {
7127
- throw new chunkYEDQLNVE_cjs.ConfigurationError(`Missing binding for parameter "${name}"`, {
6989
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(`Missing binding for parameter "${name}"`, {
7128
6990
  parameterName: name
7129
6991
  });
7130
6992
  }
@@ -7143,13 +7005,13 @@ function substituteParameters(ast, bindings) {
7143
7005
  };
7144
7006
  }
7145
7007
  function fillPlaceholders(params, bindings, dialect) {
7146
- const adapter = chunkPN37HVAV_cjs.getDialect(dialect);
7008
+ const adapter = chunkC2RWFIYP_cjs.getDialect(dialect);
7147
7009
  return params.map((parameter) => {
7148
7010
  if (parameter instanceof drizzleOrm.Placeholder) {
7149
7011
  const name = parameter.name;
7150
7012
  const value = bindings[name];
7151
7013
  if (value === void 0) {
7152
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
7014
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
7153
7015
  `Missing binding for parameter "${name}"`,
7154
7016
  { parameterName: name }
7155
7017
  );
@@ -7216,7 +7078,7 @@ var PreparedQuery = class {
7216
7078
  this.#selectFn
7217
7079
  );
7218
7080
  } catch (error) {
7219
- if (error instanceof MissingSelectiveFieldError || error instanceof chunkYEDQLNVE_cjs.UnsupportedPredicateError) {
7081
+ if (error instanceof MissingSelectiveFieldError || error instanceof chunkG6P3OVDY_cjs.UnsupportedPredicateError) {
7220
7082
  return this.#executeUnoptimized(bindings);
7221
7083
  }
7222
7084
  throw error;
@@ -7387,7 +7249,7 @@ function validateBindings(bindings, metadata) {
7387
7249
  }
7388
7250
  }
7389
7251
  if (missing.length > 0) {
7390
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
7252
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
7391
7253
  `Missing bindings for parameter${missing.length === 1 ? "" : "s"}: ${missing.map((name) => `"${name}"`).join(", ")}`,
7392
7254
  { missingParameters: missing }
7393
7255
  );
@@ -7396,7 +7258,7 @@ function validateBindings(bindings, metadata) {
7396
7258
  (name) => !expectedNames.has(name)
7397
7259
  );
7398
7260
  if (unexpected.length > 0) {
7399
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
7261
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
7400
7262
  `Unexpected bindings provided: ${unexpected.map((name) => `"${name}"`).join(", ")}`,
7401
7263
  { unexpectedParameters: unexpected }
7402
7264
  );
@@ -7408,14 +7270,14 @@ function validateBindings(bindings, metadata) {
7408
7270
  }
7409
7271
  function validateBindingValue(name, value, isStringOp) {
7410
7272
  if (value === null) {
7411
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
7273
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
7412
7274
  "Parameter value must not be null (use undefined-based patterns instead)",
7413
7275
  { parameterName: name, valueType: "null" }
7414
7276
  );
7415
7277
  }
7416
7278
  if (isStringOp) {
7417
7279
  if (typeof value !== "string") {
7418
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
7280
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
7419
7281
  `Parameter "${name}" must be a string for string operations`,
7420
7282
  { parameterName: name, actualType: typeof value }
7421
7283
  );
@@ -7425,7 +7287,7 @@ function validateBindingValue(name, value, isStringOp) {
7425
7287
  if (value instanceof Date || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
7426
7288
  return;
7427
7289
  }
7428
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
7290
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
7429
7291
  `Unsupported parameter value type: ${typeof value}`,
7430
7292
  { parameterName: name, actualType: typeof value }
7431
7293
  );
@@ -7831,7 +7693,7 @@ var ExecutableQuery = class _ExecutableQuery {
7831
7693
  this.#cachedOptimizedCompiled = NOT_COMPUTED;
7832
7694
  return void 0;
7833
7695
  }
7834
- if (error instanceof chunkYEDQLNVE_cjs.UnsupportedPredicateError) {
7696
+ if (error instanceof chunkG6P3OVDY_cjs.UnsupportedPredicateError) {
7835
7697
  this.#cachedSelectiveFieldsForExecute = void 0;
7836
7698
  this.#cachedOptimizedCompiled = NOT_COMPUTED;
7837
7699
  return void 0;
@@ -7881,7 +7743,7 @@ var ExecutableQuery = class _ExecutableQuery {
7881
7743
  this.#cachedOptimizedCompiled = NOT_COMPUTED;
7882
7744
  return void 0;
7883
7745
  }
7884
- if (error instanceof chunkYEDQLNVE_cjs.UnsupportedPredicateError) {
7746
+ if (error instanceof chunkG6P3OVDY_cjs.UnsupportedPredicateError) {
7885
7747
  this.#cachedSelectiveFieldsForExecute = void 0;
7886
7748
  this.#cachedOptimizedCompiled = NOT_COMPUTED;
7887
7749
  return void 0;
@@ -8015,7 +7877,7 @@ var ExecutableQuery = class _ExecutableQuery {
8015
7877
  selectiveFields
8016
7878
  });
8017
7879
  } catch (error) {
8018
- if (error instanceof chunkYEDQLNVE_cjs.UnsupportedPredicateError) {
7880
+ if (error instanceof chunkG6P3OVDY_cjs.UnsupportedPredicateError) {
8019
7881
  this.#cachedSelectiveFieldsForPagination = void 0;
8020
7882
  return void 0;
8021
7883
  }
@@ -8041,7 +7903,7 @@ var ExecutableQuery = class _ExecutableQuery {
8041
7903
  this.#cachedSelectiveFieldsForPagination = void 0;
8042
7904
  return void 0;
8043
7905
  }
8044
- if (error instanceof chunkYEDQLNVE_cjs.UnsupportedPredicateError) {
7906
+ if (error instanceof chunkG6P3OVDY_cjs.UnsupportedPredicateError) {
8045
7907
  this.#cachedSelectiveFieldsForPagination = void 0;
8046
7908
  return void 0;
8047
7909
  }
@@ -8066,7 +7928,7 @@ var ExecutableQuery = class _ExecutableQuery {
8066
7928
  this.#cachedSelectiveFieldsForPagination = void 0;
8067
7929
  return void 0;
8068
7930
  }
8069
- if (error instanceof chunkYEDQLNVE_cjs.UnsupportedPredicateError) {
7931
+ if (error instanceof chunkG6P3OVDY_cjs.UnsupportedPredicateError) {
8070
7932
  this.#cachedSelectiveFieldsForPagination = void 0;
8071
7933
  return void 0;
8072
7934
  }
@@ -8222,7 +8084,7 @@ var ExecutableQuery = class _ExecutableQuery {
8222
8084
  );
8223
8085
  }
8224
8086
  if (this.#state.orderBy.length === 0) {
8225
- throw new chunkYEDQLNVE_cjs.ValidationError(
8087
+ throw new chunkG6P3OVDY_cjs.ValidationError(
8226
8088
  "Cursor pagination requires ORDER BY. Add .orderBy() before .paginate()",
8227
8089
  {
8228
8090
  issues: [
@@ -8238,7 +8100,7 @@ var ExecutableQuery = class _ExecutableQuery {
8238
8100
  );
8239
8101
  }
8240
8102
  const isBackward = options.last !== void 0 || options.before !== void 0;
8241
- const limit = options.first ?? options.last ?? chunkCTHNVU6K_cjs.DEFAULT_PAGINATION_LIMIT;
8103
+ const limit = options.first ?? options.last ?? chunkUPBXUOW7_cjs.DEFAULT_PAGINATION_LIMIT;
8242
8104
  const cursor = options.after ?? options.before;
8243
8105
  let cursorData;
8244
8106
  if (cursor) {
@@ -8298,7 +8160,7 @@ var ExecutableQuery = class _ExecutableQuery {
8298
8160
  */
8299
8161
  stream(options) {
8300
8162
  if (this.#state.orderBy.length === 0) {
8301
- throw new chunkYEDQLNVE_cjs.ValidationError(
8163
+ throw new chunkG6P3OVDY_cjs.ValidationError(
8302
8164
  "Streaming requires ORDER BY. Add .orderBy() before .stream()",
8303
8165
  {
8304
8166
  issues: [
@@ -8770,7 +8632,7 @@ var TraversalBuilder = class _TraversalBuilder {
8770
8632
  toDynamic(kind, alias, options) {
8771
8633
  validateSqlIdentifier(alias);
8772
8634
  if (!this.#config.registry.hasNodeType(kind)) {
8773
- throw new chunkYEDQLNVE_cjs.KindNotFoundError(kind, "node", {
8635
+ throw new chunkG6P3OVDY_cjs.KindNotFoundError(kind, "node", {
8774
8636
  graphId: this.#config.graphId
8775
8637
  });
8776
8638
  }
@@ -8855,7 +8717,7 @@ var TraversalBuilder = class _TraversalBuilder {
8855
8717
  for (const expected of expectedKinds) {
8856
8718
  if (this.#config.registry.isAssignableTo(targetKind, expected)) return;
8857
8719
  }
8858
- throw new chunkYEDQLNVE_cjs.EndpointError({
8720
+ throw new chunkG6P3OVDY_cjs.EndpointError({
8859
8721
  edgeKind: this.#edgeKinds[0] ?? "(unknown)",
8860
8722
  endpoint: forwardSide,
8861
8723
  actualKind: targetKind,
@@ -8988,7 +8850,7 @@ var QueryBuilder = class _QueryBuilder {
8988
8850
  fromDynamic(kind, alias, options) {
8989
8851
  validateSqlIdentifier(alias);
8990
8852
  if (!this.#config.registry.hasNodeType(kind)) {
8991
- throw new chunkYEDQLNVE_cjs.KindNotFoundError(kind, "node", {
8853
+ throw new chunkG6P3OVDY_cjs.KindNotFoundError(kind, "node", {
8992
8854
  graphId: this.#config.graphId
8993
8855
  });
8994
8856
  }
@@ -9118,7 +8980,7 @@ var QueryBuilder = class _QueryBuilder {
9118
8980
  #beginDynamicTraversal(edgeKind, edgeAlias, optional, options) {
9119
8981
  validateSqlIdentifier(edgeAlias);
9120
8982
  if (!this.#config.registry.hasEdgeType(edgeKind)) {
9121
- throw new chunkYEDQLNVE_cjs.KindNotFoundError(edgeKind, "edge", {
8983
+ throw new chunkG6P3OVDY_cjs.KindNotFoundError(edgeKind, "edge", {
9122
8984
  graphId: this.#config.graphId
9123
8985
  });
9124
8986
  }
@@ -9278,7 +9140,7 @@ var QueryBuilder = class _QueryBuilder {
9278
9140
  */
9279
9141
  temporal(mode, asOf) {
9280
9142
  if (mode === "asOf" && asOf === void 0) {
9281
- throw new chunkYEDQLNVE_cjs.ValidationError(
9143
+ throw new chunkG6P3OVDY_cjs.ValidationError(
9282
9144
  'Temporal mode "asOf" requires a timestamp',
9283
9145
  {
9284
9146
  issues: [
@@ -9957,7 +9819,7 @@ setUnionableQueryClass(UnionableQuery);
9957
9819
 
9958
9820
  // src/query/builder.ts
9959
9821
  function createQueryBuilder(graphId, registry, options) {
9960
- const schemaIntrospector = chunkEK6RJ373_cjs.createSchemaIntrospector(
9822
+ const schemaIntrospector = chunkVGU26WIU_cjs.createSchemaIntrospector(
9961
9823
  registry.nodeKinds,
9962
9824
  registry.edgeKinds
9963
9825
  );
@@ -9996,12 +9858,12 @@ function createQueryBuilder(graphId, registry, options) {
9996
9858
  function buildKindRegistry(graph) {
9997
9859
  const nodeTypes = extractNodeTypes(graph);
9998
9860
  const edgeTypes = extractEdgeTypes(graph);
9999
- const closures = graph.ontology.length > 0 ? chunkZGEMI7MJ_cjs.computeClosuresFromOntology(graph.ontology) : chunkZGEMI7MJ_cjs.createEmptyClosures();
10000
- return new chunkZGEMI7MJ_cjs.KindRegistry(nodeTypes, edgeTypes, closures);
9861
+ const closures = graph.ontology.length > 0 ? chunkXTQHSOIC_cjs.computeClosuresFromOntology(graph.ontology) : chunkXTQHSOIC_cjs.createEmptyClosures();
9862
+ return new chunkXTQHSOIC_cjs.KindRegistry(nodeTypes, edgeTypes, closures);
10001
9863
  }
10002
9864
  function extractNodeTypes(graph) {
10003
9865
  const result = /* @__PURE__ */ new Map();
10004
- for (const typeName of chunkWFUN6DCM_cjs.getNodeKinds(graph)) {
9866
+ for (const typeName of chunkR2LA6MKR_cjs.getNodeKinds(graph)) {
10005
9867
  const registration = graph.nodes[typeName];
10006
9868
  result.set(typeName, registration.type);
10007
9869
  }
@@ -10009,7 +9871,7 @@ function extractNodeTypes(graph) {
10009
9871
  }
10010
9872
  function extractEdgeTypes(graph) {
10011
9873
  const result = /* @__PURE__ */ new Map();
10012
- for (const typeName of chunkWFUN6DCM_cjs.getEdgeKinds(graph)) {
9874
+ for (const typeName of chunkR2LA6MKR_cjs.getEdgeKinds(graph)) {
10013
9875
  const registration = graph.edges[typeName];
10014
9876
  result.set(typeName, registration.type);
10015
9877
  }
@@ -10038,19 +9900,19 @@ function resolveTemporalFilter(ctx, options, tableAlias) {
10038
9900
  function resolveMaxHops(rawMaxHops, fallback, optionName) {
10039
9901
  const value = rawMaxHops ?? fallback;
10040
9902
  if (!Number.isFinite(value) || !Number.isInteger(value)) {
10041
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
9903
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
10042
9904
  `Graph algorithm ${optionName} must be a finite integer, got ${String(value)}.`,
10043
9905
  { option: optionName, value }
10044
9906
  );
10045
9907
  }
10046
9908
  if (value < 1) {
10047
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
9909
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
10048
9910
  `Graph algorithm ${optionName} must be at least 1, got ${value}.`,
10049
9911
  { option: optionName, value }
10050
9912
  );
10051
9913
  }
10052
9914
  if (value > MAX_EXPLICIT_RECURSIVE_DEPTH) {
10053
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
9915
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
10054
9916
  `Graph algorithm ${optionName} (${value}) exceeds the maximum of ${MAX_EXPLICIT_RECURSIVE_DEPTH}.`,
10055
9917
  { option: optionName, value, limit: MAX_EXPLICIT_RECURSIVE_DEPTH }
10056
9918
  );
@@ -10059,7 +9921,7 @@ function resolveMaxHops(rawMaxHops, fallback, optionName) {
10059
9921
  }
10060
9922
  function assertEdgeKinds(edges) {
10061
9923
  if (edges.length === 0) {
10062
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
9924
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
10063
9925
  `Graph algorithms require at least one edge kind in 'edges'.`,
10064
9926
  { edges }
10065
9927
  );
@@ -10223,7 +10085,7 @@ function createGraphAlgorithms(params) {
10223
10085
  const ctx = {
10224
10086
  graphId: params.graphId,
10225
10087
  backend: params.backend,
10226
- dialect: chunkPN37HVAV_cjs.getDialect(params.backend.dialect),
10088
+ dialect: chunkC2RWFIYP_cjs.getDialect(params.backend.dialect),
10227
10089
  schema: params.schema ?? (params.backend.tableNames ? createSqlSchema(params.backend.tableNames) : createSqlSchema()),
10228
10090
  defaultTemporalMode: params.defaultTemporalMode
10229
10091
  };
@@ -10416,7 +10278,7 @@ function createEdgeCollection(config) {
10416
10278
  async find(options) {
10417
10279
  const untypedOptions = options;
10418
10280
  if (untypedOptions?.where !== void 0) {
10419
- throw new chunkYEDQLNVE_cjs.UnsupportedPredicateError(
10281
+ throw new chunkG6P3OVDY_cjs.UnsupportedPredicateError(
10420
10282
  `store.edges.${kind}.find({ where }) is not supported. Use store.query().traverse(...).whereEdge(...) for edge property filters.`,
10421
10283
  { kind, operation: "find" }
10422
10284
  );
@@ -10429,7 +10291,7 @@ function createEdgeCollection(config) {
10429
10291
  temporalMode: mode
10430
10292
  };
10431
10293
  if (mode === "current" || mode === "asOf") {
10432
- params.asOf = options?.asOf ?? chunkWFUN6DCM_cjs.nowIso();
10294
+ params.asOf = options?.asOf ?? chunkR2LA6MKR_cjs.nowIso();
10433
10295
  }
10434
10296
  if (options?.from?.kind !== void 0)
10435
10297
  params.fromKind = options.from.kind;
@@ -10450,7 +10312,7 @@ function createEdgeCollection(config) {
10450
10312
  temporalMode: mode
10451
10313
  };
10452
10314
  if (mode === "current" || mode === "asOf") {
10453
- params.asOf = options?.asOf ?? chunkWFUN6DCM_cjs.nowIso();
10315
+ params.asOf = options?.asOf ?? chunkR2LA6MKR_cjs.nowIso();
10454
10316
  }
10455
10317
  if (options?.from?.kind !== void 0)
10456
10318
  params.fromKind = options.from.kind;
@@ -10722,7 +10584,7 @@ function createNodeCollection(config) {
10722
10584
  },
10723
10585
  async find(options) {
10724
10586
  if (options?.where !== void 0 && createQuery === void 0) {
10725
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
10587
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
10726
10588
  `store.nodes.${kind}.find({ where }) requires a query-capable store`,
10727
10589
  { kind, operation: "find" }
10728
10590
  );
@@ -10731,7 +10593,7 @@ function createNodeCollection(config) {
10731
10593
  const mode2 = options.temporalMode ?? defaultTemporalMode;
10732
10594
  let query = createQuery().from(kind, "_n").temporal(
10733
10595
  mode2,
10734
- mode2 === "asOf" ? options.asOf ?? chunkWFUN6DCM_cjs.nowIso() : void 0
10596
+ mode2 === "asOf" ? options.asOf ?? chunkR2LA6MKR_cjs.nowIso() : void 0
10735
10597
  ).whereNode("_n", options.where).select((ctx) => ctx._n);
10736
10598
  if (options.limit !== void 0) query = query.limit(options.limit);
10737
10599
  if (options.offset !== void 0) query = query.offset(options.offset);
@@ -10746,7 +10608,7 @@ function createNodeCollection(config) {
10746
10608
  temporalMode: mode
10747
10609
  };
10748
10610
  if (mode === "current" || mode === "asOf") {
10749
- params.asOf = options?.asOf ?? chunkWFUN6DCM_cjs.nowIso();
10611
+ params.asOf = options?.asOf ?? chunkR2LA6MKR_cjs.nowIso();
10750
10612
  }
10751
10613
  if (options?.limit !== void 0) params.limit = options.limit;
10752
10614
  if (options?.offset !== void 0) params.offset = options.offset;
@@ -10762,7 +10624,7 @@ function createNodeCollection(config) {
10762
10624
  temporalMode: mode
10763
10625
  };
10764
10626
  if (mode === "current" || mode === "asOf") {
10765
- params.asOf = options?.asOf ?? chunkWFUN6DCM_cjs.nowIso();
10627
+ params.asOf = options?.asOf ?? chunkR2LA6MKR_cjs.nowIso();
10766
10628
  }
10767
10629
  return backend.countNodesByKind(params);
10768
10630
  },
@@ -10949,7 +10811,7 @@ function createNodeCollectionsProxy(graph, graphId, registry, backend, operation
10949
10811
  return new Proxy({}, {
10950
10812
  get: (_, kind) => {
10951
10813
  if (!Object.hasOwn(graph.nodes, kind)) {
10952
- throw new chunkYEDQLNVE_cjs.KindNotFoundError(kind, "node");
10814
+ throw new chunkG6P3OVDY_cjs.KindNotFoundError(kind, "node");
10953
10815
  }
10954
10816
  const cached = collectionCache.get(kind);
10955
10817
  if (cached !== void 0) {
@@ -10971,7 +10833,7 @@ function createEdgeCollectionsProxy(graph, graphId, registry, backend, operation
10971
10833
  return new Proxy({}, {
10972
10834
  get: (_, kind) => {
10973
10835
  if (!Object.hasOwn(graph.edges, kind)) {
10974
- throw new chunkYEDQLNVE_cjs.KindNotFoundError(kind, "edge");
10836
+ throw new chunkG6P3OVDY_cjs.KindNotFoundError(kind, "edge");
10975
10837
  }
10976
10838
  const cached = collectionCache.get(kind);
10977
10839
  if (cached !== void 0) {
@@ -10992,7 +10854,7 @@ function createEdgeCollectionsProxy(graph, graphId, registry, backend, operation
10992
10854
  // src/store/introspect.ts
10993
10855
  function introspectSchema(graph, context) {
10994
10856
  const extension = graph.extension;
10995
- const { nodes: runtimeNodeNames, edges: runtimeEdgeNames } = chunkZGEMI7MJ_cjs.extensionKindNames(extension);
10857
+ const { nodes: runtimeNodeNames, edges: runtimeEdgeNames } = chunkXTQHSOIC_cjs.extensionKindNames(extension);
10996
10858
  const deprecated = graph.deprecatedKinds;
10997
10859
  const kinds = [];
10998
10860
  for (const [name, registration] of Object.entries(graph.nodes)) {
@@ -11003,7 +10865,7 @@ function introspectSchema(graph, context) {
11003
10865
  description: reg.type.description,
11004
10866
  annotations: reg.type.annotations,
11005
10867
  deprecated: deprecated.has(name),
11006
- properties: chunkZGEMI7MJ_cjs.serializeSchemaProperties(reg.type.schema),
10868
+ properties: chunkXTQHSOIC_cjs.serializeSchemaProperties(reg.type.schema),
11007
10869
  unique: (reg.unique ?? []).map((constraint) => ({
11008
10870
  name: constraint.name,
11009
10871
  fields: [...constraint.fields],
@@ -11024,17 +10886,17 @@ function introspectSchema(graph, context) {
11024
10886
  to: reg.to.map((entry2) => entry2.kind),
11025
10887
  cardinality: reg.cardinality ?? "many",
11026
10888
  endpointExistence: reg.endpointExistence ?? "notDeleted",
11027
- properties: chunkZGEMI7MJ_cjs.serializeSchemaProperties(edgeType.schema),
10889
+ properties: chunkXTQHSOIC_cjs.serializeSchemaProperties(edgeType.schema),
11028
10890
  annotations: edgeType.annotations,
11029
10891
  deprecated: deprecated.has(name)
11030
10892
  });
11031
10893
  }
11032
- const runtimeOntologyKeys = chunkZGEMI7MJ_cjs.buildGraphExtensionOntologyKeySet(extension);
10894
+ const runtimeOntologyKeys = chunkXTQHSOIC_cjs.buildGraphExtensionOntologyKeySet(extension);
11033
10895
  const ontology = graph.ontology.map((relation) => ({
11034
10896
  metaEdge: relation.metaEdge.name,
11035
- from: chunkZGEMI7MJ_cjs.getTypeName(relation.from),
11036
- to: chunkZGEMI7MJ_cjs.getTypeName(relation.to),
11037
- origin: runtimeOntologyKeys.has(chunkZGEMI7MJ_cjs.compileTimeOntologyKey(relation)) ? "runtime" : "compile-time"
10897
+ from: chunkXTQHSOIC_cjs.getTypeName(relation.from),
10898
+ to: chunkXTQHSOIC_cjs.getTypeName(relation.to),
10899
+ origin: runtimeOntologyKeys.has(chunkXTQHSOIC_cjs.compileTimeOntologyKey(relation)) ? "runtime" : "compile-time"
11038
10900
  }));
11039
10901
  return {
11040
10902
  graphId: context.graphId,
@@ -11073,13 +10935,13 @@ async function runMaterialization(items, options, runOne) {
11073
10935
  async function materializeIndexes(context, options = {}) {
11074
10936
  const { graph, graphId, backend, schemaVersion } = context;
11075
10937
  if (backend.executeDdl === void 0) {
11076
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
10938
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
11077
10939
  "store.materializeIndexes() requires a backend with `executeDdl` support. The bundled SQLite and Postgres backends provide it; a custom backend without `executeDdl` cannot run index DDL.",
11078
10940
  { code: "MATERIALIZE_BACKEND_UNSUPPORTED" }
11079
10941
  );
11080
10942
  }
11081
10943
  if (backend.getIndexMaterialization === void 0 || backend.recordIndexMaterialization === void 0) {
11082
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
10944
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
11083
10945
  "store.materializeIndexes() requires a backend with index materialization status primitives. The bundled SQLite and Postgres backends provide them; a custom backend must implement `getIndexMaterialization` and `recordIndexMaterialization`.",
11084
10946
  { code: "MATERIALIZE_BACKEND_UNSUPPORTED" }
11085
10947
  );
@@ -11088,8 +10950,8 @@ async function materializeIndexes(context, options = {}) {
11088
10950
  const kindFilter = options.kinds === void 0 ? void 0 : new Set(options.kinds);
11089
10951
  if (kindFilter !== void 0) {
11090
10952
  for (const name of kindFilter) {
11091
- if (!chunkWFUN6DCM_cjs.isKnownKind(graph, name)) {
11092
- throw new chunkYEDQLNVE_cjs.KindNotFoundError(
10953
+ if (!chunkR2LA6MKR_cjs.isKnownKind(graph, name)) {
10954
+ throw new chunkG6P3OVDY_cjs.KindNotFoundError(
11093
10955
  name,
11094
10956
  Object.hasOwn(graph.edges, name) ? "edge" : "node",
11095
10957
  {
@@ -11182,7 +11044,7 @@ function parallelBucketKey(declaration) {
11182
11044
  return declaration.entity;
11183
11045
  }
11184
11046
  async function materializeRelationalIndex(declaration, backend, dialect, ddlOptions, graphId, schemaVersion, existingByStatusKey) {
11185
- const ddl = chunkPN37HVAV_cjs.generateIndexDDL(declaration, dialect, ddlOptions);
11047
+ const ddl = chunkC2RWFIYP_cjs.generateIndexDDL(declaration, dialect, ddlOptions);
11186
11048
  const targetTable = declaration.entity === "node" ? ddlOptions.nodesTableName ?? "typegraph_nodes" : ddlOptions.edgesTableName ?? "typegraph_edges";
11187
11049
  const signature = await computeIndexSignature(
11188
11050
  dialect,
@@ -11205,7 +11067,7 @@ async function materializeVectorIndex(declaration, backend, graphId, schemaVersi
11205
11067
  );
11206
11068
  }
11207
11069
  const vectorCapability = backend.capabilities.vector;
11208
- if (vectorCapability?.supported !== true || backend.createVectorIndex === void 0) {
11070
+ if (vectorCapability?.supported !== true || backend.createVectorIndex === void 0 || backend.vectorStrategy === void 0) {
11209
11071
  return skippedEntry(
11210
11072
  declaration,
11211
11073
  `Backend (${backend.dialect}) does not support vector indexes in its current configuration`
@@ -11217,7 +11079,11 @@ async function materializeVectorIndex(declaration, backend, graphId, schemaVersi
11217
11079
  `Backend (${backend.dialect}) does not support index type "${declaration.indexType}" for vector indexes; supported: ${vectorCapability.indexTypes.join(", ") || "(none)"}`
11218
11080
  );
11219
11081
  }
11220
- const embeddingsTable = backend.tableNames?.embeddings ?? "typegraph_node_embeddings";
11082
+ const embeddingsTable = backend.vectorStrategy.tableName(
11083
+ graphId,
11084
+ declaration.kind,
11085
+ declaration.fieldPath
11086
+ );
11221
11087
  const signature = await computeIndexSignature(
11222
11088
  backend.dialect,
11223
11089
  embeddingsTable,
@@ -11277,7 +11143,7 @@ async function materializeOne(declaration, backend, graphId, schemaVersion, acti
11277
11143
  }
11278
11144
  try {
11279
11145
  await run();
11280
- const attemptedAt = chunkWFUN6DCM_cjs.nowIso();
11146
+ const attemptedAt = chunkR2LA6MKR_cjs.nowIso();
11281
11147
  await recordIndexMaterialization(
11282
11148
  buildAttempt({
11283
11149
  declaration,
@@ -11354,15 +11220,15 @@ function buildAttempt(args) {
11354
11220
  kind: args.declaration.kind,
11355
11221
  signature: args.signature,
11356
11222
  schemaVersion: args.schemaVersion,
11357
- attemptedAt: args.attemptedAt ?? chunkWFUN6DCM_cjs.nowIso(),
11223
+ attemptedAt: args.attemptedAt ?? chunkR2LA6MKR_cjs.nowIso(),
11358
11224
  materializedAt: args.materializedAt,
11359
11225
  error: args.error?.message
11360
11226
  };
11361
11227
  }
11362
11228
  async function computeIndexSignature(dialect, targetTableName, declaration) {
11363
11229
  const hashable = { dialect, targetTableName, declaration };
11364
- const json = JSON.stringify(hashable, chunkIUIWCFG3_cjs.sortedReplacer);
11365
- return chunkCTHNVU6K_cjs.sha256Hex(json, 16);
11230
+ const json = JSON.stringify(hashable, chunkRP7YITHX_cjs.sortedReplacer);
11231
+ return chunkUPBXUOW7_cjs.sha256Hex(json, 16);
11366
11232
  }
11367
11233
 
11368
11234
  // src/store/materialize-removals.ts
@@ -11373,23 +11239,23 @@ function buildPendingKindRemoval(args) {
11373
11239
  async function materializeRemovals(context, options = {}) {
11374
11240
  const { backend, graphId } = context;
11375
11241
  if (backend.executeDdl === void 0 || backend.recordKindRemoval === void 0 || backend.getPendingKindRemovals === void 0) {
11376
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
11242
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
11377
11243
  "store.materializeRemovals() requires a backend with kind-removal primitives (executeDdl, recordKindRemoval, getPendingKindRemovals). The bundled SQLite and Postgres backends provide them.",
11378
11244
  { code: "MATERIALIZE_REMOVALS_BACKEND_UNSUPPORTED" }
11379
11245
  );
11380
11246
  }
11381
11247
  await ensureFocusedStatusTable(backend, backend.ensureKindRemovalsTable);
11382
11248
  await reconcilePendingRemovals(context);
11249
+ const reclaimedVectorFields = await reclaimRemovedVectorFieldTables(context);
11383
11250
  const pending = await backend.getPendingKindRemovals(graphId);
11384
11251
  const kindFilter = options.kinds === void 0 ? void 0 : new Set(options.kinds);
11385
11252
  const candidates = pending.filter(
11386
11253
  (row) => kindFilter === void 0 ? true : kindFilter.has(row.kindName)
11387
11254
  );
11388
- if (candidates.length === 0) return { results: [] };
11255
+ if (candidates.length === 0) return { results: [], reclaimedVectorFields };
11389
11256
  const tableNames = backend.tableNames;
11390
11257
  const nodesTable = tableNames?.nodes ?? "typegraph_nodes";
11391
11258
  const edgesTable = tableNames?.edges ?? "typegraph_edges";
11392
- const embeddingsTable = tableNames?.embeddings ?? "typegraph_node_embeddings";
11393
11259
  const fulltextTable = tableNames?.fulltext ?? "typegraph_node_fulltext";
11394
11260
  const uniquesTable = tableNames?.uniques ?? "typegraph_node_uniques";
11395
11261
  const ctx = {
@@ -11397,7 +11263,6 @@ async function materializeRemovals(context, options = {}) {
11397
11263
  graphId,
11398
11264
  nodesTable,
11399
11265
  edgesTable,
11400
- embeddingsTable,
11401
11266
  fulltextTable,
11402
11267
  uniquesTable
11403
11268
  };
@@ -11406,7 +11271,8 @@ async function materializeRemovals(context, options = {}) {
11406
11271
  candidates,
11407
11272
  options,
11408
11273
  (removal) => materializeOne2(removal, ctx)
11409
- )
11274
+ ),
11275
+ reclaimedVectorFields
11410
11276
  };
11411
11277
  }
11412
11278
  async function reconcilePendingRemovals(context) {
@@ -11429,14 +11295,14 @@ async function reconcilePendingRemovals(context) {
11429
11295
  const reconciliations = [];
11430
11296
  const stopAtVersion = marker ?? 1;
11431
11297
  let currentRow = activeRow;
11432
- let currentSchema = chunkZGEMI7MJ_cjs.parseSerializedSchema(activeRow.schema_doc);
11298
+ let currentSchema = chunkXTQHSOIC_cjs.parseSerializedSchema(activeRow.schema_doc);
11433
11299
  while (currentRow.version > stopAtVersion) {
11434
11300
  const priorRow = await backend.getSchemaVersion(
11435
11301
  graphId,
11436
11302
  currentRow.version - 1
11437
11303
  );
11438
11304
  if (priorRow === void 0) break;
11439
- const priorSchema = chunkZGEMI7MJ_cjs.parseSerializedSchema(priorRow.schema_doc);
11305
+ const priorSchema = chunkXTQHSOIC_cjs.parseSerializedSchema(priorRow.schema_doc);
11440
11306
  for (const entity of ENTITY_KINDS) {
11441
11307
  const priorEntries = priorSchema[entity === "node" ? "nodes" : "edges"];
11442
11308
  const currentEntries = currentSchema[entity === "node" ? "nodes" : "edges"];
@@ -11456,7 +11322,7 @@ async function reconcilePendingRemovals(context) {
11456
11322
  currentSchema = priorSchema;
11457
11323
  }
11458
11324
  if (reconciliations.length > 0) {
11459
- const attemptedAt = chunkWFUN6DCM_cjs.nowIso();
11325
+ const attemptedAt = chunkR2LA6MKR_cjs.nowIso();
11460
11326
  await Promise.all(
11461
11327
  reconciliations.map(
11462
11328
  (entry2) => recordKindRemoval(
@@ -11493,15 +11359,13 @@ async function materializeOne2(row, ctx) {
11493
11359
  executeDdl(
11494
11360
  `DELETE FROM ${quote(ctx.edgesTable)} WHERE graph_id = ${graphLit} AND (from_kind = ${kindLit} OR to_kind = ${kindLit})`
11495
11361
  ),
11496
- executeDdl(
11497
- `DELETE FROM ${quote(ctx.embeddingsTable)} WHERE graph_id = ${graphLit} AND node_kind = ${kindLit}`
11498
- ),
11499
11362
  executeDdl(
11500
11363
  `DELETE FROM ${quote(ctx.fulltextTable)} WHERE graph_id = ${graphLit} AND node_kind = ${kindLit}`
11501
11364
  ),
11502
11365
  executeDdl(
11503
11366
  `DELETE FROM ${quote(ctx.uniquesTable)} WHERE graph_id = ${graphLit} AND node_kind = ${kindLit}`
11504
- )
11367
+ ),
11368
+ ...buildEmbeddingTableCleanup(ctx, row)
11505
11369
  );
11506
11370
  } else {
11507
11371
  deletes.push(
@@ -11511,7 +11375,7 @@ async function materializeOne2(row, ctx) {
11511
11375
  );
11512
11376
  }
11513
11377
  await Promise.all(deletes);
11514
- const removedAt = chunkWFUN6DCM_cjs.nowIso();
11378
+ const removedAt = chunkR2LA6MKR_cjs.nowIso();
11515
11379
  await recordKindRemoval({
11516
11380
  graphId: ctx.graphId,
11517
11381
  kindName: row.kindName,
@@ -11533,7 +11397,7 @@ async function materializeOne2(row, ctx) {
11533
11397
  kindName: row.kindName,
11534
11398
  entity: row.entity,
11535
11399
  schemaVersion: row.schemaVersion,
11536
- attemptedAt: chunkWFUN6DCM_cjs.nowIso(),
11400
+ attemptedAt: chunkR2LA6MKR_cjs.nowIso(),
11537
11401
  removedAt: void 0,
11538
11402
  error: error.message
11539
11403
  });
@@ -11545,6 +11409,128 @@ async function materializeOne2(row, ctx) {
11545
11409
  };
11546
11410
  }
11547
11411
  }
11412
+ function buildEmbeddingTableCleanup(ctx, row) {
11413
+ const vectorStrategy = ctx.backend.vectorStrategy;
11414
+ if (vectorStrategy === void 0) return [];
11415
+ const executeDdl = ctx.backend.executeDdl;
11416
+ const cleanup = (async () => {
11417
+ const slots = await resolveRemovedKindEmbeddingSlots(ctx.backend, row);
11418
+ await Promise.all(
11419
+ slots.map(
11420
+ (slot) => dropVectorSlotStorage(vectorStrategy, executeDdl, slot)
11421
+ )
11422
+ );
11423
+ })();
11424
+ return [cleanup];
11425
+ }
11426
+ async function dropVectorSlotStorage(strategy, executeDdl, slot) {
11427
+ try {
11428
+ for (const ddl of strategy.buildDropStorage(slot)) {
11429
+ await executeDdl(ddl);
11430
+ }
11431
+ } catch (error) {
11432
+ if (!chunkRP7YITHX_cjs.isMissingTableError(error)) throw error;
11433
+ }
11434
+ }
11435
+ async function resolveRemovedKindEmbeddingSlots(backend, row) {
11436
+ const priorVersion = row.schemaVersion - 1;
11437
+ if (priorVersion < 1) return [];
11438
+ const priorRow = await backend.getSchemaVersion(row.graphId, priorVersion);
11439
+ if (priorRow === void 0) return [];
11440
+ const priorSchema = chunkXTQHSOIC_cjs.parseSerializedSchema(priorRow.schema_doc);
11441
+ const slots = /* @__PURE__ */ new Map();
11442
+ for (const declaration of priorSchema.indexes ?? []) {
11443
+ if (declaration.entity === "vector" && declaration.kind === row.kindName) {
11444
+ slots.set(declaration.fieldPath, {
11445
+ graphId: row.graphId,
11446
+ nodeKind: row.kindName,
11447
+ fieldPath: declaration.fieldPath,
11448
+ dimensions: declaration.dimensions,
11449
+ metric: declaration.metric,
11450
+ indexType: declaration.indexType
11451
+ });
11452
+ }
11453
+ }
11454
+ return [...slots.values()];
11455
+ }
11456
+ function vectorFieldKey(kind, fieldPath) {
11457
+ return `${kind}\0${fieldPath}`;
11458
+ }
11459
+ async function reclaimRemovedVectorFieldTables(context) {
11460
+ const { backend, graphId } = context;
11461
+ const vectorStrategy = backend.vectorStrategy;
11462
+ const executeDdl = backend.executeDdl;
11463
+ if (vectorStrategy === void 0 || executeDdl === void 0) return [];
11464
+ const activeRow = await backend.getActiveSchema(graphId);
11465
+ if (activeRow === void 0) return [];
11466
+ const cacheKey = `${graphId}\0${activeRow.version}`;
11467
+ let perBackend = reclaimCache.get(backend);
11468
+ const cached = perBackend?.get(cacheKey);
11469
+ if (cached !== void 0) return cached;
11470
+ const activeSchema = chunkXTQHSOIC_cjs.parseSerializedSchema(activeRow.schema_doc);
11471
+ const activeVectorFields = /* @__PURE__ */ new Set();
11472
+ for (const declaration of activeSchema.indexes ?? []) {
11473
+ if (declaration.entity === "vector") {
11474
+ activeVectorFields.add(
11475
+ vectorFieldKey(declaration.kind, declaration.fieldPath)
11476
+ );
11477
+ }
11478
+ }
11479
+ const survivingKinds = new Set(Object.keys(activeSchema.nodes));
11480
+ const historical = /* @__PURE__ */ new Map();
11481
+ for (let version = activeRow.version - 1; version >= 1; version -= 1) {
11482
+ const priorRow = await backend.getSchemaVersion(graphId, version);
11483
+ if (priorRow === void 0) continue;
11484
+ const priorSchema = chunkXTQHSOIC_cjs.parseSerializedSchema(priorRow.schema_doc);
11485
+ for (const declaration of priorSchema.indexes ?? []) {
11486
+ if (declaration.entity !== "vector") continue;
11487
+ const key = vectorFieldKey(declaration.kind, declaration.fieldPath);
11488
+ if (historical.has(key)) continue;
11489
+ historical.set(key, {
11490
+ kind: declaration.kind,
11491
+ fieldPath: declaration.fieldPath,
11492
+ slot: {
11493
+ graphId,
11494
+ nodeKind: declaration.kind,
11495
+ fieldPath: declaration.fieldPath,
11496
+ dimensions: declaration.dimensions,
11497
+ metric: declaration.metric,
11498
+ indexType: declaration.indexType
11499
+ }
11500
+ });
11501
+ }
11502
+ }
11503
+ const orphans = [...historical.values()].filter(
11504
+ (field2) => !activeVectorFields.has(vectorFieldKey(field2.kind, field2.fieldPath)) && survivingKinds.has(field2.kind)
11505
+ );
11506
+ const results = [];
11507
+ for (const field2 of orphans) {
11508
+ try {
11509
+ await dropVectorSlotStorage(vectorStrategy, executeDdl, field2.slot);
11510
+ results.push({
11511
+ kind: field2.kind,
11512
+ fieldPath: field2.fieldPath,
11513
+ status: "reclaimed"
11514
+ });
11515
+ } catch (error) {
11516
+ results.push({
11517
+ kind: field2.kind,
11518
+ fieldPath: field2.fieldPath,
11519
+ status: "failed",
11520
+ error: error instanceof Error ? error : new Error(String(error))
11521
+ });
11522
+ }
11523
+ }
11524
+ if (results.every((entry2) => entry2.status === "reclaimed")) {
11525
+ if (perBackend === void 0) {
11526
+ perBackend = /* @__PURE__ */ new Map();
11527
+ reclaimCache.set(backend, perBackend);
11528
+ }
11529
+ perBackend.set(cacheKey, results);
11530
+ }
11531
+ return results;
11532
+ }
11533
+ var reclaimCache = /* @__PURE__ */ new WeakMap();
11548
11534
  function quote(identifier) {
11549
11535
  return `"${identifier.replaceAll('"', '""')}"`;
11550
11536
  }
@@ -11633,7 +11619,7 @@ function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeC
11633
11619
  }
11634
11620
  case "one": {
11635
11621
  if (existingEdgeCount > 0) {
11636
- return new chunkYEDQLNVE_cjs.CardinalityError({
11622
+ return new chunkG6P3OVDY_cjs.CardinalityError({
11637
11623
  edgeKind,
11638
11624
  fromKind,
11639
11625
  fromId,
@@ -11648,7 +11634,7 @@ function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeC
11648
11634
  }
11649
11635
  case "oneActive": {
11650
11636
  if (hasActiveEdge) {
11651
- return new chunkYEDQLNVE_cjs.CardinalityError({
11637
+ return new chunkG6P3OVDY_cjs.CardinalityError({
11652
11638
  edgeKind,
11653
11639
  fromKind,
11654
11640
  fromId,
@@ -11662,7 +11648,7 @@ function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeC
11662
11648
  }
11663
11649
  function checkUniqueEdge(edgeKind, fromKind, fromId, _toKind, _toId, existingCount) {
11664
11650
  if (existingCount > 0) {
11665
- return new chunkYEDQLNVE_cjs.CardinalityError({
11651
+ return new chunkG6P3OVDY_cjs.CardinalityError({
11666
11652
  edgeKind,
11667
11653
  fromKind,
11668
11654
  fromId,
@@ -11678,7 +11664,7 @@ function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registr
11678
11664
  (validKind) => registry.isAssignableTo(fromKind, validKind)
11679
11665
  );
11680
11666
  if (!fromValid) {
11681
- return new chunkYEDQLNVE_cjs.EndpointError({
11667
+ return new chunkG6P3OVDY_cjs.EndpointError({
11682
11668
  edgeKind,
11683
11669
  endpoint: "from",
11684
11670
  actualKind: fromKind,
@@ -11690,7 +11676,7 @@ function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registr
11690
11676
  (validKind) => registry.isAssignableTo(toKind, validKind)
11691
11677
  );
11692
11678
  if (!toValid) {
11693
- return new chunkYEDQLNVE_cjs.EndpointError({
11679
+ return new chunkG6P3OVDY_cjs.EndpointError({
11694
11680
  edgeKind,
11695
11681
  endpoint: "to",
11696
11682
  actualKind: toKind,
@@ -11702,7 +11688,7 @@ function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registr
11702
11688
  function checkDisjointness(nodeId, nodeKind, existingKinds, registry) {
11703
11689
  for (const existingKind of existingKinds) {
11704
11690
  if (registry.areDisjoint(nodeKind, existingKind)) {
11705
- return new chunkYEDQLNVE_cjs.DisjointError({
11691
+ return new chunkG6P3OVDY_cjs.DisjointError({
11706
11692
  nodeId,
11707
11693
  attemptedKind: nodeKind,
11708
11694
  conflictingKind: existingKind
@@ -11794,7 +11780,7 @@ async function checkCardinalityConstraint(ctx, edgeKind, cardinality, fromKind,
11794
11780
  // src/store/operations/edge-operations.ts
11795
11781
  function getEdgeRegistration(graph, kind) {
11796
11782
  const registration = graph.edges[kind];
11797
- if (registration === void 0) throw new chunkYEDQLNVE_cjs.KindNotFoundError(kind, "edge");
11783
+ if (registration === void 0) throw new chunkG6P3OVDY_cjs.KindNotFoundError(kind, "edge");
11798
11784
  return registration;
11799
11785
  }
11800
11786
  function buildEdgeEndpointCacheKey(graphId, kind, id) {
@@ -11936,7 +11922,7 @@ async function validateAndPrepareEdgeCreate(ctx, input, id, backend) {
11936
11922
  if (endpointError) throw endpointError;
11937
11923
  const fromNode = await backend.getNode(ctx.graphId, fromKind, input.fromId);
11938
11924
  if (!fromNode || fromNode.deleted_at) {
11939
- throw new chunkYEDQLNVE_cjs.EndpointNotFoundError({
11925
+ throw new chunkG6P3OVDY_cjs.EndpointNotFoundError({
11940
11926
  edgeKind: kind,
11941
11927
  endpoint: "from",
11942
11928
  nodeKind: fromKind,
@@ -11945,19 +11931,19 @@ async function validateAndPrepareEdgeCreate(ctx, input, id, backend) {
11945
11931
  }
11946
11932
  const toNode = await backend.getNode(ctx.graphId, toKind, input.toId);
11947
11933
  if (!toNode || toNode.deleted_at) {
11948
- throw new chunkYEDQLNVE_cjs.EndpointNotFoundError({
11934
+ throw new chunkG6P3OVDY_cjs.EndpointNotFoundError({
11949
11935
  edgeKind: kind,
11950
11936
  endpoint: "to",
11951
11937
  nodeKind: toKind,
11952
11938
  nodeId: input.toId
11953
11939
  });
11954
11940
  }
11955
- const validatedProps = chunkZGEMI7MJ_cjs.validateEdgeProps(edgeKind.schema, input.props, {
11941
+ const validatedProps = chunkXTQHSOIC_cjs.validateEdgeProps(edgeKind.schema, input.props, {
11956
11942
  kind,
11957
11943
  operation: "create"
11958
11944
  });
11959
- const validFrom = chunkWFUN6DCM_cjs.validateOptionalIsoDate(input.validFrom, "validFrom");
11960
- const validTo = chunkWFUN6DCM_cjs.validateOptionalIsoDate(input.validTo, "validTo");
11945
+ const validFrom = chunkR2LA6MKR_cjs.validateOptionalIsoDate(input.validFrom, "validFrom");
11946
+ const validTo = chunkR2LA6MKR_cjs.validateOptionalIsoDate(input.validTo, "validTo");
11961
11947
  const cardinality = registration.cardinality ?? "many";
11962
11948
  const constraintContext = {
11963
11949
  graphId: ctx.graphId,
@@ -12012,7 +11998,7 @@ async function executeEdgeCreateInternal(ctx, input, backend, options) {
12012
11998
  async function executeEdgeCreate(ctx, input, backend) {
12013
11999
  const result = await executeEdgeCreateInternal(ctx, input, backend);
12014
12000
  if (!result) {
12015
- throw new chunkYEDQLNVE_cjs.DatabaseOperationError(
12001
+ throw new chunkG6P3OVDY_cjs.DatabaseOperationError(
12016
12002
  "Edge create failed: expected created edge row",
12017
12003
  { operation: "insert", entity: "edge" }
12018
12004
  );
@@ -12089,7 +12075,7 @@ async function executeEdgeUpdate(ctx, input, backend) {
12089
12075
  const id = input.id;
12090
12076
  const existing = await backend.getEdge(ctx.graphId, id);
12091
12077
  if (!existing || existing.deleted_at) {
12092
- throw new chunkYEDQLNVE_cjs.EdgeNotFoundError("unknown", id);
12078
+ throw new chunkG6P3OVDY_cjs.EdgeNotFoundError("unknown", id);
12093
12079
  }
12094
12080
  const opContext = ctx.createOperationContext(
12095
12081
  "update",
@@ -12102,12 +12088,12 @@ async function executeEdgeUpdate(ctx, input, backend) {
12102
12088
  const edgeKind = registration.type;
12103
12089
  const existingProps = JSON.parse(existing.props);
12104
12090
  const mergedProps = { ...existingProps, ...input.props };
12105
- const validatedProps = chunkZGEMI7MJ_cjs.validateEdgeProps(edgeKind.schema, mergedProps, {
12091
+ const validatedProps = chunkXTQHSOIC_cjs.validateEdgeProps(edgeKind.schema, mergedProps, {
12106
12092
  kind: existing.kind,
12107
12093
  operation: "update",
12108
12094
  id
12109
12095
  });
12110
- const validTo = chunkWFUN6DCM_cjs.validateOptionalIsoDate(input.validTo, "validTo");
12096
+ const validTo = chunkR2LA6MKR_cjs.validateOptionalIsoDate(input.validTo, "validTo");
12111
12097
  const updateParams = {
12112
12098
  graphId: ctx.graphId,
12113
12099
  id,
@@ -12122,18 +12108,18 @@ async function executeEdgeUpsertUpdate(ctx, input, backend, options) {
12122
12108
  const id = input.id;
12123
12109
  const existing = await backend.getEdge(ctx.graphId, id);
12124
12110
  if (!existing) {
12125
- throw new chunkYEDQLNVE_cjs.EdgeNotFoundError("unknown", id);
12111
+ throw new chunkG6P3OVDY_cjs.EdgeNotFoundError("unknown", id);
12126
12112
  }
12127
12113
  const registration = getEdgeRegistration(ctx.graph, existing.kind);
12128
12114
  const edgeKind = registration.type;
12129
12115
  const existingProps = JSON.parse(existing.props);
12130
12116
  const mergedProps = { ...existingProps, ...input.props };
12131
- const validatedProps = chunkZGEMI7MJ_cjs.validateEdgeProps(edgeKind.schema, mergedProps, {
12117
+ const validatedProps = chunkXTQHSOIC_cjs.validateEdgeProps(edgeKind.schema, mergedProps, {
12132
12118
  kind: existing.kind,
12133
12119
  operation: "update",
12134
12120
  id
12135
12121
  });
12136
- const validTo = chunkWFUN6DCM_cjs.validateOptionalIsoDate(input.validTo, "validTo");
12122
+ const validTo = chunkR2LA6MKR_cjs.validateOptionalIsoDate(input.validTo, "validTo");
12137
12123
  const updateParams = {
12138
12124
  graphId: ctx.graphId,
12139
12125
  id,
@@ -12187,7 +12173,7 @@ function validateMatchOnFields(schema, matchOn, edgeKind) {
12187
12173
  if (matchOn.length === 0) return;
12188
12174
  const shape = schema.shape;
12189
12175
  if (shape === void 0) {
12190
- throw new chunkYEDQLNVE_cjs.ValidationError(
12176
+ throw new chunkG6P3OVDY_cjs.ValidationError(
12191
12177
  `Edge kind "${edgeKind}" has no schema shape to validate matchOn fields against`,
12192
12178
  {
12193
12179
  kind: edgeKind,
@@ -12201,7 +12187,7 @@ function validateMatchOnFields(schema, matchOn, edgeKind) {
12201
12187
  }
12202
12188
  const invalidFields = matchOn.filter((field2) => !(field2 in shape));
12203
12189
  if (invalidFields.length > 0) {
12204
- throw new chunkYEDQLNVE_cjs.ValidationError(
12190
+ throw new chunkG6P3OVDY_cjs.ValidationError(
12205
12191
  `Invalid matchOn fields for edge kind "${edgeKind}": ${invalidFields.join(", ")}`,
12206
12192
  {
12207
12193
  kind: edgeKind,
@@ -12285,7 +12271,7 @@ async function executeEdgeGetOrCreateByEndpoints(ctx, kind, fromKind, fromId, to
12285
12271
  const matchOn = options?.matchOn ?? [];
12286
12272
  const registration = getEdgeRegistration(ctx.graph, kind);
12287
12273
  const edgeKind = registration.type;
12288
- const validatedProps = chunkZGEMI7MJ_cjs.validateEdgeProps(edgeKind.schema, props, {
12274
+ const validatedProps = chunkXTQHSOIC_cjs.validateEdgeProps(edgeKind.schema, props, {
12289
12275
  kind,
12290
12276
  operation: "create"
12291
12277
  });
@@ -12367,7 +12353,7 @@ async function executeEdgeBulkGetOrCreateByEndpoints(ctx, kind, items, backend,
12367
12353
  validateMatchOnFields(edgeKind.schema, matchOn, kind);
12368
12354
  const validated = [];
12369
12355
  for (const item of items) {
12370
- const validatedProps = chunkZGEMI7MJ_cjs.validateEdgeProps(edgeKind.schema, item.props, {
12356
+ const validatedProps = chunkXTQHSOIC_cjs.validateEdgeProps(edgeKind.schema, item.props, {
12371
12357
  kind,
12372
12358
  operation: "create"
12373
12359
  });
@@ -12529,46 +12515,10 @@ var embeddingFieldsCache = /* @__PURE__ */ new WeakMap();
12529
12515
  function getEmbeddingFields(schema) {
12530
12516
  const cached = embeddingFieldsCache.get(schema);
12531
12517
  if (cached) return cached;
12532
- const fields = computeEmbeddingFields(schema);
12518
+ const fields = chunkZFWNO3GE_cjs.resolveEmbeddingFields(schema);
12533
12519
  embeddingFieldsCache.set(schema, fields);
12534
12520
  return fields;
12535
12521
  }
12536
- function computeEmbeddingFields(schema) {
12537
- if (schema.type !== "object") return [];
12538
- const def = schema.def;
12539
- const shape = def.shape;
12540
- if (!shape) return [];
12541
- const fields = [];
12542
- for (const [fieldPath, fieldSchema] of Object.entries(shape)) {
12543
- const dimensions = getEmbeddingDimensionsFromField(fieldSchema);
12544
- if (dimensions !== void 0) {
12545
- fields.push({ fieldPath, dimensions });
12546
- }
12547
- }
12548
- return fields;
12549
- }
12550
- function getEmbeddingDimensionsFromField(schema) {
12551
- const directDimensions = chunkX3244EKP_cjs.getEmbeddingDimensions(schema);
12552
- if (directDimensions !== void 0) {
12553
- return directDimensions;
12554
- }
12555
- const unwrapped = unwrapToEmbedding(schema);
12556
- if (unwrapped) {
12557
- return chunkX3244EKP_cjs.getEmbeddingDimensions(unwrapped);
12558
- }
12559
- return void 0;
12560
- }
12561
- function unwrapToEmbedding(schema) {
12562
- const type = schema.type;
12563
- const def = schema.def;
12564
- if ((type === "optional" || type === "nullable" || type === "default" || type === "readonly") && def.innerType) {
12565
- if (chunkX3244EKP_cjs.isEmbeddingSchema(def.innerType)) {
12566
- return def.innerType;
12567
- }
12568
- return unwrapToEmbedding(def.innerType);
12569
- }
12570
- return void 0;
12571
- }
12572
12522
  async function syncEmbeddings(ctx, schema, props) {
12573
12523
  const { backend } = ctx;
12574
12524
  if (!backend.upsertEmbedding || !backend.deleteEmbedding) {
@@ -12587,14 +12537,19 @@ async function syncEmbeddings(ctx, schema, props) {
12587
12537
  nodeId: ctx.nodeId,
12588
12538
  fieldPath: field2.fieldPath,
12589
12539
  embedding: value,
12590
- dimensions: field2.dimensions
12540
+ dimensions: field2.dimensions,
12541
+ metric: field2.metric,
12542
+ indexType: field2.indexType
12591
12543
  });
12592
12544
  } else if (value === void 0) {
12593
12545
  await backend.deleteEmbedding({
12594
12546
  graphId: ctx.graphId,
12595
12547
  nodeKind: ctx.nodeKind,
12596
12548
  nodeId: ctx.nodeId,
12597
- fieldPath: field2.fieldPath
12549
+ fieldPath: field2.fieldPath,
12550
+ dimensions: field2.dimensions,
12551
+ metric: field2.metric,
12552
+ indexType: field2.indexType
12598
12553
  });
12599
12554
  }
12600
12555
  }
@@ -12613,7 +12568,10 @@ async function deleteNodeEmbeddings(ctx, schema) {
12613
12568
  graphId: ctx.graphId,
12614
12569
  nodeKind: ctx.nodeKind,
12615
12570
  nodeId: ctx.nodeId,
12616
- fieldPath: field2.fieldPath
12571
+ fieldPath: field2.fieldPath,
12572
+ dimensions: field2.dimensions,
12573
+ metric: field2.metric,
12574
+ indexType: field2.indexType
12617
12575
  });
12618
12576
  }
12619
12577
  }
@@ -12640,7 +12598,7 @@ function computeSearchableFields(schema) {
12640
12598
  if (!shape) return [];
12641
12599
  const fields = [];
12642
12600
  for (const [fieldPath, fieldSchema] of Object.entries(shape)) {
12643
- const metadata = chunkEK6RJ373_cjs.getSearchableMetadata(fieldSchema);
12601
+ const metadata = chunkVGU26WIU_cjs.getSearchableMetadata(fieldSchema);
12644
12602
  if (metadata !== void 0) {
12645
12603
  fields.push({ fieldPath, metadata });
12646
12604
  }
@@ -12656,14 +12614,14 @@ function warnIfConflictingLanguages(fields) {
12656
12614
  return;
12657
12615
  }
12658
12616
  const fieldSummary = fields.map((field2) => `${field2.fieldPath}=${field2.metadata.language}`).join(", ");
12659
- const winning = fields[0]?.metadata.language ?? chunkEK6RJ373_cjs.DEFAULT_SEARCHABLE_LANGUAGE;
12617
+ const winning = fields[0]?.metadata.language ?? chunkVGU26WIU_cjs.DEFAULT_SEARCHABLE_LANGUAGE;
12660
12618
  console.warn(
12661
12619
  `[typegraph] searchable() fields declare conflicting languages (${fieldSummary}). The first field's language ("${winning}") is recorded on the fulltext row; true multilingual indexing requires a dedicated node kind per language.`
12662
12620
  );
12663
12621
  }
12664
12622
  var FIELD_SEPARATOR = "\n";
12665
12623
  function resolveCombinedLanguage(fields) {
12666
- return fields[0]?.metadata.language ?? chunkEK6RJ373_cjs.DEFAULT_SEARCHABLE_LANGUAGE;
12624
+ return fields[0]?.metadata.language ?? chunkVGU26WIU_cjs.DEFAULT_SEARCHABLE_LANGUAGE;
12667
12625
  }
12668
12626
  function computeFulltextContent(schema, props) {
12669
12627
  const searchableFields = getSearchableFields(schema);
@@ -12743,7 +12701,7 @@ async function checkUniquenessConstraints(ctx, kind, id, props, constraints) {
12743
12701
  key
12744
12702
  });
12745
12703
  if (existing && existing.node_id !== id) {
12746
- throw new chunkYEDQLNVE_cjs.UniquenessError({
12704
+ throw new chunkG6P3OVDY_cjs.UniquenessError({
12747
12705
  constraintName: constraint.name,
12748
12706
  kind: kindToCheck,
12749
12707
  existingId: existing.node_id,
@@ -12826,7 +12784,7 @@ async function updateUniquenessEntries(ctx, kind, id, oldProps, newProps, constr
12826
12784
  key: newKey
12827
12785
  });
12828
12786
  if (existing && existing.node_id !== id) {
12829
- throw new chunkYEDQLNVE_cjs.UniquenessError({
12787
+ throw new chunkG6P3OVDY_cjs.UniquenessError({
12830
12788
  constraintName: constraint.name,
12831
12789
  kind: kindToCheck,
12832
12790
  existingId: existing.node_id,
@@ -12850,7 +12808,7 @@ async function updateUniquenessEntries(ctx, kind, id, oldProps, newProps, constr
12850
12808
  // src/store/operations/node-operations.ts
12851
12809
  function getNodeRegistration(graph, kind) {
12852
12810
  const registration = graph.nodes[kind];
12853
- if (registration === void 0) throw new chunkYEDQLNVE_cjs.KindNotFoundError(kind, "node");
12811
+ if (registration === void 0) throw new chunkG6P3OVDY_cjs.KindNotFoundError(kind, "node");
12854
12812
  return registration;
12855
12813
  }
12856
12814
  var CACHE_KEY_SEPARATOR = "\0";
@@ -12861,7 +12819,7 @@ function buildUniqueCacheKey(graphId, nodeKind, constraintName, key) {
12861
12819
  return `${graphId}${CACHE_KEY_SEPARATOR}${nodeKind}${CACHE_KEY_SEPARATOR}${constraintName}${CACHE_KEY_SEPARATOR}${key}`;
12862
12820
  }
12863
12821
  function createNodeAlreadyExistsError(kind, id) {
12864
- return new chunkYEDQLNVE_cjs.ValidationError(
12822
+ return new chunkG6P3OVDY_cjs.ValidationError(
12865
12823
  `Node already exists: ${kind}/${id}`,
12866
12824
  {
12867
12825
  entityType: "node",
@@ -12902,7 +12860,7 @@ function resolveConstraint(graph, kind, constraintName) {
12902
12860
  (candidate) => candidate.name === constraintName
12903
12861
  );
12904
12862
  if (constraint === void 0) {
12905
- throw new chunkYEDQLNVE_cjs.NodeConstraintNotFoundError(constraintName, kind);
12863
+ throw new chunkG6P3OVDY_cjs.NodeConstraintNotFoundError(constraintName, kind);
12906
12864
  }
12907
12865
  return constraint;
12908
12866
  }
@@ -13014,12 +12972,12 @@ async function validateAndPrepareNodeCreate(ctx, input, id, backend) {
13014
12972
  const kind = input.kind;
13015
12973
  const registration = getNodeRegistration(ctx.graph, kind);
13016
12974
  const nodeKind = registration.type;
13017
- const validatedProps = chunkZGEMI7MJ_cjs.validateNodeProps(nodeKind.schema, input.props, {
12975
+ const validatedProps = chunkXTQHSOIC_cjs.validateNodeProps(nodeKind.schema, input.props, {
13018
12976
  kind,
13019
12977
  operation: "create"
13020
12978
  });
13021
- const validFrom = chunkWFUN6DCM_cjs.validateOptionalIsoDate(input.validFrom, "validFrom");
13022
- const validTo = chunkWFUN6DCM_cjs.validateOptionalIsoDate(input.validTo, "validTo");
12979
+ const validFrom = chunkR2LA6MKR_cjs.validateOptionalIsoDate(input.validFrom, "validFrom");
12980
+ const validTo = chunkR2LA6MKR_cjs.validateOptionalIsoDate(input.validTo, "validTo");
13023
12981
  const existingNode = await backend.getNode(ctx.graphId, kind, id);
13024
12982
  if (existingNode && !existingNode.deleted_at) {
13025
12983
  throw createNodeAlreadyExistsError(kind, id);
@@ -13083,17 +13041,17 @@ async function performNodeUpdate(ctx, input, backend, options) {
13083
13041
  const registration = getNodeRegistration(ctx.graph, kind);
13084
13042
  const existing = await backend.getNode(ctx.graphId, kind, id);
13085
13043
  if (!existing || existing.deleted_at && !options?.clearDeleted) {
13086
- throw new chunkYEDQLNVE_cjs.NodeNotFoundError(kind, id);
13044
+ throw new chunkG6P3OVDY_cjs.NodeNotFoundError(kind, id);
13087
13045
  }
13088
13046
  const existingProps = JSON.parse(existing.props);
13089
13047
  const mergedProps = { ...existingProps, ...input.props };
13090
13048
  const nodeKind = registration.type;
13091
- const validatedProps = chunkZGEMI7MJ_cjs.validateNodeProps(nodeKind.schema, mergedProps, {
13049
+ const validatedProps = chunkXTQHSOIC_cjs.validateNodeProps(nodeKind.schema, mergedProps, {
13092
13050
  kind,
13093
13051
  operation: "update",
13094
13052
  id
13095
13053
  });
13096
- const validTo = chunkWFUN6DCM_cjs.validateOptionalIsoDate(input.validTo, "validTo");
13054
+ const validTo = chunkR2LA6MKR_cjs.validateOptionalIsoDate(input.validTo, "validTo");
13097
13055
  await updateUniquenessEntries(
13098
13056
  createUniquenessContext(ctx.graphId, ctx.registry, backend),
13099
13057
  kind,
@@ -13135,7 +13093,7 @@ async function enforceDeleteBehavior(ctx, kind, id, mode, backend, registration)
13135
13093
  switch (deleteBehavior) {
13136
13094
  case "restrict": {
13137
13095
  const edgeKinds = [...new Set(connectedEdges.map((edge) => edge.kind))];
13138
- throw new chunkYEDQLNVE_cjs.RestrictedDeleteError({
13096
+ throw new chunkG6P3OVDY_cjs.RestrictedDeleteError({
13139
13097
  nodeKind: kind,
13140
13098
  nodeId: id,
13141
13099
  edgeCount: connectedEdges.length,
@@ -13256,7 +13214,7 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
13256
13214
  async function executeNodeCreate(ctx, input, backend) {
13257
13215
  const result = await executeNodeCreateInternal(ctx, input, backend);
13258
13216
  if (!result) {
13259
- throw new chunkYEDQLNVE_cjs.DatabaseOperationError(
13217
+ throw new chunkG6P3OVDY_cjs.DatabaseOperationError(
13260
13218
  "Node create failed: expected created node row",
13261
13219
  { operation: "insert", entity: "node" }
13262
13220
  );
@@ -13353,6 +13311,10 @@ async function executeNodeHardDelete(ctx, kind, id, backend) {
13353
13311
  await enforceDeleteBehavior(ctx, kind, id, "hard", backend, registration);
13354
13312
  const hardDelete = async (target) => {
13355
13313
  await target.hardDeleteNode({ graphId: ctx.graphId, kind, id });
13314
+ await deleteNodeEmbeddings(
13315
+ createEmbeddingSyncContext(ctx.graphId, kind, id, target),
13316
+ registration.type.schema
13317
+ );
13356
13318
  };
13357
13319
  await ("transaction" in backend && backend.capabilities.transactions ? backend.transaction(async (tx) => hardDelete(tx)) : hardDelete(backend));
13358
13320
  });
@@ -13361,7 +13323,7 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
13361
13323
  const ifExists = options?.ifExists ?? "return";
13362
13324
  const registration = getNodeRegistration(ctx.graph, kind);
13363
13325
  const nodeKind = registration.type;
13364
- const validatedProps = chunkZGEMI7MJ_cjs.validateNodeProps(nodeKind.schema, props, {
13326
+ const validatedProps = chunkXTQHSOIC_cjs.validateNodeProps(nodeKind.schema, props, {
13365
13327
  kind,
13366
13328
  operation: "create"
13367
13329
  });
@@ -13433,7 +13395,7 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
13433
13395
  async function executeNodeFindByConstraint(ctx, kind, constraintName, props, backend) {
13434
13396
  const registration = getNodeRegistration(ctx.graph, kind);
13435
13397
  const nodeKind = registration.type;
13436
- const validatedProps = chunkZGEMI7MJ_cjs.validateNodeProps(nodeKind.schema, props, {
13398
+ const validatedProps = chunkXTQHSOIC_cjs.validateNodeProps(nodeKind.schema, props, {
13437
13399
  kind,
13438
13400
  operation: "create"
13439
13401
  });
@@ -13470,7 +13432,7 @@ async function executeNodeFindByConstraint(ctx, kind, constraintName, props, bac
13470
13432
  function validateAndComputeKeys(nodeKind, kind, constraint, items) {
13471
13433
  const validated = [];
13472
13434
  for (const item of items) {
13473
- const validatedProps = chunkZGEMI7MJ_cjs.validateNodeProps(nodeKind.schema, item.props, {
13435
+ const validatedProps = chunkXTQHSOIC_cjs.validateNodeProps(nodeKind.schema, item.props, {
13474
13436
  kind,
13475
13437
  operation: "create"
13476
13438
  });
@@ -13654,7 +13616,7 @@ var DEFAULT_MAX_SKIPPED_IDS = 1e4;
13654
13616
  function validatePageSize(value) {
13655
13617
  if (value === void 0) return DEFAULT_PAGE_SIZE;
13656
13618
  if (!Number.isInteger(value) || value <= 0) {
13657
- throw new chunkYEDQLNVE_cjs.ValidationError(
13619
+ throw new chunkG6P3OVDY_cjs.ValidationError(
13658
13620
  `pageSize must be a positive integer, got: ${String(value)}`,
13659
13621
  {
13660
13622
  issues: [{ path: "pageSize", message: "Must be a positive integer." }]
@@ -13666,7 +13628,7 @@ function validatePageSize(value) {
13666
13628
  function validateMaxSkippedIds(value) {
13667
13629
  if (value === void 0) return DEFAULT_MAX_SKIPPED_IDS;
13668
13630
  if (!Number.isInteger(value) || value < 0) {
13669
- throw new chunkYEDQLNVE_cjs.ValidationError(
13631
+ throw new chunkG6P3OVDY_cjs.ValidationError(
13670
13632
  `maxSkippedIds must be a non-negative integer, got: ${String(value)}`,
13671
13633
  {
13672
13634
  issues: [
@@ -13686,7 +13648,7 @@ function isPropsObject(value) {
13686
13648
  async function rebuildFulltextIndex(ctx, nodeKind, options) {
13687
13649
  const { backend, registry } = ctx;
13688
13650
  if (!backend.upsertFulltext || !backend.deleteFulltext) {
13689
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
13651
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
13690
13652
  "Backend does not support fulltext; cannot rebuild index",
13691
13653
  { backend: backend.dialect, capability: "fulltext" }
13692
13654
  );
@@ -13703,7 +13665,7 @@ async function rebuildFulltextIndex(ctx, nodeKind, options) {
13703
13665
  for (const kind of targetKinds) {
13704
13666
  const nodeType = registry.getNodeType(kind);
13705
13667
  if (!nodeType) {
13706
- throw new chunkYEDQLNVE_cjs.ConfigurationError(`Unknown node kind: ${kind}`, { kind });
13668
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(`Unknown node kind: ${kind}`, { kind });
13707
13669
  }
13708
13670
  if (getSearchableFields(nodeType.schema).length === 0) {
13709
13671
  continue;
@@ -13764,7 +13726,7 @@ async function rebuildFulltextIndex(ctx, nodeKind, options) {
13764
13726
  }
13765
13727
  }
13766
13728
  };
13767
- await chunkLYRUNG6E_cjs.runOptionallyInTransaction(backend, writePage);
13729
+ await chunkF2Q76CQ4_cjs.runOptionallyInTransaction(backend, writePage);
13768
13730
  processed += rows.length;
13769
13731
  upserted += pageResult.toUpsert.length;
13770
13732
  cleared += pageResult.toDelete.length;
@@ -13822,10 +13784,28 @@ function processPage(schema, rows) {
13822
13784
  }
13823
13785
 
13824
13786
  // src/store/search.ts
13787
+ function resolveSearchSlot(ctx, nodeKind, fieldPath) {
13788
+ const nodeType = ctx.registry.getNodeType(nodeKind);
13789
+ if (nodeType !== void 0) {
13790
+ const fields = getEmbeddingFields(nodeType.schema);
13791
+ const field2 = fields.find((entry2) => entry2.fieldPath === fieldPath);
13792
+ if (field2 !== void 0) {
13793
+ return {
13794
+ dimensions: field2.dimensions,
13795
+ metric: field2.metric,
13796
+ indexType: field2.indexType
13797
+ };
13798
+ }
13799
+ }
13800
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
13801
+ `Node kind "${nodeKind}" has no embedding field "${fieldPath}". Declare it with embedding(dimensions) on the node schema.`,
13802
+ { capability: "vector", graphId: ctx.graphId }
13803
+ );
13804
+ }
13825
13805
  async function executeFulltextSearch(ctx, nodeKind, options) {
13826
13806
  const { backend, graphId } = ctx;
13827
13807
  if (!backend.fulltextSearch) {
13828
- throw new chunkYEDQLNVE_cjs.ConfigurationError("Backend does not support fulltext search", {
13808
+ throw new chunkG6P3OVDY_cjs.ConfigurationError("Backend does not support fulltext search", {
13829
13809
  backend: backend.dialect,
13830
13810
  capability: "fulltext"
13831
13811
  });
@@ -13872,7 +13852,7 @@ async function executeFulltextSearch(ctx, nodeKind, options) {
13872
13852
  async function executeVectorSearch(ctx, nodeKind, options) {
13873
13853
  const { backend, graphId } = ctx;
13874
13854
  if (!backend.vectorSearch) {
13875
- throw new chunkYEDQLNVE_cjs.ConfigurationError("Backend does not support vector search", {
13855
+ throw new chunkG6P3OVDY_cjs.ConfigurationError("Backend does not support vector search", {
13876
13856
  backend: backend.dialect,
13877
13857
  capability: "vector"
13878
13858
  });
@@ -13883,12 +13863,29 @@ async function executeVectorSearch(ctx, nodeKind, options) {
13883
13863
  );
13884
13864
  }
13885
13865
  assertEfSearch(options.efSearch, "vectorSearch.efSearch");
13866
+ const slot = resolveSearchSlot(ctx, nodeKind, options.fieldPath);
13867
+ assertVectorQueryCompatible(
13868
+ backend,
13869
+ slot,
13870
+ { metric: options.metric, queryEmbedding: options.queryEmbedding },
13871
+ "vectorSearch"
13872
+ );
13873
+ assertMinScore(
13874
+ options.minScore,
13875
+ options.metric ?? slot.metric,
13876
+ "vectorSearch.minScore"
13877
+ );
13886
13878
  const rows = await backend.vectorSearch({
13887
13879
  graphId,
13888
13880
  nodeKind,
13889
13881
  fieldPath: options.fieldPath,
13890
13882
  queryEmbedding: options.queryEmbedding,
13891
- metric: options.metric ?? "cosine",
13883
+ // Default to the field's DECLARED metric (the metric its index was built
13884
+ // for); only an explicit caller override changes it. Defaulting to cosine
13885
+ // here would mis-rank l2 / inner_product fields and bypass their ANN index.
13886
+ metric: options.metric ?? slot.metric,
13887
+ dimensions: slot.dimensions,
13888
+ indexType: slot.indexType,
13892
13889
  limit: options.limit,
13893
13890
  ...options.minScore === void 0 ? {} : { minScore: options.minScore },
13894
13891
  ...options.efSearch === void 0 ? {} : { efSearch: options.efSearch }
@@ -13909,13 +13906,13 @@ async function executeVectorSearch(ctx, nodeKind, options) {
13909
13906
  async function executeHybridSearch(ctx, nodeKind, options) {
13910
13907
  const { backend, graphId } = ctx;
13911
13908
  if (!backend.vectorSearch) {
13912
- throw new chunkYEDQLNVE_cjs.ConfigurationError("Backend does not support vector search", {
13909
+ throw new chunkG6P3OVDY_cjs.ConfigurationError("Backend does not support vector search", {
13913
13910
  backend: backend.dialect,
13914
13911
  capability: "vector"
13915
13912
  });
13916
13913
  }
13917
13914
  if (!backend.fulltextSearch) {
13918
- throw new chunkYEDQLNVE_cjs.ConfigurationError("Backend does not support fulltext search", {
13915
+ throw new chunkG6P3OVDY_cjs.ConfigurationError("Backend does not support fulltext search", {
13919
13916
  backend: backend.dialect,
13920
13917
  capability: "fulltext"
13921
13918
  });
@@ -13940,12 +13937,30 @@ async function executeHybridSearch(ctx, nodeKind, options) {
13940
13937
  const overFetchMultiplier = 4;
13941
13938
  const vectorK = options.vector.k ?? options.limit * overFetchMultiplier;
13942
13939
  const fulltextK = options.fulltext.k ?? options.limit * overFetchMultiplier;
13940
+ const vectorSlot = resolveSearchSlot(ctx, nodeKind, options.vector.fieldPath);
13941
+ assertVectorQueryCompatible(
13942
+ backend,
13943
+ vectorSlot,
13944
+ {
13945
+ metric: options.vector.metric,
13946
+ queryEmbedding: options.vector.queryEmbedding
13947
+ },
13948
+ "hybridSearch.vector"
13949
+ );
13950
+ assertMinScore(
13951
+ options.vector.minScore,
13952
+ options.vector.metric ?? vectorSlot.metric,
13953
+ "hybridSearch.vector.minScore"
13954
+ );
13943
13955
  const vectorPromise = backend.vectorSearch({
13944
13956
  graphId,
13945
13957
  nodeKind,
13946
13958
  fieldPath: options.vector.fieldPath,
13947
13959
  queryEmbedding: options.vector.queryEmbedding,
13948
- metric: options.vector.metric ?? "cosine",
13960
+ // Default to the field's declared metric (see executeVectorSearch).
13961
+ metric: options.vector.metric ?? vectorSlot.metric,
13962
+ dimensions: vectorSlot.dimensions,
13963
+ indexType: vectorSlot.indexType,
13949
13964
  limit: vectorK,
13950
13965
  ...options.vector.minScore === void 0 ? {} : { minScore: options.vector.minScore },
13951
13966
  ...options.vector.efSearch === void 0 ? {} : { efSearch: options.vector.efSearch }
@@ -14036,6 +14051,30 @@ function assertEfSearch(efSearch, label) {
14036
14051
  );
14037
14052
  }
14038
14053
  }
14054
+ function assertMinScore(minScore, metric, label) {
14055
+ if (minScore === void 0) return;
14056
+ chunkC2RWFIYP_cjs.assertVectorMinScore(minScore, metric, label);
14057
+ }
14058
+ function assertVectorQueryCompatible(backend, slot, options, label) {
14059
+ if (options.metric !== void 0 && options.metric !== slot.metric) {
14060
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
14061
+ `${label}: metric "${options.metric}" does not match the field's declared metric "${slot.metric}". Vector storage is built for the declared metric \u2014 omit metric or pass "${slot.metric}".`,
14062
+ { backend: backend.dialect, capability: "vector" }
14063
+ );
14064
+ }
14065
+ const supported = backend.capabilities.vector?.metrics;
14066
+ if (supported !== void 0 && !supported.includes(slot.metric)) {
14067
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
14068
+ `${label}: backend "${backend.dialect}" does not support the "${slot.metric}" metric (supported: ${supported.join(", ")}).`,
14069
+ { backend: backend.dialect, capability: "vector" }
14070
+ );
14071
+ }
14072
+ if (options.queryEmbedding.length !== slot.dimensions) {
14073
+ throw new RangeError(
14074
+ `${label}: queryEmbedding has ${options.queryEmbedding.length} dimensions, but "${slot.dimensions}" are declared for this field.`
14075
+ );
14076
+ }
14077
+ }
14039
14078
  function validateFulltextCallOptions(backend, options) {
14040
14079
  const strategy = backend.fulltextStrategy;
14041
14080
  const capabilities = backend.capabilities.fulltext;
@@ -14057,7 +14096,7 @@ function validateFulltextCallOptions(backend, options) {
14057
14096
  function validateFulltextMode(backend, strategy, capabilities, mode) {
14058
14097
  if (strategy !== void 0) {
14059
14098
  if (strategy.supportedModes.includes(mode)) return;
14060
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
14099
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
14061
14100
  `Backend "${backend.dialect}" fulltext strategy "${strategy.name}" does not support mode "${mode}". Supported modes: ${strategy.supportedModes.join(", ")}`,
14062
14101
  {
14063
14102
  backend: backend.dialect,
@@ -14067,7 +14106,7 @@ function validateFulltextMode(backend, strategy, capabilities, mode) {
14067
14106
  );
14068
14107
  }
14069
14108
  if (mode === "phrase" && capabilities && !capabilities.phraseQueries) {
14070
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
14109
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
14071
14110
  `Backend "${backend.dialect}" does not support phrase queries`,
14072
14111
  { backend: backend.dialect, capability: "fulltext.phraseQueries" }
14073
14112
  );
@@ -14076,14 +14115,14 @@ function validateFulltextMode(backend, strategy, capabilities, mode) {
14076
14115
  function validateFulltextSnippets(backend, strategy, capabilities) {
14077
14116
  const supportsSnippets = strategy === void 0 ? capabilities?.highlighting !== false : strategy.supportsSnippets;
14078
14117
  if (supportsSnippets) return;
14079
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
14118
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
14080
14119
  `Backend "${backend.dialect}" does not support snippet highlighting; drop includeSnippets or switch to a backend where highlighting is supported`,
14081
14120
  { backend: backend.dialect, capability: "fulltext.highlighting" }
14082
14121
  );
14083
14122
  }
14084
14123
  function validateFulltextLanguageOption(backend, strategy, capabilities, language) {
14085
14124
  if (strategy !== void 0 && !strategy.supportsLanguageOverride) {
14086
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
14125
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
14087
14126
  `Backend "${backend.dialect}" fulltext strategy "${strategy.name}" does not honor a per-query \`language\` override (its tokenizer is fixed at table-create time). Drop the option, or pick a strategy that advertises \`supportsLanguageOverride: true\`.`,
14088
14127
  {
14089
14128
  backend: backend.dialect,
@@ -14142,7 +14181,11 @@ var StoreSearch = class {
14142
14181
  async fulltext(nodeKind, options) {
14143
14182
  this.#assertKindRegistered(nodeKind);
14144
14183
  return executeFulltextSearch(
14145
- { graphId: this.#context.graphId, backend: this.#context.backend },
14184
+ {
14185
+ graphId: this.#context.graphId,
14186
+ backend: this.#context.backend,
14187
+ registry: this.#context.registry
14188
+ },
14146
14189
  nodeKind,
14147
14190
  options
14148
14191
  );
@@ -14161,7 +14204,11 @@ var StoreSearch = class {
14161
14204
  async vector(nodeKind, options) {
14162
14205
  this.#assertKindRegistered(nodeKind);
14163
14206
  return executeVectorSearch(
14164
- { graphId: this.#context.graphId, backend: this.#context.backend },
14207
+ {
14208
+ graphId: this.#context.graphId,
14209
+ backend: this.#context.backend,
14210
+ registry: this.#context.registry
14211
+ },
14165
14212
  nodeKind,
14166
14213
  options
14167
14214
  );
@@ -14178,7 +14225,11 @@ var StoreSearch = class {
14178
14225
  async hybrid(nodeKind, options) {
14179
14226
  this.#assertKindRegistered(nodeKind);
14180
14227
  return executeHybridSearch(
14181
- { graphId: this.#context.graphId, backend: this.#context.backend },
14228
+ {
14229
+ graphId: this.#context.graphId,
14230
+ backend: this.#context.backend,
14231
+ registry: this.#context.registry
14232
+ },
14182
14233
  nodeKind,
14183
14234
  options
14184
14235
  );
@@ -14215,7 +14266,7 @@ var StoreSearch = class {
14215
14266
  }
14216
14267
  #assertKindRegistered(kind) {
14217
14268
  if (this.#context.registry.hasNodeType(kind)) return;
14218
- throw new chunkYEDQLNVE_cjs.KindNotFoundError(kind, "node", {
14269
+ throw new chunkG6P3OVDY_cjs.KindNotFoundError(kind, "node", {
14219
14270
  graphId: this.#context.graphId,
14220
14271
  suggestion: "Compile-time kinds come from defineGraph; extension kinds appear after store.evolve() returns. Check store.introspect() for the registered set."
14221
14272
  });
@@ -14227,6 +14278,7 @@ var UNKNOWN_SCHEMA_METADATA = Object.freeze({
14227
14278
  schemaVersion: void 0,
14228
14279
  schemaHash: void 0
14229
14280
  });
14281
+ var DEFAULT_REEMBED_BATCH_SIZE = 200;
14230
14282
  var CAUGHT_UP_VERB_DETAILS = {
14231
14283
  evolve: { phrase: "evolve", code: "EVOLVE_BEFORE_INITIALIZE" },
14232
14284
  materialize: {
@@ -14241,6 +14293,10 @@ var CAUGHT_UP_VERB_DETAILS = {
14241
14293
  undeprecate: {
14242
14294
  phrase: "undeprecate kinds on",
14243
14295
  code: "DEPRECATE_BEFORE_INITIALIZE"
14296
+ },
14297
+ reembed: {
14298
+ phrase: "re-embed a vector field on",
14299
+ code: "REEMBED_BEFORE_INITIALIZE"
14244
14300
  }
14245
14301
  };
14246
14302
  var Store = class _Store {
@@ -14401,7 +14457,7 @@ var Store = class _Store {
14401
14457
  getNodeCollectionOrThrow(kind) {
14402
14458
  const collection = this.getNodeCollection(kind);
14403
14459
  if (collection === void 0) {
14404
- throw new chunkYEDQLNVE_cjs.KindNotFoundError(kind, "node", {
14460
+ throw new chunkG6P3OVDY_cjs.KindNotFoundError(kind, "node", {
14405
14461
  graphId: this.graphId
14406
14462
  });
14407
14463
  }
@@ -14425,7 +14481,7 @@ var Store = class _Store {
14425
14481
  getEdgeCollectionOrThrow(kind) {
14426
14482
  const collection = this.getEdgeCollection(kind);
14427
14483
  if (collection === void 0) {
14428
- throw new chunkYEDQLNVE_cjs.KindNotFoundError(kind, "edge", {
14484
+ throw new chunkG6P3OVDY_cjs.KindNotFoundError(kind, "edge", {
14429
14485
  graphId: this.graphId
14430
14486
  });
14431
14487
  }
@@ -14451,7 +14507,7 @@ var Store = class _Store {
14451
14507
  getNodePropsSchemaOrThrow(kind) {
14452
14508
  const schema = this.getNodePropsSchema(kind);
14453
14509
  if (schema === void 0) {
14454
- throw new chunkYEDQLNVE_cjs.KindNotFoundError(kind, "node", {
14510
+ throw new chunkG6P3OVDY_cjs.KindNotFoundError(kind, "node", {
14455
14511
  graphId: this.graphId
14456
14512
  });
14457
14513
  }
@@ -14472,7 +14528,7 @@ var Store = class _Store {
14472
14528
  getEdgePropsSchemaOrThrow(kind) {
14473
14529
  const schema = this.getEdgePropsSchema(kind);
14474
14530
  if (schema === void 0) {
14475
- throw new chunkYEDQLNVE_cjs.KindNotFoundError(kind, "edge", {
14531
+ throw new chunkG6P3OVDY_cjs.KindNotFoundError(kind, "edge", {
14476
14532
  graphId: this.graphId
14477
14533
  });
14478
14534
  }
@@ -14688,7 +14744,7 @@ var Store = class _Store {
14688
14744
  * @returns A tuple with per-query typed results, preserving input order
14689
14745
  */
14690
14746
  async batch(...queries) {
14691
- return chunkLYRUNG6E_cjs.runOptionallyInTransaction(this.#backend, async (target) => {
14747
+ return chunkF2Q76CQ4_cjs.runOptionallyInTransaction(this.#backend, async (target) => {
14692
14748
  const results = [];
14693
14749
  for (const query of queries) {
14694
14750
  const result = await query.executeOn(target);
@@ -14730,7 +14786,7 @@ var Store = class _Store {
14730
14786
  graphId: this.graphId,
14731
14787
  rootId,
14732
14788
  backend: this.#backend,
14733
- dialect: chunkPN37HVAV_cjs.getDialect(this.#backend.dialect),
14789
+ dialect: chunkC2RWFIYP_cjs.getDialect(this.#backend.dialect),
14734
14790
  schema: this.#schema,
14735
14791
  options
14736
14792
  });
@@ -14792,7 +14848,7 @@ var Store = class _Store {
14792
14848
  return fn({ nodes: this.nodes, edges: this.edges });
14793
14849
  }
14794
14850
  return this.#backend.transaction(
14795
- async (txBackend, sql17) => fn(this.#buildTransactionContext(txBackend, sql17))
14851
+ async (txBackend, sql18) => fn(this.#buildTransactionContext(txBackend, sql18))
14796
14852
  );
14797
14853
  }
14798
14854
  /**
@@ -14853,7 +14909,7 @@ var Store = class _Store {
14853
14909
  withTransaction(externalTx) {
14854
14910
  const adopt = this.#backend.adoptTransaction;
14855
14911
  if (!adopt) {
14856
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
14912
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
14857
14913
  "This backend cannot adopt an external transaction for cross-store atomicity. adoptTransaction is provided only by the Drizzle Postgres/SQLite backends with transaction support. Check backend.capabilities.transactions, or run the relational and graph writes as separate transactions with manual compensation.",
14858
14914
  { capability: "adoptTransaction" }
14859
14915
  );
@@ -14869,7 +14925,7 @@ var Store = class _Store {
14869
14925
  * raw Drizzle handle bound to the same transaction (#140);
14870
14926
  * `undefined` only on the non-transactional fallback.
14871
14927
  */
14872
- #buildTransactionContext(txBackend, sql17) {
14928
+ #buildTransactionContext(txBackend, sql18) {
14873
14929
  const txNodeOperations = {
14874
14930
  ...this.#nodeOperations,
14875
14931
  createQuery: () => this.#createQueryForBackend(txBackend)
@@ -14892,7 +14948,7 @@ var Store = class _Store {
14892
14948
  txBackend,
14893
14949
  txEdgeOperations
14894
14950
  );
14895
- return sql17 === void 0 ? { nodes, edges } : { nodes, edges, sql: sql17 };
14951
+ return sql18 === void 0 ? { nodes, edges } : { nodes, edges, sql: sql18 };
14896
14952
  }
14897
14953
  // === Graph Lifecycle ===
14898
14954
  /**
@@ -14909,11 +14965,44 @@ var Store = class _Store {
14909
14965
  await target.clearGraph(this.graphId);
14910
14966
  };
14911
14967
  await (this.#backend.capabilities.transactions ? this.#backend.transaction(async (tx) => doClear(tx)) : doClear(this.#backend));
14968
+ await this.#clearVectorStorage();
14912
14969
  this.#nodeCollections = void 0;
14913
14970
  this.#edgeCollections = void 0;
14914
14971
  this.#algorithms = void 0;
14915
14972
  this.#search = void 0;
14916
14973
  }
14974
+ /**
14975
+ * Resets every declared embedding field's per-field storage for this graph by
14976
+ * dropping and recreating it empty. Drop+recreate (rather than DELETE) mirrors
14977
+ * `reembedVectorField` and keeps the backend's storage-ensure latch valid: the
14978
+ * table still exists after clear, so a later write finds it. Enumerated from
14979
+ * the in-memory registry (not the DB schema, which `clearGraph` just wiped).
14980
+ */
14981
+ async #clearVectorStorage() {
14982
+ const backend = this.#backend;
14983
+ const strategy = backend.vectorStrategy;
14984
+ if (strategy === void 0 || backend.executeDdl === void 0) return;
14985
+ for (const [nodeKind, nodeType] of this.#registry.nodeKinds) {
14986
+ for (const field2 of chunkZFWNO3GE_cjs.resolveEmbeddingFields(nodeType.schema)) {
14987
+ const slot = {
14988
+ graphId: this.graphId,
14989
+ nodeKind,
14990
+ fieldPath: field2.fieldPath,
14991
+ dimensions: field2.dimensions,
14992
+ metric: field2.metric,
14993
+ indexType: field2.indexType
14994
+ };
14995
+ for (const ddl of strategy.buildDropStorage(slot)) {
14996
+ await backend.executeDdl(ddl);
14997
+ }
14998
+ for (const contribution of strategy.ownedTables(slot)) {
14999
+ for (const ddl of contribution.createDdl) {
15000
+ await backend.executeDdl(ddl);
15001
+ }
15002
+ }
15003
+ }
15004
+ }
15005
+ }
14917
15006
  // === Lifecycle ===
14918
15007
  /**
14919
15008
  * Refreshes the backend's query-planner statistics.
@@ -14994,7 +15083,7 @@ var Store = class _Store {
14994
15083
  */
14995
15084
  async evolve(extension, options) {
14996
15085
  const { activeRow, baseline } = await this.#loadCaughtUp("evolve");
14997
- const merged = chunkZGEMI7MJ_cjs.mergeGraphExtension(baseline, extension);
15086
+ const merged = chunkXTQHSOIC_cjs.mergeGraphExtension(baseline, extension);
14998
15087
  if (merged === baseline) {
14999
15088
  if (baseline === this.#graph) {
15000
15089
  if (options?.ref !== void 0) options.ref.current = this;
@@ -15016,7 +15105,7 @@ var Store = class _Store {
15016
15105
  const baselineDocument = baseline.extension ?? Object.freeze({});
15017
15106
  const classification = classifyModifications(baselineDocument, extension);
15018
15107
  if (classification.incompatible.length > 0) {
15019
- throw new chunkPYJOBZR3_cjs.IncompatibleChangeError(
15108
+ throw new chunkHM6XMR3E_cjs.IncompatibleChangeError(
15020
15109
  classification.incompatible,
15021
15110
  this.graphId
15022
15111
  );
@@ -15030,7 +15119,7 @@ var Store = class _Store {
15030
15119
  );
15031
15120
  if (error !== void 0) throw error;
15032
15121
  }
15033
- const committed = await chunkZGEMI7MJ_cjs.commitNewSchemaVersion(
15122
+ const committed = await chunkXTQHSOIC_cjs.commitNewSchemaVersion(
15034
15123
  this.#backend,
15035
15124
  merged,
15036
15125
  activeRow.version
@@ -15048,7 +15137,7 @@ var Store = class _Store {
15048
15137
  async #runEagerOrThrow(store, eager) {
15049
15138
  const result = await store.materializeIndexes(eager);
15050
15139
  if (result.results.some((entry2) => entry2.status === "failed")) {
15051
- throw new chunkYEDQLNVE_cjs.EagerMaterializationError(result, this.graphId);
15140
+ throw new chunkG6P3OVDY_cjs.EagerMaterializationError(result, this.graphId);
15052
15141
  }
15053
15142
  }
15054
15143
  /**
@@ -15137,6 +15226,150 @@ var Store = class _Store {
15137
15226
  options ?? {}
15138
15227
  );
15139
15228
  }
15229
+ /**
15230
+ * Recreate a vector field's per-field storage at its current declared
15231
+ * dimension, then optionally re-embed existing rows.
15232
+ *
15233
+ * Use this after changing a field's `embedding(N)` to `embedding(M)` (e.g. a
15234
+ * new embedding model): the stored N-dim vectors are invalid under the new
15235
+ * dimension and must be recomputed, not converted. This drops and recreates
15236
+ * the per-`(graphId, kind, field)` table at the new dimension — a brief
15237
+ * window where the field returns no vector hits — resets its materialization
15238
+ * marker, then, when `options.embed` is supplied, pages the kind's nodes,
15239
+ * calls `embed(batch)`, and upserts the returned vectors. Without `embed`,
15240
+ * storage is recreated empty and the caller re-embeds via normal
15241
+ * `update()` / `upsertEmbedding` writes.
15242
+ *
15243
+ * @throws {ConfigurationError} when the backend has no vector strategy or
15244
+ * cannot execute DDL, or `(kind, fieldPath)` is not a declared embedding.
15245
+ */
15246
+ async reembedVectorField(kind, fieldPath, options) {
15247
+ if (options?.batchSize !== void 0 && (!Number.isInteger(options.batchSize) || options.batchSize <= 0)) {
15248
+ throw new RangeError(
15249
+ `reembedVectorField batchSize must be a positive integer, got: ${options.batchSize}`
15250
+ );
15251
+ }
15252
+ const { activeRow, baseline } = await this.#loadCaughtUp("reembed");
15253
+ const backend = this.#backend;
15254
+ const strategy = backend.vectorStrategy;
15255
+ if (strategy === void 0 || backend.executeDdl === void 0) {
15256
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
15257
+ "reembedVectorField requires a backend with a vector strategy and executeDdl.",
15258
+ {
15259
+ backend: backend.dialect,
15260
+ capability: "vector",
15261
+ operation: "reembed"
15262
+ }
15263
+ );
15264
+ }
15265
+ const declaration = (baseline.indexes ?? []).find(
15266
+ (candidate) => candidate.entity === "vector" && candidate.kind === kind && candidate.fieldPath === fieldPath
15267
+ );
15268
+ if (declaration === void 0) {
15269
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
15270
+ `No embedding field "${kind}.${fieldPath}" is declared in the active schema.`,
15271
+ { kind, fieldPath, operation: "reembed" }
15272
+ );
15273
+ }
15274
+ const slot = {
15275
+ graphId: this.graphId,
15276
+ nodeKind: kind,
15277
+ fieldPath,
15278
+ dimensions: declaration.dimensions,
15279
+ metric: declaration.metric,
15280
+ indexType: declaration.indexType
15281
+ };
15282
+ for (const ddl of strategy.buildDropStorage(slot)) {
15283
+ await backend.executeDdl(ddl);
15284
+ }
15285
+ for (const contribution of strategy.ownedTables(slot)) {
15286
+ for (const ddl of contribution.createDdl) {
15287
+ await backend.executeDdl(ddl);
15288
+ }
15289
+ }
15290
+ const declaredIndexMaterializes = declaration.indexType !== "none" && backend.capabilities.vector?.indexTypes.includes(
15291
+ declaration.indexType
15292
+ ) === true;
15293
+ if (declaredIndexMaterializes && backend.createVectorIndex !== void 0) {
15294
+ await backend.createVectorIndex({
15295
+ graphId: this.graphId,
15296
+ nodeKind: kind,
15297
+ fieldPath,
15298
+ dimensions: declaration.dimensions,
15299
+ metric: declaration.metric,
15300
+ indexType: declaration.indexType,
15301
+ indexParams: {
15302
+ m: declaration.indexParams.m,
15303
+ efConstruction: declaration.indexParams.efConstruction,
15304
+ ...declaration.indexParams.lists === void 0 ? {} : { lists: declaration.indexParams.lists }
15305
+ }
15306
+ });
15307
+ }
15308
+ if (declaredIndexMaterializes && backend.recordIndexMaterialization !== void 0) {
15309
+ const tableName = strategy.tableName(this.graphId, kind, fieldPath);
15310
+ const signature = await computeIndexSignature(
15311
+ backend.dialect,
15312
+ tableName,
15313
+ declaration
15314
+ );
15315
+ const now = chunkR2LA6MKR_cjs.nowIso();
15316
+ await backend.recordIndexMaterialization({
15317
+ indexName: vectorStatusKey(this.graphId, declaration.name),
15318
+ graphId: this.graphId,
15319
+ entity: "vector",
15320
+ kind,
15321
+ signature,
15322
+ schemaVersion: activeRow.version,
15323
+ attemptedAt: now,
15324
+ materializedAt: now,
15325
+ error: void 0
15326
+ });
15327
+ }
15328
+ if (options?.embed === void 0) {
15329
+ return { recreated: true, reembedded: 0 };
15330
+ }
15331
+ if (backend.upsertEmbedding === void 0) {
15332
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
15333
+ "reembedVectorField with an `embed` callback requires a backend that supports upsertEmbedding.",
15334
+ {
15335
+ backend: backend.dialect,
15336
+ capability: "vector",
15337
+ operation: "reembed"
15338
+ }
15339
+ );
15340
+ }
15341
+ const upsertEmbedding = backend.upsertEmbedding;
15342
+ const batchSize = options.batchSize ?? DEFAULT_REEMBED_BATCH_SIZE;
15343
+ const collection = this.getNodeCollectionOrThrow(kind);
15344
+ let reembedded = 0;
15345
+ let offset = 0;
15346
+ for (; ; ) {
15347
+ const batch = await collection.find({
15348
+ limit: batchSize,
15349
+ offset
15350
+ });
15351
+ if (batch.length === 0) break;
15352
+ const vectors = await options.embed(batch);
15353
+ for (const node of batch) {
15354
+ const embedding2 = vectors.get(node.id);
15355
+ if (embedding2 === void 0) continue;
15356
+ await upsertEmbedding({
15357
+ graphId: this.graphId,
15358
+ nodeKind: kind,
15359
+ nodeId: node.id,
15360
+ fieldPath,
15361
+ embedding: embedding2,
15362
+ dimensions: declaration.dimensions,
15363
+ metric: declaration.metric,
15364
+ indexType: declaration.indexType
15365
+ });
15366
+ reembedded += 1;
15367
+ }
15368
+ offset += batch.length;
15369
+ if (batch.length < batchSize) break;
15370
+ }
15371
+ return { recreated: true, reembedded };
15372
+ }
15140
15373
  /**
15141
15374
  * Removes extension kinds from the schema with cascading edge and
15142
15375
  * ontology cleanup. Two-phase by design:
@@ -15182,9 +15415,9 @@ var Store = class _Store {
15182
15415
  );
15183
15416
  }
15184
15417
  const compileTimeGraph = stripGraphExtension(this.#graph);
15185
- const merged = plan.document === void 0 ? compileTimeGraph : chunkZGEMI7MJ_cjs.mergeGraphExtension(compileTimeGraph, plan.document);
15186
- const finalGraph = chunkZGEMI7MJ_cjs.applyDeprecatedKinds(merged, baseline.deprecatedKinds);
15187
- const committedRow = await chunkZGEMI7MJ_cjs.commitNewSchemaVersion(
15418
+ const merged = plan.document === void 0 ? compileTimeGraph : chunkXTQHSOIC_cjs.mergeGraphExtension(compileTimeGraph, plan.document);
15419
+ const finalGraph = chunkXTQHSOIC_cjs.applyDeprecatedKinds(merged, baseline.deprecatedKinds);
15420
+ const committedRow = await chunkXTQHSOIC_cjs.commitNewSchemaVersion(
15188
15421
  this.#backend,
15189
15422
  finalGraph,
15190
15423
  activeRow.version
@@ -15194,7 +15427,7 @@ var Store = class _Store {
15194
15427
  if (this.#backend.ensureKindRemovalsTable !== void 0) {
15195
15428
  await this.#backend.ensureKindRemovalsTable();
15196
15429
  }
15197
- const attemptedAt = chunkWFUN6DCM_cjs.nowIso();
15430
+ const attemptedAt = chunkR2LA6MKR_cjs.nowIso();
15198
15431
  const newSchemaVersion = committedRow.version;
15199
15432
  const queue = (kindName, entity) => recordKindRemoval(
15200
15433
  buildPendingKindRemoval({
@@ -15241,8 +15474,8 @@ var Store = class _Store {
15241
15474
  const nextSet = new Set(baseline.deprecatedKinds);
15242
15475
  if (direction === "add") {
15243
15476
  for (const name of names) {
15244
- if (!chunkWFUN6DCM_cjs.isKnownKind(baseline, name)) {
15245
- throw new chunkYEDQLNVE_cjs.KindNotFoundError(
15477
+ if (!chunkR2LA6MKR_cjs.isKnownKind(baseline, name)) {
15478
+ throw new chunkG6P3OVDY_cjs.KindNotFoundError(
15246
15479
  name,
15247
15480
  isKnownEdgeKind(baseline, name) ? "edge" : "node",
15248
15481
  {
@@ -15267,8 +15500,8 @@ var Store = class _Store {
15267
15500
  schemaMetadataFromRow(activeRow)
15268
15501
  );
15269
15502
  }
15270
- const merged = chunkZGEMI7MJ_cjs.applyDeprecatedKinds(baseline, nextSet);
15271
- const result = await chunkZGEMI7MJ_cjs.ensureSchema(this.#backend, merged, {
15503
+ const merged = chunkXTQHSOIC_cjs.applyDeprecatedKinds(baseline, nextSet);
15504
+ const result = await chunkXTQHSOIC_cjs.ensureSchema(this.#backend, merged, {
15272
15505
  preloaded: { activeRow, storedSchema },
15273
15506
  autoMigrate: true
15274
15507
  });
@@ -15277,8 +15510,8 @@ var Store = class _Store {
15277
15510
  }
15278
15511
  #catchUpToStored(storedSchema) {
15279
15512
  const compileTimeGraph = stripGraphExtension(this.#graph);
15280
- const withGraphExtension = storedSchema.extension === void 0 ? compileTimeGraph : chunkZGEMI7MJ_cjs.mergeGraphExtension(compileTimeGraph, storedSchema.extension);
15281
- return chunkZGEMI7MJ_cjs.applyDeprecatedKinds(
15513
+ const withGraphExtension = storedSchema.extension === void 0 ? compileTimeGraph : chunkXTQHSOIC_cjs.mergeGraphExtension(compileTimeGraph, storedSchema.extension);
15514
+ return chunkXTQHSOIC_cjs.applyDeprecatedKinds(
15282
15515
  withGraphExtension,
15283
15516
  storedSchema.deprecatedKinds
15284
15517
  );
@@ -15296,18 +15529,18 @@ var Store = class _Store {
15296
15529
  * serializes the actual commit.
15297
15530
  */
15298
15531
  async #loadCaughtUp(verb) {
15299
- const activeRow = await chunkZGEMI7MJ_cjs.loadActiveSchemaWithBootstrap(
15532
+ const activeRow = await chunkXTQHSOIC_cjs.loadActiveSchemaWithBootstrap(
15300
15533
  this.#backend,
15301
15534
  this.graphId
15302
15535
  );
15303
15536
  if (activeRow === void 0) {
15304
15537
  const { phrase, code } = CAUGHT_UP_VERB_DETAILS[verb];
15305
- throw new chunkYEDQLNVE_cjs.ConfigurationError(
15538
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(
15306
15539
  `Cannot ${phrase} graph "${this.graphId}": no schema has been initialized. Call createStoreWithSchema first.`,
15307
15540
  { code }
15308
15541
  );
15309
15542
  }
15310
- const storedSchema = chunkZGEMI7MJ_cjs.parseSerializedSchema(activeRow.schema_doc);
15543
+ const storedSchema = chunkXTQHSOIC_cjs.parseSerializedSchema(activeRow.schema_doc);
15311
15544
  const baseline = this.#catchUpToStored(storedSchema);
15312
15545
  return { activeRow, storedSchema, baseline };
15313
15546
  }
@@ -15421,7 +15654,7 @@ var Store = class _Store {
15421
15654
  // === Internal: Temporal Filtering ===
15422
15655
  #matchesTemporalMode(row, options) {
15423
15656
  const mode = options?.temporalMode ?? this.#graph.defaults.temporalMode;
15424
- const asOf = options?.asOf ?? chunkWFUN6DCM_cjs.nowIso();
15657
+ const asOf = options?.asOf ?? chunkR2LA6MKR_cjs.nowIso();
15425
15658
  switch (mode) {
15426
15659
  case "current":
15427
15660
  case "asOf": {
@@ -15485,8 +15718,8 @@ async function createStoreWithSchema(graph, backend, options) {
15485
15718
  graph: merged,
15486
15719
  activeRow,
15487
15720
  storedSchema
15488
- } = await chunkZGEMI7MJ_cjs.loadAndMergeGraphExtensionDocument(backend, graph);
15489
- const result = await chunkZGEMI7MJ_cjs.ensureSchema(backend, merged, {
15721
+ } = await chunkXTQHSOIC_cjs.loadAndMergeGraphExtensionDocument(backend, graph);
15722
+ const result = await chunkXTQHSOIC_cjs.ensureSchema(backend, merged, {
15490
15723
  ...options,
15491
15724
  preloaded: { activeRow, storedSchema }
15492
15725
  });
@@ -15504,7 +15737,7 @@ async function createVerifiedStore(graph, backend, options) {
15504
15737
  graph: merged,
15505
15738
  activeRow,
15506
15739
  result
15507
- } = await chunkZGEMI7MJ_cjs.loadAndVerifyGraph(backend, graph);
15740
+ } = await chunkXTQHSOIC_cjs.loadAndVerifyGraph(backend, graph);
15508
15741
  const store = new Store(
15509
15742
  merged,
15510
15743
  backend,
@@ -15514,317 +15747,349 @@ async function createVerifiedStore(graph, backend, options) {
15514
15747
  return [store, result];
15515
15748
  }
15516
15749
 
15750
+ Object.defineProperty(exports, "libsqlVectorStrategy", {
15751
+ enumerable: true,
15752
+ get: function () { return chunkQ5ASTPM4_cjs.libsqlVectorStrategy; }
15753
+ });
15754
+ Object.defineProperty(exports, "pgvectorStrategy", {
15755
+ enumerable: true,
15756
+ get: function () { return chunkKGAJ5HFO_cjs.pgvectorStrategy; }
15757
+ });
15517
15758
  Object.defineProperty(exports, "broader", {
15518
15759
  enumerable: true,
15519
- get: function () { return chunkZGEMI7MJ_cjs.broader; }
15760
+ get: function () { return chunkXTQHSOIC_cjs.broader; }
15520
15761
  });
15521
15762
  Object.defineProperty(exports, "core", {
15522
15763
  enumerable: true,
15523
- get: function () { return chunkZGEMI7MJ_cjs.core; }
15764
+ get: function () { return chunkXTQHSOIC_cjs.core; }
15524
15765
  });
15525
15766
  Object.defineProperty(exports, "defineEdge", {
15526
15767
  enumerable: true,
15527
- get: function () { return chunkZGEMI7MJ_cjs.defineEdge; }
15768
+ get: function () { return chunkXTQHSOIC_cjs.defineEdge; }
15528
15769
  });
15529
15770
  Object.defineProperty(exports, "defineNode", {
15530
15771
  enumerable: true,
15531
- get: function () { return chunkZGEMI7MJ_cjs.defineNode; }
15772
+ get: function () { return chunkXTQHSOIC_cjs.defineNode; }
15532
15773
  });
15533
15774
  Object.defineProperty(exports, "differentFrom", {
15534
15775
  enumerable: true,
15535
- get: function () { return chunkZGEMI7MJ_cjs.differentFrom; }
15776
+ get: function () { return chunkXTQHSOIC_cjs.differentFrom; }
15536
15777
  });
15537
15778
  Object.defineProperty(exports, "disjointWith", {
15538
15779
  enumerable: true,
15539
- get: function () { return chunkZGEMI7MJ_cjs.disjointWith; }
15780
+ get: function () { return chunkXTQHSOIC_cjs.disjointWith; }
15540
15781
  });
15541
15782
  Object.defineProperty(exports, "equivalentTo", {
15542
15783
  enumerable: true,
15543
- get: function () { return chunkZGEMI7MJ_cjs.equivalentTo; }
15784
+ get: function () { return chunkXTQHSOIC_cjs.equivalentTo; }
15544
15785
  });
15545
15786
  Object.defineProperty(exports, "hasPart", {
15546
15787
  enumerable: true,
15547
- get: function () { return chunkZGEMI7MJ_cjs.hasPart; }
15788
+ get: function () { return chunkXTQHSOIC_cjs.hasPart; }
15548
15789
  });
15549
15790
  Object.defineProperty(exports, "implies", {
15550
15791
  enumerable: true,
15551
- get: function () { return chunkZGEMI7MJ_cjs.implies; }
15792
+ get: function () { return chunkXTQHSOIC_cjs.implies; }
15552
15793
  });
15553
15794
  Object.defineProperty(exports, "inverseOf", {
15554
15795
  enumerable: true,
15555
- get: function () { return chunkZGEMI7MJ_cjs.inverseOf; }
15796
+ get: function () { return chunkXTQHSOIC_cjs.inverseOf; }
15556
15797
  });
15557
15798
  Object.defineProperty(exports, "isMetaEdge", {
15558
15799
  enumerable: true,
15559
- get: function () { return chunkZGEMI7MJ_cjs.isMetaEdge; }
15800
+ get: function () { return chunkXTQHSOIC_cjs.isMetaEdge; }
15560
15801
  });
15561
15802
  Object.defineProperty(exports, "narrower", {
15562
15803
  enumerable: true,
15563
- get: function () { return chunkZGEMI7MJ_cjs.narrower; }
15804
+ get: function () { return chunkXTQHSOIC_cjs.narrower; }
15564
15805
  });
15565
15806
  Object.defineProperty(exports, "partOf", {
15566
15807
  enumerable: true,
15567
- get: function () { return chunkZGEMI7MJ_cjs.partOf; }
15808
+ get: function () { return chunkXTQHSOIC_cjs.partOf; }
15568
15809
  });
15569
15810
  Object.defineProperty(exports, "relatedTo", {
15570
15811
  enumerable: true,
15571
- get: function () { return chunkZGEMI7MJ_cjs.relatedTo; }
15812
+ get: function () { return chunkXTQHSOIC_cjs.relatedTo; }
15572
15813
  });
15573
15814
  Object.defineProperty(exports, "sameAs", {
15574
15815
  enumerable: true,
15575
- get: function () { return chunkZGEMI7MJ_cjs.sameAs; }
15816
+ get: function () { return chunkXTQHSOIC_cjs.sameAs; }
15576
15817
  });
15577
15818
  Object.defineProperty(exports, "subClassOf", {
15578
15819
  enumerable: true,
15579
- get: function () { return chunkZGEMI7MJ_cjs.subClassOf; }
15820
+ get: function () { return chunkXTQHSOIC_cjs.subClassOf; }
15580
15821
  });
15581
15822
  Object.defineProperty(exports, "defineGraph", {
15582
15823
  enumerable: true,
15583
- get: function () { return chunkWFUN6DCM_cjs.defineGraph; }
15824
+ get: function () { return chunkR2LA6MKR_cjs.defineGraph; }
15584
15825
  });
15585
15826
  Object.defineProperty(exports, "getEdgeKinds", {
15586
15827
  enumerable: true,
15587
- get: function () { return chunkWFUN6DCM_cjs.getEdgeKinds; }
15828
+ get: function () { return chunkR2LA6MKR_cjs.getEdgeKinds; }
15588
15829
  });
15589
15830
  Object.defineProperty(exports, "getNodeKinds", {
15590
15831
  enumerable: true,
15591
- get: function () { return chunkWFUN6DCM_cjs.getNodeKinds; }
15832
+ get: function () { return chunkR2LA6MKR_cjs.getNodeKinds; }
15592
15833
  });
15593
15834
  Object.defineProperty(exports, "isEdgeType", {
15594
15835
  enumerable: true,
15595
- get: function () { return chunkWFUN6DCM_cjs.isEdgeType; }
15836
+ get: function () { return chunkR2LA6MKR_cjs.isEdgeType; }
15596
15837
  });
15597
15838
  Object.defineProperty(exports, "isEdgeTypeWithEndpoints", {
15598
15839
  enumerable: true,
15599
- get: function () { return chunkWFUN6DCM_cjs.isEdgeTypeWithEndpoints; }
15840
+ get: function () { return chunkR2LA6MKR_cjs.isEdgeTypeWithEndpoints; }
15600
15841
  });
15601
15842
  Object.defineProperty(exports, "isGraphDef", {
15602
15843
  enumerable: true,
15603
- get: function () { return chunkWFUN6DCM_cjs.isGraphDef; }
15844
+ get: function () { return chunkR2LA6MKR_cjs.isGraphDef; }
15604
15845
  });
15605
15846
  Object.defineProperty(exports, "isNodeType", {
15606
15847
  enumerable: true,
15607
- get: function () { return chunkWFUN6DCM_cjs.isNodeType; }
15848
+ get: function () { return chunkR2LA6MKR_cjs.isNodeType; }
15608
15849
  });
15609
15850
  Object.defineProperty(exports, "defineGraphExtension", {
15610
15851
  enumerable: true,
15611
- get: function () { return chunk4FJVSF3K_cjs.defineGraphExtension; }
15852
+ get: function () { return chunkQ3ZZLU3O_cjs.defineGraphExtension; }
15612
15853
  });
15613
15854
  Object.defineProperty(exports, "CURRENT_GRAPH_EXTENSION_VERSION", {
15614
15855
  enumerable: true,
15615
- get: function () { return chunkPYJOBZR3_cjs.CURRENT_GRAPH_EXTENSION_VERSION; }
15856
+ get: function () { return chunkHM6XMR3E_cjs.CURRENT_GRAPH_EXTENSION_VERSION; }
15616
15857
  });
15617
15858
  Object.defineProperty(exports, "GraphExtensionError", {
15618
15859
  enumerable: true,
15619
- get: function () { return chunkPYJOBZR3_cjs.GraphExtensionError; }
15860
+ get: function () { return chunkHM6XMR3E_cjs.GraphExtensionError; }
15620
15861
  });
15621
15862
  Object.defineProperty(exports, "GraphExtensionUnresolvedEndpointError", {
15622
15863
  enumerable: true,
15623
- get: function () { return chunkPYJOBZR3_cjs.GraphExtensionUnresolvedEndpointError; }
15864
+ get: function () { return chunkHM6XMR3E_cjs.GraphExtensionUnresolvedEndpointError; }
15624
15865
  });
15625
15866
  Object.defineProperty(exports, "GraphExtensionValidationError", {
15626
15867
  enumerable: true,
15627
- get: function () { return chunkPYJOBZR3_cjs.GraphExtensionValidationError; }
15868
+ get: function () { return chunkHM6XMR3E_cjs.GraphExtensionValidationError; }
15628
15869
  });
15629
15870
  Object.defineProperty(exports, "GraphExtensionVersionUnsupportedError", {
15630
15871
  enumerable: true,
15631
- get: function () { return chunkPYJOBZR3_cjs.GraphExtensionVersionUnsupportedError; }
15872
+ get: function () { return chunkHM6XMR3E_cjs.GraphExtensionVersionUnsupportedError; }
15632
15873
  });
15633
15874
  Object.defineProperty(exports, "IncompatibleChangeError", {
15634
15875
  enumerable: true,
15635
- get: function () { return chunkPYJOBZR3_cjs.IncompatibleChangeError; }
15876
+ get: function () { return chunkHM6XMR3E_cjs.IncompatibleChangeError; }
15636
15877
  });
15637
15878
  Object.defineProperty(exports, "KindCollisionError", {
15638
15879
  enumerable: true,
15639
- get: function () { return chunkPYJOBZR3_cjs.KindCollisionError; }
15880
+ get: function () { return chunkHM6XMR3E_cjs.KindCollisionError; }
15640
15881
  });
15641
15882
  Object.defineProperty(exports, "KindHasReferentsError", {
15642
15883
  enumerable: true,
15643
- get: function () { return chunkPYJOBZR3_cjs.KindHasReferentsError; }
15884
+ get: function () { return chunkHM6XMR3E_cjs.KindHasReferentsError; }
15644
15885
  });
15645
15886
  Object.defineProperty(exports, "LEGACY_GRAPH_EXTENSION_VERSION", {
15646
15887
  enumerable: true,
15647
- get: function () { return chunkPYJOBZR3_cjs.LEGACY_GRAPH_EXTENSION_VERSION; }
15888
+ get: function () { return chunkHM6XMR3E_cjs.LEGACY_GRAPH_EXTENSION_VERSION; }
15648
15889
  });
15649
15890
  Object.defineProperty(exports, "RemoveCompileTimeKindError", {
15650
15891
  enumerable: true,
15651
- get: function () { return chunkPYJOBZR3_cjs.RemoveCompileTimeKindError; }
15892
+ get: function () { return chunkHM6XMR3E_cjs.RemoveCompileTimeKindError; }
15893
+ });
15894
+ Object.defineProperty(exports, "computeTransitiveClosure", {
15895
+ enumerable: true,
15896
+ get: function () { return chunkHM6XMR3E_cjs.computeTransitiveClosure; }
15897
+ });
15898
+ Object.defineProperty(exports, "invertClosure", {
15899
+ enumerable: true,
15900
+ get: function () { return chunkHM6XMR3E_cjs.invertClosure; }
15901
+ });
15902
+ Object.defineProperty(exports, "isReachable", {
15903
+ enumerable: true,
15904
+ get: function () { return chunkHM6XMR3E_cjs.isReachable; }
15652
15905
  });
15653
15906
  Object.defineProperty(exports, "validateGraphExtension", {
15654
15907
  enumerable: true,
15655
- get: function () { return chunkPYJOBZR3_cjs.validateGraphExtension; }
15908
+ get: function () { return chunkHM6XMR3E_cjs.validateGraphExtension; }
15909
+ });
15910
+ Object.defineProperty(exports, "sqliteVecStrategy", {
15911
+ enumerable: true,
15912
+ get: function () { return chunk4K6IHUW6_cjs.sqliteVecStrategy; }
15656
15913
  });
15657
15914
  Object.defineProperty(exports, "andWhere", {
15658
15915
  enumerable: true,
15659
- get: function () { return chunkPN37HVAV_cjs.andWhere; }
15916
+ get: function () { return chunkC2RWFIYP_cjs.andWhere; }
15917
+ });
15918
+ Object.defineProperty(exports, "buildVectorCapabilities", {
15919
+ enumerable: true,
15920
+ get: function () { return chunkC2RWFIYP_cjs.buildVectorCapabilities; }
15660
15921
  });
15661
15922
  Object.defineProperty(exports, "fts5Strategy", {
15662
15923
  enumerable: true,
15663
- get: function () { return chunkPN37HVAV_cjs.fts5Strategy; }
15924
+ get: function () { return chunkC2RWFIYP_cjs.fts5Strategy; }
15664
15925
  });
15665
15926
  Object.defineProperty(exports, "notWhere", {
15666
15927
  enumerable: true,
15667
- get: function () { return chunkPN37HVAV_cjs.notWhere; }
15928
+ get: function () { return chunkC2RWFIYP_cjs.notWhere; }
15668
15929
  });
15669
15930
  Object.defineProperty(exports, "orWhere", {
15670
15931
  enumerable: true,
15671
- get: function () { return chunkPN37HVAV_cjs.orWhere; }
15932
+ get: function () { return chunkC2RWFIYP_cjs.orWhere; }
15672
15933
  });
15673
15934
  Object.defineProperty(exports, "tsvectorStrategy", {
15674
15935
  enumerable: true,
15675
- get: function () { return chunkPN37HVAV_cjs.tsvectorStrategy; }
15936
+ get: function () { return chunkC2RWFIYP_cjs.tsvectorStrategy; }
15676
15937
  });
15677
15938
  Object.defineProperty(exports, "defineEdgeIndex", {
15678
15939
  enumerable: true,
15679
- get: function () { return chunkCTHNVU6K_cjs.defineEdgeIndex; }
15940
+ get: function () { return chunkUPBXUOW7_cjs.defineEdgeIndex; }
15680
15941
  });
15681
15942
  Object.defineProperty(exports, "defineNodeIndex", {
15682
15943
  enumerable: true,
15683
- get: function () { return chunkCTHNVU6K_cjs.defineNodeIndex; }
15944
+ get: function () { return chunkUPBXUOW7_cjs.defineNodeIndex; }
15684
15945
  });
15685
15946
  Object.defineProperty(exports, "DEFAULT_SEARCHABLE_LANGUAGE", {
15686
15947
  enumerable: true,
15687
- get: function () { return chunkEK6RJ373_cjs.DEFAULT_SEARCHABLE_LANGUAGE; }
15948
+ get: function () { return chunkVGU26WIU_cjs.DEFAULT_SEARCHABLE_LANGUAGE; }
15688
15949
  });
15689
15950
  Object.defineProperty(exports, "getSearchableMetadata", {
15690
15951
  enumerable: true,
15691
- get: function () { return chunkEK6RJ373_cjs.getSearchableMetadata; }
15952
+ get: function () { return chunkVGU26WIU_cjs.getSearchableMetadata; }
15692
15953
  });
15693
15954
  Object.defineProperty(exports, "isSearchableSchema", {
15694
15955
  enumerable: true,
15695
- get: function () { return chunkEK6RJ373_cjs.isSearchableSchema; }
15956
+ get: function () { return chunkVGU26WIU_cjs.isSearchableSchema; }
15696
15957
  });
15697
15958
  Object.defineProperty(exports, "searchable", {
15698
15959
  enumerable: true,
15699
- get: function () { return chunkEK6RJ373_cjs.searchable; }
15960
+ get: function () { return chunkVGU26WIU_cjs.searchable; }
15700
15961
  });
15701
15962
  Object.defineProperty(exports, "embedding", {
15702
15963
  enumerable: true,
15703
- get: function () { return chunkX3244EKP_cjs.embedding; }
15964
+ get: function () { return chunkZFWNO3GE_cjs.embedding; }
15704
15965
  });
15705
15966
  Object.defineProperty(exports, "getEmbeddingDimensions", {
15706
15967
  enumerable: true,
15707
- get: function () { return chunkX3244EKP_cjs.getEmbeddingDimensions; }
15968
+ get: function () { return chunkZFWNO3GE_cjs.getEmbeddingDimensions; }
15708
15969
  });
15709
15970
  Object.defineProperty(exports, "isEmbeddingSchema", {
15710
15971
  enumerable: true,
15711
- get: function () { return chunkX3244EKP_cjs.isEmbeddingSchema; }
15972
+ get: function () { return chunkZFWNO3GE_cjs.isEmbeddingSchema; }
15712
15973
  });
15713
15974
  Object.defineProperty(exports, "BackendDisposedError", {
15714
15975
  enumerable: true,
15715
- get: function () { return chunkYEDQLNVE_cjs.BackendDisposedError; }
15976
+ get: function () { return chunkG6P3OVDY_cjs.BackendDisposedError; }
15716
15977
  });
15717
15978
  Object.defineProperty(exports, "CardinalityError", {
15718
15979
  enumerable: true,
15719
- get: function () { return chunkYEDQLNVE_cjs.CardinalityError; }
15980
+ get: function () { return chunkG6P3OVDY_cjs.CardinalityError; }
15720
15981
  });
15721
15982
  Object.defineProperty(exports, "CompilerInvariantError", {
15722
15983
  enumerable: true,
15723
- get: function () { return chunkYEDQLNVE_cjs.CompilerInvariantError; }
15984
+ get: function () { return chunkG6P3OVDY_cjs.CompilerInvariantError; }
15724
15985
  });
15725
15986
  Object.defineProperty(exports, "ConfigurationError", {
15726
15987
  enumerable: true,
15727
- get: function () { return chunkYEDQLNVE_cjs.ConfigurationError; }
15988
+ get: function () { return chunkG6P3OVDY_cjs.ConfigurationError; }
15728
15989
  });
15729
15990
  Object.defineProperty(exports, "DatabaseOperationError", {
15730
15991
  enumerable: true,
15731
- get: function () { return chunkYEDQLNVE_cjs.DatabaseOperationError; }
15992
+ get: function () { return chunkG6P3OVDY_cjs.DatabaseOperationError; }
15732
15993
  });
15733
15994
  Object.defineProperty(exports, "DisjointError", {
15734
15995
  enumerable: true,
15735
- get: function () { return chunkYEDQLNVE_cjs.DisjointError; }
15996
+ get: function () { return chunkG6P3OVDY_cjs.DisjointError; }
15736
15997
  });
15737
15998
  Object.defineProperty(exports, "EagerMaterializationError", {
15738
15999
  enumerable: true,
15739
- get: function () { return chunkYEDQLNVE_cjs.EagerMaterializationError; }
16000
+ get: function () { return chunkG6P3OVDY_cjs.EagerMaterializationError; }
15740
16001
  });
15741
16002
  Object.defineProperty(exports, "EdgeNotFoundError", {
15742
16003
  enumerable: true,
15743
- get: function () { return chunkYEDQLNVE_cjs.EdgeNotFoundError; }
16004
+ get: function () { return chunkG6P3OVDY_cjs.EdgeNotFoundError; }
16005
+ });
16006
+ Object.defineProperty(exports, "EmbeddingDimensionChangedError", {
16007
+ enumerable: true,
16008
+ get: function () { return chunkG6P3OVDY_cjs.EmbeddingDimensionChangedError; }
15744
16009
  });
15745
16010
  Object.defineProperty(exports, "EndpointError", {
15746
16011
  enumerable: true,
15747
- get: function () { return chunkYEDQLNVE_cjs.EndpointError; }
16012
+ get: function () { return chunkG6P3OVDY_cjs.EndpointError; }
15748
16013
  });
15749
16014
  Object.defineProperty(exports, "EndpointNotFoundError", {
15750
16015
  enumerable: true,
15751
- get: function () { return chunkYEDQLNVE_cjs.EndpointNotFoundError; }
16016
+ get: function () { return chunkG6P3OVDY_cjs.EndpointNotFoundError; }
15752
16017
  });
15753
16018
  Object.defineProperty(exports, "KindNotFoundError", {
15754
16019
  enumerable: true,
15755
- get: function () { return chunkYEDQLNVE_cjs.KindNotFoundError; }
16020
+ get: function () { return chunkG6P3OVDY_cjs.KindNotFoundError; }
15756
16021
  });
15757
16022
  Object.defineProperty(exports, "MigrationError", {
15758
16023
  enumerable: true,
15759
- get: function () { return chunkYEDQLNVE_cjs.MigrationError; }
16024
+ get: function () { return chunkG6P3OVDY_cjs.MigrationError; }
15760
16025
  });
15761
16026
  Object.defineProperty(exports, "NodeConstraintNotFoundError", {
15762
16027
  enumerable: true,
15763
- get: function () { return chunkYEDQLNVE_cjs.NodeConstraintNotFoundError; }
16028
+ get: function () { return chunkG6P3OVDY_cjs.NodeConstraintNotFoundError; }
15764
16029
  });
15765
16030
  Object.defineProperty(exports, "NodeNotFoundError", {
15766
16031
  enumerable: true,
15767
- get: function () { return chunkYEDQLNVE_cjs.NodeNotFoundError; }
16032
+ get: function () { return chunkG6P3OVDY_cjs.NodeNotFoundError; }
15768
16033
  });
15769
16034
  Object.defineProperty(exports, "RestrictedDeleteError", {
15770
16035
  enumerable: true,
15771
- get: function () { return chunkYEDQLNVE_cjs.RestrictedDeleteError; }
16036
+ get: function () { return chunkG6P3OVDY_cjs.RestrictedDeleteError; }
15772
16037
  });
15773
16038
  Object.defineProperty(exports, "SchemaContentConflictError", {
15774
16039
  enumerable: true,
15775
- get: function () { return chunkYEDQLNVE_cjs.SchemaContentConflictError; }
16040
+ get: function () { return chunkG6P3OVDY_cjs.SchemaContentConflictError; }
15776
16041
  });
15777
16042
  Object.defineProperty(exports, "SchemaMismatchError", {
15778
16043
  enumerable: true,
15779
- get: function () { return chunkYEDQLNVE_cjs.SchemaMismatchError; }
16044
+ get: function () { return chunkG6P3OVDY_cjs.SchemaMismatchError; }
15780
16045
  });
15781
16046
  Object.defineProperty(exports, "StaleVersionError", {
15782
16047
  enumerable: true,
15783
- get: function () { return chunkYEDQLNVE_cjs.StaleVersionError; }
16048
+ get: function () { return chunkG6P3OVDY_cjs.StaleVersionError; }
15784
16049
  });
15785
16050
  Object.defineProperty(exports, "StoreNotInitializedError", {
15786
16051
  enumerable: true,
15787
- get: function () { return chunkYEDQLNVE_cjs.StoreNotInitializedError; }
16052
+ get: function () { return chunkG6P3OVDY_cjs.StoreNotInitializedError; }
15788
16053
  });
15789
16054
  Object.defineProperty(exports, "TypeGraphError", {
15790
16055
  enumerable: true,
15791
- get: function () { return chunkYEDQLNVE_cjs.TypeGraphError; }
16056
+ get: function () { return chunkG6P3OVDY_cjs.TypeGraphError; }
15792
16057
  });
15793
16058
  Object.defineProperty(exports, "UniquenessError", {
15794
16059
  enumerable: true,
15795
- get: function () { return chunkYEDQLNVE_cjs.UniquenessError; }
16060
+ get: function () { return chunkG6P3OVDY_cjs.UniquenessError; }
15796
16061
  });
15797
16062
  Object.defineProperty(exports, "UnsupportedPredicateError", {
15798
16063
  enumerable: true,
15799
- get: function () { return chunkYEDQLNVE_cjs.UnsupportedPredicateError; }
16064
+ get: function () { return chunkG6P3OVDY_cjs.UnsupportedPredicateError; }
15800
16065
  });
15801
16066
  Object.defineProperty(exports, "ValidationError", {
15802
16067
  enumerable: true,
15803
- get: function () { return chunkYEDQLNVE_cjs.ValidationError; }
16068
+ get: function () { return chunkG6P3OVDY_cjs.ValidationError; }
15804
16069
  });
15805
16070
  Object.defineProperty(exports, "VersionConflictError", {
15806
16071
  enumerable: true,
15807
- get: function () { return chunkYEDQLNVE_cjs.VersionConflictError; }
16072
+ get: function () { return chunkG6P3OVDY_cjs.VersionConflictError; }
15808
16073
  });
15809
16074
  Object.defineProperty(exports, "getErrorSuggestion", {
15810
16075
  enumerable: true,
15811
- get: function () { return chunkYEDQLNVE_cjs.getErrorSuggestion; }
16076
+ get: function () { return chunkG6P3OVDY_cjs.getErrorSuggestion; }
15812
16077
  });
15813
16078
  Object.defineProperty(exports, "isConstraintError", {
15814
16079
  enumerable: true,
15815
- get: function () { return chunkYEDQLNVE_cjs.isConstraintError; }
16080
+ get: function () { return chunkG6P3OVDY_cjs.isConstraintError; }
15816
16081
  });
15817
16082
  Object.defineProperty(exports, "isSystemError", {
15818
16083
  enumerable: true,
15819
- get: function () { return chunkYEDQLNVE_cjs.isSystemError; }
16084
+ get: function () { return chunkG6P3OVDY_cjs.isSystemError; }
15820
16085
  });
15821
16086
  Object.defineProperty(exports, "isTypeGraphError", {
15822
16087
  enumerable: true,
15823
- get: function () { return chunkYEDQLNVE_cjs.isTypeGraphError; }
16088
+ get: function () { return chunkG6P3OVDY_cjs.isTypeGraphError; }
15824
16089
  });
15825
16090
  Object.defineProperty(exports, "isUserRecoverable", {
15826
16091
  enumerable: true,
15827
- get: function () { return chunkYEDQLNVE_cjs.isUserRecoverable; }
16092
+ get: function () { return chunkG6P3OVDY_cjs.isUserRecoverable; }
15828
16093
  });
15829
16094
  Object.defineProperty(exports, "MAX_JSON_POINTER_DEPTH", {
15830
16095
  enumerable: true,
@@ -15887,6 +16152,7 @@ exports.isParameterRef = isParameterRef;
15887
16152
  exports.limitFragment = limitFragment;
15888
16153
  exports.max = max;
15889
16154
  exports.metaEdge = metaEdge;
16155
+ exports.migrateLegacyEmbeddings = migrateLegacyEmbeddings;
15890
16156
  exports.min = min;
15891
16157
  exports.notExists = notExists;
15892
16158
  exports.notInSubquery = notInSubquery;