@nicia-ai/typegraph 0.45.0 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (384) hide show
  1. package/dist/backend/drizzle/indexes.cjs +11 -11
  2. package/dist/backend/drizzle/indexes.d.cts +1 -1
  3. package/dist/backend/drizzle/indexes.d.ts +1 -1
  4. package/dist/backend/drizzle/indexes.js +7 -7
  5. package/dist/backend/index.cjs +53 -54
  6. package/dist/backend/index.d.cts +3 -3
  7. package/dist/backend/index.d.ts +3 -3
  8. package/dist/backend/index.js +13 -14
  9. package/dist/backend/postgres/index.cjs +29 -30
  10. package/dist/backend/postgres/index.d.cts +7 -7
  11. package/dist/backend/postgres/index.d.ts +7 -7
  12. package/dist/backend/postgres/index.js +16 -17
  13. package/dist/backend/postgres/pglite-store.cjs +48 -42
  14. package/dist/backend/postgres/pglite-store.cjs.map +1 -1
  15. package/dist/backend/postgres/pglite-store.d.cts +15 -9
  16. package/dist/backend/postgres/pglite-store.d.ts +15 -9
  17. package/dist/backend/postgres/pglite-store.js +44 -38
  18. package/dist/backend/postgres/pglite-store.js.map +1 -1
  19. package/dist/backend/postgres/pglite.cjs +18 -19
  20. package/dist/backend/postgres/pglite.d.cts +4 -4
  21. package/dist/backend/postgres/pglite.d.ts +4 -4
  22. package/dist/backend/postgres/pglite.js +17 -18
  23. package/dist/backend/sqlite/index.cjs +26 -27
  24. package/dist/backend/sqlite/index.d.cts +6 -6
  25. package/dist/backend/sqlite/index.d.ts +6 -6
  26. package/dist/backend/sqlite/index.js +14 -15
  27. package/dist/backend/sqlite/libsql.cjs +21 -22
  28. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  29. package/dist/backend/sqlite/libsql.d.cts +15 -8
  30. package/dist/backend/sqlite/libsql.d.ts +15 -8
  31. package/dist/backend/sqlite/libsql.js +17 -18
  32. package/dist/backend/sqlite/libsql.js.map +1 -1
  33. package/dist/backend/sqlite/local-store.cjs +49 -43
  34. package/dist/backend/sqlite/local-store.cjs.map +1 -1
  35. package/dist/backend/sqlite/local-store.d.cts +15 -10
  36. package/dist/backend/sqlite/local-store.d.ts +15 -10
  37. package/dist/backend/sqlite/local-store.js +45 -39
  38. package/dist/backend/sqlite/local-store.js.map +1 -1
  39. package/dist/backend/sqlite/local.cjs +19 -20
  40. package/dist/backend/sqlite/local.d.cts +3 -3
  41. package/dist/backend/sqlite/local.d.ts +3 -3
  42. package/dist/backend/sqlite/local.js +17 -18
  43. package/dist/{chunk-S3ZRKJHY.js → chunk-2LG2XB2M.js} +3 -3
  44. package/dist/{chunk-S3ZRKJHY.js.map → chunk-2LG2XB2M.js.map} +1 -1
  45. package/dist/{chunk-7PF2L3H6.cjs → chunk-2NA5DYLO.cjs} +4 -4
  46. package/dist/{chunk-7PF2L3H6.cjs.map → chunk-2NA5DYLO.cjs.map} +1 -1
  47. package/dist/{chunk-VVQM4CZD.cjs → chunk-3DHZCOT7.cjs} +20 -20
  48. package/dist/{chunk-VVQM4CZD.cjs.map → chunk-3DHZCOT7.cjs.map} +1 -1
  49. package/dist/{chunk-JXUTCSXX.cjs → chunk-4UGOKMI5.cjs} +250 -158
  50. package/dist/chunk-4UGOKMI5.cjs.map +1 -0
  51. package/dist/{chunk-RFRM3Q5K.js → chunk-5262ZMTR.js} +14 -5
  52. package/dist/chunk-5262ZMTR.js.map +1 -0
  53. package/dist/{chunk-QRNYDV5Z.js → chunk-5763DULU.js} +214 -69
  54. package/dist/chunk-5763DULU.js.map +1 -0
  55. package/dist/{chunk-BGYJW37L.js → chunk-5UVRGXD3.js} +277 -7
  56. package/dist/chunk-5UVRGXD3.js.map +1 -0
  57. package/dist/{chunk-QR24DJDF.cjs → chunk-62ZP23AW.cjs} +15 -15
  58. package/dist/{chunk-QR24DJDF.cjs.map → chunk-62ZP23AW.cjs.map} +1 -1
  59. package/dist/{chunk-S4KQ5LV4.js → chunk-775A4ZMN.js} +40 -6
  60. package/dist/chunk-775A4ZMN.js.map +1 -0
  61. package/dist/{chunk-J2ICGNHO.cjs → chunk-7BQXPCGN.cjs} +830 -169
  62. package/dist/chunk-7BQXPCGN.cjs.map +1 -0
  63. package/dist/{chunk-FJMPR3OH.cjs → chunk-7EO3TCQB.cjs} +33 -7
  64. package/dist/chunk-7EO3TCQB.cjs.map +1 -0
  65. package/dist/{chunk-UCQ3BFSY.cjs → chunk-7GT72YHH.cjs} +682 -332
  66. package/dist/chunk-7GT72YHH.cjs.map +1 -0
  67. package/dist/{chunk-DXEEHSGN.js → chunk-7VQXLT5O.js} +436 -43
  68. package/dist/chunk-7VQXLT5O.js.map +1 -0
  69. package/dist/{chunk-ID4WXTKL.js → chunk-7Z5OR7KO.js} +2360 -605
  70. package/dist/chunk-7Z5OR7KO.js.map +1 -0
  71. package/dist/chunk-A4OC4DVN.cjs +12 -0
  72. package/dist/{chunk-4SZ6XPTG.cjs.map → chunk-A4OC4DVN.cjs.map} +1 -1
  73. package/dist/{chunk-TDXIBCGY.cjs → chunk-A7J2YDDI.cjs} +5 -3
  74. package/dist/chunk-A7J2YDDI.cjs.map +1 -0
  75. package/dist/{chunk-55ITBQJI.js → chunk-AKLS3BYZ.js} +56 -5
  76. package/dist/chunk-AKLS3BYZ.js.map +1 -0
  77. package/dist/{chunk-D7PG5D5K.js → chunk-AMKPPFUO.js} +32 -6
  78. package/dist/chunk-AMKPPFUO.js.map +1 -0
  79. package/dist/{chunk-WUFASQUO.js → chunk-ASTI57H3.js} +3 -3
  80. package/dist/{chunk-WUFASQUO.js.map → chunk-ASTI57H3.js.map} +1 -1
  81. package/dist/{chunk-4QIKLIGG.js → chunk-BKCUOV7A.js} +15 -5
  82. package/dist/chunk-BKCUOV7A.js.map +1 -0
  83. package/dist/{chunk-JQXSZHF2.cjs → chunk-BSFJMMV3.cjs} +134 -7
  84. package/dist/chunk-BSFJMMV3.cjs.map +1 -0
  85. package/dist/{chunk-4GUTQPVO.js → chunk-C23WSN5E.js} +185 -24
  86. package/dist/chunk-C23WSN5E.js.map +1 -0
  87. package/dist/{chunk-QLUXRWKL.js → chunk-CBTIUB76.js} +3 -3
  88. package/dist/{chunk-QLUXRWKL.js.map → chunk-CBTIUB76.js.map} +1 -1
  89. package/dist/chunk-CNV4TXJG.js +58 -0
  90. package/dist/chunk-CNV4TXJG.js.map +1 -0
  91. package/dist/{chunk-QB6VMOJ2.cjs → chunk-CXBHOOIQ.cjs} +45 -10
  92. package/dist/chunk-CXBHOOIQ.cjs.map +1 -0
  93. package/dist/{chunk-FL5UQRES.js → chunk-DCQVHAYQ.js} +5 -5
  94. package/dist/{chunk-FL5UQRES.js.map → chunk-DCQVHAYQ.js.map} +1 -1
  95. package/dist/chunk-DLNROMQ7.js +306 -0
  96. package/dist/chunk-DLNROMQ7.js.map +1 -0
  97. package/dist/chunk-DYATYRY4.js +47 -0
  98. package/dist/chunk-DYATYRY4.js.map +1 -0
  99. package/dist/chunk-E4WNQBEF.cjs +217 -0
  100. package/dist/chunk-E4WNQBEF.cjs.map +1 -0
  101. package/dist/{chunk-G6Q5UM7U.js → chunk-FWJKWH6U.js} +5 -3
  102. package/dist/chunk-FWJKWH6U.js.map +1 -0
  103. package/dist/{chunk-VTN3C3CH.js → chunk-HFHTMECK.js} +7 -7
  104. package/dist/{chunk-VTN3C3CH.js.map → chunk-HFHTMECK.js.map} +1 -1
  105. package/dist/{chunk-FLEQ2HBK.js → chunk-I5MOXA4H.js} +20 -14
  106. package/dist/chunk-I5MOXA4H.js.map +1 -0
  107. package/dist/{chunk-4MB3AQAQ.js → chunk-J3WZ3FA2.js} +77 -3
  108. package/dist/chunk-J3WZ3FA2.js.map +1 -0
  109. package/dist/{chunk-UR7W5YQK.js → chunk-JBQQ7THH.js} +5 -3
  110. package/dist/chunk-JBQQ7THH.js.map +1 -0
  111. package/dist/chunk-JIVMTW7W.js +3393 -0
  112. package/dist/chunk-JIVMTW7W.js.map +1 -0
  113. package/dist/{chunk-TKP5T34P.js → chunk-JXA2ZP2Q.js} +6 -16
  114. package/dist/chunk-JXA2ZP2Q.js.map +1 -0
  115. package/dist/{chunk-GYA4JRP5.js → chunk-JXXDZTMN.js} +2 -2
  116. package/dist/chunk-JXXDZTMN.js.map +1 -0
  117. package/dist/chunk-JZUR7ZWE.js +254 -0
  118. package/dist/chunk-JZUR7ZWE.js.map +1 -0
  119. package/dist/{chunk-42PYUGLS.js → chunk-K5ELX2GT.js} +108 -8
  120. package/dist/chunk-K5ELX2GT.js.map +1 -0
  121. package/dist/{chunk-D54WH24V.cjs → chunk-LBJKZXDE.cjs} +115 -13
  122. package/dist/chunk-LBJKZXDE.cjs.map +1 -0
  123. package/dist/{chunk-4MEWSUVM.cjs → chunk-M4BDU5RX.cjs} +12 -12
  124. package/dist/chunk-M4BDU5RX.cjs.map +1 -0
  125. package/dist/{chunk-MIJKEVV7.js → chunk-MSY7FSX4.js} +37 -4
  126. package/dist/chunk-MSY7FSX4.js.map +1 -0
  127. package/dist/{chunk-H7VE3FL4.cjs → chunk-MUK4BU7K.cjs} +519 -125
  128. package/dist/chunk-MUK4BU7K.cjs.map +1 -0
  129. package/dist/{chunk-D56XG4EI.cjs → chunk-MXJDTH5B.cjs} +56 -45
  130. package/dist/chunk-MXJDTH5B.cjs.map +1 -0
  131. package/dist/{chunk-ZI6VQSZA.cjs → chunk-N3257XE6.cjs} +724 -577
  132. package/dist/chunk-N3257XE6.cjs.map +1 -0
  133. package/dist/chunk-N66HCGCY.cjs +57 -0
  134. package/dist/chunk-N66HCGCY.cjs.map +1 -0
  135. package/dist/{chunk-CPEL3YIR.cjs → chunk-NFCVHQ5P.cjs} +55 -22
  136. package/dist/chunk-NFCVHQ5P.cjs.map +1 -0
  137. package/dist/{chunk-C4F7VJ5D.cjs → chunk-NI72YOJB.cjs} +84 -2
  138. package/dist/chunk-NI72YOJB.cjs.map +1 -0
  139. package/dist/{chunk-BNS75YNF.cjs → chunk-NK5Q7UNE.cjs} +10 -20
  140. package/dist/chunk-NK5Q7UNE.cjs.map +1 -0
  141. package/dist/{chunk-YMTXMPV6.js → chunk-NMWDXFPH.js} +4 -4
  142. package/dist/{chunk-YMTXMPV6.js.map → chunk-NMWDXFPH.js.map} +1 -1
  143. package/dist/{chunk-TKORQCG4.js → chunk-NQ6BRJBE.js} +386 -862
  144. package/dist/chunk-NQ6BRJBE.js.map +1 -0
  145. package/dist/chunk-OH5E5KIO.js +2057 -0
  146. package/dist/chunk-OH5E5KIO.js.map +1 -0
  147. package/dist/chunk-ONU3HIED.cjs +2082 -0
  148. package/dist/chunk-ONU3HIED.cjs.map +1 -0
  149. package/dist/{chunk-NAAMUYMS.cjs → chunk-PNN7RHVR.cjs} +58 -48
  150. package/dist/chunk-PNN7RHVR.cjs.map +1 -0
  151. package/dist/{chunk-6DCB664D.js → chunk-PQBQG7IM.js} +3 -3
  152. package/dist/{chunk-6DCB664D.js.map → chunk-PQBQG7IM.js.map} +1 -1
  153. package/dist/{chunk-ACSVZPK7.cjs → chunk-PWLJ77UV.cjs} +5 -3
  154. package/dist/chunk-PWLJ77UV.cjs.map +1 -0
  155. package/dist/chunk-Q7Q4WSLJ.cjs +328 -0
  156. package/dist/chunk-Q7Q4WSLJ.cjs.map +1 -0
  157. package/dist/{chunk-FQ7ZPOTZ.js → chunk-QLRESYPU.js} +637 -493
  158. package/dist/chunk-QLRESYPU.js.map +1 -0
  159. package/dist/{chunk-Q6EDCUXV.js → chunk-QWX5YA3K.js} +554 -204
  160. package/dist/chunk-QWX5YA3K.js.map +1 -0
  161. package/dist/{chunk-5EKPX6QU.js → chunk-RJS7DECT.js} +8 -9
  162. package/dist/chunk-RJS7DECT.js.map +1 -0
  163. package/dist/{chunk-Z3WO6MND.cjs → chunk-RMQLSPA2.cjs} +297 -27
  164. package/dist/chunk-RMQLSPA2.cjs.map +1 -0
  165. package/dist/{chunk-SJDMVITW.cjs → chunk-RT5ZY4XA.cjs} +6 -5
  166. package/dist/chunk-RT5ZY4XA.cjs.map +1 -0
  167. package/dist/{chunk-4GUBTVPV.js → chunk-T4XNKYXB.js} +780 -126
  168. package/dist/chunk-T4XNKYXB.js.map +1 -0
  169. package/dist/{chunk-YDWLUT5V.cjs → chunk-TQR4KBY2.cjs} +323 -178
  170. package/dist/chunk-TQR4KBY2.cjs.map +1 -0
  171. package/dist/chunk-TTAITEPJ.cjs +755 -0
  172. package/dist/chunk-TTAITEPJ.cjs.map +1 -0
  173. package/dist/{chunk-OOA273IJ.cjs → chunk-U5SON7R2.cjs} +27 -27
  174. package/dist/{chunk-OOA273IJ.cjs.map → chunk-U5SON7R2.cjs.map} +1 -1
  175. package/dist/{chunk-IX64T5OL.cjs → chunk-U63GDNRC.cjs} +32 -26
  176. package/dist/chunk-U63GDNRC.cjs.map +1 -0
  177. package/dist/{chunk-WDBXJOU5.cjs → chunk-UDISNXDL.cjs} +56 -47
  178. package/dist/chunk-UDISNXDL.cjs.map +1 -0
  179. package/dist/{chunk-EFEOOCJ3.js → chunk-UV3SN74I.js} +5 -5
  180. package/dist/{chunk-EFEOOCJ3.js.map → chunk-UV3SN74I.js.map} +1 -1
  181. package/dist/{chunk-U5W4LKZV.cjs → chunk-VCRRKBLN.cjs} +9 -9
  182. package/dist/{chunk-U5W4LKZV.cjs.map → chunk-VCRRKBLN.cjs.map} +1 -1
  183. package/dist/{chunk-ISLPNELU.js → chunk-VGTJPTIC.js} +16 -5
  184. package/dist/chunk-VGTJPTIC.js.map +1 -0
  185. package/dist/chunk-VQH4VAWD.cjs +12 -0
  186. package/dist/{chunk-B3F2D3SP.cjs.map → chunk-VQH4VAWD.cjs.map} +1 -1
  187. package/dist/{chunk-SNXVDZAJ.js → chunk-W6OG3HDG.js} +5 -4
  188. package/dist/chunk-W6OG3HDG.js.map +1 -0
  189. package/dist/chunk-WDGA7IYB.js +207 -0
  190. package/dist/chunk-WDGA7IYB.js.map +1 -0
  191. package/dist/chunk-WEVQJ5LH.js +736 -0
  192. package/dist/chunk-WEVQJ5LH.js.map +1 -0
  193. package/dist/{chunk-EKFUG4G7.cjs → chunk-XBYVV3MP.cjs} +60 -5
  194. package/dist/chunk-XBYVV3MP.cjs.map +1 -0
  195. package/dist/{chunk-5GAONX5G.cjs → chunk-XCAGZAKP.cjs} +7 -7
  196. package/dist/{chunk-5GAONX5G.cjs.map → chunk-XCAGZAKP.cjs.map} +1 -1
  197. package/dist/{chunk-YOALGKRE.cjs → chunk-XDF2UPEQ.cjs} +3521 -1766
  198. package/dist/chunk-XDF2UPEQ.cjs.map +1 -0
  199. package/dist/{chunk-J7LXTUTP.cjs → chunk-XMQSEJCF.cjs} +604 -1094
  200. package/dist/chunk-XMQSEJCF.cjs.map +1 -0
  201. package/dist/chunk-XNLIZYRZ.cjs +3432 -0
  202. package/dist/chunk-XNLIZYRZ.cjs.map +1 -0
  203. package/dist/{chunk-KMXWZLQX.cjs → chunk-XNSI2FJO.cjs} +99 -100
  204. package/dist/chunk-XNSI2FJO.cjs.map +1 -0
  205. package/dist/chunk-XQSCL77R.cjs +60 -0
  206. package/dist/chunk-XQSCL77R.cjs.map +1 -0
  207. package/dist/{chunk-SVJ5GEXW.cjs → chunk-XUO3KQFO.cjs} +2 -2
  208. package/dist/chunk-XUO3KQFO.cjs.map +1 -0
  209. package/dist/{chunk-F4NHQHEZ.cjs → chunk-YAAM3M2S.cjs} +10 -10
  210. package/dist/{chunk-F4NHQHEZ.cjs.map → chunk-YAAM3M2S.cjs.map} +1 -1
  211. package/dist/{chunk-RUQS6M7G.js → chunk-YBFHZUXX.js} +6 -6
  212. package/dist/chunk-YBFHZUXX.js.map +1 -0
  213. package/dist/{chunk-PVUI6KGR.js → chunk-YDFDBE6D.js} +93 -6
  214. package/dist/chunk-YDFDBE6D.js.map +1 -0
  215. package/dist/{chunk-P7GTYOLB.cjs → chunk-YVWGEQJE.cjs} +297 -135
  216. package/dist/chunk-YVWGEQJE.cjs.map +1 -0
  217. package/dist/{chunk-QT6V3YRH.js → chunk-YWGVVALJ.js} +3 -3
  218. package/dist/{chunk-QT6V3YRH.js.map → chunk-YWGVVALJ.js.map} +1 -1
  219. package/dist/core/index.cjs +40 -40
  220. package/dist/core/index.d.cts +4 -5
  221. package/dist/core/index.d.ts +4 -5
  222. package/dist/core/index.js +8 -8
  223. package/dist/{ddl-BG4J805L.d.cts → ddl-BJcOp4WZ.d.cts} +3 -3
  224. package/dist/{ddl-CgiS9QLj.d.ts → ddl-BXfGHbPN.d.ts} +3 -3
  225. package/dist/graph-extension/index.cjs +26 -22
  226. package/dist/graph-extension/index.d.cts +16 -6
  227. package/dist/graph-extension/index.d.ts +16 -6
  228. package/dist/graph-extension/index.js +7 -7
  229. package/dist/graph-merge/index.cjs +2459 -654
  230. package/dist/graph-merge/index.cjs.map +1 -1
  231. package/dist/graph-merge/index.d.cts +170 -33
  232. package/dist/graph-merge/index.d.ts +170 -33
  233. package/dist/graph-merge/index.js +2269 -467
  234. package/dist/graph-merge/index.js.map +1 -1
  235. package/dist/{index-C3y_98iN.d.cts → index-BSHvKfok.d.ts} +221 -10
  236. package/dist/{index-BBxZCUdu.d.ts → index-DxaYCv8Y.d.cts} +221 -10
  237. package/dist/index.cjs +330 -268
  238. package/dist/index.cjs.map +1 -1
  239. package/dist/index.d.cts +590 -576
  240. package/dist/index.d.ts +590 -576
  241. package/dist/index.js +73 -49
  242. package/dist/index.js.map +1 -1
  243. package/dist/indexes/index.cjs +17 -17
  244. package/dist/indexes/index.d.cts +4 -4
  245. package/dist/indexes/index.d.ts +4 -4
  246. package/dist/indexes/index.js +10 -10
  247. package/dist/interchange/index.cjs +165 -51
  248. package/dist/interchange/index.cjs.map +1 -1
  249. package/dist/interchange/index.d.cts +261 -16
  250. package/dist/interchange/index.d.ts +261 -16
  251. package/dist/interchange/index.js +128 -25
  252. package/dist/interchange/index.js.map +1 -1
  253. package/dist/{manager-YoLEfcc1.d.ts → manager-CfZAimti.d.ts} +36 -5
  254. package/dist/{manager-KS7CGQQT.d.cts → manager-HGk6E_HW.d.cts} +36 -5
  255. package/dist/{materialize-indexes-Bhhyb1B3.d.ts → materialize-indexes-6A7dWGtb.d.cts} +10 -2
  256. package/dist/{materialize-indexes-OHRWypW6.d.cts → materialize-indexes-BMJP6Tms.d.ts} +10 -2
  257. package/dist/{postgres-DpkW3R5Y.d.cts → postgres-DFYWENdR.d.cts} +1961 -439
  258. package/dist/{postgres-DwqyIniy.d.ts → postgres-e7a9TdvR.d.ts} +1961 -439
  259. package/dist/profiler/index.cjs +15 -15
  260. package/dist/profiler/index.d.cts +9 -10
  261. package/dist/profiler/index.d.ts +9 -10
  262. package/dist/profiler/index.js +4 -4
  263. package/dist/provenance/index.cjs +46 -48
  264. package/dist/provenance/index.cjs.map +1 -1
  265. package/dist/provenance/index.d.cts +7 -7
  266. package/dist/provenance/index.d.ts +7 -7
  267. package/dist/provenance/index.js +12 -14
  268. package/dist/provenance/index.js.map +1 -1
  269. package/dist/schema/index.cjs +50 -48
  270. package/dist/schema/index.d.cts +9 -16
  271. package/dist/schema/index.d.ts +9 -16
  272. package/dist/schema/index.js +23 -21
  273. package/dist/{searchable-DLWEfC4a.d.ts → searchable-9OQoPuRs.d.ts} +1 -2
  274. package/dist/{searchable-CIZL8Hyw.d.cts → searchable-CIje5XYD.d.cts} +1 -2
  275. package/dist/{sqlite-DY0WODUK.d.cts → sqlite-DerU5tc7.d.ts} +2029 -347
  276. package/dist/{sqlite-L-VIRzqA.d.ts → sqlite-DitnISa9.d.cts} +2029 -347
  277. package/dist/{store-view-66p92IPi.d.ts → store-DawaWWjJ.d.ts} +1280 -767
  278. package/dist/{store-view-A85FFRnk.d.cts → store-RwTJx8LX.d.cts} +1280 -767
  279. package/dist/{temporal-BNbjXqer.d.cts → temporal-Bn-Fi8FJ.d.cts} +1 -1
  280. package/dist/{temporal-Bob6Nfbp.d.ts → temporal-BtM4UALv.d.ts} +1 -1
  281. package/dist/{types-DeORZhxn.d.cts → types-CoIx8HX5.d.cts} +1 -1
  282. package/dist/{types-Ch9a0Dx6.d.ts → types-HkveCCx0.d.cts} +726 -5
  283. package/dist/{types-Ch9a0Dx6.d.cts → types-HkveCCx0.d.ts} +726 -5
  284. package/dist/{types-ClCzT-dT.d.ts → types-KFfk-8Ah.d.ts} +1 -1
  285. package/dist/{where-DPw52ksb.d.cts → where--fk7_0kv.d.cts} +1 -1
  286. package/dist/{where-kWUZPvEA.d.ts → where-ws5hf-Ov.d.ts} +1 -1
  287. package/package.json +1 -1
  288. package/dist/chunk-2L54C2C2.js +0 -144
  289. package/dist/chunk-2L54C2C2.js.map +0 -1
  290. package/dist/chunk-35S6P5ZU.js +0 -27
  291. package/dist/chunk-35S6P5ZU.js.map +0 -1
  292. package/dist/chunk-42PYUGLS.js.map +0 -1
  293. package/dist/chunk-4GUBTVPV.js.map +0 -1
  294. package/dist/chunk-4GUTQPVO.js.map +0 -1
  295. package/dist/chunk-4MB3AQAQ.js.map +0 -1
  296. package/dist/chunk-4MEWSUVM.cjs.map +0 -1
  297. package/dist/chunk-4QIKLIGG.js.map +0 -1
  298. package/dist/chunk-4SZ6XPTG.cjs +0 -12
  299. package/dist/chunk-55ITBQJI.js.map +0 -1
  300. package/dist/chunk-5EKPX6QU.js.map +0 -1
  301. package/dist/chunk-6RYPD3NJ.cjs +0 -1282
  302. package/dist/chunk-6RYPD3NJ.cjs.map +0 -1
  303. package/dist/chunk-764JHTLT.cjs +0 -15
  304. package/dist/chunk-764JHTLT.cjs.map +0 -1
  305. package/dist/chunk-ACSVZPK7.cjs.map +0 -1
  306. package/dist/chunk-B3F2D3SP.cjs +0 -12
  307. package/dist/chunk-BGYJW37L.js.map +0 -1
  308. package/dist/chunk-BNS75YNF.cjs.map +0 -1
  309. package/dist/chunk-C4F7VJ5D.cjs.map +0 -1
  310. package/dist/chunk-CBKG6HEP.js +0 -1263
  311. package/dist/chunk-CBKG6HEP.js.map +0 -1
  312. package/dist/chunk-CPEL3YIR.cjs.map +0 -1
  313. package/dist/chunk-D54WH24V.cjs.map +0 -1
  314. package/dist/chunk-D56XG4EI.cjs.map +0 -1
  315. package/dist/chunk-D7PG5D5K.js.map +0 -1
  316. package/dist/chunk-DI74SMXS.cjs +0 -29
  317. package/dist/chunk-DI74SMXS.cjs.map +0 -1
  318. package/dist/chunk-DK2S42XB.js +0 -77
  319. package/dist/chunk-DK2S42XB.js.map +0 -1
  320. package/dist/chunk-DRACN6XG.js +0 -27
  321. package/dist/chunk-DRACN6XG.js.map +0 -1
  322. package/dist/chunk-DXEEHSGN.js.map +0 -1
  323. package/dist/chunk-EKFUG4G7.cjs.map +0 -1
  324. package/dist/chunk-EQ7JKLZO.cjs +0 -157
  325. package/dist/chunk-EQ7JKLZO.cjs.map +0 -1
  326. package/dist/chunk-FJMPR3OH.cjs.map +0 -1
  327. package/dist/chunk-FLEQ2HBK.js.map +0 -1
  328. package/dist/chunk-FQ7ZPOTZ.js.map +0 -1
  329. package/dist/chunk-G6Q5UM7U.js.map +0 -1
  330. package/dist/chunk-GYA4JRP5.js.map +0 -1
  331. package/dist/chunk-H7VE3FL4.cjs.map +0 -1
  332. package/dist/chunk-ID4WXTKL.js.map +0 -1
  333. package/dist/chunk-ISLPNELU.js.map +0 -1
  334. package/dist/chunk-ITE4IXAK.js +0 -25
  335. package/dist/chunk-ITE4IXAK.js.map +0 -1
  336. package/dist/chunk-IX64T5OL.cjs.map +0 -1
  337. package/dist/chunk-J2ICGNHO.cjs.map +0 -1
  338. package/dist/chunk-J7LXTUTP.cjs.map +0 -1
  339. package/dist/chunk-JQXSZHF2.cjs.map +0 -1
  340. package/dist/chunk-JXUTCSXX.cjs.map +0 -1
  341. package/dist/chunk-KCO5EFJU.js +0 -79
  342. package/dist/chunk-KCO5EFJU.js.map +0 -1
  343. package/dist/chunk-KKYELPZ2.cjs +0 -83
  344. package/dist/chunk-KKYELPZ2.cjs.map +0 -1
  345. package/dist/chunk-KMXWZLQX.cjs.map +0 -1
  346. package/dist/chunk-MIJKEVV7.js.map +0 -1
  347. package/dist/chunk-NAAMUYMS.cjs.map +0 -1
  348. package/dist/chunk-P7GTYOLB.cjs.map +0 -1
  349. package/dist/chunk-PVUI6KGR.js.map +0 -1
  350. package/dist/chunk-Q6EDCUXV.js.map +0 -1
  351. package/dist/chunk-QB6VMOJ2.cjs.map +0 -1
  352. package/dist/chunk-QC4MCOFV.cjs +0 -83
  353. package/dist/chunk-QC4MCOFV.cjs.map +0 -1
  354. package/dist/chunk-QMQLUA66.js +0 -12
  355. package/dist/chunk-QMQLUA66.js.map +0 -1
  356. package/dist/chunk-QRNYDV5Z.js.map +0 -1
  357. package/dist/chunk-RFRM3Q5K.js.map +0 -1
  358. package/dist/chunk-RUQS6M7G.js.map +0 -1
  359. package/dist/chunk-S4KQ5LV4.js.map +0 -1
  360. package/dist/chunk-SJDMVITW.cjs.map +0 -1
  361. package/dist/chunk-SNXVDZAJ.js.map +0 -1
  362. package/dist/chunk-SVJ5GEXW.cjs.map +0 -1
  363. package/dist/chunk-TDXIBCGY.cjs.map +0 -1
  364. package/dist/chunk-TKORQCG4.js.map +0 -1
  365. package/dist/chunk-TKP5T34P.js.map +0 -1
  366. package/dist/chunk-TRF4EBJT.cjs +0 -30
  367. package/dist/chunk-TRF4EBJT.cjs.map +0 -1
  368. package/dist/chunk-UCQ3BFSY.cjs.map +0 -1
  369. package/dist/chunk-UR7W5YQK.js.map +0 -1
  370. package/dist/chunk-V34A6R5V.js +0 -134
  371. package/dist/chunk-V34A6R5V.js.map +0 -1
  372. package/dist/chunk-WDAVPX46.js +0 -81
  373. package/dist/chunk-WDAVPX46.js.map +0 -1
  374. package/dist/chunk-WDBXJOU5.cjs.map +0 -1
  375. package/dist/chunk-YDWLUT5V.cjs.map +0 -1
  376. package/dist/chunk-YOALGKRE.cjs.map +0 -1
  377. package/dist/chunk-Z3WO6MND.cjs.map +0 -1
  378. package/dist/chunk-ZDH3DX3C.cjs +0 -30
  379. package/dist/chunk-ZDH3DX3C.cjs.map +0 -1
  380. package/dist/chunk-ZI6VQSZA.cjs.map +0 -1
  381. package/dist/chunk-ZTAJL4DT.cjs +0 -85
  382. package/dist/chunk-ZTAJL4DT.cjs.map +0 -1
  383. package/dist/define-graph-BGrJahvp.d.ts +0 -173
  384. package/dist/define-graph-alREY2wj.d.cts +0 -173
@@ -1,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-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';
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),
@@ -527,13 +568,46 @@ async function performNodeUpdate(ctx, input, backend, lock, options) {
527
568
  input.props
528
569
  );
529
570
  const nodeKind = registration.type;
571
+ const validFrom = validateOptionalCanonicalIsoDate(
572
+ input.validFrom,
573
+ "validFrom"
574
+ );
530
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
+ );
531
592
  const writeContext = createNodeWriteContext(ctx.graphId, ctx.registry, lock);
593
+ const effectiveValidFrom = validFrom ?? resurrectionInstant;
532
594
  const shared = {
533
595
  schema: nodeKind.schema,
534
596
  validatedProps,
535
597
  uniqueConstraints: registration.unique ?? [],
536
- ...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
537
611
  };
538
612
  if (options?.clearDeleted) {
539
613
  const row2 = await applyNodeUpdate(
@@ -551,6 +625,41 @@ async function performNodeUpdate(ctx, input, backend, lock, options) {
551
625
  );
552
626
  return rowToNode(row);
553
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
+ }
554
663
  async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
555
664
  if (backend.getNodes !== void 0) {
556
665
  const idsByKind = /* @__PURE__ */ new Map();
@@ -584,7 +693,7 @@ async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
584
693
  ctx.registry
585
694
  );
586
695
  for (const kindToCheck of kindsToCheck) {
587
- const groupKey = kindToCheck + CACHE_KEY_SEPARATOR + constraint.name;
696
+ const groupKey = encodeTupleKey([kindToCheck, constraint.name]);
588
697
  const group = groups.get(groupKey) ?? {
589
698
  nodeKind: kindToCheck,
590
699
  constraintName: constraint.name,
@@ -646,10 +755,60 @@ async function prepareBatchCreates(ctx, inputs, backend, options) {
646
755
  prepared.uniqueConstraints
647
756
  );
648
757
  }
649
- const batchInsertParams = preparedCreates.map(
650
- (prepared) => prepared.insertParams
651
- );
652
- 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
+ }
653
812
  }
654
813
  async function findUniqueRowAcrossKinds(backend, graphId, constraintName, key, kindsToCheck, includeDeleted) {
655
814
  for (const kindToCheck of kindsToCheck) {
@@ -708,6 +867,8 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
708
867
  opContext,
709
868
  backend,
710
869
  async (target, lock) => {
870
+ const identity = ctx.identity;
871
+ if (identity !== void 0) await identity.lock(target);
711
872
  const prepared = await validateAndPrepareNodeCreate(
712
873
  ctx,
713
874
  input,
@@ -715,18 +876,36 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
715
876
  target,
716
877
  options
717
878
  );
718
- let row;
719
- if (shouldReturnRow) {
720
- row = await target.insertNode(prepared.insertParams);
721
- } 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);
722
894
  await runInsertNoReturn(
723
895
  nodeInsertDispatch(target),
724
896
  prepared.insertParams
725
897
  );
726
- }
898
+ return;
899
+ });
727
900
  await finalizeNodeCreate(ctx, prepared, target, lock);
901
+ if (identity !== void 0) {
902
+ await identity.foldCreated(target, foldReferences([prepared]));
903
+ }
728
904
  if (row === void 0) return;
729
905
  return rowToNode(row);
906
+ },
907
+ {
908
+ fencesConstraintProbe: nodeFencesConstraintProbe(ctx, kind, "create")
730
909
  }
731
910
  );
732
911
  }
@@ -745,32 +924,92 @@ async function executeNodeCreate(ctx, input, backend, options) {
745
924
  }
746
925
  async function executeNodeCreateNoReturnBatch(ctx, inputs, backend) {
747
926
  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
- });
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
+ );
757
958
  }
758
959
  async function executeNodeCreateBatch(ctx, inputs, backend, options) {
759
960
  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
- });
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
+ );
774
1013
  }
775
1014
  async function executeNodeUpdate(ctx, input, backend, options) {
776
1015
  const opContext = ctx.createOperationContext(
@@ -783,7 +1022,32 @@ async function executeNodeUpdate(ctx, input, backend, options) {
783
1022
  ctx,
784
1023
  opContext,
785
1024
  backend,
786
- (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
+ }
787
1051
  );
788
1052
  }
789
1053
  async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candidateIdColumn, backend) {
@@ -833,7 +1097,7 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
833
1097
  kind,
834
1098
  operation: "update"
835
1099
  });
836
- const patch = {};
1100
+ const patch = createDataKeyedBag();
837
1101
  const unsetProperties = [];
838
1102
  for (const [property, value] of Object.entries(parsedPatch)) {
839
1103
  if (value === void 0) {
@@ -1013,7 +1277,13 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
1013
1277
  );
1014
1278
  return { affectedCount: result.affectedCount };
1015
1279
  },
1016
- { didWrite: (result) => result.affectedCount > 0 }
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
+ }
1017
1287
  )
1018
1288
  );
1019
1289
  }
@@ -1021,7 +1291,32 @@ async function executeNodeUpsertUpdate(ctx, input, backend, options) {
1021
1291
  return runInWriteTransaction(
1022
1292
  ctx,
1023
1293
  backend,
1024
- (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
+ }
1025
1320
  );
1026
1321
  }
1027
1322
  async function executeNodeDelete(ctx, kind, id, backend) {
@@ -1033,6 +1328,8 @@ async function executeNodeDelete(ctx, kind, id, backend) {
1033
1328
  opContext,
1034
1329
  backend,
1035
1330
  async (target, lock) => {
1331
+ const identity = ctx.identity;
1332
+ if (identity !== void 0) await identity.lock(target);
1036
1333
  const registration = getNodeRegistration(ctx.graph, kind);
1037
1334
  const preflight = await target.getNode(ctx.graphId, kind, id);
1038
1335
  if (!preflight || !isLiveNodeRow(preflight)) return;
@@ -1046,9 +1343,49 @@ async function executeNodeDelete(ctx, kind, id, backend) {
1046
1343
  },
1047
1344
  target
1048
1345
  );
1346
+ if (identity !== void 0) {
1347
+ await identity.detachDeleted(target, { kind, id }, "soft");
1348
+ }
1049
1349
  }
1050
1350
  );
1051
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
+ }
1052
1389
  async function executeNodeHardDelete(ctx, kind, id, backend) {
1053
1390
  const gate = await backend.getNode(ctx.graphId, kind, id);
1054
1391
  if (!gate) return;
@@ -1058,6 +1395,8 @@ async function executeNodeHardDelete(ctx, kind, id, backend) {
1058
1395
  opContext,
1059
1396
  backend,
1060
1397
  async (target, lock) => {
1398
+ const identity = ctx.identity;
1399
+ if (identity !== void 0) await identity.lock(target);
1061
1400
  const registration = getNodeRegistration(ctx.graph, kind);
1062
1401
  await applyNodeHardDelete(
1063
1402
  createNodeWriteContext(ctx.graphId, ctx.registry, lock),
@@ -1069,6 +1408,9 @@ async function executeNodeHardDelete(ctx, kind, id, backend) {
1069
1408
  },
1070
1409
  target
1071
1410
  );
1411
+ if (identity !== void 0) {
1412
+ await identity.detachDeleted(target, { kind, id }, "hard");
1413
+ }
1072
1414
  }
1073
1415
  );
1074
1416
  }
@@ -1504,101 +1846,109 @@ async function executeNodeBulkGetOrCreateByConstraint(ctx, kind, constraintName,
1504
1846
  constraint.scope,
1505
1847
  ctx.registry
1506
1848
  );
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,
1849
+ async function attempt() {
1850
+ const existingByKey = uniqueKeys.length > 0 ? await batchCheckUniqueAcrossKinds(
1549
1851
  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
1852
  ctx.graphId,
1563
- concreteKind,
1564
- nodeId
1565
- );
1566
- if (existingRow === void 0) {
1567
- 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(
1568
1889
  ctx,
1569
- { kind, props: validatedProps },
1890
+ createInputs,
1570
1891
  backend,
1571
1892
  { propsPreValidated: true }
1572
1893
  );
1573
- results[index] = { node, action: "created" };
1574
- continue;
1894
+ for (const [batchIndex, entry] of toCreate.entries()) {
1895
+ results[entry.index] = {
1896
+ node: requireDefined(createdNodes[batchIndex]),
1897
+ action: "created"
1898
+ };
1899
+ }
1575
1900
  }
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 }
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
1586
1907
  );
1587
- results[index] = {
1588
- node,
1589
- action: isSoftDeleted ? "resurrected" : "updated"
1590
- };
1591
- } else {
1592
- 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
+ }
1937
+ }
1938
+ for (const { index, sourceIndex } of duplicateOf) {
1939
+ const sourceResult = requireDefined(results[sourceIndex]);
1940
+ results[index] = { node: sourceResult.node, action: "found" };
1593
1941
  }
1942
+ return results;
1594
1943
  }
1595
- for (const { index, sourceIndex } of duplicateOf) {
1596
- const sourceResult = requireDefined(results[sourceIndex]);
1597
- 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();
1598
1949
  }
1599
- return results;
1600
1950
  }
1601
1951
 
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
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