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