@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,10 +1,9 @@
1
- import { createBackendOverlay, isPresent, groupBy, chunk, sqlValueList } from './chunk-V3QNTB7Z.js';
2
- import { validateCanonicalIsoDate, nowIso } from './chunk-XXVEULWX.js';
3
- import { withRecordedRelationsPrecondition } from './chunk-2MRAX3UE.js';
4
- import { sqlNull } from './chunk-GZCNZ7QW.js';
5
- import { MAX_PG_IDENTIFIER_LENGTH } from './chunk-2EBMPJBO.js';
6
- import { resolveEmbeddingFields, getSearchableMetadata, DEFAULT_SEARCHABLE_LANGUAGE } from './chunk-Z5XBMDXU.js';
7
- import { ConfigurationError, ValidationError, CardinalityError, EndpointError, DisjointError, UniquenessError, RestrictedDeleteError } from './chunk-TQOYM4LN.js';
1
+ import { asCompiledRowsSql, asCompiledStatementSql } from './chunk-UT3S4SEN.js';
2
+ import { createBackendOverlay, isPresent, rowPropsToObject, groupBy, chunk, sqlValueList, rowPropsToJsonText } from './chunk-JBTOYDMN.js';
3
+ import { validateCanonicalIsoDate, withRecordedRelationsPrecondition, nowIso } from './chunk-I7ZUZKFD.js';
4
+ import { MAX_PG_IDENTIFIER_LENGTH, sqlNull } from './chunk-OHMP6N2J.js';
5
+ import { resolveEmbeddingFields, getSearchableFields, DEFAULT_SEARCHABLE_LANGUAGE } from './chunk-KBGQIPRQ.js';
6
+ import { ConfigurationError, ValidationError, CardinalityError, EndpointError, DisjointError, UniquenessError, RestrictedDeleteError } from './chunk-MP2JQKSG.js';
8
7
  import { sql } from 'drizzle-orm';
9
8
  import { nanoid } from 'nanoid';
10
9
 
@@ -95,17 +94,6 @@ function coordinateContext(coordinate) {
95
94
  ...coordinate.recorded === void 0 ? {} : { recordedAsOf: coordinate.recorded.asOf }
96
95
  };
97
96
  }
98
-
99
- // src/query/sql-intent.ts
100
- function asCompiledRowsSql(query) {
101
- return query;
102
- }
103
- function asCompiledSelectSql(query) {
104
- return asCompiledRowsSql(query);
105
- }
106
- function asCompiledStatementSql(query) {
107
- return query;
108
- }
109
97
  var SqlSchemaDescriptor = class {
110
98
  // Private field gives SqlSchema nominal identity; runtime checks use instanceof.
111
99
  #brand = true;
@@ -115,6 +103,7 @@ var SqlSchemaDescriptor = class {
115
103
  recordedNodesTable;
116
104
  recordedEdgesTable;
117
105
  recordedClockTable;
106
+ revisionOriginsTable;
118
107
  fulltextTable;
119
108
  constructor(fields) {
120
109
  this.tables = fields.tables;
@@ -123,6 +112,7 @@ var SqlSchemaDescriptor = class {
123
112
  this.recordedNodesTable = fields.recordedNodesTable;
124
113
  this.recordedEdgesTable = fields.recordedEdgesTable;
125
114
  this.recordedClockTable = fields.recordedClockTable;
115
+ this.revisionOriginsTable = fields.revisionOriginsTable;
126
116
  this.fulltextTable = fields.fulltextTable;
127
117
  void this.#brand;
128
118
  Object.freeze(this);
@@ -134,6 +124,7 @@ var DEFAULT_TABLE_NAMES = {
134
124
  recordedNodes: "typegraph_recorded_nodes",
135
125
  recordedEdges: "typegraph_recorded_edges",
136
126
  recordedClock: "typegraph_recorded_clock",
127
+ revisionOrigins: "typegraph_revision_origins",
137
128
  fulltext: "typegraph_node_fulltext",
138
129
  uniques: "typegraph_node_uniques"
139
130
  };
@@ -144,6 +135,7 @@ function resolveTableNames(names) {
144
135
  recordedNodes: names.recordedNodes ?? DEFAULT_TABLE_NAMES.recordedNodes,
145
136
  recordedEdges: names.recordedEdges ?? DEFAULT_TABLE_NAMES.recordedEdges,
146
137
  recordedClock: names.recordedClock ?? DEFAULT_TABLE_NAMES.recordedClock,
138
+ revisionOrigins: names.revisionOrigins ?? DEFAULT_TABLE_NAMES.revisionOrigins,
147
139
  fulltext: names.fulltext ?? DEFAULT_TABLE_NAMES.fulltext,
148
140
  uniques: names.uniques ?? DEFAULT_TABLE_NAMES.uniques
149
141
  };
@@ -190,6 +182,7 @@ function createSqlSchema(names = {}) {
190
182
  validateTableName(tables.recordedNodes, "recordedNodes");
191
183
  validateTableName(tables.recordedEdges, "recordedEdges");
192
184
  validateTableName(tables.recordedClock, "recordedClock");
185
+ validateTableName(tables.revisionOrigins, "revisionOrigins");
193
186
  validateTableName(tables.fulltext, "fulltext");
194
187
  validateTableName(tables.uniques, "uniques");
195
188
  return freezeSqlSchema({
@@ -199,6 +192,7 @@ function createSqlSchema(names = {}) {
199
192
  recordedNodesTable: sql.raw(quoteIdentifier(tables.recordedNodes)),
200
193
  recordedEdgesTable: sql.raw(quoteIdentifier(tables.recordedEdges)),
201
194
  recordedClockTable: sql.raw(quoteIdentifier(tables.recordedClock)),
195
+ revisionOriginsTable: sql.raw(quoteIdentifier(tables.revisionOrigins)),
202
196
  fulltextTable: sql.raw(quoteIdentifier(tables.fulltext))
203
197
  });
204
198
  }
@@ -279,6 +273,7 @@ function recordedReadSqlSchema(binding) {
279
273
  recordedNodesTable: schema.recordedNodesTable,
280
274
  recordedEdgesTable: schema.recordedEdgesTable,
281
275
  recordedClockTable: schema.recordedClockTable,
276
+ revisionOriginsTable: schema.revisionOriginsTable,
282
277
  fulltextTable: schema.fulltextTable
283
278
  });
284
279
  }
@@ -378,44 +373,62 @@ function historyUnsafeRawWriteError(surface) {
378
373
  }
379
374
  );
380
375
  }
376
+ function revisionTrackingUnsafeRawWriteError(surface) {
377
+ return new ConfigurationError(
378
+ `${surface} is not available when revision tracking is enabled because raw SQL writes bypass the revision anchor.`,
379
+ { code: "REVISION_TRACKING_RAW_SQL_DISABLED" },
380
+ {
381
+ suggestion: "Run graph writes through store.nodes/store.edges (or tx.nodes/tx.edges inside a transaction), so TypeGraph can advance the revision anchor."
382
+ }
383
+ );
384
+ }
381
385
  function failHistoryUnsafeSqlRef() {
382
386
  throw historyUnsafeRawWriteError("tx.sql");
383
387
  }
388
+ function failRevisionTrackingUnsafeSqlRef() {
389
+ throw revisionTrackingUnsafeRawWriteError("tx.sql");
390
+ }
384
391
  function createHistoryUnsafeSqlRef() {
392
+ return createUnsafeSqlRef(failHistoryUnsafeSqlRef);
393
+ }
394
+ function createRevisionTrackingUnsafeSqlRef() {
395
+ return createUnsafeSqlRef(failRevisionTrackingUnsafeSqlRef);
396
+ }
397
+ function createUnsafeSqlRef(fail) {
385
398
  return new Proxy(
386
- function historyUnsafeSqlRef() {
387
- return failHistoryUnsafeSqlRef();
399
+ function unsafeSqlRef() {
400
+ return fail();
388
401
  },
389
402
  {
390
403
  get() {
391
- return failHistoryUnsafeSqlRef();
404
+ return fail();
392
405
  },
393
406
  apply() {
394
- return failHistoryUnsafeSqlRef();
407
+ return fail();
395
408
  },
396
409
  set() {
397
- return failHistoryUnsafeSqlRef();
410
+ return fail();
398
411
  },
399
412
  defineProperty() {
400
- return failHistoryUnsafeSqlRef();
413
+ return fail();
401
414
  },
402
415
  deleteProperty() {
403
- return failHistoryUnsafeSqlRef();
416
+ return fail();
404
417
  },
405
418
  // Enumeration / inspection traps too, so spreading (`{...tx.sql}`),
406
419
  // `Object.keys`, `in`, and prototype reads also fail loudly rather than
407
420
  // silently yielding an empty object that reads as "no raw handle".
408
421
  has() {
409
- return failHistoryUnsafeSqlRef();
422
+ return fail();
410
423
  },
411
424
  ownKeys() {
412
- return failHistoryUnsafeSqlRef();
425
+ return fail();
413
426
  },
414
427
  getOwnPropertyDescriptor() {
415
- return failHistoryUnsafeSqlRef();
428
+ return fail();
416
429
  },
417
430
  getPrototypeOf() {
418
- return failHistoryUnsafeSqlRef();
431
+ return fail();
419
432
  }
420
433
  }
421
434
  );
@@ -476,6 +489,44 @@ function assertCapturableBackend(backend) {
476
489
  );
477
490
  }
478
491
  }
492
+ function assertRevisionTrackableBackend(backend) {
493
+ if (!backend.capabilities.transactions) {
494
+ throw new ConfigurationError(
495
+ "revisionTracking: true requires a backend with transaction support.",
496
+ { dialect: backend.dialect },
497
+ {
498
+ suggestion: "Use a transactional SQLite/PostgreSQL backend or leave revision tracking disabled."
499
+ }
500
+ );
501
+ }
502
+ if (backend.executeStatement === void 0) {
503
+ throw new ConfigurationError(
504
+ "revisionTracking: true requires a backend that supports executeStatement.",
505
+ { dialect: backend.dialect },
506
+ {
507
+ suggestion: "Use a built-in SQLite/PostgreSQL backend, or implement executeStatement so TypeGraph can advance the revision clock."
508
+ }
509
+ );
510
+ }
511
+ if (backend.tableNames === void 0) {
512
+ throw new ConfigurationError(
513
+ "revisionTracking: true requires a backend that exposes tableNames.",
514
+ { dialect: backend.dialect },
515
+ {
516
+ suggestion: "Use a built-in SQLite/PostgreSQL backend, or set tableNames so TypeGraph can address the revision clock relation."
517
+ }
518
+ );
519
+ }
520
+ if (backend.ensureRevisionOriginsTable === void 0) {
521
+ throw new ConfigurationError(
522
+ "revisionTracking: true requires a backend that can bootstrap revision origins.",
523
+ { dialect: backend.dialect },
524
+ {
525
+ suggestion: "Use a built-in SQLite/PostgreSQL backend, or implement ensureRevisionOriginsTable so TypeGraph can durably namespace revision anchors."
526
+ }
527
+ );
528
+ }
529
+ }
479
530
 
480
531
  // src/store/recorded-capture/clock.ts
481
532
  var RECORDED_MIN = "1970-01-01T00:00:00.000Z";
@@ -506,19 +557,37 @@ function graphWriteLockEvidence() {
506
557
  function uncapturedGraphWriteLock() {
507
558
  return graphWriteLockEvidence();
508
559
  }
509
- async function lockRecordedGraphWrite(target, graphId) {
510
- if (target.dialect !== "postgres") return graphWriteLockEvidence();
560
+ function createRecordedGraphLockMemo() {
561
+ return /* @__PURE__ */ new Map();
562
+ }
563
+ var recordedGraphLockMemos = /* @__PURE__ */ new WeakMap();
564
+ function registerRecordedGraphLockMemo(backend, memo) {
565
+ recordedGraphLockMemos.set(backend, memo);
566
+ }
567
+ async function acquireRecordedGraphWriteLock(target, graphId) {
511
568
  await target.execute(
512
569
  asCompiledRowsSql(recordedGraphWriteAdvisoryLockSql(graphId))
513
570
  );
514
- return graphWriteLockEvidence();
515
571
  }
516
- async function lockRecordedGraphWrites(target, graphIds) {
517
- if (target.dialect !== "postgres") return;
518
- const uniqueGraphIds = [...new Set(graphIds)].toSorted();
519
- for (const graphId of uniqueGraphIds) {
520
- await lockRecordedGraphWrite(target, graphId);
572
+ async function lockRecordedGraphWrite(target, graphId, memo) {
573
+ if (target.dialect !== "postgres") return graphWriteLockEvidence();
574
+ const effectiveMemo = memo ?? recordedGraphLockMemos.get(target);
575
+ if (effectiveMemo === void 0) {
576
+ await acquireRecordedGraphWriteLock(target, graphId);
577
+ return graphWriteLockEvidence();
578
+ }
579
+ let pending = effectiveMemo.get(graphId);
580
+ if (pending === void 0) {
581
+ pending = acquireRecordedGraphWriteLock(target, graphId).catch(
582
+ (error) => {
583
+ effectiveMemo.delete(graphId);
584
+ throw error;
585
+ }
586
+ );
587
+ effectiveMemo.set(graphId, pending);
521
588
  }
589
+ await pending;
590
+ return graphWriteLockEvidence();
522
591
  }
523
592
  function failInvalidClockTimestamp(value) {
524
593
  throw new ConfigurationError(
@@ -574,6 +643,53 @@ async function readRecordedClock(target, schema, graphId) {
574
643
  const first = rows[0];
575
644
  return first === void 0 ? void 0 : toCanonicalIso(first.recorded_at);
576
645
  }
646
+ async function readRevisionOrigin(target, schema, graphId) {
647
+ const rows = await target.execute(
648
+ asCompiledRowsSql(sql`
649
+ SELECT origin
650
+ FROM ${schema.revisionOriginsTable}
651
+ WHERE graph_id = ${graphId}
652
+ `)
653
+ );
654
+ const first = rows[0];
655
+ if (first === void 0) return void 0;
656
+ if (typeof first.origin !== "string" || first.origin.length === 0) {
657
+ throw new ConfigurationError(
658
+ "Revision origin row contained an invalid origin",
659
+ { graphId, origin: first.origin }
660
+ );
661
+ }
662
+ return first.origin;
663
+ }
664
+ async function ensureRevisionOrigin(target, schema, graphId) {
665
+ const ensureTable = target.ensureRevisionOriginsTable;
666
+ if (ensureTable === void 0) {
667
+ throw new ConfigurationError(
668
+ "Revision tracking requires a backend that can bootstrap revision origins.",
669
+ { dialect: target.dialect },
670
+ {
671
+ suggestion: "Use a built-in SQLite/PostgreSQL backend, or implement ensureRevisionOriginsTable on the custom backend."
672
+ }
673
+ );
674
+ }
675
+ await ensureTable();
676
+ const existing = await readRevisionOrigin(target, schema, graphId);
677
+ if (existing !== void 0) return existing;
678
+ await executeStatement(
679
+ target,
680
+ sql`
681
+ INSERT INTO ${schema.revisionOriginsTable} (graph_id, origin)
682
+ VALUES (${graphId}, ${generateId()})
683
+ ON CONFLICT (graph_id) DO NOTHING
684
+ `
685
+ );
686
+ const origin = await readRevisionOrigin(target, schema, graphId);
687
+ if (origin !== void 0) return origin;
688
+ throw new ConfigurationError(
689
+ "Revision origin was not persisted after initialization.",
690
+ { graphId, dialect: target.dialect }
691
+ );
692
+ }
577
693
  async function writeRecordedClock(target, schema, graphId, recordedAt) {
578
694
  await executeStatement(
579
695
  target,
@@ -601,9 +717,9 @@ async function lockRecordedClock(target, schema, graphId, ownsWriteLock) {
601
717
  `
602
718
  );
603
719
  }
604
- async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock) {
720
+ async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock, previousRevision) {
605
721
  await lockRecordedClock(target, schema, graphId, ownsWriteLock);
606
- const previous = await readRecordedClock(target, schema, graphId);
722
+ const previous = previousRevision ?? await readRecordedClock(target, schema, graphId);
607
723
  const recordedCommitTime = nextRecordedCommitTime(previous);
608
724
  if (!Number.isFinite(recordedCommitTime) || recordedCommitTime >= RECORDED_MAX_TIME) {
609
725
  throw new ConfigurationError(
@@ -618,6 +734,15 @@ async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock) {
618
734
  await writeRecordedClock(target, schema, graphId, recordedCommit);
619
735
  return recordedCommit;
620
736
  }
737
+ async function advanceRevisionClock(target, schema, graphId, ownsWriteLock, previousRevision) {
738
+ return allocateRecordedCommit(
739
+ target,
740
+ schema,
741
+ graphId,
742
+ ownsWriteLock,
743
+ previousRevision
744
+ );
745
+ }
621
746
 
622
747
  // src/store/insert-dispatch.ts
623
748
  function nodeInsertDispatch(backend) {
@@ -767,7 +892,7 @@ function recordedCommonCells() {
767
892
  graph_id: (row) => sql`${row.graph_id}`,
768
893
  id: (row) => sql`${row.id}`,
769
894
  kind: (row) => sql`${row.kind}`,
770
- props: (row) => sql`${row.props}`,
895
+ props: (row) => sql`${rowPropsToJsonText(row.props)}`,
771
896
  valid_from: (row) => sql`${sqlNull(row.valid_from)}`,
772
897
  valid_to: (row) => sql`${sqlNull(row.valid_to)}`,
773
898
  created_at: (row) => sql`${row.created_at}`,
@@ -1028,6 +1153,21 @@ async function queryConnectedEdgeIds(target, schema, params) {
1028
1153
  }
1029
1154
 
1030
1155
  // src/store/recorded-capture.ts
1156
+ var RECORDED_FLUSH_OBSERVER = /* @__PURE__ */ Symbol("typegraph.recordedFlushObserver");
1157
+ function readRecordedFlushObserver(options) {
1158
+ return options?.[RECORDED_FLUSH_OBSERVER];
1159
+ }
1160
+ function stripRecordedFlushObserver(options) {
1161
+ if (options === void 0) return void 0;
1162
+ const { [RECORDED_FLUSH_OBSERVER]: _observer, ...backendOptions } = options;
1163
+ return backendOptions;
1164
+ }
1165
+ function withRecordedFlushObserver(options, observer) {
1166
+ return {
1167
+ ...stripRecordedFlushObserver(options),
1168
+ [RECORDED_FLUSH_OBSERVER]: observer
1169
+ };
1170
+ }
1031
1171
  function nodeIdentityKey(graphId, kind, id) {
1032
1172
  return `${graphId}\0${kind}\0${id}`;
1033
1173
  }
@@ -1079,7 +1219,8 @@ function createRecordedCaptureSession() {
1079
1219
  );
1080
1220
  }
1081
1221
  sealed = true;
1082
- if (touched.size === 0) return;
1222
+ if (touched.size === 0) return /* @__PURE__ */ new Map();
1223
+ const recordedByGraph = /* @__PURE__ */ new Map();
1083
1224
  const byGraph = groupBy(touched.values(), (entity) => entity.graphId);
1084
1225
  for (const [graphId, entities] of byGraph) {
1085
1226
  const recordedCommit = await allocateRecordedCommit(
@@ -1088,6 +1229,7 @@ function createRecordedCaptureSession() {
1088
1229
  graphId,
1089
1230
  ownsWriteLock
1090
1231
  );
1232
+ recordedByGraph.set(graphId, recordedCommit);
1091
1233
  const nodes = entities.filter(
1092
1234
  (entity) => entity.entity === "node"
1093
1235
  );
@@ -1098,22 +1240,26 @@ function createRecordedCaptureSession() {
1098
1240
  await flushEdges(target, schema, graphId, edges, recordedCommit);
1099
1241
  }
1100
1242
  touched.clear();
1243
+ return recordedByGraph;
1101
1244
  }
1102
1245
  };
1103
1246
  }
1104
1247
  function createRecordedTransactionBackend(target, session, schema) {
1105
1248
  const nodeDispatch = nodeInsertDispatch(target);
1106
1249
  const edgeDispatch = edgeInsertDispatch(target);
1250
+ const graphLocks = createRecordedGraphLockMemo();
1107
1251
  async function lockGraph(graphId) {
1108
- await lockRecordedGraphWrite(target, graphId);
1252
+ await lockRecordedGraphWrite(target, graphId, graphLocks);
1109
1253
  }
1110
1254
  async function lockGraphs(params) {
1111
- await lockRecordedGraphWrites(
1112
- target,
1113
- params.map((parameter) => parameter.graphId)
1114
- );
1255
+ const graphIds = [
1256
+ ...new Set(params.map((parameter) => parameter.graphId))
1257
+ ].toSorted();
1258
+ for (const graphId of graphIds) {
1259
+ await lockRecordedGraphWrite(target, graphId, graphLocks);
1260
+ }
1115
1261
  }
1116
- return createBackendOverlay(target, {
1262
+ const overlay = createBackendOverlay(target, {
1117
1263
  ...rawWriteGuards(target, "tx.backend"),
1118
1264
  async insertNode(params) {
1119
1265
  await lockGraph(params.graphId);
@@ -1233,8 +1379,28 @@ function createRecordedTransactionBackend(target, session, schema) {
1233
1379
  await lockGraph(params.graphId);
1234
1380
  await target.hardDeleteEdge(params);
1235
1381
  session.touchEdge(params.graphId, params.id);
1382
+ },
1383
+ ...target.deleteEdgesBatch === void 0 ? {} : {
1384
+ async deleteEdgesBatch(params) {
1385
+ await lockGraph(params.graphId);
1386
+ await target.deleteEdgesBatch(params);
1387
+ for (const id of params.ids) {
1388
+ session.touchEdge(params.graphId, id);
1389
+ }
1390
+ }
1391
+ },
1392
+ ...target.hardDeleteEdgesBatch === void 0 ? {} : {
1393
+ async hardDeleteEdgesBatch(params) {
1394
+ await lockGraph(params.graphId);
1395
+ await target.hardDeleteEdgesBatch(params);
1396
+ for (const id of params.ids) {
1397
+ session.touchEdge(params.graphId, id);
1398
+ }
1399
+ }
1236
1400
  }
1237
1401
  });
1402
+ registerRecordedGraphLockMemo(overlay, graphLocks);
1403
+ return overlay;
1238
1404
  }
1239
1405
  function createRecordedTransactionScope(target, schema, ownsWriteLock = false) {
1240
1406
  requireCaptureStatements(target);
@@ -1243,7 +1409,7 @@ function createRecordedTransactionScope(target, schema, ownsWriteLock = false) {
1243
1409
  return {
1244
1410
  backend: createRecordedTransactionBackend(target, session, resolvedSchema),
1245
1411
  async flush() {
1246
- await withRecordedRelationsPrecondition(
1412
+ return withRecordedRelationsPrecondition(
1247
1413
  session.flush(target, resolvedSchema, ownsWriteLock),
1248
1414
  { dialect: target.dialect, surface: "capture-flush" }
1249
1415
  );
@@ -1331,15 +1497,28 @@ function createRecordedBackend(backend, schema) {
1331
1497
  async hardDeleteEdge(params) {
1332
1498
  await capture((target) => target.hardDeleteEdge(params));
1333
1499
  },
1500
+ ...backend.deleteEdgesBatch === void 0 ? {} : {
1501
+ async deleteEdgesBatch(params) {
1502
+ await capture((target) => target.deleteEdgesBatch(params));
1503
+ }
1504
+ },
1505
+ ...backend.hardDeleteEdgesBatch === void 0 ? {} : {
1506
+ async hardDeleteEdgesBatch(params) {
1507
+ await capture((target) => target.hardDeleteEdgesBatch(params));
1508
+ }
1509
+ },
1334
1510
  async transaction(fn, options) {
1335
- assertRequestedRecordedIsolation(backend, options);
1511
+ const observer = readRecordedFlushObserver(options);
1512
+ const backendOptions = stripRecordedFlushObserver(options);
1513
+ assertRequestedRecordedIsolation(backend, backendOptions);
1336
1514
  return backend.transaction(async (target) => {
1337
1515
  await assertRecordedCaptureTransactionIsolation(target);
1338
1516
  const scope = createRecordedTransactionScope(target, schema, true);
1339
1517
  const result = await fn(scope.backend, createHistoryUnsafeSqlRef());
1340
- await scope.flush();
1518
+ const instants = await scope.flush();
1519
+ observer?.(instants);
1341
1520
  return result;
1342
- }, options);
1521
+ }, backendOptions);
1343
1522
  },
1344
1523
  ...backend.adoptTransaction === void 0 ? {} : {
1345
1524
  adoptTransaction(externalTx) {
@@ -1395,6 +1574,65 @@ async function syncEmbeddings(ctx, schema, props) {
1395
1574
  }
1396
1575
  }
1397
1576
  }
1577
+ async function syncEmbeddingsBatchForKind(args, schema, items) {
1578
+ const { graphId, nodeKind, backend } = args;
1579
+ if (!backend.upsertEmbedding || !backend.deleteEmbedding) {
1580
+ return;
1581
+ }
1582
+ const embeddingFields = getEmbeddingFields(schema);
1583
+ if (embeddingFields.length === 0) {
1584
+ return;
1585
+ }
1586
+ for (const field of embeddingFields) {
1587
+ const rows = [];
1588
+ const deletionIds = [];
1589
+ for (const item of items) {
1590
+ const value = item.props[field.fieldPath];
1591
+ if (isValidEmbeddingValue(value)) {
1592
+ rows.push({ nodeId: item.nodeId, embedding: value });
1593
+ } else if (value === void 0) {
1594
+ deletionIds.push(item.nodeId);
1595
+ }
1596
+ }
1597
+ if (rows.length > 0) {
1598
+ if (backend.upsertEmbeddingBatch === void 0) {
1599
+ for (const row of rows) {
1600
+ await backend.upsertEmbedding({
1601
+ graphId,
1602
+ nodeKind,
1603
+ nodeId: row.nodeId,
1604
+ fieldPath: field.fieldPath,
1605
+ embedding: row.embedding,
1606
+ dimensions: field.dimensions,
1607
+ metric: field.metric,
1608
+ indexType: field.indexType
1609
+ });
1610
+ }
1611
+ } else {
1612
+ await backend.upsertEmbeddingBatch({
1613
+ graphId,
1614
+ nodeKind,
1615
+ fieldPath: field.fieldPath,
1616
+ dimensions: field.dimensions,
1617
+ metric: field.metric,
1618
+ indexType: field.indexType,
1619
+ rows
1620
+ });
1621
+ }
1622
+ }
1623
+ for (const nodeId of deletionIds) {
1624
+ await backend.deleteEmbedding({
1625
+ graphId,
1626
+ nodeKind,
1627
+ nodeId,
1628
+ fieldPath: field.fieldPath,
1629
+ dimensions: field.dimensions,
1630
+ metric: field.metric,
1631
+ indexType: field.indexType
1632
+ });
1633
+ }
1634
+ }
1635
+ }
1398
1636
  async function deleteNodeEmbeddings(ctx, schema) {
1399
1637
  const { backend } = ctx;
1400
1638
  if (!backend.deleteEmbedding) {
@@ -1424,42 +1662,6 @@ function isValidEmbeddingValue(value) {
1424
1662
  }
1425
1663
 
1426
1664
  // src/store/fulltext-sync.ts
1427
- var searchableFieldsCache = /* @__PURE__ */ new WeakMap();
1428
- function getSearchableFields(schema) {
1429
- const cached = searchableFieldsCache.get(schema);
1430
- if (cached) return cached;
1431
- const fields = computeSearchableFields(schema);
1432
- searchableFieldsCache.set(schema, fields);
1433
- return fields;
1434
- }
1435
- function computeSearchableFields(schema) {
1436
- if (schema.type !== "object") return [];
1437
- const def = schema.def;
1438
- const shape = def.shape;
1439
- if (!shape) return [];
1440
- const fields = [];
1441
- for (const [fieldPath, fieldSchema] of Object.entries(shape)) {
1442
- const metadata = getSearchableMetadata(fieldSchema);
1443
- if (metadata !== void 0) {
1444
- fields.push({ fieldPath, metadata });
1445
- }
1446
- }
1447
- warnIfConflictingLanguages(fields);
1448
- return fields;
1449
- }
1450
- function warnIfConflictingLanguages(fields) {
1451
- if (fields.length < 2) return;
1452
- const languages = new Set(fields.map((field) => field.metadata.language));
1453
- if (languages.size < 2) return;
1454
- if (typeof console === "undefined" || typeof console.warn !== "function") {
1455
- return;
1456
- }
1457
- const fieldSummary = fields.map((field) => `${field.fieldPath}=${field.metadata.language}`).join(", ");
1458
- const winning = fields[0]?.metadata.language ?? DEFAULT_SEARCHABLE_LANGUAGE;
1459
- console.warn(
1460
- `[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.`
1461
- );
1462
- }
1463
1665
  var FIELD_SEPARATOR = "\n";
1464
1666
  function resolveCombinedLanguage(fields) {
1465
1667
  return fields[0]?.metadata.language ?? DEFAULT_SEARCHABLE_LANGUAGE;
@@ -1503,6 +1705,55 @@ async function syncFulltext(ctx, schema, props) {
1503
1705
  nodeId: ctx.nodeId
1504
1706
  });
1505
1707
  }
1708
+ async function syncFulltextBatchForKind(args, schema, items) {
1709
+ const { graphId, nodeKind, backend } = args;
1710
+ if (!backend.upsertFulltext || !backend.deleteFulltext) {
1711
+ return;
1712
+ }
1713
+ const rows = [];
1714
+ const emptyContentIds = [];
1715
+ const hasSearchableFields = getSearchableFields(schema).length > 0;
1716
+ for (const item of items) {
1717
+ const computed = computeFulltextContent(schema, item.props);
1718
+ if (computed !== void 0) {
1719
+ rows.push({
1720
+ nodeId: item.nodeId,
1721
+ content: computed.content,
1722
+ language: computed.language
1723
+ });
1724
+ } else if (hasSearchableFields) {
1725
+ emptyContentIds.push(item.nodeId);
1726
+ }
1727
+ }
1728
+ if (rows.length > 0) {
1729
+ if (backend.upsertFulltextBatch === void 0) {
1730
+ for (const row of rows) {
1731
+ await backend.upsertFulltext({
1732
+ graphId,
1733
+ nodeKind,
1734
+ nodeId: row.nodeId,
1735
+ content: row.content,
1736
+ language: row.language
1737
+ });
1738
+ }
1739
+ } else {
1740
+ await backend.upsertFulltextBatch({ graphId, nodeKind, rows });
1741
+ }
1742
+ }
1743
+ if (emptyContentIds.length > 0) {
1744
+ if (backend.deleteFulltextBatch === void 0) {
1745
+ for (const nodeId of emptyContentIds) {
1746
+ await backend.deleteFulltext({ graphId, nodeKind, nodeId });
1747
+ }
1748
+ } else {
1749
+ await backend.deleteFulltextBatch({
1750
+ graphId,
1751
+ nodeKind,
1752
+ nodeIds: emptyContentIds
1753
+ });
1754
+ }
1755
+ }
1756
+ }
1506
1757
  async function deleteNodeFulltext(ctx, schema) {
1507
1758
  const { backend } = ctx;
1508
1759
  if (!backend.deleteFulltext) {
@@ -1640,10 +1891,7 @@ function checkUniqueEdge(edgeKind, fromKind, fromId, _toKind, _toId, existingCou
1640
1891
  }
1641
1892
  function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registry) {
1642
1893
  const validFromKinds = registration.from.map((node) => node.kind);
1643
- const fromValid = validFromKinds.some(
1644
- (validKind) => registry.isAssignableTo(fromKind, validKind)
1645
- );
1646
- if (!fromValid) {
1894
+ if (!registry.isAssignableToAny(fromKind, validFromKinds)) {
1647
1895
  return new EndpointError({
1648
1896
  edgeKind,
1649
1897
  endpoint: "from",
@@ -1652,10 +1900,7 @@ function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registr
1652
1900
  });
1653
1901
  }
1654
1902
  const validToKinds = registration.to.map((node) => node.kind);
1655
- const toValid = validToKinds.some(
1656
- (validKind) => registry.isAssignableTo(toKind, validKind)
1657
- );
1658
- if (!toValid) {
1903
+ if (!registry.isAssignableToAny(toKind, validToKinds)) {
1659
1904
  return new EndpointError({
1660
1905
  edgeKind,
1661
1906
  endpoint: "to",
@@ -1736,6 +1981,36 @@ async function insertUniquenessEntries(ctx, kind, id, props, constraints) {
1736
1981
  });
1737
1982
  }
1738
1983
  }
1984
+ async function insertUniquenessEntriesBatch(ctx, items) {
1985
+ const entries = [];
1986
+ for (const item of items) {
1987
+ for (const constraint of item.constraints) {
1988
+ if (!checkWherePredicate(constraint, item.props)) {
1989
+ continue;
1990
+ }
1991
+ entries.push({
1992
+ graphId: ctx.graphId,
1993
+ nodeKind: item.kind,
1994
+ constraintName: constraint.name,
1995
+ key: computeUniqueKey(
1996
+ item.props,
1997
+ constraint.fields,
1998
+ constraint.collation
1999
+ ),
2000
+ nodeId: item.id,
2001
+ concreteKind: item.kind
2002
+ });
2003
+ }
2004
+ }
2005
+ if (entries.length === 0) return;
2006
+ if (ctx.backend.insertUniqueBatch !== void 0) {
2007
+ await ctx.backend.insertUniqueBatch(entries);
2008
+ return;
2009
+ }
2010
+ for (const entry of entries) {
2011
+ await ctx.backend.insertUnique(entry);
2012
+ }
2013
+ }
1739
2014
  async function deleteUniquenessEntries(ctx, kind, props, constraints) {
1740
2015
  for (const constraint of constraints) {
1741
2016
  if (!checkWherePredicate(constraint, props)) {
@@ -1847,6 +2122,14 @@ async function enforceNodeDeleteBehavior(ctx, args, backend, policy) {
1847
2122
  }
1848
2123
  case "cascade":
1849
2124
  case "disconnect": {
2125
+ const batchDelete = args.mode === "hard" ? backend.hardDeleteEdgesBatch : backend.deleteEdgesBatch;
2126
+ if (batchDelete !== void 0) {
2127
+ await batchDelete.call(backend, {
2128
+ graphId: ctx.graphId,
2129
+ ids: connectedEdges.map((edge) => edge.id)
2130
+ });
2131
+ break;
2132
+ }
1850
2133
  for (const edge of connectedEdges) {
1851
2134
  await (args.mode === "hard" ? backend.hardDeleteEdge({ graphId: ctx.graphId, id: edge.id }) : backend.deleteEdge({ graphId: ctx.graphId, id: edge.id }));
1852
2135
  }
@@ -1875,8 +2158,35 @@ async function applyNodeInsertSideEffects(ctx, args, backend) {
1875
2158
  )
1876
2159
  ]);
1877
2160
  }
2161
+ async function applyNodeInsertSideEffectsBatch(ctx, items, backend) {
2162
+ if (items.length === 0) return;
2163
+ await insertUniquenessEntriesBatch(
2164
+ uniquenessContext(ctx, backend),
2165
+ items.map((item) => ({
2166
+ kind: item.kind,
2167
+ id: item.id,
2168
+ props: item.props,
2169
+ constraints: item.uniqueConstraints
2170
+ }))
2171
+ );
2172
+ const byKind = /* @__PURE__ */ new Map();
2173
+ for (const item of items) {
2174
+ const group = byKind.get(item.kind) ?? { schema: item.schema, rows: [] };
2175
+ group.rows.push({ nodeId: item.id, props: item.props });
2176
+ byKind.set(item.kind, group);
2177
+ }
2178
+ await Promise.all(
2179
+ [...byKind.entries()].flatMap(([kind, group]) => {
2180
+ const syncArguments = { graphId: ctx.graphId, nodeKind: kind, backend };
2181
+ return [
2182
+ syncEmbeddingsBatchForKind(syncArguments, group.schema, group.rows),
2183
+ syncFulltextBatchForKind(syncArguments, group.schema, group.rows)
2184
+ ];
2185
+ })
2186
+ );
2187
+ }
1878
2188
  function parseRowProps(row) {
1879
- return JSON.parse(row.props);
2189
+ return rowPropsToObject(row.props);
1880
2190
  }
1881
2191
  async function applyNodeUpdate(ctx, args, backend) {
1882
2192
  const { kind, id } = args.existing;
@@ -2005,6 +2315,6 @@ async function applyNodeResurrect(ctx, args, backend) {
2005
2315
  return row;
2006
2316
  }
2007
2317
 
2008
- export { ALIAS_CTE_PREFIX, DEFAULT_SQL_SCHEMA, EMBEDDINGS_CTE_ALIAS, FULLTEXT_CTE_ALIAS, HYBRID_CANDIDATES_CTE_ALIAS, applyNodeHardDelete, applyNodeInsertSideEffects, applyNodeResurrect, applyNodeSoftDelete, applyNodeUpdate, asCompiledRowsSql, asCompiledSelectSql, asCompiledStatementSql, asRecordedInstant, assertRecordedCaptureTransactionIsolation, assertValidRecordedInstant, checkCardinality, checkDisjointness, checkUniqueEdge, checkUniquenessConstraints, checkWherePredicate, closeRecordedHardDeletedKind, computeFulltextContent, computeUniqueKey, coordinateContext, createHistoryUnsafeSqlRef, createNodeWriteContext, createRecordedBackend, createRecordedReadBinding, createRecordedTransactionScope, createSqlSchema, createUniquenessContext, describeCoordinate, edgeInsertDispatch, generateId, getEdgeRowsByIds, getEmbeddingFields, getKindsForUniquenessCheck, getNodeRowsByIds, getSearchableFields, lockRecordedGraphWrite, nodeInsertDispatch, readRecordedClock, recordedBindParamBudget, recordedCaptureRequiresCallbackTransactionError, recordedReadSchemaFor, recordedReadSqlSchema, recordedRelation, requireExternalRecordedReadSource, requireRecordedReadBinding, requireSqlSchema, resolveReadCoordinate, runInsertBatch, runInsertBatchReturning, runInsertNoReturn, uncapturedGraphWriteLock, validateEdgeEndpoints, vectorSlotKey, withRecordedCoordinate };
2009
- //# sourceMappingURL=chunk-A7SZZFAG.js.map
2010
- //# sourceMappingURL=chunk-A7SZZFAG.js.map
2318
+ export { ALIAS_CTE_PREFIX, DEFAULT_SQL_SCHEMA, EMBEDDINGS_CTE_ALIAS, FULLTEXT_CTE_ALIAS, HYBRID_CANDIDATES_CTE_ALIAS, advanceRevisionClock, applyNodeHardDelete, applyNodeInsertSideEffects, applyNodeInsertSideEffectsBatch, applyNodeResurrect, applyNodeSoftDelete, applyNodeUpdate, asRecordedInstant, assertRecordedCaptureTransactionIsolation, assertRevisionTrackableBackend, assertValidRecordedInstant, checkCardinality, checkDisjointness, checkUniqueEdge, checkUniquenessConstraints, checkWherePredicate, closeRecordedHardDeletedKind, computeFulltextContent, computeUniqueKey, coordinateContext, createHistoryUnsafeSqlRef, createNodeWriteContext, createRecordedBackend, createRecordedReadBinding, createRecordedTransactionScope, createRevisionTrackingUnsafeSqlRef, createSqlSchema, createUniquenessContext, describeCoordinate, edgeInsertDispatch, ensureRevisionOrigin, generateId, getEdgeRowsByIds, getEmbeddingFields, getKindsForUniquenessCheck, getNodeRowsByIds, lockRecordedGraphWrite, nodeInsertDispatch, readRecordedClock, readRevisionOrigin, recordedBindParamBudget, recordedCaptureRequiresCallbackTransactionError, recordedReadSchemaFor, recordedReadSqlSchema, recordedRelation, requireExternalRecordedReadSource, requireRecordedReadBinding, requireSqlSchema, resolveReadCoordinate, runInsertBatch, runInsertBatchReturning, runInsertNoReturn, uncapturedGraphWriteLock, validateEdgeEndpoints, vectorSlotKey, withRecordedCoordinate, withRecordedFlushObserver };
2319
+ //# sourceMappingURL=chunk-CZQ3FO2Q.js.map
2320
+ //# sourceMappingURL=chunk-CZQ3FO2Q.js.map