@nicia-ai/typegraph 0.34.0 → 0.35.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 (287) hide show
  1. package/dist/backend/postgres/index.cjs +29 -29
  2. package/dist/backend/postgres/index.d.cts +39 -7
  3. package/dist/backend/postgres/index.d.ts +39 -7
  4. package/dist/backend/postgres/index.js +16 -16
  5. package/dist/backend/postgres/pglite.cjs +21 -21
  6. package/dist/backend/postgres/pglite.d.cts +4 -4
  7. package/dist/backend/postgres/pglite.d.ts +4 -4
  8. package/dist/backend/postgres/pglite.js +16 -16
  9. package/dist/backend/sqlite/index.cjs +25 -26
  10. package/dist/backend/sqlite/index.d.cts +8 -8
  11. package/dist/backend/sqlite/index.d.ts +8 -8
  12. package/dist/backend/sqlite/index.js +13 -14
  13. package/dist/backend/sqlite/libsql.cjs +19 -19
  14. package/dist/backend/sqlite/libsql.d.cts +4 -4
  15. package/dist/backend/sqlite/libsql.d.ts +4 -4
  16. package/dist/backend/sqlite/libsql.js +15 -15
  17. package/dist/backend/sqlite/local.cjs +101 -21
  18. package/dist/backend/sqlite/local.cjs.map +1 -1
  19. package/dist/backend/sqlite/local.d.cts +95 -5
  20. package/dist/backend/sqlite/local.d.ts +95 -5
  21. package/dist/backend/sqlite/local.js +95 -16
  22. package/dist/backend/sqlite/local.js.map +1 -1
  23. package/dist/{chunk-ZV5N4DBG.js → chunk-3TWF3SH4.js} +300 -58
  24. package/dist/chunk-3TWF3SH4.js.map +1 -0
  25. package/dist/chunk-4JEZZJ6S.cjs +1271 -0
  26. package/dist/chunk-4JEZZJ6S.cjs.map +1 -0
  27. package/dist/{chunk-UNNPKQUG.cjs → chunk-4TOD4LBZ.cjs} +246 -155
  28. package/dist/chunk-4TOD4LBZ.cjs.map +1 -0
  29. package/dist/{chunk-QV245VMN.js → chunk-55MZDDZV.js} +100 -6
  30. package/dist/chunk-55MZDDZV.js.map +1 -0
  31. package/dist/{chunk-GQANNXXT.cjs → chunk-5A6FNS6N.cjs} +75 -20
  32. package/dist/chunk-5A6FNS6N.cjs.map +1 -0
  33. package/dist/{chunk-3Z6TW3CT.cjs → chunk-5AQIKK56.cjs} +65 -25
  34. package/dist/chunk-5AQIKK56.cjs.map +1 -0
  35. package/dist/{chunk-BVTWD66D.js → chunk-5SEGFTZX.js} +3 -3
  36. package/dist/{chunk-BVTWD66D.js.map → chunk-5SEGFTZX.js.map} +1 -1
  37. package/dist/{chunk-6GNSY7AV.js → chunk-6FR2MMS6.js} +7 -7
  38. package/dist/chunk-6FR2MMS6.js.map +1 -0
  39. package/dist/chunk-7YSP4V4R.cjs +69 -0
  40. package/dist/chunk-7YSP4V4R.cjs.map +1 -0
  41. package/dist/chunk-A42GCBGX.cjs +28 -0
  42. package/dist/chunk-A42GCBGX.cjs.map +1 -0
  43. package/dist/{chunk-RHZWOJVA.cjs → chunk-BLZDPRXT.cjs} +52 -4
  44. package/dist/chunk-BLZDPRXT.cjs.map +1 -0
  45. package/dist/chunk-BYPOGQWK.js +25 -0
  46. package/dist/chunk-BYPOGQWK.js.map +1 -0
  47. package/dist/{chunk-6HVOHZHS.cjs → chunk-CK5BVQOW.cjs} +213 -168
  48. package/dist/chunk-CK5BVQOW.cjs.map +1 -0
  49. package/dist/{chunk-JJRCLAUN.cjs → chunk-CTTSDJLY.cjs} +116 -10
  50. package/dist/chunk-CTTSDJLY.cjs.map +1 -0
  51. package/dist/chunk-CUHM5CWJ.cjs +12 -0
  52. package/dist/chunk-CUHM5CWJ.cjs.map +1 -0
  53. package/dist/{chunk-A7SZZFAG.js → chunk-CZQ3FO2Q.js} +409 -99
  54. package/dist/chunk-CZQ3FO2Q.js.map +1 -0
  55. package/dist/{chunk-2JXB3NYJ.cjs → chunk-D7ZEOS56.cjs} +25 -32
  56. package/dist/chunk-D7ZEOS56.cjs.map +1 -0
  57. package/dist/chunk-DFVLCOP6.js +10 -0
  58. package/dist/chunk-DFVLCOP6.js.map +1 -0
  59. package/dist/{chunk-UJLOZYKT.cjs → chunk-EM3CWPND.cjs} +441 -115
  60. package/dist/chunk-EM3CWPND.cjs.map +1 -0
  61. package/dist/chunk-EMF62TZG.cjs +1176 -0
  62. package/dist/chunk-EMF62TZG.cjs.map +1 -0
  63. package/dist/chunk-EOLERH7Y.cjs +40 -0
  64. package/dist/chunk-EOLERH7Y.cjs.map +1 -0
  65. package/dist/{chunk-TGJE22RM.cjs → chunk-FACJJWGF.cjs} +24 -6
  66. package/dist/chunk-FACJJWGF.cjs.map +1 -0
  67. package/dist/{chunk-HK5SATYM.cjs → chunk-FL472AMI.cjs} +16 -109
  68. package/dist/chunk-FL472AMI.cjs.map +1 -0
  69. package/dist/{chunk-WVC2Q2FD.cjs → chunk-FN35DLCN.cjs} +31 -9
  70. package/dist/chunk-FN35DLCN.cjs.map +1 -0
  71. package/dist/{chunk-KUTNI6SI.js → chunk-FPIZFYHE.js} +10 -18
  72. package/dist/chunk-FPIZFYHE.js.map +1 -0
  73. package/dist/{chunk-VCGO4V26.js → chunk-FRV5Q5IO.js} +64 -9
  74. package/dist/chunk-FRV5Q5IO.js.map +1 -0
  75. package/dist/{chunk-K5P5OZXS.js → chunk-G6Q5UM7U.js} +2 -2
  76. package/dist/{chunk-K5P5OZXS.js.map → chunk-G6Q5UM7U.js.map} +1 -1
  77. package/dist/chunk-GSQ6NPH6.cjs +100 -0
  78. package/dist/chunk-GSQ6NPH6.cjs.map +1 -0
  79. package/dist/chunk-GUR2FNB5.cjs +12 -0
  80. package/dist/{chunk-HMFK4BXR.cjs.map → chunk-GUR2FNB5.cjs.map} +1 -1
  81. package/dist/{chunk-JQGIPGVL.cjs → chunk-H7YNSMA7.cjs} +43 -2
  82. package/dist/chunk-H7YNSMA7.cjs.map +1 -0
  83. package/dist/{chunk-2MRAX3UE.js → chunk-I7ZUZKFD.js} +47 -4
  84. package/dist/chunk-I7ZUZKFD.js.map +1 -0
  85. package/dist/{chunk-3BRVBQQD.cjs → chunk-J7WFGBJR.cjs} +2445 -2367
  86. package/dist/chunk-J7WFGBJR.cjs.map +1 -0
  87. package/dist/{chunk-V3QNTB7Z.js → chunk-JBTOYDMN.js} +194 -114
  88. package/dist/chunk-JBTOYDMN.js.map +1 -0
  89. package/dist/{chunk-K2TGS3EN.js → chunk-K3PPLHY7.js} +138 -89
  90. package/dist/chunk-K3PPLHY7.js.map +1 -0
  91. package/dist/{chunk-Z5XBMDXU.js → chunk-KBGQIPRQ.js} +42 -3
  92. package/dist/chunk-KBGQIPRQ.js.map +1 -0
  93. package/dist/chunk-KMI7LYAF.js +1252 -0
  94. package/dist/chunk-KMI7LYAF.js.map +1 -0
  95. package/dist/{chunk-JIEJCTDS.cjs → chunk-LGEALRC6.cjs} +21 -4
  96. package/dist/chunk-LGEALRC6.cjs.map +1 -0
  97. package/dist/{chunk-TQOYM4LN.js → chunk-MP2JQKSG.js} +21 -5
  98. package/dist/chunk-MP2JQKSG.js.map +1 -0
  99. package/dist/{chunk-ZP5WHI4C.cjs → chunk-O7UN7OXA.cjs} +358 -116
  100. package/dist/chunk-O7UN7OXA.cjs.map +1 -0
  101. package/dist/chunk-OHMP6N2J.js +47 -0
  102. package/dist/chunk-OHMP6N2J.js.map +1 -0
  103. package/dist/{chunk-4DIBPQNJ.js → chunk-OR5ZA5WP.js} +135 -25
  104. package/dist/chunk-OR5ZA5WP.js.map +1 -0
  105. package/dist/{chunk-DEQFL35G.js → chunk-Q5TEXCTB.js} +61 -7
  106. package/dist/chunk-Q5TEXCTB.js.map +1 -0
  107. package/dist/chunk-QNKSQTKQ.js +1312 -0
  108. package/dist/chunk-QNKSQTKQ.js.map +1 -0
  109. package/dist/{chunk-ZURTTSCM.js → chunk-QOTI55H7.js} +6 -94
  110. package/dist/chunk-QOTI55H7.js.map +1 -0
  111. package/dist/{chunk-CHXTTSC6.js → chunk-QWEUYILR.js} +104 -5
  112. package/dist/chunk-QWEUYILR.js.map +1 -0
  113. package/dist/{chunk-LANHCOXB.js → chunk-RGP33ZJ5.js} +485 -83
  114. package/dist/chunk-RGP33ZJ5.js.map +1 -0
  115. package/dist/chunk-RGPG7EOJ.js +94 -0
  116. package/dist/chunk-RGPG7EOJ.js.map +1 -0
  117. package/dist/{chunk-G6SOJEDI.cjs → chunk-S55OV6PW.cjs} +15 -15
  118. package/dist/chunk-S55OV6PW.cjs.map +1 -0
  119. package/dist/{chunk-3E7SNSIA.cjs → chunk-SJDMVITW.cjs} +4 -4
  120. package/dist/{chunk-3E7SNSIA.cjs.map → chunk-SJDMVITW.cjs.map} +1 -1
  121. package/dist/{chunk-XLUNB2TZ.js → chunk-SNXVDZAJ.js} +3 -3
  122. package/dist/{chunk-XLUNB2TZ.js.map → chunk-SNXVDZAJ.js.map} +1 -1
  123. package/dist/{chunk-RBV7YCQD.js → chunk-T2WUSPDA.js} +49 -9
  124. package/dist/chunk-T2WUSPDA.js.map +1 -0
  125. package/dist/{chunk-KGC4LY5T.cjs → chunk-TCOCYN2P.cjs} +75 -21
  126. package/dist/chunk-TCOCYN2P.cjs.map +1 -0
  127. package/dist/{chunk-FLRCVI2G.cjs → chunk-TDXIBCGY.cjs} +2 -2
  128. package/dist/{chunk-FLRCVI2G.cjs.map → chunk-TDXIBCGY.cjs.map} +1 -1
  129. package/dist/{chunk-ZY4GXIVN.cjs → chunk-TEDRJXOG.cjs} +5 -5
  130. package/dist/{chunk-ZY4GXIVN.cjs.map → chunk-TEDRJXOG.cjs.map} +1 -1
  131. package/dist/{chunk-WLRIWYHQ.js → chunk-UES55P7G.js} +1863 -1785
  132. package/dist/chunk-UES55P7G.js.map +1 -0
  133. package/dist/{chunk-WL2SG7ZV.cjs → chunk-UMDVATGY.cjs} +6 -6
  134. package/dist/{chunk-WL2SG7ZV.cjs.map → chunk-UMDVATGY.cjs.map} +1 -1
  135. package/dist/chunk-UT3S4SEN.js +31 -0
  136. package/dist/chunk-UT3S4SEN.js.map +1 -0
  137. package/dist/{chunk-RRKQAKD6.cjs → chunk-UUT7UN2N.cjs} +149 -39
  138. package/dist/chunk-UUT7UN2N.cjs.map +1 -0
  139. package/dist/{chunk-SHLY4MCM.js → chunk-UZV3AZKF.js} +21 -3
  140. package/dist/chunk-UZV3AZKF.js.map +1 -0
  141. package/dist/{chunk-CYX2JTDG.js → chunk-VHMPG6UL.js} +29 -7
  142. package/dist/chunk-VHMPG6UL.js.map +1 -0
  143. package/dist/{chunk-T6SPUYLX.cjs → chunk-VPYHY3LJ.cjs} +116 -10
  144. package/dist/chunk-VPYHY3LJ.cjs.map +1 -0
  145. package/dist/{chunk-T46GR2VY.js → chunk-VSPCZAXF.js} +3 -3
  146. package/dist/{chunk-T46GR2VY.js.map → chunk-VSPCZAXF.js.map} +1 -1
  147. package/dist/{chunk-K34OPSJK.js → chunk-W63OVYY4.js} +3 -3
  148. package/dist/{chunk-K34OPSJK.js.map → chunk-W63OVYY4.js.map} +1 -1
  149. package/dist/{chunk-RY2VIWAM.js → chunk-WDBCBWC4.js} +355 -32
  150. package/dist/chunk-WDBCBWC4.js.map +1 -0
  151. package/dist/chunk-WJT7OU7E.cjs +1334 -0
  152. package/dist/chunk-WJT7OU7E.cjs.map +1 -0
  153. package/dist/{chunk-5IQIX7LU.cjs → chunk-XOX22WHL.cjs} +476 -163
  154. package/dist/chunk-XOX22WHL.cjs.map +1 -0
  155. package/dist/{ddl-BrmPg61z.d.ts → ddl-C2rZ-Aen.d.ts} +4 -4
  156. package/dist/{ddl-j1-sH6lE.d.cts → ddl-CZz7a0E8.d.cts} +4 -4
  157. package/dist/{extension-types-YGFJPrzK.d.cts → extension-types-ixRpJVUp.d.cts} +24 -1
  158. package/dist/{extension-types-YGFJPrzK.d.ts → extension-types-ixRpJVUp.d.ts} +24 -1
  159. package/dist/{types-DkNnF-7K.d.cts → fulltext-strategy-B57yvC5Q.d.ts} +2562 -2133
  160. package/dist/{types-D1Sqeyxy.d.ts → fulltext-strategy-CDkSSYhq.d.cts} +2562 -2133
  161. package/dist/graph-extension/index.cjs +20 -19
  162. package/dist/graph-extension/index.d.cts +4 -4
  163. package/dist/graph-extension/index.d.ts +4 -4
  164. package/dist/graph-extension/index.js +5 -4
  165. package/dist/graph-merge/index.cjs +255 -164
  166. package/dist/graph-merge/index.cjs.map +1 -1
  167. package/dist/graph-merge/index.d.cts +63 -33
  168. package/dist/graph-merge/index.d.ts +63 -33
  169. package/dist/graph-merge/index.js +135 -44
  170. package/dist/graph-merge/index.js.map +1 -1
  171. package/dist/{index-DGX6D9j1.d.ts → index-6CSUAq-x.d.ts} +234 -93
  172. package/dist/{index-SEvUHDA6.d.cts → index-Bks_3HHK.d.cts} +234 -93
  173. package/dist/index.cjs +208 -188
  174. package/dist/index.d.cts +11 -11
  175. package/dist/index.d.ts +11 -11
  176. package/dist/index.js +33 -33
  177. package/dist/indexes/index.cjs +19 -20
  178. package/dist/indexes/index.d.cts +5 -5
  179. package/dist/indexes/index.d.ts +5 -5
  180. package/dist/indexes/index.js +10 -11
  181. package/dist/interchange/index.cjs +47 -26
  182. package/dist/interchange/index.d.cts +126 -12
  183. package/dist/interchange/index.d.ts +126 -12
  184. package/dist/interchange/index.js +14 -13
  185. package/dist/{manager-ms9cKdc6.d.cts → manager-DwQi8eV0.d.cts} +9 -2
  186. package/dist/{manager-BZUeN_BU.d.ts → manager-ejUCB52T.d.ts} +9 -2
  187. package/dist/{materialize-indexes-D20xNluI.d.cts → materialize-indexes-B4e9360H.d.cts} +20 -4
  188. package/dist/{materialize-indexes-CAkIYFV-.d.ts → materialize-indexes-te9TPMMJ.d.ts} +20 -4
  189. package/dist/{postgres-BhpxGMC5.d.cts → postgres-CfEqsRMp.d.cts} +152 -1
  190. package/dist/{postgres-CWHLwNl1.d.ts → postgres-DQ5R6rzV.d.ts} +152 -1
  191. package/dist/profiler/index.cjs +11 -11
  192. package/dist/profiler/index.d.cts +7 -7
  193. package/dist/profiler/index.d.ts +7 -7
  194. package/dist/profiler/index.js +4 -4
  195. package/dist/provenance/index.cjs +40 -41
  196. package/dist/provenance/index.cjs.map +1 -1
  197. package/dist/provenance/index.d.cts +5 -5
  198. package/dist/provenance/index.d.ts +5 -5
  199. package/dist/provenance/index.js +11 -12
  200. package/dist/provenance/index.js.map +1 -1
  201. package/dist/schema/index.cjs +53 -40
  202. package/dist/schema/index.cjs.map +1 -1
  203. package/dist/schema/index.d.cts +57 -57
  204. package/dist/schema/index.d.ts +57 -57
  205. package/dist/schema/index.js +28 -15
  206. package/dist/schema/index.js.map +1 -1
  207. package/dist/{sqlite-XrDxNaa7.d.cts → sqlite-D7zBinNR.d.cts} +92 -1
  208. package/dist/{sqlite-CGu5SLsw.d.ts → sqlite-DvQndLky.d.ts} +92 -1
  209. package/dist/{store-view-D09po4H6.d.cts → store-view-BSpqvAxK.d.cts} +415 -44
  210. package/dist/{store-view-BlgnhEYf.d.ts → store-view-CKbHFRnn.d.ts} +415 -44
  211. package/dist/{types-DiE1AO7p.d.cts → types-Bv9DcS_E.d.cts} +2 -2
  212. package/dist/{types-B1TbZJYS.d.ts → types-CoxuV7EJ.d.ts} +2 -2
  213. package/dist/{where-DKjuofPr.d.cts → where-7RKFOsXt.d.ts} +2 -2
  214. package/dist/{where-DrUIIWHb.d.ts → where-DdMIXOtH.d.cts} +2 -2
  215. package/package.json +14 -13
  216. package/dist/chunk-2EBMPJBO.js +0 -16
  217. package/dist/chunk-2EBMPJBO.js.map +0 -1
  218. package/dist/chunk-2JXB3NYJ.cjs.map +0 -1
  219. package/dist/chunk-2MRAX3UE.js.map +0 -1
  220. package/dist/chunk-3BRVBQQD.cjs.map +0 -1
  221. package/dist/chunk-3EUKJEQ3.js +0 -77
  222. package/dist/chunk-3EUKJEQ3.js.map +0 -1
  223. package/dist/chunk-3Z6TW3CT.cjs.map +0 -1
  224. package/dist/chunk-4DIBPQNJ.js.map +0 -1
  225. package/dist/chunk-4S2FXGBJ.js +0 -9
  226. package/dist/chunk-4S2FXGBJ.js.map +0 -1
  227. package/dist/chunk-5IQIX7LU.cjs.map +0 -1
  228. package/dist/chunk-6GNSY7AV.js.map +0 -1
  229. package/dist/chunk-6HVOHZHS.cjs.map +0 -1
  230. package/dist/chunk-6SCVW4AS.js +0 -20
  231. package/dist/chunk-6SCVW4AS.js.map +0 -1
  232. package/dist/chunk-A7SZZFAG.js.map +0 -1
  233. package/dist/chunk-CHXTTSC6.js.map +0 -1
  234. package/dist/chunk-CYX2JTDG.js.map +0 -1
  235. package/dist/chunk-DEQFL35G.js.map +0 -1
  236. package/dist/chunk-G6SOJEDI.cjs.map +0 -1
  237. package/dist/chunk-GQANNXXT.cjs.map +0 -1
  238. package/dist/chunk-GZCNZ7QW.js +0 -24
  239. package/dist/chunk-GZCNZ7QW.js.map +0 -1
  240. package/dist/chunk-HK5SATYM.cjs.map +0 -1
  241. package/dist/chunk-HMFK4BXR.cjs +0 -12
  242. package/dist/chunk-HTGDWIDE.cjs +0 -89
  243. package/dist/chunk-HTGDWIDE.cjs.map +0 -1
  244. package/dist/chunk-JIEJCTDS.cjs.map +0 -1
  245. package/dist/chunk-JJRCLAUN.cjs.map +0 -1
  246. package/dist/chunk-JQGIPGVL.cjs.map +0 -1
  247. package/dist/chunk-K2TGS3EN.js.map +0 -1
  248. package/dist/chunk-KGC4LY5T.cjs.map +0 -1
  249. package/dist/chunk-KNHYNQQ3.cjs +0 -663
  250. package/dist/chunk-KNHYNQQ3.cjs.map +0 -1
  251. package/dist/chunk-KUTNI6SI.js.map +0 -1
  252. package/dist/chunk-LANHCOXB.js.map +0 -1
  253. package/dist/chunk-N6WTUSBV.cjs +0 -23
  254. package/dist/chunk-N6WTUSBV.cjs.map +0 -1
  255. package/dist/chunk-NAUA4PW5.cjs +0 -28
  256. package/dist/chunk-NAUA4PW5.cjs.map +0 -1
  257. package/dist/chunk-QV245VMN.js.map +0 -1
  258. package/dist/chunk-RBV7YCQD.js.map +0 -1
  259. package/dist/chunk-RHZWOJVA.cjs.map +0 -1
  260. package/dist/chunk-RRKQAKD6.cjs.map +0 -1
  261. package/dist/chunk-RY2VIWAM.js.map +0 -1
  262. package/dist/chunk-SHLY4MCM.js.map +0 -1
  263. package/dist/chunk-T2DWPQNE.js +0 -649
  264. package/dist/chunk-T2DWPQNE.js.map +0 -1
  265. package/dist/chunk-T6SPUYLX.cjs.map +0 -1
  266. package/dist/chunk-TGJE22RM.cjs.map +0 -1
  267. package/dist/chunk-TOTPVGOG.cjs +0 -774
  268. package/dist/chunk-TOTPVGOG.cjs.map +0 -1
  269. package/dist/chunk-TQOYM4LN.js.map +0 -1
  270. package/dist/chunk-UJLOZYKT.cjs.map +0 -1
  271. package/dist/chunk-UNNPKQUG.cjs.map +0 -1
  272. package/dist/chunk-V3QNTB7Z.js.map +0 -1
  273. package/dist/chunk-VCGO4V26.js.map +0 -1
  274. package/dist/chunk-WLRIWYHQ.js.map +0 -1
  275. package/dist/chunk-WVC2Q2FD.cjs.map +0 -1
  276. package/dist/chunk-XXVEULWX.js +0 -39
  277. package/dist/chunk-XXVEULWX.js.map +0 -1
  278. package/dist/chunk-YAZE7QZR.cjs +0 -32
  279. package/dist/chunk-YAZE7QZR.cjs.map +0 -1
  280. package/dist/chunk-YC6PWTHY.cjs +0 -44
  281. package/dist/chunk-YC6PWTHY.cjs.map +0 -1
  282. package/dist/chunk-Z5HBYM7U.cjs +0 -11
  283. package/dist/chunk-Z5HBYM7U.cjs.map +0 -1
  284. package/dist/chunk-Z5XBMDXU.js.map +0 -1
  285. package/dist/chunk-ZP5WHI4C.cjs.map +0 -1
  286. package/dist/chunk-ZURTTSCM.js.map +0 -1
  287. package/dist/chunk-ZV5N4DBG.js.map +0 -1
@@ -0,0 +1,1334 @@
1
+ 'use strict';
2
+
3
+ var chunkVPYHY3LJ_cjs = require('./chunk-VPYHY3LJ.cjs');
4
+ var chunkD7ZEOS56_cjs = require('./chunk-D7ZEOS56.cjs');
5
+ var chunkGSQ6NPH6_cjs = require('./chunk-GSQ6NPH6.cjs');
6
+ var chunkXOX22WHL_cjs = require('./chunk-XOX22WHL.cjs');
7
+ var chunkEOLERH7Y_cjs = require('./chunk-EOLERH7Y.cjs');
8
+ var chunk4TOD4LBZ_cjs = require('./chunk-4TOD4LBZ.cjs');
9
+ var chunkBLZDPRXT_cjs = require('./chunk-BLZDPRXT.cjs');
10
+ var chunkLGEALRC6_cjs = require('./chunk-LGEALRC6.cjs');
11
+ var chunkTDXIBCGY_cjs = require('./chunk-TDXIBCGY.cjs');
12
+ var drizzleOrm = require('drizzle-orm');
13
+
14
+ // src/store/row-mappers.ts
15
+ function nullToUndefined(value) {
16
+ return value === null ? void 0 : value;
17
+ }
18
+ function rowToNode(row) {
19
+ const rawProps = chunk4TOD4LBZ_cjs.rowPropsToObject(row.props);
20
+ const props = chunkGSQ6NPH6_cjs.filterReservedKeys(rawProps, chunkGSQ6NPH6_cjs.RESERVED_NODE_KEYS);
21
+ return {
22
+ kind: row.kind,
23
+ id: row.id,
24
+ meta: rowToNodeMeta(row),
25
+ ...props
26
+ };
27
+ }
28
+ function rowToNodeMeta(row) {
29
+ return {
30
+ version: row.version,
31
+ validFrom: nullToUndefined(row.valid_from),
32
+ validTo: nullToUndefined(row.valid_to),
33
+ createdAt: row.created_at,
34
+ updatedAt: row.updated_at,
35
+ deletedAt: nullToUndefined(row.deleted_at)
36
+ };
37
+ }
38
+ function rowToEdge(row) {
39
+ const rawProps = chunk4TOD4LBZ_cjs.rowPropsToObject(row.props);
40
+ const props = chunkGSQ6NPH6_cjs.filterReservedKeys(rawProps, chunkGSQ6NPH6_cjs.RESERVED_EDGE_KEYS);
41
+ return {
42
+ id: row.id,
43
+ kind: row.kind,
44
+ fromKind: row.from_kind,
45
+ fromId: row.from_id,
46
+ toKind: row.to_kind,
47
+ toId: row.to_id,
48
+ meta: rowToEdgeMeta(row),
49
+ ...props
50
+ };
51
+ }
52
+ function rowToEdgeMeta(row) {
53
+ return {
54
+ validFrom: nullToUndefined(row.valid_from),
55
+ validTo: nullToUndefined(row.valid_to),
56
+ createdAt: row.created_at,
57
+ updatedAt: row.updated_at,
58
+ deletedAt: nullToUndefined(row.deleted_at)
59
+ };
60
+ }
61
+
62
+ // src/store/operations/write-transaction.ts
63
+ function runInWriteTransaction(ctx, backend, fn) {
64
+ const ownsWriteLock = "transaction" in backend && backend.capabilities.transactions;
65
+ return chunk4TOD4LBZ_cjs.runOptionallyInTransaction(backend, async (target) => {
66
+ const lock = ctx.historyEnabled || ctx.revisionTrackingEnabled ? await chunkXOX22WHL_cjs.lockRecordedGraphWrite(target, ctx.graphId) : chunkXOX22WHL_cjs.uncapturedGraphWriteLock();
67
+ const result = await fn(target, lock);
68
+ if (ctx.revisionTrackingEnabled && !ctx.historyEnabled) {
69
+ await chunkXOX22WHL_cjs.advanceRevisionClock(
70
+ target,
71
+ ctx.revisionSchema,
72
+ ctx.graphId,
73
+ ownsWriteLock
74
+ );
75
+ }
76
+ return result;
77
+ });
78
+ }
79
+ function runHookedWriteOperation(ctx, opContext, backend, body) {
80
+ return ctx.withOperationHooks(
81
+ opContext,
82
+ () => runInWriteTransaction(ctx, backend, body)
83
+ );
84
+ }
85
+
86
+ // src/store/constraints.ts
87
+ async function checkDisjointnessConstraint(ctx, kind, id) {
88
+ const disjointKinds = ctx.registry.getDisjointKinds(kind);
89
+ for (const disjointKind of disjointKinds) {
90
+ const existing = await ctx.backend.getNode(ctx.graphId, disjointKind, id);
91
+ if (existing && !existing.deleted_at) {
92
+ const error = chunkXOX22WHL_cjs.checkDisjointness(id, kind, [disjointKind], ctx.registry);
93
+ if (error) throw error;
94
+ }
95
+ }
96
+ }
97
+ async function checkCardinalityConstraint(ctx, edgeKind, cardinality, fromKind, fromId, toKind, toId, validTo) {
98
+ switch (cardinality) {
99
+ case "many": {
100
+ return;
101
+ }
102
+ case "one": {
103
+ const count = await ctx.backend.countEdgesFrom({
104
+ graphId: ctx.graphId,
105
+ edgeKind,
106
+ fromKind,
107
+ fromId
108
+ });
109
+ const error = chunkXOX22WHL_cjs.checkCardinality(
110
+ edgeKind,
111
+ fromKind,
112
+ fromId,
113
+ "one",
114
+ count,
115
+ false
116
+ );
117
+ if (error) throw error;
118
+ return;
119
+ }
120
+ case "unique": {
121
+ const exists = await ctx.backend.edgeExistsBetween({
122
+ graphId: ctx.graphId,
123
+ edgeKind,
124
+ fromKind,
125
+ fromId,
126
+ toKind,
127
+ toId
128
+ });
129
+ const error = chunkXOX22WHL_cjs.checkUniqueEdge(
130
+ edgeKind,
131
+ fromKind,
132
+ fromId,
133
+ toKind,
134
+ toId,
135
+ exists ? 1 : 0
136
+ );
137
+ if (error) throw error;
138
+ return;
139
+ }
140
+ case "oneActive": {
141
+ if (validTo !== void 0) {
142
+ return;
143
+ }
144
+ const count = await ctx.backend.countEdgesFrom({
145
+ graphId: ctx.graphId,
146
+ edgeKind,
147
+ fromKind,
148
+ fromId,
149
+ activeOnly: true
150
+ });
151
+ const error = chunkXOX22WHL_cjs.checkCardinality(
152
+ edgeKind,
153
+ fromKind,
154
+ fromId,
155
+ "oneActive",
156
+ count,
157
+ count > 0
158
+ );
159
+ if (error) throw error;
160
+ return;
161
+ }
162
+ }
163
+ }
164
+
165
+ // src/store/operations/node-operations.ts
166
+ function getNodeRegistration(graph, kind) {
167
+ const registration = graph.nodes[kind];
168
+ if (registration === void 0) throw new chunkLGEALRC6_cjs.KindNotFoundError(kind, "node");
169
+ return registration;
170
+ }
171
+ var CACHE_KEY_SEPARATOR = "\0";
172
+ function buildNodeCacheKey(graphId, kind, id) {
173
+ return `${graphId}${CACHE_KEY_SEPARATOR}${kind}${CACHE_KEY_SEPARATOR}${id}`;
174
+ }
175
+ function buildUniqueCacheKey(graphId, nodeKind, constraintName, key) {
176
+ return `${graphId}${CACHE_KEY_SEPARATOR}${nodeKind}${CACHE_KEY_SEPARATOR}${constraintName}${CACHE_KEY_SEPARATOR}${key}`;
177
+ }
178
+ function createNodeAlreadyExistsError(kind, id) {
179
+ return new chunkLGEALRC6_cjs.ValidationError(
180
+ `Node already exists: ${kind}/${id}`,
181
+ {
182
+ entityType: "node",
183
+ kind,
184
+ operation: "create",
185
+ id,
186
+ issues: [{ path: "id", message: "A node with this ID already exists" }]
187
+ },
188
+ { suggestion: `Use a different ID or update the existing node.` }
189
+ );
190
+ }
191
+ function buildInsertNodeParams(graphId, kind, id, props, validFrom, validTo) {
192
+ const insertParams = {
193
+ graphId,
194
+ kind,
195
+ id,
196
+ props
197
+ };
198
+ if (validFrom !== void 0) insertParams.validFrom = validFrom;
199
+ if (validTo !== void 0) insertParams.validTo = validTo;
200
+ return insertParams;
201
+ }
202
+ function createPendingUniqueRow(graphId, nodeKind, constraintName, key, nodeId) {
203
+ return {
204
+ graph_id: graphId,
205
+ node_kind: nodeKind,
206
+ constraint_name: constraintName,
207
+ key,
208
+ node_id: nodeId,
209
+ concrete_kind: nodeKind,
210
+ deleted_at: void 0
211
+ };
212
+ }
213
+ function resolveConstraint(graph, kind, constraintName) {
214
+ const registration = getNodeRegistration(graph, kind);
215
+ const constraints = registration.unique ?? [];
216
+ const constraint = constraints.find(
217
+ (candidate) => candidate.name === constraintName
218
+ );
219
+ if (constraint === void 0) {
220
+ throw new chunkLGEALRC6_cjs.NodeConstraintNotFoundError(constraintName, kind);
221
+ }
222
+ return constraint;
223
+ }
224
+ function createNodeBatchValidationBackend(graphId, registry, backend) {
225
+ const nodeCache = /* @__PURE__ */ new Map();
226
+ const pendingNodes = /* @__PURE__ */ new Map();
227
+ const uniqueCache = /* @__PURE__ */ new Map();
228
+ const pendingUniqueOwners = /* @__PURE__ */ new Map();
229
+ async function getNodeCached(lookupGraphId, kind, id) {
230
+ const cacheKey = buildNodeCacheKey(lookupGraphId, kind, id);
231
+ const pendingNode = pendingNodes.get(cacheKey);
232
+ if (pendingNode !== void 0) return pendingNode;
233
+ if (nodeCache.has(cacheKey)) return nodeCache.get(cacheKey);
234
+ const existing = await backend.getNode(lookupGraphId, kind, id);
235
+ nodeCache.set(cacheKey, existing);
236
+ return existing;
237
+ }
238
+ async function checkUniqueCached(params) {
239
+ const cacheKey = buildUniqueCacheKey(
240
+ params.graphId,
241
+ params.nodeKind,
242
+ params.constraintName,
243
+ params.key
244
+ );
245
+ const pendingOwner = pendingUniqueOwners.get(cacheKey);
246
+ if (pendingOwner !== void 0) {
247
+ return createPendingUniqueRow(
248
+ params.graphId,
249
+ params.nodeKind,
250
+ params.constraintName,
251
+ params.key,
252
+ pendingOwner
253
+ );
254
+ }
255
+ if (uniqueCache.has(cacheKey)) return uniqueCache.get(cacheKey);
256
+ const existing = await backend.checkUnique(params);
257
+ uniqueCache.set(cacheKey, existing);
258
+ return existing;
259
+ }
260
+ function registerPendingNode(params) {
261
+ const cacheKey = buildNodeCacheKey(params.graphId, params.kind, params.id);
262
+ pendingNodes.set(cacheKey, {
263
+ graph_id: params.graphId,
264
+ kind: params.kind,
265
+ id: params.id,
266
+ props: JSON.stringify(params.props),
267
+ version: 1,
268
+ // The simulated cached row only needs a NodeRow-shaped valid_from
269
+ // (string | undefined, never null) for existence/uniqueness checks,
270
+ // which don't inspect its value — normalize import's explicit-NULL
271
+ // sentinel away rather than widen this cache's row shape.
272
+ valid_from: params.validFrom ?? void 0,
273
+ valid_to: params.validTo,
274
+ created_at: "",
275
+ updated_at: "",
276
+ deleted_at: void 0
277
+ });
278
+ }
279
+ function registerPendingUniqueEntries(kind, id, props, constraints) {
280
+ for (const constraint of constraints) {
281
+ if (!chunkXOX22WHL_cjs.checkWherePredicate(constraint, props)) continue;
282
+ const key = chunkXOX22WHL_cjs.computeUniqueKey(
283
+ props,
284
+ constraint.fields,
285
+ constraint.collation
286
+ );
287
+ const concreteEntryKey = buildUniqueCacheKey(
288
+ graphId,
289
+ kind,
290
+ constraint.name,
291
+ key
292
+ );
293
+ pendingUniqueOwners.set(concreteEntryKey, id);
294
+ if (constraint.scope !== "kind") {
295
+ const kindsToCheck = chunkXOX22WHL_cjs.getKindsForUniquenessCheck(
296
+ kind,
297
+ constraint.scope,
298
+ registry
299
+ );
300
+ for (const kindToCheck of kindsToCheck) {
301
+ const inheritedEntryKey = buildUniqueCacheKey(
302
+ graphId,
303
+ kindToCheck,
304
+ constraint.name,
305
+ key
306
+ );
307
+ pendingUniqueOwners.set(inheritedEntryKey, id);
308
+ }
309
+ }
310
+ }
311
+ }
312
+ function registerAppliedNodeUpdate(kind, id, oldProps, newProps, constraints) {
313
+ for (const constraint of constraints) {
314
+ const oldApplies = chunkXOX22WHL_cjs.checkWherePredicate(constraint, oldProps);
315
+ const newApplies = chunkXOX22WHL_cjs.checkWherePredicate(constraint, newProps);
316
+ const oldKey = oldApplies ? chunkXOX22WHL_cjs.computeUniqueKey(oldProps, constraint.fields, constraint.collation) : void 0;
317
+ const newKey = newApplies ? chunkXOX22WHL_cjs.computeUniqueKey(newProps, constraint.fields, constraint.collation) : void 0;
318
+ if (oldKey === newKey) continue;
319
+ const kindsToCheck = chunkXOX22WHL_cjs.getKindsForUniquenessCheck(
320
+ kind,
321
+ constraint.scope,
322
+ registry
323
+ );
324
+ if (oldKey !== void 0) {
325
+ for (const kindToCheck of kindsToCheck) {
326
+ const cacheKey = buildUniqueCacheKey(
327
+ graphId,
328
+ kindToCheck,
329
+ constraint.name,
330
+ oldKey
331
+ );
332
+ pendingUniqueOwners.delete(cacheKey);
333
+ uniqueCache.set(cacheKey, void 0);
334
+ }
335
+ }
336
+ if (newKey !== void 0) {
337
+ for (const kindToCheck of kindsToCheck) {
338
+ const cacheKey = buildUniqueCacheKey(
339
+ graphId,
340
+ kindToCheck,
341
+ constraint.name,
342
+ newKey
343
+ );
344
+ pendingUniqueOwners.set(cacheKey, id);
345
+ }
346
+ }
347
+ }
348
+ }
349
+ function seedNodeRow(kind, id, row) {
350
+ const cacheKey = buildNodeCacheKey(graphId, kind, id);
351
+ if (nodeCache.has(cacheKey)) return;
352
+ nodeCache.set(cacheKey, row);
353
+ }
354
+ function seedUniqueRow(kind, constraintName, key, row) {
355
+ const cacheKey = buildUniqueCacheKey(graphId, kind, constraintName, key);
356
+ if (uniqueCache.has(cacheKey)) return;
357
+ uniqueCache.set(cacheKey, row);
358
+ }
359
+ const validationBackend = chunk4TOD4LBZ_cjs.createBackendOverlay(backend, {
360
+ getNode: getNodeCached,
361
+ checkUnique: checkUniqueCached
362
+ });
363
+ return {
364
+ backend: validationBackend,
365
+ registerPendingNode,
366
+ registerPendingUniqueEntries,
367
+ registerAppliedNodeUpdate,
368
+ seedNodeRow,
369
+ seedUniqueRow
370
+ };
371
+ }
372
+ function draftNodeCreate(ctx, input, id, options) {
373
+ const kind = input.kind;
374
+ const registration = getNodeRegistration(ctx.graph, kind);
375
+ const nodeKind = registration.type;
376
+ const validatedProps = options?.propsPreValidated === true ? input.props : chunkVPYHY3LJ_cjs.validateNodeProps(nodeKind.schema, input.props, {
377
+ kind,
378
+ operation: "create"
379
+ });
380
+ return {
381
+ kind,
382
+ id,
383
+ nodeKind,
384
+ uniqueConstraints: registration.unique ?? [],
385
+ validatedProps,
386
+ validFrom: chunkBLZDPRXT_cjs.validateOptionalCanonicalIsoDate(input.validFrom, "validFrom"),
387
+ validTo: chunkBLZDPRXT_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo")
388
+ };
389
+ }
390
+ async function finishNodeCreatePreparation(ctx, draft, backend) {
391
+ const { kind, id, validatedProps, uniqueConstraints } = draft;
392
+ const existingNode = await backend.getNode(ctx.graphId, kind, id);
393
+ if (existingNode && !existingNode.deleted_at) {
394
+ throw createNodeAlreadyExistsError(kind, id);
395
+ }
396
+ const constraintContext = {
397
+ graphId: ctx.graphId,
398
+ registry: ctx.registry,
399
+ backend
400
+ };
401
+ await checkDisjointnessConstraint(constraintContext, kind, id);
402
+ await chunkXOX22WHL_cjs.checkUniquenessConstraints(
403
+ chunkXOX22WHL_cjs.createUniquenessContext(ctx.graphId, ctx.registry, backend),
404
+ kind,
405
+ id,
406
+ validatedProps,
407
+ uniqueConstraints
408
+ );
409
+ return {
410
+ kind,
411
+ id,
412
+ nodeKind: draft.nodeKind,
413
+ validatedProps,
414
+ uniqueConstraints,
415
+ insertParams: buildInsertNodeParams(
416
+ ctx.graphId,
417
+ kind,
418
+ id,
419
+ validatedProps,
420
+ draft.validFrom,
421
+ draft.validTo
422
+ )
423
+ };
424
+ }
425
+ async function validateAndPrepareNodeCreate(ctx, input, id, backend, options) {
426
+ return finishNodeCreatePreparation(
427
+ ctx,
428
+ draftNodeCreate(ctx, input, id, options),
429
+ backend
430
+ );
431
+ }
432
+ async function finalizeNodeCreateBatch(ctx, preparedCreates, backend, lock) {
433
+ await chunkXOX22WHL_cjs.applyNodeInsertSideEffectsBatch(
434
+ chunkXOX22WHL_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
435
+ preparedCreates.map((prepared) => ({
436
+ kind: prepared.kind,
437
+ id: prepared.id,
438
+ schema: prepared.nodeKind.schema,
439
+ props: prepared.validatedProps,
440
+ uniqueConstraints: prepared.uniqueConstraints
441
+ })),
442
+ backend
443
+ );
444
+ }
445
+ async function finalizeNodeCreate(ctx, prepared, backend, lock) {
446
+ await chunkXOX22WHL_cjs.applyNodeInsertSideEffects(
447
+ chunkXOX22WHL_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
448
+ {
449
+ kind: prepared.kind,
450
+ id: prepared.id,
451
+ schema: prepared.nodeKind.schema,
452
+ props: prepared.validatedProps,
453
+ uniqueConstraints: prepared.uniqueConstraints
454
+ },
455
+ backend
456
+ );
457
+ }
458
+ async function performNodeUpdate(ctx, input, backend, lock, options) {
459
+ const { kind, id } = input;
460
+ const registration = getNodeRegistration(ctx.graph, kind);
461
+ const existing = await backend.getNode(ctx.graphId, kind, id);
462
+ if (!existing) throw new chunkLGEALRC6_cjs.NodeNotFoundError(kind, id);
463
+ const existingProps = chunk4TOD4LBZ_cjs.rowPropsToObject(existing.props);
464
+ const mergedProps = { ...existingProps, ...input.props };
465
+ const nodeKind = registration.type;
466
+ const validatedProps = chunkVPYHY3LJ_cjs.validateNodeProps(nodeKind.schema, mergedProps, {
467
+ kind,
468
+ operation: "update",
469
+ id
470
+ });
471
+ const validTo = chunkBLZDPRXT_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
472
+ const writeContext = chunkXOX22WHL_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock);
473
+ const shared = {
474
+ schema: nodeKind.schema,
475
+ validatedProps,
476
+ uniqueConstraints: registration.unique ?? [],
477
+ ...validTo !== void 0 && { validTo }
478
+ };
479
+ if (options?.clearDeleted) {
480
+ const row2 = await chunkXOX22WHL_cjs.applyNodeUpdate(
481
+ writeContext,
482
+ { ...shared, existing, clearDeleted: true },
483
+ backend
484
+ );
485
+ return rowToNode(row2);
486
+ }
487
+ if (!chunk4TOD4LBZ_cjs.isLiveNodeRow(existing)) throw new chunkLGEALRC6_cjs.NodeNotFoundError(kind, id);
488
+ const row = await chunkXOX22WHL_cjs.applyNodeUpdate(
489
+ writeContext,
490
+ { ...shared, existing },
491
+ backend
492
+ );
493
+ return rowToNode(row);
494
+ }
495
+ async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
496
+ if (backend.getNodes !== void 0) {
497
+ const idsByKind = /* @__PURE__ */ new Map();
498
+ for (const draft of drafts) {
499
+ const ids = idsByKind.get(draft.kind) ?? /* @__PURE__ */ new Set();
500
+ ids.add(draft.id);
501
+ idsByKind.set(draft.kind, ids);
502
+ }
503
+ for (const [kind, ids] of idsByKind) {
504
+ const orderedIds = [...ids];
505
+ const rows = await backend.getNodes(ctx.graphId, kind, orderedIds);
506
+ const rowsById = new Map(rows.map((row) => [row.id, row]));
507
+ for (const id of orderedIds) {
508
+ seams.seedNodeRow(kind, id, rowsById.get(id));
509
+ }
510
+ }
511
+ }
512
+ if (backend.checkUniqueBatch !== void 0) {
513
+ const groups = /* @__PURE__ */ new Map();
514
+ for (const draft of drafts) {
515
+ for (const constraint of draft.uniqueConstraints) {
516
+ if (!chunkXOX22WHL_cjs.checkWherePredicate(constraint, draft.validatedProps)) continue;
517
+ const key = chunkXOX22WHL_cjs.computeUniqueKey(
518
+ draft.validatedProps,
519
+ constraint.fields,
520
+ constraint.collation
521
+ );
522
+ const kindsToCheck = chunkXOX22WHL_cjs.getKindsForUniquenessCheck(
523
+ draft.kind,
524
+ constraint.scope,
525
+ ctx.registry
526
+ );
527
+ for (const kindToCheck of kindsToCheck) {
528
+ const groupKey = kindToCheck + CACHE_KEY_SEPARATOR + constraint.name;
529
+ const group = groups.get(groupKey) ?? {
530
+ nodeKind: kindToCheck,
531
+ constraintName: constraint.name,
532
+ keys: /* @__PURE__ */ new Set()
533
+ };
534
+ group.keys.add(key);
535
+ groups.set(groupKey, group);
536
+ }
537
+ }
538
+ }
539
+ for (const group of groups.values()) {
540
+ const orderedKeys = [...group.keys];
541
+ const rows = await backend.checkUniqueBatch({
542
+ graphId: ctx.graphId,
543
+ nodeKind: group.nodeKind,
544
+ constraintName: group.constraintName,
545
+ keys: orderedKeys
546
+ });
547
+ const rowsByKey = new Map(rows.map((row) => [row.key, row]));
548
+ for (const key of orderedKeys) {
549
+ seams.seedUniqueRow(
550
+ group.nodeKind,
551
+ group.constraintName,
552
+ key,
553
+ rowsByKey.get(key)
554
+ );
555
+ }
556
+ }
557
+ }
558
+ }
559
+ async function prepareBatchCreates(ctx, inputs, backend, options) {
560
+ const {
561
+ backend: validationBackend,
562
+ registerPendingNode,
563
+ registerPendingUniqueEntries,
564
+ seedNodeRow,
565
+ seedUniqueRow
566
+ } = createNodeBatchValidationBackend(ctx.graphId, ctx.registry, backend);
567
+ const drafts = inputs.map(
568
+ (input) => draftNodeCreate(ctx, input, input.id ?? chunkXOX22WHL_cjs.generateId(), options)
569
+ );
570
+ await primeBatchValidationCaches(ctx, drafts, backend, {
571
+ seedNodeRow,
572
+ seedUniqueRow
573
+ });
574
+ const preparedCreates = [];
575
+ for (const draft of drafts) {
576
+ const prepared = await finishNodeCreatePreparation(
577
+ ctx,
578
+ draft,
579
+ validationBackend
580
+ );
581
+ preparedCreates.push(prepared);
582
+ registerPendingNode(prepared.insertParams);
583
+ registerPendingUniqueEntries(
584
+ prepared.kind,
585
+ prepared.id,
586
+ prepared.validatedProps,
587
+ prepared.uniqueConstraints
588
+ );
589
+ }
590
+ const batchInsertParams = preparedCreates.map(
591
+ (prepared) => prepared.insertParams
592
+ );
593
+ return { preparedCreates, batchInsertParams };
594
+ }
595
+ async function findUniqueRowAcrossKinds(backend, graphId, constraintName, key, kindsToCheck, includeDeleted) {
596
+ for (const kindToCheck of kindsToCheck) {
597
+ const row = await backend.checkUnique({
598
+ graphId,
599
+ nodeKind: kindToCheck,
600
+ constraintName,
601
+ key,
602
+ includeDeleted
603
+ });
604
+ if (row !== void 0) return row;
605
+ }
606
+ return void 0;
607
+ }
608
+ async function batchCheckUniqueAcrossKinds(backend, graphId, constraintName, uniqueKeys, kindsToCheck, includeDeleted) {
609
+ const existingByKey = /* @__PURE__ */ new Map();
610
+ for (const kindToCheck of kindsToCheck) {
611
+ if (backend.checkUniqueBatch === void 0) {
612
+ for (const key of uniqueKeys) {
613
+ if (existingByKey.has(key)) continue;
614
+ const row = await backend.checkUnique({
615
+ graphId,
616
+ nodeKind: kindToCheck,
617
+ constraintName,
618
+ key,
619
+ includeDeleted
620
+ });
621
+ if (row !== void 0) {
622
+ existingByKey.set(row.key, row);
623
+ }
624
+ }
625
+ } else {
626
+ const rows = await backend.checkUniqueBatch({
627
+ graphId,
628
+ nodeKind: kindToCheck,
629
+ constraintName,
630
+ keys: uniqueKeys,
631
+ includeDeleted
632
+ });
633
+ for (const row of rows) {
634
+ if (!existingByKey.has(row.key)) {
635
+ existingByKey.set(row.key, row);
636
+ }
637
+ }
638
+ }
639
+ }
640
+ return existingByKey;
641
+ }
642
+ async function executeNodeCreateInternal(ctx, input, backend, options) {
643
+ const kind = input.kind;
644
+ const id = input.id ?? chunkXOX22WHL_cjs.generateId();
645
+ const opContext = ctx.createOperationContext("create", "node", kind, id);
646
+ const shouldReturnRow = options?.returnRow ?? true;
647
+ return runHookedWriteOperation(
648
+ ctx,
649
+ opContext,
650
+ backend,
651
+ async (target, lock) => {
652
+ const prepared = await validateAndPrepareNodeCreate(
653
+ ctx,
654
+ input,
655
+ id,
656
+ target,
657
+ options
658
+ );
659
+ let row;
660
+ if (shouldReturnRow) {
661
+ row = await target.insertNode(prepared.insertParams);
662
+ } else {
663
+ await chunkXOX22WHL_cjs.runInsertNoReturn(
664
+ chunkXOX22WHL_cjs.nodeInsertDispatch(target),
665
+ prepared.insertParams
666
+ );
667
+ }
668
+ await finalizeNodeCreate(ctx, prepared, target, lock);
669
+ if (row === void 0) return;
670
+ return rowToNode(row);
671
+ }
672
+ );
673
+ }
674
+ async function executeNodeCreate(ctx, input, backend, options) {
675
+ const result = await executeNodeCreateInternal(ctx, input, backend, {
676
+ returnRow: true,
677
+ ...options
678
+ });
679
+ if (!result) {
680
+ throw new chunkLGEALRC6_cjs.DatabaseOperationError(
681
+ "Node create failed: expected created node row",
682
+ { operation: "insert", entity: "node" }
683
+ );
684
+ }
685
+ return result;
686
+ }
687
+ async function executeNodeCreateNoReturnBatch(ctx, inputs, backend) {
688
+ if (inputs.length === 0) return;
689
+ await runInWriteTransaction(ctx, backend, async (target, lock) => {
690
+ const { preparedCreates, batchInsertParams } = await prepareBatchCreates(
691
+ ctx,
692
+ inputs,
693
+ target
694
+ );
695
+ await chunkXOX22WHL_cjs.runInsertBatch(chunkXOX22WHL_cjs.nodeInsertDispatch(target), batchInsertParams);
696
+ await finalizeNodeCreateBatch(ctx, preparedCreates, target, lock);
697
+ });
698
+ }
699
+ async function executeNodeCreateBatch(ctx, inputs, backend, options) {
700
+ if (inputs.length === 0) return [];
701
+ return runInWriteTransaction(ctx, backend, async (target, lock) => {
702
+ const { preparedCreates, batchInsertParams } = await prepareBatchCreates(
703
+ ctx,
704
+ inputs,
705
+ target,
706
+ options
707
+ );
708
+ const rows = await chunkXOX22WHL_cjs.runInsertBatchReturning(
709
+ chunkXOX22WHL_cjs.nodeInsertDispatch(target),
710
+ batchInsertParams
711
+ );
712
+ await finalizeNodeCreateBatch(ctx, preparedCreates, target, lock);
713
+ return rows.map((row) => rowToNode(row));
714
+ });
715
+ }
716
+ async function executeNodeUpdate(ctx, input, backend, options) {
717
+ const opContext = ctx.createOperationContext(
718
+ "update",
719
+ "node",
720
+ input.kind,
721
+ input.id
722
+ );
723
+ return runHookedWriteOperation(
724
+ ctx,
725
+ opContext,
726
+ backend,
727
+ (target, lock) => performNodeUpdate(ctx, input, target, lock, options)
728
+ );
729
+ }
730
+ async function executeNodeUpsertUpdate(ctx, input, backend, options) {
731
+ return runInWriteTransaction(
732
+ ctx,
733
+ backend,
734
+ (target, lock) => performNodeUpdate(ctx, input, target, lock, options)
735
+ );
736
+ }
737
+ async function executeNodeDelete(ctx, kind, id, backend) {
738
+ const gate = await backend.getNode(ctx.graphId, kind, id);
739
+ if (!gate || gate.deleted_at) return;
740
+ const opContext = ctx.createOperationContext("delete", "node", kind, id);
741
+ return runHookedWriteOperation(
742
+ ctx,
743
+ opContext,
744
+ backend,
745
+ async (target, lock) => {
746
+ const registration = getNodeRegistration(ctx.graph, kind);
747
+ const preflight = await target.getNode(ctx.graphId, kind, id);
748
+ if (!preflight || !chunk4TOD4LBZ_cjs.isLiveNodeRow(preflight)) return;
749
+ await chunkXOX22WHL_cjs.applyNodeSoftDelete(
750
+ chunkXOX22WHL_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
751
+ {
752
+ existing: preflight,
753
+ schema: registration.type.schema,
754
+ uniqueConstraints: registration.unique ?? [],
755
+ onDelete: registration.onDelete
756
+ },
757
+ target
758
+ );
759
+ }
760
+ );
761
+ }
762
+ async function executeNodeHardDelete(ctx, kind, id, backend) {
763
+ const gate = await backend.getNode(ctx.graphId, kind, id);
764
+ if (!gate) return;
765
+ const opContext = ctx.createOperationContext("delete", "node", kind, id);
766
+ return runHookedWriteOperation(
767
+ ctx,
768
+ opContext,
769
+ backend,
770
+ async (target, lock) => {
771
+ const registration = getNodeRegistration(ctx.graph, kind);
772
+ await chunkXOX22WHL_cjs.applyNodeHardDelete(
773
+ chunkXOX22WHL_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
774
+ {
775
+ kind,
776
+ id,
777
+ schema: registration.type.schema,
778
+ onDelete: registration.onDelete
779
+ },
780
+ target
781
+ );
782
+ }
783
+ );
784
+ }
785
+ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, props, backend, options) {
786
+ const ifExists = options?.ifExists ?? "return";
787
+ const registration = getNodeRegistration(ctx.graph, kind);
788
+ const nodeKind = registration.type;
789
+ const validatedProps = chunkVPYHY3LJ_cjs.validateNodeProps(nodeKind.schema, props, {
790
+ kind,
791
+ operation: "create"
792
+ });
793
+ const constraint = resolveConstraint(ctx.graph, kind, constraintName);
794
+ if (!chunkXOX22WHL_cjs.checkWherePredicate(constraint, validatedProps)) {
795
+ const node = await executeNodeCreate(
796
+ ctx,
797
+ { kind, props: validatedProps },
798
+ backend,
799
+ { propsPreValidated: true }
800
+ );
801
+ return { node, action: "created" };
802
+ }
803
+ const key = chunkXOX22WHL_cjs.computeUniqueKey(
804
+ validatedProps,
805
+ constraint.fields,
806
+ constraint.collation
807
+ );
808
+ const kindsToCheck = chunkXOX22WHL_cjs.getKindsForUniquenessCheck(
809
+ kind,
810
+ constraint.scope,
811
+ ctx.registry
812
+ );
813
+ async function attempt() {
814
+ const existingUniqueRow = await findUniqueRowAcrossKinds(
815
+ backend,
816
+ ctx.graphId,
817
+ constraint.name,
818
+ key,
819
+ kindsToCheck,
820
+ true
821
+ );
822
+ if (existingUniqueRow === void 0) {
823
+ const node = await executeNodeCreate(
824
+ ctx,
825
+ { kind, props: validatedProps },
826
+ backend,
827
+ { propsPreValidated: true }
828
+ );
829
+ return { node, action: "created" };
830
+ }
831
+ const existingRow = await backend.getNode(
832
+ ctx.graphId,
833
+ existingUniqueRow.concrete_kind,
834
+ existingUniqueRow.node_id
835
+ );
836
+ if (existingRow === void 0) {
837
+ const node = await executeNodeCreate(
838
+ ctx,
839
+ { kind, props: validatedProps },
840
+ backend,
841
+ { propsPreValidated: true }
842
+ );
843
+ return { node, action: "created" };
844
+ }
845
+ const isSoftDeleted = existingRow.deleted_at !== void 0;
846
+ if (isSoftDeleted || ifExists === "update") {
847
+ const concreteKind = existingUniqueRow.concrete_kind;
848
+ const node = await executeNodeUpsertUpdate(
849
+ ctx,
850
+ {
851
+ kind: concreteKind,
852
+ id: existingRow.id,
853
+ props: validatedProps
854
+ },
855
+ backend,
856
+ { clearDeleted: isSoftDeleted }
857
+ );
858
+ return { node, action: isSoftDeleted ? "resurrected" : "updated" };
859
+ }
860
+ return { node: rowToNode(existingRow), action: "found" };
861
+ }
862
+ try {
863
+ return await attempt();
864
+ } catch (error) {
865
+ if (!(error instanceof chunkLGEALRC6_cjs.UniquenessError)) throw error;
866
+ return attempt();
867
+ }
868
+ }
869
+ async function executeNodeFindByConstraint(ctx, kind, constraintName, props, backend) {
870
+ const registration = getNodeRegistration(ctx.graph, kind);
871
+ const nodeKind = registration.type;
872
+ const validatedProps = chunkVPYHY3LJ_cjs.validateNodeProps(nodeKind.schema, props, {
873
+ kind,
874
+ operation: "create"
875
+ });
876
+ const constraint = resolveConstraint(ctx.graph, kind, constraintName);
877
+ if (!chunkXOX22WHL_cjs.checkWherePredicate(constraint, validatedProps)) return void 0;
878
+ const key = chunkXOX22WHL_cjs.computeUniqueKey(
879
+ validatedProps,
880
+ constraint.fields,
881
+ constraint.collation
882
+ );
883
+ const kindsToCheck = chunkXOX22WHL_cjs.getKindsForUniquenessCheck(
884
+ kind,
885
+ constraint.scope,
886
+ ctx.registry
887
+ );
888
+ const existingUniqueRow = await findUniqueRowAcrossKinds(
889
+ backend,
890
+ ctx.graphId,
891
+ constraint.name,
892
+ key,
893
+ kindsToCheck,
894
+ false
895
+ );
896
+ if (existingUniqueRow === void 0) return void 0;
897
+ const existingRow = await backend.getNode(
898
+ ctx.graphId,
899
+ existingUniqueRow.concrete_kind,
900
+ existingUniqueRow.node_id
901
+ );
902
+ if (existingRow === void 0 || existingRow.deleted_at !== void 0)
903
+ return void 0;
904
+ return rowToNode(existingRow);
905
+ }
906
+ function validateAndComputeKeys(nodeKind, kind, constraint, items) {
907
+ const validated = [];
908
+ for (const item of items) {
909
+ const validatedProps = chunkVPYHY3LJ_cjs.validateNodeProps(nodeKind.schema, item.props, {
910
+ kind,
911
+ operation: "create"
912
+ });
913
+ const applies = chunkXOX22WHL_cjs.checkWherePredicate(constraint, validatedProps);
914
+ const key = applies ? chunkXOX22WHL_cjs.computeUniqueKey(
915
+ validatedProps,
916
+ constraint.fields,
917
+ constraint.collation
918
+ ) : void 0;
919
+ validated.push({ validatedProps, key });
920
+ }
921
+ return validated;
922
+ }
923
+ function collectUniqueKeys(validated) {
924
+ return [
925
+ ...new Set(
926
+ validated.map((entry) => entry.key).filter((key) => key !== void 0)
927
+ )
928
+ ];
929
+ }
930
+ async function executeNodeBulkFindByConstraint(ctx, kind, constraintName, items, backend) {
931
+ if (items.length === 0) return [];
932
+ const registration = getNodeRegistration(ctx.graph, kind);
933
+ const nodeKind = registration.type;
934
+ const constraint = resolveConstraint(ctx.graph, kind, constraintName);
935
+ const validated = validateAndComputeKeys(nodeKind, kind, constraint, items);
936
+ const uniqueKeys = collectUniqueKeys(validated);
937
+ const kindsToCheck = chunkXOX22WHL_cjs.getKindsForUniquenessCheck(
938
+ kind,
939
+ constraint.scope,
940
+ ctx.registry
941
+ );
942
+ const existingByKey = uniqueKeys.length > 0 ? await batchCheckUniqueAcrossKinds(
943
+ backend,
944
+ ctx.graphId,
945
+ constraint.name,
946
+ uniqueKeys,
947
+ kindsToCheck,
948
+ false
949
+ ) : /* @__PURE__ */ new Map();
950
+ const results = Array.from({ length: items.length });
951
+ const seenKeys = /* @__PURE__ */ new Map();
952
+ for (const [index, { key }] of validated.entries()) {
953
+ if (key === void 0) {
954
+ results[index] = void 0;
955
+ continue;
956
+ }
957
+ const previousIndex = seenKeys.get(key);
958
+ if (previousIndex !== void 0) {
959
+ results[index] = results[previousIndex];
960
+ continue;
961
+ }
962
+ seenKeys.set(key, index);
963
+ const existing = existingByKey.get(key);
964
+ if (existing === void 0) {
965
+ results[index] = void 0;
966
+ continue;
967
+ }
968
+ const existingRow = await backend.getNode(
969
+ ctx.graphId,
970
+ existing.concrete_kind,
971
+ existing.node_id
972
+ );
973
+ if (existingRow === void 0 || existingRow.deleted_at !== void 0) {
974
+ results[index] = void 0;
975
+ continue;
976
+ }
977
+ results[index] = rowToNode(existingRow);
978
+ }
979
+ return results;
980
+ }
981
+ function resolveNodeIndex(graph, kind, indexName) {
982
+ getNodeRegistration(graph, kind);
983
+ const declaration = graph.indexes?.find(
984
+ (candidate) => candidate.entity === "node" && candidate.kind === kind && candidate.name === indexName
985
+ );
986
+ if (declaration?.entity !== "node") {
987
+ throw new chunkLGEALRC6_cjs.NodeIndexNotFoundError(indexName, kind);
988
+ }
989
+ if (declaration.method !== void 0) {
990
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
991
+ `bulkFindByIndex cannot probe index "${indexName}" (method "${declaration.method}"): only btree indexes serve equality probes.`,
992
+ { indexName, kind, method: declaration.method }
993
+ );
994
+ }
995
+ return declaration;
996
+ }
997
+ var INDEX_PROBE_EXPECTED_TYPEOF = {
998
+ string: "string",
999
+ number: "number",
1000
+ boolean: "boolean"
1001
+ };
1002
+ function validateIndexProbeValue(value, valueType, pointer, kind) {
1003
+ if (value === void 0 || value === null) return;
1004
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean" && !(value instanceof Date)) {
1005
+ throw indexProbeTypeError(
1006
+ pointer,
1007
+ kind,
1008
+ "a scalar (string, number, boolean, or Date)",
1009
+ value
1010
+ );
1011
+ }
1012
+ if (valueType === "date") {
1013
+ if (value instanceof Date || typeof value === "string") return;
1014
+ throw indexProbeTypeError(
1015
+ pointer,
1016
+ kind,
1017
+ "date (Date or ISO string)",
1018
+ value
1019
+ );
1020
+ }
1021
+ const expected = INDEX_PROBE_EXPECTED_TYPEOF[valueType ?? "unknown"];
1022
+ if (expected === void 0) return;
1023
+ if (typeof value !== expected) {
1024
+ throw indexProbeTypeError(pointer, kind, expected, value);
1025
+ }
1026
+ }
1027
+ function indexProbeTypeError(pointer, kind, expected, value) {
1028
+ return new chunkLGEALRC6_cjs.ValidationError(
1029
+ `Index probe value for "${pointer}" on node kind "${kind}" has an incompatible type`,
1030
+ {
1031
+ entityType: "node",
1032
+ kind,
1033
+ issues: [
1034
+ {
1035
+ path: pointer,
1036
+ message: `Expected ${expected}, received ${typeof value}`,
1037
+ code: "invalid_type"
1038
+ }
1039
+ ]
1040
+ }
1041
+ );
1042
+ }
1043
+ function coerceIndexProbeBind(value, adapter) {
1044
+ return adapter.bindValue(normalizeProbeScalar(value));
1045
+ }
1046
+ function normalizeProbeScalar(value) {
1047
+ return value instanceof Date ? value.toISOString() : value;
1048
+ }
1049
+ var PROBE_NULL_TAG = 0;
1050
+ var PROBE_VALUE_TAG = 1;
1051
+ function canonicalIndexProbeKey(probe) {
1052
+ return JSON.stringify(
1053
+ probe.map(
1054
+ (value) => value === void 0 || value === null ? [PROBE_NULL_TAG] : [PROBE_VALUE_TAG, normalizeProbeScalar(value)]
1055
+ )
1056
+ );
1057
+ }
1058
+ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend, options) {
1059
+ if (items.length === 0) return [];
1060
+ const index = resolveNodeIndex(ctx.graph, kind, indexName);
1061
+ if (index.fields.length === 0) {
1062
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
1063
+ `bulkFindByIndex requires an index with at least one prop-based field on index "${indexName}" (node kind "${kind}")`,
1064
+ { indexName, kind },
1065
+ {
1066
+ suggestion: "bulkFindByIndex probes by prop values from each item; an index declared with only keySystemColumns/coveringFields (no fields) has nothing to probe by."
1067
+ }
1068
+ );
1069
+ }
1070
+ if (index.fieldValueTypes.includes("date")) {
1071
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
1072
+ `bulkFindByIndex does not support date-typed key fields on index "${indexName}" (node kind "${kind}")`,
1073
+ { indexName, kind },
1074
+ {
1075
+ suggestion: "Date index keys compare differently across SQLite and PostgreSQL. Use a string-encoded key field, or query date predicates via store.query(...).where(...)."
1076
+ }
1077
+ );
1078
+ }
1079
+ const limitPerInput = options?.limitPerInput;
1080
+ if (limitPerInput !== void 0 && (!Number.isInteger(limitPerInput) || limitPerInput <= 0)) {
1081
+ throw new chunkLGEALRC6_cjs.ValidationError(
1082
+ "bulkFindByIndex limitPerInput must be a positive integer",
1083
+ {
1084
+ entityType: "node",
1085
+ kind,
1086
+ issues: [
1087
+ {
1088
+ path: "limitPerInput",
1089
+ message: `Expected a positive integer, received ${String(limitPerInput)}`,
1090
+ code: "invalid_value"
1091
+ }
1092
+ ]
1093
+ }
1094
+ );
1095
+ }
1096
+ const adapter = chunkD7ZEOS56_cjs.getDialect(backend.dialect);
1097
+ const probes = items.map(
1098
+ (item) => index.fields.map((pointer, position) => {
1099
+ const value = chunkTDXIBCGY_cjs.resolveJsonPointer(item.props, pointer);
1100
+ validateIndexProbeValue(
1101
+ value,
1102
+ index.fieldValueTypes[position],
1103
+ pointer,
1104
+ kind
1105
+ );
1106
+ return value;
1107
+ })
1108
+ );
1109
+ const groupByKey = /* @__PURE__ */ new Map();
1110
+ const groupProbes = [];
1111
+ const groupToInputs = [];
1112
+ for (const [inputIndex, probe] of probes.entries()) {
1113
+ const key = canonicalIndexProbeKey(probe);
1114
+ const existing = groupByKey.get(key);
1115
+ if (existing === void 0) {
1116
+ groupByKey.set(key, groupProbes.length);
1117
+ groupProbes.push(probe);
1118
+ groupToInputs.push([inputIndex]);
1119
+ continue;
1120
+ }
1121
+ groupToInputs[existing]?.push(inputIndex);
1122
+ }
1123
+ const schema = backend.tableNames ? chunkXOX22WHL_cjs.createSqlSchema(backend.tableNames) : chunkXOX22WHL_cjs.DEFAULT_SQL_SCHEMA;
1124
+ const compileContext = {
1125
+ dialect: backend.dialect,
1126
+ propsColumn: drizzleOrm.sql.raw(`"props"`),
1127
+ systemColumn: (column) => drizzleOrm.sql.raw(`"${column}"`)
1128
+ };
1129
+ const fieldKeys = chunkD7ZEOS56_cjs.compileNodeIndexFieldKeys(index, compileContext);
1130
+ const groupPredicates = groupProbes.map(
1131
+ (probe) => drizzleOrm.sql`(${drizzleOrm.sql.join(
1132
+ fieldKeys.map((fieldKey, position) => {
1133
+ const value = probe[position];
1134
+ if (value === void 0 || value === null) {
1135
+ return drizzleOrm.sql`${fieldKey} IS NULL`;
1136
+ }
1137
+ return adapter.nullSafeEquals(
1138
+ fieldKey,
1139
+ drizzleOrm.sql`${coerceIndexProbeBind(value, adapter)}`
1140
+ );
1141
+ }),
1142
+ drizzleOrm.sql` AND `
1143
+ )})`
1144
+ );
1145
+ const caseBranches = groupPredicates.map(
1146
+ (predicate, group) => drizzleOrm.sql`WHEN ${predicate} THEN ${drizzleOrm.sql.raw(String(group))}`
1147
+ );
1148
+ const probeIndexExpr = drizzleOrm.sql`CASE ${drizzleOrm.sql.join(caseBranches, drizzleOrm.sql` `)} ELSE NULL END`;
1149
+ const conditions = [
1150
+ drizzleOrm.sql`"graph_id" = ${ctx.graphId}`,
1151
+ drizzleOrm.sql`"kind" = ${kind}`,
1152
+ drizzleOrm.sql`"deleted_at" IS NULL`
1153
+ ];
1154
+ if (index.where !== void 0) {
1155
+ conditions.push(chunkD7ZEOS56_cjs.compileIndexWhere(compileContext, index.where));
1156
+ }
1157
+ conditions.push(drizzleOrm.sql`(${drizzleOrm.sql.join(groupPredicates, drizzleOrm.sql` OR `)})`);
1158
+ const whereClause = drizzleOrm.sql.join(conditions, drizzleOrm.sql` AND `);
1159
+ const probedSelect = drizzleOrm.sql`SELECT "id", ${probeIndexExpr} AS probe_idx FROM ${schema.nodesTable} WHERE ${whereClause}`;
1160
+ const capInSql = limitPerInput !== void 0 && backend.capabilities.windowFunctions;
1161
+ const query = capInSql ? drizzleOrm.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"` : drizzleOrm.sql`${probedSelect} ORDER BY probe_idx, "id"`;
1162
+ const rawMatches = await backend.execute(
1163
+ chunkEOLERH7Y_cjs.asCompiledRowsSql(query)
1164
+ );
1165
+ const matches = limitPerInput !== void 0 && !capInSql ? capMatchesPerGroup(rawMatches, limitPerInput) : rawMatches;
1166
+ const nodesById = await hydrateNodesById(
1167
+ backend,
1168
+ ctx.graphId,
1169
+ kind,
1170
+ matches.map((match) => match.id)
1171
+ );
1172
+ const results = Array.from({ length: items.length }, () => []);
1173
+ for (const match of matches) {
1174
+ const node = nodesById.get(match.id);
1175
+ if (node === void 0) continue;
1176
+ const inputs = groupToInputs[match.probe_idx];
1177
+ if (inputs === void 0) continue;
1178
+ for (const inputIndex of inputs) {
1179
+ results[inputIndex]?.push(node);
1180
+ }
1181
+ }
1182
+ return results;
1183
+ }
1184
+ function capMatchesPerGroup(matches, limitPerInput) {
1185
+ const perGroupCount = /* @__PURE__ */ new Map();
1186
+ const capped = [];
1187
+ for (const match of matches) {
1188
+ const count = perGroupCount.get(match.probe_idx) ?? 0;
1189
+ if (count >= limitPerInput) continue;
1190
+ perGroupCount.set(match.probe_idx, count + 1);
1191
+ capped.push(match);
1192
+ }
1193
+ return capped;
1194
+ }
1195
+ async function hydrateNodesById(backend, graphId, kind, ids) {
1196
+ const rowsById = await chunkXOX22WHL_cjs.getNodeRowsByIds(backend, graphId, kind, ids);
1197
+ const nodesById = /* @__PURE__ */ new Map();
1198
+ for (const [id, row] of rowsById) {
1199
+ if (row.deleted_at !== void 0) continue;
1200
+ nodesById.set(id, rowToNode(row));
1201
+ }
1202
+ return nodesById;
1203
+ }
1204
+ async function executeNodeBulkGetOrCreateByConstraint(ctx, kind, constraintName, items, backend, options) {
1205
+ if (items.length === 0) return [];
1206
+ const ifExists = options?.ifExists ?? "return";
1207
+ const registration = getNodeRegistration(ctx.graph, kind);
1208
+ const nodeKind = registration.type;
1209
+ const constraint = resolveConstraint(ctx.graph, kind, constraintName);
1210
+ const validated = validateAndComputeKeys(nodeKind, kind, constraint, items);
1211
+ const uniqueKeys = collectUniqueKeys(validated);
1212
+ const kindsToCheck = chunkXOX22WHL_cjs.getKindsForUniquenessCheck(
1213
+ kind,
1214
+ constraint.scope,
1215
+ ctx.registry
1216
+ );
1217
+ const existingByKey = uniqueKeys.length > 0 ? await batchCheckUniqueAcrossKinds(
1218
+ backend,
1219
+ ctx.graphId,
1220
+ constraint.name,
1221
+ uniqueKeys,
1222
+ kindsToCheck,
1223
+ true
1224
+ ) : /* @__PURE__ */ new Map();
1225
+ const toCreate = [];
1226
+ const toFetch = [];
1227
+ const duplicateOf = [];
1228
+ const seenKeys = /* @__PURE__ */ new Map();
1229
+ for (const [index, { validatedProps, key }] of validated.entries()) {
1230
+ if (key === void 0) {
1231
+ toCreate.push({ index, input: { kind, props: validatedProps } });
1232
+ continue;
1233
+ }
1234
+ const previousIndex = seenKeys.get(key);
1235
+ if (previousIndex !== void 0) {
1236
+ duplicateOf.push({ index, sourceIndex: previousIndex });
1237
+ continue;
1238
+ }
1239
+ seenKeys.set(key, index);
1240
+ const existing = existingByKey.get(key);
1241
+ if (existing === void 0) {
1242
+ toCreate.push({ index, input: { kind, props: validatedProps } });
1243
+ } else {
1244
+ toFetch.push({
1245
+ index,
1246
+ nodeId: existing.node_id,
1247
+ concreteKind: existing.concrete_kind,
1248
+ validatedProps,
1249
+ isSoftDeleted: existing.deleted_at !== void 0
1250
+ });
1251
+ }
1252
+ }
1253
+ const results = Array.from({ length: items.length });
1254
+ if (toCreate.length > 0) {
1255
+ const createInputs = toCreate.map((entry) => entry.input);
1256
+ const createdNodes = await executeNodeCreateBatch(
1257
+ ctx,
1258
+ createInputs,
1259
+ backend,
1260
+ { propsPreValidated: true }
1261
+ );
1262
+ for (const [batchIndex, entry] of toCreate.entries()) {
1263
+ results[entry.index] = {
1264
+ node: createdNodes[batchIndex],
1265
+ action: "created"
1266
+ };
1267
+ }
1268
+ }
1269
+ for (const entry of toFetch) {
1270
+ const { index, concreteKind, validatedProps, isSoftDeleted, nodeId } = entry;
1271
+ const existingRow = await backend.getNode(
1272
+ ctx.graphId,
1273
+ concreteKind,
1274
+ nodeId
1275
+ );
1276
+ if (existingRow === void 0) {
1277
+ const node = await executeNodeCreate(
1278
+ ctx,
1279
+ { kind, props: validatedProps },
1280
+ backend,
1281
+ { propsPreValidated: true }
1282
+ );
1283
+ results[index] = { node, action: "created" };
1284
+ continue;
1285
+ }
1286
+ if (isSoftDeleted || ifExists === "update") {
1287
+ const node = await executeNodeUpsertUpdate(
1288
+ ctx,
1289
+ {
1290
+ kind: concreteKind,
1291
+ id: existingRow.id,
1292
+ props: validatedProps
1293
+ },
1294
+ backend,
1295
+ { clearDeleted: isSoftDeleted }
1296
+ );
1297
+ results[index] = {
1298
+ node,
1299
+ action: isSoftDeleted ? "resurrected" : "updated"
1300
+ };
1301
+ } else {
1302
+ results[index] = { node: rowToNode(existingRow), action: "found" };
1303
+ }
1304
+ }
1305
+ for (const { index, sourceIndex } of duplicateOf) {
1306
+ const sourceResult = results[sourceIndex];
1307
+ results[index] = { node: sourceResult.node, action: "found" };
1308
+ }
1309
+ return results;
1310
+ }
1311
+
1312
+ exports.checkCardinalityConstraint = checkCardinalityConstraint;
1313
+ exports.createNodeBatchValidationBackend = createNodeBatchValidationBackend;
1314
+ exports.executeNodeBulkFindByConstraint = executeNodeBulkFindByConstraint;
1315
+ exports.executeNodeBulkFindByIndex = executeNodeBulkFindByIndex;
1316
+ exports.executeNodeBulkGetOrCreateByConstraint = executeNodeBulkGetOrCreateByConstraint;
1317
+ exports.executeNodeCreate = executeNodeCreate;
1318
+ exports.executeNodeCreateBatch = executeNodeCreateBatch;
1319
+ exports.executeNodeCreateNoReturnBatch = executeNodeCreateNoReturnBatch;
1320
+ exports.executeNodeDelete = executeNodeDelete;
1321
+ exports.executeNodeFindByConstraint = executeNodeFindByConstraint;
1322
+ exports.executeNodeGetOrCreateByConstraint = executeNodeGetOrCreateByConstraint;
1323
+ exports.executeNodeHardDelete = executeNodeHardDelete;
1324
+ exports.executeNodeUpdate = executeNodeUpdate;
1325
+ exports.executeNodeUpsertUpdate = executeNodeUpsertUpdate;
1326
+ exports.primeBatchValidationCaches = primeBatchValidationCaches;
1327
+ exports.rowToEdge = rowToEdge;
1328
+ exports.rowToEdgeMeta = rowToEdgeMeta;
1329
+ exports.rowToNode = rowToNode;
1330
+ exports.rowToNodeMeta = rowToNodeMeta;
1331
+ exports.runHookedWriteOperation = runHookedWriteOperation;
1332
+ exports.runInWriteTransaction = runInWriteTransaction;
1333
+ //# sourceMappingURL=chunk-WJT7OU7E.cjs.map
1334
+ //# sourceMappingURL=chunk-WJT7OU7E.cjs.map