@nicia-ai/typegraph 0.44.0 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (392) hide show
  1. package/dist/backend/drizzle/indexes.cjs +11 -11
  2. package/dist/backend/drizzle/indexes.d.cts +1 -1
  3. package/dist/backend/drizzle/indexes.d.ts +1 -1
  4. package/dist/backend/drizzle/indexes.js +7 -7
  5. package/dist/backend/index.cjs +53 -54
  6. package/dist/backend/index.d.cts +3 -3
  7. package/dist/backend/index.d.ts +3 -3
  8. package/dist/backend/index.js +13 -14
  9. package/dist/backend/postgres/index.cjs +29 -30
  10. package/dist/backend/postgres/index.d.cts +7 -7
  11. package/dist/backend/postgres/index.d.ts +7 -7
  12. package/dist/backend/postgres/index.js +16 -17
  13. package/dist/backend/postgres/pglite-store.cjs +48 -43
  14. package/dist/backend/postgres/pglite-store.cjs.map +1 -1
  15. package/dist/backend/postgres/pglite-store.d.cts +15 -9
  16. package/dist/backend/postgres/pglite-store.d.ts +15 -9
  17. package/dist/backend/postgres/pglite-store.js +44 -39
  18. package/dist/backend/postgres/pglite-store.js.map +1 -1
  19. package/dist/backend/postgres/pglite.cjs +18 -19
  20. package/dist/backend/postgres/pglite.d.cts +4 -4
  21. package/dist/backend/postgres/pglite.d.ts +4 -4
  22. package/dist/backend/postgres/pglite.js +17 -18
  23. package/dist/backend/sqlite/index.cjs +26 -27
  24. package/dist/backend/sqlite/index.d.cts +6 -6
  25. package/dist/backend/sqlite/index.d.ts +6 -6
  26. package/dist/backend/sqlite/index.js +14 -15
  27. package/dist/backend/sqlite/libsql.cjs +21 -22
  28. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  29. package/dist/backend/sqlite/libsql.d.cts +15 -8
  30. package/dist/backend/sqlite/libsql.d.ts +15 -8
  31. package/dist/backend/sqlite/libsql.js +17 -18
  32. package/dist/backend/sqlite/libsql.js.map +1 -1
  33. package/dist/backend/sqlite/local-store.cjs +49 -44
  34. package/dist/backend/sqlite/local-store.cjs.map +1 -1
  35. package/dist/backend/sqlite/local-store.d.cts +15 -10
  36. package/dist/backend/sqlite/local-store.d.ts +15 -10
  37. package/dist/backend/sqlite/local-store.js +45 -40
  38. package/dist/backend/sqlite/local-store.js.map +1 -1
  39. package/dist/backend/sqlite/local.cjs +19 -20
  40. package/dist/backend/sqlite/local.d.cts +3 -3
  41. package/dist/backend/sqlite/local.d.ts +3 -3
  42. package/dist/backend/sqlite/local.js +17 -18
  43. package/dist/{chunk-XMYJY7NI.js → chunk-2LG2XB2M.js} +3 -3
  44. package/dist/{chunk-XMYJY7NI.js.map → chunk-2LG2XB2M.js.map} +1 -1
  45. package/dist/{chunk-QGKILWGZ.cjs → chunk-2NA5DYLO.cjs} +4 -4
  46. package/dist/{chunk-QGKILWGZ.cjs.map → chunk-2NA5DYLO.cjs.map} +1 -1
  47. package/dist/{chunk-5MUSU4ZP.cjs → chunk-3DHZCOT7.cjs} +20 -20
  48. package/dist/chunk-3DHZCOT7.cjs.map +1 -0
  49. package/dist/{chunk-OVUUTCPJ.cjs → chunk-4UGOKMI5.cjs} +268 -150
  50. package/dist/chunk-4UGOKMI5.cjs.map +1 -0
  51. package/dist/{chunk-FRHHDHKH.js → chunk-5262ZMTR.js} +26 -5
  52. package/dist/chunk-5262ZMTR.js.map +1 -0
  53. package/dist/{chunk-HOIFFY4M.js → chunk-5763DULU.js} +248 -76
  54. package/dist/chunk-5763DULU.js.map +1 -0
  55. package/dist/{chunk-7G32LIQM.js → chunk-5UVRGXD3.js} +277 -7
  56. package/dist/chunk-5UVRGXD3.js.map +1 -0
  57. package/dist/{chunk-IIT5K7SK.cjs → chunk-62ZP23AW.cjs} +15 -15
  58. package/dist/{chunk-IIT5K7SK.cjs.map → chunk-62ZP23AW.cjs.map} +1 -1
  59. package/dist/{chunk-S4KQ5LV4.js → chunk-775A4ZMN.js} +40 -6
  60. package/dist/chunk-775A4ZMN.js.map +1 -0
  61. package/dist/{chunk-QYWINYEA.cjs → chunk-7BQXPCGN.cjs} +830 -170
  62. package/dist/chunk-7BQXPCGN.cjs.map +1 -0
  63. package/dist/{chunk-FJMPR3OH.cjs → chunk-7EO3TCQB.cjs} +33 -7
  64. package/dist/chunk-7EO3TCQB.cjs.map +1 -0
  65. package/dist/chunk-7GT72YHH.cjs +1979 -0
  66. package/dist/chunk-7GT72YHH.cjs.map +1 -0
  67. package/dist/{chunk-SQRD2CYF.js → chunk-7VQXLT5O.js} +717 -76
  68. package/dist/chunk-7VQXLT5O.js.map +1 -0
  69. package/dist/{chunk-BCP7LLOY.js → chunk-7Z5OR7KO.js} +2706 -625
  70. package/dist/chunk-7Z5OR7KO.js.map +1 -0
  71. package/dist/chunk-A4OC4DVN.cjs +12 -0
  72. package/dist/{chunk-4SZ6XPTG.cjs.map → chunk-A4OC4DVN.cjs.map} +1 -1
  73. package/dist/{chunk-TDXIBCGY.cjs → chunk-A7J2YDDI.cjs} +5 -3
  74. package/dist/chunk-A7J2YDDI.cjs.map +1 -0
  75. package/dist/{chunk-FMMIX6N4.js → chunk-AKLS3BYZ.js} +56 -5
  76. package/dist/chunk-AKLS3BYZ.js.map +1 -0
  77. package/dist/{chunk-D7PG5D5K.js → chunk-AMKPPFUO.js} +32 -6
  78. package/dist/chunk-AMKPPFUO.js.map +1 -0
  79. package/dist/{chunk-PAW2XUZN.js → chunk-ASTI57H3.js} +3 -3
  80. package/dist/{chunk-PAW2XUZN.js.map → chunk-ASTI57H3.js.map} +1 -1
  81. package/dist/{chunk-FMGEZBAQ.js → chunk-BKCUOV7A.js} +27 -5
  82. package/dist/chunk-BKCUOV7A.js.map +1 -0
  83. package/dist/chunk-BSFJMMV3.cjs +268 -0
  84. package/dist/chunk-BSFJMMV3.cjs.map +1 -0
  85. package/dist/{chunk-63KCKSSH.js → chunk-C23WSN5E.js} +209 -24
  86. package/dist/chunk-C23WSN5E.js.map +1 -0
  87. package/dist/{chunk-JRP3VGHS.js → chunk-CBTIUB76.js} +3 -3
  88. package/dist/{chunk-JRP3VGHS.js.map → chunk-CBTIUB76.js.map} +1 -1
  89. package/dist/chunk-CNV4TXJG.js +58 -0
  90. package/dist/chunk-CNV4TXJG.js.map +1 -0
  91. package/dist/{chunk-QB6VMOJ2.cjs → chunk-CXBHOOIQ.cjs} +45 -10
  92. package/dist/chunk-CXBHOOIQ.cjs.map +1 -0
  93. package/dist/{chunk-46GDII45.js → chunk-DCQVHAYQ.js} +5 -5
  94. package/dist/{chunk-46GDII45.js.map → chunk-DCQVHAYQ.js.map} +1 -1
  95. package/dist/chunk-DLNROMQ7.js +306 -0
  96. package/dist/chunk-DLNROMQ7.js.map +1 -0
  97. package/dist/chunk-DYATYRY4.js +47 -0
  98. package/dist/chunk-DYATYRY4.js.map +1 -0
  99. package/dist/chunk-E4WNQBEF.cjs +217 -0
  100. package/dist/chunk-E4WNQBEF.cjs.map +1 -0
  101. package/dist/{chunk-G6Q5UM7U.js → chunk-FWJKWH6U.js} +5 -3
  102. package/dist/chunk-FWJKWH6U.js.map +1 -0
  103. package/dist/{chunk-BNUFUFAU.js → chunk-HFHTMECK.js} +7 -7
  104. package/dist/chunk-HFHTMECK.js.map +1 -0
  105. package/dist/{chunk-TFMVL4QH.js → chunk-I5MOXA4H.js} +20 -14
  106. package/dist/chunk-I5MOXA4H.js.map +1 -0
  107. package/dist/{chunk-4MB3AQAQ.js → chunk-J3WZ3FA2.js} +77 -3
  108. package/dist/chunk-J3WZ3FA2.js.map +1 -0
  109. package/dist/{chunk-UR7W5YQK.js → chunk-JBQQ7THH.js} +5 -3
  110. package/dist/chunk-JBQQ7THH.js.map +1 -0
  111. package/dist/chunk-JIVMTW7W.js +3393 -0
  112. package/dist/chunk-JIVMTW7W.js.map +1 -0
  113. package/dist/{chunk-2Y4IFKW7.js → chunk-JXA2ZP2Q.js} +6 -17
  114. package/dist/chunk-JXA2ZP2Q.js.map +1 -0
  115. package/dist/{chunk-GYA4JRP5.js → chunk-JXXDZTMN.js} +2 -2
  116. package/dist/chunk-JXXDZTMN.js.map +1 -0
  117. package/dist/chunk-JZUR7ZWE.js +254 -0
  118. package/dist/chunk-JZUR7ZWE.js.map +1 -0
  119. package/dist/chunk-K5ELX2GT.js +248 -0
  120. package/dist/chunk-K5ELX2GT.js.map +1 -0
  121. package/dist/chunk-LBJKZXDE.cjs +257 -0
  122. package/dist/chunk-LBJKZXDE.cjs.map +1 -0
  123. package/dist/{chunk-FGO5JFVJ.cjs → chunk-M4BDU5RX.cjs} +12 -12
  124. package/dist/{chunk-FGO5JFVJ.cjs.map → chunk-M4BDU5RX.cjs.map} +1 -1
  125. package/dist/{chunk-MIJKEVV7.js → chunk-MSY7FSX4.js} +37 -4
  126. package/dist/chunk-MSY7FSX4.js.map +1 -0
  127. package/dist/{chunk-ST3LPB2V.cjs → chunk-MUK4BU7K.cjs} +788 -146
  128. package/dist/chunk-MUK4BU7K.cjs.map +1 -0
  129. package/dist/{chunk-MCHP7RHZ.cjs → chunk-MXJDTH5B.cjs} +64 -41
  130. package/dist/chunk-MXJDTH5B.cjs.map +1 -0
  131. package/dist/{chunk-2VLBGQBY.cjs → chunk-N3257XE6.cjs} +724 -577
  132. package/dist/chunk-N3257XE6.cjs.map +1 -0
  133. package/dist/chunk-N66HCGCY.cjs +57 -0
  134. package/dist/chunk-N66HCGCY.cjs.map +1 -0
  135. package/dist/{chunk-CPEL3YIR.cjs → chunk-NFCVHQ5P.cjs} +55 -22
  136. package/dist/chunk-NFCVHQ5P.cjs.map +1 -0
  137. package/dist/{chunk-C4F7VJ5D.cjs → chunk-NI72YOJB.cjs} +84 -2
  138. package/dist/chunk-NI72YOJB.cjs.map +1 -0
  139. package/dist/{chunk-EE7N5XXQ.cjs → chunk-NK5Q7UNE.cjs} +10 -21
  140. package/dist/chunk-NK5Q7UNE.cjs.map +1 -0
  141. package/dist/{chunk-PHXITZE4.js → chunk-NMWDXFPH.js} +4 -4
  142. package/dist/{chunk-PHXITZE4.js.map → chunk-NMWDXFPH.js.map} +1 -1
  143. package/dist/{chunk-FSXTPBRN.js → chunk-NQ6BRJBE.js} +416 -850
  144. package/dist/chunk-NQ6BRJBE.js.map +1 -0
  145. package/dist/chunk-OH5E5KIO.js +2057 -0
  146. package/dist/chunk-OH5E5KIO.js.map +1 -0
  147. package/dist/chunk-ONU3HIED.cjs +2082 -0
  148. package/dist/chunk-ONU3HIED.cjs.map +1 -0
  149. package/dist/{chunk-STQ3BSED.cjs → chunk-PNN7RHVR.cjs} +66 -44
  150. package/dist/chunk-PNN7RHVR.cjs.map +1 -0
  151. package/dist/{chunk-6DCB664D.js → chunk-PQBQG7IM.js} +3 -3
  152. package/dist/{chunk-6DCB664D.js.map → chunk-PQBQG7IM.js.map} +1 -1
  153. package/dist/{chunk-ACSVZPK7.cjs → chunk-PWLJ77UV.cjs} +5 -3
  154. package/dist/chunk-PWLJ77UV.cjs.map +1 -0
  155. package/dist/chunk-Q7Q4WSLJ.cjs +328 -0
  156. package/dist/chunk-Q7Q4WSLJ.cjs.map +1 -0
  157. package/dist/{chunk-BEFM74L2.js → chunk-QLRESYPU.js} +637 -493
  158. package/dist/chunk-QLRESYPU.js.map +1 -0
  159. package/dist/{chunk-SBPC5IP3.js → chunk-QWX5YA3K.js} +784 -202
  160. package/dist/chunk-QWX5YA3K.js.map +1 -0
  161. package/dist/{chunk-TCRIQMBU.js → chunk-RJS7DECT.js} +8 -9
  162. package/dist/chunk-RJS7DECT.js.map +1 -0
  163. package/dist/{chunk-6JZUSDY2.cjs → chunk-RMQLSPA2.cjs} +297 -27
  164. package/dist/chunk-RMQLSPA2.cjs.map +1 -0
  165. package/dist/{chunk-SJDMVITW.cjs → chunk-RT5ZY4XA.cjs} +6 -5
  166. package/dist/chunk-RT5ZY4XA.cjs.map +1 -0
  167. package/dist/{chunk-IJTLXNGJ.js → chunk-T4XNKYXB.js} +780 -127
  168. package/dist/chunk-T4XNKYXB.js.map +1 -0
  169. package/dist/{chunk-PDGEXGS6.cjs → chunk-TQR4KBY2.cjs} +354 -182
  170. package/dist/chunk-TQR4KBY2.cjs.map +1 -0
  171. package/dist/chunk-TTAITEPJ.cjs +755 -0
  172. package/dist/chunk-TTAITEPJ.cjs.map +1 -0
  173. package/dist/{chunk-NN3QSOVS.cjs → chunk-U5SON7R2.cjs} +27 -27
  174. package/dist/{chunk-NN3QSOVS.cjs.map → chunk-U5SON7R2.cjs.map} +1 -1
  175. package/dist/{chunk-A2I2XO52.cjs → chunk-U63GDNRC.cjs} +32 -26
  176. package/dist/chunk-U63GDNRC.cjs.map +1 -0
  177. package/dist/{chunk-YNULOIR5.cjs → chunk-UDISNXDL.cjs} +64 -43
  178. package/dist/chunk-UDISNXDL.cjs.map +1 -0
  179. package/dist/{chunk-GWEDD3DH.js → chunk-UV3SN74I.js} +5 -5
  180. package/dist/{chunk-GWEDD3DH.js.map → chunk-UV3SN74I.js.map} +1 -1
  181. package/dist/{chunk-U5W4LKZV.cjs → chunk-VCRRKBLN.cjs} +9 -9
  182. package/dist/{chunk-U5W4LKZV.cjs.map → chunk-VCRRKBLN.cjs.map} +1 -1
  183. package/dist/{chunk-EFELJVLA.js → chunk-VGTJPTIC.js} +28 -5
  184. package/dist/chunk-VGTJPTIC.js.map +1 -0
  185. package/dist/chunk-VQH4VAWD.cjs +12 -0
  186. package/dist/{chunk-EPTSMFH7.cjs.map → chunk-VQH4VAWD.cjs.map} +1 -1
  187. package/dist/{chunk-SNXVDZAJ.js → chunk-W6OG3HDG.js} +5 -4
  188. package/dist/chunk-W6OG3HDG.js.map +1 -0
  189. package/dist/chunk-WDGA7IYB.js +207 -0
  190. package/dist/chunk-WDGA7IYB.js.map +1 -0
  191. package/dist/chunk-WEVQJ5LH.js +736 -0
  192. package/dist/chunk-WEVQJ5LH.js.map +1 -0
  193. package/dist/{chunk-3PRKZW6D.cjs → chunk-XBYVV3MP.cjs} +60 -5
  194. package/dist/chunk-XBYVV3MP.cjs.map +1 -0
  195. package/dist/{chunk-GFRGG2US.cjs → chunk-XCAGZAKP.cjs} +7 -7
  196. package/dist/{chunk-GFRGG2US.cjs.map → chunk-XCAGZAKP.cjs.map} +1 -1
  197. package/dist/{chunk-XR4YZFKW.cjs → chunk-XDF2UPEQ.cjs} +3864 -1783
  198. package/dist/chunk-XDF2UPEQ.cjs.map +1 -0
  199. package/dist/{chunk-7V2FGGI2.cjs → chunk-XMQSEJCF.cjs} +632 -1080
  200. package/dist/chunk-XMQSEJCF.cjs.map +1 -0
  201. package/dist/chunk-XNLIZYRZ.cjs +3432 -0
  202. package/dist/chunk-XNLIZYRZ.cjs.map +1 -0
  203. package/dist/{chunk-66UVLHQA.cjs → chunk-XNSI2FJO.cjs} +99 -100
  204. package/dist/chunk-XNSI2FJO.cjs.map +1 -0
  205. package/dist/chunk-XQSCL77R.cjs +60 -0
  206. package/dist/chunk-XQSCL77R.cjs.map +1 -0
  207. package/dist/{chunk-SVJ5GEXW.cjs → chunk-XUO3KQFO.cjs} +2 -2
  208. package/dist/chunk-XUO3KQFO.cjs.map +1 -0
  209. package/dist/{chunk-HJH3RMXG.cjs → chunk-YAAM3M2S.cjs} +10 -10
  210. package/dist/{chunk-HJH3RMXG.cjs.map → chunk-YAAM3M2S.cjs.map} +1 -1
  211. package/dist/{chunk-ATLN63JA.js → chunk-YBFHZUXX.js} +6 -6
  212. package/dist/{chunk-ATLN63JA.js.map → chunk-YBFHZUXX.js.map} +1 -1
  213. package/dist/{chunk-K3BUWSFR.js → chunk-YDFDBE6D.js} +119 -6
  214. package/dist/chunk-YDFDBE6D.js.map +1 -0
  215. package/dist/{chunk-OSZPLZIV.cjs → chunk-YVWGEQJE.cjs} +318 -132
  216. package/dist/chunk-YVWGEQJE.cjs.map +1 -0
  217. package/dist/{chunk-QT6V3YRH.js → chunk-YWGVVALJ.js} +3 -3
  218. package/dist/{chunk-QT6V3YRH.js.map → chunk-YWGVVALJ.js.map} +1 -1
  219. package/dist/core/index.cjs +40 -41
  220. package/dist/core/index.d.cts +4 -5
  221. package/dist/core/index.d.ts +4 -5
  222. package/dist/core/index.js +8 -9
  223. package/dist/{ddl-eWg7hx6R.d.cts → ddl-BJcOp4WZ.d.cts} +3 -3
  224. package/dist/{ddl-D5369kOY.d.ts → ddl-BXfGHbPN.d.ts} +3 -3
  225. package/dist/graph-extension/index.cjs +26 -23
  226. package/dist/graph-extension/index.d.cts +16 -6
  227. package/dist/graph-extension/index.d.ts +16 -6
  228. package/dist/graph-extension/index.js +7 -8
  229. package/dist/graph-merge/index.cjs +2459 -655
  230. package/dist/graph-merge/index.cjs.map +1 -1
  231. package/dist/graph-merge/index.d.cts +170 -33
  232. package/dist/graph-merge/index.d.ts +170 -33
  233. package/dist/graph-merge/index.js +2269 -468
  234. package/dist/graph-merge/index.js.map +1 -1
  235. package/dist/{index-By89Sezh.d.ts → index-BSHvKfok.d.ts} +221 -10
  236. package/dist/{index-DcQ3Sxs-.d.cts → index-DxaYCv8Y.d.cts} +221 -10
  237. package/dist/index.cjs +330 -269
  238. package/dist/index.cjs.map +1 -1
  239. package/dist/index.d.cts +590 -576
  240. package/dist/index.d.ts +590 -576
  241. package/dist/index.js +73 -50
  242. package/dist/index.js.map +1 -1
  243. package/dist/indexes/index.cjs +17 -17
  244. package/dist/indexes/index.d.cts +4 -4
  245. package/dist/indexes/index.d.ts +4 -4
  246. package/dist/indexes/index.js +10 -10
  247. package/dist/interchange/index.cjs +165 -50
  248. package/dist/interchange/index.cjs.map +1 -1
  249. package/dist/interchange/index.d.cts +261 -16
  250. package/dist/interchange/index.d.ts +261 -16
  251. package/dist/interchange/index.js +128 -24
  252. package/dist/interchange/index.js.map +1 -1
  253. package/dist/{manager-B0KjKE93.d.ts → manager-CfZAimti.d.ts} +36 -5
  254. package/dist/{manager-Cn0NFIhN.d.cts → manager-HGk6E_HW.d.cts} +36 -5
  255. package/dist/{materialize-indexes-BD4V3svD.d.ts → materialize-indexes-6A7dWGtb.d.cts} +10 -2
  256. package/dist/{materialize-indexes-DVRhd5h4.d.cts → materialize-indexes-BMJP6Tms.d.ts} +10 -2
  257. package/dist/{postgres-DaEWvN4x.d.cts → postgres-DFYWENdR.d.cts} +1961 -439
  258. package/dist/{postgres-u0a0HN2D.d.ts → postgres-e7a9TdvR.d.ts} +1961 -439
  259. package/dist/profiler/index.cjs +15 -15
  260. package/dist/profiler/index.d.cts +9 -10
  261. package/dist/profiler/index.d.ts +9 -10
  262. package/dist/profiler/index.js +4 -4
  263. package/dist/provenance/index.cjs +46 -48
  264. package/dist/provenance/index.cjs.map +1 -1
  265. package/dist/provenance/index.d.cts +7 -7
  266. package/dist/provenance/index.d.ts +7 -7
  267. package/dist/provenance/index.js +12 -14
  268. package/dist/provenance/index.js.map +1 -1
  269. package/dist/schema/index.cjs +50 -49
  270. package/dist/schema/index.d.cts +9 -16
  271. package/dist/schema/index.d.ts +9 -16
  272. package/dist/schema/index.js +23 -22
  273. package/dist/{searchable-CnYEancP.d.ts → searchable-9OQoPuRs.d.ts} +1 -2
  274. package/dist/{searchable-BT7j9_IK.d.cts → searchable-CIje5XYD.d.cts} +1 -2
  275. package/dist/{sqlite-BrMoSsI7.d.cts → sqlite-DerU5tc7.d.ts} +2029 -347
  276. package/dist/{sqlite-CHhZUyO5.d.ts → sqlite-DitnISa9.d.cts} +2029 -347
  277. package/dist/{store-view-Bvdku0Ht.d.ts → store-DawaWWjJ.d.ts} +3145 -2556
  278. package/dist/{store-view-w-md0nQ4.d.cts → store-RwTJx8LX.d.cts} +3145 -2556
  279. package/dist/{temporal-BCORwUau.d.cts → temporal-Bn-Fi8FJ.d.cts} +1 -1
  280. package/dist/{temporal--x9T8K4S.d.ts → temporal-BtM4UALv.d.ts} +1 -1
  281. package/dist/{types-6-WJmSD4.d.cts → types-CoIx8HX5.d.cts} +1 -1
  282. package/dist/{types-Cjvkj0jA.d.ts → types-HkveCCx0.d.cts} +866 -21
  283. package/dist/{types-Cjvkj0jA.d.cts → types-HkveCCx0.d.ts} +866 -21
  284. package/dist/{types-COODtTJU.d.ts → types-KFfk-8Ah.d.ts} +1 -1
  285. package/dist/{where-CUQmCR6d.d.cts → where--fk7_0kv.d.cts} +1 -1
  286. package/dist/{where-5xVawAwL.d.ts → where-ws5hf-Ov.d.ts} +1 -1
  287. package/package.json +1 -1
  288. package/dist/chunk-2BIG7U6E.cjs +0 -83
  289. package/dist/chunk-2BIG7U6E.cjs.map +0 -1
  290. package/dist/chunk-2L54C2C2.js +0 -144
  291. package/dist/chunk-2L54C2C2.js.map +0 -1
  292. package/dist/chunk-2VLBGQBY.cjs.map +0 -1
  293. package/dist/chunk-2WDD2NO3.js +0 -59
  294. package/dist/chunk-2WDD2NO3.js.map +0 -1
  295. package/dist/chunk-2Y4IFKW7.js.map +0 -1
  296. package/dist/chunk-35S6P5ZU.js +0 -27
  297. package/dist/chunk-35S6P5ZU.js.map +0 -1
  298. package/dist/chunk-3PRKZW6D.cjs.map +0 -1
  299. package/dist/chunk-4MB3AQAQ.js.map +0 -1
  300. package/dist/chunk-4SZ6XPTG.cjs +0 -12
  301. package/dist/chunk-5MUSU4ZP.cjs.map +0 -1
  302. package/dist/chunk-63KCKSSH.js.map +0 -1
  303. package/dist/chunk-66UVLHQA.cjs.map +0 -1
  304. package/dist/chunk-6JZUSDY2.cjs.map +0 -1
  305. package/dist/chunk-764JHTLT.cjs +0 -15
  306. package/dist/chunk-764JHTLT.cjs.map +0 -1
  307. package/dist/chunk-7G32LIQM.js.map +0 -1
  308. package/dist/chunk-7V2FGGI2.cjs.map +0 -1
  309. package/dist/chunk-A2I2XO52.cjs.map +0 -1
  310. package/dist/chunk-A4PBRX4C.cjs +0 -100
  311. package/dist/chunk-A4PBRX4C.cjs.map +0 -1
  312. package/dist/chunk-ACSVZPK7.cjs.map +0 -1
  313. package/dist/chunk-ALFUGRYB.cjs +0 -1282
  314. package/dist/chunk-ALFUGRYB.cjs.map +0 -1
  315. package/dist/chunk-B75XRV3O.js +0 -125
  316. package/dist/chunk-B75XRV3O.js.map +0 -1
  317. package/dist/chunk-BCP7LLOY.js.map +0 -1
  318. package/dist/chunk-BEFM74L2.js.map +0 -1
  319. package/dist/chunk-BNUFUFAU.js.map +0 -1
  320. package/dist/chunk-C4F7VJ5D.cjs.map +0 -1
  321. package/dist/chunk-CPEL3YIR.cjs.map +0 -1
  322. package/dist/chunk-D7PG5D5K.js.map +0 -1
  323. package/dist/chunk-DI74SMXS.cjs +0 -29
  324. package/dist/chunk-DI74SMXS.cjs.map +0 -1
  325. package/dist/chunk-DK2S42XB.js +0 -77
  326. package/dist/chunk-DK2S42XB.js.map +0 -1
  327. package/dist/chunk-DRACN6XG.js +0 -27
  328. package/dist/chunk-DRACN6XG.js.map +0 -1
  329. package/dist/chunk-EE7N5XXQ.cjs.map +0 -1
  330. package/dist/chunk-EFELJVLA.js.map +0 -1
  331. package/dist/chunk-EPTSMFH7.cjs +0 -12
  332. package/dist/chunk-EQ7JKLZO.cjs +0 -157
  333. package/dist/chunk-EQ7JKLZO.cjs.map +0 -1
  334. package/dist/chunk-FJMPR3OH.cjs.map +0 -1
  335. package/dist/chunk-FMGEZBAQ.js.map +0 -1
  336. package/dist/chunk-FMMIX6N4.js.map +0 -1
  337. package/dist/chunk-FRHHDHKH.js.map +0 -1
  338. package/dist/chunk-FSXTPBRN.js.map +0 -1
  339. package/dist/chunk-G6Q5UM7U.js.map +0 -1
  340. package/dist/chunk-GYA4JRP5.js.map +0 -1
  341. package/dist/chunk-HOHAJ2NR.cjs +0 -61
  342. package/dist/chunk-HOHAJ2NR.cjs.map +0 -1
  343. package/dist/chunk-HOIFFY4M.js.map +0 -1
  344. package/dist/chunk-IIMQJYAM.js +0 -81
  345. package/dist/chunk-IIMQJYAM.js.map +0 -1
  346. package/dist/chunk-IJTLXNGJ.js.map +0 -1
  347. package/dist/chunk-ITE4IXAK.js +0 -25
  348. package/dist/chunk-ITE4IXAK.js.map +0 -1
  349. package/dist/chunk-K3BUWSFR.js.map +0 -1
  350. package/dist/chunk-KCO5EFJU.js +0 -79
  351. package/dist/chunk-KCO5EFJU.js.map +0 -1
  352. package/dist/chunk-KKYELPZ2.cjs +0 -83
  353. package/dist/chunk-KKYELPZ2.cjs.map +0 -1
  354. package/dist/chunk-MCHP7RHZ.cjs.map +0 -1
  355. package/dist/chunk-MIJKEVV7.js.map +0 -1
  356. package/dist/chunk-NCX65HBY.cjs +0 -1396
  357. package/dist/chunk-NCX65HBY.cjs.map +0 -1
  358. package/dist/chunk-OSZPLZIV.cjs.map +0 -1
  359. package/dist/chunk-OVUUTCPJ.cjs.map +0 -1
  360. package/dist/chunk-PDGEXGS6.cjs.map +0 -1
  361. package/dist/chunk-QB6VMOJ2.cjs.map +0 -1
  362. package/dist/chunk-QMQLUA66.js +0 -12
  363. package/dist/chunk-QMQLUA66.js.map +0 -1
  364. package/dist/chunk-QYWINYEA.cjs.map +0 -1
  365. package/dist/chunk-S4KQ5LV4.js.map +0 -1
  366. package/dist/chunk-SBPC5IP3.js.map +0 -1
  367. package/dist/chunk-SJDMVITW.cjs.map +0 -1
  368. package/dist/chunk-SNXVDZAJ.js.map +0 -1
  369. package/dist/chunk-SQRD2CYF.js.map +0 -1
  370. package/dist/chunk-ST3LPB2V.cjs.map +0 -1
  371. package/dist/chunk-STQ3BSED.cjs.map +0 -1
  372. package/dist/chunk-SVJ5GEXW.cjs.map +0 -1
  373. package/dist/chunk-TCRIQMBU.js.map +0 -1
  374. package/dist/chunk-TDXIBCGY.cjs.map +0 -1
  375. package/dist/chunk-TFMVL4QH.js.map +0 -1
  376. package/dist/chunk-TRF4EBJT.cjs +0 -30
  377. package/dist/chunk-TRF4EBJT.cjs.map +0 -1
  378. package/dist/chunk-TVLKA4AY.js +0 -94
  379. package/dist/chunk-TVLKA4AY.js.map +0 -1
  380. package/dist/chunk-UR7W5YQK.js.map +0 -1
  381. package/dist/chunk-VITTKBWF.js +0 -1263
  382. package/dist/chunk-VITTKBWF.js.map +0 -1
  383. package/dist/chunk-WBUFJ7BS.cjs +0 -131
  384. package/dist/chunk-WBUFJ7BS.cjs.map +0 -1
  385. package/dist/chunk-XR4YZFKW.cjs.map +0 -1
  386. package/dist/chunk-YNULOIR5.cjs.map +0 -1
  387. package/dist/chunk-ZDH3DX3C.cjs +0 -30
  388. package/dist/chunk-ZDH3DX3C.cjs.map +0 -1
  389. package/dist/chunk-ZTAJL4DT.cjs +0 -85
  390. package/dist/chunk-ZTAJL4DT.cjs.map +0 -1
  391. package/dist/define-graph-DVF-oN1i.d.cts +0 -173
  392. package/dist/define-graph-SvYXOl78.d.ts +0 -173
@@ -1,1396 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk7V2FGGI2_cjs = require('./chunk-7V2FGGI2.cjs');
4
- var chunkCPEL3YIR_cjs = require('./chunk-CPEL3YIR.cjs');
5
- var chunk3PRKZW6D_cjs = require('./chunk-3PRKZW6D.cjs');
6
- var chunkKKYELPZ2_cjs = require('./chunk-KKYELPZ2.cjs');
7
- var chunkACSVZPK7_cjs = require('./chunk-ACSVZPK7.cjs');
8
- var chunkZTAJL4DT_cjs = require('./chunk-ZTAJL4DT.cjs');
9
- var chunkOVUUTCPJ_cjs = require('./chunk-OVUUTCPJ.cjs');
10
- var chunkU5W4LKZV_cjs = require('./chunk-U5W4LKZV.cjs');
11
- var chunk764JHTLT_cjs = require('./chunk-764JHTLT.cjs');
12
- var chunkA4PBRX4C_cjs = require('./chunk-A4PBRX4C.cjs');
13
- var chunkC4F7VJ5D_cjs = require('./chunk-C4F7VJ5D.cjs');
14
- var chunkTDXIBCGY_cjs = require('./chunk-TDXIBCGY.cjs');
15
-
16
- // src/store/row-mappers.ts
17
- function nullToUndefined(value) {
18
- return value === null ? void 0 : value;
19
- }
20
- function rowToNode(row) {
21
- const rawProps = chunk3PRKZW6D_cjs.rowPropsToObject(row.props);
22
- const props = chunkA4PBRX4C_cjs.filterReservedKeys(rawProps, chunkA4PBRX4C_cjs.RESERVED_NODE_KEYS);
23
- return {
24
- kind: row.kind,
25
- id: row.id,
26
- meta: rowToNodeMeta(row),
27
- ...props
28
- };
29
- }
30
- function rowToNodeMeta(row) {
31
- return {
32
- version: row.version,
33
- validFrom: nullToUndefined(row.valid_from),
34
- validTo: nullToUndefined(row.valid_to),
35
- createdAt: row.created_at,
36
- updatedAt: row.updated_at,
37
- deletedAt: nullToUndefined(row.deleted_at)
38
- };
39
- }
40
- function rowToEdge(row) {
41
- const rawProps = chunk3PRKZW6D_cjs.rowPropsToObject(row.props);
42
- const props = chunkA4PBRX4C_cjs.filterReservedKeys(rawProps, chunkA4PBRX4C_cjs.RESERVED_EDGE_KEYS);
43
- return {
44
- id: row.id,
45
- kind: row.kind,
46
- fromKind: row.from_kind,
47
- fromId: row.from_id,
48
- toKind: row.to_kind,
49
- toId: row.to_id,
50
- meta: rowToEdgeMeta(row),
51
- ...props
52
- };
53
- }
54
- function rowToEdgeMeta(row) {
55
- return {
56
- validFrom: nullToUndefined(row.valid_from),
57
- validTo: nullToUndefined(row.valid_to),
58
- createdAt: row.created_at,
59
- updatedAt: row.updated_at,
60
- deletedAt: nullToUndefined(row.deleted_at)
61
- };
62
- }
63
-
64
- // src/store/operations/write-transaction.ts
65
- async function lockSchemaVersionForStoreWrite(ctx, backend) {
66
- const expectedVersion = ctx.schemaVersion;
67
- if (expectedVersion === void 0) return;
68
- if ("transaction" in backend && !backend.capabilities.transactions) {
69
- throw new chunkC4F7VJ5D_cjs.ConfigurationError(
70
- "Schema-managed Store writes require a transactional backend so schema changes and entity writes can share one fence.",
71
- {
72
- code: "SCHEMA_WRITE_FENCE_UNSUPPORTED",
73
- graphId: ctx.graphId
74
- }
75
- );
76
- }
77
- const lockSchemaVersionForWrite = backend.lockSchemaVersionForWrite;
78
- if (lockSchemaVersionForWrite === void 0) {
79
- throw new chunkC4F7VJ5D_cjs.ConfigurationError(
80
- "This backend cannot fence schema-managed Store writes against a concurrent schema change.",
81
- {
82
- code: "SCHEMA_WRITE_FENCE_UNSUPPORTED",
83
- graphId: ctx.graphId
84
- }
85
- );
86
- }
87
- await lockSchemaVersionForWrite({
88
- graphId: ctx.graphId,
89
- expectedVersion
90
- });
91
- }
92
- function runInWriteTransaction(ctx, backend, fn) {
93
- const ownsWriteLock = "transaction" in backend && backend.capabilities.transactions;
94
- return chunk3PRKZW6D_cjs.runOptionallyInTransaction(backend, async (target) => {
95
- await lockSchemaVersionForStoreWrite(ctx, target);
96
- const lock = ctx.historyEnabled || ctx.revisionTrackingEnabled ? await chunk7V2FGGI2_cjs.lockRecordedGraphWrite(target, ctx.graphId) : chunk7V2FGGI2_cjs.uncapturedGraphWriteLock();
97
- const result = await fn(target, lock);
98
- if (ctx.revisionTrackingEnabled && !ctx.historyEnabled) {
99
- await chunk7V2FGGI2_cjs.advanceRevisionClock(
100
- target,
101
- ctx.revisionSchema,
102
- ctx.graphId,
103
- ownsWriteLock
104
- );
105
- }
106
- return result;
107
- });
108
- }
109
- function runHookedWriteOperation(ctx, opContext, backend, body) {
110
- return ctx.withOperationHooks(
111
- opContext,
112
- () => runInWriteTransaction(ctx, backend, body)
113
- );
114
- }
115
-
116
- // src/store/constraints.ts
117
- async function checkDisjointnessConstraint(ctx, kind, id) {
118
- const disjointKinds = ctx.registry.getDisjointKinds(kind);
119
- for (const disjointKind of disjointKinds) {
120
- const existing = await ctx.backend.getNode(ctx.graphId, disjointKind, id);
121
- if (existing && !existing.deleted_at) {
122
- const error = chunk7V2FGGI2_cjs.checkDisjointness(id, kind, [disjointKind], ctx.registry);
123
- if (error) throw error;
124
- }
125
- }
126
- }
127
- async function checkCardinalityConstraint(ctx, edgeKind, cardinality, fromKind, fromId, toKind, toId, validTo) {
128
- switch (cardinality) {
129
- case "many": {
130
- return;
131
- }
132
- case "one": {
133
- const count = await ctx.backend.countEdgesFrom({
134
- graphId: ctx.graphId,
135
- edgeKind,
136
- fromKind,
137
- fromId
138
- });
139
- const error = chunk7V2FGGI2_cjs.checkCardinality(
140
- edgeKind,
141
- fromKind,
142
- fromId,
143
- "one",
144
- count,
145
- false
146
- );
147
- if (error) throw error;
148
- return;
149
- }
150
- case "unique": {
151
- const exists = await ctx.backend.edgeExistsBetween({
152
- graphId: ctx.graphId,
153
- edgeKind,
154
- fromKind,
155
- fromId,
156
- toKind,
157
- toId
158
- });
159
- const error = chunk7V2FGGI2_cjs.checkUniqueEdge(
160
- edgeKind,
161
- fromKind,
162
- fromId,
163
- toKind,
164
- toId,
165
- exists ? 1 : 0
166
- );
167
- if (error) throw error;
168
- return;
169
- }
170
- case "oneActive": {
171
- if (validTo !== void 0) {
172
- return;
173
- }
174
- const count = await ctx.backend.countEdgesFrom({
175
- graphId: ctx.graphId,
176
- edgeKind,
177
- fromKind,
178
- fromId,
179
- activeOnly: true
180
- });
181
- const error = chunk7V2FGGI2_cjs.checkCardinality(
182
- edgeKind,
183
- fromKind,
184
- fromId,
185
- "oneActive",
186
- count,
187
- count > 0
188
- );
189
- if (error) throw error;
190
- return;
191
- }
192
- }
193
- }
194
-
195
- // src/store/operations/node-operations.ts
196
- function getNodeRegistration(graph, kind) {
197
- const registration = graph.nodes[kind];
198
- if (registration === void 0) throw new chunkC4F7VJ5D_cjs.KindNotFoundError(kind, "node");
199
- return registration;
200
- }
201
- var CACHE_KEY_SEPARATOR = "\0";
202
- function buildNodeCacheKey(graphId, kind, id) {
203
- return `${graphId}${CACHE_KEY_SEPARATOR}${kind}${CACHE_KEY_SEPARATOR}${id}`;
204
- }
205
- function buildUniqueCacheKey(graphId, nodeKind, constraintName, key) {
206
- return `${graphId}${CACHE_KEY_SEPARATOR}${nodeKind}${CACHE_KEY_SEPARATOR}${constraintName}${CACHE_KEY_SEPARATOR}${key}`;
207
- }
208
- function createNodeAlreadyExistsError(kind, id) {
209
- return new chunkC4F7VJ5D_cjs.ValidationError(
210
- `Node already exists: ${kind}/${id}`,
211
- {
212
- entityType: "node",
213
- kind,
214
- operation: "create",
215
- id,
216
- issues: [{ path: "id", message: "A node with this ID already exists" }]
217
- },
218
- { suggestion: `Use a different ID or update the existing node.` }
219
- );
220
- }
221
- function buildInsertNodeParams(graphId, kind, id, props, validFrom, validTo) {
222
- const insertParams = {
223
- graphId,
224
- kind,
225
- id,
226
- props
227
- };
228
- if (validFrom !== void 0) insertParams.validFrom = validFrom;
229
- if (validTo !== void 0) insertParams.validTo = validTo;
230
- return insertParams;
231
- }
232
- function createPendingUniqueRow(graphId, nodeKind, constraintName, key, nodeId) {
233
- return {
234
- graph_id: graphId,
235
- node_kind: nodeKind,
236
- constraint_name: constraintName,
237
- key,
238
- node_id: nodeId,
239
- concrete_kind: nodeKind,
240
- deleted_at: void 0
241
- };
242
- }
243
- function resolveConstraint(graph, kind, constraintName) {
244
- const registration = getNodeRegistration(graph, kind);
245
- const constraints = registration.unique ?? [];
246
- const constraint = constraints.find(
247
- (candidate) => candidate.name === constraintName
248
- );
249
- if (constraint === void 0) {
250
- throw new chunkC4F7VJ5D_cjs.NodeConstraintNotFoundError(constraintName, kind);
251
- }
252
- return constraint;
253
- }
254
- function createNodeBatchValidationBackend(graphId, registry, backend) {
255
- const nodeCache = /* @__PURE__ */ new Map();
256
- const pendingNodes = /* @__PURE__ */ new Map();
257
- const uniqueCache = /* @__PURE__ */ new Map();
258
- const pendingUniqueOwners = /* @__PURE__ */ new Map();
259
- async function getNodeCached(lookupGraphId, kind, id) {
260
- const cacheKey = buildNodeCacheKey(lookupGraphId, kind, id);
261
- const pendingNode = pendingNodes.get(cacheKey);
262
- if (pendingNode !== void 0) return pendingNode;
263
- if (nodeCache.has(cacheKey)) return nodeCache.get(cacheKey);
264
- const existing = await backend.getNode(lookupGraphId, kind, id);
265
- nodeCache.set(cacheKey, existing);
266
- return existing;
267
- }
268
- async function checkUniqueCached(params) {
269
- const cacheKey = buildUniqueCacheKey(
270
- params.graphId,
271
- params.nodeKind,
272
- params.constraintName,
273
- params.key
274
- );
275
- const pendingOwner = pendingUniqueOwners.get(cacheKey);
276
- if (pendingOwner !== void 0) {
277
- return createPendingUniqueRow(
278
- params.graphId,
279
- params.nodeKind,
280
- params.constraintName,
281
- params.key,
282
- pendingOwner
283
- );
284
- }
285
- if (uniqueCache.has(cacheKey)) return uniqueCache.get(cacheKey);
286
- const existing = await backend.checkUnique(params);
287
- uniqueCache.set(cacheKey, existing);
288
- return existing;
289
- }
290
- function registerPendingNode(params) {
291
- const cacheKey = buildNodeCacheKey(params.graphId, params.kind, params.id);
292
- pendingNodes.set(cacheKey, {
293
- graph_id: params.graphId,
294
- kind: params.kind,
295
- id: params.id,
296
- props: JSON.stringify(params.props),
297
- version: 1,
298
- // The simulated cached row only needs a NodeRow-shaped valid_from
299
- // (string | undefined, never null) for existence/uniqueness checks,
300
- // which don't inspect its value — normalize import's explicit-NULL
301
- // sentinel away rather than widen this cache's row shape.
302
- valid_from: params.validFrom ?? void 0,
303
- valid_to: params.validTo,
304
- created_at: "",
305
- updated_at: "",
306
- deleted_at: void 0
307
- });
308
- }
309
- function registerPendingUniqueEntries(kind, id, props, constraints) {
310
- for (const constraint of constraints) {
311
- if (!chunk7V2FGGI2_cjs.checkWherePredicate(constraint, props)) continue;
312
- const key = chunk7V2FGGI2_cjs.computeUniqueKey(
313
- props,
314
- constraint.fields,
315
- constraint.collation
316
- );
317
- const concreteEntryKey = buildUniqueCacheKey(
318
- graphId,
319
- kind,
320
- constraint.name,
321
- key
322
- );
323
- pendingUniqueOwners.set(concreteEntryKey, id);
324
- if (constraint.scope !== "kind") {
325
- const kindsToCheck = chunk7V2FGGI2_cjs.getKindsForUniquenessCheck(
326
- kind,
327
- constraint.scope,
328
- registry
329
- );
330
- for (const kindToCheck of kindsToCheck) {
331
- const inheritedEntryKey = buildUniqueCacheKey(
332
- graphId,
333
- kindToCheck,
334
- constraint.name,
335
- key
336
- );
337
- pendingUniqueOwners.set(inheritedEntryKey, id);
338
- }
339
- }
340
- }
341
- }
342
- function registerAppliedNodeUpdate(kind, id, oldProps, newProps, constraints) {
343
- for (const constraint of constraints) {
344
- const oldApplies = chunk7V2FGGI2_cjs.checkWherePredicate(constraint, oldProps);
345
- const newApplies = chunk7V2FGGI2_cjs.checkWherePredicate(constraint, newProps);
346
- const oldKey = oldApplies ? chunk7V2FGGI2_cjs.computeUniqueKey(oldProps, constraint.fields, constraint.collation) : void 0;
347
- const newKey = newApplies ? chunk7V2FGGI2_cjs.computeUniqueKey(newProps, constraint.fields, constraint.collation) : void 0;
348
- if (oldKey === newKey) continue;
349
- const kindsToCheck = chunk7V2FGGI2_cjs.getKindsForUniquenessCheck(
350
- kind,
351
- constraint.scope,
352
- registry
353
- );
354
- if (oldKey !== void 0) {
355
- for (const kindToCheck of kindsToCheck) {
356
- const cacheKey = buildUniqueCacheKey(
357
- graphId,
358
- kindToCheck,
359
- constraint.name,
360
- oldKey
361
- );
362
- pendingUniqueOwners.delete(cacheKey);
363
- uniqueCache.set(cacheKey, void 0);
364
- }
365
- }
366
- if (newKey !== void 0) {
367
- for (const kindToCheck of kindsToCheck) {
368
- const cacheKey = buildUniqueCacheKey(
369
- graphId,
370
- kindToCheck,
371
- constraint.name,
372
- newKey
373
- );
374
- pendingUniqueOwners.set(cacheKey, id);
375
- }
376
- }
377
- }
378
- }
379
- function seedNodeRow(kind, id, row) {
380
- const cacheKey = buildNodeCacheKey(graphId, kind, id);
381
- if (nodeCache.has(cacheKey)) return;
382
- nodeCache.set(cacheKey, row);
383
- }
384
- function seedUniqueRow(kind, constraintName, key, row) {
385
- const cacheKey = buildUniqueCacheKey(graphId, kind, constraintName, key);
386
- if (uniqueCache.has(cacheKey)) return;
387
- uniqueCache.set(cacheKey, row);
388
- }
389
- const validationBackend = chunk3PRKZW6D_cjs.createBackendOverlay(backend, {
390
- getNode: getNodeCached,
391
- checkUnique: checkUniqueCached
392
- });
393
- return {
394
- backend: validationBackend,
395
- registerPendingNode,
396
- registerPendingUniqueEntries,
397
- registerAppliedNodeUpdate,
398
- seedNodeRow,
399
- seedUniqueRow
400
- };
401
- }
402
- function draftNodeCreate(ctx, input, id, options) {
403
- const kind = input.kind;
404
- const registration = getNodeRegistration(ctx.graph, kind);
405
- const nodeKind = registration.type;
406
- const validatedProps = options?.propsPreValidated === true ? input.props : chunkKKYELPZ2_cjs.validateNodeProps(nodeKind.schema, input.props, {
407
- kind,
408
- operation: "create"
409
- });
410
- return {
411
- kind,
412
- id,
413
- nodeKind,
414
- uniqueConstraints: registration.unique ?? [],
415
- validatedProps,
416
- validFrom: chunkZTAJL4DT_cjs.validateOptionalCanonicalIsoDate(input.validFrom, "validFrom"),
417
- validTo: chunkZTAJL4DT_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo")
418
- };
419
- }
420
- async function finishNodeCreatePreparation(ctx, draft, backend) {
421
- const { kind, id, validatedProps, uniqueConstraints } = draft;
422
- const existingNode = await backend.getNode(ctx.graphId, kind, id);
423
- if (existingNode && !existingNode.deleted_at) {
424
- throw createNodeAlreadyExistsError(kind, id);
425
- }
426
- const constraintContext = {
427
- graphId: ctx.graphId,
428
- registry: ctx.registry,
429
- backend
430
- };
431
- await checkDisjointnessConstraint(constraintContext, kind, id);
432
- await chunk7V2FGGI2_cjs.checkUniquenessConstraints(
433
- chunk7V2FGGI2_cjs.createUniquenessContext(ctx.graphId, ctx.registry, backend),
434
- kind,
435
- id,
436
- validatedProps,
437
- uniqueConstraints
438
- );
439
- return {
440
- kind,
441
- id,
442
- nodeKind: draft.nodeKind,
443
- validatedProps,
444
- uniqueConstraints,
445
- insertParams: buildInsertNodeParams(
446
- ctx.graphId,
447
- kind,
448
- id,
449
- validatedProps,
450
- draft.validFrom,
451
- draft.validTo
452
- )
453
- };
454
- }
455
- async function validateAndPrepareNodeCreate(ctx, input, id, backend, options) {
456
- return finishNodeCreatePreparation(
457
- ctx,
458
- draftNodeCreate(ctx, input, id, options),
459
- backend
460
- );
461
- }
462
- async function finalizeNodeCreateBatch(ctx, preparedCreates, backend, lock) {
463
- await chunk7V2FGGI2_cjs.applyNodeInsertSideEffectsBatch(
464
- chunk7V2FGGI2_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
465
- preparedCreates.map((prepared) => ({
466
- kind: prepared.kind,
467
- id: prepared.id,
468
- schema: prepared.nodeKind.schema,
469
- props: prepared.validatedProps,
470
- uniqueConstraints: prepared.uniqueConstraints
471
- })),
472
- backend
473
- );
474
- }
475
- async function finalizeNodeCreate(ctx, prepared, backend, lock) {
476
- await chunk7V2FGGI2_cjs.applyNodeInsertSideEffects(
477
- chunk7V2FGGI2_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
478
- {
479
- kind: prepared.kind,
480
- id: prepared.id,
481
- schema: prepared.nodeKind.schema,
482
- props: prepared.validatedProps,
483
- uniqueConstraints: prepared.uniqueConstraints
484
- },
485
- backend
486
- );
487
- }
488
- function computeNodeUpdate(ctx, kind, id, existingProps, inputProps) {
489
- const registration = getNodeRegistration(ctx.graph, kind);
490
- const validatedProps = chunkKKYELPZ2_cjs.validateNodeProps(
491
- registration.type.schema,
492
- { ...existingProps, ...inputProps },
493
- { kind, operation: "update", id }
494
- );
495
- return { registration, validatedProps };
496
- }
497
- function resolveNodeUpdateProps(ctx, existing, inputProps) {
498
- const existingProps = chunk3PRKZW6D_cjs.rowPropsToObject(existing.props);
499
- const { registration, validatedProps } = computeNodeUpdate(
500
- ctx,
501
- existing.kind,
502
- existing.id,
503
- existingProps,
504
- inputProps
505
- );
506
- return { registration, existingProps, validatedProps };
507
- }
508
- function nodeUpsertDirtyCheck(ctx, kind, id, existingProps, inputProps) {
509
- const { validatedProps } = computeNodeUpdate(
510
- ctx,
511
- kind,
512
- id,
513
- existingProps,
514
- inputProps
515
- );
516
- return {
517
- validatedProps,
518
- unchanged: chunkACSVZPK7_cjs.canonicalEqual(validatedProps, existingProps)
519
- };
520
- }
521
- async function performNodeUpdate(ctx, input, backend, lock, options) {
522
- const { kind, id } = input;
523
- const existing = await backend.getNode(ctx.graphId, kind, id);
524
- if (!existing) throw new chunkC4F7VJ5D_cjs.NodeNotFoundError(kind, id);
525
- const { registration, validatedProps } = resolveNodeUpdateProps(
526
- ctx,
527
- existing,
528
- input.props
529
- );
530
- const nodeKind = registration.type;
531
- const validTo = chunkZTAJL4DT_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
532
- const writeContext = chunk7V2FGGI2_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock);
533
- const shared = {
534
- schema: nodeKind.schema,
535
- validatedProps,
536
- uniqueConstraints: registration.unique ?? [],
537
- ...validTo !== void 0 && { validTo }
538
- };
539
- if (options?.clearDeleted) {
540
- const row2 = await chunk7V2FGGI2_cjs.applyNodeUpdate(
541
- writeContext,
542
- { ...shared, existing, clearDeleted: true },
543
- backend
544
- );
545
- return rowToNode(row2);
546
- }
547
- if (!chunk3PRKZW6D_cjs.isLiveNodeRow(existing)) throw new chunkC4F7VJ5D_cjs.NodeNotFoundError(kind, id);
548
- const row = await chunk7V2FGGI2_cjs.applyNodeUpdate(
549
- writeContext,
550
- { ...shared, existing },
551
- backend
552
- );
553
- return rowToNode(row);
554
- }
555
- async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
556
- if (backend.getNodes !== void 0) {
557
- const idsByKind = /* @__PURE__ */ new Map();
558
- for (const draft of drafts) {
559
- const ids = idsByKind.get(draft.kind) ?? /* @__PURE__ */ new Set();
560
- ids.add(draft.id);
561
- idsByKind.set(draft.kind, ids);
562
- }
563
- for (const [kind, ids] of idsByKind) {
564
- const orderedIds = [...ids];
565
- const rows = await backend.getNodes(ctx.graphId, kind, orderedIds);
566
- const rowsById = new Map(rows.map((row) => [row.id, row]));
567
- for (const id of orderedIds) {
568
- seams.seedNodeRow(kind, id, rowsById.get(id));
569
- }
570
- }
571
- }
572
- if (backend.checkUniqueBatch !== void 0) {
573
- const groups = /* @__PURE__ */ new Map();
574
- for (const draft of drafts) {
575
- for (const constraint of draft.uniqueConstraints) {
576
- if (!chunk7V2FGGI2_cjs.checkWherePredicate(constraint, draft.validatedProps)) continue;
577
- const key = chunk7V2FGGI2_cjs.computeUniqueKey(
578
- draft.validatedProps,
579
- constraint.fields,
580
- constraint.collation
581
- );
582
- const kindsToCheck = chunk7V2FGGI2_cjs.getKindsForUniquenessCheck(
583
- draft.kind,
584
- constraint.scope,
585
- ctx.registry
586
- );
587
- for (const kindToCheck of kindsToCheck) {
588
- const groupKey = kindToCheck + CACHE_KEY_SEPARATOR + constraint.name;
589
- const group = groups.get(groupKey) ?? {
590
- nodeKind: kindToCheck,
591
- constraintName: constraint.name,
592
- keys: /* @__PURE__ */ new Set()
593
- };
594
- group.keys.add(key);
595
- groups.set(groupKey, group);
596
- }
597
- }
598
- }
599
- for (const group of groups.values()) {
600
- const orderedKeys = [...group.keys];
601
- const rows = await backend.checkUniqueBatch({
602
- graphId: ctx.graphId,
603
- nodeKind: group.nodeKind,
604
- constraintName: group.constraintName,
605
- keys: orderedKeys
606
- });
607
- const rowsByKey = new Map(rows.map((row) => [row.key, row]));
608
- for (const key of orderedKeys) {
609
- seams.seedUniqueRow(
610
- group.nodeKind,
611
- group.constraintName,
612
- key,
613
- rowsByKey.get(key)
614
- );
615
- }
616
- }
617
- }
618
- }
619
- async function prepareBatchCreates(ctx, inputs, backend, options) {
620
- const {
621
- backend: validationBackend,
622
- registerPendingNode,
623
- registerPendingUniqueEntries,
624
- seedNodeRow,
625
- seedUniqueRow
626
- } = createNodeBatchValidationBackend(ctx.graphId, ctx.registry, backend);
627
- const drafts = inputs.map(
628
- (input) => draftNodeCreate(ctx, input, input.id ?? chunk7V2FGGI2_cjs.generateId(), options)
629
- );
630
- await primeBatchValidationCaches(ctx, drafts, backend, {
631
- seedNodeRow,
632
- seedUniqueRow
633
- });
634
- const preparedCreates = [];
635
- for (const draft of drafts) {
636
- const prepared = await finishNodeCreatePreparation(
637
- ctx,
638
- draft,
639
- validationBackend
640
- );
641
- preparedCreates.push(prepared);
642
- registerPendingNode(prepared.insertParams);
643
- registerPendingUniqueEntries(
644
- prepared.kind,
645
- prepared.id,
646
- prepared.validatedProps,
647
- prepared.uniqueConstraints
648
- );
649
- }
650
- const batchInsertParams = preparedCreates.map(
651
- (prepared) => prepared.insertParams
652
- );
653
- return { preparedCreates, batchInsertParams };
654
- }
655
- async function findUniqueRowAcrossKinds(backend, graphId, constraintName, key, kindsToCheck, includeDeleted) {
656
- for (const kindToCheck of kindsToCheck) {
657
- const row = await backend.checkUnique({
658
- graphId,
659
- nodeKind: kindToCheck,
660
- constraintName,
661
- key,
662
- includeDeleted
663
- });
664
- if (row !== void 0) return row;
665
- }
666
- return void 0;
667
- }
668
- async function batchCheckUniqueAcrossKinds(backend, graphId, constraintName, uniqueKeys, kindsToCheck, includeDeleted) {
669
- const existingByKey = /* @__PURE__ */ new Map();
670
- for (const kindToCheck of kindsToCheck) {
671
- if (backend.checkUniqueBatch === void 0) {
672
- for (const key of uniqueKeys) {
673
- if (existingByKey.has(key)) continue;
674
- const row = await backend.checkUnique({
675
- graphId,
676
- nodeKind: kindToCheck,
677
- constraintName,
678
- key,
679
- includeDeleted
680
- });
681
- if (row !== void 0) {
682
- existingByKey.set(row.key, row);
683
- }
684
- }
685
- } else {
686
- const rows = await backend.checkUniqueBatch({
687
- graphId,
688
- nodeKind: kindToCheck,
689
- constraintName,
690
- keys: uniqueKeys,
691
- includeDeleted
692
- });
693
- for (const row of rows) {
694
- if (!existingByKey.has(row.key)) {
695
- existingByKey.set(row.key, row);
696
- }
697
- }
698
- }
699
- }
700
- return existingByKey;
701
- }
702
- async function executeNodeCreateInternal(ctx, input, backend, options) {
703
- const kind = input.kind;
704
- const id = input.id ?? chunk7V2FGGI2_cjs.generateId();
705
- const opContext = ctx.createOperationContext("create", "node", kind, id);
706
- const shouldReturnRow = options?.returnRow ?? true;
707
- return runHookedWriteOperation(
708
- ctx,
709
- opContext,
710
- backend,
711
- async (target, lock) => {
712
- const prepared = await validateAndPrepareNodeCreate(
713
- ctx,
714
- input,
715
- id,
716
- target,
717
- options
718
- );
719
- let row;
720
- if (shouldReturnRow) {
721
- row = await target.insertNode(prepared.insertParams);
722
- } else {
723
- await chunk7V2FGGI2_cjs.runInsertNoReturn(
724
- chunk7V2FGGI2_cjs.nodeInsertDispatch(target),
725
- prepared.insertParams
726
- );
727
- }
728
- await finalizeNodeCreate(ctx, prepared, target, lock);
729
- if (row === void 0) return;
730
- return rowToNode(row);
731
- }
732
- );
733
- }
734
- async function executeNodeCreate(ctx, input, backend, options) {
735
- const result = await executeNodeCreateInternal(ctx, input, backend, {
736
- returnRow: true,
737
- ...options
738
- });
739
- if (!result) {
740
- throw new chunkC4F7VJ5D_cjs.DatabaseOperationError(
741
- "Node create failed: expected created node row",
742
- { operation: "insert", entity: "node" }
743
- );
744
- }
745
- return result;
746
- }
747
- async function executeNodeCreateNoReturnBatch(ctx, inputs, backend) {
748
- if (inputs.length === 0) return;
749
- await runInWriteTransaction(ctx, backend, async (target, lock) => {
750
- const { preparedCreates, batchInsertParams } = await prepareBatchCreates(
751
- ctx,
752
- inputs,
753
- target
754
- );
755
- await chunk7V2FGGI2_cjs.runInsertBatch(chunk7V2FGGI2_cjs.nodeInsertDispatch(target), batchInsertParams);
756
- await finalizeNodeCreateBatch(ctx, preparedCreates, target, lock);
757
- });
758
- }
759
- async function executeNodeCreateBatch(ctx, inputs, backend, options) {
760
- if (inputs.length === 0) return [];
761
- return runInWriteTransaction(ctx, backend, async (target, lock) => {
762
- const { preparedCreates, batchInsertParams } = await prepareBatchCreates(
763
- ctx,
764
- inputs,
765
- target,
766
- options
767
- );
768
- const rows = await chunk7V2FGGI2_cjs.runInsertBatchReturning(
769
- chunk7V2FGGI2_cjs.nodeInsertDispatch(target),
770
- batchInsertParams
771
- );
772
- await finalizeNodeCreateBatch(ctx, preparedCreates, target, lock);
773
- return rows.map((row) => rowToNode(row));
774
- });
775
- }
776
- async function executeNodeUpdate(ctx, input, backend, options) {
777
- const opContext = ctx.createOperationContext(
778
- "update",
779
- "node",
780
- input.kind,
781
- input.id
782
- );
783
- return runHookedWriteOperation(
784
- ctx,
785
- opContext,
786
- backend,
787
- (target, lock) => performNodeUpdate(ctx, input, target, lock, options)
788
- );
789
- }
790
- async function executeNodeUpsertUpdate(ctx, input, backend, options) {
791
- return runInWriteTransaction(
792
- ctx,
793
- backend,
794
- (target, lock) => performNodeUpdate(ctx, input, target, lock, options)
795
- );
796
- }
797
- async function executeNodeDelete(ctx, kind, id, backend) {
798
- const gate = await backend.getNode(ctx.graphId, kind, id);
799
- if (!gate || gate.deleted_at) return;
800
- const opContext = ctx.createOperationContext("delete", "node", kind, id);
801
- return runHookedWriteOperation(
802
- ctx,
803
- opContext,
804
- backend,
805
- async (target, lock) => {
806
- const registration = getNodeRegistration(ctx.graph, kind);
807
- const preflight = await target.getNode(ctx.graphId, kind, id);
808
- if (!preflight || !chunk3PRKZW6D_cjs.isLiveNodeRow(preflight)) return;
809
- await chunk7V2FGGI2_cjs.applyNodeSoftDelete(
810
- chunk7V2FGGI2_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
811
- {
812
- existing: preflight,
813
- schema: registration.type.schema,
814
- uniqueConstraints: registration.unique ?? [],
815
- onDelete: registration.onDelete
816
- },
817
- target
818
- );
819
- }
820
- );
821
- }
822
- async function executeNodeHardDelete(ctx, kind, id, backend) {
823
- const gate = await backend.getNode(ctx.graphId, kind, id);
824
- if (!gate) return;
825
- const opContext = ctx.createOperationContext("delete", "node", kind, id);
826
- return runHookedWriteOperation(
827
- ctx,
828
- opContext,
829
- backend,
830
- async (target, lock) => {
831
- const registration = getNodeRegistration(ctx.graph, kind);
832
- await chunk7V2FGGI2_cjs.applyNodeHardDelete(
833
- chunk7V2FGGI2_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
834
- {
835
- kind,
836
- id,
837
- schema: registration.type.schema,
838
- onDelete: registration.onDelete
839
- },
840
- target
841
- );
842
- }
843
- );
844
- }
845
- async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, props, backend, options) {
846
- const ifExists = options?.ifExists ?? "return";
847
- const registration = getNodeRegistration(ctx.graph, kind);
848
- const nodeKind = registration.type;
849
- const validatedProps = chunkKKYELPZ2_cjs.validateNodeProps(nodeKind.schema, props, {
850
- kind,
851
- operation: "create"
852
- });
853
- const constraint = resolveConstraint(ctx.graph, kind, constraintName);
854
- if (!chunk7V2FGGI2_cjs.checkWherePredicate(constraint, validatedProps)) {
855
- const node = await executeNodeCreate(
856
- ctx,
857
- { kind, props: validatedProps },
858
- backend,
859
- { propsPreValidated: true }
860
- );
861
- return { node, action: "created" };
862
- }
863
- const key = chunk7V2FGGI2_cjs.computeUniqueKey(
864
- validatedProps,
865
- constraint.fields,
866
- constraint.collation
867
- );
868
- const kindsToCheck = chunk7V2FGGI2_cjs.getKindsForUniquenessCheck(
869
- kind,
870
- constraint.scope,
871
- ctx.registry
872
- );
873
- async function attempt() {
874
- const existingUniqueRow = await findUniqueRowAcrossKinds(
875
- backend,
876
- ctx.graphId,
877
- constraint.name,
878
- key,
879
- kindsToCheck,
880
- true
881
- );
882
- if (existingUniqueRow === void 0) {
883
- const node = await executeNodeCreate(
884
- ctx,
885
- { kind, props: validatedProps },
886
- backend,
887
- { propsPreValidated: true }
888
- );
889
- return { node, action: "created" };
890
- }
891
- const existingRow = await backend.getNode(
892
- ctx.graphId,
893
- existingUniqueRow.concrete_kind,
894
- existingUniqueRow.node_id
895
- );
896
- if (existingRow === void 0) {
897
- const node = await executeNodeCreate(
898
- ctx,
899
- { kind, props: validatedProps },
900
- backend,
901
- { propsPreValidated: true }
902
- );
903
- return { node, action: "created" };
904
- }
905
- const isSoftDeleted = existingRow.deleted_at !== void 0;
906
- if (isSoftDeleted || ifExists === "update") {
907
- const concreteKind = existingUniqueRow.concrete_kind;
908
- const node = await executeNodeUpsertUpdate(
909
- ctx,
910
- {
911
- kind: concreteKind,
912
- id: existingRow.id,
913
- props: validatedProps
914
- },
915
- backend,
916
- { clearDeleted: isSoftDeleted }
917
- );
918
- return { node, action: isSoftDeleted ? "resurrected" : "updated" };
919
- }
920
- return { node: rowToNode(existingRow), action: "found" };
921
- }
922
- try {
923
- return await attempt();
924
- } catch (error) {
925
- if (!(error instanceof chunkC4F7VJ5D_cjs.UniquenessError)) throw error;
926
- return attempt();
927
- }
928
- }
929
- async function executeNodeFindByConstraint(ctx, kind, constraintName, props, backend) {
930
- const registration = getNodeRegistration(ctx.graph, kind);
931
- const nodeKind = registration.type;
932
- const validatedProps = chunkKKYELPZ2_cjs.validateNodeProps(nodeKind.schema, props, {
933
- kind,
934
- operation: "create"
935
- });
936
- const constraint = resolveConstraint(ctx.graph, kind, constraintName);
937
- if (!chunk7V2FGGI2_cjs.checkWherePredicate(constraint, validatedProps)) return void 0;
938
- const key = chunk7V2FGGI2_cjs.computeUniqueKey(
939
- validatedProps,
940
- constraint.fields,
941
- constraint.collation
942
- );
943
- const kindsToCheck = chunk7V2FGGI2_cjs.getKindsForUniquenessCheck(
944
- kind,
945
- constraint.scope,
946
- ctx.registry
947
- );
948
- const existingUniqueRow = await findUniqueRowAcrossKinds(
949
- backend,
950
- ctx.graphId,
951
- constraint.name,
952
- key,
953
- kindsToCheck,
954
- false
955
- );
956
- if (existingUniqueRow === void 0) return void 0;
957
- const existingRow = await backend.getNode(
958
- ctx.graphId,
959
- existingUniqueRow.concrete_kind,
960
- existingUniqueRow.node_id
961
- );
962
- if (existingRow === void 0 || existingRow.deleted_at !== void 0)
963
- return void 0;
964
- return rowToNode(existingRow);
965
- }
966
- function validateAndComputeKeys(nodeKind, kind, constraint, items) {
967
- const validated = [];
968
- for (const item of items) {
969
- const validatedProps = chunkKKYELPZ2_cjs.validateNodeProps(nodeKind.schema, item.props, {
970
- kind,
971
- operation: "create"
972
- });
973
- const applies = chunk7V2FGGI2_cjs.checkWherePredicate(constraint, validatedProps);
974
- const key = applies ? chunk7V2FGGI2_cjs.computeUniqueKey(
975
- validatedProps,
976
- constraint.fields,
977
- constraint.collation
978
- ) : void 0;
979
- validated.push({ validatedProps, key });
980
- }
981
- return validated;
982
- }
983
- function collectUniqueKeys(validated) {
984
- return [
985
- ...new Set(
986
- validated.map((entry) => entry.key).filter((key) => key !== void 0)
987
- )
988
- ];
989
- }
990
- async function executeNodeBulkFindByConstraint(ctx, kind, constraintName, items, backend) {
991
- if (items.length === 0) return [];
992
- const registration = getNodeRegistration(ctx.graph, kind);
993
- const nodeKind = registration.type;
994
- const constraint = resolveConstraint(ctx.graph, kind, constraintName);
995
- const validated = validateAndComputeKeys(nodeKind, kind, constraint, items);
996
- const uniqueKeys = collectUniqueKeys(validated);
997
- const kindsToCheck = chunk7V2FGGI2_cjs.getKindsForUniquenessCheck(
998
- kind,
999
- constraint.scope,
1000
- ctx.registry
1001
- );
1002
- const existingByKey = uniqueKeys.length > 0 ? await batchCheckUniqueAcrossKinds(
1003
- backend,
1004
- ctx.graphId,
1005
- constraint.name,
1006
- uniqueKeys,
1007
- kindsToCheck,
1008
- false
1009
- ) : /* @__PURE__ */ new Map();
1010
- const results = Array.from({ length: items.length });
1011
- const seenKeys = /* @__PURE__ */ new Map();
1012
- for (const [index, { key }] of validated.entries()) {
1013
- if (key === void 0) {
1014
- results[index] = void 0;
1015
- continue;
1016
- }
1017
- const previousIndex = seenKeys.get(key);
1018
- if (previousIndex !== void 0) {
1019
- results[index] = results[previousIndex];
1020
- continue;
1021
- }
1022
- seenKeys.set(key, index);
1023
- const existing = existingByKey.get(key);
1024
- if (existing === void 0) {
1025
- results[index] = void 0;
1026
- continue;
1027
- }
1028
- const existingRow = await backend.getNode(
1029
- ctx.graphId,
1030
- existing.concrete_kind,
1031
- existing.node_id
1032
- );
1033
- if (existingRow === void 0 || existingRow.deleted_at !== void 0) {
1034
- results[index] = void 0;
1035
- continue;
1036
- }
1037
- results[index] = rowToNode(existingRow);
1038
- }
1039
- return results;
1040
- }
1041
- function resolveNodeIndex(graph, kind, indexName) {
1042
- getNodeRegistration(graph, kind);
1043
- const declaration = graph.indexes?.find(
1044
- (candidate) => candidate.entity === "node" && candidate.kind === kind && candidate.name === indexName
1045
- );
1046
- if (declaration?.entity !== "node") {
1047
- throw new chunkC4F7VJ5D_cjs.NodeIndexNotFoundError(indexName, kind);
1048
- }
1049
- if (declaration.method !== void 0) {
1050
- throw new chunkC4F7VJ5D_cjs.ConfigurationError(
1051
- `bulkFindByIndex cannot probe index "${indexName}" (method "${declaration.method}"): only btree indexes serve equality probes.`,
1052
- { indexName, kind, method: declaration.method }
1053
- );
1054
- }
1055
- return declaration;
1056
- }
1057
- var INDEX_PROBE_EXPECTED_TYPEOF = {
1058
- string: "string",
1059
- number: "number",
1060
- boolean: "boolean"
1061
- };
1062
- function validateIndexProbeValue(value, valueType, pointer, kind) {
1063
- if (value === void 0 || value === null) return;
1064
- if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean" && !(value instanceof Date)) {
1065
- throw indexProbeTypeError(
1066
- pointer,
1067
- kind,
1068
- "a scalar (string, number, boolean, or Date)",
1069
- value
1070
- );
1071
- }
1072
- if (valueType === "date") {
1073
- if (value instanceof Date || typeof value === "string") return;
1074
- throw indexProbeTypeError(
1075
- pointer,
1076
- kind,
1077
- "date (Date or ISO string)",
1078
- value
1079
- );
1080
- }
1081
- const expected = INDEX_PROBE_EXPECTED_TYPEOF[valueType ?? "unknown"];
1082
- if (expected === void 0) return;
1083
- if (typeof value !== expected) {
1084
- throw indexProbeTypeError(pointer, kind, expected, value);
1085
- }
1086
- }
1087
- function indexProbeTypeError(pointer, kind, expected, value) {
1088
- return new chunkC4F7VJ5D_cjs.ValidationError(
1089
- `Index probe value for "${pointer}" on node kind "${kind}" has an incompatible type`,
1090
- {
1091
- entityType: "node",
1092
- kind,
1093
- issues: [
1094
- {
1095
- path: pointer,
1096
- message: `Expected ${expected}, received ${typeof value}`,
1097
- code: "invalid_type"
1098
- }
1099
- ]
1100
- }
1101
- );
1102
- }
1103
- function coerceIndexProbeBind(value, adapter) {
1104
- return adapter.bindValue(normalizeProbeScalar(value));
1105
- }
1106
- function normalizeProbeScalar(value) {
1107
- return value instanceof Date ? value.toISOString() : value;
1108
- }
1109
- var PROBE_NULL_TAG = 0;
1110
- var PROBE_VALUE_TAG = 1;
1111
- function canonicalIndexProbeKey(probe) {
1112
- return JSON.stringify(
1113
- probe.map(
1114
- (value) => value === void 0 || value === null ? [PROBE_NULL_TAG] : [PROBE_VALUE_TAG, normalizeProbeScalar(value)]
1115
- )
1116
- );
1117
- }
1118
- async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend, options) {
1119
- if (items.length === 0) return [];
1120
- const index = resolveNodeIndex(ctx.graph, kind, indexName);
1121
- if (index.fields.length === 0) {
1122
- throw new chunkC4F7VJ5D_cjs.ConfigurationError(
1123
- `bulkFindByIndex requires an index with at least one prop-based field on index "${indexName}" (node kind "${kind}")`,
1124
- { indexName, kind },
1125
- {
1126
- suggestion: "bulkFindByIndex probes by prop values from each item; an index declared with only keySystemColumns/coveringFields (no fields) has nothing to probe by."
1127
- }
1128
- );
1129
- }
1130
- if (index.fieldValueTypes.includes("date")) {
1131
- throw new chunkC4F7VJ5D_cjs.ConfigurationError(
1132
- `bulkFindByIndex does not support date-typed key fields on index "${indexName}" (node kind "${kind}")`,
1133
- { indexName, kind },
1134
- {
1135
- suggestion: "Date index keys compare differently across SQLite and PostgreSQL. Use a string-encoded key field, or query date predicates via store.query(...).where(...)."
1136
- }
1137
- );
1138
- }
1139
- const limitPerInput = options?.limitPerInput;
1140
- if (limitPerInput !== void 0 && (!Number.isInteger(limitPerInput) || limitPerInput <= 0)) {
1141
- throw new chunkC4F7VJ5D_cjs.ValidationError(
1142
- "bulkFindByIndex limitPerInput must be a positive integer",
1143
- {
1144
- entityType: "node",
1145
- kind,
1146
- issues: [
1147
- {
1148
- path: "limitPerInput",
1149
- message: `Expected a positive integer, received ${String(limitPerInput)}`,
1150
- code: "invalid_value"
1151
- }
1152
- ]
1153
- }
1154
- );
1155
- }
1156
- const adapter = chunkOVUUTCPJ_cjs.getDialect(backend.dialect);
1157
- const probes = items.map(
1158
- (item) => index.fields.map((pointer, position) => {
1159
- const value = chunkTDXIBCGY_cjs.resolveJsonPointer(item.props, pointer);
1160
- validateIndexProbeValue(
1161
- value,
1162
- index.fieldValueTypes[position],
1163
- pointer,
1164
- kind
1165
- );
1166
- return value;
1167
- })
1168
- );
1169
- const groupByKey = /* @__PURE__ */ new Map();
1170
- const groupProbes = [];
1171
- const groupToInputs = [];
1172
- for (const [inputIndex, probe] of probes.entries()) {
1173
- const key = canonicalIndexProbeKey(probe);
1174
- const existing = groupByKey.get(key);
1175
- if (existing === void 0) {
1176
- groupByKey.set(key, groupProbes.length);
1177
- groupProbes.push(probe);
1178
- groupToInputs.push([inputIndex]);
1179
- continue;
1180
- }
1181
- groupToInputs[existing]?.push(inputIndex);
1182
- }
1183
- const schema = backend.tableNames ? chunkCPEL3YIR_cjs.createSqlSchema(backend.tableNames) : chunkCPEL3YIR_cjs.DEFAULT_SQL_SCHEMA;
1184
- const compileContext = {
1185
- dialect: backend.dialect,
1186
- propsColumn: chunkU5W4LKZV_cjs.sql.raw(`"props"`),
1187
- systemColumn: (column) => chunkU5W4LKZV_cjs.sql.raw(`"${column}"`)
1188
- };
1189
- const fieldKeys = chunkOVUUTCPJ_cjs.compileNodeIndexFieldKeys(index, compileContext);
1190
- const groupPredicates = groupProbes.map(
1191
- (probe) => chunkU5W4LKZV_cjs.sql`(${chunkU5W4LKZV_cjs.sql.join(
1192
- fieldKeys.map((fieldKey, position) => {
1193
- const value = probe[position];
1194
- if (value === void 0 || value === null) {
1195
- return chunkU5W4LKZV_cjs.sql`${fieldKey} IS NULL`;
1196
- }
1197
- return adapter.nullSafeEquals(
1198
- fieldKey,
1199
- chunkU5W4LKZV_cjs.sql`${coerceIndexProbeBind(value, adapter)}`
1200
- );
1201
- }),
1202
- chunkU5W4LKZV_cjs.sql` AND `
1203
- )})`
1204
- );
1205
- const caseBranches = groupPredicates.map(
1206
- (predicate, group) => chunkU5W4LKZV_cjs.sql`WHEN ${predicate} THEN ${chunkU5W4LKZV_cjs.sql.raw(String(group))}`
1207
- );
1208
- const probeIndexExpr = chunkU5W4LKZV_cjs.sql`CASE ${chunkU5W4LKZV_cjs.sql.join(caseBranches, chunkU5W4LKZV_cjs.sql` `)} ELSE NULL END`;
1209
- const conditions = [
1210
- chunkU5W4LKZV_cjs.sql`"graph_id" = ${ctx.graphId}`,
1211
- chunkU5W4LKZV_cjs.sql`"kind" = ${kind}`,
1212
- chunkU5W4LKZV_cjs.sql`"deleted_at" IS NULL`
1213
- ];
1214
- if (index.where !== void 0) {
1215
- conditions.push(chunkOVUUTCPJ_cjs.compileIndexWhere(compileContext, index.where));
1216
- }
1217
- conditions.push(chunkU5W4LKZV_cjs.sql`(${chunkU5W4LKZV_cjs.sql.join(groupPredicates, chunkU5W4LKZV_cjs.sql` OR `)})`);
1218
- const whereClause = chunkU5W4LKZV_cjs.sql.join(conditions, chunkU5W4LKZV_cjs.sql` AND `);
1219
- const probedSelect = chunkU5W4LKZV_cjs.sql`SELECT "id", ${probeIndexExpr} AS probe_idx FROM ${schema.nodesTable} WHERE ${whereClause}`;
1220
- const capInSql = limitPerInput !== void 0 && backend.capabilities.windowFunctions;
1221
- const query = capInSql ? chunkU5W4LKZV_cjs.sql`SELECT "id", probe_idx FROM (SELECT "id", probe_idx, ROW_NUMBER() OVER (PARTITION BY probe_idx ORDER BY "id") AS probe_rank FROM (${probedSelect}) AS probed) AS ranked WHERE probe_rank <= ${limitPerInput} ORDER BY probe_idx, "id"` : chunkU5W4LKZV_cjs.sql`${probedSelect} ORDER BY probe_idx, "id"`;
1222
- const rawMatches = await backend.execute(
1223
- chunkU5W4LKZV_cjs.asCompiledRowsSql(query)
1224
- );
1225
- const matches = limitPerInput !== void 0 && !capInSql ? capMatchesPerGroup(rawMatches, limitPerInput) : rawMatches;
1226
- const nodesById = await hydrateNodesById(
1227
- backend,
1228
- ctx.graphId,
1229
- kind,
1230
- matches.map((match) => match.id)
1231
- );
1232
- const results = Array.from({ length: items.length }, () => []);
1233
- for (const match of matches) {
1234
- const node = nodesById.get(match.id);
1235
- if (node === void 0) continue;
1236
- const inputs = groupToInputs[match.probe_idx];
1237
- if (inputs === void 0) continue;
1238
- for (const inputIndex of inputs) {
1239
- results[inputIndex]?.push(node);
1240
- }
1241
- }
1242
- return results;
1243
- }
1244
- function capMatchesPerGroup(matches, limitPerInput) {
1245
- const perGroupCount = /* @__PURE__ */ new Map();
1246
- const capped = [];
1247
- for (const match of matches) {
1248
- const count = perGroupCount.get(match.probe_idx) ?? 0;
1249
- if (count >= limitPerInput) continue;
1250
- perGroupCount.set(match.probe_idx, count + 1);
1251
- capped.push(match);
1252
- }
1253
- return capped;
1254
- }
1255
- async function hydrateNodesById(backend, graphId, kind, ids) {
1256
- const rowsById = await chunk7V2FGGI2_cjs.getNodeRowsByIds(backend, graphId, kind, ids);
1257
- const nodesById = /* @__PURE__ */ new Map();
1258
- for (const [id, row] of rowsById) {
1259
- if (row.deleted_at !== void 0) continue;
1260
- nodesById.set(id, rowToNode(row));
1261
- }
1262
- return nodesById;
1263
- }
1264
- async function executeNodeBulkGetOrCreateByConstraint(ctx, kind, constraintName, items, backend, options) {
1265
- if (items.length === 0) return [];
1266
- const ifExists = options?.ifExists ?? "return";
1267
- const registration = getNodeRegistration(ctx.graph, kind);
1268
- const nodeKind = registration.type;
1269
- const constraint = resolveConstraint(ctx.graph, kind, constraintName);
1270
- const validated = validateAndComputeKeys(nodeKind, kind, constraint, items);
1271
- const uniqueKeys = collectUniqueKeys(validated);
1272
- const kindsToCheck = chunk7V2FGGI2_cjs.getKindsForUniquenessCheck(
1273
- kind,
1274
- constraint.scope,
1275
- ctx.registry
1276
- );
1277
- const existingByKey = uniqueKeys.length > 0 ? await batchCheckUniqueAcrossKinds(
1278
- backend,
1279
- ctx.graphId,
1280
- constraint.name,
1281
- uniqueKeys,
1282
- kindsToCheck,
1283
- true
1284
- ) : /* @__PURE__ */ new Map();
1285
- const toCreate = [];
1286
- const toFetch = [];
1287
- const duplicateOf = [];
1288
- const seenKeys = /* @__PURE__ */ new Map();
1289
- for (const [index, { validatedProps, key }] of validated.entries()) {
1290
- if (key === void 0) {
1291
- toCreate.push({ index, input: { kind, props: validatedProps } });
1292
- continue;
1293
- }
1294
- const previousIndex = seenKeys.get(key);
1295
- if (previousIndex !== void 0) {
1296
- duplicateOf.push({ index, sourceIndex: previousIndex });
1297
- continue;
1298
- }
1299
- seenKeys.set(key, index);
1300
- const existing = existingByKey.get(key);
1301
- if (existing === void 0) {
1302
- toCreate.push({ index, input: { kind, props: validatedProps } });
1303
- } else {
1304
- toFetch.push({
1305
- index,
1306
- nodeId: existing.node_id,
1307
- concreteKind: existing.concrete_kind,
1308
- validatedProps,
1309
- isSoftDeleted: existing.deleted_at !== void 0
1310
- });
1311
- }
1312
- }
1313
- const results = Array.from({ length: items.length });
1314
- if (toCreate.length > 0) {
1315
- const createInputs = toCreate.map((entry) => entry.input);
1316
- const createdNodes = await executeNodeCreateBatch(
1317
- ctx,
1318
- createInputs,
1319
- backend,
1320
- { propsPreValidated: true }
1321
- );
1322
- for (const [batchIndex, entry] of toCreate.entries()) {
1323
- results[entry.index] = {
1324
- node: chunk764JHTLT_cjs.requireDefined(createdNodes[batchIndex]),
1325
- action: "created"
1326
- };
1327
- }
1328
- }
1329
- for (const entry of toFetch) {
1330
- const { index, concreteKind, validatedProps, isSoftDeleted, nodeId } = entry;
1331
- const existingRow = await backend.getNode(
1332
- ctx.graphId,
1333
- concreteKind,
1334
- nodeId
1335
- );
1336
- if (existingRow === void 0) {
1337
- const node = await executeNodeCreate(
1338
- ctx,
1339
- { kind, props: validatedProps },
1340
- backend,
1341
- { propsPreValidated: true }
1342
- );
1343
- results[index] = { node, action: "created" };
1344
- continue;
1345
- }
1346
- if (isSoftDeleted || ifExists === "update") {
1347
- const node = await executeNodeUpsertUpdate(
1348
- ctx,
1349
- {
1350
- kind: concreteKind,
1351
- id: existingRow.id,
1352
- props: validatedProps
1353
- },
1354
- backend,
1355
- { clearDeleted: isSoftDeleted }
1356
- );
1357
- results[index] = {
1358
- node,
1359
- action: isSoftDeleted ? "resurrected" : "updated"
1360
- };
1361
- } else {
1362
- results[index] = { node: rowToNode(existingRow), action: "found" };
1363
- }
1364
- }
1365
- for (const { index, sourceIndex } of duplicateOf) {
1366
- const sourceResult = chunk764JHTLT_cjs.requireDefined(results[sourceIndex]);
1367
- results[index] = { node: sourceResult.node, action: "found" };
1368
- }
1369
- return results;
1370
- }
1371
-
1372
- exports.checkCardinalityConstraint = checkCardinalityConstraint;
1373
- exports.createNodeBatchValidationBackend = createNodeBatchValidationBackend;
1374
- exports.executeNodeBulkFindByConstraint = executeNodeBulkFindByConstraint;
1375
- exports.executeNodeBulkFindByIndex = executeNodeBulkFindByIndex;
1376
- exports.executeNodeBulkGetOrCreateByConstraint = executeNodeBulkGetOrCreateByConstraint;
1377
- exports.executeNodeCreate = executeNodeCreate;
1378
- exports.executeNodeCreateBatch = executeNodeCreateBatch;
1379
- exports.executeNodeCreateNoReturnBatch = executeNodeCreateNoReturnBatch;
1380
- exports.executeNodeDelete = executeNodeDelete;
1381
- exports.executeNodeFindByConstraint = executeNodeFindByConstraint;
1382
- exports.executeNodeGetOrCreateByConstraint = executeNodeGetOrCreateByConstraint;
1383
- exports.executeNodeHardDelete = executeNodeHardDelete;
1384
- exports.executeNodeUpdate = executeNodeUpdate;
1385
- exports.executeNodeUpsertUpdate = executeNodeUpsertUpdate;
1386
- exports.lockSchemaVersionForStoreWrite = lockSchemaVersionForStoreWrite;
1387
- exports.nodeUpsertDirtyCheck = nodeUpsertDirtyCheck;
1388
- exports.primeBatchValidationCaches = primeBatchValidationCaches;
1389
- exports.rowToEdge = rowToEdge;
1390
- exports.rowToEdgeMeta = rowToEdgeMeta;
1391
- exports.rowToNode = rowToNode;
1392
- exports.rowToNodeMeta = rowToNodeMeta;
1393
- exports.runHookedWriteOperation = runHookedWriteOperation;
1394
- exports.runInWriteTransaction = runInWriteTransaction;
1395
- //# sourceMappingURL=chunk-NCX65HBY.cjs.map
1396
- //# sourceMappingURL=chunk-NCX65HBY.cjs.map