@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
@@ -1,913 +0,0 @@
1
- import { encodeTupleKey } from './chunk-S5TERQVW.js';
2
- import { rowPropsToObject } from './chunk-6LN7FIVU.js';
3
- import { checkWherePredicate, computeUniqueKey, getKindsForUniquenessCheck } from './chunk-GLHXM7C4.js';
4
- import { typeGraphGlobalSymbol } from './chunk-3DMMGT6S.js';
5
- import { resolveEmbeddingFields, getSearchableFields, DEFAULT_SEARCHABLE_LANGUAGE } from './chunk-PC2UBAUB.js';
6
- import { ConfigurationError, UniquenessError, RestrictedDeleteError } from './chunk-ZLONH2UD.js';
7
- import { readOwnProperty } from './chunk-DYATYRY4.js';
8
-
9
- // src/store/types.ts
10
- var AUTO_REFRESH_STATISTICS_ROW_THRESHOLD = 1e3;
11
- var TRANSACTION_RUNTIME = typeGraphGlobalSymbol(
12
- "transaction-runtime-v1"
13
- );
14
-
15
- // src/store/runtime-port.ts
16
- var STORE_RUNTIME = typeGraphGlobalSymbol("store-runtime-v1");
17
- function storeRuntime(store) {
18
- const runtime = store[STORE_RUNTIME];
19
- if (runtime === void 0) {
20
- throw new TypeError(
21
- "Cannot access this Store's runtime port. The Store may come from an incompatible TypeGraph version."
22
- );
23
- }
24
- return runtime;
25
- }
26
- function storeBackend(store) {
27
- return storeRuntime(store).backend;
28
- }
29
- function transactionBackend(transaction) {
30
- const runtime = transaction[TRANSACTION_RUNTIME];
31
- if (runtime === void 0) {
32
- throw new TypeError(
33
- "Cannot access this transaction's runtime port. The transaction may come from an incompatible TypeGraph version."
34
- );
35
- }
36
- return runtime.backend;
37
- }
38
- function transactionNodeOperationHookRunner(transaction) {
39
- const runtime = transaction[TRANSACTION_RUNTIME];
40
- if (runtime === void 0) {
41
- throw new TypeError(
42
- "Cannot access this transaction's runtime port. The transaction may come from an incompatible TypeGraph version."
43
- );
44
- }
45
- return runtime.runNodeOperationHooks;
46
- }
47
-
48
- // src/store/embedding-sync.ts
49
- var embeddingFieldsCache = /* @__PURE__ */ new WeakMap();
50
- function getEmbeddingFields(schema) {
51
- const cached = embeddingFieldsCache.get(schema);
52
- if (cached) return cached;
53
- const fields = resolveEmbeddingFields(schema);
54
- embeddingFieldsCache.set(schema, fields);
55
- return fields;
56
- }
57
- async function syncEmbeddings(ctx, schema, props) {
58
- const { backend } = ctx;
59
- if (!backend.upsertEmbedding || !backend.deleteEmbedding) {
60
- return;
61
- }
62
- const embeddingFields = getEmbeddingFields(schema);
63
- if (embeddingFields.length === 0) {
64
- return;
65
- }
66
- for (const field of embeddingFields) {
67
- const value = readOwnProperty(props, field.fieldPath);
68
- if (isValidEmbeddingValue(value)) {
69
- await backend.upsertEmbedding({
70
- graphId: ctx.graphId,
71
- nodeKind: ctx.nodeKind,
72
- nodeId: ctx.nodeId,
73
- fieldPath: field.fieldPath,
74
- embedding: value,
75
- dimensions: field.dimensions,
76
- metric: field.metric,
77
- indexType: field.indexType
78
- });
79
- } else if (value === void 0) {
80
- await backend.deleteEmbedding({
81
- graphId: ctx.graphId,
82
- nodeKind: ctx.nodeKind,
83
- nodeId: ctx.nodeId,
84
- fieldPath: field.fieldPath,
85
- dimensions: field.dimensions,
86
- metric: field.metric,
87
- indexType: field.indexType
88
- });
89
- }
90
- }
91
- }
92
- async function syncEmbeddingsBatchForKind(args, schema, items) {
93
- const { graphId, nodeKind, backend } = args;
94
- if (!backend.upsertEmbedding || !backend.deleteEmbedding) {
95
- return;
96
- }
97
- const embeddingFields = getEmbeddingFields(schema);
98
- if (embeddingFields.length === 0) {
99
- return;
100
- }
101
- for (const field of embeddingFields) {
102
- const rows = [];
103
- const deletionIds = [];
104
- for (const item of items) {
105
- const value = readOwnProperty(item.props, field.fieldPath);
106
- if (isValidEmbeddingValue(value)) {
107
- rows.push({ nodeId: item.nodeId, embedding: value });
108
- } else if (value === void 0) {
109
- deletionIds.push(item.nodeId);
110
- }
111
- }
112
- if (rows.length > 0) {
113
- if (backend.upsertEmbeddingBatch === void 0) {
114
- for (const row of rows) {
115
- await backend.upsertEmbedding({
116
- graphId,
117
- nodeKind,
118
- nodeId: row.nodeId,
119
- fieldPath: field.fieldPath,
120
- embedding: row.embedding,
121
- dimensions: field.dimensions,
122
- metric: field.metric,
123
- indexType: field.indexType
124
- });
125
- }
126
- } else {
127
- await backend.upsertEmbeddingBatch({
128
- graphId,
129
- nodeKind,
130
- fieldPath: field.fieldPath,
131
- dimensions: field.dimensions,
132
- metric: field.metric,
133
- indexType: field.indexType,
134
- rows
135
- });
136
- }
137
- }
138
- if (deletionIds.length > 0 && backend.deleteEmbeddingBatch !== void 0) {
139
- await backend.deleteEmbeddingBatch({
140
- graphId,
141
- nodeKind,
142
- nodeIds: deletionIds,
143
- fieldPath: field.fieldPath,
144
- dimensions: field.dimensions,
145
- metric: field.metric,
146
- indexType: field.indexType
147
- });
148
- } else {
149
- for (const nodeId of deletionIds) {
150
- await backend.deleteEmbedding({
151
- graphId,
152
- nodeKind,
153
- nodeId,
154
- fieldPath: field.fieldPath,
155
- dimensions: field.dimensions,
156
- metric: field.metric,
157
- indexType: field.indexType
158
- });
159
- }
160
- }
161
- }
162
- }
163
- async function deleteNodeEmbeddings(ctx, schema) {
164
- const { backend } = ctx;
165
- if (!backend.deleteEmbedding) {
166
- return;
167
- }
168
- const embeddingFields = getEmbeddingFields(schema);
169
- if (embeddingFields.length === 0) {
170
- return;
171
- }
172
- for (const field of embeddingFields) {
173
- await backend.deleteEmbedding({
174
- graphId: ctx.graphId,
175
- nodeKind: ctx.nodeKind,
176
- nodeId: ctx.nodeId,
177
- fieldPath: field.fieldPath,
178
- dimensions: field.dimensions,
179
- metric: field.metric,
180
- indexType: field.indexType
181
- });
182
- }
183
- }
184
- function isValidEmbeddingValue(value) {
185
- if (!Array.isArray(value)) {
186
- return false;
187
- }
188
- return value.every((n) => typeof n === "number" && Number.isFinite(n));
189
- }
190
-
191
- // src/store/fulltext-sync.ts
192
- var FIELD_SEPARATOR = "\n";
193
- function resolveCombinedLanguage(fields) {
194
- return fields[0]?.metadata.language ?? DEFAULT_SEARCHABLE_LANGUAGE;
195
- }
196
- function computeFulltextContent(schema, props) {
197
- const searchableFields = getSearchableFields(schema);
198
- if (searchableFields.length === 0) return void 0;
199
- const parts = [];
200
- for (const field of searchableFields) {
201
- const value = readOwnProperty(props, field.fieldPath);
202
- if (typeof value === "string" && value.length > 0) {
203
- parts.push(value);
204
- }
205
- }
206
- if (parts.length === 0) return void 0;
207
- return {
208
- content: parts.join(FIELD_SEPARATOR),
209
- language: resolveCombinedLanguage(searchableFields)
210
- };
211
- }
212
- async function syncFulltext(ctx, schema, props) {
213
- const { backend } = ctx;
214
- if (!backend.upsertFulltext || !backend.deleteFulltext) {
215
- return;
216
- }
217
- const computed = computeFulltextContent(schema, props);
218
- if (computed !== void 0) {
219
- await backend.upsertFulltext({
220
- graphId: ctx.graphId,
221
- nodeKind: ctx.nodeKind,
222
- nodeId: ctx.nodeId,
223
- content: computed.content,
224
- language: computed.language
225
- });
226
- return;
227
- }
228
- if (getSearchableFields(schema).length === 0) return;
229
- await backend.deleteFulltext({
230
- graphId: ctx.graphId,
231
- nodeKind: ctx.nodeKind,
232
- nodeId: ctx.nodeId
233
- });
234
- }
235
- async function syncFulltextBatchForKind(args, schema, items) {
236
- const { graphId, nodeKind, backend } = args;
237
- if (!backend.upsertFulltext || !backend.deleteFulltext) {
238
- return;
239
- }
240
- const rows = [];
241
- const emptyContentIds = [];
242
- const hasSearchableFields = getSearchableFields(schema).length > 0;
243
- for (const item of items) {
244
- const computed = computeFulltextContent(schema, item.props);
245
- if (computed !== void 0) {
246
- rows.push({
247
- nodeId: item.nodeId,
248
- content: computed.content,
249
- language: computed.language
250
- });
251
- } else if (hasSearchableFields) {
252
- emptyContentIds.push(item.nodeId);
253
- }
254
- }
255
- if (rows.length > 0) {
256
- if (backend.upsertFulltextBatch === void 0) {
257
- for (const row of rows) {
258
- await backend.upsertFulltext({
259
- graphId,
260
- nodeKind,
261
- nodeId: row.nodeId,
262
- content: row.content,
263
- language: row.language
264
- });
265
- }
266
- } else {
267
- await backend.upsertFulltextBatch({ graphId, nodeKind, rows });
268
- }
269
- }
270
- if (emptyContentIds.length > 0) {
271
- if (backend.deleteFulltextBatch === void 0) {
272
- for (const nodeId of emptyContentIds) {
273
- await backend.deleteFulltext({ graphId, nodeKind, nodeId });
274
- }
275
- } else {
276
- await backend.deleteFulltextBatch({
277
- graphId,
278
- nodeKind,
279
- nodeIds: emptyContentIds
280
- });
281
- }
282
- }
283
- }
284
- async function deleteNodeFulltext(ctx, schema) {
285
- const { backend } = ctx;
286
- if (!backend.deleteFulltext) {
287
- return;
288
- }
289
- if (getSearchableFields(schema).length === 0) {
290
- return;
291
- }
292
- await backend.deleteFulltext({
293
- graphId: ctx.graphId,
294
- nodeKind: ctx.nodeKind,
295
- nodeId: ctx.nodeId
296
- });
297
- }
298
-
299
- // src/store/uniqueness.ts
300
- function createUniquenessContext(graphId, registry, backend) {
301
- return { graphId, registry, backend };
302
- }
303
- function nodeIdentityKey(reference) {
304
- return encodeTupleKey([reference.kind, reference.id]);
305
- }
306
- function proposedUniqueClaims(ctx, upserts) {
307
- const claims = [];
308
- const claimsByCheckedKind = /* @__PURE__ */ new Map();
309
- const claimsByOwnKind = /* @__PURE__ */ new Map();
310
- const orderedConstraints = [];
311
- const seenConstraints = /* @__PURE__ */ new Set();
312
- for (const upsert of upserts) {
313
- for (const constraint of upsert.constraints) {
314
- if (seenConstraints.has(constraint)) continue;
315
- seenConstraints.add(constraint);
316
- orderedConstraints.push(constraint);
317
- }
318
- }
319
- for (const constraint of orderedConstraints) {
320
- for (const upsert of upserts) {
321
- if (!upsert.constraints.includes(constraint)) continue;
322
- if (!checkWherePredicate(constraint, upsert.props)) continue;
323
- const claim = {
324
- kind: upsert.kind,
325
- id: upsert.id,
326
- constraint,
327
- key: computeUniqueKey(
328
- upsert.props,
329
- constraint.fields,
330
- constraint.collation
331
- ),
332
- kindsToCheck: getKindsForUniquenessCheck(
333
- upsert.kind,
334
- constraint.scope,
335
- ctx.registry
336
- )
337
- };
338
- const identity = nodeIdentityKey(claim);
339
- const candidateGroups = [
340
- claimsByCheckedKind.get(
341
- encodeTupleKey([constraint.name, claim.key, claim.kind])
342
- ) ?? [],
343
- ...claim.kindsToCheck.map(
344
- (kind) => claimsByOwnKind.get(
345
- encodeTupleKey([constraint.name, claim.key, kind])
346
- ) ?? []
347
- )
348
- ];
349
- const collision = candidateGroups.flat().find((existing) => nodeIdentityKey(existing) !== identity);
350
- if (collision !== void 0) {
351
- throw new UniquenessError({
352
- constraintName: constraint.name,
353
- kind: collision.kind,
354
- existingId: collision.id,
355
- newId: upsert.id,
356
- fields: constraint.fields
357
- });
358
- }
359
- claims.push(claim);
360
- const ownKindKey = encodeTupleKey([
361
- constraint.name,
362
- claim.key,
363
- claim.kind
364
- ]);
365
- const sameKindClaims = claimsByOwnKind.get(ownKindKey);
366
- if (sameKindClaims === void 0) {
367
- claimsByOwnKind.set(ownKindKey, [claim]);
368
- } else {
369
- sameKindClaims.push(claim);
370
- }
371
- for (const kind of claim.kindsToCheck) {
372
- const checkedKindKey = encodeTupleKey([
373
- constraint.name,
374
- claim.key,
375
- kind
376
- ]);
377
- const sameDomainClaims = claimsByCheckedKind.get(checkedKindKey);
378
- if (sameDomainClaims === void 0) {
379
- claimsByCheckedKind.set(checkedKindKey, [claim]);
380
- } else {
381
- sameDomainClaims.push(claim);
382
- }
383
- }
384
- }
385
- }
386
- return claims;
387
- }
388
- function groupUniqueClaimsForBatchProbe(claims) {
389
- const groups = /* @__PURE__ */ new Map();
390
- for (const claim of claims) {
391
- for (const nodeKind of claim.kindsToCheck) {
392
- const groupKey = encodeTupleKey([nodeKind, claim.constraint.name]);
393
- const existing = groups.get(groupKey);
394
- if (existing === void 0) {
395
- groups.set(groupKey, {
396
- nodeKind,
397
- constraintName: claim.constraint.name,
398
- claimsByKey: /* @__PURE__ */ new Map([[claim.key, claim]])
399
- });
400
- continue;
401
- }
402
- existing.claimsByKey.set(claim.key, claim);
403
- }
404
- }
405
- return [...groups.values()];
406
- }
407
- async function validateResolvedNodeUniqueness(ctx, upserts, releases = []) {
408
- const checkUniqueBatch = ctx.backend.checkUniqueBatch;
409
- if (checkUniqueBatch === void 0) {
410
- throw new ConfigurationError(
411
- "Resolved node writes require batched uniqueness probes",
412
- { code: "RESOLVED_NODE_UNIQUENESS_UNSUPPORTED" }
413
- );
414
- }
415
- const claims = proposedUniqueClaims(ctx, upserts);
416
- if (claims.length === 0) return;
417
- const affectedOwners = new Set(
418
- [...upserts, ...releases].map((reference) => nodeIdentityKey(reference))
419
- );
420
- for (const group of groupUniqueClaimsForBatchProbe(claims)) {
421
- const existingRows = await checkUniqueBatch({
422
- graphId: ctx.graphId,
423
- nodeKind: group.nodeKind,
424
- constraintName: group.constraintName,
425
- keys: [...group.claimsByKey.keys()]
426
- });
427
- for (const existing of existingRows) {
428
- if (affectedOwners.has(
429
- nodeIdentityKey({
430
- kind: existing.concrete_kind,
431
- id: existing.node_id
432
- })
433
- )) {
434
- continue;
435
- }
436
- const claim = group.claimsByKey.get(existing.key);
437
- if (claim === void 0) continue;
438
- throw new UniquenessError({
439
- constraintName: group.constraintName,
440
- kind: group.nodeKind,
441
- existingId: existing.node_id,
442
- newId: claim.id,
443
- fields: claim.constraint.fields
444
- });
445
- }
446
- }
447
- }
448
- async function prepareResolvedNodeUniqueness(ctx, upserts, releases) {
449
- const hardDeleteUniquesByNodeIds = ctx.backend.hardDeleteUniquesByNodeIds;
450
- if (ctx.backend.checkUniqueBatch === void 0 || ctx.backend.insertUniqueBatch === void 0 || hardDeleteUniquesByNodeIds === void 0) {
451
- throw new ConfigurationError(
452
- "Resolved node writes require batched uniqueness operations",
453
- { code: "RESOLVED_NODE_UNIQUENESS_UNSUPPORTED" }
454
- );
455
- }
456
- await validateResolvedNodeUniqueness(ctx, upserts, releases);
457
- const idsByKind = /* @__PURE__ */ new Map();
458
- for (const reference of [...upserts, ...releases]) {
459
- const ids = idsByKind.get(reference.kind) ?? /* @__PURE__ */ new Set();
460
- ids.add(reference.id);
461
- idsByKind.set(reference.kind, ids);
462
- }
463
- for (const [concreteKind, nodeIds] of idsByKind) {
464
- await hardDeleteUniquesByNodeIds({
465
- graphId: ctx.graphId,
466
- concreteKind,
467
- nodeIds: [...nodeIds]
468
- });
469
- }
470
- }
471
- async function applyResolvedNodeUniqueness(ctx, upserts, releases, apply) {
472
- await prepareResolvedNodeUniqueness(ctx, upserts, releases);
473
- const result = await apply();
474
- await insertUniquenessEntriesBatch(ctx, upserts);
475
- return result;
476
- }
477
- async function probeUniqueKey(ctx, kind, id, constraint, key) {
478
- const kindsToCheck = getKindsForUniquenessCheck(
479
- kind,
480
- constraint.scope,
481
- ctx.registry
482
- );
483
- let heldByThisNode = false;
484
- for (const kindToCheck of kindsToCheck) {
485
- const existing = await ctx.backend.checkUnique({
486
- graphId: ctx.graphId,
487
- nodeKind: kindToCheck,
488
- constraintName: constraint.name,
489
- key
490
- });
491
- if (existing === void 0) continue;
492
- if (existing.node_id !== id) {
493
- throw new UniquenessError({
494
- constraintName: constraint.name,
495
- kind: kindToCheck,
496
- existingId: existing.node_id,
497
- newId: id,
498
- fields: constraint.fields
499
- });
500
- }
501
- if (kindToCheck === kind) heldByThisNode = true;
502
- }
503
- return heldByThisNode;
504
- }
505
- async function checkUniquenessConstraints(ctx, kind, id, props, constraints) {
506
- for (const constraint of constraints) {
507
- if (!checkWherePredicate(constraint, props)) {
508
- continue;
509
- }
510
- await probeUniqueKey(
511
- ctx,
512
- kind,
513
- id,
514
- constraint,
515
- computeUniqueKey(props, constraint.fields, constraint.collation)
516
- );
517
- }
518
- }
519
- async function insertUniquenessEntries(ctx, kind, id, props, constraints) {
520
- for (const constraint of constraints) {
521
- if (!checkWherePredicate(constraint, props)) {
522
- continue;
523
- }
524
- const key = computeUniqueKey(
525
- props,
526
- constraint.fields,
527
- constraint.collation
528
- );
529
- await ctx.backend.insertUnique({
530
- graphId: ctx.graphId,
531
- nodeKind: kind,
532
- constraintName: constraint.name,
533
- key,
534
- nodeId: id,
535
- concreteKind: kind
536
- });
537
- }
538
- }
539
- async function insertUniquenessEntriesBatch(ctx, items) {
540
- const entries = [];
541
- for (const item of items) {
542
- for (const constraint of item.constraints) {
543
- if (!checkWherePredicate(constraint, item.props)) {
544
- continue;
545
- }
546
- entries.push({
547
- graphId: ctx.graphId,
548
- nodeKind: item.kind,
549
- constraintName: constraint.name,
550
- key: computeUniqueKey(
551
- item.props,
552
- constraint.fields,
553
- constraint.collation
554
- ),
555
- nodeId: item.id,
556
- concreteKind: item.kind
557
- });
558
- }
559
- }
560
- if (entries.length === 0) return;
561
- if (ctx.backend.insertUniqueBatch !== void 0) {
562
- await ctx.backend.insertUniqueBatch(entries);
563
- return;
564
- }
565
- for (const entry of entries) {
566
- await ctx.backend.insertUnique(entry);
567
- }
568
- }
569
- async function deleteUniquenessEntries(ctx, kind, props, constraints) {
570
- for (const constraint of constraints) {
571
- if (!checkWherePredicate(constraint, props)) {
572
- continue;
573
- }
574
- const key = computeUniqueKey(
575
- props,
576
- constraint.fields,
577
- constraint.collation
578
- );
579
- await ctx.backend.deleteUnique({
580
- graphId: ctx.graphId,
581
- nodeKind: kind,
582
- constraintName: constraint.name,
583
- key
584
- });
585
- }
586
- }
587
- async function planUniquenessUpdate(ctx, kind, id, oldProps, newProps, constraints) {
588
- const pending = [];
589
- for (const constraint of constraints) {
590
- const oldApplies = checkWherePredicate(constraint, oldProps);
591
- const newApplies = checkWherePredicate(constraint, newProps);
592
- const oldKey = oldApplies ? computeUniqueKey(oldProps, constraint.fields, constraint.collation) : void 0;
593
- const newKey = newApplies ? computeUniqueKey(newProps, constraint.fields, constraint.collation) : void 0;
594
- if (!oldApplies && !newApplies) {
595
- continue;
596
- }
597
- if (oldApplies && newApplies && oldKey === newKey) {
598
- continue;
599
- }
600
- const alreadyHeld = newKey === void 0 ? false : await probeUniqueKey(ctx, kind, id, constraint, newKey);
601
- pending.push({
602
- constraintName: constraint.name,
603
- release: oldKey,
604
- claim: alreadyHeld ? void 0 : newKey
605
- });
606
- }
607
- return pending;
608
- }
609
- async function planUniquenessReinsert(ctx, kind, id, props, constraints) {
610
- const pending = [];
611
- for (const constraint of constraints) {
612
- if (!checkWherePredicate(constraint, props)) continue;
613
- const key = computeUniqueKey(
614
- props,
615
- constraint.fields,
616
- constraint.collation
617
- );
618
- const alreadyHeld = await probeUniqueKey(ctx, kind, id, constraint, key);
619
- pending.push({
620
- constraintName: constraint.name,
621
- release: void 0,
622
- claim: alreadyHeld ? void 0 : key
623
- });
624
- }
625
- return pending;
626
- }
627
- async function releaseUniqueKeys(ctx, kind, keys) {
628
- for (const entry of keys) {
629
- await ctx.backend.deleteUnique({
630
- graphId: ctx.graphId,
631
- nodeKind: kind,
632
- constraintName: entry.constraintName,
633
- key: entry.key
634
- });
635
- }
636
- }
637
- async function claimUniqueKeysThen(ctx, kind, id, plan, gatedWrite) {
638
- const claimed = [];
639
- try {
640
- for (const mutation of plan) {
641
- if (mutation.claim === void 0) continue;
642
- await ctx.backend.insertUnique({
643
- graphId: ctx.graphId,
644
- nodeKind: kind,
645
- constraintName: mutation.constraintName,
646
- key: mutation.claim,
647
- nodeId: id,
648
- concreteKind: kind
649
- });
650
- claimed.push({
651
- constraintName: mutation.constraintName,
652
- key: mutation.claim
653
- });
654
- }
655
- return await gatedWrite();
656
- } catch (error) {
657
- await releaseUniqueKeys(ctx, kind, claimed);
658
- throw error;
659
- }
660
- }
661
- async function withUniquenessTransition(ctx, kind, id, plan, gatedWrite) {
662
- const result = await claimUniqueKeysThen(ctx, kind, id, plan, gatedWrite);
663
- await releaseUniqueKeys(
664
- ctx,
665
- kind,
666
- plan.flatMap(
667
- (mutation) => mutation.release === void 0 ? [] : [{ constraintName: mutation.constraintName, key: mutation.release }]
668
- )
669
- );
670
- return result;
671
- }
672
-
673
- // src/store/operations/node-write-pipeline.ts
674
- function createNodeWriteContext(graphId, registry, lock) {
675
- return { graphId, registry, lock };
676
- }
677
- function uniquenessContext(ctx, backend) {
678
- return createUniquenessContext(ctx.graphId, ctx.registry, backend);
679
- }
680
- function nodeSyncContext(ctx, kind, id, backend) {
681
- return { graphId: ctx.graphId, nodeKind: kind, nodeId: id, backend };
682
- }
683
- async function enforceNodeDeleteBehavior(ctx, args, backend, policy) {
684
- if (policy?.enforceDeleteBehavior === false) return;
685
- const behavior = args.onDelete ?? "restrict";
686
- const connectedEdges = await backend.findEdgesConnectedTo({
687
- graphId: ctx.graphId,
688
- nodeKind: args.kind,
689
- nodeId: args.id
690
- });
691
- if (connectedEdges.length === 0) return;
692
- switch (behavior) {
693
- case "restrict": {
694
- throw new RestrictedDeleteError({
695
- nodeKind: args.kind,
696
- nodeId: args.id,
697
- edgeCount: connectedEdges.length,
698
- edgeKinds: [...new Set(connectedEdges.map((edge) => edge.kind))]
699
- });
700
- }
701
- case "cascade":
702
- case "disconnect": {
703
- const batchDelete = args.mode === "hard" ? backend.hardDeleteEdgesBatch : backend.deleteEdgesBatch;
704
- if (batchDelete !== void 0) {
705
- await batchDelete({
706
- graphId: ctx.graphId,
707
- ids: connectedEdges.map((edge) => edge.id)
708
- });
709
- break;
710
- }
711
- for (const edge of connectedEdges) {
712
- await (args.mode === "hard" ? backend.hardDeleteEdge({ graphId: ctx.graphId, id: edge.id }) : backend.deleteEdge({ graphId: ctx.graphId, id: edge.id }));
713
- }
714
- break;
715
- }
716
- }
717
- }
718
- async function applyNodeInsertSideEffects(ctx, args, backend) {
719
- await insertUniquenessEntries(
720
- uniquenessContext(ctx, backend),
721
- args.kind,
722
- args.id,
723
- args.props,
724
- args.uniqueConstraints
725
- );
726
- await Promise.all([
727
- syncEmbeddings(
728
- nodeSyncContext(ctx, args.kind, args.id, backend),
729
- args.schema,
730
- args.props
731
- ),
732
- syncFulltext(
733
- nodeSyncContext(ctx, args.kind, args.id, backend),
734
- args.schema,
735
- args.props
736
- )
737
- ]);
738
- }
739
- async function applyNodeInsertSideEffectsBatch(ctx, items, backend) {
740
- if (items.length === 0) return;
741
- await insertUniquenessEntriesBatch(
742
- uniquenessContext(ctx, backend),
743
- items.map((item) => ({
744
- kind: item.kind,
745
- id: item.id,
746
- props: item.props,
747
- constraints: item.uniqueConstraints
748
- }))
749
- );
750
- const byKind = /* @__PURE__ */ new Map();
751
- for (const item of items) {
752
- const group = byKind.get(item.kind) ?? { schema: item.schema, rows: [] };
753
- group.rows.push({ nodeId: item.id, props: item.props });
754
- byKind.set(item.kind, group);
755
- }
756
- await Promise.all(
757
- [...byKind.entries()].flatMap(([kind, group]) => {
758
- const syncArguments = { graphId: ctx.graphId, nodeKind: kind, backend };
759
- return [
760
- syncEmbeddingsBatchForKind(syncArguments, group.schema, group.rows),
761
- syncFulltextBatchForKind(syncArguments, group.schema, group.rows)
762
- ];
763
- })
764
- );
765
- }
766
- function parseRowProps(row) {
767
- return rowPropsToObject(row.props);
768
- }
769
- async function planNodeUpdateUniqueness(ctx, args, backend) {
770
- const { kind, id } = args.existing;
771
- if (args.existing.deleted_at !== void 0) {
772
- return planUniquenessReinsert(
773
- uniquenessContext(ctx, backend),
774
- kind,
775
- id,
776
- args.validatedProps,
777
- args.uniqueConstraints
778
- );
779
- }
780
- return planUniquenessUpdate(
781
- uniquenessContext(ctx, backend),
782
- kind,
783
- id,
784
- parseRowProps(args.existing),
785
- args.validatedProps,
786
- args.uniqueConstraints
787
- );
788
- }
789
- async function applyNodeUpdate(ctx, args, backend) {
790
- const { kind, id } = args.existing;
791
- const plan = await planNodeUpdateUniqueness(
792
- ctx,
793
- {
794
- existing: args.existing,
795
- validatedProps: args.validatedProps,
796
- uniqueConstraints: args.uniqueConstraints
797
- },
798
- backend
799
- );
800
- const updateParams = {
801
- graphId: ctx.graphId,
802
- kind,
803
- id,
804
- props: args.validatedProps,
805
- incrementVersion: true
806
- };
807
- if (args.validFrom !== void 0) updateParams.validFrom = args.validFrom;
808
- if (args.expectedValidFrom !== void 0) {
809
- updateParams.expectedValidFrom = args.expectedValidFrom;
810
- }
811
- if (args.clearDeleted) updateParams.clearDeleted = true;
812
- const row = await withUniquenessTransition(
813
- uniquenessContext(ctx, backend),
814
- kind,
815
- id,
816
- plan,
817
- () => backend.updateNode({
818
- ...updateParams,
819
- ...args.clearValidTo === true ? { clearValidTo: true } : args.validTo === void 0 ? {} : { validTo: args.validTo }
820
- })
821
- );
822
- await Promise.all([
823
- syncEmbeddings(
824
- nodeSyncContext(ctx, kind, id, backend),
825
- args.schema,
826
- args.validatedProps
827
- ),
828
- syncFulltext(
829
- nodeSyncContext(ctx, kind, id, backend),
830
- args.schema,
831
- args.validatedProps
832
- )
833
- ]);
834
- return row;
835
- }
836
- async function applyNodeSoftDelete(ctx, args, backend, policy) {
837
- const { kind, id } = args.existing;
838
- await enforceNodeDeleteBehavior(
839
- ctx,
840
- { kind, id, mode: "soft", onDelete: args.onDelete },
841
- backend,
842
- policy
843
- );
844
- await backend.deleteNode({
845
- graphId: ctx.graphId,
846
- kind,
847
- id
848
- });
849
- await deleteUniquenessEntries(
850
- uniquenessContext(ctx, backend),
851
- kind,
852
- parseRowProps(args.existing),
853
- args.uniqueConstraints
854
- );
855
- await deleteNodeEmbeddings(
856
- nodeSyncContext(ctx, kind, id, backend),
857
- args.schema
858
- );
859
- await deleteNodeFulltext(
860
- nodeSyncContext(ctx, kind, id, backend),
861
- args.schema
862
- );
863
- }
864
- async function applyNodeHardDelete(ctx, args, backend) {
865
- await enforceNodeDeleteBehavior(
866
- ctx,
867
- { kind: args.kind, id: args.id, mode: "hard", onDelete: args.onDelete },
868
- backend
869
- );
870
- await backend.hardDeleteNode({
871
- graphId: ctx.graphId,
872
- kind: args.kind,
873
- id: args.id
874
- });
875
- await deleteNodeEmbeddings(
876
- nodeSyncContext(ctx, args.kind, args.id, backend),
877
- args.schema
878
- );
879
- }
880
- async function applyNodeResurrect(ctx, args, backend) {
881
- const { kind, id } = args.existing;
882
- const props = parseRowProps(args.existing);
883
- const plan = await planUniquenessReinsert(
884
- uniquenessContext(ctx, backend),
885
- kind,
886
- id,
887
- props,
888
- args.uniqueConstraints
889
- );
890
- const row = await withUniquenessTransition(
891
- uniquenessContext(ctx, backend),
892
- kind,
893
- id,
894
- plan,
895
- () => backend.updateNode({
896
- graphId: ctx.graphId,
897
- kind,
898
- id,
899
- props,
900
- incrementVersion: true,
901
- clearDeleted: true
902
- })
903
- );
904
- await Promise.all([
905
- syncEmbeddings(nodeSyncContext(ctx, kind, id, backend), args.schema, props),
906
- syncFulltext(nodeSyncContext(ctx, kind, id, backend), args.schema, props)
907
- ]);
908
- return row;
909
- }
910
-
911
- export { AUTO_REFRESH_STATISTICS_ROW_THRESHOLD, STORE_RUNTIME, TRANSACTION_RUNTIME, applyNodeHardDelete, applyNodeInsertSideEffects, applyNodeInsertSideEffectsBatch, applyNodeResurrect, applyNodeSoftDelete, applyNodeUpdate, applyResolvedNodeUniqueness, checkUniquenessConstraints, computeFulltextContent, createNodeWriteContext, createUniquenessContext, getEmbeddingFields, storeBackend, storeRuntime, transactionBackend, transactionNodeOperationHookRunner, validateResolvedNodeUniqueness };
912
- //# sourceMappingURL=chunk-I4GAZH5Z.js.map
913
- //# sourceMappingURL=chunk-I4GAZH5Z.js.map