@nicia-ai/typegraph 0.45.0 → 0.46.1

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 (384) 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 -42
  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 -38
  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 -43
  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 -39
  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-S3ZRKJHY.js → chunk-2LG2XB2M.js} +3 -3
  44. package/dist/{chunk-S3ZRKJHY.js.map → chunk-2LG2XB2M.js.map} +1 -1
  45. package/dist/{chunk-7PF2L3H6.cjs → chunk-2NA5DYLO.cjs} +4 -4
  46. package/dist/{chunk-7PF2L3H6.cjs.map → chunk-2NA5DYLO.cjs.map} +1 -1
  47. package/dist/chunk-2Z2Z3ZD6.js +58 -0
  48. package/dist/chunk-2Z2Z3ZD6.js.map +1 -0
  49. package/dist/{chunk-VVQM4CZD.cjs → chunk-3DHZCOT7.cjs} +20 -20
  50. package/dist/{chunk-VVQM4CZD.cjs.map → chunk-3DHZCOT7.cjs.map} +1 -1
  51. package/dist/{chunk-JXUTCSXX.cjs → chunk-4UGOKMI5.cjs} +250 -158
  52. package/dist/chunk-4UGOKMI5.cjs.map +1 -0
  53. package/dist/{chunk-RFRM3Q5K.js → chunk-5262ZMTR.js} +14 -5
  54. package/dist/chunk-5262ZMTR.js.map +1 -0
  55. package/dist/{chunk-QRNYDV5Z.js → chunk-5763DULU.js} +214 -69
  56. package/dist/chunk-5763DULU.js.map +1 -0
  57. package/dist/{chunk-BGYJW37L.js → chunk-5UVRGXD3.js} +277 -7
  58. package/dist/chunk-5UVRGXD3.js.map +1 -0
  59. package/dist/{chunk-QR24DJDF.cjs → chunk-62ZP23AW.cjs} +15 -15
  60. package/dist/{chunk-QR24DJDF.cjs.map → chunk-62ZP23AW.cjs.map} +1 -1
  61. package/dist/{chunk-ZI6VQSZA.cjs → chunk-65E3XWGF.cjs} +724 -577
  62. package/dist/chunk-65E3XWGF.cjs.map +1 -0
  63. package/dist/{chunk-S4KQ5LV4.js → chunk-775A4ZMN.js} +40 -6
  64. package/dist/chunk-775A4ZMN.js.map +1 -0
  65. package/dist/{chunk-J2ICGNHO.cjs → chunk-7BQXPCGN.cjs} +830 -169
  66. package/dist/chunk-7BQXPCGN.cjs.map +1 -0
  67. package/dist/{chunk-FJMPR3OH.cjs → chunk-7EO3TCQB.cjs} +33 -7
  68. package/dist/chunk-7EO3TCQB.cjs.map +1 -0
  69. package/dist/{chunk-DXEEHSGN.js → chunk-7VQXLT5O.js} +436 -43
  70. package/dist/chunk-7VQXLT5O.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-55ITBQJI.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-WUFASQUO.js → chunk-ASTI57H3.js} +3 -3
  80. package/dist/{chunk-WUFASQUO.js.map → chunk-ASTI57H3.js.map} +1 -1
  81. package/dist/{chunk-4QIKLIGG.js → chunk-BKCUOV7A.js} +15 -5
  82. package/dist/chunk-BKCUOV7A.js.map +1 -0
  83. package/dist/{chunk-JQXSZHF2.cjs → chunk-BSFJMMV3.cjs} +134 -7
  84. package/dist/chunk-BSFJMMV3.cjs.map +1 -0
  85. package/dist/{chunk-4GUTQPVO.js → chunk-C23WSN5E.js} +185 -24
  86. package/dist/chunk-C23WSN5E.js.map +1 -0
  87. package/dist/{chunk-QLUXRWKL.js → chunk-CBTIUB76.js} +3 -3
  88. package/dist/{chunk-QLUXRWKL.js.map → chunk-CBTIUB76.js.map} +1 -1
  89. package/dist/chunk-CMWHLBVN.cjs +2082 -0
  90. package/dist/chunk-CMWHLBVN.cjs.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-FL5UQRES.js → chunk-DCQVHAYQ.js} +5 -5
  94. package/dist/{chunk-FL5UQRES.js.map → chunk-DCQVHAYQ.js.map} +1 -1
  95. package/dist/chunk-DTVWX77L.cjs +3432 -0
  96. package/dist/chunk-DTVWX77L.cjs.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-GF3KXUTW.js +3393 -0
  104. package/dist/chunk-GF3KXUTW.js.map +1 -0
  105. package/dist/{chunk-VTN3C3CH.js → chunk-HFHTMECK.js} +7 -7
  106. package/dist/{chunk-VTN3C3CH.js.map → chunk-HFHTMECK.js.map} +1 -1
  107. package/dist/{chunk-FLEQ2HBK.js → chunk-I5MOXA4H.js} +20 -14
  108. package/dist/chunk-I5MOXA4H.js.map +1 -0
  109. package/dist/{chunk-4MB3AQAQ.js → chunk-J3WZ3FA2.js} +77 -3
  110. package/dist/chunk-J3WZ3FA2.js.map +1 -0
  111. package/dist/{chunk-UR7W5YQK.js → chunk-JBQQ7THH.js} +5 -3
  112. package/dist/chunk-JBQQ7THH.js.map +1 -0
  113. package/dist/{chunk-TKP5T34P.js → chunk-JXA2ZP2Q.js} +6 -16
  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-42PYUGLS.js → chunk-K5ELX2GT.js} +108 -8
  120. package/dist/chunk-K5ELX2GT.js.map +1 -0
  121. package/dist/{chunk-Q6EDCUXV.js → chunk-L65OU2U3.js} +556 -204
  122. package/dist/chunk-L65OU2U3.js.map +1 -0
  123. package/dist/{chunk-D54WH24V.cjs → chunk-LBJKZXDE.cjs} +115 -13
  124. package/dist/chunk-LBJKZXDE.cjs.map +1 -0
  125. package/dist/{chunk-FQ7ZPOTZ.js → chunk-LGHCOKTT.js} +637 -493
  126. package/dist/chunk-LGHCOKTT.js.map +1 -0
  127. package/dist/chunk-M3WP7RQZ.js +736 -0
  128. package/dist/chunk-M3WP7RQZ.js.map +1 -0
  129. package/dist/{chunk-4MEWSUVM.cjs → chunk-M4BDU5RX.cjs} +12 -12
  130. package/dist/chunk-M4BDU5RX.cjs.map +1 -0
  131. package/dist/chunk-MCLYU6BN.cjs +332 -0
  132. package/dist/chunk-MCLYU6BN.cjs.map +1 -0
  133. package/dist/{chunk-MIJKEVV7.js → chunk-MSY7FSX4.js} +37 -4
  134. package/dist/chunk-MSY7FSX4.js.map +1 -0
  135. package/dist/{chunk-H7VE3FL4.cjs → chunk-MUK4BU7K.cjs} +519 -125
  136. package/dist/chunk-MUK4BU7K.cjs.map +1 -0
  137. package/dist/{chunk-D56XG4EI.cjs → chunk-MXJDTH5B.cjs} +56 -45
  138. package/dist/chunk-MXJDTH5B.cjs.map +1 -0
  139. package/dist/{chunk-5EKPX6QU.js → chunk-MZLPX2R7.js} +8 -9
  140. package/dist/chunk-MZLPX2R7.js.map +1 -0
  141. package/dist/chunk-N66HCGCY.cjs +57 -0
  142. package/dist/chunk-N66HCGCY.cjs.map +1 -0
  143. package/dist/{chunk-CPEL3YIR.cjs → chunk-NFCVHQ5P.cjs} +55 -22
  144. package/dist/chunk-NFCVHQ5P.cjs.map +1 -0
  145. package/dist/{chunk-C4F7VJ5D.cjs → chunk-NI72YOJB.cjs} +84 -2
  146. package/dist/chunk-NI72YOJB.cjs.map +1 -0
  147. package/dist/{chunk-BNS75YNF.cjs → chunk-NK5Q7UNE.cjs} +10 -20
  148. package/dist/chunk-NK5Q7UNE.cjs.map +1 -0
  149. package/dist/{chunk-TKORQCG4.js → chunk-NLI2AVEF.js} +386 -862
  150. package/dist/chunk-NLI2AVEF.js.map +1 -0
  151. package/dist/{chunk-YMTXMPV6.js → chunk-NMWDXFPH.js} +4 -4
  152. package/dist/{chunk-YMTXMPV6.js.map → chunk-NMWDXFPH.js.map} +1 -1
  153. package/dist/{chunk-J7LXTUTP.cjs → chunk-PF6F5NLJ.cjs} +604 -1094
  154. package/dist/chunk-PF6F5NLJ.cjs.map +1 -0
  155. package/dist/{chunk-NAAMUYMS.cjs → chunk-PNN7RHVR.cjs} +58 -48
  156. package/dist/chunk-PNN7RHVR.cjs.map +1 -0
  157. package/dist/{chunk-YOALGKRE.cjs → chunk-PNTCATDE.cjs} +3528 -1763
  158. package/dist/chunk-PNTCATDE.cjs.map +1 -0
  159. package/dist/{chunk-6DCB664D.js → chunk-PQBQG7IM.js} +3 -3
  160. package/dist/{chunk-6DCB664D.js.map → chunk-PQBQG7IM.js.map} +1 -1
  161. package/dist/{chunk-UCQ3BFSY.cjs → chunk-PT7RIRIZ.cjs} +684 -332
  162. package/dist/chunk-PT7RIRIZ.cjs.map +1 -0
  163. package/dist/{chunk-ACSVZPK7.cjs → chunk-PWLJ77UV.cjs} +5 -3
  164. package/dist/chunk-PWLJ77UV.cjs.map +1 -0
  165. package/dist/chunk-Q3G6A4I3.cjs +755 -0
  166. package/dist/chunk-Q3G6A4I3.cjs.map +1 -0
  167. package/dist/{chunk-Z3WO6MND.cjs → chunk-RMQLSPA2.cjs} +297 -27
  168. package/dist/chunk-RMQLSPA2.cjs.map +1 -0
  169. package/dist/{chunk-SJDMVITW.cjs → chunk-RT5ZY4XA.cjs} +6 -5
  170. package/dist/chunk-RT5ZY4XA.cjs.map +1 -0
  171. package/dist/{chunk-ID4WXTKL.js → chunk-S6PW7VV5.js} +2382 -617
  172. package/dist/chunk-S6PW7VV5.js.map +1 -0
  173. package/dist/{chunk-4GUBTVPV.js → chunk-T4XNKYXB.js} +780 -126
  174. package/dist/chunk-T4XNKYXB.js.map +1 -0
  175. package/dist/{chunk-YDWLUT5V.cjs → chunk-TQR4KBY2.cjs} +323 -178
  176. package/dist/chunk-TQR4KBY2.cjs.map +1 -0
  177. package/dist/{chunk-OOA273IJ.cjs → chunk-U5SON7R2.cjs} +27 -27
  178. package/dist/{chunk-OOA273IJ.cjs.map → chunk-U5SON7R2.cjs.map} +1 -1
  179. package/dist/{chunk-IX64T5OL.cjs → chunk-U63GDNRC.cjs} +32 -26
  180. package/dist/chunk-U63GDNRC.cjs.map +1 -0
  181. package/dist/{chunk-WDBXJOU5.cjs → chunk-UDISNXDL.cjs} +56 -47
  182. package/dist/chunk-UDISNXDL.cjs.map +1 -0
  183. package/dist/{chunk-EFEOOCJ3.js → chunk-UV3SN74I.js} +5 -5
  184. package/dist/{chunk-EFEOOCJ3.js.map → chunk-UV3SN74I.js.map} +1 -1
  185. package/dist/{chunk-U5W4LKZV.cjs → chunk-VCRRKBLN.cjs} +9 -9
  186. package/dist/{chunk-U5W4LKZV.cjs.map → chunk-VCRRKBLN.cjs.map} +1 -1
  187. package/dist/{chunk-ISLPNELU.js → chunk-VGTJPTIC.js} +16 -5
  188. package/dist/chunk-VGTJPTIC.js.map +1 -0
  189. package/dist/chunk-VLT6PEWR.cjs +60 -0
  190. package/dist/chunk-VLT6PEWR.cjs.map +1 -0
  191. package/dist/chunk-VQH4VAWD.cjs +12 -0
  192. package/dist/{chunk-B3F2D3SP.cjs.map → chunk-VQH4VAWD.cjs.map} +1 -1
  193. package/dist/{chunk-SNXVDZAJ.js → chunk-W6OG3HDG.js} +5 -4
  194. package/dist/chunk-W6OG3HDG.js.map +1 -0
  195. package/dist/chunk-WDGA7IYB.js +207 -0
  196. package/dist/chunk-WDGA7IYB.js.map +1 -0
  197. package/dist/chunk-WQZLUGVR.js +2057 -0
  198. package/dist/chunk-WQZLUGVR.js.map +1 -0
  199. package/dist/{chunk-EKFUG4G7.cjs → chunk-XBYVV3MP.cjs} +60 -5
  200. package/dist/chunk-XBYVV3MP.cjs.map +1 -0
  201. package/dist/{chunk-5GAONX5G.cjs → chunk-XCAGZAKP.cjs} +7 -7
  202. package/dist/{chunk-5GAONX5G.cjs.map → chunk-XCAGZAKP.cjs.map} +1 -1
  203. package/dist/chunk-XL7SLCXS.js +309 -0
  204. package/dist/chunk-XL7SLCXS.js.map +1 -0
  205. package/dist/{chunk-SVJ5GEXW.cjs → chunk-XUO3KQFO.cjs} +2 -2
  206. package/dist/chunk-XUO3KQFO.cjs.map +1 -0
  207. package/dist/{chunk-F4NHQHEZ.cjs → chunk-YAAM3M2S.cjs} +10 -10
  208. package/dist/{chunk-F4NHQHEZ.cjs.map → chunk-YAAM3M2S.cjs.map} +1 -1
  209. package/dist/{chunk-RUQS6M7G.js → chunk-YBFHZUXX.js} +6 -6
  210. package/dist/chunk-YBFHZUXX.js.map +1 -0
  211. package/dist/{chunk-KMXWZLQX.cjs → chunk-YBQOHKHN.cjs} +99 -100
  212. package/dist/chunk-YBQOHKHN.cjs.map +1 -0
  213. package/dist/{chunk-PVUI6KGR.js → chunk-YDFDBE6D.js} +93 -6
  214. package/dist/chunk-YDFDBE6D.js.map +1 -0
  215. package/dist/{chunk-P7GTYOLB.cjs → chunk-YVWGEQJE.cjs} +297 -135
  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 -40
  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 -8
  223. package/dist/{ddl-BG4J805L.d.cts → ddl-BJcOp4WZ.d.cts} +3 -3
  224. package/dist/{ddl-CgiS9QLj.d.ts → ddl-BXfGHbPN.d.ts} +3 -3
  225. package/dist/graph-extension/index.cjs +26 -22
  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 -7
  229. package/dist/graph-merge/index.cjs +2459 -654
  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 -467
  234. package/dist/graph-merge/index.js.map +1 -1
  235. package/dist/{index-C3y_98iN.d.cts → index-BSHvKfok.d.ts} +221 -10
  236. package/dist/{index-BBxZCUdu.d.ts → index-DxaYCv8Y.d.cts} +221 -10
  237. package/dist/index.cjs +330 -268
  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 -49
  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 -51
  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 -25
  252. package/dist/interchange/index.js.map +1 -1
  253. package/dist/{manager-YoLEfcc1.d.ts → manager-CfZAimti.d.ts} +36 -5
  254. package/dist/{manager-KS7CGQQT.d.cts → manager-HGk6E_HW.d.cts} +36 -5
  255. package/dist/{materialize-indexes-Bhhyb1B3.d.ts → materialize-indexes-6A7dWGtb.d.cts} +10 -2
  256. package/dist/{materialize-indexes-OHRWypW6.d.cts → materialize-indexes-BMJP6Tms.d.ts} +10 -2
  257. package/dist/{postgres-DpkW3R5Y.d.cts → postgres-DFYWENdR.d.cts} +1961 -439
  258. package/dist/{postgres-DwqyIniy.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 -48
  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 -21
  273. package/dist/{searchable-DLWEfC4a.d.ts → searchable-9OQoPuRs.d.ts} +1 -2
  274. package/dist/{searchable-CIZL8Hyw.d.cts → searchable-CIje5XYD.d.cts} +1 -2
  275. package/dist/{sqlite-DY0WODUK.d.cts → sqlite-DerU5tc7.d.ts} +2029 -347
  276. package/dist/{sqlite-L-VIRzqA.d.ts → sqlite-DitnISa9.d.cts} +2029 -347
  277. package/dist/{store-view-A85FFRnk.d.cts → store-B0h6x7wo.d.cts} +1289 -767
  278. package/dist/{store-view-66p92IPi.d.ts → store-ClQ-MZQS.d.ts} +1289 -767
  279. package/dist/{temporal-BNbjXqer.d.cts → temporal-Bn-Fi8FJ.d.cts} +1 -1
  280. package/dist/{temporal-Bob6Nfbp.d.ts → temporal-BtM4UALv.d.ts} +1 -1
  281. package/dist/{types-DeORZhxn.d.cts → types-CoIx8HX5.d.cts} +1 -1
  282. package/dist/{types-Ch9a0Dx6.d.ts → types-HkveCCx0.d.cts} +726 -5
  283. package/dist/{types-Ch9a0Dx6.d.cts → types-HkveCCx0.d.ts} +726 -5
  284. package/dist/{types-ClCzT-dT.d.ts → types-KFfk-8Ah.d.ts} +1 -1
  285. package/dist/{where-DPw52ksb.d.cts → where--fk7_0kv.d.cts} +1 -1
  286. package/dist/{where-kWUZPvEA.d.ts → where-ws5hf-Ov.d.ts} +1 -1
  287. package/package.json +3 -3
  288. package/dist/chunk-2L54C2C2.js +0 -144
  289. package/dist/chunk-2L54C2C2.js.map +0 -1
  290. package/dist/chunk-35S6P5ZU.js +0 -27
  291. package/dist/chunk-35S6P5ZU.js.map +0 -1
  292. package/dist/chunk-42PYUGLS.js.map +0 -1
  293. package/dist/chunk-4GUBTVPV.js.map +0 -1
  294. package/dist/chunk-4GUTQPVO.js.map +0 -1
  295. package/dist/chunk-4MB3AQAQ.js.map +0 -1
  296. package/dist/chunk-4MEWSUVM.cjs.map +0 -1
  297. package/dist/chunk-4QIKLIGG.js.map +0 -1
  298. package/dist/chunk-4SZ6XPTG.cjs +0 -12
  299. package/dist/chunk-55ITBQJI.js.map +0 -1
  300. package/dist/chunk-5EKPX6QU.js.map +0 -1
  301. package/dist/chunk-6RYPD3NJ.cjs +0 -1282
  302. package/dist/chunk-6RYPD3NJ.cjs.map +0 -1
  303. package/dist/chunk-764JHTLT.cjs +0 -15
  304. package/dist/chunk-764JHTLT.cjs.map +0 -1
  305. package/dist/chunk-ACSVZPK7.cjs.map +0 -1
  306. package/dist/chunk-B3F2D3SP.cjs +0 -12
  307. package/dist/chunk-BGYJW37L.js.map +0 -1
  308. package/dist/chunk-BNS75YNF.cjs.map +0 -1
  309. package/dist/chunk-C4F7VJ5D.cjs.map +0 -1
  310. package/dist/chunk-CBKG6HEP.js +0 -1263
  311. package/dist/chunk-CBKG6HEP.js.map +0 -1
  312. package/dist/chunk-CPEL3YIR.cjs.map +0 -1
  313. package/dist/chunk-D54WH24V.cjs.map +0 -1
  314. package/dist/chunk-D56XG4EI.cjs.map +0 -1
  315. package/dist/chunk-D7PG5D5K.js.map +0 -1
  316. package/dist/chunk-DI74SMXS.cjs +0 -29
  317. package/dist/chunk-DI74SMXS.cjs.map +0 -1
  318. package/dist/chunk-DK2S42XB.js +0 -77
  319. package/dist/chunk-DK2S42XB.js.map +0 -1
  320. package/dist/chunk-DRACN6XG.js +0 -27
  321. package/dist/chunk-DRACN6XG.js.map +0 -1
  322. package/dist/chunk-DXEEHSGN.js.map +0 -1
  323. package/dist/chunk-EKFUG4G7.cjs.map +0 -1
  324. package/dist/chunk-EQ7JKLZO.cjs +0 -157
  325. package/dist/chunk-EQ7JKLZO.cjs.map +0 -1
  326. package/dist/chunk-FJMPR3OH.cjs.map +0 -1
  327. package/dist/chunk-FLEQ2HBK.js.map +0 -1
  328. package/dist/chunk-FQ7ZPOTZ.js.map +0 -1
  329. package/dist/chunk-G6Q5UM7U.js.map +0 -1
  330. package/dist/chunk-GYA4JRP5.js.map +0 -1
  331. package/dist/chunk-H7VE3FL4.cjs.map +0 -1
  332. package/dist/chunk-ID4WXTKL.js.map +0 -1
  333. package/dist/chunk-ISLPNELU.js.map +0 -1
  334. package/dist/chunk-ITE4IXAK.js +0 -25
  335. package/dist/chunk-ITE4IXAK.js.map +0 -1
  336. package/dist/chunk-IX64T5OL.cjs.map +0 -1
  337. package/dist/chunk-J2ICGNHO.cjs.map +0 -1
  338. package/dist/chunk-J7LXTUTP.cjs.map +0 -1
  339. package/dist/chunk-JQXSZHF2.cjs.map +0 -1
  340. package/dist/chunk-JXUTCSXX.cjs.map +0 -1
  341. package/dist/chunk-KCO5EFJU.js +0 -79
  342. package/dist/chunk-KCO5EFJU.js.map +0 -1
  343. package/dist/chunk-KKYELPZ2.cjs +0 -83
  344. package/dist/chunk-KKYELPZ2.cjs.map +0 -1
  345. package/dist/chunk-KMXWZLQX.cjs.map +0 -1
  346. package/dist/chunk-MIJKEVV7.js.map +0 -1
  347. package/dist/chunk-NAAMUYMS.cjs.map +0 -1
  348. package/dist/chunk-P7GTYOLB.cjs.map +0 -1
  349. package/dist/chunk-PVUI6KGR.js.map +0 -1
  350. package/dist/chunk-Q6EDCUXV.js.map +0 -1
  351. package/dist/chunk-QB6VMOJ2.cjs.map +0 -1
  352. package/dist/chunk-QC4MCOFV.cjs +0 -83
  353. package/dist/chunk-QC4MCOFV.cjs.map +0 -1
  354. package/dist/chunk-QMQLUA66.js +0 -12
  355. package/dist/chunk-QMQLUA66.js.map +0 -1
  356. package/dist/chunk-QRNYDV5Z.js.map +0 -1
  357. package/dist/chunk-RFRM3Q5K.js.map +0 -1
  358. package/dist/chunk-RUQS6M7G.js.map +0 -1
  359. package/dist/chunk-S4KQ5LV4.js.map +0 -1
  360. package/dist/chunk-SJDMVITW.cjs.map +0 -1
  361. package/dist/chunk-SNXVDZAJ.js.map +0 -1
  362. package/dist/chunk-SVJ5GEXW.cjs.map +0 -1
  363. package/dist/chunk-TDXIBCGY.cjs.map +0 -1
  364. package/dist/chunk-TKORQCG4.js.map +0 -1
  365. package/dist/chunk-TKP5T34P.js.map +0 -1
  366. package/dist/chunk-TRF4EBJT.cjs +0 -30
  367. package/dist/chunk-TRF4EBJT.cjs.map +0 -1
  368. package/dist/chunk-UCQ3BFSY.cjs.map +0 -1
  369. package/dist/chunk-UR7W5YQK.js.map +0 -1
  370. package/dist/chunk-V34A6R5V.js +0 -134
  371. package/dist/chunk-V34A6R5V.js.map +0 -1
  372. package/dist/chunk-WDAVPX46.js +0 -81
  373. package/dist/chunk-WDAVPX46.js.map +0 -1
  374. package/dist/chunk-WDBXJOU5.cjs.map +0 -1
  375. package/dist/chunk-YDWLUT5V.cjs.map +0 -1
  376. package/dist/chunk-YOALGKRE.cjs.map +0 -1
  377. package/dist/chunk-Z3WO6MND.cjs.map +0 -1
  378. package/dist/chunk-ZDH3DX3C.cjs +0 -30
  379. package/dist/chunk-ZDH3DX3C.cjs.map +0 -1
  380. package/dist/chunk-ZI6VQSZA.cjs.map +0 -1
  381. package/dist/chunk-ZTAJL4DT.cjs +0 -85
  382. package/dist/chunk-ZTAJL4DT.cjs.map +0 -1
  383. package/dist/define-graph-BGrJahvp.d.ts +0 -173
  384. package/dist/define-graph-alREY2wj.d.cts +0 -173
@@ -1,1282 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkUCQ3BFSY_cjs = require('./chunk-UCQ3BFSY.cjs');
4
- var chunkJ7LXTUTP_cjs = require('./chunk-J7LXTUTP.cjs');
5
- var chunkEKFUG4G7_cjs = require('./chunk-EKFUG4G7.cjs');
6
- var chunkQB6VMOJ2_cjs = require('./chunk-QB6VMOJ2.cjs');
7
- var chunkZTAJL4DT_cjs = require('./chunk-ZTAJL4DT.cjs');
8
- var chunk764JHTLT_cjs = require('./chunk-764JHTLT.cjs');
9
- var chunkC4F7VJ5D_cjs = require('./chunk-C4F7VJ5D.cjs');
10
- var zod = require('zod');
11
-
12
- var FORMAT_VERSION = "1.0";
13
- var ValidityTimestampSchema = zod.z.iso.datetime().refine((value) => chunkZTAJL4DT_cjs.isCanonicalIsoDate(value), {
14
- message: "Expected canonical UTC ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ); convert with new Date(value).toISOString()."
15
- });
16
- var InterchangeNodeSchema = zod.z.object({
17
- kind: zod.z.string().min(1),
18
- id: zod.z.string().min(1),
19
- properties: zod.z.record(zod.z.string(), zod.z.unknown()),
20
- /**
21
- * `undefined` (key absent): not requested (`includeTemporal: false`) —
22
- * import defaults it to the import's own creation timestamp. `null`:
23
- * requested and confirmed the row has no lower bound (e.g. a legacy row
24
- * predating the "omitted validFrom defaults to creation time" fix) —
25
- * import preserves that open-left validity instead of re-stamping it.
26
- */
27
- validFrom: ValidityTimestampSchema.nullable().optional(),
28
- validTo: ValidityTimestampSchema.optional(),
29
- meta: zod.z.object({
30
- version: zod.z.number().int().positive().optional(),
31
- createdAt: zod.z.iso.datetime().optional(),
32
- updatedAt: zod.z.iso.datetime().optional()
33
- }).optional()
34
- });
35
- var InterchangeEdgeSchema = zod.z.object({
36
- kind: zod.z.string().min(1),
37
- id: zod.z.string().min(1),
38
- from: zod.z.object({
39
- kind: zod.z.string().min(1),
40
- id: zod.z.string().min(1)
41
- }),
42
- to: zod.z.object({
43
- kind: zod.z.string().min(1),
44
- id: zod.z.string().min(1)
45
- }),
46
- properties: zod.z.record(zod.z.string(), zod.z.unknown()).default({}),
47
- /** See {@link InterchangeNodeSchema}'s `validFrom` for the null/undefined contract. */
48
- validFrom: ValidityTimestampSchema.nullable().optional(),
49
- validTo: ValidityTimestampSchema.optional(),
50
- meta: zod.z.object({
51
- createdAt: zod.z.iso.datetime().optional(),
52
- updatedAt: zod.z.iso.datetime().optional()
53
- }).optional()
54
- });
55
- var ConflictStrategySchema = zod.z.enum(["skip", "update", "error"]);
56
- var UnknownPropertyStrategySchema = zod.z.enum([
57
- "error",
58
- "strip",
59
- "allow"
60
- ]);
61
- var ImportOptionsSchema = zod.z.object({
62
- /** How to handle existing nodes/edges with the same ID */
63
- onConflict: ConflictStrategySchema,
64
- /** How to handle properties not in the schema */
65
- onUnknownProperty: UnknownPropertyStrategySchema.default("error"),
66
- /** Whether to validate that edge endpoints exist */
67
- validateReferences: zod.z.boolean().default(true),
68
- /**
69
- * Number of items to process in each batch. Each batch pays fixed
70
- * per-round-trip costs (existence probe, unique check, one multi-row
71
- * insert), so undersized batches dominate import time on client/server
72
- * engines: measured on PostgreSQL, 20k nodes + 5k edges import in
73
- * 1,515ms at 100 vs 781ms at 1,000. Above ~1,000 the multi-row insert
74
- * itself dominates and larger batches stop paying; SQLite is
75
- * insensitive to the value (in-process, no round trips). The backend
76
- * further splits inserts by its bind-parameter budget, so a large
77
- * batch never overruns driver limits.
78
- */
79
- batchSize: zod.z.number().int().positive().default(1e3),
80
- /**
81
- * Refresh planner statistics (ANALYZE) after an import that created or
82
- * updated rows. Bulk loads otherwise run against stale statistics until
83
- * the engine catches up on its own. Default: true.
84
- */
85
- refreshStatistics: zod.z.boolean().optional(),
86
- /**
87
- * How a streamed import reacts when one chunk reports entity-level errors.
88
- * `abort` is the safe default: earlier chunks are already committed, so
89
- * callers must not mistake a partial stream for a successful retryable load.
90
- * `continue` is reserved for explicit best-effort ingestion.
91
- */
92
- onStreamChunkError: zod.z.enum(["abort", "continue"]).default("abort")
93
- });
94
- var GraphDataSourceSchema = zod.z.discriminatedUnion("type", [
95
- zod.z.object({
96
- type: zod.z.literal("typegraph-export"),
97
- graphId: zod.z.string(),
98
- schemaVersion: zod.z.number().int().positive()
99
- }),
100
- zod.z.object({
101
- type: zod.z.literal("external"),
102
- description: zod.z.string().optional()
103
- })
104
- ]);
105
- var GraphDataSchema = zod.z.object({
106
- formatVersion: zod.z.literal(FORMAT_VERSION),
107
- exportedAt: zod.z.iso.datetime(),
108
- source: GraphDataSourceSchema,
109
- nodes: zod.z.array(InterchangeNodeSchema),
110
- edges: zod.z.array(InterchangeEdgeSchema)
111
- });
112
- var GraphDataHeaderSchema = GraphDataSchema.omit({
113
- nodes: true,
114
- edges: true
115
- });
116
- var GraphInterchangeChunkSchema = zod.z.discriminatedUnion("type", [
117
- zod.z.object({ type: zod.z.literal("header"), header: GraphDataHeaderSchema }),
118
- zod.z.object({ type: zod.z.literal("nodes"), nodes: zod.z.array(InterchangeNodeSchema) }),
119
- zod.z.object({ type: zod.z.literal("edges"), edges: zod.z.array(InterchangeEdgeSchema) })
120
- ]);
121
- var ImportErrorSchema = zod.z.object({
122
- entityType: zod.z.enum(["node", "edge"]),
123
- kind: zod.z.string(),
124
- id: zod.z.string(),
125
- error: zod.z.string()
126
- });
127
- var ImportResultSchema = zod.z.object({
128
- success: zod.z.boolean(),
129
- nodes: zod.z.object({
130
- created: zod.z.number().int().nonnegative(),
131
- updated: zod.z.number().int().nonnegative(),
132
- skipped: zod.z.number().int().nonnegative()
133
- }),
134
- edges: zod.z.object({
135
- created: zod.z.number().int().nonnegative(),
136
- updated: zod.z.number().int().nonnegative(),
137
- skipped: zod.z.number().int().nonnegative()
138
- }),
139
- errors: zod.z.array(ImportErrorSchema)
140
- });
141
- var ExportOptionsSchema = zod.z.object({
142
- /** Filter to specific node kinds (undefined = all) */
143
- nodeKinds: zod.z.array(zod.z.string()).optional(),
144
- /** Filter to specific edge kinds (undefined = all) */
145
- edgeKinds: zod.z.array(zod.z.string()).optional(),
146
- /** Include temporal fields (validFrom, validTo) */
147
- includeTemporal: zod.z.boolean().default(false),
148
- /** Include metadata (version, timestamps) */
149
- includeMeta: zod.z.boolean().default(false),
150
- /** Include soft-deleted records */
151
- includeDeleted: zod.z.boolean().default(false)
152
- });
153
- var ExportStreamOptionsSchema = ExportOptionsSchema.extend({
154
- batchSize: zod.z.number().int().positive().default(1e3)
155
- });
156
-
157
- // src/interchange/export.ts
158
- async function exportGraph(store, options) {
159
- const nodes = [];
160
- const edges = [];
161
- let header;
162
- for await (const chunk of exportGraphStream(store, options)) {
163
- switch (chunk.type) {
164
- case "header": {
165
- header = chunk.header;
166
- break;
167
- }
168
- case "nodes": {
169
- nodes.push(...chunk.nodes);
170
- break;
171
- }
172
- case "edges": {
173
- edges.push(...chunk.edges);
174
- break;
175
- }
176
- }
177
- }
178
- if (header === void 0) {
179
- throw new Error("Graph export stream ended before emitting its header.");
180
- }
181
- return { ...header, nodes, edges };
182
- }
183
- async function* exportGraphStream(store, options) {
184
- const resolved = ExportStreamOptionsSchema.parse(options ?? {});
185
- const graphId = store.graphId;
186
- const backend = chunkJ7LXTUTP_cjs.storeBackend(store);
187
- const nodeKinds = resolved.nodeKinds ?? chunkQB6VMOJ2_cjs.getNodeKinds(store.graph);
188
- const edgeKinds = resolved.edgeKinds ?? chunkQB6VMOJ2_cjs.getEdgeKinds(store.graph);
189
- const schemaVersion = await backend.getActiveSchema(graphId);
190
- yield {
191
- type: "header",
192
- header: {
193
- formatVersion: FORMAT_VERSION,
194
- exportedAt: chunkZTAJL4DT_cjs.nowIso(),
195
- source: {
196
- type: "typegraph-export",
197
- graphId,
198
- schemaVersion: schemaVersion?.version ?? 1
199
- }
200
- }
201
- };
202
- for (const kind of nodeKinds) {
203
- yield* exportNodeChunks(backend, graphId, kind, resolved);
204
- }
205
- for (const kind of edgeKinds) {
206
- yield* exportEdgeChunks(backend, graphId, kind, resolved);
207
- }
208
- }
209
- async function* exportNodeChunks(backend, graphId, kind, options) {
210
- let after;
211
- for (; ; ) {
212
- const rows = await backend.findNodesByKind({
213
- graphId,
214
- kind,
215
- excludeDeleted: !options.includeDeleted,
216
- orderBy: "id",
217
- limit: options.batchSize,
218
- ...after === void 0 ? {} : { after }
219
- });
220
- if (rows.length === 0) return;
221
- const nodes = rows.map((row) => {
222
- const node = {
223
- kind: row.kind,
224
- id: row.id,
225
- properties: chunkEKFUG4G7_cjs.rowPropsToObject(row.props)
226
- };
227
- if (options.includeTemporal) {
228
- const validFrom = (
229
- // eslint-disable-next-line unicorn/no-null
230
- row.valid_from ?? null
231
- );
232
- node.validFrom = validFrom;
233
- if (row.valid_to) {
234
- node.validTo = row.valid_to;
235
- }
236
- }
237
- if (options.includeMeta) {
238
- node.meta = {
239
- version: row.version,
240
- createdAt: row.created_at,
241
- updatedAt: row.updated_at
242
- };
243
- }
244
- return node;
245
- });
246
- yield { type: "nodes", nodes };
247
- if (rows.length < options.batchSize) return;
248
- after = chunk764JHTLT_cjs.requireDefined(rows.at(-1)).id;
249
- }
250
- }
251
- async function* exportEdgeChunks(backend, graphId, kind, options) {
252
- let after;
253
- for (; ; ) {
254
- const rows = await backend.findEdgesByKind({
255
- graphId,
256
- kind,
257
- excludeDeleted: !options.includeDeleted,
258
- orderBy: "id",
259
- limit: options.batchSize,
260
- ...after === void 0 ? {} : { after }
261
- });
262
- if (rows.length === 0) return;
263
- const edges = rows.map((row) => {
264
- const edge = {
265
- kind: row.kind,
266
- id: row.id,
267
- from: {
268
- kind: row.from_kind,
269
- id: row.from_id
270
- },
271
- to: {
272
- kind: row.to_kind,
273
- id: row.to_id
274
- },
275
- properties: chunkEKFUG4G7_cjs.rowPropsToObject(row.props)
276
- };
277
- if (options.includeTemporal) {
278
- const validFrom = (
279
- // eslint-disable-next-line unicorn/no-null
280
- row.valid_from ?? null
281
- );
282
- edge.validFrom = validFrom;
283
- if (row.valid_to) {
284
- edge.validTo = row.valid_to;
285
- }
286
- }
287
- if (options.includeMeta) {
288
- edge.meta = {
289
- createdAt: row.created_at,
290
- updatedAt: row.updated_at
291
- };
292
- }
293
- return edge;
294
- });
295
- yield { type: "edges", edges };
296
- if (rows.length < options.batchSize) return;
297
- after = chunk764JHTLT_cjs.requireDefined(rows.at(-1)).id;
298
- }
299
- }
300
-
301
- // src/interchange/import.ts
302
- async function importGraph(store, data, rawOptions) {
303
- const options = ImportOptionsSchema.parse(rawOptions);
304
- const result = emptyImportResult();
305
- const errors = [];
306
- const graph = store.graph;
307
- const graphId = store.graphId;
308
- const backend = chunkJ7LXTUTP_cjs.storeBackend(store);
309
- const registry = store.registry;
310
- const nodeSchemas = buildNodeSchemaMap(graph);
311
- const edgeSchemas = buildEdgeSchemaMap(graph);
312
- const importedNodeIds = /* @__PURE__ */ new Set();
313
- await chunkUCQ3BFSY_cjs.runInWriteTransaction(
314
- {
315
- graphId,
316
- schemaVersion: store.introspect().schemaVersion,
317
- historyEnabled: store.historyEnabled,
318
- revisionTrackingEnabled: store.revisionTrackingEnabled,
319
- revisionSchema: store.revisionSchema
320
- },
321
- backend,
322
- async (target, lock) => {
323
- await processNodes(
324
- target,
325
- graphId,
326
- registry,
327
- data.nodes,
328
- nodeSchemas,
329
- options,
330
- result,
331
- errors,
332
- importedNodeIds,
333
- lock
334
- );
335
- await processEdges(
336
- target,
337
- graphId,
338
- registry,
339
- data.edges,
340
- edgeSchemas,
341
- nodeSchemas,
342
- options,
343
- result,
344
- errors,
345
- importedNodeIds
346
- );
347
- }
348
- );
349
- await refreshStatisticsAfterImport(store, options, result, "importGraph");
350
- return {
351
- ...result,
352
- success: errors.length === 0,
353
- errors
354
- };
355
- }
356
- async function importGraphStream(store, chunks, rawOptions) {
357
- const options = ImportOptionsSchema.parse(rawOptions);
358
- const result = emptyImportResult();
359
- let header;
360
- let receivedEdges = false;
361
- for await (const chunk of chunks) {
362
- switch (chunk.type) {
363
- case "header": {
364
- if (header !== void 0) {
365
- throw new Error(
366
- "Graph interchange stream emitted more than one header."
367
- );
368
- }
369
- header = chunk.header;
370
- break;
371
- }
372
- case "nodes": {
373
- if (header === void 0) {
374
- throw new Error("Graph interchange stream must start with a header.");
375
- }
376
- if (receivedEdges) {
377
- throw new Error(
378
- "Graph interchange stream cannot emit nodes after edges."
379
- );
380
- }
381
- if (chunk.nodes.length === 0) break;
382
- mergeImportResult(
383
- result,
384
- await importGraph(store, graphDataForChunk(header, chunk.nodes, []), {
385
- ...options,
386
- refreshStatistics: false
387
- })
388
- );
389
- throwIfStreamChunkFailed(result, options);
390
- break;
391
- }
392
- case "edges": {
393
- if (header === void 0) {
394
- throw new Error("Graph interchange stream must start with a header.");
395
- }
396
- receivedEdges = true;
397
- if (chunk.edges.length === 0) break;
398
- mergeImportResult(
399
- result,
400
- await importGraph(store, graphDataForChunk(header, [], chunk.edges), {
401
- ...options,
402
- refreshStatistics: false
403
- })
404
- );
405
- throwIfStreamChunkFailed(result, options);
406
- break;
407
- }
408
- }
409
- }
410
- if (header === void 0) {
411
- throw new Error("Graph interchange stream ended before emitting a header.");
412
- }
413
- await refreshStatisticsAfterImport(
414
- store,
415
- options,
416
- result,
417
- "importGraphStream"
418
- );
419
- return { ...result, success: result.errors.length === 0 };
420
- }
421
- function throwIfStreamChunkFailed(result, options) {
422
- if (options.onStreamChunkError === "continue" || result.errors.length === 0) {
423
- return;
424
- }
425
- throw new Error(
426
- 'Graph interchange stream aborted after a chunk reported import errors. Earlier chunks remain committed; use onStreamChunkError: "continue" for best-effort ingestion.'
427
- );
428
- }
429
- function emptyImportResult() {
430
- return {
431
- success: true,
432
- nodes: { created: 0, updated: 0, skipped: 0 },
433
- edges: { created: 0, updated: 0, skipped: 0 },
434
- errors: []
435
- };
436
- }
437
- function graphDataForChunk(header, nodes, edges) {
438
- return { ...header, nodes, edges };
439
- }
440
- function mergeImportResult(target, source) {
441
- target.nodes.created += source.nodes.created;
442
- target.nodes.updated += source.nodes.updated;
443
- target.nodes.skipped += source.nodes.skipped;
444
- target.edges.created += source.edges.created;
445
- target.edges.updated += source.edges.updated;
446
- target.edges.skipped += source.edges.skipped;
447
- target.errors.push(...source.errors);
448
- }
449
- async function refreshStatisticsAfterImport(store, options, result, surface) {
450
- const mutationCount = result.nodes.created + result.nodes.updated + result.edges.created + result.edges.updated;
451
- if ((options.refreshStatistics ?? true) && mutationCount > 0) {
452
- try {
453
- await store.refreshStatistics();
454
- } catch (error) {
455
- if (typeof console !== "undefined" && typeof console.warn === "function") {
456
- console.warn(
457
- `[typegraph] ${surface} committed its rows but the follow-up statistics refresh failed; run store.refreshStatistics() to give the planner fresh statistics.`,
458
- error
459
- );
460
- }
461
- }
462
- }
463
- }
464
- function buildNodeSchemaMap(graph) {
465
- const map = /* @__PURE__ */ new Map();
466
- for (const kindName of chunkQB6VMOJ2_cjs.getNodeKinds(graph)) {
467
- const registration = graph.nodes[kindName];
468
- map.set(kindName, {
469
- registration,
470
- schema: registration.type.schema
471
- });
472
- }
473
- return map;
474
- }
475
- function buildEdgeSchemaMap(graph) {
476
- const map = /* @__PURE__ */ new Map();
477
- for (const kindName of chunkQB6VMOJ2_cjs.getEdgeKinds(graph)) {
478
- const registration = graph.edges[kindName];
479
- map.set(kindName, {
480
- registration,
481
- schema: registration.type.schema
482
- });
483
- }
484
- return map;
485
- }
486
- async function processNodes(backend, graphId, registry, nodes, schemas, options, result, errors, importedNodeIds, lock) {
487
- const batchSize = options.batchSize;
488
- for (let index = 0; index < nodes.length; index += batchSize) {
489
- const batch = nodes.slice(index, index + batchSize);
490
- await processNodeSlice(
491
- backend,
492
- graphId,
493
- registry,
494
- batch,
495
- schemas,
496
- options,
497
- result,
498
- errors,
499
- importedNodeIds,
500
- lock
501
- );
502
- }
503
- }
504
- function recordNodeOutcome(node, outcome, result, errors, importedNodeIds) {
505
- switch (outcome.status) {
506
- case "created": {
507
- result.nodes.created++;
508
- importedNodeIds.add(makeNodeKey(node.kind, node.id));
509
- break;
510
- }
511
- case "updated": {
512
- result.nodes.updated++;
513
- importedNodeIds.add(makeNodeKey(node.kind, node.id));
514
- break;
515
- }
516
- case "skipped": {
517
- result.nodes.skipped++;
518
- if (outcome.liveTarget) {
519
- importedNodeIds.add(makeNodeKey(node.kind, node.id));
520
- }
521
- break;
522
- }
523
- case "error": {
524
- errors.push({
525
- entityType: "node",
526
- kind: node.kind,
527
- id: node.id,
528
- error: outcome.error
529
- });
530
- break;
531
- }
532
- }
533
- }
534
- async function processNodeSlice(backend, graphId, registry, batch, schemas, options, result, errors, importedNodeIds, lock) {
535
- const record = (node, outcome) => {
536
- recordNodeOutcome(node, outcome, result, errors, importedNodeIds);
537
- };
538
- const candidates = [];
539
- const deferred = [];
540
- const seenKeys = /* @__PURE__ */ new Set();
541
- for (const node of batch) {
542
- const schemaEntry = schemas.get(node.kind);
543
- if (!schemaEntry) {
544
- record(node, {
545
- status: "error",
546
- error: `Unknown node kind: ${node.kind}`
547
- });
548
- continue;
549
- }
550
- const propsResult = validateProperties(
551
- node.properties,
552
- schemaEntry.schema,
553
- options.onUnknownProperty
554
- );
555
- if (!propsResult.success) {
556
- record(node, { status: "error", error: propsResult.error });
557
- continue;
558
- }
559
- const validityError = validateValidityWindow(node);
560
- if (validityError !== void 0) {
561
- record(node, { status: "error", error: validityError });
562
- continue;
563
- }
564
- const key = makeNodeKey(node.kind, node.id);
565
- if (seenKeys.has(key)) {
566
- deferred.push(node);
567
- continue;
568
- }
569
- seenKeys.add(key);
570
- candidates.push({
571
- node,
572
- schemaEntry,
573
- props: propsResult.data,
574
- draft: {
575
- kind: node.kind,
576
- id: node.id,
577
- nodeKind: schemaEntry.registration.type,
578
- uniqueConstraints: schemaEntry.registration.unique ?? [],
579
- validatedProps: propsResult.data,
580
- // NodeCreateDraft.validFrom is string | undefined (never null) — it
581
- // only feeds batch validation-cache priming, which never inspects
582
- // it, so normalizing the explicit-NULL sentinel away here is inert.
583
- // The actual insert (buildImportInsertParams) reads node.validFrom
584
- // directly and preserves the null.
585
- validFrom: node.validFrom ?? void 0,
586
- validTo: node.validTo
587
- }
588
- });
589
- }
590
- const {
591
- backend: validationBackend,
592
- registerPendingNode,
593
- registerPendingUniqueEntries,
594
- registerAppliedNodeUpdate,
595
- seedNodeRow,
596
- seedUniqueRow
597
- } = chunkUCQ3BFSY_cjs.createNodeBatchValidationBackend(graphId, registry, backend);
598
- await chunkUCQ3BFSY_cjs.primeBatchValidationCaches(
599
- { graphId, registry },
600
- candidates.map((candidate) => candidate.draft),
601
- backend,
602
- { seedNodeRow, seedUniqueRow }
603
- );
604
- const writeContext = { graphId, registry, lock };
605
- const accepted = [];
606
- for (const candidate of candidates) {
607
- const { node, schemaEntry, props } = candidate;
608
- const uniqueConstraints = schemaEntry.registration.unique ?? [];
609
- const existing = await validationBackend.getNode(
610
- graphId,
611
- node.kind,
612
- node.id
613
- );
614
- if (existing) {
615
- switch (options.onConflict) {
616
- case "skip": {
617
- record(node, {
618
- status: "skipped",
619
- liveTarget: chunkEKFUG4G7_cjs.isLiveNodeRow(existing)
620
- });
621
- break;
622
- }
623
- case "error": {
624
- record(node, {
625
- status: "error",
626
- error: `Node already exists: ${node.kind}:${node.id}`
627
- });
628
- break;
629
- }
630
- case "update": {
631
- if (!chunkEKFUG4G7_cjs.isLiveNodeRow(existing)) {
632
- record(node, { status: "skipped", liveTarget: false });
633
- break;
634
- }
635
- const updateResult = await catchUniquenessError(
636
- () => chunkJ7LXTUTP_cjs.applyNodeUpdate(
637
- writeContext,
638
- {
639
- existing,
640
- schema: schemaEntry.registration.type.schema,
641
- validatedProps: props,
642
- uniqueConstraints,
643
- ...node.validTo !== void 0 && { validTo: node.validTo }
644
- },
645
- // The pending-aware overlay, not the raw backend: the update's
646
- // uniqueness pre-check must see a unique value already reserved by
647
- // an unflushed create EARLIER in this slice, so it degrades to a
648
- // per-row error exactly as the sequential path does — rather than
649
- // claiming the key on the real backend and colliding with that
650
- // create at flush (which would throw and roll back the whole
651
- // import). Writes still delegate to the real backend.
652
- validationBackend
653
- )
654
- );
655
- if (updateResult.ok) {
656
- registerAppliedNodeUpdate(
657
- node.kind,
658
- node.id,
659
- chunkEKFUG4G7_cjs.rowPropsToObject(existing.props),
660
- props,
661
- uniqueConstraints
662
- );
663
- }
664
- record(
665
- node,
666
- updateResult.ok ? { status: "updated" } : { status: "error", error: updateResult.error }
667
- );
668
- break;
669
- }
670
- }
671
- continue;
672
- }
673
- const uniquenessResult = await catchUniquenessError(
674
- () => chunkJ7LXTUTP_cjs.checkUniquenessConstraints(
675
- { graphId, registry, backend: validationBackend },
676
- node.kind,
677
- node.id,
678
- props,
679
- uniqueConstraints
680
- )
681
- );
682
- if (!uniquenessResult.ok) {
683
- record(node, { status: "error", error: uniquenessResult.error });
684
- continue;
685
- }
686
- registerPendingNode(buildImportInsertParams(graphId, candidate));
687
- registerPendingUniqueEntries(node.kind, node.id, props, uniqueConstraints);
688
- accepted.push(candidate);
689
- }
690
- if (accepted.length > 0) {
691
- const insertParamsList = accepted.map(
692
- (candidate) => buildImportInsertParams(graphId, candidate)
693
- );
694
- if (backend.insertNodesBatch === void 0) {
695
- for (const params of insertParamsList) {
696
- await backend.insertNode(params);
697
- }
698
- } else {
699
- await backend.insertNodesBatch(insertParamsList);
700
- }
701
- await chunkJ7LXTUTP_cjs.applyNodeInsertSideEffectsBatch(
702
- writeContext,
703
- accepted.map((candidate) => ({
704
- kind: candidate.node.kind,
705
- id: candidate.node.id,
706
- schema: candidate.schemaEntry.registration.type.schema,
707
- props: candidate.props,
708
- uniqueConstraints: candidate.schemaEntry.registration.unique ?? []
709
- })),
710
- backend
711
- );
712
- for (const candidate of accepted) {
713
- record(candidate.node, { status: "created" });
714
- }
715
- }
716
- for (const node of deferred) {
717
- record(
718
- node,
719
- await processNode(
720
- backend,
721
- graphId,
722
- registry,
723
- node,
724
- schemas,
725
- options,
726
- lock
727
- )
728
- );
729
- }
730
- }
731
- function buildImportInsertParams(graphId, candidate) {
732
- const { node, props } = candidate;
733
- return {
734
- graphId,
735
- kind: node.kind,
736
- id: node.id,
737
- props,
738
- ...node.validFrom !== void 0 && { validFrom: node.validFrom },
739
- ...node.validTo !== void 0 && { validTo: node.validTo }
740
- };
741
- }
742
- async function catchUniquenessError(fn) {
743
- try {
744
- return { ok: true, value: await fn() };
745
- } catch (error) {
746
- if (error instanceof chunkC4F7VJ5D_cjs.UniquenessError) {
747
- return { ok: false, error: error.message };
748
- }
749
- throw error;
750
- }
751
- }
752
- function validateValidityWindow(entity) {
753
- try {
754
- chunkZTAJL4DT_cjs.validateOptionalCanonicalIsoDate(
755
- entity.validFrom ?? void 0,
756
- "validFrom"
757
- );
758
- chunkZTAJL4DT_cjs.validateOptionalCanonicalIsoDate(entity.validTo, "validTo");
759
- return void 0;
760
- } catch (error) {
761
- return error instanceof Error ? error.message : String(error);
762
- }
763
- }
764
- async function processNode(backend, graphId, registry, node, schemas, options, lock) {
765
- const schemaEntry = schemas.get(node.kind);
766
- if (!schemaEntry) {
767
- return { status: "error", error: `Unknown node kind: ${node.kind}` };
768
- }
769
- const propsResult = validateProperties(
770
- node.properties,
771
- schemaEntry.schema,
772
- options.onUnknownProperty
773
- );
774
- if (!propsResult.success) {
775
- return { status: "error", error: propsResult.error };
776
- }
777
- const validityError = validateValidityWindow(node);
778
- if (validityError !== void 0) {
779
- return { status: "error", error: validityError };
780
- }
781
- const { registration } = schemaEntry;
782
- const uniqueConstraints = registration.unique ?? [];
783
- const writeContext = { graphId, registry, lock };
784
- const existing = await backend.getNode(graphId, node.kind, node.id);
785
- if (existing) {
786
- switch (options.onConflict) {
787
- case "skip": {
788
- return { status: "skipped", liveTarget: chunkEKFUG4G7_cjs.isLiveNodeRow(existing) };
789
- }
790
- case "error": {
791
- return {
792
- status: "error",
793
- error: `Node already exists: ${node.kind}:${node.id}`
794
- };
795
- }
796
- case "update": {
797
- if (!chunkEKFUG4G7_cjs.isLiveNodeRow(existing)) {
798
- return { status: "skipped", liveTarget: false };
799
- }
800
- const updateResult = await catchUniquenessError(
801
- () => chunkJ7LXTUTP_cjs.applyNodeUpdate(
802
- writeContext,
803
- {
804
- existing,
805
- schema: registration.type.schema,
806
- validatedProps: propsResult.data,
807
- uniqueConstraints,
808
- ...node.validTo !== void 0 && { validTo: node.validTo }
809
- },
810
- backend
811
- )
812
- );
813
- if (!updateResult.ok) {
814
- return { status: "error", error: updateResult.error };
815
- }
816
- return { status: "updated" };
817
- }
818
- }
819
- }
820
- const uniquenessResult = await catchUniquenessError(
821
- () => chunkJ7LXTUTP_cjs.checkUniquenessConstraints(
822
- { graphId, registry, backend },
823
- node.kind,
824
- node.id,
825
- propsResult.data,
826
- uniqueConstraints
827
- )
828
- );
829
- if (!uniquenessResult.ok) {
830
- return { status: "error", error: uniquenessResult.error };
831
- }
832
- await backend.insertNode({
833
- graphId,
834
- kind: node.kind,
835
- id: node.id,
836
- props: propsResult.data,
837
- ...node.validFrom !== void 0 && { validFrom: node.validFrom },
838
- ...node.validTo !== void 0 && { validTo: node.validTo }
839
- });
840
- await chunkJ7LXTUTP_cjs.applyNodeInsertSideEffects(
841
- writeContext,
842
- {
843
- kind: node.kind,
844
- id: node.id,
845
- schema: registration.type.schema,
846
- props: propsResult.data,
847
- uniqueConstraints
848
- },
849
- backend
850
- );
851
- return { status: "created" };
852
- }
853
- async function processEdges(backend, graphId, registry, edges, edgeSchemas, nodeSchemas, options, result, errors, importedNodeIds) {
854
- const batchSize = options.batchSize;
855
- for (let index = 0; index < edges.length; index += batchSize) {
856
- const batch = edges.slice(index, index + batchSize);
857
- await processEdgeSlice(
858
- backend,
859
- graphId,
860
- registry,
861
- batch,
862
- edgeSchemas,
863
- nodeSchemas,
864
- options,
865
- result,
866
- errors,
867
- importedNodeIds
868
- );
869
- }
870
- }
871
- function recordEdgeOutcome(edge, outcome, result, errors) {
872
- switch (outcome.status) {
873
- case "created": {
874
- result.edges.created++;
875
- break;
876
- }
877
- case "updated": {
878
- result.edges.updated++;
879
- break;
880
- }
881
- case "skipped": {
882
- result.edges.skipped++;
883
- break;
884
- }
885
- case "error": {
886
- errors.push({
887
- entityType: "edge",
888
- kind: edge.kind,
889
- id: edge.id,
890
- error: outcome.error
891
- });
892
- break;
893
- }
894
- }
895
- }
896
- async function processEdgeSlice(backend, graphId, registry, batch, edgeSchemas, nodeSchemas, options, result, errors, importedNodeIds) {
897
- const record = (edge, outcome) => {
898
- recordEdgeOutcome(edge, outcome, result, errors);
899
- };
900
- const candidates = [];
901
- const deferred = [];
902
- const seenIds = /* @__PURE__ */ new Set();
903
- for (const edge of batch) {
904
- const schemaEntry = edgeSchemas.get(edge.kind);
905
- if (!schemaEntry) {
906
- record(edge, {
907
- status: "error",
908
- error: `Unknown edge kind: ${edge.kind}`
909
- });
910
- continue;
911
- }
912
- if (!nodeSchemas.has(edge.from.kind)) {
913
- record(edge, {
914
- status: "error",
915
- error: `Unknown from node kind: ${edge.from.kind}`
916
- });
917
- continue;
918
- }
919
- if (!nodeSchemas.has(edge.to.kind)) {
920
- record(edge, {
921
- status: "error",
922
- error: `Unknown to node kind: ${edge.to.kind}`
923
- });
924
- continue;
925
- }
926
- const endpointError = chunkJ7LXTUTP_cjs.validateEdgeEndpoints(
927
- edge.kind,
928
- edge.from.kind,
929
- edge.to.kind,
930
- schemaEntry.registration,
931
- registry
932
- );
933
- if (endpointError !== void 0) {
934
- record(edge, { status: "error", error: endpointError.message });
935
- continue;
936
- }
937
- const propsResult = validateProperties(
938
- edge.properties,
939
- schemaEntry.schema,
940
- options.onUnknownProperty
941
- );
942
- if (!propsResult.success) {
943
- record(edge, { status: "error", error: propsResult.error });
944
- continue;
945
- }
946
- const validityError = validateValidityWindow(edge);
947
- if (validityError !== void 0) {
948
- record(edge, { status: "error", error: validityError });
949
- continue;
950
- }
951
- if (seenIds.has(edge.id)) {
952
- deferred.push(edge);
953
- continue;
954
- }
955
- seenIds.add(edge.id);
956
- candidates.push({ edge, props: propsResult.data });
957
- }
958
- const liveEndpointKeys = /* @__PURE__ */ new Set();
959
- const checkedEndpointKeys = /* @__PURE__ */ new Set();
960
- if (options.validateReferences && backend.getNodes !== void 0) {
961
- const idsByKind = /* @__PURE__ */ new Map();
962
- for (const { edge } of candidates) {
963
- for (const endpoint of [edge.from, edge.to]) {
964
- const key = makeNodeKey(endpoint.kind, endpoint.id);
965
- if (importedNodeIds.has(key) || checkedEndpointKeys.has(key)) continue;
966
- checkedEndpointKeys.add(key);
967
- const ids = idsByKind.get(endpoint.kind) ?? /* @__PURE__ */ new Set();
968
- ids.add(endpoint.id);
969
- idsByKind.set(endpoint.kind, ids);
970
- }
971
- }
972
- for (const [kind, ids] of idsByKind) {
973
- const rows = await backend.getNodes(graphId, kind, [...ids]);
974
- for (const row of rows) {
975
- if (chunkEKFUG4G7_cjs.isLiveNodeRow(row)) {
976
- liveEndpointKeys.add(makeNodeKey(kind, row.id));
977
- }
978
- }
979
- }
980
- }
981
- const endpointIsLive = async (endpoint) => {
982
- const key = makeNodeKey(endpoint.kind, endpoint.id);
983
- if (importedNodeIds.has(key)) return true;
984
- if (checkedEndpointKeys.has(key)) return liveEndpointKeys.has(key);
985
- const row = await backend.getNode(graphId, endpoint.kind, endpoint.id);
986
- return row !== void 0 && chunkEKFUG4G7_cjs.isLiveNodeRow(row);
987
- };
988
- const existingById = /* @__PURE__ */ new Map();
989
- if (candidates.length > 0 && backend.getEdges !== void 0) {
990
- const rows = await backend.getEdges(
991
- graphId,
992
- candidates.map((candidate) => candidate.edge.id)
993
- );
994
- for (const row of rows) {
995
- existingById.set(row.id, row);
996
- }
997
- for (const { edge } of candidates) {
998
- if (!existingById.has(edge.id)) existingById.set(edge.id, void 0);
999
- }
1000
- }
1001
- const accepted = [];
1002
- for (const candidate of candidates) {
1003
- const { edge, props } = candidate;
1004
- if (options.validateReferences) {
1005
- if (!await endpointIsLive(edge.from)) {
1006
- record(edge, {
1007
- status: "error",
1008
- error: `From node not found: ${edge.from.kind}:${edge.from.id}`
1009
- });
1010
- continue;
1011
- }
1012
- if (!await endpointIsLive(edge.to)) {
1013
- record(edge, {
1014
- status: "error",
1015
- error: `To node not found: ${edge.to.kind}:${edge.to.id}`
1016
- });
1017
- continue;
1018
- }
1019
- }
1020
- const existing = existingById.has(edge.id) ? existingById.get(edge.id) : await backend.getEdge(graphId, edge.id);
1021
- if (existing) {
1022
- switch (options.onConflict) {
1023
- case "skip": {
1024
- record(edge, {
1025
- status: "skipped",
1026
- liveTarget: existing.deleted_at === void 0
1027
- });
1028
- break;
1029
- }
1030
- case "error": {
1031
- record(edge, {
1032
- status: "error",
1033
- error: `Edge already exists: ${edge.id}`
1034
- });
1035
- break;
1036
- }
1037
- case "update": {
1038
- if (existing.deleted_at !== void 0) {
1039
- record(edge, { status: "skipped"});
1040
- break;
1041
- }
1042
- await backend.updateEdge({
1043
- graphId,
1044
- id: edge.id,
1045
- props,
1046
- ...edge.validTo !== void 0 && { validTo: edge.validTo }
1047
- });
1048
- record(edge, { status: "updated" });
1049
- break;
1050
- }
1051
- }
1052
- continue;
1053
- }
1054
- accepted.push(candidate);
1055
- }
1056
- if (accepted.length > 0) {
1057
- const insertParamsList = accepted.map(({ edge, props }) => ({
1058
- graphId,
1059
- id: edge.id,
1060
- kind: edge.kind,
1061
- fromKind: edge.from.kind,
1062
- fromId: edge.from.id,
1063
- toKind: edge.to.kind,
1064
- toId: edge.to.id,
1065
- props,
1066
- ...edge.validFrom !== void 0 && { validFrom: edge.validFrom },
1067
- ...edge.validTo !== void 0 && { validTo: edge.validTo }
1068
- }));
1069
- if (backend.insertEdgesBatch === void 0) {
1070
- for (const params of insertParamsList) {
1071
- await backend.insertEdge(params);
1072
- }
1073
- } else {
1074
- await backend.insertEdgesBatch(insertParamsList);
1075
- }
1076
- for (const candidate of accepted) {
1077
- record(candidate.edge, { status: "created" });
1078
- }
1079
- }
1080
- for (const edge of deferred) {
1081
- record(
1082
- edge,
1083
- await processEdge(
1084
- backend,
1085
- graphId,
1086
- registry,
1087
- edge,
1088
- edgeSchemas,
1089
- nodeSchemas,
1090
- options,
1091
- importedNodeIds
1092
- )
1093
- );
1094
- }
1095
- }
1096
- async function processEdge(backend, graphId, registry, edge, edgeSchemas, nodeSchemas, options, importedNodeIds) {
1097
- const schemaEntry = edgeSchemas.get(edge.kind);
1098
- if (!schemaEntry) {
1099
- return { status: "error", error: `Unknown edge kind: ${edge.kind}` };
1100
- }
1101
- if (!nodeSchemas.has(edge.from.kind)) {
1102
- return {
1103
- status: "error",
1104
- error: `Unknown from node kind: ${edge.from.kind}`
1105
- };
1106
- }
1107
- if (!nodeSchemas.has(edge.to.kind)) {
1108
- return { status: "error", error: `Unknown to node kind: ${edge.to.kind}` };
1109
- }
1110
- const endpointError = chunkJ7LXTUTP_cjs.validateEdgeEndpoints(
1111
- edge.kind,
1112
- edge.from.kind,
1113
- edge.to.kind,
1114
- schemaEntry.registration,
1115
- registry
1116
- );
1117
- if (endpointError !== void 0) {
1118
- return { status: "error", error: endpointError.message };
1119
- }
1120
- if (options.validateReferences) {
1121
- const fromKey = makeNodeKey(edge.from.kind, edge.from.id);
1122
- const toKey = makeNodeKey(edge.to.kind, edge.to.id);
1123
- if (!importedNodeIds.has(fromKey)) {
1124
- const fromExists = await backend.getNode(
1125
- graphId,
1126
- edge.from.kind,
1127
- edge.from.id
1128
- );
1129
- if (fromExists === void 0 || !chunkEKFUG4G7_cjs.isLiveNodeRow(fromExists)) {
1130
- return {
1131
- status: "error",
1132
- error: `From node not found: ${edge.from.kind}:${edge.from.id}`
1133
- };
1134
- }
1135
- }
1136
- if (!importedNodeIds.has(toKey)) {
1137
- const toExists = await backend.getNode(graphId, edge.to.kind, edge.to.id);
1138
- if (toExists === void 0 || !chunkEKFUG4G7_cjs.isLiveNodeRow(toExists)) {
1139
- return {
1140
- status: "error",
1141
- error: `To node not found: ${edge.to.kind}:${edge.to.id}`
1142
- };
1143
- }
1144
- }
1145
- }
1146
- const propsResult = validateProperties(
1147
- edge.properties,
1148
- schemaEntry.schema,
1149
- options.onUnknownProperty
1150
- );
1151
- if (!propsResult.success) {
1152
- return { status: "error", error: propsResult.error };
1153
- }
1154
- const validityError = validateValidityWindow(edge);
1155
- if (validityError !== void 0) {
1156
- return { status: "error", error: validityError };
1157
- }
1158
- const existing = await backend.getEdge(graphId, edge.id);
1159
- if (existing) {
1160
- switch (options.onConflict) {
1161
- case "skip": {
1162
- return {
1163
- status: "skipped",
1164
- liveTarget: existing.deleted_at === void 0
1165
- };
1166
- }
1167
- case "error": {
1168
- return { status: "error", error: `Edge already exists: ${edge.id}` };
1169
- }
1170
- case "update": {
1171
- if (existing.deleted_at !== void 0) {
1172
- return { status: "skipped", liveTarget: false };
1173
- }
1174
- await backend.updateEdge({
1175
- graphId,
1176
- id: edge.id,
1177
- props: propsResult.data,
1178
- ...edge.validTo !== void 0 && { validTo: edge.validTo }
1179
- });
1180
- return { status: "updated" };
1181
- }
1182
- }
1183
- }
1184
- await backend.insertEdge({
1185
- graphId,
1186
- id: edge.id,
1187
- kind: edge.kind,
1188
- fromKind: edge.from.kind,
1189
- fromId: edge.from.id,
1190
- toKind: edge.to.kind,
1191
- toId: edge.to.id,
1192
- props: propsResult.data,
1193
- ...edge.validFrom !== void 0 && { validFrom: edge.validFrom },
1194
- ...edge.validTo !== void 0 && { validTo: edge.validTo }
1195
- });
1196
- return { status: "created" };
1197
- }
1198
- function validateProperties(properties, schema, unknownStrategy) {
1199
- try {
1200
- const knownKeys = new Set(Object.keys(schema.shape));
1201
- const unknownKeys = Object.keys(properties).filter(
1202
- (key) => !knownKeys.has(key)
1203
- );
1204
- if (unknownKeys.length > 0) {
1205
- switch (unknownStrategy) {
1206
- case "error": {
1207
- return {
1208
- success: false,
1209
- error: `Unknown properties: ${unknownKeys.join(", ")}`
1210
- };
1211
- }
1212
- case "strip": {
1213
- const stripped = {};
1214
- for (const key of knownKeys) {
1215
- if (key in properties) {
1216
- stripped[key] = properties[key];
1217
- }
1218
- }
1219
- const result2 = schema.safeParse(stripped);
1220
- if (!result2.success) {
1221
- return {
1222
- success: false,
1223
- error: formatZodError(result2.error)
1224
- };
1225
- }
1226
- return {
1227
- success: true,
1228
- data: result2.data
1229
- };
1230
- }
1231
- case "allow": {
1232
- const result2 = schema.safeParse(properties);
1233
- if (!result2.success) {
1234
- return {
1235
- success: false,
1236
- error: formatZodError(result2.error)
1237
- };
1238
- }
1239
- return { success: true, data: properties };
1240
- }
1241
- }
1242
- }
1243
- const result = schema.safeParse(properties);
1244
- if (!result.success) {
1245
- return { success: false, error: formatZodError(result.error) };
1246
- }
1247
- return { success: true, data: result.data };
1248
- } catch (error) {
1249
- const message = error instanceof Error ? error.message : String(error);
1250
- return { success: false, error: `Validation error: ${message}` };
1251
- }
1252
- }
1253
- function formatZodError(error) {
1254
- return error.issues.map((issue) => {
1255
- const path = issue.path.join(".");
1256
- return path ? `${path}: ${issue.message}` : issue.message;
1257
- }).join("; ");
1258
- }
1259
- function makeNodeKey(kind, id) {
1260
- return `${kind}:${id}`;
1261
- }
1262
-
1263
- exports.ConflictStrategySchema = ConflictStrategySchema;
1264
- exports.ExportOptionsSchema = ExportOptionsSchema;
1265
- exports.ExportStreamOptionsSchema = ExportStreamOptionsSchema;
1266
- exports.FORMAT_VERSION = FORMAT_VERSION;
1267
- exports.GraphDataHeaderSchema = GraphDataHeaderSchema;
1268
- exports.GraphDataSchema = GraphDataSchema;
1269
- exports.GraphDataSourceSchema = GraphDataSourceSchema;
1270
- exports.GraphInterchangeChunkSchema = GraphInterchangeChunkSchema;
1271
- exports.ImportErrorSchema = ImportErrorSchema;
1272
- exports.ImportOptionsSchema = ImportOptionsSchema;
1273
- exports.ImportResultSchema = ImportResultSchema;
1274
- exports.InterchangeEdgeSchema = InterchangeEdgeSchema;
1275
- exports.InterchangeNodeSchema = InterchangeNodeSchema;
1276
- exports.UnknownPropertyStrategySchema = UnknownPropertyStrategySchema;
1277
- exports.exportGraph = exportGraph;
1278
- exports.exportGraphStream = exportGraphStream;
1279
- exports.importGraph = importGraph;
1280
- exports.importGraphStream = importGraphStream;
1281
- //# sourceMappingURL=chunk-6RYPD3NJ.cjs.map
1282
- //# sourceMappingURL=chunk-6RYPD3NJ.cjs.map