@nicia-ai/typegraph 0.34.0 → 0.35.0

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