@nicia-ai/typegraph 0.34.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/dist/backend/postgres/index.cjs +29 -29
  2. package/dist/backend/postgres/index.d.cts +39 -7
  3. package/dist/backend/postgres/index.d.ts +39 -7
  4. package/dist/backend/postgres/index.js +16 -16
  5. package/dist/backend/postgres/pglite.cjs +21 -21
  6. package/dist/backend/postgres/pglite.d.cts +4 -4
  7. package/dist/backend/postgres/pglite.d.ts +4 -4
  8. package/dist/backend/postgres/pglite.js +16 -16
  9. package/dist/backend/sqlite/index.cjs +25 -26
  10. package/dist/backend/sqlite/index.d.cts +8 -8
  11. package/dist/backend/sqlite/index.d.ts +8 -8
  12. package/dist/backend/sqlite/index.js +13 -14
  13. package/dist/backend/sqlite/libsql.cjs +19 -19
  14. package/dist/backend/sqlite/libsql.d.cts +4 -4
  15. package/dist/backend/sqlite/libsql.d.ts +4 -4
  16. package/dist/backend/sqlite/libsql.js +15 -15
  17. package/dist/backend/sqlite/local.cjs +101 -21
  18. package/dist/backend/sqlite/local.cjs.map +1 -1
  19. package/dist/backend/sqlite/local.d.cts +95 -5
  20. package/dist/backend/sqlite/local.d.ts +95 -5
  21. package/dist/backend/sqlite/local.js +95 -16
  22. package/dist/backend/sqlite/local.js.map +1 -1
  23. package/dist/{chunk-ZV5N4DBG.js → chunk-3TWF3SH4.js} +300 -58
  24. package/dist/chunk-3TWF3SH4.js.map +1 -0
  25. package/dist/chunk-4JEZZJ6S.cjs +1271 -0
  26. package/dist/chunk-4JEZZJ6S.cjs.map +1 -0
  27. package/dist/{chunk-UNNPKQUG.cjs → chunk-4TOD4LBZ.cjs} +246 -155
  28. package/dist/chunk-4TOD4LBZ.cjs.map +1 -0
  29. package/dist/{chunk-QV245VMN.js → chunk-55MZDDZV.js} +100 -6
  30. package/dist/chunk-55MZDDZV.js.map +1 -0
  31. package/dist/{chunk-GQANNXXT.cjs → chunk-5A6FNS6N.cjs} +75 -20
  32. package/dist/chunk-5A6FNS6N.cjs.map +1 -0
  33. package/dist/{chunk-3Z6TW3CT.cjs → chunk-5AQIKK56.cjs} +65 -25
  34. package/dist/chunk-5AQIKK56.cjs.map +1 -0
  35. package/dist/{chunk-BVTWD66D.js → chunk-5SEGFTZX.js} +3 -3
  36. package/dist/{chunk-BVTWD66D.js.map → chunk-5SEGFTZX.js.map} +1 -1
  37. package/dist/{chunk-6GNSY7AV.js → chunk-6FR2MMS6.js} +7 -7
  38. package/dist/chunk-6FR2MMS6.js.map +1 -0
  39. package/dist/chunk-7YSP4V4R.cjs +69 -0
  40. package/dist/chunk-7YSP4V4R.cjs.map +1 -0
  41. package/dist/chunk-A42GCBGX.cjs +28 -0
  42. package/dist/chunk-A42GCBGX.cjs.map +1 -0
  43. package/dist/{chunk-RHZWOJVA.cjs → chunk-BLZDPRXT.cjs} +52 -4
  44. package/dist/chunk-BLZDPRXT.cjs.map +1 -0
  45. package/dist/chunk-BYPOGQWK.js +25 -0
  46. package/dist/chunk-BYPOGQWK.js.map +1 -0
  47. package/dist/{chunk-6HVOHZHS.cjs → chunk-CK5BVQOW.cjs} +213 -168
  48. package/dist/chunk-CK5BVQOW.cjs.map +1 -0
  49. package/dist/{chunk-JJRCLAUN.cjs → chunk-CTTSDJLY.cjs} +116 -10
  50. package/dist/chunk-CTTSDJLY.cjs.map +1 -0
  51. package/dist/chunk-CUHM5CWJ.cjs +12 -0
  52. package/dist/chunk-CUHM5CWJ.cjs.map +1 -0
  53. package/dist/{chunk-A7SZZFAG.js → chunk-CZQ3FO2Q.js} +409 -99
  54. package/dist/chunk-CZQ3FO2Q.js.map +1 -0
  55. package/dist/{chunk-2JXB3NYJ.cjs → chunk-D7ZEOS56.cjs} +25 -32
  56. package/dist/chunk-D7ZEOS56.cjs.map +1 -0
  57. package/dist/chunk-DFVLCOP6.js +10 -0
  58. package/dist/chunk-DFVLCOP6.js.map +1 -0
  59. package/dist/{chunk-UJLOZYKT.cjs → chunk-EM3CWPND.cjs} +441 -115
  60. package/dist/chunk-EM3CWPND.cjs.map +1 -0
  61. package/dist/chunk-EMF62TZG.cjs +1176 -0
  62. package/dist/chunk-EMF62TZG.cjs.map +1 -0
  63. package/dist/chunk-EOLERH7Y.cjs +40 -0
  64. package/dist/chunk-EOLERH7Y.cjs.map +1 -0
  65. package/dist/{chunk-TGJE22RM.cjs → chunk-FACJJWGF.cjs} +24 -6
  66. package/dist/chunk-FACJJWGF.cjs.map +1 -0
  67. package/dist/{chunk-HK5SATYM.cjs → chunk-FL472AMI.cjs} +16 -109
  68. package/dist/chunk-FL472AMI.cjs.map +1 -0
  69. package/dist/{chunk-WVC2Q2FD.cjs → chunk-FN35DLCN.cjs} +31 -9
  70. package/dist/chunk-FN35DLCN.cjs.map +1 -0
  71. package/dist/{chunk-KUTNI6SI.js → chunk-FPIZFYHE.js} +10 -18
  72. package/dist/chunk-FPIZFYHE.js.map +1 -0
  73. package/dist/{chunk-VCGO4V26.js → chunk-FRV5Q5IO.js} +64 -9
  74. package/dist/chunk-FRV5Q5IO.js.map +1 -0
  75. package/dist/{chunk-K5P5OZXS.js → chunk-G6Q5UM7U.js} +2 -2
  76. package/dist/{chunk-K5P5OZXS.js.map → chunk-G6Q5UM7U.js.map} +1 -1
  77. package/dist/chunk-GSQ6NPH6.cjs +100 -0
  78. package/dist/chunk-GSQ6NPH6.cjs.map +1 -0
  79. package/dist/chunk-GUR2FNB5.cjs +12 -0
  80. package/dist/{chunk-HMFK4BXR.cjs.map → chunk-GUR2FNB5.cjs.map} +1 -1
  81. package/dist/{chunk-JQGIPGVL.cjs → chunk-H7YNSMA7.cjs} +43 -2
  82. package/dist/chunk-H7YNSMA7.cjs.map +1 -0
  83. package/dist/{chunk-2MRAX3UE.js → chunk-I7ZUZKFD.js} +47 -4
  84. package/dist/chunk-I7ZUZKFD.js.map +1 -0
  85. package/dist/{chunk-3BRVBQQD.cjs → chunk-J7WFGBJR.cjs} +2445 -2367
  86. package/dist/chunk-J7WFGBJR.cjs.map +1 -0
  87. package/dist/{chunk-V3QNTB7Z.js → chunk-JBTOYDMN.js} +194 -114
  88. package/dist/chunk-JBTOYDMN.js.map +1 -0
  89. package/dist/{chunk-K2TGS3EN.js → chunk-K3PPLHY7.js} +138 -89
  90. package/dist/chunk-K3PPLHY7.js.map +1 -0
  91. package/dist/{chunk-Z5XBMDXU.js → chunk-KBGQIPRQ.js} +42 -3
  92. package/dist/chunk-KBGQIPRQ.js.map +1 -0
  93. package/dist/chunk-KMI7LYAF.js +1252 -0
  94. package/dist/chunk-KMI7LYAF.js.map +1 -0
  95. package/dist/{chunk-JIEJCTDS.cjs → chunk-LGEALRC6.cjs} +21 -4
  96. package/dist/chunk-LGEALRC6.cjs.map +1 -0
  97. package/dist/{chunk-TQOYM4LN.js → chunk-MP2JQKSG.js} +21 -5
  98. package/dist/chunk-MP2JQKSG.js.map +1 -0
  99. package/dist/{chunk-ZP5WHI4C.cjs → chunk-O7UN7OXA.cjs} +358 -116
  100. package/dist/chunk-O7UN7OXA.cjs.map +1 -0
  101. package/dist/chunk-OHMP6N2J.js +47 -0
  102. package/dist/chunk-OHMP6N2J.js.map +1 -0
  103. package/dist/{chunk-4DIBPQNJ.js → chunk-OR5ZA5WP.js} +135 -25
  104. package/dist/chunk-OR5ZA5WP.js.map +1 -0
  105. package/dist/{chunk-DEQFL35G.js → chunk-Q5TEXCTB.js} +61 -7
  106. package/dist/chunk-Q5TEXCTB.js.map +1 -0
  107. package/dist/chunk-QNKSQTKQ.js +1312 -0
  108. package/dist/chunk-QNKSQTKQ.js.map +1 -0
  109. package/dist/{chunk-ZURTTSCM.js → chunk-QOTI55H7.js} +6 -94
  110. package/dist/chunk-QOTI55H7.js.map +1 -0
  111. package/dist/{chunk-CHXTTSC6.js → chunk-QWEUYILR.js} +104 -5
  112. package/dist/chunk-QWEUYILR.js.map +1 -0
  113. package/dist/{chunk-LANHCOXB.js → chunk-RGP33ZJ5.js} +485 -83
  114. package/dist/chunk-RGP33ZJ5.js.map +1 -0
  115. package/dist/chunk-RGPG7EOJ.js +94 -0
  116. package/dist/chunk-RGPG7EOJ.js.map +1 -0
  117. package/dist/{chunk-G6SOJEDI.cjs → chunk-S55OV6PW.cjs} +15 -15
  118. package/dist/chunk-S55OV6PW.cjs.map +1 -0
  119. package/dist/{chunk-3E7SNSIA.cjs → chunk-SJDMVITW.cjs} +4 -4
  120. package/dist/{chunk-3E7SNSIA.cjs.map → chunk-SJDMVITW.cjs.map} +1 -1
  121. package/dist/{chunk-XLUNB2TZ.js → chunk-SNXVDZAJ.js} +3 -3
  122. package/dist/{chunk-XLUNB2TZ.js.map → chunk-SNXVDZAJ.js.map} +1 -1
  123. package/dist/{chunk-RBV7YCQD.js → chunk-T2WUSPDA.js} +49 -9
  124. package/dist/chunk-T2WUSPDA.js.map +1 -0
  125. package/dist/{chunk-KGC4LY5T.cjs → chunk-TCOCYN2P.cjs} +75 -21
  126. package/dist/chunk-TCOCYN2P.cjs.map +1 -0
  127. package/dist/{chunk-FLRCVI2G.cjs → chunk-TDXIBCGY.cjs} +2 -2
  128. package/dist/{chunk-FLRCVI2G.cjs.map → chunk-TDXIBCGY.cjs.map} +1 -1
  129. package/dist/{chunk-ZY4GXIVN.cjs → chunk-TEDRJXOG.cjs} +5 -5
  130. package/dist/{chunk-ZY4GXIVN.cjs.map → chunk-TEDRJXOG.cjs.map} +1 -1
  131. package/dist/{chunk-WLRIWYHQ.js → chunk-UES55P7G.js} +1863 -1785
  132. package/dist/chunk-UES55P7G.js.map +1 -0
  133. package/dist/{chunk-WL2SG7ZV.cjs → chunk-UMDVATGY.cjs} +6 -6
  134. package/dist/{chunk-WL2SG7ZV.cjs.map → chunk-UMDVATGY.cjs.map} +1 -1
  135. package/dist/chunk-UT3S4SEN.js +31 -0
  136. package/dist/chunk-UT3S4SEN.js.map +1 -0
  137. package/dist/{chunk-RRKQAKD6.cjs → chunk-UUT7UN2N.cjs} +149 -39
  138. package/dist/chunk-UUT7UN2N.cjs.map +1 -0
  139. package/dist/{chunk-SHLY4MCM.js → chunk-UZV3AZKF.js} +21 -3
  140. package/dist/chunk-UZV3AZKF.js.map +1 -0
  141. package/dist/{chunk-CYX2JTDG.js → chunk-VHMPG6UL.js} +29 -7
  142. package/dist/chunk-VHMPG6UL.js.map +1 -0
  143. package/dist/{chunk-T6SPUYLX.cjs → chunk-VPYHY3LJ.cjs} +116 -10
  144. package/dist/chunk-VPYHY3LJ.cjs.map +1 -0
  145. package/dist/{chunk-T46GR2VY.js → chunk-VSPCZAXF.js} +3 -3
  146. package/dist/{chunk-T46GR2VY.js.map → chunk-VSPCZAXF.js.map} +1 -1
  147. package/dist/{chunk-K34OPSJK.js → chunk-W63OVYY4.js} +3 -3
  148. package/dist/{chunk-K34OPSJK.js.map → chunk-W63OVYY4.js.map} +1 -1
  149. package/dist/{chunk-RY2VIWAM.js → chunk-WDBCBWC4.js} +355 -32
  150. package/dist/chunk-WDBCBWC4.js.map +1 -0
  151. package/dist/chunk-WJT7OU7E.cjs +1334 -0
  152. package/dist/chunk-WJT7OU7E.cjs.map +1 -0
  153. package/dist/{chunk-5IQIX7LU.cjs → chunk-XOX22WHL.cjs} +476 -163
  154. package/dist/chunk-XOX22WHL.cjs.map +1 -0
  155. package/dist/{ddl-BrmPg61z.d.ts → ddl-C2rZ-Aen.d.ts} +4 -4
  156. package/dist/{ddl-j1-sH6lE.d.cts → ddl-CZz7a0E8.d.cts} +4 -4
  157. package/dist/{extension-types-YGFJPrzK.d.cts → extension-types-ixRpJVUp.d.cts} +24 -1
  158. package/dist/{extension-types-YGFJPrzK.d.ts → extension-types-ixRpJVUp.d.ts} +24 -1
  159. package/dist/{types-DkNnF-7K.d.cts → fulltext-strategy-B57yvC5Q.d.ts} +2562 -2133
  160. package/dist/{types-D1Sqeyxy.d.ts → fulltext-strategy-CDkSSYhq.d.cts} +2562 -2133
  161. package/dist/graph-extension/index.cjs +20 -19
  162. package/dist/graph-extension/index.d.cts +4 -4
  163. package/dist/graph-extension/index.d.ts +4 -4
  164. package/dist/graph-extension/index.js +5 -4
  165. package/dist/graph-merge/index.cjs +255 -164
  166. package/dist/graph-merge/index.cjs.map +1 -1
  167. package/dist/graph-merge/index.d.cts +63 -33
  168. package/dist/graph-merge/index.d.ts +63 -33
  169. package/dist/graph-merge/index.js +135 -44
  170. package/dist/graph-merge/index.js.map +1 -1
  171. package/dist/{index-DGX6D9j1.d.ts → index-6CSUAq-x.d.ts} +234 -93
  172. package/dist/{index-SEvUHDA6.d.cts → index-Bks_3HHK.d.cts} +234 -93
  173. package/dist/index.cjs +208 -188
  174. package/dist/index.d.cts +11 -11
  175. package/dist/index.d.ts +11 -11
  176. package/dist/index.js +33 -33
  177. package/dist/indexes/index.cjs +19 -20
  178. package/dist/indexes/index.d.cts +5 -5
  179. package/dist/indexes/index.d.ts +5 -5
  180. package/dist/indexes/index.js +10 -11
  181. package/dist/interchange/index.cjs +47 -26
  182. package/dist/interchange/index.d.cts +126 -12
  183. package/dist/interchange/index.d.ts +126 -12
  184. package/dist/interchange/index.js +14 -13
  185. package/dist/{manager-ms9cKdc6.d.cts → manager-DwQi8eV0.d.cts} +9 -2
  186. package/dist/{manager-BZUeN_BU.d.ts → manager-ejUCB52T.d.ts} +9 -2
  187. package/dist/{materialize-indexes-D20xNluI.d.cts → materialize-indexes-B4e9360H.d.cts} +20 -4
  188. package/dist/{materialize-indexes-CAkIYFV-.d.ts → materialize-indexes-te9TPMMJ.d.ts} +20 -4
  189. package/dist/{postgres-BhpxGMC5.d.cts → postgres-CfEqsRMp.d.cts} +152 -1
  190. package/dist/{postgres-CWHLwNl1.d.ts → postgres-DQ5R6rzV.d.ts} +152 -1
  191. package/dist/profiler/index.cjs +11 -11
  192. package/dist/profiler/index.d.cts +7 -7
  193. package/dist/profiler/index.d.ts +7 -7
  194. package/dist/profiler/index.js +4 -4
  195. package/dist/provenance/index.cjs +40 -41
  196. package/dist/provenance/index.cjs.map +1 -1
  197. package/dist/provenance/index.d.cts +5 -5
  198. package/dist/provenance/index.d.ts +5 -5
  199. package/dist/provenance/index.js +11 -12
  200. package/dist/provenance/index.js.map +1 -1
  201. package/dist/schema/index.cjs +53 -40
  202. package/dist/schema/index.cjs.map +1 -1
  203. package/dist/schema/index.d.cts +57 -57
  204. package/dist/schema/index.d.ts +57 -57
  205. package/dist/schema/index.js +28 -15
  206. package/dist/schema/index.js.map +1 -1
  207. package/dist/{sqlite-XrDxNaa7.d.cts → sqlite-D7zBinNR.d.cts} +92 -1
  208. package/dist/{sqlite-CGu5SLsw.d.ts → sqlite-DvQndLky.d.ts} +92 -1
  209. package/dist/{store-view-D09po4H6.d.cts → store-view-BSpqvAxK.d.cts} +415 -44
  210. package/dist/{store-view-BlgnhEYf.d.ts → store-view-CKbHFRnn.d.ts} +415 -44
  211. package/dist/{types-DiE1AO7p.d.cts → types-Bv9DcS_E.d.cts} +2 -2
  212. package/dist/{types-B1TbZJYS.d.ts → types-CoxuV7EJ.d.ts} +2 -2
  213. package/dist/{where-DKjuofPr.d.cts → where-7RKFOsXt.d.ts} +2 -2
  214. package/dist/{where-DrUIIWHb.d.ts → where-DdMIXOtH.d.cts} +2 -2
  215. package/package.json +14 -13
  216. package/dist/chunk-2EBMPJBO.js +0 -16
  217. package/dist/chunk-2EBMPJBO.js.map +0 -1
  218. package/dist/chunk-2JXB3NYJ.cjs.map +0 -1
  219. package/dist/chunk-2MRAX3UE.js.map +0 -1
  220. package/dist/chunk-3BRVBQQD.cjs.map +0 -1
  221. package/dist/chunk-3EUKJEQ3.js +0 -77
  222. package/dist/chunk-3EUKJEQ3.js.map +0 -1
  223. package/dist/chunk-3Z6TW3CT.cjs.map +0 -1
  224. package/dist/chunk-4DIBPQNJ.js.map +0 -1
  225. package/dist/chunk-4S2FXGBJ.js +0 -9
  226. package/dist/chunk-4S2FXGBJ.js.map +0 -1
  227. package/dist/chunk-5IQIX7LU.cjs.map +0 -1
  228. package/dist/chunk-6GNSY7AV.js.map +0 -1
  229. package/dist/chunk-6HVOHZHS.cjs.map +0 -1
  230. package/dist/chunk-6SCVW4AS.js +0 -20
  231. package/dist/chunk-6SCVW4AS.js.map +0 -1
  232. package/dist/chunk-A7SZZFAG.js.map +0 -1
  233. package/dist/chunk-CHXTTSC6.js.map +0 -1
  234. package/dist/chunk-CYX2JTDG.js.map +0 -1
  235. package/dist/chunk-DEQFL35G.js.map +0 -1
  236. package/dist/chunk-G6SOJEDI.cjs.map +0 -1
  237. package/dist/chunk-GQANNXXT.cjs.map +0 -1
  238. package/dist/chunk-GZCNZ7QW.js +0 -24
  239. package/dist/chunk-GZCNZ7QW.js.map +0 -1
  240. package/dist/chunk-HK5SATYM.cjs.map +0 -1
  241. package/dist/chunk-HMFK4BXR.cjs +0 -12
  242. package/dist/chunk-HTGDWIDE.cjs +0 -89
  243. package/dist/chunk-HTGDWIDE.cjs.map +0 -1
  244. package/dist/chunk-JIEJCTDS.cjs.map +0 -1
  245. package/dist/chunk-JJRCLAUN.cjs.map +0 -1
  246. package/dist/chunk-JQGIPGVL.cjs.map +0 -1
  247. package/dist/chunk-K2TGS3EN.js.map +0 -1
  248. package/dist/chunk-KGC4LY5T.cjs.map +0 -1
  249. package/dist/chunk-KNHYNQQ3.cjs +0 -663
  250. package/dist/chunk-KNHYNQQ3.cjs.map +0 -1
  251. package/dist/chunk-KUTNI6SI.js.map +0 -1
  252. package/dist/chunk-LANHCOXB.js.map +0 -1
  253. package/dist/chunk-N6WTUSBV.cjs +0 -23
  254. package/dist/chunk-N6WTUSBV.cjs.map +0 -1
  255. package/dist/chunk-NAUA4PW5.cjs +0 -28
  256. package/dist/chunk-NAUA4PW5.cjs.map +0 -1
  257. package/dist/chunk-QV245VMN.js.map +0 -1
  258. package/dist/chunk-RBV7YCQD.js.map +0 -1
  259. package/dist/chunk-RHZWOJVA.cjs.map +0 -1
  260. package/dist/chunk-RRKQAKD6.cjs.map +0 -1
  261. package/dist/chunk-RY2VIWAM.js.map +0 -1
  262. package/dist/chunk-SHLY4MCM.js.map +0 -1
  263. package/dist/chunk-T2DWPQNE.js +0 -649
  264. package/dist/chunk-T2DWPQNE.js.map +0 -1
  265. package/dist/chunk-T6SPUYLX.cjs.map +0 -1
  266. package/dist/chunk-TGJE22RM.cjs.map +0 -1
  267. package/dist/chunk-TOTPVGOG.cjs +0 -774
  268. package/dist/chunk-TOTPVGOG.cjs.map +0 -1
  269. package/dist/chunk-TQOYM4LN.js.map +0 -1
  270. package/dist/chunk-UJLOZYKT.cjs.map +0 -1
  271. package/dist/chunk-UNNPKQUG.cjs.map +0 -1
  272. package/dist/chunk-V3QNTB7Z.js.map +0 -1
  273. package/dist/chunk-VCGO4V26.js.map +0 -1
  274. package/dist/chunk-WLRIWYHQ.js.map +0 -1
  275. package/dist/chunk-WVC2Q2FD.cjs.map +0 -1
  276. package/dist/chunk-XXVEULWX.js +0 -39
  277. package/dist/chunk-XXVEULWX.js.map +0 -1
  278. package/dist/chunk-YAZE7QZR.cjs +0 -32
  279. package/dist/chunk-YAZE7QZR.cjs.map +0 -1
  280. package/dist/chunk-YC6PWTHY.cjs +0 -44
  281. package/dist/chunk-YC6PWTHY.cjs.map +0 -1
  282. package/dist/chunk-Z5HBYM7U.cjs +0 -11
  283. package/dist/chunk-Z5HBYM7U.cjs.map +0 -1
  284. package/dist/chunk-Z5XBMDXU.js.map +0 -1
  285. package/dist/chunk-ZP5WHI4C.cjs.map +0 -1
  286. package/dist/chunk-ZURTTSCM.js.map +0 -1
  287. package/dist/chunk-ZV5N4DBG.js.map +0 -1
@@ -1,21 +1,20 @@
1
1
  'use strict';
2
2
 
3
- var chunkUNNPKQUG_cjs = require('./chunk-UNNPKQUG.cjs');
4
- var chunkYC6PWTHY_cjs = require('./chunk-YC6PWTHY.cjs');
5
- var chunkRHZWOJVA_cjs = require('./chunk-RHZWOJVA.cjs');
6
- var chunkYAZE7QZR_cjs = require('./chunk-YAZE7QZR.cjs');
7
- var chunkNAUA4PW5_cjs = require('./chunk-NAUA4PW5.cjs');
8
- var chunkJQGIPGVL_cjs = require('./chunk-JQGIPGVL.cjs');
9
- var chunkJIEJCTDS_cjs = require('./chunk-JIEJCTDS.cjs');
3
+ var chunkEOLERH7Y_cjs = require('./chunk-EOLERH7Y.cjs');
4
+ var chunk4TOD4LBZ_cjs = require('./chunk-4TOD4LBZ.cjs');
5
+ var chunkBLZDPRXT_cjs = require('./chunk-BLZDPRXT.cjs');
6
+ var chunk7YSP4V4R_cjs = require('./chunk-7YSP4V4R.cjs');
7
+ var chunkH7YNSMA7_cjs = require('./chunk-H7YNSMA7.cjs');
8
+ var chunkLGEALRC6_cjs = require('./chunk-LGEALRC6.cjs');
10
9
  var drizzleOrm = require('drizzle-orm');
11
10
  var nanoid = require('nanoid');
12
11
 
13
12
  // src/core/temporal.ts
14
13
  var RECORDED_MAX = "9999-12-31T23:59:59.999Z";
15
14
  function assertValidRecordedInstant(value, path) {
16
- chunkYC6PWTHY_cjs.validateCanonicalIsoDate(value, path);
15
+ chunkBLZDPRXT_cjs.validateCanonicalIsoDate(value, path);
17
16
  if (value >= RECORDED_MAX) {
18
- throw new chunkJIEJCTDS_cjs.ValidationError(
17
+ throw new chunkLGEALRC6_cjs.ValidationError(
19
18
  `${path} must be before the recorded-time open sentinel ${RECORDED_MAX}.`,
20
19
  {
21
20
  issues: [
@@ -37,7 +36,7 @@ function asRecordedInstant(value) {
37
36
  }
38
37
  function resolveReadCoordinate(mode, asOf, suggestion) {
39
38
  if (mode !== "asOf" && asOf !== void 0) {
40
- throw new chunkJIEJCTDS_cjs.ValidationError(
39
+ throw new chunkLGEALRC6_cjs.ValidationError(
41
40
  `Temporal mode "${mode}" does not take an asOf timestamp.`,
42
41
  {
43
42
  issues: [
@@ -68,7 +67,7 @@ function withRecordedCoordinate(coordinate, recordedAsOf) {
68
67
  }
69
68
  function assertValidAsOf(mode, asOf, options) {
70
69
  if (mode === "asOf" && asOf === void 0) {
71
- throw new chunkJIEJCTDS_cjs.ValidationError(
70
+ throw new chunkLGEALRC6_cjs.ValidationError(
72
71
  'Temporal mode "asOf" requires a timestamp',
73
72
  {
74
73
  issues: [
@@ -81,7 +80,7 @@ function assertValidAsOf(mode, asOf, options) {
81
80
  );
82
81
  }
83
82
  if (asOf !== void 0) {
84
- chunkYC6PWTHY_cjs.validateCanonicalIsoDate(asOf, "asOf");
83
+ chunkBLZDPRXT_cjs.validateCanonicalIsoDate(asOf, "asOf");
85
84
  }
86
85
  }
87
86
  function describeCoordinate(coordinate) {
@@ -97,17 +96,6 @@ function coordinateContext(coordinate) {
97
96
  ...coordinate.recorded === void 0 ? {} : { recordedAsOf: coordinate.recorded.asOf }
98
97
  };
99
98
  }
100
-
101
- // src/query/sql-intent.ts
102
- function asCompiledRowsSql(query) {
103
- return query;
104
- }
105
- function asCompiledSelectSql(query) {
106
- return asCompiledRowsSql(query);
107
- }
108
- function asCompiledStatementSql(query) {
109
- return query;
110
- }
111
99
  var SqlSchemaDescriptor = class {
112
100
  // Private field gives SqlSchema nominal identity; runtime checks use instanceof.
113
101
  #brand = true;
@@ -117,6 +105,7 @@ var SqlSchemaDescriptor = class {
117
105
  recordedNodesTable;
118
106
  recordedEdgesTable;
119
107
  recordedClockTable;
108
+ revisionOriginsTable;
120
109
  fulltextTable;
121
110
  constructor(fields) {
122
111
  this.tables = fields.tables;
@@ -125,6 +114,7 @@ var SqlSchemaDescriptor = class {
125
114
  this.recordedNodesTable = fields.recordedNodesTable;
126
115
  this.recordedEdgesTable = fields.recordedEdgesTable;
127
116
  this.recordedClockTable = fields.recordedClockTable;
117
+ this.revisionOriginsTable = fields.revisionOriginsTable;
128
118
  this.fulltextTable = fields.fulltextTable;
129
119
  void this.#brand;
130
120
  Object.freeze(this);
@@ -136,6 +126,7 @@ var DEFAULT_TABLE_NAMES = {
136
126
  recordedNodes: "typegraph_recorded_nodes",
137
127
  recordedEdges: "typegraph_recorded_edges",
138
128
  recordedClock: "typegraph_recorded_clock",
129
+ revisionOrigins: "typegraph_revision_origins",
139
130
  fulltext: "typegraph_node_fulltext",
140
131
  uniques: "typegraph_node_uniques"
141
132
  };
@@ -146,6 +137,7 @@ function resolveTableNames(names) {
146
137
  recordedNodes: names.recordedNodes ?? DEFAULT_TABLE_NAMES.recordedNodes,
147
138
  recordedEdges: names.recordedEdges ?? DEFAULT_TABLE_NAMES.recordedEdges,
148
139
  recordedClock: names.recordedClock ?? DEFAULT_TABLE_NAMES.recordedClock,
140
+ revisionOrigins: names.revisionOrigins ?? DEFAULT_TABLE_NAMES.revisionOrigins,
149
141
  fulltext: names.fulltext ?? DEFAULT_TABLE_NAMES.fulltext,
150
142
  uniques: names.uniques ?? DEFAULT_TABLE_NAMES.uniques
151
143
  };
@@ -153,15 +145,15 @@ function resolveTableNames(names) {
153
145
  var VALID_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/i;
154
146
  function validateTableName(name, label) {
155
147
  if (!name || name.length === 0) {
156
- throw new chunkJIEJCTDS_cjs.ConfigurationError(`${label} table name cannot be empty`);
148
+ throw new chunkLGEALRC6_cjs.ConfigurationError(`${label} table name cannot be empty`);
157
149
  }
158
- if (name.length > chunkNAUA4PW5_cjs.MAX_PG_IDENTIFIER_LENGTH) {
159
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
160
- `${label} table name exceeds maximum length of ${chunkNAUA4PW5_cjs.MAX_PG_IDENTIFIER_LENGTH} characters`
150
+ if (name.length > chunk7YSP4V4R_cjs.MAX_PG_IDENTIFIER_LENGTH) {
151
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
152
+ `${label} table name exceeds maximum length of ${chunk7YSP4V4R_cjs.MAX_PG_IDENTIFIER_LENGTH} characters`
161
153
  );
162
154
  }
163
155
  if (!VALID_IDENTIFIER_PATTERN.test(name)) {
164
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
156
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
165
157
  `${label} table name "${name}" is not a valid SQL identifier. Table names must start with a letter or underscore and contain only letters, digits, underscores, or dollar signs.`
166
158
  );
167
159
  }
@@ -177,7 +169,7 @@ function isSqlSchema(schema) {
177
169
  }
178
170
  function requireSqlSchema(schema, surface = "SqlSchema") {
179
171
  if (isSqlSchema(schema)) return schema;
180
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
172
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
181
173
  `${surface} must be created with createSqlSchema(...).`,
182
174
  { code: "INVALID_SQL_SCHEMA", surface },
183
175
  {
@@ -192,6 +184,7 @@ function createSqlSchema(names = {}) {
192
184
  validateTableName(tables.recordedNodes, "recordedNodes");
193
185
  validateTableName(tables.recordedEdges, "recordedEdges");
194
186
  validateTableName(tables.recordedClock, "recordedClock");
187
+ validateTableName(tables.revisionOrigins, "revisionOrigins");
195
188
  validateTableName(tables.fulltext, "fulltext");
196
189
  validateTableName(tables.uniques, "uniques");
197
190
  return freezeSqlSchema({
@@ -201,6 +194,7 @@ function createSqlSchema(names = {}) {
201
194
  recordedNodesTable: drizzleOrm.sql.raw(quoteIdentifier(tables.recordedNodes)),
202
195
  recordedEdgesTable: drizzleOrm.sql.raw(quoteIdentifier(tables.recordedEdges)),
203
196
  recordedClockTable: drizzleOrm.sql.raw(quoteIdentifier(tables.recordedClock)),
197
+ revisionOriginsTable: drizzleOrm.sql.raw(quoteIdentifier(tables.revisionOrigins)),
204
198
  fulltextTable: drizzleOrm.sql.raw(quoteIdentifier(tables.fulltext))
205
199
  });
206
200
  }
@@ -221,7 +215,7 @@ function recordedRelation(options) {
221
215
  function requireExternalRecordedReadSource(source) {
222
216
  if (source === void 0) return void 0;
223
217
  if (isExternalRecordedReadSource(source)) return source;
224
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
218
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
225
219
  "recordedRead must be created with recordedRelation({ schema }).",
226
220
  { code: "INVALID_RECORDED_READ_SOURCE" },
227
221
  {
@@ -245,7 +239,7 @@ function createRecordedReadBinding(schema) {
245
239
  function requireRecordedReadBinding(binding, surface) {
246
240
  if (isRecordedReadBinding(binding)) return binding;
247
241
  if (binding !== void 0) {
248
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
242
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
249
243
  "Recorded-time reads require a recorded read relation created by TypeGraph.",
250
244
  { code: "INVALID_RECORDED_READ_BINDING", surface },
251
245
  {
@@ -253,7 +247,7 @@ function requireRecordedReadBinding(binding, surface) {
253
247
  }
254
248
  );
255
249
  }
256
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
250
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
257
251
  "Recorded-time reads require a recorded read relation.",
258
252
  { code: "RECORDED_READ_REQUIRES_BINDING", surface },
259
253
  {
@@ -281,6 +275,7 @@ function recordedReadSqlSchema(binding) {
281
275
  recordedNodesTable: schema.recordedNodesTable,
282
276
  recordedEdgesTable: schema.recordedEdgesTable,
283
277
  recordedClockTable: schema.recordedClockTable,
278
+ revisionOriginsTable: schema.revisionOriginsTable,
284
279
  fulltextTable: schema.fulltextTable
285
280
  });
286
281
  }
@@ -302,7 +297,7 @@ function generateId() {
302
297
  }
303
298
  function requireRecordedSchema(target) {
304
299
  if (target.tableNames === void 0) {
305
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
300
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
306
301
  "Recorded-time capture requires the backend to expose tableNames.",
307
302
  { dialect: target.dialect },
308
303
  {
@@ -314,7 +309,7 @@ function requireRecordedSchema(target) {
314
309
  }
315
310
  function requireCaptureStatements(target) {
316
311
  if (target.executeStatement === void 0) {
317
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
312
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
318
313
  "Recorded-time capture requires backend.executeStatement support on the transaction backend.",
319
314
  { dialect: target.dialect },
320
315
  {
@@ -325,10 +320,10 @@ function requireCaptureStatements(target) {
325
320
  }
326
321
  async function executeStatement(target, query) {
327
322
  requireCaptureStatements(target);
328
- await target.executeStatement(asCompiledStatementSql(query));
323
+ await target.executeStatement(chunkEOLERH7Y_cjs.asCompiledStatementSql(query));
329
324
  }
330
325
  function unsupportedPostgresIsolationError(isolationLevel) {
331
- return new chunkJIEJCTDS_cjs.ConfigurationError(
326
+ return new chunkLGEALRC6_cjs.ConfigurationError(
332
327
  "Recorded-time capture on PostgreSQL requires read_committed isolation.",
333
328
  { isolationLevel: isolationLevel ?? "unknown" },
334
329
  {
@@ -352,7 +347,7 @@ function normalizeIsolationLevel(value) {
352
347
  async function assertRecordedCaptureTransactionIsolation(target) {
353
348
  if (target.dialect !== "postgres") return;
354
349
  const rows = await target.execute(
355
- asCompiledRowsSql(drizzleOrm.sql`
350
+ chunkEOLERH7Y_cjs.asCompiledRowsSql(drizzleOrm.sql`
356
351
  SELECT current_setting('transaction_isolation') AS transaction_isolation
357
352
  `)
358
353
  );
@@ -363,7 +358,7 @@ async function assertRecordedCaptureTransactionIsolation(target) {
363
358
  throw unsupportedPostgresIsolationError(isolationLevel);
364
359
  }
365
360
  function recordedCaptureRequiresCallbackTransactionError(details) {
366
- return new chunkJIEJCTDS_cjs.ConfigurationError(
361
+ return new chunkLGEALRC6_cjs.ConfigurationError(
367
362
  "withTransaction() has no recorded-time capture flush point when history is enabled.",
368
363
  details,
369
364
  {
@@ -372,7 +367,7 @@ function recordedCaptureRequiresCallbackTransactionError(details) {
372
367
  );
373
368
  }
374
369
  function historyUnsafeRawWriteError(surface) {
375
- return new chunkJIEJCTDS_cjs.ConfigurationError(
370
+ return new chunkLGEALRC6_cjs.ConfigurationError(
376
371
  `${surface} is not available when history capture is enabled because raw SQL writes bypass recorded-time capture.`,
377
372
  { code: "RECORDED_CAPTURE_RAW_SQL_DISABLED" },
378
373
  {
@@ -380,44 +375,62 @@ function historyUnsafeRawWriteError(surface) {
380
375
  }
381
376
  );
382
377
  }
378
+ function revisionTrackingUnsafeRawWriteError(surface) {
379
+ return new chunkLGEALRC6_cjs.ConfigurationError(
380
+ `${surface} is not available when revision tracking is enabled because raw SQL writes bypass the revision anchor.`,
381
+ { code: "REVISION_TRACKING_RAW_SQL_DISABLED" },
382
+ {
383
+ suggestion: "Run graph writes through store.nodes/store.edges (or tx.nodes/tx.edges inside a transaction), so TypeGraph can advance the revision anchor."
384
+ }
385
+ );
386
+ }
383
387
  function failHistoryUnsafeSqlRef() {
384
388
  throw historyUnsafeRawWriteError("tx.sql");
385
389
  }
390
+ function failRevisionTrackingUnsafeSqlRef() {
391
+ throw revisionTrackingUnsafeRawWriteError("tx.sql");
392
+ }
386
393
  function createHistoryUnsafeSqlRef() {
394
+ return createUnsafeSqlRef(failHistoryUnsafeSqlRef);
395
+ }
396
+ function createRevisionTrackingUnsafeSqlRef() {
397
+ return createUnsafeSqlRef(failRevisionTrackingUnsafeSqlRef);
398
+ }
399
+ function createUnsafeSqlRef(fail) {
387
400
  return new Proxy(
388
- function historyUnsafeSqlRef() {
389
- return failHistoryUnsafeSqlRef();
401
+ function unsafeSqlRef() {
402
+ return fail();
390
403
  },
391
404
  {
392
405
  get() {
393
- return failHistoryUnsafeSqlRef();
406
+ return fail();
394
407
  },
395
408
  apply() {
396
- return failHistoryUnsafeSqlRef();
409
+ return fail();
397
410
  },
398
411
  set() {
399
- return failHistoryUnsafeSqlRef();
412
+ return fail();
400
413
  },
401
414
  defineProperty() {
402
- return failHistoryUnsafeSqlRef();
415
+ return fail();
403
416
  },
404
417
  deleteProperty() {
405
- return failHistoryUnsafeSqlRef();
418
+ return fail();
406
419
  },
407
420
  // Enumeration / inspection traps too, so spreading (`{...tx.sql}`),
408
421
  // `Object.keys`, `in`, and prototype reads also fail loudly rather than
409
422
  // silently yielding an empty object that reads as "no raw handle".
410
423
  has() {
411
- return failHistoryUnsafeSqlRef();
424
+ return fail();
412
425
  },
413
426
  ownKeys() {
414
- return failHistoryUnsafeSqlRef();
427
+ return fail();
415
428
  },
416
429
  getOwnPropertyDescriptor() {
417
- return failHistoryUnsafeSqlRef();
430
+ return fail();
418
431
  },
419
432
  getPrototypeOf() {
420
- return failHistoryUnsafeSqlRef();
433
+ return fail();
421
434
  }
422
435
  }
423
436
  );
@@ -442,7 +455,7 @@ function rawWriteGuards(target, prefix) {
442
455
  }
443
456
  function assertCapturableBackend(backend) {
444
457
  if (!backend.capabilities.transactions) {
445
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
458
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
446
459
  "history: true requires a backend with transaction support.",
447
460
  { dialect: backend.dialect },
448
461
  {
@@ -451,7 +464,7 @@ function assertCapturableBackend(backend) {
451
464
  );
452
465
  }
453
466
  if (backend.executeStatement === void 0) {
454
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
467
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
455
468
  "history: true requires a backend that supports executeStatement.",
456
469
  { dialect: backend.dialect },
457
470
  {
@@ -460,7 +473,7 @@ function assertCapturableBackend(backend) {
460
473
  );
461
474
  }
462
475
  if (backend.capabilities.returning === false) {
463
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
476
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
464
477
  "history: true requires a backend that supports UPDATE \u2026 RETURNING.",
465
478
  { dialect: backend.dialect },
466
479
  {
@@ -469,7 +482,7 @@ function assertCapturableBackend(backend) {
469
482
  );
470
483
  }
471
484
  if (backend.tableNames === void 0) {
472
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
485
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
473
486
  "history: true requires a backend that exposes tableNames.",
474
487
  { dialect: backend.dialect },
475
488
  {
@@ -478,6 +491,44 @@ function assertCapturableBackend(backend) {
478
491
  );
479
492
  }
480
493
  }
494
+ function assertRevisionTrackableBackend(backend) {
495
+ if (!backend.capabilities.transactions) {
496
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
497
+ "revisionTracking: true requires a backend with transaction support.",
498
+ { dialect: backend.dialect },
499
+ {
500
+ suggestion: "Use a transactional SQLite/PostgreSQL backend or leave revision tracking disabled."
501
+ }
502
+ );
503
+ }
504
+ if (backend.executeStatement === void 0) {
505
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
506
+ "revisionTracking: true requires a backend that supports executeStatement.",
507
+ { dialect: backend.dialect },
508
+ {
509
+ suggestion: "Use a built-in SQLite/PostgreSQL backend, or implement executeStatement so TypeGraph can advance the revision clock."
510
+ }
511
+ );
512
+ }
513
+ if (backend.tableNames === void 0) {
514
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
515
+ "revisionTracking: true requires a backend that exposes tableNames.",
516
+ { dialect: backend.dialect },
517
+ {
518
+ suggestion: "Use a built-in SQLite/PostgreSQL backend, or set tableNames so TypeGraph can address the revision clock relation."
519
+ }
520
+ );
521
+ }
522
+ if (backend.ensureRevisionOriginsTable === void 0) {
523
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
524
+ "revisionTracking: true requires a backend that can bootstrap revision origins.",
525
+ { dialect: backend.dialect },
526
+ {
527
+ suggestion: "Use a built-in SQLite/PostgreSQL backend, or implement ensureRevisionOriginsTable so TypeGraph can durably namespace revision anchors."
528
+ }
529
+ );
530
+ }
531
+ }
481
532
 
482
533
  // src/store/recorded-capture/clock.ts
483
534
  var RECORDED_MIN = "1970-01-01T00:00:00.000Z";
@@ -508,22 +559,40 @@ function graphWriteLockEvidence() {
508
559
  function uncapturedGraphWriteLock() {
509
560
  return graphWriteLockEvidence();
510
561
  }
511
- async function lockRecordedGraphWrite(target, graphId) {
512
- if (target.dialect !== "postgres") return graphWriteLockEvidence();
562
+ function createRecordedGraphLockMemo() {
563
+ return /* @__PURE__ */ new Map();
564
+ }
565
+ var recordedGraphLockMemos = /* @__PURE__ */ new WeakMap();
566
+ function registerRecordedGraphLockMemo(backend, memo) {
567
+ recordedGraphLockMemos.set(backend, memo);
568
+ }
569
+ async function acquireRecordedGraphWriteLock(target, graphId) {
513
570
  await target.execute(
514
- asCompiledRowsSql(recordedGraphWriteAdvisoryLockSql(graphId))
571
+ chunkEOLERH7Y_cjs.asCompiledRowsSql(recordedGraphWriteAdvisoryLockSql(graphId))
515
572
  );
516
- return graphWriteLockEvidence();
517
573
  }
518
- async function lockRecordedGraphWrites(target, graphIds) {
519
- if (target.dialect !== "postgres") return;
520
- const uniqueGraphIds = [...new Set(graphIds)].toSorted();
521
- for (const graphId of uniqueGraphIds) {
522
- await lockRecordedGraphWrite(target, graphId);
574
+ async function lockRecordedGraphWrite(target, graphId, memo) {
575
+ if (target.dialect !== "postgres") return graphWriteLockEvidence();
576
+ const effectiveMemo = memo ?? recordedGraphLockMemos.get(target);
577
+ if (effectiveMemo === void 0) {
578
+ await acquireRecordedGraphWriteLock(target, graphId);
579
+ return graphWriteLockEvidence();
580
+ }
581
+ let pending = effectiveMemo.get(graphId);
582
+ if (pending === void 0) {
583
+ pending = acquireRecordedGraphWriteLock(target, graphId).catch(
584
+ (error) => {
585
+ effectiveMemo.delete(graphId);
586
+ throw error;
587
+ }
588
+ );
589
+ effectiveMemo.set(graphId, pending);
523
590
  }
591
+ await pending;
592
+ return graphWriteLockEvidence();
524
593
  }
525
594
  function failInvalidClockTimestamp(value) {
526
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
595
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
527
596
  "Recorded clock row contained an invalid timestamp",
528
597
  { value }
529
598
  );
@@ -562,12 +631,12 @@ function toCanonicalIso(value) {
562
631
  return failInvalidClockTimestamp(value);
563
632
  }
564
633
  function nextRecordedCommitTime(previous) {
565
- const wallTime = Date.parse(chunkYC6PWTHY_cjs.nowIso());
634
+ const wallTime = Date.parse(chunkBLZDPRXT_cjs.nowIso());
566
635
  return previous === void 0 ? wallTime : Math.max(wallTime, Date.parse(previous) + 1);
567
636
  }
568
637
  async function readRecordedClock(target, schema, graphId) {
569
638
  const rows = await target.execute(
570
- asCompiledRowsSql(drizzleOrm.sql`
639
+ chunkEOLERH7Y_cjs.asCompiledRowsSql(drizzleOrm.sql`
571
640
  SELECT recorded_at
572
641
  FROM ${schema.recordedClockTable}
573
642
  WHERE graph_id = ${graphId}
@@ -576,6 +645,53 @@ async function readRecordedClock(target, schema, graphId) {
576
645
  const first = rows[0];
577
646
  return first === void 0 ? void 0 : toCanonicalIso(first.recorded_at);
578
647
  }
648
+ async function readRevisionOrigin(target, schema, graphId) {
649
+ const rows = await target.execute(
650
+ chunkEOLERH7Y_cjs.asCompiledRowsSql(drizzleOrm.sql`
651
+ SELECT origin
652
+ FROM ${schema.revisionOriginsTable}
653
+ WHERE graph_id = ${graphId}
654
+ `)
655
+ );
656
+ const first = rows[0];
657
+ if (first === void 0) return void 0;
658
+ if (typeof first.origin !== "string" || first.origin.length === 0) {
659
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
660
+ "Revision origin row contained an invalid origin",
661
+ { graphId, origin: first.origin }
662
+ );
663
+ }
664
+ return first.origin;
665
+ }
666
+ async function ensureRevisionOrigin(target, schema, graphId) {
667
+ const ensureTable = target.ensureRevisionOriginsTable;
668
+ if (ensureTable === void 0) {
669
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
670
+ "Revision tracking requires a backend that can bootstrap revision origins.",
671
+ { dialect: target.dialect },
672
+ {
673
+ suggestion: "Use a built-in SQLite/PostgreSQL backend, or implement ensureRevisionOriginsTable on the custom backend."
674
+ }
675
+ );
676
+ }
677
+ await ensureTable();
678
+ const existing = await readRevisionOrigin(target, schema, graphId);
679
+ if (existing !== void 0) return existing;
680
+ await executeStatement(
681
+ target,
682
+ drizzleOrm.sql`
683
+ INSERT INTO ${schema.revisionOriginsTable} (graph_id, origin)
684
+ VALUES (${graphId}, ${generateId()})
685
+ ON CONFLICT (graph_id) DO NOTHING
686
+ `
687
+ );
688
+ const origin = await readRevisionOrigin(target, schema, graphId);
689
+ if (origin !== void 0) return origin;
690
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
691
+ "Revision origin was not persisted after initialization.",
692
+ { graphId, dialect: target.dialect }
693
+ );
694
+ }
579
695
  async function writeRecordedClock(target, schema, graphId, recordedAt) {
580
696
  await executeStatement(
581
697
  target,
@@ -589,7 +705,7 @@ async function writeRecordedClock(target, schema, graphId, recordedAt) {
589
705
  async function lockRecordedClock(target, schema, graphId, ownsWriteLock) {
590
706
  if (target.dialect === "postgres") {
591
707
  await target.execute(
592
- asCompiledRowsSql(recordedClockAdvisoryLockSql(graphId))
708
+ chunkEOLERH7Y_cjs.asCompiledRowsSql(recordedClockAdvisoryLockSql(graphId))
593
709
  );
594
710
  return;
595
711
  }
@@ -603,12 +719,12 @@ async function lockRecordedClock(target, schema, graphId, ownsWriteLock) {
603
719
  `
604
720
  );
605
721
  }
606
- async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock) {
722
+ async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock, previousRevision) {
607
723
  await lockRecordedClock(target, schema, graphId, ownsWriteLock);
608
- const previous = await readRecordedClock(target, schema, graphId);
724
+ const previous = previousRevision ?? await readRecordedClock(target, schema, graphId);
609
725
  const recordedCommitTime = nextRecordedCommitTime(previous);
610
726
  if (!Number.isFinite(recordedCommitTime) || recordedCommitTime >= RECORDED_MAX_TIME) {
611
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
727
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
612
728
  `Recorded commit clock reached the open sentinel ${RECORDED_MAX}`,
613
729
  { graphId, recordedCommitTime },
614
730
  {
@@ -620,6 +736,15 @@ async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock) {
620
736
  await writeRecordedClock(target, schema, graphId, recordedCommit);
621
737
  return recordedCommit;
622
738
  }
739
+ async function advanceRevisionClock(target, schema, graphId, ownsWriteLock, previousRevision) {
740
+ return allocateRecordedCommit(
741
+ target,
742
+ schema,
743
+ graphId,
744
+ ownsWriteLock,
745
+ previousRevision
746
+ );
747
+ }
623
748
 
624
749
  // src/store/insert-dispatch.ts
625
750
  function nodeInsertDispatch(backend) {
@@ -748,7 +873,7 @@ var RECORDED_BIND_PARAM_BUDGET = 900;
748
873
  function recordedBindParamBudget(target) {
749
874
  const budget = target.capabilities.maxBindParameters ?? RECORDED_BIND_PARAM_BUDGET;
750
875
  if (!Number.isSafeInteger(budget) || budget < 1) {
751
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
876
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
752
877
  `backend capabilities.maxBindParameters must be a positive integer, got: ${String(budget)}`,
753
878
  {
754
879
  code: "INVALID_BACKEND_CAPABILITY",
@@ -769,12 +894,12 @@ function recordedCommonCells() {
769
894
  graph_id: (row) => drizzleOrm.sql`${row.graph_id}`,
770
895
  id: (row) => drizzleOrm.sql`${row.id}`,
771
896
  kind: (row) => drizzleOrm.sql`${row.kind}`,
772
- props: (row) => drizzleOrm.sql`${row.props}`,
773
- valid_from: (row) => drizzleOrm.sql`${chunkYAZE7QZR_cjs.sqlNull(row.valid_from)}`,
774
- valid_to: (row) => drizzleOrm.sql`${chunkYAZE7QZR_cjs.sqlNull(row.valid_to)}`,
897
+ props: (row) => drizzleOrm.sql`${chunk4TOD4LBZ_cjs.rowPropsToJsonText(row.props)}`,
898
+ valid_from: (row) => drizzleOrm.sql`${chunk7YSP4V4R_cjs.sqlNull(row.valid_from)}`,
899
+ valid_to: (row) => drizzleOrm.sql`${chunk7YSP4V4R_cjs.sqlNull(row.valid_to)}`,
775
900
  created_at: (row) => drizzleOrm.sql`${row.created_at}`,
776
901
  updated_at: (row) => drizzleOrm.sql`${row.updated_at}`,
777
- deleted_at: (row) => drizzleOrm.sql`${chunkYAZE7QZR_cjs.sqlNull(row.deleted_at)}`,
902
+ deleted_at: (row) => drizzleOrm.sql`${chunk7YSP4V4R_cjs.sqlNull(row.deleted_at)}`,
778
903
  recorded_from: (_row, recordedCommit) => drizzleOrm.sql`${recordedCommit}`,
779
904
  recorded_to: () => drizzleOrm.sql`${RECORDED_MAX}`,
780
905
  op: (_row, _recordedCommit, operation) => drizzleOrm.sql`${operation}`,
@@ -862,20 +987,20 @@ function entityKey(entity) {
862
987
  async function closeOpenReturning(target, table, graphId, ids, recordedCommit, kind) {
863
988
  const kindFilter = kind === void 0 ? drizzleOrm.sql`` : drizzleOrm.sql`AND kind = ${kind}`;
864
989
  const rows = await target.execute(
865
- asCompiledRowsSql(drizzleOrm.sql`
990
+ chunkEOLERH7Y_cjs.asCompiledRowsSql(drizzleOrm.sql`
866
991
  UPDATE ${table}
867
992
  SET recorded_to = ${recordedCommit}
868
993
  WHERE graph_id = ${graphId}
869
994
  ${kindFilter}
870
995
  AND recorded_to = ${RECORDED_MAX}
871
- AND id IN (${chunkUNNPKQUG_cjs.sqlValueList(ids)})
996
+ AND id IN (${chunk4TOD4LBZ_cjs.sqlValueList(ids)})
872
997
  RETURNING id, deleted_at
873
998
  `)
874
999
  );
875
- return new Map(rows.map((row) => [row.id, chunkUNNPKQUG_cjs.isPresent(row.deleted_at)]));
1000
+ return new Map(rows.map((row) => [row.id, chunk4TOD4LBZ_cjs.isPresent(row.deleted_at)]));
876
1001
  }
877
1002
  function recordedOp(hadOpenRow, priorRowWasTombstone, after) {
878
- if (chunkUNNPKQUG_cjs.isPresent(after.deleted_at)) return "delete";
1003
+ if (chunk4TOD4LBZ_cjs.isPresent(after.deleted_at)) return "delete";
879
1004
  if (!hadOpenRow || priorRowWasTombstone) return "create";
880
1005
  return "update";
881
1006
  }
@@ -912,7 +1037,7 @@ function recordedInsertsFor(afterById, closed) {
912
1037
  async function flushNodes(target, schema, graphId, entities, recordedCommit) {
913
1038
  const chunkSize = recordedNodeChunkSize(target);
914
1039
  for (const [kind, group] of groupNodesByKind(entities)) {
915
- for (const entityChunk of chunkUNNPKQUG_cjs.chunk(group, chunkSize)) {
1040
+ for (const entityChunk of chunk4TOD4LBZ_cjs.chunk(group, chunkSize)) {
916
1041
  const ids = entityChunk.map((entity) => entity.id);
917
1042
  const closed = await closeOpenReturning(
918
1043
  target,
@@ -937,7 +1062,7 @@ async function flushNodes(target, schema, graphId, entities, recordedCommit) {
937
1062
  }
938
1063
  async function flushEdges(target, schema, graphId, entities, recordedCommit) {
939
1064
  const chunkSize = recordedEdgeChunkSize(target);
940
- for (const entityChunk of chunkUNNPKQUG_cjs.chunk(entities, chunkSize)) {
1065
+ for (const entityChunk of chunk4TOD4LBZ_cjs.chunk(entities, chunkSize)) {
941
1066
  const ids = entityChunk.map((entity) => entity.id);
942
1067
  const closed = await closeOpenReturning(
943
1068
  target,
@@ -1016,7 +1141,7 @@ async function closeRecordedHardDeletedKind(target, schema, graphId, removal, ow
1016
1141
  }
1017
1142
  async function queryConnectedEdgeIds(target, schema, params) {
1018
1143
  const rows = await target.execute(
1019
- asCompiledRowsSql(drizzleOrm.sql`
1144
+ chunkEOLERH7Y_cjs.asCompiledRowsSql(drizzleOrm.sql`
1020
1145
  SELECT id
1021
1146
  FROM ${schema.edgesTable}
1022
1147
  WHERE graph_id = ${params.graphId}
@@ -1030,6 +1155,21 @@ async function queryConnectedEdgeIds(target, schema, params) {
1030
1155
  }
1031
1156
 
1032
1157
  // src/store/recorded-capture.ts
1158
+ var RECORDED_FLUSH_OBSERVER = /* @__PURE__ */ Symbol("typegraph.recordedFlushObserver");
1159
+ function readRecordedFlushObserver(options) {
1160
+ return options?.[RECORDED_FLUSH_OBSERVER];
1161
+ }
1162
+ function stripRecordedFlushObserver(options) {
1163
+ if (options === void 0) return void 0;
1164
+ const { [RECORDED_FLUSH_OBSERVER]: _observer, ...backendOptions } = options;
1165
+ return backendOptions;
1166
+ }
1167
+ function withRecordedFlushObserver(options, observer) {
1168
+ return {
1169
+ ...stripRecordedFlushObserver(options),
1170
+ [RECORDED_FLUSH_OBSERVER]: observer
1171
+ };
1172
+ }
1033
1173
  function nodeIdentityKey(graphId, kind, id) {
1034
1174
  return `${graphId}\0${kind}\0${id}`;
1035
1175
  }
@@ -1053,7 +1193,7 @@ function createRecordedCaptureSession() {
1053
1193
  let sealed = false;
1054
1194
  function touch(entity) {
1055
1195
  if (sealed) {
1056
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
1196
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
1057
1197
  "Recorded-time capture session is sealed: a graph write happened after the transaction's capture was flushed.",
1058
1198
  { entity: entity.entity, graphId: entity.graphId, id: entity.id },
1059
1199
  {
@@ -1072,7 +1212,7 @@ function createRecordedCaptureSession() {
1072
1212
  },
1073
1213
  async flush(target, schema, ownsWriteLock) {
1074
1214
  if (sealed) {
1075
- throw new chunkJIEJCTDS_cjs.ConfigurationError(
1215
+ throw new chunkLGEALRC6_cjs.ConfigurationError(
1076
1216
  "Recorded-time capture session was already flushed.",
1077
1217
  {},
1078
1218
  {
@@ -1081,8 +1221,9 @@ function createRecordedCaptureSession() {
1081
1221
  );
1082
1222
  }
1083
1223
  sealed = true;
1084
- if (touched.size === 0) return;
1085
- const byGraph = chunkUNNPKQUG_cjs.groupBy(touched.values(), (entity) => entity.graphId);
1224
+ if (touched.size === 0) return /* @__PURE__ */ new Map();
1225
+ const recordedByGraph = /* @__PURE__ */ new Map();
1226
+ const byGraph = chunk4TOD4LBZ_cjs.groupBy(touched.values(), (entity) => entity.graphId);
1086
1227
  for (const [graphId, entities] of byGraph) {
1087
1228
  const recordedCommit = await allocateRecordedCommit(
1088
1229
  target,
@@ -1090,6 +1231,7 @@ function createRecordedCaptureSession() {
1090
1231
  graphId,
1091
1232
  ownsWriteLock
1092
1233
  );
1234
+ recordedByGraph.set(graphId, recordedCommit);
1093
1235
  const nodes = entities.filter(
1094
1236
  (entity) => entity.entity === "node"
1095
1237
  );
@@ -1100,22 +1242,26 @@ function createRecordedCaptureSession() {
1100
1242
  await flushEdges(target, schema, graphId, edges, recordedCommit);
1101
1243
  }
1102
1244
  touched.clear();
1245
+ return recordedByGraph;
1103
1246
  }
1104
1247
  };
1105
1248
  }
1106
1249
  function createRecordedTransactionBackend(target, session, schema) {
1107
1250
  const nodeDispatch = nodeInsertDispatch(target);
1108
1251
  const edgeDispatch = edgeInsertDispatch(target);
1252
+ const graphLocks = createRecordedGraphLockMemo();
1109
1253
  async function lockGraph(graphId) {
1110
- await lockRecordedGraphWrite(target, graphId);
1254
+ await lockRecordedGraphWrite(target, graphId, graphLocks);
1111
1255
  }
1112
1256
  async function lockGraphs(params) {
1113
- await lockRecordedGraphWrites(
1114
- target,
1115
- params.map((parameter) => parameter.graphId)
1116
- );
1257
+ const graphIds = [
1258
+ ...new Set(params.map((parameter) => parameter.graphId))
1259
+ ].toSorted();
1260
+ for (const graphId of graphIds) {
1261
+ await lockRecordedGraphWrite(target, graphId, graphLocks);
1262
+ }
1117
1263
  }
1118
- return chunkUNNPKQUG_cjs.createBackendOverlay(target, {
1264
+ const overlay = chunk4TOD4LBZ_cjs.createBackendOverlay(target, {
1119
1265
  ...rawWriteGuards(target, "tx.backend"),
1120
1266
  async insertNode(params) {
1121
1267
  await lockGraph(params.graphId);
@@ -1235,8 +1381,28 @@ function createRecordedTransactionBackend(target, session, schema) {
1235
1381
  await lockGraph(params.graphId);
1236
1382
  await target.hardDeleteEdge(params);
1237
1383
  session.touchEdge(params.graphId, params.id);
1384
+ },
1385
+ ...target.deleteEdgesBatch === void 0 ? {} : {
1386
+ async deleteEdgesBatch(params) {
1387
+ await lockGraph(params.graphId);
1388
+ await target.deleteEdgesBatch(params);
1389
+ for (const id of params.ids) {
1390
+ session.touchEdge(params.graphId, id);
1391
+ }
1392
+ }
1393
+ },
1394
+ ...target.hardDeleteEdgesBatch === void 0 ? {} : {
1395
+ async hardDeleteEdgesBatch(params) {
1396
+ await lockGraph(params.graphId);
1397
+ await target.hardDeleteEdgesBatch(params);
1398
+ for (const id of params.ids) {
1399
+ session.touchEdge(params.graphId, id);
1400
+ }
1401
+ }
1238
1402
  }
1239
1403
  });
1404
+ registerRecordedGraphLockMemo(overlay, graphLocks);
1405
+ return overlay;
1240
1406
  }
1241
1407
  function createRecordedTransactionScope(target, schema, ownsWriteLock = false) {
1242
1408
  requireCaptureStatements(target);
@@ -1245,7 +1411,7 @@ function createRecordedTransactionScope(target, schema, ownsWriteLock = false) {
1245
1411
  return {
1246
1412
  backend: createRecordedTransactionBackend(target, session, resolvedSchema),
1247
1413
  async flush() {
1248
- await chunkRHZWOJVA_cjs.withRecordedRelationsPrecondition(
1414
+ return chunkBLZDPRXT_cjs.withRecordedRelationsPrecondition(
1249
1415
  session.flush(target, resolvedSchema, ownsWriteLock),
1250
1416
  { dialect: target.dialect, surface: "capture-flush" }
1251
1417
  );
@@ -1265,7 +1431,7 @@ async function runCapturedAutocommit(backend, schema, fn, options) {
1265
1431
  function createRecordedBackend(backend, schema) {
1266
1432
  assertCapturableBackend(backend);
1267
1433
  const capture = (fn) => runCapturedAutocommit(backend, schema, fn);
1268
- return chunkUNNPKQUG_cjs.createBackendOverlay(backend, {
1434
+ return chunk4TOD4LBZ_cjs.createBackendOverlay(backend, {
1269
1435
  ...rawWriteGuards(backend, "backend"),
1270
1436
  async insertNode(params) {
1271
1437
  return capture((target) => target.insertNode(params));
@@ -1333,15 +1499,28 @@ function createRecordedBackend(backend, schema) {
1333
1499
  async hardDeleteEdge(params) {
1334
1500
  await capture((target) => target.hardDeleteEdge(params));
1335
1501
  },
1502
+ ...backend.deleteEdgesBatch === void 0 ? {} : {
1503
+ async deleteEdgesBatch(params) {
1504
+ await capture((target) => target.deleteEdgesBatch(params));
1505
+ }
1506
+ },
1507
+ ...backend.hardDeleteEdgesBatch === void 0 ? {} : {
1508
+ async hardDeleteEdgesBatch(params) {
1509
+ await capture((target) => target.hardDeleteEdgesBatch(params));
1510
+ }
1511
+ },
1336
1512
  async transaction(fn, options) {
1337
- assertRequestedRecordedIsolation(backend, options);
1513
+ const observer = readRecordedFlushObserver(options);
1514
+ const backendOptions = stripRecordedFlushObserver(options);
1515
+ assertRequestedRecordedIsolation(backend, backendOptions);
1338
1516
  return backend.transaction(async (target) => {
1339
1517
  await assertRecordedCaptureTransactionIsolation(target);
1340
1518
  const scope = createRecordedTransactionScope(target, schema, true);
1341
1519
  const result = await fn(scope.backend, createHistoryUnsafeSqlRef());
1342
- await scope.flush();
1520
+ const instants = await scope.flush();
1521
+ observer?.(instants);
1343
1522
  return result;
1344
- }, options);
1523
+ }, backendOptions);
1345
1524
  },
1346
1525
  ...backend.adoptTransaction === void 0 ? {} : {
1347
1526
  adoptTransaction(externalTx) {
@@ -1358,7 +1537,7 @@ var embeddingFieldsCache = /* @__PURE__ */ new WeakMap();
1358
1537
  function getEmbeddingFields(schema) {
1359
1538
  const cached = embeddingFieldsCache.get(schema);
1360
1539
  if (cached) return cached;
1361
- const fields = chunkJQGIPGVL_cjs.resolveEmbeddingFields(schema);
1540
+ const fields = chunkH7YNSMA7_cjs.resolveEmbeddingFields(schema);
1362
1541
  embeddingFieldsCache.set(schema, fields);
1363
1542
  return fields;
1364
1543
  }
@@ -1397,6 +1576,65 @@ async function syncEmbeddings(ctx, schema, props) {
1397
1576
  }
1398
1577
  }
1399
1578
  }
1579
+ async function syncEmbeddingsBatchForKind(args, schema, items) {
1580
+ const { graphId, nodeKind, backend } = args;
1581
+ if (!backend.upsertEmbedding || !backend.deleteEmbedding) {
1582
+ return;
1583
+ }
1584
+ const embeddingFields = getEmbeddingFields(schema);
1585
+ if (embeddingFields.length === 0) {
1586
+ return;
1587
+ }
1588
+ for (const field of embeddingFields) {
1589
+ const rows = [];
1590
+ const deletionIds = [];
1591
+ for (const item of items) {
1592
+ const value = item.props[field.fieldPath];
1593
+ if (isValidEmbeddingValue(value)) {
1594
+ rows.push({ nodeId: item.nodeId, embedding: value });
1595
+ } else if (value === void 0) {
1596
+ deletionIds.push(item.nodeId);
1597
+ }
1598
+ }
1599
+ if (rows.length > 0) {
1600
+ if (backend.upsertEmbeddingBatch === void 0) {
1601
+ for (const row of rows) {
1602
+ await backend.upsertEmbedding({
1603
+ graphId,
1604
+ nodeKind,
1605
+ nodeId: row.nodeId,
1606
+ fieldPath: field.fieldPath,
1607
+ embedding: row.embedding,
1608
+ dimensions: field.dimensions,
1609
+ metric: field.metric,
1610
+ indexType: field.indexType
1611
+ });
1612
+ }
1613
+ } else {
1614
+ await backend.upsertEmbeddingBatch({
1615
+ graphId,
1616
+ nodeKind,
1617
+ fieldPath: field.fieldPath,
1618
+ dimensions: field.dimensions,
1619
+ metric: field.metric,
1620
+ indexType: field.indexType,
1621
+ rows
1622
+ });
1623
+ }
1624
+ }
1625
+ for (const nodeId of deletionIds) {
1626
+ await backend.deleteEmbedding({
1627
+ graphId,
1628
+ nodeKind,
1629
+ nodeId,
1630
+ fieldPath: field.fieldPath,
1631
+ dimensions: field.dimensions,
1632
+ metric: field.metric,
1633
+ indexType: field.indexType
1634
+ });
1635
+ }
1636
+ }
1637
+ }
1400
1638
  async function deleteNodeEmbeddings(ctx, schema) {
1401
1639
  const { backend } = ctx;
1402
1640
  if (!backend.deleteEmbedding) {
@@ -1426,48 +1664,12 @@ function isValidEmbeddingValue(value) {
1426
1664
  }
1427
1665
 
1428
1666
  // src/store/fulltext-sync.ts
1429
- var searchableFieldsCache = /* @__PURE__ */ new WeakMap();
1430
- function getSearchableFields(schema) {
1431
- const cached = searchableFieldsCache.get(schema);
1432
- if (cached) return cached;
1433
- const fields = computeSearchableFields(schema);
1434
- searchableFieldsCache.set(schema, fields);
1435
- return fields;
1436
- }
1437
- function computeSearchableFields(schema) {
1438
- if (schema.type !== "object") return [];
1439
- const def = schema.def;
1440
- const shape = def.shape;
1441
- if (!shape) return [];
1442
- const fields = [];
1443
- for (const [fieldPath, fieldSchema] of Object.entries(shape)) {
1444
- const metadata = chunkJQGIPGVL_cjs.getSearchableMetadata(fieldSchema);
1445
- if (metadata !== void 0) {
1446
- fields.push({ fieldPath, metadata });
1447
- }
1448
- }
1449
- warnIfConflictingLanguages(fields);
1450
- return fields;
1451
- }
1452
- function warnIfConflictingLanguages(fields) {
1453
- if (fields.length < 2) return;
1454
- const languages = new Set(fields.map((field) => field.metadata.language));
1455
- if (languages.size < 2) return;
1456
- if (typeof console === "undefined" || typeof console.warn !== "function") {
1457
- return;
1458
- }
1459
- const fieldSummary = fields.map((field) => `${field.fieldPath}=${field.metadata.language}`).join(", ");
1460
- const winning = fields[0]?.metadata.language ?? chunkJQGIPGVL_cjs.DEFAULT_SEARCHABLE_LANGUAGE;
1461
- console.warn(
1462
- `[typegraph] searchable() fields declare conflicting languages (${fieldSummary}). The first field's language ("${winning}") is recorded on the fulltext row; true multilingual indexing requires a dedicated node kind per language.`
1463
- );
1464
- }
1465
1667
  var FIELD_SEPARATOR = "\n";
1466
1668
  function resolveCombinedLanguage(fields) {
1467
- return fields[0]?.metadata.language ?? chunkJQGIPGVL_cjs.DEFAULT_SEARCHABLE_LANGUAGE;
1669
+ return fields[0]?.metadata.language ?? chunkH7YNSMA7_cjs.DEFAULT_SEARCHABLE_LANGUAGE;
1468
1670
  }
1469
1671
  function computeFulltextContent(schema, props) {
1470
- const searchableFields = getSearchableFields(schema);
1672
+ const searchableFields = chunkH7YNSMA7_cjs.getSearchableFields(schema);
1471
1673
  if (searchableFields.length === 0) return void 0;
1472
1674
  const parts = [];
1473
1675
  for (const field of searchableFields) {
@@ -1498,19 +1700,68 @@ async function syncFulltext(ctx, schema, props) {
1498
1700
  });
1499
1701
  return;
1500
1702
  }
1501
- if (getSearchableFields(schema).length === 0) return;
1703
+ if (chunkH7YNSMA7_cjs.getSearchableFields(schema).length === 0) return;
1502
1704
  await backend.deleteFulltext({
1503
1705
  graphId: ctx.graphId,
1504
1706
  nodeKind: ctx.nodeKind,
1505
1707
  nodeId: ctx.nodeId
1506
1708
  });
1507
1709
  }
1710
+ async function syncFulltextBatchForKind(args, schema, items) {
1711
+ const { graphId, nodeKind, backend } = args;
1712
+ if (!backend.upsertFulltext || !backend.deleteFulltext) {
1713
+ return;
1714
+ }
1715
+ const rows = [];
1716
+ const emptyContentIds = [];
1717
+ const hasSearchableFields = chunkH7YNSMA7_cjs.getSearchableFields(schema).length > 0;
1718
+ for (const item of items) {
1719
+ const computed = computeFulltextContent(schema, item.props);
1720
+ if (computed !== void 0) {
1721
+ rows.push({
1722
+ nodeId: item.nodeId,
1723
+ content: computed.content,
1724
+ language: computed.language
1725
+ });
1726
+ } else if (hasSearchableFields) {
1727
+ emptyContentIds.push(item.nodeId);
1728
+ }
1729
+ }
1730
+ if (rows.length > 0) {
1731
+ if (backend.upsertFulltextBatch === void 0) {
1732
+ for (const row of rows) {
1733
+ await backend.upsertFulltext({
1734
+ graphId,
1735
+ nodeKind,
1736
+ nodeId: row.nodeId,
1737
+ content: row.content,
1738
+ language: row.language
1739
+ });
1740
+ }
1741
+ } else {
1742
+ await backend.upsertFulltextBatch({ graphId, nodeKind, rows });
1743
+ }
1744
+ }
1745
+ if (emptyContentIds.length > 0) {
1746
+ if (backend.deleteFulltextBatch === void 0) {
1747
+ for (const nodeId of emptyContentIds) {
1748
+ await backend.deleteFulltext({ graphId, nodeKind, nodeId });
1749
+ }
1750
+ } else {
1751
+ await backend.deleteFulltextBatch({
1752
+ graphId,
1753
+ nodeKind,
1754
+ nodeIds: emptyContentIds
1755
+ });
1756
+ }
1757
+ }
1758
+ }
1508
1759
  async function deleteNodeFulltext(ctx, schema) {
1509
1760
  const { backend } = ctx;
1510
1761
  if (!backend.deleteFulltext) {
1511
1762
  return;
1512
1763
  }
1513
- if (getSearchableFields(schema).length === 0) {
1764
+ if (chunkH7YNSMA7_cjs.getSearchableFields(schema).length === 0) {
1514
1765
  return;
1515
1766
  }
1516
1767
  await backend.deleteFulltext({
@@ -1572,7 +1823,7 @@ function evaluatePredicate(predicate, props) {
1572
1823
  if (pred.op === "isNull") {
1573
1824
  return value === null || value === void 0;
1574
1825
  }
1575
- return chunkUNNPKQUG_cjs.isPresent(value);
1826
+ return chunk4TOD4LBZ_cjs.isPresent(value);
1576
1827
  }
1577
1828
  function getKindsForUniquenessCheck(baseKind, scope, registry) {
1578
1829
  if (scope === "kind") {
@@ -1601,7 +1852,7 @@ function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeC
1601
1852
  }
1602
1853
  case "one": {
1603
1854
  if (existingEdgeCount > 0) {
1604
- return new chunkJIEJCTDS_cjs.CardinalityError({
1855
+ return new chunkLGEALRC6_cjs.CardinalityError({
1605
1856
  edgeKind,
1606
1857
  fromKind,
1607
1858
  fromId,
@@ -1616,7 +1867,7 @@ function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeC
1616
1867
  }
1617
1868
  case "oneActive": {
1618
1869
  if (hasActiveEdge) {
1619
- return new chunkJIEJCTDS_cjs.CardinalityError({
1870
+ return new chunkLGEALRC6_cjs.CardinalityError({
1620
1871
  edgeKind,
1621
1872
  fromKind,
1622
1873
  fromId,
@@ -1630,7 +1881,7 @@ function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeC
1630
1881
  }
1631
1882
  function checkUniqueEdge(edgeKind, fromKind, fromId, _toKind, _toId, existingCount) {
1632
1883
  if (existingCount > 0) {
1633
- return new chunkJIEJCTDS_cjs.CardinalityError({
1884
+ return new chunkLGEALRC6_cjs.CardinalityError({
1634
1885
  edgeKind,
1635
1886
  fromKind,
1636
1887
  fromId,
@@ -1642,11 +1893,8 @@ function checkUniqueEdge(edgeKind, fromKind, fromId, _toKind, _toId, existingCou
1642
1893
  }
1643
1894
  function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registry) {
1644
1895
  const validFromKinds = registration.from.map((node) => node.kind);
1645
- const fromValid = validFromKinds.some(
1646
- (validKind) => registry.isAssignableTo(fromKind, validKind)
1647
- );
1648
- if (!fromValid) {
1649
- return new chunkJIEJCTDS_cjs.EndpointError({
1896
+ if (!registry.isAssignableToAny(fromKind, validFromKinds)) {
1897
+ return new chunkLGEALRC6_cjs.EndpointError({
1650
1898
  edgeKind,
1651
1899
  endpoint: "from",
1652
1900
  actualKind: fromKind,
@@ -1654,11 +1902,8 @@ function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registr
1654
1902
  });
1655
1903
  }
1656
1904
  const validToKinds = registration.to.map((node) => node.kind);
1657
- const toValid = validToKinds.some(
1658
- (validKind) => registry.isAssignableTo(toKind, validKind)
1659
- );
1660
- if (!toValid) {
1661
- return new chunkJIEJCTDS_cjs.EndpointError({
1905
+ if (!registry.isAssignableToAny(toKind, validToKinds)) {
1906
+ return new chunkLGEALRC6_cjs.EndpointError({
1662
1907
  edgeKind,
1663
1908
  endpoint: "to",
1664
1909
  actualKind: toKind,
@@ -1670,7 +1915,7 @@ function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registr
1670
1915
  function checkDisjointness(nodeId, nodeKind, existingKinds, registry) {
1671
1916
  for (const existingKind of existingKinds) {
1672
1917
  if (registry.areDisjoint(nodeKind, existingKind)) {
1673
- return new chunkJIEJCTDS_cjs.DisjointError({
1918
+ return new chunkLGEALRC6_cjs.DisjointError({
1674
1919
  nodeId,
1675
1920
  attemptedKind: nodeKind,
1676
1921
  conflictingKind: existingKind
@@ -1707,7 +1952,7 @@ async function checkUniquenessConstraints(ctx, kind, id, props, constraints) {
1707
1952
  key
1708
1953
  });
1709
1954
  if (existing && existing.node_id !== id) {
1710
- throw new chunkJIEJCTDS_cjs.UniquenessError({
1955
+ throw new chunkLGEALRC6_cjs.UniquenessError({
1711
1956
  constraintName: constraint.name,
1712
1957
  kind: kindToCheck,
1713
1958
  existingId: existing.node_id,
@@ -1738,6 +1983,36 @@ async function insertUniquenessEntries(ctx, kind, id, props, constraints) {
1738
1983
  });
1739
1984
  }
1740
1985
  }
1986
+ async function insertUniquenessEntriesBatch(ctx, items) {
1987
+ const entries = [];
1988
+ for (const item of items) {
1989
+ for (const constraint of item.constraints) {
1990
+ if (!checkWherePredicate(constraint, item.props)) {
1991
+ continue;
1992
+ }
1993
+ entries.push({
1994
+ graphId: ctx.graphId,
1995
+ nodeKind: item.kind,
1996
+ constraintName: constraint.name,
1997
+ key: computeUniqueKey(
1998
+ item.props,
1999
+ constraint.fields,
2000
+ constraint.collation
2001
+ ),
2002
+ nodeId: item.id,
2003
+ concreteKind: item.kind
2004
+ });
2005
+ }
2006
+ }
2007
+ if (entries.length === 0) return;
2008
+ if (ctx.backend.insertUniqueBatch !== void 0) {
2009
+ await ctx.backend.insertUniqueBatch(entries);
2010
+ return;
2011
+ }
2012
+ for (const entry of entries) {
2013
+ await ctx.backend.insertUnique(entry);
2014
+ }
2015
+ }
1741
2016
  async function deleteUniquenessEntries(ctx, kind, props, constraints) {
1742
2017
  for (const constraint of constraints) {
1743
2018
  if (!checkWherePredicate(constraint, props)) {
@@ -1783,7 +2058,7 @@ async function updateUniquenessEntries(ctx, kind, id, oldProps, newProps, constr
1783
2058
  key: newKey
1784
2059
  });
1785
2060
  if (existing && existing.node_id !== id) {
1786
- throw new chunkJIEJCTDS_cjs.UniquenessError({
2061
+ throw new chunkLGEALRC6_cjs.UniquenessError({
1787
2062
  constraintName: constraint.name,
1788
2063
  kind: kindToCheck,
1789
2064
  existingId: existing.node_id,
@@ -1840,7 +2115,7 @@ async function enforceNodeDeleteBehavior(ctx, args, backend, policy) {
1840
2115
  if (connectedEdges.length === 0) return;
1841
2116
  switch (behavior) {
1842
2117
  case "restrict": {
1843
- throw new chunkJIEJCTDS_cjs.RestrictedDeleteError({
2118
+ throw new chunkLGEALRC6_cjs.RestrictedDeleteError({
1844
2119
  nodeKind: args.kind,
1845
2120
  nodeId: args.id,
1846
2121
  edgeCount: connectedEdges.length,
@@ -1849,6 +2124,14 @@ async function enforceNodeDeleteBehavior(ctx, args, backend, policy) {
1849
2124
  }
1850
2125
  case "cascade":
1851
2126
  case "disconnect": {
2127
+ const batchDelete = args.mode === "hard" ? backend.hardDeleteEdgesBatch : backend.deleteEdgesBatch;
2128
+ if (batchDelete !== void 0) {
2129
+ await batchDelete.call(backend, {
2130
+ graphId: ctx.graphId,
2131
+ ids: connectedEdges.map((edge) => edge.id)
2132
+ });
2133
+ break;
2134
+ }
1852
2135
  for (const edge of connectedEdges) {
1853
2136
  await (args.mode === "hard" ? backend.hardDeleteEdge({ graphId: ctx.graphId, id: edge.id }) : backend.deleteEdge({ graphId: ctx.graphId, id: edge.id }));
1854
2137
  }
@@ -1877,8 +2160,35 @@ async function applyNodeInsertSideEffects(ctx, args, backend) {
1877
2160
  )
1878
2161
  ]);
1879
2162
  }
2163
+ async function applyNodeInsertSideEffectsBatch(ctx, items, backend) {
2164
+ if (items.length === 0) return;
2165
+ await insertUniquenessEntriesBatch(
2166
+ uniquenessContext(ctx, backend),
2167
+ items.map((item) => ({
2168
+ kind: item.kind,
2169
+ id: item.id,
2170
+ props: item.props,
2171
+ constraints: item.uniqueConstraints
2172
+ }))
2173
+ );
2174
+ const byKind = /* @__PURE__ */ new Map();
2175
+ for (const item of items) {
2176
+ const group = byKind.get(item.kind) ?? { schema: item.schema, rows: [] };
2177
+ group.rows.push({ nodeId: item.id, props: item.props });
2178
+ byKind.set(item.kind, group);
2179
+ }
2180
+ await Promise.all(
2181
+ [...byKind.entries()].flatMap(([kind, group]) => {
2182
+ const syncArguments = { graphId: ctx.graphId, nodeKind: kind, backend };
2183
+ return [
2184
+ syncEmbeddingsBatchForKind(syncArguments, group.schema, group.rows),
2185
+ syncFulltextBatchForKind(syncArguments, group.schema, group.rows)
2186
+ ];
2187
+ })
2188
+ );
2189
+ }
1880
2190
  function parseRowProps(row) {
1881
- return JSON.parse(row.props);
2191
+ return chunk4TOD4LBZ_cjs.rowPropsToObject(row.props);
1882
2192
  }
1883
2193
  async function applyNodeUpdate(ctx, args, backend) {
1884
2194
  const { kind, id } = args.existing;
@@ -2012,16 +2322,16 @@ exports.DEFAULT_SQL_SCHEMA = DEFAULT_SQL_SCHEMA;
2012
2322
  exports.EMBEDDINGS_CTE_ALIAS = EMBEDDINGS_CTE_ALIAS;
2013
2323
  exports.FULLTEXT_CTE_ALIAS = FULLTEXT_CTE_ALIAS;
2014
2324
  exports.HYBRID_CANDIDATES_CTE_ALIAS = HYBRID_CANDIDATES_CTE_ALIAS;
2325
+ exports.advanceRevisionClock = advanceRevisionClock;
2015
2326
  exports.applyNodeHardDelete = applyNodeHardDelete;
2016
2327
  exports.applyNodeInsertSideEffects = applyNodeInsertSideEffects;
2328
+ exports.applyNodeInsertSideEffectsBatch = applyNodeInsertSideEffectsBatch;
2017
2329
  exports.applyNodeResurrect = applyNodeResurrect;
2018
2330
  exports.applyNodeSoftDelete = applyNodeSoftDelete;
2019
2331
  exports.applyNodeUpdate = applyNodeUpdate;
2020
- exports.asCompiledRowsSql = asCompiledRowsSql;
2021
- exports.asCompiledSelectSql = asCompiledSelectSql;
2022
- exports.asCompiledStatementSql = asCompiledStatementSql;
2023
2332
  exports.asRecordedInstant = asRecordedInstant;
2024
2333
  exports.assertRecordedCaptureTransactionIsolation = assertRecordedCaptureTransactionIsolation;
2334
+ exports.assertRevisionTrackableBackend = assertRevisionTrackableBackend;
2025
2335
  exports.assertValidRecordedInstant = assertValidRecordedInstant;
2026
2336
  exports.checkCardinality = checkCardinality;
2027
2337
  exports.checkDisjointness = checkDisjointness;
@@ -2037,19 +2347,21 @@ exports.createNodeWriteContext = createNodeWriteContext;
2037
2347
  exports.createRecordedBackend = createRecordedBackend;
2038
2348
  exports.createRecordedReadBinding = createRecordedReadBinding;
2039
2349
  exports.createRecordedTransactionScope = createRecordedTransactionScope;
2350
+ exports.createRevisionTrackingUnsafeSqlRef = createRevisionTrackingUnsafeSqlRef;
2040
2351
  exports.createSqlSchema = createSqlSchema;
2041
2352
  exports.createUniquenessContext = createUniquenessContext;
2042
2353
  exports.describeCoordinate = describeCoordinate;
2043
2354
  exports.edgeInsertDispatch = edgeInsertDispatch;
2355
+ exports.ensureRevisionOrigin = ensureRevisionOrigin;
2044
2356
  exports.generateId = generateId;
2045
2357
  exports.getEdgeRowsByIds = getEdgeRowsByIds;
2046
2358
  exports.getEmbeddingFields = getEmbeddingFields;
2047
2359
  exports.getKindsForUniquenessCheck = getKindsForUniquenessCheck;
2048
2360
  exports.getNodeRowsByIds = getNodeRowsByIds;
2049
- exports.getSearchableFields = getSearchableFields;
2050
2361
  exports.lockRecordedGraphWrite = lockRecordedGraphWrite;
2051
2362
  exports.nodeInsertDispatch = nodeInsertDispatch;
2052
2363
  exports.readRecordedClock = readRecordedClock;
2364
+ exports.readRevisionOrigin = readRevisionOrigin;
2053
2365
  exports.recordedBindParamBudget = recordedBindParamBudget;
2054
2366
  exports.recordedCaptureRequiresCallbackTransactionError = recordedCaptureRequiresCallbackTransactionError;
2055
2367
  exports.recordedReadSchemaFor = recordedReadSchemaFor;
@@ -2066,5 +2378,6 @@ exports.uncapturedGraphWriteLock = uncapturedGraphWriteLock;
2066
2378
  exports.validateEdgeEndpoints = validateEdgeEndpoints;
2067
2379
  exports.vectorSlotKey = vectorSlotKey;
2068
2380
  exports.withRecordedCoordinate = withRecordedCoordinate;
2069
- //# sourceMappingURL=chunk-5IQIX7LU.cjs.map
2070
- //# sourceMappingURL=chunk-5IQIX7LU.cjs.map
2381
+ exports.withRecordedFlushObserver = withRecordedFlushObserver;
2382
+ //# sourceMappingURL=chunk-XOX22WHL.cjs.map
2383
+ //# sourceMappingURL=chunk-XOX22WHL.cjs.map