@nicia-ai/typegraph 0.44.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 (392) 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 -43
  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 -39
  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 -44
  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 -40
  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-XMYJY7NI.js → chunk-2LG2XB2M.js} +3 -3
  44. package/dist/{chunk-XMYJY7NI.js.map → chunk-2LG2XB2M.js.map} +1 -1
  45. package/dist/{chunk-QGKILWGZ.cjs → chunk-2NA5DYLO.cjs} +4 -4
  46. package/dist/{chunk-QGKILWGZ.cjs.map → chunk-2NA5DYLO.cjs.map} +1 -1
  47. package/dist/{chunk-5MUSU4ZP.cjs → chunk-3DHZCOT7.cjs} +20 -20
  48. package/dist/chunk-3DHZCOT7.cjs.map +1 -0
  49. package/dist/{chunk-OVUUTCPJ.cjs → chunk-4UGOKMI5.cjs} +268 -150
  50. package/dist/chunk-4UGOKMI5.cjs.map +1 -0
  51. package/dist/{chunk-FRHHDHKH.js → chunk-5262ZMTR.js} +26 -5
  52. package/dist/chunk-5262ZMTR.js.map +1 -0
  53. package/dist/{chunk-HOIFFY4M.js → chunk-5763DULU.js} +248 -76
  54. package/dist/chunk-5763DULU.js.map +1 -0
  55. package/dist/{chunk-7G32LIQM.js → chunk-5UVRGXD3.js} +277 -7
  56. package/dist/chunk-5UVRGXD3.js.map +1 -0
  57. package/dist/{chunk-IIT5K7SK.cjs → chunk-62ZP23AW.cjs} +15 -15
  58. package/dist/{chunk-IIT5K7SK.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-QYWINYEA.cjs → chunk-7BQXPCGN.cjs} +830 -170
  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-7GT72YHH.cjs +1979 -0
  66. package/dist/chunk-7GT72YHH.cjs.map +1 -0
  67. package/dist/{chunk-SQRD2CYF.js → chunk-7VQXLT5O.js} +717 -76
  68. package/dist/chunk-7VQXLT5O.js.map +1 -0
  69. package/dist/{chunk-BCP7LLOY.js → chunk-7Z5OR7KO.js} +2706 -625
  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-FMMIX6N4.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-PAW2XUZN.js → chunk-ASTI57H3.js} +3 -3
  80. package/dist/{chunk-PAW2XUZN.js.map → chunk-ASTI57H3.js.map} +1 -1
  81. package/dist/{chunk-FMGEZBAQ.js → chunk-BKCUOV7A.js} +27 -5
  82. package/dist/chunk-BKCUOV7A.js.map +1 -0
  83. package/dist/chunk-BSFJMMV3.cjs +268 -0
  84. package/dist/chunk-BSFJMMV3.cjs.map +1 -0
  85. package/dist/{chunk-63KCKSSH.js → chunk-C23WSN5E.js} +209 -24
  86. package/dist/chunk-C23WSN5E.js.map +1 -0
  87. package/dist/{chunk-JRP3VGHS.js → chunk-CBTIUB76.js} +3 -3
  88. package/dist/{chunk-JRP3VGHS.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-46GDII45.js → chunk-DCQVHAYQ.js} +5 -5
  94. package/dist/{chunk-46GDII45.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-BNUFUFAU.js → chunk-HFHTMECK.js} +7 -7
  104. package/dist/chunk-HFHTMECK.js.map +1 -0
  105. package/dist/{chunk-TFMVL4QH.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-2Y4IFKW7.js → chunk-JXA2ZP2Q.js} +6 -17
  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-K5ELX2GT.js +248 -0
  120. package/dist/chunk-K5ELX2GT.js.map +1 -0
  121. package/dist/chunk-LBJKZXDE.cjs +257 -0
  122. package/dist/chunk-LBJKZXDE.cjs.map +1 -0
  123. package/dist/{chunk-FGO5JFVJ.cjs → chunk-M4BDU5RX.cjs} +12 -12
  124. package/dist/{chunk-FGO5JFVJ.cjs.map → chunk-M4BDU5RX.cjs.map} +1 -1
  125. package/dist/{chunk-MIJKEVV7.js → chunk-MSY7FSX4.js} +37 -4
  126. package/dist/chunk-MSY7FSX4.js.map +1 -0
  127. package/dist/{chunk-ST3LPB2V.cjs → chunk-MUK4BU7K.cjs} +788 -146
  128. package/dist/chunk-MUK4BU7K.cjs.map +1 -0
  129. package/dist/{chunk-MCHP7RHZ.cjs → chunk-MXJDTH5B.cjs} +64 -41
  130. package/dist/chunk-MXJDTH5B.cjs.map +1 -0
  131. package/dist/{chunk-2VLBGQBY.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-EE7N5XXQ.cjs → chunk-NK5Q7UNE.cjs} +10 -21
  140. package/dist/chunk-NK5Q7UNE.cjs.map +1 -0
  141. package/dist/{chunk-PHXITZE4.js → chunk-NMWDXFPH.js} +4 -4
  142. package/dist/{chunk-PHXITZE4.js.map → chunk-NMWDXFPH.js.map} +1 -1
  143. package/dist/{chunk-FSXTPBRN.js → chunk-NQ6BRJBE.js} +416 -850
  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-STQ3BSED.cjs → chunk-PNN7RHVR.cjs} +66 -44
  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-BEFM74L2.js → chunk-QLRESYPU.js} +637 -493
  158. package/dist/chunk-QLRESYPU.js.map +1 -0
  159. package/dist/{chunk-SBPC5IP3.js → chunk-QWX5YA3K.js} +784 -202
  160. package/dist/chunk-QWX5YA3K.js.map +1 -0
  161. package/dist/{chunk-TCRIQMBU.js → chunk-RJS7DECT.js} +8 -9
  162. package/dist/chunk-RJS7DECT.js.map +1 -0
  163. package/dist/{chunk-6JZUSDY2.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-IJTLXNGJ.js → chunk-T4XNKYXB.js} +780 -127
  168. package/dist/chunk-T4XNKYXB.js.map +1 -0
  169. package/dist/{chunk-PDGEXGS6.cjs → chunk-TQR4KBY2.cjs} +354 -182
  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-NN3QSOVS.cjs → chunk-U5SON7R2.cjs} +27 -27
  174. package/dist/{chunk-NN3QSOVS.cjs.map → chunk-U5SON7R2.cjs.map} +1 -1
  175. package/dist/{chunk-A2I2XO52.cjs → chunk-U63GDNRC.cjs} +32 -26
  176. package/dist/chunk-U63GDNRC.cjs.map +1 -0
  177. package/dist/{chunk-YNULOIR5.cjs → chunk-UDISNXDL.cjs} +64 -43
  178. package/dist/chunk-UDISNXDL.cjs.map +1 -0
  179. package/dist/{chunk-GWEDD3DH.js → chunk-UV3SN74I.js} +5 -5
  180. package/dist/{chunk-GWEDD3DH.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-EFELJVLA.js → chunk-VGTJPTIC.js} +28 -5
  184. package/dist/chunk-VGTJPTIC.js.map +1 -0
  185. package/dist/chunk-VQH4VAWD.cjs +12 -0
  186. package/dist/{chunk-EPTSMFH7.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-3PRKZW6D.cjs → chunk-XBYVV3MP.cjs} +60 -5
  194. package/dist/chunk-XBYVV3MP.cjs.map +1 -0
  195. package/dist/{chunk-GFRGG2US.cjs → chunk-XCAGZAKP.cjs} +7 -7
  196. package/dist/{chunk-GFRGG2US.cjs.map → chunk-XCAGZAKP.cjs.map} +1 -1
  197. package/dist/{chunk-XR4YZFKW.cjs → chunk-XDF2UPEQ.cjs} +3864 -1783
  198. package/dist/chunk-XDF2UPEQ.cjs.map +1 -0
  199. package/dist/{chunk-7V2FGGI2.cjs → chunk-XMQSEJCF.cjs} +632 -1080
  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-66UVLHQA.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-HJH3RMXG.cjs → chunk-YAAM3M2S.cjs} +10 -10
  210. package/dist/{chunk-HJH3RMXG.cjs.map → chunk-YAAM3M2S.cjs.map} +1 -1
  211. package/dist/{chunk-ATLN63JA.js → chunk-YBFHZUXX.js} +6 -6
  212. package/dist/{chunk-ATLN63JA.js.map → chunk-YBFHZUXX.js.map} +1 -1
  213. package/dist/{chunk-K3BUWSFR.js → chunk-YDFDBE6D.js} +119 -6
  214. package/dist/chunk-YDFDBE6D.js.map +1 -0
  215. package/dist/{chunk-OSZPLZIV.cjs → chunk-YVWGEQJE.cjs} +318 -132
  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 -41
  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 -9
  223. package/dist/{ddl-eWg7hx6R.d.cts → ddl-BJcOp4WZ.d.cts} +3 -3
  224. package/dist/{ddl-D5369kOY.d.ts → ddl-BXfGHbPN.d.ts} +3 -3
  225. package/dist/graph-extension/index.cjs +26 -23
  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 -8
  229. package/dist/graph-merge/index.cjs +2459 -655
  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 -468
  234. package/dist/graph-merge/index.js.map +1 -1
  235. package/dist/{index-By89Sezh.d.ts → index-BSHvKfok.d.ts} +221 -10
  236. package/dist/{index-DcQ3Sxs-.d.cts → index-DxaYCv8Y.d.cts} +221 -10
  237. package/dist/index.cjs +330 -269
  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 -50
  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 -50
  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 -24
  252. package/dist/interchange/index.js.map +1 -1
  253. package/dist/{manager-B0KjKE93.d.ts → manager-CfZAimti.d.ts} +36 -5
  254. package/dist/{manager-Cn0NFIhN.d.cts → manager-HGk6E_HW.d.cts} +36 -5
  255. package/dist/{materialize-indexes-BD4V3svD.d.ts → materialize-indexes-6A7dWGtb.d.cts} +10 -2
  256. package/dist/{materialize-indexes-DVRhd5h4.d.cts → materialize-indexes-BMJP6Tms.d.ts} +10 -2
  257. package/dist/{postgres-DaEWvN4x.d.cts → postgres-DFYWENdR.d.cts} +1961 -439
  258. package/dist/{postgres-u0a0HN2D.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 -49
  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 -22
  273. package/dist/{searchable-CnYEancP.d.ts → searchable-9OQoPuRs.d.ts} +1 -2
  274. package/dist/{searchable-BT7j9_IK.d.cts → searchable-CIje5XYD.d.cts} +1 -2
  275. package/dist/{sqlite-BrMoSsI7.d.cts → sqlite-DerU5tc7.d.ts} +2029 -347
  276. package/dist/{sqlite-CHhZUyO5.d.ts → sqlite-DitnISa9.d.cts} +2029 -347
  277. package/dist/{store-view-Bvdku0Ht.d.ts → store-DawaWWjJ.d.ts} +3145 -2556
  278. package/dist/{store-view-w-md0nQ4.d.cts → store-RwTJx8LX.d.cts} +3145 -2556
  279. package/dist/{temporal-BCORwUau.d.cts → temporal-Bn-Fi8FJ.d.cts} +1 -1
  280. package/dist/{temporal--x9T8K4S.d.ts → temporal-BtM4UALv.d.ts} +1 -1
  281. package/dist/{types-6-WJmSD4.d.cts → types-CoIx8HX5.d.cts} +1 -1
  282. package/dist/{types-Cjvkj0jA.d.ts → types-HkveCCx0.d.cts} +866 -21
  283. package/dist/{types-Cjvkj0jA.d.cts → types-HkveCCx0.d.ts} +866 -21
  284. package/dist/{types-COODtTJU.d.ts → types-KFfk-8Ah.d.ts} +1 -1
  285. package/dist/{where-CUQmCR6d.d.cts → where--fk7_0kv.d.cts} +1 -1
  286. package/dist/{where-5xVawAwL.d.ts → where-ws5hf-Ov.d.ts} +1 -1
  287. package/package.json +1 -1
  288. package/dist/chunk-2BIG7U6E.cjs +0 -83
  289. package/dist/chunk-2BIG7U6E.cjs.map +0 -1
  290. package/dist/chunk-2L54C2C2.js +0 -144
  291. package/dist/chunk-2L54C2C2.js.map +0 -1
  292. package/dist/chunk-2VLBGQBY.cjs.map +0 -1
  293. package/dist/chunk-2WDD2NO3.js +0 -59
  294. package/dist/chunk-2WDD2NO3.js.map +0 -1
  295. package/dist/chunk-2Y4IFKW7.js.map +0 -1
  296. package/dist/chunk-35S6P5ZU.js +0 -27
  297. package/dist/chunk-35S6P5ZU.js.map +0 -1
  298. package/dist/chunk-3PRKZW6D.cjs.map +0 -1
  299. package/dist/chunk-4MB3AQAQ.js.map +0 -1
  300. package/dist/chunk-4SZ6XPTG.cjs +0 -12
  301. package/dist/chunk-5MUSU4ZP.cjs.map +0 -1
  302. package/dist/chunk-63KCKSSH.js.map +0 -1
  303. package/dist/chunk-66UVLHQA.cjs.map +0 -1
  304. package/dist/chunk-6JZUSDY2.cjs.map +0 -1
  305. package/dist/chunk-764JHTLT.cjs +0 -15
  306. package/dist/chunk-764JHTLT.cjs.map +0 -1
  307. package/dist/chunk-7G32LIQM.js.map +0 -1
  308. package/dist/chunk-7V2FGGI2.cjs.map +0 -1
  309. package/dist/chunk-A2I2XO52.cjs.map +0 -1
  310. package/dist/chunk-A4PBRX4C.cjs +0 -100
  311. package/dist/chunk-A4PBRX4C.cjs.map +0 -1
  312. package/dist/chunk-ACSVZPK7.cjs.map +0 -1
  313. package/dist/chunk-ALFUGRYB.cjs +0 -1282
  314. package/dist/chunk-ALFUGRYB.cjs.map +0 -1
  315. package/dist/chunk-B75XRV3O.js +0 -125
  316. package/dist/chunk-B75XRV3O.js.map +0 -1
  317. package/dist/chunk-BCP7LLOY.js.map +0 -1
  318. package/dist/chunk-BEFM74L2.js.map +0 -1
  319. package/dist/chunk-BNUFUFAU.js.map +0 -1
  320. package/dist/chunk-C4F7VJ5D.cjs.map +0 -1
  321. package/dist/chunk-CPEL3YIR.cjs.map +0 -1
  322. package/dist/chunk-D7PG5D5K.js.map +0 -1
  323. package/dist/chunk-DI74SMXS.cjs +0 -29
  324. package/dist/chunk-DI74SMXS.cjs.map +0 -1
  325. package/dist/chunk-DK2S42XB.js +0 -77
  326. package/dist/chunk-DK2S42XB.js.map +0 -1
  327. package/dist/chunk-DRACN6XG.js +0 -27
  328. package/dist/chunk-DRACN6XG.js.map +0 -1
  329. package/dist/chunk-EE7N5XXQ.cjs.map +0 -1
  330. package/dist/chunk-EFELJVLA.js.map +0 -1
  331. package/dist/chunk-EPTSMFH7.cjs +0 -12
  332. package/dist/chunk-EQ7JKLZO.cjs +0 -157
  333. package/dist/chunk-EQ7JKLZO.cjs.map +0 -1
  334. package/dist/chunk-FJMPR3OH.cjs.map +0 -1
  335. package/dist/chunk-FMGEZBAQ.js.map +0 -1
  336. package/dist/chunk-FMMIX6N4.js.map +0 -1
  337. package/dist/chunk-FRHHDHKH.js.map +0 -1
  338. package/dist/chunk-FSXTPBRN.js.map +0 -1
  339. package/dist/chunk-G6Q5UM7U.js.map +0 -1
  340. package/dist/chunk-GYA4JRP5.js.map +0 -1
  341. package/dist/chunk-HOHAJ2NR.cjs +0 -61
  342. package/dist/chunk-HOHAJ2NR.cjs.map +0 -1
  343. package/dist/chunk-HOIFFY4M.js.map +0 -1
  344. package/dist/chunk-IIMQJYAM.js +0 -81
  345. package/dist/chunk-IIMQJYAM.js.map +0 -1
  346. package/dist/chunk-IJTLXNGJ.js.map +0 -1
  347. package/dist/chunk-ITE4IXAK.js +0 -25
  348. package/dist/chunk-ITE4IXAK.js.map +0 -1
  349. package/dist/chunk-K3BUWSFR.js.map +0 -1
  350. package/dist/chunk-KCO5EFJU.js +0 -79
  351. package/dist/chunk-KCO5EFJU.js.map +0 -1
  352. package/dist/chunk-KKYELPZ2.cjs +0 -83
  353. package/dist/chunk-KKYELPZ2.cjs.map +0 -1
  354. package/dist/chunk-MCHP7RHZ.cjs.map +0 -1
  355. package/dist/chunk-MIJKEVV7.js.map +0 -1
  356. package/dist/chunk-NCX65HBY.cjs +0 -1396
  357. package/dist/chunk-NCX65HBY.cjs.map +0 -1
  358. package/dist/chunk-OSZPLZIV.cjs.map +0 -1
  359. package/dist/chunk-OVUUTCPJ.cjs.map +0 -1
  360. package/dist/chunk-PDGEXGS6.cjs.map +0 -1
  361. package/dist/chunk-QB6VMOJ2.cjs.map +0 -1
  362. package/dist/chunk-QMQLUA66.js +0 -12
  363. package/dist/chunk-QMQLUA66.js.map +0 -1
  364. package/dist/chunk-QYWINYEA.cjs.map +0 -1
  365. package/dist/chunk-S4KQ5LV4.js.map +0 -1
  366. package/dist/chunk-SBPC5IP3.js.map +0 -1
  367. package/dist/chunk-SJDMVITW.cjs.map +0 -1
  368. package/dist/chunk-SNXVDZAJ.js.map +0 -1
  369. package/dist/chunk-SQRD2CYF.js.map +0 -1
  370. package/dist/chunk-ST3LPB2V.cjs.map +0 -1
  371. package/dist/chunk-STQ3BSED.cjs.map +0 -1
  372. package/dist/chunk-SVJ5GEXW.cjs.map +0 -1
  373. package/dist/chunk-TCRIQMBU.js.map +0 -1
  374. package/dist/chunk-TDXIBCGY.cjs.map +0 -1
  375. package/dist/chunk-TFMVL4QH.js.map +0 -1
  376. package/dist/chunk-TRF4EBJT.cjs +0 -30
  377. package/dist/chunk-TRF4EBJT.cjs.map +0 -1
  378. package/dist/chunk-TVLKA4AY.js +0 -94
  379. package/dist/chunk-TVLKA4AY.js.map +0 -1
  380. package/dist/chunk-UR7W5YQK.js.map +0 -1
  381. package/dist/chunk-VITTKBWF.js +0 -1263
  382. package/dist/chunk-VITTKBWF.js.map +0 -1
  383. package/dist/chunk-WBUFJ7BS.cjs +0 -131
  384. package/dist/chunk-WBUFJ7BS.cjs.map +0 -1
  385. package/dist/chunk-XR4YZFKW.cjs.map +0 -1
  386. package/dist/chunk-YNULOIR5.cjs.map +0 -1
  387. package/dist/chunk-ZDH3DX3C.cjs +0 -30
  388. package/dist/chunk-ZDH3DX3C.cjs.map +0 -1
  389. package/dist/chunk-ZTAJL4DT.cjs +0 -85
  390. package/dist/chunk-ZTAJL4DT.cjs.map +0 -1
  391. package/dist/define-graph-DVF-oN1i.d.cts +0 -173
  392. package/dist/define-graph-SvYXOl78.d.ts +0 -173
@@ -1,15 +1,18 @@
1
- import { lockRecordedGraphWrite, uncapturedGraphWriteLock, advanceRevisionClock, checkCardinality, checkUniqueEdge, checkWherePredicate, computeUniqueKey, getKindsForUniquenessCheck, runInsertBatch, nodeInsertDispatch, runInsertBatchReturning, applyNodeSoftDelete, createNodeWriteContext, applyNodeHardDelete, getNodeRowsByIds, generateId, runInsertNoReturn, applyNodeInsertSideEffectsBatch, applyNodeUpdate, applyNodeInsertSideEffects, checkUniquenessConstraints, createUniquenessContext, checkDisjointness } from './chunk-FSXTPBRN.js';
2
- import { createSqlSchema, DEFAULT_SQL_SCHEMA } from './chunk-MIJKEVV7.js';
3
- import { rowPropsToObject, runOptionallyInTransaction, createBackendOverlay, isLiveNodeRow } from './chunk-FMMIX6N4.js';
4
- import { validateNodeProps } from './chunk-DK2S42XB.js';
5
- import { canonicalEqual } from './chunk-UR7W5YQK.js';
6
- import { validateOptionalCanonicalIsoDate } from './chunk-KCO5EFJU.js';
7
- import { getDialect, compileNodeIndexFieldKeys, compileIndexWhere } from './chunk-K3BUWSFR.js';
8
- import { sql, asCompiledRowsSql } from './chunk-6DCB664D.js';
9
- import { requireDefined } from './chunk-QMQLUA66.js';
10
- import { filterReservedKeys, RESERVED_NODE_KEYS, RESERVED_EDGE_KEYS } from './chunk-TVLKA4AY.js';
11
- import { ConfigurationError, DatabaseOperationError, UniquenessError, ValidationError, NodeNotFoundError, KindNotFoundError, NodeConstraintNotFoundError, NodeIndexNotFoundError } from './chunk-4MB3AQAQ.js';
12
- import { resolveJsonPointer } from './chunk-G6Q5UM7U.js';
1
+ import { getEmbeddingFields, applyNodeInsertSideEffectsBatch, createNodeWriteContext, applyNodeSoftDelete, applyNodeHardDelete, applyNodeUpdate, applyNodeInsertSideEffects, checkUniquenessConstraints, createUniquenessContext } from './chunk-WEVQJ5LH.js';
2
+ import { encodeTupleKey, runInWriteTransaction, refKey, runHookedWriteOperation, validateNodeProps } from './chunk-JIVMTW7W.js';
3
+ import { runInsertBatch, nodeInsertDispatch, runInsertBatchReturning, getNodeRowsByIds, generateId, runInsertNoReturn } from './chunk-NQ6BRJBE.js';
4
+ import { canonicalEqual } from './chunk-JBQQ7THH.js';
5
+ import { createSqlSchema, DEFAULT_SQL_SCHEMA } from './chunk-MSY7FSX4.js';
6
+ import { rowPropsToObject, createBackendOverlay, isLiveNodeRow } from './chunk-AKLS3BYZ.js';
7
+ import { checkCardinality, checkUniqueEdge, checkWherePredicate, computeUniqueKey, getKindsForUniquenessCheck, checkDisjointness } from './chunk-WDGA7IYB.js';
8
+ import { validateOptionalCanonicalIsoDate, assertOrderedValidityWindow, nowIso, assertWritableValidityWindow } from './chunk-DLNROMQ7.js';
9
+ import { getDialect, compileNodeIndexFieldKeys, compileIndexWhere } from './chunk-YDFDBE6D.js';
10
+ import { sql, asCompiledRowsSql } from './chunk-PQBQG7IM.js';
11
+ import { getSearchableFields } from './chunk-PC2UBAUB.js';
12
+ import { filterReservedKeys, RESERVED_NODE_KEYS, RESERVED_EDGE_KEYS, assertJsonValue } from './chunk-K5ELX2GT.js';
13
+ import { DatabaseOperationError, ConfigurationError, ValidationError, UniquenessError, NodeNotFoundError, KindNotFoundError, NodeConstraintNotFoundError, NodeIndexNotFoundError, ENTITY_ALREADY_EXISTS_CODE } from './chunk-J3WZ3FA2.js';
14
+ import { resolveJsonPointer } from './chunk-FWJKWH6U.js';
15
+ import { requireDefined, createDataKeyedBag, hasOwnKey } from './chunk-DYATYRY4.js';
13
16
 
14
17
  // src/store/row-mappers.ts
15
18
  function nullToUndefined(value) {
@@ -59,59 +62,19 @@ function rowToEdgeMeta(row) {
59
62
  };
60
63
  }
61
64
 
62
- // src/store/operations/write-transaction.ts
63
- async function lockSchemaVersionForStoreWrite(ctx, backend) {
64
- const expectedVersion = ctx.schemaVersion;
65
- if (expectedVersion === void 0) return;
66
- if ("transaction" in backend && !backend.capabilities.transactions) {
67
- throw new ConfigurationError(
68
- "Schema-managed Store writes require a transactional backend so schema changes and entity writes can share one fence.",
69
- {
70
- code: "SCHEMA_WRITE_FENCE_UNSUPPORTED",
71
- graphId: ctx.graphId
72
- }
73
- );
74
- }
75
- const lockSchemaVersionForWrite = backend.lockSchemaVersionForWrite;
76
- if (lockSchemaVersionForWrite === void 0) {
77
- throw new ConfigurationError(
78
- "This backend cannot fence schema-managed Store writes against a concurrent schema change.",
79
- {
80
- code: "SCHEMA_WRITE_FENCE_UNSUPPORTED",
81
- graphId: ctx.graphId
82
- }
83
- );
84
- }
85
- await lockSchemaVersionForWrite({
86
- graphId: ctx.graphId,
87
- expectedVersion
88
- });
89
- }
90
- function runInWriteTransaction(ctx, backend, fn) {
91
- const ownsWriteLock = "transaction" in backend && backend.capabilities.transactions;
92
- return runOptionallyInTransaction(backend, async (target) => {
93
- await lockSchemaVersionForStoreWrite(ctx, target);
94
- const lock = ctx.historyEnabled || ctx.revisionTrackingEnabled ? await lockRecordedGraphWrite(target, ctx.graphId) : uncapturedGraphWriteLock();
95
- const result = await fn(target, lock);
96
- if (ctx.revisionTrackingEnabled && !ctx.historyEnabled) {
97
- await advanceRevisionClock(
98
- target,
99
- ctx.revisionSchema,
100
- ctx.graphId,
101
- ownsWriteLock
102
- );
103
- }
104
- return result;
105
- });
65
+ // src/store/constraints.ts
66
+ function edgeWriteNeedsConstraintFence(cardinality) {
67
+ return cardinality === "many" ? void 0 : "edgeCardinality";
106
68
  }
107
- function runHookedWriteOperation(ctx, opContext, backend, body) {
108
- return ctx.withOperationHooks(
109
- opContext,
110
- () => runInWriteTransaction(ctx, backend, body)
69
+ function nodeWriteNeedsConstraintFence(registry, kind, uniqueConstraints, operation) {
70
+ if (operation === "create" && registry.getDisjointKinds(kind).length > 0) {
71
+ return "nodeDisjointness";
72
+ }
73
+ const sharedScope = uniqueConstraints.some(
74
+ (constraint) => getKindsForUniquenessCheck(kind, constraint.scope, registry).length > 1
111
75
  );
76
+ return sharedScope ? "nodeUniquenessScope" : void 0;
112
77
  }
113
-
114
- // src/store/constraints.ts
115
78
  async function checkDisjointnessConstraint(ctx, kind, id) {
116
79
  const disjointKinds = ctx.registry.getDisjointKinds(kind);
117
80
  for (const disjointKind of disjointKinds) {
@@ -190,31 +153,98 @@ async function checkCardinalityConstraint(ctx, edgeKind, cardinality, fromKind,
190
153
  }
191
154
  }
192
155
 
156
+ // src/store/operations/already-exists.ts
157
+ var ENTITY_LABELS = {
158
+ node: { title: "Node", article: "A node" },
159
+ edge: { title: "Edge", article: "An edge" }
160
+ };
161
+ function alreadyExistsError(entity, kind, id, detail, cause) {
162
+ const label = ENTITY_LABELS[entity];
163
+ return new ValidationError(
164
+ `${label.title} already exists: ${detail}`,
165
+ {
166
+ entityType: entity,
167
+ kind,
168
+ operation: "create",
169
+ ...id === void 0 ? {} : { id },
170
+ issues: [
171
+ {
172
+ path: "id",
173
+ code: ENTITY_ALREADY_EXISTS_CODE,
174
+ message: `${label.article} with this ID already exists`
175
+ }
176
+ ]
177
+ },
178
+ {
179
+ suggestion: `Use a different ID or update the existing ${entity}.`,
180
+ ...cause === void 0 ? {} : { cause }
181
+ }
182
+ );
183
+ }
184
+ function createAlreadyExistsError(entity, kind, id) {
185
+ return alreadyExistsError(entity, kind, id, `${kind}/${id}`, void 0);
186
+ }
187
+ function isDuplicateKeyInsertError(error, entity) {
188
+ return error instanceof DatabaseOperationError && error.details.operation === "insert" && error.details.entity === entity && error.details.reason === "duplicate_key";
189
+ }
190
+ function rethrowAsAlreadyExists(error, entity) {
191
+ if (!isDuplicateKeyInsertError(error, entity)) throw error;
192
+ const attempted = error.details.attempted ?? [];
193
+ const first = attempted[0];
194
+ if (first === void 0) throw error;
195
+ if (attempted.length === 1) {
196
+ throw alreadyExistsError(
197
+ entity,
198
+ first.kind,
199
+ first.id,
200
+ `${first.kind}/${first.id}`,
201
+ error
202
+ );
203
+ }
204
+ throw alreadyExistsError(
205
+ entity,
206
+ first.kind,
207
+ void 0,
208
+ `one of the ${attempted.length} ${first.kind} ids in the refused insert`,
209
+ error
210
+ );
211
+ }
212
+ async function withAlreadyExistsTranslation(entity, run) {
213
+ try {
214
+ return await run();
215
+ } catch (error) {
216
+ rethrowAsAlreadyExists(error, entity);
217
+ }
218
+ }
219
+
193
220
  // src/store/operations/node-operations.ts
194
221
  function getNodeRegistration(graph, kind) {
222
+ if (!hasOwnKey(graph.nodes, kind)) throw new KindNotFoundError(kind, "node");
195
223
  const registration = graph.nodes[kind];
196
224
  if (registration === void 0) throw new KindNotFoundError(kind, "node");
197
225
  return registration;
198
226
  }
199
- var CACHE_KEY_SEPARATOR = "\0";
227
+ function nodeFencesConstraintProbe(ctx, kind, operation) {
228
+ if (!hasOwnKey(ctx.graph.nodes, kind)) return void 0;
229
+ return nodeWriteNeedsConstraintFence(
230
+ ctx.registry,
231
+ kind,
232
+ getNodeRegistration(ctx.graph, kind).unique ?? [],
233
+ operation
234
+ );
235
+ }
236
+ function nodeBatchFencesConstraintProbe(ctx, inputs, operation) {
237
+ for (const input of inputs) {
238
+ const reason = nodeFencesConstraintProbe(ctx, input.kind, operation);
239
+ if (reason !== void 0) return reason;
240
+ }
241
+ return void 0;
242
+ }
200
243
  function buildNodeCacheKey(graphId, kind, id) {
201
- return `${graphId}${CACHE_KEY_SEPARATOR}${kind}${CACHE_KEY_SEPARATOR}${id}`;
244
+ return encodeTupleKey([graphId, kind, id]);
202
245
  }
203
246
  function buildUniqueCacheKey(graphId, nodeKind, constraintName, key) {
204
- return `${graphId}${CACHE_KEY_SEPARATOR}${nodeKind}${CACHE_KEY_SEPARATOR}${constraintName}${CACHE_KEY_SEPARATOR}${key}`;
205
- }
206
- function createNodeAlreadyExistsError(kind, id) {
207
- return new ValidationError(
208
- `Node already exists: ${kind}/${id}`,
209
- {
210
- entityType: "node",
211
- kind,
212
- operation: "create",
213
- id,
214
- issues: [{ path: "id", message: "A node with this ID already exists" }]
215
- },
216
- { suggestion: `Use a different ID or update the existing node.` }
217
- );
247
+ return encodeTupleKey([graphId, nodeKind, constraintName, key]);
218
248
  }
219
249
  function buildInsertNodeParams(graphId, kind, id, props, validFrom, validTo) {
220
250
  const insertParams = {
@@ -405,21 +435,28 @@ function draftNodeCreate(ctx, input, id, options) {
405
435
  kind,
406
436
  operation: "create"
407
437
  });
438
+ const validFrom = validateOptionalCanonicalIsoDate(
439
+ input.validFrom,
440
+ "validFrom"
441
+ );
442
+ const validTo = validateOptionalCanonicalIsoDate(input.validTo, "validTo");
443
+ assertOrderedValidityWindow(`${kind} "${id}"`, validFrom, validTo);
408
444
  return {
409
445
  kind,
410
446
  id,
447
+ idProvided: input.id !== void 0,
411
448
  nodeKind,
412
449
  uniqueConstraints: registration.unique ?? [],
413
450
  validatedProps,
414
- validFrom: validateOptionalCanonicalIsoDate(input.validFrom, "validFrom"),
415
- validTo: validateOptionalCanonicalIsoDate(input.validTo, "validTo")
451
+ validFrom,
452
+ validTo
416
453
  };
417
454
  }
418
455
  async function finishNodeCreatePreparation(ctx, draft, backend) {
419
456
  const { kind, id, validatedProps, uniqueConstraints } = draft;
420
457
  const existingNode = await backend.getNode(ctx.graphId, kind, id);
421
458
  if (existingNode && !existingNode.deleted_at) {
422
- throw createNodeAlreadyExistsError(kind, id);
459
+ throw createAlreadyExistsError("node", kind, id);
423
460
  }
424
461
  const constraintContext = {
425
462
  graphId: ctx.graphId,
@@ -437,6 +474,8 @@ async function finishNodeCreatePreparation(ctx, draft, backend) {
437
474
  return {
438
475
  kind,
439
476
  id,
477
+ idProvided: draft.idProvided,
478
+ tombstone: existingNode,
440
479
  nodeKind: draft.nodeKind,
441
480
  validatedProps,
442
481
  uniqueConstraints,
@@ -470,6 +509,9 @@ async function finalizeNodeCreateBatch(ctx, preparedCreates, backend, lock) {
470
509
  backend
471
510
  );
472
511
  }
512
+ function foldReferences(preparedCreates) {
513
+ return preparedCreates.filter((prepared) => prepared.idProvided).map((prepared) => ({ kind: prepared.kind, id: prepared.id }));
514
+ }
473
515
  async function finalizeNodeCreate(ctx, prepared, backend, lock) {
474
516
  await applyNodeInsertSideEffects(
475
517
  createNodeWriteContext(ctx.graphId, ctx.registry, lock),
@@ -526,13 +568,46 @@ async function performNodeUpdate(ctx, input, backend, lock, options) {
526
568
  input.props
527
569
  );
528
570
  const nodeKind = registration.type;
571
+ const validFrom = validateOptionalCanonicalIsoDate(
572
+ input.validFrom,
573
+ "validFrom"
574
+ );
529
575
  const validTo = validateOptionalCanonicalIsoDate(input.validTo, "validTo");
576
+ const resurrectionInstant = options?.clearDeleted === true && existing.deleted_at !== void 0 ? nowIso() : void 0;
577
+ const windowVerdict = assertWritableValidityWindow(
578
+ `${kind} "${id}"`,
579
+ validFrom,
580
+ resurrectionInstant === void 0 ? {
581
+ effectiveValidFrom: existing.valid_from,
582
+ appliesStatedValidFrom: false,
583
+ effectiveBoundIsStored: true
584
+ } : {
585
+ effectiveValidFrom: resurrectionInstant,
586
+ appliesStatedValidFrom: true,
587
+ // The instant this write is about to stamp, not a bound the row holds.
588
+ effectiveBoundIsStored: false
589
+ },
590
+ validTo
591
+ );
530
592
  const writeContext = createNodeWriteContext(ctx.graphId, ctx.registry, lock);
593
+ const effectiveValidFrom = validFrom ?? resurrectionInstant;
531
594
  const shared = {
532
595
  schema: nodeKind.schema,
533
596
  validatedProps,
534
597
  uniqueConstraints: registration.unique ?? [],
535
- ...validTo !== void 0 && { validTo }
598
+ ...effectiveValidFrom !== void 0 && { validFrom: effectiveValidFrom },
599
+ ...validTo !== void 0 && { validTo },
600
+ // The bound the verdict above READ, carried into the UPDATE's own `WHERE`
601
+ // so the row this writes is the row that was judged. The verdict hands over
602
+ // the predicate rather than a flag, so both conditions that decide it — did
603
+ // the verdict consult the effective bound, and WAS that bound the row's
604
+ // stored one — are answered where they are known. A plain
605
+ // `update({ props })` states no window, reads no bound, and stays unfenced:
606
+ // the same rule `UpdateEdgeParams`'s identity components follow, for the
607
+ // same reason. The resurrecting leg is judged against `resurrectionInstant`
608
+ // and so fences on `deleted_at IS NOT NULL` alone, converging through the
609
+ // recovery below.
610
+ ...windowVerdict.storedLowerBoundFence
536
611
  };
537
612
  if (options?.clearDeleted) {
538
613
  const row2 = await applyNodeUpdate(
@@ -550,6 +625,41 @@ async function performNodeUpdate(ctx, input, backend, lock, options) {
550
625
  );
551
626
  return rowToNode(row);
552
627
  }
628
+ var NODE_UPDATE_ATTEMPTS = 2;
629
+ async function performNodeUpdateWithResurrectionRecovery(ctx, input, target, lock, options) {
630
+ for (let attempt = 1; attempt <= NODE_UPDATE_ATTEMPTS; attempt += 1) {
631
+ try {
632
+ return await performNodeUpdate(
633
+ ctx,
634
+ input,
635
+ target,
636
+ lock,
637
+ attempt === 1 ? options : void 0
638
+ );
639
+ } catch (error) {
640
+ if (!isNodeUpdateNoRowError(error) || attempt === NODE_UPDATE_ATTEMPTS) {
641
+ throw nodeUpdateRaceError(input, error);
642
+ }
643
+ const current = await target.getNode(ctx.graphId, input.kind, input.id);
644
+ if (current === void 0 || current.deleted_at !== void 0) {
645
+ throw new NodeNotFoundError(input.kind, input.id);
646
+ }
647
+ }
648
+ }
649
+ throw new NodeNotFoundError(input.kind, input.id);
650
+ }
651
+ function nodeUpdateRaceError(input, error) {
652
+ if (!isNodeUpdateNoRowError(error)) return error;
653
+ return new DatabaseOperationError(
654
+ `Node update for ${input.kind} "${input.id}" could not be applied to a stable row after ${NODE_UPDATE_ATTEMPTS} attempts: the row was removed and recreated between each read and its write. A concurrent writer is replacing this node faster than it can be read; serialize the writers, or retry.`,
655
+ {
656
+ operation: "update",
657
+ entity: "node",
658
+ attempted: [{ kind: input.kind, id: input.id }]
659
+ },
660
+ { cause: error }
661
+ );
662
+ }
553
663
  async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
554
664
  if (backend.getNodes !== void 0) {
555
665
  const idsByKind = /* @__PURE__ */ new Map();
@@ -583,7 +693,7 @@ async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
583
693
  ctx.registry
584
694
  );
585
695
  for (const kindToCheck of kindsToCheck) {
586
- const groupKey = kindToCheck + CACHE_KEY_SEPARATOR + constraint.name;
696
+ const groupKey = encodeTupleKey([kindToCheck, constraint.name]);
587
697
  const group = groups.get(groupKey) ?? {
588
698
  nodeKind: kindToCheck,
589
699
  constraintName: constraint.name,
@@ -645,10 +755,60 @@ async function prepareBatchCreates(ctx, inputs, backend, options) {
645
755
  prepared.uniqueConstraints
646
756
  );
647
757
  }
648
- const batchInsertParams = preparedCreates.map(
649
- (prepared) => prepared.insertParams
650
- );
651
- return { preparedCreates, batchInsertParams };
758
+ return preparedCreates;
759
+ }
760
+ function partitionCreates(preparedCreates) {
761
+ const inserts = [];
762
+ const resurrections = [];
763
+ for (const prepared of preparedCreates) {
764
+ if (prepared.tombstone === void 0) {
765
+ inserts.push(prepared);
766
+ } else {
767
+ resurrections.push(prepared);
768
+ }
769
+ }
770
+ return { inserts, resurrections };
771
+ }
772
+ function isNodeUpdateNoRowError(error) {
773
+ return error instanceof DatabaseOperationError && error.details.operation === "update" && error.details.entity === "node" && error.details.reason === "no_row_returned";
774
+ }
775
+ async function resurrectPreparedNode(ctx, target, lock, prepared) {
776
+ const current = await target.getNode(ctx.graphId, prepared.kind, prepared.id);
777
+ if (current === void 0) {
778
+ throw new DatabaseOperationError(
779
+ `Node tombstone disappeared before resurrection: ${prepared.kind} ${prepared.id}`,
780
+ { operation: "update", entity: "node" }
781
+ );
782
+ }
783
+ if (current.deleted_at === void 0) {
784
+ throw createAlreadyExistsError("node", prepared.kind, prepared.id);
785
+ }
786
+ try {
787
+ return await applyNodeUpdate(
788
+ createNodeWriteContext(ctx.graphId, ctx.registry, lock),
789
+ {
790
+ existing: current,
791
+ clearDeleted: true,
792
+ schema: prepared.nodeKind.schema,
793
+ validatedProps: prepared.validatedProps,
794
+ uniqueConstraints: prepared.uniqueConstraints,
795
+ ...prepared.insertParams.validFrom === void 0 ? {} : { validFrom: prepared.insertParams.validFrom },
796
+ ...prepared.insertParams.validTo === void 0 ? {} : { validTo: prepared.insertParams.validTo }
797
+ },
798
+ target
799
+ );
800
+ } catch (error) {
801
+ if (!isNodeUpdateNoRowError(error)) throw error;
802
+ const afterFailure = await target.getNode(
803
+ ctx.graphId,
804
+ prepared.kind,
805
+ prepared.id
806
+ );
807
+ if (afterFailure !== void 0 && afterFailure.deleted_at === void 0) {
808
+ throw createAlreadyExistsError("node", prepared.kind, prepared.id);
809
+ }
810
+ throw error;
811
+ }
652
812
  }
653
813
  async function findUniqueRowAcrossKinds(backend, graphId, constraintName, key, kindsToCheck, includeDeleted) {
654
814
  for (const kindToCheck of kindsToCheck) {
@@ -707,6 +867,8 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
707
867
  opContext,
708
868
  backend,
709
869
  async (target, lock) => {
870
+ const identity = ctx.identity;
871
+ if (identity !== void 0) await identity.lock(target);
710
872
  const prepared = await validateAndPrepareNodeCreate(
711
873
  ctx,
712
874
  input,
@@ -714,18 +876,36 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
714
876
  target,
715
877
  options
716
878
  );
717
- let row;
718
- if (shouldReturnRow) {
719
- row = await target.insertNode(prepared.insertParams);
720
- } else {
879
+ const existing = prepared.tombstone;
880
+ if (existing !== void 0) {
881
+ const resurrected = await resurrectPreparedNode(
882
+ ctx,
883
+ target,
884
+ lock,
885
+ prepared
886
+ );
887
+ if (identity !== void 0) {
888
+ await identity.foldCreated(target, foldReferences([prepared]));
889
+ }
890
+ return shouldReturnRow ? rowToNode(resurrected) : void 0;
891
+ }
892
+ const row = await withAlreadyExistsTranslation("node", async () => {
893
+ if (shouldReturnRow) return target.insertNode(prepared.insertParams);
721
894
  await runInsertNoReturn(
722
895
  nodeInsertDispatch(target),
723
896
  prepared.insertParams
724
897
  );
725
- }
898
+ return;
899
+ });
726
900
  await finalizeNodeCreate(ctx, prepared, target, lock);
901
+ if (identity !== void 0) {
902
+ await identity.foldCreated(target, foldReferences([prepared]));
903
+ }
727
904
  if (row === void 0) return;
728
905
  return rowToNode(row);
906
+ },
907
+ {
908
+ fencesConstraintProbe: nodeFencesConstraintProbe(ctx, kind, "create")
729
909
  }
730
910
  );
731
911
  }
@@ -744,32 +924,92 @@ async function executeNodeCreate(ctx, input, backend, options) {
744
924
  }
745
925
  async function executeNodeCreateNoReturnBatch(ctx, inputs, backend) {
746
926
  if (inputs.length === 0) return;
747
- await runInWriteTransaction(ctx, backend, async (target, lock) => {
748
- const { preparedCreates, batchInsertParams } = await prepareBatchCreates(
749
- ctx,
750
- inputs,
751
- target
752
- );
753
- await runInsertBatch(nodeInsertDispatch(target), batchInsertParams);
754
- await finalizeNodeCreateBatch(ctx, preparedCreates, target, lock);
755
- });
927
+ await runInWriteTransaction(
928
+ ctx,
929
+ backend,
930
+ async (target, lock) => {
931
+ const identity = ctx.identity;
932
+ if (identity !== void 0) await identity.lock(target);
933
+ const preparedCreates = await prepareBatchCreates(ctx, inputs, target);
934
+ const partition = partitionCreates(preparedCreates);
935
+ await withAlreadyExistsTranslation(
936
+ "node",
937
+ () => runInsertBatch(
938
+ nodeInsertDispatch(target),
939
+ partition.inserts.map((prepared) => prepared.insertParams)
940
+ )
941
+ );
942
+ for (const prepared of partition.resurrections) {
943
+ await resurrectPreparedNode(ctx, target, lock, prepared);
944
+ }
945
+ await finalizeNodeCreateBatch(ctx, partition.inserts, target, lock);
946
+ if (identity !== void 0) {
947
+ await identity.foldCreated(target, foldReferences(preparedCreates));
948
+ }
949
+ },
950
+ {
951
+ fencesConstraintProbe: nodeBatchFencesConstraintProbe(
952
+ ctx,
953
+ inputs,
954
+ "create"
955
+ )
956
+ }
957
+ );
756
958
  }
757
959
  async function executeNodeCreateBatch(ctx, inputs, backend, options) {
758
960
  if (inputs.length === 0) return [];
759
- return runInWriteTransaction(ctx, backend, async (target, lock) => {
760
- const { preparedCreates, batchInsertParams } = await prepareBatchCreates(
761
- ctx,
762
- inputs,
763
- target,
764
- options
765
- );
766
- const rows = await runInsertBatchReturning(
767
- nodeInsertDispatch(target),
768
- batchInsertParams
769
- );
770
- await finalizeNodeCreateBatch(ctx, preparedCreates, target, lock);
771
- return rows.map((row) => rowToNode(row));
772
- });
961
+ return runInWriteTransaction(
962
+ ctx,
963
+ backend,
964
+ async (target, lock) => {
965
+ const identity = ctx.identity;
966
+ if (identity !== void 0) await identity.lock(target);
967
+ const preparedCreates = await prepareBatchCreates(
968
+ ctx,
969
+ inputs,
970
+ target,
971
+ options
972
+ );
973
+ const partition = partitionCreates(preparedCreates);
974
+ const inserted = await withAlreadyExistsTranslation(
975
+ "node",
976
+ () => runInsertBatchReturning(
977
+ nodeInsertDispatch(target),
978
+ partition.inserts.map((prepared) => prepared.insertParams)
979
+ )
980
+ );
981
+ const resurrected = [];
982
+ for (const prepared of partition.resurrections) {
983
+ resurrected.push(
984
+ await resurrectPreparedNode(ctx, target, lock, prepared)
985
+ );
986
+ }
987
+ await finalizeNodeCreateBatch(ctx, partition.inserts, target, lock);
988
+ const byReference = new Map(
989
+ [...inserted, ...resurrected].map((row) => [
990
+ refKey({ kind: row.kind, id: row.id }),
991
+ row
992
+ ])
993
+ );
994
+ const rows = preparedCreates.map(
995
+ (prepared) => requireDefined(
996
+ byReference.get(refKey({ kind: prepared.kind, id: prepared.id })),
997
+ `Missing written row for ${prepared.kind} ${prepared.id}`
998
+ )
999
+ );
1000
+ if (identity !== void 0) {
1001
+ await identity.foldCreated(target, foldReferences(preparedCreates));
1002
+ }
1003
+ return rows.map((row) => rowToNode(row));
1004
+ },
1005
+ {
1006
+ fencesConstraintProbe: nodeBatchFencesConstraintProbe(
1007
+ ctx,
1008
+ inputs,
1009
+ "create"
1010
+ )
1011
+ }
1012
+ );
773
1013
  }
774
1014
  async function executeNodeUpdate(ctx, input, backend, options) {
775
1015
  const opContext = ctx.createOperationContext(
@@ -782,14 +1022,301 @@ async function executeNodeUpdate(ctx, input, backend, options) {
782
1022
  ctx,
783
1023
  opContext,
784
1024
  backend,
785
- (target, lock) => performNodeUpdate(ctx, input, target, lock, options)
1025
+ async (target, lock) => {
1026
+ const identity = ctx.identity;
1027
+ if (options?.clearDeleted && identity !== void 0) {
1028
+ await identity.lock(target);
1029
+ }
1030
+ const node = await performNodeUpdateWithResurrectionRecovery(
1031
+ ctx,
1032
+ input,
1033
+ target,
1034
+ lock,
1035
+ options
1036
+ );
1037
+ if (options?.clearDeleted && identity !== void 0) {
1038
+ await identity.foldCreated(target, [
1039
+ { kind: input.kind, id: input.id }
1040
+ ]);
1041
+ }
1042
+ return node;
1043
+ },
1044
+ {
1045
+ fencesConstraintProbe: nodeFencesConstraintProbe(
1046
+ ctx,
1047
+ input.kind,
1048
+ "update"
1049
+ )
1050
+ }
1051
+ );
1052
+ }
1053
+ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candidateIdColumn, backend) {
1054
+ const registration = getNodeRegistration(ctx.graph, kind);
1055
+ const schema = registration.type.schema;
1056
+ const uniqueConstraints = registration.unique ?? [];
1057
+ if (!backend.capabilities.transactions) {
1058
+ throw new ConfigurationError(
1059
+ "updateWhere() requires a transactional backend so validation and sidecars are atomic",
1060
+ { code: "SET_UPDATE_TRANSACTIONS_REQUIRED", kind }
1061
+ );
1062
+ }
1063
+ if (backend.updateNodeSet === void 0) {
1064
+ throw new ConfigurationError(
1065
+ "This backend does not support set-based node updates",
1066
+ { code: "SET_UPDATE_UNSUPPORTED", kind }
1067
+ );
1068
+ }
1069
+ if (Object.keys(inputPatch).length === 0) {
1070
+ throw new ValidationError("updateWhere() patch must not be empty", {
1071
+ entityType: "node",
1072
+ kind,
1073
+ operation: "update",
1074
+ issues: [{ path: "patch", message: "Provide at least one property" }]
1075
+ });
1076
+ }
1077
+ const unknownProperty = Object.keys(inputPatch).find(
1078
+ (property) => !Object.hasOwn(schema.shape, property)
1079
+ );
1080
+ if (unknownProperty !== void 0) {
1081
+ throw new ValidationError(
1082
+ `Unknown ${kind} property in updateWhere() patch: ${unknownProperty}`,
1083
+ {
1084
+ entityType: "node",
1085
+ kind,
1086
+ operation: "update",
1087
+ issues: [
1088
+ {
1089
+ path: unknownProperty,
1090
+ message: "Property is not declared by the node schema"
1091
+ }
1092
+ ]
1093
+ }
1094
+ );
1095
+ }
1096
+ const parsedPatch = validateNodeProps(schema.partial(), inputPatch, {
1097
+ kind,
1098
+ operation: "update"
1099
+ });
1100
+ const patch = createDataKeyedBag();
1101
+ const unsetProperties = [];
1102
+ for (const [property, value] of Object.entries(parsedPatch)) {
1103
+ if (value === void 0) {
1104
+ unsetProperties.push(property);
1105
+ continue;
1106
+ }
1107
+ assertJsonValue(value, property, `Node "${kind}" updateWhere patch`);
1108
+ patch[property] = value;
1109
+ }
1110
+ if (Object.keys(patch).length === 0 && unsetProperties.length === 0) {
1111
+ throw new ValidationError(
1112
+ "updateWhere() patch has no recognized properties",
1113
+ {
1114
+ entityType: "node",
1115
+ kind,
1116
+ operation: "update",
1117
+ issues: [
1118
+ { path: "patch", message: "Provide a declared node property" }
1119
+ ]
1120
+ }
1121
+ );
1122
+ }
1123
+ if (uniqueConstraints.length > 0 && (backend.hardDeleteUniquesByNodeIds === void 0 || backend.insertUniqueBatch === void 0 || backend.checkUniqueBatch === void 0)) {
1124
+ throw new ConfigurationError(
1125
+ "updateWhere() requires batched uniqueness sidecar operations for constrained nodes",
1126
+ { code: "SET_UPDATE_UNIQUENESS_UNSUPPORTED", kind }
1127
+ );
1128
+ }
1129
+ if (getSearchableFields(schema).length > 0 && (backend.upsertFulltext === void 0 || backend.deleteFulltext === void 0 || backend.upsertFulltextBatch === void 0 || backend.deleteFulltextBatch === void 0)) {
1130
+ throw new ConfigurationError(
1131
+ "updateWhere() requires batched fulltext sidecar operations for searchable nodes",
1132
+ { code: "SET_UPDATE_FULLTEXT_UNSUPPORTED", kind }
1133
+ );
1134
+ }
1135
+ if (getEmbeddingFields(schema).length > 0 && (backend.upsertEmbedding === void 0 || backend.deleteEmbedding === void 0 || backend.upsertEmbeddingBatch === void 0 || backend.deleteEmbeddingBatch === void 0)) {
1136
+ throw new ConfigurationError(
1137
+ "updateWhere() requires batched vector sidecar operations for embedded nodes",
1138
+ { code: "SET_UPDATE_VECTOR_UNSUPPORTED", kind }
1139
+ );
1140
+ }
1141
+ const hookContext = ctx.createBulkOperationContext("updateWhere", kind);
1142
+ return ctx.withBulkOperationHooks(
1143
+ hookContext,
1144
+ () => runInWriteTransaction(
1145
+ ctx,
1146
+ backend,
1147
+ async (target, lock) => {
1148
+ const updateNodeSet = target.updateNodeSet;
1149
+ if (updateNodeSet === void 0) {
1150
+ throw new ConfigurationError(
1151
+ "The transaction backend does not support set-based node updates",
1152
+ { code: "SET_UPDATE_UNSUPPORTED", kind }
1153
+ );
1154
+ }
1155
+ const hardDeleteUniquesByNodeIds = target.hardDeleteUniquesByNodeIds;
1156
+ if (uniqueConstraints.length > 0 && (hardDeleteUniquesByNodeIds === void 0 || target.insertUniqueBatch === void 0 || target.checkUniqueBatch === void 0)) {
1157
+ throw new ConfigurationError(
1158
+ "The transaction backend lacks batched uniqueness operations",
1159
+ { code: "SET_UPDATE_UNIQUENESS_UNSUPPORTED", kind }
1160
+ );
1161
+ }
1162
+ if (getSearchableFields(schema).length > 0 && (target.upsertFulltext === void 0 || target.deleteFulltext === void 0 || target.upsertFulltextBatch === void 0 || target.deleteFulltextBatch === void 0)) {
1163
+ throw new ConfigurationError(
1164
+ "The transaction backend lacks batched fulltext operations",
1165
+ { code: "SET_UPDATE_FULLTEXT_UNSUPPORTED", kind }
1166
+ );
1167
+ }
1168
+ if (getEmbeddingFields(schema).length > 0 && (target.upsertEmbedding === void 0 || target.deleteEmbedding === void 0 || target.upsertEmbeddingBatch === void 0 || target.deleteEmbeddingBatch === void 0)) {
1169
+ throw new ConfigurationError(
1170
+ "The transaction backend lacks batched vector operations",
1171
+ { code: "SET_UPDATE_VECTOR_UNSUPPORTED", kind }
1172
+ );
1173
+ }
1174
+ const result = await updateNodeSet({
1175
+ graphId: ctx.graphId,
1176
+ kind,
1177
+ patch,
1178
+ unsetProperties,
1179
+ candidateIds,
1180
+ candidateIdColumn
1181
+ });
1182
+ if (result.affectedCount === 0) return { affectedCount: 0 };
1183
+ const sidecarItems = result.rows.map((row) => {
1184
+ const props = rowPropsToObject(row.props);
1185
+ const validatedProps = validateNodeProps(schema, props, {
1186
+ kind,
1187
+ operation: "update",
1188
+ id: row.id
1189
+ });
1190
+ if (!canonicalEqual(validatedProps, props)) {
1191
+ throw new ValidationError(
1192
+ `Set update would persist a non-canonical ${kind} row`,
1193
+ {
1194
+ entityType: "node",
1195
+ kind,
1196
+ operation: "update",
1197
+ id: row.id,
1198
+ issues: [
1199
+ {
1200
+ path: "props",
1201
+ message: "The complete row requires schema normalization"
1202
+ }
1203
+ ]
1204
+ }
1205
+ );
1206
+ }
1207
+ return {
1208
+ kind,
1209
+ id: row.id,
1210
+ schema,
1211
+ props: validatedProps,
1212
+ uniqueConstraints
1213
+ };
1214
+ });
1215
+ if (uniqueConstraints.length > 0) {
1216
+ const affectedIds = new Set(result.rows.map((row) => row.id));
1217
+ for (const constraint of uniqueConstraints) {
1218
+ const keyToId = /* @__PURE__ */ new Map();
1219
+ for (const item of sidecarItems) {
1220
+ if (!checkWherePredicate(constraint, item.props)) continue;
1221
+ const key = computeUniqueKey(
1222
+ item.props,
1223
+ constraint.fields,
1224
+ constraint.collation
1225
+ );
1226
+ const priorId = keyToId.get(key);
1227
+ if (priorId !== void 0 && priorId !== item.id) {
1228
+ throw new UniquenessError({
1229
+ constraintName: constraint.name,
1230
+ kind,
1231
+ existingId: priorId,
1232
+ newId: item.id,
1233
+ fields: constraint.fields
1234
+ });
1235
+ }
1236
+ keyToId.set(key, item.id);
1237
+ }
1238
+ const keys = [...keyToId.keys()];
1239
+ if (keys.length === 0) continue;
1240
+ for (const kindToCheck of getKindsForUniquenessCheck(
1241
+ kind,
1242
+ constraint.scope,
1243
+ ctx.registry
1244
+ )) {
1245
+ const existingRows = await requireDefined(
1246
+ target.checkUniqueBatch
1247
+ )({
1248
+ graphId: ctx.graphId,
1249
+ nodeKind: kindToCheck,
1250
+ constraintName: constraint.name,
1251
+ keys
1252
+ });
1253
+ for (const existing of existingRows) {
1254
+ if (existing.concrete_kind === kind && affectedIds.has(existing.node_id)) {
1255
+ continue;
1256
+ }
1257
+ throw new UniquenessError({
1258
+ constraintName: constraint.name,
1259
+ kind: kindToCheck,
1260
+ existingId: existing.node_id,
1261
+ newId: requireDefined(keyToId.get(existing.key)),
1262
+ fields: constraint.fields
1263
+ });
1264
+ }
1265
+ }
1266
+ }
1267
+ await requireDefined(hardDeleteUniquesByNodeIds)({
1268
+ graphId: ctx.graphId,
1269
+ concreteKind: kind,
1270
+ nodeIds: result.rows.map((row) => row.id)
1271
+ });
1272
+ }
1273
+ await applyNodeInsertSideEffectsBatch(
1274
+ createNodeWriteContext(ctx.graphId, ctx.registry, lock),
1275
+ sidecarItems,
1276
+ target
1277
+ );
1278
+ return { affectedCount: result.affectedCount };
1279
+ },
1280
+ {
1281
+ didWrite: (result) => result.affectedCount > 0,
1282
+ // The set update re-checks every changed unique key across the
1283
+ // constraint's scope before rebuilding the sidecars, so a shared-scope
1284
+ // constraint makes it a constrained write like any other update.
1285
+ fencesConstraintProbe: nodeFencesConstraintProbe(ctx, kind, "update")
1286
+ }
1287
+ )
786
1288
  );
787
1289
  }
788
1290
  async function executeNodeUpsertUpdate(ctx, input, backend, options) {
789
1291
  return runInWriteTransaction(
790
1292
  ctx,
791
1293
  backend,
792
- (target, lock) => performNodeUpdate(ctx, input, target, lock, options)
1294
+ async (target, lock) => {
1295
+ const identity = ctx.identity;
1296
+ if (options?.clearDeleted && identity !== void 0) {
1297
+ await identity.lock(target);
1298
+ }
1299
+ const node = await performNodeUpdateWithResurrectionRecovery(
1300
+ ctx,
1301
+ input,
1302
+ target,
1303
+ lock,
1304
+ options
1305
+ );
1306
+ if (options?.clearDeleted && identity !== void 0) {
1307
+ await identity.foldCreated(target, [
1308
+ { kind: input.kind, id: input.id }
1309
+ ]);
1310
+ }
1311
+ return node;
1312
+ },
1313
+ {
1314
+ fencesConstraintProbe: nodeFencesConstraintProbe(
1315
+ ctx,
1316
+ input.kind,
1317
+ "update"
1318
+ )
1319
+ }
793
1320
  );
794
1321
  }
795
1322
  async function executeNodeDelete(ctx, kind, id, backend) {
@@ -801,6 +1328,8 @@ async function executeNodeDelete(ctx, kind, id, backend) {
801
1328
  opContext,
802
1329
  backend,
803
1330
  async (target, lock) => {
1331
+ const identity = ctx.identity;
1332
+ if (identity !== void 0) await identity.lock(target);
804
1333
  const registration = getNodeRegistration(ctx.graph, kind);
805
1334
  const preflight = await target.getNode(ctx.graphId, kind, id);
806
1335
  if (!preflight || !isLiveNodeRow(preflight)) return;
@@ -814,9 +1343,49 @@ async function executeNodeDelete(ctx, kind, id, backend) {
814
1343
  },
815
1344
  target
816
1345
  );
1346
+ if (identity !== void 0) {
1347
+ await identity.detachDeleted(target, { kind, id }, "soft");
1348
+ }
817
1349
  }
818
1350
  );
819
1351
  }
1352
+ async function executeNodeDeleteBatch(ctx, kind, ids, backend) {
1353
+ await runInWriteTransaction(
1354
+ ctx,
1355
+ backend,
1356
+ async (target, lock) => {
1357
+ const identity = ctx.identity;
1358
+ if (identity !== void 0) await identity.lock(target);
1359
+ const registration = getNodeRegistration(ctx.graph, kind);
1360
+ const writeContext = createNodeWriteContext(
1361
+ ctx.graphId,
1362
+ ctx.registry,
1363
+ lock
1364
+ );
1365
+ let affectedCount = 0;
1366
+ for (const id of ids) {
1367
+ const preflight = await target.getNode(ctx.graphId, kind, id);
1368
+ if (!preflight || !isLiveNodeRow(preflight)) continue;
1369
+ await applyNodeSoftDelete(
1370
+ writeContext,
1371
+ {
1372
+ existing: preflight,
1373
+ schema: registration.type.schema,
1374
+ uniqueConstraints: registration.unique ?? [],
1375
+ onDelete: registration.onDelete
1376
+ },
1377
+ target
1378
+ );
1379
+ if (identity !== void 0) {
1380
+ await identity.detachDeleted(target, { kind, id }, "soft");
1381
+ }
1382
+ affectedCount += 1;
1383
+ }
1384
+ return affectedCount;
1385
+ },
1386
+ { didWrite: (affectedCount) => affectedCount > 0 }
1387
+ );
1388
+ }
820
1389
  async function executeNodeHardDelete(ctx, kind, id, backend) {
821
1390
  const gate = await backend.getNode(ctx.graphId, kind, id);
822
1391
  if (!gate) return;
@@ -826,6 +1395,8 @@ async function executeNodeHardDelete(ctx, kind, id, backend) {
826
1395
  opContext,
827
1396
  backend,
828
1397
  async (target, lock) => {
1398
+ const identity = ctx.identity;
1399
+ if (identity !== void 0) await identity.lock(target);
829
1400
  const registration = getNodeRegistration(ctx.graph, kind);
830
1401
  await applyNodeHardDelete(
831
1402
  createNodeWriteContext(ctx.graphId, ctx.registry, lock),
@@ -837,6 +1408,9 @@ async function executeNodeHardDelete(ctx, kind, id, backend) {
837
1408
  },
838
1409
  target
839
1410
  );
1411
+ if (identity !== void 0) {
1412
+ await identity.detachDeleted(target, { kind, id }, "hard");
1413
+ }
840
1414
  }
841
1415
  );
842
1416
  }
@@ -1272,101 +1846,109 @@ async function executeNodeBulkGetOrCreateByConstraint(ctx, kind, constraintName,
1272
1846
  constraint.scope,
1273
1847
  ctx.registry
1274
1848
  );
1275
- const existingByKey = uniqueKeys.length > 0 ? await batchCheckUniqueAcrossKinds(
1276
- backend,
1277
- ctx.graphId,
1278
- constraint.name,
1279
- uniqueKeys,
1280
- kindsToCheck,
1281
- true
1282
- ) : /* @__PURE__ */ new Map();
1283
- const toCreate = [];
1284
- const toFetch = [];
1285
- const duplicateOf = [];
1286
- const seenKeys = /* @__PURE__ */ new Map();
1287
- for (const [index, { validatedProps, key }] of validated.entries()) {
1288
- if (key === void 0) {
1289
- toCreate.push({ index, input: { kind, props: validatedProps } });
1290
- continue;
1291
- }
1292
- const previousIndex = seenKeys.get(key);
1293
- if (previousIndex !== void 0) {
1294
- duplicateOf.push({ index, sourceIndex: previousIndex });
1295
- continue;
1296
- }
1297
- seenKeys.set(key, index);
1298
- const existing = existingByKey.get(key);
1299
- if (existing === void 0) {
1300
- toCreate.push({ index, input: { kind, props: validatedProps } });
1301
- } else {
1302
- toFetch.push({
1303
- index,
1304
- nodeId: existing.node_id,
1305
- concreteKind: existing.concrete_kind,
1306
- validatedProps,
1307
- isSoftDeleted: existing.deleted_at !== void 0
1308
- });
1309
- }
1310
- }
1311
- const results = Array.from({ length: items.length });
1312
- if (toCreate.length > 0) {
1313
- const createInputs = toCreate.map((entry) => entry.input);
1314
- const createdNodes = await executeNodeCreateBatch(
1315
- ctx,
1316
- createInputs,
1849
+ async function attempt() {
1850
+ const existingByKey = uniqueKeys.length > 0 ? await batchCheckUniqueAcrossKinds(
1317
1851
  backend,
1318
- { propsPreValidated: true }
1319
- );
1320
- for (const [batchIndex, entry] of toCreate.entries()) {
1321
- results[entry.index] = {
1322
- node: requireDefined(createdNodes[batchIndex]),
1323
- action: "created"
1324
- };
1325
- }
1326
- }
1327
- for (const entry of toFetch) {
1328
- const { index, concreteKind, validatedProps, isSoftDeleted, nodeId } = entry;
1329
- const existingRow = await backend.getNode(
1330
1852
  ctx.graphId,
1331
- concreteKind,
1332
- nodeId
1333
- );
1334
- if (existingRow === void 0) {
1335
- const node = await executeNodeCreate(
1853
+ constraint.name,
1854
+ uniqueKeys,
1855
+ kindsToCheck,
1856
+ true
1857
+ ) : /* @__PURE__ */ new Map();
1858
+ const toCreate = [];
1859
+ const toFetch = [];
1860
+ const duplicateOf = [];
1861
+ const seenKeys = /* @__PURE__ */ new Map();
1862
+ for (const [index, { validatedProps, key }] of validated.entries()) {
1863
+ if (key === void 0) {
1864
+ toCreate.push({ index, input: { kind, props: validatedProps } });
1865
+ continue;
1866
+ }
1867
+ const previousIndex = seenKeys.get(key);
1868
+ if (previousIndex !== void 0) {
1869
+ duplicateOf.push({ index, sourceIndex: previousIndex });
1870
+ continue;
1871
+ }
1872
+ seenKeys.set(key, index);
1873
+ const existing = existingByKey.get(key);
1874
+ if (existing === void 0) {
1875
+ toCreate.push({ index, input: { kind, props: validatedProps } });
1876
+ } else {
1877
+ toFetch.push({
1878
+ index,
1879
+ nodeId: existing.node_id,
1880
+ concreteKind: existing.concrete_kind,
1881
+ validatedProps
1882
+ });
1883
+ }
1884
+ }
1885
+ const results = Array.from({ length: items.length });
1886
+ if (toCreate.length > 0) {
1887
+ const createInputs = toCreate.map((entry) => entry.input);
1888
+ const createdNodes = await executeNodeCreateBatch(
1336
1889
  ctx,
1337
- { kind, props: validatedProps },
1890
+ createInputs,
1338
1891
  backend,
1339
1892
  { propsPreValidated: true }
1340
1893
  );
1341
- results[index] = { node, action: "created" };
1342
- continue;
1894
+ for (const [batchIndex, entry] of toCreate.entries()) {
1895
+ results[entry.index] = {
1896
+ node: requireDefined(createdNodes[batchIndex]),
1897
+ action: "created"
1898
+ };
1899
+ }
1343
1900
  }
1344
- if (isSoftDeleted || ifExists === "update") {
1345
- const node = await executeNodeUpsertUpdate(
1346
- ctx,
1347
- {
1348
- kind: concreteKind,
1349
- id: existingRow.id,
1350
- props: validatedProps
1351
- },
1352
- backend,
1353
- { clearDeleted: isSoftDeleted }
1901
+ for (const entry of toFetch) {
1902
+ const { index, concreteKind, validatedProps, nodeId } = entry;
1903
+ const existingRow = await backend.getNode(
1904
+ ctx.graphId,
1905
+ concreteKind,
1906
+ nodeId
1354
1907
  );
1355
- results[index] = {
1356
- node,
1357
- action: isSoftDeleted ? "resurrected" : "updated"
1358
- };
1359
- } else {
1360
- results[index] = { node: rowToNode(existingRow), action: "found" };
1908
+ if (existingRow === void 0) {
1909
+ const node = await executeNodeCreate(
1910
+ ctx,
1911
+ { kind, props: validatedProps },
1912
+ backend,
1913
+ { propsPreValidated: true }
1914
+ );
1915
+ results[index] = { node, action: "created" };
1916
+ continue;
1917
+ }
1918
+ const isSoftDeleted = existingRow.deleted_at !== void 0;
1919
+ if (isSoftDeleted || ifExists === "update") {
1920
+ const node = await executeNodeUpsertUpdate(
1921
+ ctx,
1922
+ {
1923
+ kind: concreteKind,
1924
+ id: existingRow.id,
1925
+ props: validatedProps
1926
+ },
1927
+ backend,
1928
+ { clearDeleted: isSoftDeleted }
1929
+ );
1930
+ results[index] = {
1931
+ node,
1932
+ action: isSoftDeleted ? "resurrected" : "updated"
1933
+ };
1934
+ } else {
1935
+ results[index] = { node: rowToNode(existingRow), action: "found" };
1936
+ }
1361
1937
  }
1938
+ for (const { index, sourceIndex } of duplicateOf) {
1939
+ const sourceResult = requireDefined(results[sourceIndex]);
1940
+ results[index] = { node: sourceResult.node, action: "found" };
1941
+ }
1942
+ return results;
1362
1943
  }
1363
- for (const { index, sourceIndex } of duplicateOf) {
1364
- const sourceResult = requireDefined(results[sourceIndex]);
1365
- results[index] = { node: sourceResult.node, action: "found" };
1944
+ try {
1945
+ return await attempt();
1946
+ } catch (error) {
1947
+ if (!(error instanceof UniquenessError)) throw error;
1948
+ return attempt();
1366
1949
  }
1367
- return results;
1368
1950
  }
1369
1951
 
1370
- export { checkCardinalityConstraint, createNodeBatchValidationBackend, executeNodeBulkFindByConstraint, executeNodeBulkFindByIndex, executeNodeBulkGetOrCreateByConstraint, executeNodeCreate, executeNodeCreateBatch, executeNodeCreateNoReturnBatch, executeNodeDelete, executeNodeFindByConstraint, executeNodeGetOrCreateByConstraint, executeNodeHardDelete, executeNodeUpdate, executeNodeUpsertUpdate, lockSchemaVersionForStoreWrite, nodeUpsertDirtyCheck, primeBatchValidationCaches, rowToEdge, rowToEdgeMeta, rowToNode, rowToNodeMeta, runHookedWriteOperation, runInWriteTransaction };
1371
- //# sourceMappingURL=chunk-SBPC5IP3.js.map
1372
- //# sourceMappingURL=chunk-SBPC5IP3.js.map
1952
+ export { checkCardinalityConstraint, createNodeBatchValidationBackend, edgeWriteNeedsConstraintFence, executeNodeBulkFindByConstraint, executeNodeBulkFindByIndex, executeNodeBulkGetOrCreateByConstraint, executeNodeCreate, executeNodeCreateBatch, executeNodeCreateNoReturnBatch, executeNodeDelete, executeNodeDeleteBatch, executeNodeFindByConstraint, executeNodeGetOrCreateByConstraint, executeNodeHardDelete, executeNodeUpdate, executeNodeUpdateWhere, executeNodeUpsertUpdate, nodeUpsertDirtyCheck, primeBatchValidationCaches, rowToEdge, rowToEdgeMeta, rowToNode, rowToNodeMeta, withAlreadyExistsTranslation };
1953
+ //# sourceMappingURL=chunk-QWX5YA3K.js.map
1954
+ //# sourceMappingURL=chunk-QWX5YA3K.js.map