@nicia-ai/typegraph 0.45.0 → 0.46.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 (384) hide show
  1. package/dist/backend/drizzle/indexes.cjs +11 -11
  2. package/dist/backend/drizzle/indexes.d.cts +1 -1
  3. package/dist/backend/drizzle/indexes.d.ts +1 -1
  4. package/dist/backend/drizzle/indexes.js +7 -7
  5. package/dist/backend/index.cjs +53 -54
  6. package/dist/backend/index.d.cts +3 -3
  7. package/dist/backend/index.d.ts +3 -3
  8. package/dist/backend/index.js +13 -14
  9. package/dist/backend/postgres/index.cjs +29 -30
  10. package/dist/backend/postgres/index.d.cts +7 -7
  11. package/dist/backend/postgres/index.d.ts +7 -7
  12. package/dist/backend/postgres/index.js +16 -17
  13. package/dist/backend/postgres/pglite-store.cjs +48 -42
  14. package/dist/backend/postgres/pglite-store.cjs.map +1 -1
  15. package/dist/backend/postgres/pglite-store.d.cts +15 -9
  16. package/dist/backend/postgres/pglite-store.d.ts +15 -9
  17. package/dist/backend/postgres/pglite-store.js +44 -38
  18. package/dist/backend/postgres/pglite-store.js.map +1 -1
  19. package/dist/backend/postgres/pglite.cjs +18 -19
  20. package/dist/backend/postgres/pglite.d.cts +4 -4
  21. package/dist/backend/postgres/pglite.d.ts +4 -4
  22. package/dist/backend/postgres/pglite.js +17 -18
  23. package/dist/backend/sqlite/index.cjs +26 -27
  24. package/dist/backend/sqlite/index.d.cts +6 -6
  25. package/dist/backend/sqlite/index.d.ts +6 -6
  26. package/dist/backend/sqlite/index.js +14 -15
  27. package/dist/backend/sqlite/libsql.cjs +21 -22
  28. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  29. package/dist/backend/sqlite/libsql.d.cts +15 -8
  30. package/dist/backend/sqlite/libsql.d.ts +15 -8
  31. package/dist/backend/sqlite/libsql.js +17 -18
  32. package/dist/backend/sqlite/libsql.js.map +1 -1
  33. package/dist/backend/sqlite/local-store.cjs +49 -43
  34. package/dist/backend/sqlite/local-store.cjs.map +1 -1
  35. package/dist/backend/sqlite/local-store.d.cts +15 -10
  36. package/dist/backend/sqlite/local-store.d.ts +15 -10
  37. package/dist/backend/sqlite/local-store.js +45 -39
  38. package/dist/backend/sqlite/local-store.js.map +1 -1
  39. package/dist/backend/sqlite/local.cjs +19 -20
  40. package/dist/backend/sqlite/local.d.cts +3 -3
  41. package/dist/backend/sqlite/local.d.ts +3 -3
  42. package/dist/backend/sqlite/local.js +17 -18
  43. package/dist/{chunk-S3ZRKJHY.js → chunk-2LG2XB2M.js} +3 -3
  44. package/dist/{chunk-S3ZRKJHY.js.map → chunk-2LG2XB2M.js.map} +1 -1
  45. package/dist/{chunk-7PF2L3H6.cjs → chunk-2NA5DYLO.cjs} +4 -4
  46. package/dist/{chunk-7PF2L3H6.cjs.map → chunk-2NA5DYLO.cjs.map} +1 -1
  47. package/dist/{chunk-VVQM4CZD.cjs → chunk-3DHZCOT7.cjs} +20 -20
  48. package/dist/{chunk-VVQM4CZD.cjs.map → chunk-3DHZCOT7.cjs.map} +1 -1
  49. package/dist/{chunk-JXUTCSXX.cjs → chunk-4UGOKMI5.cjs} +250 -158
  50. package/dist/chunk-4UGOKMI5.cjs.map +1 -0
  51. package/dist/{chunk-RFRM3Q5K.js → chunk-5262ZMTR.js} +14 -5
  52. package/dist/chunk-5262ZMTR.js.map +1 -0
  53. package/dist/{chunk-QRNYDV5Z.js → chunk-5763DULU.js} +214 -69
  54. package/dist/chunk-5763DULU.js.map +1 -0
  55. package/dist/{chunk-BGYJW37L.js → chunk-5UVRGXD3.js} +277 -7
  56. package/dist/chunk-5UVRGXD3.js.map +1 -0
  57. package/dist/{chunk-QR24DJDF.cjs → chunk-62ZP23AW.cjs} +15 -15
  58. package/dist/{chunk-QR24DJDF.cjs.map → chunk-62ZP23AW.cjs.map} +1 -1
  59. package/dist/{chunk-S4KQ5LV4.js → chunk-775A4ZMN.js} +40 -6
  60. package/dist/chunk-775A4ZMN.js.map +1 -0
  61. package/dist/{chunk-J2ICGNHO.cjs → chunk-7BQXPCGN.cjs} +830 -169
  62. package/dist/chunk-7BQXPCGN.cjs.map +1 -0
  63. package/dist/{chunk-FJMPR3OH.cjs → chunk-7EO3TCQB.cjs} +33 -7
  64. package/dist/chunk-7EO3TCQB.cjs.map +1 -0
  65. package/dist/{chunk-UCQ3BFSY.cjs → chunk-7GT72YHH.cjs} +682 -332
  66. package/dist/chunk-7GT72YHH.cjs.map +1 -0
  67. package/dist/{chunk-DXEEHSGN.js → chunk-7VQXLT5O.js} +436 -43
  68. package/dist/chunk-7VQXLT5O.js.map +1 -0
  69. package/dist/{chunk-ID4WXTKL.js → chunk-7Z5OR7KO.js} +2360 -605
  70. package/dist/chunk-7Z5OR7KO.js.map +1 -0
  71. package/dist/chunk-A4OC4DVN.cjs +12 -0
  72. package/dist/{chunk-4SZ6XPTG.cjs.map → chunk-A4OC4DVN.cjs.map} +1 -1
  73. package/dist/{chunk-TDXIBCGY.cjs → chunk-A7J2YDDI.cjs} +5 -3
  74. package/dist/chunk-A7J2YDDI.cjs.map +1 -0
  75. package/dist/{chunk-55ITBQJI.js → chunk-AKLS3BYZ.js} +56 -5
  76. package/dist/chunk-AKLS3BYZ.js.map +1 -0
  77. package/dist/{chunk-D7PG5D5K.js → chunk-AMKPPFUO.js} +32 -6
  78. package/dist/chunk-AMKPPFUO.js.map +1 -0
  79. package/dist/{chunk-WUFASQUO.js → chunk-ASTI57H3.js} +3 -3
  80. package/dist/{chunk-WUFASQUO.js.map → chunk-ASTI57H3.js.map} +1 -1
  81. package/dist/{chunk-4QIKLIGG.js → chunk-BKCUOV7A.js} +15 -5
  82. package/dist/chunk-BKCUOV7A.js.map +1 -0
  83. package/dist/{chunk-JQXSZHF2.cjs → chunk-BSFJMMV3.cjs} +134 -7
  84. package/dist/chunk-BSFJMMV3.cjs.map +1 -0
  85. package/dist/{chunk-4GUTQPVO.js → chunk-C23WSN5E.js} +185 -24
  86. package/dist/chunk-C23WSN5E.js.map +1 -0
  87. package/dist/{chunk-QLUXRWKL.js → chunk-CBTIUB76.js} +3 -3
  88. package/dist/{chunk-QLUXRWKL.js.map → chunk-CBTIUB76.js.map} +1 -1
  89. package/dist/chunk-CNV4TXJG.js +58 -0
  90. package/dist/chunk-CNV4TXJG.js.map +1 -0
  91. package/dist/{chunk-QB6VMOJ2.cjs → chunk-CXBHOOIQ.cjs} +45 -10
  92. package/dist/chunk-CXBHOOIQ.cjs.map +1 -0
  93. package/dist/{chunk-FL5UQRES.js → chunk-DCQVHAYQ.js} +5 -5
  94. package/dist/{chunk-FL5UQRES.js.map → chunk-DCQVHAYQ.js.map} +1 -1
  95. package/dist/chunk-DLNROMQ7.js +306 -0
  96. package/dist/chunk-DLNROMQ7.js.map +1 -0
  97. package/dist/chunk-DYATYRY4.js +47 -0
  98. package/dist/chunk-DYATYRY4.js.map +1 -0
  99. package/dist/chunk-E4WNQBEF.cjs +217 -0
  100. package/dist/chunk-E4WNQBEF.cjs.map +1 -0
  101. package/dist/{chunk-G6Q5UM7U.js → chunk-FWJKWH6U.js} +5 -3
  102. package/dist/chunk-FWJKWH6U.js.map +1 -0
  103. package/dist/{chunk-VTN3C3CH.js → chunk-HFHTMECK.js} +7 -7
  104. package/dist/{chunk-VTN3C3CH.js.map → chunk-HFHTMECK.js.map} +1 -1
  105. package/dist/{chunk-FLEQ2HBK.js → chunk-I5MOXA4H.js} +20 -14
  106. package/dist/chunk-I5MOXA4H.js.map +1 -0
  107. package/dist/{chunk-4MB3AQAQ.js → chunk-J3WZ3FA2.js} +77 -3
  108. package/dist/chunk-J3WZ3FA2.js.map +1 -0
  109. package/dist/{chunk-UR7W5YQK.js → chunk-JBQQ7THH.js} +5 -3
  110. package/dist/chunk-JBQQ7THH.js.map +1 -0
  111. package/dist/chunk-JIVMTW7W.js +3393 -0
  112. package/dist/chunk-JIVMTW7W.js.map +1 -0
  113. package/dist/{chunk-TKP5T34P.js → chunk-JXA2ZP2Q.js} +6 -16
  114. package/dist/chunk-JXA2ZP2Q.js.map +1 -0
  115. package/dist/{chunk-GYA4JRP5.js → chunk-JXXDZTMN.js} +2 -2
  116. package/dist/chunk-JXXDZTMN.js.map +1 -0
  117. package/dist/chunk-JZUR7ZWE.js +254 -0
  118. package/dist/chunk-JZUR7ZWE.js.map +1 -0
  119. package/dist/{chunk-42PYUGLS.js → chunk-K5ELX2GT.js} +108 -8
  120. package/dist/chunk-K5ELX2GT.js.map +1 -0
  121. package/dist/{chunk-D54WH24V.cjs → chunk-LBJKZXDE.cjs} +115 -13
  122. package/dist/chunk-LBJKZXDE.cjs.map +1 -0
  123. package/dist/{chunk-4MEWSUVM.cjs → chunk-M4BDU5RX.cjs} +12 -12
  124. package/dist/chunk-M4BDU5RX.cjs.map +1 -0
  125. package/dist/{chunk-MIJKEVV7.js → chunk-MSY7FSX4.js} +37 -4
  126. package/dist/chunk-MSY7FSX4.js.map +1 -0
  127. package/dist/{chunk-H7VE3FL4.cjs → chunk-MUK4BU7K.cjs} +519 -125
  128. package/dist/chunk-MUK4BU7K.cjs.map +1 -0
  129. package/dist/{chunk-D56XG4EI.cjs → chunk-MXJDTH5B.cjs} +56 -45
  130. package/dist/chunk-MXJDTH5B.cjs.map +1 -0
  131. package/dist/{chunk-ZI6VQSZA.cjs → chunk-N3257XE6.cjs} +724 -577
  132. package/dist/chunk-N3257XE6.cjs.map +1 -0
  133. package/dist/chunk-N66HCGCY.cjs +57 -0
  134. package/dist/chunk-N66HCGCY.cjs.map +1 -0
  135. package/dist/{chunk-CPEL3YIR.cjs → chunk-NFCVHQ5P.cjs} +55 -22
  136. package/dist/chunk-NFCVHQ5P.cjs.map +1 -0
  137. package/dist/{chunk-C4F7VJ5D.cjs → chunk-NI72YOJB.cjs} +84 -2
  138. package/dist/chunk-NI72YOJB.cjs.map +1 -0
  139. package/dist/{chunk-BNS75YNF.cjs → chunk-NK5Q7UNE.cjs} +10 -20
  140. package/dist/chunk-NK5Q7UNE.cjs.map +1 -0
  141. package/dist/{chunk-YMTXMPV6.js → chunk-NMWDXFPH.js} +4 -4
  142. package/dist/{chunk-YMTXMPV6.js.map → chunk-NMWDXFPH.js.map} +1 -1
  143. package/dist/{chunk-TKORQCG4.js → chunk-NQ6BRJBE.js} +386 -862
  144. package/dist/chunk-NQ6BRJBE.js.map +1 -0
  145. package/dist/chunk-OH5E5KIO.js +2057 -0
  146. package/dist/chunk-OH5E5KIO.js.map +1 -0
  147. package/dist/chunk-ONU3HIED.cjs +2082 -0
  148. package/dist/chunk-ONU3HIED.cjs.map +1 -0
  149. package/dist/{chunk-NAAMUYMS.cjs → chunk-PNN7RHVR.cjs} +58 -48
  150. package/dist/chunk-PNN7RHVR.cjs.map +1 -0
  151. package/dist/{chunk-6DCB664D.js → chunk-PQBQG7IM.js} +3 -3
  152. package/dist/{chunk-6DCB664D.js.map → chunk-PQBQG7IM.js.map} +1 -1
  153. package/dist/{chunk-ACSVZPK7.cjs → chunk-PWLJ77UV.cjs} +5 -3
  154. package/dist/chunk-PWLJ77UV.cjs.map +1 -0
  155. package/dist/chunk-Q7Q4WSLJ.cjs +328 -0
  156. package/dist/chunk-Q7Q4WSLJ.cjs.map +1 -0
  157. package/dist/{chunk-FQ7ZPOTZ.js → chunk-QLRESYPU.js} +637 -493
  158. package/dist/chunk-QLRESYPU.js.map +1 -0
  159. package/dist/{chunk-Q6EDCUXV.js → chunk-QWX5YA3K.js} +554 -204
  160. package/dist/chunk-QWX5YA3K.js.map +1 -0
  161. package/dist/{chunk-5EKPX6QU.js → chunk-RJS7DECT.js} +8 -9
  162. package/dist/chunk-RJS7DECT.js.map +1 -0
  163. package/dist/{chunk-Z3WO6MND.cjs → chunk-RMQLSPA2.cjs} +297 -27
  164. package/dist/chunk-RMQLSPA2.cjs.map +1 -0
  165. package/dist/{chunk-SJDMVITW.cjs → chunk-RT5ZY4XA.cjs} +6 -5
  166. package/dist/chunk-RT5ZY4XA.cjs.map +1 -0
  167. package/dist/{chunk-4GUBTVPV.js → chunk-T4XNKYXB.js} +780 -126
  168. package/dist/chunk-T4XNKYXB.js.map +1 -0
  169. package/dist/{chunk-YDWLUT5V.cjs → chunk-TQR4KBY2.cjs} +323 -178
  170. package/dist/chunk-TQR4KBY2.cjs.map +1 -0
  171. package/dist/chunk-TTAITEPJ.cjs +755 -0
  172. package/dist/chunk-TTAITEPJ.cjs.map +1 -0
  173. package/dist/{chunk-OOA273IJ.cjs → chunk-U5SON7R2.cjs} +27 -27
  174. package/dist/{chunk-OOA273IJ.cjs.map → chunk-U5SON7R2.cjs.map} +1 -1
  175. package/dist/{chunk-IX64T5OL.cjs → chunk-U63GDNRC.cjs} +32 -26
  176. package/dist/chunk-U63GDNRC.cjs.map +1 -0
  177. package/dist/{chunk-WDBXJOU5.cjs → chunk-UDISNXDL.cjs} +56 -47
  178. package/dist/chunk-UDISNXDL.cjs.map +1 -0
  179. package/dist/{chunk-EFEOOCJ3.js → chunk-UV3SN74I.js} +5 -5
  180. package/dist/{chunk-EFEOOCJ3.js.map → chunk-UV3SN74I.js.map} +1 -1
  181. package/dist/{chunk-U5W4LKZV.cjs → chunk-VCRRKBLN.cjs} +9 -9
  182. package/dist/{chunk-U5W4LKZV.cjs.map → chunk-VCRRKBLN.cjs.map} +1 -1
  183. package/dist/{chunk-ISLPNELU.js → chunk-VGTJPTIC.js} +16 -5
  184. package/dist/chunk-VGTJPTIC.js.map +1 -0
  185. package/dist/chunk-VQH4VAWD.cjs +12 -0
  186. package/dist/{chunk-B3F2D3SP.cjs.map → chunk-VQH4VAWD.cjs.map} +1 -1
  187. package/dist/{chunk-SNXVDZAJ.js → chunk-W6OG3HDG.js} +5 -4
  188. package/dist/chunk-W6OG3HDG.js.map +1 -0
  189. package/dist/chunk-WDGA7IYB.js +207 -0
  190. package/dist/chunk-WDGA7IYB.js.map +1 -0
  191. package/dist/chunk-WEVQJ5LH.js +736 -0
  192. package/dist/chunk-WEVQJ5LH.js.map +1 -0
  193. package/dist/{chunk-EKFUG4G7.cjs → chunk-XBYVV3MP.cjs} +60 -5
  194. package/dist/chunk-XBYVV3MP.cjs.map +1 -0
  195. package/dist/{chunk-5GAONX5G.cjs → chunk-XCAGZAKP.cjs} +7 -7
  196. package/dist/{chunk-5GAONX5G.cjs.map → chunk-XCAGZAKP.cjs.map} +1 -1
  197. package/dist/{chunk-YOALGKRE.cjs → chunk-XDF2UPEQ.cjs} +3521 -1766
  198. package/dist/chunk-XDF2UPEQ.cjs.map +1 -0
  199. package/dist/{chunk-J7LXTUTP.cjs → chunk-XMQSEJCF.cjs} +604 -1094
  200. package/dist/chunk-XMQSEJCF.cjs.map +1 -0
  201. package/dist/chunk-XNLIZYRZ.cjs +3432 -0
  202. package/dist/chunk-XNLIZYRZ.cjs.map +1 -0
  203. package/dist/{chunk-KMXWZLQX.cjs → chunk-XNSI2FJO.cjs} +99 -100
  204. package/dist/chunk-XNSI2FJO.cjs.map +1 -0
  205. package/dist/chunk-XQSCL77R.cjs +60 -0
  206. package/dist/chunk-XQSCL77R.cjs.map +1 -0
  207. package/dist/{chunk-SVJ5GEXW.cjs → chunk-XUO3KQFO.cjs} +2 -2
  208. package/dist/chunk-XUO3KQFO.cjs.map +1 -0
  209. package/dist/{chunk-F4NHQHEZ.cjs → chunk-YAAM3M2S.cjs} +10 -10
  210. package/dist/{chunk-F4NHQHEZ.cjs.map → chunk-YAAM3M2S.cjs.map} +1 -1
  211. package/dist/{chunk-RUQS6M7G.js → chunk-YBFHZUXX.js} +6 -6
  212. package/dist/chunk-YBFHZUXX.js.map +1 -0
  213. package/dist/{chunk-PVUI6KGR.js → chunk-YDFDBE6D.js} +93 -6
  214. package/dist/chunk-YDFDBE6D.js.map +1 -0
  215. package/dist/{chunk-P7GTYOLB.cjs → chunk-YVWGEQJE.cjs} +297 -135
  216. package/dist/chunk-YVWGEQJE.cjs.map +1 -0
  217. package/dist/{chunk-QT6V3YRH.js → chunk-YWGVVALJ.js} +3 -3
  218. package/dist/{chunk-QT6V3YRH.js.map → chunk-YWGVVALJ.js.map} +1 -1
  219. package/dist/core/index.cjs +40 -40
  220. package/dist/core/index.d.cts +4 -5
  221. package/dist/core/index.d.ts +4 -5
  222. package/dist/core/index.js +8 -8
  223. package/dist/{ddl-BG4J805L.d.cts → ddl-BJcOp4WZ.d.cts} +3 -3
  224. package/dist/{ddl-CgiS9QLj.d.ts → ddl-BXfGHbPN.d.ts} +3 -3
  225. package/dist/graph-extension/index.cjs +26 -22
  226. package/dist/graph-extension/index.d.cts +16 -6
  227. package/dist/graph-extension/index.d.ts +16 -6
  228. package/dist/graph-extension/index.js +7 -7
  229. package/dist/graph-merge/index.cjs +2459 -654
  230. package/dist/graph-merge/index.cjs.map +1 -1
  231. package/dist/graph-merge/index.d.cts +170 -33
  232. package/dist/graph-merge/index.d.ts +170 -33
  233. package/dist/graph-merge/index.js +2269 -467
  234. package/dist/graph-merge/index.js.map +1 -1
  235. package/dist/{index-C3y_98iN.d.cts → index-BSHvKfok.d.ts} +221 -10
  236. package/dist/{index-BBxZCUdu.d.ts → index-DxaYCv8Y.d.cts} +221 -10
  237. package/dist/index.cjs +330 -268
  238. package/dist/index.cjs.map +1 -1
  239. package/dist/index.d.cts +590 -576
  240. package/dist/index.d.ts +590 -576
  241. package/dist/index.js +73 -49
  242. package/dist/index.js.map +1 -1
  243. package/dist/indexes/index.cjs +17 -17
  244. package/dist/indexes/index.d.cts +4 -4
  245. package/dist/indexes/index.d.ts +4 -4
  246. package/dist/indexes/index.js +10 -10
  247. package/dist/interchange/index.cjs +165 -51
  248. package/dist/interchange/index.cjs.map +1 -1
  249. package/dist/interchange/index.d.cts +261 -16
  250. package/dist/interchange/index.d.ts +261 -16
  251. package/dist/interchange/index.js +128 -25
  252. package/dist/interchange/index.js.map +1 -1
  253. package/dist/{manager-YoLEfcc1.d.ts → manager-CfZAimti.d.ts} +36 -5
  254. package/dist/{manager-KS7CGQQT.d.cts → manager-HGk6E_HW.d.cts} +36 -5
  255. package/dist/{materialize-indexes-Bhhyb1B3.d.ts → materialize-indexes-6A7dWGtb.d.cts} +10 -2
  256. package/dist/{materialize-indexes-OHRWypW6.d.cts → materialize-indexes-BMJP6Tms.d.ts} +10 -2
  257. package/dist/{postgres-DpkW3R5Y.d.cts → postgres-DFYWENdR.d.cts} +1961 -439
  258. package/dist/{postgres-DwqyIniy.d.ts → postgres-e7a9TdvR.d.ts} +1961 -439
  259. package/dist/profiler/index.cjs +15 -15
  260. package/dist/profiler/index.d.cts +9 -10
  261. package/dist/profiler/index.d.ts +9 -10
  262. package/dist/profiler/index.js +4 -4
  263. package/dist/provenance/index.cjs +46 -48
  264. package/dist/provenance/index.cjs.map +1 -1
  265. package/dist/provenance/index.d.cts +7 -7
  266. package/dist/provenance/index.d.ts +7 -7
  267. package/dist/provenance/index.js +12 -14
  268. package/dist/provenance/index.js.map +1 -1
  269. package/dist/schema/index.cjs +50 -48
  270. package/dist/schema/index.d.cts +9 -16
  271. package/dist/schema/index.d.ts +9 -16
  272. package/dist/schema/index.js +23 -21
  273. package/dist/{searchable-DLWEfC4a.d.ts → searchable-9OQoPuRs.d.ts} +1 -2
  274. package/dist/{searchable-CIZL8Hyw.d.cts → searchable-CIje5XYD.d.cts} +1 -2
  275. package/dist/{sqlite-DY0WODUK.d.cts → sqlite-DerU5tc7.d.ts} +2029 -347
  276. package/dist/{sqlite-L-VIRzqA.d.ts → sqlite-DitnISa9.d.cts} +2029 -347
  277. package/dist/{store-view-66p92IPi.d.ts → store-DawaWWjJ.d.ts} +1280 -767
  278. package/dist/{store-view-A85FFRnk.d.cts → store-RwTJx8LX.d.cts} +1280 -767
  279. package/dist/{temporal-BNbjXqer.d.cts → temporal-Bn-Fi8FJ.d.cts} +1 -1
  280. package/dist/{temporal-Bob6Nfbp.d.ts → temporal-BtM4UALv.d.ts} +1 -1
  281. package/dist/{types-DeORZhxn.d.cts → types-CoIx8HX5.d.cts} +1 -1
  282. package/dist/{types-Ch9a0Dx6.d.ts → types-HkveCCx0.d.cts} +726 -5
  283. package/dist/{types-Ch9a0Dx6.d.cts → types-HkveCCx0.d.ts} +726 -5
  284. package/dist/{types-ClCzT-dT.d.ts → types-KFfk-8Ah.d.ts} +1 -1
  285. package/dist/{where-DPw52ksb.d.cts → where--fk7_0kv.d.cts} +1 -1
  286. package/dist/{where-kWUZPvEA.d.ts → where-ws5hf-Ov.d.ts} +1 -1
  287. package/package.json +1 -1
  288. package/dist/chunk-2L54C2C2.js +0 -144
  289. package/dist/chunk-2L54C2C2.js.map +0 -1
  290. package/dist/chunk-35S6P5ZU.js +0 -27
  291. package/dist/chunk-35S6P5ZU.js.map +0 -1
  292. package/dist/chunk-42PYUGLS.js.map +0 -1
  293. package/dist/chunk-4GUBTVPV.js.map +0 -1
  294. package/dist/chunk-4GUTQPVO.js.map +0 -1
  295. package/dist/chunk-4MB3AQAQ.js.map +0 -1
  296. package/dist/chunk-4MEWSUVM.cjs.map +0 -1
  297. package/dist/chunk-4QIKLIGG.js.map +0 -1
  298. package/dist/chunk-4SZ6XPTG.cjs +0 -12
  299. package/dist/chunk-55ITBQJI.js.map +0 -1
  300. package/dist/chunk-5EKPX6QU.js.map +0 -1
  301. package/dist/chunk-6RYPD3NJ.cjs +0 -1282
  302. package/dist/chunk-6RYPD3NJ.cjs.map +0 -1
  303. package/dist/chunk-764JHTLT.cjs +0 -15
  304. package/dist/chunk-764JHTLT.cjs.map +0 -1
  305. package/dist/chunk-ACSVZPK7.cjs.map +0 -1
  306. package/dist/chunk-B3F2D3SP.cjs +0 -12
  307. package/dist/chunk-BGYJW37L.js.map +0 -1
  308. package/dist/chunk-BNS75YNF.cjs.map +0 -1
  309. package/dist/chunk-C4F7VJ5D.cjs.map +0 -1
  310. package/dist/chunk-CBKG6HEP.js +0 -1263
  311. package/dist/chunk-CBKG6HEP.js.map +0 -1
  312. package/dist/chunk-CPEL3YIR.cjs.map +0 -1
  313. package/dist/chunk-D54WH24V.cjs.map +0 -1
  314. package/dist/chunk-D56XG4EI.cjs.map +0 -1
  315. package/dist/chunk-D7PG5D5K.js.map +0 -1
  316. package/dist/chunk-DI74SMXS.cjs +0 -29
  317. package/dist/chunk-DI74SMXS.cjs.map +0 -1
  318. package/dist/chunk-DK2S42XB.js +0 -77
  319. package/dist/chunk-DK2S42XB.js.map +0 -1
  320. package/dist/chunk-DRACN6XG.js +0 -27
  321. package/dist/chunk-DRACN6XG.js.map +0 -1
  322. package/dist/chunk-DXEEHSGN.js.map +0 -1
  323. package/dist/chunk-EKFUG4G7.cjs.map +0 -1
  324. package/dist/chunk-EQ7JKLZO.cjs +0 -157
  325. package/dist/chunk-EQ7JKLZO.cjs.map +0 -1
  326. package/dist/chunk-FJMPR3OH.cjs.map +0 -1
  327. package/dist/chunk-FLEQ2HBK.js.map +0 -1
  328. package/dist/chunk-FQ7ZPOTZ.js.map +0 -1
  329. package/dist/chunk-G6Q5UM7U.js.map +0 -1
  330. package/dist/chunk-GYA4JRP5.js.map +0 -1
  331. package/dist/chunk-H7VE3FL4.cjs.map +0 -1
  332. package/dist/chunk-ID4WXTKL.js.map +0 -1
  333. package/dist/chunk-ISLPNELU.js.map +0 -1
  334. package/dist/chunk-ITE4IXAK.js +0 -25
  335. package/dist/chunk-ITE4IXAK.js.map +0 -1
  336. package/dist/chunk-IX64T5OL.cjs.map +0 -1
  337. package/dist/chunk-J2ICGNHO.cjs.map +0 -1
  338. package/dist/chunk-J7LXTUTP.cjs.map +0 -1
  339. package/dist/chunk-JQXSZHF2.cjs.map +0 -1
  340. package/dist/chunk-JXUTCSXX.cjs.map +0 -1
  341. package/dist/chunk-KCO5EFJU.js +0 -79
  342. package/dist/chunk-KCO5EFJU.js.map +0 -1
  343. package/dist/chunk-KKYELPZ2.cjs +0 -83
  344. package/dist/chunk-KKYELPZ2.cjs.map +0 -1
  345. package/dist/chunk-KMXWZLQX.cjs.map +0 -1
  346. package/dist/chunk-MIJKEVV7.js.map +0 -1
  347. package/dist/chunk-NAAMUYMS.cjs.map +0 -1
  348. package/dist/chunk-P7GTYOLB.cjs.map +0 -1
  349. package/dist/chunk-PVUI6KGR.js.map +0 -1
  350. package/dist/chunk-Q6EDCUXV.js.map +0 -1
  351. package/dist/chunk-QB6VMOJ2.cjs.map +0 -1
  352. package/dist/chunk-QC4MCOFV.cjs +0 -83
  353. package/dist/chunk-QC4MCOFV.cjs.map +0 -1
  354. package/dist/chunk-QMQLUA66.js +0 -12
  355. package/dist/chunk-QMQLUA66.js.map +0 -1
  356. package/dist/chunk-QRNYDV5Z.js.map +0 -1
  357. package/dist/chunk-RFRM3Q5K.js.map +0 -1
  358. package/dist/chunk-RUQS6M7G.js.map +0 -1
  359. package/dist/chunk-S4KQ5LV4.js.map +0 -1
  360. package/dist/chunk-SJDMVITW.cjs.map +0 -1
  361. package/dist/chunk-SNXVDZAJ.js.map +0 -1
  362. package/dist/chunk-SVJ5GEXW.cjs.map +0 -1
  363. package/dist/chunk-TDXIBCGY.cjs.map +0 -1
  364. package/dist/chunk-TKORQCG4.js.map +0 -1
  365. package/dist/chunk-TKP5T34P.js.map +0 -1
  366. package/dist/chunk-TRF4EBJT.cjs +0 -30
  367. package/dist/chunk-TRF4EBJT.cjs.map +0 -1
  368. package/dist/chunk-UCQ3BFSY.cjs.map +0 -1
  369. package/dist/chunk-UR7W5YQK.js.map +0 -1
  370. package/dist/chunk-V34A6R5V.js +0 -134
  371. package/dist/chunk-V34A6R5V.js.map +0 -1
  372. package/dist/chunk-WDAVPX46.js +0 -81
  373. package/dist/chunk-WDAVPX46.js.map +0 -1
  374. package/dist/chunk-WDBXJOU5.cjs.map +0 -1
  375. package/dist/chunk-YDWLUT5V.cjs.map +0 -1
  376. package/dist/chunk-YOALGKRE.cjs.map +0 -1
  377. package/dist/chunk-Z3WO6MND.cjs.map +0 -1
  378. package/dist/chunk-ZDH3DX3C.cjs +0 -30
  379. package/dist/chunk-ZDH3DX3C.cjs.map +0 -1
  380. package/dist/chunk-ZI6VQSZA.cjs.map +0 -1
  381. package/dist/chunk-ZTAJL4DT.cjs +0 -85
  382. package/dist/chunk-ZTAJL4DT.cjs.map +0 -1
  383. package/dist/define-graph-BGrJahvp.d.ts +0 -173
  384. package/dist/define-graph-alREY2wj.d.cts +0 -173
@@ -1,15 +1,14 @@
1
- import { formatPostgresTimestamp, coerceNumericScore, nowIso } from './chunk-YMTXMPV6.js';
2
- import { runtimeStrategyContributions } from './chunk-BGYJW37L.js';
3
- import { toDrizzleSql } from './chunk-EFEOOCJ3.js';
4
- import { chunk } from './chunk-35S6P5ZU.js';
5
- import { createBackendOverlay } from './chunk-55ITBQJI.js';
6
- import { sortedReplacer } from './chunk-UR7W5YQK.js';
7
- import { parseDimensionMismatch, isMissingTableError } from './chunk-V34A6R5V.js';
1
+ import { formatPostgresTimestamp, coerceNumericScore, nowIso } from './chunk-NMWDXFPH.js';
2
+ import { runtimeStrategyContributions } from './chunk-5UVRGXD3.js';
3
+ import { toDrizzleSql } from './chunk-UV3SN74I.js';
4
+ import { sortedReplacer } from './chunk-JBQQ7THH.js';
5
+ import { parseDimensionMismatch, chunk, isDuplicatePrimaryKeyError, isMissingTableError } from './chunk-JZUR7ZWE.js';
6
+ import { createBackendOverlay } from './chunk-AKLS3BYZ.js';
8
7
  import { sha256Hex } from './chunk-K34OPSJK.js';
9
- import { getDialect } from './chunk-PVUI6KGR.js';
10
- import { sql as sql$1, asCompiledStatementSql, isSqlFragment } from './chunk-6DCB664D.js';
11
- import { isPresent } from './chunk-QMQLUA66.js';
12
- import { EmbeddingDimensionChangedError, ConfigurationError, StaleVersionError, MigrationError, SchemaContentConflictError, DatabaseOperationError, UniquenessError, TrustedImportError, StoreNotInitializedError } from './chunk-4MB3AQAQ.js';
8
+ import { buildFulltextGraphDelete, buildForeignFulltextGraphProbe, getDialect } from './chunk-YDFDBE6D.js';
9
+ import { sql as sql$1, asCompiledStatementSql, asCompiledRowsSql, isSqlFragment } from './chunk-PQBQG7IM.js';
10
+ import { EmbeddingDimensionChangedError, ConfigurationError, StaleVersionError, MigrationError, SchemaContentConflictError, DatabaseOperationError, UniquenessError, TrustedImportError, ContributionRebuildUnsupportedError, StoreNotInitializedError } from './chunk-J3WZ3FA2.js';
11
+ import { isPresent } from './chunk-DYATYRY4.js';
13
12
  import { sql, is, getTableName } from 'drizzle-orm';
14
13
 
15
14
  // src/backend/edge-endpoint-sets.ts
@@ -225,6 +224,20 @@ function diagnoseContribution(row, signature, tableExists) {
225
224
  }
226
225
  }
227
226
  }
227
+ var PROBE_PROJECTION_ORDER = [
228
+ "fulltext",
229
+ "vector"
230
+ ];
231
+ var PROBE_DETAIL_PHRASE = {
232
+ "orphaned-marker": "storage is missing",
233
+ "missing-marker": "storage is not attested by a durable marker",
234
+ "failed-materialization": "provisioning failed and produced no storage",
235
+ stale: "storage exists at a different shape than the current declaration"
236
+ };
237
+ function describeProbeDiagnostic(diagnostic) {
238
+ const subject = diagnostic.kind === void 0 || diagnostic.fieldPath === void 0 ? `table "${diagnostic.physicalName}"` : `${diagnostic.kind}.${diagnostic.fieldPath}`;
239
+ return `${subject}: ${PROBE_DETAIL_PHRASE[diagnostic.state]} (${diagnostic.state})`;
240
+ }
228
241
  function identityOf(graphId, contribution) {
229
242
  return {
230
243
  graphId,
@@ -285,6 +298,13 @@ function gateFulltext(tx, assert) {
285
298
  gateFulltextMethods(tx, assert)
286
299
  );
287
300
  }
301
+ function contributionRebuildSupported(fulltextStrategy, fulltextTableName, transactional) {
302
+ return transactional && runtimeStrategyContributions(fulltextStrategy, fulltextTableName).every(
303
+ (contribution) => contribution.dropDdl !== void 0
304
+ );
305
+ }
306
+ var CONTRIBUTION_DDL_LOCK_KEY = "typegraph:contribution-ddl";
307
+ var FOREIGN_GRAPH_REPORT_LIMIT = 5;
288
308
  var CONTRIBUTION_KEY_SEPARATOR = String.fromCodePoint(0);
289
309
  function contributionKey(graphId, contribution) {
290
310
  return [
@@ -354,7 +374,7 @@ function createContributionMaterializer(deps) {
354
374
  );
355
375
  await deps.recordMarker({
356
376
  ...identity,
357
- signature,
377
+ signature: existing.signature,
358
378
  attemptedAt: nowIso(),
359
379
  materializedAt: void 0,
360
380
  error: error.message
@@ -533,7 +553,7 @@ function createContributionMaterializer(deps) {
533
553
  else existing.push(target);
534
554
  }
535
555
  for (const contribution of runtimeContributions()) {
536
- addTarget(graphId, { contribution });
556
+ addTarget(graphId, { contribution, projection: "fulltext" });
537
557
  }
538
558
  const { vectorStrategy } = deps;
539
559
  if (vectorStrategy !== void 0) {
@@ -541,6 +561,7 @@ function createContributionMaterializer(deps) {
541
561
  for (const contribution of vectorStrategy.ownedTables(slot)) {
542
562
  addTarget(slot.graphId, {
543
563
  contribution,
564
+ projection: "vector",
544
565
  kind: slot.nodeKind,
545
566
  fieldPath: slot.fieldPath
546
567
  });
@@ -549,8 +570,7 @@ function createContributionMaterializer(deps) {
549
570
  }
550
571
  return targets;
551
572
  }
552
- async function diagnoseContributions(graphId, vectorSlots) {
553
- const targetsByGraph = verificationTargetsByGraph(graphId, vectorSlots);
573
+ async function diagnoseTargets(targetsByGraph) {
554
574
  const probes = /* @__PURE__ */ new Map();
555
575
  function tableExists(tableName) {
556
576
  const pending = probes.get(tableName);
@@ -563,7 +583,7 @@ function createContributionMaterializer(deps) {
563
583
  for (const [id, targets] of targetsByGraph) {
564
584
  const read = await readMarkerRows(id);
565
585
  const rows = read.kind === "rows" ? read.rows : /* @__PURE__ */ new Map();
566
- for (const { contribution, kind, fieldPath } of targets) {
586
+ for (const { contribution, projection, kind, fieldPath } of targets) {
567
587
  const key = contributionKey(id, contribution);
568
588
  const row = rows.get(key);
569
589
  const state = diagnoseContribution(
@@ -575,6 +595,7 @@ function createContributionMaterializer(deps) {
575
595
  diagnosed.push({
576
596
  graphId: id,
577
597
  contribution,
598
+ projection,
578
599
  diagnostic: {
579
600
  owner: contribution.owner,
580
601
  logicalName: contribution.logicalName,
@@ -593,14 +614,46 @@ function createContributionMaterializer(deps) {
593
614
  }
594
615
  return diagnosed;
595
616
  }
617
+ async function diagnoseContributions(graphId, vectorSlots) {
618
+ return diagnoseTargets(verificationTargetsByGraph(graphId, vectorSlots));
619
+ }
596
620
  async function verifyContributions(graphId, vectorSlots) {
597
621
  const diagnosed = await diagnoseContributions(graphId, vectorSlots);
598
622
  return diagnosed.map((entry) => entry.diagnostic);
599
623
  }
624
+ async function probeContributions(graphId, vectorSlots) {
625
+ const targetsByGraph = verificationTargetsByGraph(graphId, vectorSlots);
626
+ const declared = /* @__PURE__ */ new Set();
627
+ for (const targets of targetsByGraph.values()) {
628
+ for (const target of targets) declared.add(target.projection);
629
+ }
630
+ const diagnosed = await diagnoseTargets(targetsByGraph);
631
+ const entries = [];
632
+ for (const projection of PROBE_PROJECTION_ORDER) {
633
+ if (!declared.has(projection)) continue;
634
+ const problems = diagnosed.filter(
635
+ (entry) => entry.projection === projection
636
+ );
637
+ if (problems.length === 0) {
638
+ entries.push({ contribution: projection, state: "ready" });
639
+ continue;
640
+ }
641
+ entries.push({
642
+ contribution: projection,
643
+ state: "degraded",
644
+ detail: problems.map((entry) => describeProbeDiagnostic(entry.diagnostic)).join("; ")
645
+ });
646
+ }
647
+ return entries;
648
+ }
600
649
  async function repairContributions(graphId, vectorSlots) {
601
650
  const diagnosed = await diagnoseContributions(graphId, vectorSlots);
602
651
  const results = [];
603
- for (const { graphId: targetGraphId, contribution, diagnostic } of diagnosed) {
652
+ for (const {
653
+ graphId: targetGraphId,
654
+ contribution,
655
+ diagnostic
656
+ } of diagnosed) {
604
657
  if (diagnostic.state === "stale" || diagnostic.state === "orphaned-marker") {
605
658
  results.push({ diagnostic, status: "requires-rebuild" });
606
659
  continue;
@@ -623,6 +676,156 @@ function createContributionMaterializer(deps) {
623
676
  remaining: await verifyContributions(graphId, vectorSlots)
624
677
  };
625
678
  }
679
+ async function lockContributionDdl(tx) {
680
+ if (dialect !== "postgres") return;
681
+ await tx.execute(
682
+ asCompiledRowsSql(
683
+ sql$1`SELECT pg_advisory_xact_lock(hashtext(${CONTRIBUTION_DDL_LOCK_KEY}), 0)`
684
+ )
685
+ );
686
+ }
687
+ async function lockSharedFulltextTable(tx, tableName) {
688
+ if (dialect !== "postgres") return;
689
+ await tx.executeStatement(
690
+ asCompiledStatementSql(
691
+ sql$1`LOCK TABLE ${sql$1.identifier(tableName)} IN ACCESS EXCLUSIVE MODE`
692
+ )
693
+ );
694
+ }
695
+ async function readForeignGraphIds(tx, tableName, graphId) {
696
+ const rows = await tx.execute(
697
+ asCompiledRowsSql(
698
+ buildForeignFulltextGraphProbe(
699
+ tableName,
700
+ graphId,
701
+ FOREIGN_GRAPH_REPORT_LIMIT
702
+ )
703
+ )
704
+ );
705
+ return rows.map((row) => String(row.graph_id));
706
+ }
707
+ async function rebuildContribution(graphId, scope, repopulate) {
708
+ if (scope === "vector") {
709
+ throw new ContributionRebuildUnsupportedError(
710
+ "vector-source-unavailable",
711
+ { graphId, contribution: scope }
712
+ );
713
+ }
714
+ const contributions = runtimeContributions();
715
+ const withoutTeardown = contributions.find(
716
+ (contribution) => contribution.dropDdl === void 0
717
+ );
718
+ if (withoutTeardown !== void 0) {
719
+ throw new ContributionRebuildUnsupportedError("no-drop-ddl", {
720
+ graphId,
721
+ contribution: scope,
722
+ owner: withoutTeardown.owner,
723
+ logicalName: withoutTeardown.logicalName,
724
+ physicalName: withoutTeardown.tableName
725
+ });
726
+ }
727
+ const fence = deps.schemaWriteTransaction;
728
+ if (fence === void 0) {
729
+ throw new ContributionRebuildUnsupportedError("no-schema-fence", {
730
+ graphId,
731
+ contribution: scope,
732
+ backend: dialect
733
+ });
734
+ }
735
+ const stamps = await Promise.all(
736
+ contributions.map(async (contribution) => {
737
+ const key = contributionKey(graphId, contribution);
738
+ return {
739
+ contribution,
740
+ key,
741
+ signature: await resolveContributionSignature(key, contribution)
742
+ };
743
+ })
744
+ );
745
+ await deps.ensureMarkerTable();
746
+ const markers = indexMarkerRows(graphId, await deps.getMarkers(graphId));
747
+ const sharedTable = deps.fulltextTableName;
748
+ const sharedTableExisted = await deps.tableExists(sharedTable);
749
+ const rebuilt = await fence(graphId, async (tx) => {
750
+ const record = tx.recordContributionMaterialization;
751
+ if (record === void 0) {
752
+ throw new ConfigurationError(
753
+ "rebuildContribution requires a transaction-scoped backend that can write contribution markers; without it the drop, recreate, and stamp could not commit together.",
754
+ {
755
+ backend: dialect,
756
+ capability: "contributions",
757
+ operation: "rebuild"
758
+ }
759
+ );
760
+ }
761
+ await lockContributionDdl(tx);
762
+ const unlockedForeignGraphIds = sharedTableExisted ? await readForeignGraphIds(tx, sharedTable, graphId) : [];
763
+ const mayRecreate = sharedTableExisted && unlockedForeignGraphIds.length === 0;
764
+ if (mayRecreate) await lockSharedFulltextTable(tx, sharedTable);
765
+ const foreignGraphIds = mayRecreate ? await readForeignGraphIds(tx, sharedTable, graphId) : unlockedForeignGraphIds;
766
+ const recreateStorage = mayRecreate && foreignGraphIds.length === 0;
767
+ if (!recreateStorage) {
768
+ const staleStamp = stamps.find(
769
+ ({ key, signature }) => diagnoseContribution(
770
+ markers.get(key),
771
+ signature,
772
+ sharedTableExisted
773
+ ) === "stale"
774
+ );
775
+ if (staleStamp !== void 0) {
776
+ throw new ContributionRebuildUnsupportedError(
777
+ "shared-storage-in-use",
778
+ {
779
+ graphId,
780
+ contribution: scope,
781
+ owner: staleStamp.contribution.owner,
782
+ logicalName: staleStamp.contribution.logicalName,
783
+ physicalName: staleStamp.contribution.tableName,
784
+ otherGraphIds: foreignGraphIds
785
+ }
786
+ );
787
+ }
788
+ }
789
+ for (const { contribution } of stamps) {
790
+ if (recreateStorage) {
791
+ for (const statement of contribution.dropDdl ?? []) {
792
+ await tx.executeSchemaDdl(statement);
793
+ }
794
+ }
795
+ for (const statement of contribution.createDdl) {
796
+ await tx.executeSchemaDdl(statement);
797
+ }
798
+ }
799
+ if (!recreateStorage) {
800
+ await tx.executeStatement(
801
+ asCompiledStatementSql(
802
+ buildFulltextGraphDelete(sharedTable, graphId)
803
+ )
804
+ );
805
+ }
806
+ const stats = await repopulate(tx);
807
+ const now = nowIso();
808
+ for (const { contribution, signature } of stamps) {
809
+ await record({
810
+ ...identityOf(graphId, contribution),
811
+ signature,
812
+ attemptedAt: now,
813
+ materializedAt: now,
814
+ error: void 0
815
+ });
816
+ }
817
+ return {
818
+ rebuilt: stamps.map(({ contribution }) => contribution.tableName),
819
+ processed: stats.processed,
820
+ repopulated: stats.repopulated,
821
+ skipped: stats.skipped
822
+ };
823
+ });
824
+ for (const { key, signature } of stamps) {
825
+ cacheInitializedSignature(key, signature);
826
+ }
827
+ return rebuilt;
828
+ }
626
829
  function evictVectorSlot(slot) {
627
830
  if (deps.vectorStrategy === void 0) return;
628
831
  for (const contribution of deps.vectorStrategy.ownedTables(slot)) {
@@ -652,7 +855,9 @@ function createContributionMaterializer(deps) {
652
855
  dropVectorSlot,
653
856
  evictVectorSlot,
654
857
  verifyContributions,
655
- repairContributions
858
+ repairContributions,
859
+ probeContributions,
860
+ rebuildContribution
656
861
  };
657
862
  }
658
863
  var SQLITE_INDEX_MAT_TIMESTAMPS = {
@@ -759,6 +964,30 @@ function buildKindRemovalOnConflictSet(removedAtColumn, paramsRemovedAt) {
759
964
  lastError: sql`excluded.${sql.identifier("last_error")}`
760
965
  };
761
966
  }
967
+ function primaryKeyConstraintNames(relation, keyColumns) {
968
+ return [`${relation}_pkey`, `${relation}_${keyColumns.join("_")}_pk`];
969
+ }
970
+ function nodePrimaryKeyConstraint(nodes) {
971
+ const relation = getTableName(nodes);
972
+ return {
973
+ table: relation,
974
+ constraintNames: primaryKeyConstraintNames(relation, [
975
+ nodes.graphId.name,
976
+ nodes.kind.name,
977
+ nodes.id.name
978
+ ])
979
+ };
980
+ }
981
+ function edgePrimaryKeyConstraint(edges) {
982
+ const relation = getTableName(edges);
983
+ return {
984
+ table: relation,
985
+ constraintNames: primaryKeyConstraintNames(relation, [
986
+ edges.graphId.name,
987
+ edges.id.name
988
+ ])
989
+ };
990
+ }
762
991
  function sqlNull(value) {
763
992
  return value ?? sql.raw("NULL");
764
993
  }
@@ -766,6 +995,11 @@ function resolveValidFrom(validFrom, timestamp) {
766
995
  if (validFrom === null) return void 0;
767
996
  return validFrom ?? timestamp;
768
997
  }
998
+ function expectedValidFromPredicate(column, expected) {
999
+ if (expected === void 0) return sql.empty();
1000
+ if (expected === null) return sql` AND ${column} IS NULL`;
1001
+ return sql` AND ${column} = ${expected}`;
1002
+ }
769
1003
  function quotedColumn(column) {
770
1004
  return sql.raw(`"${column.name.replaceAll('"', '""')}"`);
771
1005
  }
@@ -898,9 +1132,16 @@ function mapHybridSearchRow(row, toNodeRow) {
898
1132
  };
899
1133
  }
900
1134
  function buildClearGraph(tables, graphId) {
901
- const fulltext = quotedTableName(tables.fulltextTableName);
902
1135
  return [
903
- { query: sql`DELETE FROM ${fulltext} WHERE "graph_id" = ${graphId}` },
1136
+ // The fulltext table is shared by every graph in the database, so its
1137
+ // graph-scoped delete is owned by one builder the destructive
1138
+ // contribution rebuild calls too — see `buildFulltextGraphDelete`.
1139
+ { query: buildFulltextGraphDelete(tables.fulltextTableName, graphId) },
1140
+ {
1141
+ query: sql`DELETE FROM ${tables.recordedIdentityAssertions} WHERE ${tables.recordedIdentityAssertions.graphId} = ${graphId}`,
1142
+ ignoreMissingTable: true,
1143
+ requiredTableName: getTableName(tables.recordedIdentityAssertions)
1144
+ },
904
1145
  {
905
1146
  query: sql`DELETE FROM ${tables.recordedEdges} WHERE ${tables.recordedEdges.graphId} = ${graphId}`,
906
1147
  ignoreMissingTable: true,
@@ -916,6 +1157,21 @@ function buildClearGraph(tables, graphId) {
916
1157
  ignoreMissingTable: true,
917
1158
  requiredTableName: getTableName(tables.recordedClock)
918
1159
  },
1160
+ {
1161
+ query: sql`DELETE FROM ${tables.identitySeparation} WHERE ${tables.identitySeparation.graphId} = ${graphId}`,
1162
+ ignoreMissingTable: true,
1163
+ requiredTableName: getTableName(tables.identitySeparation)
1164
+ },
1165
+ {
1166
+ query: sql`DELETE FROM ${tables.identityClosure} WHERE ${tables.identityClosure.graphId} = ${graphId}`,
1167
+ ignoreMissingTable: true,
1168
+ requiredTableName: getTableName(tables.identityClosure)
1169
+ },
1170
+ {
1171
+ query: sql`DELETE FROM ${tables.identityAssertions} WHERE ${tables.identityAssertions.graphId} = ${graphId}`,
1172
+ ignoreMissingTable: true,
1173
+ requiredTableName: getTableName(tables.identityAssertions)
1174
+ },
919
1175
  {
920
1176
  query: sql`DELETE FROM ${tables.uniques} WHERE ${tables.uniques.graphId} = ${graphId}`
921
1177
  },
@@ -1252,6 +1508,17 @@ function buildGetEdges(tables, graphId, ids) {
1252
1508
  )})
1253
1509
  `;
1254
1510
  }
1511
+ function expectedIdentityPredicate(tables, expected) {
1512
+ const { edges } = tables;
1513
+ const parts = [
1514
+ expected.kind === void 0 ? void 0 : sql` AND ${edges.kind} = ${expected.kind}`,
1515
+ expected.fromKind === void 0 ? void 0 : sql` AND ${edges.fromKind} = ${expected.fromKind}`,
1516
+ expected.fromId === void 0 ? void 0 : sql` AND ${edges.fromId} = ${expected.fromId}`,
1517
+ expected.toKind === void 0 ? void 0 : sql` AND ${edges.toKind} = ${expected.toKind}`,
1518
+ expected.toId === void 0 ? void 0 : sql` AND ${edges.toId} = ${expected.toId}`
1519
+ ].filter((part) => part !== void 0);
1520
+ return parts.length === 0 ? sql.empty() : sql.join(parts, sql``);
1521
+ }
1255
1522
  function buildUpdateEdge(tables, params, timestamp) {
1256
1523
  const { edges } = tables;
1257
1524
  const propsJson = JSON.stringify(params.props);
@@ -1259,19 +1526,29 @@ function buildUpdateEdge(tables, params, timestamp) {
1259
1526
  sql`${quotedColumn(edges.props)} = ${propsJson}`,
1260
1527
  sql`${quotedColumn(edges.updatedAt)} = ${timestamp}`
1261
1528
  ];
1262
- if (params.validTo !== void 0) {
1529
+ if (params.clearDeleted && params.validFrom !== void 0) {
1530
+ setParts.push(
1531
+ sql`${quotedColumn(edges.validFrom)} = ${sqlNull(resolveValidFrom(params.validFrom, timestamp))}`,
1532
+ sql`${quotedColumn(edges.validTo)} = ${sqlNull(params.validTo)}`
1533
+ );
1534
+ } else if (params.validTo !== void 0) {
1263
1535
  setParts.push(sql`${quotedColumn(edges.validTo)} = ${params.validTo}`);
1264
1536
  }
1265
1537
  if (params.clearDeleted) {
1266
1538
  setParts.push(sql`${quotedColumn(edges.deletedAt)} = NULL`);
1267
1539
  }
1268
1540
  const setClause = sql.join(setParts, sql`, `);
1541
+ const expectedIdentity = expectedIdentityPredicate(tables, params);
1542
+ const expectedValidFrom = expectedValidFromPredicate(
1543
+ edges.validFrom,
1544
+ params.expectedValidFrom
1545
+ );
1269
1546
  if (params.clearDeleted) {
1270
1547
  return sql`
1271
1548
  UPDATE ${edges}
1272
1549
  SET ${setClause}
1273
1550
  WHERE ${edges.graphId} = ${params.graphId}
1274
- AND ${edges.id} = ${params.id}
1551
+ AND ${edges.id} = ${params.id}${expectedIdentity}${expectedValidFrom}
1275
1552
  RETURNING *
1276
1553
  `;
1277
1554
  }
@@ -1279,7 +1556,7 @@ function buildUpdateEdge(tables, params, timestamp) {
1279
1556
  UPDATE ${edges}
1280
1557
  SET ${setClause}
1281
1558
  WHERE ${edges.graphId} = ${params.graphId}
1282
- AND ${edges.id} = ${params.id}
1559
+ AND ${edges.id} = ${params.id}${expectedIdentity}${expectedValidFrom}
1283
1560
  AND ${edges.deletedAt} IS NULL
1284
1561
  RETURNING *
1285
1562
  `;
@@ -1290,7 +1567,7 @@ function buildDeleteEdge(tables, params, timestamp) {
1290
1567
  UPDATE ${edges}
1291
1568
  SET ${quotedColumn(edges.deletedAt)} = ${timestamp}
1292
1569
  WHERE ${edges.graphId} = ${params.graphId}
1293
- AND ${edges.id} = ${params.id}
1570
+ AND ${edges.id} = ${params.id}${expectedIdentityPredicate(tables, params.kind === void 0 ? {} : { kind: params.kind })}
1294
1571
  AND ${edges.deletedAt} IS NULL
1295
1572
  `;
1296
1573
  }
@@ -1323,7 +1600,7 @@ function buildHardDeleteEdge(tables, params) {
1323
1600
  return sql`
1324
1601
  DELETE FROM ${edges}
1325
1602
  WHERE ${edges.graphId} = ${params.graphId}
1326
- AND ${edges.id} = ${params.id}
1603
+ AND ${edges.id} = ${params.id}${expectedIdentityPredicate(tables, params.kind === void 0 ? {} : { kind: params.kind })}
1327
1604
  `;
1328
1605
  }
1329
1606
  function buildHardDeleteEdgesByNode(tables, graphId, nodeKind, nodeId) {
@@ -1536,20 +1813,30 @@ function buildUpdateNode(tables, params, timestamp) {
1536
1813
  sql`${quotedColumn(nodes.version)} = ${quotedColumn(nodes.version)} + 1`
1537
1814
  );
1538
1815
  }
1539
- if (params.validTo !== void 0) {
1816
+ if (params.clearDeleted) {
1817
+ setParts.push(
1818
+ sql`${quotedColumn(nodes.validFrom)} = ${sqlNull(resolveValidFrom(params.validFrom, timestamp))}`,
1819
+ sql`${quotedColumn(nodes.validTo)} = ${sqlNull(params.validTo)}`
1820
+ );
1821
+ } else if (params.validTo !== void 0) {
1540
1822
  setParts.push(sql`${quotedColumn(nodes.validTo)} = ${params.validTo}`);
1541
1823
  }
1542
1824
  if (params.clearDeleted) {
1543
1825
  setParts.push(sql`${quotedColumn(nodes.deletedAt)} = NULL`);
1544
1826
  }
1545
1827
  const setClause = sql.join(setParts, sql`, `);
1828
+ const expectedValidFrom = expectedValidFromPredicate(
1829
+ nodes.validFrom,
1830
+ params.expectedValidFrom
1831
+ );
1546
1832
  if (params.clearDeleted) {
1547
1833
  return sql`
1548
1834
  UPDATE ${nodes}
1549
1835
  SET ${setClause}
1550
1836
  WHERE ${nodes.graphId} = ${params.graphId}
1551
1837
  AND ${nodes.kind} = ${params.kind}
1552
- AND ${nodes.id} = ${params.id}
1838
+ AND ${nodes.id} = ${params.id}${expectedValidFrom}
1839
+ AND ${nodes.deletedAt} IS NOT NULL
1553
1840
  RETURNING *
1554
1841
  `;
1555
1842
  }
@@ -1558,7 +1845,7 @@ function buildUpdateNode(tables, params, timestamp) {
1558
1845
  SET ${setClause}
1559
1846
  WHERE ${nodes.graphId} = ${params.graphId}
1560
1847
  AND ${nodes.kind} = ${params.kind}
1561
- AND ${nodes.id} = ${params.id}
1848
+ AND ${nodes.id} = ${params.id}${expectedValidFrom}
1562
1849
  AND ${nodes.deletedAt} IS NULL
1563
1850
  RETURNING *
1564
1851
  `;
@@ -1894,6 +2181,9 @@ function buildCheckUniqueBatch(tables, params) {
1894
2181
  }
1895
2182
 
1896
2183
  // src/backend/drizzle/operations/strategy.ts
2184
+ function nullableText(value) {
2185
+ return value === void 0 ? sql`NULL` : sql`${value}`;
2186
+ }
1897
2187
  function bindTableOperationBuilders(tables, builders) {
1898
2188
  const boundEntries = Object.entries(builders).map(([name, builder]) => {
1899
2189
  function boundBuilder(...args) {
@@ -2016,6 +2306,24 @@ function createCommonOperationStrategy(tables, dialect, fulltextStrategy) {
2016
2306
  });
2017
2307
  }
2018
2308
  };
2309
+ function buildInsertContributionMaterialization(params) {
2310
+ return sql`
2311
+ INSERT INTO ${contributionMaterializations}
2312
+ (graph_id, logical_name, owner, table_name, signature,
2313
+ materialized_at, last_attempted_at, last_error)
2314
+ VALUES (
2315
+ ${params.graphId}, ${params.logicalName}, ${params.owner},
2316
+ ${params.tableName}, ${params.signature},
2317
+ ${nullableText(params.materializedAt)}, ${params.attemptedAt},
2318
+ ${nullableText(params.error)}
2319
+ )
2320
+ ON CONFLICT (graph_id, logical_name, owner, table_name) DO UPDATE SET
2321
+ signature = excluded.signature,
2322
+ materialized_at = excluded.materialized_at,
2323
+ last_attempted_at = excluded.last_attempted_at,
2324
+ last_error = excluded.last_error
2325
+ `;
2326
+ }
2019
2327
  function buildDeleteContributionMaterialization(identity) {
2020
2328
  return sql`
2021
2329
  DELETE FROM ${contributionMaterializations}
@@ -2028,10 +2336,15 @@ function createCommonOperationStrategy(tables, dialect, fulltextStrategy) {
2028
2336
  return {
2029
2337
  ...tableOperations,
2030
2338
  ...fulltextBuilders,
2339
+ primaryKeyConstraints: {
2340
+ nodes: nodePrimaryKeyConstraint(tables.nodes),
2341
+ edges: edgePrimaryKeyConstraint(tables.edges)
2342
+ },
2031
2343
  buildUpdateNodeSet(params, timestamp) {
2032
2344
  return buildUpdateNodeSet(tables, dialect, params, timestamp);
2033
2345
  },
2034
2346
  buildDeleteContributionMaterialization,
2347
+ buildInsertContributionMaterialization,
2035
2348
  buildInsertUnique(params) {
2036
2349
  return buildInsertUnique(tables, dialect, params);
2037
2350
  },
@@ -2112,6 +2425,26 @@ function assertAdoptedDialect(externalTx, brand, backend) {
2112
2425
  { backend, capability: "adoptTransaction" }
2113
2426
  );
2114
2427
  }
2428
+ async function withDuplicateKeyClassification(run, context) {
2429
+ try {
2430
+ return await run();
2431
+ } catch (error) {
2432
+ if (!isDuplicatePrimaryKeyError(error, context.relation)) throw error;
2433
+ throw new DatabaseOperationError(
2434
+ `Insert ${context.entity} failed: a row with this identity already exists`,
2435
+ {
2436
+ operation: "insert",
2437
+ entity: context.entity,
2438
+ reason: "duplicate_key",
2439
+ attempted: context.attempted
2440
+ },
2441
+ { cause: error }
2442
+ );
2443
+ }
2444
+ }
2445
+ function attemptedInserts(params) {
2446
+ return params.map((item) => ({ kind: item.kind, id: item.id }));
2447
+ }
2115
2448
  function verifyExpectedActiveVersion(graphId, expected, actualActiveVersion) {
2116
2449
  const expectedVersion = expected.kind === "active" ? expected.version : 0;
2117
2450
  assertActiveSchemaVersion(graphId, expectedVersion, actualActiveVersion);
@@ -2201,11 +2534,22 @@ function createCommonOperationBackend(options) {
2201
2534
  async insertNode(params) {
2202
2535
  const timestamp = nowIso2();
2203
2536
  const query = operationStrategy.buildInsertNode(params, timestamp);
2204
- const row = await execution.execGet(query);
2537
+ const row = await withDuplicateKeyClassification(
2538
+ () => execution.execGet(query),
2539
+ {
2540
+ entity: "node",
2541
+ relation: operationStrategy.primaryKeyConstraints.nodes,
2542
+ attempted: attemptedInserts([params])
2543
+ }
2544
+ );
2205
2545
  if (!row)
2206
2546
  throw new DatabaseOperationError(
2207
2547
  "Insert node failed: no row returned",
2208
- { operation: "insert", entity: "node" }
2548
+ {
2549
+ operation: "insert",
2550
+ entity: "node",
2551
+ reason: "no_row_returned"
2552
+ }
2209
2553
  );
2210
2554
  return rowMappers.toNodeRow(row);
2211
2555
  },
@@ -2215,7 +2559,11 @@ function createCommonOperationBackend(options) {
2215
2559
  params,
2216
2560
  timestamp
2217
2561
  );
2218
- await execution.execRun(query);
2562
+ await withDuplicateKeyClassification(() => execution.execRun(query), {
2563
+ entity: "node",
2564
+ relation: operationStrategy.primaryKeyConstraints.nodes,
2565
+ attempted: attemptedInserts([params])
2566
+ });
2219
2567
  },
2220
2568
  async insertNodesBatch(params) {
2221
2569
  if (params.length === 0) {
@@ -2224,7 +2572,11 @@ function createCommonOperationBackend(options) {
2224
2572
  const timestamp = nowIso2();
2225
2573
  for (const chunk2 of chunk(params, batchConfig.nodeInsertBatchSize)) {
2226
2574
  const query = operationStrategy.buildInsertNodesBatch(chunk2, timestamp);
2227
- await execution.execRun(query);
2575
+ await withDuplicateKeyClassification(() => execution.execRun(query), {
2576
+ entity: "node",
2577
+ relation: operationStrategy.primaryKeyConstraints.nodes,
2578
+ attempted: attemptedInserts(chunk2)
2579
+ });
2228
2580
  }
2229
2581
  },
2230
2582
  async insertNodesBatchReturning(params) {
@@ -2238,7 +2590,14 @@ function createCommonOperationBackend(options) {
2238
2590
  chunk2,
2239
2591
  timestamp
2240
2592
  );
2241
- const rows = await execution.execAll(query);
2593
+ const rows = await withDuplicateKeyClassification(
2594
+ () => execution.execAll(query),
2595
+ {
2596
+ entity: "node",
2597
+ relation: operationStrategy.primaryKeyConstraints.nodes,
2598
+ attempted: attemptedInserts(chunk2)
2599
+ }
2600
+ );
2242
2601
  allRows.push(...rows.map((row) => rowMappers.toNodeRow(row)));
2243
2602
  }
2244
2603
  return allRows;
@@ -2265,7 +2624,11 @@ function createCommonOperationBackend(options) {
2265
2624
  if (!row)
2266
2625
  throw new DatabaseOperationError(
2267
2626
  "Update node failed: no row returned",
2268
- { operation: "update", entity: "node" }
2627
+ {
2628
+ operation: "update",
2629
+ entity: "node",
2630
+ reason: "no_row_returned"
2631
+ }
2269
2632
  );
2270
2633
  return rowMappers.toNodeRow(row);
2271
2634
  },
@@ -2329,11 +2692,22 @@ function createCommonOperationBackend(options) {
2329
2692
  async insertEdge(params) {
2330
2693
  const timestamp = nowIso2();
2331
2694
  const query = operationStrategy.buildInsertEdge(params, timestamp);
2332
- const row = await execution.execGet(query);
2695
+ const row = await withDuplicateKeyClassification(
2696
+ () => execution.execGet(query),
2697
+ {
2698
+ entity: "edge",
2699
+ relation: operationStrategy.primaryKeyConstraints.edges,
2700
+ attempted: attemptedInserts([params])
2701
+ }
2702
+ );
2333
2703
  if (!row)
2334
2704
  throw new DatabaseOperationError(
2335
2705
  "Insert edge failed: no row returned",
2336
- { operation: "insert", entity: "edge" }
2706
+ {
2707
+ operation: "insert",
2708
+ entity: "edge",
2709
+ reason: "no_row_returned"
2710
+ }
2337
2711
  );
2338
2712
  return rowMappers.toEdgeRow(row);
2339
2713
  },
@@ -2343,7 +2717,11 @@ function createCommonOperationBackend(options) {
2343
2717
  params,
2344
2718
  timestamp
2345
2719
  );
2346
- await execution.execRun(query);
2720
+ await withDuplicateKeyClassification(() => execution.execRun(query), {
2721
+ entity: "edge",
2722
+ relation: operationStrategy.primaryKeyConstraints.edges,
2723
+ attempted: attemptedInserts([params])
2724
+ });
2347
2725
  },
2348
2726
  async insertEdgesBatch(params) {
2349
2727
  if (params.length === 0) {
@@ -2352,7 +2730,11 @@ function createCommonOperationBackend(options) {
2352
2730
  const timestamp = nowIso2();
2353
2731
  for (const chunk2 of chunk(params, batchConfig.edgeInsertBatchSize)) {
2354
2732
  const query = operationStrategy.buildInsertEdgesBatch(chunk2, timestamp);
2355
- await execution.execRun(query);
2733
+ await withDuplicateKeyClassification(() => execution.execRun(query), {
2734
+ entity: "edge",
2735
+ relation: operationStrategy.primaryKeyConstraints.edges,
2736
+ attempted: attemptedInserts(chunk2)
2737
+ });
2356
2738
  }
2357
2739
  },
2358
2740
  async insertEdgesBatchReturning(params) {
@@ -2366,7 +2748,14 @@ function createCommonOperationBackend(options) {
2366
2748
  chunk2,
2367
2749
  timestamp
2368
2750
  );
2369
- const rows = await execution.execAll(query);
2751
+ const rows = await withDuplicateKeyClassification(
2752
+ () => execution.execAll(query),
2753
+ {
2754
+ entity: "edge",
2755
+ relation: operationStrategy.primaryKeyConstraints.edges,
2756
+ attempted: attemptedInserts(chunk2)
2757
+ }
2758
+ );
2370
2759
  allRows.push(...rows.map((row) => rowMappers.toEdgeRow(row)));
2371
2760
  }
2372
2761
  return allRows;
@@ -2393,7 +2782,11 @@ function createCommonOperationBackend(options) {
2393
2782
  if (!row)
2394
2783
  throw new DatabaseOperationError(
2395
2784
  "Update edge failed: no row returned",
2396
- { operation: "update", entity: "edge" }
2785
+ {
2786
+ operation: "update",
2787
+ entity: "edge",
2788
+ reason: "no_row_returned"
2789
+ }
2397
2790
  );
2398
2791
  return rowMappers.toEdgeRow(row);
2399
2792
  },
@@ -2978,6 +3371,6 @@ function getOrCreateLru(cache, key, cacheMax, create) {
2978
3371
  return value;
2979
3372
  }
2980
3373
 
2981
- export { EMBEDDING_UPSERT_PARAM_COUNT, FIND_EDGES_ENDPOINT_FIXED_PARAM_COUNT, POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS, POSTGRES_INDEX_MAT_TIMESTAMPS, POSTGRES_KIND_REMOVAL_TIMESTAMPS, SQLITE_CONTRIBUTION_MAT_TIMESTAMPS, SQLITE_INDEX_MAT_TIMESTAMPS, SQLITE_KIND_REMOVAL_TIMESTAMPS, analyzeImportedTables, assertActiveSchemaVersion, assertAdoptedDialect, assertTrustedImportDatabaseEmpty, buildContributionInsertValues, buildContributionOnConflictSet, buildKindRemovalInsertValues, buildKindRemovalOnConflictSet, buildLiveNodeCandidates, buildMaterializationInsertValues, buildMaterializationOnConflictSet, commitSchemaVersionIfKindsEmpty, createCachedTableExistence, createCommonOperationBackend, createContributionMaterializer, createPostgresOperationStrategy, createPostgresTrustedImportSession, createSqliteOperationStrategy, createSqliteTrustedImportSession, gateFulltext, gateFulltextMethods, getOrCreateLru, lockPostgresTrustedImportTables, mapContributionMaterializationRow, mapHybridSearchRow, mapKindRemovalRow, mapMaterializationRow, mapVectorWriteError, restoreSecondaryIndexes, suspendPostgresSecondaryIndexes, suspendSqliteSecondaryIndexes, tableExistsFromRow, vectorSlotFromCreateIndexParams, vectorSlotFromDropIndexParams, vectorSlotFromParams };
2982
- //# sourceMappingURL=chunk-DXEEHSGN.js.map
2983
- //# sourceMappingURL=chunk-DXEEHSGN.js.map
3374
+ export { EMBEDDING_UPSERT_PARAM_COUNT, FIND_EDGES_ENDPOINT_FIXED_PARAM_COUNT, POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS, POSTGRES_INDEX_MAT_TIMESTAMPS, POSTGRES_KIND_REMOVAL_TIMESTAMPS, SQLITE_CONTRIBUTION_MAT_TIMESTAMPS, SQLITE_INDEX_MAT_TIMESTAMPS, SQLITE_KIND_REMOVAL_TIMESTAMPS, analyzeImportedTables, assertActiveSchemaVersion, assertAdoptedDialect, assertTrustedImportDatabaseEmpty, buildContributionInsertValues, buildContributionOnConflictSet, buildKindRemovalInsertValues, buildKindRemovalOnConflictSet, buildLiveNodeCandidates, buildMaterializationInsertValues, buildMaterializationOnConflictSet, commitSchemaVersionIfKindsEmpty, contributionRebuildSupported, createCachedTableExistence, createCommonOperationBackend, createContributionMaterializer, createPostgresOperationStrategy, createPostgresTrustedImportSession, createSqliteOperationStrategy, createSqliteTrustedImportSession, gateFulltext, gateFulltextMethods, getOrCreateLru, lockPostgresTrustedImportTables, mapContributionMaterializationRow, mapHybridSearchRow, mapKindRemovalRow, mapMaterializationRow, mapVectorWriteError, restoreSecondaryIndexes, suspendPostgresSecondaryIndexes, suspendSqliteSecondaryIndexes, tableExistsFromRow, vectorSlotFromCreateIndexParams, vectorSlotFromDropIndexParams, vectorSlotFromParams };
3375
+ //# sourceMappingURL=chunk-7VQXLT5O.js.map
3376
+ //# sourceMappingURL=chunk-7VQXLT5O.js.map