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