@nicia-ai/typegraph 0.49.0 → 0.51.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 (370) hide show
  1. package/README.md +12 -0
  2. package/dist/backend/drizzle/indexes.cjs +11 -9
  3. package/dist/backend/drizzle/indexes.d.cts +1 -1
  4. package/dist/backend/drizzle/indexes.d.ts +1 -1
  5. package/dist/backend/drizzle/indexes.js +7 -5
  6. package/dist/backend/index.cjs +190 -53
  7. package/dist/backend/index.d.cts +90 -4
  8. package/dist/backend/index.d.ts +90 -4
  9. package/dist/backend/index.js +9 -12
  10. package/dist/backend/postgres/index.cjs +36 -28
  11. package/dist/backend/postgres/index.d.cts +7 -7
  12. package/dist/backend/postgres/index.d.ts +7 -7
  13. package/dist/backend/postgres/index.js +19 -15
  14. package/dist/backend/postgres/pglite-store.cjs +7 -62
  15. package/dist/backend/postgres/pglite-store.cjs.map +1 -1
  16. package/dist/backend/postgres/pglite-store.d.cts +8 -8
  17. package/dist/backend/postgres/pglite-store.d.ts +8 -8
  18. package/dist/backend/postgres/pglite-store.js +7 -62
  19. package/dist/backend/postgres/pglite-store.js.map +1 -1
  20. package/dist/backend/postgres/pglite.cjs +21 -17
  21. package/dist/backend/postgres/pglite.d.cts +3 -3
  22. package/dist/backend/postgres/pglite.d.ts +3 -3
  23. package/dist/backend/postgres/pglite.js +20 -16
  24. package/dist/backend/sqlite/index.cjs +33 -25
  25. package/dist/backend/sqlite/index.d.cts +7 -7
  26. package/dist/backend/sqlite/index.d.ts +7 -7
  27. package/dist/backend/sqlite/index.js +17 -13
  28. package/dist/backend/sqlite/libsql.cjs +24 -20
  29. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  30. package/dist/backend/sqlite/libsql.d.cts +3 -3
  31. package/dist/backend/sqlite/libsql.d.ts +3 -3
  32. package/dist/backend/sqlite/libsql.js +19 -15
  33. package/dist/backend/sqlite/libsql.js.map +1 -1
  34. package/dist/backend/sqlite/local-store.cjs +9 -64
  35. package/dist/backend/sqlite/local-store.cjs.map +1 -1
  36. package/dist/backend/sqlite/local-store.d.cts +8 -8
  37. package/dist/backend/sqlite/local-store.d.ts +8 -8
  38. package/dist/backend/sqlite/local-store.js +8 -64
  39. package/dist/backend/sqlite/local-store.js.map +1 -1
  40. package/dist/backend/sqlite/local.cjs +25 -20
  41. package/dist/backend/sqlite/local.d.cts +3 -3
  42. package/dist/backend/sqlite/local.d.ts +3 -3
  43. package/dist/backend/sqlite/local.js +21 -16
  44. package/dist/chunk-2CVDZCXH.cjs +1278 -0
  45. package/dist/chunk-2CVDZCXH.cjs.map +1 -0
  46. package/dist/{chunk-MYKHJI2J.js → chunk-2DWTBNSH.js} +3 -3
  47. package/dist/{chunk-MYKHJI2J.js.map → chunk-2DWTBNSH.js.map} +1 -1
  48. package/dist/{chunk-JB6T4GLL.cjs → chunk-2KCTP3U2.cjs} +870 -528
  49. package/dist/chunk-2KCTP3U2.cjs.map +1 -0
  50. package/dist/{chunk-OORXGFL5.cjs → chunk-322TBTOQ.cjs} +48 -48
  51. package/dist/{chunk-OORXGFL5.cjs.map → chunk-322TBTOQ.cjs.map} +1 -1
  52. package/dist/{chunk-FA2AFWLP.cjs → chunk-36SX6QXP.cjs} +31 -12
  53. package/dist/chunk-36SX6QXP.cjs.map +1 -0
  54. package/dist/{chunk-SDBBMD4N.js → chunk-36VYWVQU.js} +3 -3
  55. package/dist/{chunk-SDBBMD4N.js.map → chunk-36VYWVQU.js.map} +1 -1
  56. package/dist/chunk-4DKY6RIU.js +1253 -0
  57. package/dist/chunk-4DKY6RIU.js.map +1 -0
  58. package/dist/chunk-4QKOZYMV.js +9 -0
  59. package/dist/chunk-4QKOZYMV.js.map +1 -0
  60. package/dist/{chunk-WIC7DRXW.js → chunk-57JM6NW3.js} +9 -19
  61. package/dist/chunk-57JM6NW3.js.map +1 -0
  62. package/dist/chunk-5WWEYV4H.cjs +5113 -0
  63. package/dist/chunk-5WWEYV4H.cjs.map +1 -0
  64. package/dist/chunk-6KQEICJ6.cjs +12 -0
  65. package/dist/{chunk-MKJ4KXL5.cjs.map → chunk-6KQEICJ6.cjs.map} +1 -1
  66. package/dist/{chunk-DZAICA5J.js → chunk-6NKSE5AU.js} +4 -4
  67. package/dist/{chunk-DZAICA5J.js.map → chunk-6NKSE5AU.js.map} +1 -1
  68. package/dist/{chunk-KKBDXCLQ.js → chunk-6NLYIMJO.js} +4 -4
  69. package/dist/{chunk-KKBDXCLQ.js.map → chunk-6NLYIMJO.js.map} +1 -1
  70. package/dist/{chunk-BFUOME67.cjs → chunk-7B7I7YAW.cjs} +20 -11
  71. package/dist/chunk-7B7I7YAW.cjs.map +1 -0
  72. package/dist/{chunk-ZDKTPBGV.js → chunk-7G5IYROL.js} +6 -548
  73. package/dist/chunk-7G5IYROL.js.map +1 -0
  74. package/dist/{chunk-3DMMGT6S.js → chunk-7QFRK6PU.js} +4 -8
  75. package/dist/chunk-7QFRK6PU.js.map +1 -0
  76. package/dist/chunk-A4C4NJ5U.cjs +12 -0
  77. package/dist/chunk-A4C4NJ5U.cjs.map +1 -0
  78. package/dist/{chunk-CHAOFCHV.js → chunk-AH2A74OZ.js} +3 -3
  79. package/dist/{chunk-CHAOFCHV.js.map → chunk-AH2A74OZ.js.map} +1 -1
  80. package/dist/{chunk-UGHQV7MP.cjs → chunk-B3MN7EJR.cjs} +228 -162
  81. package/dist/chunk-B3MN7EJR.cjs.map +1 -0
  82. package/dist/{chunk-TZEGUG6D.cjs → chunk-BZ5MVITP.cjs} +4 -4
  83. package/dist/{chunk-TZEGUG6D.cjs.map → chunk-BZ5MVITP.cjs.map} +1 -1
  84. package/dist/{chunk-YVF2EM7B.js → chunk-CAI6SMP6.js} +3 -3
  85. package/dist/{chunk-YVF2EM7B.js.map → chunk-CAI6SMP6.js.map} +1 -1
  86. package/dist/{chunk-JONXFAPO.js → chunk-CBOD7TXH.js} +5 -5
  87. package/dist/{chunk-JONXFAPO.js.map → chunk-CBOD7TXH.js.map} +1 -1
  88. package/dist/{chunk-FQPEMEWX.cjs → chunk-CRZ56SZU.cjs} +81 -32
  89. package/dist/chunk-CRZ56SZU.cjs.map +1 -0
  90. package/dist/{chunk-DO7SAMEK.cjs → chunk-D3GWARN7.cjs} +47 -47
  91. package/dist/{chunk-DO7SAMEK.cjs.map → chunk-D3GWARN7.cjs.map} +1 -1
  92. package/dist/{chunk-QTD6HX4O.js → chunk-D3OUDFU7.js} +5 -5
  93. package/dist/{chunk-QTD6HX4O.js.map → chunk-D3OUDFU7.js.map} +1 -1
  94. package/dist/{chunk-2QGYQBS2.cjs → chunk-DWUDZ66O.cjs} +10 -10
  95. package/dist/{chunk-2QGYQBS2.cjs.map → chunk-DWUDZ66O.cjs.map} +1 -1
  96. package/dist/chunk-EKG2UXNX.cjs +23 -0
  97. package/dist/chunk-EKG2UXNX.cjs.map +1 -0
  98. package/dist/chunk-FMMW3KX7.cjs +148 -0
  99. package/dist/chunk-FMMW3KX7.cjs.map +1 -0
  100. package/dist/{chunk-XVWOYKIK.js → chunk-FZHF5UWR.js} +3 -3
  101. package/dist/{chunk-XVWOYKIK.js.map → chunk-FZHF5UWR.js.map} +1 -1
  102. package/dist/chunk-H2VWDQWC.cjs +571 -0
  103. package/dist/chunk-H2VWDQWC.cjs.map +1 -0
  104. package/dist/chunk-H4FY6OZK.js +13 -0
  105. package/dist/chunk-H4FY6OZK.js.map +1 -0
  106. package/dist/{chunk-EDN4Y4ZG.cjs → chunk-H5IJSROF.cjs} +9 -15
  107. package/dist/chunk-H5IJSROF.cjs.map +1 -0
  108. package/dist/chunk-HZUB5CON.js +27 -0
  109. package/dist/chunk-HZUB5CON.js.map +1 -0
  110. package/dist/{chunk-NACVVDWB.js → chunk-I5IOSA27.js} +103 -105
  111. package/dist/chunk-I5IOSA27.js.map +1 -0
  112. package/dist/{chunk-OI2GQ25X.cjs → chunk-I7YAY2VQ.cjs} +7 -7
  113. package/dist/{chunk-OI2GQ25X.cjs.map → chunk-I7YAY2VQ.cjs.map} +1 -1
  114. package/dist/chunk-IRCWIA3R.js +20 -0
  115. package/dist/chunk-IRCWIA3R.js.map +1 -0
  116. package/dist/chunk-IVQBLXBK.cjs +55 -0
  117. package/dist/chunk-IVQBLXBK.cjs.map +1 -0
  118. package/dist/{chunk-7SQSZN2J.js → chunk-IZD4HTCP.js} +5 -5
  119. package/dist/{chunk-7SQSZN2J.js.map → chunk-IZD4HTCP.js.map} +1 -1
  120. package/dist/{chunk-3FPR224C.cjs → chunk-JHRUZ73O.cjs} +116 -107
  121. package/dist/chunk-JHRUZ73O.cjs.map +1 -0
  122. package/dist/{chunk-EZEEWCFJ.cjs → chunk-JQKMEKKW.cjs} +525 -298
  123. package/dist/chunk-JQKMEKKW.cjs.map +1 -0
  124. package/dist/chunk-JVA3KDEA.cjs +691 -0
  125. package/dist/chunk-JVA3KDEA.cjs.map +1 -0
  126. package/dist/{chunk-5K2BKEBD.js → chunk-K46SDNQD.js} +10 -4
  127. package/dist/chunk-K46SDNQD.js.map +1 -0
  128. package/dist/{chunk-7LZJNLA5.js → chunk-K67P5DLL.js} +108 -42
  129. package/dist/chunk-K67P5DLL.js.map +1 -0
  130. package/dist/{chunk-3G5W2U2L.cjs → chunk-KACEYDYV.cjs} +335 -258
  131. package/dist/chunk-KACEYDYV.cjs.map +1 -0
  132. package/dist/{chunk-JFRT7S3B.cjs → chunk-L6EVYIID.cjs} +318 -478
  133. package/dist/chunk-L6EVYIID.cjs.map +1 -0
  134. package/dist/{chunk-SHFBB23Q.js → chunk-LI4K2KEJ.js} +6 -4
  135. package/dist/chunk-LI4K2KEJ.js.map +1 -0
  136. package/dist/chunk-LKZDQ2B4.js +1581 -0
  137. package/dist/chunk-LKZDQ2B4.js.map +1 -0
  138. package/dist/{chunk-WODMN3Q2.cjs → chunk-LLFPQOBA.cjs} +27 -27
  139. package/dist/{chunk-WODMN3Q2.cjs.map → chunk-LLFPQOBA.cjs.map} +1 -1
  140. package/dist/{chunk-P6YLZTRE.js → chunk-LZMQ3SFK.js} +3 -3
  141. package/dist/{chunk-P6YLZTRE.js.map → chunk-LZMQ3SFK.js.map} +1 -1
  142. package/dist/{chunk-HEV35TGT.js → chunk-M3VTS3F6.js} +13 -4
  143. package/dist/chunk-M3VTS3F6.js.map +1 -0
  144. package/dist/{chunk-TQHGE7UC.cjs → chunk-M5MSP3BI.cjs} +18 -10
  145. package/dist/chunk-M5MSP3BI.cjs.map +1 -0
  146. package/dist/{chunk-D4QLTJSM.js → chunk-NBOS7BY3.js} +63 -23
  147. package/dist/chunk-NBOS7BY3.js.map +1 -0
  148. package/dist/chunk-NGQDGL5X.js +140 -0
  149. package/dist/chunk-NGQDGL5X.js.map +1 -0
  150. package/dist/{chunk-SIT26LAZ.cjs → chunk-NLX5OWK7.cjs} +33 -5
  151. package/dist/chunk-NLX5OWK7.cjs.map +1 -0
  152. package/dist/chunk-NUQ2YFFH.cjs +1637 -0
  153. package/dist/chunk-NUQ2YFFH.cjs.map +1 -0
  154. package/dist/{chunk-UMGZDVOA.cjs → chunk-OGL4X4PH.cjs} +206 -208
  155. package/dist/chunk-OGL4X4PH.cjs.map +1 -0
  156. package/dist/{chunk-LRQKXRXO.cjs → chunk-OTNTGEXR.cjs} +4 -4
  157. package/dist/{chunk-LRQKXRXO.cjs.map → chunk-OTNTGEXR.cjs.map} +1 -1
  158. package/dist/chunk-OTWE63BW.js +53 -0
  159. package/dist/chunk-OTWE63BW.js.map +1 -0
  160. package/dist/chunk-PC5NGH5A.js +549 -0
  161. package/dist/chunk-PC5NGH5A.js.map +1 -0
  162. package/dist/{chunk-26YKDNUD.cjs → chunk-PS3TUWJM.cjs} +12 -10
  163. package/dist/chunk-PS3TUWJM.cjs.map +1 -0
  164. package/dist/{chunk-OMZ37BM2.js → chunk-PVFFH7TL.js} +5 -5
  165. package/dist/{chunk-OMZ37BM2.js.map → chunk-PVFFH7TL.js.map} +1 -1
  166. package/dist/chunk-QCD5JKU4.cjs +15 -0
  167. package/dist/chunk-QCD5JKU4.cjs.map +1 -0
  168. package/dist/{chunk-UGHG7PGX.js → chunk-QG5VEOKX.js} +30 -4
  169. package/dist/chunk-QG5VEOKX.js.map +1 -0
  170. package/dist/{chunk-TUNPBZY3.cjs → chunk-QLLZM5I3.cjs} +4 -4
  171. package/dist/{chunk-TUNPBZY3.cjs.map → chunk-QLLZM5I3.cjs.map} +1 -1
  172. package/dist/{chunk-BRRP76WO.js → chunk-RCBG6YMT.js} +781 -375
  173. package/dist/chunk-RCBG6YMT.js.map +1 -0
  174. package/dist/{chunk-LTXQOEIC.js → chunk-RI7RJH4G.js} +281 -204
  175. package/dist/chunk-RI7RJH4G.js.map +1 -0
  176. package/dist/{chunk-GYEG3ZLZ.cjs → chunk-RJMHU2MG.cjs} +121 -18
  177. package/dist/chunk-RJMHU2MG.cjs.map +1 -0
  178. package/dist/{chunk-GLHXM7C4.js → chunk-RVUL2HXY.js} +61 -23
  179. package/dist/chunk-RVUL2HXY.js.map +1 -0
  180. package/dist/chunk-RWUWTJQY.cjs +30 -0
  181. package/dist/chunk-RWUWTJQY.cjs.map +1 -0
  182. package/dist/{chunk-2O4PCIZ6.cjs → chunk-S5GU4LUN.cjs} +13 -13
  183. package/dist/{chunk-2O4PCIZ6.cjs.map → chunk-S5GU4LUN.cjs.map} +1 -1
  184. package/dist/{chunk-JPD2CTC3.js → chunk-SDPWO2Z5.js} +7 -7
  185. package/dist/{chunk-JPD2CTC3.js.map → chunk-SDPWO2Z5.js.map} +1 -1
  186. package/dist/{chunk-OVI7IXYX.js → chunk-SLGGT2XD.js} +3 -3
  187. package/dist/{chunk-OVI7IXYX.js.map → chunk-SLGGT2XD.js.map} +1 -1
  188. package/dist/{chunk-ROR5ZR6A.cjs → chunk-TIJUA4I6.cjs} +45 -45
  189. package/dist/{chunk-ROR5ZR6A.cjs.map → chunk-TIJUA4I6.cjs.map} +1 -1
  190. package/dist/{chunk-AOSSQDVO.cjs → chunk-TM54OBHX.cjs} +13 -13
  191. package/dist/{chunk-AOSSQDVO.cjs.map → chunk-TM54OBHX.cjs.map} +1 -1
  192. package/dist/{chunk-KF6K7TGH.js → chunk-TYEYRCXL.js} +766 -433
  193. package/dist/chunk-TYEYRCXL.js.map +1 -0
  194. package/dist/{chunk-Z2JCLZFJ.js → chunk-UKOVGCRN.js} +2151 -570
  195. package/dist/chunk-UKOVGCRN.js.map +1 -0
  196. package/dist/chunk-UYKDYE5D.cjs +12 -0
  197. package/dist/{chunk-CICO5GXD.cjs.map → chunk-UYKDYE5D.cjs.map} +1 -1
  198. package/dist/{chunk-S5TERQVW.js → chunk-VAAC7L57.js} +284 -66
  199. package/dist/chunk-VAAC7L57.js.map +1 -0
  200. package/dist/{chunk-7UOLHNWC.cjs → chunk-VKHXYVN7.cjs} +22 -33
  201. package/dist/chunk-VKHXYVN7.cjs.map +1 -0
  202. package/dist/{chunk-6NGW27EO.cjs → chunk-VLBTRXA2.cjs} +10 -10
  203. package/dist/{chunk-6NGW27EO.cjs.map → chunk-VLBTRXA2.cjs.map} +1 -1
  204. package/dist/{chunk-YIURNGXI.js → chunk-VUQZNUHU.js} +22 -6
  205. package/dist/chunk-VUQZNUHU.js.map +1 -0
  206. package/dist/{chunk-YYUHLYM2.cjs → chunk-WDM5WQK4.cjs} +183 -143
  207. package/dist/chunk-WDM5WQK4.cjs.map +1 -0
  208. package/dist/{chunk-ZFMCDJGB.js → chunk-WFSYYU4W.js} +70 -220
  209. package/dist/chunk-WFSYYU4W.js.map +1 -0
  210. package/dist/{chunk-SR725PWF.cjs → chunk-WRBV2FNH.cjs} +2065 -1659
  211. package/dist/chunk-WRBV2FNH.cjs.map +1 -0
  212. package/dist/{chunk-MRDBBHIZ.cjs → chunk-X4GDXBOP.cjs} +2 -2
  213. package/dist/chunk-X4GDXBOP.cjs.map +1 -0
  214. package/dist/chunk-XORONCV3.js +202 -0
  215. package/dist/chunk-XORONCV3.js.map +1 -0
  216. package/dist/{chunk-D5R42W5D.js → chunk-XZW2CTNO.js} +115 -12
  217. package/dist/chunk-XZW2CTNO.js.map +1 -0
  218. package/dist/{chunk-ZLONH2UD.js → chunk-YDEJQWOL.js} +2 -2
  219. package/dist/chunk-YDEJQWOL.js.map +1 -0
  220. package/dist/{chunk-2TYSSBU5.js → chunk-YT2IVFAI.js} +30 -21
  221. package/dist/chunk-YT2IVFAI.js.map +1 -0
  222. package/dist/chunk-ZGVTNKTX.cjs +217 -0
  223. package/dist/chunk-ZGVTNKTX.cjs.map +1 -0
  224. package/dist/core/index.cjs +29 -28
  225. package/dist/core/index.d.cts +4 -4
  226. package/dist/core/index.d.ts +4 -4
  227. package/dist/core/index.js +9 -8
  228. package/dist/{ddl-D_oW-EVO.d.ts → ddl-BvcbgzHo.d.ts} +3 -3
  229. package/dist/{ddl-BL1NZLMY.d.cts → ddl-Ufebz5q5.d.cts} +3 -3
  230. package/dist/graph-extension/index.cjs +21 -20
  231. package/dist/graph-extension/index.d.cts +2 -4
  232. package/dist/graph-extension/index.d.ts +2 -4
  233. package/dist/graph-extension/index.js +5 -4
  234. package/dist/graph-merge/index.cjs +324 -307
  235. package/dist/graph-merge/index.cjs.map +1 -1
  236. package/dist/graph-merge/index.d.cts +8 -9
  237. package/dist/graph-merge/index.d.ts +8 -9
  238. package/dist/graph-merge/index.js +51 -34
  239. package/dist/graph-merge/index.js.map +1 -1
  240. package/dist/index.cjs +224 -222
  241. package/dist/index.cjs.map +1 -1
  242. package/dist/index.d.cts +11 -12
  243. package/dist/index.d.ts +11 -12
  244. package/dist/index.js +38 -36
  245. package/dist/index.js.map +1 -1
  246. package/dist/indexes/index.cjs +15 -13
  247. package/dist/indexes/index.d.cts +4 -4
  248. package/dist/indexes/index.d.ts +4 -4
  249. package/dist/indexes/index.js +8 -6
  250. package/dist/{ingestion-import-target-dNeL7iAv.d.ts → ingestion-import-target-CAs1OX-l.d.cts} +1 -1
  251. package/dist/{ingestion-import-target-XPxZYw89.d.cts → ingestion-import-target-DCQSPfNx.d.ts} +1 -1
  252. package/dist/interchange/index.cjs +57 -54
  253. package/dist/interchange/index.cjs.map +1 -1
  254. package/dist/interchange/index.d.cts +19 -8
  255. package/dist/interchange/index.d.ts +19 -8
  256. package/dist/interchange/index.js +21 -18
  257. package/dist/interchange/index.js.map +1 -1
  258. package/dist/local-store-impl-6DDTFM32.cjs +77 -0
  259. package/dist/local-store-impl-6DDTFM32.cjs.map +1 -0
  260. package/dist/local-store-impl-OXTOVU2J.js +75 -0
  261. package/dist/local-store-impl-OXTOVU2J.js.map +1 -0
  262. package/dist/{manager-CYaff3n3.d.cts → manager-B68OrPR2.d.ts} +29 -2
  263. package/dist/{manager-D9eRT_ns.d.ts → manager-D_t7oK69.d.cts} +29 -2
  264. package/dist/pglite-store-impl-6EMZGL7K.js +73 -0
  265. package/dist/pglite-store-impl-6EMZGL7K.js.map +1 -0
  266. package/dist/pglite-store-impl-GJG3Y7RP.cjs +75 -0
  267. package/dist/pglite-store-impl-GJG3Y7RP.cjs.map +1 -0
  268. package/dist/{postgres-CcL4bAHS.d.ts → postgres-BPLSVyHM.d.ts} +279 -2
  269. package/dist/{postgres-DMj39MEu.d.cts → postgres-CqvtFC2y.d.cts} +279 -2
  270. package/dist/profiler/index.d.cts +9 -9
  271. package/dist/profiler/index.d.ts +9 -9
  272. package/dist/provenance/index.cjs +59 -44
  273. package/dist/provenance/index.cjs.map +1 -1
  274. package/dist/provenance/index.d.cts +7 -7
  275. package/dist/provenance/index.d.ts +7 -7
  276. package/dist/provenance/index.js +28 -13
  277. package/dist/provenance/index.js.map +1 -1
  278. package/dist/{repair-validity-windows-BFNZvd_H.d.cts → repair-validity-windows-DEzCKAdy.d.cts} +7 -3
  279. package/dist/{repair-validity-windows-DlUSqwCg.d.ts → repair-validity-windows-GMdaS2AH.d.ts} +7 -3
  280. package/dist/resolve-D_H8MHtq.d.ts +1805 -0
  281. package/dist/resolve-WEW8gWws.d.cts +1805 -0
  282. package/dist/schema/index.cjs +48 -46
  283. package/dist/schema/index.d.cts +4 -6
  284. package/dist/schema/index.d.ts +4 -6
  285. package/dist/schema/index.js +21 -19
  286. package/dist/{searchable-bpE1bBfc.d.ts → searchable-C_UREI9K.d.ts} +1 -1
  287. package/dist/{searchable-DHJMh_nj.d.cts → searchable-ClgET_i7.d.cts} +1 -1
  288. package/dist/{sqlite-YppHrNFb.d.cts → sqlite-D1mXO9Kp.d.cts} +310 -2
  289. package/dist/{sqlite-D7Oz0SQh.d.ts → sqlite-MZA3oZNB.d.ts} +310 -2
  290. package/dist/{store-bphCSo7z.d.cts → store-CuFX7fCx.d.cts} +117 -31
  291. package/dist/{store-DRrFCx5x.d.ts → store-D-ZjXQpW.d.ts} +117 -31
  292. package/dist/{temporal-CbnLzTmM.d.ts → temporal-CpyEiRY8.d.cts} +1 -1
  293. package/dist/{temporal-5GqpYCk2.d.cts → temporal-y0Aep9Su.d.ts} +1 -1
  294. package/dist/{types-BqFZTQmV.d.cts → types-6yf0Vv-_.d.cts} +2016 -94
  295. package/dist/{types-BqFZTQmV.d.ts → types-6yf0Vv-_.d.ts} +2016 -94
  296. package/dist/{types-Bx74kaTt.d.ts → types-DzJ4dlzk.d.cts} +1 -1
  297. package/dist/{types-CXAhpW-c.d.cts → types-_vVSB9k-.d.ts} +1 -1
  298. package/dist/{where-O-k2wgYm.d.ts → where-DuG2LCLe.d.ts} +1 -1
  299. package/dist/{where-DI_Fqz-X.d.cts → where-Mhf_yyKX.d.cts} +1 -1
  300. package/package.json +7 -2
  301. package/dist/chunk-26YKDNUD.cjs.map +0 -1
  302. package/dist/chunk-2TYSSBU5.js.map +0 -1
  303. package/dist/chunk-3DMMGT6S.js.map +0 -1
  304. package/dist/chunk-3FPR224C.cjs.map +0 -1
  305. package/dist/chunk-3G5W2U2L.cjs.map +0 -1
  306. package/dist/chunk-3KOY4FH3.cjs +0 -934
  307. package/dist/chunk-3KOY4FH3.cjs.map +0 -1
  308. package/dist/chunk-3QNZ5SAJ.cjs +0 -3502
  309. package/dist/chunk-3QNZ5SAJ.cjs.map +0 -1
  310. package/dist/chunk-3U5ABFDW.cjs +0 -259
  311. package/dist/chunk-3U5ABFDW.cjs.map +0 -1
  312. package/dist/chunk-5K2BKEBD.js.map +0 -1
  313. package/dist/chunk-5PRKMB24.cjs +0 -124
  314. package/dist/chunk-5PRKMB24.cjs.map +0 -1
  315. package/dist/chunk-6LN7FIVU.js +0 -107
  316. package/dist/chunk-6LN7FIVU.js.map +0 -1
  317. package/dist/chunk-6SWPJEYN.js +0 -1126
  318. package/dist/chunk-6SWPJEYN.js.map +0 -1
  319. package/dist/chunk-7LZJNLA5.js.map +0 -1
  320. package/dist/chunk-7UOLHNWC.cjs.map +0 -1
  321. package/dist/chunk-BFUOME67.cjs.map +0 -1
  322. package/dist/chunk-BRRP76WO.js.map +0 -1
  323. package/dist/chunk-CICO5GXD.cjs +0 -12
  324. package/dist/chunk-D4QLTJSM.js.map +0 -1
  325. package/dist/chunk-D5R42W5D.js.map +0 -1
  326. package/dist/chunk-EDN4Y4ZG.cjs.map +0 -1
  327. package/dist/chunk-EZEEWCFJ.cjs.map +0 -1
  328. package/dist/chunk-FA2AFWLP.cjs.map +0 -1
  329. package/dist/chunk-FQPEMEWX.cjs.map +0 -1
  330. package/dist/chunk-GLHXM7C4.js.map +0 -1
  331. package/dist/chunk-GYEG3ZLZ.cjs.map +0 -1
  332. package/dist/chunk-HDL2ARHX.cjs +0 -1156
  333. package/dist/chunk-HDL2ARHX.cjs.map +0 -1
  334. package/dist/chunk-HEV35TGT.js.map +0 -1
  335. package/dist/chunk-I4GAZH5Z.js +0 -913
  336. package/dist/chunk-I4GAZH5Z.js.map +0 -1
  337. package/dist/chunk-JB6T4GLL.cjs.map +0 -1
  338. package/dist/chunk-JBQQ7THH.js +0 -20
  339. package/dist/chunk-JBQQ7THH.js.map +0 -1
  340. package/dist/chunk-JFRT7S3B.cjs.map +0 -1
  341. package/dist/chunk-KF6K7TGH.js.map +0 -1
  342. package/dist/chunk-L3LQNR34.cjs +0 -1254
  343. package/dist/chunk-L3LQNR34.cjs.map +0 -1
  344. package/dist/chunk-LTXQOEIC.js.map +0 -1
  345. package/dist/chunk-MKJ4KXL5.cjs +0 -12
  346. package/dist/chunk-MRDBBHIZ.cjs.map +0 -1
  347. package/dist/chunk-NACVVDWB.js.map +0 -1
  348. package/dist/chunk-NVY5CJFP.js +0 -244
  349. package/dist/chunk-NVY5CJFP.js.map +0 -1
  350. package/dist/chunk-PWLJ77UV.cjs +0 -23
  351. package/dist/chunk-PWLJ77UV.cjs.map +0 -1
  352. package/dist/chunk-S5TERQVW.js.map +0 -1
  353. package/dist/chunk-SHFBB23Q.js.map +0 -1
  354. package/dist/chunk-SIT26LAZ.cjs.map +0 -1
  355. package/dist/chunk-SR725PWF.cjs.map +0 -1
  356. package/dist/chunk-TQHGE7UC.cjs.map +0 -1
  357. package/dist/chunk-UGHG7PGX.js.map +0 -1
  358. package/dist/chunk-UGHQV7MP.cjs.map +0 -1
  359. package/dist/chunk-UMGZDVOA.cjs.map +0 -1
  360. package/dist/chunk-WIC7DRXW.js.map +0 -1
  361. package/dist/chunk-YIURNGXI.js.map +0 -1
  362. package/dist/chunk-YYUHLYM2.cjs.map +0 -1
  363. package/dist/chunk-Z2JCLZFJ.js.map +0 -1
  364. package/dist/chunk-ZDKTPBGV.js.map +0 -1
  365. package/dist/chunk-ZFMCDJGB.js.map +0 -1
  366. package/dist/chunk-ZLONH2UD.js.map +0 -1
  367. package/dist/index-COs_z6nV.d.cts +0 -1132
  368. package/dist/index-D7d1u2gr.d.ts +0 -1132
  369. package/dist/materialize-indexes-DJ3ykH59.d.ts +0 -266
  370. package/dist/materialize-indexes-DTtAnvfY.d.cts +0 -266
@@ -0,0 +1,1278 @@
1
+ 'use strict';
2
+
3
+ var chunkFMMW3KX7_cjs = require('./chunk-FMMW3KX7.cjs');
4
+ var chunkJQKMEKKW_cjs = require('./chunk-JQKMEKKW.cjs');
5
+ var chunkNLX5OWK7_cjs = require('./chunk-NLX5OWK7.cjs');
6
+ var chunkZGVTNKTX_cjs = require('./chunk-ZGVTNKTX.cjs');
7
+ var chunkNUQ2YFFH_cjs = require('./chunk-NUQ2YFFH.cjs');
8
+ var chunkCRZ56SZU_cjs = require('./chunk-CRZ56SZU.cjs');
9
+ var chunkM5MSP3BI_cjs = require('./chunk-M5MSP3BI.cjs');
10
+ var chunkH5IJSROF_cjs = require('./chunk-H5IJSROF.cjs');
11
+ var chunkHAHNRASW_cjs = require('./chunk-HAHNRASW.cjs');
12
+ var chunkX4GDXBOP_cjs = require('./chunk-X4GDXBOP.cjs');
13
+ var chunkN66HCGCY_cjs = require('./chunk-N66HCGCY.cjs');
14
+
15
+ // src/store/types.ts
16
+ var AUTO_REFRESH_STATISTICS_ROW_THRESHOLD = 1e3;
17
+ var TRANSACTION_RUNTIME = chunkH5IJSROF_cjs.typeGraphGlobalSymbol(
18
+ "transaction-runtime-v1"
19
+ );
20
+
21
+ // src/store/runtime-port.ts
22
+ var STORE_RUNTIME = chunkH5IJSROF_cjs.typeGraphGlobalSymbol("store-runtime-v1");
23
+ function storeRuntime(store) {
24
+ const runtime = store[STORE_RUNTIME];
25
+ if (runtime === void 0) {
26
+ throw new TypeError(
27
+ "Cannot access this Store's runtime port. The Store may come from an incompatible TypeGraph version."
28
+ );
29
+ }
30
+ return runtime;
31
+ }
32
+ function storeBackend(store) {
33
+ return storeRuntime(store).backend;
34
+ }
35
+ function transactionBackend(transaction) {
36
+ const runtime = transaction[TRANSACTION_RUNTIME];
37
+ if (runtime === void 0) {
38
+ throw new TypeError(
39
+ "Cannot access this transaction's runtime port. The transaction may come from an incompatible TypeGraph version."
40
+ );
41
+ }
42
+ return runtime.backend;
43
+ }
44
+ function transactionNodeOperationHookRunner(transaction) {
45
+ const runtime = transaction[TRANSACTION_RUNTIME];
46
+ if (runtime === void 0) {
47
+ throw new TypeError(
48
+ "Cannot access this transaction's runtime port. The transaction may come from an incompatible TypeGraph version."
49
+ );
50
+ }
51
+ return runtime.runNodeOperationHooks;
52
+ }
53
+
54
+ // src/store/claims/sites.ts
55
+ function disjointnessSites(registry, kind) {
56
+ return registry.getDisjointKinds(kind).map((otherKind) => ({
57
+ axis: chunkCRZ56SZU_cjs.disjointnessClaimAxis(kind, otherKind, registry),
58
+ constraintName: chunkCRZ56SZU_cjs.DISJOINT_CONSTRAINT_NAME,
59
+ needsLockFence: true,
60
+ placement: "pre-insert",
61
+ refusalReason: "nodeDisjointness",
62
+ refusal: { kind: "disjointness", ownKind: kind, otherKind }
63
+ }));
64
+ }
65
+ function nodeClaimSites(registry, kind, uniqueConstraints, operation) {
66
+ const uniqueness = uniqueConstraints.map((constraint) => {
67
+ const target = chunkCRZ56SZU_cjs.uniquenessClaimTarget(kind, constraint.scope, registry);
68
+ return {
69
+ axis: target.axis,
70
+ constraintName: constraint.name,
71
+ needsLockFence: target.crossKind,
72
+ placement: operation !== "create" || target.crossKind ? "pre-insert" : "post-insert",
73
+ refusalReason: target.crossKind ? "nodeUniquenessScope" : "nodeUniquenessClaim",
74
+ refusal: { kind: "uniqueness", constraint }
75
+ };
76
+ });
77
+ return operation === "update" ? uniqueness : [...disjointnessSites(registry, kind), ...uniqueness];
78
+ }
79
+
80
+ // src/store/claims/node-claims.ts
81
+ function createUniquenessContext(graphId, registry, backend, uniqueSidecarBatch) {
82
+ return { graphId, registry, backend, uniqueSidecarBatch };
83
+ }
84
+ function claimKeyFor(refusal, id, props) {
85
+ if (refusal.kind === "disjointness") return id;
86
+ return chunkCRZ56SZU_cjs.checkWherePredicate(refusal.constraint, props) ? chunkCRZ56SZU_cjs.computeUniqueKey(
87
+ props,
88
+ refusal.constraint.fields,
89
+ refusal.constraint.collation
90
+ ) : void 0;
91
+ }
92
+ function nodeClaimEntries(registry, kind, id, props, constraints, operation) {
93
+ return nodeClaimSites(registry, kind, constraints, operation).flatMap(
94
+ (site) => {
95
+ const key = claimKeyFor(site.refusal, id, props);
96
+ return key === void 0 ? [] : [
97
+ {
98
+ axis: site.axis,
99
+ constraintName: site.constraintName,
100
+ key,
101
+ placement: site.placement,
102
+ refusalReason: site.refusalReason,
103
+ refusal: site.refusal
104
+ }
105
+ ];
106
+ }
107
+ );
108
+ }
109
+ function mapClaimRefusal(error, entries) {
110
+ const owed = entries.find(
111
+ (entry) => entry.refusal.kind === "disjointness" && entry.constraintName === error.details.constraintName && entry.key === error.details.newId && (error.details.axis === void 0 || entry.axis === error.details.axis)
112
+ );
113
+ if (owed === void 0) throw error;
114
+ throw new chunkX4GDXBOP_cjs.DisjointError(
115
+ {
116
+ nodeId: error.details.newId,
117
+ attemptedKind: owed.refusal.ownKind,
118
+ conflictingKind: error.details.kind
119
+ },
120
+ { cause: error }
121
+ );
122
+ }
123
+ async function issuingClaims(entries, issue) {
124
+ try {
125
+ await issue();
126
+ } catch (error) {
127
+ if (error instanceof chunkX4GDXBOP_cjs.UniquenessError) mapClaimRefusal(error, entries);
128
+ throw error;
129
+ }
130
+ }
131
+ function claimFenceRefusal(ctx, backend, entries) {
132
+ const gating = entries.find((entry) => entry.placement === "pre-insert");
133
+ if (gating === void 0) return void 0;
134
+ return chunkJQKMEKKW_cjs.constraintFenceRefusal(ctx, backend, gating.refusalReason);
135
+ }
136
+ function isUniquenessClaimEntry(entry) {
137
+ return entry.refusal.kind === "uniqueness";
138
+ }
139
+ async function probeUniqueKey(ctx, kind, id, entry) {
140
+ const mine = { concreteKind: kind, nodeId: id };
141
+ let heldByThisNode = false;
142
+ for (const kindToCheck of chunkCRZ56SZU_cjs.uniquenessProbeKinds(
143
+ kind,
144
+ entry.refusal.constraint.scope,
145
+ ctx.registry
146
+ )) {
147
+ const existing = await ctx.backend.checkUnique({
148
+ graphId: ctx.graphId,
149
+ nodeKind: kindToCheck,
150
+ constraintName: entry.constraintName,
151
+ key: entry.key
152
+ });
153
+ if (existing === void 0) continue;
154
+ if (!chunkCRZ56SZU_cjs.isSameClaimOwner(
155
+ { concreteKind: existing.concrete_kind, nodeId: existing.node_id },
156
+ mine
157
+ )) {
158
+ throw new chunkX4GDXBOP_cjs.UniquenessError({
159
+ constraintName: entry.constraintName,
160
+ kind: existing.concrete_kind,
161
+ existingId: existing.node_id,
162
+ newId: id,
163
+ fields: entry.refusal.constraint.fields
164
+ });
165
+ }
166
+ if (kindToCheck === entry.axis) heldByThisNode = true;
167
+ }
168
+ return heldByThisNode;
169
+ }
170
+ async function checkUniquenessConstraints(ctx, kind, id, props, constraints) {
171
+ for (const entry of nodeClaimEntries(
172
+ ctx.registry,
173
+ kind,
174
+ id,
175
+ props,
176
+ constraints,
177
+ "create"
178
+ )) {
179
+ if (isUniquenessClaimEntry(entry))
180
+ await probeUniqueKey(ctx, kind, id, entry);
181
+ }
182
+ }
183
+ function claimTarget(graphId, entry) {
184
+ return {
185
+ relation: "uniques",
186
+ graphId,
187
+ axis: entry.axis,
188
+ constraintName: entry.constraintName,
189
+ key: entry.key
190
+ };
191
+ }
192
+ function claimInsertParams(graphId, claim) {
193
+ return {
194
+ graphId,
195
+ nodeKind: claim.entry.axis,
196
+ constraintName: claim.entry.constraintName,
197
+ key: claim.entry.key,
198
+ nodeId: claim.item.id,
199
+ concreteKind: claim.item.kind
200
+ };
201
+ }
202
+ async function issueClaimsIndividually(ctx, claims, onIssued) {
203
+ for (const claim of claims) {
204
+ await issuingClaims(
205
+ [claim.entry],
206
+ () => ctx.backend.insertUnique(claimInsertParams(ctx.graphId, claim))
207
+ );
208
+ onIssued?.([claim]);
209
+ }
210
+ }
211
+ async function issueClaimsBatched(ctx, claims, onIssued) {
212
+ if (claims.length === 0) return;
213
+ const bound = chunkNUQ2YFFH_cjs.bindExtraIfReachable(
214
+ ctx.backend,
215
+ ctx.uniqueSidecarBatch.extras.insertUniqueBatch,
216
+ chunkNUQ2YFFH_cjs.UNIQUE_SIDECAR_BATCH.id
217
+ );
218
+ if (bound === void 0) {
219
+ await issueClaimsIndividually(ctx, claims, onIssued);
220
+ return;
221
+ }
222
+ await issuingClaims(
223
+ claims.map((claim) => claim.entry),
224
+ async () => {
225
+ await bound.insertUniqueBatch(
226
+ claims.map((claim) => claimInsertParams(ctx.graphId, claim))
227
+ );
228
+ }
229
+ );
230
+ onIssued?.(claims);
231
+ }
232
+ async function claimGroupThenWrite(ctx, issue, gating, gatedWrite) {
233
+ const issued = [];
234
+ try {
235
+ await issue(ctx, gating, (landed) => {
236
+ issued.push(...landed);
237
+ });
238
+ return await gatedWrite();
239
+ } catch (error) {
240
+ for (const claim of issued.toReversed()) {
241
+ await releaseClaimedUniqueKeys(ctx, claim.item.kind, claim.item.id, [
242
+ {
243
+ axis: claim.entry.axis,
244
+ constraintName: claim.entry.constraintName,
245
+ key: claim.entry.key
246
+ }
247
+ ]);
248
+ }
249
+ throw error;
250
+ }
251
+ }
252
+ async function withNodeCreateClaimsIssuedBy(ctx, items, backend, issue, gatedInsert) {
253
+ const claimContext = createUniquenessContext(
254
+ ctx.graphId,
255
+ ctx.registry,
256
+ backend,
257
+ ctx.uniqueSidecarBatch
258
+ );
259
+ const claims = items.flatMap(
260
+ (item) => nodeClaimEntries(
261
+ ctx.registry,
262
+ item.kind,
263
+ item.id,
264
+ item.props,
265
+ item.constraints,
266
+ "create"
267
+ ).map((entry) => ({
268
+ item,
269
+ entry,
270
+ target: claimTarget(ctx.graphId, entry)
271
+ }))
272
+ );
273
+ const refusal = claimFenceRefusal(
274
+ ctx,
275
+ backend,
276
+ claims.map((claim) => claim.entry)
277
+ );
278
+ if (refusal !== void 0) throw refusal;
279
+ const inPlacement = (placement) => claims.filter((claim) => claim.entry.placement === placement).toSorted(
280
+ (left, right) => chunkCRZ56SZU_cjs.compareClaimTargets(left.target, right.target)
281
+ );
282
+ const result = await claimGroupThenWrite(
283
+ claimContext,
284
+ issue,
285
+ inPlacement("pre-insert"),
286
+ gatedInsert
287
+ );
288
+ await issue(claimContext, inPlacement("post-insert"));
289
+ return result;
290
+ }
291
+ function withNodeCreateClaims(ctx, item, backend, gatedInsert) {
292
+ return withNodeCreateClaimsIssuedBy(
293
+ ctx,
294
+ [item],
295
+ backend,
296
+ issueClaimsIndividually,
297
+ gatedInsert
298
+ );
299
+ }
300
+ function withNodeCreateClaimsBatch(ctx, items, backend, gatedInsert) {
301
+ return withNodeCreateClaimsIssuedBy(
302
+ ctx,
303
+ items,
304
+ backend,
305
+ issueClaimsBatched,
306
+ gatedInsert
307
+ );
308
+ }
309
+ function alreadyAppliedRowWrite() {
310
+ return Promise.resolve(void 0);
311
+ }
312
+ async function deleteUniquenessEntries(ctx, kind, id, props, constraints) {
313
+ await releaseOwnedUniqueKeys(
314
+ ctx,
315
+ kind,
316
+ id,
317
+ nodeClaimEntries(ctx.registry, kind, id, props, constraints, "create")
318
+ );
319
+ }
320
+ async function hardDeleteClaimsByNodeIds(ctx, concreteKind, nodeIds) {
321
+ await chunkN66HCGCY_cjs.requireDefined(
322
+ chunkNUQ2YFFH_cjs.bindExtraIfReachable(
323
+ ctx.backend,
324
+ ctx.uniqueSidecarBatch.extras.hardDeleteUniquesByNodeIds,
325
+ chunkNUQ2YFFH_cjs.UNIQUE_SIDECAR_BATCH.id
326
+ )?.hardDeleteUniquesByNodeIds
327
+ )({
328
+ graphId: ctx.graphId,
329
+ concreteKind,
330
+ nodeIds
331
+ });
332
+ }
333
+ async function planNodeClaimUpdate(ctx, kind, id, oldProps, newProps, constraints) {
334
+ const oldKeys = new Map(
335
+ nodeClaimEntries(
336
+ ctx.registry,
337
+ kind,
338
+ id,
339
+ oldProps,
340
+ constraints,
341
+ "update"
342
+ ).map((entry) => [entry.constraintName, entry.key])
343
+ );
344
+ const newEntries = new Map(
345
+ nodeClaimEntries(ctx.registry, kind, id, newProps, constraints, "update").filter(
346
+ (entry) => isUniquenessClaimEntry(entry)
347
+ ).map((entry) => [entry.constraintName, entry])
348
+ );
349
+ const pending = [];
350
+ for (const constraint of constraints) {
351
+ const oldKey = oldKeys.get(constraint.name);
352
+ const newEntry = newEntries.get(constraint.name);
353
+ if (oldKey === void 0 && newEntry === void 0) continue;
354
+ if (oldKey !== void 0 && oldKey === newEntry?.key) continue;
355
+ const alreadyHeld = newEntry === void 0 ? false : await probeUniqueKey(ctx, kind, id, newEntry);
356
+ pending.push({
357
+ constraintName: constraint.name,
358
+ release: oldKey,
359
+ claim: newEntry === void 0 || alreadyHeld ? void 0 : newEntry
360
+ });
361
+ }
362
+ return pending;
363
+ }
364
+ async function planNodeClaimReinsert(ctx, kind, id, props, constraints) {
365
+ const pending = [];
366
+ for (const entry of nodeClaimEntries(
367
+ ctx.registry,
368
+ kind,
369
+ id,
370
+ props,
371
+ constraints,
372
+ "resurrect"
373
+ )) {
374
+ const alreadyHeld = isUniquenessClaimEntry(entry) ? await probeUniqueKey(ctx, kind, id, entry) : false;
375
+ pending.push({
376
+ constraintName: entry.constraintName,
377
+ release: void 0,
378
+ claim: alreadyHeld ? void 0 : entry
379
+ });
380
+ }
381
+ return pending;
382
+ }
383
+ async function releaseOwnedUniqueKeys(ctx, kind, id, keys) {
384
+ for (const entry of keys) {
385
+ await ctx.backend.deleteUnique({
386
+ graphId: ctx.graphId,
387
+ constraintName: entry.constraintName,
388
+ key: entry.key,
389
+ concreteKind: kind,
390
+ nodeId: id
391
+ });
392
+ }
393
+ }
394
+ async function releaseClaimedUniqueKeys(ctx, kind, id, keys) {
395
+ for (const entry of keys) {
396
+ await ctx.backend.deleteUnique({
397
+ graphId: ctx.graphId,
398
+ nodeKind: entry.axis,
399
+ constraintName: entry.constraintName,
400
+ key: entry.key,
401
+ concreteKind: kind,
402
+ nodeId: id
403
+ });
404
+ }
405
+ }
406
+ async function claimUniqueKeysThen(ctx, kind, id, plan, gatedWrite) {
407
+ const claimed = [];
408
+ try {
409
+ for (const mutation of plan) {
410
+ const claim = mutation.claim;
411
+ if (claim === void 0) continue;
412
+ await issuingClaims(
413
+ [claim],
414
+ () => ctx.backend.insertUnique({
415
+ graphId: ctx.graphId,
416
+ nodeKind: claim.axis,
417
+ constraintName: mutation.constraintName,
418
+ key: claim.key,
419
+ nodeId: id,
420
+ concreteKind: kind
421
+ })
422
+ );
423
+ claimed.push({
424
+ axis: claim.axis,
425
+ constraintName: mutation.constraintName,
426
+ key: claim.key
427
+ });
428
+ }
429
+ return await gatedWrite();
430
+ } catch (error) {
431
+ await releaseClaimedUniqueKeys(ctx, kind, id, claimed);
432
+ throw error;
433
+ }
434
+ }
435
+ async function withNodeClaimTransition(ctx, kind, id, plan, gatedWrite) {
436
+ const refusal = claimFenceRefusal(
437
+ ctx,
438
+ ctx.backend,
439
+ plan.flatMap(
440
+ (mutation) => mutation.claim === void 0 ? [] : [mutation.claim]
441
+ )
442
+ );
443
+ if (refusal !== void 0) throw refusal;
444
+ const result = await claimUniqueKeysThen(ctx, kind, id, plan, gatedWrite);
445
+ await releaseOwnedUniqueKeys(
446
+ ctx,
447
+ kind,
448
+ id,
449
+ plan.flatMap(
450
+ (mutation) => mutation.release === void 0 ? [] : [{ constraintName: mutation.constraintName, key: mutation.release }]
451
+ )
452
+ );
453
+ return result;
454
+ }
455
+
456
+ // src/store/claims/resolved-node-claims.ts
457
+ function claimRowKey(entry) {
458
+ return chunkCRZ56SZU_cjs.encodeTupleKey([entry.constraintName, entry.key]);
459
+ }
460
+ function claimsCompete(left, right) {
461
+ return claimRowKey(left.entry) === claimRowKey(right.entry) && (right.probeKinds.includes(left.entry.axis) || left.probeKinds.includes(right.entry.axis));
462
+ }
463
+ function proposedClaimRefusal(incumbent, challenger) {
464
+ return new chunkX4GDXBOP_cjs.UniquenessError({
465
+ constraintName: challenger.entry.constraintName,
466
+ kind: incumbent.owner.concreteKind,
467
+ existingId: incumbent.owner.nodeId,
468
+ newId: challenger.owner.nodeId,
469
+ fields: challenger.entry.refusal.constraint.fields
470
+ });
471
+ }
472
+ function proposedClaims(ctx, upserts) {
473
+ const accepted = [];
474
+ for (const upsert of upserts) {
475
+ const owner = {
476
+ concreteKind: upsert.kind,
477
+ nodeId: upsert.id
478
+ };
479
+ const entries = nodeClaimEntries(
480
+ ctx.registry,
481
+ upsert.kind,
482
+ upsert.id,
483
+ { ...upsert.props },
484
+ upsert.constraints,
485
+ "create"
486
+ );
487
+ for (const entry of entries) {
488
+ if (!isUniquenessClaimEntry(entry)) continue;
489
+ const proposal = {
490
+ owner,
491
+ entry,
492
+ probeKinds: chunkCRZ56SZU_cjs.uniquenessProbeKinds(
493
+ upsert.kind,
494
+ entry.refusal.constraint.scope,
495
+ ctx.registry
496
+ )
497
+ };
498
+ const incumbent = accepted.find(
499
+ (candidate) => !chunkCRZ56SZU_cjs.isSameClaimOwner(candidate.owner, proposal.owner) && claimsCompete(candidate, proposal)
500
+ );
501
+ if (incumbent !== void 0) {
502
+ throw proposedClaimRefusal(incumbent, proposal);
503
+ }
504
+ accepted.push(proposal);
505
+ }
506
+ }
507
+ return accepted;
508
+ }
509
+ function groupClaimsForProbe(claims) {
510
+ const groups = /* @__PURE__ */ new Map();
511
+ for (const claim of claims) {
512
+ for (const probeKind of claim.probeKinds) {
513
+ const groupKey = chunkCRZ56SZU_cjs.encodeTupleKey([probeKind, claim.entry.constraintName]);
514
+ const existing = groups.get(groupKey);
515
+ if (existing === void 0) {
516
+ groups.set(groupKey, {
517
+ probeKind,
518
+ constraintName: claim.entry.constraintName,
519
+ claimsByKey: /* @__PURE__ */ new Map([[claim.entry.key, claim]])
520
+ });
521
+ continue;
522
+ }
523
+ existing.claimsByKey.set(claim.entry.key, claim);
524
+ }
525
+ }
526
+ return [...groups.values()];
527
+ }
528
+ function requireBatchProbe(ctx) {
529
+ const bound = chunkNUQ2YFFH_cjs.bindExtraIfReachable(
530
+ ctx.backend,
531
+ ctx.uniqueSidecarBatch.extras.checkUniqueBatch,
532
+ chunkNUQ2YFFH_cjs.UNIQUE_SIDECAR_BATCH.id
533
+ );
534
+ if (bound === void 0) {
535
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
536
+ "Resolved node writes require batched uniqueness probes",
537
+ { code: "RESOLVED_NODE_UNIQUENESS_UNSUPPORTED" }
538
+ );
539
+ }
540
+ return bound.checkUniqueBatch;
541
+ }
542
+ async function validateResolvedNodeClaims(ctx, upserts, releases = []) {
543
+ const checkUniqueBatch = requireBatchProbe(ctx);
544
+ const claims = proposedClaims(ctx, upserts);
545
+ if (claims.length === 0) return;
546
+ const affectedOwners = new Set(
547
+ [...upserts, ...releases].map(
548
+ (reference) => chunkCRZ56SZU_cjs.claimOwnerKey({ concreteKind: reference.kind, nodeId: reference.id })
549
+ )
550
+ );
551
+ for (const group of groupClaimsForProbe(claims)) {
552
+ const existingRows = await checkUniqueBatch({
553
+ graphId: ctx.graphId,
554
+ nodeKind: group.probeKind,
555
+ constraintName: group.constraintName,
556
+ keys: [...group.claimsByKey.keys()]
557
+ });
558
+ for (const existing of existingRows) {
559
+ if (affectedOwners.has(
560
+ chunkCRZ56SZU_cjs.claimOwnerKey({
561
+ concreteKind: existing.concrete_kind,
562
+ nodeId: existing.node_id
563
+ })
564
+ )) {
565
+ continue;
566
+ }
567
+ const claim = group.claimsByKey.get(existing.key);
568
+ if (claim === void 0) continue;
569
+ throw new chunkX4GDXBOP_cjs.UniquenessError({
570
+ constraintName: group.constraintName,
571
+ // The holder's own kind, never `group.probeKind`: that is the claim
572
+ // AXIS, which a shared scope folds across kinds and which the caller
573
+ // never wrote. The probe and the fence report the same value.
574
+ kind: existing.concrete_kind,
575
+ existingId: existing.node_id,
576
+ newId: claim.owner.nodeId,
577
+ fields: claim.entry.refusal.constraint.fields
578
+ });
579
+ }
580
+ }
581
+ }
582
+ function resolvedNodeUniquenessOperationsRefusal() {
583
+ return new chunkX4GDXBOP_cjs.ConfigurationError(
584
+ "Resolved node writes require batched uniqueness operations",
585
+ { code: "RESOLVED_NODE_UNIQUENESS_UNSUPPORTED" }
586
+ );
587
+ }
588
+ async function prepareResolvedNodeClaims(ctx, upserts, releases) {
589
+ chunkZGVTNKTX_cjs.requireExtras(
590
+ chunkNUQ2YFFH_cjs.UNIQUE_SIDECAR_BATCH,
591
+ ctx.uniqueSidecarBatch,
592
+ "resolved node write",
593
+ () => {
594
+ throw resolvedNodeUniquenessOperationsRefusal();
595
+ }
596
+ );
597
+ const boundHardDelete = chunkNUQ2YFFH_cjs.bindExtraIfReachable(
598
+ ctx.backend,
599
+ ctx.uniqueSidecarBatch.extras.hardDeleteUniquesByNodeIds,
600
+ chunkNUQ2YFFH_cjs.UNIQUE_SIDECAR_BATCH.id
601
+ );
602
+ if (boundHardDelete === void 0) {
603
+ throw resolvedNodeUniquenessOperationsRefusal();
604
+ }
605
+ const { hardDeleteUniquesByNodeIds } = boundHardDelete;
606
+ if (chunkNUQ2YFFH_cjs.bindExtraIfReachable(
607
+ ctx.backend,
608
+ ctx.uniqueSidecarBatch.extras.insertUniqueBatch,
609
+ chunkNUQ2YFFH_cjs.UNIQUE_SIDECAR_BATCH.id
610
+ ) === void 0) {
611
+ throw resolvedNodeUniquenessOperationsRefusal();
612
+ }
613
+ await validateResolvedNodeClaims(ctx, upserts, releases);
614
+ const idsByKind = /* @__PURE__ */ new Map();
615
+ for (const reference of [...upserts, ...releases]) {
616
+ const ids = idsByKind.get(reference.kind) ?? /* @__PURE__ */ new Set();
617
+ ids.add(reference.id);
618
+ idsByKind.set(reference.kind, ids);
619
+ }
620
+ for (const [concreteKind, nodeIds] of idsByKind) {
621
+ await hardDeleteUniquesByNodeIds({
622
+ graphId: ctx.graphId,
623
+ concreteKind,
624
+ nodeIds: [...nodeIds]
625
+ });
626
+ }
627
+ }
628
+ async function applyResolvedNodeClaims(ctx, backend, upserts, releases, apply) {
629
+ const claimContext = {
630
+ graphId: ctx.graphId,
631
+ registry: ctx.registry,
632
+ backend,
633
+ uniqueSidecarBatch: ctx.uniqueSidecarBatch
634
+ };
635
+ await prepareResolvedNodeClaims(claimContext, upserts, releases);
636
+ const result = await apply();
637
+ await withNodeCreateClaimsBatch(
638
+ ctx,
639
+ upserts.map((upsert) => ({
640
+ kind: upsert.kind,
641
+ id: upsert.id,
642
+ props: { ...upsert.props },
643
+ constraints: upsert.constraints
644
+ })),
645
+ backend,
646
+ alreadyAppliedRowWrite
647
+ );
648
+ return result;
649
+ }
650
+
651
+ // src/store/embedding-sync.ts
652
+ var embeddingFieldsCache = /* @__PURE__ */ new WeakMap();
653
+ function getEmbeddingFields(schema) {
654
+ const cached = embeddingFieldsCache.get(schema);
655
+ if (cached) return cached;
656
+ const fields = chunkHAHNRASW_cjs.resolveEmbeddingFields(schema);
657
+ embeddingFieldsCache.set(schema, fields);
658
+ return fields;
659
+ }
660
+ async function syncEmbeddings(ctx, schema, props) {
661
+ const { backend } = ctx;
662
+ if (!backend.upsertEmbedding || !backend.deleteEmbedding) {
663
+ return;
664
+ }
665
+ const embeddingFields = getEmbeddingFields(schema);
666
+ if (embeddingFields.length === 0) {
667
+ return;
668
+ }
669
+ for (const field of embeddingFields) {
670
+ const value = chunkN66HCGCY_cjs.readOwnProperty(props, field.fieldPath);
671
+ if (isValidEmbeddingValue(value)) {
672
+ await backend.upsertEmbedding({
673
+ graphId: ctx.graphId,
674
+ nodeKind: ctx.nodeKind,
675
+ nodeId: ctx.nodeId,
676
+ fieldPath: field.fieldPath,
677
+ embedding: value,
678
+ dimensions: field.dimensions,
679
+ metric: field.metric,
680
+ indexType: field.indexType
681
+ });
682
+ } else if (value === void 0) {
683
+ await backend.deleteEmbedding({
684
+ graphId: ctx.graphId,
685
+ nodeKind: ctx.nodeKind,
686
+ nodeId: ctx.nodeId,
687
+ fieldPath: field.fieldPath,
688
+ dimensions: field.dimensions,
689
+ metric: field.metric,
690
+ indexType: field.indexType
691
+ });
692
+ }
693
+ }
694
+ }
695
+ async function syncEmbeddingsBatchForKind(args, schema, items) {
696
+ const { graphId, nodeKind, backend } = args;
697
+ if (!backend.upsertEmbedding || !backend.deleteEmbedding) {
698
+ return;
699
+ }
700
+ const embeddingFields = getEmbeddingFields(schema);
701
+ if (embeddingFields.length === 0) {
702
+ return;
703
+ }
704
+ for (const field of embeddingFields) {
705
+ const rows = [];
706
+ const deletionIds = [];
707
+ for (const item of items) {
708
+ const value = chunkN66HCGCY_cjs.readOwnProperty(item.props, field.fieldPath);
709
+ if (isValidEmbeddingValue(value)) {
710
+ rows.push({ nodeId: item.nodeId, embedding: value });
711
+ } else if (value === void 0) {
712
+ deletionIds.push(item.nodeId);
713
+ }
714
+ }
715
+ if (rows.length > 0) {
716
+ if (backend.upsertEmbeddingBatch === void 0) {
717
+ for (const row of rows) {
718
+ await backend.upsertEmbedding({
719
+ graphId,
720
+ nodeKind,
721
+ nodeId: row.nodeId,
722
+ fieldPath: field.fieldPath,
723
+ embedding: row.embedding,
724
+ dimensions: field.dimensions,
725
+ metric: field.metric,
726
+ indexType: field.indexType
727
+ });
728
+ }
729
+ } else {
730
+ await backend.upsertEmbeddingBatch({
731
+ graphId,
732
+ nodeKind,
733
+ fieldPath: field.fieldPath,
734
+ dimensions: field.dimensions,
735
+ metric: field.metric,
736
+ indexType: field.indexType,
737
+ rows
738
+ });
739
+ }
740
+ }
741
+ if (deletionIds.length > 0 && backend.deleteEmbeddingBatch !== void 0) {
742
+ await backend.deleteEmbeddingBatch({
743
+ graphId,
744
+ nodeKind,
745
+ nodeIds: deletionIds,
746
+ fieldPath: field.fieldPath,
747
+ dimensions: field.dimensions,
748
+ metric: field.metric,
749
+ indexType: field.indexType
750
+ });
751
+ } else {
752
+ for (const nodeId of deletionIds) {
753
+ await backend.deleteEmbedding({
754
+ graphId,
755
+ nodeKind,
756
+ nodeId,
757
+ fieldPath: field.fieldPath,
758
+ dimensions: field.dimensions,
759
+ metric: field.metric,
760
+ indexType: field.indexType
761
+ });
762
+ }
763
+ }
764
+ }
765
+ }
766
+ async function deleteNodeEmbeddings(ctx, schema) {
767
+ const { backend } = ctx;
768
+ if (!backend.deleteEmbedding) {
769
+ return;
770
+ }
771
+ const embeddingFields = getEmbeddingFields(schema);
772
+ if (embeddingFields.length === 0) {
773
+ return;
774
+ }
775
+ for (const field of embeddingFields) {
776
+ await backend.deleteEmbedding({
777
+ graphId: ctx.graphId,
778
+ nodeKind: ctx.nodeKind,
779
+ nodeId: ctx.nodeId,
780
+ fieldPath: field.fieldPath,
781
+ dimensions: field.dimensions,
782
+ metric: field.metric,
783
+ indexType: field.indexType
784
+ });
785
+ }
786
+ }
787
+ function isValidEmbeddingValue(value) {
788
+ if (!Array.isArray(value)) {
789
+ return false;
790
+ }
791
+ return value.every((n) => typeof n === "number" && Number.isFinite(n));
792
+ }
793
+
794
+ // src/store/fulltext-sync.ts
795
+ var FIELD_SEPARATOR = "\n";
796
+ function resolveCombinedLanguage(fields) {
797
+ return fields[0]?.metadata.language ?? chunkHAHNRASW_cjs.DEFAULT_SEARCHABLE_LANGUAGE;
798
+ }
799
+ function computeFulltextContent(schema, props) {
800
+ const searchableFields = chunkHAHNRASW_cjs.getSearchableFields(schema);
801
+ if (searchableFields.length === 0) return void 0;
802
+ const parts = [];
803
+ for (const field of searchableFields) {
804
+ const value = chunkN66HCGCY_cjs.readOwnProperty(props, field.fieldPath);
805
+ if (typeof value === "string" && value.length > 0) {
806
+ parts.push(value);
807
+ }
808
+ }
809
+ if (parts.length === 0) return void 0;
810
+ return {
811
+ content: parts.join(FIELD_SEPARATOR),
812
+ language: resolveCombinedLanguage(searchableFields)
813
+ };
814
+ }
815
+ async function syncFulltext(ctx, schema, props) {
816
+ const { backend } = ctx;
817
+ if (!backend.upsertFulltext || !backend.deleteFulltext) {
818
+ return;
819
+ }
820
+ const computed = computeFulltextContent(schema, props);
821
+ if (computed !== void 0) {
822
+ await backend.upsertFulltext({
823
+ graphId: ctx.graphId,
824
+ nodeKind: ctx.nodeKind,
825
+ nodeId: ctx.nodeId,
826
+ content: computed.content,
827
+ language: computed.language
828
+ });
829
+ return;
830
+ }
831
+ if (chunkHAHNRASW_cjs.getSearchableFields(schema).length === 0) return;
832
+ await backend.deleteFulltext({
833
+ graphId: ctx.graphId,
834
+ nodeKind: ctx.nodeKind,
835
+ nodeId: ctx.nodeId
836
+ });
837
+ }
838
+ async function syncFulltextBatchForKind(args, schema, items) {
839
+ const { graphId, nodeKind, backend } = args;
840
+ if (!backend.upsertFulltext || !backend.deleteFulltext) {
841
+ return;
842
+ }
843
+ const rows = [];
844
+ const emptyContentIds = [];
845
+ const hasSearchableFields = chunkHAHNRASW_cjs.getSearchableFields(schema).length > 0;
846
+ for (const item of items) {
847
+ const computed = computeFulltextContent(schema, item.props);
848
+ if (computed !== void 0) {
849
+ rows.push({
850
+ nodeId: item.nodeId,
851
+ content: computed.content,
852
+ language: computed.language
853
+ });
854
+ } else if (hasSearchableFields) {
855
+ emptyContentIds.push(item.nodeId);
856
+ }
857
+ }
858
+ if (rows.length > 0) {
859
+ if (backend.upsertFulltextBatch === void 0) {
860
+ for (const row of rows) {
861
+ await backend.upsertFulltext({
862
+ graphId,
863
+ nodeKind,
864
+ nodeId: row.nodeId,
865
+ content: row.content,
866
+ language: row.language
867
+ });
868
+ }
869
+ } else {
870
+ await backend.upsertFulltextBatch({ graphId, nodeKind, rows });
871
+ }
872
+ }
873
+ if (emptyContentIds.length > 0) {
874
+ if (backend.deleteFulltextBatch === void 0) {
875
+ for (const nodeId of emptyContentIds) {
876
+ await backend.deleteFulltext({ graphId, nodeKind, nodeId });
877
+ }
878
+ } else {
879
+ await backend.deleteFulltextBatch({
880
+ graphId,
881
+ nodeKind,
882
+ nodeIds: emptyContentIds
883
+ });
884
+ }
885
+ }
886
+ }
887
+ async function deleteNodeFulltext(ctx, schema) {
888
+ const { backend } = ctx;
889
+ if (!backend.deleteFulltext) {
890
+ return;
891
+ }
892
+ if (chunkHAHNRASW_cjs.getSearchableFields(schema).length === 0) {
893
+ return;
894
+ }
895
+ await backend.deleteFulltext({
896
+ graphId: ctx.graphId,
897
+ nodeKind: ctx.nodeKind,
898
+ nodeId: ctx.nodeId
899
+ });
900
+ }
901
+
902
+ // src/store/operations/node-write-pipeline.ts
903
+ function createNodeWriteContext(graphId, registry, lock, claimsVerdict, uniqueSidecarBatch) {
904
+ return { graphId, registry, lock, claimsVerdict, uniqueSidecarBatch };
905
+ }
906
+ function uniquenessContext(ctx, backend) {
907
+ return createUniquenessContext(
908
+ ctx.graphId,
909
+ ctx.registry,
910
+ backend,
911
+ ctx.uniqueSidecarBatch
912
+ );
913
+ }
914
+ function nodeSyncContext(ctx, kind, id, backend) {
915
+ return { graphId: ctx.graphId, nodeKind: kind, nodeId: id, backend };
916
+ }
917
+ async function enforceNodeDeleteBehavior(ctx, args, backend, policy) {
918
+ if (policy?.enforceDeleteBehavior === false) return;
919
+ const behavior = args.onDelete ?? "restrict";
920
+ const connectedEdges = await backend.findEdgesConnectedTo({
921
+ graphId: ctx.graphId,
922
+ nodeKind: args.kind,
923
+ nodeId: args.id
924
+ });
925
+ if (connectedEdges.length === 0) return;
926
+ switch (behavior) {
927
+ case "restrict": {
928
+ throw new chunkX4GDXBOP_cjs.RestrictedDeleteError({
929
+ nodeKind: args.kind,
930
+ nodeId: args.id,
931
+ edgeCount: connectedEdges.length,
932
+ edgeKinds: [...new Set(connectedEdges.map((edge) => edge.kind))]
933
+ });
934
+ }
935
+ case "cascade":
936
+ case "disconnect": {
937
+ const connectedEdgeIds = connectedEdges.map((edge) => edge.id);
938
+ const batchDelete = args.mode === "hard" ? backend.hardDeleteEdgesBatch : backend.deleteEdgesBatch;
939
+ if (batchDelete === void 0) {
940
+ for (const edge of connectedEdges) {
941
+ await (args.mode === "hard" ? backend.hardDeleteEdge({ graphId: ctx.graphId, id: edge.id }) : backend.deleteEdge({ graphId: ctx.graphId, id: edge.id }));
942
+ }
943
+ } else {
944
+ await batchDelete({
945
+ graphId: ctx.graphId,
946
+ ids: connectedEdgeIds
947
+ });
948
+ }
949
+ if (args.mode === "hard") {
950
+ await chunkFMMW3KX7_cjs.purgeEdgeClaims(
951
+ backend,
952
+ ctx.claimsVerdict(),
953
+ ctx.graphId,
954
+ connectedEdgeIds
955
+ );
956
+ }
957
+ break;
958
+ }
959
+ }
960
+ }
961
+ async function applyNodeInsertSyncFans(ctx, args, backend) {
962
+ await Promise.all([
963
+ syncEmbeddings(
964
+ nodeSyncContext(ctx, args.kind, args.id, backend),
965
+ args.schema,
966
+ args.props
967
+ ),
968
+ syncFulltext(
969
+ nodeSyncContext(ctx, args.kind, args.id, backend),
970
+ args.schema,
971
+ args.props
972
+ )
973
+ ]);
974
+ }
975
+ async function applyNodeInsertSyncFansBatch(ctx, items, backend) {
976
+ if (items.length === 0) return;
977
+ const byKind = /* @__PURE__ */ new Map();
978
+ for (const item of items) {
979
+ const group = byKind.get(item.kind) ?? { schema: item.schema, rows: [] };
980
+ group.rows.push({ nodeId: item.id, props: item.props });
981
+ byKind.set(item.kind, group);
982
+ }
983
+ await Promise.all(
984
+ [...byKind.entries()].flatMap(([kind, group]) => {
985
+ const syncArguments = { graphId: ctx.graphId, nodeKind: kind, backend };
986
+ return [
987
+ syncEmbeddingsBatchForKind(syncArguments, group.schema, group.rows),
988
+ syncFulltextBatchForKind(syncArguments, group.schema, group.rows)
989
+ ];
990
+ })
991
+ );
992
+ }
993
+ function parseRowProps(row) {
994
+ return chunkNUQ2YFFH_cjs.rowPropsToObject(row.props);
995
+ }
996
+ async function planNodeUpdateUniqueness(ctx, args, backend) {
997
+ const { kind, id } = args.existing;
998
+ if (args.existing.deleted_at !== void 0) {
999
+ return planNodeClaimReinsert(
1000
+ uniquenessContext(ctx, backend),
1001
+ kind,
1002
+ id,
1003
+ args.validatedProps,
1004
+ args.uniqueConstraints
1005
+ );
1006
+ }
1007
+ return planNodeClaimUpdate(
1008
+ uniquenessContext(ctx, backend),
1009
+ kind,
1010
+ id,
1011
+ parseRowProps(args.existing),
1012
+ args.validatedProps,
1013
+ args.uniqueConstraints
1014
+ );
1015
+ }
1016
+ async function applyNodeUpdate(ctx, args, backend) {
1017
+ const { kind, id } = args.existing;
1018
+ const plan = await planNodeUpdateUniqueness(
1019
+ ctx,
1020
+ {
1021
+ existing: args.existing,
1022
+ validatedProps: args.validatedProps,
1023
+ uniqueConstraints: args.uniqueConstraints
1024
+ },
1025
+ backend
1026
+ );
1027
+ const updateParams = {
1028
+ graphId: ctx.graphId,
1029
+ kind,
1030
+ id,
1031
+ props: args.validatedProps,
1032
+ incrementVersion: true
1033
+ };
1034
+ if (args.validFrom !== void 0) updateParams.validFrom = args.validFrom;
1035
+ if (chunkM5MSP3BI_cjs.assertsStoredLowerBound(args)) {
1036
+ updateParams.expectedValidFrom = args.expectedValidFrom;
1037
+ }
1038
+ if (args.clearDeleted) updateParams.clearDeleted = true;
1039
+ const row = await withNodeClaimTransition(
1040
+ uniquenessContext(ctx, backend),
1041
+ kind,
1042
+ id,
1043
+ plan,
1044
+ () => backend.updateNode({
1045
+ ...updateParams,
1046
+ ...args.clearValidTo === true ? { clearValidTo: true } : args.validTo === void 0 ? {} : { validTo: args.validTo }
1047
+ })
1048
+ );
1049
+ await Promise.all([
1050
+ syncEmbeddings(
1051
+ nodeSyncContext(ctx, kind, id, backend),
1052
+ args.schema,
1053
+ args.validatedProps
1054
+ ),
1055
+ syncFulltext(
1056
+ nodeSyncContext(ctx, kind, id, backend),
1057
+ args.schema,
1058
+ args.validatedProps
1059
+ )
1060
+ ]);
1061
+ return row;
1062
+ }
1063
+ async function applyNodeSoftDelete(ctx, args, backend, policy) {
1064
+ const { kind, id } = args.existing;
1065
+ await enforceNodeDeleteBehavior(
1066
+ ctx,
1067
+ { kind, id, mode: "soft", onDelete: args.onDelete },
1068
+ backend,
1069
+ policy
1070
+ );
1071
+ await backend.deleteNode({
1072
+ graphId: ctx.graphId,
1073
+ kind,
1074
+ id
1075
+ });
1076
+ await deleteUniquenessEntries(
1077
+ uniquenessContext(ctx, backend),
1078
+ kind,
1079
+ id,
1080
+ parseRowProps(args.existing),
1081
+ args.uniqueConstraints
1082
+ );
1083
+ await deleteNodeEmbeddings(
1084
+ nodeSyncContext(ctx, kind, id, backend),
1085
+ args.schema
1086
+ );
1087
+ await deleteNodeFulltext(
1088
+ nodeSyncContext(ctx, kind, id, backend),
1089
+ args.schema
1090
+ );
1091
+ }
1092
+ async function applyNodeHardDelete(ctx, args, backend) {
1093
+ await enforceNodeDeleteBehavior(
1094
+ ctx,
1095
+ { kind: args.kind, id: args.id, mode: "hard", onDelete: args.onDelete },
1096
+ backend
1097
+ );
1098
+ await backend.hardDeleteNode({
1099
+ graphId: ctx.graphId,
1100
+ kind: args.kind,
1101
+ id: args.id
1102
+ });
1103
+ await deleteNodeEmbeddings(
1104
+ nodeSyncContext(ctx, args.kind, args.id, backend),
1105
+ args.schema
1106
+ );
1107
+ }
1108
+ async function applyNodeResurrect(ctx, args, backend) {
1109
+ const { kind, id } = args.existing;
1110
+ const props = parseRowProps(args.existing);
1111
+ const plan = await planNodeClaimReinsert(
1112
+ uniquenessContext(ctx, backend),
1113
+ kind,
1114
+ id,
1115
+ props,
1116
+ args.uniqueConstraints
1117
+ );
1118
+ const row = await withNodeClaimTransition(
1119
+ uniquenessContext(ctx, backend),
1120
+ kind,
1121
+ id,
1122
+ plan,
1123
+ () => backend.updateNode({
1124
+ graphId: ctx.graphId,
1125
+ kind,
1126
+ id,
1127
+ props,
1128
+ incrementVersion: true,
1129
+ clearDeleted: true
1130
+ })
1131
+ );
1132
+ await Promise.all([
1133
+ syncEmbeddings(nodeSyncContext(ctx, kind, id, backend), args.schema, props),
1134
+ syncFulltext(nodeSyncContext(ctx, kind, id, backend), args.schema, props)
1135
+ ]);
1136
+ return row;
1137
+ }
1138
+ async function applyNodeSetUpdate(ctx, args, backend) {
1139
+ const { kind, schema, uniqueConstraints } = args;
1140
+ const updateNodeSet = backend.updateNodeSet;
1141
+ if (updateNodeSet === void 0) {
1142
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
1143
+ "The transaction backend does not support set-based node updates",
1144
+ { code: "SET_UPDATE_UNSUPPORTED", kind }
1145
+ );
1146
+ }
1147
+ if (uniqueConstraints.length > 0 && chunkZGVTNKTX_cjs.missingRequiredExtras(
1148
+ chunkNUQ2YFFH_cjs.UNIQUE_SIDECAR_BATCH,
1149
+ ctx.uniqueSidecarBatch,
1150
+ "set-based node update"
1151
+ ).length > 0) {
1152
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
1153
+ "The transaction backend lacks batched uniqueness operations",
1154
+ { code: "SET_UPDATE_UNIQUENESS_UNSUPPORTED", kind }
1155
+ );
1156
+ }
1157
+ if (chunkHAHNRASW_cjs.getSearchableFields(schema).length > 0 && (backend.upsertFulltext === void 0 || backend.deleteFulltext === void 0 || backend.upsertFulltextBatch === void 0 || backend.deleteFulltextBatch === void 0)) {
1158
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
1159
+ "The transaction backend lacks batched fulltext operations",
1160
+ { code: "SET_UPDATE_FULLTEXT_UNSUPPORTED", kind }
1161
+ );
1162
+ }
1163
+ if (getEmbeddingFields(schema).length > 0 && (backend.upsertEmbedding === void 0 || backend.deleteEmbedding === void 0 || backend.upsertEmbeddingBatch === void 0 || backend.deleteEmbeddingBatch === void 0)) {
1164
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
1165
+ "The transaction backend lacks batched vector operations",
1166
+ { code: "SET_UPDATE_VECTOR_UNSUPPORTED", kind }
1167
+ );
1168
+ }
1169
+ const result = await updateNodeSet({
1170
+ graphId: ctx.graphId,
1171
+ kind,
1172
+ patch: args.patch,
1173
+ unsetProperties: args.unsetProperties,
1174
+ candidateIds: args.candidateIds,
1175
+ candidateIdColumn: args.candidateIdColumn
1176
+ });
1177
+ if (result.affectedCount === 0) return { affectedCount: 0 };
1178
+ const sidecarItems = result.rows.map((row) => {
1179
+ const props = chunkNUQ2YFFH_cjs.rowPropsToObject(row.props);
1180
+ const validatedProps = chunkJQKMEKKW_cjs.validateNodeProps(schema, props, {
1181
+ kind,
1182
+ operation: "update",
1183
+ id: row.id
1184
+ });
1185
+ if (!chunkNLX5OWK7_cjs.canonicalEqual(validatedProps, props)) {
1186
+ throw new chunkX4GDXBOP_cjs.ValidationError(
1187
+ `Set update would persist a non-canonical ${kind} row`,
1188
+ {
1189
+ entityType: "node",
1190
+ kind,
1191
+ operation: "update",
1192
+ id: row.id,
1193
+ issues: [
1194
+ {
1195
+ path: "props",
1196
+ message: "The complete row requires schema normalization"
1197
+ }
1198
+ ]
1199
+ }
1200
+ );
1201
+ }
1202
+ return {
1203
+ kind,
1204
+ id: row.id,
1205
+ schema,
1206
+ props: validatedProps,
1207
+ uniqueConstraints
1208
+ };
1209
+ });
1210
+ const claimItems = sidecarItems.map((item) => ({
1211
+ kind: item.kind,
1212
+ id: item.id,
1213
+ props: item.props,
1214
+ constraints: item.uniqueConstraints
1215
+ }));
1216
+ if (uniqueConstraints.length > 0) {
1217
+ if (chunkNUQ2YFFH_cjs.bindExtraIfReachable(
1218
+ backend,
1219
+ ctx.uniqueSidecarBatch.extras.insertUniqueBatch,
1220
+ chunkNUQ2YFFH_cjs.UNIQUE_SIDECAR_BATCH.id
1221
+ ) === void 0) {
1222
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
1223
+ "The transaction backend lacks batched uniqueness operations",
1224
+ { code: "SET_UPDATE_UNIQUENESS_UNSUPPORTED", kind }
1225
+ );
1226
+ }
1227
+ await validateResolvedNodeClaims(
1228
+ createUniquenessContext(
1229
+ ctx.graphId,
1230
+ ctx.registry,
1231
+ backend,
1232
+ ctx.uniqueSidecarBatch
1233
+ ),
1234
+ claimItems,
1235
+ []
1236
+ );
1237
+ await hardDeleteClaimsByNodeIds(
1238
+ uniquenessContext(ctx, backend),
1239
+ kind,
1240
+ result.rows.map((row) => row.id)
1241
+ );
1242
+ }
1243
+ await withNodeCreateClaimsBatch(
1244
+ ctx,
1245
+ claimItems,
1246
+ backend,
1247
+ alreadyAppliedRowWrite
1248
+ );
1249
+ await applyNodeInsertSyncFansBatch(ctx, sidecarItems, backend);
1250
+ return { affectedCount: result.affectedCount };
1251
+ }
1252
+
1253
+ exports.AUTO_REFRESH_STATISTICS_ROW_THRESHOLD = AUTO_REFRESH_STATISTICS_ROW_THRESHOLD;
1254
+ exports.STORE_RUNTIME = STORE_RUNTIME;
1255
+ exports.TRANSACTION_RUNTIME = TRANSACTION_RUNTIME;
1256
+ exports.applyNodeHardDelete = applyNodeHardDelete;
1257
+ exports.applyNodeInsertSyncFans = applyNodeInsertSyncFans;
1258
+ exports.applyNodeInsertSyncFansBatch = applyNodeInsertSyncFansBatch;
1259
+ exports.applyNodeResurrect = applyNodeResurrect;
1260
+ exports.applyNodeSetUpdate = applyNodeSetUpdate;
1261
+ exports.applyNodeSoftDelete = applyNodeSoftDelete;
1262
+ exports.applyNodeUpdate = applyNodeUpdate;
1263
+ exports.applyResolvedNodeClaims = applyResolvedNodeClaims;
1264
+ exports.checkUniquenessConstraints = checkUniquenessConstraints;
1265
+ exports.computeFulltextContent = computeFulltextContent;
1266
+ exports.createNodeWriteContext = createNodeWriteContext;
1267
+ exports.createUniquenessContext = createUniquenessContext;
1268
+ exports.getEmbeddingFields = getEmbeddingFields;
1269
+ exports.nodeClaimEntries = nodeClaimEntries;
1270
+ exports.nodeClaimSites = nodeClaimSites;
1271
+ exports.storeBackend = storeBackend;
1272
+ exports.storeRuntime = storeRuntime;
1273
+ exports.transactionBackend = transactionBackend;
1274
+ exports.transactionNodeOperationHookRunner = transactionNodeOperationHookRunner;
1275
+ exports.withNodeCreateClaims = withNodeCreateClaims;
1276
+ exports.withNodeCreateClaimsBatch = withNodeCreateClaimsBatch;
1277
+ //# sourceMappingURL=chunk-2CVDZCXH.cjs.map
1278
+ //# sourceMappingURL=chunk-2CVDZCXH.cjs.map