@nicia-ai/typegraph 0.45.0 → 0.46.1

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-2Z2Z3ZD6.js +58 -0
  48. package/dist/chunk-2Z2Z3ZD6.js.map +1 -0
  49. package/dist/{chunk-VVQM4CZD.cjs → chunk-3DHZCOT7.cjs} +20 -20
  50. package/dist/{chunk-VVQM4CZD.cjs.map → chunk-3DHZCOT7.cjs.map} +1 -1
  51. package/dist/{chunk-JXUTCSXX.cjs → chunk-4UGOKMI5.cjs} +250 -158
  52. package/dist/chunk-4UGOKMI5.cjs.map +1 -0
  53. package/dist/{chunk-RFRM3Q5K.js → chunk-5262ZMTR.js} +14 -5
  54. package/dist/chunk-5262ZMTR.js.map +1 -0
  55. package/dist/{chunk-QRNYDV5Z.js → chunk-5763DULU.js} +214 -69
  56. package/dist/chunk-5763DULU.js.map +1 -0
  57. package/dist/{chunk-BGYJW37L.js → chunk-5UVRGXD3.js} +277 -7
  58. package/dist/chunk-5UVRGXD3.js.map +1 -0
  59. package/dist/{chunk-QR24DJDF.cjs → chunk-62ZP23AW.cjs} +15 -15
  60. package/dist/{chunk-QR24DJDF.cjs.map → chunk-62ZP23AW.cjs.map} +1 -1
  61. package/dist/{chunk-ZI6VQSZA.cjs → chunk-65E3XWGF.cjs} +724 -577
  62. package/dist/chunk-65E3XWGF.cjs.map +1 -0
  63. package/dist/{chunk-S4KQ5LV4.js → chunk-775A4ZMN.js} +40 -6
  64. package/dist/chunk-775A4ZMN.js.map +1 -0
  65. package/dist/{chunk-J2ICGNHO.cjs → chunk-7BQXPCGN.cjs} +830 -169
  66. package/dist/chunk-7BQXPCGN.cjs.map +1 -0
  67. package/dist/{chunk-FJMPR3OH.cjs → chunk-7EO3TCQB.cjs} +33 -7
  68. package/dist/chunk-7EO3TCQB.cjs.map +1 -0
  69. package/dist/{chunk-DXEEHSGN.js → chunk-7VQXLT5O.js} +436 -43
  70. package/dist/chunk-7VQXLT5O.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-CMWHLBVN.cjs +2082 -0
  90. package/dist/chunk-CMWHLBVN.cjs.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-DTVWX77L.cjs +3432 -0
  96. package/dist/chunk-DTVWX77L.cjs.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-GF3KXUTW.js +3393 -0
  104. package/dist/chunk-GF3KXUTW.js.map +1 -0
  105. package/dist/{chunk-VTN3C3CH.js → chunk-HFHTMECK.js} +7 -7
  106. package/dist/{chunk-VTN3C3CH.js.map → chunk-HFHTMECK.js.map} +1 -1
  107. package/dist/{chunk-FLEQ2HBK.js → chunk-I5MOXA4H.js} +20 -14
  108. package/dist/chunk-I5MOXA4H.js.map +1 -0
  109. package/dist/{chunk-4MB3AQAQ.js → chunk-J3WZ3FA2.js} +77 -3
  110. package/dist/chunk-J3WZ3FA2.js.map +1 -0
  111. package/dist/{chunk-UR7W5YQK.js → chunk-JBQQ7THH.js} +5 -3
  112. package/dist/chunk-JBQQ7THH.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-Q6EDCUXV.js → chunk-L65OU2U3.js} +556 -204
  122. package/dist/chunk-L65OU2U3.js.map +1 -0
  123. package/dist/{chunk-D54WH24V.cjs → chunk-LBJKZXDE.cjs} +115 -13
  124. package/dist/chunk-LBJKZXDE.cjs.map +1 -0
  125. package/dist/{chunk-FQ7ZPOTZ.js → chunk-LGHCOKTT.js} +637 -493
  126. package/dist/chunk-LGHCOKTT.js.map +1 -0
  127. package/dist/chunk-M3WP7RQZ.js +736 -0
  128. package/dist/chunk-M3WP7RQZ.js.map +1 -0
  129. package/dist/{chunk-4MEWSUVM.cjs → chunk-M4BDU5RX.cjs} +12 -12
  130. package/dist/chunk-M4BDU5RX.cjs.map +1 -0
  131. package/dist/chunk-MCLYU6BN.cjs +332 -0
  132. package/dist/chunk-MCLYU6BN.cjs.map +1 -0
  133. package/dist/{chunk-MIJKEVV7.js → chunk-MSY7FSX4.js} +37 -4
  134. package/dist/chunk-MSY7FSX4.js.map +1 -0
  135. package/dist/{chunk-H7VE3FL4.cjs → chunk-MUK4BU7K.cjs} +519 -125
  136. package/dist/chunk-MUK4BU7K.cjs.map +1 -0
  137. package/dist/{chunk-D56XG4EI.cjs → chunk-MXJDTH5B.cjs} +56 -45
  138. package/dist/chunk-MXJDTH5B.cjs.map +1 -0
  139. package/dist/{chunk-5EKPX6QU.js → chunk-MZLPX2R7.js} +8 -9
  140. package/dist/chunk-MZLPX2R7.js.map +1 -0
  141. package/dist/chunk-N66HCGCY.cjs +57 -0
  142. package/dist/chunk-N66HCGCY.cjs.map +1 -0
  143. package/dist/{chunk-CPEL3YIR.cjs → chunk-NFCVHQ5P.cjs} +55 -22
  144. package/dist/chunk-NFCVHQ5P.cjs.map +1 -0
  145. package/dist/{chunk-C4F7VJ5D.cjs → chunk-NI72YOJB.cjs} +84 -2
  146. package/dist/chunk-NI72YOJB.cjs.map +1 -0
  147. package/dist/{chunk-BNS75YNF.cjs → chunk-NK5Q7UNE.cjs} +10 -20
  148. package/dist/chunk-NK5Q7UNE.cjs.map +1 -0
  149. package/dist/{chunk-TKORQCG4.js → chunk-NLI2AVEF.js} +386 -862
  150. package/dist/chunk-NLI2AVEF.js.map +1 -0
  151. package/dist/{chunk-YMTXMPV6.js → chunk-NMWDXFPH.js} +4 -4
  152. package/dist/{chunk-YMTXMPV6.js.map → chunk-NMWDXFPH.js.map} +1 -1
  153. package/dist/{chunk-J7LXTUTP.cjs → chunk-PF6F5NLJ.cjs} +604 -1094
  154. package/dist/chunk-PF6F5NLJ.cjs.map +1 -0
  155. package/dist/{chunk-NAAMUYMS.cjs → chunk-PNN7RHVR.cjs} +58 -48
  156. package/dist/chunk-PNN7RHVR.cjs.map +1 -0
  157. package/dist/{chunk-YOALGKRE.cjs → chunk-PNTCATDE.cjs} +3528 -1763
  158. package/dist/chunk-PNTCATDE.cjs.map +1 -0
  159. package/dist/{chunk-6DCB664D.js → chunk-PQBQG7IM.js} +3 -3
  160. package/dist/{chunk-6DCB664D.js.map → chunk-PQBQG7IM.js.map} +1 -1
  161. package/dist/{chunk-UCQ3BFSY.cjs → chunk-PT7RIRIZ.cjs} +684 -332
  162. package/dist/chunk-PT7RIRIZ.cjs.map +1 -0
  163. package/dist/{chunk-ACSVZPK7.cjs → chunk-PWLJ77UV.cjs} +5 -3
  164. package/dist/chunk-PWLJ77UV.cjs.map +1 -0
  165. package/dist/chunk-Q3G6A4I3.cjs +755 -0
  166. package/dist/chunk-Q3G6A4I3.cjs.map +1 -0
  167. package/dist/{chunk-Z3WO6MND.cjs → chunk-RMQLSPA2.cjs} +297 -27
  168. package/dist/chunk-RMQLSPA2.cjs.map +1 -0
  169. package/dist/{chunk-SJDMVITW.cjs → chunk-RT5ZY4XA.cjs} +6 -5
  170. package/dist/chunk-RT5ZY4XA.cjs.map +1 -0
  171. package/dist/{chunk-ID4WXTKL.js → chunk-S6PW7VV5.js} +2382 -617
  172. package/dist/chunk-S6PW7VV5.js.map +1 -0
  173. package/dist/{chunk-4GUBTVPV.js → chunk-T4XNKYXB.js} +780 -126
  174. package/dist/chunk-T4XNKYXB.js.map +1 -0
  175. package/dist/{chunk-YDWLUT5V.cjs → chunk-TQR4KBY2.cjs} +323 -178
  176. package/dist/chunk-TQR4KBY2.cjs.map +1 -0
  177. package/dist/{chunk-OOA273IJ.cjs → chunk-U5SON7R2.cjs} +27 -27
  178. package/dist/{chunk-OOA273IJ.cjs.map → chunk-U5SON7R2.cjs.map} +1 -1
  179. package/dist/{chunk-IX64T5OL.cjs → chunk-U63GDNRC.cjs} +32 -26
  180. package/dist/chunk-U63GDNRC.cjs.map +1 -0
  181. package/dist/{chunk-WDBXJOU5.cjs → chunk-UDISNXDL.cjs} +56 -47
  182. package/dist/chunk-UDISNXDL.cjs.map +1 -0
  183. package/dist/{chunk-EFEOOCJ3.js → chunk-UV3SN74I.js} +5 -5
  184. package/dist/{chunk-EFEOOCJ3.js.map → chunk-UV3SN74I.js.map} +1 -1
  185. package/dist/{chunk-U5W4LKZV.cjs → chunk-VCRRKBLN.cjs} +9 -9
  186. package/dist/{chunk-U5W4LKZV.cjs.map → chunk-VCRRKBLN.cjs.map} +1 -1
  187. package/dist/{chunk-ISLPNELU.js → chunk-VGTJPTIC.js} +16 -5
  188. package/dist/chunk-VGTJPTIC.js.map +1 -0
  189. package/dist/chunk-VLT6PEWR.cjs +60 -0
  190. package/dist/chunk-VLT6PEWR.cjs.map +1 -0
  191. package/dist/chunk-VQH4VAWD.cjs +12 -0
  192. package/dist/{chunk-B3F2D3SP.cjs.map → chunk-VQH4VAWD.cjs.map} +1 -1
  193. package/dist/{chunk-SNXVDZAJ.js → chunk-W6OG3HDG.js} +5 -4
  194. package/dist/chunk-W6OG3HDG.js.map +1 -0
  195. package/dist/chunk-WDGA7IYB.js +207 -0
  196. package/dist/chunk-WDGA7IYB.js.map +1 -0
  197. package/dist/chunk-WQZLUGVR.js +2057 -0
  198. package/dist/chunk-WQZLUGVR.js.map +1 -0
  199. package/dist/{chunk-EKFUG4G7.cjs → chunk-XBYVV3MP.cjs} +60 -5
  200. package/dist/chunk-XBYVV3MP.cjs.map +1 -0
  201. package/dist/{chunk-5GAONX5G.cjs → chunk-XCAGZAKP.cjs} +7 -7
  202. package/dist/{chunk-5GAONX5G.cjs.map → chunk-XCAGZAKP.cjs.map} +1 -1
  203. package/dist/chunk-XL7SLCXS.js +309 -0
  204. package/dist/chunk-XL7SLCXS.js.map +1 -0
  205. package/dist/{chunk-SVJ5GEXW.cjs → chunk-XUO3KQFO.cjs} +2 -2
  206. package/dist/chunk-XUO3KQFO.cjs.map +1 -0
  207. package/dist/{chunk-F4NHQHEZ.cjs → chunk-YAAM3M2S.cjs} +10 -10
  208. package/dist/{chunk-F4NHQHEZ.cjs.map → chunk-YAAM3M2S.cjs.map} +1 -1
  209. package/dist/{chunk-RUQS6M7G.js → chunk-YBFHZUXX.js} +6 -6
  210. package/dist/chunk-YBFHZUXX.js.map +1 -0
  211. package/dist/{chunk-KMXWZLQX.cjs → chunk-YBQOHKHN.cjs} +99 -100
  212. package/dist/chunk-YBQOHKHN.cjs.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-A85FFRnk.d.cts → store-B0h6x7wo.d.cts} +1289 -767
  278. package/dist/{store-view-66p92IPi.d.ts → store-ClQ-MZQS.d.ts} +1289 -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 +3 -3
  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,16 +1,18 @@
1
- import { lockRecordedGraphWrite, uncapturedGraphWriteLock, advanceRevisionClock, checkCardinality, checkUniqueEdge, checkWherePredicate, computeUniqueKey, getKindsForUniquenessCheck, runInsertBatch, nodeInsertDispatch, runInsertBatchReturning, getEmbeddingFields, applyNodeInsertSideEffectsBatch, createNodeWriteContext, applyNodeSoftDelete, applyNodeHardDelete, getNodeRowsByIds, generateId, runInsertNoReturn, applyNodeUpdate, applyNodeInsertSideEffects, checkUniquenessConstraints, createUniquenessContext, checkDisjointness } from './chunk-TKORQCG4.js';
2
- import { createSqlSchema, DEFAULT_SQL_SCHEMA } from './chunk-MIJKEVV7.js';
3
- import { rowPropsToObject, runOptionallyInTransaction, createBackendOverlay, isLiveNodeRow } from './chunk-55ITBQJI.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-PVUI6KGR.js';
8
- import { sql, asCompiledRowsSql } from './chunk-6DCB664D.js';
9
- import { requireDefined } from './chunk-QMQLUA66.js';
1
+ import { getEmbeddingFields, applyNodeInsertSideEffectsBatch, createNodeWriteContext, applyNodeSoftDelete, applyNodeHardDelete, applyNodeUpdate, applyNodeInsertSideEffects, checkUniquenessConstraints, createUniquenessContext } from './chunk-M3WP7RQZ.js';
2
+ import { encodeTupleKey, runInWriteTransaction, refKey, runHookedWriteOperation, validateNodeProps } from './chunk-GF3KXUTW.js';
3
+ import { runInsertBatch, nodeInsertDispatch, runInsertBatchReturning, getNodeRowsByIds, generateId, runInsertNoReturn } from './chunk-NLI2AVEF.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, preservesImmutableLowerBound, assertWritableValidityWindow } from './chunk-XL7SLCXS.js';
9
+ import { getDialect, compileNodeIndexFieldKeys, compileIndexWhere } from './chunk-YDFDBE6D.js';
10
+ import { sql, asCompiledRowsSql } from './chunk-PQBQG7IM.js';
10
11
  import { getSearchableFields } from './chunk-PC2UBAUB.js';
11
- import { filterReservedKeys, RESERVED_NODE_KEYS, RESERVED_EDGE_KEYS, assertJsonValue } from './chunk-42PYUGLS.js';
12
- import { ConfigurationError, DatabaseOperationError, ValidationError, UniquenessError, NodeNotFoundError, KindNotFoundError, NodeConstraintNotFoundError, NodeIndexNotFoundError } from './chunk-4MB3AQAQ.js';
13
- import { resolveJsonPointer } from './chunk-G6Q5UM7U.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';
14
16
 
15
17
  // src/store/row-mappers.ts
16
18
  function nullToUndefined(value) {
@@ -60,59 +62,19 @@ function rowToEdgeMeta(row) {
60
62
  };
61
63
  }
62
64
 
63
- // src/store/operations/write-transaction.ts
64
- async function lockSchemaVersionForStoreWrite(ctx, backend) {
65
- const expectedVersion = ctx.schemaVersion;
66
- if (expectedVersion === void 0) return;
67
- if ("transaction" in backend && !backend.capabilities.transactions) {
68
- throw new ConfigurationError(
69
- "Schema-managed Store writes require a transactional backend so schema changes and entity writes can share one fence.",
70
- {
71
- code: "SCHEMA_WRITE_FENCE_UNSUPPORTED",
72
- graphId: ctx.graphId
73
- }
74
- );
75
- }
76
- const lockSchemaVersionForWrite = backend.lockSchemaVersionForWrite;
77
- if (lockSchemaVersionForWrite === void 0) {
78
- throw new ConfigurationError(
79
- "This backend cannot fence schema-managed Store writes against a concurrent schema change.",
80
- {
81
- code: "SCHEMA_WRITE_FENCE_UNSUPPORTED",
82
- graphId: ctx.graphId
83
- }
84
- );
85
- }
86
- await lockSchemaVersionForWrite({
87
- graphId: ctx.graphId,
88
- expectedVersion
89
- });
90
- }
91
- function runInWriteTransaction(ctx, backend, fn, options) {
92
- const ownsWriteLock = "transaction" in backend && backend.capabilities.transactions;
93
- return runOptionallyInTransaction(backend, async (target) => {
94
- await lockSchemaVersionForStoreWrite(ctx, target);
95
- const lock = ctx.historyEnabled || ctx.revisionTrackingEnabled ? await lockRecordedGraphWrite(target, ctx.graphId) : uncapturedGraphWriteLock();
96
- const result = await fn(target, lock);
97
- if (ctx.revisionTrackingEnabled && !ctx.historyEnabled && (options?.didWrite?.(result) ?? true)) {
98
- await advanceRevisionClock(
99
- target,
100
- ctx.revisionSchema,
101
- ctx.graphId,
102
- ownsWriteLock
103
- );
104
- }
105
- return result;
106
- });
65
+ // src/store/constraints.ts
66
+ function edgeWriteNeedsConstraintFence(cardinality) {
67
+ return cardinality === "many" ? void 0 : "edgeCardinality";
107
68
  }
108
- function runHookedWriteOperation(ctx, opContext, backend, body) {
109
- return ctx.withOperationHooks(
110
- opContext,
111
- () => 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
112
75
  );
76
+ return sharedScope ? "nodeUniquenessScope" : void 0;
113
77
  }
114
-
115
- // src/store/constraints.ts
116
78
  async function checkDisjointnessConstraint(ctx, kind, id) {
117
79
  const disjointKinds = ctx.registry.getDisjointKinds(kind);
118
80
  for (const disjointKind of disjointKinds) {
@@ -191,31 +153,98 @@ async function checkCardinalityConstraint(ctx, edgeKind, cardinality, fromKind,
191
153
  }
192
154
  }
193
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
+
194
220
  // src/store/operations/node-operations.ts
195
221
  function getNodeRegistration(graph, kind) {
222
+ if (!hasOwnKey(graph.nodes, kind)) throw new KindNotFoundError(kind, "node");
196
223
  const registration = graph.nodes[kind];
197
224
  if (registration === void 0) throw new KindNotFoundError(kind, "node");
198
225
  return registration;
199
226
  }
200
- 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
+ }
201
243
  function buildNodeCacheKey(graphId, kind, id) {
202
- return `${graphId}${CACHE_KEY_SEPARATOR}${kind}${CACHE_KEY_SEPARATOR}${id}`;
244
+ return encodeTupleKey([graphId, kind, id]);
203
245
  }
204
246
  function buildUniqueCacheKey(graphId, nodeKind, constraintName, key) {
205
- return `${graphId}${CACHE_KEY_SEPARATOR}${nodeKind}${CACHE_KEY_SEPARATOR}${constraintName}${CACHE_KEY_SEPARATOR}${key}`;
206
- }
207
- function createNodeAlreadyExistsError(kind, id) {
208
- return new ValidationError(
209
- `Node already exists: ${kind}/${id}`,
210
- {
211
- entityType: "node",
212
- kind,
213
- operation: "create",
214
- id,
215
- issues: [{ path: "id", message: "A node with this ID already exists" }]
216
- },
217
- { suggestion: `Use a different ID or update the existing node.` }
218
- );
247
+ return encodeTupleKey([graphId, nodeKind, constraintName, key]);
219
248
  }
220
249
  function buildInsertNodeParams(graphId, kind, id, props, validFrom, validTo) {
221
250
  const insertParams = {
@@ -406,21 +435,28 @@ function draftNodeCreate(ctx, input, id, options) {
406
435
  kind,
407
436
  operation: "create"
408
437
  });
438
+ const validFrom = validateOptionalCanonicalIsoDate(
439
+ input.validFrom,
440
+ "validFrom"
441
+ );
442
+ const validTo = validateOptionalCanonicalIsoDate(input.validTo, "validTo");
443
+ assertOrderedValidityWindow(`${kind} "${id}"`, validFrom, validTo);
409
444
  return {
410
445
  kind,
411
446
  id,
447
+ idProvided: input.id !== void 0,
412
448
  nodeKind,
413
449
  uniqueConstraints: registration.unique ?? [],
414
450
  validatedProps,
415
- validFrom: validateOptionalCanonicalIsoDate(input.validFrom, "validFrom"),
416
- validTo: validateOptionalCanonicalIsoDate(input.validTo, "validTo")
451
+ validFrom,
452
+ validTo
417
453
  };
418
454
  }
419
455
  async function finishNodeCreatePreparation(ctx, draft, backend) {
420
456
  const { kind, id, validatedProps, uniqueConstraints } = draft;
421
457
  const existingNode = await backend.getNode(ctx.graphId, kind, id);
422
458
  if (existingNode && !existingNode.deleted_at) {
423
- throw createNodeAlreadyExistsError(kind, id);
459
+ throw createAlreadyExistsError("node", kind, id);
424
460
  }
425
461
  const constraintContext = {
426
462
  graphId: ctx.graphId,
@@ -438,6 +474,8 @@ async function finishNodeCreatePreparation(ctx, draft, backend) {
438
474
  return {
439
475
  kind,
440
476
  id,
477
+ idProvided: draft.idProvided,
478
+ tombstone: existingNode,
441
479
  nodeKind: draft.nodeKind,
442
480
  validatedProps,
443
481
  uniqueConstraints,
@@ -471,6 +509,9 @@ async function finalizeNodeCreateBatch(ctx, preparedCreates, backend, lock) {
471
509
  backend
472
510
  );
473
511
  }
512
+ function foldReferences(preparedCreates) {
513
+ return preparedCreates.filter((prepared) => prepared.idProvided).map((prepared) => ({ kind: prepared.kind, id: prepared.id }));
514
+ }
474
515
  async function finalizeNodeCreate(ctx, prepared, backend, lock) {
475
516
  await applyNodeInsertSideEffects(
476
517
  createNodeWriteContext(ctx.graphId, ctx.registry, lock),
@@ -528,12 +569,47 @@ async function performNodeUpdate(ctx, input, backend, lock, options) {
528
569
  );
529
570
  const nodeKind = registration.type;
530
571
  const validTo = validateOptionalCanonicalIsoDate(input.validTo, "validTo");
572
+ const resurrectionInstant = options?.clearDeleted === true && existing.deleted_at !== void 0 ? nowIso() : void 0;
573
+ const preservesLiveLowerBound = resurrectionInstant === void 0 && preservesImmutableLowerBound(input.onImmutableLowerBound);
574
+ const statedValidFrom = validateOptionalCanonicalIsoDate(
575
+ input.validFrom,
576
+ "validFrom"
577
+ );
578
+ const validFrom = preservesLiveLowerBound ? void 0 : statedValidFrom;
579
+ const windowVerdict = assertWritableValidityWindow(
580
+ `${kind} "${id}"`,
581
+ validFrom,
582
+ resurrectionInstant === void 0 ? {
583
+ effectiveValidFrom: existing.valid_from,
584
+ appliesStatedValidFrom: false,
585
+ effectiveBoundIsStored: true
586
+ } : {
587
+ effectiveValidFrom: resurrectionInstant,
588
+ appliesStatedValidFrom: true,
589
+ // The instant this write is about to stamp, not a bound the row holds.
590
+ effectiveBoundIsStored: false
591
+ },
592
+ validTo
593
+ );
531
594
  const writeContext = createNodeWriteContext(ctx.graphId, ctx.registry, lock);
595
+ const effectiveValidFrom = validFrom ?? resurrectionInstant;
532
596
  const shared = {
533
597
  schema: nodeKind.schema,
534
598
  validatedProps,
535
599
  uniqueConstraints: registration.unique ?? [],
536
- ...validTo !== void 0 && { validTo }
600
+ ...effectiveValidFrom !== void 0 && { validFrom: effectiveValidFrom },
601
+ ...validTo !== void 0 && { validTo },
602
+ // The bound the verdict above READ, carried into the UPDATE's own `WHERE`
603
+ // so the row this writes is the row that was judged. The verdict hands over
604
+ // the predicate rather than a flag, so both conditions that decide it — did
605
+ // the verdict consult the effective bound, and WAS that bound the row's
606
+ // stored one — are answered where they are known. A plain
607
+ // `update({ props })` states no window, reads no bound, and stays unfenced:
608
+ // the same rule `UpdateEdgeParams`'s identity components follow, for the
609
+ // same reason. The resurrecting leg is judged against `resurrectionInstant`
610
+ // and so fences on `deleted_at IS NOT NULL` alone, converging through the
611
+ // recovery below.
612
+ ...windowVerdict.storedLowerBoundFence
537
613
  };
538
614
  if (options?.clearDeleted) {
539
615
  const row2 = await applyNodeUpdate(
@@ -551,6 +627,41 @@ async function performNodeUpdate(ctx, input, backend, lock, options) {
551
627
  );
552
628
  return rowToNode(row);
553
629
  }
630
+ var NODE_UPDATE_ATTEMPTS = 2;
631
+ async function performNodeUpdateWithResurrectionRecovery(ctx, input, target, lock, options) {
632
+ for (let attempt = 1; attempt <= NODE_UPDATE_ATTEMPTS; attempt += 1) {
633
+ try {
634
+ return await performNodeUpdate(
635
+ ctx,
636
+ input,
637
+ target,
638
+ lock,
639
+ attempt === 1 ? options : void 0
640
+ );
641
+ } catch (error) {
642
+ if (!isNodeUpdateNoRowError(error) || attempt === NODE_UPDATE_ATTEMPTS) {
643
+ throw nodeUpdateRaceError(input, error);
644
+ }
645
+ const current = await target.getNode(ctx.graphId, input.kind, input.id);
646
+ if (current === void 0 || current.deleted_at !== void 0) {
647
+ throw new NodeNotFoundError(input.kind, input.id);
648
+ }
649
+ }
650
+ }
651
+ throw new NodeNotFoundError(input.kind, input.id);
652
+ }
653
+ function nodeUpdateRaceError(input, error) {
654
+ if (!isNodeUpdateNoRowError(error)) return error;
655
+ return new DatabaseOperationError(
656
+ `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.`,
657
+ {
658
+ operation: "update",
659
+ entity: "node",
660
+ attempted: [{ kind: input.kind, id: input.id }]
661
+ },
662
+ { cause: error }
663
+ );
664
+ }
554
665
  async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
555
666
  if (backend.getNodes !== void 0) {
556
667
  const idsByKind = /* @__PURE__ */ new Map();
@@ -584,7 +695,7 @@ async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
584
695
  ctx.registry
585
696
  );
586
697
  for (const kindToCheck of kindsToCheck) {
587
- const groupKey = kindToCheck + CACHE_KEY_SEPARATOR + constraint.name;
698
+ const groupKey = encodeTupleKey([kindToCheck, constraint.name]);
588
699
  const group = groups.get(groupKey) ?? {
589
700
  nodeKind: kindToCheck,
590
701
  constraintName: constraint.name,
@@ -646,10 +757,60 @@ async function prepareBatchCreates(ctx, inputs, backend, options) {
646
757
  prepared.uniqueConstraints
647
758
  );
648
759
  }
649
- const batchInsertParams = preparedCreates.map(
650
- (prepared) => prepared.insertParams
651
- );
652
- return { preparedCreates, batchInsertParams };
760
+ return preparedCreates;
761
+ }
762
+ function partitionCreates(preparedCreates) {
763
+ const inserts = [];
764
+ const resurrections = [];
765
+ for (const prepared of preparedCreates) {
766
+ if (prepared.tombstone === void 0) {
767
+ inserts.push(prepared);
768
+ } else {
769
+ resurrections.push(prepared);
770
+ }
771
+ }
772
+ return { inserts, resurrections };
773
+ }
774
+ function isNodeUpdateNoRowError(error) {
775
+ return error instanceof DatabaseOperationError && error.details.operation === "update" && error.details.entity === "node" && error.details.reason === "no_row_returned";
776
+ }
777
+ async function resurrectPreparedNode(ctx, target, lock, prepared) {
778
+ const current = await target.getNode(ctx.graphId, prepared.kind, prepared.id);
779
+ if (current === void 0) {
780
+ throw new DatabaseOperationError(
781
+ `Node tombstone disappeared before resurrection: ${prepared.kind} ${prepared.id}`,
782
+ { operation: "update", entity: "node" }
783
+ );
784
+ }
785
+ if (current.deleted_at === void 0) {
786
+ throw createAlreadyExistsError("node", prepared.kind, prepared.id);
787
+ }
788
+ try {
789
+ return await applyNodeUpdate(
790
+ createNodeWriteContext(ctx.graphId, ctx.registry, lock),
791
+ {
792
+ existing: current,
793
+ clearDeleted: true,
794
+ schema: prepared.nodeKind.schema,
795
+ validatedProps: prepared.validatedProps,
796
+ uniqueConstraints: prepared.uniqueConstraints,
797
+ ...prepared.insertParams.validFrom === void 0 ? {} : { validFrom: prepared.insertParams.validFrom },
798
+ ...prepared.insertParams.validTo === void 0 ? {} : { validTo: prepared.insertParams.validTo }
799
+ },
800
+ target
801
+ );
802
+ } catch (error) {
803
+ if (!isNodeUpdateNoRowError(error)) throw error;
804
+ const afterFailure = await target.getNode(
805
+ ctx.graphId,
806
+ prepared.kind,
807
+ prepared.id
808
+ );
809
+ if (afterFailure !== void 0 && afterFailure.deleted_at === void 0) {
810
+ throw createAlreadyExistsError("node", prepared.kind, prepared.id);
811
+ }
812
+ throw error;
813
+ }
653
814
  }
654
815
  async function findUniqueRowAcrossKinds(backend, graphId, constraintName, key, kindsToCheck, includeDeleted) {
655
816
  for (const kindToCheck of kindsToCheck) {
@@ -708,6 +869,8 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
708
869
  opContext,
709
870
  backend,
710
871
  async (target, lock) => {
872
+ const identity = ctx.identity;
873
+ if (identity !== void 0) await identity.lock(target);
711
874
  const prepared = await validateAndPrepareNodeCreate(
712
875
  ctx,
713
876
  input,
@@ -715,18 +878,36 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
715
878
  target,
716
879
  options
717
880
  );
718
- let row;
719
- if (shouldReturnRow) {
720
- row = await target.insertNode(prepared.insertParams);
721
- } else {
881
+ const existing = prepared.tombstone;
882
+ if (existing !== void 0) {
883
+ const resurrected = await resurrectPreparedNode(
884
+ ctx,
885
+ target,
886
+ lock,
887
+ prepared
888
+ );
889
+ if (identity !== void 0) {
890
+ await identity.foldCreated(target, foldReferences([prepared]));
891
+ }
892
+ return shouldReturnRow ? rowToNode(resurrected) : void 0;
893
+ }
894
+ const row = await withAlreadyExistsTranslation("node", async () => {
895
+ if (shouldReturnRow) return target.insertNode(prepared.insertParams);
722
896
  await runInsertNoReturn(
723
897
  nodeInsertDispatch(target),
724
898
  prepared.insertParams
725
899
  );
726
- }
900
+ return;
901
+ });
727
902
  await finalizeNodeCreate(ctx, prepared, target, lock);
903
+ if (identity !== void 0) {
904
+ await identity.foldCreated(target, foldReferences([prepared]));
905
+ }
728
906
  if (row === void 0) return;
729
907
  return rowToNode(row);
908
+ },
909
+ {
910
+ fencesConstraintProbe: nodeFencesConstraintProbe(ctx, kind, "create")
730
911
  }
731
912
  );
732
913
  }
@@ -745,32 +926,92 @@ async function executeNodeCreate(ctx, input, backend, options) {
745
926
  }
746
927
  async function executeNodeCreateNoReturnBatch(ctx, inputs, backend) {
747
928
  if (inputs.length === 0) return;
748
- await runInWriteTransaction(ctx, backend, async (target, lock) => {
749
- const { preparedCreates, batchInsertParams } = await prepareBatchCreates(
750
- ctx,
751
- inputs,
752
- target
753
- );
754
- await runInsertBatch(nodeInsertDispatch(target), batchInsertParams);
755
- await finalizeNodeCreateBatch(ctx, preparedCreates, target, lock);
756
- });
929
+ await runInWriteTransaction(
930
+ ctx,
931
+ backend,
932
+ async (target, lock) => {
933
+ const identity = ctx.identity;
934
+ if (identity !== void 0) await identity.lock(target);
935
+ const preparedCreates = await prepareBatchCreates(ctx, inputs, target);
936
+ const partition = partitionCreates(preparedCreates);
937
+ await withAlreadyExistsTranslation(
938
+ "node",
939
+ () => runInsertBatch(
940
+ nodeInsertDispatch(target),
941
+ partition.inserts.map((prepared) => prepared.insertParams)
942
+ )
943
+ );
944
+ for (const prepared of partition.resurrections) {
945
+ await resurrectPreparedNode(ctx, target, lock, prepared);
946
+ }
947
+ await finalizeNodeCreateBatch(ctx, partition.inserts, target, lock);
948
+ if (identity !== void 0) {
949
+ await identity.foldCreated(target, foldReferences(preparedCreates));
950
+ }
951
+ },
952
+ {
953
+ fencesConstraintProbe: nodeBatchFencesConstraintProbe(
954
+ ctx,
955
+ inputs,
956
+ "create"
957
+ )
958
+ }
959
+ );
757
960
  }
758
961
  async function executeNodeCreateBatch(ctx, inputs, backend, options) {
759
962
  if (inputs.length === 0) return [];
760
- return runInWriteTransaction(ctx, backend, async (target, lock) => {
761
- const { preparedCreates, batchInsertParams } = await prepareBatchCreates(
762
- ctx,
763
- inputs,
764
- target,
765
- options
766
- );
767
- const rows = await runInsertBatchReturning(
768
- nodeInsertDispatch(target),
769
- batchInsertParams
770
- );
771
- await finalizeNodeCreateBatch(ctx, preparedCreates, target, lock);
772
- return rows.map((row) => rowToNode(row));
773
- });
963
+ return runInWriteTransaction(
964
+ ctx,
965
+ backend,
966
+ async (target, lock) => {
967
+ const identity = ctx.identity;
968
+ if (identity !== void 0) await identity.lock(target);
969
+ const preparedCreates = await prepareBatchCreates(
970
+ ctx,
971
+ inputs,
972
+ target,
973
+ options
974
+ );
975
+ const partition = partitionCreates(preparedCreates);
976
+ const inserted = await withAlreadyExistsTranslation(
977
+ "node",
978
+ () => runInsertBatchReturning(
979
+ nodeInsertDispatch(target),
980
+ partition.inserts.map((prepared) => prepared.insertParams)
981
+ )
982
+ );
983
+ const resurrected = [];
984
+ for (const prepared of partition.resurrections) {
985
+ resurrected.push(
986
+ await resurrectPreparedNode(ctx, target, lock, prepared)
987
+ );
988
+ }
989
+ await finalizeNodeCreateBatch(ctx, partition.inserts, target, lock);
990
+ const byReference = new Map(
991
+ [...inserted, ...resurrected].map((row) => [
992
+ refKey({ kind: row.kind, id: row.id }),
993
+ row
994
+ ])
995
+ );
996
+ const rows = preparedCreates.map(
997
+ (prepared) => requireDefined(
998
+ byReference.get(refKey({ kind: prepared.kind, id: prepared.id })),
999
+ `Missing written row for ${prepared.kind} ${prepared.id}`
1000
+ )
1001
+ );
1002
+ if (identity !== void 0) {
1003
+ await identity.foldCreated(target, foldReferences(preparedCreates));
1004
+ }
1005
+ return rows.map((row) => rowToNode(row));
1006
+ },
1007
+ {
1008
+ fencesConstraintProbe: nodeBatchFencesConstraintProbe(
1009
+ ctx,
1010
+ inputs,
1011
+ "create"
1012
+ )
1013
+ }
1014
+ );
774
1015
  }
775
1016
  async function executeNodeUpdate(ctx, input, backend, options) {
776
1017
  const opContext = ctx.createOperationContext(
@@ -783,7 +1024,32 @@ async function executeNodeUpdate(ctx, input, backend, options) {
783
1024
  ctx,
784
1025
  opContext,
785
1026
  backend,
786
- (target, lock) => performNodeUpdate(ctx, input, target, lock, options)
1027
+ async (target, lock) => {
1028
+ const identity = ctx.identity;
1029
+ if (options?.clearDeleted && identity !== void 0) {
1030
+ await identity.lock(target);
1031
+ }
1032
+ const node = await performNodeUpdateWithResurrectionRecovery(
1033
+ ctx,
1034
+ input,
1035
+ target,
1036
+ lock,
1037
+ options
1038
+ );
1039
+ if (options?.clearDeleted && identity !== void 0) {
1040
+ await identity.foldCreated(target, [
1041
+ { kind: input.kind, id: input.id }
1042
+ ]);
1043
+ }
1044
+ return node;
1045
+ },
1046
+ {
1047
+ fencesConstraintProbe: nodeFencesConstraintProbe(
1048
+ ctx,
1049
+ input.kind,
1050
+ "update"
1051
+ )
1052
+ }
787
1053
  );
788
1054
  }
789
1055
  async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candidateIdColumn, backend) {
@@ -833,7 +1099,7 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
833
1099
  kind,
834
1100
  operation: "update"
835
1101
  });
836
- const patch = {};
1102
+ const patch = createDataKeyedBag();
837
1103
  const unsetProperties = [];
838
1104
  for (const [property, value] of Object.entries(parsedPatch)) {
839
1105
  if (value === void 0) {
@@ -1013,7 +1279,13 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
1013
1279
  );
1014
1280
  return { affectedCount: result.affectedCount };
1015
1281
  },
1016
- { didWrite: (result) => result.affectedCount > 0 }
1282
+ {
1283
+ didWrite: (result) => result.affectedCount > 0,
1284
+ // The set update re-checks every changed unique key across the
1285
+ // constraint's scope before rebuilding the sidecars, so a shared-scope
1286
+ // constraint makes it a constrained write like any other update.
1287
+ fencesConstraintProbe: nodeFencesConstraintProbe(ctx, kind, "update")
1288
+ }
1017
1289
  )
1018
1290
  );
1019
1291
  }
@@ -1021,7 +1293,32 @@ async function executeNodeUpsertUpdate(ctx, input, backend, options) {
1021
1293
  return runInWriteTransaction(
1022
1294
  ctx,
1023
1295
  backend,
1024
- (target, lock) => performNodeUpdate(ctx, input, target, lock, options)
1296
+ async (target, lock) => {
1297
+ const identity = ctx.identity;
1298
+ if (options?.clearDeleted && identity !== void 0) {
1299
+ await identity.lock(target);
1300
+ }
1301
+ const node = await performNodeUpdateWithResurrectionRecovery(
1302
+ ctx,
1303
+ input,
1304
+ target,
1305
+ lock,
1306
+ options
1307
+ );
1308
+ if (options?.clearDeleted && identity !== void 0) {
1309
+ await identity.foldCreated(target, [
1310
+ { kind: input.kind, id: input.id }
1311
+ ]);
1312
+ }
1313
+ return node;
1314
+ },
1315
+ {
1316
+ fencesConstraintProbe: nodeFencesConstraintProbe(
1317
+ ctx,
1318
+ input.kind,
1319
+ "update"
1320
+ )
1321
+ }
1025
1322
  );
1026
1323
  }
1027
1324
  async function executeNodeDelete(ctx, kind, id, backend) {
@@ -1033,6 +1330,8 @@ async function executeNodeDelete(ctx, kind, id, backend) {
1033
1330
  opContext,
1034
1331
  backend,
1035
1332
  async (target, lock) => {
1333
+ const identity = ctx.identity;
1334
+ if (identity !== void 0) await identity.lock(target);
1036
1335
  const registration = getNodeRegistration(ctx.graph, kind);
1037
1336
  const preflight = await target.getNode(ctx.graphId, kind, id);
1038
1337
  if (!preflight || !isLiveNodeRow(preflight)) return;
@@ -1046,9 +1345,49 @@ async function executeNodeDelete(ctx, kind, id, backend) {
1046
1345
  },
1047
1346
  target
1048
1347
  );
1348
+ if (identity !== void 0) {
1349
+ await identity.detachDeleted(target, { kind, id }, "soft");
1350
+ }
1049
1351
  }
1050
1352
  );
1051
1353
  }
1354
+ async function executeNodeDeleteBatch(ctx, kind, ids, backend) {
1355
+ await runInWriteTransaction(
1356
+ ctx,
1357
+ backend,
1358
+ async (target, lock) => {
1359
+ const identity = ctx.identity;
1360
+ if (identity !== void 0) await identity.lock(target);
1361
+ const registration = getNodeRegistration(ctx.graph, kind);
1362
+ const writeContext = createNodeWriteContext(
1363
+ ctx.graphId,
1364
+ ctx.registry,
1365
+ lock
1366
+ );
1367
+ let affectedCount = 0;
1368
+ for (const id of ids) {
1369
+ const preflight = await target.getNode(ctx.graphId, kind, id);
1370
+ if (!preflight || !isLiveNodeRow(preflight)) continue;
1371
+ await applyNodeSoftDelete(
1372
+ writeContext,
1373
+ {
1374
+ existing: preflight,
1375
+ schema: registration.type.schema,
1376
+ uniqueConstraints: registration.unique ?? [],
1377
+ onDelete: registration.onDelete
1378
+ },
1379
+ target
1380
+ );
1381
+ if (identity !== void 0) {
1382
+ await identity.detachDeleted(target, { kind, id }, "soft");
1383
+ }
1384
+ affectedCount += 1;
1385
+ }
1386
+ return affectedCount;
1387
+ },
1388
+ { didWrite: (affectedCount) => affectedCount > 0 }
1389
+ );
1390
+ }
1052
1391
  async function executeNodeHardDelete(ctx, kind, id, backend) {
1053
1392
  const gate = await backend.getNode(ctx.graphId, kind, id);
1054
1393
  if (!gate) return;
@@ -1058,6 +1397,8 @@ async function executeNodeHardDelete(ctx, kind, id, backend) {
1058
1397
  opContext,
1059
1398
  backend,
1060
1399
  async (target, lock) => {
1400
+ const identity = ctx.identity;
1401
+ if (identity !== void 0) await identity.lock(target);
1061
1402
  const registration = getNodeRegistration(ctx.graph, kind);
1062
1403
  await applyNodeHardDelete(
1063
1404
  createNodeWriteContext(ctx.graphId, ctx.registry, lock),
@@ -1069,6 +1410,9 @@ async function executeNodeHardDelete(ctx, kind, id, backend) {
1069
1410
  },
1070
1411
  target
1071
1412
  );
1413
+ if (identity !== void 0) {
1414
+ await identity.detachDeleted(target, { kind, id }, "hard");
1415
+ }
1072
1416
  }
1073
1417
  );
1074
1418
  }
@@ -1504,101 +1848,109 @@ async function executeNodeBulkGetOrCreateByConstraint(ctx, kind, constraintName,
1504
1848
  constraint.scope,
1505
1849
  ctx.registry
1506
1850
  );
1507
- const existingByKey = uniqueKeys.length > 0 ? await batchCheckUniqueAcrossKinds(
1508
- backend,
1509
- ctx.graphId,
1510
- constraint.name,
1511
- uniqueKeys,
1512
- kindsToCheck,
1513
- true
1514
- ) : /* @__PURE__ */ new Map();
1515
- const toCreate = [];
1516
- const toFetch = [];
1517
- const duplicateOf = [];
1518
- const seenKeys = /* @__PURE__ */ new Map();
1519
- for (const [index, { validatedProps, key }] of validated.entries()) {
1520
- if (key === void 0) {
1521
- toCreate.push({ index, input: { kind, props: validatedProps } });
1522
- continue;
1523
- }
1524
- const previousIndex = seenKeys.get(key);
1525
- if (previousIndex !== void 0) {
1526
- duplicateOf.push({ index, sourceIndex: previousIndex });
1527
- continue;
1528
- }
1529
- seenKeys.set(key, index);
1530
- const existing = existingByKey.get(key);
1531
- if (existing === void 0) {
1532
- toCreate.push({ index, input: { kind, props: validatedProps } });
1533
- } else {
1534
- toFetch.push({
1535
- index,
1536
- nodeId: existing.node_id,
1537
- concreteKind: existing.concrete_kind,
1538
- validatedProps,
1539
- isSoftDeleted: existing.deleted_at !== void 0
1540
- });
1541
- }
1542
- }
1543
- const results = Array.from({ length: items.length });
1544
- if (toCreate.length > 0) {
1545
- const createInputs = toCreate.map((entry) => entry.input);
1546
- const createdNodes = await executeNodeCreateBatch(
1547
- ctx,
1548
- createInputs,
1851
+ async function attempt() {
1852
+ const existingByKey = uniqueKeys.length > 0 ? await batchCheckUniqueAcrossKinds(
1549
1853
  backend,
1550
- { propsPreValidated: true }
1551
- );
1552
- for (const [batchIndex, entry] of toCreate.entries()) {
1553
- results[entry.index] = {
1554
- node: requireDefined(createdNodes[batchIndex]),
1555
- action: "created"
1556
- };
1557
- }
1558
- }
1559
- for (const entry of toFetch) {
1560
- const { index, concreteKind, validatedProps, isSoftDeleted, nodeId } = entry;
1561
- const existingRow = await backend.getNode(
1562
1854
  ctx.graphId,
1563
- concreteKind,
1564
- nodeId
1565
- );
1566
- if (existingRow === void 0) {
1567
- const node = await executeNodeCreate(
1855
+ constraint.name,
1856
+ uniqueKeys,
1857
+ kindsToCheck,
1858
+ true
1859
+ ) : /* @__PURE__ */ new Map();
1860
+ const toCreate = [];
1861
+ const toFetch = [];
1862
+ const duplicateOf = [];
1863
+ const seenKeys = /* @__PURE__ */ new Map();
1864
+ for (const [index, { validatedProps, key }] of validated.entries()) {
1865
+ if (key === void 0) {
1866
+ toCreate.push({ index, input: { kind, props: validatedProps } });
1867
+ continue;
1868
+ }
1869
+ const previousIndex = seenKeys.get(key);
1870
+ if (previousIndex !== void 0) {
1871
+ duplicateOf.push({ index, sourceIndex: previousIndex });
1872
+ continue;
1873
+ }
1874
+ seenKeys.set(key, index);
1875
+ const existing = existingByKey.get(key);
1876
+ if (existing === void 0) {
1877
+ toCreate.push({ index, input: { kind, props: validatedProps } });
1878
+ } else {
1879
+ toFetch.push({
1880
+ index,
1881
+ nodeId: existing.node_id,
1882
+ concreteKind: existing.concrete_kind,
1883
+ validatedProps
1884
+ });
1885
+ }
1886
+ }
1887
+ const results = Array.from({ length: items.length });
1888
+ if (toCreate.length > 0) {
1889
+ const createInputs = toCreate.map((entry) => entry.input);
1890
+ const createdNodes = await executeNodeCreateBatch(
1568
1891
  ctx,
1569
- { kind, props: validatedProps },
1892
+ createInputs,
1570
1893
  backend,
1571
1894
  { propsPreValidated: true }
1572
1895
  );
1573
- results[index] = { node, action: "created" };
1574
- continue;
1896
+ for (const [batchIndex, entry] of toCreate.entries()) {
1897
+ results[entry.index] = {
1898
+ node: requireDefined(createdNodes[batchIndex]),
1899
+ action: "created"
1900
+ };
1901
+ }
1575
1902
  }
1576
- if (isSoftDeleted || ifExists === "update") {
1577
- const node = await executeNodeUpsertUpdate(
1578
- ctx,
1579
- {
1580
- kind: concreteKind,
1581
- id: existingRow.id,
1582
- props: validatedProps
1583
- },
1584
- backend,
1585
- { clearDeleted: isSoftDeleted }
1903
+ for (const entry of toFetch) {
1904
+ const { index, concreteKind, validatedProps, nodeId } = entry;
1905
+ const existingRow = await backend.getNode(
1906
+ ctx.graphId,
1907
+ concreteKind,
1908
+ nodeId
1586
1909
  );
1587
- results[index] = {
1588
- node,
1589
- action: isSoftDeleted ? "resurrected" : "updated"
1590
- };
1591
- } else {
1592
- results[index] = { node: rowToNode(existingRow), action: "found" };
1910
+ if (existingRow === void 0) {
1911
+ const node = await executeNodeCreate(
1912
+ ctx,
1913
+ { kind, props: validatedProps },
1914
+ backend,
1915
+ { propsPreValidated: true }
1916
+ );
1917
+ results[index] = { node, action: "created" };
1918
+ continue;
1919
+ }
1920
+ const isSoftDeleted = existingRow.deleted_at !== void 0;
1921
+ if (isSoftDeleted || ifExists === "update") {
1922
+ const node = await executeNodeUpsertUpdate(
1923
+ ctx,
1924
+ {
1925
+ kind: concreteKind,
1926
+ id: existingRow.id,
1927
+ props: validatedProps
1928
+ },
1929
+ backend,
1930
+ { clearDeleted: isSoftDeleted }
1931
+ );
1932
+ results[index] = {
1933
+ node,
1934
+ action: isSoftDeleted ? "resurrected" : "updated"
1935
+ };
1936
+ } else {
1937
+ results[index] = { node: rowToNode(existingRow), action: "found" };
1938
+ }
1939
+ }
1940
+ for (const { index, sourceIndex } of duplicateOf) {
1941
+ const sourceResult = requireDefined(results[sourceIndex]);
1942
+ results[index] = { node: sourceResult.node, action: "found" };
1593
1943
  }
1944
+ return results;
1594
1945
  }
1595
- for (const { index, sourceIndex } of duplicateOf) {
1596
- const sourceResult = requireDefined(results[sourceIndex]);
1597
- results[index] = { node: sourceResult.node, action: "found" };
1946
+ try {
1947
+ return await attempt();
1948
+ } catch (error) {
1949
+ if (!(error instanceof UniquenessError)) throw error;
1950
+ return attempt();
1598
1951
  }
1599
- return results;
1600
1952
  }
1601
1953
 
1602
- export { checkCardinalityConstraint, createNodeBatchValidationBackend, executeNodeBulkFindByConstraint, executeNodeBulkFindByIndex, executeNodeBulkGetOrCreateByConstraint, executeNodeCreate, executeNodeCreateBatch, executeNodeCreateNoReturnBatch, executeNodeDelete, executeNodeFindByConstraint, executeNodeGetOrCreateByConstraint, executeNodeHardDelete, executeNodeUpdate, executeNodeUpdateWhere, executeNodeUpsertUpdate, lockSchemaVersionForStoreWrite, nodeUpsertDirtyCheck, primeBatchValidationCaches, rowToEdge, rowToEdgeMeta, rowToNode, rowToNodeMeta, runHookedWriteOperation, runInWriteTransaction };
1603
- //# sourceMappingURL=chunk-Q6EDCUXV.js.map
1604
- //# sourceMappingURL=chunk-Q6EDCUXV.js.map
1954
+ 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 };
1955
+ //# sourceMappingURL=chunk-L65OU2U3.js.map
1956
+ //# sourceMappingURL=chunk-L65OU2U3.js.map