@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,11 @@
1
- import { pgvectorStrategy, assertPgvectorEfSearch } from './chunk-PRMKPFN5.js';
2
- import { quoteIdentifier } from './chunk-3EUKJEQ3.js';
3
- import { tables, createVectorSlotLatch, createPostgresOperationStrategy, createCachedTableExistence, createContributionMaterializer, gateFulltextMethods, createCommonOperationBackend, generatePgCreateTableSQL, mapContributionMaterializationRow, POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS, buildContributionInsertValues, buildContributionOnConflictSet, assertAdoptedDialect, buildKindRemovalInsertValues, POSTGRES_KIND_REMOVAL_TIMESTAMPS, buildKindRemovalOnConflictSet, mapKindRemovalRow, buildMaterializationInsertValues, POSTGRES_INDEX_MAT_TIMESTAMPS, buildMaterializationOnConflictSet, mapMaterializationRow, generatePostgresDDL, vectorSlotFromParams, mapVectorWriteError, vectorSlotFromDropIndexParams, vectorSlotFromCreateIndexParams, gateFulltext, compileQueryWithDialect, getOrCreateLru } from './chunk-UPDMJEW6.js';
4
- import { createNodeRowMapper, POSTGRES_ROW_MAPPER_CONFIG, createEdgeRowMapper, createUniqueRowMapper, createSchemaVersionRowMapper, nowIso, POSTGRES_CAPABILITIES, coerceNumericScore, POSTGRES_MAX_BIND_PARAMETERS } from './chunk-PYD3UCDU.js';
5
- import { isMissingTableError } from './chunk-GYVBEZAO.js';
6
- import { tsvectorStrategy, buildFulltextCapabilities, buildVectorCapabilities, assertVectorSearchLimit } from './chunk-C4C4Q7A6.js';
7
- import { ConfigurationError } from './chunk-TQOYM4LN.js';
1
+ import { tables, createVectorSlotLatch, createPostgresOperationStrategy, createCachedTableExistence, createContributionMaterializer, gateFulltextMethods, EMBEDDING_UPSERT_PARAM_COUNT, createCommonOperationBackend, vectorSlotFromParams, hybridCandidatesRef, mapVectorWriteError, mapHybridSearchRow, generatePgCreateTableSQL, mapContributionMaterializationRow, POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS, buildContributionInsertValues, buildContributionOnConflictSet, assertAdoptedDialect, buildKindRemovalInsertValues, POSTGRES_KIND_REMOVAL_TIMESTAMPS, buildKindRemovalOnConflictSet, mapKindRemovalRow, buildMaterializationInsertValues, POSTGRES_INDEX_MAT_TIMESTAMPS, buildMaterializationOnConflictSet, mapMaterializationRow, generatePostgresDDL, vectorSlotFromDropIndexParams, vectorSlotFromCreateIndexParams, gateFulltext, compileQueryWithDialect, getOrCreateLru } from './chunk-WDBCBWC4.js';
2
+ import { pgvectorStrategy, assertPgvectorEfSearch } from './chunk-Q5TEXCTB.js';
3
+ import { createNodeRowMapper, POSTGRES_ROW_MAPPER_CONFIG, createEdgeRowMapper, createUniqueRowMapper, createSchemaVersionRowMapper, quoteIdentifier, nowIso, coerceNumericScore } from './chunk-55MZDDZV.js';
4
+ import { tsvectorStrategy, assertVectorSearchLimit, buildFulltextCapabilities, buildVectorCapabilities } from './chunk-FPIZFYHE.js';
5
+ import { shouldForceCustomPlan, annIndexScanTypes } from './chunk-UT3S4SEN.js';
6
+ import { POSTGRES_MAX_BIND_PARAMETERS, POSTGRES_CAPABILITIES, chunk } from './chunk-JBTOYDMN.js';
7
+ import { isMissingTableError, isInsufficientResourcesError } from './chunk-I7ZUZKFD.js';
8
+ import { ConfigurationError, CompilerInvariantError, TransactionClosedError } from './chunk-MP2JQKSG.js';
8
9
  import { getTableName, sql, and, eq, isNull, inArray } from 'drizzle-orm';
9
10
  import { PgDatabase, PgTransaction } from 'drizzle-orm/pg-core';
10
11
 
@@ -72,21 +73,32 @@ function wrapNodePgClient(client, cacheMax) {
72
73
  values: params
73
74
  });
74
75
  return { rows: normalizeRows(result.rows) };
76
+ },
77
+ async queryUnnamed(sqlText, params) {
78
+ const result = await client.query(sqlText, params);
79
+ return { rows: normalizeRows(result.rows) };
75
80
  }
76
81
  };
77
82
  }
78
83
  function wrapNodePgClientUnnamed(client) {
84
+ async function queryUnnamed(sqlText, params) {
85
+ const result = await client.query(sqlText, params);
86
+ return { rows: normalizeRows(result.rows) };
87
+ }
79
88
  return {
80
- async query(sqlText, params) {
81
- const result = await client.query(sqlText, params);
82
- return { rows: normalizeRows(result.rows) };
83
- }
89
+ query: queryUnnamed,
90
+ queryUnnamed
84
91
  };
85
92
  }
86
93
  function adaptPostgresJsClient(sql2) {
94
+ async function query(sqlText, params) {
95
+ const rows = await sql2.unsafe(sqlText, params);
96
+ return { rows };
97
+ }
87
98
  return {
88
- async query(sqlText, params) {
89
- const rows = await sql2.unsafe(sqlText, params);
99
+ query,
100
+ async queryUnnamed(sqlText, params) {
101
+ const rows = await sql2.unsafe(sqlText, params, { prepare: false });
90
102
  return { rows };
91
103
  }
92
104
  };
@@ -149,6 +161,13 @@ function createPostgresExecutionAdapter(db, options = {}) {
149
161
  compile,
150
162
  async execute(query) {
151
163
  const compiled = compile(query);
164
+ if (shouldForceCustomPlan(query)) {
165
+ const result = await pgQueryClient.queryUnnamed(
166
+ compiled.sql,
167
+ compiled.params
168
+ );
169
+ return result.rows;
170
+ }
152
171
  return executeCompiled(compiled);
153
172
  },
154
173
  executeCompiled,
@@ -158,6 +177,57 @@ function createPostgresExecutionAdapter(db, options = {}) {
158
177
  };
159
178
  }
160
179
 
180
+ // src/backend/drizzle/execution/statement-queue.ts
181
+ function ignoreOutcome() {
182
+ }
183
+ function createStatementQueue() {
184
+ let tail = Promise.resolve();
185
+ let closed = false;
186
+ return {
187
+ enqueue(task) {
188
+ if (closed) return Promise.reject(new TransactionClosedError());
189
+ const result = tail.then(() => task());
190
+ tail = result.then(ignoreOutcome, ignoreOutcome);
191
+ return result;
192
+ },
193
+ async drainAndClose() {
194
+ closed = true;
195
+ await tail;
196
+ }
197
+ };
198
+ }
199
+ function createSerialExecutionAdapter(adapter) {
200
+ const { enqueue, drainAndClose } = createStatementQueue();
201
+ const { executeCompiled, prepare } = adapter;
202
+ return {
203
+ drainAndClose,
204
+ compile(query) {
205
+ return adapter.compile(query);
206
+ },
207
+ execute(query) {
208
+ return enqueue(() => adapter.execute(query));
209
+ },
210
+ runExclusive(critical) {
211
+ return enqueue(() => critical(adapter));
212
+ },
213
+ ...executeCompiled === void 0 ? {} : {
214
+ executeCompiled(compiledQuery) {
215
+ return enqueue(() => executeCompiled(compiledQuery));
216
+ }
217
+ },
218
+ ...prepare === void 0 ? {} : {
219
+ prepare(sqlText) {
220
+ const statement = prepare(sqlText);
221
+ return {
222
+ execute(params) {
223
+ return enqueue(() => statement.execute(params));
224
+ }
225
+ };
226
+ }
227
+ }
228
+ };
229
+ }
230
+
161
231
  // src/backend/drizzle/postgres.ts
162
232
  var NODE_INSERT_PARAM_COUNT = 9;
163
233
  var EDGE_INSERT_PARAM_COUNT = 12;
@@ -177,11 +247,26 @@ var POSTGRES_GET_EDGES_ID_CHUNK_SIZE = Math.max(
177
247
  1,
178
248
  POSTGRES_MAX_BIND_PARAMETERS - 1
179
249
  );
250
+ var FULLTEXT_UPSERT_PARAM_COUNT = 6;
251
+ var FULLTEXT_DELETE_FIXED_PARAM_COUNT = 2;
252
+ var POSTGRES_FULLTEXT_UPSERT_BATCH_SIZE = Math.max(
253
+ 1,
254
+ Math.floor(POSTGRES_MAX_BIND_PARAMETERS / FULLTEXT_UPSERT_PARAM_COUNT)
255
+ );
256
+ var POSTGRES_FULLTEXT_DELETE_CHUNK_SIZE = Math.max(
257
+ 1,
258
+ POSTGRES_MAX_BIND_PARAMETERS - FULLTEXT_DELETE_FIXED_PARAM_COUNT
259
+ );
180
260
  var CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT = 3;
181
261
  var POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE = Math.max(
182
262
  1,
183
263
  POSTGRES_MAX_BIND_PARAMETERS - CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT
184
264
  );
265
+ var UNIQUE_INSERT_PARAM_COUNT = 6;
266
+ var POSTGRES_UNIQUE_INSERT_BATCH_SIZE = Math.max(
267
+ 1,
268
+ Math.floor(POSTGRES_MAX_BIND_PARAMETERS / UNIQUE_INSERT_PARAM_COUNT)
269
+ );
185
270
  var toNodeRow = createNodeRowMapper(POSTGRES_ROW_MAPPER_CONFIG);
186
271
  var toEdgeRow = createEdgeRowMapper(POSTGRES_ROW_MAPPER_CONFIG);
187
272
  var toUniqueRow = createUniqueRowMapper(POSTGRES_ROW_MAPPER_CONFIG);
@@ -200,6 +285,7 @@ function createPostgresBackend(db, options = {}) {
200
285
  const fulltextStrategy = options.fulltext ?? tsvectorStrategy;
201
286
  const vectorStrategy = options.vector === false ? void 0 : options.vector ?? pgvectorStrategy;
202
287
  const vectorSlotLatch = vectorStrategy === void 0 ? void 0 : createVectorSlotLatch();
288
+ const iterativeScanProbe = createIterativeScanProbe();
203
289
  const baseCapabilities = buildPostgresCapabilities(
204
290
  fulltextStrategy,
205
291
  vectorStrategy
@@ -221,18 +307,16 @@ function createPostgresBackend(db, options = {}) {
221
307
  recordedNodes: getTableName(tables2.recordedNodes),
222
308
  recordedEdges: getTableName(tables2.recordedEdges),
223
309
  recordedClock: getTableName(tables2.recordedClock),
310
+ revisionOrigins: getTableName(tables2.revisionOrigins),
224
311
  fulltext: tables2.fulltextTableName,
225
312
  uniques: getTableName(tables2.uniques)
226
313
  };
227
- const coreAnalyzeStatement = sql`ANALYZE ${sql.join(
228
- [
229
- tableNames.nodes,
230
- tableNames.edges,
231
- getTableName(tables2.uniques),
232
- tableNames.fulltext
233
- ].map((name) => quoteIdentifier(name)),
234
- sql`, `
235
- )}`;
314
+ const coreAnalyzeStatements = [
315
+ tableNames.nodes,
316
+ tableNames.edges,
317
+ getTableName(tables2.uniques),
318
+ tableNames.fulltext
319
+ ].map((name) => sql`ANALYZE (SKIP_LOCKED) ${quoteIdentifier(name)}`);
236
320
  const recordedAnalyzeTables = [
237
321
  tableNames.recordedNodes,
238
322
  tableNames.recordedEdges,
@@ -251,7 +335,8 @@ function createPostgresBackend(db, options = {}) {
251
335
  capabilities,
252
336
  fulltextStrategy,
253
337
  vectorStrategy,
254
- vectorSlotLatch
338
+ vectorSlotLatch,
339
+ iterativeScanProbe
255
340
  });
256
341
  const recordedTableExists = createCachedTableExistence(
257
342
  async (tableName) => {
@@ -275,15 +360,21 @@ function createPostgresBackend(db, options = {}) {
275
360
  }
276
361
  return db.transaction(async (tx) => {
277
362
  await tx.execute(sql`SELECT pg_advisory_xact_lock(hashtext(${graphId}))`);
278
- const txBackend = createTransactionBackend({
363
+ const { backend: txBackend, drainAndClose } = createTransactionBackend({
279
364
  db: tx,
280
365
  adapterOptions,
281
366
  operationStrategy,
282
367
  tableNames,
283
368
  capabilities,
284
369
  fulltextStrategy,
285
- vectorStrategy});
286
- return fn(txBackend);
370
+ vectorStrategy,
371
+ iterativeScanProbe
372
+ });
373
+ try {
374
+ return await fn(txBackend);
375
+ } finally {
376
+ await drainAndClose();
377
+ }
287
378
  });
288
379
  }
289
380
  const matTable = tables2.contributionMaterializations;
@@ -337,15 +428,23 @@ function createPostgresBackend(db, options = {}) {
337
428
  recordMarker: recordContributionMaterializationRow
338
429
  });
339
430
  function bindTransactionBackend(tx) {
340
- const txBackend = createTransactionBackend({
431
+ const { backend: backend2, drainAndClose } = createTransactionBackend({
341
432
  db: tx,
342
433
  adapterOptions,
343
434
  operationStrategy,
344
435
  tableNames,
345
436
  capabilities,
346
437
  fulltextStrategy,
347
- vectorStrategy});
348
- return gateFulltext(txBackend, contributionMaterializer.assertInitialized);
438
+ vectorStrategy,
439
+ iterativeScanProbe
440
+ });
441
+ return {
442
+ backend: gateFulltext(
443
+ backend2,
444
+ contributionMaterializer.assertInitialized
445
+ ),
446
+ drainAndClose
447
+ };
349
448
  }
350
449
  const backend = {
351
450
  ...operations,
@@ -355,6 +454,11 @@ function createPostgresBackend(db, options = {}) {
355
454
  await db.execute(sql.raw(statement));
356
455
  }
357
456
  },
457
+ async ensureRevisionOriginsTable() {
458
+ await db.execute(
459
+ sql.raw(generatePgCreateTableSQL(tables2.revisionOrigins))
460
+ );
461
+ },
358
462
  // Every fulltext-touching method asserts the durable marker instead
359
463
  // of lazily emitting DDL. Steady state performs zero ensure; an
360
464
  // uninitialized database throws `StoreNotInitializedError` loudly
@@ -371,6 +475,50 @@ function createPostgresBackend(db, options = {}) {
371
475
  await db.execute(
372
476
  sql.raw(generatePgCreateTableSQL(tables2.indexMaterializations))
373
477
  );
478
+ const tableName = getTableName(tables2.indexMaterializations);
479
+ await db.execute(
480
+ sql.raw(
481
+ `ALTER TABLE "${tableName}" ADD COLUMN IF NOT EXISTS "building_since" timestamptz;`
482
+ )
483
+ );
484
+ await db.execute(
485
+ sql.raw(
486
+ `ALTER TABLE "${tableName}" ADD COLUMN IF NOT EXISTS "claim_token" text;`
487
+ )
488
+ );
489
+ },
490
+ async claimIndexMaterialization(params) {
491
+ const t = tables2.indexMaterializations;
492
+ const rows = await db.execute(sql`
493
+ INSERT INTO ${t} (
494
+ "index_name", "graph_id", "entity", "kind", "signature",
495
+ "schema_version", "last_attempted_at", "building_since",
496
+ "claim_token"
497
+ )
498
+ VALUES (
499
+ ${params.indexName}, ${params.graphId}, ${params.entity},
500
+ ${params.kind}, ${params.signature}, ${params.schemaVersion},
501
+ now(), now(), ${params.token}
502
+ )
503
+ ON CONFLICT ("index_name") DO UPDATE SET
504
+ "building_since" = now(),
505
+ "claim_token" = EXCLUDED."claim_token"
506
+ WHERE ${t}."building_since" IS NULL
507
+ OR ${t}."building_since" < now() - (${params.leaseMs} * interval '1 millisecond')
508
+ RETURNING "index_name"
509
+ `);
510
+ const result = rows;
511
+ const returned = Array.isArray(result) ? result : result.rows ?? [];
512
+ return returned.length > 0;
513
+ },
514
+ async releaseIndexMaterializationClaim(params) {
515
+ const t = tables2.indexMaterializations;
516
+ await db.execute(sql`
517
+ UPDATE ${t}
518
+ SET "building_since" = NULL, "claim_token" = NULL
519
+ WHERE "index_name" = ${params.indexName}
520
+ AND "claim_token" = ${params.token}
521
+ `);
374
522
  },
375
523
  async getIndexMaterialization(indexName) {
376
524
  const t = tables2.indexMaterializations;
@@ -472,7 +620,9 @@ function createPostgresBackend(db, options = {}) {
472
620
  });
473
621
  },
474
622
  async refreshStatistics() {
475
- await db.execute(coreAnalyzeStatement);
623
+ for (const statement of coreAnalyzeStatements) {
624
+ await db.execute(statement);
625
+ }
476
626
  const tablePresence = await Promise.all(
477
627
  recordedAnalyzeTables.map(async (tableName) => ({
478
628
  tableName,
@@ -480,12 +630,9 @@ function createPostgresBackend(db, options = {}) {
480
630
  }))
481
631
  );
482
632
  const presentRecordedTables = tablePresence.filter((entry) => entry.exists).map((entry) => entry.tableName);
483
- if (presentRecordedTables.length > 0) {
633
+ for (const tableName of presentRecordedTables) {
484
634
  await db.execute(
485
- sql`ANALYZE ${sql.join(
486
- presentRecordedTables.map((name) => quoteIdentifier(name)),
487
- sql`, `
488
- )}`
635
+ sql`ANALYZE (SKIP_LOCKED) ${quoteIdentifier(tableName)}`
489
636
  );
490
637
  }
491
638
  },
@@ -505,10 +652,14 @@ function createPostgresBackend(db, options = {}) {
505
652
  const txConfig = options2?.isolationLevel ? {
506
653
  isolationLevel: options2.isolationLevel.replace("_", " ")
507
654
  } : void 0;
508
- return db.transaction(
509
- async (tx) => fn(bindTransactionBackend(tx), tx),
510
- txConfig
511
- );
655
+ return db.transaction(async (tx) => {
656
+ const { backend: txBackend, drainAndClose } = bindTransactionBackend(tx);
657
+ try {
658
+ return await fn(txBackend, tx);
659
+ } finally {
660
+ await drainAndClose();
661
+ }
662
+ }, txConfig);
512
663
  },
513
664
  adoptTransaction(externalTx) {
514
665
  if (!capabilities.transactions) {
@@ -522,13 +673,46 @@ function createPostgresBackend(db, options = {}) {
522
673
  );
523
674
  }
524
675
  assertAdoptedDialect(externalTx, PgDatabase, "postgres");
525
- return bindTransactionBackend(externalTx);
676
+ return bindTransactionBackend(externalTx).backend;
526
677
  },
527
678
  async close() {
528
679
  }
529
680
  };
530
681
  return backend;
531
682
  }
683
+ function createIterativeScanProbe() {
684
+ let probe;
685
+ let warned = false;
686
+ function warnUnavailable(version) {
687
+ if (warned) return;
688
+ warned = true;
689
+ if (typeof console === "undefined" || typeof console.warn !== "function") {
690
+ return;
691
+ }
692
+ console.warn(
693
+ `[typegraph] pgvector ${version} has no iterative scan (added in 0.8), so a filtered approximate vector search stays ef_search-bounded and can return fewer rows than \`limit\` while more matches exist. Upgrade pgvector to >= 0.8, or use an exact search (\`approximate: false\`) where a full page matters.`
694
+ );
695
+ }
696
+ return {
697
+ isSupported(execAll) {
698
+ probe ??= (async () => {
699
+ try {
700
+ const [row] = await execAll(
701
+ sql`SELECT extversion AS v FROM pg_extension WHERE extname = 'vector'`
702
+ );
703
+ if (typeof row?.v !== "string") return false;
704
+ const [major = 0, minor = 0] = row.v.split(".").map((part) => Number.parseInt(part, 10));
705
+ const supported = major > 0 || major === 0 && minor >= 8;
706
+ if (!supported) warnUnavailable(row.v);
707
+ return supported;
708
+ } catch {
709
+ return false;
710
+ }
711
+ })();
712
+ return probe;
713
+ }
714
+ };
715
+ }
532
716
  function createPostgresOperationBackend(options) {
533
717
  const {
534
718
  db,
@@ -539,7 +723,8 @@ function createPostgresOperationBackend(options) {
539
723
  capabilities,
540
724
  fulltextStrategy,
541
725
  vectorStrategy,
542
- vectorSlotLatch
726
+ vectorSlotLatch,
727
+ iterativeScanProbe
543
728
  } = options;
544
729
  async function execAll(query) {
545
730
  return executionAdapter.execute(query);
@@ -562,31 +747,75 @@ function createPostgresOperationBackend(options) {
562
747
  "[typegraph] efSearch (hnsw.ef_search override) was ignored: this Postgres backend has transactions disabled (e.g. drizzle-orm/neon-http), and SET LOCAL needs a transaction to scope the override. Use a transactional driver (node-postgres / neon-serverless / postgres-js) to apply efSearch."
563
748
  );
564
749
  }
565
- async function runVectorSearch(efSearch, query) {
566
- if (efSearch === void 0) {
567
- return execAll(query);
750
+ function pgvectorIterativeScanSupported() {
751
+ return iterativeScanProbe.isSupported(execAll);
752
+ }
753
+ async function vectorSearchGucOverrides(params) {
754
+ const overrides = [];
755
+ if (params.efSearch !== void 0) {
756
+ if (capabilities.transactions) {
757
+ overrides.push({
758
+ name: "hnsw.ef_search",
759
+ value: String(params.efSearch)
760
+ });
761
+ } else {
762
+ warnEfSearchUnsupported();
763
+ }
568
764
  }
569
- if (!capabilities.transactions) {
570
- warnEfSearchUnsupported();
571
- return execAll(query);
765
+ if (params.indexType === "hnsw" && capabilities.transactions && await pgvectorIterativeScanSupported()) {
766
+ overrides.push({ name: "hnsw.iterative_scan", value: "strict_order" });
572
767
  }
573
- const setEfSearch = sql.raw(`SET LOCAL hnsw.ef_search = ${efSearch}`);
574
- if (db instanceof PgTransaction) {
575
- const [setting] = await execAll(
576
- sql`SELECT current_setting('hnsw.ef_search') AS ef_search`
768
+ if (params.indexType === "ivfflat" && capabilities.transactions && await pgvectorIterativeScanSupported()) {
769
+ overrides.push({
770
+ name: "ivfflat.iterative_scan",
771
+ value: "relaxed_order"
772
+ });
773
+ }
774
+ return overrides;
775
+ }
776
+ async function runVectorSearchGucGroup(overrides, query) {
777
+ const runExclusive = executionAdapter.runExclusive;
778
+ if (runExclusive === void 0) {
779
+ throw new CompilerInvariantError(
780
+ "A transaction-scoped Postgres backend must expose runExclusive; its execution adapter was not wrapped by createSerialExecutionAdapter."
577
781
  );
578
- await execRun(setEfSearch);
579
- const rows = await execAll(query);
580
- if (setting !== void 0) {
581
- await execRun(
582
- sql`SELECT set_config('hnsw.ef_search', ${setting.ef_search}, true)`
782
+ }
783
+ return runExclusive(async (connection) => {
784
+ const snapshots = [];
785
+ for (const override of overrides) {
786
+ const [setting] = await connection.execute(
787
+ sql`SELECT current_setting(${override.name}) AS v`
788
+ );
789
+ if (setting !== void 0) {
790
+ snapshots.push({ name: override.name, value: setting.v });
791
+ }
792
+ await connection.execute(
793
+ sql`SELECT set_config(${override.name}, ${override.value}, true)`
794
+ );
795
+ }
796
+ const rows = await connection.execute(query);
797
+ for (const snapshot of snapshots) {
798
+ await connection.execute(
799
+ sql`SELECT set_config(${snapshot.name}, ${snapshot.value}, true)`
583
800
  );
584
801
  }
585
802
  return rows;
803
+ });
804
+ }
805
+ async function runVectorSearch(overrides, query) {
806
+ if (overrides.length === 0) {
807
+ return execAll(query);
808
+ }
809
+ if (db instanceof PgTransaction) {
810
+ return runVectorSearchGucGroup(overrides, query);
586
811
  }
587
812
  return db.transaction(async (tx) => {
588
813
  const txAdapter = createPostgresExecutionAdapter(tx, adapterOptions);
589
- await txAdapter.execute(setEfSearch);
814
+ for (const override of overrides) {
815
+ await txAdapter.execute(
816
+ sql`SELECT set_config(${override.name}, ${override.value}, true)`
817
+ );
818
+ }
590
819
  return txAdapter.execute(query);
591
820
  });
592
821
  }
@@ -596,14 +825,25 @@ function createPostgresOperationBackend(options) {
596
825
  await execRun(sql.raw(statement));
597
826
  });
598
827
  }
828
+ const batchConfig = {
829
+ checkUniqueBatchChunkSize: POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE,
830
+ edgeInsertBatchSize: POSTGRES_EDGE_INSERT_BATCH_SIZE,
831
+ // Unlike the static siblings, the embedding upsert honors a runtime
832
+ // `maxBindParameters` override so its chunk size tracks the connection's
833
+ // actual bind budget.
834
+ embeddingUpsertBatchSize: Math.max(
835
+ 1,
836
+ Math.floor(
837
+ (capabilities.maxBindParameters ?? POSTGRES_MAX_BIND_PARAMETERS) / EMBEDDING_UPSERT_PARAM_COUNT
838
+ )
839
+ ),
840
+ getEdgesChunkSize: POSTGRES_GET_EDGES_ID_CHUNK_SIZE,
841
+ getNodesChunkSize: POSTGRES_GET_NODES_ID_CHUNK_SIZE,
842
+ nodeInsertBatchSize: POSTGRES_NODE_INSERT_BATCH_SIZE,
843
+ uniqueInsertBatchSize: POSTGRES_UNIQUE_INSERT_BATCH_SIZE
844
+ };
599
845
  const commonBackend = createCommonOperationBackend({
600
- batchConfig: {
601
- checkUniqueBatchChunkSize: POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE,
602
- edgeInsertBatchSize: POSTGRES_EDGE_INSERT_BATCH_SIZE,
603
- getEdgesChunkSize: POSTGRES_GET_EDGES_ID_CHUNK_SIZE,
604
- getNodesChunkSize: POSTGRES_GET_NODES_ID_CHUNK_SIZE,
605
- nodeInsertBatchSize: POSTGRES_NODE_INSERT_BATCH_SIZE
606
- },
846
+ batchConfig,
607
847
  execution: {
608
848
  execAll,
609
849
  execGet,
@@ -638,6 +878,48 @@ function createPostgresOperationBackend(options) {
638
878
  throw mapVectorWriteError(error, params);
639
879
  }
640
880
  },
881
+ async upsertEmbeddingBatch(params) {
882
+ if (params.rows.length === 0) return;
883
+ const slot = vectorSlotFromParams(params);
884
+ await ensureVectorSlotStorage(slot);
885
+ const rowsById = new Map(
886
+ params.rows.map((row) => [row.nodeId, row])
887
+ );
888
+ const rows = [...rowsById.values()];
889
+ const timestamp = nowIso();
890
+ try {
891
+ for (const chunk2 of chunk(
892
+ rows,
893
+ batchConfig.embeddingUpsertBatchSize
894
+ )) {
895
+ const statements = vectorStrategy.buildUpsertBatch === void 0 ? chunk2.flatMap(
896
+ (row) => vectorStrategy.buildUpsert(
897
+ slot,
898
+ {
899
+ graphId: params.graphId,
900
+ nodeKind: params.nodeKind,
901
+ nodeId: row.nodeId,
902
+ fieldPath: params.fieldPath,
903
+ embedding: row.embedding,
904
+ dimensions: params.dimensions,
905
+ metric: params.metric,
906
+ indexType: params.indexType
907
+ },
908
+ timestamp
909
+ )
910
+ ) : vectorStrategy.buildUpsertBatch(
911
+ slot,
912
+ { ...params, rows: chunk2 },
913
+ timestamp
914
+ );
915
+ for (const statement of statements) {
916
+ await execRun(statement);
917
+ }
918
+ }
919
+ } catch (error) {
920
+ throw mapVectorWriteError(error, params);
921
+ }
922
+ },
641
923
  async deleteEmbedding(params) {
642
924
  const slot = vectorSlotFromParams(params);
643
925
  await ensureVectorSlotStorage(slot);
@@ -651,10 +933,20 @@ function createPostgresOperationBackend(options) {
651
933
  assertPgvectorEfSearch(params.efSearch);
652
934
  const slot = vectorSlotFromParams(params);
653
935
  await ensureVectorSlotStorage(slot);
654
- const query = vectorStrategy.buildSearch(slot, params);
936
+ const query = vectorStrategy.buildSearch(
937
+ slot,
938
+ params,
939
+ // Store-compiled candidates (predicates + subclass + currency)
940
+ // take precedence; the live-node default covers direct backend use.
941
+ params.candidates ?? operationStrategy.buildLiveNodeIds(
942
+ params.graphId,
943
+ params.nodeKind
944
+ )
945
+ );
946
+ const gucOverrides = await vectorSearchGucOverrides(params);
655
947
  let rows;
656
948
  try {
657
- rows = await runVectorSearch(params.efSearch, query);
949
+ rows = await runVectorSearch(gucOverrides, query);
658
950
  } catch (error) {
659
951
  throw mapVectorWriteError(error, params);
660
952
  }
@@ -662,7 +954,65 @@ function createPostgresOperationBackend(options) {
662
954
  nodeId: row.node_id,
663
955
  score: row.score
664
956
  }));
665
- }
957
+ },
958
+ // Single-statement hybrid needs ROW_NUMBER(); a capability
959
+ // profile that disables window functions keeps the store's
960
+ // multi-statement fallback by simply not exposing the member.
961
+ ...capabilities.windowFunctions ? {
962
+ async hybridSearch(params) {
963
+ assertVectorSearchLimit(params.limit);
964
+ assertVectorSearchLimit(params.vector.k);
965
+ assertPgvectorEfSearch(params.vector.efSearch);
966
+ const slot = vectorSlotFromParams({
967
+ graphId: params.graphId,
968
+ nodeKind: params.nodeKind,
969
+ fieldPath: params.vector.fieldPath,
970
+ dimensions: params.vector.dimensions,
971
+ metric: params.vector.metric,
972
+ indexType: params.vector.indexType
973
+ });
974
+ await ensureVectorSlotStorage(slot);
975
+ const candidates = params.candidates ?? operationStrategy.buildLiveNodeIds(
976
+ params.graphId,
977
+ params.nodeKind
978
+ );
979
+ const vectorParams = {
980
+ graphId: params.graphId,
981
+ nodeKind: params.nodeKind,
982
+ fieldPath: params.vector.fieldPath,
983
+ queryEmbedding: params.vector.queryEmbedding,
984
+ metric: params.vector.metric,
985
+ dimensions: params.vector.dimensions,
986
+ indexType: params.vector.indexType,
987
+ limit: params.vector.k,
988
+ ...params.vector.minScore === void 0 ? {} : { minScore: params.vector.minScore }
989
+ };
990
+ const vectorSql = vectorStrategy.buildSearch(
991
+ slot,
992
+ vectorParams,
993
+ hybridCandidatesRef()
994
+ );
995
+ const statement = operationStrategy.buildHybridSearch(
996
+ { ...params, candidates },
997
+ vectorSql,
998
+ params.vector.metric === "cosine"
999
+ );
1000
+ const gucOverrides = await vectorSearchGucOverrides({
1001
+ indexType: params.vector.indexType,
1002
+ ...params.vector.efSearch === void 0 ? {} : { efSearch: params.vector.efSearch }
1003
+ });
1004
+ let raw;
1005
+ try {
1006
+ raw = await runVectorSearch(
1007
+ gucOverrides,
1008
+ statement
1009
+ );
1010
+ } catch (error) {
1011
+ throw mapVectorWriteError(error, vectorParams);
1012
+ }
1013
+ return raw.map((row) => mapHybridSearchRow(row, toNodeRow));
1014
+ }
1015
+ } : {}
666
1016
  };
667
1017
  const operationBackend = {
668
1018
  ...commonBackend,
@@ -682,7 +1032,30 @@ function createPostgresOperationBackend(options) {
682
1032
  concurrent: params.concurrent === true
683
1033
  });
684
1034
  if (indexStatement !== void 0) {
685
- await execRun(indexStatement);
1035
+ try {
1036
+ await execRun(indexStatement);
1037
+ } catch (error) {
1038
+ if (!isInsufficientResourcesError(error)) throw error;
1039
+ const dropStatement = vectorStrategy.buildDropIndex?.(slot);
1040
+ if (dropStatement !== void 0) {
1041
+ await execRun(dropStatement);
1042
+ }
1043
+ const table = quoteIdentifier(
1044
+ vectorStrategy.tableName(
1045
+ slot.graphId,
1046
+ slot.nodeKind,
1047
+ slot.fieldPath
1048
+ )
1049
+ );
1050
+ await execRun(
1051
+ sql`ALTER TABLE ${table} SET (parallel_workers = 0)`
1052
+ );
1053
+ try {
1054
+ await execRun(indexStatement);
1055
+ } finally {
1056
+ await execRun(sql`ALTER TABLE ${table} RESET (parallel_workers)`);
1057
+ }
1058
+ }
686
1059
  }
687
1060
  },
688
1061
  // === Fulltext Operations ===
@@ -705,19 +1078,32 @@ function createPostgresOperationBackend(options) {
705
1078
  async upsertFulltextBatch(params) {
706
1079
  if (params.rows.length === 0) return;
707
1080
  const timestamp = nowIso();
708
- const statements = operationStrategy.buildUpsertFulltextBatch(
709
- params,
710
- timestamp
711
- );
712
- for (const stmt of statements) {
713
- await execRun(stmt);
1081
+ for (const rows of chunk(
1082
+ params.rows,
1083
+ POSTGRES_FULLTEXT_UPSERT_BATCH_SIZE
1084
+ )) {
1085
+ const statements = operationStrategy.buildUpsertFulltextBatch(
1086
+ { ...params, rows },
1087
+ timestamp
1088
+ );
1089
+ for (const stmt of statements) {
1090
+ await execRun(stmt);
1091
+ }
714
1092
  }
715
1093
  },
716
1094
  async deleteFulltextBatch(params) {
717
1095
  if (params.nodeIds.length === 0) return;
718
- const statements = operationStrategy.buildDeleteFulltextBatch(params);
719
- for (const stmt of statements) {
720
- await execRun(stmt);
1096
+ for (const nodeIds of chunk(
1097
+ params.nodeIds,
1098
+ POSTGRES_FULLTEXT_DELETE_CHUNK_SIZE
1099
+ )) {
1100
+ const statements = operationStrategy.buildDeleteFulltextBatch({
1101
+ ...params,
1102
+ nodeIds
1103
+ });
1104
+ for (const stmt of statements) {
1105
+ await execRun(stmt);
1106
+ }
721
1107
  }
722
1108
  },
723
1109
  async fulltextSearch(params) {
@@ -743,6 +1129,17 @@ function createPostgresOperationBackend(options) {
743
1129
  },
744
1130
  // === Query Execution ===
745
1131
  async execute(query) {
1132
+ const annTypes = annIndexScanTypes(query);
1133
+ if (annTypes !== void 0 && vectorStrategy !== void 0) {
1134
+ const overrides = [];
1135
+ for (const indexType of annTypes) {
1136
+ if (indexType !== "hnsw" && indexType !== "ivfflat") continue;
1137
+ overrides.push(
1138
+ ...await vectorSearchGucOverrides({ indexType })
1139
+ );
1140
+ }
1141
+ return runVectorSearch(overrides, query);
1142
+ }
746
1143
  return executionAdapter.execute(query);
747
1144
  },
748
1145
  compileSql(query) {
@@ -752,8 +1149,10 @@ function createPostgresOperationBackend(options) {
752
1149
  return operationBackend;
753
1150
  }
754
1151
  function createTransactionBackend(options) {
755
- const txExecutionAdapter = options.executionAdapter ?? createPostgresExecutionAdapter(options.db, options.adapterOptions);
756
- return createPostgresOperationBackend({
1152
+ const txExecutionAdapter = createSerialExecutionAdapter(
1153
+ createPostgresExecutionAdapter(options.db, options.adapterOptions)
1154
+ );
1155
+ const backend = createPostgresOperationBackend({
757
1156
  db: options.db,
758
1157
  executionAdapter: txExecutionAdapter,
759
1158
  adapterOptions: options.adapterOptions,
@@ -762,10 +1161,14 @@ function createTransactionBackend(options) {
762
1161
  capabilities: options.capabilities,
763
1162
  fulltextStrategy: options.fulltextStrategy,
764
1163
  vectorStrategy: options.vectorStrategy,
765
- vectorSlotLatch: options.vectorStrategy === void 0 ? void 0 : createVectorSlotLatch()
1164
+ vectorSlotLatch: options.vectorStrategy === void 0 ? void 0 : createVectorSlotLatch(),
1165
+ // The probe is process-wide truth, so — unlike the slot latch — the outer
1166
+ // instance's is reused rather than a fresh one per transaction.
1167
+ iterativeScanProbe: options.iterativeScanProbe
766
1168
  });
1169
+ return { backend, drainAndClose: txExecutionAdapter.drainAndClose };
767
1170
  }
768
1171
 
769
1172
  export { createPostgresBackend };
770
- //# sourceMappingURL=chunk-OS6KS3HV.js.map
771
- //# sourceMappingURL=chunk-OS6KS3HV.js.map
1173
+ //# sourceMappingURL=chunk-RGP33ZJ5.js.map
1174
+ //# sourceMappingURL=chunk-RGP33ZJ5.js.map