@nicia-ai/typegraph 0.33.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 (284) hide show
  1. package/README.md +20 -0
  2. package/dist/backend/postgres/index.cjs +30 -26
  3. package/dist/backend/postgres/index.d.cts +39 -7
  4. package/dist/backend/postgres/index.d.ts +39 -7
  5. package/dist/backend/postgres/index.js +17 -13
  6. package/dist/backend/postgres/pglite.cjs +22 -18
  7. package/dist/backend/postgres/pglite.cjs.map +1 -1
  8. package/dist/backend/postgres/pglite.d.cts +4 -4
  9. package/dist/backend/postgres/pglite.d.ts +4 -4
  10. package/dist/backend/postgres/pglite.js +17 -13
  11. package/dist/backend/postgres/pglite.js.map +1 -1
  12. package/dist/backend/sqlite/index.cjs +26 -23
  13. package/dist/backend/sqlite/index.d.cts +8 -8
  14. package/dist/backend/sqlite/index.d.ts +8 -8
  15. package/dist/backend/sqlite/index.js +14 -11
  16. package/dist/backend/sqlite/libsql.cjs +21 -17
  17. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  18. package/dist/backend/sqlite/libsql.d.cts +13 -6
  19. package/dist/backend/sqlite/libsql.d.ts +13 -6
  20. package/dist/backend/sqlite/libsql.js +17 -13
  21. package/dist/backend/sqlite/libsql.js.map +1 -1
  22. package/dist/backend/sqlite/local.cjs +102 -18
  23. package/dist/backend/sqlite/local.cjs.map +1 -1
  24. package/dist/backend/sqlite/local.d.cts +95 -5
  25. package/dist/backend/sqlite/local.d.ts +95 -5
  26. package/dist/backend/sqlite/local.js +96 -13
  27. package/dist/backend/sqlite/local.js.map +1 -1
  28. package/dist/{chunk-JHOBXD7O.js → chunk-3TWF3SH4.js} +332 -64
  29. package/dist/chunk-3TWF3SH4.js.map +1 -0
  30. package/dist/chunk-4JEZZJ6S.cjs +1271 -0
  31. package/dist/chunk-4JEZZJ6S.cjs.map +1 -0
  32. package/dist/{chunk-I4W7MKVG.cjs → chunk-4TOD4LBZ.cjs} +249 -294
  33. package/dist/chunk-4TOD4LBZ.cjs.map +1 -0
  34. package/dist/chunk-55MZDDZV.js +239 -0
  35. package/dist/chunk-55MZDDZV.js.map +1 -0
  36. package/dist/{chunk-LM2IC4ZJ.cjs → chunk-5A6FNS6N.cjs} +75 -19
  37. package/dist/chunk-5A6FNS6N.cjs.map +1 -0
  38. package/dist/{chunk-FDN43KXV.cjs → chunk-5AQIKK56.cjs} +65 -24
  39. package/dist/chunk-5AQIKK56.cjs.map +1 -0
  40. package/dist/{chunk-IZ4PCL47.js → chunk-5SEGFTZX.js} +4 -66
  41. package/dist/chunk-5SEGFTZX.js.map +1 -0
  42. package/dist/{chunk-CWFPJ3RC.js → chunk-6FR2MMS6.js} +7 -7
  43. package/dist/chunk-6FR2MMS6.js.map +1 -0
  44. package/dist/chunk-7YSP4V4R.cjs +69 -0
  45. package/dist/chunk-7YSP4V4R.cjs.map +1 -0
  46. package/dist/chunk-A42GCBGX.cjs +28 -0
  47. package/dist/chunk-A42GCBGX.cjs.map +1 -0
  48. package/dist/chunk-ACSVZPK7.cjs +21 -0
  49. package/dist/chunk-ACSVZPK7.cjs.map +1 -0
  50. package/dist/{chunk-OIE2UPVG.cjs → chunk-BLZDPRXT.cjs} +52 -21
  51. package/dist/chunk-BLZDPRXT.cjs.map +1 -0
  52. package/dist/chunk-BYPOGQWK.js +25 -0
  53. package/dist/chunk-BYPOGQWK.js.map +1 -0
  54. package/dist/{chunk-NG5N7R45.cjs → chunk-CK5BVQOW.cjs} +325 -213
  55. package/dist/chunk-CK5BVQOW.cjs.map +1 -0
  56. package/dist/chunk-CTTSDJLY.cjs +261 -0
  57. package/dist/chunk-CTTSDJLY.cjs.map +1 -0
  58. package/dist/chunk-CUHM5CWJ.cjs +12 -0
  59. package/dist/chunk-CUHM5CWJ.cjs.map +1 -0
  60. package/dist/chunk-CZQ3FO2Q.js +2320 -0
  61. package/dist/chunk-CZQ3FO2Q.js.map +1 -0
  62. package/dist/{chunk-CFNT3ITG.cjs → chunk-D7ZEOS56.cjs} +25 -52
  63. package/dist/chunk-D7ZEOS56.cjs.map +1 -0
  64. package/dist/chunk-DFVLCOP6.js +10 -0
  65. package/dist/chunk-DFVLCOP6.js.map +1 -0
  66. package/dist/chunk-DI74SMXS.cjs +29 -0
  67. package/dist/chunk-DI74SMXS.cjs.map +1 -0
  68. package/dist/{chunk-KY5SDVA7.cjs → chunk-EM3CWPND.cjs} +442 -113
  69. package/dist/chunk-EM3CWPND.cjs.map +1 -0
  70. package/dist/chunk-EMF62TZG.cjs +1176 -0
  71. package/dist/chunk-EMF62TZG.cjs.map +1 -0
  72. package/dist/chunk-EOLERH7Y.cjs +40 -0
  73. package/dist/chunk-EOLERH7Y.cjs.map +1 -0
  74. package/dist/{chunk-3QRBXYT5.cjs → chunk-FACJJWGF.cjs} +24 -6
  75. package/dist/chunk-FACJJWGF.cjs.map +1 -0
  76. package/dist/{chunk-KTIEB7VH.cjs → chunk-FL472AMI.cjs} +49 -165
  77. package/dist/chunk-FL472AMI.cjs.map +1 -0
  78. package/dist/{chunk-4RBAJVEC.cjs → chunk-FN35DLCN.cjs} +31 -9
  79. package/dist/chunk-FN35DLCN.cjs.map +1 -0
  80. package/dist/{chunk-C4C4Q7A6.js → chunk-FPIZFYHE.js} +12 -35
  81. package/dist/chunk-FPIZFYHE.js.map +1 -0
  82. package/dist/{chunk-XKNAK27R.js → chunk-FRV5Q5IO.js} +64 -8
  83. package/dist/chunk-FRV5Q5IO.js.map +1 -0
  84. package/dist/{chunk-K5P5OZXS.js → chunk-G6Q5UM7U.js} +2 -2
  85. package/dist/{chunk-K5P5OZXS.js.map → chunk-G6Q5UM7U.js.map} +1 -1
  86. package/dist/chunk-GSQ6NPH6.cjs +100 -0
  87. package/dist/chunk-GSQ6NPH6.cjs.map +1 -0
  88. package/dist/chunk-GUR2FNB5.cjs +12 -0
  89. package/dist/{chunk-6ZR4QC3O.cjs.map → chunk-GUR2FNB5.cjs.map} +1 -1
  90. package/dist/{chunk-ZFWNO3GE.cjs → chunk-H7YNSMA7.cjs} +107 -2
  91. package/dist/chunk-H7YNSMA7.cjs.map +1 -0
  92. package/dist/{chunk-GYVBEZAO.js → chunk-I7ZUZKFD.js} +47 -19
  93. package/dist/chunk-I7ZUZKFD.js.map +1 -0
  94. package/dist/chunk-ITE4IXAK.js +25 -0
  95. package/dist/chunk-ITE4IXAK.js.map +1 -0
  96. package/dist/{chunk-D3EWZ67S.cjs → chunk-J7WFGBJR.cjs} +3372 -4970
  97. package/dist/chunk-J7WFGBJR.cjs.map +1 -0
  98. package/dist/{chunk-PYD3UCDU.js → chunk-JBTOYDMN.js} +202 -251
  99. package/dist/chunk-JBTOYDMN.js.map +1 -0
  100. package/dist/{chunk-XVUJY72M.js → chunk-K3PPLHY7.js} +234 -118
  101. package/dist/chunk-K3PPLHY7.js.map +1 -0
  102. package/dist/{chunk-454I6GDF.js → chunk-KBGQIPRQ.js} +102 -3
  103. package/dist/chunk-KBGQIPRQ.js.map +1 -0
  104. package/dist/chunk-KMI7LYAF.js +1252 -0
  105. package/dist/chunk-KMI7LYAF.js.map +1 -0
  106. package/dist/{chunk-JIEJCTDS.cjs → chunk-LGEALRC6.cjs} +21 -4
  107. package/dist/chunk-LGEALRC6.cjs.map +1 -0
  108. package/dist/{chunk-TQOYM4LN.js → chunk-MP2JQKSG.js} +21 -5
  109. package/dist/chunk-MP2JQKSG.js.map +1 -0
  110. package/dist/{chunk-3642VBVC.cjs → chunk-O7UN7OXA.cjs} +389 -121
  111. package/dist/chunk-O7UN7OXA.cjs.map +1 -0
  112. package/dist/chunk-OHMP6N2J.js +47 -0
  113. package/dist/chunk-OHMP6N2J.js.map +1 -0
  114. package/dist/{chunk-6NRFUHMS.js → chunk-OR5ZA5WP.js} +135 -24
  115. package/dist/chunk-OR5ZA5WP.js.map +1 -0
  116. package/dist/{chunk-PRMKPFN5.js → chunk-Q5TEXCTB.js} +61 -6
  117. package/dist/chunk-Q5TEXCTB.js.map +1 -0
  118. package/dist/chunk-QNKSQTKQ.js +1312 -0
  119. package/dist/chunk-QNKSQTKQ.js.map +1 -0
  120. package/dist/{chunk-YCV72E6L.js → chunk-QOTI55H7.js} +7 -116
  121. package/dist/chunk-QOTI55H7.js.map +1 -0
  122. package/dist/{chunk-QBYTJSAY.js → chunk-QWEUYILR.js} +99 -34
  123. package/dist/chunk-QWEUYILR.js.map +1 -0
  124. package/dist/{chunk-OS6KS3HV.js → chunk-RGP33ZJ5.js} +485 -82
  125. package/dist/chunk-RGP33ZJ5.js.map +1 -0
  126. package/dist/chunk-RGPG7EOJ.js +94 -0
  127. package/dist/chunk-RGPG7EOJ.js.map +1 -0
  128. package/dist/{chunk-WWVV44DY.cjs → chunk-S55OV6PW.cjs} +15 -15
  129. package/dist/chunk-S55OV6PW.cjs.map +1 -0
  130. package/dist/{chunk-3E7SNSIA.cjs → chunk-SJDMVITW.cjs} +4 -4
  131. package/dist/{chunk-3E7SNSIA.cjs.map → chunk-SJDMVITW.cjs.map} +1 -1
  132. package/dist/{chunk-XLUNB2TZ.js → chunk-SNXVDZAJ.js} +3 -3
  133. package/dist/{chunk-XLUNB2TZ.js.map → chunk-SNXVDZAJ.js.map} +1 -1
  134. package/dist/{chunk-CEF2QOTO.js → chunk-T2WUSPDA.js} +49 -8
  135. package/dist/chunk-T2WUSPDA.js.map +1 -0
  136. package/dist/{chunk-YW7GHMF4.cjs → chunk-TCOCYN2P.cjs} +75 -20
  137. package/dist/chunk-TCOCYN2P.cjs.map +1 -0
  138. package/dist/{chunk-FLRCVI2G.cjs → chunk-TDXIBCGY.cjs} +2 -2
  139. package/dist/{chunk-FLRCVI2G.cjs.map → chunk-TDXIBCGY.cjs.map} +1 -1
  140. package/dist/chunk-TEDRJXOG.cjs +32 -0
  141. package/dist/chunk-TEDRJXOG.cjs.map +1 -0
  142. package/dist/{chunk-WLP6TKFB.js → chunk-UES55P7G.js} +2809 -4398
  143. package/dist/chunk-UES55P7G.js.map +1 -0
  144. package/dist/{chunk-EF3Z645U.cjs → chunk-UMDVATGY.cjs} +6 -72
  145. package/dist/chunk-UMDVATGY.cjs.map +1 -0
  146. package/dist/chunk-UR7W5YQK.js +18 -0
  147. package/dist/chunk-UR7W5YQK.js.map +1 -0
  148. package/dist/chunk-UT3S4SEN.js +31 -0
  149. package/dist/chunk-UT3S4SEN.js.map +1 -0
  150. package/dist/{chunk-3IR2GEMJ.cjs → chunk-UUT7UN2N.cjs} +149 -38
  151. package/dist/chunk-UUT7UN2N.cjs.map +1 -0
  152. package/dist/{chunk-PIHXFF73.js → chunk-UZV3AZKF.js} +21 -3
  153. package/dist/chunk-UZV3AZKF.js.map +1 -0
  154. package/dist/{chunk-DJYRRDHA.js → chunk-VHMPG6UL.js} +29 -7
  155. package/dist/chunk-VHMPG6UL.js.map +1 -0
  156. package/dist/{chunk-MBLXCV2Y.cjs → chunk-VPYHY3LJ.cjs} +111 -43
  157. package/dist/chunk-VPYHY3LJ.cjs.map +1 -0
  158. package/dist/{chunk-WYTUF3QO.js → chunk-VSPCZAXF.js} +3 -3
  159. package/dist/{chunk-WYTUF3QO.js.map → chunk-VSPCZAXF.js.map} +1 -1
  160. package/dist/chunk-W63OVYY4.js +29 -0
  161. package/dist/chunk-W63OVYY4.js.map +1 -0
  162. package/dist/{chunk-UPDMJEW6.js → chunk-WDBCBWC4.js} +356 -30
  163. package/dist/chunk-WDBCBWC4.js.map +1 -0
  164. package/dist/chunk-WJT7OU7E.cjs +1334 -0
  165. package/dist/chunk-WJT7OU7E.cjs.map +1 -0
  166. package/dist/chunk-XOX22WHL.cjs +2383 -0
  167. package/dist/chunk-XOX22WHL.cjs.map +1 -0
  168. package/dist/{ddl-CVnHJcar.d.ts → ddl-C2rZ-Aen.d.ts} +4 -4
  169. package/dist/{ddl-Dxt_fBHr.d.cts → ddl-CZz7a0E8.d.cts} +4 -4
  170. package/dist/{extension-types-YGFJPrzK.d.cts → extension-types-ixRpJVUp.d.cts} +24 -1
  171. package/dist/{extension-types-YGFJPrzK.d.ts → extension-types-ixRpJVUp.d.ts} +24 -1
  172. package/dist/{types-DGylBhWo.d.ts → fulltext-strategy-B57yvC5Q.d.ts} +2558 -2125
  173. package/dist/{types-C_UnQOQp.d.cts → fulltext-strategy-CDkSSYhq.d.cts} +2558 -2125
  174. package/dist/graph-extension/index.cjs +21 -19
  175. package/dist/graph-extension/index.d.cts +4 -4
  176. package/dist/graph-extension/index.d.ts +4 -4
  177. package/dist/graph-extension/index.js +6 -4
  178. package/dist/graph-merge/index.cjs +408 -169
  179. package/dist/graph-merge/index.cjs.map +1 -1
  180. package/dist/graph-merge/index.d.cts +63 -33
  181. package/dist/graph-merge/index.d.ts +63 -33
  182. package/dist/graph-merge/index.js +286 -47
  183. package/dist/graph-merge/index.js.map +1 -1
  184. package/dist/{index-DGX6D9j1.d.ts → index-6CSUAq-x.d.ts} +234 -93
  185. package/dist/{index-SEvUHDA6.d.cts → index-Bks_3HHK.d.cts} +234 -93
  186. package/dist/index.cjs +240 -211
  187. package/dist/index.cjs.map +1 -1
  188. package/dist/index.d.cts +11 -11
  189. package/dist/index.d.ts +11 -11
  190. package/dist/index.js +35 -27
  191. package/dist/index.js.map +1 -1
  192. package/dist/indexes/index.cjs +28 -27
  193. package/dist/indexes/index.d.cts +5 -5
  194. package/dist/indexes/index.d.ts +5 -5
  195. package/dist/indexes/index.js +10 -9
  196. package/dist/interchange/index.cjs +47 -17
  197. package/dist/interchange/index.d.cts +126 -12
  198. package/dist/interchange/index.d.ts +126 -12
  199. package/dist/interchange/index.js +14 -4
  200. package/dist/{manager-BYl_zyZR.d.cts → manager-DwQi8eV0.d.cts} +9 -2
  201. package/dist/{manager-C0_r0ALf.d.ts → manager-ejUCB52T.d.ts} +9 -2
  202. package/dist/{materialize-indexes-D20xNluI.d.cts → materialize-indexes-B4e9360H.d.cts} +20 -4
  203. package/dist/{materialize-indexes-CAkIYFV-.d.ts → materialize-indexes-te9TPMMJ.d.ts} +20 -4
  204. package/dist/{postgres-_9psmVGm.d.cts → postgres-CfEqsRMp.d.cts} +152 -1
  205. package/dist/{postgres-MzBPkYzq.d.ts → postgres-DQ5R6rzV.d.ts} +152 -1
  206. package/dist/profiler/index.cjs +11 -11
  207. package/dist/profiler/index.d.cts +7 -7
  208. package/dist/profiler/index.d.ts +7 -7
  209. package/dist/profiler/index.js +4 -4
  210. package/dist/provenance/index.cjs +590 -0
  211. package/dist/provenance/index.cjs.map +1 -0
  212. package/dist/provenance/index.d.cts +73 -0
  213. package/dist/provenance/index.d.ts +73 -0
  214. package/dist/provenance/index.js +588 -0
  215. package/dist/provenance/index.js.map +1 -0
  216. package/dist/schema/index.cjs +55 -38
  217. package/dist/schema/index.cjs.map +1 -1
  218. package/dist/schema/index.d.cts +57 -57
  219. package/dist/schema/index.d.ts +57 -57
  220. package/dist/schema/index.js +30 -13
  221. package/dist/schema/index.js.map +1 -1
  222. package/dist/{sqlite-gm44dShb.d.ts → sqlite-D7zBinNR.d.cts} +92 -1
  223. package/dist/{sqlite-BfksSb45.d.cts → sqlite-DvQndLky.d.ts} +92 -1
  224. package/dist/{store-view-FfE5_7eo.d.ts → store-view-BSpqvAxK.d.cts} +445 -46
  225. package/dist/{store-view-9jQ2rPum.d.cts → store-view-CKbHFRnn.d.ts} +445 -46
  226. package/dist/{types-B6mhrcLv.d.cts → types-Bv9DcS_E.d.cts} +2 -2
  227. package/dist/{types-CdWxK-nD.d.ts → types-CoxuV7EJ.d.ts} +2 -2
  228. package/dist/{where-Bpp2ul_z.d.cts → where-7RKFOsXt.d.ts} +2 -2
  229. package/dist/{where-BsEXraKW.d.ts → where-DdMIXOtH.d.cts} +2 -2
  230. package/package.json +21 -14
  231. package/dist/chunk-2YMGNYXY.js +0 -40
  232. package/dist/chunk-2YMGNYXY.js.map +0 -1
  233. package/dist/chunk-3642VBVC.cjs.map +0 -1
  234. package/dist/chunk-3EUKJEQ3.js +0 -77
  235. package/dist/chunk-3EUKJEQ3.js.map +0 -1
  236. package/dist/chunk-3IR2GEMJ.cjs.map +0 -1
  237. package/dist/chunk-3QRBXYT5.cjs.map +0 -1
  238. package/dist/chunk-454I6GDF.js.map +0 -1
  239. package/dist/chunk-4RBAJVEC.cjs.map +0 -1
  240. package/dist/chunk-6NRFUHMS.js.map +0 -1
  241. package/dist/chunk-6ZR4QC3O.cjs +0 -12
  242. package/dist/chunk-73KASJGO.cjs +0 -52
  243. package/dist/chunk-73KASJGO.cjs.map +0 -1
  244. package/dist/chunk-BF3ZDEUE.cjs +0 -773
  245. package/dist/chunk-BF3ZDEUE.cjs.map +0 -1
  246. package/dist/chunk-C4C4Q7A6.js.map +0 -1
  247. package/dist/chunk-CEF2QOTO.js.map +0 -1
  248. package/dist/chunk-CFNT3ITG.cjs.map +0 -1
  249. package/dist/chunk-CWFPJ3RC.js.map +0 -1
  250. package/dist/chunk-D3EWZ67S.cjs.map +0 -1
  251. package/dist/chunk-DJYRRDHA.js.map +0 -1
  252. package/dist/chunk-EF3Z645U.cjs.map +0 -1
  253. package/dist/chunk-FDN43KXV.cjs.map +0 -1
  254. package/dist/chunk-GYVBEZAO.js.map +0 -1
  255. package/dist/chunk-HTGDWIDE.cjs +0 -89
  256. package/dist/chunk-HTGDWIDE.cjs.map +0 -1
  257. package/dist/chunk-I4W7MKVG.cjs.map +0 -1
  258. package/dist/chunk-IZ4PCL47.js.map +0 -1
  259. package/dist/chunk-JHOBXD7O.js.map +0 -1
  260. package/dist/chunk-JIEJCTDS.cjs.map +0 -1
  261. package/dist/chunk-KTIEB7VH.cjs.map +0 -1
  262. package/dist/chunk-KY5SDVA7.cjs.map +0 -1
  263. package/dist/chunk-LM2IC4ZJ.cjs.map +0 -1
  264. package/dist/chunk-MBLXCV2Y.cjs.map +0 -1
  265. package/dist/chunk-NG5N7R45.cjs.map +0 -1
  266. package/dist/chunk-OIE2UPVG.cjs.map +0 -1
  267. package/dist/chunk-OS6KS3HV.js.map +0 -1
  268. package/dist/chunk-PIHXFF73.js.map +0 -1
  269. package/dist/chunk-PRMKPFN5.js.map +0 -1
  270. package/dist/chunk-PYD3UCDU.js.map +0 -1
  271. package/dist/chunk-QBYTJSAY.js.map +0 -1
  272. package/dist/chunk-SPT5JMME.js +0 -610
  273. package/dist/chunk-SPT5JMME.js.map +0 -1
  274. package/dist/chunk-SST7XDY6.cjs +0 -624
  275. package/dist/chunk-SST7XDY6.cjs.map +0 -1
  276. package/dist/chunk-TQOYM4LN.js.map +0 -1
  277. package/dist/chunk-UPDMJEW6.js.map +0 -1
  278. package/dist/chunk-WLP6TKFB.js.map +0 -1
  279. package/dist/chunk-WWVV44DY.cjs.map +0 -1
  280. package/dist/chunk-XKNAK27R.js.map +0 -1
  281. package/dist/chunk-XVUJY72M.js.map +0 -1
  282. package/dist/chunk-YCV72E6L.js.map +0 -1
  283. package/dist/chunk-YW7GHMF4.cjs.map +0 -1
  284. package/dist/chunk-ZFWNO3GE.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/interchange/types.ts","../src/interchange/export.ts","../src/interchange/import.ts"],"names":["result"],"mappings":";;;;;;;;AAqBO,IAAM,cAAA,GAAiB;AAW9B,IAAM,uBAAA,GAA0B,CAAA,CAAE,GAAA,CAC/B,QAAA,EAAS,CACT,OAAO,CAAC,KAAA,KAAU,kBAAA,CAAmB,KAAK,CAAA,EAAG;AAAA,EAC5C,OAAA,EACE;AACJ,CAAC,CAAA;AAYI,IAAM,qBAAA,GAAwB,EAAE,MAAA,CAAO;AAAA,EAC5C,IAAA,EAAM,CAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA,EACtB,EAAA,EAAI,CAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA,EACpB,UAAA,EAAY,EAAE,MAAA,CAAO,CAAA,CAAE,QAAO,EAAG,CAAA,CAAE,SAAS,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5C,SAAA,EAAW,uBAAA,CAAwB,QAAA,EAAS,CAAE,QAAA,EAAS;AAAA,EAC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AAA,OAAO,KAAA,CAAM,MAAA,CACV,GAAA,CAAI,CAAC,KAAA,KAAU;AACd,IAAA,MAAM,IAAA,GAAO,KAAA,CAAM,IAAA,CAAK,IAAA,CAAK,GAAG,CAAA;AAChC,IAAA,OAAO,OAAO,CAAA,EAAG,IAAI,KAAK,KAAA,CAAM,OAAO,KAAK,KAAA,CAAM,OAAA;AAAA,EACpD,CAAC,CAAA,CACA,IAAA,CAAK,IAAI,CAAA;AACd;AAMA,SAAS,WAAA,CAAY,MAAc,EAAA,EAAoB;AACrD,EAAA,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA;AACtB","file":"chunk-KMI7LYAF.js","sourcesContent":["/**\n * Graph interchange format types.\n *\n * Defines Zod schemas for importing and exporting graph data.\n * The format is designed to be:\n * - JSON-serializable for API transport\n * - Validated via Zod at runtime\n * - Exportable as JSON Schema for LLM/API documentation\n */\nimport { z } from \"zod\";\n\nimport { isCanonicalIsoDate } from \"../utils/date\";\n\n// ============================================================\n// Format Version\n// ============================================================\n\n/**\n * Current interchange format version.\n * Increment for breaking changes to the format.\n */\nexport const FORMAT_VERSION = \"1.0\" as const;\n\n/**\n * A stored validity-window timestamp (`validFrom` / `validTo`). Must be a\n * canonical fixed-width UTC ISO-8601 string (`YYYY-MM-DDTHH:mm:ss.sssZ`) — the\n * same contract `create` / `update` enforce — because temporal filters compare\n * it as text against the `asOf` read coordinate, and a variable-width value\n * (date-only, offset, missing/variable milliseconds) would mis-sort and\n * silently include or exclude the wrong rows. Convert non-canonical inputs with\n * `new Date(value).toISOString()`.\n */\nconst ValidityTimestampSchema = z.iso\n .datetime()\n .refine((value) => isCanonicalIsoDate(value), {\n message:\n \"Expected canonical UTC ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ); convert with new Date(value).toISOString().\",\n });\n\n// ============================================================\n// Node Interchange\n// ============================================================\n\n/**\n * Interchange format for a node.\n *\n * Properties are stored as a record to allow schema-agnostic transport.\n * Validation against the actual schema happens during import.\n */\nexport const InterchangeNodeSchema = z.object({\n kind: z.string().min(1),\n id: z.string().min(1),\n properties: z.record(z.string(), z.unknown()),\n /**\n * `undefined` (key absent): not requested (`includeTemporal: false`) —\n * import defaults it to the import's own creation timestamp. `null`:\n * requested and confirmed the row has no lower bound (e.g. a legacy row\n * predating the \"omitted validFrom defaults to creation time\" fix) —\n * import preserves that open-left validity instead of re-stamping it.\n */\n validFrom: ValidityTimestampSchema.nullable().optional(),\n validTo: ValidityTimestampSchema.optional(),\n meta: z\n .object({\n version: z.number().int().positive().optional(),\n createdAt: z.iso.datetime().optional(),\n updatedAt: z.iso.datetime().optional(),\n })\n .optional(),\n});\n\nexport type InterchangeNode = z.infer<typeof InterchangeNodeSchema>;\n\n// ============================================================\n// Edge Interchange\n// ============================================================\n\n/**\n * Interchange format for an edge.\n *\n * Endpoint references are objects with kind and id, rather than\n * composite strings, for clarity and type safety.\n */\nexport const InterchangeEdgeSchema = z.object({\n kind: z.string().min(1),\n id: z.string().min(1),\n from: z.object({\n kind: z.string().min(1),\n id: z.string().min(1),\n }),\n to: z.object({\n kind: z.string().min(1),\n id: z.string().min(1),\n }),\n properties: z.record(z.string(), z.unknown()).default({}),\n /** See {@link InterchangeNodeSchema}'s `validFrom` for the null/undefined contract. */\n validFrom: ValidityTimestampSchema.nullable().optional(),\n validTo: ValidityTimestampSchema.optional(),\n meta: z\n .object({\n createdAt: z.iso.datetime().optional(),\n updatedAt: z.iso.datetime().optional(),\n })\n .optional(),\n});\n\nexport type InterchangeEdge = z.infer<typeof InterchangeEdgeSchema>;\n\n// ============================================================\n// Import Configuration\n// ============================================================\n\n/**\n * Strategy for handling conflicts when a node/edge ID already exists.\n *\n * - `skip`: Keep existing, ignore incoming\n * - `update`: Merge incoming properties into existing\n * - `error`: Throw an error on conflict\n */\nexport const ConflictStrategySchema = z.enum([\"skip\", \"update\", \"error\"]);\nexport type ConflictStrategy = z.infer<typeof ConflictStrategySchema>;\n\n/**\n * Strategy for handling properties not defined in the schema.\n *\n * - `error`: Throw a validation error\n * - `strip`: Remove unknown properties silently\n * - `allow`: Pass through to storage (relies on backend behavior)\n */\nexport const UnknownPropertyStrategySchema = z.enum([\n \"error\",\n \"strip\",\n \"allow\",\n]);\nexport type UnknownPropertyStrategy = z.infer<\n typeof UnknownPropertyStrategySchema\n>;\n\n/**\n * Options for importing graph data.\n */\nexport const ImportOptionsSchema = z.object({\n /** How to handle existing nodes/edges with the same ID */\n onConflict: ConflictStrategySchema,\n /** How to handle properties not in the schema */\n onUnknownProperty: UnknownPropertyStrategySchema.default(\"error\"),\n /** Whether to validate that edge endpoints exist */\n validateReferences: z.boolean().default(true),\n /**\n * Number of items to process in each batch. Each batch pays fixed\n * per-round-trip costs (existence probe, unique check, one multi-row\n * insert), so undersized batches dominate import time on client/server\n * engines: measured on PostgreSQL, 20k nodes + 5k edges import in\n * 1,515ms at 100 vs 781ms at 1,000. Above ~1,000 the multi-row insert\n * itself dominates and larger batches stop paying; SQLite is\n * insensitive to the value (in-process, no round trips). The backend\n * further splits inserts by its bind-parameter budget, so a large\n * batch never overruns driver limits.\n */\n batchSize: z.number().int().positive().default(1000),\n /**\n * Refresh planner statistics (ANALYZE) after an import that created or\n * updated rows. Bulk loads otherwise run against stale statistics until\n * the engine catches up on its own. Default: true.\n */\n refreshStatistics: z.boolean().optional(),\n /**\n * How a streamed import reacts when one chunk reports entity-level errors.\n * `abort` is the safe default: earlier chunks are already committed, so\n * callers must not mistake a partial stream for a successful retryable load.\n * `continue` is reserved for explicit best-effort ingestion.\n */\n onStreamChunkError: z.enum([\"abort\", \"continue\"]).default(\"abort\"),\n});\n\n/**\n * Caller-facing options: fields with schema defaults are optional.\n * `importGraph` parses these once at its boundary; internal stages\n * consume {@link ResolvedImportOptions} with every default applied.\n */\nexport type ImportOptions = z.input<typeof ImportOptionsSchema>;\n\n/** {@link ImportOptions} after schema parsing — all defaults resolved. */\nexport type ResolvedImportOptions = z.infer<typeof ImportOptionsSchema>;\n\n// ============================================================\n// Graph Data Source\n// ============================================================\n\n/**\n * Source metadata for graph data.\n *\n * Uses discriminated union to capture different origin types:\n * - `typegraph-export`: Exported from a TypeGraph store\n * - `external`: From a third-party system\n */\nexport const GraphDataSourceSchema = z.discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"typegraph-export\"),\n graphId: z.string(),\n schemaVersion: z.number().int().positive(),\n }),\n z.object({\n type: z.literal(\"external\"),\n description: z.string().optional(),\n }),\n]);\n\nexport type GraphDataSource = z.infer<typeof GraphDataSourceSchema>;\n\n// ============================================================\n// Graph Data Envelope\n// ============================================================\n\n/**\n * Complete graph data interchange format.\n *\n * The envelope contains metadata about the data source and format version,\n * plus arrays of nodes and edges to import.\n */\nexport const GraphDataSchema = z.object({\n formatVersion: z.literal(FORMAT_VERSION),\n exportedAt: z.iso.datetime(),\n source: GraphDataSourceSchema,\n nodes: z.array(InterchangeNodeSchema),\n edges: z.array(InterchangeEdgeSchema),\n});\n\nexport type GraphData = z.infer<typeof GraphDataSchema>;\n\n/** The metadata envelope emitted before streamed graph entities. */\nexport const GraphDataHeaderSchema = GraphDataSchema.omit({\n nodes: true,\n edges: true,\n});\n\nexport type GraphDataHeader = z.infer<typeof GraphDataHeaderSchema>;\n\n/**\n * One bounded unit in the streamed interchange protocol. Nodes always precede\n * edges, so an importer can validate endpoints from rows already written to its\n * target without retaining all prior nodes in memory.\n */\nexport const GraphInterchangeChunkSchema = z.discriminatedUnion(\"type\", [\n z.object({ type: z.literal(\"header\"), header: GraphDataHeaderSchema }),\n z.object({ type: z.literal(\"nodes\"), nodes: z.array(InterchangeNodeSchema) }),\n z.object({ type: z.literal(\"edges\"), edges: z.array(InterchangeEdgeSchema) }),\n]);\n\nexport type GraphInterchangeChunk = z.infer<typeof GraphInterchangeChunkSchema>;\n\n// ============================================================\n// Import Result\n// ============================================================\n\n/**\n * An error that occurred during import.\n */\nexport const ImportErrorSchema = z.object({\n entityType: z.enum([\"node\", \"edge\"]),\n kind: z.string(),\n id: z.string(),\n error: z.string(),\n});\n\nexport type ImportError = z.infer<typeof ImportErrorSchema>;\n\n/**\n * Result of an import operation.\n *\n * Contains counts of created/updated/skipped entities and any errors.\n */\nexport const ImportResultSchema = z.object({\n success: z.boolean(),\n nodes: z.object({\n created: z.number().int().nonnegative(),\n updated: z.number().int().nonnegative(),\n skipped: z.number().int().nonnegative(),\n }),\n edges: z.object({\n created: z.number().int().nonnegative(),\n updated: z.number().int().nonnegative(),\n skipped: z.number().int().nonnegative(),\n }),\n errors: z.array(ImportErrorSchema),\n});\n\nexport type ImportResult = z.infer<typeof ImportResultSchema>;\n\n// ============================================================\n// Export Options\n// ============================================================\n\n/**\n * Options for exporting graph data.\n */\nexport const ExportOptionsSchema = z.object({\n /** Filter to specific node kinds (undefined = all) */\n nodeKinds: z.array(z.string()).optional(),\n /** Filter to specific edge kinds (undefined = all) */\n edgeKinds: z.array(z.string()).optional(),\n /** Include temporal fields (validFrom, validTo) */\n includeTemporal: z.boolean().default(false),\n /** Include metadata (version, timestamps) */\n includeMeta: z.boolean().default(false),\n /** Include soft-deleted records */\n includeDeleted: z.boolean().default(false),\n});\n\n/** Export options with defaults applied (output type) */\nexport type ExportOptions = z.infer<typeof ExportOptionsSchema>;\n\n/** Export options as accepted by exportGraph (input type with optional defaults) */\nexport type ExportOptionsInput = z.input<typeof ExportOptionsSchema>;\n\n/**\n * Export options for {@link exportGraphStream}. `batchSize` bounds the number\n * of node or edge entities retained for one yielded chunk.\n */\nexport const ExportStreamOptionsSchema = ExportOptionsSchema.extend({\n batchSize: z.number().int().positive().default(1000),\n});\n\nexport type ExportStreamOptions = z.infer<typeof ExportStreamOptionsSchema>;\nexport type ExportStreamOptionsInput = z.input<\n typeof ExportStreamOptionsSchema\n>;\n","/**\n * Graph data export functionality.\n *\n * Exports nodes and edges from a store to the interchange format.\n */\nimport { type GraphBackend, rowPropsToObject } from \"../backend/types\";\nimport {\n getEdgeKinds,\n getNodeKinds,\n type GraphDef,\n} from \"../core/define-graph\";\nimport { type Store } from \"../store/store\";\nimport { nowIso } from \"../utils/date\";\nimport {\n type ExportOptionsInput,\n type ExportStreamOptionsInput,\n ExportStreamOptionsSchema,\n FORMAT_VERSION,\n type GraphData,\n type GraphDataHeader,\n type GraphInterchangeChunk,\n type InterchangeEdge,\n type InterchangeNode,\n} from \"./types\";\n\n// ============================================================\n// Export Function\n// ============================================================\n\n/**\n * Export graph data from a store.\n *\n * @param store - The graph store to export from\n * @param options - Export configuration\n * @returns Graph data in interchange format\n *\n * @example\n * ```typescript\n * const data = await exportGraph(store, {\n * nodeKinds: [\"Person\", \"Organization\"],\n * includeMeta: true,\n * });\n *\n * // Write to file\n * await fs.writeFile(\"backup.json\", JSON.stringify(data, null, 2));\n * ```\n */\nexport async function exportGraph<G extends GraphDef>(\n store: Store<G>,\n options?: ExportOptionsInput,\n): Promise<GraphData> {\n const nodes: InterchangeNode[] = [];\n const edges: InterchangeEdge[] = [];\n let header: GraphDataHeader | undefined;\n for await (const chunk of exportGraphStream(store, options)) {\n switch (chunk.type) {\n case \"header\": {\n header = chunk.header;\n break;\n }\n case \"nodes\": {\n nodes.push(...chunk.nodes);\n break;\n }\n case \"edges\": {\n edges.push(...chunk.edges);\n break;\n }\n }\n }\n if (header === undefined) {\n throw new Error(\"Graph export stream ended before emitting its header.\");\n }\n return { ...header, nodes, edges };\n}\n\n/**\n * Exports a graph as bounded node and edge chunks. The stream always yields one\n * header, then every node chunk, then every edge chunk. Consumers that write to\n * a network, file, or fresh working copy can process one chunk at a time rather\n * than materializing a graph-sized {@link GraphData} value.\n */\nexport async function* exportGraphStream<G extends GraphDef>(\n store: Store<G>,\n options?: ExportStreamOptionsInput,\n): AsyncIterable<GraphInterchangeChunk> {\n const resolved = ExportStreamOptionsSchema.parse(options ?? {});\n const graphId = store.graphId;\n const backend = store.backend;\n const nodeKinds = resolved.nodeKinds ?? getNodeKinds(store.graph);\n const edgeKinds = resolved.edgeKinds ?? getEdgeKinds(store.graph);\n const schemaVersion = await backend.getActiveSchema(graphId);\n\n yield {\n type: \"header\",\n header: {\n formatVersion: FORMAT_VERSION,\n exportedAt: nowIso(),\n source: {\n type: \"typegraph-export\",\n graphId,\n schemaVersion: schemaVersion?.version ?? 1,\n },\n },\n };\n\n for (const kind of nodeKinds) {\n yield* exportNodeChunks(backend, graphId, kind, resolved);\n }\n for (const kind of edgeKinds) {\n yield* exportEdgeChunks(backend, graphId, kind, resolved);\n }\n}\n\n// ============================================================\n// Node Export\n// ============================================================\n\ntype ExportOptions_ = Readonly<{\n includeTemporal: boolean;\n includeMeta: boolean;\n includeDeleted: boolean;\n}>;\n\nasync function* exportNodeChunks(\n backend: GraphBackend,\n graphId: string,\n kind: string,\n options: ExportOptions_ & Readonly<{ batchSize: number }>,\n): AsyncIterable<GraphInterchangeChunk> {\n let after: string | undefined;\n for (;;) {\n const rows = await backend.findNodesByKind({\n graphId,\n kind,\n excludeDeleted: !options.includeDeleted,\n orderBy: \"id\",\n limit: options.batchSize,\n ...(after === undefined ? {} : { after }),\n });\n if (rows.length === 0) return;\n const nodes = rows.map((row) => {\n const node: InterchangeNode = {\n kind: row.kind,\n id: row.id,\n properties: rowPropsToObject(row.props),\n };\n\n if (options.includeTemporal) {\n // validFrom is always emitted (as `null` when the row has no lower\n // bound) so import can tell \"confirmed open-left\" apart from \"not\n // requested\" and preserve it instead of defaulting to import time —\n // see the schema doc on InterchangeNodeSchema.validFrom. validTo has\n // no such ambiguity (it was never defaulted), so it stays gated.\n // `null` (not `undefined`) is the wire-protocol signal here — JSON has\n // no other way to say \"explicitly cleared\" vs. \"field absent\".\n const validFrom =\n // eslint-disable-next-line unicorn/no-null\n row.valid_from ?? null;\n (node as { validFrom?: string | null }).validFrom = validFrom;\n if (row.valid_to) {\n (node as { validTo?: string }).validTo = row.valid_to;\n }\n }\n\n if (options.includeMeta) {\n (node as { meta?: InterchangeNode[\"meta\"] }).meta = {\n version: row.version,\n createdAt: row.created_at,\n updatedAt: row.updated_at,\n };\n }\n\n return node;\n });\n yield { type: \"nodes\", nodes };\n if (rows.length < options.batchSize) return;\n after = rows.at(-1)!.id;\n }\n}\n\n// ============================================================\n// Edge Export\n// ============================================================\n\nasync function* exportEdgeChunks(\n backend: GraphBackend,\n graphId: string,\n kind: string,\n options: ExportOptions_ & Readonly<{ batchSize: number }>,\n): AsyncIterable<GraphInterchangeChunk> {\n let after: string | undefined;\n for (;;) {\n const rows = await backend.findEdgesByKind({\n graphId,\n kind,\n excludeDeleted: !options.includeDeleted,\n orderBy: \"id\",\n limit: options.batchSize,\n ...(after === undefined ? {} : { after }),\n });\n if (rows.length === 0) return;\n const edges = rows.map((row) => {\n const edge: InterchangeEdge = {\n kind: row.kind,\n id: row.id,\n from: {\n kind: row.from_kind,\n id: row.from_id,\n },\n to: {\n kind: row.to_kind,\n id: row.to_id,\n },\n properties: rowPropsToObject(row.props),\n };\n\n if (options.includeTemporal) {\n // See exportNodesOfKind's validFrom comment: always emitted (as\n // `null` when open-left) so import can distinguish \"confirmed no\n // lower bound\" from \"not requested\".\n const validFrom =\n // eslint-disable-next-line unicorn/no-null\n row.valid_from ?? null;\n (edge as { validFrom?: string | null }).validFrom = validFrom;\n if (row.valid_to) {\n (edge as { validTo?: string }).validTo = row.valid_to;\n }\n }\n\n if (options.includeMeta) {\n (edge as { meta?: InterchangeEdge[\"meta\"] }).meta = {\n createdAt: row.created_at,\n updatedAt: row.updated_at,\n };\n }\n\n return edge;\n });\n yield { type: \"edges\", edges };\n if (rows.length < options.batchSize) return;\n after = rows.at(-1)!.id;\n }\n}\n","/**\n * Graph data import functionality.\n *\n * Imports nodes and edges from the interchange format into a store,\n * with configurable conflict resolution and validation.\n */\nimport type { z } from \"zod\";\n\nimport {\n type GraphBackend,\n isLiveNodeRow,\n rowPropsToObject,\n type TransactionBackend,\n} from \"../backend/types\";\nimport { validateEdgeEndpoints } from \"../constraints\";\nimport {\n getEdgeKinds,\n getNodeKinds,\n type GraphDef,\n} from \"../core/define-graph\";\nimport { type EdgeRegistration, type NodeRegistration } from \"../core/types\";\nimport { UniquenessError } from \"../errors\";\nimport { type KindRegistry } from \"../registry/kind-registry\";\nimport {\n createNodeBatchValidationBackend,\n type NodeCreateDraft,\n primeBatchValidationCaches,\n} from \"../store/operations/node-operations\";\nimport {\n applyNodeInsertSideEffects,\n applyNodeInsertSideEffectsBatch,\n applyNodeUpdate,\n} from \"../store/operations/node-write-pipeline\";\nimport { runInWriteTransaction } from \"../store/operations/write-transaction\";\nimport { type GraphWriteLock } from \"../store/recorded-capture/clock\";\nimport { type Store } from \"../store/store\";\nimport { checkUniquenessConstraints } from \"../store/uniqueness\";\nimport { validateOptionalCanonicalIsoDate } from \"../utils/date\";\nimport {\n type GraphData,\n type GraphDataHeader,\n type GraphInterchangeChunk,\n type ImportError,\n type ImportOptions,\n ImportOptionsSchema,\n type ImportResult,\n type InterchangeEdge,\n type InterchangeNode,\n type ResolvedImportOptions,\n type UnknownPropertyStrategy,\n} from \"./types\";\n\n// ============================================================\n// Import Function\n// ============================================================\n\n/**\n * Import graph data into a store.\n *\n * Nodes are imported first to satisfy edge reference validation.\n * The import runs within a transaction for atomicity when supported.\n *\n * @param store - The graph store to import into\n * @param data - Graph data in interchange format\n * @param options - Import configuration\n * @returns Import statistics and any errors\n *\n * @example\n * ```typescript\n * const result = await importGraph(store, data, {\n * onConflict: \"update\",\n * onUnknownProperty: \"strip\",\n * });\n *\n * console.log(`Created ${result.nodes.created} nodes`);\n * ```\n */\nexport async function importGraph<G extends GraphDef>(\n store: Store<G>,\n data: GraphData,\n rawOptions: ImportOptions,\n): Promise<ImportResult> {\n // Parse ONCE at the public boundary: schema defaults (batchSize, ...)\n // only exist after parsing, and every internal stage reads them\n // directly.\n const options = ImportOptionsSchema.parse(rawOptions);\n const result = emptyImportResult();\n\n const errors: ImportError[] = [];\n const graph = store.graph;\n const graphId = store.graphId;\n const backend = store.backend;\n const registry = store.registry;\n\n // Build lookup maps for schema validation\n const nodeSchemas = buildNodeSchemaMap(graph);\n const edgeSchemas = buildEdgeSchemaMap(graph);\n\n // Track imported node IDs for reference validation\n const importedNodeIds = new Set<string>();\n\n // One transaction on a transactional backend; runs directly otherwise, with\n // the per-graph write lock taken before any row work — see\n // runInWriteTransaction for the shared lock-before-rows contract every\n // writer follows.\n await runInWriteTransaction(store, backend, async (target, lock) => {\n await processNodes(\n target,\n graphId,\n registry,\n data.nodes,\n nodeSchemas,\n options,\n result,\n errors,\n importedNodeIds,\n lock,\n );\n await processEdges(\n target,\n graphId,\n registry,\n data.edges,\n edgeSchemas,\n nodeSchemas,\n options,\n result,\n errors,\n importedNodeIds,\n );\n });\n\n // A bulk load runs against stale planner statistics until ANALYZE runs\n // (documented regressions: 0.5ms → 5ms traversals on Postgres, 0.9ms →\n // 23ms fulltext on SQLite), so a mutating import refreshes them once,\n // after the transaction commits.\n //\n // Best-effort: by this point the import is committed, so a failed\n // statistics refresh must not convert the completed (non-atomic on some\n // backends, non-retryable) import into a thrown failure — it degrades to\n // a warning, and the caller can run `store.refreshStatistics()`.\n await refreshStatisticsAfterImport(store, options, result, \"importGraph\");\n\n return {\n ...result,\n success: errors.length === 0,\n errors,\n };\n}\n\n/**\n * Imports a header-first stream of bounded interchange chunks.\n *\n * Each chunk is committed through the same {@link importGraph} implementation\n * as an in-memory import, so validation and conflict semantics stay identical.\n * Chunks are individually atomic on transactional backends; a consumer needing\n * all-or-nothing behavior can import into a disposable working-copy backend and\n * publish it only after this function succeeds.\n *\n * Nodes must precede edges. Once a node chunk commits, edge validation reads the\n * target store rather than retaining every imported node id in memory.\n */\nexport async function importGraphStream<G extends GraphDef>(\n store: Store<G>,\n chunks: AsyncIterable<GraphInterchangeChunk>,\n rawOptions: ImportOptions,\n): Promise<ImportResult> {\n const options = ImportOptionsSchema.parse(rawOptions);\n const result = emptyImportResult();\n let header: GraphDataHeader | undefined;\n let receivedEdges = false;\n\n for await (const chunk of chunks) {\n switch (chunk.type) {\n case \"header\": {\n if (header !== undefined) {\n throw new Error(\n \"Graph interchange stream emitted more than one header.\",\n );\n }\n header = chunk.header;\n break;\n }\n case \"nodes\": {\n if (header === undefined) {\n throw new Error(\"Graph interchange stream must start with a header.\");\n }\n if (receivedEdges) {\n throw new Error(\n \"Graph interchange stream cannot emit nodes after edges.\",\n );\n }\n if (chunk.nodes.length === 0) break;\n mergeImportResult(\n result,\n await importGraph(store, graphDataForChunk(header, chunk.nodes, []), {\n ...options,\n refreshStatistics: false,\n }),\n );\n throwIfStreamChunkFailed(result, options);\n break;\n }\n case \"edges\": {\n if (header === undefined) {\n throw new Error(\"Graph interchange stream must start with a header.\");\n }\n receivedEdges = true;\n if (chunk.edges.length === 0) break;\n mergeImportResult(\n result,\n await importGraph(store, graphDataForChunk(header, [], chunk.edges), {\n ...options,\n refreshStatistics: false,\n }),\n );\n throwIfStreamChunkFailed(result, options);\n break;\n }\n }\n }\n\n if (header === undefined) {\n throw new Error(\"Graph interchange stream ended before emitting a header.\");\n }\n await refreshStatisticsAfterImport(\n store,\n options,\n result,\n \"importGraphStream\",\n );\n return { ...result, success: result.errors.length === 0 };\n}\n\nfunction throwIfStreamChunkFailed(\n result: ImportResult,\n options: ResolvedImportOptions,\n): void {\n if (options.onStreamChunkError === \"continue\" || result.errors.length === 0) {\n return;\n }\n throw new Error(\n \"Graph interchange stream aborted after a chunk reported import errors. \" +\n 'Earlier chunks remain committed; use onStreamChunkError: \"continue\" for best-effort ingestion.',\n );\n}\n\nfunction emptyImportResult(): ImportResult {\n return {\n success: true,\n nodes: { created: 0, updated: 0, skipped: 0 },\n edges: { created: 0, updated: 0, skipped: 0 },\n errors: [],\n };\n}\n\nfunction graphDataForChunk(\n header: GraphDataHeader,\n nodes: GraphData[\"nodes\"],\n edges: GraphData[\"edges\"],\n): GraphData {\n return { ...header, nodes, edges };\n}\nfunction mergeImportResult(target: ImportResult, source: ImportResult): void {\n target.nodes.created += source.nodes.created;\n target.nodes.updated += source.nodes.updated;\n target.nodes.skipped += source.nodes.skipped;\n target.edges.created += source.edges.created;\n target.edges.updated += source.edges.updated;\n target.edges.skipped += source.edges.skipped;\n target.errors.push(...source.errors);\n}\n\nasync function refreshStatisticsAfterImport<G extends GraphDef>(\n store: Store<G>,\n options: ResolvedImportOptions,\n result: ImportResult,\n surface: \"importGraph\" | \"importGraphStream\",\n): Promise<void> {\n const mutationCount =\n result.nodes.created +\n result.nodes.updated +\n result.edges.created +\n result.edges.updated;\n if ((options.refreshStatistics ?? true) && mutationCount > 0) {\n try {\n await store.refreshStatistics();\n } catch (error) {\n if (\n typeof console !== \"undefined\" &&\n typeof console.warn === \"function\"\n ) {\n console.warn(\n `[typegraph] ${surface} committed its rows but the follow-up ` +\n \"statistics refresh failed; run store.refreshStatistics() to \" +\n \"give the planner fresh statistics.\",\n error,\n );\n }\n }\n }\n}\n\n// ============================================================\n// Schema Maps\n// ============================================================\n\ntype NodeSchemaEntry = Readonly<{\n registration: NodeRegistration;\n schema: z.ZodObject<z.ZodRawShape>;\n}>;\n\ntype EdgeSchemaEntry = Readonly<{\n registration: EdgeRegistration;\n schema: z.ZodObject<z.ZodRawShape>;\n}>;\n\nfunction buildNodeSchemaMap(\n graph: GraphDef,\n): ReadonlyMap<string, NodeSchemaEntry> {\n const map = new Map<string, NodeSchemaEntry>();\n\n for (const kindName of getNodeKinds(graph)) {\n const registration = graph.nodes[kindName] as NodeRegistration;\n map.set(kindName, {\n registration,\n schema: registration.type.schema,\n });\n }\n\n return map;\n}\n\nfunction buildEdgeSchemaMap(\n graph: GraphDef,\n): ReadonlyMap<string, EdgeSchemaEntry> {\n const map = new Map<string, EdgeSchemaEntry>();\n\n for (const kindName of getEdgeKinds(graph)) {\n const registration = graph.edges[kindName] as EdgeRegistration;\n map.set(kindName, {\n registration,\n schema: registration.type.schema,\n });\n }\n\n return map;\n}\n\n// ============================================================\n// Node Processing\n// ============================================================\n\nasync function processNodes(\n backend: GraphBackend | TransactionBackend,\n graphId: string,\n registry: KindRegistry,\n nodes: readonly InterchangeNode[],\n schemas: ReadonlyMap<string, NodeSchemaEntry>,\n options: ResolvedImportOptions,\n result: ImportResult,\n errors: ImportError[],\n importedNodeIds: Set<string>,\n lock: GraphWriteLock,\n): Promise<void> {\n const batchSize = options.batchSize;\n\n for (let index = 0; index < nodes.length; index += batchSize) {\n const batch = nodes.slice(index, index + batchSize);\n await processNodeSlice(\n backend,\n graphId,\n registry,\n batch,\n schemas,\n options,\n result,\n errors,\n importedNodeIds,\n lock,\n );\n }\n}\n\nfunction recordNodeOutcome(\n node: InterchangeNode,\n outcome: ProcessResult,\n result: ImportResult,\n errors: ImportError[],\n importedNodeIds: Set<string>,\n): void {\n switch (outcome.status) {\n case \"created\": {\n result.nodes.created++;\n importedNodeIds.add(makeNodeKey(node.kind, node.id));\n break;\n }\n case \"updated\": {\n result.nodes.updated++;\n importedNodeIds.add(makeNodeKey(node.kind, node.id));\n break;\n }\n case \"skipped\": {\n result.nodes.skipped++;\n // A live skipped row is still a valid edge endpoint; a tombstone\n // is not.\n if (outcome.liveTarget) {\n importedNodeIds.add(makeNodeKey(node.kind, node.id));\n }\n break;\n }\n case \"error\": {\n errors.push({\n entityType: \"node\",\n kind: node.kind,\n id: node.id,\n error: outcome.error,\n });\n break;\n }\n }\n}\n\ntype NodeImportCandidate = Readonly<{\n node: InterchangeNode;\n schemaEntry: NodeSchemaEntry;\n props: Record<string, unknown>;\n draft: NodeCreateDraft;\n}>;\n\n/**\n * Processes one batchSize slice of nodes with batched round trips:\n * one `getNodes` per kind for existence, one `checkUniqueBatch` per\n * (constraint, kind) for uniqueness pre-checks (both priming the shared\n * batch validation caches), then one multi-row insert and one batched\n * side-effect pass for the accepted creates. Per-row semantics are\n * unchanged — conflicts route by `onConflict`, a uniqueness conflict is a\n * per-row error entry, and rows repeating an id already seen in the slice\n * defer to the per-row path after the flush (so they observe the first\n * occurrence's row exactly as the sequential implementation did).\n */\nasync function processNodeSlice(\n backend: GraphBackend | TransactionBackend,\n graphId: string,\n registry: KindRegistry,\n batch: readonly InterchangeNode[],\n schemas: ReadonlyMap<string, NodeSchemaEntry>,\n options: ResolvedImportOptions,\n result: ImportResult,\n errors: ImportError[],\n importedNodeIds: Set<string>,\n lock: GraphWriteLock,\n): Promise<void> {\n const record = (node: InterchangeNode, outcome: ProcessResult): void => {\n recordNodeOutcome(node, outcome, result, errors, importedNodeIds);\n };\n\n // Pass 1 (synchronous): kind + property + validity validation, and\n // in-slice duplicate deferral.\n const candidates: NodeImportCandidate[] = [];\n const deferred: InterchangeNode[] = [];\n const seenKeys = new Set<string>();\n for (const node of batch) {\n const schemaEntry = schemas.get(node.kind);\n if (!schemaEntry) {\n record(node, {\n status: \"error\",\n error: `Unknown node kind: ${node.kind}`,\n });\n continue;\n }\n const propsResult = validateProperties(\n node.properties,\n schemaEntry.schema,\n options.onUnknownProperty,\n );\n if (!propsResult.success) {\n record(node, { status: \"error\", error: propsResult.error });\n continue;\n }\n const validityError = validateValidityWindow(node);\n if (validityError !== undefined) {\n record(node, { status: \"error\", error: validityError });\n continue;\n }\n const key = makeNodeKey(node.kind, node.id);\n if (seenKeys.has(key)) {\n deferred.push(node);\n continue;\n }\n seenKeys.add(key);\n candidates.push({\n node,\n schemaEntry,\n props: propsResult.data,\n draft: {\n kind: node.kind,\n id: node.id,\n nodeKind: schemaEntry.registration.type,\n uniqueConstraints: schemaEntry.registration.unique ?? [],\n validatedProps: propsResult.data,\n // NodeCreateDraft.validFrom is string | undefined (never null) — it\n // only feeds batch validation-cache priming, which never inspects\n // it, so normalizing the explicit-NULL sentinel away here is inert.\n // The actual insert (buildImportInsertParams) reads node.validFrom\n // directly and preserves the null.\n validFrom: node.validFrom ?? undefined,\n validTo: node.validTo,\n },\n });\n }\n\n // Prime the validation caches with batched reads, then route each row\n // against memory in input order.\n const {\n backend: validationBackend,\n registerPendingNode,\n registerPendingUniqueEntries,\n registerAppliedNodeUpdate,\n seedNodeRow,\n seedUniqueRow,\n } = createNodeBatchValidationBackend(graphId, registry, backend);\n await primeBatchValidationCaches(\n { graphId, registry },\n candidates.map((candidate) => candidate.draft),\n backend,\n { seedNodeRow, seedUniqueRow },\n );\n\n const writeContext = { graphId, registry, lock };\n const accepted: NodeImportCandidate[] = [];\n for (const candidate of candidates) {\n const { node, schemaEntry, props } = candidate;\n const uniqueConstraints = schemaEntry.registration.unique ?? [];\n const existing = await validationBackend.getNode(\n graphId,\n node.kind,\n node.id,\n );\n\n if (existing) {\n switch (options.onConflict) {\n case \"skip\": {\n record(node, {\n status: \"skipped\",\n liveTarget: isLiveNodeRow(existing),\n });\n break;\n }\n case \"error\": {\n record(node, {\n status: \"error\",\n error: `Node already exists: ${node.kind}:${node.id}`,\n });\n break;\n }\n case \"update\": {\n if (!isLiveNodeRow(existing)) {\n // Import never resurrects a tombstone — see processNode.\n record(node, { status: \"skipped\", liveTarget: false });\n break;\n }\n const updateResult = await catchUniquenessError(() =>\n applyNodeUpdate(\n writeContext,\n {\n existing,\n schema: schemaEntry.registration.type.schema,\n validatedProps: props,\n uniqueConstraints,\n ...(node.validTo !== undefined && { validTo: node.validTo }),\n },\n // The pending-aware overlay, not the raw backend: the update's\n // uniqueness pre-check must see a unique value already reserved by\n // an unflushed create EARLIER in this slice, so it degrades to a\n // per-row error exactly as the sequential path does — rather than\n // claiming the key on the real backend and colliding with that\n // create at flush (which would throw and roll back the whole\n // import). Writes still delegate to the real backend.\n validationBackend,\n ),\n );\n if (updateResult.ok) {\n // The update mutated the real backend's uniqueness rows directly;\n // reconcile the shared prime caches so a later create in this\n // slice sees the post-update reservation state (matching the\n // sequential path). See registerAppliedNodeUpdate.\n registerAppliedNodeUpdate(\n node.kind,\n node.id,\n rowPropsToObject(existing.props),\n props,\n uniqueConstraints,\n );\n }\n record(\n node,\n updateResult.ok ?\n { status: \"updated\" }\n : { status: \"error\", error: updateResult.error },\n );\n break;\n }\n }\n continue;\n }\n\n const uniquenessResult = await catchUniquenessError(() =>\n checkUniquenessConstraints(\n { graphId, registry, backend: validationBackend },\n node.kind,\n node.id,\n props,\n uniqueConstraints,\n ),\n );\n if (!uniquenessResult.ok) {\n record(node, { status: \"error\", error: uniquenessResult.error });\n continue;\n }\n\n registerPendingNode(buildImportInsertParams(graphId, candidate));\n registerPendingUniqueEntries(node.kind, node.id, props, uniqueConstraints);\n accepted.push(candidate);\n }\n\n // Flush the accepted creates: one multi-row insert, then the batched\n // side effects (uniqueness entries, fulltext, embeddings).\n if (accepted.length > 0) {\n const insertParamsList = accepted.map((candidate) =>\n buildImportInsertParams(graphId, candidate),\n );\n if (backend.insertNodesBatch === undefined) {\n for (const params of insertParamsList) {\n await backend.insertNode(params);\n }\n } else {\n await backend.insertNodesBatch(insertParamsList);\n }\n await applyNodeInsertSideEffectsBatch(\n writeContext,\n accepted.map((candidate) => ({\n kind: candidate.node.kind,\n id: candidate.node.id,\n schema: candidate.schemaEntry.registration.type.schema,\n props: candidate.props,\n uniqueConstraints: candidate.schemaEntry.registration.unique ?? [],\n })),\n backend,\n );\n for (const candidate of accepted) {\n record(candidate.node, { status: \"created\" });\n }\n }\n\n // In-slice duplicate ids run per-row AFTER the flush so they observe the\n // first occurrence's committed row, exactly as the sequential path did.\n for (const node of deferred) {\n record(\n node,\n await processNode(\n backend,\n graphId,\n registry,\n node,\n schemas,\n options,\n lock,\n ),\n );\n }\n}\n\nfunction buildImportInsertParams(\n graphId: string,\n candidate: NodeImportCandidate,\n): Parameters<GraphBackend[\"insertNode\"]>[0] {\n const { node, props } = candidate;\n return {\n graphId,\n kind: node.kind,\n id: node.id,\n props,\n ...(node.validFrom !== undefined && { validFrom: node.validFrom }),\n ...(node.validTo !== undefined && { validTo: node.validTo }),\n };\n}\n\ntype ProcessResult =\n | { status: \"created\" }\n | { status: \"updated\" }\n /**\n * `liveTarget` distinguishes \"skipped because a LIVE row already exists\"\n * (a valid edge endpoint) from \"skipped because the row is a tombstone\"\n * (which must NOT be recorded as available — a live edge pointing at a\n * soft-deleted node violates the endpoint-liveness invariant the\n * collection API enforces).\n */\n | { status: \"skipped\"; liveTarget: boolean }\n | { status: \"error\"; error: string };\n\ntype UniquenessGuardResult<T> =\n Readonly<{ ok: true; value: T }> | Readonly<{ ok: false; error: string }>;\n\n/**\n * Runs `fn` and reports a `UniquenessError` as a per-row result instead of\n * letting it abort the whole import — the same recovery both the node\n * uniqueness pre-check and the update path need. Any other error still\n * propagates.\n */\nasync function catchUniquenessError<T>(\n fn: () => Promise<T>,\n): Promise<UniquenessGuardResult<T>> {\n try {\n return { ok: true, value: await fn() };\n } catch (error) {\n if (error instanceof UniquenessError) {\n return { ok: false, error: error.message };\n }\n throw error;\n }\n}\n\n/**\n * Validates an entity's validity-window timestamps against the canonical\n * fixed-width UTC ISO-8601 contract that `create` / `update` enforce, so no\n * import write path can persist a non-canonical `valid_from` / `valid_to` that\n * later mis-sorts as text against an `asOf` read coordinate. The interchange\n * schema enforces the same contract at the parse boundary, but `importGraph`\n * accepts a pre-typed `GraphData` and does not re-parse it, so this is the\n * guarantee for callers that bypass the schema. Returns a per-row error message\n * (recorded in the import result) instead of throwing, so one malformed row\n * does not abort the whole import.\n */\nfunction validateValidityWindow(\n entity: Readonly<{\n validFrom?: string | null | undefined;\n validTo?: string | undefined;\n }>,\n): string | undefined {\n try {\n // null is a confirmed open-left window (see InterchangeNodeSchema's\n // validFrom doc), not a value to format-check — treat it like\n // \"not provided\" here, same as the canonical-date validator does.\n validateOptionalCanonicalIsoDate(\n entity.validFrom ?? undefined,\n \"validFrom\",\n );\n validateOptionalCanonicalIsoDate(entity.validTo, \"validTo\");\n return undefined;\n } catch (error) {\n return error instanceof Error ? error.message : String(error);\n }\n}\n\nasync function processNode(\n backend: GraphBackend | TransactionBackend,\n graphId: string,\n registry: KindRegistry,\n node: InterchangeNode,\n schemas: ReadonlyMap<string, NodeSchemaEntry>,\n options: ResolvedImportOptions,\n lock: GraphWriteLock,\n): Promise<ProcessResult> {\n // Validate kind exists\n const schemaEntry = schemas.get(node.kind);\n if (!schemaEntry) {\n return { status: \"error\", error: `Unknown node kind: ${node.kind}` };\n }\n\n // Validate and transform properties\n const propsResult = validateProperties(\n node.properties,\n schemaEntry.schema,\n options.onUnknownProperty,\n );\n\n if (!propsResult.success) {\n return { status: \"error\", error: propsResult.error };\n }\n\n const validityError = validateValidityWindow(node);\n if (validityError !== undefined) {\n return { status: \"error\", error: validityError };\n }\n\n const { registration } = schemaEntry;\n const uniqueConstraints = registration.unique ?? [];\n const writeContext = { graphId, registry, lock };\n\n // Check if node already exists\n const existing = await backend.getNode(graphId, node.kind, node.id);\n\n if (existing) {\n switch (options.onConflict) {\n case \"skip\": {\n return { status: \"skipped\", liveTarget: isLiveNodeRow(existing) };\n }\n case \"error\": {\n return {\n status: \"error\",\n error: `Node already exists: ${node.kind}:${node.id}`,\n };\n }\n case \"update\": {\n if (!isLiveNodeRow(existing)) {\n // A soft-deleted node is not updatable: import never resurrects a\n // tombstone, and running the live-row update pipeline here would\n // recreate uniqueness/embedding/fulltext rows for a node that\n // stays invisible — a uniqueness reservation held by a tombstoned\n // node would block live creates of the same value.\n return { status: \"skipped\", liveTarget: false };\n }\n // Route through the shared write step so the update maintains\n // uniqueness entries, embeddings, and fulltext — the collection API's\n // integrity, which a raw backend.updateNode would skip. A uniqueness\n // conflict is reported per-row (updateUniquenessEntries throws before\n // the row is written, so no partial write escapes).\n const updateResult = await catchUniquenessError(() =>\n applyNodeUpdate(\n writeContext,\n {\n existing,\n schema: registration.type.schema,\n validatedProps: propsResult.data,\n uniqueConstraints,\n ...(node.validTo !== undefined && { validTo: node.validTo }),\n },\n backend,\n ),\n );\n if (!updateResult.ok) {\n return { status: \"error\", error: updateResult.error };\n }\n return { status: \"updated\" };\n }\n }\n }\n\n // Create new node. Pre-check uniqueness (as the collection create does) so a\n // conflict is a per-row error rather than an orphaned node row, then apply the\n // integrity side effects the raw backend.insertNode would otherwise bypass.\n const uniquenessResult = await catchUniquenessError(() =>\n checkUniquenessConstraints(\n { graphId, registry, backend },\n node.kind,\n node.id,\n propsResult.data,\n uniqueConstraints,\n ),\n );\n if (!uniquenessResult.ok) {\n return { status: \"error\", error: uniquenessResult.error };\n }\n\n await backend.insertNode({\n graphId,\n kind: node.kind,\n id: node.id,\n props: propsResult.data,\n ...(node.validFrom !== undefined && { validFrom: node.validFrom }),\n ...(node.validTo !== undefined && { validTo: node.validTo }),\n });\n await applyNodeInsertSideEffects(\n writeContext,\n {\n kind: node.kind,\n id: node.id,\n schema: registration.type.schema,\n props: propsResult.data,\n uniqueConstraints,\n },\n backend,\n );\n\n return { status: \"created\" };\n}\n\n// ============================================================\n// Edge Processing\n// ============================================================\n\nasync function processEdges(\n backend: GraphBackend | TransactionBackend,\n graphId: string,\n registry: KindRegistry,\n edges: readonly InterchangeEdge[],\n edgeSchemas: ReadonlyMap<string, EdgeSchemaEntry>,\n nodeSchemas: ReadonlyMap<string, NodeSchemaEntry>,\n options: ResolvedImportOptions,\n result: ImportResult,\n errors: ImportError[],\n importedNodeIds: Set<string>,\n): Promise<void> {\n const batchSize = options.batchSize;\n\n for (let index = 0; index < edges.length; index += batchSize) {\n const batch = edges.slice(index, index + batchSize);\n await processEdgeSlice(\n backend,\n graphId,\n registry,\n batch,\n edgeSchemas,\n nodeSchemas,\n options,\n result,\n errors,\n importedNodeIds,\n );\n }\n}\n\nfunction recordEdgeOutcome(\n edge: InterchangeEdge,\n outcome: ProcessResult,\n result: ImportResult,\n errors: ImportError[],\n): void {\n switch (outcome.status) {\n case \"created\": {\n result.edges.created++;\n break;\n }\n case \"updated\": {\n result.edges.updated++;\n break;\n }\n case \"skipped\": {\n result.edges.skipped++;\n break;\n }\n case \"error\": {\n errors.push({\n entityType: \"edge\",\n kind: edge.kind,\n id: edge.id,\n error: outcome.error,\n });\n break;\n }\n }\n}\n\ntype EdgeImportCandidate = Readonly<{\n edge: InterchangeEdge;\n props: Record<string, unknown>;\n}>;\n\n/**\n * Processes one batchSize slice of edges with batched round trips: one\n * `getNodes` per endpoint kind for reference liveness, one `getEdges` for\n * existence, and one multi-row insert for the accepted creates. Per-row\n * semantics are unchanged; duplicate ids within a slice defer to the\n * per-row path after the flush.\n */\nasync function processEdgeSlice(\n backend: GraphBackend | TransactionBackend,\n graphId: string,\n registry: KindRegistry,\n batch: readonly InterchangeEdge[],\n edgeSchemas: ReadonlyMap<string, EdgeSchemaEntry>,\n nodeSchemas: ReadonlyMap<string, NodeSchemaEntry>,\n options: ResolvedImportOptions,\n result: ImportResult,\n errors: ImportError[],\n importedNodeIds: Set<string>,\n): Promise<void> {\n const record = (edge: InterchangeEdge, outcome: ProcessResult): void => {\n recordEdgeOutcome(edge, outcome, result, errors);\n };\n\n // Pass 1 (synchronous): kind, endpoint-kind, endpoint-assignability,\n // property, and validity validation, plus in-slice duplicate deferral.\n const candidates: EdgeImportCandidate[] = [];\n const deferred: InterchangeEdge[] = [];\n const seenIds = new Set<string>();\n for (const edge of batch) {\n const schemaEntry = edgeSchemas.get(edge.kind);\n if (!schemaEntry) {\n record(edge, {\n status: \"error\",\n error: `Unknown edge kind: ${edge.kind}`,\n });\n continue;\n }\n if (!nodeSchemas.has(edge.from.kind)) {\n record(edge, {\n status: \"error\",\n error: `Unknown from node kind: ${edge.from.kind}`,\n });\n continue;\n }\n if (!nodeSchemas.has(edge.to.kind)) {\n record(edge, {\n status: \"error\",\n error: `Unknown to node kind: ${edge.to.kind}`,\n });\n continue;\n }\n const endpointError = validateEdgeEndpoints(\n edge.kind,\n edge.from.kind,\n edge.to.kind,\n schemaEntry.registration,\n registry,\n );\n if (endpointError !== undefined) {\n record(edge, { status: \"error\", error: endpointError.message });\n continue;\n }\n const propsResult = validateProperties(\n edge.properties,\n schemaEntry.schema,\n options.onUnknownProperty,\n );\n if (!propsResult.success) {\n record(edge, { status: \"error\", error: propsResult.error });\n continue;\n }\n const validityError = validateValidityWindow(edge);\n if (validityError !== undefined) {\n record(edge, { status: \"error\", error: validityError });\n continue;\n }\n if (seenIds.has(edge.id)) {\n deferred.push(edge);\n continue;\n }\n seenIds.add(edge.id);\n candidates.push({ edge, props: propsResult.data });\n }\n\n // Batch the endpoint-liveness reads: one getNodes per endpoint kind for\n // every key the import itself didn't create. Falls back to per-row\n // getNode inside the routing loop when the backend lacks getNodes.\n const liveEndpointKeys = new Set<string>();\n const checkedEndpointKeys = new Set<string>();\n if (options.validateReferences && backend.getNodes !== undefined) {\n const idsByKind = new Map<string, Set<string>>();\n for (const { edge } of candidates) {\n for (const endpoint of [edge.from, edge.to]) {\n const key = makeNodeKey(endpoint.kind, endpoint.id);\n if (importedNodeIds.has(key) || checkedEndpointKeys.has(key)) continue;\n checkedEndpointKeys.add(key);\n const ids = idsByKind.get(endpoint.kind) ?? new Set<string>();\n ids.add(endpoint.id);\n idsByKind.set(endpoint.kind, ids);\n }\n }\n for (const [kind, ids] of idsByKind) {\n const rows = await backend.getNodes(graphId, kind, [...ids]);\n for (const row of rows) {\n if (isLiveNodeRow(row)) {\n liveEndpointKeys.add(makeNodeKey(kind, row.id));\n }\n }\n }\n }\n\n const endpointIsLive = async (endpoint: {\n kind: string;\n id: string;\n }): Promise<boolean> => {\n const key = makeNodeKey(endpoint.kind, endpoint.id);\n if (importedNodeIds.has(key)) return true;\n if (checkedEndpointKeys.has(key)) return liveEndpointKeys.has(key);\n const row = await backend.getNode(graphId, endpoint.kind, endpoint.id);\n return row !== undefined && isLiveNodeRow(row);\n };\n\n // Batch the existence reads. Falls back to per-row getEdge when the\n // backend lacks getEdges.\n const existingById = new Map<\n string,\n Awaited<ReturnType<GraphBackend[\"getEdge\"]>>\n >();\n if (candidates.length > 0 && backend.getEdges !== undefined) {\n const rows = await backend.getEdges(\n graphId,\n candidates.map((candidate) => candidate.edge.id),\n );\n for (const row of rows) {\n existingById.set(row.id, row);\n }\n for (const { edge } of candidates) {\n if (!existingById.has(edge.id)) existingById.set(edge.id, undefined);\n }\n }\n\n const accepted: EdgeImportCandidate[] = [];\n for (const candidate of candidates) {\n const { edge, props } = candidate;\n\n if (options.validateReferences) {\n if (!(await endpointIsLive(edge.from))) {\n record(edge, {\n status: \"error\",\n error: `From node not found: ${edge.from.kind}:${edge.from.id}`,\n });\n continue;\n }\n if (!(await endpointIsLive(edge.to))) {\n record(edge, {\n status: \"error\",\n error: `To node not found: ${edge.to.kind}:${edge.to.id}`,\n });\n continue;\n }\n }\n\n const existing =\n existingById.has(edge.id) ?\n existingById.get(edge.id)\n : await backend.getEdge(graphId, edge.id);\n\n if (existing) {\n switch (options.onConflict) {\n case \"skip\": {\n record(edge, {\n status: \"skipped\",\n liveTarget: existing.deleted_at === undefined,\n });\n break;\n }\n case \"error\": {\n record(edge, {\n status: \"error\",\n error: `Edge already exists: ${edge.id}`,\n });\n break;\n }\n case \"update\": {\n if (existing.deleted_at !== undefined) {\n record(edge, { status: \"skipped\", liveTarget: false });\n break;\n }\n await backend.updateEdge({\n graphId,\n id: edge.id,\n props,\n ...(edge.validTo !== undefined && { validTo: edge.validTo }),\n });\n record(edge, { status: \"updated\" });\n break;\n }\n }\n continue;\n }\n\n accepted.push(candidate);\n }\n\n if (accepted.length > 0) {\n const insertParamsList = accepted.map(({ edge, props }) => ({\n graphId,\n id: edge.id,\n kind: edge.kind,\n fromKind: edge.from.kind,\n fromId: edge.from.id,\n toKind: edge.to.kind,\n toId: edge.to.id,\n props,\n ...(edge.validFrom !== undefined && { validFrom: edge.validFrom }),\n ...(edge.validTo !== undefined && { validTo: edge.validTo }),\n }));\n if (backend.insertEdgesBatch === undefined) {\n for (const params of insertParamsList) {\n await backend.insertEdge(params);\n }\n } else {\n await backend.insertEdgesBatch(insertParamsList);\n }\n for (const candidate of accepted) {\n record(candidate.edge, { status: \"created\" });\n }\n }\n\n for (const edge of deferred) {\n record(\n edge,\n await processEdge(\n backend,\n graphId,\n registry,\n edge,\n edgeSchemas,\n nodeSchemas,\n options,\n importedNodeIds,\n ),\n );\n }\n}\n\nasync function processEdge(\n backend: GraphBackend | TransactionBackend,\n graphId: string,\n registry: KindRegistry,\n edge: InterchangeEdge,\n edgeSchemas: ReadonlyMap<string, EdgeSchemaEntry>,\n nodeSchemas: ReadonlyMap<string, NodeSchemaEntry>,\n options: ResolvedImportOptions,\n importedNodeIds: Set<string>,\n): Promise<ProcessResult> {\n // Validate edge kind exists\n const schemaEntry = edgeSchemas.get(edge.kind);\n if (!schemaEntry) {\n return { status: \"error\", error: `Unknown edge kind: ${edge.kind}` };\n }\n\n // Validate endpoint kinds exist\n if (!nodeSchemas.has(edge.from.kind)) {\n return {\n status: \"error\",\n error: `Unknown from node kind: ${edge.from.kind}`,\n };\n }\n if (!nodeSchemas.has(edge.to.kind)) {\n return { status: \"error\", error: `Unknown to node kind: ${edge.to.kind}` };\n }\n\n // Validate endpoint kinds are allowed for this edge type. Uses the shared,\n // subclass-aware check (registry.isAssignableTo) that the collection API uses,\n // so an edge whose endpoint is a subclass of a declared kind — legal in the\n // store and emitted verbatim by export — imports cleanly instead of being\n // rejected by an exact-kind comparison.\n const endpointError = validateEdgeEndpoints(\n edge.kind,\n edge.from.kind,\n edge.to.kind,\n schemaEntry.registration,\n registry,\n );\n if (endpointError !== undefined) {\n return { status: \"error\", error: endpointError.message };\n }\n\n // Validate references exist (in DB or in import batch)\n if (options.validateReferences) {\n const fromKey = makeNodeKey(edge.from.kind, edge.from.id);\n const toKey = makeNodeKey(edge.to.kind, edge.to.id);\n\n // Check import batch first, then DB. The DB row must be LIVE: getNode\n // returns tombstones, and inserting an edge whose endpoint is\n // soft-deleted would bypass the endpoint-liveness invariant the\n // collection API enforces.\n if (!importedNodeIds.has(fromKey)) {\n const fromExists = await backend.getNode(\n graphId,\n edge.from.kind,\n edge.from.id,\n );\n if (fromExists === undefined || !isLiveNodeRow(fromExists)) {\n return {\n status: \"error\",\n error: `From node not found: ${edge.from.kind}:${edge.from.id}`,\n };\n }\n }\n\n if (!importedNodeIds.has(toKey)) {\n const toExists = await backend.getNode(graphId, edge.to.kind, edge.to.id);\n if (toExists === undefined || !isLiveNodeRow(toExists)) {\n return {\n status: \"error\",\n error: `To node not found: ${edge.to.kind}:${edge.to.id}`,\n };\n }\n }\n }\n\n // Validate and transform properties\n const propsResult = validateProperties(\n edge.properties,\n schemaEntry.schema,\n options.onUnknownProperty,\n );\n\n if (!propsResult.success) {\n return { status: \"error\", error: propsResult.error };\n }\n\n const validityError = validateValidityWindow(edge);\n if (validityError !== undefined) {\n return { status: \"error\", error: validityError };\n }\n\n // Check if edge already exists\n const existing = await backend.getEdge(graphId, edge.id);\n\n if (existing) {\n switch (options.onConflict) {\n case \"skip\": {\n return {\n status: \"skipped\",\n liveTarget: existing.deleted_at === undefined,\n };\n }\n case \"error\": {\n return { status: \"error\", error: `Edge already exists: ${edge.id}` };\n }\n case \"update\": {\n // Same contract as nodes: import never resurrects a tombstone, and\n // the backend's update targets live rows only.\n if (existing.deleted_at !== undefined) {\n return { status: \"skipped\", liveTarget: false };\n }\n await backend.updateEdge({\n graphId,\n id: edge.id,\n props: propsResult.data,\n ...(edge.validTo !== undefined && { validTo: edge.validTo }),\n });\n return { status: \"updated\" };\n }\n }\n }\n\n // Create new edge\n await backend.insertEdge({\n graphId,\n id: edge.id,\n kind: edge.kind,\n fromKind: edge.from.kind,\n fromId: edge.from.id,\n toKind: edge.to.kind,\n toId: edge.to.id,\n props: propsResult.data,\n ...(edge.validFrom !== undefined && { validFrom: edge.validFrom }),\n ...(edge.validTo !== undefined && { validTo: edge.validTo }),\n });\n\n return { status: \"created\" };\n}\n\n// ============================================================\n// Property Validation\n// ============================================================\n\ntype ValidationResult =\n | { success: true; data: Record<string, unknown> }\n | { success: false; error: string };\n\nfunction validateProperties(\n properties: Record<string, unknown>,\n schema: z.ZodObject<z.ZodRawShape>,\n unknownStrategy: UnknownPropertyStrategy,\n): ValidationResult {\n try {\n // Get the schema's known keys\n const knownKeys = new Set(Object.keys(schema.shape));\n\n // Check for unknown properties\n const unknownKeys = Object.keys(properties).filter(\n (key) => !knownKeys.has(key),\n );\n\n if (unknownKeys.length > 0) {\n switch (unknownStrategy) {\n case \"error\": {\n return {\n success: false,\n error: `Unknown properties: ${unknownKeys.join(\", \")}`,\n };\n }\n case \"strip\": {\n // Remove unknown properties\n const stripped: Record<string, unknown> = {};\n for (const key of knownKeys) {\n if (key in properties) {\n stripped[key] = properties[key];\n }\n }\n // Validate stripped properties\n const result = schema.safeParse(stripped);\n if (!result.success) {\n return {\n success: false,\n error: formatZodError(result.error),\n };\n }\n return {\n success: true,\n data: result.data,\n };\n }\n case \"allow\": {\n // Validate the known fields, then return the ORIGINAL properties\n // verbatim — unknown keys preserved, known values byte-for-byte.\n // Exported data already carries post-transform values, so\n // re-applying schema transforms here would corrupt every\n // export→import round trip whose transforms are not idempotent.\n // \"allow\" is the fidelity-preserving strategy; \"strip\" (and the\n // create path) remain the normalizing ones.\n const result = schema.safeParse(properties);\n if (!result.success) {\n return {\n success: false,\n error: formatZodError(result.error),\n };\n }\n return { success: true, data: properties };\n }\n }\n }\n\n // No unknown properties - standard validation\n const result = schema.safeParse(properties);\n if (!result.success) {\n return { success: false, error: formatZodError(result.error) };\n }\n\n return { success: true, data: result.data };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return { success: false, error: `Validation error: ${message}` };\n }\n}\n\nfunction formatZodError(error: z.ZodError): string {\n return error.issues\n .map((issue) => {\n const path = issue.path.join(\".\");\n return path ? `${path}: ${issue.message}` : issue.message;\n })\n .join(\"; \");\n}\n\n// ============================================================\n// Helpers\n// ============================================================\n\nfunction makeNodeKey(kind: string, id: string): string {\n return `${kind}:${id}`;\n}\n"]}
@@ -380,13 +380,15 @@ var STORE_NOT_INITIALIZED_REASON_PHRASE = {
380
380
  var StoreNotInitializedError = class extends TypeGraphError {
381
381
  // `graphId`/`reason` are positional and required: both are
382
382
  // load-bearing for the message and for programmatic handling via
383
- // `details.reason`. Caller `details` merge on top.
383
+ // `details.reason`. Caller `details` merge underneath — spread first
384
+ // so `graphId`/`reason` win and can't be clobbered by an
385
+ // accidentally-colliding extra key.
384
386
  constructor(graphId, reason, options) {
385
387
  super(
386
388
  `fulltext storage for graph "${graphId}" ${STORE_NOT_INITIALIZED_REASON_PHRASE[reason]}. Run createStoreWithSchema(graph, backend) during application boot, outside request handlers and adopted transactions, before using createStore().`,
387
389
  "STORE_NOT_INITIALIZED",
388
390
  {
389
- details: { graphId, reason, ...options?.details },
391
+ details: { ...options?.details, graphId, reason },
390
392
  category: "user",
391
393
  suggestion: "Call createStoreWithSchema(graph, backend) once at application startup. createStore() attaches to an already-initialized database and does not materialize storage itself.",
392
394
  cause: options?.cause
@@ -453,6 +455,20 @@ var BackendDisposedError = class extends TypeGraphError {
453
455
  this.name = "BackendDisposedError";
454
456
  }
455
457
  };
458
+ var TransactionClosedError = class extends TypeGraphError {
459
+ constructor(options) {
460
+ super(
461
+ "Statement issued on a transaction-scoped backend after its transaction boundary returned. The connection has been released; the statement was not run.",
462
+ "TRANSACTION_CLOSED",
463
+ {
464
+ category: "user",
465
+ suggestion: "Await every write started inside store.transaction(...) before the callback returns. Prefer awaiting a Promise.allSettled(...) over a Promise.all(...) whose rejection would orphan its siblings.",
466
+ cause: options?.cause
467
+ }
468
+ );
469
+ this.name = "TransactionClosedError";
470
+ }
471
+ };
456
472
  function isTypeGraphError(error) {
457
473
  return error instanceof TypeGraphError;
458
474
  }
@@ -491,6 +507,7 @@ exports.SchemaContentConflictError = SchemaContentConflictError;
491
507
  exports.SchemaMismatchError = SchemaMismatchError;
492
508
  exports.StaleVersionError = StaleVersionError;
493
509
  exports.StoreNotInitializedError = StoreNotInitializedError;
510
+ exports.TransactionClosedError = TransactionClosedError;
494
511
  exports.TypeGraphError = TypeGraphError;
495
512
  exports.UniquenessError = UniquenessError;
496
513
  exports.UnsupportedPredicateError = UnsupportedPredicateError;
@@ -501,5 +518,5 @@ exports.isConstraintError = isConstraintError;
501
518
  exports.isSystemError = isSystemError;
502
519
  exports.isTypeGraphError = isTypeGraphError;
503
520
  exports.isUserRecoverable = isUserRecoverable;
504
- //# sourceMappingURL=chunk-JIEJCTDS.cjs.map
505
- //# sourceMappingURL=chunk-JIEJCTDS.cjs.map
521
+ //# sourceMappingURL=chunk-LGEALRC6.cjs.map
522
+ //# s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Aa,MAAA,IAAU,KAAA,CAAM,QAAA,KAAa,YAAA;AACzD;AAUO,SAAS,cAAc,KAAA,EAAyB;AACrD,EAAA,OAAO,gBAAA,CAAiB,KAAK,CAAA,IAAK,KAAA,CAAM,QAAA,KAAa,QAAA;AACvD;AAKO,SAAS,kBAAkB,KAAA,EAAyB;AACzD,EAAA,OAAO,gBAAA,CAAiB,KAAK,CAAA,IAAK,KAAA,CAAM,QAAA,KAAa,YAAA;AACvD;AAKO,SAAS,mBAAmB,KAAA,EAAoC;AACrE,EAAA,OAAO,gBAAA,CAAiB,KAAK,CAAA,GAAI,KAAA,CAAM,UAAA,GAAa,MAAA;AACtD","file":"chunk-LGEALRC6.cjs","sourcesContent":["/**\n * TypeGraph Error Hierarchy\n *\n * All errors extend TypeGraphError with:\n * - `code`: Machine-readable error code for programmatic handling\n * - `category`: Classification for error handling strategies\n * - `suggestion`: Optional recovery guidance for users\n * - `details`: Structured context about the error\n *\n * @example\n * ```typescript\n * try {\n * await store.nodes.Person.create({ name: \"\" });\n * } catch (error) {\n * if (isTypeGraphError(error)) {\n * console.error(error.toUserMessage());\n * if (isUserRecoverable(error)) {\n * // Show to user for correction\n * }\n * }\n * }\n * ```\n */\n\nimport type { KindEntity } from \"../core/types\";\n// Type-only import: `materialize-indexes.ts` value-imports\n// `ConfigurationError` from this file, but type-only imports are erased\n// at runtime so this back-edge does not create a value cycle.\nimport type { MaterializeIndexesResult } from \"../store/materialize-indexes\";\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Error category for programmatic handling.\n *\n * - `user`: Caused by invalid input or incorrect usage. Recoverable by fixing input.\n * - `constraint`: Business rule or schema constraint violation. Recoverable by changing data.\n * - `system`: Internal error or infrastructure issue. May require investigation or retry.\n */\nexport type ErrorCategory = \"user\" | \"constraint\" | \"system\";\n\n/**\n * Options for TypeGraphError constructor.\n */\nexport type TypeGraphErrorOptions = Readonly<{\n /** Structured context about the error */\n details?: Record<string, unknown>;\n /** Error category for handling strategies */\n category: ErrorCategory;\n /** Recovery guidance for users */\n suggestion?: string;\n /** Underlying cause of the error */\n cause?: unknown;\n}>;\n\nfunction formatCause(cause: unknown): string {\n if (cause instanceof Error) {\n return cause.stack ?? cause.message;\n }\n if (typeof cause === \"string\") {\n return cause;\n }\n if (\n typeof cause === \"number\" ||\n typeof cause === \"boolean\" ||\n typeof cause === \"bigint\"\n ) {\n return String(cause);\n }\n if (typeof cause === \"symbol\") {\n return cause.description ?? \"Symbol\";\n }\n if (cause === undefined) {\n return \"Unknown cause\";\n }\n\n try {\n return JSON.stringify(cause);\n } catch (error) {\n return `Unserializable cause: ${\n error instanceof Error ? error.message : \"Unknown error\"\n }`;\n }\n}\n\n// ============================================================\n// Base Error\n// ============================================================\n\n/**\n * Base error class for all TypeGraph errors.\n *\n * Provides structured error information for both programmatic handling\n * and user-friendly messages.\n */\nexport class TypeGraphError extends Error {\n /** Machine-readable error code (e.g., \"VALIDATION_ERROR\") */\n readonly code: string;\n\n /** Error category for handling strategies */\n readonly category: ErrorCategory;\n\n /** Structured context about the error */\n readonly details: Readonly<Record<string, unknown>>;\n\n /** Recovery guidance for users */\n readonly suggestion?: string;\n\n constructor(message: string, code: string, options: TypeGraphErrorOptions) {\n super(message, options.cause ? { cause: options.cause } : undefined);\n this.name = \"TypeGraphError\";\n this.code = code;\n this.category = options.category;\n this.details = Object.freeze(options.details ?? {});\n if (options.suggestion !== undefined) {\n this.suggestion = options.suggestion;\n }\n }\n\n /**\n * Returns a user-friendly error message with suggestion if available.\n */\n toUserMessage(): string {\n if (this.suggestion) {\n return `${this.message}\\n\\nSuggestion: ${this.suggestion}`;\n }\n return this.message;\n }\n\n /**\n * Returns a detailed string representation for logging.\n */\n toLogString(): string {\n const lines = [\n `[${this.code}] ${this.message}`,\n ` Category: ${this.category}`,\n ];\n\n if (this.suggestion) {\n lines.push(` Suggestion: ${this.suggestion}`);\n }\n\n const detailKeys = Object.keys(this.details);\n if (detailKeys.length > 0) {\n lines.push(` Details: ${JSON.stringify(this.details)}`);\n }\n\n if (this.cause) {\n lines.push(` Cause: ${formatCause(this.cause)}`);\n }\n\n return lines.join(\"\\n\");\n }\n}\n\n// ============================================================\n// Validation Errors (category: \"user\")\n// ============================================================\n\n/**\n * Validation issue from Zod or custom validation.\n */\nexport type ValidationIssue = Readonly<{\n /** Path to the invalid field (e.g., \"address.city\") */\n path: string;\n /** Human-readable error message */\n message: string;\n /** Zod error code if from Zod validation */\n code?: string;\n}>;\n\n/**\n * Details for ValidationError.\n */\nexport type ValidationErrorDetails = Readonly<{\n /** Type of entity being validated */\n entityType?: KindEntity;\n /** Kind/type name of the entity */\n kind?: string;\n /** Operation being performed */\n operation?: \"create\" | \"update\";\n /** Entity ID if updating */\n id?: string;\n /** Individual validation issues */\n issues: readonly ValidationIssue[];\n}>;\n\n/**\n * Thrown when schema validation fails during node or edge operations.\n *\n * @example\n * ```typescript\n * try {\n * await store.nodes.Person.create({ email: \"invalid\" });\n * } catch (error) {\n * if (error instanceof ValidationError) {\n * console.log(error.details.issues);\n * // [{ path: \"email\", message: \"Invalid email\" }]\n * }\n * }\n * ```\n */\nexport class ValidationError extends TypeGraphError {\n declare readonly details: ValidationErrorDetails;\n\n constructor(\n message: string,\n details: ValidationErrorDetails,\n options?: { cause?: unknown; suggestion?: string },\n ) {\n const fieldList =\n details.issues.length > 0 ?\n details.issues.map((index) => index.path || \"(root)\").join(\", \")\n : \"unknown\";\n\n super(message, \"VALIDATION_ERROR\", {\n details,\n category: \"user\",\n suggestion:\n options?.suggestion ??\n `Check the following fields: ${fieldList}. See error.details.issues for specific validation failures.`,\n cause: options?.cause,\n });\n this.name = \"ValidationError\";\n }\n}\n\n// ============================================================\n// Not Found Errors (category: \"user\")\n// ============================================================\n\n/**\n * Details for NodeNotFoundError.\n */\nexport type NodeNotFoundErrorDetails = Readonly<{\n kind: string;\n id: string;\n}>;\n\n/**\n * Thrown when a node is not found.\n *\n * @example\n * ```typescript\n * try {\n * await store.nodes.Person.get(\"nonexistent-id\");\n * } catch (error) {\n * if (error instanceof NodeNotFoundError) {\n * console.log(error.details.kind, error.details.id);\n * }\n * }\n * ```\n */\nexport class NodeNotFoundError extends TypeGraphError {\n declare readonly details: NodeNotFoundErrorDetails;\n\n constructor(kind: string, id: string, options?: { cause?: unknown }) {\n super(`Node not found: ${kind}/${id}`, \"NODE_NOT_FOUND\", {\n details: { kind, id },\n category: \"user\",\n suggestion: `Verify the node ID \"${id}\" exists and has not been deleted.`,\n cause: options?.cause,\n });\n this.name = \"NodeNotFoundError\";\n }\n}\n\n/**\n * Details for EdgeNotFoundError.\n */\nexport type EdgeNotFoundErrorDetails = Readonly<{\n kind: string;\n id: string;\n}>;\n\n/**\n * Thrown when an edge is not found.\n */\nexport class EdgeNotFoundError extends TypeGraphError {\n declare readonly details: EdgeNotFoundErrorDetails;\n\n constructor(kind: string, id: string, options?: { cause?: unknown }) {\n super(`Edge not found: ${kind}/${id}`, \"EDGE_NOT_FOUND\", {\n details: { kind, id },\n category: \"user\",\n suggestion: `Verify the edge ID \"${id}\" exists and has not been deleted.`,\n cause: options?.cause,\n });\n this.name = \"EdgeNotFoundError\";\n }\n}\n\n/**\n * Details for KindNotFoundError.\n */\nexport type KindNotFoundErrorDetails = Readonly<{\n kindName: string;\n entity: KindEntity;\n graphId?: string;\n}>;\n\n/**\n * Thrown when an operation references a kind that isn't registered on\n * the graph — `getNodeCollectionOrThrow` against an unknown kind, a\n * `materializeIndexes({ kinds })` filter naming a missing kind, an\n * extension referencing an unresolved endpoint, search facade typos,\n * etc. Carries the offending `kindName` and `entity` plus the host\n * `graphId` so logs are unambiguous when multiple stores share a\n * process.\n */\nexport class KindNotFoundError extends TypeGraphError {\n declare readonly details: KindNotFoundErrorDetails;\n readonly kindName: string;\n readonly entity: KindEntity;\n\n constructor(\n kindName: string,\n entity: KindEntity,\n options?: Readonly<{\n graphId?: string;\n suggestion?: string;\n cause?: unknown;\n }>,\n ) {\n const where =\n options?.graphId === undefined ? \"\" : ` on graph \"${options.graphId}\"`;\n super(\n `${entity === \"node\" ? \"Node\" : \"Edge\"} kind \"${kindName}\" is not registered${where}.`,\n \"KIND_NOT_FOUND\",\n {\n details: {\n kindName,\n entity,\n ...(options?.graphId === undefined ?\n {}\n : { graphId: options.graphId }),\n },\n category: \"user\",\n suggestion:\n options?.suggestion ??\n \"Compile-time kinds come from defineGraph; extension kinds appear after store.evolve() returns. Check store.introspect() for the registered set.\",\n cause: options?.cause,\n },\n );\n this.name = \"KindNotFoundError\";\n this.kindName = kindName;\n this.entity = entity;\n }\n}\n\n/**\n * Details for NodeConstraintNotFoundError.\n */\nexport type NodeConstraintNotFoundErrorDetails = Readonly<{\n constraintName: string;\n kind: string;\n}>;\n\n/**\n * Thrown when a uniqueness constraint name is not found on a node kind.\n */\nexport class NodeConstraintNotFoundError extends TypeGraphError {\n declare readonly details: NodeConstraintNotFoundErrorDetails;\n\n constructor(\n constraintName: string,\n kind: string,\n options?: { cause?: unknown },\n ) {\n super(\n `Constraint not found: \"${constraintName}\" on node kind \"${kind}\"`,\n \"CONSTRAINT_NOT_FOUND\",\n {\n details: { constraintName, kind },\n category: \"user\",\n suggestion: `Verify the constraint name \"${constraintName}\" is defined in the unique constraints for \"${kind}\".`,\n cause: options?.cause,\n },\n );\n this.name = \"NodeConstraintNotFoundError\";\n }\n}\n\n/**\n * Details for NodeIndexNotFoundError.\n */\nexport type NodeIndexNotFoundErrorDetails = Readonly<{\n indexName: string;\n kind: string;\n}>;\n\n/**\n * Thrown when a declared node index name is not found on a node kind.\n */\nexport class NodeIndexNotFoundError extends TypeGraphError {\n declare readonly details: NodeIndexNotFoundErrorDetails;\n\n constructor(indexName: string, kind: string, options?: { cause?: unknown }) {\n super(\n `Index not found: \"${indexName}\" on node kind \"${kind}\"`,\n \"INDEX_NOT_FOUND\",\n {\n details: { indexName, kind },\n category: \"user\",\n suggestion: `Verify the index name \"${indexName}\" is declared via defineNodeIndex for \"${kind}\" and passed to defineGraph({ indexes }).`,\n cause: options?.cause,\n },\n );\n this.name = \"NodeIndexNotFoundError\";\n }\n}\n\n// ============================================================\n// Constraint Errors (category: \"constraint\")\n// ============================================================\n\n/**\n * Details for EndpointNotFoundError.\n */\nexport type EndpointNotFoundErrorDetails = Readonly<{\n edgeKind: string;\n endpoint: \"from\" | \"to\";\n nodeKind: string;\n nodeId: string;\n}>;\n\n/**\n * Thrown when edge endpoint node does not exist or is deleted.\n */\nexport class EndpointNotFoundError extends TypeGraphError {\n declare readonly details: EndpointNotFoundErrorDetails;\n\n constructor(\n details: EndpointNotFoundErrorDetails,\n options?: { cause?: unknown },\n ) {\n super(\n `Endpoint node not found for edge \"${details.edgeKind}\": ${details.nodeKind}/${details.nodeId} (${details.endpoint})`,\n \"ENDPOINT_NOT_FOUND\",\n {\n details,\n category: \"constraint\",\n suggestion: `Ensure the ${details.endpoint} node exists before creating the edge.`,\n cause: options?.cause,\n },\n );\n this.name = \"EndpointNotFoundError\";\n }\n}\n\n/**\n * Details for EndpointError.\n */\nexport type EndpointErrorDetails = Readonly<{\n edgeKind: string;\n endpoint: \"from\" | \"to\";\n actualKind: string;\n expectedKinds: readonly string[];\n}>;\n\n/**\n * Thrown when edge endpoint has wrong node type.\n */\nexport class EndpointError extends TypeGraphError {\n declare readonly details: EndpointErrorDetails;\n\n constructor(details: EndpointErrorDetails, options?: { cause?: unknown }) {\n const expected = details.expectedKinds.join(\" | \");\n super(\n `Invalid ${details.endpoint} endpoint for edge \"${details.edgeKind}\": got \"${details.actualKind}\", expected ${expected}`,\n \"ENDPOINT_ERROR\",\n {\n details,\n category: \"constraint\",\n suggestion: `Use a node of type ${expected} as the ${details.endpoint} endpoint.`,\n cause: options?.cause,\n },\n );\n this.name = \"EndpointError\";\n }\n}\n\n/**\n * Details for UniquenessError.\n */\nexport type UniquenessErrorDetails = Readonly<{\n constraintName: string;\n kind: string;\n existingId: string;\n newId: string;\n fields: readonly string[];\n}>;\n\n/**\n * Thrown when uniqueness constraint is violated.\n */\nexport class UniquenessError extends TypeGraphError {\n declare readonly details: UniquenessErrorDetails;\n\n constructor(details: UniquenessErrorDetails, options?: { cause?: unknown }) {\n const fieldList = details.fields.join(\", \");\n super(\n `Uniqueness violation on \"${details.kind}\": constraint \"${details.constraintName}\" (fields: ${fieldList}) conflicts with existing node ${details.existingId}`,\n \"UNIQUENESS_VIOLATION\",\n {\n details,\n category: \"constraint\",\n suggestion: `Change the values for fields [${fieldList}] to be unique, or update the existing node ${details.existingId} instead.`,\n cause: options?.cause,\n },\n );\n this.name = \"UniquenessError\";\n }\n}\n\n/**\n * Details for CardinalityError.\n */\nexport type CardinalityErrorDetails = Readonly<{\n edgeKind: string;\n fromKind: string;\n fromId: string;\n cardinality: string;\n existingCount: number;\n}>;\n\n/**\n * Thrown when cardinality constraint is violated.\n */\nexport class CardinalityError extends TypeGraphError {\n declare readonly details: CardinalityErrorDetails;\n\n constructor(details: CardinalityErrorDetails, options?: { cause?: unknown }) {\n super(\n `Cardinality violation: \"${details.edgeKind}\" from ${details.fromKind}/${details.fromId} allows \"${details.cardinality}\" but ${details.existingCount} edge(s) already exist`,\n \"CARDINALITY_ERROR\",\n {\n details,\n category: \"constraint\",\n suggestion:\n details.cardinality === \"one\" || details.cardinality === \"unique\" ?\n `Delete the existing edge before creating a new one, or use cardinality \"many\".`\n : `Check if the cardinality constraint \"${details.cardinality}\" is correct for your use case.`,\n cause: options?.cause,\n },\n );\n this.name = \"CardinalityError\";\n }\n}\n\n/**\n * Details for DisjointError.\n */\nexport type DisjointErrorDetails = Readonly<{\n nodeId: string;\n attemptedKind: string;\n conflictingKind: string;\n}>;\n\n/**\n * Thrown when disjointness constraint is violated.\n *\n * Disjoint types cannot share the same ID - a node cannot be both\n * a Person and an Organization if they are declared disjoint.\n */\nexport class DisjointError extends TypeGraphError {\n declare readonly details: DisjointErrorDetails;\n\n constructor(details: DisjointErrorDetails, options?: { cause?: unknown }) {\n super(\n `Disjoint constraint violation: cannot create ${details.attemptedKind} with ID \"${details.nodeId}\" - conflicts with existing ${details.conflictingKind}`,\n \"DISJOINT_ERROR\",\n {\n details,\n category: \"constraint\",\n suggestion: `Use a different ID for the new ${details.attemptedKind} node, or delete the existing ${details.conflictingKind}/${details.nodeId} first.`,\n cause: options?.cause,\n },\n );\n this.name = \"DisjointError\";\n }\n}\n\n/**\n * Details for RestrictedDeleteError.\n */\nexport type RestrictedDeleteErrorDetails = Readonly<{\n nodeKind: string;\n nodeId: string;\n edgeCount: number;\n edgeKinds: readonly string[];\n}>;\n\n/**\n * Thrown when deletion is blocked due to existing edges (restrict behavior).\n */\nexport class RestrictedDeleteError extends TypeGraphError {\n declare readonly details: RestrictedDeleteErrorDetails;\n\n constructor(\n details: RestrictedDeleteErrorDetails,\n options?: { cause?: unknown },\n ) {\n const edgeList = details.edgeKinds.join(\", \");\n super(\n `Cannot delete ${details.nodeKind}/${details.nodeId}: ${details.edgeCount} connected edge(s) exist (${edgeList})`,\n \"RESTRICTED_DELETE\",\n {\n details,\n category: \"constraint\",\n suggestion: `Delete the connected edges first, or change onDelete behavior to \"cascade\" (auto-delete edges) or \"disconnect\" (soft-delete edges).`,\n cause: options?.cause,\n },\n );\n this.name = \"RestrictedDeleteError\";\n }\n}\n\n// ============================================================\n// Concurrency Errors (category: \"system\")\n// ============================================================\n\n/**\n * Details for VersionConflictError.\n */\nexport type VersionConflictErrorDetails = Readonly<{\n kind: string;\n id: string;\n expectedVersion: number;\n actualVersion: number;\n}>;\n\n/**\n * Thrown when optimistic locking detects a concurrent modification.\n *\n * This occurs when two operations try to update the same entity simultaneously.\n * The operation with the stale version fails.\n */\nexport class VersionConflictError extends TypeGraphError {\n declare readonly details: VersionConflictErrorDetails;\n\n constructor(\n details: VersionConflictErrorDetails,\n options?: { cause?: unknown },\n ) {\n super(\n `Version conflict on ${details.kind}/${details.id}: expected version ${details.expectedVersion}, found ${details.actualVersion}`,\n \"VERSION_CONFLICT\",\n {\n details,\n category: \"system\",\n suggestion: `Fetch the latest version of the entity and retry the operation. This error indicates concurrent modification.`,\n cause: options?.cause,\n },\n );\n this.name = \"VersionConflictError\";\n }\n}\n\n// ============================================================\n// Schema Errors (category: \"system\")\n// ============================================================\n\n/**\n * Details for SchemaMismatchError.\n */\nexport type SchemaMismatchErrorDetails = Readonly<{\n graphId: string;\n expectedHash: string;\n actualHash: string;\n}>;\n\n/**\n * Thrown when the schema in code doesn't match the schema in the database.\n */\nexport class SchemaMismatchError extends TypeGraphError {\n declare readonly details: SchemaMismatchErrorDetails;\n\n constructor(\n details: SchemaMismatchErrorDetails,\n options?: { cause?: unknown },\n ) {\n super(\n `Schema mismatch for graph \"${details.graphId}\": code schema differs from database schema`,\n \"SCHEMA_MISMATCH\",\n {\n details,\n category: \"system\",\n suggestion: `Run schema migration to update the database, or use createStoreWithSchema() for automatic migration.`,\n cause: options?.cause,\n },\n );\n this.name = \"SchemaMismatchError\";\n }\n}\n\n/**\n * Details for MigrationError.\n */\nexport type MigrationErrorDetails = Readonly<{\n graphId: string;\n fromVersion: number;\n toVersion: number;\n reason?: string;\n}>;\n\n/**\n * Thrown when schema migration fails.\n */\nexport class MigrationError extends TypeGraphError {\n declare readonly details: MigrationErrorDetails;\n\n constructor(\n message: string,\n details: MigrationErrorDetails,\n options?: { cause?: unknown },\n ) {\n super(message, \"MIGRATION_ERROR\", {\n details,\n category: \"system\",\n suggestion: `Review the schema changes and ensure they are backwards compatible, or implement a data migration.`,\n cause: options?.cause,\n });\n this.name = \"MigrationError\";\n }\n}\n\n/**\n * Details for EagerMaterializationError.\n */\nexport type EagerMaterializationErrorDetails = Readonly<{\n graphId: string;\n failedIndexNames: readonly string[];\n}>;\n\n/**\n * Thrown by `Store.evolve(extension, { eager })` when the schema\n * commit succeeded but the follow-on `materializeIndexes()` produced\n * one or more failed entries.\n *\n * Recovery: the schema commit is NOT rolled back. The new `Store` is\n * fully constructed and (when `options.ref` was supplied) `ref.current`\n * already points to it — the caller can read the new store via the ref\n * and decide how to handle the failed indexes (retry, skip, alert).\n * The full `MaterializeIndexesResult` is attached as `.materialization`.\n *\n * @example\n * ```ts\n * const ref = { current: store };\n * try {\n * await store.evolve(extension, { ref, eager: {} });\n * } catch (error) {\n * if (error instanceof EagerMaterializationError) {\n * // schema is committed; ref.current is the new store\n * log.warn(\n * { failed: error.failedIndexNames },\n * \"indexes did not materialize; will retry\",\n * );\n * await ref.current.materializeIndexes();\n * } else {\n * throw error;\n * }\n * }\n * ```\n */\nexport class EagerMaterializationError extends TypeGraphError {\n declare readonly details: EagerMaterializationErrorDetails;\n\n /**\n * The full materialization result, including successful and failed\n * entries. Same shape as `Store.materializeIndexes()` returns.\n */\n readonly materialization: MaterializeIndexesResult;\n\n constructor(materialization: MaterializeIndexesResult, graphId: string) {\n const names = collectFailedIndexNames(materialization);\n super(\n `Eager materialization failed for ${names.length} index(es) on graph \"${graphId}\": ${names.join(\", \")}. The schema commit succeeded; the new Store is available via the ref handle (when supplied) and the failed indexes can be retried via store.materializeIndexes().`,\n \"EAGER_MATERIALIZATION_FAILED\",\n {\n details: { graphId, failedIndexNames: names },\n category: \"system\",\n suggestion: `Inspect error.materialization for per-index errors. Each failure preserves any prior successful materialization timestamp; the schema is committed regardless.`,\n },\n );\n this.name = \"EagerMaterializationError\";\n this.materialization = materialization;\n }\n\n /**\n * Names of just the indexes that failed — derived from\n * `materialization.results` so the two views can never disagree.\n */\n get failedIndexNames(): readonly string[] {\n return collectFailedIndexNames(this.materialization);\n }\n}\n\nfunction collectFailedIndexNames(\n materialization: MaterializeIndexesResult,\n): readonly string[] {\n const names: string[] = [];\n for (const entry of materialization.results) {\n if (entry.status === \"failed\") names.push(entry.indexName);\n }\n return names;\n}\n\n/**\n * Details for StaleVersionError. `actual` is `0` when no active version\n * exists yet (initial-commit race where another writer initialized first).\n */\nexport type StaleVersionErrorDetails = Readonly<{\n graphId: string;\n expected: number;\n actual: number;\n}>;\n\n/**\n * Thrown by `commitSchemaVersion` and `setActiveVersion` when the\n * caller's view of the active schema version is out of date — another\n * writer has already advanced it.\n *\n * Recovery: re-read the active version with `getActiveSchema(graphId)`,\n * recompute against the new baseline, and retry. This is a routine\n * concurrency signal, not a bug.\n */\nexport class StaleVersionError extends TypeGraphError {\n declare readonly details: StaleVersionErrorDetails;\n\n constructor(\n details: StaleVersionErrorDetails,\n options?: { cause?: unknown },\n ) {\n super(\n `Schema version was advanced by another writer for graph \"${details.graphId}\": expected active version ${details.expected}, actual is ${details.actual}`,\n \"STALE_SCHEMA_VERSION\",\n {\n details,\n category: \"system\",\n suggestion: `Re-read the active schema version, recompute the new version against that baseline, and retry the commit.`,\n cause: options?.cause,\n },\n );\n this.name = \"StaleVersionError\";\n }\n}\n\n/**\n * Details for SchemaContentConflictError.\n */\nexport type SchemaContentConflictErrorDetails = Readonly<{\n graphId: string;\n version: number;\n existingHash: string;\n incomingHash: string;\n}>;\n\n/**\n * Thrown by `commitSchemaVersion` when a row already exists at the\n * target version with a *different* schema hash — i.e. two writers\n * committed materially different schemas at the same version number.\n *\n * Distinct from `StaleVersionError`: this is not a refetch-and-retry\n * situation, it's a content disagreement that needs operator\n * intervention. Typically caused by inconsistent application\n * deployments writing schemas that hash differently.\n */\nexport class SchemaContentConflictError extends TypeGraphError {\n declare readonly details: SchemaContentConflictErrorDetails;\n\n constructor(\n details: SchemaContentConflictErrorDetails,\n options?: { cause?: unknown },\n ) {\n super(\n `Schema content conflict for graph \"${details.graphId}\" at version ${details.version}: existing hash ${details.existingHash} differs from incoming hash ${details.incomingHash}`,\n \"SCHEMA_CONTENT_CONFLICT\",\n {\n details,\n category: \"system\",\n suggestion: `Two writers committed different schemas at the same version. Reconcile the application deployments so they produce the same canonical schema, then retry.`,\n cause: options?.cause,\n },\n );\n this.name = \"SchemaContentConflictError\";\n }\n}\n\n// ============================================================\n// Configuration Errors (category: \"user\")\n// ============================================================\n\n/**\n * Thrown when graph configuration is invalid.\n *\n * This includes invalid schema definitions, ontology conflicts,\n * and other configuration issues detected at graph creation time.\n */\nexport class ConfigurationError extends TypeGraphError {\n constructor(\n message: string,\n details: Record<string, unknown> = {},\n options?: { cause?: unknown; suggestion?: string },\n ) {\n super(message, \"CONFIGURATION_ERROR\", {\n details,\n category: \"user\",\n suggestion:\n options?.suggestion ?? `Review your graph definition for errors.`,\n cause: options?.cause,\n });\n this.name = \"ConfigurationError\";\n }\n}\n\n/**\n * Why a store's strategy-owned storage is not usable on the current\n * connection. Drives the {@link StoreNotInitializedError} message and\n * is surfaced in `details.reason` for programmatic handling.\n *\n * - `missing`: no durable materialization marker exists — the database\n * was never initialized for this graph's runtime contributions.\n * - `stale`: a marker exists but its recorded signature no longer\n * matches the resolved contribution DDL (strategy swap or DDL drift).\n * The hot path refuses rather than silently re-materializing.\n * - `failed`: the most recent boot-time materialization attempt\n * recorded an error. Boot may retry; the hot path refuses.\n */\nexport type StoreNotInitializedReason = \"missing\" | \"stale\" | \"failed\";\n\nconst STORE_NOT_INITIALIZED_REASON_PHRASE: Readonly<\n Record<StoreNotInitializedReason, string>\n> = {\n missing: \"is not initialized\",\n stale: \"is stale (recorded materialization signature no longer matches)\",\n failed: \"failed its last initialization attempt\",\n};\n\n/**\n * Details for StoreNotInitializedError. `graphId`/`reason` are always\n * present; callers may merge additional context (e.g. `logicalName`) via\n * `options.details`.\n */\nexport type StoreNotInitializedErrorDetails = Readonly<{\n graphId: string;\n reason: StoreNotInitializedReason;\n}> &\n Readonly<Record<string, unknown>>;\n\n/**\n * Thrown when a fulltext-dependent operation runs against a connection\n * whose strategy-owned storage has not been durably materialized.\n *\n * `createStore()` is a synchronous, zero-I/O attach: it never creates\n * tables, repairs DDL, or writes materialization markers. The durable\n * marker is written exclusively by the async boot path\n * (`createStoreWithSchema`). When a fulltext read/write — or an\n * adopted/business transaction — observes no valid marker, it refuses\n * loudly here instead of lazily emitting DDL on the hot path.\n */\nexport class StoreNotInitializedError extends TypeGraphError {\n declare readonly details: StoreNotInitializedErrorDetails;\n\n // `graphId`/`reason` are positional and required: both are\n // load-bearing for the message and for programmatic handling via\n // `details.reason`. Caller `details` merge underneath — spread first\n // so `graphId`/`reason` win and can't be clobbered by an\n // accidentally-colliding extra key.\n constructor(\n graphId: string,\n reason: StoreNotInitializedReason,\n options?: {\n cause?: unknown;\n details?: Readonly<Record<string, unknown>> &\n Readonly<{ graphId?: never; reason?: never }>;\n },\n ) {\n super(\n `fulltext storage for graph \"${graphId}\" ${STORE_NOT_INITIALIZED_REASON_PHRASE[reason]}. ` +\n `Run createStoreWithSchema(graph, backend) during application boot, ` +\n `outside request handlers and adopted transactions, before using createStore().`,\n \"STORE_NOT_INITIALIZED\",\n {\n details: { ...options?.details, graphId, reason },\n category: \"user\",\n suggestion:\n \"Call createStoreWithSchema(graph, backend) once at application \" +\n \"startup. createStore() attaches to an already-initialized \" +\n \"database and does not materialize storage itself.\",\n cause: options?.cause,\n },\n );\n this.name = \"StoreNotInitializedError\";\n }\n}\n\n// ============================================================\n// Database Errors (category: \"system\")\n// ============================================================\n\n/**\n * Details for DatabaseOperationError.\n */\nexport type DatabaseOperationErrorDetails = Readonly<{\n operation: string;\n entity: string;\n}>;\n\n/**\n * Thrown when a database operation fails unexpectedly.\n *\n * This indicates a system-level failure in the database backend,\n * not a user-recoverable error.\n */\nexport class DatabaseOperationError extends TypeGraphError {\n declare readonly details: DatabaseOperationErrorDetails;\n\n constructor(\n message: string,\n details: DatabaseOperationErrorDetails,\n options?: { cause?: unknown },\n ) {\n super(message, \"DATABASE_OPERATION_ERROR\", {\n details,\n category: \"system\",\n suggestion: `This is a system-level database error. Check the database connection and retry the operation. If the problem persists, investigate the underlying cause.`,\n cause: options?.cause,\n });\n this.name = \"DatabaseOperationError\";\n }\n}\n\n// ============================================================\n// Vector / Embedding Errors (category: \"user\")\n// ============================================================\n\n/**\n * Details for EmbeddingDimensionChangedError.\n */\nexport type EmbeddingDimensionChangedErrorDetails = Readonly<{\n kind: string;\n fieldPath: string;\n declaredDimensions?: number;\n storedDimensions?: number;\n}>;\n\n/**\n * Thrown when an embedding field's declared dimension no longer matches the\n * dimension of its materialized per-field storage — i.e. a field's\n * `embedding(N)` was changed to `embedding(M)`. The stored vectors are invalid\n * under the new dimension and cannot be converted, only recomputed, so this is\n * a deliberate app-driven migration: call\n * `store.reembedVectorField(kind, fieldPath, ...)` to recreate the storage at\n * the new dimension and re-embed existing rows.\n */\nexport class EmbeddingDimensionChangedError extends TypeGraphError {\n declare readonly details: EmbeddingDimensionChangedErrorDetails;\n\n constructor(\n message: string,\n details: EmbeddingDimensionChangedErrorDetails,\n options?: { cause?: unknown },\n ) {\n super(message, \"EMBEDDING_DIMENSION_CHANGED\", {\n details,\n category: \"user\",\n suggestion: `Run store.reembedVectorField(\"${details.kind}\", \"${details.fieldPath}\", { embed }) to recreate the field's storage at the new dimension and re-embed existing rows.`,\n cause: options?.cause,\n });\n this.name = \"EmbeddingDimensionChangedError\";\n }\n}\n\n// ============================================================\n// Query Errors (category: \"system\")\n// ============================================================\n\n/**\n * Thrown when a query predicate cannot be compiled for the target database.\n */\nexport class UnsupportedPredicateError extends TypeGraphError {\n constructor(\n message: string,\n details: Readonly<Record<string, unknown>> = {},\n options?: { cause?: unknown; suggestion?: string },\n ) {\n super(message, \"UNSUPPORTED_PREDICATE\", {\n details,\n category: \"system\",\n suggestion:\n options?.suggestion ??\n `This predicate may not be supported by your database backend. Check the documentation for supported predicates.`,\n cause: options?.cause,\n });\n this.name = \"UnsupportedPredicateError\";\n }\n}\n\n// ============================================================\n// Compiler Errors (category: \"system\")\n// ============================================================\n\n/**\n * Thrown when a compiler invariant is violated.\n *\n * This indicates a bug in the query compiler — the compiler reached\n * a state that should be unreachable. These errors are not user-recoverable.\n */\nexport class CompilerInvariantError extends TypeGraphError {\n constructor(\n message: string,\n details?: Readonly<Record<string, unknown>>,\n options?: { cause?: unknown },\n ) {\n super(message, \"COMPILER_INVARIANT_ERROR\", {\n details: details ?? {},\n category: \"system\",\n suggestion: `This is an internal compiler error. Please report it as a bug with the query that triggered it.`,\n cause: options?.cause,\n });\n this.name = \"CompilerInvariantError\";\n }\n}\n\n// ============================================================\n// Lifecycle Errors (category: \"system\")\n// ============================================================\n\n/**\n * Thrown when an operation is attempted on a backend that has been disposed.\n *\n * This typically occurs during runtime teardown — for example, when a\n * Cloudflare Workers test runner resets Durable Object storage while\n * the TypeGraph backend still has queued operations.\n */\nexport class BackendDisposedError extends TypeGraphError {\n constructor(options?: { cause?: unknown }) {\n super(\n \"Backend has been disposed — the underlying database connection is no longer available\",\n \"BACKEND_DISPOSED\",\n {\n category: \"system\",\n suggestion:\n \"Ensure all store operations complete before calling backend.close(). \" +\n \"In test environments, await store teardown before resetting the database.\",\n cause: options?.cause,\n },\n );\n this.name = \"BackendDisposedError\";\n }\n}\n\n/**\n * Thrown when a statement is issued on a transaction-scoped backend after\n * its transaction boundary has already returned.\n *\n * The usual source is a callback that lets work escape it. `Promise.all`\n * rejects on its first rejection while its siblings keep running, so\n *\n * ```typescript\n * await store.transaction(async (tx) => {\n * await Promise.all([tx.nodes.Doc.create(a), tx.nodes.Doc.create(b)]);\n * });\n * ```\n *\n * leaves `b`'s remaining statements in flight when `a` fails. Those\n * statements have nowhere safe to go: the driver is about to emit `ROLLBACK`\n * on the same pinned connection and then hand it back to the pool, where a\n * late arrival would execute inside somebody else's transaction. TypeGraph\n * refuses them here instead.\n *\n * The error is normally invisible — `Promise.all` has already rejected with\n * the original failure, and discards this one.\n */\nexport class TransactionClosedError extends TypeGraphError {\n constructor(options?: { cause?: unknown }) {\n super(\n \"Statement issued on a transaction-scoped backend after its transaction \" +\n \"boundary returned. The connection has been released; the statement was not run.\",\n \"TRANSACTION_CLOSED\",\n {\n category: \"user\",\n suggestion:\n \"Await every write started inside store.transaction(...) before the \" +\n \"callback returns. Prefer awaiting a Promise.allSettled(...) over a \" +\n \"Promise.all(...) whose rejection would orphan its siblings.\",\n cause: options?.cause,\n },\n );\n this.name = \"TransactionClosedError\";\n }\n}\n\n// ============================================================\n// Utility Functions\n// ============================================================\n\n/**\n * Type guard for TypeGraphError.\n *\n * @example\n * ```typescript\n * try {\n * await store.nodes.Person.create({});\n * } catch (error) {\n * if (isTypeGraphError(error)) {\n * console.log(error.code, error.category);\n * }\n * }\n * ```\n */\nexport function isTypeGraphError(error: unknown): error is TypeGraphError {\n return error instanceof TypeGraphError;\n}\n\n/**\n * Check if error is recoverable by user action (user or constraint error).\n *\n * User-recoverable errors can typically be resolved by:\n * - Fixing invalid input data\n * - Using different IDs or values\n * - Deleting conflicting data first\n *\n * @example\n * ```typescript\n * if (isUserRecoverable(error)) {\n * showErrorToUser(error.toUserMessage());\n * } else {\n * logAndAlertOps(error);\n * }\n * ```\n */\nexport function isUserRecoverable(error: unknown): boolean {\n if (!isTypeGraphError(error)) return false;\n return error.category === \"user\" || error.category === \"constraint\";\n}\n\n/**\n * Check if error indicates a system/infrastructure issue.\n *\n * System errors typically require:\n * - Retry logic (for transient failures)\n * - Investigation (for persistent failures)\n * - Ops team notification\n */\nexport function isSystemError(error: unknown): boolean {\n return isTypeGraphError(error) && error.category === \"system\";\n}\n\n/**\n * Check if error is a constraint violation.\n */\nexport function isConstraintError(error: unknown): boolean {\n return isTypeGraphError(error) && error.category === \"constraint\";\n}\n\n/**\n * Extract suggestion from error if available.\n */\nexport function getErrorSuggestion(error: unknown): string | undefined {\n return isTypeGraphError(error) ? error.suggestion : undefined;\n}\n"]}
@@ -378,13 +378,15 @@ var STORE_NOT_INITIALIZED_REASON_PHRASE = {
378
378
  var StoreNotInitializedError = class extends TypeGraphError {
379
379
  // `graphId`/`reason` are positional and required: both are
380
380
  // load-bearing for the message and for programmatic handling via
381
- // `details.reason`. Caller `details` merge on top.
381
+ // `details.reason`. Caller `details` merge underneath — spread first
382
+ // so `graphId`/`reason` win and can't be clobbered by an
383
+ // accidentally-colliding extra key.
382
384
  constructor(graphId, reason, options) {
383
385
  super(
384
386
  `fulltext storage for graph "${graphId}" ${STORE_NOT_INITIALIZED_REASON_PHRASE[reason]}. Run createStoreWithSchema(graph, backend) during application boot, outside request handlers and adopted transactions, before using createStore().`,
385
387
  "STORE_NOT_INITIALIZED",
386
388
  {
387
- details: { graphId, reason, ...options?.details },
389
+ details: { ...options?.details, graphId, reason },
388
390
  category: "user",
389
391
  suggestion: "Call createStoreWithSchema(graph, backend) once at application startup. createStore() attaches to an already-initialized database and does not materialize storage itself.",
390
392
  cause: options?.cause
@@ -451,6 +453,20 @@ var BackendDisposedError = class extends TypeGraphError {
451
453
  this.name = "BackendDisposedError";
452
454
  }
453
455
  };
456
+ var TransactionClosedError = class extends TypeGraphError {
457
+ constructor(options) {
458
+ super(
459
+ "Statement issued on a transaction-scoped backend after its transaction boundary returned. The connection has been released; the statement was not run.",
460
+ "TRANSACTION_CLOSED",
461
+ {
462
+ category: "user",
463
+ suggestion: "Await every write started inside store.transaction(...) before the callback returns. Prefer awaiting a Promise.allSettled(...) over a Promise.all(...) whose rejection would orphan its siblings.",
464
+ cause: options?.cause
465
+ }
466
+ );
467
+ this.name = "TransactionClosedError";
468
+ }
469
+ };
454
470
  function isTypeGraphError(error) {
455
471
  return error instanceof TypeGraphError;
456
472
  }
@@ -468,6 +484,6 @@ function getErrorSuggestion(error) {
468
484
  return isTypeGraphError(error) ? error.suggestion : void 0;
469
485
  }
470
486
 
471
- export { BackendDisposedError, CardinalityError, CompilerInvariantError, ConfigurationError, DatabaseOperationError, DisjointError, EagerMaterializationError, EdgeNotFoundError, EmbeddingDimensionChangedError, EndpointError, EndpointNotFoundError, KindNotFoundError, MigrationError, NodeConstraintNotFoundError, NodeIndexNotFoundError, NodeNotFoundError, RestrictedDeleteError, SchemaContentConflictError, SchemaMismatchError, StaleVersionError, StoreNotInitializedError, TypeGraphError, UniquenessError, UnsupportedPredicateError, ValidationError, VersionConflictError, getErrorSuggestion, isConstraintError, isSystemError, isTypeGraphError, isUserRecoverable };
472
- //# sourceMappingURL=chunk-TQOYM4LN.js.map
473
- //# sourceMappingURL=chunk-TQOYM4LN.js.map
487
+ export { BackendDisposedError, CardinalityError, CompilerInvariantError, ConfigurationError, DatabaseOperationError, DisjointError, EagerMaterializationError, EdgeNotFoundError, EmbeddingDimensionChangedError, EndpointError, EndpointNotFoundError, KindNotFoundError, MigrationError, NodeConstraintNotFoundError, NodeIndexNotFoundError, NodeNotFoundError, RestrictedDeleteError, SchemaContentConflictError, SchemaMismatchError, StaleVersionError, StoreNotInitializedError, TransactionClosedError, TypeGraphError, UniquenessError, UnsupportedPredicateError, ValidationError, VersionConflictError, getErrorSuggestion, isConstraintError, isSystemError, isTypeGraphError, isUserRecoverable };
488
+ //# sourceMappingURL=chunk-MP2JQKSG.js.map
489
+ //# sourceMappingURL=chunk-MP2JQKSG.js.map