@nicia-ai/typegraph 0.34.0 → 0.36.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 (287) hide show
  1. package/dist/backend/postgres/index.cjs +29 -29
  2. package/dist/backend/postgres/index.d.cts +39 -7
  3. package/dist/backend/postgres/index.d.ts +39 -7
  4. package/dist/backend/postgres/index.js +16 -16
  5. package/dist/backend/postgres/pglite.cjs +21 -21
  6. package/dist/backend/postgres/pglite.d.cts +4 -4
  7. package/dist/backend/postgres/pglite.d.ts +4 -4
  8. package/dist/backend/postgres/pglite.js +16 -16
  9. package/dist/backend/sqlite/index.cjs +25 -26
  10. package/dist/backend/sqlite/index.d.cts +8 -8
  11. package/dist/backend/sqlite/index.d.ts +8 -8
  12. package/dist/backend/sqlite/index.js +13 -14
  13. package/dist/backend/sqlite/libsql.cjs +19 -19
  14. package/dist/backend/sqlite/libsql.d.cts +4 -4
  15. package/dist/backend/sqlite/libsql.d.ts +4 -4
  16. package/dist/backend/sqlite/libsql.js +15 -15
  17. package/dist/backend/sqlite/local.cjs +101 -21
  18. package/dist/backend/sqlite/local.cjs.map +1 -1
  19. package/dist/backend/sqlite/local.d.cts +95 -5
  20. package/dist/backend/sqlite/local.d.ts +95 -5
  21. package/dist/backend/sqlite/local.js +95 -16
  22. package/dist/backend/sqlite/local.js.map +1 -1
  23. package/dist/{chunk-T6SPUYLX.cjs → chunk-2THZ3TQI.cjs} +116 -10
  24. package/dist/chunk-2THZ3TQI.cjs.map +1 -0
  25. package/dist/{chunk-UJLOZYKT.cjs → chunk-456Z2U7Y.cjs} +441 -115
  26. package/dist/chunk-456Z2U7Y.cjs.map +1 -0
  27. package/dist/chunk-4BCU6VFZ.cjs +100 -0
  28. package/dist/chunk-4BCU6VFZ.cjs.map +1 -0
  29. package/dist/chunk-4BMPGT35.cjs +12 -0
  30. package/dist/{chunk-HMFK4BXR.cjs.map → chunk-4BMPGT35.cjs.map} +1 -1
  31. package/dist/chunk-4CAXEB2F.cjs +1366 -0
  32. package/dist/chunk-4CAXEB2F.cjs.map +1 -0
  33. package/dist/{chunk-RY2VIWAM.js → chunk-4GX2JJXS.js} +355 -32
  34. package/dist/chunk-4GX2JJXS.js.map +1 -0
  35. package/dist/{chunk-GQANNXXT.cjs → chunk-5A6FNS6N.cjs} +75 -20
  36. package/dist/chunk-5A6FNS6N.cjs.map +1 -0
  37. package/dist/{chunk-3Z6TW3CT.cjs → chunk-5AQIKK56.cjs} +65 -25
  38. package/dist/chunk-5AQIKK56.cjs.map +1 -0
  39. package/dist/{chunk-WLRIWYHQ.js → chunk-5DIPR3L3.js} +2145 -1937
  40. package/dist/chunk-5DIPR3L3.js.map +1 -0
  41. package/dist/{chunk-BVTWD66D.js → chunk-5SEGFTZX.js} +3 -3
  42. package/dist/{chunk-BVTWD66D.js.map → chunk-5SEGFTZX.js.map} +1 -1
  43. package/dist/{chunk-A7SZZFAG.js → chunk-5VTR2F2K.js} +452 -109
  44. package/dist/chunk-5VTR2F2K.js.map +1 -0
  45. package/dist/{chunk-JJRCLAUN.cjs → chunk-5W4L6DLF.cjs} +116 -10
  46. package/dist/chunk-5W4L6DLF.cjs.map +1 -0
  47. package/dist/{chunk-6GNSY7AV.js → chunk-6FR2MMS6.js} +7 -7
  48. package/dist/chunk-6FR2MMS6.js.map +1 -0
  49. package/dist/{chunk-3BRVBQQD.cjs → chunk-7BQLPXK6.cjs} +2648 -2440
  50. package/dist/chunk-7BQLPXK6.cjs.map +1 -0
  51. package/dist/chunk-7YSP4V4R.cjs +69 -0
  52. package/dist/chunk-7YSP4V4R.cjs.map +1 -0
  53. package/dist/chunk-A42GCBGX.cjs +28 -0
  54. package/dist/chunk-A42GCBGX.cjs.map +1 -0
  55. package/dist/{chunk-ZV5N4DBG.js → chunk-BJVEU3ZL.js} +300 -58
  56. package/dist/chunk-BJVEU3ZL.js.map +1 -0
  57. package/dist/chunk-BYPOGQWK.js +25 -0
  58. package/dist/chunk-BYPOGQWK.js.map +1 -0
  59. package/dist/chunk-CUHM5CWJ.cjs +12 -0
  60. package/dist/chunk-CUHM5CWJ.cjs.map +1 -0
  61. package/dist/{chunk-2JXB3NYJ.cjs → chunk-D7ZEOS56.cjs} +25 -32
  62. package/dist/chunk-D7ZEOS56.cjs.map +1 -0
  63. package/dist/chunk-DFVLCOP6.js +10 -0
  64. package/dist/chunk-DFVLCOP6.js.map +1 -0
  65. package/dist/{chunk-JIEJCTDS.cjs → chunk-DIK74MXX.cjs} +37 -4
  66. package/dist/chunk-DIK74MXX.cjs.map +1 -0
  67. package/dist/chunk-DN5VP4JC.js +1343 -0
  68. package/dist/chunk-DN5VP4JC.js.map +1 -0
  69. package/dist/chunk-EOLERH7Y.cjs +40 -0
  70. package/dist/chunk-EOLERH7Y.cjs.map +1 -0
  71. package/dist/{chunk-TGJE22RM.cjs → chunk-FACJJWGF.cjs} +24 -6
  72. package/dist/chunk-FACJJWGF.cjs.map +1 -0
  73. package/dist/{chunk-WVC2Q2FD.cjs → chunk-FN35DLCN.cjs} +31 -9
  74. package/dist/chunk-FN35DLCN.cjs.map +1 -0
  75. package/dist/{chunk-KUTNI6SI.js → chunk-FPIZFYHE.js} +10 -18
  76. package/dist/chunk-FPIZFYHE.js.map +1 -0
  77. package/dist/{chunk-VCGO4V26.js → chunk-FRV5Q5IO.js} +64 -9
  78. package/dist/chunk-FRV5Q5IO.js.map +1 -0
  79. package/dist/{chunk-K5P5OZXS.js → chunk-G6Q5UM7U.js} +2 -2
  80. package/dist/{chunk-K5P5OZXS.js.map → chunk-G6Q5UM7U.js.map} +1 -1
  81. package/dist/{chunk-JQGIPGVL.cjs → chunk-H7YNSMA7.cjs} +43 -2
  82. package/dist/chunk-H7YNSMA7.cjs.map +1 -0
  83. package/dist/chunk-HW3LW7DH.cjs +1271 -0
  84. package/dist/chunk-HW3LW7DH.cjs.map +1 -0
  85. package/dist/{chunk-V3QNTB7Z.js → chunk-IU46OHVW.js} +194 -114
  86. package/dist/chunk-IU46OHVW.js.map +1 -0
  87. package/dist/{chunk-HK5SATYM.cjs → chunk-J3LEGNQB.cjs} +16 -109
  88. package/dist/chunk-J3LEGNQB.cjs.map +1 -0
  89. package/dist/{chunk-ZP5WHI4C.cjs → chunk-JFMEONLG.cjs} +358 -116
  90. package/dist/chunk-JFMEONLG.cjs.map +1 -0
  91. package/dist/{chunk-2MRAX3UE.js → chunk-JFUPDJXD.js} +47 -4
  92. package/dist/chunk-JFUPDJXD.js.map +1 -0
  93. package/dist/{chunk-Z5XBMDXU.js → chunk-KBGQIPRQ.js} +42 -3
  94. package/dist/chunk-KBGQIPRQ.js.map +1 -0
  95. package/dist/{chunk-K2TGS3EN.js → chunk-M75SUBFG.js} +138 -89
  96. package/dist/chunk-M75SUBFG.js.map +1 -0
  97. package/dist/chunk-OHMP6N2J.js +47 -0
  98. package/dist/chunk-OHMP6N2J.js.map +1 -0
  99. package/dist/{chunk-4DIBPQNJ.js → chunk-OR5ZA5WP.js} +135 -25
  100. package/dist/chunk-OR5ZA5WP.js.map +1 -0
  101. package/dist/{chunk-6HVOHZHS.cjs → chunk-PWGX5DF5.cjs} +213 -168
  102. package/dist/chunk-PWGX5DF5.cjs.map +1 -0
  103. package/dist/chunk-PZKNKG5M.js +1252 -0
  104. package/dist/chunk-PZKNKG5M.js.map +1 -0
  105. package/dist/{chunk-DEQFL35G.js → chunk-Q5TEXCTB.js} +61 -7
  106. package/dist/chunk-Q5TEXCTB.js.map +1 -0
  107. package/dist/{chunk-QV245VMN.js → chunk-RAXU3RMB.js} +100 -6
  108. package/dist/chunk-RAXU3RMB.js.map +1 -0
  109. package/dist/{chunk-RHZWOJVA.cjs → chunk-RSSQKPSZ.cjs} +52 -4
  110. package/dist/chunk-RSSQKPSZ.cjs.map +1 -0
  111. package/dist/{chunk-G6SOJEDI.cjs → chunk-S55OV6PW.cjs} +15 -15
  112. package/dist/chunk-S55OV6PW.cjs.map +1 -0
  113. package/dist/chunk-S5F7ZLP2.js +94 -0
  114. package/dist/chunk-S5F7ZLP2.js.map +1 -0
  115. package/dist/{chunk-3E7SNSIA.cjs → chunk-SJDMVITW.cjs} +4 -4
  116. package/dist/{chunk-3E7SNSIA.cjs.map → chunk-SJDMVITW.cjs.map} +1 -1
  117. package/dist/{chunk-CHXTTSC6.js → chunk-SKCOUWAX.js} +104 -5
  118. package/dist/chunk-SKCOUWAX.js.map +1 -0
  119. package/dist/{chunk-XLUNB2TZ.js → chunk-SNXVDZAJ.js} +3 -3
  120. package/dist/{chunk-XLUNB2TZ.js.map → chunk-SNXVDZAJ.js.map} +1 -1
  121. package/dist/{chunk-ZURTTSCM.js → chunk-SXGE7ITL.js} +6 -94
  122. package/dist/chunk-SXGE7ITL.js.map +1 -0
  123. package/dist/{chunk-RBV7YCQD.js → chunk-T2WUSPDA.js} +49 -9
  124. package/dist/chunk-T2WUSPDA.js.map +1 -0
  125. package/dist/{chunk-KGC4LY5T.cjs → chunk-TCOCYN2P.cjs} +75 -21
  126. package/dist/chunk-TCOCYN2P.cjs.map +1 -0
  127. package/dist/{chunk-FLRCVI2G.cjs → chunk-TDXIBCGY.cjs} +2 -2
  128. package/dist/{chunk-FLRCVI2G.cjs.map → chunk-TDXIBCGY.cjs.map} +1 -1
  129. package/dist/{chunk-ZY4GXIVN.cjs → chunk-TEDRJXOG.cjs} +5 -5
  130. package/dist/{chunk-ZY4GXIVN.cjs.map → chunk-TEDRJXOG.cjs.map} +1 -1
  131. package/dist/{chunk-WL2SG7ZV.cjs → chunk-UMDVATGY.cjs} +6 -6
  132. package/dist/{chunk-WL2SG7ZV.cjs.map → chunk-UMDVATGY.cjs.map} +1 -1
  133. package/dist/chunk-UT3S4SEN.js +31 -0
  134. package/dist/chunk-UT3S4SEN.js.map +1 -0
  135. package/dist/{chunk-RRKQAKD6.cjs → chunk-UUT7UN2N.cjs} +149 -39
  136. package/dist/chunk-UUT7UN2N.cjs.map +1 -0
  137. package/dist/{chunk-SHLY4MCM.js → chunk-UZV3AZKF.js} +21 -3
  138. package/dist/chunk-UZV3AZKF.js.map +1 -0
  139. package/dist/{chunk-CYX2JTDG.js → chunk-VHMPG6UL.js} +29 -7
  140. package/dist/chunk-VHMPG6UL.js.map +1 -0
  141. package/dist/{chunk-LANHCOXB.js → chunk-VQEXF5D4.js} +485 -83
  142. package/dist/chunk-VQEXF5D4.js.map +1 -0
  143. package/dist/{chunk-K34OPSJK.js → chunk-W63OVYY4.js} +3 -3
  144. package/dist/{chunk-K34OPSJK.js.map → chunk-W63OVYY4.js.map} +1 -1
  145. package/dist/{chunk-TQOYM4LN.js → chunk-WI7ISNQF.js} +35 -5
  146. package/dist/chunk-WI7ISNQF.js.map +1 -0
  147. package/dist/{chunk-UNNPKQUG.cjs → chunk-X4JBT642.cjs} +246 -155
  148. package/dist/chunk-X4JBT642.cjs.map +1 -0
  149. package/dist/chunk-ZAMFOJ5P.cjs +1176 -0
  150. package/dist/chunk-ZAMFOJ5P.cjs.map +1 -0
  151. package/dist/{chunk-T46GR2VY.js → chunk-ZIGXMKQQ.js} +3 -3
  152. package/dist/{chunk-T46GR2VY.js.map → chunk-ZIGXMKQQ.js.map} +1 -1
  153. package/dist/{chunk-5IQIX7LU.cjs → chunk-ZUNQ5BEP.cjs} +518 -172
  154. package/dist/chunk-ZUNQ5BEP.cjs.map +1 -0
  155. package/dist/{ddl-BrmPg61z.d.ts → ddl-C2rZ-Aen.d.ts} +4 -4
  156. package/dist/{ddl-j1-sH6lE.d.cts → ddl-CZz7a0E8.d.cts} +4 -4
  157. package/dist/{extension-types-YGFJPrzK.d.cts → extension-types-ixRpJVUp.d.cts} +24 -1
  158. package/dist/{extension-types-YGFJPrzK.d.ts → extension-types-ixRpJVUp.d.ts} +24 -1
  159. package/dist/{types-DkNnF-7K.d.cts → fulltext-strategy-B57yvC5Q.d.ts} +2562 -2133
  160. package/dist/{types-D1Sqeyxy.d.ts → fulltext-strategy-CDkSSYhq.d.cts} +2562 -2133
  161. package/dist/graph-extension/index.cjs +20 -19
  162. package/dist/graph-extension/index.d.cts +4 -4
  163. package/dist/graph-extension/index.d.ts +4 -4
  164. package/dist/graph-extension/index.js +5 -4
  165. package/dist/graph-merge/index.cjs +255 -164
  166. package/dist/graph-merge/index.cjs.map +1 -1
  167. package/dist/graph-merge/index.d.cts +63 -33
  168. package/dist/graph-merge/index.d.ts +63 -33
  169. package/dist/graph-merge/index.js +135 -44
  170. package/dist/graph-merge/index.js.map +1 -1
  171. package/dist/{index-DGX6D9j1.d.ts → index-BFvdmBPV.d.ts} +301 -93
  172. package/dist/{index-SEvUHDA6.d.cts → index-BLtQWKRj.d.cts} +301 -93
  173. package/dist/index.cjs +216 -188
  174. package/dist/index.d.cts +11 -11
  175. package/dist/index.d.ts +11 -11
  176. package/dist/index.js +33 -33
  177. package/dist/indexes/index.cjs +19 -20
  178. package/dist/indexes/index.d.cts +5 -5
  179. package/dist/indexes/index.d.ts +5 -5
  180. package/dist/indexes/index.js +10 -11
  181. package/dist/interchange/index.cjs +48 -26
  182. package/dist/interchange/index.d.cts +126 -12
  183. package/dist/interchange/index.d.ts +126 -12
  184. package/dist/interchange/index.js +15 -13
  185. package/dist/{manager-ms9cKdc6.d.cts → manager-DwQi8eV0.d.cts} +9 -2
  186. package/dist/{manager-BZUeN_BU.d.ts → manager-ejUCB52T.d.ts} +9 -2
  187. package/dist/{materialize-indexes-D20xNluI.d.cts → materialize-indexes-B4e9360H.d.cts} +20 -4
  188. package/dist/{materialize-indexes-CAkIYFV-.d.ts → materialize-indexes-te9TPMMJ.d.ts} +20 -4
  189. package/dist/{postgres-BhpxGMC5.d.cts → postgres-CfEqsRMp.d.cts} +152 -1
  190. package/dist/{postgres-CWHLwNl1.d.ts → postgres-DQ5R6rzV.d.ts} +152 -1
  191. package/dist/profiler/index.cjs +11 -11
  192. package/dist/profiler/index.d.cts +7 -7
  193. package/dist/profiler/index.d.ts +7 -7
  194. package/dist/profiler/index.js +4 -4
  195. package/dist/provenance/index.cjs +40 -41
  196. package/dist/provenance/index.cjs.map +1 -1
  197. package/dist/provenance/index.d.cts +5 -5
  198. package/dist/provenance/index.d.ts +5 -5
  199. package/dist/provenance/index.js +11 -12
  200. package/dist/provenance/index.js.map +1 -1
  201. package/dist/schema/index.cjs +53 -40
  202. package/dist/schema/index.cjs.map +1 -1
  203. package/dist/schema/index.d.cts +57 -57
  204. package/dist/schema/index.d.ts +57 -57
  205. package/dist/schema/index.js +28 -15
  206. package/dist/schema/index.js.map +1 -1
  207. package/dist/{sqlite-XrDxNaa7.d.cts → sqlite-D7zBinNR.d.cts} +92 -1
  208. package/dist/{sqlite-CGu5SLsw.d.ts → sqlite-DvQndLky.d.ts} +92 -1
  209. package/dist/{store-view-D09po4H6.d.cts → store-view-9KDOpZzF.d.cts} +643 -58
  210. package/dist/{store-view-BlgnhEYf.d.ts → store-view-DplHC3Nt.d.ts} +643 -58
  211. package/dist/{types-DiE1AO7p.d.cts → types-Bv9DcS_E.d.cts} +2 -2
  212. package/dist/{types-B1TbZJYS.d.ts → types-CoxuV7EJ.d.ts} +2 -2
  213. package/dist/{where-DKjuofPr.d.cts → where-7RKFOsXt.d.ts} +2 -2
  214. package/dist/{where-DrUIIWHb.d.ts → where-DdMIXOtH.d.cts} +2 -2
  215. package/package.json +14 -13
  216. package/dist/chunk-2EBMPJBO.js +0 -16
  217. package/dist/chunk-2EBMPJBO.js.map +0 -1
  218. package/dist/chunk-2JXB3NYJ.cjs.map +0 -1
  219. package/dist/chunk-2MRAX3UE.js.map +0 -1
  220. package/dist/chunk-3BRVBQQD.cjs.map +0 -1
  221. package/dist/chunk-3EUKJEQ3.js +0 -77
  222. package/dist/chunk-3EUKJEQ3.js.map +0 -1
  223. package/dist/chunk-3Z6TW3CT.cjs.map +0 -1
  224. package/dist/chunk-4DIBPQNJ.js.map +0 -1
  225. package/dist/chunk-4S2FXGBJ.js +0 -9
  226. package/dist/chunk-4S2FXGBJ.js.map +0 -1
  227. package/dist/chunk-5IQIX7LU.cjs.map +0 -1
  228. package/dist/chunk-6GNSY7AV.js.map +0 -1
  229. package/dist/chunk-6HVOHZHS.cjs.map +0 -1
  230. package/dist/chunk-6SCVW4AS.js +0 -20
  231. package/dist/chunk-6SCVW4AS.js.map +0 -1
  232. package/dist/chunk-A7SZZFAG.js.map +0 -1
  233. package/dist/chunk-CHXTTSC6.js.map +0 -1
  234. package/dist/chunk-CYX2JTDG.js.map +0 -1
  235. package/dist/chunk-DEQFL35G.js.map +0 -1
  236. package/dist/chunk-G6SOJEDI.cjs.map +0 -1
  237. package/dist/chunk-GQANNXXT.cjs.map +0 -1
  238. package/dist/chunk-GZCNZ7QW.js +0 -24
  239. package/dist/chunk-GZCNZ7QW.js.map +0 -1
  240. package/dist/chunk-HK5SATYM.cjs.map +0 -1
  241. package/dist/chunk-HMFK4BXR.cjs +0 -12
  242. package/dist/chunk-HTGDWIDE.cjs +0 -89
  243. package/dist/chunk-HTGDWIDE.cjs.map +0 -1
  244. package/dist/chunk-JIEJCTDS.cjs.map +0 -1
  245. package/dist/chunk-JJRCLAUN.cjs.map +0 -1
  246. package/dist/chunk-JQGIPGVL.cjs.map +0 -1
  247. package/dist/chunk-K2TGS3EN.js.map +0 -1
  248. package/dist/chunk-KGC4LY5T.cjs.map +0 -1
  249. package/dist/chunk-KNHYNQQ3.cjs +0 -663
  250. package/dist/chunk-KNHYNQQ3.cjs.map +0 -1
  251. package/dist/chunk-KUTNI6SI.js.map +0 -1
  252. package/dist/chunk-LANHCOXB.js.map +0 -1
  253. package/dist/chunk-N6WTUSBV.cjs +0 -23
  254. package/dist/chunk-N6WTUSBV.cjs.map +0 -1
  255. package/dist/chunk-NAUA4PW5.cjs +0 -28
  256. package/dist/chunk-NAUA4PW5.cjs.map +0 -1
  257. package/dist/chunk-QV245VMN.js.map +0 -1
  258. package/dist/chunk-RBV7YCQD.js.map +0 -1
  259. package/dist/chunk-RHZWOJVA.cjs.map +0 -1
  260. package/dist/chunk-RRKQAKD6.cjs.map +0 -1
  261. package/dist/chunk-RY2VIWAM.js.map +0 -1
  262. package/dist/chunk-SHLY4MCM.js.map +0 -1
  263. package/dist/chunk-T2DWPQNE.js +0 -649
  264. package/dist/chunk-T2DWPQNE.js.map +0 -1
  265. package/dist/chunk-T6SPUYLX.cjs.map +0 -1
  266. package/dist/chunk-TGJE22RM.cjs.map +0 -1
  267. package/dist/chunk-TOTPVGOG.cjs +0 -774
  268. package/dist/chunk-TOTPVGOG.cjs.map +0 -1
  269. package/dist/chunk-TQOYM4LN.js.map +0 -1
  270. package/dist/chunk-UJLOZYKT.cjs.map +0 -1
  271. package/dist/chunk-UNNPKQUG.cjs.map +0 -1
  272. package/dist/chunk-V3QNTB7Z.js.map +0 -1
  273. package/dist/chunk-VCGO4V26.js.map +0 -1
  274. package/dist/chunk-WLRIWYHQ.js.map +0 -1
  275. package/dist/chunk-WVC2Q2FD.cjs.map +0 -1
  276. package/dist/chunk-XXVEULWX.js +0 -39
  277. package/dist/chunk-XXVEULWX.js.map +0 -1
  278. package/dist/chunk-YAZE7QZR.cjs +0 -32
  279. package/dist/chunk-YAZE7QZR.cjs.map +0 -1
  280. package/dist/chunk-YC6PWTHY.cjs +0 -44
  281. package/dist/chunk-YC6PWTHY.cjs.map +0 -1
  282. package/dist/chunk-Z5HBYM7U.cjs +0 -11
  283. package/dist/chunk-Z5HBYM7U.cjs.map +0 -1
  284. package/dist/chunk-Z5XBMDXU.js.map +0 -1
  285. package/dist/chunk-ZP5WHI4C.cjs.map +0 -1
  286. package/dist/chunk-ZURTTSCM.js.map +0 -1
  287. package/dist/chunk-ZV5N4DBG.js.map +0 -1
@@ -0,0 +1,1176 @@
1
+ 'use strict';
2
+
3
+ var chunk456Z2U7Y_cjs = require('./chunk-456Z2U7Y.cjs');
4
+ var chunkTCOCYN2P_cjs = require('./chunk-TCOCYN2P.cjs');
5
+ var chunk5W4L6DLF_cjs = require('./chunk-5W4L6DLF.cjs');
6
+ var chunkD7ZEOS56_cjs = require('./chunk-D7ZEOS56.cjs');
7
+ var chunkEOLERH7Y_cjs = require('./chunk-EOLERH7Y.cjs');
8
+ var chunkX4JBT642_cjs = require('./chunk-X4JBT642.cjs');
9
+ var chunkRSSQKPSZ_cjs = require('./chunk-RSSQKPSZ.cjs');
10
+ var chunkDIK74MXX_cjs = require('./chunk-DIK74MXX.cjs');
11
+ var drizzleOrm = require('drizzle-orm');
12
+ var pgCore = require('drizzle-orm/pg-core');
13
+
14
+ // src/backend/drizzle/execution/postgres-execution.ts
15
+ function hasFunctionProperty(value, property) {
16
+ if (value === void 0 || value === null) {
17
+ return false;
18
+ }
19
+ const candidate = value;
20
+ return typeof candidate[property] === "function";
21
+ }
22
+ function isPgNativeClient(candidate) {
23
+ return typeof candidate === "object" && hasFunctionProperty(candidate, "query");
24
+ }
25
+ function isPgliteClient(candidate) {
26
+ return typeof candidate === "object" && hasFunctionProperty(candidate, "query") && hasFunctionProperty(candidate, "dumpDataDir");
27
+ }
28
+ function isPostgresJsClient(candidate) {
29
+ return typeof candidate === "function" && hasFunctionProperty(candidate, "unsafe") && hasFunctionProperty(candidate, "begin");
30
+ }
31
+ function isNeonHttpClient(db) {
32
+ const candidate = db.$client;
33
+ return typeof candidate === "function" && hasFunctionProperty(candidate, "transaction") && !hasFunctionProperty(candidate, "begin");
34
+ }
35
+ var DEFAULT_POSTGRES_STATEMENT_CACHE_MAX = 256;
36
+ var STATEMENT_NAME_CACHE = /* @__PURE__ */ new Map();
37
+ var nextStatementId = 0;
38
+ function statementNameFor(sqlText, cacheMax) {
39
+ return chunk456Z2U7Y_cjs.getOrCreateLru(STATEMENT_NAME_CACHE, sqlText, cacheMax, () => {
40
+ const name = `tg_${nextStatementId}`;
41
+ nextStatementId += 1;
42
+ return name;
43
+ });
44
+ }
45
+ function normalizeRow(row) {
46
+ if (row === null || typeof row !== "object") return row;
47
+ let mutated;
48
+ for (const key of Object.keys(row)) {
49
+ const value = row[key];
50
+ if (value instanceof Date) {
51
+ mutated ??= { ...row };
52
+ mutated[key] = value.toISOString();
53
+ }
54
+ }
55
+ return mutated ?? row;
56
+ }
57
+ function normalizeRows(rows) {
58
+ let mutated;
59
+ for (let index = 0; index < rows.length; index += 1) {
60
+ const original = rows[index];
61
+ const normalized = normalizeRow(original);
62
+ if (normalized !== original) {
63
+ mutated ??= [...rows];
64
+ mutated[index] = normalized;
65
+ }
66
+ }
67
+ return mutated ?? rows;
68
+ }
69
+ function wrapNodePgClient(client, cacheMax) {
70
+ return {
71
+ async query(sqlText, params) {
72
+ const result = await client.query({
73
+ name: statementNameFor(sqlText, cacheMax),
74
+ text: sqlText,
75
+ values: params
76
+ });
77
+ return { rows: normalizeRows(result.rows) };
78
+ },
79
+ async queryUnnamed(sqlText, params) {
80
+ const result = await client.query(sqlText, params);
81
+ return { rows: normalizeRows(result.rows) };
82
+ }
83
+ };
84
+ }
85
+ function wrapNodePgClientUnnamed(client) {
86
+ async function queryUnnamed(sqlText, params) {
87
+ const result = await client.query(sqlText, params);
88
+ return { rows: normalizeRows(result.rows) };
89
+ }
90
+ return {
91
+ query: queryUnnamed,
92
+ queryUnnamed
93
+ };
94
+ }
95
+ function adaptPostgresJsClient(sql2) {
96
+ async function query(sqlText, params) {
97
+ const rows = await sql2.unsafe(sqlText, params);
98
+ return { rows };
99
+ }
100
+ return {
101
+ query,
102
+ async queryUnnamed(sqlText, params) {
103
+ const rows = await sql2.unsafe(sqlText, params, { prepare: false });
104
+ return { rows };
105
+ }
106
+ };
107
+ }
108
+ function resolvePgClient(db, prepareStatements, cacheMax) {
109
+ if (isNeonHttpClient(db)) {
110
+ return void 0;
111
+ }
112
+ const client = db.$client;
113
+ if (isPgliteClient(client)) {
114
+ return wrapNodePgClientUnnamed(client);
115
+ }
116
+ if (isPgNativeClient(client)) {
117
+ return prepareStatements ? wrapNodePgClient(client, cacheMax) : wrapNodePgClientUnnamed(client);
118
+ }
119
+ if (isPostgresJsClient(client)) {
120
+ return adaptPostgresJsClient(client);
121
+ }
122
+ return void 0;
123
+ }
124
+ async function executeDrizzleQuery(db, query) {
125
+ const result = await db.execute(query);
126
+ if (Array.isArray(result)) {
127
+ return result;
128
+ }
129
+ return result.rows;
130
+ }
131
+ function createPgPreparedStatement(pgClient, sqlText) {
132
+ return {
133
+ async execute(params) {
134
+ const result = await pgClient.query(sqlText, params);
135
+ return result.rows;
136
+ }
137
+ };
138
+ }
139
+ function createPostgresExecutionAdapter(db, options = {}) {
140
+ const prepareStatements = options.prepareStatements ?? true;
141
+ const cacheMax = options.preparedStatementCacheMax ?? DEFAULT_POSTGRES_STATEMENT_CACHE_MAX;
142
+ const pgClient = resolvePgClient(db, prepareStatements, cacheMax);
143
+ function compile(query) {
144
+ return chunk456Z2U7Y_cjs.compileQueryWithDialect(db, query, "PostgreSQL");
145
+ }
146
+ if (pgClient === void 0) {
147
+ return {
148
+ compile,
149
+ async execute(query) {
150
+ return executeDrizzleQuery(db, query);
151
+ }
152
+ };
153
+ }
154
+ const pgQueryClient = pgClient;
155
+ async function executeCompiled(compiledQuery) {
156
+ const result = await pgQueryClient.query(
157
+ compiledQuery.sql,
158
+ compiledQuery.params
159
+ );
160
+ return result.rows;
161
+ }
162
+ return {
163
+ compile,
164
+ async execute(query) {
165
+ const compiled = compile(query);
166
+ if (chunkEOLERH7Y_cjs.shouldForceCustomPlan(query)) {
167
+ const result = await pgQueryClient.queryUnnamed(
168
+ compiled.sql,
169
+ compiled.params
170
+ );
171
+ return result.rows;
172
+ }
173
+ return executeCompiled(compiled);
174
+ },
175
+ executeCompiled,
176
+ prepare(sqlText) {
177
+ return createPgPreparedStatement(pgQueryClient, sqlText);
178
+ }
179
+ };
180
+ }
181
+
182
+ // src/backend/drizzle/execution/statement-queue.ts
183
+ function ignoreOutcome() {
184
+ }
185
+ function createStatementQueue() {
186
+ let tail = Promise.resolve();
187
+ let closed = false;
188
+ return {
189
+ enqueue(task) {
190
+ if (closed) return Promise.reject(new chunkDIK74MXX_cjs.TransactionClosedError());
191
+ const result = tail.then(() => task());
192
+ tail = result.then(ignoreOutcome, ignoreOutcome);
193
+ return result;
194
+ },
195
+ async drainAndClose() {
196
+ closed = true;
197
+ await tail;
198
+ }
199
+ };
200
+ }
201
+ function createSerialExecutionAdapter(adapter) {
202
+ const { enqueue, drainAndClose } = createStatementQueue();
203
+ const { executeCompiled, prepare } = adapter;
204
+ return {
205
+ drainAndClose,
206
+ compile(query) {
207
+ return adapter.compile(query);
208
+ },
209
+ execute(query) {
210
+ return enqueue(() => adapter.execute(query));
211
+ },
212
+ runExclusive(critical) {
213
+ return enqueue(() => critical(adapter));
214
+ },
215
+ ...executeCompiled === void 0 ? {} : {
216
+ executeCompiled(compiledQuery) {
217
+ return enqueue(() => executeCompiled(compiledQuery));
218
+ }
219
+ },
220
+ ...prepare === void 0 ? {} : {
221
+ prepare(sqlText) {
222
+ const statement = prepare(sqlText);
223
+ return {
224
+ execute(params) {
225
+ return enqueue(() => statement.execute(params));
226
+ }
227
+ };
228
+ }
229
+ }
230
+ };
231
+ }
232
+
233
+ // src/backend/drizzle/postgres.ts
234
+ var NODE_INSERT_PARAM_COUNT = 9;
235
+ var EDGE_INSERT_PARAM_COUNT = 12;
236
+ var POSTGRES_NODE_INSERT_BATCH_SIZE = Math.max(
237
+ 1,
238
+ Math.floor(chunkX4JBT642_cjs.POSTGRES_MAX_BIND_PARAMETERS / NODE_INSERT_PARAM_COUNT)
239
+ );
240
+ var POSTGRES_EDGE_INSERT_BATCH_SIZE = Math.max(
241
+ 1,
242
+ Math.floor(chunkX4JBT642_cjs.POSTGRES_MAX_BIND_PARAMETERS / EDGE_INSERT_PARAM_COUNT)
243
+ );
244
+ var POSTGRES_GET_NODES_ID_CHUNK_SIZE = Math.max(
245
+ 1,
246
+ chunkX4JBT642_cjs.POSTGRES_MAX_BIND_PARAMETERS - 2
247
+ );
248
+ var POSTGRES_GET_EDGES_ID_CHUNK_SIZE = Math.max(
249
+ 1,
250
+ chunkX4JBT642_cjs.POSTGRES_MAX_BIND_PARAMETERS - 1
251
+ );
252
+ var FULLTEXT_UPSERT_PARAM_COUNT = 6;
253
+ var FULLTEXT_DELETE_FIXED_PARAM_COUNT = 2;
254
+ var POSTGRES_FULLTEXT_UPSERT_BATCH_SIZE = Math.max(
255
+ 1,
256
+ Math.floor(chunkX4JBT642_cjs.POSTGRES_MAX_BIND_PARAMETERS / FULLTEXT_UPSERT_PARAM_COUNT)
257
+ );
258
+ var POSTGRES_FULLTEXT_DELETE_CHUNK_SIZE = Math.max(
259
+ 1,
260
+ chunkX4JBT642_cjs.POSTGRES_MAX_BIND_PARAMETERS - FULLTEXT_DELETE_FIXED_PARAM_COUNT
261
+ );
262
+ var CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT = 3;
263
+ var POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE = Math.max(
264
+ 1,
265
+ chunkX4JBT642_cjs.POSTGRES_MAX_BIND_PARAMETERS - CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT
266
+ );
267
+ var UNIQUE_INSERT_PARAM_COUNT = 6;
268
+ var POSTGRES_UNIQUE_INSERT_BATCH_SIZE = Math.max(
269
+ 1,
270
+ Math.floor(chunkX4JBT642_cjs.POSTGRES_MAX_BIND_PARAMETERS / UNIQUE_INSERT_PARAM_COUNT)
271
+ );
272
+ var toNodeRow = chunk5W4L6DLF_cjs.createNodeRowMapper(chunk5W4L6DLF_cjs.POSTGRES_ROW_MAPPER_CONFIG);
273
+ var toEdgeRow = chunk5W4L6DLF_cjs.createEdgeRowMapper(chunk5W4L6DLF_cjs.POSTGRES_ROW_MAPPER_CONFIG);
274
+ var toUniqueRow = chunk5W4L6DLF_cjs.createUniqueRowMapper(chunk5W4L6DLF_cjs.POSTGRES_ROW_MAPPER_CONFIG);
275
+ var toSchemaVersionRow = chunk5W4L6DLF_cjs.createSchemaVersionRowMapper(
276
+ chunk5W4L6DLF_cjs.POSTGRES_ROW_MAPPER_CONFIG
277
+ );
278
+ function buildPostgresCapabilities(fulltextStrategy, vectorStrategy) {
279
+ return {
280
+ ...chunkX4JBT642_cjs.POSTGRES_CAPABILITIES,
281
+ ...vectorStrategy === void 0 ? {} : { vector: chunkD7ZEOS56_cjs.buildVectorCapabilities(vectorStrategy) },
282
+ fulltext: chunkD7ZEOS56_cjs.buildFulltextCapabilities(fulltextStrategy)
283
+ };
284
+ }
285
+ function createPostgresBackend(db, options = {}) {
286
+ const tables2 = options.tables ?? chunk456Z2U7Y_cjs.tables;
287
+ const fulltextStrategy = options.fulltext ?? chunkD7ZEOS56_cjs.tsvectorStrategy;
288
+ const vectorStrategy = options.vector === false ? void 0 : options.vector ?? chunkTCOCYN2P_cjs.pgvectorStrategy;
289
+ const vectorSlotLatch = vectorStrategy === void 0 ? void 0 : chunk456Z2U7Y_cjs.createVectorSlotLatch();
290
+ const iterativeScanProbe = createIterativeScanProbe();
291
+ const baseCapabilities = buildPostgresCapabilities(
292
+ fulltextStrategy,
293
+ vectorStrategy
294
+ );
295
+ const httpOnlyOverrides = isNeonHttpClient(db) ? { transactions: false } : {};
296
+ const capabilities = {
297
+ ...baseCapabilities,
298
+ ...httpOnlyOverrides,
299
+ ...options.capabilities
300
+ };
301
+ const adapterOptions = {
302
+ ...options.prepareStatements === void 0 ? {} : { prepareStatements: options.prepareStatements },
303
+ ...options.preparedStatementCacheMax === void 0 ? {} : { preparedStatementCacheMax: options.preparedStatementCacheMax }
304
+ };
305
+ const executionAdapter = createPostgresExecutionAdapter(db, adapterOptions);
306
+ const tableNames = {
307
+ nodes: drizzleOrm.getTableName(tables2.nodes),
308
+ edges: drizzleOrm.getTableName(tables2.edges),
309
+ recordedNodes: drizzleOrm.getTableName(tables2.recordedNodes),
310
+ recordedEdges: drizzleOrm.getTableName(tables2.recordedEdges),
311
+ recordedClock: drizzleOrm.getTableName(tables2.recordedClock),
312
+ revisionOrigins: drizzleOrm.getTableName(tables2.revisionOrigins),
313
+ fulltext: tables2.fulltextTableName,
314
+ uniques: drizzleOrm.getTableName(tables2.uniques)
315
+ };
316
+ const coreAnalyzeStatements = [
317
+ tableNames.nodes,
318
+ tableNames.edges,
319
+ drizzleOrm.getTableName(tables2.uniques),
320
+ tableNames.fulltext
321
+ ].map((name) => drizzleOrm.sql`ANALYZE (SKIP_LOCKED) ${chunk5W4L6DLF_cjs.quoteIdentifier(name)}`);
322
+ const recordedAnalyzeTables = [
323
+ tableNames.recordedNodes,
324
+ tableNames.recordedEdges,
325
+ tableNames.recordedClock
326
+ ];
327
+ const operationStrategy = chunk456Z2U7Y_cjs.createPostgresOperationStrategy(
328
+ tables2,
329
+ fulltextStrategy
330
+ );
331
+ const operations = createPostgresOperationBackend({
332
+ db,
333
+ executionAdapter,
334
+ adapterOptions,
335
+ operationStrategy,
336
+ tableNames,
337
+ capabilities,
338
+ fulltextStrategy,
339
+ vectorStrategy,
340
+ vectorSlotLatch,
341
+ iterativeScanProbe
342
+ });
343
+ const recordedTableExists = chunk456Z2U7Y_cjs.createCachedTableExistence(
344
+ async (tableName) => {
345
+ const rows = await executionAdapter.execute(
346
+ operationStrategy.buildTableExists(tableName)
347
+ );
348
+ return rows[0];
349
+ },
350
+ { cacheExisting: false }
351
+ );
352
+ function runSchemaWriteTransaction(graphId, fn) {
353
+ if (!capabilities.transactions) {
354
+ throw new chunkDIK74MXX_cjs.ConfigurationError(
355
+ "commitSchemaVersion and setActiveVersion require atomic transactions, but this Postgres backend does not provide them. The drizzle-orm/neon-http driver communicates over HTTP and cannot hold a session across statements; use drizzle-orm/neon-serverless (websocket) for transactional writes.",
356
+ {
357
+ backend: "postgres",
358
+ capability: "transactions",
359
+ supportsTransactions: false
360
+ }
361
+ );
362
+ }
363
+ return db.transaction(async (tx) => {
364
+ await tx.execute(drizzleOrm.sql`SELECT pg_advisory_xact_lock(hashtext(${graphId}))`);
365
+ const { backend: txBackend, drainAndClose } = createTransactionBackend({
366
+ db: tx,
367
+ adapterOptions,
368
+ operationStrategy,
369
+ tableNames,
370
+ capabilities,
371
+ fulltextStrategy,
372
+ vectorStrategy,
373
+ iterativeScanProbe
374
+ });
375
+ try {
376
+ return await fn(txBackend);
377
+ } finally {
378
+ await drainAndClose();
379
+ }
380
+ });
381
+ }
382
+ const matTable = tables2.contributionMaterializations;
383
+ async function ensureContributionMaterializationsTableImpl() {
384
+ await db.execute(drizzleOrm.sql.raw(chunk456Z2U7Y_cjs.generatePgCreateTableSQL(matTable)));
385
+ }
386
+ async function getContributionMaterializationRow(identity) {
387
+ const rows = await db.select().from(matTable).where(
388
+ drizzleOrm.and(
389
+ drizzleOrm.eq(matTable.graphId, identity.graphId),
390
+ drizzleOrm.eq(matTable.logicalName, identity.logicalName),
391
+ drizzleOrm.eq(matTable.owner, identity.owner),
392
+ drizzleOrm.eq(matTable.tableName, identity.tableName)
393
+ )
394
+ );
395
+ const row = rows[0];
396
+ if (row === void 0) return void 0;
397
+ return chunk456Z2U7Y_cjs.mapContributionMaterializationRow(
398
+ row,
399
+ chunk456Z2U7Y_cjs.POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS.decode
400
+ );
401
+ }
402
+ async function recordContributionMaterializationRow(params) {
403
+ await db.insert(matTable).values(
404
+ chunk456Z2U7Y_cjs.buildContributionInsertValues(
405
+ params,
406
+ chunk456Z2U7Y_cjs.POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS.encode
407
+ )
408
+ ).onConflictDoUpdate({
409
+ target: [
410
+ matTable.graphId,
411
+ matTable.logicalName,
412
+ matTable.owner,
413
+ matTable.tableName
414
+ ],
415
+ set: chunk456Z2U7Y_cjs.buildContributionOnConflictSet(
416
+ matTable.materializedAt,
417
+ params.materializedAt
418
+ )
419
+ });
420
+ }
421
+ const contributionMaterializer = chunk456Z2U7Y_cjs.createContributionMaterializer({
422
+ dialect: "postgres",
423
+ fulltextStrategy,
424
+ fulltextTableName: tables2.fulltextTableName,
425
+ execDdl: async (statement) => {
426
+ await db.execute(drizzleOrm.sql.raw(statement));
427
+ },
428
+ ensureMarkerTable: ensureContributionMaterializationsTableImpl,
429
+ getMarker: getContributionMaterializationRow,
430
+ recordMarker: recordContributionMaterializationRow
431
+ });
432
+ function bindTransactionBackend(tx) {
433
+ const { backend: backend2, drainAndClose } = createTransactionBackend({
434
+ db: tx,
435
+ adapterOptions,
436
+ operationStrategy,
437
+ tableNames,
438
+ capabilities,
439
+ fulltextStrategy,
440
+ vectorStrategy,
441
+ iterativeScanProbe
442
+ });
443
+ return {
444
+ backend: chunk456Z2U7Y_cjs.gateFulltext(
445
+ backend2,
446
+ contributionMaterializer.assertInitialized
447
+ ),
448
+ drainAndClose
449
+ };
450
+ }
451
+ const backend = {
452
+ ...operations,
453
+ async bootstrapTables() {
454
+ const statements = chunk456Z2U7Y_cjs.generatePostgresDDL(tables2, fulltextStrategy);
455
+ for (const statement of statements) {
456
+ await db.execute(drizzleOrm.sql.raw(statement));
457
+ }
458
+ },
459
+ async ensureRevisionOriginsTable() {
460
+ await db.execute(
461
+ drizzleOrm.sql.raw(chunk456Z2U7Y_cjs.generatePgCreateTableSQL(tables2.revisionOrigins))
462
+ );
463
+ },
464
+ // Every fulltext-touching method asserts the durable marker instead
465
+ // of lazily emitting DDL. Steady state performs zero ensure; an
466
+ // uninitialized database throws `StoreNotInitializedError` loudly
467
+ // rather than self-healing on a read/write path (#135). Shared
468
+ // verbatim with the tx-scoped gate via `gateFulltextMethods`.
469
+ ...chunk456Z2U7Y_cjs.gateFulltextMethods(
470
+ operations,
471
+ contributionMaterializer.assertInitialized
472
+ ),
473
+ async executeDdl(ddl) {
474
+ await db.execute(drizzleOrm.sql.raw(ddl));
475
+ },
476
+ async ensureIndexMaterializationsTable() {
477
+ await db.execute(
478
+ drizzleOrm.sql.raw(chunk456Z2U7Y_cjs.generatePgCreateTableSQL(tables2.indexMaterializations))
479
+ );
480
+ const tableName = drizzleOrm.getTableName(tables2.indexMaterializations);
481
+ await db.execute(
482
+ drizzleOrm.sql.raw(
483
+ `ALTER TABLE "${tableName}" ADD COLUMN IF NOT EXISTS "building_since" timestamptz;`
484
+ )
485
+ );
486
+ await db.execute(
487
+ drizzleOrm.sql.raw(
488
+ `ALTER TABLE "${tableName}" ADD COLUMN IF NOT EXISTS "claim_token" text;`
489
+ )
490
+ );
491
+ },
492
+ async claimIndexMaterialization(params) {
493
+ const t = tables2.indexMaterializations;
494
+ const rows = await db.execute(drizzleOrm.sql`
495
+ INSERT INTO ${t} (
496
+ "index_name", "graph_id", "entity", "kind", "signature",
497
+ "schema_version", "last_attempted_at", "building_since",
498
+ "claim_token"
499
+ )
500
+ VALUES (
501
+ ${params.indexName}, ${params.graphId}, ${params.entity},
502
+ ${params.kind}, ${params.signature}, ${params.schemaVersion},
503
+ now(), now(), ${params.token}
504
+ )
505
+ ON CONFLICT ("index_name") DO UPDATE SET
506
+ "building_since" = now(),
507
+ "claim_token" = EXCLUDED."claim_token"
508
+ WHERE ${t}."building_since" IS NULL
509
+ OR ${t}."building_since" < now() - (${params.leaseMs} * interval '1 millisecond')
510
+ RETURNING "index_name"
511
+ `);
512
+ const result = rows;
513
+ const returned = Array.isArray(result) ? result : result.rows ?? [];
514
+ return returned.length > 0;
515
+ },
516
+ async releaseIndexMaterializationClaim(params) {
517
+ const t = tables2.indexMaterializations;
518
+ await db.execute(drizzleOrm.sql`
519
+ UPDATE ${t}
520
+ SET "building_since" = NULL, "claim_token" = NULL
521
+ WHERE "index_name" = ${params.indexName}
522
+ AND "claim_token" = ${params.token}
523
+ `);
524
+ },
525
+ async getIndexMaterialization(indexName) {
526
+ const t = tables2.indexMaterializations;
527
+ const rows = await db.select().from(t).where(drizzleOrm.eq(t.indexName, indexName));
528
+ const row = rows[0];
529
+ if (row === void 0) return void 0;
530
+ return chunk456Z2U7Y_cjs.mapMaterializationRow(row, chunk456Z2U7Y_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.decode);
531
+ },
532
+ async getIndexMaterializations(statusKeys) {
533
+ if (statusKeys.length === 0) return [];
534
+ const t = tables2.indexMaterializations;
535
+ const rows = await db.select().from(t).where(drizzleOrm.inArray(t.indexName, [...statusKeys]));
536
+ return rows.map(
537
+ (row) => chunk456Z2U7Y_cjs.mapMaterializationRow(row, chunk456Z2U7Y_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.decode)
538
+ );
539
+ },
540
+ async recordIndexMaterialization(params) {
541
+ const t = tables2.indexMaterializations;
542
+ await db.insert(t).values(
543
+ chunk456Z2U7Y_cjs.buildMaterializationInsertValues(
544
+ params,
545
+ chunk456Z2U7Y_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.encode
546
+ )
547
+ ).onConflictDoUpdate({
548
+ target: t.indexName,
549
+ set: chunk456Z2U7Y_cjs.buildMaterializationOnConflictSet(
550
+ t.materializedAt,
551
+ params.materializedAt
552
+ )
553
+ });
554
+ },
555
+ async ensureContributionMaterializationsTable() {
556
+ await ensureContributionMaterializationsTableImpl();
557
+ },
558
+ async getContributionMaterialization(identity) {
559
+ return getContributionMaterializationRow(identity);
560
+ },
561
+ async recordContributionMaterialization(params) {
562
+ await recordContributionMaterializationRow(params);
563
+ },
564
+ async assertRuntimeContributionsInitialized(graphId) {
565
+ await contributionMaterializer.assertInitialized(graphId);
566
+ },
567
+ async ensureKindRemovalsTable() {
568
+ await db.execute(drizzleOrm.sql.raw(chunk456Z2U7Y_cjs.generatePgCreateTableSQL(tables2.kindRemovals)));
569
+ },
570
+ async getPendingKindRemovals(graphId) {
571
+ const t = tables2.kindRemovals;
572
+ const rows = await db.select().from(t).where(drizzleOrm.and(drizzleOrm.eq(t.graphId, graphId), drizzleOrm.isNull(t.removedAt)));
573
+ return rows.map(
574
+ (row) => chunk456Z2U7Y_cjs.mapKindRemovalRow(row, chunk456Z2U7Y_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.decode)
575
+ );
576
+ },
577
+ async getAllKindRemovals(graphId) {
578
+ const t = tables2.kindRemovals;
579
+ const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
580
+ return rows.map(
581
+ (row) => chunk456Z2U7Y_cjs.mapKindRemovalRow(row, chunk456Z2U7Y_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.decode)
582
+ );
583
+ },
584
+ async recordKindRemoval(params) {
585
+ const t = tables2.kindRemovals;
586
+ await db.insert(t).values(
587
+ chunk456Z2U7Y_cjs.buildKindRemovalInsertValues(
588
+ params,
589
+ chunk456Z2U7Y_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.encode
590
+ )
591
+ ).onConflictDoUpdate({
592
+ target: [t.graphId, t.kindName, t.entity, t.schemaVersion],
593
+ set: chunk456Z2U7Y_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
594
+ });
595
+ },
596
+ async ensureReconciliationMarkersTable() {
597
+ await db.execute(
598
+ drizzleOrm.sql.raw(chunk456Z2U7Y_cjs.generatePgCreateTableSQL(tables2.reconciliationMarkers))
599
+ );
600
+ },
601
+ async ensureRuntimeContributions(graphId) {
602
+ await contributionMaterializer.ensureRuntimeContributions(graphId);
603
+ },
604
+ /**
605
+ * Superseded by `ensureRuntimeContributions(graphId)` (#129).
606
+ * Retained as a thin back-compat wrapper for callers predating
607
+ * #129; #135 routed it through the durable-marker writer.
608
+ */
609
+ async ensureFulltextTable(graphId) {
610
+ await contributionMaterializer.ensureRuntimeContributions(graphId);
611
+ },
612
+ async getReconciliationMarker(graphId) {
613
+ const t = tables2.reconciliationMarkers;
614
+ const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
615
+ return rows[0]?.reconciledToVersion;
616
+ },
617
+ async setReconciliationMarker(graphId, version) {
618
+ const t = tables2.reconciliationMarkers;
619
+ await db.insert(t).values({ graphId, reconciledToVersion: version }).onConflictDoUpdate({
620
+ target: t.graphId,
621
+ set: { reconciledToVersion: version }
622
+ });
623
+ },
624
+ async refreshStatistics() {
625
+ for (const statement of coreAnalyzeStatements) {
626
+ await db.execute(statement);
627
+ }
628
+ const tablePresence = await Promise.all(
629
+ recordedAnalyzeTables.map(async (tableName) => ({
630
+ tableName,
631
+ exists: await recordedTableExists(tableName)
632
+ }))
633
+ );
634
+ const presentRecordedTables = tablePresence.filter((entry) => entry.exists).map((entry) => entry.tableName);
635
+ for (const tableName of presentRecordedTables) {
636
+ await db.execute(
637
+ drizzleOrm.sql`ANALYZE (SKIP_LOCKED) ${chunk5W4L6DLF_cjs.quoteIdentifier(tableName)}`
638
+ );
639
+ }
640
+ },
641
+ async commitSchemaVersion(params) {
642
+ return runSchemaWriteTransaction(
643
+ params.graphId,
644
+ (target) => target.commitSchemaVersion(params)
645
+ );
646
+ },
647
+ async setActiveVersion(params) {
648
+ await runSchemaWriteTransaction(
649
+ params.graphId,
650
+ (target) => target.setActiveVersion(params)
651
+ );
652
+ },
653
+ async transaction(fn, options2) {
654
+ const txConfig = options2?.isolationLevel ? {
655
+ isolationLevel: options2.isolationLevel.replace("_", " ")
656
+ } : void 0;
657
+ return db.transaction(async (tx) => {
658
+ const { backend: txBackend, drainAndClose } = bindTransactionBackend(tx);
659
+ try {
660
+ return await fn(txBackend, tx);
661
+ } finally {
662
+ await drainAndClose();
663
+ }
664
+ }, txConfig);
665
+ },
666
+ adoptTransaction(externalTx) {
667
+ if (!capabilities.transactions) {
668
+ throw new chunkDIK74MXX_cjs.ConfigurationError(
669
+ "Cross-store atomicity is unavailable on this Postgres backend: its driver does not support transactions (drizzle-orm/neon-http, Cloudflare D1). Adopting an external transaction here would let the caller's relational write commit with no way to roll back the graph write. Use a node-postgres or neon-serverless (Pool/WebSocket) connection for cross-store transactions.",
670
+ {
671
+ backend: "postgres",
672
+ capability: "transactions",
673
+ supportsTransactions: false
674
+ }
675
+ );
676
+ }
677
+ chunk456Z2U7Y_cjs.assertAdoptedDialect(externalTx, pgCore.PgDatabase, "postgres");
678
+ return bindTransactionBackend(externalTx).backend;
679
+ },
680
+ async close() {
681
+ }
682
+ };
683
+ return backend;
684
+ }
685
+ function createIterativeScanProbe() {
686
+ let probe;
687
+ let warned = false;
688
+ function warnUnavailable(version) {
689
+ if (warned) return;
690
+ warned = true;
691
+ if (typeof console === "undefined" || typeof console.warn !== "function") {
692
+ return;
693
+ }
694
+ console.warn(
695
+ `[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.`
696
+ );
697
+ }
698
+ return {
699
+ isSupported(execAll) {
700
+ probe ??= (async () => {
701
+ try {
702
+ const [row] = await execAll(
703
+ drizzleOrm.sql`SELECT extversion AS v FROM pg_extension WHERE extname = 'vector'`
704
+ );
705
+ if (typeof row?.v !== "string") return false;
706
+ const [major = 0, minor = 0] = row.v.split(".").map((part) => Number.parseInt(part, 10));
707
+ const supported = major > 0 || major === 0 && minor >= 8;
708
+ if (!supported) warnUnavailable(row.v);
709
+ return supported;
710
+ } catch {
711
+ return false;
712
+ }
713
+ })();
714
+ return probe;
715
+ }
716
+ };
717
+ }
718
+ function createPostgresOperationBackend(options) {
719
+ const {
720
+ db,
721
+ executionAdapter,
722
+ adapterOptions,
723
+ operationStrategy,
724
+ tableNames,
725
+ capabilities,
726
+ fulltextStrategy,
727
+ vectorStrategy,
728
+ vectorSlotLatch,
729
+ iterativeScanProbe
730
+ } = options;
731
+ async function execAll(query) {
732
+ return executionAdapter.execute(query);
733
+ }
734
+ async function execGet(query) {
735
+ const rows = await executionAdapter.execute(query);
736
+ return rows[0];
737
+ }
738
+ async function execRun(query) {
739
+ await executionAdapter.execute(query);
740
+ }
741
+ let efSearchUnsupportedWarned = false;
742
+ function warnEfSearchUnsupported() {
743
+ if (efSearchUnsupportedWarned) return;
744
+ efSearchUnsupportedWarned = true;
745
+ if (typeof console === "undefined" || typeof console.warn !== "function") {
746
+ return;
747
+ }
748
+ console.warn(
749
+ "[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."
750
+ );
751
+ }
752
+ function pgvectorIterativeScanSupported() {
753
+ return iterativeScanProbe.isSupported(execAll);
754
+ }
755
+ async function vectorSearchGucOverrides(params) {
756
+ const overrides = [];
757
+ if (params.efSearch !== void 0) {
758
+ if (capabilities.transactions) {
759
+ overrides.push({
760
+ name: "hnsw.ef_search",
761
+ value: String(params.efSearch)
762
+ });
763
+ } else {
764
+ warnEfSearchUnsupported();
765
+ }
766
+ }
767
+ if (params.indexType === "hnsw" && capabilities.transactions && await pgvectorIterativeScanSupported()) {
768
+ overrides.push({ name: "hnsw.iterative_scan", value: "strict_order" });
769
+ }
770
+ if (params.indexType === "ivfflat" && capabilities.transactions && await pgvectorIterativeScanSupported()) {
771
+ overrides.push({
772
+ name: "ivfflat.iterative_scan",
773
+ value: "relaxed_order"
774
+ });
775
+ }
776
+ return overrides;
777
+ }
778
+ async function runVectorSearchGucGroup(overrides, query) {
779
+ const runExclusive = executionAdapter.runExclusive;
780
+ if (runExclusive === void 0) {
781
+ throw new chunkDIK74MXX_cjs.CompilerInvariantError(
782
+ "A transaction-scoped Postgres backend must expose runExclusive; its execution adapter was not wrapped by createSerialExecutionAdapter."
783
+ );
784
+ }
785
+ return runExclusive(async (connection) => {
786
+ const snapshots = [];
787
+ for (const override of overrides) {
788
+ const [setting] = await connection.execute(
789
+ drizzleOrm.sql`SELECT current_setting(${override.name}) AS v`
790
+ );
791
+ if (setting !== void 0) {
792
+ snapshots.push({ name: override.name, value: setting.v });
793
+ }
794
+ await connection.execute(
795
+ drizzleOrm.sql`SELECT set_config(${override.name}, ${override.value}, true)`
796
+ );
797
+ }
798
+ const rows = await connection.execute(query);
799
+ for (const snapshot of snapshots) {
800
+ await connection.execute(
801
+ drizzleOrm.sql`SELECT set_config(${snapshot.name}, ${snapshot.value}, true)`
802
+ );
803
+ }
804
+ return rows;
805
+ });
806
+ }
807
+ async function runVectorSearch(overrides, query) {
808
+ if (overrides.length === 0) {
809
+ return execAll(query);
810
+ }
811
+ if (db instanceof pgCore.PgTransaction) {
812
+ return runVectorSearchGucGroup(overrides, query);
813
+ }
814
+ return db.transaction(async (tx) => {
815
+ const txAdapter = createPostgresExecutionAdapter(tx, adapterOptions);
816
+ for (const override of overrides) {
817
+ await txAdapter.execute(
818
+ drizzleOrm.sql`SELECT set_config(${override.name}, ${override.value}, true)`
819
+ );
820
+ }
821
+ return txAdapter.execute(query);
822
+ });
823
+ }
824
+ async function ensureVectorSlotStorage(slot) {
825
+ if (vectorStrategy === void 0 || vectorSlotLatch === void 0) return;
826
+ await vectorSlotLatch.ensure(vectorStrategy, slot, async (statement) => {
827
+ await execRun(drizzleOrm.sql.raw(statement));
828
+ });
829
+ }
830
+ const batchConfig = {
831
+ checkUniqueBatchChunkSize: POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE,
832
+ edgeInsertBatchSize: POSTGRES_EDGE_INSERT_BATCH_SIZE,
833
+ // Unlike the static siblings, the embedding upsert honors a runtime
834
+ // `maxBindParameters` override so its chunk size tracks the connection's
835
+ // actual bind budget.
836
+ embeddingUpsertBatchSize: Math.max(
837
+ 1,
838
+ Math.floor(
839
+ (capabilities.maxBindParameters ?? chunkX4JBT642_cjs.POSTGRES_MAX_BIND_PARAMETERS) / chunk456Z2U7Y_cjs.EMBEDDING_UPSERT_PARAM_COUNT
840
+ )
841
+ ),
842
+ getEdgesChunkSize: POSTGRES_GET_EDGES_ID_CHUNK_SIZE,
843
+ getNodesChunkSize: POSTGRES_GET_NODES_ID_CHUNK_SIZE,
844
+ nodeInsertBatchSize: POSTGRES_NODE_INSERT_BATCH_SIZE,
845
+ uniqueInsertBatchSize: POSTGRES_UNIQUE_INSERT_BATCH_SIZE
846
+ };
847
+ const commonBackend = chunk456Z2U7Y_cjs.createCommonOperationBackend({
848
+ batchConfig,
849
+ execution: {
850
+ execAll,
851
+ execGet,
852
+ execRun
853
+ },
854
+ nowIso: chunk5W4L6DLF_cjs.nowIso,
855
+ operationStrategy,
856
+ rowMappers: {
857
+ toEdgeRow,
858
+ toNodeRow,
859
+ toSchemaVersionRow,
860
+ toUniqueRow
861
+ },
862
+ tableExistenceCache: { cacheExisting: false }
863
+ });
864
+ const executeCompiled = executionAdapter.executeCompiled;
865
+ const executeRawMethod = executeCompiled === void 0 ? {} : {
866
+ async executeRaw(sqlText, params) {
867
+ return executeCompiled({ params, sql: sqlText });
868
+ }
869
+ };
870
+ const vectorEmbeddingMethods = vectorStrategy === void 0 ? {} : {
871
+ async upsertEmbedding(params) {
872
+ const slot = chunk456Z2U7Y_cjs.vectorSlotFromParams(params);
873
+ await ensureVectorSlotStorage(slot);
874
+ const statements = vectorStrategy.buildUpsert(slot, params, chunk5W4L6DLF_cjs.nowIso());
875
+ try {
876
+ for (const statement of statements) {
877
+ await execRun(statement);
878
+ }
879
+ } catch (error) {
880
+ throw chunk456Z2U7Y_cjs.mapVectorWriteError(error, params);
881
+ }
882
+ },
883
+ async upsertEmbeddingBatch(params) {
884
+ if (params.rows.length === 0) return;
885
+ const slot = chunk456Z2U7Y_cjs.vectorSlotFromParams(params);
886
+ await ensureVectorSlotStorage(slot);
887
+ const rowsById = new Map(
888
+ params.rows.map((row) => [row.nodeId, row])
889
+ );
890
+ const rows = [...rowsById.values()];
891
+ const timestamp = chunk5W4L6DLF_cjs.nowIso();
892
+ try {
893
+ for (const chunk2 of chunkX4JBT642_cjs.chunk(
894
+ rows,
895
+ batchConfig.embeddingUpsertBatchSize
896
+ )) {
897
+ const statements = vectorStrategy.buildUpsertBatch === void 0 ? chunk2.flatMap(
898
+ (row) => vectorStrategy.buildUpsert(
899
+ slot,
900
+ {
901
+ graphId: params.graphId,
902
+ nodeKind: params.nodeKind,
903
+ nodeId: row.nodeId,
904
+ fieldPath: params.fieldPath,
905
+ embedding: row.embedding,
906
+ dimensions: params.dimensions,
907
+ metric: params.metric,
908
+ indexType: params.indexType
909
+ },
910
+ timestamp
911
+ )
912
+ ) : vectorStrategy.buildUpsertBatch(
913
+ slot,
914
+ { ...params, rows: chunk2 },
915
+ timestamp
916
+ );
917
+ for (const statement of statements) {
918
+ await execRun(statement);
919
+ }
920
+ }
921
+ } catch (error) {
922
+ throw chunk456Z2U7Y_cjs.mapVectorWriteError(error, params);
923
+ }
924
+ },
925
+ async deleteEmbedding(params) {
926
+ const slot = chunk456Z2U7Y_cjs.vectorSlotFromParams(params);
927
+ await ensureVectorSlotStorage(slot);
928
+ const statements = vectorStrategy.buildDelete(slot, params);
929
+ for (const statement of statements) {
930
+ await execRun(statement);
931
+ }
932
+ },
933
+ async vectorSearch(params) {
934
+ chunkD7ZEOS56_cjs.assertVectorSearchLimit(params.limit);
935
+ chunkTCOCYN2P_cjs.assertPgvectorEfSearch(params.efSearch);
936
+ const slot = chunk456Z2U7Y_cjs.vectorSlotFromParams(params);
937
+ await ensureVectorSlotStorage(slot);
938
+ const query = vectorStrategy.buildSearch(
939
+ slot,
940
+ params,
941
+ // Store-compiled candidates (predicates + subclass + currency)
942
+ // take precedence; the live-node default covers direct backend use.
943
+ params.candidates ?? operationStrategy.buildLiveNodeIds(
944
+ params.graphId,
945
+ params.nodeKind
946
+ )
947
+ );
948
+ const gucOverrides = await vectorSearchGucOverrides(params);
949
+ let rows;
950
+ try {
951
+ rows = await runVectorSearch(gucOverrides, query);
952
+ } catch (error) {
953
+ throw chunk456Z2U7Y_cjs.mapVectorWriteError(error, params);
954
+ }
955
+ return rows.map((row) => ({
956
+ nodeId: row.node_id,
957
+ score: row.score
958
+ }));
959
+ },
960
+ // Single-statement hybrid needs ROW_NUMBER(); a capability
961
+ // profile that disables window functions keeps the store's
962
+ // multi-statement fallback by simply not exposing the member.
963
+ ...capabilities.windowFunctions ? {
964
+ async hybridSearch(params) {
965
+ chunkD7ZEOS56_cjs.assertVectorSearchLimit(params.limit);
966
+ chunkD7ZEOS56_cjs.assertVectorSearchLimit(params.vector.k);
967
+ chunkTCOCYN2P_cjs.assertPgvectorEfSearch(params.vector.efSearch);
968
+ const slot = chunk456Z2U7Y_cjs.vectorSlotFromParams({
969
+ graphId: params.graphId,
970
+ nodeKind: params.nodeKind,
971
+ fieldPath: params.vector.fieldPath,
972
+ dimensions: params.vector.dimensions,
973
+ metric: params.vector.metric,
974
+ indexType: params.vector.indexType
975
+ });
976
+ await ensureVectorSlotStorage(slot);
977
+ const candidates = params.candidates ?? operationStrategy.buildLiveNodeIds(
978
+ params.graphId,
979
+ params.nodeKind
980
+ );
981
+ const vectorParams = {
982
+ graphId: params.graphId,
983
+ nodeKind: params.nodeKind,
984
+ fieldPath: params.vector.fieldPath,
985
+ queryEmbedding: params.vector.queryEmbedding,
986
+ metric: params.vector.metric,
987
+ dimensions: params.vector.dimensions,
988
+ indexType: params.vector.indexType,
989
+ limit: params.vector.k,
990
+ ...params.vector.minScore === void 0 ? {} : { minScore: params.vector.minScore }
991
+ };
992
+ const vectorSql = vectorStrategy.buildSearch(
993
+ slot,
994
+ vectorParams,
995
+ chunk456Z2U7Y_cjs.hybridCandidatesRef()
996
+ );
997
+ const statement = operationStrategy.buildHybridSearch(
998
+ { ...params, candidates },
999
+ vectorSql,
1000
+ params.vector.metric === "cosine"
1001
+ );
1002
+ const gucOverrides = await vectorSearchGucOverrides({
1003
+ indexType: params.vector.indexType,
1004
+ ...params.vector.efSearch === void 0 ? {} : { efSearch: params.vector.efSearch }
1005
+ });
1006
+ let raw;
1007
+ try {
1008
+ raw = await runVectorSearch(
1009
+ gucOverrides,
1010
+ statement
1011
+ );
1012
+ } catch (error) {
1013
+ throw chunk456Z2U7Y_cjs.mapVectorWriteError(error, vectorParams);
1014
+ }
1015
+ return raw.map((row) => chunk456Z2U7Y_cjs.mapHybridSearchRow(row, toNodeRow));
1016
+ }
1017
+ } : {}
1018
+ };
1019
+ const operationBackend = {
1020
+ ...commonBackend,
1021
+ ...executeRawMethod,
1022
+ ...vectorEmbeddingMethods,
1023
+ capabilities,
1024
+ fulltextStrategy,
1025
+ ...vectorStrategy === void 0 ? {} : { vectorStrategy },
1026
+ dialect: "postgres",
1027
+ tableNames,
1028
+ // === Vector Index Operations ===
1029
+ async createVectorIndex(params) {
1030
+ if (vectorStrategy === void 0) return;
1031
+ const slot = chunk456Z2U7Y_cjs.vectorSlotFromCreateIndexParams(params);
1032
+ await ensureVectorSlotStorage(slot);
1033
+ const indexStatement = vectorStrategy.buildCreateIndex?.(slot, {
1034
+ concurrent: params.concurrent === true
1035
+ });
1036
+ if (indexStatement !== void 0) {
1037
+ try {
1038
+ await execRun(indexStatement);
1039
+ } catch (error) {
1040
+ if (!chunkRSSQKPSZ_cjs.isInsufficientResourcesError(error)) throw error;
1041
+ const dropStatement = vectorStrategy.buildDropIndex?.(slot);
1042
+ if (dropStatement !== void 0) {
1043
+ await execRun(dropStatement);
1044
+ }
1045
+ const table = chunk5W4L6DLF_cjs.quoteIdentifier(
1046
+ vectorStrategy.tableName(
1047
+ slot.graphId,
1048
+ slot.nodeKind,
1049
+ slot.fieldPath
1050
+ )
1051
+ );
1052
+ await execRun(
1053
+ drizzleOrm.sql`ALTER TABLE ${table} SET (parallel_workers = 0)`
1054
+ );
1055
+ try {
1056
+ await execRun(indexStatement);
1057
+ } finally {
1058
+ await execRun(drizzleOrm.sql`ALTER TABLE ${table} RESET (parallel_workers)`);
1059
+ }
1060
+ }
1061
+ }
1062
+ },
1063
+ // === Fulltext Operations ===
1064
+ async upsertFulltext(params) {
1065
+ const timestamp = chunk5W4L6DLF_cjs.nowIso();
1066
+ const statements = operationStrategy.buildUpsertFulltext(
1067
+ params,
1068
+ timestamp
1069
+ );
1070
+ for (const stmt of statements) {
1071
+ await execRun(stmt);
1072
+ }
1073
+ },
1074
+ async deleteFulltext(params) {
1075
+ const statements = operationStrategy.buildDeleteFulltext(params);
1076
+ for (const stmt of statements) {
1077
+ await execRun(stmt);
1078
+ }
1079
+ },
1080
+ async upsertFulltextBatch(params) {
1081
+ if (params.rows.length === 0) return;
1082
+ const timestamp = chunk5W4L6DLF_cjs.nowIso();
1083
+ for (const rows of chunkX4JBT642_cjs.chunk(
1084
+ params.rows,
1085
+ POSTGRES_FULLTEXT_UPSERT_BATCH_SIZE
1086
+ )) {
1087
+ const statements = operationStrategy.buildUpsertFulltextBatch(
1088
+ { ...params, rows },
1089
+ timestamp
1090
+ );
1091
+ for (const stmt of statements) {
1092
+ await execRun(stmt);
1093
+ }
1094
+ }
1095
+ },
1096
+ async deleteFulltextBatch(params) {
1097
+ if (params.nodeIds.length === 0) return;
1098
+ for (const nodeIds of chunkX4JBT642_cjs.chunk(
1099
+ params.nodeIds,
1100
+ POSTGRES_FULLTEXT_DELETE_CHUNK_SIZE
1101
+ )) {
1102
+ const statements = operationStrategy.buildDeleteFulltextBatch({
1103
+ ...params,
1104
+ nodeIds
1105
+ });
1106
+ for (const stmt of statements) {
1107
+ await execRun(stmt);
1108
+ }
1109
+ }
1110
+ },
1111
+ async fulltextSearch(params) {
1112
+ const query = operationStrategy.buildFulltextSearch(params);
1113
+ const rows = await execAll(query);
1114
+ return rows.map((row, index) => ({
1115
+ nodeId: row.node_id,
1116
+ score: chunk5W4L6DLF_cjs.coerceNumericScore(row.score),
1117
+ rank: index + 1,
1118
+ ...row.snippet === null ? {} : { snippet: row.snippet }
1119
+ }));
1120
+ },
1121
+ async dropVectorIndex(params) {
1122
+ if (vectorStrategy === void 0) return;
1123
+ const slot = chunk456Z2U7Y_cjs.vectorSlotFromDropIndexParams(params);
1124
+ const dropStatement = vectorStrategy.buildDropIndex?.(slot);
1125
+ if (dropStatement === void 0) return;
1126
+ try {
1127
+ await execRun(dropStatement);
1128
+ } catch (error) {
1129
+ if (!chunkRSSQKPSZ_cjs.isMissingTableError(error)) throw error;
1130
+ }
1131
+ },
1132
+ // === Query Execution ===
1133
+ async execute(query) {
1134
+ const annTypes = chunkEOLERH7Y_cjs.annIndexScanTypes(query);
1135
+ if (annTypes !== void 0 && vectorStrategy !== void 0) {
1136
+ const overrides = [];
1137
+ for (const indexType of annTypes) {
1138
+ if (indexType !== "hnsw" && indexType !== "ivfflat") continue;
1139
+ overrides.push(
1140
+ ...await vectorSearchGucOverrides({ indexType })
1141
+ );
1142
+ }
1143
+ return runVectorSearch(overrides, query);
1144
+ }
1145
+ return executionAdapter.execute(query);
1146
+ },
1147
+ compileSql(query) {
1148
+ return executionAdapter.compile(query);
1149
+ }
1150
+ };
1151
+ return operationBackend;
1152
+ }
1153
+ function createTransactionBackend(options) {
1154
+ const txExecutionAdapter = createSerialExecutionAdapter(
1155
+ createPostgresExecutionAdapter(options.db, options.adapterOptions)
1156
+ );
1157
+ const backend = createPostgresOperationBackend({
1158
+ db: options.db,
1159
+ executionAdapter: txExecutionAdapter,
1160
+ adapterOptions: options.adapterOptions,
1161
+ operationStrategy: options.operationStrategy,
1162
+ tableNames: options.tableNames,
1163
+ capabilities: options.capabilities,
1164
+ fulltextStrategy: options.fulltextStrategy,
1165
+ vectorStrategy: options.vectorStrategy,
1166
+ vectorSlotLatch: options.vectorStrategy === void 0 ? void 0 : chunk456Z2U7Y_cjs.createVectorSlotLatch(),
1167
+ // The probe is process-wide truth, so — unlike the slot latch — the outer
1168
+ // instance's is reused rather than a fresh one per transaction.
1169
+ iterativeScanProbe: options.iterativeScanProbe
1170
+ });
1171
+ return { backend, drainAndClose: txExecutionAdapter.drainAndClose };
1172
+ }
1173
+
1174
+ exports.createPostgresBackend = createPostgresBackend;
1175
+ //# sourceMappingURL=chunk-ZAMFOJ5P.cjs.map
1176
+ //# sourceMappingURL=chunk-ZAMFOJ5P.cjs.map