@nicia-ai/typegraph 0.37.0 → 0.38.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 (372) hide show
  1. package/README.md +12 -10
  2. package/dist/backend/drizzle/indexes.cjs +32 -0
  3. package/dist/backend/drizzle/indexes.cjs.map +1 -0
  4. package/dist/backend/drizzle/indexes.d.cts +43 -0
  5. package/dist/backend/drizzle/indexes.d.ts +43 -0
  6. package/dist/backend/drizzle/indexes.js +11 -0
  7. package/dist/backend/drizzle/indexes.js.map +1 -0
  8. package/dist/backend/index.cjs +161 -0
  9. package/dist/backend/index.cjs.map +1 -0
  10. package/dist/backend/index.d.cts +3 -0
  11. package/dist/backend/index.d.ts +3 -0
  12. package/dist/backend/index.js +8 -0
  13. package/dist/backend/index.js.map +1 -0
  14. package/dist/backend/postgres/index.cjs +32 -28
  15. package/dist/backend/postgres/index.d.cts +13 -12
  16. package/dist/backend/postgres/index.d.ts +13 -12
  17. package/dist/backend/postgres/index.js +19 -15
  18. package/dist/backend/postgres/pglite-store.cjs +67 -0
  19. package/dist/backend/postgres/pglite-store.cjs.map +1 -0
  20. package/dist/backend/postgres/pglite-store.d.cts +38 -0
  21. package/dist/backend/postgres/pglite-store.d.ts +38 -0
  22. package/dist/backend/postgres/pglite-store.js +65 -0
  23. package/dist/backend/postgres/pglite-store.js.map +1 -0
  24. package/dist/backend/postgres/pglite.cjs +25 -50
  25. package/dist/backend/postgres/pglite.cjs.map +1 -1
  26. package/dist/backend/postgres/pglite.d.cts +10 -9
  27. package/dist/backend/postgres/pglite.d.ts +10 -9
  28. package/dist/backend/postgres/pglite.js +20 -52
  29. package/dist/backend/postgres/pglite.js.map +1 -1
  30. package/dist/backend/sqlite/index.cjs +29 -25
  31. package/dist/backend/sqlite/index.d.cts +11 -11
  32. package/dist/backend/sqlite/index.d.ts +11 -11
  33. package/dist/backend/sqlite/index.js +17 -13
  34. package/dist/backend/sqlite/libsql.cjs +23 -19
  35. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  36. package/dist/backend/sqlite/libsql.d.cts +9 -10
  37. package/dist/backend/sqlite/libsql.d.ts +9 -10
  38. package/dist/backend/sqlite/libsql.js +19 -15
  39. package/dist/backend/sqlite/libsql.js.map +1 -1
  40. package/dist/backend/sqlite/local-store.cjs +72 -0
  41. package/dist/backend/sqlite/local-store.cjs.map +1 -0
  42. package/dist/backend/sqlite/local-store.d.cts +42 -0
  43. package/dist/backend/sqlite/local-store.d.ts +42 -0
  44. package/dist/backend/sqlite/local-store.js +67 -0
  45. package/dist/backend/sqlite/local-store.js.map +1 -0
  46. package/dist/backend/sqlite/local.cjs +28 -183
  47. package/dist/backend/sqlite/local.cjs.map +1 -1
  48. package/dist/backend/sqlite/local.d.cts +8 -81
  49. package/dist/backend/sqlite/local.d.ts +8 -81
  50. package/dist/backend/sqlite/local.js +20 -180
  51. package/dist/backend/sqlite/local.js.map +1 -1
  52. package/dist/chunk-2EBMPJBO.js +16 -0
  53. package/dist/chunk-2EBMPJBO.js.map +1 -0
  54. package/dist/{chunk-NBP2WTJW.cjs → chunk-2SL7OGPR.cjs} +2900 -1597
  55. package/dist/chunk-2SL7OGPR.cjs.map +1 -0
  56. package/dist/chunk-35S6P5ZU.js +27 -0
  57. package/dist/chunk-35S6P5ZU.js.map +1 -0
  58. package/dist/chunk-3LKL3S6X.js +50 -0
  59. package/dist/chunk-3LKL3S6X.js.map +1 -0
  60. package/dist/chunk-6G5CQ6JX.js +47 -0
  61. package/dist/chunk-6G5CQ6JX.js.map +1 -0
  62. package/dist/chunk-6XDBRDZE.js +312 -0
  63. package/dist/chunk-6XDBRDZE.js.map +1 -0
  64. package/dist/chunk-764JHTLT.cjs +15 -0
  65. package/dist/chunk-764JHTLT.cjs.map +1 -0
  66. package/dist/chunk-76HE7DJP.js +68 -0
  67. package/dist/chunk-76HE7DJP.js.map +1 -0
  68. package/dist/{chunk-VGDDG3XJ.cjs → chunk-7M3NACL3.cjs} +12 -12
  69. package/dist/{chunk-VGDDG3XJ.cjs.map → chunk-7M3NACL3.cjs.map} +1 -1
  70. package/dist/{chunk-NXQFATMF.cjs → chunk-7VLCN3JB.cjs} +153 -123
  71. package/dist/chunk-7VLCN3JB.cjs.map +1 -0
  72. package/dist/{chunk-552KNYQJ.js → chunk-A2FGSWMQ.js} +1907 -607
  73. package/dist/chunk-A2FGSWMQ.js.map +1 -0
  74. package/dist/chunk-AOL64O4Z.js +165 -0
  75. package/dist/chunk-AOL64O4Z.js.map +1 -0
  76. package/dist/{chunk-27SSDCEP.cjs → chunk-B63IFHXR.cjs} +53 -74
  77. package/dist/chunk-B63IFHXR.cjs.map +1 -0
  78. package/dist/{chunk-3XXGYU62.cjs → chunk-BKAKAVRW.cjs} +56 -53
  79. package/dist/chunk-BKAKAVRW.cjs.map +1 -0
  80. package/dist/{chunk-YTSN73ND.js → chunk-BQITNFQJ.js} +3 -3
  81. package/dist/{chunk-YTSN73ND.js.map → chunk-BQITNFQJ.js.map} +1 -1
  82. package/dist/{chunk-NUIG3BCV.cjs → chunk-CQC6VBAF.cjs} +93 -155
  83. package/dist/chunk-CQC6VBAF.cjs.map +1 -0
  84. package/dist/{chunk-6EEO3OVU.cjs → chunk-CWX77JB4.cjs} +22 -59
  85. package/dist/chunk-CWX77JB4.cjs.map +1 -0
  86. package/dist/{chunk-UGZUAYAR.js → chunk-D7PG5D5K.js} +4 -3
  87. package/dist/chunk-D7PG5D5K.js.map +1 -0
  88. package/dist/chunk-DDCIXXOO.js +9 -0
  89. package/dist/chunk-DDCIXXOO.js.map +1 -0
  90. package/dist/chunk-DDCYVIVV.cjs +44 -0
  91. package/dist/chunk-DDCYVIVV.cjs.map +1 -0
  92. package/dist/{chunk-XPCZADMT.cjs → chunk-DOVMTPKE.cjs} +89 -27
  93. package/dist/chunk-DOVMTPKE.cjs.map +1 -0
  94. package/dist/{chunk-5PNMDJ7J.js → chunk-DPNA466P.js} +14 -9
  95. package/dist/chunk-DPNA466P.js.map +1 -0
  96. package/dist/{chunk-BYPOGQWK.js → chunk-DRACN6XG.js} +6 -4
  97. package/dist/chunk-DRACN6XG.js.map +1 -0
  98. package/dist/chunk-E6TXEISH.cjs +175 -0
  99. package/dist/chunk-E6TXEISH.cjs.map +1 -0
  100. package/dist/{chunk-TKT2XHED.js → chunk-E6YZRKMM.js} +13 -12
  101. package/dist/chunk-E6YZRKMM.js.map +1 -0
  102. package/dist/{chunk-3C2RYI6L.cjs → chunk-EOJFGECD.cjs} +11 -11
  103. package/dist/chunk-EOJFGECD.cjs.map +1 -0
  104. package/dist/{chunk-XWV4JT34.js → chunk-ERZ4QPQX.js} +27 -22
  105. package/dist/chunk-ERZ4QPQX.js.map +1 -0
  106. package/dist/{chunk-DFVLCOP6.js → chunk-EZH7FNUS.js} +3 -3
  107. package/dist/{chunk-DFVLCOP6.js.map → chunk-EZH7FNUS.js.map} +1 -1
  108. package/dist/{chunk-WWFHO375.cjs → chunk-FJMPR3OH.cjs} +4 -3
  109. package/dist/chunk-FJMPR3OH.cjs.map +1 -0
  110. package/dist/chunk-FMNUSGZ4.cjs +12 -0
  111. package/dist/chunk-FMNUSGZ4.cjs.map +1 -0
  112. package/dist/{chunk-K3Q3LJY3.js → chunk-G32AO634.js} +201 -100
  113. package/dist/chunk-G32AO634.js.map +1 -0
  114. package/dist/{chunk-EXU3RASM.js → chunk-G3CSQLLT.js} +20 -474
  115. package/dist/chunk-G3CSQLLT.js.map +1 -0
  116. package/dist/chunk-GNPGGLAE.cjs +212 -0
  117. package/dist/chunk-GNPGGLAE.cjs.map +1 -0
  118. package/dist/{chunk-QARBLBXT.cjs → chunk-GUUWKPTK.cjs} +7 -7
  119. package/dist/{chunk-QARBLBXT.cjs.map → chunk-GUUWKPTK.cjs.map} +1 -1
  120. package/dist/chunk-GYA4JRP5.js +31 -0
  121. package/dist/chunk-GYA4JRP5.js.map +1 -0
  122. package/dist/chunk-I6FX7AAG.js +39 -0
  123. package/dist/chunk-I6FX7AAG.js.map +1 -0
  124. package/dist/chunk-IMQKXL4E.cjs +12 -0
  125. package/dist/{chunk-QSXTWU4U.cjs.map → chunk-IMQKXL4E.cjs.map} +1 -1
  126. package/dist/chunk-J6IJARLG.js +94 -0
  127. package/dist/chunk-J6IJARLG.js.map +1 -0
  128. package/dist/{chunk-W63OVYY4.js → chunk-K34OPSJK.js} +3 -3
  129. package/dist/{chunk-W63OVYY4.js.map → chunk-K34OPSJK.js.map} +1 -1
  130. package/dist/{chunk-TGOMW4MB.cjs → chunk-KCLZHYPU.cjs} +110 -109
  131. package/dist/chunk-KCLZHYPU.cjs.map +1 -0
  132. package/dist/{chunk-XGPUQ56G.js → chunk-KFLXWVUJ.js} +4 -38
  133. package/dist/chunk-KFLXWVUJ.js.map +1 -0
  134. package/dist/{chunk-3DS7Z4T4.cjs → chunk-LZ3TVJY4.cjs} +44 -43
  135. package/dist/chunk-LZ3TVJY4.cjs.map +1 -0
  136. package/dist/{chunk-UXLSNRYL.js → chunk-MTNEGGM2.js} +4 -4
  137. package/dist/chunk-MTNEGGM2.js.map +1 -0
  138. package/dist/{chunk-IP3CGGPA.cjs → chunk-N2V3HJFV.cjs} +92 -185
  139. package/dist/chunk-N2V3HJFV.cjs.map +1 -0
  140. package/dist/chunk-NAUA4PW5.cjs +28 -0
  141. package/dist/chunk-NAUA4PW5.cjs.map +1 -0
  142. package/dist/chunk-NMQ6C6TS.cjs +61 -0
  143. package/dist/chunk-NMQ6C6TS.cjs.map +1 -0
  144. package/dist/{chunk-2N6EOBTH.cjs → chunk-NPWACFQJ.cjs} +58 -53
  145. package/dist/chunk-NPWACFQJ.cjs.map +1 -0
  146. package/dist/{chunk-5KEQ74YU.cjs → chunk-NT6ILURI.cjs} +9 -86
  147. package/dist/chunk-NT6ILURI.cjs.map +1 -0
  148. package/dist/chunk-NU23DUSJ.cjs +192 -0
  149. package/dist/chunk-NU23DUSJ.cjs.map +1 -0
  150. package/dist/{chunk-WOJMKB3N.cjs → chunk-NWYCOFEZ.cjs} +1677 -308
  151. package/dist/chunk-NWYCOFEZ.cjs.map +1 -0
  152. package/dist/{chunk-3GH67G4Z.cjs → chunk-O5H62ZWJ.cjs} +4 -42
  153. package/dist/chunk-O5H62ZWJ.cjs.map +1 -0
  154. package/dist/{chunk-3SLPDKHQ.js → chunk-PH4IJ3V5.js} +5 -77
  155. package/dist/chunk-PH4IJ3V5.js.map +1 -0
  156. package/dist/chunk-PWXGB77L.cjs +56 -0
  157. package/dist/chunk-PWXGB77L.cjs.map +1 -0
  158. package/dist/chunk-PZHC5GCD.js +193 -0
  159. package/dist/chunk-PZHC5GCD.js.map +1 -0
  160. package/dist/chunk-QMQLUA66.js +12 -0
  161. package/dist/chunk-QMQLUA66.js.map +1 -0
  162. package/dist/{chunk-5WWVZMVX.js → chunk-QZ7A6HBM.js} +2 -2
  163. package/dist/{chunk-5WWVZMVX.js.map → chunk-QZ7A6HBM.js.map} +1 -1
  164. package/dist/{chunk-VKGKDOKR.js → chunk-RQPRCEIO.js} +1539 -206
  165. package/dist/chunk-RQPRCEIO.js.map +1 -0
  166. package/dist/chunk-RW24SAHI.cjs +74 -0
  167. package/dist/chunk-RW24SAHI.cjs.map +1 -0
  168. package/dist/{chunk-BVRDGYXQ.cjs → chunk-SAFZ6JTI.cjs} +14 -9
  169. package/dist/chunk-SAFZ6JTI.cjs.map +1 -0
  170. package/dist/{chunk-L7HQ2OSI.js → chunk-SCTZRFW5.js} +87 -166
  171. package/dist/chunk-SCTZRFW5.js.map +1 -0
  172. package/dist/{chunk-5KPNWT6X.js → chunk-SDHV2MWU.js} +24 -45
  173. package/dist/chunk-SDHV2MWU.js.map +1 -0
  174. package/dist/chunk-SVJ5GEXW.cjs +45 -0
  175. package/dist/chunk-SVJ5GEXW.cjs.map +1 -0
  176. package/dist/chunk-SVUKGWSN.cjs +102 -0
  177. package/dist/chunk-SVUKGWSN.cjs.map +1 -0
  178. package/dist/chunk-TAUGGLNQ.js +59 -0
  179. package/dist/chunk-TAUGGLNQ.js.map +1 -0
  180. package/dist/{chunk-J4IUSYFF.js → chunk-TE5ZA4VX.js} +69 -27
  181. package/dist/chunk-TE5ZA4VX.js.map +1 -0
  182. package/dist/{chunk-A42GCBGX.cjs → chunk-TRF4EBJT.cjs} +6 -4
  183. package/dist/chunk-TRF4EBJT.cjs.map +1 -0
  184. package/dist/{chunk-KQJ54OG5.js → chunk-U4JDJKPD.js} +19 -56
  185. package/dist/chunk-U4JDJKPD.js.map +1 -0
  186. package/dist/chunk-UH2USOMG.cjs +627 -0
  187. package/dist/chunk-UH2USOMG.cjs.map +1 -0
  188. package/dist/{chunk-RCVLFTCT.js → chunk-UPXDVI3T.js} +13 -12
  189. package/dist/chunk-UPXDVI3T.js.map +1 -0
  190. package/dist/{chunk-5VQM6VWP.cjs → chunk-UWG5GX6E.cjs} +2 -2
  191. package/dist/{chunk-5VQM6VWP.cjs.map → chunk-UWG5GX6E.cjs.map} +1 -1
  192. package/dist/{chunk-3RWZPJKV.js → chunk-VBH7ZXSZ.js} +21 -78
  193. package/dist/chunk-VBH7ZXSZ.js.map +1 -0
  194. package/dist/{chunk-K5UBVGJN.js → chunk-VDYA2HMS.js} +6 -6
  195. package/dist/{chunk-K5UBVGJN.js.map → chunk-VDYA2HMS.js.map} +1 -1
  196. package/dist/chunk-X4PVHAZ6.cjs +83 -0
  197. package/dist/chunk-X4PVHAZ6.cjs.map +1 -0
  198. package/dist/{chunk-UYQMBBWJ.js → chunk-X6CNEA32.js} +23 -20
  199. package/dist/chunk-X6CNEA32.js.map +1 -0
  200. package/dist/chunk-X6RDQ5NB.cjs +335 -0
  201. package/dist/chunk-X6RDQ5NB.cjs.map +1 -0
  202. package/dist/chunk-XD6X7O5R.js +184 -0
  203. package/dist/chunk-XD6X7O5R.js.map +1 -0
  204. package/dist/{chunk-DIQ3AV5W.cjs → chunk-XFY73JWD.cjs} +324 -224
  205. package/dist/chunk-XFY73JWD.cjs.map +1 -0
  206. package/dist/{chunk-DEFQM7JU.cjs → chunk-XRU7V7FF.cjs} +7 -7
  207. package/dist/{chunk-DEFQM7JU.cjs.map → chunk-XRU7V7FF.cjs.map} +1 -1
  208. package/dist/{chunk-TPF25IG6.js → chunk-XZA3Y4YH.js} +3 -3
  209. package/dist/{chunk-TPF25IG6.js.map → chunk-XZA3Y4YH.js.map} +1 -1
  210. package/dist/chunk-Y7M44XEK.js +462 -0
  211. package/dist/chunk-Y7M44XEK.js.map +1 -0
  212. package/dist/{chunk-RRSNR3TP.js → chunk-YIRLBUNN.js} +3 -3
  213. package/dist/{chunk-RRSNR3TP.js.map → chunk-YIRLBUNN.js.map} +1 -1
  214. package/dist/{chunk-IXGYRP2P.js → chunk-YJDSPA5E.js} +79 -49
  215. package/dist/chunk-YJDSPA5E.js.map +1 -0
  216. package/dist/{chunk-JBNOGRKW.cjs → chunk-YLINFV7Z.cjs} +157 -115
  217. package/dist/chunk-YLINFV7Z.cjs.map +1 -0
  218. package/dist/{chunk-QERAIDRJ.js → chunk-Z2PPIVOO.js} +82 -22
  219. package/dist/chunk-Z2PPIVOO.js.map +1 -0
  220. package/dist/chunk-Z5QHVL5U.cjs +12 -0
  221. package/dist/chunk-Z5QHVL5U.cjs.map +1 -0
  222. package/dist/chunk-ZDH3DX3C.cjs +30 -0
  223. package/dist/chunk-ZDH3DX3C.cjs.map +1 -0
  224. package/dist/chunk-ZE6NVENI.js +77 -0
  225. package/dist/chunk-ZE6NVENI.js.map +1 -0
  226. package/dist/chunk-ZHX4KEM7.cjs +49 -0
  227. package/dist/chunk-ZHX4KEM7.cjs.map +1 -0
  228. package/dist/chunk-ZKZAIX42.cjs +479 -0
  229. package/dist/chunk-ZKZAIX42.cjs.map +1 -0
  230. package/dist/{chunk-TEDRJXOG.cjs → chunk-ZY4GXIVN.cjs} +5 -5
  231. package/dist/{chunk-TEDRJXOG.cjs.map → chunk-ZY4GXIVN.cjs.map} +1 -1
  232. package/dist/core/index.cjs +117 -0
  233. package/dist/core/index.cjs.map +1 -0
  234. package/dist/core/index.d.cts +225 -0
  235. package/dist/core/index.d.ts +225 -0
  236. package/dist/core/index.js +12 -0
  237. package/dist/core/index.js.map +1 -0
  238. package/dist/{ddl-CS0KUVwB.d.ts → ddl-Dx3Z0_WC.d.ts} +3 -3
  239. package/dist/{ddl-BD-ZfKeX.d.cts → ddl-J6sDyABg.d.cts} +3 -3
  240. package/dist/define-graph-CzEvA_8F.d.cts +174 -0
  241. package/dist/define-graph-DRo9xpYN.d.ts +174 -0
  242. package/dist/{extension-types-BM2ACfYO.d.cts → extension-types-BLEVH4SG.d.cts} +1 -1
  243. package/dist/{extension-types-BM2ACfYO.d.ts → extension-types-BLEVH4SG.d.ts} +1 -1
  244. package/dist/graph-extension/index.cjs +21 -19
  245. package/dist/graph-extension/index.d.cts +4 -4
  246. package/dist/graph-extension/index.d.ts +4 -4
  247. package/dist/graph-extension/index.js +6 -4
  248. package/dist/graph-merge/index.cjs +265 -214
  249. package/dist/graph-merge/index.cjs.map +1 -1
  250. package/dist/graph-merge/index.d.cts +8 -89
  251. package/dist/graph-merge/index.d.ts +8 -89
  252. package/dist/graph-merge/index.js +141 -90
  253. package/dist/graph-merge/index.js.map +1 -1
  254. package/dist/{index-BeacbPoe.d.ts → index-BD_3TCgh.d.ts} +6 -4
  255. package/dist/{index-BPM59vsg.d.cts → index-BihFPsPu.d.cts} +6 -4
  256. package/dist/{fulltext-strategy-C27vXaeB.d.cts → index-Bq7vSPHy.d.ts} +3195 -2646
  257. package/dist/{fulltext-strategy-DebsMrqg.d.ts → index-CrFL_ENI.d.cts} +3195 -2646
  258. package/dist/index.cjs +326 -315
  259. package/dist/index.cjs.map +1 -1
  260. package/dist/index.d.cts +59 -240
  261. package/dist/index.d.ts +59 -240
  262. package/dist/index.js +46 -79
  263. package/dist/index.js.map +1 -1
  264. package/dist/indexes/index.cjs +26 -38
  265. package/dist/indexes/index.d.cts +6 -41
  266. package/dist/indexes/index.d.ts +6 -41
  267. package/dist/indexes/index.js +14 -10
  268. package/dist/interchange/index.cjs +48 -39
  269. package/dist/interchange/index.cjs.map +1 -1
  270. package/dist/interchange/index.d.cts +7 -8
  271. package/dist/interchange/index.d.ts +7 -8
  272. package/dist/interchange/index.js +23 -14
  273. package/dist/interchange/index.js.map +1 -1
  274. package/dist/local-options-CZ1BnIoF.d.cts +29 -0
  275. package/dist/local-options-CZ1BnIoF.d.ts +29 -0
  276. package/dist/{manager-D00_NXvT.d.ts → manager-CASfhmzV.d.ts} +4 -173
  277. package/dist/{manager-nU1vTJLy.d.cts → manager-nCEJiYBb.d.cts} +4 -173
  278. package/dist/{materialize-indexes-zK2J_flP.d.ts → materialize-indexes-D4iei4Kp.d.ts} +1 -1
  279. package/dist/{materialize-indexes-CuR3gAZb.d.cts → materialize-indexes-ExQ6OrAh.d.cts} +1 -1
  280. package/dist/{postgres-IaBA4RgE.d.ts → postgres-Cl1ZAN1G.d.ts} +1 -1
  281. package/dist/{postgres-YrYmPlaU.d.cts → postgres-DMgIKQU-.d.cts} +1 -1
  282. package/dist/postgres-execution-fKW0qRiN.d.cts +14 -0
  283. package/dist/postgres-execution-fKW0qRiN.d.ts +14 -0
  284. package/dist/profiler/index.cjs +9 -8
  285. package/dist/profiler/index.cjs.map +1 -1
  286. package/dist/profiler/index.d.cts +9 -17
  287. package/dist/profiler/index.d.ts +9 -17
  288. package/dist/profiler/index.js +8 -7
  289. package/dist/profiler/index.js.map +1 -1
  290. package/dist/provenance/index.cjs +61 -55
  291. package/dist/provenance/index.cjs.map +1 -1
  292. package/dist/provenance/index.d.cts +7 -8
  293. package/dist/provenance/index.d.ts +7 -8
  294. package/dist/provenance/index.js +34 -28
  295. package/dist/provenance/index.js.map +1 -1
  296. package/dist/schema/index.cjs +46 -37
  297. package/dist/schema/index.cjs.map +1 -1
  298. package/dist/schema/index.d.cts +8 -10
  299. package/dist/schema/index.d.ts +8 -10
  300. package/dist/schema/index.js +22 -13
  301. package/dist/schema/index.js.map +1 -1
  302. package/dist/{sqlite-BUOHPx7p.d.ts → sqlite-BDkW39aa.d.cts} +1 -1
  303. package/dist/{sqlite-Pp8O19WE.d.cts → sqlite-CYfhvESj.d.ts} +1 -1
  304. package/dist/sqlite-execution-DwbE2a9y.d.cts +32 -0
  305. package/dist/sqlite-execution-DwbE2a9y.d.ts +32 -0
  306. package/dist/{store-view-X96Rd00T.d.cts → store-view-BoHqdHjB.d.cts} +394 -1393
  307. package/dist/{store-view-ANL6mTph.d.ts → store-view-Ctq-3OHy.d.ts} +394 -1393
  308. package/dist/temporal-BC_NQV5Y.d.cts +281 -0
  309. package/dist/temporal-DqtOEo_B.d.ts +281 -0
  310. package/dist/{types-r-Zyq2Hz.d.cts → types-COq3-vMC.d.cts} +2 -2
  311. package/dist/{types-wsvuBgPK.d.ts → types-CUevi_D1.d.ts} +2 -2
  312. package/dist/{where-CJOpJj3a.d.ts → where-BdE_cYtx.d.ts} +5 -5
  313. package/dist/{where-K3uBP33l.d.cts → where-C92TXCzT.d.cts} +5 -5
  314. package/package.json +37 -6
  315. package/dist/chunk-27SSDCEP.cjs.map +0 -1
  316. package/dist/chunk-2N6EOBTH.cjs.map +0 -1
  317. package/dist/chunk-3C2RYI6L.cjs.map +0 -1
  318. package/dist/chunk-3DS7Z4T4.cjs.map +0 -1
  319. package/dist/chunk-3GH67G4Z.cjs.map +0 -1
  320. package/dist/chunk-3RWZPJKV.js.map +0 -1
  321. package/dist/chunk-3SLPDKHQ.js.map +0 -1
  322. package/dist/chunk-3XXGYU62.cjs.map +0 -1
  323. package/dist/chunk-44TA22QT.js +0 -1478
  324. package/dist/chunk-44TA22QT.js.map +0 -1
  325. package/dist/chunk-552KNYQJ.js.map +0 -1
  326. package/dist/chunk-5KEQ74YU.cjs.map +0 -1
  327. package/dist/chunk-5KPNWT6X.js.map +0 -1
  328. package/dist/chunk-5PNMDJ7J.js.map +0 -1
  329. package/dist/chunk-6EEO3OVU.cjs.map +0 -1
  330. package/dist/chunk-7YSP4V4R.cjs +0 -69
  331. package/dist/chunk-7YSP4V4R.cjs.map +0 -1
  332. package/dist/chunk-A42GCBGX.cjs.map +0 -1
  333. package/dist/chunk-BVRDGYXQ.cjs.map +0 -1
  334. package/dist/chunk-BYPOGQWK.js.map +0 -1
  335. package/dist/chunk-CUHM5CWJ.cjs +0 -12
  336. package/dist/chunk-CUHM5CWJ.cjs.map +0 -1
  337. package/dist/chunk-DIQ3AV5W.cjs.map +0 -1
  338. package/dist/chunk-EXU3RASM.js.map +0 -1
  339. package/dist/chunk-IP3CGGPA.cjs.map +0 -1
  340. package/dist/chunk-IPSVVTWT.cjs +0 -1540
  341. package/dist/chunk-IPSVVTWT.cjs.map +0 -1
  342. package/dist/chunk-IXGYRP2P.js.map +0 -1
  343. package/dist/chunk-J4IUSYFF.js.map +0 -1
  344. package/dist/chunk-JBNOGRKW.cjs.map +0 -1
  345. package/dist/chunk-K3Q3LJY3.js.map +0 -1
  346. package/dist/chunk-KQJ54OG5.js.map +0 -1
  347. package/dist/chunk-L7HQ2OSI.js.map +0 -1
  348. package/dist/chunk-M6VES7V6.js +0 -239
  349. package/dist/chunk-M6VES7V6.js.map +0 -1
  350. package/dist/chunk-NBP2WTJW.cjs.map +0 -1
  351. package/dist/chunk-NUIG3BCV.cjs.map +0 -1
  352. package/dist/chunk-NXQFATMF.cjs.map +0 -1
  353. package/dist/chunk-OHMP6N2J.js +0 -47
  354. package/dist/chunk-OHMP6N2J.js.map +0 -1
  355. package/dist/chunk-QERAIDRJ.js.map +0 -1
  356. package/dist/chunk-QSXTWU4U.cjs +0 -12
  357. package/dist/chunk-RCVLFTCT.js.map +0 -1
  358. package/dist/chunk-TGOMW4MB.cjs.map +0 -1
  359. package/dist/chunk-TKT2XHED.js.map +0 -1
  360. package/dist/chunk-UGZUAYAR.js.map +0 -1
  361. package/dist/chunk-UXLSNRYL.js.map +0 -1
  362. package/dist/chunk-UYQMBBWJ.js.map +0 -1
  363. package/dist/chunk-VKGKDOKR.js.map +0 -1
  364. package/dist/chunk-VL2V6PEN.cjs +0 -261
  365. package/dist/chunk-VL2V6PEN.cjs.map +0 -1
  366. package/dist/chunk-WOJMKB3N.cjs.map +0 -1
  367. package/dist/chunk-WWFHO375.cjs.map +0 -1
  368. package/dist/chunk-XGPUQ56G.js.map +0 -1
  369. package/dist/chunk-XGU7DZDA.cjs +0 -1095
  370. package/dist/chunk-XGU7DZDA.cjs.map +0 -1
  371. package/dist/chunk-XPCZADMT.cjs.map +0 -1
  372. package/dist/chunk-XWV4JT34.js.map +0 -1
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/meta-edge.ts","../src/core/external-ref.ts","../src/backend/migrate-vectors.ts"],"names":["embedding"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CO,SAAS,QAAA,CACd,IAAA,EACA,OAAA,GAA2B,EAAC,EACf;AACb,EAAA,MAAM,UAAA,GAAiC;AAAA,IACrC,UAAA,EAAY,QAAQ,UAAA,IAAc,KAAA;AAAA,IAClC,SAAA,EAAW,QAAQ,SAAA,IAAa,KAAA;AAAA,IAChC,SAAA,EAAW,QAAQ,SAAA,IAAa,KAAA;AAAA,IAChC,SAAS,OAAA,CAAQ,OAAA;AAAA,IACjB,SAAA,EAAW,QAAQ,SAAA,IAAa,MAAA;AAAA,IAChC,aAAa,OAAA,CAAQ;AAAA,GACvB;AAEA,EAAA,OAAO,OAAO,MAAA,CAAO;AAAA,IACnB,CAAC,eAAe,GAAG,IAAA;AAAA,IACnB,IAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH;AC/CO,IAAM,sBAAA,GAAyB,mBAAA;AA6E/B,SAAS,YAA8B,KAAA,EAAgC;AAC5E,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,CAAM,WAAW,CAAA,EAAG;AACnD,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,0DAAA,EAA6D,OAAO,KAAA,KAAU,QAAA,GAAW,IAAI,KAAK,CAAA,CAAA,CAAA,GAAM,OAAO,KAAK,CAAA;AAAA,KACtH;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AA,QAAA,EAC3C,GAAA,CAAI,QAAQ,CAAA,OAAA,EAAU,IAAI,OAAO,CAAA,kCAAA,EACzB,KAAK,CAAA,EAAA,EAAK,MAAA,CAAO,KAAK,CAAC,CAAA,CAAA;AAAA,OAC7C;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["import {\n type InferenceType,\n META_EDGE_BRAND,\n type MetaEdge,\n type MetaEdgeProperties,\n} from \"../ontology/types\";\n\n// ============================================================\n// Meta-Edge Factory Options\n// ============================================================\n\n/**\n * Options for creating a meta-edge.\n */\nexport type MetaEdgeOptions = Readonly<{\n /** Whether the relationship is transitive (A→B, B→C implies A→C) */\n transitive?: boolean;\n /** Whether the relationship is symmetric (A→B implies B→A) */\n symmetric?: boolean;\n /** Whether the relationship is reflexive (A→A is always true) */\n reflexive?: boolean;\n /** Name of the inverse meta-edge */\n inverse?: string;\n /** How this meta-edge affects queries and validation */\n inference?: InferenceType;\n /** Optional description */\n description?: string;\n}>;\n\n// ============================================================\n// Meta-Edge Factory\n// ============================================================\n\n/**\n * Creates a custom meta-edge definition.\n *\n * @example\n * ```typescript\n * // Custom meta-edge for regulatory relationships\n * const regulatedBy = metaEdge(\"regulatedBy\", {\n * description: \"Type X is regulated by authority type Y\",\n * transitive: false,\n * symmetric: false,\n * });\n * ```\n */\nexport function metaEdge<K extends string>(\n name: K,\n options: MetaEdgeOptions = {},\n): MetaEdge<K> {\n const properties: MetaEdgeProperties = {\n transitive: options.transitive ?? false,\n symmetric: options.symmetric ?? false,\n reflexive: options.reflexive ?? false,\n inverse: options.inverse,\n inference: options.inference ?? \"none\",\n description: options.description,\n };\n\n return Object.freeze({\n [META_EDGE_BRAND]: true as const,\n name,\n properties,\n });\n}\n","/**\n * External reference type for hybrid overlay patterns.\n *\n * Creates a Zod-compatible schema for referencing entities in external\n * data sources (e.g., existing application tables) from TypeGraph nodes.\n */\nimport { z } from \"zod\";\n\n// ============================================================\n// External Reference Metadata Symbol\n// ============================================================\n\n/**\n * Symbol key for storing external table name on the schema.\n * This allows the schema introspector to detect external reference types\n * and extract source information.\n */\nexport const EXTERNAL_REF_TABLE_KEY = \"_externalRefTable\" as const;\n\n// ============================================================\n// External Reference Value Type\n// ============================================================\n\n/**\n * The shape of an external reference value.\n * Contains the source table identifier and the ID of the referenced record.\n */\nexport type ExternalRefValue<T extends string = string> = Readonly<{\n table: T;\n id: string;\n}>;\n\n// ============================================================\n// External Reference Schema Type\n// ============================================================\n\n/**\n * A Zod schema for external references with attached table metadata.\n */\nexport type ExternalRefSchema<T extends string = string> = z.ZodType<\n ExternalRefValue<T>\n> &\n Readonly<{\n [EXTERNAL_REF_TABLE_KEY]: T;\n }>;\n\n// ============================================================\n// External Reference Factory\n// ============================================================\n\n/**\n * Creates a Zod schema for referencing external data sources.\n *\n * Use this when building a hybrid overlay where TypeGraph stores\n * graph relationships and metadata while your existing tables\n * remain the source of truth for entity data.\n *\n * @param table - The identifier for the external table/source (e.g., \"users\", \"documents\")\n * @returns A Zod schema that validates external reference objects\n *\n * @example\n * ```typescript\n * import { defineNode, externalRef, embedding } from \"@nicia-ai/typegraph\";\n *\n * // Reference documents from your existing application database\n * const Document = defineNode(\"Document\", {\n * schema: z.object({\n * source: externalRef(\"documents\"),\n * embedding: embedding(1536).optional(),\n * extractedTopics: z.array(z.string()).optional(),\n * }),\n * });\n *\n * // Create a node referencing an external document\n * await store.nodes.Document.create({\n * source: { table: \"documents\", id: \"doc_abc123\" },\n * embedding: await generateEmbedding(docContent),\n * });\n *\n * // Query and hydrate with external data\n * const results = await store\n * .query()\n * .from(\"Document\", \"d\")\n * .whereNode(\"d\", (d) => d.embedding.similarTo(query, 10))\n * .select((ctx) => ctx.d.source)\n * .execute();\n *\n * // Fetch full data from your app database\n * const externalIds = results.map((r) => r.id);\n * const fullDocs = await appDb.query.documents.findMany({\n * where: inArray(documents.id, externalIds),\n * });\n * ```\n */\nexport function externalRef<T extends string>(table: T): ExternalRefSchema<T> {\n if (typeof table !== \"string\" || table.length === 0) {\n throw new Error(\n `External reference table must be a non-empty string, got: ${typeof table === \"string\" ? `\"${table}\"` : typeof table}`,\n );\n }\n\n const schema = z.object({\n table: z.literal(table),\n id: z.string().min(1, \"External reference ID must be non-empty\"),\n });\n\n // Attach table metadata for introspection\n return Object.assign(schema, {\n [EXTERNAL_REF_TABLE_KEY]: table,\n });\n}\n\n// ============================================================\n// Type Guards\n// ============================================================\n\n/**\n * Checks if a value is an external reference schema.\n */\nexport function isExternalRefSchema(\n value: unknown,\n): value is ExternalRefSchema {\n return (\n typeof value === \"object\" &&\n value !== null &&\n EXTERNAL_REF_TABLE_KEY in value &&\n typeof (value as Record<string, unknown>)[EXTERNAL_REF_TABLE_KEY] ===\n \"string\"\n );\n}\n\n/**\n * Gets the table name from an external reference schema.\n * Returns undefined if the schema is not an external reference schema.\n */\nexport function getExternalRefTable(schema: z.ZodType): string | undefined {\n if (isExternalRefSchema(schema)) {\n return schema[EXTERNAL_REF_TABLE_KEY];\n }\n return undefined;\n}\n\n// ============================================================\n// Helper for creating reference values\n// ============================================================\n\n/**\n * Helper function to create a typed external reference value.\n * Useful when you want to avoid repeating the table name.\n *\n * @example\n * ```typescript\n * const docRef = createExternalRef(\"documents\");\n *\n * await store.nodes.Document.create({\n * source: docRef(\"doc_123\"),\n * embedding: [...],\n * });\n * ```\n */\nexport function createExternalRef<T extends string>(\n table: T,\n): (id: string) => ExternalRefValue<T> {\n return (id: string) => ({ table, id });\n}\n","/**\n * One-time offline migration: legacy shared embeddings table → per-field\n * strategy storage.\n *\n * ## What this is for\n *\n * The cross-backend vector cutover (#157) dropped the single shared\n * `typegraph_node_embeddings` table. Each\n * `VectorStrategy` now OWNS one typed, fixed-dimension structure per\n * `(nodeKind, fieldPath)` — the only layout that can be ANN-indexed on\n * libSQL and sqlite-vec, not just pgvector.\n *\n * Deployments that wrote embeddings under the old shared table before\n * upgrading still hold those rows. This utility drains them into the new\n * per-field storage **once**, during the upgrade, so existing embedded\n * data survives the cutover without re-embedding from source.\n *\n * It is an explicitly-run, offline step — not wired into `materializeIndexes`\n * or any boot path. Run it once after deploying the new version and before\n * (or alongside) the first `materializeIndexes()`, then drop the legacy\n * table at your leisure.\n *\n * ## How it works\n *\n * - Skips cleanly (returns a zero summary) when the legacy table is absent —\n * a fresh install, or a re-run after the table was dropped.\n * - Reads rows in keyset-paginated batches (never the whole table at once),\n * decoding the engine-native embedding column to a numeric array at the SQL\n * level: sqlite-vec stored a `vec_f32` blob (`vec_to_json` decodes it);\n * pgvector stored a native `vector` (`::text` yields a `[…]` literal).\n * - Re-inserts each row through `backend.upsertEmbedding`, which routes the\n * active strategy's `buildUpsert` and idempotently provisions the per-field\n * storage (the same `(nodeKind, fieldPath)` slot a fresh store write uses).\n * The migration stays graph-agnostic and execution-correct on both the\n * sync (better-sqlite3) and async (libsql / Postgres) backends — it does\n * not re-implement the backend's statement-execution glue.\n *\n * Idempotent and resumable: a partial run followed by a full run converges\n * to the same per-field tables, because every write is an upsert keyed by\n * `(graph_id, node_id)` in the strategy's owned storage.\n */\nimport { type SQL, sql } from \"drizzle-orm\";\n\nimport {\n DEFAULT_EMBEDDING_INDEX_TYPE,\n DEFAULT_EMBEDDING_METRIC,\n type EmbeddingIndexType,\n type EmbeddingMetric,\n} from \"../core/embedding\";\nimport { EmbeddingDimensionChangedError } from \"../errors\";\nimport { asCompiledRowsSql } from \"../query/sql-intent\";\nimport { isMissingTableError } from \"../utils/sql-errors\";\nimport { quotedTableName } from \"./drizzle/operations/shared\";\nimport { LEGACY_EMBEDDINGS_TABLE_NAME } from \"./drizzle/schema/sqlite\";\nimport { type GraphBackend } from \"./types\";\n\n/**\n * Default rows read per round-trip. Large enough to amortize round-trip\n * latency, small enough to bound peak memory regardless of table size.\n */\nconst DEFAULT_BATCH_SIZE = 500;\n\n/**\n * Metric / index type applied to a migrated field when no\n * {@link MigrateLegacyEmbeddingsOptions.resolveSlotConfig} is supplied (or\n * it returns `undefined`). Matches the defaults `embedding()` and\n * `resolveEmbeddingFields` apply, so a migrated field lands in storage shaped\n * identically to one written fresh through the store. Migrated data is only\n * ever brute-forceable until `materializeIndexes()` builds the ANN index, so\n * the index-type default governs only which ANN structure the per-field\n * storage DDL provisions, not the migration's correctness.\n */\nconst DEFAULT_SLOT_METRIC: EmbeddingMetric = DEFAULT_EMBEDDING_METRIC;\nconst DEFAULT_SLOT_INDEX_TYPE: EmbeddingIndexType =\n DEFAULT_EMBEDDING_INDEX_TYPE;\n\n/**\n * The resolved storage config for one `(nodeKind, fieldPath)` slot that the\n * legacy table did not record. The legacy shared table stored only the\n * vector and its dimension count — not the metric or index type — so a\n * caller that wants migrated fields to match a specific graph's `embedding()`\n * declarations supplies this resolver.\n */\nexport type LegacyEmbeddingSlotConfig = Readonly<{\n metric: EmbeddingMetric;\n indexType: EmbeddingIndexType;\n}>;\n\n/**\n * Options for {@link migrateLegacyEmbeddings}.\n */\nexport type MigrateLegacyEmbeddingsOptions = Readonly<{\n /**\n * The backend to migrate, wired with the destination `VectorStrategy`\n * (i.e. the post-cutover backend). Its `vectorStrategy` owns the per-field\n * storage rows are written into and its `upsertEmbedding` performs the\n * writes.\n */\n backend: GraphBackend;\n\n /**\n * Restrict the migration to a single graph. When omitted, every graph's\n * rows in the legacy table are migrated (the table is graph-scoped by its\n * `graph_id` column).\n */\n graphId?: string;\n\n /**\n * Resolves the metric / index type for a `(nodeKind, fieldPath)` slot the\n * legacy table didn't persist. Return `undefined` to fall back to the\n * cosine / hnsw defaults. Supply this (typically reading the graph's\n * `embedding()` declarations) when migrated fields must match a specific\n * metric — e.g. an `l2` field, which scores incorrectly under the cosine\n * default.\n */\n resolveSlotConfig?: (\n nodeKind: string,\n fieldPath: string,\n ) => LegacyEmbeddingSlotConfig | undefined;\n\n /** Rows read per round-trip. Defaults to {@link DEFAULT_BATCH_SIZE}. */\n batchSize?: number;\n\n /**\n * Physical name of the legacy table to drain. Defaults to\n * {@link LEGACY_EMBEDDINGS_TABLE_NAME}. Override only for a non-default\n * deployment that renamed the embeddings table.\n */\n legacyTableName?: string;\n}>;\n\n/**\n * Summary of a {@link migrateLegacyEmbeddings} run.\n */\nexport type MigrateLegacyEmbeddingsResult = Readonly<{\n /** Total embedding rows re-inserted into per-field storage. */\n migrated: number;\n /**\n * Per-`(nodeKind, fieldPath)` counts, keyed `\"<nodeKind>.<fieldPath>\"`\n * (the strategy's logical-slot key form). Empty when the legacy table was\n * absent or held no rows for the requested scope.\n */\n perField: Readonly<Record<string, number>>;\n /**\n * Rows skipped because their vector length didn't match the per-field\n * table's fixed dimension. The legacy shared column allowed mixed\n * dimensions for one `(nodeKind, fieldPath)` (e.g. an unmigrated model\n * change); the first migrated row fixes the typed table's dimension and\n * any differently-sized rows for that slot are skipped rather than aborting\n * the whole migration. Keyed `\"<nodeKind>.<fieldPath>\"`. Non-empty here\n * means those fields need a deliberate re-embed at a single dimension.\n */\n skippedDimensionMismatch: Readonly<Record<string, number>>;\n /**\n * Rows skipped because their legacy embedding could not be decoded into a\n * finite-number array — a corrupt value (e.g. a pgvector `vector` column\n * permits `NaN`/`Infinity`, which is not valid JSON). Keyed\n * `\"<nodeKind>.<fieldPath>\"`. Skipping + reporting keeps one bad row from\n * aborting the whole migration; non-empty here means those rows need manual\n * repair.\n */\n skippedDecodeError: Readonly<Record<string, number>>;\n /**\n * Whether the legacy table existed. `false` means the run was a clean\n * no-op (fresh install, or already-dropped table on a re-run).\n */\n legacyTablePresent: boolean;\n}>;\n\n/**\n * A single legacy embedding row, with the engine-native vector already\n * decoded to a JSON array string by the dialect-specific SELECT. The\n * legacy `dimensions` column is intentionally not read: the decoded array's\n * length is the authoritative fixed dimension for the destination slot, and\n * relying on it sidesteps the per-driver string/number coercion the legacy\n * integer column would otherwise need.\n */\ntype LegacyEmbeddingRow = Readonly<{\n graph_id: string;\n node_kind: string;\n node_id: string;\n field_path: string;\n /** JSON array text, e.g. `\"[0.1,0.2,0.3]\"` — decoded per dialect. */\n embedding_json: string;\n}>;\n\n/**\n * Re-inserts every embedding from the legacy shared\n * `typegraph_node_embeddings` table into the active\n * `backend.vectorStrategy`'s per-`(nodeKind, fieldPath)` storage.\n *\n * One-time, explicitly-run upgrade step for the shared-table → per-field\n * cutover (#157). Idempotent, batched, and a clean no-op when the legacy\n * table is absent. See the module doc comment for the full contract.\n *\n * @throws Error when the backend exposes no `vectorStrategy` /\n * `upsertEmbedding` (nothing to migrate *into*) — a configuration\n * error the caller must fix by wiring the destination strategy\n * before migrating.\n */\nexport async function migrateLegacyEmbeddings(\n options: MigrateLegacyEmbeddingsOptions,\n): Promise<MigrateLegacyEmbeddingsResult> {\n const {\n backend,\n graphId,\n resolveSlotConfig,\n batchSize = DEFAULT_BATCH_SIZE,\n legacyTableName = LEGACY_EMBEDDINGS_TABLE_NAME,\n } = options;\n\n if (\n backend.vectorStrategy === undefined ||\n backend.upsertEmbedding === undefined\n ) {\n throw new Error(\n \"migrateLegacyEmbeddings requires a backend wired with a vectorStrategy \" +\n \"(the destination per-field storage). Pass the post-cutover backend.\",\n );\n }\n if (!Number.isInteger(batchSize) || batchSize <= 0) {\n throw new RangeError(\n `batchSize must be a positive integer, got: ${batchSize}`,\n );\n }\n const upsertEmbedding = backend.upsertEmbedding;\n const ensureVectorSlotContribution = backend.ensureVectorSlotContribution;\n\n const perField: Record<string, number> = {};\n const skippedDimensionMismatch: Record<string, number> = {};\n const skippedDecodeError: Record<string, number> = {};\n // (kind, field) slots whose per-field table + durable marker this run has\n // already provisioned, mapped to the dimension the table was fixed at.\n // `upsertEmbedding` asserts the marker (#135) and no longer self-creates\n // the table, so this offline migration (privileged) provisions each slot\n // once — at the first row's dimension, which fixes the typed table just as\n // the original lazy write did. Differently-sized later rows for the same\n // slot are detected against this map and skipped BEFORE the upsert: the\n // marker assert would otherwise read the differently-dimensioned slot as\n // stale and abort the whole migration, and the ensure is deliberately not\n // re-run per row (that would trip the marker drift-guard).\n const ensuredSlots = new Map<string, number>();\n let migrated = 0;\n\n let cursor: LegacyRowCursor | undefined;\n for (;;) {\n let batch: readonly LegacyEmbeddingRow[];\n try {\n batch = await readLegacyBatch(backend, {\n legacyTableName,\n graphId,\n batchSize,\n after: cursor,\n });\n } catch (error) {\n // A missing legacy table is the expected \"nothing to migrate\" path on\n // the first read — surface it as a clean no-op, not a failure.\n if (cursor === undefined && isMissingTableError(error)) {\n return {\n migrated: 0,\n perField: {},\n skippedDimensionMismatch: {},\n skippedDecodeError: {},\n legacyTablePresent: false,\n };\n }\n throw error;\n }\n\n if (batch.length === 0) break;\n\n for (const row of batch) {\n const slotKey = `${row.node_kind}.${row.field_path}`;\n\n let embedding: readonly number[];\n try {\n embedding = decodeEmbeddingJson(row);\n } catch {\n // A corrupt legacy value (e.g. a pgvector `vector` column permits\n // NaN/Infinity, which is not valid JSON) is skipped + reported rather\n // than aborting the whole migration on one bad row.\n skippedDecodeError[slotKey] = (skippedDecodeError[slotKey] ?? 0) + 1;\n continue;\n }\n const config = resolveSlotConfig?.(row.node_kind, row.field_path);\n // The decoded length is the authoritative fixed dimension — the\n // strategy provisions its column type (e.g. `F32_BLOB(N)`) from it.\n const slot = {\n graphId: row.graph_id,\n nodeKind: row.node_kind,\n fieldPath: row.field_path,\n dimensions: embedding.length,\n metric: config?.metric ?? DEFAULT_SLOT_METRIC,\n indexType: config?.indexType ?? DEFAULT_SLOT_INDEX_TYPE,\n };\n\n // Provision the per-field table + durable marker before the first\n // write into this slot. Once per (graph, kind, field): the first row's\n // dimension fixes the table. Keyed by graph id too — the legacy table\n // is graph-scoped, so the same `kind.field` can recur across graphs.\n const ensuredKey = JSON.stringify([\n row.graph_id,\n row.node_kind,\n row.field_path,\n ]);\n if (\n ensureVectorSlotContribution !== undefined &&\n !ensuredSlots.has(ensuredKey)\n ) {\n await ensureVectorSlotContribution(slot);\n ensuredSlots.set(ensuredKey, slot.dimensions);\n }\n\n // The legacy shared column allowed mixed dimensions for one\n // (nodeKind, fieldPath); the per-field table is fixed at the first\n // migrated row's dimension. Skip a differently-sized row up front —\n // its slot would fail the marker assert as stale (different\n // signature), aborting the migration instead of skipping the row.\n const provisionedDimensions = ensuredSlots.get(ensuredKey);\n if (\n provisionedDimensions !== undefined &&\n provisionedDimensions !== embedding.length\n ) {\n skippedDimensionMismatch[slotKey] =\n (skippedDimensionMismatch[slotKey] ?? 0) + 1;\n continue;\n }\n\n try {\n await upsertEmbedding({ ...slot, nodeId: row.node_id, embedding });\n } catch (error) {\n // The legacy shared column allowed mixed dimensions for one\n // (nodeKind, fieldPath); the per-field table is fixed at the first\n // migrated row's dimension, so a differently-sized row is skipped and\n // reported rather than aborting the whole migration.\n if (error instanceof EmbeddingDimensionChangedError) {\n skippedDimensionMismatch[slotKey] =\n (skippedDimensionMismatch[slotKey] ?? 0) + 1;\n continue;\n }\n throw error;\n }\n\n migrated += 1;\n perField[slotKey] = (perField[slotKey] ?? 0) + 1;\n }\n\n if (batch.length < batchSize) break;\n const last = batch.at(-1)!;\n cursor = {\n graphId: last.graph_id,\n nodeKind: last.node_kind,\n nodeId: last.node_id,\n fieldPath: last.field_path,\n };\n }\n\n return {\n migrated,\n perField,\n skippedDimensionMismatch,\n skippedDecodeError,\n legacyTablePresent: true,\n };\n}\n\n/**\n * Composite keyset cursor over the legacy table's primary key\n * `(graph_id, node_kind, node_id, field_path)`. Stable under concurrent\n * writes and immune to OFFSET drift, so a batched walk reads every row once.\n */\ntype LegacyRowCursor = Readonly<{\n graphId: string;\n nodeKind: string;\n nodeId: string;\n fieldPath: string;\n}>;\n\ntype ReadLegacyBatchParams = Readonly<{\n legacyTableName: string;\n graphId: string | undefined;\n batchSize: number;\n after: LegacyRowCursor | undefined;\n}>;\n\n/**\n * Reads one keyset-paginated batch of legacy rows, ordered by the primary\n * key, with the engine-native embedding column decoded to a JSON array\n * string by the dialect.\n */\nasync function readLegacyBatch(\n backend: GraphBackend,\n params: ReadLegacyBatchParams,\n): Promise<readonly LegacyEmbeddingRow[]> {\n const table = quotedTableName(params.legacyTableName);\n const embeddingJson = legacyEmbeddingDecodeExpression(backend);\n\n const conditions: SQL[] = [];\n if (params.graphId !== undefined) {\n conditions.push(sql`\"graph_id\" = ${params.graphId}`);\n }\n if (params.after !== undefined) {\n conditions.push(keysetAfterCondition(params.after));\n }\n\n const whereClause =\n conditions.length === 0 ?\n sql``\n : sql` WHERE ${sql.join(conditions, sql` AND `)}`;\n\n const query = sql`\n SELECT\n \"graph_id\" AS graph_id,\n \"node_kind\" AS node_kind,\n \"node_id\" AS node_id,\n \"field_path\" AS field_path,\n ${embeddingJson} AS embedding_json\n FROM ${table}${whereClause}\n ORDER BY \"graph_id\" ASC, \"node_kind\" ASC, \"node_id\" ASC, \"field_path\" ASC\n LIMIT ${params.batchSize}\n `;\n\n return backend.execute<LegacyEmbeddingRow>(asCompiledRowsSql(query));\n}\n\n/**\n * The strict `>` comparison over the composite primary key, expressed as\n * the standard lexicographic OR-chain so it works on every dialect (SQLite\n * supports row-value comparison, but Postgres + SQLite both accept this\n * portable form).\n */\nfunction keysetAfterCondition(after: LegacyRowCursor): SQL {\n return sql`\n (\n \"graph_id\" > ${after.graphId}\n OR (\"graph_id\" = ${after.graphId} AND \"node_kind\" > ${after.nodeKind})\n OR (\"graph_id\" = ${after.graphId} AND \"node_kind\" = ${after.nodeKind} AND \"node_id\" > ${after.nodeId})\n OR (\n \"graph_id\" = ${after.graphId}\n AND \"node_kind\" = ${after.nodeKind}\n AND \"node_id\" = ${after.nodeId}\n AND \"field_path\" > ${after.fieldPath}\n )\n )\n `;\n}\n\n/**\n * The SQL expression that decodes the legacy engine-native embedding column\n * into a JSON array string `embedding_json`. The single dialect branch in\n * this whole module: the legacy storage formats are genuinely engine-\n * specific, and there is no longer a strategy abstraction over the *legacy*\n * table to delegate to.\n */\nfunction legacyEmbeddingDecodeExpression(backend: GraphBackend): SQL {\n switch (backend.dialect) {\n case \"sqlite\": {\n // Legacy SQLite embeddings were written via `vec_f32('[…]')`\n // (sqlite-vec binary). `vec_to_json` is its inverse, yielding the\n // JSON array text. Requires sqlite-vec on the connection — which the\n // legacy write path also required, so any deployment with legacy rows\n // has it loaded.\n return sql`vec_to_json(\"embedding\")`;\n }\n case \"postgres\": {\n // pgvector's native `vector` casts to its `[…]` text literal, which is\n // valid JSON for `JSON.parse`.\n return sql`\"embedding\"::text`;\n }\n default: {\n const _exhaustive: never = backend.dialect;\n throw new Error(\n `migrateLegacyEmbeddings does not support dialect: ${String(_exhaustive)}`,\n );\n }\n }\n}\n\n/**\n * Parses a decoded `embedding_json` array, asserting it is a non-empty array\n * of finite numbers. A bad decode (wrong type, NaN) names the offending row\n * loudly instead of writing a corrupt vector into per-field storage.\n */\nfunction decodeEmbeddingJson(row: LegacyEmbeddingRow): readonly number[] {\n let parsed: unknown;\n try {\n parsed = JSON.parse(row.embedding_json) as unknown;\n } catch (error) {\n throw new Error(\n `Failed to decode legacy embedding for ${row.node_kind}.${row.field_path} ` +\n `(graph ${row.graph_id}, node ${row.node_id}): not valid JSON.`,\n { cause: error },\n );\n }\n if (!Array.isArray(parsed) || parsed.length === 0) {\n throw new Error(\n `Legacy embedding for ${row.node_kind}.${row.field_path} ` +\n `(graph ${row.graph_id}, node ${row.node_id}) decoded to a non-array ` +\n `or empty value.`,\n );\n }\n for (const [index, value] of parsed.entries()) {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n throw new TypeError(\n `Legacy embedding for ${row.node_kind}.${row.field_path} ` +\n `(graph ${row.graph_id}, node ${row.node_id}) has a non-finite ` +\n `value at index ${index}: ${String(value)}.`,\n );\n }\n }\n return parsed as readonly number[];\n}\n"]}
1
+ {"version":3,"sources":["../src/backend/migrate-vectors.ts"],"names":["embedding"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,IAAM,kBAAA,GAAqB,GAAA;AAY3B,IAAM,mBAAA,GAAuC,wBAAA;AAC7C,IAAM,uBAAA,GACJ,4BAAA;AA8HF,eAAsB,wBACpB,OAAA,EACwC;AACxC,EAAA,MAAM;AAAA,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AAO,CAAA,wCAAA;AAAA,KAE/C;AAAA,EACF;AACA,EAAA,KAAA,MAAW,CAAC,KAAA,EAAO,KAAK,CAAA,IAAK,MAAA,CAAO,SAAQ,EAAG;AAC7C,IAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,CAAC,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,EAAG;AACxD,MAAA,MAAM,IAAI,SAAA;AAAA,QACR,wBAAwB,GAAA,CAAI,SAAS,CAAA,CAAA,EAAI,GAAA,CAAI,UAAU,CAAA,QAAA,EAC3C,GAAA,CAAI,QAAQ,CAAA,OAAA,EAAU,IAAI,OAAO,CAAA,kCAAA,EACzB,KAAK,CAAA,EAAA,EAAK,MAAA,CAAO,KAAK,CAAC,CAAA,CAAA;AAAA,OAC7C;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["/**\n * One-time offline migration: legacy shared embeddings table → per-field\n * strategy storage.\n *\n * ## What this is for\n *\n * The cross-backend vector cutover (#157) dropped the single shared\n * `typegraph_node_embeddings` table. Each\n * `VectorStrategy` now OWNS one typed, fixed-dimension structure per\n * `(nodeKind, fieldPath)` — the only layout that can be ANN-indexed on\n * libSQL and sqlite-vec, not just pgvector.\n *\n * Deployments that wrote embeddings under the old shared table before\n * upgrading still hold those rows. This utility drains them into the new\n * per-field storage **once**, during the upgrade, so existing embedded\n * data survives the cutover without re-embedding from source.\n *\n * It is an explicitly-run, offline step — not wired into `materializeIndexes`\n * or any boot path. Run it once after deploying the new version and before\n * (or alongside) the first `materializeIndexes()`, then drop the legacy\n * table at your leisure.\n *\n * ## How it works\n *\n * - Skips cleanly (returns a zero summary) when the legacy table is absent —\n * a fresh install, or a re-run after the table was dropped.\n * - Reads rows in keyset-paginated batches (never the whole table at once),\n * decoding the engine-native embedding column to a numeric array at the SQL\n * level: sqlite-vec stored a `vec_f32` blob (`vec_to_json` decodes it);\n * pgvector stored a native `vector` (`::text` yields a `[…]` literal).\n * - Re-inserts each row through `backend.upsertEmbedding`, which routes the\n * active strategy's `buildUpsert` and idempotently provisions the per-field\n * storage (the same `(nodeKind, fieldPath)` slot a fresh store write uses).\n * The migration stays graph-agnostic and execution-correct on both the\n * sync (better-sqlite3) and async (libsql / Postgres) backends — it does\n * not re-implement the backend's statement-execution glue.\n *\n * Idempotent and resumable: a partial run followed by a full run converges\n * to the same per-field tables, because every write is an upsert keyed by\n * `(graph_id, node_id)` in the strategy's owned storage.\n */\nimport {\n DEFAULT_EMBEDDING_INDEX_TYPE,\n DEFAULT_EMBEDDING_METRIC,\n type EmbeddingIndexType,\n type EmbeddingMetric,\n} from \"../core/embedding\";\nimport { EmbeddingDimensionChangedError } from \"../errors\";\nimport { sql, type SqlFragment } from \"../query/sql-fragment\";\nimport { asCompiledRowsSql } from \"../query/sql-intent\";\nimport { requireDefined } from \"../utils/presence\";\nimport { isMissingTableError } from \"../utils/sql-errors\";\nimport { LEGACY_EMBEDDINGS_TABLE_NAME } from \"./drizzle/schema/sqlite\";\nimport { type GraphBackend } from \"./types\";\n\n/**\n * Default rows read per round-trip. Large enough to amortize round-trip\n * latency, small enough to bound peak memory regardless of table size.\n */\nconst DEFAULT_BATCH_SIZE = 500;\n\n/**\n * Metric / index type applied to a migrated field when no\n * {@link MigrateLegacyEmbeddingsOptions.resolveSlotConfig} is supplied (or\n * it returns `undefined`). Matches the defaults `embedding()` and\n * `resolveEmbeddingFields` apply, so a migrated field lands in storage shaped\n * identically to one written fresh through the store. Migrated data is only\n * ever brute-forceable until `materializeIndexes()` builds the ANN index, so\n * the index-type default governs only which ANN structure the per-field\n * storage DDL provisions, not the migration's correctness.\n */\nconst DEFAULT_SLOT_METRIC: EmbeddingMetric = DEFAULT_EMBEDDING_METRIC;\nconst DEFAULT_SLOT_INDEX_TYPE: EmbeddingIndexType =\n DEFAULT_EMBEDDING_INDEX_TYPE;\n\n/**\n * The resolved storage config for one `(nodeKind, fieldPath)` slot that the\n * legacy table did not record. The legacy shared table stored only the\n * vector and its dimension count — not the metric or index type — so a\n * caller that wants migrated fields to match a specific graph's `embedding()`\n * declarations supplies this resolver.\n */\nexport type LegacyEmbeddingSlotConfig = Readonly<{\n metric: EmbeddingMetric;\n indexType: EmbeddingIndexType;\n}>;\n\n/**\n * Options for {@link migrateLegacyEmbeddings}.\n */\nexport type MigrateLegacyEmbeddingsOptions = Readonly<{\n /**\n * The backend to migrate, wired with the destination `VectorStrategy`\n * (i.e. the post-cutover backend). Its `vectorStrategy` owns the per-field\n * storage rows are written into and its `upsertEmbedding` performs the\n * writes.\n */\n backend: GraphBackend;\n\n /**\n * Restrict the migration to a single graph. When omitted, every graph's\n * rows in the legacy table are migrated (the table is graph-scoped by its\n * `graph_id` column).\n */\n graphId?: string;\n\n /**\n * Resolves the metric / index type for a `(nodeKind, fieldPath)` slot the\n * legacy table didn't persist. Return `undefined` to fall back to the\n * cosine / hnsw defaults. Supply this (typically reading the graph's\n * `embedding()` declarations) when migrated fields must match a specific\n * metric — e.g. an `l2` field, which scores incorrectly under the cosine\n * default.\n */\n resolveSlotConfig?: (\n nodeKind: string,\n fieldPath: string,\n ) => LegacyEmbeddingSlotConfig | undefined;\n\n /** Rows read per round-trip. Defaults to {@link DEFAULT_BATCH_SIZE}. */\n batchSize?: number;\n\n /**\n * Physical name of the legacy table to drain. Defaults to\n * {@link LEGACY_EMBEDDINGS_TABLE_NAME}. Override only for a non-default\n * deployment that renamed the embeddings table.\n */\n legacyTableName?: string;\n}>;\n\n/**\n * Summary of a {@link migrateLegacyEmbeddings} run.\n */\nexport type MigrateLegacyEmbeddingsResult = Readonly<{\n /** Total embedding rows re-inserted into per-field storage. */\n migrated: number;\n /**\n * Per-`(nodeKind, fieldPath)` counts, keyed `\"<nodeKind>.<fieldPath>\"`\n * (the strategy's logical-slot key form). Empty when the legacy table was\n * absent or held no rows for the requested scope.\n */\n perField: Readonly<Record<string, number>>;\n /**\n * Rows skipped because their vector length didn't match the per-field\n * table's fixed dimension. The legacy shared column allowed mixed\n * dimensions for one `(nodeKind, fieldPath)` (e.g. an unmigrated model\n * change); the first migrated row fixes the typed table's dimension and\n * any differently-sized rows for that slot are skipped rather than aborting\n * the whole migration. Keyed `\"<nodeKind>.<fieldPath>\"`. Non-empty here\n * means those fields need a deliberate re-embed at a single dimension.\n */\n skippedDimensionMismatch: Readonly<Record<string, number>>;\n /**\n * Rows skipped because their legacy embedding could not be decoded into a\n * finite-number array — a corrupt value (e.g. a pgvector `vector` column\n * permits `NaN`/`Infinity`, which is not valid JSON). Keyed\n * `\"<nodeKind>.<fieldPath>\"`. Skipping + reporting keeps one bad row from\n * aborting the whole migration; non-empty here means those rows need manual\n * repair.\n */\n skippedDecodeError: Readonly<Record<string, number>>;\n /**\n * Whether the legacy table existed. `false` means the run was a clean\n * no-op (fresh install, or already-dropped table on a re-run).\n */\n legacyTablePresent: boolean;\n}>;\n\n/**\n * A single legacy embedding row, with the engine-native vector already\n * decoded to a JSON array string by the dialect-specific SELECT. The\n * legacy `dimensions` column is intentionally not read: the decoded array's\n * length is the authoritative fixed dimension for the destination slot, and\n * relying on it sidesteps the per-driver string/number coercion the legacy\n * integer column would otherwise need.\n */\ntype LegacyEmbeddingRow = Readonly<{\n graph_id: string;\n node_kind: string;\n node_id: string;\n field_path: string;\n /** JSON array text, e.g. `\"[0.1,0.2,0.3]\"` — decoded per dialect. */\n embedding_json: string;\n}>;\n\n/**\n * Re-inserts every embedding from the legacy shared\n * `typegraph_node_embeddings` table into the active\n * `backend.vectorStrategy`'s per-`(nodeKind, fieldPath)` storage.\n *\n * One-time, explicitly-run upgrade step for the shared-table → per-field\n * cutover (#157). Idempotent, batched, and a clean no-op when the legacy\n * table is absent. See the module doc comment for the full contract.\n *\n * @throws Error when the backend exposes no `vectorStrategy` /\n * `upsertEmbedding` (nothing to migrate *into*) — a configuration\n * error the caller must fix by wiring the destination strategy\n * before migrating.\n */\nexport async function migrateLegacyEmbeddings(\n options: MigrateLegacyEmbeddingsOptions,\n): Promise<MigrateLegacyEmbeddingsResult> {\n const {\n backend,\n graphId,\n resolveSlotConfig,\n batchSize = DEFAULT_BATCH_SIZE,\n legacyTableName = LEGACY_EMBEDDINGS_TABLE_NAME,\n } = options;\n\n if (\n backend.vectorStrategy === undefined ||\n backend.upsertEmbedding === undefined\n ) {\n throw new Error(\n \"migrateLegacyEmbeddings requires a backend wired with a vectorStrategy \" +\n \"(the destination per-field storage). Pass the post-cutover backend.\",\n );\n }\n if (!Number.isInteger(batchSize) || batchSize <= 0) {\n throw new RangeError(\n `batchSize must be a positive integer, got: ${batchSize}`,\n );\n }\n const upsertEmbedding = backend.upsertEmbedding;\n const ensureVectorSlotContribution = backend.ensureVectorSlotContribution;\n\n const perField: Record<string, number> = {};\n const skippedDimensionMismatch: Record<string, number> = {};\n const skippedDecodeError: Record<string, number> = {};\n // (kind, field) slots whose per-field table + durable marker this run has\n // already provisioned, mapped to the dimension the table was fixed at.\n // `upsertEmbedding` asserts the marker (#135) and no longer self-creates\n // the table, so this offline migration (privileged) provisions each slot\n // once — at the first row's dimension, which fixes the typed table just as\n // the original lazy write did. Differently-sized later rows for the same\n // slot are detected against this map and skipped BEFORE the upsert: the\n // marker assert would otherwise read the differently-dimensioned slot as\n // stale and abort the whole migration, and the ensure is deliberately not\n // re-run per row (that would trip the marker drift-guard).\n const ensuredSlots = new Map<string, number>();\n let migrated = 0;\n\n let cursor: LegacyRowCursor | undefined;\n for (;;) {\n let batch: readonly LegacyEmbeddingRow[];\n try {\n batch = await readLegacyBatch(backend, {\n legacyTableName,\n graphId,\n batchSize,\n after: cursor,\n });\n } catch (error) {\n // A missing legacy table is the expected \"nothing to migrate\" path on\n // the first read — surface it as a clean no-op, not a failure.\n if (cursor === undefined && isMissingTableError(error)) {\n return {\n migrated: 0,\n perField: {},\n skippedDimensionMismatch: {},\n skippedDecodeError: {},\n legacyTablePresent: false,\n };\n }\n throw error;\n }\n\n if (batch.length === 0) break;\n\n for (const row of batch) {\n const slotKey = `${row.node_kind}.${row.field_path}`;\n\n let embedding: readonly number[];\n try {\n embedding = decodeEmbeddingJson(row);\n } catch {\n // A corrupt legacy value (e.g. a pgvector `vector` column permits\n // NaN/Infinity, which is not valid JSON) is skipped + reported rather\n // than aborting the whole migration on one bad row.\n skippedDecodeError[slotKey] = (skippedDecodeError[slotKey] ?? 0) + 1;\n continue;\n }\n const config = resolveSlotConfig?.(row.node_kind, row.field_path);\n // The decoded length is the authoritative fixed dimension — the\n // strategy provisions its column type (e.g. `F32_BLOB(N)`) from it.\n const slot = {\n graphId: row.graph_id,\n nodeKind: row.node_kind,\n fieldPath: row.field_path,\n dimensions: embedding.length,\n metric: config?.metric ?? DEFAULT_SLOT_METRIC,\n indexType: config?.indexType ?? DEFAULT_SLOT_INDEX_TYPE,\n };\n\n // Provision the per-field table + durable marker before the first\n // write into this slot. Once per (graph, kind, field): the first row's\n // dimension fixes the table. Keyed by graph id too — the legacy table\n // is graph-scoped, so the same `kind.field` can recur across graphs.\n const ensuredKey = JSON.stringify([\n row.graph_id,\n row.node_kind,\n row.field_path,\n ]);\n if (\n ensureVectorSlotContribution !== undefined &&\n !ensuredSlots.has(ensuredKey)\n ) {\n await ensureVectorSlotContribution(slot);\n ensuredSlots.set(ensuredKey, slot.dimensions);\n }\n\n // The legacy shared column allowed mixed dimensions for one\n // (nodeKind, fieldPath); the per-field table is fixed at the first\n // migrated row's dimension. Skip a differently-sized row up front —\n // its slot would fail the marker assert as stale (different\n // signature), aborting the migration instead of skipping the row.\n const provisionedDimensions = ensuredSlots.get(ensuredKey);\n if (\n provisionedDimensions !== undefined &&\n provisionedDimensions !== embedding.length\n ) {\n skippedDimensionMismatch[slotKey] =\n (skippedDimensionMismatch[slotKey] ?? 0) + 1;\n continue;\n }\n\n try {\n await upsertEmbedding({ ...slot, nodeId: row.node_id, embedding });\n } catch (error) {\n // The legacy shared column allowed mixed dimensions for one\n // (nodeKind, fieldPath); the per-field table is fixed at the first\n // migrated row's dimension, so a differently-sized row is skipped and\n // reported rather than aborting the whole migration.\n if (error instanceof EmbeddingDimensionChangedError) {\n skippedDimensionMismatch[slotKey] =\n (skippedDimensionMismatch[slotKey] ?? 0) + 1;\n continue;\n }\n throw error;\n }\n\n migrated += 1;\n perField[slotKey] = (perField[slotKey] ?? 0) + 1;\n }\n\n if (batch.length < batchSize) break;\n const last = requireDefined(batch.at(-1));\n cursor = {\n graphId: last.graph_id,\n nodeKind: last.node_kind,\n nodeId: last.node_id,\n fieldPath: last.field_path,\n };\n }\n\n return {\n migrated,\n perField,\n skippedDimensionMismatch,\n skippedDecodeError,\n legacyTablePresent: true,\n };\n}\n\n/**\n * Composite keyset cursor over the legacy table's primary key\n * `(graph_id, node_kind, node_id, field_path)`. Stable under concurrent\n * writes and immune to OFFSET drift, so a batched walk reads every row once.\n */\ntype LegacyRowCursor = Readonly<{\n graphId: string;\n nodeKind: string;\n nodeId: string;\n fieldPath: string;\n}>;\n\ntype ReadLegacyBatchParams = Readonly<{\n legacyTableName: string;\n graphId: string | undefined;\n batchSize: number;\n after: LegacyRowCursor | undefined;\n}>;\n\n/**\n * Reads one keyset-paginated batch of legacy rows, ordered by the primary\n * key, with the engine-native embedding column decoded to a JSON array\n * string by the dialect.\n */\nasync function readLegacyBatch(\n backend: GraphBackend,\n params: ReadLegacyBatchParams,\n): Promise<readonly LegacyEmbeddingRow[]> {\n const table = sql.identifier(params.legacyTableName);\n const embeddingJson = legacyEmbeddingDecodeExpression(backend);\n\n const conditions: SqlFragment[] = [];\n if (params.graphId !== undefined) {\n conditions.push(sql`\"graph_id\" = ${params.graphId}`);\n }\n if (params.after !== undefined) {\n conditions.push(keysetAfterCondition(params.after));\n }\n\n const whereClause =\n conditions.length === 0 ?\n sql``\n : sql` WHERE ${sql.join(conditions, sql` AND `)}`;\n\n const query = sql`\n SELECT\n \"graph_id\" AS graph_id,\n \"node_kind\" AS node_kind,\n \"node_id\" AS node_id,\n \"field_path\" AS field_path,\n ${embeddingJson} AS embedding_json\n FROM ${table}${whereClause}\n ORDER BY \"graph_id\" ASC, \"node_kind\" ASC, \"node_id\" ASC, \"field_path\" ASC\n LIMIT ${params.batchSize}\n `;\n\n return backend.execute<LegacyEmbeddingRow>(asCompiledRowsSql(query));\n}\n\n/**\n * The strict `>` comparison over the composite primary key, expressed as\n * the standard lexicographic OR-chain so it works on every dialect (SQLite\n * supports row-value comparison, but Postgres + SQLite both accept this\n * portable form).\n */\nfunction keysetAfterCondition(after: LegacyRowCursor): SqlFragment {\n return sql`\n (\n \"graph_id\" > ${after.graphId}\n OR (\"graph_id\" = ${after.graphId} AND \"node_kind\" > ${after.nodeKind})\n OR (\"graph_id\" = ${after.graphId} AND \"node_kind\" = ${after.nodeKind} AND \"node_id\" > ${after.nodeId})\n OR (\n \"graph_id\" = ${after.graphId}\n AND \"node_kind\" = ${after.nodeKind}\n AND \"node_id\" = ${after.nodeId}\n AND \"field_path\" > ${after.fieldPath}\n )\n )\n `;\n}\n\n/**\n * The SQL expression that decodes the legacy engine-native embedding column\n * into a JSON array string `embedding_json`. The single dialect branch in\n * this whole module: the legacy storage formats are genuinely engine-\n * specific, and there is no longer a strategy abstraction over the *legacy*\n * table to delegate to.\n */\nfunction legacyEmbeddingDecodeExpression(backend: GraphBackend): SqlFragment {\n switch (backend.dialect) {\n case \"sqlite\": {\n // Legacy SQLite embeddings were written via `vec_f32('[…]')`\n // (sqlite-vec binary). `vec_to_json` is its inverse, yielding the\n // JSON array text. Requires sqlite-vec on the connection — which the\n // legacy write path also required, so any deployment with legacy rows\n // has it loaded.\n return sql`vec_to_json(\"embedding\")`;\n }\n case \"postgres\": {\n // pgvector's native `vector` casts to its `[…]` text literal, which is\n // valid JSON for `JSON.parse`.\n return sql`\"embedding\"::text`;\n }\n default: {\n const _exhaustive: never = backend.dialect;\n throw new Error(\n `migrateLegacyEmbeddings does not support dialect: ${String(_exhaustive)}`,\n );\n }\n }\n}\n\n/**\n * Parses a decoded `embedding_json` array, asserting it is a non-empty array\n * of finite numbers. A bad decode (wrong type, NaN) names the offending row\n * loudly instead of writing a corrupt vector into per-field storage.\n */\nfunction decodeEmbeddingJson(row: LegacyEmbeddingRow): readonly number[] {\n let parsed: unknown;\n try {\n parsed = JSON.parse(row.embedding_json) as unknown;\n } catch (error) {\n throw new Error(\n `Failed to decode legacy embedding for ${row.node_kind}.${row.field_path} ` +\n `(graph ${row.graph_id}, node ${row.node_id}): not valid JSON.`,\n { cause: error },\n );\n }\n if (!Array.isArray(parsed) || parsed.length === 0) {\n throw new Error(\n `Legacy embedding for ${row.node_kind}.${row.field_path} ` +\n `(graph ${row.graph_id}, node ${row.node_id}) decoded to a non-array ` +\n `or empty value.`,\n );\n }\n for (const [index, value] of parsed.entries()) {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n throw new TypeError(\n `Legacy embedding for ${row.node_kind}.${row.field_path} ` +\n `(graph ${row.graph_id}, node ${row.node_id}) has a non-finite ` +\n `value at index ${index}: ${String(value)}.`,\n );\n }\n }\n return parsed as readonly number[];\n}\n"]}
@@ -1,83 +1,71 @@
1
1
  'use strict';
2
2
 
3
- var chunk5VQM6VWP_cjs = require('../chunk-5VQM6VWP.cjs');
4
- var chunkXPCZADMT_cjs = require('../chunk-XPCZADMT.cjs');
5
- var chunk6EEO3OVU_cjs = require('../chunk-6EEO3OVU.cjs');
6
- var chunkQARBLBXT_cjs = require('../chunk-QARBLBXT.cjs');
7
- var chunkVGDDG3XJ_cjs = require('../chunk-VGDDG3XJ.cjs');
8
- require('../chunk-TEDRJXOG.cjs');
9
- require('../chunk-XGU7DZDA.cjs');
10
- require('../chunk-WWFHO375.cjs');
11
- require('../chunk-7YSP4V4R.cjs');
12
- require('../chunk-HAHNRASW.cjs');
3
+ var chunkUWG5GX6E_cjs = require('../chunk-UWG5GX6E.cjs');
4
+ var chunkCWX77JB4_cjs = require('../chunk-CWX77JB4.cjs');
5
+ var chunkGUUWKPTK_cjs = require('../chunk-GUUWKPTK.cjs');
6
+ var chunk7M3NACL3_cjs = require('../chunk-7M3NACL3.cjs');
7
+ require('../chunk-ZY4GXIVN.cjs');
8
+ require('../chunk-NAUA4PW5.cjs');
9
+ require('../chunk-UH2USOMG.cjs');
10
+ require('../chunk-Z5QHVL5U.cjs');
11
+ require('../chunk-ZKZAIX42.cjs');
12
+ require('../chunk-X6RDQ5NB.cjs');
13
+ require('../chunk-FJMPR3OH.cjs');
13
14
  require('../chunk-SJDMVITW.cjs');
15
+ require('../chunk-764JHTLT.cjs');
16
+ require('../chunk-HAHNRASW.cjs');
17
+ require('../chunk-SAFZ6JTI.cjs');
14
18
  require('../chunk-TDXIBCGY.cjs');
15
19
 
16
20
 
17
21
 
18
22
  Object.defineProperty(exports, "andWhere", {
19
23
  enumerable: true,
20
- get: function () { return chunk5VQM6VWP_cjs.andWhere; }
24
+ get: function () { return chunkUWG5GX6E_cjs.andWhere; }
21
25
  });
22
26
  Object.defineProperty(exports, "notWhere", {
23
27
  enumerable: true,
24
- get: function () { return chunk5VQM6VWP_cjs.notWhere; }
28
+ get: function () { return chunkUWG5GX6E_cjs.notWhere; }
25
29
  });
26
30
  Object.defineProperty(exports, "orWhere", {
27
31
  enumerable: true,
28
- get: function () { return chunk5VQM6VWP_cjs.orWhere; }
32
+ get: function () { return chunkUWG5GX6E_cjs.orWhere; }
29
33
  });
30
34
  Object.defineProperty(exports, "toDeclaredIndex", {
31
35
  enumerable: true,
32
- get: function () { return chunk5VQM6VWP_cjs.toDeclaredIndex; }
36
+ get: function () { return chunkUWG5GX6E_cjs.toDeclaredIndex; }
33
37
  });
34
38
  Object.defineProperty(exports, "toDeclaredIndexes", {
35
39
  enumerable: true,
36
- get: function () { return chunk5VQM6VWP_cjs.toDeclaredIndexes; }
37
- });
38
- Object.defineProperty(exports, "buildPostgresEdgeIndexBuilders", {
39
- enumerable: true,
40
- get: function () { return chunkXPCZADMT_cjs.buildPostgresEdgeIndexBuilders; }
41
- });
42
- Object.defineProperty(exports, "buildPostgresNodeIndexBuilders", {
43
- enumerable: true,
44
- get: function () { return chunkXPCZADMT_cjs.buildPostgresNodeIndexBuilders; }
45
- });
46
- Object.defineProperty(exports, "buildSqliteEdgeIndexBuilders", {
47
- enumerable: true,
48
- get: function () { return chunkXPCZADMT_cjs.buildSqliteEdgeIndexBuilders; }
49
- });
50
- Object.defineProperty(exports, "buildSqliteNodeIndexBuilders", {
51
- enumerable: true,
52
- get: function () { return chunkXPCZADMT_cjs.buildSqliteNodeIndexBuilders; }
40
+ get: function () { return chunkUWG5GX6E_cjs.toDeclaredIndexes; }
53
41
  });
54
42
  Object.defineProperty(exports, "generateEdgeIndexDDL", {
55
43
  enumerable: true,
56
- get: function () { return chunk6EEO3OVU_cjs.generateEdgeIndexDDL; }
44
+ get: function () { return chunkCWX77JB4_cjs.generateEdgeIndexDDL; }
57
45
  });
58
46
  Object.defineProperty(exports, "generateIndexDDL", {
59
47
  enumerable: true,
60
- get: function () { return chunk6EEO3OVU_cjs.generateIndexDDL; }
48
+ get: function () { return chunkCWX77JB4_cjs.generateIndexDDL; }
61
49
  });
62
50
  Object.defineProperty(exports, "generateNodeIndexDDL", {
63
51
  enumerable: true,
64
- get: function () { return chunk6EEO3OVU_cjs.generateNodeIndexDDL; }
52
+ get: function () { return chunkCWX77JB4_cjs.generateNodeIndexDDL; }
65
53
  });
66
54
  Object.defineProperty(exports, "SYSTEM_INDEX_DECLARATIONS", {
67
55
  enumerable: true,
68
- get: function () { return chunkQARBLBXT_cjs.SYSTEM_INDEX_DECLARATIONS; }
56
+ get: function () { return chunkGUUWKPTK_cjs.SYSTEM_INDEX_DECLARATIONS; }
69
57
  });
70
58
  Object.defineProperty(exports, "generateSystemIndexDDL", {
71
59
  enumerable: true,
72
- get: function () { return chunkQARBLBXT_cjs.generateSystemIndexDDL; }
60
+ get: function () { return chunkGUUWKPTK_cjs.generateSystemIndexDDL; }
73
61
  });
74
62
  Object.defineProperty(exports, "defineEdgeIndex", {
75
63
  enumerable: true,
76
- get: function () { return chunkVGDDG3XJ_cjs.defineEdgeIndex; }
64
+ get: function () { return chunk7M3NACL3_cjs.defineEdgeIndex; }
77
65
  });
78
66
  Object.defineProperty(exports, "defineNodeIndex", {
79
67
  enumerable: true,
80
- get: function () { return chunkVGDDG3XJ_cjs.defineNodeIndex; }
68
+ get: function () { return chunk7M3NACL3_cjs.defineNodeIndex; }
81
69
  });
82
70
  //# sourceMappingURL=index.cjs.map
83
71
  //# sourceMappingURL=index.cjs.map
@@ -1,11 +1,8 @@
1
- import { E as EdgeIndexDeclaration, c as SqlDialect, R as RelationalIndexDeclaration, N as NodeIndexDeclaration, I as IndexDeclaration } from '../fulltext-strategy-C27vXaeB.cjs';
2
- export { d as EdgeIndexConfig, e as EdgeIndexDirection, f as EdgeIndexWhereBuilder, g as IndexOrigin, h as IndexScope, i as IndexWhereExpression, j as IndexWhereFieldBuilder, k as IndexWhereInput, l as NodeIndexConfig, m as NodeIndexWhereBuilder, n as SystemColumnName, o as VectorIndexDeclaration, p as VectorIndexImplementation, q as VectorIndexMetric, r as VectorIndexParams } from '../fulltext-strategy-C27vXaeB.cjs';
3
- export { S as SYSTEM_INDEX_DECLARATIONS, a as SystemIndexDeclaration, b as SystemIndexTable, c as andWhere, d as defineEdgeIndex, e as defineNodeIndex, g as generateSystemIndexDDL, n as notWhere, o as orWhere } from '../where-K3uBP33l.cjs';
4
- import { SQLWrapper } from 'drizzle-orm';
5
- import { IndexBuilder } from 'drizzle-orm/pg-core';
6
- import { IndexBuilder as IndexBuilder$1 } from 'drizzle-orm/sqlite-core';
7
- import { D as DeclaredIndex } from '../types-r-Zyq2Hz.cjs';
8
- import '../extension-types-BM2ACfYO.cjs';
1
+ import { E as EdgeIndexDeclaration, S as SqlDialect, R as RelationalIndexDeclaration, N as NodeIndexDeclaration, I as IndexDeclaration } from '../index-CrFL_ENI.cjs';
2
+ export { a as EdgeIndexConfig, b as EdgeIndexDirection, c as EdgeIndexWhereBuilder, d as IndexOrigin, e as IndexScope, f as IndexWhereExpression, g as IndexWhereFieldBuilder, h as IndexWhereInput, i as NodeIndexConfig, j as NodeIndexWhereBuilder, k as SystemColumnName, l as VectorIndexDeclaration, m as VectorIndexImplementation, n as VectorIndexMetric, o as VectorIndexParams } from '../index-CrFL_ENI.cjs';
3
+ export { S as SYSTEM_INDEX_DECLARATIONS, a as SystemIndexDeclaration, b as SystemIndexTable, c as andWhere, d as defineEdgeIndex, e as defineNodeIndex, g as generateSystemIndexDDL, n as notWhere, o as orWhere } from '../where-C92TXCzT.cjs';
4
+ import { D as DeclaredIndex } from '../types-COq3-vMC.cjs';
5
+ import '../extension-types-BLEVH4SG.cjs';
9
6
  import 'zod';
10
7
 
11
8
  type GenerateIndexDdlOptions = Readonly<{
@@ -35,38 +32,6 @@ declare function generateIndexDDL(index: RelationalIndexDeclaration, dialect: Sq
35
32
  declare function generateNodeIndexDDL(index: NodeIndexDeclaration, dialect: SqlDialect, options?: GenerateIndexDdlOptions): string;
36
33
  declare function generateEdgeIndexDDL(index: EdgeIndexDeclaration, dialect: SqlDialect, options?: GenerateIndexDdlOptions): string;
37
34
 
38
- declare function buildPostgresNodeIndexBuilders(table: NodeIndexTable, indexes: readonly IndexDeclaration[]): readonly IndexBuilder[];
39
- declare function buildPostgresEdgeIndexBuilders(table: EdgeIndexTable, indexes: readonly IndexDeclaration[]): readonly IndexBuilder[];
40
- declare function buildSqliteNodeIndexBuilders(table: NodeIndexTable, indexes: readonly IndexDeclaration[]): readonly IndexBuilder$1[];
41
- declare function buildSqliteEdgeIndexBuilders(table: EdgeIndexTable, indexes: readonly IndexDeclaration[]): readonly IndexBuilder$1[];
42
- type NodeIndexTable = Readonly<{
43
- graphId: SQLWrapper;
44
- kind: SQLWrapper;
45
- id: SQLWrapper;
46
- props: SQLWrapper;
47
- version: SQLWrapper;
48
- validFrom: SQLWrapper;
49
- validTo: SQLWrapper;
50
- createdAt: SQLWrapper;
51
- updatedAt: SQLWrapper;
52
- deletedAt: SQLWrapper;
53
- }>;
54
- type EdgeIndexTable = Readonly<{
55
- graphId: SQLWrapper;
56
- id: SQLWrapper;
57
- kind: SQLWrapper;
58
- fromKind: SQLWrapper;
59
- fromId: SQLWrapper;
60
- toKind: SQLWrapper;
61
- toId: SQLWrapper;
62
- props: SQLWrapper;
63
- validFrom: SQLWrapper;
64
- validTo: SQLWrapper;
65
- createdAt: SQLWrapper;
66
- updatedAt: SQLWrapper;
67
- deletedAt: SQLWrapper;
68
- }>;
69
-
70
35
  declare function toDeclaredIndex(index: RelationalIndexDeclaration): DeclaredIndex;
71
36
  /**
72
37
  * Vector indexes are excluded from the profiler-format conversion —
@@ -77,4 +42,4 @@ declare function toDeclaredIndex(index: RelationalIndexDeclaration): DeclaredInd
77
42
  */
78
43
  declare function toDeclaredIndexes(indexes: readonly IndexDeclaration[]): readonly DeclaredIndex[];
79
44
 
80
- export { EdgeIndexDeclaration, type GenerateIndexDdlOptions, IndexDeclaration, NodeIndexDeclaration, RelationalIndexDeclaration, buildPostgresEdgeIndexBuilders, buildPostgresNodeIndexBuilders, buildSqliteEdgeIndexBuilders, buildSqliteNodeIndexBuilders, generateEdgeIndexDDL, generateIndexDDL, generateNodeIndexDDL, toDeclaredIndex, toDeclaredIndexes };
45
+ export { EdgeIndexDeclaration, type GenerateIndexDdlOptions, IndexDeclaration, NodeIndexDeclaration, RelationalIndexDeclaration, generateEdgeIndexDDL, generateIndexDDL, generateNodeIndexDDL, toDeclaredIndex, toDeclaredIndexes };
@@ -1,11 +1,8 @@
1
- import { E as EdgeIndexDeclaration, c as SqlDialect, R as RelationalIndexDeclaration, N as NodeIndexDeclaration, I as IndexDeclaration } from '../fulltext-strategy-DebsMrqg.js';
2
- export { d as EdgeIndexConfig, e as EdgeIndexDirection, f as EdgeIndexWhereBuilder, g as IndexOrigin, h as IndexScope, i as IndexWhereExpression, j as IndexWhereFieldBuilder, k as IndexWhereInput, l as NodeIndexConfig, m as NodeIndexWhereBuilder, n as SystemColumnName, o as VectorIndexDeclaration, p as VectorIndexImplementation, q as VectorIndexMetric, r as VectorIndexParams } from '../fulltext-strategy-DebsMrqg.js';
3
- export { S as SYSTEM_INDEX_DECLARATIONS, a as SystemIndexDeclaration, b as SystemIndexTable, c as andWhere, d as defineEdgeIndex, e as defineNodeIndex, g as generateSystemIndexDDL, n as notWhere, o as orWhere } from '../where-CJOpJj3a.js';
4
- import { SQLWrapper } from 'drizzle-orm';
5
- import { IndexBuilder } from 'drizzle-orm/pg-core';
6
- import { IndexBuilder as IndexBuilder$1 } from 'drizzle-orm/sqlite-core';
7
- import { D as DeclaredIndex } from '../types-wsvuBgPK.js';
8
- import '../extension-types-BM2ACfYO.js';
1
+ import { E as EdgeIndexDeclaration, S as SqlDialect, R as RelationalIndexDeclaration, N as NodeIndexDeclaration, I as IndexDeclaration } from '../index-Bq7vSPHy.js';
2
+ export { a as EdgeIndexConfig, b as EdgeIndexDirection, c as EdgeIndexWhereBuilder, d as IndexOrigin, e as IndexScope, f as IndexWhereExpression, g as IndexWhereFieldBuilder, h as IndexWhereInput, i as NodeIndexConfig, j as NodeIndexWhereBuilder, k as SystemColumnName, l as VectorIndexDeclaration, m as VectorIndexImplementation, n as VectorIndexMetric, o as VectorIndexParams } from '../index-Bq7vSPHy.js';
3
+ export { S as SYSTEM_INDEX_DECLARATIONS, a as SystemIndexDeclaration, b as SystemIndexTable, c as andWhere, d as defineEdgeIndex, e as defineNodeIndex, g as generateSystemIndexDDL, n as notWhere, o as orWhere } from '../where-BdE_cYtx.js';
4
+ import { D as DeclaredIndex } from '../types-CUevi_D1.js';
5
+ import '../extension-types-BLEVH4SG.js';
9
6
  import 'zod';
10
7
 
11
8
  type GenerateIndexDdlOptions = Readonly<{
@@ -35,38 +32,6 @@ declare function generateIndexDDL(index: RelationalIndexDeclaration, dialect: Sq
35
32
  declare function generateNodeIndexDDL(index: NodeIndexDeclaration, dialect: SqlDialect, options?: GenerateIndexDdlOptions): string;
36
33
  declare function generateEdgeIndexDDL(index: EdgeIndexDeclaration, dialect: SqlDialect, options?: GenerateIndexDdlOptions): string;
37
34
 
38
- declare function buildPostgresNodeIndexBuilders(table: NodeIndexTable, indexes: readonly IndexDeclaration[]): readonly IndexBuilder[];
39
- declare function buildPostgresEdgeIndexBuilders(table: EdgeIndexTable, indexes: readonly IndexDeclaration[]): readonly IndexBuilder[];
40
- declare function buildSqliteNodeIndexBuilders(table: NodeIndexTable, indexes: readonly IndexDeclaration[]): readonly IndexBuilder$1[];
41
- declare function buildSqliteEdgeIndexBuilders(table: EdgeIndexTable, indexes: readonly IndexDeclaration[]): readonly IndexBuilder$1[];
42
- type NodeIndexTable = Readonly<{
43
- graphId: SQLWrapper;
44
- kind: SQLWrapper;
45
- id: SQLWrapper;
46
- props: SQLWrapper;
47
- version: SQLWrapper;
48
- validFrom: SQLWrapper;
49
- validTo: SQLWrapper;
50
- createdAt: SQLWrapper;
51
- updatedAt: SQLWrapper;
52
- deletedAt: SQLWrapper;
53
- }>;
54
- type EdgeIndexTable = Readonly<{
55
- graphId: SQLWrapper;
56
- id: SQLWrapper;
57
- kind: SQLWrapper;
58
- fromKind: SQLWrapper;
59
- fromId: SQLWrapper;
60
- toKind: SQLWrapper;
61
- toId: SQLWrapper;
62
- props: SQLWrapper;
63
- validFrom: SQLWrapper;
64
- validTo: SQLWrapper;
65
- createdAt: SQLWrapper;
66
- updatedAt: SQLWrapper;
67
- deletedAt: SQLWrapper;
68
- }>;
69
-
70
35
  declare function toDeclaredIndex(index: RelationalIndexDeclaration): DeclaredIndex;
71
36
  /**
72
37
  * Vector indexes are excluded from the profiler-format conversion —
@@ -77,4 +42,4 @@ declare function toDeclaredIndex(index: RelationalIndexDeclaration): DeclaredInd
77
42
  */
78
43
  declare function toDeclaredIndexes(indexes: readonly IndexDeclaration[]): readonly DeclaredIndex[];
79
44
 
80
- export { EdgeIndexDeclaration, type GenerateIndexDdlOptions, IndexDeclaration, NodeIndexDeclaration, RelationalIndexDeclaration, buildPostgresEdgeIndexBuilders, buildPostgresNodeIndexBuilders, buildSqliteEdgeIndexBuilders, buildSqliteNodeIndexBuilders, generateEdgeIndexDDL, generateIndexDDL, generateNodeIndexDDL, toDeclaredIndex, toDeclaredIndexes };
45
+ export { EdgeIndexDeclaration, type GenerateIndexDdlOptions, IndexDeclaration, NodeIndexDeclaration, RelationalIndexDeclaration, generateEdgeIndexDDL, generateIndexDDL, generateNodeIndexDDL, toDeclaredIndex, toDeclaredIndexes };
@@ -1,14 +1,18 @@
1
- export { andWhere, notWhere, orWhere, toDeclaredIndex, toDeclaredIndexes } from '../chunk-5WWVZMVX.js';
2
- export { buildPostgresEdgeIndexBuilders, buildPostgresNodeIndexBuilders, buildSqliteEdgeIndexBuilders, buildSqliteNodeIndexBuilders } from '../chunk-QERAIDRJ.js';
3
- export { generateEdgeIndexDDL, generateIndexDDL, generateNodeIndexDDL } from '../chunk-KQJ54OG5.js';
4
- export { SYSTEM_INDEX_DECLARATIONS, generateSystemIndexDDL } from '../chunk-YTSN73ND.js';
5
- export { defineEdgeIndex, defineNodeIndex } from '../chunk-K5UBVGJN.js';
6
- import '../chunk-W63OVYY4.js';
7
- import '../chunk-EXU3RASM.js';
8
- import '../chunk-UGZUAYAR.js';
9
- import '../chunk-OHMP6N2J.js';
10
- import '../chunk-PC2UBAUB.js';
1
+ export { andWhere, notWhere, orWhere, toDeclaredIndex, toDeclaredIndexes } from '../chunk-QZ7A6HBM.js';
2
+ export { generateEdgeIndexDDL, generateIndexDDL, generateNodeIndexDDL } from '../chunk-U4JDJKPD.js';
3
+ export { SYSTEM_INDEX_DECLARATIONS, generateSystemIndexDDL } from '../chunk-BQITNFQJ.js';
4
+ export { defineEdgeIndex, defineNodeIndex } from '../chunk-VDYA2HMS.js';
5
+ import '../chunk-K34OPSJK.js';
6
+ import '../chunk-2EBMPJBO.js';
7
+ import '../chunk-G3CSQLLT.js';
8
+ import '../chunk-DDCIXXOO.js';
9
+ import '../chunk-Y7M44XEK.js';
10
+ import '../chunk-6XDBRDZE.js';
11
+ import '../chunk-D7PG5D5K.js';
11
12
  import '../chunk-SNXVDZAJ.js';
13
+ import '../chunk-QMQLUA66.js';
14
+ import '../chunk-PC2UBAUB.js';
15
+ import '../chunk-DPNA466P.js';
12
16
  import '../chunk-G6Q5UM7U.js';
13
17
  //# sourceMappingURL=index.js.map
14
18
  //# sourceMappingURL=index.js.map
@@ -1,31 +1,39 @@
1
1
  'use strict';
2
2
 
3
- var chunk3DS7Z4T4_cjs = require('../chunk-3DS7Z4T4.cjs');
4
- require('../chunk-TGOMW4MB.cjs');
5
- require('../chunk-5KEQ74YU.cjs');
3
+ var chunkLZ3TVJY4_cjs = require('../chunk-LZ3TVJY4.cjs');
4
+ require('../chunk-KCLZHYPU.cjs');
5
+ var chunkNWYCOFEZ_cjs = require('../chunk-NWYCOFEZ.cjs');
6
+ require('../chunk-ZDH3DX3C.cjs');
7
+ require('../chunk-GNPGGLAE.cjs');
8
+ require('../chunk-SVUKGWSN.cjs');
9
+ require('../chunk-X4PVHAZ6.cjs');
6
10
  require('../chunk-ACSVZPK7.cjs');
7
- require('../chunk-XGU7DZDA.cjs');
8
- require('../chunk-DEFQM7JU.cjs');
9
- require('../chunk-WOJMKB3N.cjs');
10
- require('../chunk-IPSVVTWT.cjs');
11
- require('../chunk-3GH67G4Z.cjs');
12
- require('../chunk-7YSP4V4R.cjs');
13
- var chunkHAHNRASW_cjs = require('../chunk-HAHNRASW.cjs');
11
+ require('../chunk-O5H62ZWJ.cjs');
12
+ require('../chunk-NT6ILURI.cjs');
13
+ require('../chunk-DDCYVIVV.cjs');
14
+ require('../chunk-NAUA4PW5.cjs');
15
+ require('../chunk-UH2USOMG.cjs');
16
+ require('../chunk-Z5QHVL5U.cjs');
17
+ require('../chunk-ZKZAIX42.cjs');
18
+ require('../chunk-X6RDQ5NB.cjs');
14
19
  require('../chunk-SJDMVITW.cjs');
15
- var chunkBVRDGYXQ_cjs = require('../chunk-BVRDGYXQ.cjs');
20
+ require('../chunk-764JHTLT.cjs');
21
+ var chunkHAHNRASW_cjs = require('../chunk-HAHNRASW.cjs');
22
+ require('../chunk-XRU7V7FF.cjs');
23
+ var chunkSAFZ6JTI_cjs = require('../chunk-SAFZ6JTI.cjs');
16
24
  require('../chunk-TDXIBCGY.cjs');
17
25
 
18
26
  // src/interchange/trusted-import.ts
19
27
  function rejectUnsupportedStoreFeatures(store) {
20
28
  if (store.historyEnabled) {
21
- throw new chunkBVRDGYXQ_cjs.TrustedImportError(
29
+ throw new chunkSAFZ6JTI_cjs.TrustedImportError(
22
30
  "Trusted import does not support recorded-time history capture.",
23
31
  "history_unsupported",
24
32
  { graphId: store.graphId }
25
33
  );
26
34
  }
27
35
  if (store.revisionTrackingEnabled) {
28
- throw new chunkBVRDGYXQ_cjs.TrustedImportError(
36
+ throw new chunkSAFZ6JTI_cjs.TrustedImportError(
29
37
  "Trusted import does not support revision tracking.",
30
38
  "revision_tracking_unsupported",
31
39
  { graphId: store.graphId }
@@ -33,7 +41,7 @@ function rejectUnsupportedStoreFeatures(store) {
33
41
  }
34
42
  const uniqueKinds = Object.values(store.graph.nodes).filter((registration) => (registration.unique?.length ?? 0) > 0).map((registration) => registration.type.kind);
35
43
  if (uniqueKinds.length > 0) {
36
- throw new chunkBVRDGYXQ_cjs.TrustedImportError(
44
+ throw new chunkSAFZ6JTI_cjs.TrustedImportError(
37
45
  "Trusted import does not maintain node uniqueness sidecars.",
38
46
  "uniqueness_unsupported",
39
47
  { graphId: store.graphId, nodeKinds: uniqueKinds }
@@ -43,7 +51,7 @@ function rejectUnsupportedStoreFeatures(store) {
43
51
  (registration) => chunkHAHNRASW_cjs.getSearchableFields(registration.type.schema).length > 0
44
52
  ).map((registration) => registration.type.kind);
45
53
  if (searchableKinds.length > 0) {
46
- throw new chunkBVRDGYXQ_cjs.TrustedImportError(
54
+ throw new chunkSAFZ6JTI_cjs.TrustedImportError(
47
55
  "Trusted import does not maintain fulltext sidecars.",
48
56
  "fulltext_unsupported",
49
57
  { graphId: store.graphId, nodeKinds: searchableKinds }
@@ -51,7 +59,7 @@ function rejectUnsupportedStoreFeatures(store) {
51
59
  }
52
60
  const vectorSlots = chunkHAHNRASW_cjs.resolveGraphVectorSlots(store.graph);
53
61
  if (vectorSlots.length > 0) {
54
- throw new chunkBVRDGYXQ_cjs.TrustedImportError(
62
+ throw new chunkSAFZ6JTI_cjs.TrustedImportError(
55
63
  "Trusted import does not maintain vector sidecars.",
56
64
  "vector_unsupported",
57
65
  {
@@ -62,7 +70,7 @@ function rejectUnsupportedStoreFeatures(store) {
62
70
  }
63
71
  }
64
72
  function invalidStream(message) {
65
- return new chunkBVRDGYXQ_cjs.TrustedImportError(message, "invalid_stream");
73
+ return new chunkSAFZ6JTI_cjs.TrustedImportError(message, "invalid_stream");
66
74
  }
67
75
  function nodeParams(graphId, node) {
68
76
  return {
@@ -171,12 +179,13 @@ async function consumeTrustedChunks(store, session, chunks) {
171
179
  }
172
180
  async function trustedImportGraphStream(store, chunks) {
173
181
  rejectUnsupportedStoreFeatures(store);
174
- const trustedImport = store.backend.trustedImport;
182
+ const backend = chunkNWYCOFEZ_cjs.storeBackend(store);
183
+ const trustedImport = backend.trustedImport;
175
184
  if (trustedImport === void 0) {
176
- throw new chunkBVRDGYXQ_cjs.TrustedImportError(
177
- `The ${store.backend.dialect} backend does not support trusted import.`,
185
+ throw new chunkSAFZ6JTI_cjs.TrustedImportError(
186
+ `The ${backend.dialect} backend does not support trusted import.`,
178
187
  "backend_unsupported",
179
- { dialect: store.backend.dialect }
188
+ { dialect: backend.dialect }
180
189
  );
181
190
  }
182
191
  return trustedImport(
@@ -195,75 +204,75 @@ function trustedImportGraph(store, data) {
195
204
 
196
205
  Object.defineProperty(exports, "ConflictStrategySchema", {
197
206
  enumerable: true,
198
- get: function () { return chunk3DS7Z4T4_cjs.ConflictStrategySchema; }
207
+ get: function () { return chunkLZ3TVJY4_cjs.ConflictStrategySchema; }
199
208
  });
200
209
  Object.defineProperty(exports, "ExportOptionsSchema", {
201
210
  enumerable: true,
202
- get: function () { return chunk3DS7Z4T4_cjs.ExportOptionsSchema; }
211
+ get: function () { return chunkLZ3TVJY4_cjs.ExportOptionsSchema; }
203
212
  });
204
213
  Object.defineProperty(exports, "ExportStreamOptionsSchema", {
205
214
  enumerable: true,
206
- get: function () { return chunk3DS7Z4T4_cjs.ExportStreamOptionsSchema; }
215
+ get: function () { return chunkLZ3TVJY4_cjs.ExportStreamOptionsSchema; }
207
216
  });
208
217
  Object.defineProperty(exports, "FORMAT_VERSION", {
209
218
  enumerable: true,
210
- get: function () { return chunk3DS7Z4T4_cjs.FORMAT_VERSION; }
219
+ get: function () { return chunkLZ3TVJY4_cjs.FORMAT_VERSION; }
211
220
  });
212
221
  Object.defineProperty(exports, "GraphDataHeaderSchema", {
213
222
  enumerable: true,
214
- get: function () { return chunk3DS7Z4T4_cjs.GraphDataHeaderSchema; }
223
+ get: function () { return chunkLZ3TVJY4_cjs.GraphDataHeaderSchema; }
215
224
  });
216
225
  Object.defineProperty(exports, "GraphDataSchema", {
217
226
  enumerable: true,
218
- get: function () { return chunk3DS7Z4T4_cjs.GraphDataSchema; }
227
+ get: function () { return chunkLZ3TVJY4_cjs.GraphDataSchema; }
219
228
  });
220
229
  Object.defineProperty(exports, "GraphDataSourceSchema", {
221
230
  enumerable: true,
222
- get: function () { return chunk3DS7Z4T4_cjs.GraphDataSourceSchema; }
231
+ get: function () { return chunkLZ3TVJY4_cjs.GraphDataSourceSchema; }
223
232
  });
224
233
  Object.defineProperty(exports, "GraphInterchangeChunkSchema", {
225
234
  enumerable: true,
226
- get: function () { return chunk3DS7Z4T4_cjs.GraphInterchangeChunkSchema; }
235
+ get: function () { return chunkLZ3TVJY4_cjs.GraphInterchangeChunkSchema; }
227
236
  });
228
237
  Object.defineProperty(exports, "ImportErrorSchema", {
229
238
  enumerable: true,
230
- get: function () { return chunk3DS7Z4T4_cjs.ImportErrorSchema; }
239
+ get: function () { return chunkLZ3TVJY4_cjs.ImportErrorSchema; }
231
240
  });
232
241
  Object.defineProperty(exports, "ImportOptionsSchema", {
233
242
  enumerable: true,
234
- get: function () { return chunk3DS7Z4T4_cjs.ImportOptionsSchema; }
243
+ get: function () { return chunkLZ3TVJY4_cjs.ImportOptionsSchema; }
235
244
  });
236
245
  Object.defineProperty(exports, "ImportResultSchema", {
237
246
  enumerable: true,
238
- get: function () { return chunk3DS7Z4T4_cjs.ImportResultSchema; }
247
+ get: function () { return chunkLZ3TVJY4_cjs.ImportResultSchema; }
239
248
  });
240
249
  Object.defineProperty(exports, "InterchangeEdgeSchema", {
241
250
  enumerable: true,
242
- get: function () { return chunk3DS7Z4T4_cjs.InterchangeEdgeSchema; }
251
+ get: function () { return chunkLZ3TVJY4_cjs.InterchangeEdgeSchema; }
243
252
  });
244
253
  Object.defineProperty(exports, "InterchangeNodeSchema", {
245
254
  enumerable: true,
246
- get: function () { return chunk3DS7Z4T4_cjs.InterchangeNodeSchema; }
255
+ get: function () { return chunkLZ3TVJY4_cjs.InterchangeNodeSchema; }
247
256
  });
248
257
  Object.defineProperty(exports, "UnknownPropertyStrategySchema", {
249
258
  enumerable: true,
250
- get: function () { return chunk3DS7Z4T4_cjs.UnknownPropertyStrategySchema; }
259
+ get: function () { return chunkLZ3TVJY4_cjs.UnknownPropertyStrategySchema; }
251
260
  });
252
261
  Object.defineProperty(exports, "exportGraph", {
253
262
  enumerable: true,
254
- get: function () { return chunk3DS7Z4T4_cjs.exportGraph; }
263
+ get: function () { return chunkLZ3TVJY4_cjs.exportGraph; }
255
264
  });
256
265
  Object.defineProperty(exports, "exportGraphStream", {
257
266
  enumerable: true,
258
- get: function () { return chunk3DS7Z4T4_cjs.exportGraphStream; }
267
+ get: function () { return chunkLZ3TVJY4_cjs.exportGraphStream; }
259
268
  });
260
269
  Object.defineProperty(exports, "importGraph", {
261
270
  enumerable: true,
262
- get: function () { return chunk3DS7Z4T4_cjs.importGraph; }
271
+ get: function () { return chunkLZ3TVJY4_cjs.importGraph; }
263
272
  });
264
273
  Object.defineProperty(exports, "importGraphStream", {
265
274
  enumerable: true,
266
- get: function () { return chunk3DS7Z4T4_cjs.importGraphStream; }
275
+ get: function () { return chunkLZ3TVJY4_cjs.importGraphStream; }
267
276
  });
268
277
  exports.trustedImportGraph = trustedImportGraph;
269
278
  exports.trustedImportGraphStream = trustedImportGraphStream;