@nicia-ai/typegraph 0.49.0 → 0.50.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 (327) hide show
  1. package/dist/backend/drizzle/indexes.cjs +9 -9
  2. package/dist/backend/drizzle/indexes.d.cts +1 -1
  3. package/dist/backend/drizzle/indexes.d.ts +1 -1
  4. package/dist/backend/drizzle/indexes.js +5 -5
  5. package/dist/backend/index.cjs +56 -52
  6. package/dist/backend/index.d.cts +3 -3
  7. package/dist/backend/index.d.ts +3 -3
  8. package/dist/backend/index.js +11 -11
  9. package/dist/backend/postgres/index.cjs +34 -28
  10. package/dist/backend/postgres/index.d.cts +7 -7
  11. package/dist/backend/postgres/index.d.ts +7 -7
  12. package/dist/backend/postgres/index.js +17 -15
  13. package/dist/backend/postgres/pglite-store.cjs +36 -35
  14. package/dist/backend/postgres/pglite-store.cjs.map +1 -1
  15. package/dist/backend/postgres/pglite-store.d.cts +8 -8
  16. package/dist/backend/postgres/pglite-store.d.ts +8 -8
  17. package/dist/backend/postgres/pglite-store.js +32 -31
  18. package/dist/backend/postgres/pglite-store.js.map +1 -1
  19. package/dist/backend/postgres/pglite.cjs +19 -17
  20. package/dist/backend/postgres/pglite.d.cts +3 -3
  21. package/dist/backend/postgres/pglite.d.ts +3 -3
  22. package/dist/backend/postgres/pglite.js +18 -16
  23. package/dist/backend/sqlite/index.cjs +31 -25
  24. package/dist/backend/sqlite/index.d.cts +7 -7
  25. package/dist/backend/sqlite/index.d.ts +7 -7
  26. package/dist/backend/sqlite/index.js +15 -13
  27. package/dist/backend/sqlite/libsql.cjs +22 -20
  28. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  29. package/dist/backend/sqlite/libsql.d.cts +3 -3
  30. package/dist/backend/sqlite/libsql.d.ts +3 -3
  31. package/dist/backend/sqlite/libsql.js +17 -15
  32. package/dist/backend/sqlite/libsql.js.map +1 -1
  33. package/dist/backend/sqlite/local-store.cjs +37 -36
  34. package/dist/backend/sqlite/local-store.cjs.map +1 -1
  35. package/dist/backend/sqlite/local-store.d.cts +8 -8
  36. package/dist/backend/sqlite/local-store.d.ts +8 -8
  37. package/dist/backend/sqlite/local-store.js +33 -32
  38. package/dist/backend/sqlite/local-store.js.map +1 -1
  39. package/dist/backend/sqlite/local.cjs +20 -18
  40. package/dist/backend/sqlite/local.d.cts +3 -3
  41. package/dist/backend/sqlite/local.d.ts +3 -3
  42. package/dist/backend/sqlite/local.js +18 -16
  43. package/dist/{chunk-LTXQOEIC.js → chunk-2CYI5HRH.js} +248 -203
  44. package/dist/chunk-2CYI5HRH.js.map +1 -0
  45. package/dist/{chunk-KF6K7TGH.js → chunk-2GIV5X4P.js} +702 -422
  46. package/dist/chunk-2GIV5X4P.js.map +1 -0
  47. package/dist/{chunk-2TYSSBU5.js → chunk-2Q45FAIE.js} +15 -15
  48. package/dist/{chunk-2TYSSBU5.js.map → chunk-2Q45FAIE.js.map} +1 -1
  49. package/dist/{chunk-WODMN3Q2.cjs → chunk-45YZXI6X.cjs} +27 -27
  50. package/dist/{chunk-WODMN3Q2.cjs.map → chunk-45YZXI6X.cjs.map} +1 -1
  51. package/dist/{chunk-3DMMGT6S.js → chunk-46UGOVRW.js} +3 -3
  52. package/dist/{chunk-3DMMGT6S.js.map → chunk-46UGOVRW.js.map} +1 -1
  53. package/dist/{chunk-GLHXM7C4.js → chunk-5LKOVCPP.js} +60 -23
  54. package/dist/chunk-5LKOVCPP.js.map +1 -0
  55. package/dist/{chunk-JFRT7S3B.cjs → chunk-5OWHU7Z7.cjs} +261 -459
  56. package/dist/chunk-5OWHU7Z7.cjs.map +1 -0
  57. package/dist/{chunk-7SQSZN2J.js → chunk-5PP4KRPV.js} +5 -5
  58. package/dist/{chunk-7SQSZN2J.js.map → chunk-5PP4KRPV.js.map} +1 -1
  59. package/dist/chunk-6KQEICJ6.cjs +12 -0
  60. package/dist/{chunk-MKJ4KXL5.cjs.map → chunk-6KQEICJ6.cjs.map} +1 -1
  61. package/dist/{chunk-6SWPJEYN.js → chunk-6LEOAIIB.js} +40 -6
  62. package/dist/chunk-6LEOAIIB.js.map +1 -0
  63. package/dist/{chunk-DZAICA5J.js → chunk-6NKSE5AU.js} +4 -4
  64. package/dist/{chunk-DZAICA5J.js.map → chunk-6NKSE5AU.js.map} +1 -1
  65. package/dist/{chunk-OVI7IXYX.js → chunk-6S3PTHL4.js} +3 -3
  66. package/dist/{chunk-OVI7IXYX.js.map → chunk-6S3PTHL4.js.map} +1 -1
  67. package/dist/{chunk-3FPR224C.cjs → chunk-7CCMCMJO.cjs} +102 -102
  68. package/dist/{chunk-3FPR224C.cjs.map → chunk-7CCMCMJO.cjs.map} +1 -1
  69. package/dist/{chunk-SHFBB23Q.js → chunk-7OWE7WD6.js} +6 -4
  70. package/dist/chunk-7OWE7WD6.js.map +1 -0
  71. package/dist/chunk-7PRMDZIA.cjs +182 -0
  72. package/dist/chunk-7PRMDZIA.cjs.map +1 -0
  73. package/dist/{chunk-CHAOFCHV.js → chunk-AH2A74OZ.js} +3 -3
  74. package/dist/{chunk-CHAOFCHV.js.map → chunk-AH2A74OZ.js.map} +1 -1
  75. package/dist/{chunk-OORXGFL5.cjs → chunk-BYBDM423.cjs} +48 -48
  76. package/dist/{chunk-OORXGFL5.cjs.map → chunk-BYBDM423.cjs.map} +1 -1
  77. package/dist/{chunk-JB6T4GLL.cjs → chunk-C76WFIVZ.cjs} +808 -519
  78. package/dist/chunk-C76WFIVZ.cjs.map +1 -0
  79. package/dist/{chunk-3G5W2U2L.cjs → chunk-CS6JTQQ2.cjs} +302 -257
  80. package/dist/chunk-CS6JTQQ2.cjs.map +1 -0
  81. package/dist/{chunk-AOSSQDVO.cjs → chunk-CSNOYIB4.cjs} +13 -13
  82. package/dist/{chunk-AOSSQDVO.cjs.map → chunk-CSNOYIB4.cjs.map} +1 -1
  83. package/dist/{chunk-HEV35TGT.js → chunk-DI6VC62F.js} +13 -4
  84. package/dist/chunk-DI6VC62F.js.map +1 -0
  85. package/dist/{chunk-2QGYQBS2.cjs → chunk-DWUDZ66O.cjs} +10 -10
  86. package/dist/{chunk-2QGYQBS2.cjs.map → chunk-DWUDZ66O.cjs.map} +1 -1
  87. package/dist/{chunk-ZDKTPBGV.js → chunk-EDLKIQRI.js} +4 -4
  88. package/dist/{chunk-ZDKTPBGV.js.map → chunk-EDLKIQRI.js.map} +1 -1
  89. package/dist/chunk-EH3JZJUM.cjs +567 -0
  90. package/dist/chunk-EH3JZJUM.cjs.map +1 -0
  91. package/dist/{chunk-S5TERQVW.js → chunk-FX5ZW6PN.js} +196 -33
  92. package/dist/chunk-FX5ZW6PN.js.map +1 -0
  93. package/dist/{chunk-XVWOYKIK.js → chunk-FZHF5UWR.js} +3 -3
  94. package/dist/{chunk-XVWOYKIK.js.map → chunk-FZHF5UWR.js.map} +1 -1
  95. package/dist/{chunk-BFUOME67.cjs → chunk-G2TLHH6T.cjs} +20 -11
  96. package/dist/chunk-G2TLHH6T.cjs.map +1 -0
  97. package/dist/{chunk-5PRKMB24.cjs → chunk-GHZPZNFC.cjs} +12 -4
  98. package/dist/chunk-GHZPZNFC.cjs.map +1 -0
  99. package/dist/{chunk-ZFMCDJGB.js → chunk-GVYVGGPJ.js} +11 -199
  100. package/dist/chunk-GVYVGGPJ.js.map +1 -0
  101. package/dist/{chunk-SDBBMD4N.js → chunk-H3XP6BAV.js} +3 -3
  102. package/dist/{chunk-SDBBMD4N.js.map → chunk-H3XP6BAV.js.map} +1 -1
  103. package/dist/{chunk-ROR5ZR6A.cjs → chunk-HSEZ7X6Y.cjs} +45 -45
  104. package/dist/{chunk-ROR5ZR6A.cjs.map → chunk-HSEZ7X6Y.cjs.map} +1 -1
  105. package/dist/{chunk-LRQKXRXO.cjs → chunk-HY5BNOUN.cjs} +4 -4
  106. package/dist/{chunk-LRQKXRXO.cjs.map → chunk-HY5BNOUN.cjs.map} +1 -1
  107. package/dist/chunk-HZUB5CON.js +27 -0
  108. package/dist/chunk-HZUB5CON.js.map +1 -0
  109. package/dist/{chunk-MYKHJI2J.js → chunk-I5C6OTKR.js} +3 -3
  110. package/dist/{chunk-MYKHJI2J.js.map → chunk-I5C6OTKR.js.map} +1 -1
  111. package/dist/{chunk-3U5ABFDW.cjs → chunk-IHK5KA2Q.cjs} +31 -28
  112. package/dist/chunk-IHK5KA2Q.cjs.map +1 -0
  113. package/dist/{chunk-26YKDNUD.cjs → chunk-IPRP6TDL.cjs} +12 -10
  114. package/dist/chunk-IPRP6TDL.cjs.map +1 -0
  115. package/dist/{chunk-UGHG7PGX.js → chunk-IRPYOHRC.js} +26 -4
  116. package/dist/chunk-IRPYOHRC.js.map +1 -0
  117. package/dist/{chunk-7UOLHNWC.cjs → chunk-ISKCIQF2.cjs} +20 -20
  118. package/dist/{chunk-7UOLHNWC.cjs.map → chunk-ISKCIQF2.cjs.map} +1 -1
  119. package/dist/{chunk-7LZJNLA5.js → chunk-JG5XIJDY.js} +57 -31
  120. package/dist/chunk-JG5XIJDY.js.map +1 -0
  121. package/dist/{chunk-YYUHLYM2.cjs → chunk-K2XYLVVB.cjs} +134 -133
  122. package/dist/chunk-K2XYLVVB.cjs.map +1 -0
  123. package/dist/{chunk-5K2BKEBD.js → chunk-K46SDNQD.js} +10 -4
  124. package/dist/chunk-K46SDNQD.js.map +1 -0
  125. package/dist/{chunk-TZEGUG6D.cjs → chunk-K6VKTBST.cjs} +4 -4
  126. package/dist/{chunk-TZEGUG6D.cjs.map → chunk-K6VKTBST.cjs.map} +1 -1
  127. package/dist/chunk-KWNWG4RC.cjs +12 -0
  128. package/dist/{chunk-CICO5GXD.cjs.map → chunk-KWNWG4RC.cjs.map} +1 -1
  129. package/dist/{chunk-FQPEMEWX.cjs → chunk-LLVOQOWE.cjs} +80 -32
  130. package/dist/chunk-LLVOQOWE.cjs.map +1 -0
  131. package/dist/{chunk-TQHGE7UC.cjs → chunk-M5MSP3BI.cjs} +18 -10
  132. package/dist/chunk-M5MSP3BI.cjs.map +1 -0
  133. package/dist/{chunk-Z2JCLZFJ.js → chunk-MJPZNEJZ.js} +273 -291
  134. package/dist/chunk-MJPZNEJZ.js.map +1 -0
  135. package/dist/{chunk-TUNPBZY3.cjs → chunk-MM3JHVKZ.cjs} +4 -4
  136. package/dist/{chunk-TUNPBZY3.cjs.map → chunk-MM3JHVKZ.cjs.map} +1 -1
  137. package/dist/{chunk-BRRP76WO.js → chunk-MX7EKQPM.js} +457 -299
  138. package/dist/chunk-MX7EKQPM.js.map +1 -0
  139. package/dist/{chunk-D4QLTJSM.js → chunk-MZ34E2GN.js} +13 -12
  140. package/dist/chunk-MZ34E2GN.js.map +1 -0
  141. package/dist/{chunk-EDN4Y4ZG.cjs → chunk-OJHD3LXJ.cjs} +9 -9
  142. package/dist/{chunk-EDN4Y4ZG.cjs.map → chunk-OJHD3LXJ.cjs.map} +1 -1
  143. package/dist/{chunk-DO7SAMEK.cjs → chunk-ON47CBE4.cjs} +47 -47
  144. package/dist/{chunk-DO7SAMEK.cjs.map → chunk-ON47CBE4.cjs.map} +1 -1
  145. package/dist/{chunk-6LN7FIVU.js → chunk-PALYTHGM.js} +11 -4
  146. package/dist/chunk-PALYTHGM.js.map +1 -0
  147. package/dist/{chunk-YVF2EM7B.js → chunk-R7MRFE5P.js} +3 -3
  148. package/dist/{chunk-YVF2EM7B.js.map → chunk-R7MRFE5P.js.map} +1 -1
  149. package/dist/{chunk-EZEEWCFJ.cjs → chunk-RDP6ZRSM.cjs} +435 -265
  150. package/dist/chunk-RDP6ZRSM.cjs.map +1 -0
  151. package/dist/{chunk-GYEG3ZLZ.cjs → chunk-RJMHU2MG.cjs} +121 -18
  152. package/dist/chunk-RJMHU2MG.cjs.map +1 -0
  153. package/dist/chunk-RWUWTJQY.cjs +30 -0
  154. package/dist/chunk-RWUWTJQY.cjs.map +1 -0
  155. package/dist/{chunk-JPD2CTC3.js → chunk-S33YQEL7.js} +7 -7
  156. package/dist/{chunk-JPD2CTC3.js.map → chunk-S33YQEL7.js.map} +1 -1
  157. package/dist/chunk-S3SDEQMC.js +532 -0
  158. package/dist/chunk-S3SDEQMC.js.map +1 -0
  159. package/dist/{chunk-OI2GQ25X.cjs → chunk-SHC7BCG5.cjs} +7 -7
  160. package/dist/{chunk-OI2GQ25X.cjs.map → chunk-SHC7BCG5.cjs.map} +1 -1
  161. package/dist/{chunk-L3LQNR34.cjs → chunk-TEC24ZDA.cjs} +161 -161
  162. package/dist/{chunk-L3LQNR34.cjs.map → chunk-TEC24ZDA.cjs.map} +1 -1
  163. package/dist/{chunk-HDL2ARHX.cjs → chunk-TP4NJTI3.cjs} +63 -27
  164. package/dist/chunk-TP4NJTI3.cjs.map +1 -0
  165. package/dist/{chunk-UMGZDVOA.cjs → chunk-TTCOPKUL.cjs} +124 -124
  166. package/dist/{chunk-UMGZDVOA.cjs.map → chunk-TTCOPKUL.cjs.map} +1 -1
  167. package/dist/chunk-TUVD4DFR.cjs +1207 -0
  168. package/dist/chunk-TUVD4DFR.cjs.map +1 -0
  169. package/dist/{chunk-UGHQV7MP.cjs → chunk-TYGGUWMS.cjs} +178 -152
  170. package/dist/chunk-TYGGUWMS.cjs.map +1 -0
  171. package/dist/{chunk-WIC7DRXW.js → chunk-U3Z7XKAG.js} +7 -7
  172. package/dist/{chunk-WIC7DRXW.js.map → chunk-U3Z7XKAG.js.map} +1 -1
  173. package/dist/{chunk-NACVVDWB.js → chunk-U5EL6JUV.js} +10 -10
  174. package/dist/{chunk-NACVVDWB.js.map → chunk-U5EL6JUV.js.map} +1 -1
  175. package/dist/{chunk-OMZ37BM2.js → chunk-V76FGHY3.js} +5 -5
  176. package/dist/{chunk-OMZ37BM2.js.map → chunk-V76FGHY3.js.map} +1 -1
  177. package/dist/{chunk-6NGW27EO.cjs → chunk-VLBTRXA2.cjs} +10 -10
  178. package/dist/{chunk-6NGW27EO.cjs.map → chunk-VLBTRXA2.cjs.map} +1 -1
  179. package/dist/chunk-VTJVMP4I.js +1182 -0
  180. package/dist/chunk-VTJVMP4I.js.map +1 -0
  181. package/dist/{chunk-QTD6HX4O.js → chunk-W5SOCUBL.js} +5 -5
  182. package/dist/{chunk-QTD6HX4O.js.map → chunk-W5SOCUBL.js.map} +1 -1
  183. package/dist/{chunk-SR725PWF.cjs → chunk-WCLMKNQE.cjs} +1750 -1592
  184. package/dist/chunk-WCLMKNQE.cjs.map +1 -0
  185. package/dist/{chunk-2O4PCIZ6.cjs → chunk-WK23PGTP.cjs} +13 -13
  186. package/dist/{chunk-2O4PCIZ6.cjs.map → chunk-WK23PGTP.cjs.map} +1 -1
  187. package/dist/{chunk-KKBDXCLQ.js → chunk-WQBAQZHR.js} +4 -4
  188. package/dist/{chunk-KKBDXCLQ.js.map → chunk-WQBAQZHR.js.map} +1 -1
  189. package/dist/{chunk-MRDBBHIZ.cjs → chunk-X4GDXBOP.cjs} +2 -2
  190. package/dist/chunk-X4GDXBOP.cjs.map +1 -0
  191. package/dist/{chunk-3QNZ5SAJ.cjs → chunk-XMY2SXOH.cjs} +437 -455
  192. package/dist/chunk-XMY2SXOH.cjs.map +1 -0
  193. package/dist/{chunk-D5R42W5D.js → chunk-XZW2CTNO.js} +115 -12
  194. package/dist/chunk-XZW2CTNO.js.map +1 -0
  195. package/dist/{chunk-NVY5CJFP.js → chunk-Y55DLLEG.js} +9 -6
  196. package/dist/chunk-Y55DLLEG.js.map +1 -0
  197. package/dist/chunk-YA36ABIL.js +174 -0
  198. package/dist/chunk-YA36ABIL.js.map +1 -0
  199. package/dist/{chunk-ZLONH2UD.js → chunk-YDEJQWOL.js} +2 -2
  200. package/dist/chunk-YDEJQWOL.js.map +1 -0
  201. package/dist/{chunk-JONXFAPO.js → chunk-ZAQUKCUC.js} +5 -5
  202. package/dist/{chunk-JONXFAPO.js.map → chunk-ZAQUKCUC.js.map} +1 -1
  203. package/dist/{chunk-SIT26LAZ.cjs → chunk-ZBFZGLZE.cjs} +29 -5
  204. package/dist/chunk-ZBFZGLZE.cjs.map +1 -0
  205. package/dist/{chunk-P6YLZTRE.js → chunk-ZRJTM7MT.js} +3 -3
  206. package/dist/{chunk-P6YLZTRE.js.map → chunk-ZRJTM7MT.js.map} +1 -1
  207. package/dist/core/index.cjs +29 -28
  208. package/dist/core/index.d.cts +4 -4
  209. package/dist/core/index.d.ts +4 -4
  210. package/dist/core/index.js +9 -8
  211. package/dist/{ddl-D_oW-EVO.d.ts → ddl-B49O7dB_.d.ts} +3 -3
  212. package/dist/{ddl-BL1NZLMY.d.cts → ddl-DcZG660s.d.cts} +3 -3
  213. package/dist/graph-extension/index.cjs +21 -20
  214. package/dist/graph-extension/index.d.cts +4 -4
  215. package/dist/graph-extension/index.d.ts +4 -4
  216. package/dist/graph-extension/index.js +5 -4
  217. package/dist/graph-merge/index.cjs +305 -303
  218. package/dist/graph-merge/index.cjs.map +1 -1
  219. package/dist/graph-merge/index.d.cts +9 -9
  220. package/dist/graph-merge/index.d.ts +9 -9
  221. package/dist/graph-merge/index.js +29 -27
  222. package/dist/graph-merge/index.js.map +1 -1
  223. package/dist/{index-D7d1u2gr.d.ts → index-B0PrmE3K.d.cts} +16 -2
  224. package/dist/{index-COs_z6nV.d.cts → index-CwcXsL5R.d.ts} +16 -2
  225. package/dist/index.cjs +223 -222
  226. package/dist/index.cjs.map +1 -1
  227. package/dist/index.d.cts +12 -12
  228. package/dist/index.d.ts +12 -12
  229. package/dist/index.js +37 -36
  230. package/dist/index.js.map +1 -1
  231. package/dist/indexes/index.cjs +13 -13
  232. package/dist/indexes/index.d.cts +4 -4
  233. package/dist/indexes/index.d.ts +4 -4
  234. package/dist/indexes/index.js +6 -6
  235. package/dist/{ingestion-import-target-dNeL7iAv.d.ts → ingestion-import-target-CI8OWIkM.d.ts} +1 -1
  236. package/dist/{ingestion-import-target-XPxZYw89.d.cts → ingestion-import-target-DCpfM1PX.d.cts} +1 -1
  237. package/dist/interchange/index.cjs +55 -54
  238. package/dist/interchange/index.cjs.map +1 -1
  239. package/dist/interchange/index.d.cts +19 -8
  240. package/dist/interchange/index.d.ts +19 -8
  241. package/dist/interchange/index.js +19 -18
  242. package/dist/interchange/index.js.map +1 -1
  243. package/dist/{manager-D9eRT_ns.d.ts → manager-Cfg1ENj1.d.ts} +30 -2
  244. package/dist/{manager-CYaff3n3.d.cts → manager-D348fa6W.d.cts} +30 -2
  245. package/dist/{materialize-indexes-DJ3ykH59.d.ts → materialize-indexes-C9GG3O3C.d.ts} +1 -1
  246. package/dist/{materialize-indexes-DTtAnvfY.d.cts → materialize-indexes-CrSiW_lT.d.cts} +1 -1
  247. package/dist/{postgres-CcL4bAHS.d.ts → postgres-CH1kkM5J.d.cts} +279 -2
  248. package/dist/{postgres-DMj39MEu.d.cts → postgres-UStOycLI.d.ts} +279 -2
  249. package/dist/profiler/index.d.cts +9 -9
  250. package/dist/profiler/index.d.ts +9 -9
  251. package/dist/provenance/index.cjs +46 -44
  252. package/dist/provenance/index.cjs.map +1 -1
  253. package/dist/provenance/index.d.cts +7 -7
  254. package/dist/provenance/index.d.ts +7 -7
  255. package/dist/provenance/index.js +12 -10
  256. package/dist/provenance/index.js.map +1 -1
  257. package/dist/{repair-validity-windows-DlUSqwCg.d.ts → repair-validity-windows-BtOEe2pS.d.ts} +2 -2
  258. package/dist/{repair-validity-windows-BFNZvd_H.d.cts → repair-validity-windows-aWX7VNvv.d.cts} +2 -2
  259. package/dist/schema/index.cjs +46 -46
  260. package/dist/schema/index.d.cts +6 -6
  261. package/dist/schema/index.d.ts +6 -6
  262. package/dist/schema/index.js +19 -19
  263. package/dist/{searchable-DHJMh_nj.d.cts → searchable-C8-RrL3l.d.cts} +1 -1
  264. package/dist/{searchable-bpE1bBfc.d.ts → searchable-z4BiFfHI.d.ts} +1 -1
  265. package/dist/{sqlite-YppHrNFb.d.cts → sqlite-Cyx9j9o6.d.cts} +309 -2
  266. package/dist/{sqlite-D7Oz0SQh.d.ts → sqlite-axLw5Lo5.d.ts} +309 -2
  267. package/dist/{store-bphCSo7z.d.cts → store-CTfQ9taw.d.ts} +102 -13
  268. package/dist/{store-DRrFCx5x.d.ts → store-DR9J7JVB.d.cts} +102 -13
  269. package/dist/{temporal-5GqpYCk2.d.cts → temporal-B4Ky4wzh.d.cts} +1 -1
  270. package/dist/{temporal-CbnLzTmM.d.ts → temporal-CBOrERz5.d.ts} +1 -1
  271. package/dist/{types-CXAhpW-c.d.cts → types-BE921wRl.d.cts} +1 -1
  272. package/dist/{types-Bx74kaTt.d.ts → types-BScHXVM7.d.ts} +1 -1
  273. package/dist/{types-BqFZTQmV.d.cts → types-CWg4dTjj.d.cts} +257 -6
  274. package/dist/{types-BqFZTQmV.d.ts → types-CWg4dTjj.d.ts} +257 -6
  275. package/dist/{where-O-k2wgYm.d.ts → where-BWXUPV3C.d.ts} +1 -1
  276. package/dist/{where-DI_Fqz-X.d.cts → where-CNtx1aLc.d.cts} +1 -1
  277. package/package.json +3 -2
  278. package/dist/chunk-26YKDNUD.cjs.map +0 -1
  279. package/dist/chunk-3G5W2U2L.cjs.map +0 -1
  280. package/dist/chunk-3KOY4FH3.cjs +0 -934
  281. package/dist/chunk-3KOY4FH3.cjs.map +0 -1
  282. package/dist/chunk-3QNZ5SAJ.cjs.map +0 -1
  283. package/dist/chunk-3U5ABFDW.cjs.map +0 -1
  284. package/dist/chunk-5K2BKEBD.js.map +0 -1
  285. package/dist/chunk-5PRKMB24.cjs.map +0 -1
  286. package/dist/chunk-6LN7FIVU.js.map +0 -1
  287. package/dist/chunk-6SWPJEYN.js.map +0 -1
  288. package/dist/chunk-7LZJNLA5.js.map +0 -1
  289. package/dist/chunk-BFUOME67.cjs.map +0 -1
  290. package/dist/chunk-BRRP76WO.js.map +0 -1
  291. package/dist/chunk-CICO5GXD.cjs +0 -12
  292. package/dist/chunk-D4QLTJSM.js.map +0 -1
  293. package/dist/chunk-D5R42W5D.js.map +0 -1
  294. package/dist/chunk-EZEEWCFJ.cjs.map +0 -1
  295. package/dist/chunk-FA2AFWLP.cjs +0 -167
  296. package/dist/chunk-FA2AFWLP.cjs.map +0 -1
  297. package/dist/chunk-FQPEMEWX.cjs.map +0 -1
  298. package/dist/chunk-GLHXM7C4.js.map +0 -1
  299. package/dist/chunk-GYEG3ZLZ.cjs.map +0 -1
  300. package/dist/chunk-HDL2ARHX.cjs.map +0 -1
  301. package/dist/chunk-HEV35TGT.js.map +0 -1
  302. package/dist/chunk-I4GAZH5Z.js +0 -913
  303. package/dist/chunk-I4GAZH5Z.js.map +0 -1
  304. package/dist/chunk-JB6T4GLL.cjs.map +0 -1
  305. package/dist/chunk-JBQQ7THH.js +0 -20
  306. package/dist/chunk-JBQQ7THH.js.map +0 -1
  307. package/dist/chunk-JFRT7S3B.cjs.map +0 -1
  308. package/dist/chunk-KF6K7TGH.js.map +0 -1
  309. package/dist/chunk-LTXQOEIC.js.map +0 -1
  310. package/dist/chunk-MKJ4KXL5.cjs +0 -12
  311. package/dist/chunk-MRDBBHIZ.cjs.map +0 -1
  312. package/dist/chunk-NVY5CJFP.js.map +0 -1
  313. package/dist/chunk-PWLJ77UV.cjs +0 -23
  314. package/dist/chunk-PWLJ77UV.cjs.map +0 -1
  315. package/dist/chunk-S5TERQVW.js.map +0 -1
  316. package/dist/chunk-SHFBB23Q.js.map +0 -1
  317. package/dist/chunk-SIT26LAZ.cjs.map +0 -1
  318. package/dist/chunk-SR725PWF.cjs.map +0 -1
  319. package/dist/chunk-TQHGE7UC.cjs.map +0 -1
  320. package/dist/chunk-UGHG7PGX.js.map +0 -1
  321. package/dist/chunk-UGHQV7MP.cjs.map +0 -1
  322. package/dist/chunk-YIURNGXI.js +0 -155
  323. package/dist/chunk-YIURNGXI.js.map +0 -1
  324. package/dist/chunk-YYUHLYM2.cjs.map +0 -1
  325. package/dist/chunk-Z2JCLZFJ.js.map +0 -1
  326. package/dist/chunk-ZFMCDJGB.js.map +0 -1
  327. package/dist/chunk-ZLONH2UD.js.map +0 -1
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/identity/rebuild.ts","../src/identity/types.ts","../src/backend/migrate-vectors.ts"],"names":["embedding"],"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K,MAAA,CAAO,KAAK,CAAC,CAAA,CAAA;AAAA,OAC7C;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["import { type GraphDef, type GraphIdentityConfig } from \"../core/define-graph\";\nimport { storeRuntime } from \"../store/runtime-port\";\nimport { type Store } from \"../store/store\";\n\n/**\n * Rebuilds the derived current identity closure for an identity-enabled store.\n * This is a repair operation: it does not change graph revision or assertions.\n */\nexport async function rebuildIdentityClosure<\n G extends GraphDef & Readonly<{ identity: GraphIdentityConfig }>,\n>(store: Store<G>): Promise<void> {\n await storeRuntime(store).rebuildIdentityClosure();\n}\n","import {\n type AllNodeTypes,\n type GraphDef,\n type NodeKinds,\n} from \"../core/define-graph\";\nimport { ValidationError } from \"../errors\";\nimport {\n type DynamicNode,\n type DynamicNodeReference,\n type GraphNodeReference,\n type Node,\n type NodeRef,\n} from \"../store/types\";\n\n/**\n * The accepted *input* form for every identity facade method: a whole node or\n * a `{ kind, id }` pair for any compile-time graph kind, plus a proof-bearing\n * node or reference produced through the runtime collection lane. Runtime\n * values stay nominal so accepting them does not make an arbitrary\n * `{ kind: string, id: string }` object type-safe.\n *\n * Identity results use {@link IdentityNodeReference}, which honestly includes\n * runtime kinds because an evolved kind can belong to a class reached from a\n * compile-time node.\n */\nexport type IdentityNodeRefInput<G extends GraphDef> =\n NodeRef<AllNodeTypes<G>> | DynamicNode | DynamicNodeReference;\n\n/**\n * A node reference returned by Operational Identity.\n *\n * Identity classes can contain runtime-evolved kinds even when a read starts\n * from a compile-time node, so results honestly include both lanes.\n */\nexport type IdentityNodeReference<G extends GraphDef> =\n GraphNodeReference<G> | DynamicNodeReference;\n\n/** A hydrated compile-time or runtime identity member. */\nexport type IdentityNode<G extends GraphDef> =\n | {\n [K in NodeKinds<G>]: Node<G[\"nodes\"][K][\"type\"]>;\n }[NodeKinds<G>]\n | DynamicNode;\n\ndeclare const __identityAssertionId: unique symbol;\n\nexport type IdentityAssertionId = string &\n Readonly<{ [__identityAssertionId]: true }>;\n\n/**\n * Brands a non-empty string as an {@link IdentityAssertionId}.\n *\n * Use this when a persisted identity assertion id has round-tripped through\n * untyped storage or an external boundary and must be passed back to a\n * retraction surface such as `retractAssertion` or `bulkRetractAssertions`.\n * Mirrors the `asNodeId` / `asEdgeId` precedent.\n *\n * @throws {ValidationError} when `value` is empty.\n */\nexport function asIdentityAssertionId(value: string): IdentityAssertionId {\n if (value.length === 0) {\n throw new ValidationError(\n \"asIdentityAssertionId must be a non-empty string.\",\n {\n issues: [\n {\n path: \"asIdentityAssertionId\",\n message: \"Expected a non-empty string.\",\n },\n ],\n },\n {\n suggestion: \"Use a persisted identity assertion id value.\",\n },\n );\n }\n return value as IdentityAssertionId;\n}\n\n/**\n * What one assertion claims about a pair of nodes: `\"same\"` merges them into\n * one equivalence set, `\"different\"` records a disjointness that a later\n * `\"same\"` claim must not contradict.\n */\nexport type IdentityRelation = \"same\" | \"different\";\n\n/**\n * One persisted identity claim about an ordered pair of nodes. Returned by the\n * assertion writers and by `identity.assertionsOf(...)`; `validTo` is set when\n * the assertion has been retracted, so a historical read can still see it.\n */\nexport type IdentityAssertion<G extends GraphDef> = Readonly<{\n id: IdentityAssertionId;\n relation: IdentityRelation;\n a: IdentityNodeReference<G>;\n b: IdentityNodeReference<G>;\n validFrom: string;\n validTo?: string;\n}>;\n\n/** Result of an idempotent assertion write. */\nexport type IdentityAssertionResult<G extends GraphDef> = Readonly<{\n assertion: IdentityAssertion<G>;\n action: \"created\" | \"existing\";\n}>;\n\n/** The half-open effective-time window of an identity assertion. */\nexport type IdentityValidityWindow = Readonly<{\n validFrom?: string;\n validTo?: string;\n}>;\n\n/** One ordered node pair handed to `bulkAssertSame` / `bulkAssertDifferent`. */\nexport type IdentityPair<G extends GraphDef> = Readonly<{\n a: IdentityNodeRefInput<G>;\n b: IdentityNodeRefInput<G>;\n}> &\n IdentityValidityWindow;\n\n/**\n * The read half of the identity surface: equivalence-set membership,\n * representative selection, and the assertions behind them.\n *\n * Obtained from a read-only lens — `store.asOf(...).identity`,\n * `store.snapshot().identity` — where it answers at that view's coordinate.\n * The full read+write surface is {@link IdentityFacade}.\n */\nexport type IdentityReadFacade<G extends GraphDef> = Readonly<{\n representativeOf: (\n ref: IdentityNodeRefInput<G>,\n ) => Promise<IdentityNodeReference<G> | undefined>;\n membersOf: (\n ref: IdentityNodeRefInput<G>,\n ) => Promise<readonly IdentityNodeReference<G>[]>;\n nodesOf: (\n ref: IdentityNodeRefInput<G>,\n ) => Promise<readonly IdentityNode<G>[]>;\n areSame: (\n a: IdentityNodeRefInput<G>,\n b: IdentityNodeRefInput<G>,\n ) => Promise<boolean>;\n areDifferent: (\n a: IdentityNodeRefInput<G>,\n b: IdentityNodeRefInput<G>,\n ) => Promise<boolean>;\n assertionsOf: (\n ref: IdentityNodeRefInput<G>,\n ) => Promise<readonly IdentityAssertion<G>[]>;\n}>;\n\n/**\n * The full TypeGraph Identity Profile surface: {@link IdentityReadFacade} plus\n * the assertion writers and retractions.\n *\n * Obtained from `store.identity` or `tx.identity`, and present only on graphs\n * that declared `identity: { ... }` in `defineGraph`. Every writer is\n * idempotent — re-asserting an existing claim returns it with\n * `action: \"existing\"` rather than duplicating it.\n */\nexport type IdentityFacade<G extends GraphDef> = IdentityReadFacade<G> &\n Readonly<{\n assertSame: (\n a: IdentityNodeRefInput<G>,\n b: IdentityNodeRefInput<G>,\n window?: IdentityValidityWindow,\n ) => Promise<IdentityAssertionResult<G>>;\n assertDifferent: (\n a: IdentityNodeRefInput<G>,\n b: IdentityNodeRefInput<G>,\n window?: IdentityValidityWindow,\n ) => Promise<IdentityAssertionResult<G>>;\n bulkAssertSame: (\n pairs: readonly IdentityPair<G>[],\n ) => Promise<readonly IdentityAssertionResult<G>[]>;\n bulkAssertDifferent: (\n pairs: readonly IdentityPair<G>[],\n ) => Promise<readonly IdentityAssertionResult<G>[]>;\n retractAssertion: (\n id: IdentityAssertionId,\n ) => Promise<IdentityAssertion<G> | undefined>;\n retractSameAssertion: (\n a: IdentityNodeRefInput<G>,\n b: IdentityNodeRefInput<G>,\n ) => Promise<IdentityAssertion<G> | undefined>;\n retractDifferentAssertion: (\n a: IdentityNodeRefInput<G>,\n b: IdentityNodeRefInput<G>,\n ) => Promise<IdentityAssertion<G> | undefined>;\n bulkRetractAssertions: (\n ids: readonly IdentityAssertionId[],\n ) => Promise<readonly IdentityAssertion<G>[]>;\n }>;\n\n/**\n * The assertion-only write surface of the TypeGraph Identity Profile.\n *\n * This deliberately excludes reads and retractions so constrained staging\n * handles can accept incoming identity claims without exposing the broader\n * operational identity surface.\n */\nexport type IdentityAssertionWriteFacade<G extends GraphDef> = Pick<\n IdentityFacade<G>,\n \"assertSame\" | \"assertDifferent\" | \"bulkAssertSame\" | \"bulkAssertDifferent\"\n>;\n\n/**\n * Per-transaction identity write counts carried by a transaction receipt.\n * `total` is the sum of the three preceding counters.\n */\nexport type IdentityWriteSummary = Readonly<{\n sameAssertions: number;\n differentAssertions: number;\n retractions: number;\n total: number;\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 {\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 { createDataKeyedBag } from \"../utils/object\";\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 // Data-keyed: slot keys are built from a row's `node_kind` / `field_path`.\n const perField = createDataKeyedBag<number>();\n const skippedDimensionMismatch = createDataKeyedBag<number>();\n const skippedDecodeError = createDataKeyedBag<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 // SPREAD at the boundary. The three maps are null-prototype accumulators\n // because their keys are slot names built from row data; that protection is\n // internal, and returning the bags as-is handed a caller three maps with no\n // `toString` and `instanceof Object === false` — while the early\n // \"nothing to migrate\" return above hands back `{}` literals, so the same\n // exported function answered with two different kinds of object depending on\n // whether the legacy table existed. Spread copies own properties with\n // CreateDataProperty, so a `__proto__` slot key survives as an own key.\n return {\n migrated,\n perField: { ...perField },\n skippedDimensionMismatch: { ...skippedDimensionMismatch },\n skippedDecodeError: { ...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
+ {"version":3,"sources":["../src/identity/rebuild.ts","../src/identity/types.ts","../src/backend/migrate-vectors.ts"],"names":["embedding"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,eAAsB,uBAEpB,KAAA,EAAgC;AAChC,EAAA,M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ourcesContent":["import { type GraphDef, type GraphIdentityConfig } from \"../core/define-graph\";\nimport { storeRuntime } from \"../store/runtime-port\";\nimport { type Store } from \"../store/store\";\n\n/**\n * Rebuilds the derived current identity closure for an identity-enabled store.\n * This is a repair operation: it does not change graph revision or assertions.\n */\nexport async function rebuildIdentityClosure<\n G extends GraphDef & Readonly<{ identity: GraphIdentityConfig }>,\n>(store: Store<G>): Promise<void> {\n await storeRuntime(store).rebuildIdentityClosure();\n}\n","import {\n type AllNodeTypes,\n type GraphDef,\n type NodeKinds,\n} from \"../core/define-graph\";\nimport { ValidationError } from \"../errors\";\nimport {\n type DynamicNode,\n type DynamicNodeReference,\n type GraphNodeReference,\n type Node,\n type NodeRef,\n} from \"../store/types\";\n\n/**\n * The accepted *input* form for every identity facade method: a whole node or\n * a `{ kind, id }` pair for any compile-time graph kind, plus a proof-bearing\n * node or reference produced through the runtime collection lane. Runtime\n * values stay nominal so accepting them does not make an arbitrary\n * `{ kind: string, id: string }` object type-safe.\n *\n * Identity results use {@link IdentityNodeReference}, which honestly includes\n * runtime kinds because an evolved kind can belong to a class reached from a\n * compile-time node.\n */\nexport type IdentityNodeRefInput<G extends GraphDef> =\n NodeRef<AllNodeTypes<G>> | DynamicNode | DynamicNodeReference;\n\n/**\n * A node reference returned by Operational Identity.\n *\n * Identity classes can contain runtime-evolved kinds even when a read starts\n * from a compile-time node, so results honestly include both lanes.\n */\nexport type IdentityNodeReference<G extends GraphDef> =\n GraphNodeReference<G> | DynamicNodeReference;\n\n/** A hydrated compile-time or runtime identity member. */\nexport type IdentityNode<G extends GraphDef> =\n | {\n [K in NodeKinds<G>]: Node<G[\"nodes\"][K][\"type\"]>;\n }[NodeKinds<G>]\n | DynamicNode;\n\ndeclare const __identityAssertionId: unique symbol;\n\nexport type IdentityAssertionId = string &\n Readonly<{ [__identityAssertionId]: true }>;\n\n/**\n * Brands a non-empty string as an {@link IdentityAssertionId}.\n *\n * Use this when a persisted identity assertion id has round-tripped through\n * untyped storage or an external boundary and must be passed back to a\n * retraction surface such as `retractAssertion` or `bulkRetractAssertions`.\n * Mirrors the `asNodeId` / `asEdgeId` precedent.\n *\n * @throws {ValidationError} when `value` is empty.\n */\nexport function asIdentityAssertionId(value: string): IdentityAssertionId {\n if (value.length === 0) {\n throw new ValidationError(\n \"asIdentityAssertionId must be a non-empty string.\",\n {\n issues: [\n {\n path: \"asIdentityAssertionId\",\n message: \"Expected a non-empty string.\",\n },\n ],\n },\n {\n suggestion: \"Use a persisted identity assertion id value.\",\n },\n );\n }\n return value as IdentityAssertionId;\n}\n\n/**\n * What one assertion claims about a pair of nodes: `\"same\"` merges them into\n * one equivalence set, `\"different\"` records a disjointness that a later\n * `\"same\"` claim must not contradict.\n */\nexport type IdentityRelation = \"same\" | \"different\";\n\n/**\n * One persisted identity claim about an ordered pair of nodes. Returned by the\n * assertion writers and by `identity.assertionsOf(...)`; `validTo` is set when\n * the assertion has been retracted, so a historical read can still see it.\n */\nexport type IdentityAssertion<G extends GraphDef> = Readonly<{\n id: IdentityAssertionId;\n relation: IdentityRelation;\n a: IdentityNodeReference<G>;\n b: IdentityNodeReference<G>;\n validFrom: string;\n validTo?: string;\n}>;\n\n/** Result of an idempotent assertion write. */\nexport type IdentityAssertionResult<G extends GraphDef> = Readonly<{\n assertion: IdentityAssertion<G>;\n action: \"created\" | \"existing\";\n}>;\n\n/** The half-open effective-time window of an identity assertion. */\nexport type IdentityValidityWindow = Readonly<{\n validFrom?: string;\n validTo?: string;\n}>;\n\n/** One ordered node pair handed to `bulkAssertSame` / `bulkAssertDifferent`. */\nexport type IdentityPair<G extends GraphDef> = Readonly<{\n a: IdentityNodeRefInput<G>;\n b: IdentityNodeRefInput<G>;\n}> &\n IdentityValidityWindow;\n\n/**\n * The read half of the identity surface: equivalence-set membership,\n * representative selection, and the assertions behind them.\n *\n * Obtained from a read-only lens — `store.asOf(...).identity`,\n * `store.snapshot().identity` — where it answers at that view's coordinate.\n * The full read+write surface is {@link IdentityFacade}.\n */\nexport type IdentityReadFacade<G extends GraphDef> = Readonly<{\n representativeOf: (\n ref: IdentityNodeRefInput<G>,\n ) => Promise<IdentityNodeReference<G> | undefined>;\n membersOf: (\n ref: IdentityNodeRefInput<G>,\n ) => Promise<readonly IdentityNodeReference<G>[]>;\n nodesOf: (\n ref: IdentityNodeRefInput<G>,\n ) => Promise<readonly IdentityNode<G>[]>;\n areSame: (\n a: IdentityNodeRefInput<G>,\n b: IdentityNodeRefInput<G>,\n ) => Promise<boolean>;\n areDifferent: (\n a: IdentityNodeRefInput<G>,\n b: IdentityNodeRefInput<G>,\n ) => Promise<boolean>;\n assertionsOf: (\n ref: IdentityNodeRefInput<G>,\n ) => Promise<readonly IdentityAssertion<G>[]>;\n}>;\n\n/**\n * The full TypeGraph Identity Profile surface: {@link IdentityReadFacade} plus\n * the assertion writers and retractions.\n *\n * Obtained from `store.identity` or `tx.identity`, and present only on graphs\n * that declared `identity: { ... }` in `defineGraph`. Every writer is\n * idempotent — re-asserting an existing claim returns it with\n * `action: \"existing\"` rather than duplicating it.\n */\nexport type IdentityFacade<G extends GraphDef> = IdentityReadFacade<G> &\n Readonly<{\n assertSame: (\n a: IdentityNodeRefInput<G>,\n b: IdentityNodeRefInput<G>,\n window?: IdentityValidityWindow,\n ) => Promise<IdentityAssertionResult<G>>;\n assertDifferent: (\n a: IdentityNodeRefInput<G>,\n b: IdentityNodeRefInput<G>,\n window?: IdentityValidityWindow,\n ) => Promise<IdentityAssertionResult<G>>;\n bulkAssertSame: (\n pairs: readonly IdentityPair<G>[],\n ) => Promise<readonly IdentityAssertionResult<G>[]>;\n bulkAssertDifferent: (\n pairs: readonly IdentityPair<G>[],\n ) => Promise<readonly IdentityAssertionResult<G>[]>;\n retractAssertion: (\n id: IdentityAssertionId,\n ) => Promise<IdentityAssertion<G> | undefined>;\n retractSameAssertion: (\n a: IdentityNodeRefInput<G>,\n b: IdentityNodeRefInput<G>,\n ) => Promise<IdentityAssertion<G> | undefined>;\n retractDifferentAssertion: (\n a: IdentityNodeRefInput<G>,\n b: IdentityNodeRefInput<G>,\n ) => Promise<IdentityAssertion<G> | undefined>;\n bulkRetractAssertions: (\n ids: readonly IdentityAssertionId[],\n ) => Promise<readonly IdentityAssertion<G>[]>;\n }>;\n\n/**\n * The assertion-only write surface of the TypeGraph Identity Profile.\n *\n * This deliberately excludes reads and retractions so constrained staging\n * handles can accept incoming identity claims without exposing the broader\n * operational identity surface.\n */\nexport type IdentityAssertionWriteFacade<G extends GraphDef> = Pick<\n IdentityFacade<G>,\n \"assertSame\" | \"assertDifferent\" | \"bulkAssertSame\" | \"bulkAssertDifferent\"\n>;\n\n/**\n * Per-transaction identity write counts carried by a transaction receipt.\n * `total` is the sum of the three preceding counters.\n */\nexport type IdentityWriteSummary = Readonly<{\n sameAssertions: number;\n differentAssertions: number;\n retractions: number;\n total: number;\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 {\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 { createDataKeyedBag } from \"../utils/object\";\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 // Data-keyed: slot keys are built from a row's `node_kind` / `field_path`.\n const perField = createDataKeyedBag<number>();\n const skippedDimensionMismatch = createDataKeyedBag<number>();\n const skippedDecodeError = createDataKeyedBag<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 // SPREAD at the boundary. The three maps are null-prototype accumulators\n // because their keys are slot names built from row data; that protection is\n // internal, and returning the bags as-is handed a caller three maps with no\n // `toString` and `instanceof Object === false` — while the early\n // \"nothing to migrate\" return above hands back `{}` literals, so the same\n // exported function answered with two different kinds of object depending on\n // whether the legacy table existed. Spread copies own properties with\n // CreateDataProperty, so a `__proto__` slot key survives as an own key.\n return {\n migrated,\n perField: { ...perField },\n skippedDimensionMismatch: { ...skippedDimensionMismatch },\n skippedDecodeError: { ...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,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkUWG5GX6E_cjs = require('../chunk-UWG5GX6E.cjs');
4
- var chunkAOSSQDVO_cjs = require('../chunk-AOSSQDVO.cjs');
5
- var chunkOI2GQ25X_cjs = require('../chunk-OI2GQ25X.cjs');
6
- var chunkLRQKXRXO_cjs = require('../chunk-LRQKXRXO.cjs');
4
+ var chunkCSNOYIB4_cjs = require('../chunk-CSNOYIB4.cjs');
5
+ var chunkSHC7BCG5_cjs = require('../chunk-SHC7BCG5.cjs');
6
+ var chunkHY5BNOUN_cjs = require('../chunk-HY5BNOUN.cjs');
7
7
  require('../chunk-ZY4GXIVN.cjs');
8
8
  require('../chunk-NAUA4PW5.cjs');
9
- require('../chunk-L3LQNR34.cjs');
10
- require('../chunk-EDN4Y4ZG.cjs');
9
+ require('../chunk-TEC24ZDA.cjs');
10
+ require('../chunk-OJHD3LXJ.cjs');
11
11
  require('../chunk-7EO3TCQB.cjs');
12
12
  require('../chunk-RT5ZY4XA.cjs');
13
13
  require('../chunk-HAHNRASW.cjs');
14
- require('../chunk-MRDBBHIZ.cjs');
14
+ require('../chunk-X4GDXBOP.cjs');
15
15
  require('../chunk-A7J2YDDI.cjs');
16
16
  require('../chunk-N66HCGCY.cjs');
17
17
 
@@ -39,31 +39,31 @@ Object.defineProperty(exports, "toDeclaredIndexes", {
39
39
  });
40
40
  Object.defineProperty(exports, "generateEdgeIndexDDL", {
41
41
  enumerable: true,
42
- get: function () { return chunkAOSSQDVO_cjs.generateEdgeIndexDDL; }
42
+ get: function () { return chunkCSNOYIB4_cjs.generateEdgeIndexDDL; }
43
43
  });
44
44
  Object.defineProperty(exports, "generateIndexDDL", {
45
45
  enumerable: true,
46
- get: function () { return chunkAOSSQDVO_cjs.generateIndexDDL; }
46
+ get: function () { return chunkCSNOYIB4_cjs.generateIndexDDL; }
47
47
  });
48
48
  Object.defineProperty(exports, "generateNodeIndexDDL", {
49
49
  enumerable: true,
50
- get: function () { return chunkAOSSQDVO_cjs.generateNodeIndexDDL; }
50
+ get: function () { return chunkCSNOYIB4_cjs.generateNodeIndexDDL; }
51
51
  });
52
52
  Object.defineProperty(exports, "SYSTEM_INDEX_DECLARATIONS", {
53
53
  enumerable: true,
54
- get: function () { return chunkOI2GQ25X_cjs.SYSTEM_INDEX_DECLARATIONS; }
54
+ get: function () { return chunkSHC7BCG5_cjs.SYSTEM_INDEX_DECLARATIONS; }
55
55
  });
56
56
  Object.defineProperty(exports, "generateSystemIndexDDL", {
57
57
  enumerable: true,
58
- get: function () { return chunkOI2GQ25X_cjs.generateSystemIndexDDL; }
58
+ get: function () { return chunkSHC7BCG5_cjs.generateSystemIndexDDL; }
59
59
  });
60
60
  Object.defineProperty(exports, "defineEdgeIndex", {
61
61
  enumerable: true,
62
- get: function () { return chunkLRQKXRXO_cjs.defineEdgeIndex; }
62
+ get: function () { return chunkHY5BNOUN_cjs.defineEdgeIndex; }
63
63
  });
64
64
  Object.defineProperty(exports, "defineNodeIndex", {
65
65
  enumerable: true,
66
- get: function () { return chunkLRQKXRXO_cjs.defineNodeIndex; }
66
+ get: function () { return chunkHY5BNOUN_cjs.defineNodeIndex; }
67
67
  });
68
68
  //# sourceMappingURL=index.cjs.map
69
69
  //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
- import { a7 as EdgeIndexDeclaration, c2 as SqlDialect, bE as RelationalIndexDeclaration, br as NodeIndexDeclaration, I as IndexDeclaration } from '../types-BqFZTQmV.cjs';
2
- export { da as EdgeIndexConfig, a8 as EdgeIndexDirection, db as EdgeIndexWhereBuilder, b3 as IndexOrigin, b4 as IndexScope, b5 as IndexWhereExpression, dc as IndexWhereFieldBuilder, dd as IndexWhereInput, de as NodeIndexConfig, df as NodeIndexWhereBuilder, cc as SystemColumnName, cA as VectorIndexDeclaration, cB as VectorIndexImplementation, cC as VectorIndexMetric, cD as VectorIndexParams } from '../types-BqFZTQmV.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-DI_Fqz-X.cjs';
4
- import { D as DeclaredIndex } from '../types-CXAhpW-c.cjs';
1
+ import { ag as EdgeIndexDeclaration, ce as SqlDialect, bQ as RelationalIndexDeclaration, bB as NodeIndexDeclaration, I as IndexDeclaration } from '../types-CWg4dTjj.cjs';
2
+ export { dm as EdgeIndexConfig, ah as EdgeIndexDirection, dn as EdgeIndexWhereBuilder, bd as IndexOrigin, be as IndexScope, bf as IndexWhereExpression, dp as IndexWhereFieldBuilder, dq as IndexWhereInput, dr as NodeIndexConfig, ds as NodeIndexWhereBuilder, co as SystemColumnName, cM as VectorIndexDeclaration, cN as VectorIndexImplementation, cO as VectorIndexMetric, cP as VectorIndexParams } from '../types-CWg4dTjj.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-CNtx1aLc.cjs';
4
+ import { D as DeclaredIndex } from '../types-BE921wRl.cjs';
5
5
  import 'zod';
6
6
 
7
7
  type GenerateIndexDdlOptions = Readonly<{
@@ -1,7 +1,7 @@
1
- import { a7 as EdgeIndexDeclaration, c2 as SqlDialect, bE as RelationalIndexDeclaration, br as NodeIndexDeclaration, I as IndexDeclaration } from '../types-BqFZTQmV.js';
2
- export { da as EdgeIndexConfig, a8 as EdgeIndexDirection, db as EdgeIndexWhereBuilder, b3 as IndexOrigin, b4 as IndexScope, b5 as IndexWhereExpression, dc as IndexWhereFieldBuilder, dd as IndexWhereInput, de as NodeIndexConfig, df as NodeIndexWhereBuilder, cc as SystemColumnName, cA as VectorIndexDeclaration, cB as VectorIndexImplementation, cC as VectorIndexMetric, cD as VectorIndexParams } from '../types-BqFZTQmV.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-O-k2wgYm.js';
4
- import { D as DeclaredIndex } from '../types-Bx74kaTt.js';
1
+ import { ag as EdgeIndexDeclaration, ce as SqlDialect, bQ as RelationalIndexDeclaration, bB as NodeIndexDeclaration, I as IndexDeclaration } from '../types-CWg4dTjj.js';
2
+ export { dm as EdgeIndexConfig, ah as EdgeIndexDirection, dn as EdgeIndexWhereBuilder, bd as IndexOrigin, be as IndexScope, bf as IndexWhereExpression, dp as IndexWhereFieldBuilder, dq as IndexWhereInput, dr as NodeIndexConfig, ds as NodeIndexWhereBuilder, co as SystemColumnName, cM as VectorIndexDeclaration, cN as VectorIndexImplementation, cO as VectorIndexMetric, cP as VectorIndexParams } from '../types-CWg4dTjj.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-BWXUPV3C.js';
4
+ import { D as DeclaredIndex } from '../types-BScHXVM7.js';
5
5
  import 'zod';
6
6
 
7
7
  type GenerateIndexDdlOptions = Readonly<{
@@ -1,15 +1,15 @@
1
1
  export { andWhere, notWhere, orWhere, toDeclaredIndex, toDeclaredIndexes } from '../chunk-QZ7A6HBM.js';
2
- export { generateEdgeIndexDDL, generateIndexDDL, generateNodeIndexDDL } from '../chunk-KKBDXCLQ.js';
3
- export { SYSTEM_INDEX_DECLARATIONS, generateSystemIndexDDL } from '../chunk-SDBBMD4N.js';
4
- export { defineEdgeIndex, defineNodeIndex } from '../chunk-P6YLZTRE.js';
2
+ export { generateEdgeIndexDDL, generateIndexDDL, generateNodeIndexDDL } from '../chunk-WQBAQZHR.js';
3
+ export { SYSTEM_INDEX_DECLARATIONS, generateSystemIndexDDL } from '../chunk-H3XP6BAV.js';
4
+ export { defineEdgeIndex, defineNodeIndex } from '../chunk-ZRJTM7MT.js';
5
5
  import '../chunk-K34OPSJK.js';
6
6
  import '../chunk-2EBMPJBO.js';
7
- import '../chunk-ZDKTPBGV.js';
8
- import '../chunk-3DMMGT6S.js';
7
+ import '../chunk-EDLKIQRI.js';
8
+ import '../chunk-46UGOVRW.js';
9
9
  import '../chunk-AMKPPFUO.js';
10
10
  import '../chunk-W6OG3HDG.js';
11
11
  import '../chunk-PC2UBAUB.js';
12
- import '../chunk-ZLONH2UD.js';
12
+ import '../chunk-YDEJQWOL.js';
13
13
  import '../chunk-FWJKWH6U.js';
14
14
  import '../chunk-DYATYRY4.js';
15
15
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { d8 as GraphDef } from './types-BqFZTQmV.js';
1
+ import { dk as GraphDef } from './types-CWg4dTjj.js';
2
2
 
3
3
  /**
4
4
  * Private capability bridge from an opaque ingestion branch to interchange.
@@ -1,4 +1,4 @@
1
- import { d8 as GraphDef } from './types-BqFZTQmV.cjs';
1
+ import { dk as GraphDef } from './types-CWg4dTjj.cjs';
2
2
 
3
3
  /**
4
4
  * Private capability bridge from an opaque ingestion branch to interchange.
@@ -1,46 +1,47 @@
1
1
  'use strict';
2
2
 
3
- var chunk3G5W2U2L_cjs = require('../chunk-3G5W2U2L.cjs');
4
- require('../chunk-JB6T4GLL.cjs');
5
- var chunk3KOY4FH3_cjs = require('../chunk-3KOY4FH3.cjs');
6
- require('../chunk-JFRT7S3B.cjs');
7
- require('../chunk-EZEEWCFJ.cjs');
8
- require('../chunk-PWLJ77UV.cjs');
9
- var chunkSIT26LAZ_cjs = require('../chunk-SIT26LAZ.cjs');
10
- require('../chunk-3U5ABFDW.cjs');
11
- require('../chunk-5PRKMB24.cjs');
12
- require('../chunk-BFUOME67.cjs');
13
- require('../chunk-FQPEMEWX.cjs');
14
- require('../chunk-2QGYQBS2.cjs');
15
- var chunkTQHGE7UC_cjs = require('../chunk-TQHGE7UC.cjs');
3
+ var chunkCS6JTQQ2_cjs = require('../chunk-CS6JTQQ2.cjs');
4
+ require('../chunk-C76WFIVZ.cjs');
5
+ var chunkTUVD4DFR_cjs = require('../chunk-TUVD4DFR.cjs');
6
+ require('../chunk-7PRMDZIA.cjs');
7
+ require('../chunk-5OWHU7Z7.cjs');
8
+ require('../chunk-RDP6ZRSM.cjs');
9
+ var chunkZBFZGLZE_cjs = require('../chunk-ZBFZGLZE.cjs');
10
+ require('../chunk-IHK5KA2Q.cjs');
11
+ require('../chunk-GHZPZNFC.cjs');
12
+ require('../chunk-G2TLHH6T.cjs');
13
+ require('../chunk-LLVOQOWE.cjs');
14
+ require('../chunk-DWUDZ66O.cjs');
15
+ var chunkM5MSP3BI_cjs = require('../chunk-M5MSP3BI.cjs');
16
16
  require('../chunk-NAUA4PW5.cjs');
17
- require('../chunk-L3LQNR34.cjs');
18
- require('../chunk-EDN4Y4ZG.cjs');
17
+ require('../chunk-TEC24ZDA.cjs');
18
+ require('../chunk-OJHD3LXJ.cjs');
19
19
  require('../chunk-RT5ZY4XA.cjs');
20
20
  var chunkHAHNRASW_cjs = require('../chunk-HAHNRASW.cjs');
21
- require('../chunk-6NGW27EO.cjs');
22
- var chunkMRDBBHIZ_cjs = require('../chunk-MRDBBHIZ.cjs');
21
+ require('../chunk-VLBTRXA2.cjs');
22
+ require('../chunk-RWUWTJQY.cjs');
23
+ var chunkX4GDXBOP_cjs = require('../chunk-X4GDXBOP.cjs');
23
24
  require('../chunk-A7J2YDDI.cjs');
24
25
  require('../chunk-N66HCGCY.cjs');
25
26
 
26
27
  // src/interchange/trusted-import.ts
27
28
  function rejectUnsupportedStoreFeatures(store) {
28
29
  if (store.historyEnabled) {
29
- throw new chunkMRDBBHIZ_cjs.TrustedImportError(
30
+ throw new chunkX4GDXBOP_cjs.TrustedImportError(
30
31
  "Trusted import does not support recorded-time history capture.",
31
32
  "history_unsupported",
32
33
  { graphId: store.graphId }
33
34
  );
34
35
  }
35
36
  if (store.revisionTrackingEnabled) {
36
- throw new chunkMRDBBHIZ_cjs.TrustedImportError(
37
+ throw new chunkX4GDXBOP_cjs.TrustedImportError(
37
38
  "Trusted import does not support revision tracking.",
38
39
  "revision_tracking_unsupported",
39
40
  { graphId: store.graphId }
40
41
  );
41
42
  }
42
43
  if (store.graph.identity !== void 0) {
43
- throw new chunkMRDBBHIZ_cjs.TrustedImportError(
44
+ throw new chunkX4GDXBOP_cjs.TrustedImportError(
44
45
  "Trusted import does not maintain Operational Identity assertions or closure.",
45
46
  "identity_unsupported",
46
47
  { graphId: store.graphId }
@@ -48,7 +49,7 @@ function rejectUnsupportedStoreFeatures(store) {
48
49
  }
49
50
  const uniqueKinds = Object.values(store.graph.nodes).filter((registration) => (registration.unique?.length ?? 0) > 0).map((registration) => registration.type.kind);
50
51
  if (uniqueKinds.length > 0) {
51
- throw new chunkMRDBBHIZ_cjs.TrustedImportError(
52
+ throw new chunkX4GDXBOP_cjs.TrustedImportError(
52
53
  "Trusted import does not maintain node uniqueness sidecars.",
53
54
  "uniqueness_unsupported",
54
55
  { graphId: store.graphId, nodeKinds: uniqueKinds }
@@ -58,7 +59,7 @@ function rejectUnsupportedStoreFeatures(store) {
58
59
  (registration) => chunkHAHNRASW_cjs.getSearchableFields(registration.type.schema).length > 0
59
60
  ).map((registration) => registration.type.kind);
60
61
  if (searchableKinds.length > 0) {
61
- throw new chunkMRDBBHIZ_cjs.TrustedImportError(
62
+ throw new chunkX4GDXBOP_cjs.TrustedImportError(
62
63
  "Trusted import does not maintain fulltext sidecars.",
63
64
  "fulltext_unsupported",
64
65
  { graphId: store.graphId, nodeKinds: searchableKinds }
@@ -66,7 +67,7 @@ function rejectUnsupportedStoreFeatures(store) {
66
67
  }
67
68
  const vectorSlots = chunkHAHNRASW_cjs.resolveGraphVectorSlots(store.graph);
68
69
  if (vectorSlots.length > 0) {
69
- throw new chunkMRDBBHIZ_cjs.TrustedImportError(
70
+ throw new chunkX4GDXBOP_cjs.TrustedImportError(
70
71
  "Trusted import does not maintain vector sidecars.",
71
72
  "vector_unsupported",
72
73
  {
@@ -77,14 +78,14 @@ function rejectUnsupportedStoreFeatures(store) {
77
78
  }
78
79
  }
79
80
  function invalidStream(message) {
80
- return new chunkMRDBBHIZ_cjs.TrustedImportError(message, "invalid_stream");
81
+ return new chunkX4GDXBOP_cjs.TrustedImportError(message, "invalid_stream");
81
82
  }
82
83
  function nonCanonicalWindowOf(entity) {
83
84
  const { validFrom, validTo } = entity;
84
- if (typeof validFrom === "string" && !chunkTQHGE7UC_cjs.isCanonicalIsoDate(validFrom)) {
85
+ if (typeof validFrom === "string" && !chunkM5MSP3BI_cjs.isCanonicalIsoDate(validFrom)) {
85
86
  return { field: "validFrom", value: validFrom };
86
87
  }
87
- if (typeof validTo === "string" && !chunkTQHGE7UC_cjs.isCanonicalIsoDate(validTo)) {
88
+ if (typeof validTo === "string" && !chunkM5MSP3BI_cjs.isCanonicalIsoDate(validTo)) {
88
89
  return { field: "validTo", value: validTo };
89
90
  }
90
91
  return void 0;
@@ -100,7 +101,7 @@ function nonCanonicalWindowMessage(subject, field, value) {
100
101
  return `Non-canonical ${field} in trusted import: ${subject} states "${value}". Expected canonical fixed-width UTC ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ), which is what makes a stored timestamp sort chronologically against an asOf coordinate. Convert with new Date(value).toISOString().`;
101
102
  }
102
103
  function hasInvertedWindow(entity) {
103
- return chunkTQHGE7UC_cjs.isInvertedValidityWindow(
104
+ return chunkM5MSP3BI_cjs.isInvertedValidityWindow(
104
105
  entity.validFrom ?? void 0,
105
106
  entity.validTo
106
107
  );
@@ -260,19 +261,19 @@ async function consumeTrustedChunks(store, session, chunks) {
260
261
  }
261
262
  async function trustedImportGraphStream(store, chunks) {
262
263
  rejectUnsupportedStoreFeatures(store);
263
- const backend = chunk3KOY4FH3_cjs.storeBackend(store);
264
+ const backend = chunkTUVD4DFR_cjs.storeBackend(store);
264
265
  const trustedImport = backend.trustedImport;
265
266
  if (trustedImport === void 0) {
266
- throw new chunkMRDBBHIZ_cjs.TrustedImportError(
267
+ throw new chunkX4GDXBOP_cjs.TrustedImportError(
267
268
  `The ${backend.dialect} backend does not support trusted import.`,
268
269
  "backend_unsupported",
269
270
  { dialect: backend.dialect }
270
271
  );
271
272
  }
272
- const sourceBackend = Symbol.asyncIterator in chunks ? chunk3G5W2U2L_cjs.exportStreamBackend(chunks) : void 0;
273
- const contention = sourceBackend === void 0 ? void 0 : chunkSIT26LAZ_cjs.snapshotExportContention(sourceBackend, backend);
273
+ const sourceBackend = Symbol.asyncIterator in chunks ? chunkCS6JTQQ2_cjs.exportStreamBackend(chunks) : void 0;
274
+ const contention = sourceBackend === void 0 ? void 0 : chunkZBFZGLZE_cjs.snapshotExportContention(sourceBackend, backend);
274
275
  if (contention !== void 0) {
275
- throw chunk3G5W2U2L_cjs.serializedStreamRefusal({
276
+ throw chunkCS6JTQQ2_cjs.serializedStreamRefusal({
276
277
  graphId: store.graphId,
277
278
  requested: "import-stream",
278
279
  heldBy: "export-snapshot",
@@ -286,7 +287,7 @@ async function trustedImportGraphStream(store, chunks) {
286
287
  expectedVersion: schemaVersion
287
288
  }
288
289
  };
289
- return chunk3G5W2U2L_cjs.withImportStreamLease(
290
+ return chunkCS6JTQQ2_cjs.withImportStreamLease(
290
291
  store,
291
292
  () => trustedImport(
292
293
  (session) => consumeTrustedChunks(store, session, chunks),
@@ -315,87 +316,87 @@ function trustedImportGraph(store, data) {
315
316
 
316
317
  Object.defineProperty(exports, "ConflictStrategySchema", {
317
318
  enumerable: true,
318
- get: function () { return chunk3G5W2U2L_cjs.ConflictStrategySchema; }
319
+ get: function () { return chunkCS6JTQQ2_cjs.ConflictStrategySchema; }
319
320
  });
320
321
  Object.defineProperty(exports, "ExportOptionsSchema", {
321
322
  enumerable: true,
322
- get: function () { return chunk3G5W2U2L_cjs.ExportOptionsSchema; }
323
+ get: function () { return chunkCS6JTQQ2_cjs.ExportOptionsSchema; }
323
324
  });
324
325
  Object.defineProperty(exports, "ExportStreamOptionsSchema", {
325
326
  enumerable: true,
326
- get: function () { return chunk3G5W2U2L_cjs.ExportStreamOptionsSchema; }
327
+ get: function () { return chunkCS6JTQQ2_cjs.ExportStreamOptionsSchema; }
327
328
  });
328
329
  Object.defineProperty(exports, "FORMAT_VERSION", {
329
330
  enumerable: true,
330
- get: function () { return chunk3G5W2U2L_cjs.FORMAT_VERSION; }
331
+ get: function () { return chunkCS6JTQQ2_cjs.FORMAT_VERSION; }
331
332
  });
332
333
  Object.defineProperty(exports, "GraphDataHeaderSchema", {
333
334
  enumerable: true,
334
- get: function () { return chunk3G5W2U2L_cjs.GraphDataHeaderSchema; }
335
+ get: function () { return chunkCS6JTQQ2_cjs.GraphDataHeaderSchema; }
335
336
  });
336
337
  Object.defineProperty(exports, "GraphDataSchema", {
337
338
  enumerable: true,
338
- get: function () { return chunk3G5W2U2L_cjs.GraphDataSchema; }
339
+ get: function () { return chunkCS6JTQQ2_cjs.GraphDataSchema; }
339
340
  });
340
341
  Object.defineProperty(exports, "GraphDataSourceSchema", {
341
342
  enumerable: true,
342
- get: function () { return chunk3G5W2U2L_cjs.GraphDataSourceSchema; }
343
+ get: function () { return chunkCS6JTQQ2_cjs.GraphDataSourceSchema; }
343
344
  });
344
345
  Object.defineProperty(exports, "GraphInterchangeChunkSchema", {
345
346
  enumerable: true,
346
- get: function () { return chunk3G5W2U2L_cjs.GraphInterchangeChunkSchema; }
347
+ get: function () { return chunkCS6JTQQ2_cjs.GraphInterchangeChunkSchema; }
347
348
  });
348
349
  Object.defineProperty(exports, "IdentityInterchangeModeSchema", {
349
350
  enumerable: true,
350
- get: function () { return chunk3G5W2U2L_cjs.IdentityInterchangeModeSchema; }
351
+ get: function () { return chunkCS6JTQQ2_cjs.IdentityInterchangeModeSchema; }
351
352
  });
352
353
  Object.defineProperty(exports, "ImportErrorSchema", {
353
354
  enumerable: true,
354
- get: function () { return chunk3G5W2U2L_cjs.ImportErrorSchema; }
355
+ get: function () { return chunkCS6JTQQ2_cjs.ImportErrorSchema; }
355
356
  });
356
357
  Object.defineProperty(exports, "ImportOptionsSchema", {
357
358
  enumerable: true,
358
- get: function () { return chunk3G5W2U2L_cjs.ImportOptionsSchema; }
359
+ get: function () { return chunkCS6JTQQ2_cjs.ImportOptionsSchema; }
359
360
  });
360
361
  Object.defineProperty(exports, "ImportResultSchema", {
361
362
  enumerable: true,
362
- get: function () { return chunk3G5W2U2L_cjs.ImportResultSchema; }
363
+ get: function () { return chunkCS6JTQQ2_cjs.ImportResultSchema; }
363
364
  });
364
365
  Object.defineProperty(exports, "InterchangeEdgeSchema", {
365
366
  enumerable: true,
366
- get: function () { return chunk3G5W2U2L_cjs.InterchangeEdgeSchema; }
367
+ get: function () { return chunkCS6JTQQ2_cjs.InterchangeEdgeSchema; }
367
368
  });
368
369
  Object.defineProperty(exports, "InterchangeIdentityAssertionSchema", {
369
370
  enumerable: true,
370
- get: function () { return chunk3G5W2U2L_cjs.InterchangeIdentityAssertionSchema; }
371
+ get: function () { return chunkCS6JTQQ2_cjs.InterchangeIdentityAssertionSchema; }
371
372
  });
372
373
  Object.defineProperty(exports, "InterchangeIdentitySchema", {
373
374
  enumerable: true,
374
- get: function () { return chunk3G5W2U2L_cjs.InterchangeIdentitySchema; }
375
+ get: function () { return chunkCS6JTQQ2_cjs.InterchangeIdentitySchema; }
375
376
  });
376
377
  Object.defineProperty(exports, "InterchangeNodeSchema", {
377
378
  enumerable: true,
378
- get: function () { return chunk3G5W2U2L_cjs.InterchangeNodeSchema; }
379
+ get: function () { return chunkCS6JTQQ2_cjs.InterchangeNodeSchema; }
379
380
  });
380
381
  Object.defineProperty(exports, "UnknownPropertyStrategySchema", {
381
382
  enumerable: true,
382
- get: function () { return chunk3G5W2U2L_cjs.UnknownPropertyStrategySchema; }
383
+ get: function () { return chunkCS6JTQQ2_cjs.UnknownPropertyStrategySchema; }
383
384
  });
384
385
  Object.defineProperty(exports, "exportGraph", {
385
386
  enumerable: true,
386
- get: function () { return chunk3G5W2U2L_cjs.exportGraph; }
387
+ get: function () { return chunkCS6JTQQ2_cjs.exportGraph; }
387
388
  });
388
389
  Object.defineProperty(exports, "exportGraphStream", {
389
390
  enumerable: true,
390
- get: function () { return chunk3G5W2U2L_cjs.exportGraphStream; }
391
+ get: function () { return chunkCS6JTQQ2_cjs.exportGraphStream; }
391
392
  });
392
393
  Object.defineProperty(exports, "importGraph", {
393
394
  enumerable: true,
394
- get: function () { return chunk3G5W2U2L_cjs.importGraph; }
395
+ get: function () { return chunkCS6JTQQ2_cjs.importGraph; }
395
396
  });
396
397
  Object.defineProperty(exports, "importGraphStream", {
397
398
  enumerable: true,
398
- get: function () { return chunk3G5W2U2L_cjs.importGraphStream; }
399
+ get: function () { return chunkCS6JTQQ2_cjs.importGraphStream; }
399
400
  });
400
401
  exports.trustedImportGraph = trustedImportGraph;
401
402
  exports.trustedImportGraphStream = trustedImportGraphStream;