@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,590 @@
1
+ 'use strict';
2
+
3
+ var chunkA42GCBGX_cjs = require('../chunk-A42GCBGX.cjs');
4
+ var chunkXOX22WHL_cjs = require('../chunk-XOX22WHL.cjs');
5
+ require('../chunk-EOLERH7Y.cjs');
6
+ var chunk4TOD4LBZ_cjs = require('../chunk-4TOD4LBZ.cjs');
7
+ var chunkBLZDPRXT_cjs = require('../chunk-BLZDPRXT.cjs');
8
+ require('../chunk-7YSP4V4R.cjs');
9
+ require('../chunk-H7YNSMA7.cjs');
10
+ require('../chunk-SJDMVITW.cjs');
11
+ var chunkDI74SMXS_cjs = require('../chunk-DI74SMXS.cjs');
12
+ var chunkLGEALRC6_cjs = require('../chunk-LGEALRC6.cjs');
13
+ require('../chunk-TDXIBCGY.cjs');
14
+
15
+ // src/provenance/index.ts
16
+ var DEFAULT_RETRACTED_FIELD = "retracted";
17
+ var KEY_SEPARATOR = "\0";
18
+ function refKey(ref) {
19
+ return `${ref.kind}${KEY_SEPARATOR}${ref.id}`;
20
+ }
21
+ function rowKey(row) {
22
+ return refKey({ kind: row.kind, id: row.id });
23
+ }
24
+ function edgeFromKey(edge) {
25
+ return refKey({ kind: edge.from_kind, id: edge.from_id });
26
+ }
27
+ function edgeToKey(edge) {
28
+ return refKey({ kind: edge.to_kind, id: edge.to_id });
29
+ }
30
+ function keyToRef(key) {
31
+ const separatorIndex = key.indexOf(KEY_SEPARATOR);
32
+ if (separatorIndex === -1) {
33
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
34
+ "Invalid provenance identity key.",
35
+ { key },
36
+ {
37
+ suggestion: "Report this TypeGraph provenance bug with the graph roles that produced the key."
38
+ }
39
+ );
40
+ }
41
+ const kind = key.slice(0, separatorIndex);
42
+ const id = key.slice(separatorIndex + KEY_SEPARATOR.length);
43
+ return { kind, id };
44
+ }
45
+ function sortedReferences(keys) {
46
+ return [...keys].toSorted((left, right) => chunkA42GCBGX_cjs.compareStrings(left, right)).map((key) => keyToRef(key));
47
+ }
48
+ function parseNodeProps(row) {
49
+ const parsed = chunk4TOD4LBZ_cjs.rowPropsToObject(row.props);
50
+ if (!chunkDI74SMXS_cjs.isPlainObject(parsed)) {
51
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
52
+ `Node ${row.kind}/${row.id} props are not an object.`,
53
+ { kind: row.kind, id: row.id }
54
+ );
55
+ }
56
+ return parsed;
57
+ }
58
+ function sourceRetractedState(row, retractedField) {
59
+ const props = parseNodeProps(row);
60
+ const value = props[retractedField];
61
+ if (value === void 0) return "available";
62
+ if (typeof value !== "boolean") {
63
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
64
+ `Provenance source field "${retractedField}" must contain a boolean value.`,
65
+ { kind: row.kind, id: row.id, field: retractedField },
66
+ {
67
+ suggestion: "Use a source node schema with a boolean retracted flag, for example z.boolean().default(false)."
68
+ }
69
+ );
70
+ }
71
+ return value ? "retracted" : "available";
72
+ }
73
+ function normalizeConfig(graph, config) {
74
+ const sourceKinds = sourceKindsFromConfig(config.source);
75
+ const justificationKind = config.justification.kind;
76
+ const factKinds = [...config.fact.kinds];
77
+ const premiseOfKind = config.premiseOf.kind;
78
+ const derivesKind = config.derives.kind;
79
+ const retractedField = config.source.retractedField ?? DEFAULT_RETRACTED_FIELD;
80
+ if (sourceKinds.length === 0) {
81
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
82
+ "Provenance retraction requires at least one source kind.",
83
+ { role: "source" }
84
+ );
85
+ }
86
+ if (factKinds.length === 0) {
87
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
88
+ "Provenance retraction requires at least one fact kind.",
89
+ { role: "fact" }
90
+ );
91
+ }
92
+ const duplicateSourceKinds = duplicateValues(sourceKinds);
93
+ if (duplicateSourceKinds.length > 0) {
94
+ throw new chunkLGEALRC6_cjs.ConfigurationError("Provenance source kinds must be unique.", {
95
+ duplicateSourceKinds
96
+ });
97
+ }
98
+ const duplicateFactKinds = duplicateValues(factKinds);
99
+ if (duplicateFactKinds.length > 0) {
100
+ throw new chunkLGEALRC6_cjs.ConfigurationError("Provenance fact kinds must be unique.", {
101
+ duplicateFactKinds
102
+ });
103
+ }
104
+ for (const kind of sourceKinds) {
105
+ assertKind(graph.nodes, kind, "source", "node", graph.id);
106
+ }
107
+ assertKind(graph.nodes, justificationKind, "justification", "node", graph.id);
108
+ for (const kind of factKinds) {
109
+ assertKind(graph.nodes, kind, "fact", "node", graph.id);
110
+ }
111
+ for (const kind of sourceKinds)
112
+ assertSourceField(graph, kind, retractedField);
113
+ assertKind(graph.edges, premiseOfKind, "premiseOf", "edge", graph.id);
114
+ assertKind(graph.edges, derivesKind, "derives", "edge", graph.id);
115
+ if (factKinds.some(
116
+ (kind) => sourceKinds.includes(kind) || kind === justificationKind
117
+ )) {
118
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
119
+ "Provenance fact kinds must be distinct from source and justification kinds.",
120
+ { sourceKinds, justificationKind, factKinds }
121
+ );
122
+ }
123
+ assertEdgeEndpoints(graph, premiseOfKind, {
124
+ role: "premiseOf",
125
+ fromKinds: sourceKinds,
126
+ toKinds: [justificationKind]
127
+ });
128
+ assertEdgeEndpoints(graph, derivesKind, {
129
+ role: "derives",
130
+ fromKinds: [justificationKind],
131
+ toKinds: factKinds
132
+ });
133
+ return {
134
+ sourceKinds,
135
+ retractedField,
136
+ justificationKind,
137
+ factKinds,
138
+ premiseOfKind,
139
+ derivesKind
140
+ };
141
+ }
142
+ function sourceKindsFromConfig(source) {
143
+ if ("kinds" in source) return [...source.kinds];
144
+ return [source.kind];
145
+ }
146
+ function duplicateValues(values) {
147
+ const seen = /* @__PURE__ */ new Set();
148
+ const duplicates = /* @__PURE__ */ new Set();
149
+ for (const value of values) {
150
+ if (seen.has(value)) {
151
+ duplicates.add(value);
152
+ continue;
153
+ }
154
+ seen.add(value);
155
+ }
156
+ return [...duplicates].toSorted((left, right) => chunkA42GCBGX_cjs.compareStrings(left, right));
157
+ }
158
+ function assertKind(records, kind, role, noun, graphId) {
159
+ if (Object.hasOwn(records, kind)) return;
160
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
161
+ `Provenance ${role} kind "${kind}" is not a ${noun} kind in this graph.`,
162
+ { role, kind, graphId }
163
+ );
164
+ }
165
+ function assertSourceField(graph, sourceKind, retractedField) {
166
+ const registration = graph.nodes[sourceKind];
167
+ if (registration === void 0) return;
168
+ if (Object.hasOwn(registration.type.schema.shape, retractedField)) return;
169
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
170
+ `Provenance source kind "${sourceKind}" must include field "${retractedField}".`,
171
+ { sourceKind, retractedField },
172
+ {
173
+ suggestion: "Add a boolean retracted flag to the source node schema or pass source.retractedField."
174
+ }
175
+ );
176
+ }
177
+ function assertEdgeEndpoints(graph, edgeKind, expected) {
178
+ const registration = graph.edges[edgeKind];
179
+ if (registration === void 0) return;
180
+ const fromKinds = new Set(registration.from.map((node) => node.kind));
181
+ const toKinds = new Set(registration.to.map((node) => node.kind));
182
+ for (const kind of expected.fromKinds) {
183
+ if (fromKinds.has(kind)) continue;
184
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
185
+ `Provenance ${expected.role} edge "${edgeKind}" cannot start at "${kind}".`,
186
+ { edgeKind, role: expected.role, expectedFrom: kind }
187
+ );
188
+ }
189
+ for (const kind of expected.toKinds) {
190
+ if (toKinds.has(kind)) continue;
191
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
192
+ `Provenance ${expected.role} edge "${edgeKind}" cannot end at "${kind}".`,
193
+ { edgeKind, role: expected.role, expectedTo: kind }
194
+ );
195
+ }
196
+ }
197
+ function isValidAt(row, asOf) {
198
+ return (row.valid_from === void 0 || row.valid_from <= asOf) && (row.valid_to === void 0 || row.valid_to > asOf);
199
+ }
200
+ async function findNodeRows(backend, graphId, kind, options) {
201
+ if (options.includeTombstones) {
202
+ const rows = await backend.findNodesByKind({
203
+ graphId,
204
+ kind,
205
+ excludeDeleted: false,
206
+ temporalMode: "includeTombstones",
207
+ orderBy: "id"
208
+ });
209
+ return rows.filter((row) => isValidAt(row, options.asOf));
210
+ }
211
+ return backend.findNodesByKind({
212
+ graphId,
213
+ kind,
214
+ excludeDeleted: true,
215
+ temporalMode: "current",
216
+ asOf: options.asOf,
217
+ orderBy: "id"
218
+ });
219
+ }
220
+ async function findEdgeRows(backend, graphId, kind, asOf) {
221
+ return backend.findEdgesByKind({
222
+ graphId,
223
+ kind,
224
+ excludeDeleted: true,
225
+ temporalMode: "current",
226
+ asOf,
227
+ orderBy: "id"
228
+ });
229
+ }
230
+ async function readRoles(backend, graphId, config, asOf) {
231
+ const [justificationRows, factRowsByKind, premiseEdges, deriveEdges] = await Promise.all([
232
+ findNodeRows(backend, graphId, config.justificationKind, {
233
+ includeTombstones: false,
234
+ asOf
235
+ }),
236
+ Promise.all(
237
+ config.factKinds.map(
238
+ (kind) => findNodeRows(backend, graphId, kind, {
239
+ includeTombstones: true,
240
+ asOf
241
+ })
242
+ )
243
+ ),
244
+ findEdgeRows(backend, graphId, config.premiseOfKind, asOf),
245
+ findEdgeRows(backend, graphId, config.derivesKind, asOf)
246
+ ]);
247
+ const factRows = factRowsByKind.flat();
248
+ return {
249
+ justifications: rowsByKey(justificationRows),
250
+ facts: rowsByKey(factRows),
251
+ premiseEdges,
252
+ deriveEdges
253
+ };
254
+ }
255
+ function rowsByKey(rows) {
256
+ const byKey = /* @__PURE__ */ new Map();
257
+ for (const row of rows) byKey.set(rowKey(row), row);
258
+ return byKey;
259
+ }
260
+ function appendGroupedValue(groups, key, value) {
261
+ const group = groups.get(key);
262
+ if (group === void 0) {
263
+ groups.set(key, [value]);
264
+ return;
265
+ }
266
+ if (group.includes(value)) return;
267
+ group.push(value);
268
+ }
269
+ function buildSupportEdges(config, rows) {
270
+ const premisesByJustification = /* @__PURE__ */ new Map();
271
+ const factsByJustification = /* @__PURE__ */ new Map();
272
+ const justificationsByPremise = /* @__PURE__ */ new Map();
273
+ for (const edge of rows.premiseEdges) {
274
+ if (edge.to_kind !== config.justificationKind) continue;
275
+ if (!isPremiseKind(config, edge.from_kind)) continue;
276
+ const premiseKey = edgeFromKey(edge);
277
+ const justificationKey = edgeToKey(edge);
278
+ appendGroupedValue(premisesByJustification, justificationKey, premiseKey);
279
+ appendGroupedValue(justificationsByPremise, premiseKey, justificationKey);
280
+ }
281
+ for (const edge of rows.deriveEdges) {
282
+ if (edge.from_kind !== config.justificationKind) continue;
283
+ if (!config.factKinds.includes(edge.to_kind)) continue;
284
+ appendGroupedValue(
285
+ factsByJustification,
286
+ edgeFromKey(edge),
287
+ edgeToKey(edge)
288
+ );
289
+ }
290
+ return {
291
+ premisesByJustification,
292
+ factsByJustification,
293
+ justificationsByPremise
294
+ };
295
+ }
296
+ async function loadSupportGraph(backend, graphId, config) {
297
+ const asOf = chunkBLZDPRXT_cjs.nowIso();
298
+ const roles = await readRoles(backend, graphId, config, asOf);
299
+ const supportEdges = buildSupportEdges(config, roles);
300
+ const sourceRowsByKind = await Promise.all(
301
+ config.sourceKinds.map(
302
+ (kind) => findNodeRows(backend, graphId, kind, { includeTombstones: false, asOf })
303
+ )
304
+ );
305
+ return { roles, supportEdges, sourceRows: sourceRowsByKind.flat() };
306
+ }
307
+ function availableSourceKeys(sourceRows, retractedField) {
308
+ const available = /* @__PURE__ */ new Set();
309
+ for (const row of sourceRows) {
310
+ if (sourceRetractedState(row, retractedField) === "available") {
311
+ available.add(rowKey(row));
312
+ }
313
+ }
314
+ return available;
315
+ }
316
+ function computeSupportSnapshot(graph, available) {
317
+ const { roles, supportEdges } = graph;
318
+ const supported = /* @__PURE__ */ new Set();
319
+ const inSet = new Set(available);
320
+ const firingJustifications = /* @__PURE__ */ new Set();
321
+ const firingJustificationKeysByFact = /* @__PURE__ */ new Map();
322
+ let changed = true;
323
+ while (changed) {
324
+ changed = false;
325
+ for (const [justificationKey] of roles.justifications) {
326
+ if (firingJustifications.has(justificationKey)) continue;
327
+ const premises = supportEdges.premisesByJustification.get(justificationKey) ?? [];
328
+ if (!allPremisesSupported(premises, inSet)) continue;
329
+ firingJustifications.add(justificationKey);
330
+ const derivedFacts = supportEdges.factsByJustification.get(justificationKey) ?? [];
331
+ for (const factKey of derivedFacts) {
332
+ if (!roles.facts.has(factKey)) continue;
333
+ appendGroupedValue(
334
+ firingJustificationKeysByFact,
335
+ factKey,
336
+ justificationKey
337
+ );
338
+ if (supported.has(factKey)) continue;
339
+ supported.add(factKey);
340
+ inSet.add(factKey);
341
+ changed = true;
342
+ }
343
+ }
344
+ }
345
+ const believed = /* @__PURE__ */ new Set();
346
+ for (const key of supported) {
347
+ const row = roles.facts.get(key);
348
+ if (row !== void 0 && row.deleted_at === void 0) believed.add(key);
349
+ }
350
+ return {
351
+ facts: roles.facts,
352
+ supportedFactKeys: supported,
353
+ believedFactKeys: believed,
354
+ firingJustificationKeysByFact,
355
+ affectedFactKeys(targets) {
356
+ return computeAffectedFactKeys(targets, roles, supportEdges);
357
+ }
358
+ };
359
+ }
360
+ async function computeSupport(backend, graphId, config) {
361
+ const graph = await loadSupportGraph(backend, graphId, config);
362
+ return computeSupportSnapshot(
363
+ graph,
364
+ availableSourceKeys(graph.sourceRows, config.retractedField)
365
+ );
366
+ }
367
+ function isPremiseKind(config, kind) {
368
+ return config.sourceKinds.includes(kind) || config.factKinds.includes(kind);
369
+ }
370
+ function allPremisesSupported(premises, supported) {
371
+ for (const premise of premises) {
372
+ if (!supported.has(premise)) return false;
373
+ }
374
+ return true;
375
+ }
376
+ function computeAffectedFactKeys(sources, roles, supportEdges) {
377
+ const affected = /* @__PURE__ */ new Set();
378
+ const frontier = sources.map((source) => refKey(source));
379
+ const seen = new Set(frontier);
380
+ while (frontier.length > 0) {
381
+ const current = frontier.shift();
382
+ if (current === void 0) continue;
383
+ const justifications = supportEdges.justificationsByPremise.get(current) ?? [];
384
+ for (const justificationKey of justifications) {
385
+ const derivedFacts = supportEdges.factsByJustification.get(justificationKey) ?? [];
386
+ for (const factKey of derivedFacts) {
387
+ if (!roles.facts.has(factKey)) continue;
388
+ affected.add(factKey);
389
+ if (seen.has(factKey)) continue;
390
+ seen.add(factKey);
391
+ frontier.push(factKey);
392
+ }
393
+ }
394
+ }
395
+ return affected;
396
+ }
397
+ function buildReport(before, after, affected) {
398
+ const believedBefore = [...before.believedFactKeys];
399
+ const died = sortedReferences(
400
+ believedBefore.filter((key) => !after.supportedFactKeys.has(key))
401
+ );
402
+ const unaffected = sortedReferences(
403
+ believedBefore.filter((key) => !affected.has(key))
404
+ );
405
+ const survivedVia = [...affected].filter((key) => after.supportedFactKeys.has(key)).toSorted((left, right) => chunkA42GCBGX_cjs.compareStrings(left, right)).map((key) => ({
406
+ fact: keyToRef(key),
407
+ via: sortedReferences(
408
+ after.firingJustificationKeysByFact.get(key) ?? []
409
+ )
410
+ }));
411
+ return { died, survivedVia, unaffected };
412
+ }
413
+ async function forEachAffectedFact(snapshot, affected, isTargetKey, isTargetRow, action) {
414
+ const rows = [];
415
+ for (const [key, row] of snapshot.facts) {
416
+ if (!affected.has(key)) continue;
417
+ if (!isTargetKey(key)) continue;
418
+ if (!isTargetRow(row)) continue;
419
+ rows.push(row);
420
+ }
421
+ await Promise.all(rows.map((row) => action(row)));
422
+ }
423
+ async function synchronizeFactCurrency(backend, store, runHooks, snapshot, affected, lock) {
424
+ await forEachAffectedFact(
425
+ snapshot,
426
+ affected,
427
+ (key) => !snapshot.supportedFactKeys.has(key),
428
+ chunk4TOD4LBZ_cjs.isLiveNodeRow,
429
+ (row) => closeFactCurrency(backend, store, runHooks, row, lock)
430
+ );
431
+ await forEachAffectedFact(
432
+ snapshot,
433
+ affected,
434
+ (key) => snapshot.supportedFactKeys.has(key),
435
+ chunk4TOD4LBZ_cjs.isTombstonedNodeRow,
436
+ (row) => reopenFactCurrency(backend, store, runHooks, row, lock)
437
+ );
438
+ }
439
+ function getFactRegistration(store, row) {
440
+ const registration = store.graph.nodes[row.kind];
441
+ if (registration !== void 0) return registration;
442
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
443
+ `Provenance fact kind "${row.kind}" is not a node kind in this graph.`,
444
+ { kind: row.kind, graphId: store.graphId }
445
+ );
446
+ }
447
+ async function closeFactCurrency(backend, store, runHooks, row, lock) {
448
+ await runHooks("delete", row.kind, row.id, async () => {
449
+ const registration = getFactRegistration(store, row);
450
+ await chunkXOX22WHL_cjs.applyNodeSoftDelete(
451
+ chunkXOX22WHL_cjs.createNodeWriteContext(store.graphId, store.registry, lock),
452
+ {
453
+ existing: row,
454
+ schema: registration.type.schema,
455
+ uniqueConstraints: registration.unique ?? [],
456
+ onDelete: registration.onDelete
457
+ },
458
+ backend,
459
+ { enforceDeleteBehavior: false }
460
+ );
461
+ });
462
+ }
463
+ async function reopenFactCurrency(backend, store, runHooks, row, lock) {
464
+ await runHooks("update", row.kind, row.id, async () => {
465
+ const registration = getFactRegistration(store, row);
466
+ await chunkXOX22WHL_cjs.applyNodeResurrect(
467
+ chunkXOX22WHL_cjs.createNodeWriteContext(store.graphId, store.registry, lock),
468
+ {
469
+ existing: row,
470
+ schema: registration.type.schema,
471
+ uniqueConstraints: registration.unique ?? []
472
+ },
473
+ backend
474
+ );
475
+ });
476
+ }
477
+ function getTransactionNodeCollection(tx, kind) {
478
+ const collection = tx.getNodeCollection(kind);
479
+ if (collection !== void 0) return collection;
480
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
481
+ `Provenance source kind "${kind}" is not available on this transaction.`,
482
+ { kind }
483
+ );
484
+ }
485
+ async function setSourceRetractionState(tx, config, source, retracted) {
486
+ const collection = getTransactionNodeCollection(tx, source.kind);
487
+ await collection.update(source.id, { [config.retractedField]: retracted });
488
+ }
489
+ async function runTransition(store, config, sources, retracted) {
490
+ const uniqueSources = uniqueNodeReferences(sources);
491
+ for (const source of uniqueSources) {
492
+ if (config.sourceKinds.includes(source.kind)) continue;
493
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
494
+ `Provenance retraction source must be one of: ${config.sourceKinds.join(", ")}.`,
495
+ { expectedKinds: config.sourceKinds, actualKind: source.kind }
496
+ );
497
+ }
498
+ return store.transaction(async (tx) => {
499
+ const lock = await chunkXOX22WHL_cjs.lockRecordedGraphWrite(tx.backend, store.graphId);
500
+ const rows = await Promise.all(
501
+ uniqueSources.map(
502
+ (source) => tx.backend.getNode(store.graphId, source.kind, source.id)
503
+ )
504
+ );
505
+ const sourceRows = uniqueSources.map((source, index) => {
506
+ const sourceRow = rows[index];
507
+ if (sourceRow === void 0 || sourceRow.deleted_at !== void 0) {
508
+ throw new chunkLGEALRC6_cjs.NodeNotFoundError(source.kind, source.id);
509
+ }
510
+ return { source, row: sourceRow };
511
+ });
512
+ const supportGraph = await loadSupportGraph(
513
+ tx.backend,
514
+ store.graphId,
515
+ config
516
+ );
517
+ const availableBefore = availableSourceKeys(
518
+ supportGraph.sourceRows,
519
+ config.retractedField
520
+ );
521
+ const before = computeSupportSnapshot(supportGraph, availableBefore);
522
+ const nextState = retracted ? "retracted" : "available";
523
+ const availableAfter = new Set(availableBefore);
524
+ for (const { source, row } of sourceRows) {
525
+ const currentState = sourceRetractedState(row, config.retractedField);
526
+ if (currentState === nextState) continue;
527
+ await setSourceRetractionState(tx, config, source, retracted);
528
+ if (nextState === "available") {
529
+ availableAfter.add(refKey(source));
530
+ } else {
531
+ availableAfter.delete(refKey(source));
532
+ }
533
+ }
534
+ const after = computeSupportSnapshot(supportGraph, availableAfter);
535
+ const affected = after.affectedFactKeys(uniqueSources);
536
+ await synchronizeFactCurrency(
537
+ tx.backend,
538
+ store,
539
+ tx.runNodeOperationHooks,
540
+ after,
541
+ affected,
542
+ lock
543
+ );
544
+ return buildReport(before, after, affected);
545
+ });
546
+ }
547
+ function uniqueNodeReferences(references) {
548
+ const byKey = /* @__PURE__ */ new Map();
549
+ for (const reference of references) {
550
+ byKey.set(refKey(reference), reference);
551
+ }
552
+ return [...byKey.values()];
553
+ }
554
+ function createRetractionCapability(store, config) {
555
+ const historyEnabled = store.historyEnabled;
556
+ if (!historyEnabled) {
557
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
558
+ "createRetractionCapability requires a store created with { history: true }.",
559
+ { graphId: store.graphId },
560
+ {
561
+ suggestion: "Use createStoreWithSchema(graph, backend, { history: true }) so retraction mutations are captured and queryable with asOfRecorded()."
562
+ }
563
+ );
564
+ }
565
+ const normalized = normalizeConfig(store.graph, config);
566
+ const transition = (sources, retracted) => runTransition(store, normalized, sources, retracted);
567
+ return {
568
+ retract: (source) => transition([source], true),
569
+ retractMany: (sources) => transition(sources, true),
570
+ unRetract: (source) => transition([source], false),
571
+ unRetractMany: (sources) => transition(sources, false),
572
+ async holding() {
573
+ return store.transaction(async (tx) => {
574
+ await chunkXOX22WHL_cjs.lockRecordedGraphWrite(tx.backend, store.graphId);
575
+ const snapshot = await computeSupport(
576
+ tx.backend,
577
+ store.graphId,
578
+ normalized
579
+ );
580
+ return sortedReferences(
581
+ snapshot.believedFactKeys
582
+ );
583
+ });
584
+ }
585
+ };
586
+ }
587
+
588
+ exports.createRetractionCapability = createRetractionCapability;
589
+ //# sourceMappingURL=index.cjs.map
590
+ //# sourceMappingURL=index.cjs.map