@nicia-ai/typegraph 0.33.0 → 0.35.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 (284) hide show
  1. package/README.md +20 -0
  2. package/dist/backend/postgres/index.cjs +30 -26
  3. package/dist/backend/postgres/index.d.cts +39 -7
  4. package/dist/backend/postgres/index.d.ts +39 -7
  5. package/dist/backend/postgres/index.js +17 -13
  6. package/dist/backend/postgres/pglite.cjs +22 -18
  7. package/dist/backend/postgres/pglite.cjs.map +1 -1
  8. package/dist/backend/postgres/pglite.d.cts +4 -4
  9. package/dist/backend/postgres/pglite.d.ts +4 -4
  10. package/dist/backend/postgres/pglite.js +17 -13
  11. package/dist/backend/postgres/pglite.js.map +1 -1
  12. package/dist/backend/sqlite/index.cjs +26 -23
  13. package/dist/backend/sqlite/index.d.cts +8 -8
  14. package/dist/backend/sqlite/index.d.ts +8 -8
  15. package/dist/backend/sqlite/index.js +14 -11
  16. package/dist/backend/sqlite/libsql.cjs +21 -17
  17. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  18. package/dist/backend/sqlite/libsql.d.cts +13 -6
  19. package/dist/backend/sqlite/libsql.d.ts +13 -6
  20. package/dist/backend/sqlite/libsql.js +17 -13
  21. package/dist/backend/sqlite/libsql.js.map +1 -1
  22. package/dist/backend/sqlite/local.cjs +102 -18
  23. package/dist/backend/sqlite/local.cjs.map +1 -1
  24. package/dist/backend/sqlite/local.d.cts +95 -5
  25. package/dist/backend/sqlite/local.d.ts +95 -5
  26. package/dist/backend/sqlite/local.js +96 -13
  27. package/dist/backend/sqlite/local.js.map +1 -1
  28. package/dist/{chunk-JHOBXD7O.js → chunk-3TWF3SH4.js} +332 -64
  29. package/dist/chunk-3TWF3SH4.js.map +1 -0
  30. package/dist/chunk-4JEZZJ6S.cjs +1271 -0
  31. package/dist/chunk-4JEZZJ6S.cjs.map +1 -0
  32. package/dist/{chunk-I4W7MKVG.cjs → chunk-4TOD4LBZ.cjs} +249 -294
  33. package/dist/chunk-4TOD4LBZ.cjs.map +1 -0
  34. package/dist/chunk-55MZDDZV.js +239 -0
  35. package/dist/chunk-55MZDDZV.js.map +1 -0
  36. package/dist/{chunk-LM2IC4ZJ.cjs → chunk-5A6FNS6N.cjs} +75 -19
  37. package/dist/chunk-5A6FNS6N.cjs.map +1 -0
  38. package/dist/{chunk-FDN43KXV.cjs → chunk-5AQIKK56.cjs} +65 -24
  39. package/dist/chunk-5AQIKK56.cjs.map +1 -0
  40. package/dist/{chunk-IZ4PCL47.js → chunk-5SEGFTZX.js} +4 -66
  41. package/dist/chunk-5SEGFTZX.js.map +1 -0
  42. package/dist/{chunk-CWFPJ3RC.js → chunk-6FR2MMS6.js} +7 -7
  43. package/dist/chunk-6FR2MMS6.js.map +1 -0
  44. package/dist/chunk-7YSP4V4R.cjs +69 -0
  45. package/dist/chunk-7YSP4V4R.cjs.map +1 -0
  46. package/dist/chunk-A42GCBGX.cjs +28 -0
  47. package/dist/chunk-A42GCBGX.cjs.map +1 -0
  48. package/dist/chunk-ACSVZPK7.cjs +21 -0
  49. package/dist/chunk-ACSVZPK7.cjs.map +1 -0
  50. package/dist/{chunk-OIE2UPVG.cjs → chunk-BLZDPRXT.cjs} +52 -21
  51. package/dist/chunk-BLZDPRXT.cjs.map +1 -0
  52. package/dist/chunk-BYPOGQWK.js +25 -0
  53. package/dist/chunk-BYPOGQWK.js.map +1 -0
  54. package/dist/{chunk-NG5N7R45.cjs → chunk-CK5BVQOW.cjs} +325 -213
  55. package/dist/chunk-CK5BVQOW.cjs.map +1 -0
  56. package/dist/chunk-CTTSDJLY.cjs +261 -0
  57. package/dist/chunk-CTTSDJLY.cjs.map +1 -0
  58. package/dist/chunk-CUHM5CWJ.cjs +12 -0
  59. package/dist/chunk-CUHM5CWJ.cjs.map +1 -0
  60. package/dist/chunk-CZQ3FO2Q.js +2320 -0
  61. package/dist/chunk-CZQ3FO2Q.js.map +1 -0
  62. package/dist/{chunk-CFNT3ITG.cjs → chunk-D7ZEOS56.cjs} +25 -52
  63. package/dist/chunk-D7ZEOS56.cjs.map +1 -0
  64. package/dist/chunk-DFVLCOP6.js +10 -0
  65. package/dist/chunk-DFVLCOP6.js.map +1 -0
  66. package/dist/chunk-DI74SMXS.cjs +29 -0
  67. package/dist/chunk-DI74SMXS.cjs.map +1 -0
  68. package/dist/{chunk-KY5SDVA7.cjs → chunk-EM3CWPND.cjs} +442 -113
  69. package/dist/chunk-EM3CWPND.cjs.map +1 -0
  70. package/dist/chunk-EMF62TZG.cjs +1176 -0
  71. package/dist/chunk-EMF62TZG.cjs.map +1 -0
  72. package/dist/chunk-EOLERH7Y.cjs +40 -0
  73. package/dist/chunk-EOLERH7Y.cjs.map +1 -0
  74. package/dist/{chunk-3QRBXYT5.cjs → chunk-FACJJWGF.cjs} +24 -6
  75. package/dist/chunk-FACJJWGF.cjs.map +1 -0
  76. package/dist/{chunk-KTIEB7VH.cjs → chunk-FL472AMI.cjs} +49 -165
  77. package/dist/chunk-FL472AMI.cjs.map +1 -0
  78. package/dist/{chunk-4RBAJVEC.cjs → chunk-FN35DLCN.cjs} +31 -9
  79. package/dist/chunk-FN35DLCN.cjs.map +1 -0
  80. package/dist/{chunk-C4C4Q7A6.js → chunk-FPIZFYHE.js} +12 -35
  81. package/dist/chunk-FPIZFYHE.js.map +1 -0
  82. package/dist/{chunk-XKNAK27R.js → chunk-FRV5Q5IO.js} +64 -8
  83. package/dist/chunk-FRV5Q5IO.js.map +1 -0
  84. package/dist/{chunk-K5P5OZXS.js → chunk-G6Q5UM7U.js} +2 -2
  85. package/dist/{chunk-K5P5OZXS.js.map → chunk-G6Q5UM7U.js.map} +1 -1
  86. package/dist/chunk-GSQ6NPH6.cjs +100 -0
  87. package/dist/chunk-GSQ6NPH6.cjs.map +1 -0
  88. package/dist/chunk-GUR2FNB5.cjs +12 -0
  89. package/dist/{chunk-6ZR4QC3O.cjs.map → chunk-GUR2FNB5.cjs.map} +1 -1
  90. package/dist/{chunk-ZFWNO3GE.cjs → chunk-H7YNSMA7.cjs} +107 -2
  91. package/dist/chunk-H7YNSMA7.cjs.map +1 -0
  92. package/dist/{chunk-GYVBEZAO.js → chunk-I7ZUZKFD.js} +47 -19
  93. package/dist/chunk-I7ZUZKFD.js.map +1 -0
  94. package/dist/chunk-ITE4IXAK.js +25 -0
  95. package/dist/chunk-ITE4IXAK.js.map +1 -0
  96. package/dist/{chunk-D3EWZ67S.cjs → chunk-J7WFGBJR.cjs} +3372 -4970
  97. package/dist/chunk-J7WFGBJR.cjs.map +1 -0
  98. package/dist/{chunk-PYD3UCDU.js → chunk-JBTOYDMN.js} +202 -251
  99. package/dist/chunk-JBTOYDMN.js.map +1 -0
  100. package/dist/{chunk-XVUJY72M.js → chunk-K3PPLHY7.js} +234 -118
  101. package/dist/chunk-K3PPLHY7.js.map +1 -0
  102. package/dist/{chunk-454I6GDF.js → chunk-KBGQIPRQ.js} +102 -3
  103. package/dist/chunk-KBGQIPRQ.js.map +1 -0
  104. package/dist/chunk-KMI7LYAF.js +1252 -0
  105. package/dist/chunk-KMI7LYAF.js.map +1 -0
  106. package/dist/{chunk-JIEJCTDS.cjs → chunk-LGEALRC6.cjs} +21 -4
  107. package/dist/chunk-LGEALRC6.cjs.map +1 -0
  108. package/dist/{chunk-TQOYM4LN.js → chunk-MP2JQKSG.js} +21 -5
  109. package/dist/chunk-MP2JQKSG.js.map +1 -0
  110. package/dist/{chunk-3642VBVC.cjs → chunk-O7UN7OXA.cjs} +389 -121
  111. package/dist/chunk-O7UN7OXA.cjs.map +1 -0
  112. package/dist/chunk-OHMP6N2J.js +47 -0
  113. package/dist/chunk-OHMP6N2J.js.map +1 -0
  114. package/dist/{chunk-6NRFUHMS.js → chunk-OR5ZA5WP.js} +135 -24
  115. package/dist/chunk-OR5ZA5WP.js.map +1 -0
  116. package/dist/{chunk-PRMKPFN5.js → chunk-Q5TEXCTB.js} +61 -6
  117. package/dist/chunk-Q5TEXCTB.js.map +1 -0
  118. package/dist/chunk-QNKSQTKQ.js +1312 -0
  119. package/dist/chunk-QNKSQTKQ.js.map +1 -0
  120. package/dist/{chunk-YCV72E6L.js → chunk-QOTI55H7.js} +7 -116
  121. package/dist/chunk-QOTI55H7.js.map +1 -0
  122. package/dist/{chunk-QBYTJSAY.js → chunk-QWEUYILR.js} +99 -34
  123. package/dist/chunk-QWEUYILR.js.map +1 -0
  124. package/dist/{chunk-OS6KS3HV.js → chunk-RGP33ZJ5.js} +485 -82
  125. package/dist/chunk-RGP33ZJ5.js.map +1 -0
  126. package/dist/chunk-RGPG7EOJ.js +94 -0
  127. package/dist/chunk-RGPG7EOJ.js.map +1 -0
  128. package/dist/{chunk-WWVV44DY.cjs → chunk-S55OV6PW.cjs} +15 -15
  129. package/dist/chunk-S55OV6PW.cjs.map +1 -0
  130. package/dist/{chunk-3E7SNSIA.cjs → chunk-SJDMVITW.cjs} +4 -4
  131. package/dist/{chunk-3E7SNSIA.cjs.map → chunk-SJDMVITW.cjs.map} +1 -1
  132. package/dist/{chunk-XLUNB2TZ.js → chunk-SNXVDZAJ.js} +3 -3
  133. package/dist/{chunk-XLUNB2TZ.js.map → chunk-SNXVDZAJ.js.map} +1 -1
  134. package/dist/{chunk-CEF2QOTO.js → chunk-T2WUSPDA.js} +49 -8
  135. package/dist/chunk-T2WUSPDA.js.map +1 -0
  136. package/dist/{chunk-YW7GHMF4.cjs → chunk-TCOCYN2P.cjs} +75 -20
  137. package/dist/chunk-TCOCYN2P.cjs.map +1 -0
  138. package/dist/{chunk-FLRCVI2G.cjs → chunk-TDXIBCGY.cjs} +2 -2
  139. package/dist/{chunk-FLRCVI2G.cjs.map → chunk-TDXIBCGY.cjs.map} +1 -1
  140. package/dist/chunk-TEDRJXOG.cjs +32 -0
  141. package/dist/chunk-TEDRJXOG.cjs.map +1 -0
  142. package/dist/{chunk-WLP6TKFB.js → chunk-UES55P7G.js} +2809 -4398
  143. package/dist/chunk-UES55P7G.js.map +1 -0
  144. package/dist/{chunk-EF3Z645U.cjs → chunk-UMDVATGY.cjs} +6 -72
  145. package/dist/chunk-UMDVATGY.cjs.map +1 -0
  146. package/dist/chunk-UR7W5YQK.js +18 -0
  147. package/dist/chunk-UR7W5YQK.js.map +1 -0
  148. package/dist/chunk-UT3S4SEN.js +31 -0
  149. package/dist/chunk-UT3S4SEN.js.map +1 -0
  150. package/dist/{chunk-3IR2GEMJ.cjs → chunk-UUT7UN2N.cjs} +149 -38
  151. package/dist/chunk-UUT7UN2N.cjs.map +1 -0
  152. package/dist/{chunk-PIHXFF73.js → chunk-UZV3AZKF.js} +21 -3
  153. package/dist/chunk-UZV3AZKF.js.map +1 -0
  154. package/dist/{chunk-DJYRRDHA.js → chunk-VHMPG6UL.js} +29 -7
  155. package/dist/chunk-VHMPG6UL.js.map +1 -0
  156. package/dist/{chunk-MBLXCV2Y.cjs → chunk-VPYHY3LJ.cjs} +111 -43
  157. package/dist/chunk-VPYHY3LJ.cjs.map +1 -0
  158. package/dist/{chunk-WYTUF3QO.js → chunk-VSPCZAXF.js} +3 -3
  159. package/dist/{chunk-WYTUF3QO.js.map → chunk-VSPCZAXF.js.map} +1 -1
  160. package/dist/chunk-W63OVYY4.js +29 -0
  161. package/dist/chunk-W63OVYY4.js.map +1 -0
  162. package/dist/{chunk-UPDMJEW6.js → chunk-WDBCBWC4.js} +356 -30
  163. package/dist/chunk-WDBCBWC4.js.map +1 -0
  164. package/dist/chunk-WJT7OU7E.cjs +1334 -0
  165. package/dist/chunk-WJT7OU7E.cjs.map +1 -0
  166. package/dist/chunk-XOX22WHL.cjs +2383 -0
  167. package/dist/chunk-XOX22WHL.cjs.map +1 -0
  168. package/dist/{ddl-CVnHJcar.d.ts → ddl-C2rZ-Aen.d.ts} +4 -4
  169. package/dist/{ddl-Dxt_fBHr.d.cts → ddl-CZz7a0E8.d.cts} +4 -4
  170. package/dist/{extension-types-YGFJPrzK.d.cts → extension-types-ixRpJVUp.d.cts} +24 -1
  171. package/dist/{extension-types-YGFJPrzK.d.ts → extension-types-ixRpJVUp.d.ts} +24 -1
  172. package/dist/{types-DGylBhWo.d.ts → fulltext-strategy-B57yvC5Q.d.ts} +2558 -2125
  173. package/dist/{types-C_UnQOQp.d.cts → fulltext-strategy-CDkSSYhq.d.cts} +2558 -2125
  174. package/dist/graph-extension/index.cjs +21 -19
  175. package/dist/graph-extension/index.d.cts +4 -4
  176. package/dist/graph-extension/index.d.ts +4 -4
  177. package/dist/graph-extension/index.js +6 -4
  178. package/dist/graph-merge/index.cjs +408 -169
  179. package/dist/graph-merge/index.cjs.map +1 -1
  180. package/dist/graph-merge/index.d.cts +63 -33
  181. package/dist/graph-merge/index.d.ts +63 -33
  182. package/dist/graph-merge/index.js +286 -47
  183. package/dist/graph-merge/index.js.map +1 -1
  184. package/dist/{index-DGX6D9j1.d.ts → index-6CSUAq-x.d.ts} +234 -93
  185. package/dist/{index-SEvUHDA6.d.cts → index-Bks_3HHK.d.cts} +234 -93
  186. package/dist/index.cjs +240 -211
  187. package/dist/index.cjs.map +1 -1
  188. package/dist/index.d.cts +11 -11
  189. package/dist/index.d.ts +11 -11
  190. package/dist/index.js +35 -27
  191. package/dist/index.js.map +1 -1
  192. package/dist/indexes/index.cjs +28 -27
  193. package/dist/indexes/index.d.cts +5 -5
  194. package/dist/indexes/index.d.ts +5 -5
  195. package/dist/indexes/index.js +10 -9
  196. package/dist/interchange/index.cjs +47 -17
  197. package/dist/interchange/index.d.cts +126 -12
  198. package/dist/interchange/index.d.ts +126 -12
  199. package/dist/interchange/index.js +14 -4
  200. package/dist/{manager-BYl_zyZR.d.cts → manager-DwQi8eV0.d.cts} +9 -2
  201. package/dist/{manager-C0_r0ALf.d.ts → manager-ejUCB52T.d.ts} +9 -2
  202. package/dist/{materialize-indexes-D20xNluI.d.cts → materialize-indexes-B4e9360H.d.cts} +20 -4
  203. package/dist/{materialize-indexes-CAkIYFV-.d.ts → materialize-indexes-te9TPMMJ.d.ts} +20 -4
  204. package/dist/{postgres-_9psmVGm.d.cts → postgres-CfEqsRMp.d.cts} +152 -1
  205. package/dist/{postgres-MzBPkYzq.d.ts → postgres-DQ5R6rzV.d.ts} +152 -1
  206. package/dist/profiler/index.cjs +11 -11
  207. package/dist/profiler/index.d.cts +7 -7
  208. package/dist/profiler/index.d.ts +7 -7
  209. package/dist/profiler/index.js +4 -4
  210. package/dist/provenance/index.cjs +590 -0
  211. package/dist/provenance/index.cjs.map +1 -0
  212. package/dist/provenance/index.d.cts +73 -0
  213. package/dist/provenance/index.d.ts +73 -0
  214. package/dist/provenance/index.js +588 -0
  215. package/dist/provenance/index.js.map +1 -0
  216. package/dist/schema/index.cjs +55 -38
  217. package/dist/schema/index.cjs.map +1 -1
  218. package/dist/schema/index.d.cts +57 -57
  219. package/dist/schema/index.d.ts +57 -57
  220. package/dist/schema/index.js +30 -13
  221. package/dist/schema/index.js.map +1 -1
  222. package/dist/{sqlite-gm44dShb.d.ts → sqlite-D7zBinNR.d.cts} +92 -1
  223. package/dist/{sqlite-BfksSb45.d.cts → sqlite-DvQndLky.d.ts} +92 -1
  224. package/dist/{store-view-FfE5_7eo.d.ts → store-view-BSpqvAxK.d.cts} +445 -46
  225. package/dist/{store-view-9jQ2rPum.d.cts → store-view-CKbHFRnn.d.ts} +445 -46
  226. package/dist/{types-B6mhrcLv.d.cts → types-Bv9DcS_E.d.cts} +2 -2
  227. package/dist/{types-CdWxK-nD.d.ts → types-CoxuV7EJ.d.ts} +2 -2
  228. package/dist/{where-Bpp2ul_z.d.cts → where-7RKFOsXt.d.ts} +2 -2
  229. package/dist/{where-BsEXraKW.d.ts → where-DdMIXOtH.d.cts} +2 -2
  230. package/package.json +21 -14
  231. package/dist/chunk-2YMGNYXY.js +0 -40
  232. package/dist/chunk-2YMGNYXY.js.map +0 -1
  233. package/dist/chunk-3642VBVC.cjs.map +0 -1
  234. package/dist/chunk-3EUKJEQ3.js +0 -77
  235. package/dist/chunk-3EUKJEQ3.js.map +0 -1
  236. package/dist/chunk-3IR2GEMJ.cjs.map +0 -1
  237. package/dist/chunk-3QRBXYT5.cjs.map +0 -1
  238. package/dist/chunk-454I6GDF.js.map +0 -1
  239. package/dist/chunk-4RBAJVEC.cjs.map +0 -1
  240. package/dist/chunk-6NRFUHMS.js.map +0 -1
  241. package/dist/chunk-6ZR4QC3O.cjs +0 -12
  242. package/dist/chunk-73KASJGO.cjs +0 -52
  243. package/dist/chunk-73KASJGO.cjs.map +0 -1
  244. package/dist/chunk-BF3ZDEUE.cjs +0 -773
  245. package/dist/chunk-BF3ZDEUE.cjs.map +0 -1
  246. package/dist/chunk-C4C4Q7A6.js.map +0 -1
  247. package/dist/chunk-CEF2QOTO.js.map +0 -1
  248. package/dist/chunk-CFNT3ITG.cjs.map +0 -1
  249. package/dist/chunk-CWFPJ3RC.js.map +0 -1
  250. package/dist/chunk-D3EWZ67S.cjs.map +0 -1
  251. package/dist/chunk-DJYRRDHA.js.map +0 -1
  252. package/dist/chunk-EF3Z645U.cjs.map +0 -1
  253. package/dist/chunk-FDN43KXV.cjs.map +0 -1
  254. package/dist/chunk-GYVBEZAO.js.map +0 -1
  255. package/dist/chunk-HTGDWIDE.cjs +0 -89
  256. package/dist/chunk-HTGDWIDE.cjs.map +0 -1
  257. package/dist/chunk-I4W7MKVG.cjs.map +0 -1
  258. package/dist/chunk-IZ4PCL47.js.map +0 -1
  259. package/dist/chunk-JHOBXD7O.js.map +0 -1
  260. package/dist/chunk-JIEJCTDS.cjs.map +0 -1
  261. package/dist/chunk-KTIEB7VH.cjs.map +0 -1
  262. package/dist/chunk-KY5SDVA7.cjs.map +0 -1
  263. package/dist/chunk-LM2IC4ZJ.cjs.map +0 -1
  264. package/dist/chunk-MBLXCV2Y.cjs.map +0 -1
  265. package/dist/chunk-NG5N7R45.cjs.map +0 -1
  266. package/dist/chunk-OIE2UPVG.cjs.map +0 -1
  267. package/dist/chunk-OS6KS3HV.js.map +0 -1
  268. package/dist/chunk-PIHXFF73.js.map +0 -1
  269. package/dist/chunk-PRMKPFN5.js.map +0 -1
  270. package/dist/chunk-PYD3UCDU.js.map +0 -1
  271. package/dist/chunk-QBYTJSAY.js.map +0 -1
  272. package/dist/chunk-SPT5JMME.js +0 -610
  273. package/dist/chunk-SPT5JMME.js.map +0 -1
  274. package/dist/chunk-SST7XDY6.cjs +0 -624
  275. package/dist/chunk-SST7XDY6.cjs.map +0 -1
  276. package/dist/chunk-TQOYM4LN.js.map +0 -1
  277. package/dist/chunk-UPDMJEW6.js.map +0 -1
  278. package/dist/chunk-WLP6TKFB.js.map +0 -1
  279. package/dist/chunk-WWVV44DY.cjs.map +0 -1
  280. package/dist/chunk-XKNAK27R.js.map +0 -1
  281. package/dist/chunk-XVUJY72M.js.map +0 -1
  282. package/dist/chunk-YCV72E6L.js.map +0 -1
  283. package/dist/chunk-YW7GHMF4.cjs.map +0 -1
  284. package/dist/chunk-ZFWNO3GE.cjs.map +0 -1
@@ -1,10 +1,13 @@
1
- import { tables } from './chunk-DJYRRDHA.js';
2
- import { buildPostgresNodeIndexBuilders, buildPostgresEdgeIndexBuilders } from './chunk-CWFPJ3RC.js';
3
- import { formatPostgresTimestamp, createBackendOverlay, nowIso, chunk, isPresent, sqlValueList } from './chunk-PYD3UCDU.js';
4
- import { parseDimensionMismatch, isMissingTableError, sortedReplacer } from './chunk-GYVBEZAO.js';
5
- import { tsvectorStrategy, fts5Strategy, BASE_CONTRIBUTION_OWNER, quotedTableName, quotedColumn, edgeColumnList, sqlNull, nodeColumnList } from './chunk-C4C4Q7A6.js';
6
- import { sha256Hex } from './chunk-2YMGNYXY.js';
7
- import { EmbeddingDimensionChangedError, ConfigurationError, MigrationError, SchemaContentConflictError, DatabaseOperationError, UniquenessError, StoreNotInitializedError, StaleVersionError } from './chunk-TQOYM4LN.js';
1
+ import { tables } from './chunk-VHMPG6UL.js';
2
+ import { buildPostgresNodeIndexBuilders, buildPostgresEdgeIndexBuilders } from './chunk-6FR2MMS6.js';
3
+ import { formatPostgresTimestamp, coerceNumericScore, nowIso } from './chunk-55MZDDZV.js';
4
+ import { sortedReplacer } from './chunk-UR7W5YQK.js';
5
+ import { sha256Hex } from './chunk-W63OVYY4.js';
6
+ import { tsvectorStrategy, fts5Strategy, BASE_CONTRIBUTION_OWNER } from './chunk-FPIZFYHE.js';
7
+ import { createBackendOverlay, chunk, isPresent, sqlValueList } from './chunk-JBTOYDMN.js';
8
+ import { parseDimensionMismatch, isMissingTableError } from './chunk-I7ZUZKFD.js';
9
+ import { liveNodeIdsSubquery, quotedTableName, quotedColumn, codePointOrderKey, edgeColumnList, sqlNull, resolveValidFrom, nodeColumnList } from './chunk-OHMP6N2J.js';
10
+ import { EmbeddingDimensionChangedError, ConfigurationError, MigrationError, SchemaContentConflictError, DatabaseOperationError, UniquenessError, StoreNotInitializedError, StaleVersionError } from './chunk-MP2JQKSG.js';
8
11
  import { sql, is, getTableName } from 'drizzle-orm';
9
12
  import { customType, pgTable, timestamp, integer, jsonb, text, primaryKey, index, boolean, uniqueIndex, getTableConfig as getTableConfig$1, PgTable } from 'drizzle-orm/pg-core';
10
13
  import { getTableConfig, SQLiteTable } from 'drizzle-orm/sqlite-core';
@@ -23,6 +26,7 @@ var DEFAULT_TABLE_NAMES = {
23
26
  recordedNodes: "typegraph_recorded_nodes",
24
27
  recordedEdges: "typegraph_recorded_edges",
25
28
  recordedClock: "typegraph_recorded_clock",
29
+ revisionOrigins: "typegraph_revision_origins",
26
30
  uniques: "typegraph_node_uniques",
27
31
  schemaVersions: "typegraph_schema_versions",
28
32
  fulltext: "typegraph_node_fulltext",
@@ -83,7 +87,13 @@ function createPostgresTables(names = {}, options = {}) {
83
87
  primaryKey({ columns: [t.graphId, t.id] }),
84
88
  index(`${n.edges}_kind_idx`).on(t.graphId, t.kind),
85
89
  // Directional traversal index (outgoing): supports endpoint lookups
86
- // and extra filtering by edge kind / target kind.
90
+ // and extra filtering by edge kind / target kind. Includes every
91
+ // system column the compiled query's soft-delete/temporal-validity
92
+ // predicate touches (deleted_at, valid_from, valid_to), trailed by
93
+ // to_id — the compiled traversal join reads `n.id = e.to_id` for an
94
+ // outgoing traversal (standard-builders.ts), so without to_id here
95
+ // the join still fetches the edge's heap row for that one column
96
+ // even with the seek/predicate columns covered.
87
97
  index(`${n.edges}_from_idx`).on(
88
98
  t.graphId,
89
99
  t.fromKind,
@@ -91,9 +101,13 @@ function createPostgresTables(names = {}, options = {}) {
91
101
  t.kind,
92
102
  t.toKind,
93
103
  t.deletedAt,
94
- t.validTo
104
+ t.validFrom,
105
+ t.validTo,
106
+ t.toId
95
107
  ),
96
- // Directional traversal index (incoming): mirrors from_idx for reverse traversals.
108
+ // Directional traversal index (incoming): mirrors from_idx for
109
+ // reverse traversals, trailed by from_id for the same reason
110
+ // (`n.id = e.from_id` for an incoming traversal).
97
111
  index(`${n.edges}_to_idx`).on(
98
112
  t.graphId,
99
113
  t.toKind,
@@ -101,7 +115,9 @@ function createPostgresTables(names = {}, options = {}) {
101
115
  t.kind,
102
116
  t.fromKind,
103
117
  t.deletedAt,
104
- t.validTo
118
+ t.validFrom,
119
+ t.validTo,
120
+ t.fromId
105
121
  ),
106
122
  index(`${n.edges}_kind_created_idx`).on(
107
123
  t.graphId,
@@ -226,6 +242,14 @@ function createPostgresTables(names = {}, options = {}) {
226
242
  },
227
243
  (t) => [primaryKey({ columns: [t.graphId] })]
228
244
  );
245
+ const revisionOrigins = pgTable(
246
+ n.revisionOrigins,
247
+ {
248
+ graphId: text("graph_id").notNull(),
249
+ origin: text("origin").notNull()
250
+ },
251
+ (t) => [primaryKey({ columns: [t.graphId] })]
252
+ );
229
253
  const uniques2 = pgTable(
230
254
  n.uniques,
231
255
  {
@@ -278,7 +302,14 @@ function createPostgresTables(names = {}, options = {}) {
278
302
  lastAttemptedAt: timestamp("last_attempted_at", {
279
303
  withTimezone: true
280
304
  }).notNull(),
281
- lastError: text("last_error")
305
+ lastError: text("last_error"),
306
+ // Cross-caller build claim: while `building_since` is fresh (within
307
+ // the lease), exactly one materializer owns this index's CREATE
308
+ // INDEX CONCURRENTLY. Serializes same-index CIC across processes —
309
+ // two concurrent expression-index CICs deadlock each other (no
310
+ // safe-snapshot exemption). NULL when no build is in flight.
311
+ buildingSince: timestamp("building_since", { withTimezone: true }),
312
+ claimToken: text("claim_token")
282
313
  },
283
314
  (t) => [primaryKey({ columns: [t.indexName] })]
284
315
  );
@@ -352,6 +383,7 @@ function createPostgresTables(names = {}, options = {}) {
352
383
  recordedNodes: recordedNodes2,
353
384
  recordedEdges: recordedEdges2,
354
385
  recordedClock: recordedClock2,
386
+ revisionOrigins,
355
387
  uniques: uniques2,
356
388
  schemaVersions: schemaVersions2,
357
389
  indexMaterializations,
@@ -428,9 +460,9 @@ function renderIndexColumn(col) {
428
460
  if (col && typeof col === "object" && "name" in col) {
429
461
  return `"${col.name}"`;
430
462
  }
431
- const sql13 = tryInlineSql(col);
432
- if (sql13 !== void 0) {
433
- return sql13;
463
+ const sql14 = tryInlineSql(col);
464
+ if (sql14 !== void 0) {
465
+ return sql14;
434
466
  }
435
467
  return "unknown";
436
468
  }
@@ -686,6 +718,7 @@ function createVectorSlotLatch() {
686
718
  };
687
719
  }
688
720
  var VECTOR_SLOT_PLACEHOLDER_DIMENSIONS = 1;
721
+ var EMBEDDING_UPSERT_PARAM_COUNT = 5;
689
722
  function vectorSlotFromParams(params) {
690
723
  return {
691
724
  graphId: params.graphId,
@@ -1062,6 +1095,109 @@ function buildKindRemovalOnConflictSet(removedAtColumn, paramsRemovedAt) {
1062
1095
  lastError: sql`excluded.${sql.identifier("last_error")}`
1063
1096
  };
1064
1097
  }
1098
+ function nodeIdOrderKey(dialect) {
1099
+ return codePointOrderKey(sql.raw("node_id"), dialect);
1100
+ }
1101
+ function hybridCandidatesRef() {
1102
+ return sql`SELECT node_id FROM tg_hybrid_cand`;
1103
+ }
1104
+ function buildHybridSearchStatement(input) {
1105
+ const { nodes: nodes2 } = input;
1106
+ const nodeIdOrder = nodeIdOrderKey(input.dialect);
1107
+ const vectorOrder = input.vectorScoreDescending ? sql`score DESC, ${nodeIdOrder} ASC` : sql`score ASC, ${nodeIdOrder} ASC`;
1108
+ const columnPairs = [
1109
+ [nodes2.graphId, "graph_id"],
1110
+ [nodes2.kind, "kind"],
1111
+ [nodes2.id, "id"],
1112
+ [nodes2.props, "props"],
1113
+ [nodes2.version, "version"],
1114
+ [nodes2.validFrom, "valid_from"],
1115
+ [nodes2.validTo, "valid_to"],
1116
+ [nodes2.createdAt, "created_at"],
1117
+ [nodes2.updatedAt, "updated_at"],
1118
+ [nodes2.deletedAt, "deleted_at"]
1119
+ ];
1120
+ const nodeColumns = sql.raw(
1121
+ columnPairs.map(
1122
+ ([column, alias]) => `tg_hybrid_node."${column.name.replaceAll('"', '""')}" AS ${alias}`
1123
+ ).join(", ")
1124
+ );
1125
+ return sql`
1126
+ WITH tg_hybrid_cand AS (
1127
+ SELECT node_id FROM (${input.candidatesSql}) AS tg_hybrid_cand_src
1128
+ ),
1129
+ tg_hybrid_vec AS (
1130
+ SELECT node_id, score,
1131
+ ROW_NUMBER() OVER (ORDER BY ${vectorOrder}) AS ord
1132
+ FROM (${input.vectorSql}) AS tg_hybrid_vec_src
1133
+ ),
1134
+ tg_hybrid_fts AS (
1135
+ SELECT node_id, score, snippet,
1136
+ ROW_NUMBER() OVER (ORDER BY score DESC, ${nodeIdOrder} ASC) AS ord
1137
+ FROM (${input.fulltextSql}) AS tg_hybrid_fts_src
1138
+ ),
1139
+ tg_hybrid_pairs AS (
1140
+ SELECT node_id, ord AS vector_rank, score AS vector_score,
1141
+ NULL AS fulltext_rank, NULL AS fulltext_score, NULL AS snippet
1142
+ FROM tg_hybrid_vec
1143
+ UNION ALL
1144
+ SELECT node_id, NULL, NULL, ord, score, snippet
1145
+ FROM tg_hybrid_fts
1146
+ ),
1147
+ tg_hybrid_fused AS MATERIALIZED (
1148
+ SELECT node_id,
1149
+ SUM(
1150
+ COALESCE((${input.vectorWeight} * 1.0) / (${input.fusionK} + vector_rank), 0)
1151
+ + COALESCE((${input.fulltextWeight} * 1.0) / (${input.fusionK} + fulltext_rank), 0)
1152
+ ) AS fused_score,
1153
+ MAX(vector_rank) AS vector_rank,
1154
+ MAX(vector_score) AS vector_score,
1155
+ MAX(fulltext_rank) AS fulltext_rank,
1156
+ MAX(fulltext_score) AS fulltext_score,
1157
+ MAX(snippet) AS snippet
1158
+ FROM tg_hybrid_pairs
1159
+ GROUP BY node_id
1160
+ )
1161
+ SELECT
1162
+ tg_hybrid_fused.node_id AS node_id,
1163
+ tg_hybrid_fused.fused_score AS fused_score,
1164
+ tg_hybrid_fused.vector_rank AS vector_rank,
1165
+ tg_hybrid_fused.vector_score AS vector_score,
1166
+ tg_hybrid_fused.fulltext_rank AS fulltext_rank,
1167
+ tg_hybrid_fused.fulltext_score AS fulltext_score,
1168
+ tg_hybrid_fused.snippet AS snippet,
1169
+ ${nodeColumns}
1170
+ FROM tg_hybrid_fused
1171
+ JOIN ${nodes2} AS tg_hybrid_node
1172
+ ON ${qualified(nodes2, "graphId")} = ${input.graphId}
1173
+ AND ${qualified(nodes2, "kind")} = ${input.nodeKind}
1174
+ AND ${qualified(nodes2, "id")} = tg_hybrid_fused.node_id
1175
+ AND ${qualified(nodes2, "deletedAt")} IS NULL
1176
+ ORDER BY fused_score DESC, ${nodeIdOrder} ASC
1177
+ LIMIT ${input.limit} OFFSET ${input.offset}
1178
+ `;
1179
+ }
1180
+ function qualified(nodes2, member) {
1181
+ return sql`tg_hybrid_node.${quotedColumn(nodes2[member])}`;
1182
+ }
1183
+ function present(value) {
1184
+ return value !== null && value !== void 0;
1185
+ }
1186
+ function mapHybridSearchRow(row, toNodeRow) {
1187
+ return {
1188
+ node: toNodeRow(row),
1189
+ fusedScore: coerceNumericScore(row.fused_score),
1190
+ ...present(row.vector_rank) ? { vectorRank: Number(row.vector_rank) } : {},
1191
+ ...present(row.vector_score) ? { vectorScore: coerceNumericScore(row.vector_score) } : {},
1192
+ ...present(row.fulltext_rank) ? { fulltextRank: Number(row.fulltext_rank) } : {},
1193
+ ...present(row.fulltext_score) ? {
1194
+ fulltextScore: coerceNumericScore(
1195
+ row.fulltext_score
1196
+ )
1197
+ } : {},
1198
+ ...present(row.snippet) ? { snippet: String(row.snippet) } : {}
1199
+ };
1200
+ }
1065
1201
  function buildClearGraph(tables3, graphId) {
1066
1202
  const fulltext2 = quotedTableName(tables3.fulltextTableName);
1067
1203
  return [
@@ -1251,7 +1387,7 @@ function buildInsertEdge(tables3, params, timestamp2) {
1251
1387
  VALUES (
1252
1388
  ${params.graphId}, ${params.id}, ${params.kind},
1253
1389
  ${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
1254
- ${propsJson}, ${sqlNull(params.validFrom)}, ${sqlNull(params.validTo)},
1390
+ ${propsJson}, ${sqlNull(resolveValidFrom(params.validFrom, timestamp2))}, ${sqlNull(params.validTo)},
1255
1391
  ${timestamp2}, ${timestamp2}
1256
1392
  )
1257
1393
  RETURNING *
@@ -1266,7 +1402,7 @@ function buildInsertEdgeNoReturn(tables3, params, timestamp2) {
1266
1402
  VALUES (
1267
1403
  ${params.graphId}, ${params.id}, ${params.kind},
1268
1404
  ${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
1269
- ${propsJson}, ${sqlNull(params.validFrom)}, ${sqlNull(params.validTo)},
1405
+ ${propsJson}, ${sqlNull(resolveValidFrom(params.validFrom, timestamp2))}, ${sqlNull(params.validTo)},
1270
1406
  ${timestamp2}, ${timestamp2}
1271
1407
  )
1272
1408
  `;
@@ -1276,7 +1412,7 @@ function buildInsertEdgesBatch(tables3, params, timestamp2) {
1276
1412
  const columns = edgeColumnList(edges2);
1277
1413
  const values = params.map((edgeParams) => {
1278
1414
  const propsJson = JSON.stringify(edgeParams.props);
1279
- return sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${sqlNull(edgeParams.validFrom)}, ${sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
1415
+ return sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${sqlNull(resolveValidFrom(edgeParams.validFrom, timestamp2))}, ${sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
1280
1416
  });
1281
1417
  return sql`
1282
1418
  INSERT INTO ${edges2} (${columns})
@@ -1288,7 +1424,7 @@ function buildInsertEdgesBatchReturning(tables3, params, timestamp2) {
1288
1424
  const columns = edgeColumnList(edges2);
1289
1425
  const values = params.map((edgeParams) => {
1290
1426
  const propsJson = JSON.stringify(edgeParams.props);
1291
- return sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${sqlNull(edgeParams.validFrom)}, ${sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
1427
+ return sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${sqlNull(resolveValidFrom(edgeParams.validFrom, timestamp2))}, ${sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
1292
1428
  });
1293
1429
  return sql`
1294
1430
  INSERT INTO ${edges2} (${columns})
@@ -1354,6 +1490,24 @@ function buildDeleteEdge(tables3, params, timestamp2) {
1354
1490
  AND ${edges2.deletedAt} IS NULL
1355
1491
  `;
1356
1492
  }
1493
+ function buildDeleteEdgesBatch(tables3, params, timestamp2) {
1494
+ const { edges: edges2 } = tables3;
1495
+ return sql`
1496
+ UPDATE ${edges2}
1497
+ SET ${quotedColumn(edges2.deletedAt)} = ${timestamp2}
1498
+ WHERE ${edges2.graphId} = ${params.graphId}
1499
+ AND ${edges2.id} IN (${sqlValueList(params.ids)})
1500
+ AND ${edges2.deletedAt} IS NULL
1501
+ `;
1502
+ }
1503
+ function buildHardDeleteEdgesBatch(tables3, params) {
1504
+ const { edges: edges2 } = tables3;
1505
+ return sql`
1506
+ DELETE FROM ${edges2}
1507
+ WHERE ${edges2.graphId} = ${params.graphId}
1508
+ AND ${edges2.id} IN (${sqlValueList(params.ids)})
1509
+ `;
1510
+ }
1357
1511
  function buildHardDeleteEdge(tables3, params) {
1358
1512
  const { edges: edges2 } = tables3;
1359
1513
  return sql`
@@ -1432,7 +1586,7 @@ function buildFindEdgesConnectedTo(tables3, params) {
1432
1586
  function resolveMode(mode) {
1433
1587
  return mode ?? "websearch";
1434
1588
  }
1435
- function buildFulltextSearch(tableName, params, strategy) {
1589
+ function buildFulltextSearch(tableName, params, strategy, dialect, candidates) {
1436
1590
  assertValidSearchParams(params);
1437
1591
  const mode = resolveMode(params.mode);
1438
1592
  const table = quotedTableName(tableName);
@@ -1456,12 +1610,16 @@ function buildFulltextSearch(tableName, params, strategy) {
1456
1610
  if (params.minScore !== void 0) {
1457
1611
  conditions.push(sql`${rankExpression} >= ${params.minScore}`);
1458
1612
  }
1613
+ if (candidates !== void 0) {
1614
+ conditions.push(sql`"node_id" IN (${candidates})`);
1615
+ }
1459
1616
  const snippetExpr = params.includeSnippets === true && strategy.supportsSnippets ? strategy.snippetExpression(
1460
1617
  tableName,
1461
1618
  params.query,
1462
1619
  mode,
1463
1620
  params.language
1464
1621
  ) : sql`NULL`;
1622
+ const pageClause = params.offset === void 0 || params.offset === 0 ? sql`LIMIT ${params.limit}` : sql`LIMIT ${params.limit} OFFSET ${params.offset}`;
1465
1623
  return sql`
1466
1624
  SELECT
1467
1625
  "node_id" AS node_id,
@@ -1469,8 +1627,8 @@ function buildFulltextSearch(tableName, params, strategy) {
1469
1627
  ${snippetExpr} AS snippet
1470
1628
  FROM ${table}
1471
1629
  WHERE ${sql.join(conditions, sql` AND `)}
1472
- ORDER BY ${rankExpression} DESC, "node_id" ASC
1473
- LIMIT ${params.limit}
1630
+ ORDER BY ${rankExpression} DESC, ${codePointOrderKey(sql.raw('"node_id"'), dialect)} ASC
1631
+ ${pageClause}
1474
1632
  `;
1475
1633
  }
1476
1634
  function assertValidSearchParams(params) {
@@ -1491,7 +1649,7 @@ function buildInsertNode(tables3, params, timestamp2) {
1491
1649
  INSERT INTO ${nodes2} (${columns})
1492
1650
  VALUES (
1493
1651
  ${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
1494
- 1, ${sqlNull(params.validFrom)}, ${sqlNull(params.validTo)},
1652
+ 1, ${sqlNull(resolveValidFrom(params.validFrom, timestamp2))}, ${sqlNull(params.validTo)},
1495
1653
  ${timestamp2}, ${timestamp2}
1496
1654
  )
1497
1655
  RETURNING *
@@ -1505,7 +1663,7 @@ function buildInsertNodeNoReturn(tables3, params, timestamp2) {
1505
1663
  INSERT INTO ${nodes2} (${columns})
1506
1664
  VALUES (
1507
1665
  ${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
1508
- 1, ${sqlNull(params.validFrom)}, ${sqlNull(params.validTo)},
1666
+ 1, ${sqlNull(resolveValidFrom(params.validFrom, timestamp2))}, ${sqlNull(params.validTo)},
1509
1667
  ${timestamp2}, ${timestamp2}
1510
1668
  )
1511
1669
  `;
@@ -1515,7 +1673,7 @@ function buildInsertNodesBatch(tables3, params, timestamp2) {
1515
1673
  const columns = nodeColumnList(nodes2);
1516
1674
  const values = params.map((nodeParams) => {
1517
1675
  const propsJson = JSON.stringify(nodeParams.props);
1518
- return sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${sqlNull(nodeParams.validFrom)}, ${sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
1676
+ return sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${sqlNull(resolveValidFrom(nodeParams.validFrom, timestamp2))}, ${sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
1519
1677
  });
1520
1678
  return sql`
1521
1679
  INSERT INTO ${nodes2} (${columns})
@@ -1527,7 +1685,7 @@ function buildInsertNodesBatchReturning(tables3, params, timestamp2) {
1527
1685
  const columns = nodeColumnList(nodes2);
1528
1686
  const values = params.map((nodeParams) => {
1529
1687
  const propsJson = JSON.stringify(nodeParams.props);
1530
- return sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${sqlNull(nodeParams.validFrom)}, ${sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
1688
+ return sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${sqlNull(resolveValidFrom(nodeParams.validFrom, timestamp2))}, ${sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
1531
1689
  });
1532
1690
  return sql`
1533
1691
  INSERT INTO ${nodes2} (${columns})
@@ -1744,6 +1902,50 @@ function buildInsertUnique(tables3, dialect, params) {
1744
1902
  const builder = UNIQUE_INSERT_BUILDERS[dialect];
1745
1903
  return builder(tables3, params);
1746
1904
  }
1905
+ function buildInsertUniqueBatch(tables3, dialect, entries) {
1906
+ const { uniques: uniques2 } = tables3;
1907
+ const columns = sql.raw(
1908
+ `"${uniques2.graphId.name}", "${uniques2.nodeKind.name}", "${uniques2.constraintName.name}", "${uniques2.key.name}", "${uniques2.nodeId.name}", "${uniques2.concreteKind.name}", "${uniques2.deletedAt.name}"`
1909
+ );
1910
+ const conflictColumns = sql.raw(
1911
+ `"${uniques2.graphId.name}", "${uniques2.nodeKind.name}", "${uniques2.constraintName.name}", "${uniques2.key.name}"`
1912
+ );
1913
+ const tableName = getTableName(uniques2);
1914
+ const existingColumn = (column) => dialect === "postgres" ? sql.raw(`"${tableName}"."${column.name}"`) : sql.raw(`"${column.name}"`);
1915
+ const excludedColumn = (column) => sql.raw(`excluded."${column.name}"`);
1916
+ const valueRows = sql.join(
1917
+ entries.map(
1918
+ (params) => sql`(${params.graphId}, ${params.nodeKind}, ${params.constraintName}, ${params.key}, ${params.nodeId}, ${params.concreteKind}, ${sql.raw("NULL")})`
1919
+ ),
1920
+ sql`, `
1921
+ );
1922
+ return sql`
1923
+ INSERT INTO ${uniques2} (${columns})
1924
+ VALUES ${valueRows}
1925
+ ON CONFLICT (${conflictColumns})
1926
+ DO UPDATE SET
1927
+ ${quotedColumn(uniques2.nodeId)} = CASE
1928
+ WHEN ${existingColumn(uniques2.nodeId)} = ${excludedColumn(uniques2.nodeId)} THEN ${excludedColumn(uniques2.nodeId)}
1929
+ WHEN ${existingColumn(uniques2.deletedAt)} IS NOT NULL THEN ${excludedColumn(uniques2.nodeId)}
1930
+ ELSE ${existingColumn(uniques2.nodeId)}
1931
+ END,
1932
+ ${quotedColumn(uniques2.concreteKind)} = CASE
1933
+ WHEN ${existingColumn(uniques2.nodeId)} = ${excludedColumn(uniques2.nodeId)} THEN ${excludedColumn(uniques2.concreteKind)}
1934
+ WHEN ${existingColumn(uniques2.deletedAt)} IS NOT NULL THEN ${excludedColumn(uniques2.concreteKind)}
1935
+ ELSE ${existingColumn(uniques2.concreteKind)}
1936
+ END,
1937
+ ${quotedColumn(uniques2.deletedAt)} = CASE
1938
+ WHEN ${existingColumn(uniques2.nodeId)} = ${excludedColumn(uniques2.nodeId)} THEN NULL
1939
+ WHEN ${existingColumn(uniques2.deletedAt)} IS NOT NULL THEN NULL
1940
+ ELSE ${existingColumn(uniques2.deletedAt)}
1941
+ END
1942
+ RETURNING
1943
+ ${quotedColumn(uniques2.nodeKind)} as node_kind,
1944
+ ${quotedColumn(uniques2.constraintName)} as constraint_name,
1945
+ ${quotedColumn(uniques2.key)} as key,
1946
+ ${quotedColumn(uniques2.nodeId)} as node_id
1947
+ `;
1948
+ }
1747
1949
  function buildDeleteUnique(tables3, params, timestamp2) {
1748
1950
  const { uniques: uniques2 } = tables3;
1749
1951
  return sql`
@@ -1837,7 +2039,9 @@ var COMMON_TABLE_OPERATION_BUILDERS = {
1837
2039
  buildGetEdges,
1838
2040
  buildUpdateEdge,
1839
2041
  buildDeleteEdge,
2042
+ buildDeleteEdgesBatch,
1840
2043
  buildHardDeleteEdge,
2044
+ buildHardDeleteEdgesBatch,
1841
2045
  buildHardDeleteEdgesByNode,
1842
2046
  buildCountEdgesFrom,
1843
2047
  buildEdgeExistsBetween,
@@ -1868,7 +2072,57 @@ function createCommonOperationStrategy(tables3, dialect, fulltextStrategy) {
1868
2072
  }),
1869
2073
  buildUpsertFulltextBatch: (params, timestamp2) => fulltextStrategy.buildBatchUpsert(fulltextTable, params, timestamp2),
1870
2074
  buildDeleteFulltextBatch: (params) => fulltextStrategy.buildBatchDelete(fulltextTable, params),
1871
- buildFulltextSearch: (params) => buildFulltextSearch(fulltextTable, params, fulltextStrategy)
2075
+ buildFulltextSearch: (params) => buildFulltextSearch(
2076
+ fulltextTable,
2077
+ params,
2078
+ fulltextStrategy,
2079
+ dialect,
2080
+ // Store-compiled candidates (predicates + subclass + currency)
2081
+ // take precedence; the live-node default covers direct backend use.
2082
+ params.candidates ?? liveNodeIdsSubquery(tables3.nodes, params.graphId, params.nodeKind, nowIso())
2083
+ ),
2084
+ buildLiveNodeIds: (graphId, nodeKind) => liveNodeIdsSubquery(tables3.nodes, graphId, nodeKind, nowIso()),
2085
+ buildHybridSearch: (params, vectorSql, vectorScoreDescending) => {
2086
+ const candidates = params.candidates ?? liveNodeIdsSubquery(
2087
+ tables3.nodes,
2088
+ params.graphId,
2089
+ params.nodeKind,
2090
+ nowIso()
2091
+ );
2092
+ const fulltextSql = buildFulltextSearch(
2093
+ fulltextTable,
2094
+ {
2095
+ graphId: params.graphId,
2096
+ nodeKind: params.nodeKind,
2097
+ query: params.fulltext.query,
2098
+ limit: params.fulltext.k,
2099
+ ...params.fulltext.mode === void 0 ? {} : { mode: params.fulltext.mode },
2100
+ ...params.fulltext.language === void 0 ? {} : { language: params.fulltext.language },
2101
+ ...params.fulltext.minScore === void 0 ? {} : { minScore: params.fulltext.minScore },
2102
+ ...params.fulltext.includeSnippets === void 0 ? {} : { includeSnippets: params.fulltext.includeSnippets }
2103
+ },
2104
+ fulltextStrategy,
2105
+ dialect,
2106
+ // Reference, not copy: the statement evaluates the shared
2107
+ // tg_hybrid_cand CTE once for both legs.
2108
+ hybridCandidatesRef()
2109
+ );
2110
+ return buildHybridSearchStatement({
2111
+ candidatesSql: candidates,
2112
+ vectorSql,
2113
+ vectorScoreDescending,
2114
+ fulltextSql,
2115
+ nodes: tables3.nodes,
2116
+ dialect,
2117
+ graphId: params.graphId,
2118
+ nodeKind: params.nodeKind,
2119
+ fusionK: params.fusion.k,
2120
+ vectorWeight: params.fusion.vectorWeight,
2121
+ fulltextWeight: params.fusion.fulltextWeight,
2122
+ limit: params.limit,
2123
+ offset: params.offset ?? 0
2124
+ });
2125
+ }
1872
2126
  };
1873
2127
  return {
1874
2128
  ...tableOperations,
@@ -1876,6 +2130,9 @@ function createCommonOperationStrategy(tables3, dialect, fulltextStrategy) {
1876
2130
  buildInsertUnique(params) {
1877
2131
  return buildInsertUnique(tables3, dialect, params);
1878
2132
  },
2133
+ buildInsertUniqueBatch(entries) {
2134
+ return buildInsertUniqueBatch(tables3, dialect, entries);
2135
+ },
1879
2136
  buildGetActiveSchema(graphId) {
1880
2137
  return buildGetActiveSchema(tables3, graphId, dialect);
1881
2138
  },
@@ -2134,6 +2391,28 @@ function createCommonOperationBackend(options) {
2134
2391
  const query = operationStrategy.buildHardDeleteEdge(params);
2135
2392
  await execution.execRun(query);
2136
2393
  },
2394
+ async deleteEdgesBatch(params) {
2395
+ if (params.ids.length === 0) return;
2396
+ const timestamp2 = nowIso2();
2397
+ const softDeleteChunkSize = Math.max(1, batchConfig.getEdgesChunkSize - 1);
2398
+ for (const chunk2 of chunk(params.ids, softDeleteChunkSize)) {
2399
+ const query = operationStrategy.buildDeleteEdgesBatch(
2400
+ { graphId: params.graphId, ids: chunk2 },
2401
+ timestamp2
2402
+ );
2403
+ await execution.execRun(query);
2404
+ }
2405
+ },
2406
+ async hardDeleteEdgesBatch(params) {
2407
+ if (params.ids.length === 0) return;
2408
+ for (const chunk2 of chunk(params.ids, batchConfig.getEdgesChunkSize)) {
2409
+ const query = operationStrategy.buildHardDeleteEdgesBatch({
2410
+ graphId: params.graphId,
2411
+ ids: chunk2
2412
+ });
2413
+ await execution.execRun(query);
2414
+ }
2415
+ },
2137
2416
  async countEdgesFrom(params) {
2138
2417
  const query = operationStrategy.buildCountEdgesFrom(params);
2139
2418
  const row = await execution.execGet(query);
@@ -2182,6 +2461,53 @@ function createCommonOperationBackend(options) {
2182
2461
  });
2183
2462
  }
2184
2463
  },
2464
+ async insertUniqueBatch(entries) {
2465
+ if (entries.length === 0) return;
2466
+ const targetKey = (entry) => `${entry.nodeKind}\0${entry.constraintName}\0${entry.key}`;
2467
+ const byTarget = /* @__PURE__ */ new Map();
2468
+ for (const entry of entries) {
2469
+ const existing = byTarget.get(targetKey(entry));
2470
+ if (existing === void 0) {
2471
+ byTarget.set(targetKey(entry), entry);
2472
+ continue;
2473
+ }
2474
+ if (existing.nodeId !== entry.nodeId) {
2475
+ throw new UniquenessError({
2476
+ constraintName: entry.constraintName,
2477
+ kind: entry.nodeKind,
2478
+ existingId: existing.nodeId,
2479
+ newId: entry.nodeId,
2480
+ fields: []
2481
+ });
2482
+ }
2483
+ }
2484
+ const deduped = [...byTarget.values()];
2485
+ for (const chunk2 of chunk(
2486
+ deduped,
2487
+ batchConfig.uniqueInsertBatchSize
2488
+ )) {
2489
+ const query = operationStrategy.buildInsertUniqueBatch(chunk2);
2490
+ const rows = await execution.execAll(query);
2491
+ const ownerByTarget = new Map(
2492
+ rows.map((row) => [
2493
+ `${row.node_kind}\0${row.constraint_name}\0${row.key}`,
2494
+ row.node_id
2495
+ ])
2496
+ );
2497
+ for (const entry of chunk2) {
2498
+ const owner = ownerByTarget.get(targetKey(entry));
2499
+ if (owner !== void 0 && owner !== entry.nodeId) {
2500
+ throw new UniquenessError({
2501
+ constraintName: entry.constraintName,
2502
+ kind: entry.nodeKind,
2503
+ existingId: owner,
2504
+ newId: entry.nodeId,
2505
+ fields: []
2506
+ });
2507
+ }
2508
+ }
2509
+ }
2510
+ },
2185
2511
  async deleteUnique(params) {
2186
2512
  const timestamp2 = nowIso2();
2187
2513
  const query = operationStrategy.buildDeleteUnique(params, timestamp2);
@@ -2344,6 +2670,6 @@ function compileQueryWithDialect(db, query, backendName) {
2344
2670
  return compiler.sqlToQuery(query);
2345
2671
  }
2346
2672
 
2347
- export { POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS, POSTGRES_INDEX_MAT_TIMESTAMPS, POSTGRES_KIND_REMOVAL_TIMESTAMPS, SQLITE_CONTRIBUTION_MAT_TIMESTAMPS, SQLITE_INDEX_MAT_TIMESTAMPS, SQLITE_KIND_REMOVAL_TIMESTAMPS, assertAdoptedDialect, buildContributionInsertValues, buildContributionOnConflictSet, buildKindRemovalInsertValues, buildKindRemovalOnConflictSet, buildMaterializationInsertValues, buildMaterializationOnConflictSet, compileQueryWithDialect, createCachedTableExistence, createCommonOperationBackend, createContributionMaterializer, createPostgresOperationStrategy, createPostgresTables, createSqliteOperationStrategy, createVectorSlotLatch, edges, fulltext, gateFulltext, gateFulltextMethods, generatePgCreateTableSQL, generatePostgresDDL, generatePostgresMigrationSQL, generateSqliteCreateTableSQL, generateSqliteDDL, generateSqliteMigrationSQL, getOrCreateLru, mapContributionMaterializationRow, mapKindRemovalRow, mapMaterializationRow, mapVectorWriteError, nodes, recordedClock, recordedEdges, recordedNodes, schemaVersions, tables2 as tables, uniques, vectorSlotFromCreateIndexParams, vectorSlotFromDropIndexParams, vectorSlotFromParams };
2348
- //# sourceMappingURL=chunk-UPDMJEW6.js.map
2349
- //# sourceMappingURL=chunk-UPDMJEW6.js.map
2673
+ export { EMBEDDING_UPSERT_PARAM_COUNT, POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS, POSTGRES_INDEX_MAT_TIMESTAMPS, POSTGRES_KIND_REMOVAL_TIMESTAMPS, SQLITE_CONTRIBUTION_MAT_TIMESTAMPS, SQLITE_INDEX_MAT_TIMESTAMPS, SQLITE_KIND_REMOVAL_TIMESTAMPS, assertAdoptedDialect, buildContributionInsertValues, buildContributionOnConflictSet, buildKindRemovalInsertValues, buildKindRemovalOnConflictSet, buildMaterializationInsertValues, buildMaterializationOnConflictSet, compileQueryWithDialect, createCachedTableExistence, createCommonOperationBackend, createContributionMaterializer, createPostgresOperationStrategy, createPostgresTables, createSqliteOperationStrategy, createVectorSlotLatch, edges, fulltext, gateFulltext, gateFulltextMethods, generatePgCreateTableSQL, generatePostgresDDL, generatePostgresMigrationSQL, generateSqliteCreateTableSQL, generateSqliteDDL, generateSqliteMigrationSQL, getOrCreateLru, hybridCandidatesRef, mapContributionMaterializationRow, mapHybridSearchRow, mapKindRemovalRow, mapMaterializationRow, mapVectorWriteError, nodes, recordedClock, recordedEdges, recordedNodes, schemaVersions, tables2 as tables, uniques, vectorSlotFromCreateIndexParams, vectorSlotFromDropIndexParams, vectorSlotFromParams };
2674
+ //# sourceMappingURL=chunk-WDBCBWC4.js.map
2675
+ //# sourceMappingURL=chunk-WDBCBWC4.js.map