@nicia-ai/typegraph 0.35.0 → 0.37.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 (234) hide show
  1. package/dist/backend/postgres/index.cjs +24 -24
  2. package/dist/backend/postgres/index.d.cts +6 -6
  3. package/dist/backend/postgres/index.d.ts +6 -6
  4. package/dist/backend/postgres/index.js +11 -11
  5. package/dist/backend/postgres/pglite.cjs +16 -16
  6. package/dist/backend/postgres/pglite.d.cts +3 -3
  7. package/dist/backend/postgres/pglite.d.ts +3 -3
  8. package/dist/backend/postgres/pglite.js +11 -11
  9. package/dist/backend/sqlite/index.cjs +22 -21
  10. package/dist/backend/sqlite/index.d.cts +11 -9
  11. package/dist/backend/sqlite/index.d.ts +11 -9
  12. package/dist/backend/sqlite/index.js +10 -9
  13. package/dist/backend/sqlite/libsql.cjs +15 -14
  14. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  15. package/dist/backend/sqlite/libsql.d.cts +3 -3
  16. package/dist/backend/sqlite/libsql.d.ts +3 -3
  17. package/dist/backend/sqlite/libsql.js +11 -10
  18. package/dist/backend/sqlite/libsql.js.map +1 -1
  19. package/dist/backend/sqlite/local.cjs +30 -23
  20. package/dist/backend/sqlite/local.cjs.map +1 -1
  21. package/dist/backend/sqlite/local.d.cts +3 -3
  22. package/dist/backend/sqlite/local.d.ts +3 -3
  23. package/dist/backend/sqlite/local.js +18 -11
  24. package/dist/backend/sqlite/local.js.map +1 -1
  25. package/dist/{chunk-TCOCYN2P.cjs → chunk-27SSDCEP.cjs} +14 -14
  26. package/dist/{chunk-TCOCYN2P.cjs.map → chunk-27SSDCEP.cjs.map} +1 -1
  27. package/dist/{chunk-5AQIKK56.cjs → chunk-2N6EOBTH.cjs} +16 -16
  28. package/dist/{chunk-5AQIKK56.cjs.map → chunk-2N6EOBTH.cjs.map} +1 -1
  29. package/dist/{chunk-FN35DLCN.cjs → chunk-3C2RYI6L.cjs} +13 -107
  30. package/dist/chunk-3C2RYI6L.cjs.map +1 -0
  31. package/dist/{chunk-4JEZZJ6S.cjs → chunk-3DS7Z4T4.cjs} +39 -39
  32. package/dist/{chunk-4JEZZJ6S.cjs.map → chunk-3DS7Z4T4.cjs.map} +1 -1
  33. package/dist/{chunk-BLZDPRXT.cjs → chunk-3GH67G4Z.cjs} +5 -5
  34. package/dist/{chunk-BLZDPRXT.cjs.map → chunk-3GH67G4Z.cjs.map} +1 -1
  35. package/dist/{chunk-K3PPLHY7.js → chunk-3RWZPJKV.js} +24 -9
  36. package/dist/chunk-3RWZPJKV.js.map +1 -0
  37. package/dist/{chunk-QWEUYILR.js → chunk-3SLPDKHQ.js} +4 -4
  38. package/dist/chunk-3SLPDKHQ.js.map +1 -0
  39. package/dist/{chunk-5A6FNS6N.cjs → chunk-3XXGYU62.cjs} +11 -11
  40. package/dist/{chunk-5A6FNS6N.cjs.map → chunk-3XXGYU62.cjs.map} +1 -1
  41. package/dist/{chunk-JBTOYDMN.js → chunk-44TA22QT.js} +58 -11
  42. package/dist/chunk-44TA22QT.js.map +1 -0
  43. package/dist/{chunk-UES55P7G.js → chunk-552KNYQJ.js} +2652 -409
  44. package/dist/chunk-552KNYQJ.js.map +1 -0
  45. package/dist/{chunk-VPYHY3LJ.cjs → chunk-5KEQ74YU.cjs} +14 -14
  46. package/dist/chunk-5KEQ74YU.cjs.map +1 -0
  47. package/dist/{chunk-Q5TEXCTB.js → chunk-5KPNWT6X.js} +3 -3
  48. package/dist/{chunk-Q5TEXCTB.js.map → chunk-5KPNWT6X.js.map} +1 -1
  49. package/dist/{chunk-MP2JQKSG.js → chunk-5PNMDJ7J.js} +108 -5
  50. package/dist/chunk-5PNMDJ7J.js.map +1 -0
  51. package/dist/{chunk-AW4A3P5A.cjs → chunk-5VQM6VWP.cjs} +2 -2
  52. package/dist/{chunk-AW4A3P5A.cjs.map → chunk-5VQM6VWP.cjs.map} +1 -1
  53. package/dist/{chunk-A3W7QG7K.js → chunk-5WWVZMVX.js} +2 -2
  54. package/dist/{chunk-A3W7QG7K.js.map → chunk-5WWVZMVX.js.map} +1 -1
  55. package/dist/{chunk-FACJJWGF.cjs → chunk-6EEO3OVU.cjs} +7 -7
  56. package/dist/{chunk-FACJJWGF.cjs.map → chunk-6EEO3OVU.cjs.map} +1 -1
  57. package/dist/{chunk-LGEALRC6.cjs → chunk-BVRDGYXQ.cjs} +113 -4
  58. package/dist/chunk-BVRDGYXQ.cjs.map +1 -0
  59. package/dist/{chunk-GSQ6NPH6.cjs → chunk-DEFQM7JU.cjs} +7 -7
  60. package/dist/{chunk-GSQ6NPH6.cjs.map → chunk-DEFQM7JU.cjs.map} +1 -1
  61. package/dist/{chunk-EM3CWPND.cjs → chunk-DIQ3AV5W.cjs} +574 -268
  62. package/dist/chunk-DIQ3AV5W.cjs.map +1 -0
  63. package/dist/{chunk-FPIZFYHE.js → chunk-EXU3RASM.js} +74 -15
  64. package/dist/chunk-EXU3RASM.js.map +1 -0
  65. package/dist/{chunk-H7YNSMA7.cjs → chunk-HAHNRASW.cjs} +20 -2
  66. package/dist/chunk-HAHNRASW.cjs.map +1 -0
  67. package/dist/{chunk-FL472AMI.cjs → chunk-IP3CGGPA.cjs} +8 -8
  68. package/dist/{chunk-FL472AMI.cjs.map → chunk-IP3CGGPA.cjs.map} +1 -1
  69. package/dist/{chunk-4TOD4LBZ.cjs → chunk-IPSVVTWT.cjs} +94 -35
  70. package/dist/chunk-IPSVVTWT.cjs.map +1 -0
  71. package/dist/{chunk-RGP33ZJ5.js → chunk-IXGYRP2P.js} +184 -92
  72. package/dist/chunk-IXGYRP2P.js.map +1 -0
  73. package/dist/{chunk-3TWF3SH4.js → chunk-J4IUSYFF.js} +251 -121
  74. package/dist/chunk-J4IUSYFF.js.map +1 -0
  75. package/dist/{chunk-O7UN7OXA.cjs → chunk-JBNOGRKW.cjs} +318 -188
  76. package/dist/chunk-JBNOGRKW.cjs.map +1 -0
  77. package/dist/{chunk-WDBCBWC4.js → chunk-K3Q3LJY3.js} +520 -221
  78. package/dist/chunk-K3Q3LJY3.js.map +1 -0
  79. package/dist/{chunk-OR5ZA5WP.js → chunk-K5UBVGJN.js} +4 -4
  80. package/dist/{chunk-OR5ZA5WP.js.map → chunk-K5UBVGJN.js.map} +1 -1
  81. package/dist/{chunk-UZV3AZKF.js → chunk-KQJ54OG5.js} +3 -3
  82. package/dist/{chunk-UZV3AZKF.js.map → chunk-KQJ54OG5.js.map} +1 -1
  83. package/dist/{chunk-QOTI55H7.js → chunk-L7HQ2OSI.js} +4 -4
  84. package/dist/{chunk-QOTI55H7.js.map → chunk-L7HQ2OSI.js.map} +1 -1
  85. package/dist/{chunk-55MZDDZV.js → chunk-M6VES7V6.js} +4 -4
  86. package/dist/{chunk-55MZDDZV.js.map → chunk-M6VES7V6.js.map} +1 -1
  87. package/dist/{chunk-J7WFGBJR.cjs → chunk-NBP2WTJW.cjs} +3249 -1006
  88. package/dist/chunk-NBP2WTJW.cjs.map +1 -0
  89. package/dist/{chunk-CK5BVQOW.cjs → chunk-NUIG3BCV.cjs} +100 -85
  90. package/dist/chunk-NUIG3BCV.cjs.map +1 -0
  91. package/dist/{chunk-EMF62TZG.cjs → chunk-NXQFATMF.cjs} +269 -177
  92. package/dist/chunk-NXQFATMF.cjs.map +1 -0
  93. package/dist/{chunk-KBGQIPRQ.js → chunk-PC2UBAUB.js} +20 -3
  94. package/dist/chunk-PC2UBAUB.js.map +1 -0
  95. package/dist/chunk-QARBLBXT.cjs +219 -0
  96. package/dist/chunk-QARBLBXT.cjs.map +1 -0
  97. package/dist/{chunk-6FR2MMS6.js → chunk-QERAIDRJ.js} +45 -4
  98. package/dist/chunk-QERAIDRJ.js.map +1 -0
  99. package/dist/chunk-QSXTWU4U.cjs +12 -0
  100. package/dist/{chunk-GUR2FNB5.cjs.map → chunk-QSXTWU4U.cjs.map} +1 -1
  101. package/dist/{chunk-QNKSQTKQ.js → chunk-RCVLFTCT.js} +49 -19
  102. package/dist/chunk-RCVLFTCT.js.map +1 -0
  103. package/dist/{chunk-VSPCZAXF.js → chunk-RRSNR3TP.js} +3 -3
  104. package/dist/{chunk-VSPCZAXF.js.map → chunk-RRSNR3TP.js.map} +1 -1
  105. package/dist/{chunk-WJT7OU7E.cjs → chunk-TGOMW4MB.cjs} +129 -98
  106. package/dist/chunk-TGOMW4MB.cjs.map +1 -0
  107. package/dist/{chunk-KMI7LYAF.js → chunk-TKT2XHED.js} +8 -8
  108. package/dist/{chunk-KMI7LYAF.js.map → chunk-TKT2XHED.js.map} +1 -1
  109. package/dist/{chunk-RGPG7EOJ.js → chunk-TPF25IG6.js} +3 -3
  110. package/dist/{chunk-RGPG7EOJ.js.map → chunk-TPF25IG6.js.map} +1 -1
  111. package/dist/{chunk-5SEGFTZX.js → chunk-UGZUAYAR.js} +3 -3
  112. package/dist/{chunk-5SEGFTZX.js.map → chunk-UGZUAYAR.js.map} +1 -1
  113. package/dist/{chunk-VHMPG6UL.js → chunk-UXLSNRYL.js} +11 -105
  114. package/dist/chunk-UXLSNRYL.js.map +1 -0
  115. package/dist/{chunk-FRV5Q5IO.js → chunk-UYQMBBWJ.js} +3 -3
  116. package/dist/{chunk-FRV5Q5IO.js.map → chunk-UYQMBBWJ.js.map} +1 -1
  117. package/dist/{chunk-UUT7UN2N.cjs → chunk-VGDDG3XJ.cjs} +7 -7
  118. package/dist/{chunk-UUT7UN2N.cjs.map → chunk-VGDDG3XJ.cjs.map} +1 -1
  119. package/dist/{chunk-CZQ3FO2Q.js → chunk-VKGKDOKR.js} +56 -21
  120. package/dist/chunk-VKGKDOKR.js.map +1 -0
  121. package/dist/{chunk-CTTSDJLY.cjs → chunk-VL2V6PEN.cjs} +11 -11
  122. package/dist/{chunk-CTTSDJLY.cjs.map → chunk-VL2V6PEN.cjs.map} +1 -1
  123. package/dist/{chunk-XOX22WHL.cjs → chunk-WOJMKB3N.cjs} +125 -90
  124. package/dist/chunk-WOJMKB3N.cjs.map +1 -0
  125. package/dist/{chunk-UMDVATGY.cjs → chunk-WWFHO375.cjs} +6 -6
  126. package/dist/{chunk-UMDVATGY.cjs.map → chunk-WWFHO375.cjs.map} +1 -1
  127. package/dist/{chunk-I7ZUZKFD.js → chunk-XGPUQ56G.js} +3 -3
  128. package/dist/{chunk-I7ZUZKFD.js.map → chunk-XGPUQ56G.js.map} +1 -1
  129. package/dist/{chunk-D7ZEOS56.cjs → chunk-XGU7DZDA.cjs} +74 -14
  130. package/dist/chunk-XGU7DZDA.cjs.map +1 -0
  131. package/dist/{chunk-S55OV6PW.cjs → chunk-XPCZADMT.cjs} +54 -11
  132. package/dist/chunk-XPCZADMT.cjs.map +1 -0
  133. package/dist/{chunk-T2WUSPDA.js → chunk-XWV4JT34.js} +3 -3
  134. package/dist/{chunk-T2WUSPDA.js.map → chunk-XWV4JT34.js.map} +1 -1
  135. package/dist/chunk-YTSN73ND.js +212 -0
  136. package/dist/chunk-YTSN73ND.js.map +1 -0
  137. package/dist/{ddl-CZz7a0E8.d.cts → ddl-BD-ZfKeX.d.cts} +3 -3
  138. package/dist/{ddl-C2rZ-Aen.d.ts → ddl-CS0KUVwB.d.ts} +3 -3
  139. package/dist/{extension-types-ixRpJVUp.d.cts → extension-types-BM2ACfYO.d.cts} +6 -1
  140. package/dist/{extension-types-ixRpJVUp.d.ts → extension-types-BM2ACfYO.d.ts} +6 -1
  141. package/dist/{fulltext-strategy-CDkSSYhq.d.cts → fulltext-strategy-C27vXaeB.d.cts} +127 -8
  142. package/dist/{fulltext-strategy-B57yvC5Q.d.ts → fulltext-strategy-DebsMrqg.d.ts} +127 -8
  143. package/dist/graph-extension/index.cjs +19 -19
  144. package/dist/graph-extension/index.d.cts +4 -4
  145. package/dist/graph-extension/index.d.ts +4 -4
  146. package/dist/graph-extension/index.js +4 -4
  147. package/dist/graph-merge/index.cjs +88 -88
  148. package/dist/graph-merge/index.cjs.map +1 -1
  149. package/dist/graph-merge/index.d.cts +6 -6
  150. package/dist/graph-merge/index.d.ts +6 -6
  151. package/dist/graph-merge/index.js +19 -19
  152. package/dist/graph-merge/index.js.map +1 -1
  153. package/dist/{index-Bks_3HHK.d.cts → index-BPM59vsg.d.cts} +119 -7
  154. package/dist/{index-6CSUAq-x.d.ts → index-BeacbPoe.d.ts} +119 -7
  155. package/dist/index.cjs +230 -185
  156. package/dist/index.cjs.map +1 -1
  157. package/dist/index.d.cts +11 -11
  158. package/dist/index.d.ts +11 -11
  159. package/dist/index.js +53 -40
  160. package/dist/index.js.map +1 -1
  161. package/dist/indexes/index.cjs +30 -21
  162. package/dist/indexes/index.d.cts +5 -5
  163. package/dist/indexes/index.d.ts +5 -5
  164. package/dist/indexes/index.js +8 -7
  165. package/dist/interchange/index.cjs +208 -30
  166. package/dist/interchange/index.cjs.map +1 -1
  167. package/dist/interchange/index.d.cts +25 -8
  168. package/dist/interchange/index.d.ts +25 -8
  169. package/dist/interchange/index.js +191 -11
  170. package/dist/interchange/index.js.map +1 -1
  171. package/dist/{manager-DwQi8eV0.d.cts → manager-D00_NXvT.d.ts} +11 -2
  172. package/dist/{manager-ejUCB52T.d.ts → manager-nU1vTJLy.d.cts} +11 -2
  173. package/dist/{materialize-indexes-B4e9360H.d.cts → materialize-indexes-CuR3gAZb.d.cts} +8 -2
  174. package/dist/{materialize-indexes-te9TPMMJ.d.ts → materialize-indexes-zK2J_flP.d.ts} +8 -2
  175. package/dist/{postgres-DQ5R6rzV.d.ts → postgres-IaBA4RgE.d.ts} +1 -1
  176. package/dist/{postgres-CfEqsRMp.d.cts → postgres-YrYmPlaU.d.cts} +1 -1
  177. package/dist/profiler/index.cjs +3 -3
  178. package/dist/profiler/index.d.cts +7 -7
  179. package/dist/profiler/index.d.ts +7 -7
  180. package/dist/profiler/index.js +2 -2
  181. package/dist/provenance/index.cjs +32 -33
  182. package/dist/provenance/index.cjs.map +1 -1
  183. package/dist/provenance/index.d.cts +5 -5
  184. package/dist/provenance/index.d.ts +5 -5
  185. package/dist/provenance/index.js +5 -6
  186. package/dist/provenance/index.js.map +1 -1
  187. package/dist/schema/index.cjs +35 -35
  188. package/dist/schema/index.d.cts +7 -7
  189. package/dist/schema/index.d.ts +7 -7
  190. package/dist/schema/index.js +11 -11
  191. package/dist/{sqlite-DvQndLky.d.ts → sqlite-BUOHPx7p.d.ts} +1 -1
  192. package/dist/{sqlite-D7zBinNR.d.cts → sqlite-Pp8O19WE.d.cts} +1 -1
  193. package/dist/{store-view-CKbHFRnn.d.ts → store-view-ANL6mTph.d.ts} +457 -57
  194. package/dist/{store-view-BSpqvAxK.d.cts → store-view-X96Rd00T.d.cts} +457 -57
  195. package/dist/{types-Bv9DcS_E.d.cts → types-r-Zyq2Hz.d.cts} +2 -2
  196. package/dist/{types-CoxuV7EJ.d.ts → types-wsvuBgPK.d.ts} +2 -2
  197. package/dist/where-CJOpJj3a.d.ts +36 -0
  198. package/dist/where-K3uBP33l.d.cts +36 -0
  199. package/package.json +1 -1
  200. package/dist/chunk-3TWF3SH4.js.map +0 -1
  201. package/dist/chunk-4TOD4LBZ.cjs.map +0 -1
  202. package/dist/chunk-6FR2MMS6.js.map +0 -1
  203. package/dist/chunk-CK5BVQOW.cjs.map +0 -1
  204. package/dist/chunk-CZQ3FO2Q.js.map +0 -1
  205. package/dist/chunk-D7ZEOS56.cjs.map +0 -1
  206. package/dist/chunk-EM3CWPND.cjs.map +0 -1
  207. package/dist/chunk-EMF62TZG.cjs.map +0 -1
  208. package/dist/chunk-EOLERH7Y.cjs +0 -40
  209. package/dist/chunk-EOLERH7Y.cjs.map +0 -1
  210. package/dist/chunk-FN35DLCN.cjs.map +0 -1
  211. package/dist/chunk-FPIZFYHE.js.map +0 -1
  212. package/dist/chunk-GUR2FNB5.cjs +0 -12
  213. package/dist/chunk-H7YNSMA7.cjs.map +0 -1
  214. package/dist/chunk-J7WFGBJR.cjs.map +0 -1
  215. package/dist/chunk-JBTOYDMN.js.map +0 -1
  216. package/dist/chunk-K3PPLHY7.js.map +0 -1
  217. package/dist/chunk-KBGQIPRQ.js.map +0 -1
  218. package/dist/chunk-LGEALRC6.cjs.map +0 -1
  219. package/dist/chunk-MP2JQKSG.js.map +0 -1
  220. package/dist/chunk-O7UN7OXA.cjs.map +0 -1
  221. package/dist/chunk-QNKSQTKQ.js.map +0 -1
  222. package/dist/chunk-QWEUYILR.js.map +0 -1
  223. package/dist/chunk-RGP33ZJ5.js.map +0 -1
  224. package/dist/chunk-S55OV6PW.cjs.map +0 -1
  225. package/dist/chunk-UES55P7G.js.map +0 -1
  226. package/dist/chunk-UT3S4SEN.js +0 -31
  227. package/dist/chunk-UT3S4SEN.js.map +0 -1
  228. package/dist/chunk-VHMPG6UL.js.map +0 -1
  229. package/dist/chunk-VPYHY3LJ.cjs.map +0 -1
  230. package/dist/chunk-WDBCBWC4.js.map +0 -1
  231. package/dist/chunk-WJT7OU7E.cjs.map +0 -1
  232. package/dist/chunk-XOX22WHL.cjs.map +0 -1
  233. package/dist/where-7RKFOsXt.d.ts +0 -11
  234. package/dist/where-DdMIXOtH.d.cts +0 -11
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkEM3CWPND_cjs = require('./chunk-EM3CWPND.cjs');
4
- var chunkFN35DLCN_cjs = require('./chunk-FN35DLCN.cjs');
5
- var chunkCTTSDJLY_cjs = require('./chunk-CTTSDJLY.cjs');
6
- var chunkD7ZEOS56_cjs = require('./chunk-D7ZEOS56.cjs');
7
- var chunk4TOD4LBZ_cjs = require('./chunk-4TOD4LBZ.cjs');
8
- var chunkBLZDPRXT_cjs = require('./chunk-BLZDPRXT.cjs');
9
- var chunkLGEALRC6_cjs = require('./chunk-LGEALRC6.cjs');
3
+ var chunkDIQ3AV5W_cjs = require('./chunk-DIQ3AV5W.cjs');
4
+ var chunk3C2RYI6L_cjs = require('./chunk-3C2RYI6L.cjs');
5
+ var chunkVL2V6PEN_cjs = require('./chunk-VL2V6PEN.cjs');
6
+ var chunkXGU7DZDA_cjs = require('./chunk-XGU7DZDA.cjs');
7
+ var chunkIPSVVTWT_cjs = require('./chunk-IPSVVTWT.cjs');
8
+ var chunk3GH67G4Z_cjs = require('./chunk-3GH67G4Z.cjs');
9
+ var chunkBVRDGYXQ_cjs = require('./chunk-BVRDGYXQ.cjs');
10
10
  var drizzleOrm = require('drizzle-orm');
11
11
  var sqliteCore = require('drizzle-orm/sqlite-core');
12
12
 
@@ -26,11 +26,30 @@ function isDurableObjectBySessionName(db) {
26
26
  const sessionName = getSessionName(db);
27
27
  return sessionName === "SQLiteDOSession" || sessionName === "SQLiteDurableObjectSession";
28
28
  }
29
+ function isDurableObjectStorageClient(value) {
30
+ if (typeof value !== "object" || value === null) return false;
31
+ const candidate = value;
32
+ const sqlApi = candidate.sql;
33
+ return typeof candidate.transaction === "function" && typeof candidate.transactionSync === "function" && typeof sqlApi === "object" && sqlApi !== null && typeof sqlApi.exec === "function";
34
+ }
35
+ function getDurableObjectStorageClient(db) {
36
+ const client = db.$client;
37
+ return isDurableObjectStorageClient(client) ? client : void 0;
38
+ }
39
+ function detectHostedPlatform(db) {
40
+ if (getDurableObjectStorageClient(db) !== void 0 || isDurableObjectBySessionName(db)) {
41
+ return "durable-object";
42
+ }
43
+ if (isD1DatabaseBySessionName(db)) return "d1";
44
+ return void 0;
45
+ }
29
46
  function isSyncDatabaseBySessionName(db) {
30
47
  const sessionName = getSessionName(db);
31
48
  return sessionName === "BetterSQLiteSession" || sessionName === "BunSQLiteSession";
32
49
  }
33
- function detectSyncProfile(db, profileHints) {
50
+ function detectSyncProfile(db, profileHints, hostedPlatform) {
51
+ if (hostedPlatform === "durable-object") return true;
52
+ if (hostedPlatform === "d1") return false;
34
53
  if (profileHints.isSync !== void 0) {
35
54
  return profileHints.isSync;
36
55
  }
@@ -38,12 +57,6 @@ function detectSyncProfile(db, profileHints) {
38
57
  if (sessionName === "BetterSQLiteSession" || sessionName === "BunSQLiteSession") {
39
58
  return true;
40
59
  }
41
- if (isDurableObjectBySessionName(db)) {
42
- return true;
43
- }
44
- if (sessionName === "SQLiteD1Session") {
45
- return false;
46
- }
47
60
  try {
48
61
  const probeResult = db.get(drizzleOrm.sql`SELECT 1 AS __typegraph_sync_probe__`);
49
62
  return !(probeResult instanceof Promise);
@@ -51,16 +64,12 @@ function detectSyncProfile(db, profileHints) {
51
64
  return isSyncDatabaseBySessionName(db);
52
65
  }
53
66
  }
54
- function detectTransactionMode(db, profileHints, isSync) {
67
+ function detectTransactionMode(profileHints, isSync, hostedPlatform) {
68
+ if (hostedPlatform === "durable-object") return "do-sqlite";
69
+ if (hostedPlatform === "d1") return "none";
55
70
  if (profileHints.transactionMode !== void 0) {
56
71
  return profileHints.transactionMode;
57
72
  }
58
- if (isDurableObjectBySessionName(db)) {
59
- return "do-sqlite";
60
- }
61
- if (isD1DatabaseBySessionName(db)) {
62
- return "none";
63
- }
64
73
  if (isSync) return "sql";
65
74
  return "drizzle";
66
75
  }
@@ -86,9 +95,16 @@ function hasModernBindLimitByVersion(rows) {
86
95
  if (!Number.isFinite(major) || !Number.isFinite(minor)) return false;
87
96
  return major > FIRST_MODERN_BIND_LIMIT_MAJOR || major === FIRST_MODERN_BIND_LIMIT_MAJOR && minor >= FIRST_MODERN_BIND_LIMIT_MINOR;
88
97
  }
89
- function detectMaxBindParameters(db, sqliteClient) {
90
- if (isD1DatabaseBySessionName(db)) return chunk4TOD4LBZ_cjs.D1_MAX_BIND_PARAMETERS;
91
- if (sqliteClient === void 0) return chunk4TOD4LBZ_cjs.SQLITE_MAX_BIND_PARAMETERS;
98
+ function detectHardMaxBindParameters(transactionMode, hostedPlatform) {
99
+ if (hostedPlatform === "durable-object" || transactionMode === "do-sqlite") {
100
+ return chunkIPSVVTWT_cjs.DURABLE_OBJECT_MAX_BIND_PARAMETERS;
101
+ }
102
+ if (hostedPlatform === "d1") return chunkIPSVVTWT_cjs.D1_MAX_BIND_PARAMETERS;
103
+ return void 0;
104
+ }
105
+ function detectMaxBindParameters(sqliteClient, hardMaxBindParameters) {
106
+ if (hardMaxBindParameters !== void 0) return hardMaxBindParameters;
107
+ if (sqliteClient === void 0) return chunkIPSVVTWT_cjs.SQLITE_MAX_BIND_PARAMETERS;
92
108
  try {
93
109
  const compiled = parseCompiledMaxVariableNumber(
94
110
  sqliteClient.prepare("PRAGMA compile_options").all()
@@ -97,21 +113,20 @@ function detectMaxBindParameters(db, sqliteClient) {
97
113
  const isModern = hasModernBindLimitByVersion(
98
114
  sqliteClient.prepare("SELECT sqlite_version() AS version").all()
99
115
  );
100
- return isModern ? chunk4TOD4LBZ_cjs.MODERN_SQLITE_MAX_BIND_PARAMETERS : chunk4TOD4LBZ_cjs.SQLITE_MAX_BIND_PARAMETERS;
116
+ return isModern ? chunkIPSVVTWT_cjs.MODERN_SQLITE_MAX_BIND_PARAMETERS : chunkIPSVVTWT_cjs.SQLITE_MAX_BIND_PARAMETERS;
101
117
  } catch {
102
- return chunk4TOD4LBZ_cjs.SQLITE_MAX_BIND_PARAMETERS;
118
+ return chunkIPSVVTWT_cjs.SQLITE_MAX_BIND_PARAMETERS;
103
119
  }
104
120
  }
105
121
  function resolveSqliteClient(db) {
106
- const databaseWithClient = db;
107
- const sqliteClient = databaseWithClient.$client;
108
- if (sqliteClient?.prepare === void 0) {
109
- return void 0;
110
- }
122
+ const sqliteClient = db.$client;
123
+ if (typeof sqliteClient !== "object" || sqliteClient === null) return;
124
+ const candidate = sqliteClient;
125
+ if (typeof candidate.prepare !== "function") return;
111
126
  return sqliteClient;
112
127
  }
113
128
  function getOrCreatePreparedStatement(cache, sqliteClient, sqlText, cacheMax) {
114
- return chunkEM3CWPND_cjs.getOrCreateLru(
129
+ return chunkDIQ3AV5W_cjs.getOrCreateLru(
115
130
  cache,
116
131
  sqlText,
117
132
  cacheMax,
@@ -139,16 +154,31 @@ function createSqliteExecutionAdapter(db, statementCacheMaxOrOptions = {}) {
139
154
  const options = typeof statementCacheMaxOrOptions === "number" ? { statementCacheMax: statementCacheMaxOrOptions } : statementCacheMaxOrOptions;
140
155
  const statementCacheMax = options.statementCacheMax ?? DEFAULT_PREPARED_STATEMENT_CACHE_MAX;
141
156
  const profileHints = options.profileHints ?? {};
142
- const isSync = detectSyncProfile(db, profileHints);
157
+ const hostedPlatform = detectHostedPlatform(db);
158
+ const isSync = detectSyncProfile(db, profileHints, hostedPlatform);
143
159
  const sqliteClient = isSync ? resolveSqliteClient(db) : void 0;
144
- const transactionMode = detectTransactionMode(db, profileHints, isSync);
160
+ const transactionMode = detectTransactionMode(
161
+ profileHints,
162
+ isSync,
163
+ hostedPlatform
164
+ );
165
+ const hardMaxBindParameters = detectHardMaxBindParameters(
166
+ transactionMode,
167
+ hostedPlatform
168
+ );
169
+ const maxBindParameters = detectMaxBindParameters(
170
+ sqliteClient,
171
+ hardMaxBindParameters
172
+ );
145
173
  const profile = {
174
+ ...hostedPlatform === void 0 ? {} : { hostedPlatform },
175
+ ...hardMaxBindParameters === void 0 ? {} : { hardMaxBindParameters },
146
176
  isSync,
147
- maxBindParameters: detectMaxBindParameters(db, sqliteClient),
177
+ maxBindParameters,
148
178
  supportsCompiledExecution: sqliteClient !== void 0,
149
179
  transactionMode
150
180
  };
151
- const compile = (query) => chunkEM3CWPND_cjs.compileQueryWithDialect(db, query, "SQLite");
181
+ const compile = (query) => chunkDIQ3AV5W_cjs.compileQueryWithDialect(db, query, "SQLite");
152
182
  if (sqliteClient !== void 0) {
153
183
  let executeCompiled2 = function(compiledQuery) {
154
184
  const preparedStatement = getOrCreatePreparedStatement(
@@ -172,6 +202,22 @@ function createSqliteExecutionAdapter(db, statementCacheMaxOrOptions = {}) {
172
202
  preparedStatement.run(...compiledQuery.params);
173
203
  }
174
204
  return Promise.resolve();
205
+ }, executePreparedRunBatch2 = function(sqlText, parameterRows) {
206
+ const preparedStatement = getOrCreatePreparedStatement(
207
+ statementCache,
208
+ client,
209
+ sqlText,
210
+ statementCacheMax
211
+ );
212
+ if (preparedStatement.run === void 0) {
213
+ throw new Error(
214
+ "Trusted SQLite import requires a prepared statement run() method."
215
+ );
216
+ }
217
+ for (const params of parameterRows) {
218
+ preparedStatement.run(...params);
219
+ }
220
+ return Promise.resolve();
175
221
  };
176
222
  const client = sqliteClient;
177
223
  const statementCache = /* @__PURE__ */ new Map();
@@ -186,6 +232,7 @@ function createSqliteExecutionAdapter(db, statementCacheMaxOrOptions = {}) {
186
232
  },
187
233
  executeCompiled: executeCompiled2,
188
234
  executeCompiledRun: executeCompiledRun2,
235
+ executePreparedRunBatch: executePreparedRunBatch2,
189
236
  prepare(sqlText) {
190
237
  return createPreparedStatementExecutor(
191
238
  client,
@@ -226,7 +273,7 @@ function computeSqliteBatchChunkSizes(maxBindParameters) {
226
273
  ),
227
274
  embeddingUpsertBatchSize: Math.max(
228
275
  1,
229
- Math.floor(maxBindParameters / chunkEM3CWPND_cjs.EMBEDDING_UPSERT_PARAM_COUNT)
276
+ Math.floor(maxBindParameters / chunkDIQ3AV5W_cjs.EMBEDDING_UPSERT_PARAM_COUNT)
230
277
  ),
231
278
  fulltextUpsertBatchSize: Math.max(
232
279
  1,
@@ -258,11 +305,11 @@ function computeSqliteBatchChunkSizes(maxBindParameters) {
258
305
  )
259
306
  };
260
307
  }
261
- var toNodeRow = chunkCTTSDJLY_cjs.createNodeRowMapper(chunkCTTSDJLY_cjs.SQLITE_ROW_MAPPER_CONFIG);
262
- var toEdgeRow = chunkCTTSDJLY_cjs.createEdgeRowMapper(chunkCTTSDJLY_cjs.SQLITE_ROW_MAPPER_CONFIG);
263
- var toUniqueRow = chunkCTTSDJLY_cjs.createUniqueRowMapper(chunkCTTSDJLY_cjs.SQLITE_ROW_MAPPER_CONFIG);
264
- var toSchemaVersionRow = chunkCTTSDJLY_cjs.createSchemaVersionRowMapper(
265
- chunkCTTSDJLY_cjs.SQLITE_ROW_MAPPER_CONFIG
308
+ var toNodeRow = chunkVL2V6PEN_cjs.createNodeRowMapper(chunkVL2V6PEN_cjs.SQLITE_ROW_MAPPER_CONFIG);
309
+ var toEdgeRow = chunkVL2V6PEN_cjs.createEdgeRowMapper(chunkVL2V6PEN_cjs.SQLITE_ROW_MAPPER_CONFIG);
310
+ var toUniqueRow = chunkVL2V6PEN_cjs.createUniqueRowMapper(chunkVL2V6PEN_cjs.SQLITE_ROW_MAPPER_CONFIG);
311
+ var toSchemaVersionRow = chunkVL2V6PEN_cjs.createSchemaVersionRowMapper(
312
+ chunkVL2V6PEN_cjs.SQLITE_ROW_MAPPER_CONFIG
266
313
  );
267
314
  var PENDING_FOREVER = new Promise(noop);
268
315
  function pendingForever() {
@@ -281,7 +328,7 @@ async function loadQueueTaskContext() {
281
328
  void loadQueueTaskContext();
282
329
  function rejectReentrantQueueSubmission() {
283
330
  return Promise.reject(
284
- new chunkLGEALRC6_cjs.ConfigurationError(
331
+ new chunkBVRDGYXQ_cjs.ConfigurationError(
285
332
  "This operation was awaited from inside a transaction running on the same SQLite backend and would deadlock: the transaction holds the backend's serialized execution slot until it completes, so the operation could never run.",
286
333
  { backend: "sqlite", capability: "concurrentRootAccess" },
287
334
  {
@@ -302,7 +349,7 @@ function createSerializedExecutionQueue() {
302
349
  disposed = true;
303
350
  },
304
351
  runExclusive(task) {
305
- if (isDisposed()) return Promise.reject(new chunkLGEALRC6_cjs.BackendDisposedError());
352
+ if (isDisposed()) return Promise.reject(new chunkBVRDGYXQ_cjs.BackendDisposedError());
306
353
  if (queueTaskContext?.getStore() === taskMarker) {
307
354
  return rejectReentrantQueueSubmission();
308
355
  }
@@ -330,21 +377,34 @@ function runWithSerializedQueue(queue, task) {
330
377
  return queue.runExclusive(task);
331
378
  }
332
379
  function throwSqliteTransactionsDisabled(message) {
333
- throw new chunkLGEALRC6_cjs.ConfigurationError(message, {
380
+ throw new chunkBVRDGYXQ_cjs.ConfigurationError(message, {
334
381
  backend: "sqlite",
335
382
  capability: "transactions",
336
383
  supportsTransactions: false
337
384
  });
338
385
  }
339
386
  function buildSqliteCapabilities(options) {
340
- const base = options.transactionMode === "none" ? { ...chunk4TOD4LBZ_cjs.SQLITE_CAPABILITIES, transactions: false } : chunk4TOD4LBZ_cjs.SQLITE_CAPABILITIES;
387
+ const base = options.transactionMode === "none" ? {
388
+ ...chunkIPSVVTWT_cjs.SQLITE_CAPABILITIES,
389
+ transactions: false,
390
+ graphAnalytics: {
391
+ ...chunkIPSVVTWT_cjs.SQLITE_CAPABILITIES.graphAnalytics ?? {
392
+ mathFunctions: false
393
+ },
394
+ supported: false
395
+ }
396
+ } : chunkIPSVVTWT_cjs.SQLITE_CAPABILITIES;
341
397
  return {
342
398
  ...base,
343
399
  maxBindParameters: options.maxBindParameters,
344
- fulltext: chunkD7ZEOS56_cjs.buildFulltextCapabilities(options.fulltextStrategy),
345
- ...options.vectorStrategy === void 0 ? {} : { vector: chunkD7ZEOS56_cjs.buildVectorCapabilities(options.vectorStrategy) }
400
+ fulltext: chunkXGU7DZDA_cjs.buildFulltextCapabilities(options.fulltextStrategy),
401
+ ...options.vectorStrategy === void 0 ? {} : { vector: chunkXGU7DZDA_cjs.buildVectorCapabilities(options.vectorStrategy) }
346
402
  };
347
403
  }
404
+ function resolveMaxBindParametersCapability(profile, override) {
405
+ const requested = override ?? profile.maxBindParameters;
406
+ return profile.hardMaxBindParameters === void 0 ? requested : Math.min(requested, profile.hardMaxBindParameters);
407
+ }
348
408
  function createSqliteOperationBackend(options) {
349
409
  const {
350
410
  capabilities,
@@ -355,7 +415,7 @@ function createSqliteOperationBackend(options) {
355
415
  tableNames,
356
416
  fulltextStrategy,
357
417
  vectorStrategy,
358
- vectorSlotLatch
418
+ contributionMaterializer
359
419
  } = options;
360
420
  const compiledExecute = executionAdapter.executeCompiled;
361
421
  const compiledRun = executionAdapter.executeCompiledRun;
@@ -387,16 +447,16 @@ function createSqliteOperationBackend(options) {
387
447
  });
388
448
  }
389
449
  const batchConfig = computeSqliteBatchChunkSizes(
390
- capabilities.maxBindParameters ?? chunk4TOD4LBZ_cjs.SQLITE_MAX_BIND_PARAMETERS
450
+ capabilities.maxBindParameters ?? chunkIPSVVTWT_cjs.SQLITE_MAX_BIND_PARAMETERS
391
451
  );
392
- const commonBackend = chunkEM3CWPND_cjs.createCommonOperationBackend({
452
+ const commonBackend = chunkDIQ3AV5W_cjs.createCommonOperationBackend({
393
453
  batchConfig,
394
454
  execution: {
395
455
  execAll,
396
456
  execGet,
397
457
  execRun
398
458
  },
399
- nowIso: chunkCTTSDJLY_cjs.nowIso,
459
+ nowIso: chunkVL2V6PEN_cjs.nowIso,
400
460
  operationStrategy,
401
461
  rowMappers: {
402
462
  toEdgeRow,
@@ -414,36 +474,30 @@ function createSqliteOperationBackend(options) {
414
474
  );
415
475
  }
416
476
  };
417
- async function ensureVectorSlotStorage(slot) {
418
- if (vectorStrategy === void 0 || vectorSlotLatch === void 0) return;
419
- await vectorSlotLatch.ensure(vectorStrategy, slot, async (statement) => {
420
- await execRun(drizzleOrm.sql.raw(statement));
421
- });
422
- }
423
477
  const vectorEmbeddingMethods = vectorStrategy === void 0 ? {} : {
424
478
  async upsertEmbedding(params) {
425
- const slot = chunkEM3CWPND_cjs.vectorSlotFromParams(params);
426
- await ensureVectorSlotStorage(slot);
427
- const statements = vectorStrategy.buildUpsert(slot, params, chunkCTTSDJLY_cjs.nowIso());
479
+ const slot = chunkDIQ3AV5W_cjs.vectorSlotFromParams(params);
480
+ await contributionMaterializer.assertVectorSlot(slot);
481
+ const statements = vectorStrategy.buildUpsert(slot, params, chunkVL2V6PEN_cjs.nowIso());
428
482
  try {
429
483
  for (const statement of statements) {
430
484
  await execRun(statement);
431
485
  }
432
486
  } catch (error) {
433
- throw chunkEM3CWPND_cjs.mapVectorWriteError(error, params);
487
+ throw chunkDIQ3AV5W_cjs.mapVectorWriteError(error, params);
434
488
  }
435
489
  },
436
490
  async upsertEmbeddingBatch(params) {
437
491
  if (params.rows.length === 0) return;
438
- const slot = chunkEM3CWPND_cjs.vectorSlotFromParams(params);
439
- await ensureVectorSlotStorage(slot);
492
+ const slot = chunkDIQ3AV5W_cjs.vectorSlotFromParams(params);
493
+ await contributionMaterializer.assertVectorSlot(slot);
440
494
  const rowsById = new Map(
441
495
  params.rows.map((row) => [row.nodeId, row])
442
496
  );
443
497
  const rows = [...rowsById.values()];
444
- const timestamp = chunkCTTSDJLY_cjs.nowIso();
498
+ const timestamp = chunkVL2V6PEN_cjs.nowIso();
445
499
  try {
446
- for (const chunk2 of chunk4TOD4LBZ_cjs.chunk(
500
+ for (const chunk2 of chunkIPSVVTWT_cjs.chunk(
447
501
  rows,
448
502
  batchConfig.embeddingUpsertBatchSize
449
503
  )) {
@@ -472,21 +526,20 @@ function createSqliteOperationBackend(options) {
472
526
  }
473
527
  }
474
528
  } catch (error) {
475
- throw chunkEM3CWPND_cjs.mapVectorWriteError(error, params);
529
+ throw chunkDIQ3AV5W_cjs.mapVectorWriteError(error, params);
476
530
  }
477
531
  },
478
532
  async deleteEmbedding(params) {
479
- const slot = chunkEM3CWPND_cjs.vectorSlotFromParams(params);
480
- await ensureVectorSlotStorage(slot);
533
+ const slot = chunkDIQ3AV5W_cjs.vectorSlotFromParams(params);
534
+ await contributionMaterializer.assertVectorSlot(slot);
481
535
  const statements = vectorStrategy.buildDelete(slot, params);
482
536
  for (const statement of statements) {
483
537
  await execRun(statement);
484
538
  }
485
539
  },
486
540
  async vectorSearch(params) {
487
- chunkD7ZEOS56_cjs.assertVectorSearchLimit(params.limit);
488
- const slot = chunkEM3CWPND_cjs.vectorSlotFromParams(params);
489
- await ensureVectorSlotStorage(slot);
541
+ chunkXGU7DZDA_cjs.assertVectorSearchLimit(params.limit);
542
+ const slot = chunkDIQ3AV5W_cjs.vectorSlotFromParams(params);
490
543
  const query = vectorStrategy.buildSearch(
491
544
  slot,
492
545
  params,
@@ -501,7 +554,7 @@ function createSqliteOperationBackend(options) {
501
554
  try {
502
555
  rows = await execAll(query);
503
556
  } catch (error) {
504
- throw chunkEM3CWPND_cjs.mapVectorWriteError(error, params);
557
+ throw chunkDIQ3AV5W_cjs.mapVectorWriteError(error, params);
505
558
  }
506
559
  return rows.map((row) => ({
507
560
  nodeId: row.node_id,
@@ -513,9 +566,9 @@ function createSqliteOperationBackend(options) {
513
566
  // fallback by simply not exposing the member.
514
567
  ...capabilities.windowFunctions ? {
515
568
  async hybridSearch(params) {
516
- chunkD7ZEOS56_cjs.assertVectorSearchLimit(params.limit);
517
- chunkD7ZEOS56_cjs.assertVectorSearchLimit(params.vector.k);
518
- const slot = chunkEM3CWPND_cjs.vectorSlotFromParams({
569
+ chunkXGU7DZDA_cjs.assertVectorSearchLimit(params.limit);
570
+ chunkXGU7DZDA_cjs.assertVectorSearchLimit(params.vector.k);
571
+ const slot = chunkDIQ3AV5W_cjs.vectorSlotFromParams({
519
572
  graphId: params.graphId,
520
573
  nodeKind: params.nodeKind,
521
574
  fieldPath: params.vector.fieldPath,
@@ -523,7 +576,6 @@ function createSqliteOperationBackend(options) {
523
576
  metric: params.vector.metric,
524
577
  indexType: params.vector.indexType
525
578
  });
526
- await ensureVectorSlotStorage(slot);
527
579
  const candidates = params.candidates ?? operationStrategy.buildLiveNodeIds(
528
580
  params.graphId,
529
581
  params.nodeKind
@@ -542,7 +594,7 @@ function createSqliteOperationBackend(options) {
542
594
  const vectorSql = vectorStrategy.buildSearch(
543
595
  slot,
544
596
  vectorParams,
545
- chunkEM3CWPND_cjs.hybridCandidatesRef()
597
+ chunkDIQ3AV5W_cjs.hybridCandidatesRef()
546
598
  );
547
599
  const statement = operationStrategy.buildHybridSearch(
548
600
  { ...params, candidates },
@@ -553,9 +605,9 @@ function createSqliteOperationBackend(options) {
553
605
  try {
554
606
  raw = await execAll(statement);
555
607
  } catch (error) {
556
- throw chunkEM3CWPND_cjs.mapVectorWriteError(error, vectorParams);
608
+ throw chunkDIQ3AV5W_cjs.mapVectorWriteError(error, vectorParams);
557
609
  }
558
- return raw.map((row) => chunkEM3CWPND_cjs.mapHybridSearchRow(row, toNodeRow));
610
+ return raw.map((row) => chunkDIQ3AV5W_cjs.mapHybridSearchRow(row, toNodeRow));
559
611
  }
560
612
  } : {}
561
613
  };
@@ -570,8 +622,8 @@ function createSqliteOperationBackend(options) {
570
622
  ...vectorStrategy === void 0 ? {} : { vectorStrategy },
571
623
  async createVectorIndex(params) {
572
624
  if (vectorStrategy === void 0) return;
573
- const slot = chunkEM3CWPND_cjs.vectorSlotFromCreateIndexParams(params);
574
- await ensureVectorSlotStorage(slot);
625
+ const slot = chunkDIQ3AV5W_cjs.vectorSlotFromCreateIndexParams(params);
626
+ await contributionMaterializer.ensureVectorSlot(slot);
575
627
  const indexStatement = vectorStrategy.buildCreateIndex?.(slot);
576
628
  if (indexStatement !== void 0) {
577
629
  await execRun(indexStatement);
@@ -579,18 +631,18 @@ function createSqliteOperationBackend(options) {
579
631
  },
580
632
  async dropVectorIndex(params) {
581
633
  if (vectorStrategy === void 0) return;
582
- const slot = chunkEM3CWPND_cjs.vectorSlotFromDropIndexParams(params);
634
+ const slot = chunkDIQ3AV5W_cjs.vectorSlotFromDropIndexParams(params);
583
635
  const dropStatement = vectorStrategy.buildDropIndex?.(slot);
584
636
  if (dropStatement === void 0) return;
585
637
  try {
586
638
  await execRun(dropStatement);
587
639
  } catch (error) {
588
- if (!chunkBLZDPRXT_cjs.isMissingTableError(error)) throw error;
640
+ if (!chunk3GH67G4Z_cjs.isMissingTableError(error)) throw error;
589
641
  }
590
642
  },
591
643
  // === Fulltext Operations ===
592
644
  async upsertFulltext(params) {
593
- const timestamp = chunkCTTSDJLY_cjs.nowIso();
645
+ const timestamp = chunkVL2V6PEN_cjs.nowIso();
594
646
  const statements = operationStrategy.buildUpsertFulltext(
595
647
  params,
596
648
  timestamp
@@ -607,8 +659,8 @@ function createSqliteOperationBackend(options) {
607
659
  },
608
660
  async upsertFulltextBatch(params) {
609
661
  if (params.rows.length === 0) return;
610
- const timestamp = chunkCTTSDJLY_cjs.nowIso();
611
- for (const rows of chunk4TOD4LBZ_cjs.chunk(
662
+ const timestamp = chunkVL2V6PEN_cjs.nowIso();
663
+ for (const rows of chunkIPSVVTWT_cjs.chunk(
612
664
  params.rows,
613
665
  batchConfig.fulltextUpsertBatchSize
614
666
  )) {
@@ -623,7 +675,7 @@ function createSqliteOperationBackend(options) {
623
675
  },
624
676
  async deleteFulltextBatch(params) {
625
677
  if (params.nodeIds.length === 0) return;
626
- for (const nodeIds of chunk4TOD4LBZ_cjs.chunk(
678
+ for (const nodeIds of chunkIPSVVTWT_cjs.chunk(
627
679
  params.nodeIds,
628
680
  batchConfig.fulltextDeleteChunkSize
629
681
  )) {
@@ -641,7 +693,7 @@ function createSqliteOperationBackend(options) {
641
693
  const rows = await execAll(query);
642
694
  return rows.map((row, index) => ({
643
695
  nodeId: row.node_id,
644
- score: chunkCTTSDJLY_cjs.coerceNumericScore(row.score),
696
+ score: chunkVL2V6PEN_cjs.coerceNumericScore(row.score),
645
697
  rank: index + 1,
646
698
  ...row.snippet === null ? {} : { snippet: row.snippet }
647
699
  }));
@@ -660,22 +712,26 @@ function createSqliteOperationBackend(options) {
660
712
  return operationBackend;
661
713
  }
662
714
  function createSqliteBackend(db, options = {}) {
663
- const tables2 = options.tables ?? chunkFN35DLCN_cjs.tables;
664
- const fulltextStrategy = options.fulltext ?? chunkD7ZEOS56_cjs.fts5Strategy;
715
+ const tables2 = options.tables ?? chunk3C2RYI6L_cjs.tables;
716
+ const fulltextStrategy = options.fulltext ?? chunkXGU7DZDA_cjs.fts5Strategy;
665
717
  const profileHints = options.executionProfile ?? {};
666
718
  const executionAdapter = createSqliteExecutionAdapter(db, { profileHints });
667
719
  const { isSync, transactionMode } = executionAdapter.profile;
668
720
  const vectorStrategy = options.vector;
669
- const vectorSlotLatch = vectorStrategy === void 0 ? void 0 : chunkEM3CWPND_cjs.createVectorSlotLatch();
670
- const capabilities = {
721
+ const capabilityOverrides = options.capabilities ?? {};
722
+ const capabilities = chunkIPSVVTWT_cjs.normalizeGraphAnalyticsCapabilities({
671
723
  ...buildSqliteCapabilities({
672
724
  fulltextStrategy,
673
725
  vectorStrategy,
674
726
  transactionMode,
675
727
  maxBindParameters: executionAdapter.profile.maxBindParameters
676
728
  }),
677
- ...options.capabilities
678
- };
729
+ ...capabilityOverrides,
730
+ maxBindParameters: resolveMaxBindParametersCapability(
731
+ executionAdapter.profile,
732
+ capabilityOverrides.maxBindParameters
733
+ )
734
+ });
679
735
  const tableNames = {
680
736
  nodes: drizzleOrm.getTableName(tables2.nodes),
681
737
  edges: drizzleOrm.getTableName(tables2.edges),
@@ -697,11 +753,82 @@ function createSqliteBackend(db, options = {}) {
697
753
  tableNames.recordedEdges,
698
754
  tableNames.recordedClock
699
755
  ];
700
- const operationStrategy = chunkEM3CWPND_cjs.createSqliteOperationStrategy(
756
+ const operationStrategy = chunkDIQ3AV5W_cjs.createSqliteOperationStrategy(
701
757
  tables2,
702
758
  fulltextStrategy
703
759
  );
704
760
  const serializedQueue = transactionMode === "none" ? void 0 : createSerializedExecutionQueue();
761
+ const matTable = tables2.contributionMaterializations;
762
+ async function ensureContributionMaterializationsTableImpl() {
763
+ await db.run(drizzleOrm.sql.raw(chunkDIQ3AV5W_cjs.generateSqliteCreateTableSQL(matTable)));
764
+ }
765
+ async function getContributionMaterializationRow(identity) {
766
+ const rows = await db.select().from(matTable).where(
767
+ drizzleOrm.and(
768
+ drizzleOrm.eq(matTable.graphId, identity.graphId),
769
+ drizzleOrm.eq(matTable.logicalName, identity.logicalName),
770
+ drizzleOrm.eq(matTable.owner, identity.owner),
771
+ drizzleOrm.eq(matTable.tableName, identity.tableName)
772
+ )
773
+ );
774
+ const row = rows[0];
775
+ if (row === void 0) return void 0;
776
+ return chunkDIQ3AV5W_cjs.mapContributionMaterializationRow(
777
+ row,
778
+ chunkDIQ3AV5W_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.decode
779
+ );
780
+ }
781
+ async function getContributionMaterializationRows(graphId) {
782
+ const rows = await db.select().from(matTable).where(drizzleOrm.eq(matTable.graphId, graphId));
783
+ return rows.map(
784
+ (row) => chunkDIQ3AV5W_cjs.mapContributionMaterializationRow(
785
+ row,
786
+ chunkDIQ3AV5W_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.decode
787
+ )
788
+ );
789
+ }
790
+ async function recordContributionMaterializationRow(params) {
791
+ await db.insert(matTable).values(
792
+ chunkDIQ3AV5W_cjs.buildContributionInsertValues(
793
+ params,
794
+ chunkDIQ3AV5W_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.encode
795
+ )
796
+ ).onConflictDoUpdate({
797
+ target: [
798
+ matTable.graphId,
799
+ matTable.logicalName,
800
+ matTable.owner,
801
+ matTable.tableName
802
+ ],
803
+ set: chunkDIQ3AV5W_cjs.buildContributionOnConflictSet(
804
+ matTable.materializedAt,
805
+ params.materializedAt
806
+ )
807
+ });
808
+ }
809
+ async function deleteContributionMaterializationRow(identity) {
810
+ await db.delete(matTable).where(
811
+ drizzleOrm.and(
812
+ drizzleOrm.eq(matTable.graphId, identity.graphId),
813
+ drizzleOrm.eq(matTable.logicalName, identity.logicalName),
814
+ drizzleOrm.eq(matTable.owner, identity.owner),
815
+ drizzleOrm.eq(matTable.tableName, identity.tableName)
816
+ )
817
+ );
818
+ }
819
+ const contributionMaterializer = chunkDIQ3AV5W_cjs.createContributionMaterializer({
820
+ dialect: "sqlite",
821
+ fulltextStrategy,
822
+ fulltextTableName: tables2.fulltextTableName,
823
+ vectorStrategy,
824
+ execDdl: async (statement) => {
825
+ await db.run(drizzleOrm.sql.raw(statement));
826
+ },
827
+ ensureMarkerTable: ensureContributionMaterializationsTableImpl,
828
+ getMarkers: getContributionMaterializationRows,
829
+ recordMarker: recordContributionMaterializationRow,
830
+ deleteMarker: deleteContributionMaterializationRow
831
+ });
705
832
  const operations = createSqliteOperationBackend({
706
833
  capabilities,
707
834
  db,
@@ -710,20 +837,19 @@ function createSqliteBackend(db, options = {}) {
710
837
  tableNames,
711
838
  fulltextStrategy,
712
839
  vectorStrategy,
713
- vectorSlotLatch,
840
+ contributionMaterializer,
714
841
  ...serializedQueue === void 0 ? {} : { serializedQueue }
715
842
  });
716
843
  function runDoSqliteStorageTransaction(run) {
717
- const storage = db.$client;
718
- const storageTransaction = storage?.transaction;
719
- if (typeof storageTransaction !== "function") {
844
+ const storage = getDurableObjectStorageClient(db);
845
+ if (storage === void 0) {
720
846
  throwSqliteTransactionsDisabled(
721
- "transactionMode 'do-sqlite' requires a Drizzle Durable Objects database (drizzle(ctx.storage)) whose `$client` exposes the async storage `transaction(async () => ...)` runner."
847
+ "transactionMode 'do-sqlite' requires a Drizzle Durable Objects database (drizzle(ctx.storage)) whose `$client` exposes the SQL, transactionSync, and async transaction runners."
722
848
  );
723
849
  }
724
850
  return runWithSerializedQueue(
725
851
  serializedQueue,
726
- async () => storageTransaction.call(storage, run)
852
+ () => storage.transaction(run)
727
853
  );
728
854
  }
729
855
  async function runFrameStatement(query) {
@@ -750,7 +876,9 @@ function createSqliteBackend(db, options = {}) {
750
876
  profileHints: { isSync },
751
877
  tableNames,
752
878
  fulltextStrategy,
753
- vectorStrategy});
879
+ vectorStrategy,
880
+ contributionMaterializer
881
+ });
754
882
  await runFrameStatement(drizzleOrm.sql`BEGIN IMMEDIATE`);
755
883
  try {
756
884
  const result = await fn(txBackend);
@@ -771,7 +899,9 @@ function createSqliteBackend(db, options = {}) {
771
899
  profileHints: { isSync },
772
900
  tableNames,
773
901
  fulltextStrategy,
774
- vectorStrategy});
902
+ vectorStrategy,
903
+ contributionMaterializer
904
+ });
775
905
  return fn(txBackend);
776
906
  });
777
907
  }
@@ -786,63 +916,15 @@ function createSqliteBackend(db, options = {}) {
786
916
  profileHints: { isSync },
787
917
  tableNames,
788
918
  fulltextStrategy,
789
- vectorStrategy});
919
+ vectorStrategy,
920
+ contributionMaterializer
921
+ });
790
922
  return fn(txBackend);
791
923
  },
792
924
  { behavior: "immediate" }
793
925
  )
794
926
  );
795
927
  }
796
- const matTable = tables2.contributionMaterializations;
797
- async function ensureContributionMaterializationsTableImpl() {
798
- await db.run(drizzleOrm.sql.raw(chunkEM3CWPND_cjs.generateSqliteCreateTableSQL(matTable)));
799
- }
800
- async function getContributionMaterializationRow(identity) {
801
- const rows = await db.select().from(matTable).where(
802
- drizzleOrm.and(
803
- drizzleOrm.eq(matTable.graphId, identity.graphId),
804
- drizzleOrm.eq(matTable.logicalName, identity.logicalName),
805
- drizzleOrm.eq(matTable.owner, identity.owner),
806
- drizzleOrm.eq(matTable.tableName, identity.tableName)
807
- )
808
- );
809
- const row = rows[0];
810
- if (row === void 0) return void 0;
811
- return chunkEM3CWPND_cjs.mapContributionMaterializationRow(
812
- row,
813
- chunkEM3CWPND_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.decode
814
- );
815
- }
816
- async function recordContributionMaterializationRow(params) {
817
- await db.insert(matTable).values(
818
- chunkEM3CWPND_cjs.buildContributionInsertValues(
819
- params,
820
- chunkEM3CWPND_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.encode
821
- )
822
- ).onConflictDoUpdate({
823
- target: [
824
- matTable.graphId,
825
- matTable.logicalName,
826
- matTable.owner,
827
- matTable.tableName
828
- ],
829
- set: chunkEM3CWPND_cjs.buildContributionOnConflictSet(
830
- matTable.materializedAt,
831
- params.materializedAt
832
- )
833
- });
834
- }
835
- const contributionMaterializer = chunkEM3CWPND_cjs.createContributionMaterializer({
836
- dialect: "sqlite",
837
- fulltextStrategy,
838
- fulltextTableName: tables2.fulltextTableName,
839
- execDdl: async (statement) => {
840
- await db.run(drizzleOrm.sql.raw(statement));
841
- },
842
- ensureMarkerTable: ensureContributionMaterializationsTableImpl,
843
- getMarker: getContributionMaterializationRow,
844
- recordMarker: recordContributionMaterializationRow
845
- });
846
928
  function bindTransactionBackend(tx) {
847
929
  const txBackend = createTransactionBackend({
848
930
  capabilities,
@@ -851,20 +933,39 @@ function createSqliteBackend(db, options = {}) {
851
933
  profileHints: { isSync },
852
934
  tableNames,
853
935
  fulltextStrategy,
854
- vectorStrategy});
855
- return chunkEM3CWPND_cjs.gateFulltext(txBackend, contributionMaterializer.assertInitialized);
936
+ vectorStrategy,
937
+ contributionMaterializer
938
+ });
939
+ return chunkDIQ3AV5W_cjs.gateFulltext(txBackend, contributionMaterializer.assertInitialized);
856
940
  }
857
941
  const backend = {
858
942
  ...operations,
943
+ ...isSync && transactionMode === "sql" && executionAdapter.executePreparedRunBatch !== void 0 ? {
944
+ async trustedImport(fn) {
945
+ return backend.transaction(async (tx) => {
946
+ await chunkDIQ3AV5W_cjs.assertTrustedImportDatabaseEmpty(tx, tableNames);
947
+ const indexDefinitions = await chunkDIQ3AV5W_cjs.suspendSqliteSecondaryIndexes(
948
+ tx,
949
+ tableNames
950
+ );
951
+ const result = await fn(
952
+ chunkDIQ3AV5W_cjs.createSqliteTrustedImportSession(executionAdapter, tableNames)
953
+ );
954
+ await chunkDIQ3AV5W_cjs.restoreSecondaryIndexes(tx, indexDefinitions);
955
+ await chunkDIQ3AV5W_cjs.analyzeImportedTables(tx, tableNames);
956
+ return result;
957
+ });
958
+ }
959
+ } : {},
859
960
  async bootstrapTables() {
860
- const statements = chunkEM3CWPND_cjs.generateSqliteDDL(tables2, fulltextStrategy);
961
+ const statements = chunkDIQ3AV5W_cjs.generateSqliteDDL(tables2, fulltextStrategy);
861
962
  for (const statement of statements) {
862
963
  await db.run(drizzleOrm.sql.raw(statement));
863
964
  }
864
965
  },
865
966
  async ensureRevisionOriginsTable() {
866
967
  await db.run(
867
- drizzleOrm.sql.raw(chunkEM3CWPND_cjs.generateSqliteCreateTableSQL(tables2.revisionOrigins))
968
+ drizzleOrm.sql.raw(chunkDIQ3AV5W_cjs.generateSqliteCreateTableSQL(tables2.revisionOrigins))
868
969
  );
869
970
  },
870
971
  // Every fulltext-touching method asserts the durable marker instead
@@ -872,7 +973,7 @@ function createSqliteBackend(db, options = {}) {
872
973
  // uninitialized database throws `StoreNotInitializedError` rather
873
974
  // than self-healing (#135). Shared verbatim with the tx-scoped gate
874
975
  // via `gateFulltextMethods`.
875
- ...chunkEM3CWPND_cjs.gateFulltextMethods(
976
+ ...chunkDIQ3AV5W_cjs.gateFulltextMethods(
876
977
  operations,
877
978
  contributionMaterializer.assertInitialized
878
979
  ),
@@ -881,7 +982,7 @@ function createSqliteBackend(db, options = {}) {
881
982
  },
882
983
  async ensureIndexMaterializationsTable() {
883
984
  await db.run(
884
- drizzleOrm.sql.raw(chunkEM3CWPND_cjs.generateSqliteCreateTableSQL(tables2.indexMaterializations))
985
+ drizzleOrm.sql.raw(chunkDIQ3AV5W_cjs.generateSqliteCreateTableSQL(tables2.indexMaterializations))
885
986
  );
886
987
  },
887
988
  async getIndexMaterialization(indexName) {
@@ -889,29 +990,26 @@ function createSqliteBackend(db, options = {}) {
889
990
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.indexName, indexName));
890
991
  const row = rows[0];
891
992
  if (row === void 0) return void 0;
892
- return chunkEM3CWPND_cjs.mapMaterializationRow(row, chunkEM3CWPND_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode);
993
+ return chunkDIQ3AV5W_cjs.mapMaterializationRow(row, chunkDIQ3AV5W_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode);
893
994
  },
894
995
  async getIndexMaterializations(statusKeys) {
895
996
  if (statusKeys.length === 0) return [];
896
997
  const t = tables2.indexMaterializations;
897
998
  const rows = await db.select().from(t).where(drizzleOrm.inArray(t.indexName, [...statusKeys]));
898
999
  return rows.map(
899
- (row) => chunkEM3CWPND_cjs.mapMaterializationRow(row, chunkEM3CWPND_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode)
1000
+ (row) => chunkDIQ3AV5W_cjs.mapMaterializationRow(row, chunkDIQ3AV5W_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode)
900
1001
  );
901
1002
  },
902
1003
  async recordIndexMaterialization(params) {
903
1004
  const t = tables2.indexMaterializations;
904
1005
  await db.insert(t).values(
905
- chunkEM3CWPND_cjs.buildMaterializationInsertValues(
1006
+ chunkDIQ3AV5W_cjs.buildMaterializationInsertValues(
906
1007
  params,
907
- chunkEM3CWPND_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.encode
1008
+ chunkDIQ3AV5W_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.encode
908
1009
  )
909
1010
  ).onConflictDoUpdate({
910
1011
  target: t.indexName,
911
- set: chunkEM3CWPND_cjs.buildMaterializationOnConflictSet(
912
- t.materializedAt,
913
- params.materializedAt
914
- )
1012
+ set: chunkDIQ3AV5W_cjs.buildMaterializationOnConflictSet(params.materializedAt)
915
1013
  });
916
1014
  },
917
1015
  async ensureContributionMaterializationsTable() {
@@ -927,37 +1025,37 @@ function createSqliteBackend(db, options = {}) {
927
1025
  await contributionMaterializer.assertInitialized(graphId);
928
1026
  },
929
1027
  async ensureKindRemovalsTable() {
930
- await db.run(drizzleOrm.sql.raw(chunkEM3CWPND_cjs.generateSqliteCreateTableSQL(tables2.kindRemovals)));
1028
+ await db.run(drizzleOrm.sql.raw(chunkDIQ3AV5W_cjs.generateSqliteCreateTableSQL(tables2.kindRemovals)));
931
1029
  },
932
1030
  async getPendingKindRemovals(graphId) {
933
1031
  const t = tables2.kindRemovals;
934
1032
  const rows = await db.select().from(t).where(drizzleOrm.and(drizzleOrm.eq(t.graphId, graphId), drizzleOrm.isNull(t.removedAt)));
935
1033
  return rows.map(
936
- (row) => chunkEM3CWPND_cjs.mapKindRemovalRow(row, chunkEM3CWPND_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
1034
+ (row) => chunkDIQ3AV5W_cjs.mapKindRemovalRow(row, chunkDIQ3AV5W_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
937
1035
  );
938
1036
  },
939
1037
  async getAllKindRemovals(graphId) {
940
1038
  const t = tables2.kindRemovals;
941
1039
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
942
1040
  return rows.map(
943
- (row) => chunkEM3CWPND_cjs.mapKindRemovalRow(row, chunkEM3CWPND_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
1041
+ (row) => chunkDIQ3AV5W_cjs.mapKindRemovalRow(row, chunkDIQ3AV5W_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
944
1042
  );
945
1043
  },
946
1044
  async recordKindRemoval(params) {
947
1045
  const t = tables2.kindRemovals;
948
1046
  await db.insert(t).values(
949
- chunkEM3CWPND_cjs.buildKindRemovalInsertValues(
1047
+ chunkDIQ3AV5W_cjs.buildKindRemovalInsertValues(
950
1048
  params,
951
- chunkEM3CWPND_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.encode
1049
+ chunkDIQ3AV5W_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.encode
952
1050
  )
953
1051
  ).onConflictDoUpdate({
954
1052
  target: [t.graphId, t.kindName, t.entity, t.schemaVersion],
955
- set: chunkEM3CWPND_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
1053
+ set: chunkDIQ3AV5W_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
956
1054
  });
957
1055
  },
958
1056
  async ensureReconciliationMarkersTable() {
959
1057
  await db.run(
960
- drizzleOrm.sql.raw(chunkEM3CWPND_cjs.generateSqliteCreateTableSQL(tables2.reconciliationMarkers))
1058
+ drizzleOrm.sql.raw(chunkDIQ3AV5W_cjs.generateSqliteCreateTableSQL(tables2.reconciliationMarkers))
961
1059
  );
962
1060
  },
963
1061
  async ensureRuntimeContributions(graphId) {
@@ -971,6 +1069,27 @@ function createSqliteBackend(db, options = {}) {
971
1069
  async ensureFulltextTable(graphId) {
972
1070
  await contributionMaterializer.ensureRuntimeContributions(graphId);
973
1071
  },
1072
+ // Vector counterparts of the runtime-contribution methods. Present
1073
+ // only when a vector strategy is wired (omitted on a plain SQLite
1074
+ // connection with no vector extension), mirroring the embedding/
1075
+ // search methods.
1076
+ ...vectorStrategy === void 0 ? {} : {
1077
+ async ensureVectorSlotContribution(slot, options_) {
1078
+ await contributionMaterializer.ensureVectorSlot(slot, options_);
1079
+ },
1080
+ async ensureVectorSlotContributions(slots, options_) {
1081
+ await contributionMaterializer.ensureVectorSlots(slots, options_);
1082
+ },
1083
+ async assertVectorSlotInitialized(slot) {
1084
+ await contributionMaterializer.assertVectorSlot(slot);
1085
+ },
1086
+ async assertVectorSlotsInitialized(slots) {
1087
+ await contributionMaterializer.assertVectorSlots(slots);
1088
+ },
1089
+ async deleteVectorSlotContribution(slot) {
1090
+ await contributionMaterializer.dropVectorSlot(slot);
1091
+ }
1092
+ },
974
1093
  async getReconciliationMarker(graphId) {
975
1094
  const t = tables2.reconciliationMarkers;
976
1095
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
@@ -988,13 +1107,13 @@ function createSqliteBackend(db, options = {}) {
988
1107
  drizzleOrm.sql`PRAGMA analysis_limit = ${drizzleOrm.sql.raw(String(SQLITE_ANALYZE_ROW_LIMIT))}`
989
1108
  );
990
1109
  for (const tableName of coreAnalyzeTables) {
991
- await db.run(drizzleOrm.sql`ANALYZE ${chunkCTTSDJLY_cjs.quoteIdentifier(tableName)}`);
1110
+ await db.run(drizzleOrm.sql`ANALYZE ${chunkVL2V6PEN_cjs.quoteIdentifier(tableName)}`);
992
1111
  }
993
1112
  for (const tableName of recordedAnalyzeTables) {
994
1113
  try {
995
- await db.run(drizzleOrm.sql`ANALYZE ${chunkCTTSDJLY_cjs.quoteIdentifier(tableName)}`);
1114
+ await db.run(drizzleOrm.sql`ANALYZE ${chunkVL2V6PEN_cjs.quoteIdentifier(tableName)}`);
996
1115
  } catch (error) {
997
- if (!chunkBLZDPRXT_cjs.isMissingTableError(error)) throw error;
1116
+ if (!chunk3GH67G4Z_cjs.isMissingTableError(error)) throw error;
998
1117
  }
999
1118
  }
1000
1119
  },
@@ -1008,7 +1127,14 @@ function createSqliteBackend(db, options = {}) {
1008
1127
  (target) => target.setActiveVersion(params)
1009
1128
  );
1010
1129
  },
1011
- async transaction(fn, _options) {
1130
+ async transaction(fn, options2) {
1131
+ const temporaryWrites = options2?.temporaryWrites === chunkIPSVVTWT_cjs.INTERNAL_TEMPORARY_WRITES;
1132
+ if (temporaryWrites && options2.accessMode !== "read_only") {
1133
+ throw new chunkBVRDGYXQ_cjs.ConfigurationError(
1134
+ "Temporary-write transactions must be semantically read-only.",
1135
+ { dialect: "sqlite" }
1136
+ );
1137
+ }
1012
1138
  if (transactionMode === "none") {
1013
1139
  throwSqliteTransactionsDisabled(
1014
1140
  "This SQLite backend does not support atomic transactions. Operations within a transaction are not rolled back on failure. Use backend.capabilities.transactions to check for transaction support, or use individual operations with manual error handling."
@@ -1024,11 +1150,15 @@ function createSqliteBackend(db, options = {}) {
1024
1150
  profileHints: { isSync },
1025
1151
  tableNames,
1026
1152
  fulltextStrategy,
1027
- vectorStrategy});
1028
- await runFrameStatement(drizzleOrm.sql`BEGIN IMMEDIATE`);
1153
+ vectorStrategy,
1154
+ contributionMaterializer
1155
+ });
1156
+ await runFrameStatement(
1157
+ options2?.accessMode === "read_only" || temporaryWrites ? drizzleOrm.sql`BEGIN` : drizzleOrm.sql`BEGIN IMMEDIATE`
1158
+ );
1029
1159
  try {
1030
1160
  const result = await fn(
1031
- chunkEM3CWPND_cjs.gateFulltext(
1161
+ chunkDIQ3AV5W_cjs.gateFulltext(
1032
1162
  txBackend,
1033
1163
  contributionMaterializer.assertInitialized
1034
1164
  ),
@@ -1050,7 +1180,7 @@ function createSqliteBackend(db, options = {}) {
1050
1180
  return runWithSerializedQueue(
1051
1181
  serializedQueue,
1052
1182
  async () => db.transaction(async (tx) => fn(bindTransactionBackend(tx), tx), {
1053
- behavior: "immediate"
1183
+ behavior: options2?.accessMode === "read_only" || temporaryWrites ? "deferred" : "immediate"
1054
1184
  })
1055
1185
  );
1056
1186
  },
@@ -1060,7 +1190,7 @@ function createSqliteBackend(db, options = {}) {
1060
1190
  "Cross-store atomicity is unavailable on this SQLite backend: transactions are disabled (transactionMode: 'none'). Adopting an external transaction here would let the caller's relational write commit with no way to roll back the graph write. Configure a driver that supports transactions (better-sqlite3, libsql, bun:sqlite)."
1061
1191
  );
1062
1192
  }
1063
- chunkEM3CWPND_cjs.assertAdoptedDialect(
1193
+ chunkDIQ3AV5W_cjs.assertAdoptedDialect(
1064
1194
  externalTx,
1065
1195
  sqliteCore.BaseSQLiteDatabase,
1066
1196
  "sqlite"
@@ -1086,10 +1216,10 @@ function createTransactionBackend(options) {
1086
1216
  tableNames: options.tableNames,
1087
1217
  fulltextStrategy: options.fulltextStrategy,
1088
1218
  vectorStrategy: options.vectorStrategy,
1089
- ...options.vectorStrategy === void 0 ? {} : { vectorSlotLatch: chunkEM3CWPND_cjs.createVectorSlotLatch() }
1219
+ contributionMaterializer: options.contributionMaterializer
1090
1220
  });
1091
1221
  }
1092
1222
 
1093
1223
  exports.createSqliteBackend = createSqliteBackend;
1094
- //# sourceMappingURL=chunk-O7UN7OXA.cjs.map
1095
- //# sourceMappingURL=chunk-O7UN7OXA.cjs.map
1224
+ //# sourceMappingURL=chunk-JBNOGRKW.cjs.map
1225
+ //# sourceMappingURL=chunk-JBNOGRKW.cjs.map