@nicia-ai/typegraph 0.36.0 → 0.37.1

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 (232) 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-HW3LW7DH.cjs → chunk-3DS7Z4T4.cjs} +39 -39
  32. package/dist/{chunk-HW3LW7DH.cjs.map → chunk-3DS7Z4T4.cjs.map} +1 -1
  33. package/dist/{chunk-RSSQKPSZ.cjs → chunk-3GH67G4Z.cjs} +5 -5
  34. package/dist/{chunk-RSSQKPSZ.cjs.map → chunk-3GH67G4Z.cjs.map} +1 -1
  35. package/dist/{chunk-M75SUBFG.js → chunk-3RWZPJKV.js} +24 -9
  36. package/dist/chunk-3RWZPJKV.js.map +1 -0
  37. package/dist/{chunk-SKCOUWAX.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-IU46OHVW.js → chunk-44TA22QT.js} +58 -11
  42. package/dist/chunk-44TA22QT.js.map +1 -0
  43. package/dist/{chunk-7BQLPXK6.cjs → chunk-5AVRFNP4.cjs} +2955 -898
  44. package/dist/chunk-5AVRFNP4.cjs.map +1 -0
  45. package/dist/{chunk-2THZ3TQI.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-WI7ISNQF.js → chunk-5PNMDJ7J.js} +94 -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-DIK74MXX.cjs → chunk-BVRDGYXQ.cjs} +97 -4
  58. package/dist/chunk-BVRDGYXQ.cjs.map +1 -0
  59. package/dist/{chunk-4BCU6VFZ.cjs → chunk-DEFQM7JU.cjs} +7 -7
  60. package/dist/{chunk-4BCU6VFZ.cjs.map → chunk-DEFQM7JU.cjs.map} +1 -1
  61. package/dist/{chunk-456Z2U7Y.cjs → chunk-DIQ3AV5W.cjs} +574 -268
  62. package/dist/chunk-DIQ3AV5W.cjs.map +1 -0
  63. package/dist/{chunk-JFMEONLG.cjs → chunk-EJYMTO3K.cjs} +332 -188
  64. package/dist/chunk-EJYMTO3K.cjs.map +1 -0
  65. package/dist/{chunk-FPIZFYHE.js → chunk-EXU3RASM.js} +74 -15
  66. package/dist/chunk-EXU3RASM.js.map +1 -0
  67. package/dist/{chunk-5DIPR3L3.js → chunk-GA4TT3DH.js} +2338 -281
  68. package/dist/chunk-GA4TT3DH.js.map +1 -0
  69. package/dist/{chunk-H7YNSMA7.cjs → chunk-HAHNRASW.cjs} +20 -2
  70. package/dist/chunk-HAHNRASW.cjs.map +1 -0
  71. package/dist/{chunk-J3LEGNQB.cjs → chunk-IP3CGGPA.cjs} +8 -8
  72. package/dist/{chunk-J3LEGNQB.cjs.map → chunk-IP3CGGPA.cjs.map} +1 -1
  73. package/dist/{chunk-X4JBT642.cjs → chunk-IPSVVTWT.cjs} +94 -35
  74. package/dist/chunk-IPSVVTWT.cjs.map +1 -0
  75. package/dist/{chunk-VQEXF5D4.js → chunk-IXGYRP2P.js} +184 -92
  76. package/dist/chunk-IXGYRP2P.js.map +1 -0
  77. package/dist/{chunk-4GX2JJXS.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-SXGE7ITL.js → chunk-L7HQ2OSI.js} +4 -4
  84. package/dist/{chunk-SXGE7ITL.js.map → chunk-L7HQ2OSI.js.map} +1 -1
  85. package/dist/{chunk-RAXU3RMB.js → chunk-M6VES7V6.js} +4 -4
  86. package/dist/{chunk-RAXU3RMB.js.map → chunk-M6VES7V6.js.map} +1 -1
  87. package/dist/{chunk-PWGX5DF5.cjs → chunk-NUIG3BCV.cjs} +100 -85
  88. package/dist/chunk-NUIG3BCV.cjs.map +1 -0
  89. package/dist/{chunk-ZAMFOJ5P.cjs → chunk-NXQFATMF.cjs} +269 -177
  90. package/dist/chunk-NXQFATMF.cjs.map +1 -0
  91. package/dist/{chunk-KBGQIPRQ.js → chunk-PC2UBAUB.js} +20 -3
  92. package/dist/chunk-PC2UBAUB.js.map +1 -0
  93. package/dist/chunk-QARBLBXT.cjs +219 -0
  94. package/dist/chunk-QARBLBXT.cjs.map +1 -0
  95. package/dist/{chunk-6FR2MMS6.js → chunk-QERAIDRJ.js} +45 -4
  96. package/dist/chunk-QERAIDRJ.js.map +1 -0
  97. package/dist/chunk-QSXTWU4U.cjs +12 -0
  98. package/dist/{chunk-4BMPGT35.cjs.map → chunk-QSXTWU4U.cjs.map} +1 -1
  99. package/dist/{chunk-DN5VP4JC.js → chunk-RCVLFTCT.js} +9 -10
  100. package/dist/chunk-RCVLFTCT.js.map +1 -0
  101. package/dist/{chunk-ZIGXMKQQ.js → chunk-RRSNR3TP.js} +3 -3
  102. package/dist/{chunk-ZIGXMKQQ.js.map → chunk-RRSNR3TP.js.map} +1 -1
  103. package/dist/{chunk-4CAXEB2F.cjs → chunk-TGOMW4MB.cjs} +91 -92
  104. package/dist/chunk-TGOMW4MB.cjs.map +1 -0
  105. package/dist/{chunk-PZKNKG5M.js → chunk-TKT2XHED.js} +8 -8
  106. package/dist/{chunk-PZKNKG5M.js.map → chunk-TKT2XHED.js.map} +1 -1
  107. package/dist/{chunk-S5F7ZLP2.js → chunk-TPF25IG6.js} +3 -3
  108. package/dist/{chunk-S5F7ZLP2.js.map → chunk-TPF25IG6.js.map} +1 -1
  109. package/dist/{chunk-5SEGFTZX.js → chunk-UGZUAYAR.js} +3 -3
  110. package/dist/{chunk-5SEGFTZX.js.map → chunk-UGZUAYAR.js.map} +1 -1
  111. package/dist/{chunk-BJVEU3ZL.js → chunk-UV3WP5WZ.js} +265 -121
  112. package/dist/chunk-UV3WP5WZ.js.map +1 -0
  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-5VTR2F2K.js → chunk-VKGKDOKR.js} +12 -10
  120. package/dist/chunk-VKGKDOKR.js.map +1 -0
  121. package/dist/{chunk-5W4L6DLF.cjs → chunk-VL2V6PEN.cjs} +11 -11
  122. package/dist/{chunk-5W4L6DLF.cjs.map → chunk-VL2V6PEN.cjs.map} +1 -1
  123. package/dist/{chunk-ZUNQ5BEP.cjs → chunk-WOJMKB3N.cjs} +82 -80
  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-JFUPDJXD.js → chunk-XGPUQ56G.js} +3 -3
  128. package/dist/{chunk-JFUPDJXD.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.ts → extension-types-BM2ACfYO.d.cts} +6 -1
  140. package/dist/{extension-types-ixRpJVUp.d.cts → 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.d.cts +6 -6
  149. package/dist/graph-merge/index.d.ts +6 -6
  150. package/dist/graph-merge/index.js +19 -19
  151. package/dist/{index-BLtQWKRj.d.cts → index-BPM59vsg.d.cts} +52 -7
  152. package/dist/{index-BFvdmBPV.d.ts → index-BeacbPoe.d.ts} +52 -7
  153. package/dist/index.cjs +224 -187
  154. package/dist/index.cjs.map +1 -1
  155. package/dist/index.d.cts +11 -11
  156. package/dist/index.d.ts +11 -11
  157. package/dist/index.js +53 -40
  158. package/dist/index.js.map +1 -1
  159. package/dist/indexes/index.cjs +30 -21
  160. package/dist/indexes/index.d.cts +5 -5
  161. package/dist/indexes/index.d.ts +5 -5
  162. package/dist/indexes/index.js +8 -7
  163. package/dist/interchange/index.cjs +207 -30
  164. package/dist/interchange/index.cjs.map +1 -1
  165. package/dist/interchange/index.d.cts +25 -8
  166. package/dist/interchange/index.d.ts +25 -8
  167. package/dist/interchange/index.js +190 -11
  168. package/dist/interchange/index.js.map +1 -1
  169. package/dist/{manager-DwQi8eV0.d.cts → manager-D00_NXvT.d.ts} +11 -2
  170. package/dist/{manager-ejUCB52T.d.ts → manager-nU1vTJLy.d.cts} +11 -2
  171. package/dist/{materialize-indexes-B4e9360H.d.cts → materialize-indexes-CuR3gAZb.d.cts} +8 -2
  172. package/dist/{materialize-indexes-te9TPMMJ.d.ts → materialize-indexes-zK2J_flP.d.ts} +8 -2
  173. package/dist/{postgres-CfEqsRMp.d.cts → postgres-IaBA4RgE.d.ts} +1 -1
  174. package/dist/{postgres-DQ5R6rzV.d.ts → postgres-YrYmPlaU.d.cts} +1 -1
  175. package/dist/profiler/index.cjs +3 -3
  176. package/dist/profiler/index.d.cts +7 -7
  177. package/dist/profiler/index.d.ts +7 -7
  178. package/dist/profiler/index.js +2 -2
  179. package/dist/provenance/index.cjs +32 -33
  180. package/dist/provenance/index.cjs.map +1 -1
  181. package/dist/provenance/index.d.cts +5 -5
  182. package/dist/provenance/index.d.ts +5 -5
  183. package/dist/provenance/index.js +5 -6
  184. package/dist/provenance/index.js.map +1 -1
  185. package/dist/schema/index.cjs +35 -35
  186. package/dist/schema/index.d.cts +7 -7
  187. package/dist/schema/index.d.ts +7 -7
  188. package/dist/schema/index.js +11 -11
  189. package/dist/{sqlite-DvQndLky.d.ts → sqlite-BUOHPx7p.d.ts} +1 -1
  190. package/dist/{sqlite-D7zBinNR.d.cts → sqlite-Pp8O19WE.d.cts} +1 -1
  191. package/dist/{store-view-DplHC3Nt.d.ts → store-view-ANL6mTph.d.ts} +213 -27
  192. package/dist/{store-view-9KDOpZzF.d.cts → store-view-X96Rd00T.d.cts} +213 -27
  193. package/dist/{types-Bv9DcS_E.d.cts → types-r-Zyq2Hz.d.cts} +2 -2
  194. package/dist/{types-CoxuV7EJ.d.ts → types-wsvuBgPK.d.ts} +2 -2
  195. package/dist/where-CJOpJj3a.d.ts +36 -0
  196. package/dist/where-K3uBP33l.d.cts +36 -0
  197. package/package.json +1 -1
  198. package/dist/chunk-2THZ3TQI.cjs.map +0 -1
  199. package/dist/chunk-456Z2U7Y.cjs.map +0 -1
  200. package/dist/chunk-4BMPGT35.cjs +0 -12
  201. package/dist/chunk-4CAXEB2F.cjs.map +0 -1
  202. package/dist/chunk-4GX2JJXS.js.map +0 -1
  203. package/dist/chunk-5DIPR3L3.js.map +0 -1
  204. package/dist/chunk-5VTR2F2K.js.map +0 -1
  205. package/dist/chunk-6FR2MMS6.js.map +0 -1
  206. package/dist/chunk-7BQLPXK6.cjs.map +0 -1
  207. package/dist/chunk-BJVEU3ZL.js.map +0 -1
  208. package/dist/chunk-D7ZEOS56.cjs.map +0 -1
  209. package/dist/chunk-DIK74MXX.cjs.map +0 -1
  210. package/dist/chunk-DN5VP4JC.js.map +0 -1
  211. package/dist/chunk-EOLERH7Y.cjs +0 -40
  212. package/dist/chunk-EOLERH7Y.cjs.map +0 -1
  213. package/dist/chunk-FN35DLCN.cjs.map +0 -1
  214. package/dist/chunk-FPIZFYHE.js.map +0 -1
  215. package/dist/chunk-H7YNSMA7.cjs.map +0 -1
  216. package/dist/chunk-IU46OHVW.js.map +0 -1
  217. package/dist/chunk-JFMEONLG.cjs.map +0 -1
  218. package/dist/chunk-KBGQIPRQ.js.map +0 -1
  219. package/dist/chunk-M75SUBFG.js.map +0 -1
  220. package/dist/chunk-PWGX5DF5.cjs.map +0 -1
  221. package/dist/chunk-S55OV6PW.cjs.map +0 -1
  222. package/dist/chunk-SKCOUWAX.js.map +0 -1
  223. package/dist/chunk-UT3S4SEN.js +0 -31
  224. package/dist/chunk-UT3S4SEN.js.map +0 -1
  225. package/dist/chunk-VHMPG6UL.js.map +0 -1
  226. package/dist/chunk-VQEXF5D4.js.map +0 -1
  227. package/dist/chunk-WI7ISNQF.js.map +0 -1
  228. package/dist/chunk-X4JBT642.cjs.map +0 -1
  229. package/dist/chunk-ZAMFOJ5P.cjs.map +0 -1
  230. package/dist/chunk-ZUNQ5BEP.cjs.map +0 -1
  231. package/dist/where-7RKFOsXt.d.ts +0 -11
  232. package/dist/where-DdMIXOtH.d.cts +0 -11
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunk456Z2U7Y_cjs = require('./chunk-456Z2U7Y.cjs');
4
- var chunkFN35DLCN_cjs = require('./chunk-FN35DLCN.cjs');
5
- var chunk5W4L6DLF_cjs = require('./chunk-5W4L6DLF.cjs');
6
- var chunkD7ZEOS56_cjs = require('./chunk-D7ZEOS56.cjs');
7
- var chunkX4JBT642_cjs = require('./chunk-X4JBT642.cjs');
8
- var chunkRSSQKPSZ_cjs = require('./chunk-RSSQKPSZ.cjs');
9
- var chunkDIK74MXX_cjs = require('./chunk-DIK74MXX.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 chunkX4JBT642_cjs.D1_MAX_BIND_PARAMETERS;
91
- if (sqliteClient === void 0) return chunkX4JBT642_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 ? chunkX4JBT642_cjs.MODERN_SQLITE_MAX_BIND_PARAMETERS : chunkX4JBT642_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 chunkX4JBT642_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 chunk456Z2U7Y_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) => chunk456Z2U7Y_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 / chunk456Z2U7Y_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 = chunk5W4L6DLF_cjs.createNodeRowMapper(chunk5W4L6DLF_cjs.SQLITE_ROW_MAPPER_CONFIG);
262
- var toEdgeRow = chunk5W4L6DLF_cjs.createEdgeRowMapper(chunk5W4L6DLF_cjs.SQLITE_ROW_MAPPER_CONFIG);
263
- var toUniqueRow = chunk5W4L6DLF_cjs.createUniqueRowMapper(chunk5W4L6DLF_cjs.SQLITE_ROW_MAPPER_CONFIG);
264
- var toSchemaVersionRow = chunk5W4L6DLF_cjs.createSchemaVersionRowMapper(
265
- chunk5W4L6DLF_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 chunkDIK74MXX_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 chunkDIK74MXX_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,44 @@ function runWithSerializedQueue(queue, task) {
330
377
  return queue.runExclusive(task);
331
378
  }
332
379
  function throwSqliteTransactionsDisabled(message) {
333
- throw new chunkDIK74MXX_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" ? { ...chunkX4JBT642_cjs.SQLITE_CAPABILITIES, transactions: false } : chunkX4JBT642_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
+ }
408
+ function resolveSqliteGraphAnalyticsCapabilities(profile, override) {
409
+ const requested = override ?? chunkIPSVVTWT_cjs.SQLITE_CAPABILITIES.graphAnalytics ?? {
410
+ supported: false,
411
+ mathFunctions: false
412
+ };
413
+ if (profile.transactionMode !== "do-sqlite" && profile.transactionMode !== "none") {
414
+ return requested;
415
+ }
416
+ return { ...requested, supported: false };
417
+ }
348
418
  function createSqliteOperationBackend(options) {
349
419
  const {
350
420
  capabilities,
@@ -355,7 +425,7 @@ function createSqliteOperationBackend(options) {
355
425
  tableNames,
356
426
  fulltextStrategy,
357
427
  vectorStrategy,
358
- vectorSlotLatch
428
+ contributionMaterializer
359
429
  } = options;
360
430
  const compiledExecute = executionAdapter.executeCompiled;
361
431
  const compiledRun = executionAdapter.executeCompiledRun;
@@ -387,16 +457,16 @@ function createSqliteOperationBackend(options) {
387
457
  });
388
458
  }
389
459
  const batchConfig = computeSqliteBatchChunkSizes(
390
- capabilities.maxBindParameters ?? chunkX4JBT642_cjs.SQLITE_MAX_BIND_PARAMETERS
460
+ capabilities.maxBindParameters ?? chunkIPSVVTWT_cjs.SQLITE_MAX_BIND_PARAMETERS
391
461
  );
392
- const commonBackend = chunk456Z2U7Y_cjs.createCommonOperationBackend({
462
+ const commonBackend = chunkDIQ3AV5W_cjs.createCommonOperationBackend({
393
463
  batchConfig,
394
464
  execution: {
395
465
  execAll,
396
466
  execGet,
397
467
  execRun
398
468
  },
399
- nowIso: chunk5W4L6DLF_cjs.nowIso,
469
+ nowIso: chunkVL2V6PEN_cjs.nowIso,
400
470
  operationStrategy,
401
471
  rowMappers: {
402
472
  toEdgeRow,
@@ -414,36 +484,30 @@ function createSqliteOperationBackend(options) {
414
484
  );
415
485
  }
416
486
  };
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
487
  const vectorEmbeddingMethods = vectorStrategy === void 0 ? {} : {
424
488
  async upsertEmbedding(params) {
425
- const slot = chunk456Z2U7Y_cjs.vectorSlotFromParams(params);
426
- await ensureVectorSlotStorage(slot);
427
- const statements = vectorStrategy.buildUpsert(slot, params, chunk5W4L6DLF_cjs.nowIso());
489
+ const slot = chunkDIQ3AV5W_cjs.vectorSlotFromParams(params);
490
+ await contributionMaterializer.assertVectorSlot(slot);
491
+ const statements = vectorStrategy.buildUpsert(slot, params, chunkVL2V6PEN_cjs.nowIso());
428
492
  try {
429
493
  for (const statement of statements) {
430
494
  await execRun(statement);
431
495
  }
432
496
  } catch (error) {
433
- throw chunk456Z2U7Y_cjs.mapVectorWriteError(error, params);
497
+ throw chunkDIQ3AV5W_cjs.mapVectorWriteError(error, params);
434
498
  }
435
499
  },
436
500
  async upsertEmbeddingBatch(params) {
437
501
  if (params.rows.length === 0) return;
438
- const slot = chunk456Z2U7Y_cjs.vectorSlotFromParams(params);
439
- await ensureVectorSlotStorage(slot);
502
+ const slot = chunkDIQ3AV5W_cjs.vectorSlotFromParams(params);
503
+ await contributionMaterializer.assertVectorSlot(slot);
440
504
  const rowsById = new Map(
441
505
  params.rows.map((row) => [row.nodeId, row])
442
506
  );
443
507
  const rows = [...rowsById.values()];
444
- const timestamp = chunk5W4L6DLF_cjs.nowIso();
508
+ const timestamp = chunkVL2V6PEN_cjs.nowIso();
445
509
  try {
446
- for (const chunk2 of chunkX4JBT642_cjs.chunk(
510
+ for (const chunk2 of chunkIPSVVTWT_cjs.chunk(
447
511
  rows,
448
512
  batchConfig.embeddingUpsertBatchSize
449
513
  )) {
@@ -472,21 +536,20 @@ function createSqliteOperationBackend(options) {
472
536
  }
473
537
  }
474
538
  } catch (error) {
475
- throw chunk456Z2U7Y_cjs.mapVectorWriteError(error, params);
539
+ throw chunkDIQ3AV5W_cjs.mapVectorWriteError(error, params);
476
540
  }
477
541
  },
478
542
  async deleteEmbedding(params) {
479
- const slot = chunk456Z2U7Y_cjs.vectorSlotFromParams(params);
480
- await ensureVectorSlotStorage(slot);
543
+ const slot = chunkDIQ3AV5W_cjs.vectorSlotFromParams(params);
544
+ await contributionMaterializer.assertVectorSlot(slot);
481
545
  const statements = vectorStrategy.buildDelete(slot, params);
482
546
  for (const statement of statements) {
483
547
  await execRun(statement);
484
548
  }
485
549
  },
486
550
  async vectorSearch(params) {
487
- chunkD7ZEOS56_cjs.assertVectorSearchLimit(params.limit);
488
- const slot = chunk456Z2U7Y_cjs.vectorSlotFromParams(params);
489
- await ensureVectorSlotStorage(slot);
551
+ chunkXGU7DZDA_cjs.assertVectorSearchLimit(params.limit);
552
+ const slot = chunkDIQ3AV5W_cjs.vectorSlotFromParams(params);
490
553
  const query = vectorStrategy.buildSearch(
491
554
  slot,
492
555
  params,
@@ -501,7 +564,7 @@ function createSqliteOperationBackend(options) {
501
564
  try {
502
565
  rows = await execAll(query);
503
566
  } catch (error) {
504
- throw chunk456Z2U7Y_cjs.mapVectorWriteError(error, params);
567
+ throw chunkDIQ3AV5W_cjs.mapVectorWriteError(error, params);
505
568
  }
506
569
  return rows.map((row) => ({
507
570
  nodeId: row.node_id,
@@ -513,9 +576,9 @@ function createSqliteOperationBackend(options) {
513
576
  // fallback by simply not exposing the member.
514
577
  ...capabilities.windowFunctions ? {
515
578
  async hybridSearch(params) {
516
- chunkD7ZEOS56_cjs.assertVectorSearchLimit(params.limit);
517
- chunkD7ZEOS56_cjs.assertVectorSearchLimit(params.vector.k);
518
- const slot = chunk456Z2U7Y_cjs.vectorSlotFromParams({
579
+ chunkXGU7DZDA_cjs.assertVectorSearchLimit(params.limit);
580
+ chunkXGU7DZDA_cjs.assertVectorSearchLimit(params.vector.k);
581
+ const slot = chunkDIQ3AV5W_cjs.vectorSlotFromParams({
519
582
  graphId: params.graphId,
520
583
  nodeKind: params.nodeKind,
521
584
  fieldPath: params.vector.fieldPath,
@@ -523,7 +586,6 @@ function createSqliteOperationBackend(options) {
523
586
  metric: params.vector.metric,
524
587
  indexType: params.vector.indexType
525
588
  });
526
- await ensureVectorSlotStorage(slot);
527
589
  const candidates = params.candidates ?? operationStrategy.buildLiveNodeIds(
528
590
  params.graphId,
529
591
  params.nodeKind
@@ -542,7 +604,7 @@ function createSqliteOperationBackend(options) {
542
604
  const vectorSql = vectorStrategy.buildSearch(
543
605
  slot,
544
606
  vectorParams,
545
- chunk456Z2U7Y_cjs.hybridCandidatesRef()
607
+ chunkDIQ3AV5W_cjs.hybridCandidatesRef()
546
608
  );
547
609
  const statement = operationStrategy.buildHybridSearch(
548
610
  { ...params, candidates },
@@ -553,9 +615,9 @@ function createSqliteOperationBackend(options) {
553
615
  try {
554
616
  raw = await execAll(statement);
555
617
  } catch (error) {
556
- throw chunk456Z2U7Y_cjs.mapVectorWriteError(error, vectorParams);
618
+ throw chunkDIQ3AV5W_cjs.mapVectorWriteError(error, vectorParams);
557
619
  }
558
- return raw.map((row) => chunk456Z2U7Y_cjs.mapHybridSearchRow(row, toNodeRow));
620
+ return raw.map((row) => chunkDIQ3AV5W_cjs.mapHybridSearchRow(row, toNodeRow));
559
621
  }
560
622
  } : {}
561
623
  };
@@ -570,8 +632,8 @@ function createSqliteOperationBackend(options) {
570
632
  ...vectorStrategy === void 0 ? {} : { vectorStrategy },
571
633
  async createVectorIndex(params) {
572
634
  if (vectorStrategy === void 0) return;
573
- const slot = chunk456Z2U7Y_cjs.vectorSlotFromCreateIndexParams(params);
574
- await ensureVectorSlotStorage(slot);
635
+ const slot = chunkDIQ3AV5W_cjs.vectorSlotFromCreateIndexParams(params);
636
+ await contributionMaterializer.ensureVectorSlot(slot);
575
637
  const indexStatement = vectorStrategy.buildCreateIndex?.(slot);
576
638
  if (indexStatement !== void 0) {
577
639
  await execRun(indexStatement);
@@ -579,18 +641,18 @@ function createSqliteOperationBackend(options) {
579
641
  },
580
642
  async dropVectorIndex(params) {
581
643
  if (vectorStrategy === void 0) return;
582
- const slot = chunk456Z2U7Y_cjs.vectorSlotFromDropIndexParams(params);
644
+ const slot = chunkDIQ3AV5W_cjs.vectorSlotFromDropIndexParams(params);
583
645
  const dropStatement = vectorStrategy.buildDropIndex?.(slot);
584
646
  if (dropStatement === void 0) return;
585
647
  try {
586
648
  await execRun(dropStatement);
587
649
  } catch (error) {
588
- if (!chunkRSSQKPSZ_cjs.isMissingTableError(error)) throw error;
650
+ if (!chunk3GH67G4Z_cjs.isMissingTableError(error)) throw error;
589
651
  }
590
652
  },
591
653
  // === Fulltext Operations ===
592
654
  async upsertFulltext(params) {
593
- const timestamp = chunk5W4L6DLF_cjs.nowIso();
655
+ const timestamp = chunkVL2V6PEN_cjs.nowIso();
594
656
  const statements = operationStrategy.buildUpsertFulltext(
595
657
  params,
596
658
  timestamp
@@ -607,8 +669,8 @@ function createSqliteOperationBackend(options) {
607
669
  },
608
670
  async upsertFulltextBatch(params) {
609
671
  if (params.rows.length === 0) return;
610
- const timestamp = chunk5W4L6DLF_cjs.nowIso();
611
- for (const rows of chunkX4JBT642_cjs.chunk(
672
+ const timestamp = chunkVL2V6PEN_cjs.nowIso();
673
+ for (const rows of chunkIPSVVTWT_cjs.chunk(
612
674
  params.rows,
613
675
  batchConfig.fulltextUpsertBatchSize
614
676
  )) {
@@ -623,7 +685,7 @@ function createSqliteOperationBackend(options) {
623
685
  },
624
686
  async deleteFulltextBatch(params) {
625
687
  if (params.nodeIds.length === 0) return;
626
- for (const nodeIds of chunkX4JBT642_cjs.chunk(
688
+ for (const nodeIds of chunkIPSVVTWT_cjs.chunk(
627
689
  params.nodeIds,
628
690
  batchConfig.fulltextDeleteChunkSize
629
691
  )) {
@@ -641,7 +703,7 @@ function createSqliteOperationBackend(options) {
641
703
  const rows = await execAll(query);
642
704
  return rows.map((row, index) => ({
643
705
  nodeId: row.node_id,
644
- score: chunk5W4L6DLF_cjs.coerceNumericScore(row.score),
706
+ score: chunkVL2V6PEN_cjs.coerceNumericScore(row.score),
645
707
  rank: index + 1,
646
708
  ...row.snippet === null ? {} : { snippet: row.snippet }
647
709
  }));
@@ -660,22 +722,30 @@ function createSqliteOperationBackend(options) {
660
722
  return operationBackend;
661
723
  }
662
724
  function createSqliteBackend(db, options = {}) {
663
- const tables2 = options.tables ?? chunkFN35DLCN_cjs.tables;
664
- const fulltextStrategy = options.fulltext ?? chunkD7ZEOS56_cjs.fts5Strategy;
725
+ const tables2 = options.tables ?? chunk3C2RYI6L_cjs.tables;
726
+ const fulltextStrategy = options.fulltext ?? chunkXGU7DZDA_cjs.fts5Strategy;
665
727
  const profileHints = options.executionProfile ?? {};
666
728
  const executionAdapter = createSqliteExecutionAdapter(db, { profileHints });
667
729
  const { isSync, transactionMode } = executionAdapter.profile;
668
730
  const vectorStrategy = options.vector;
669
- const vectorSlotLatch = vectorStrategy === void 0 ? void 0 : chunk456Z2U7Y_cjs.createVectorSlotLatch();
670
- const capabilities = {
731
+ const capabilityOverrides = options.capabilities ?? {};
732
+ const capabilities = chunkIPSVVTWT_cjs.normalizeGraphAnalyticsCapabilities({
671
733
  ...buildSqliteCapabilities({
672
734
  fulltextStrategy,
673
735
  vectorStrategy,
674
736
  transactionMode,
675
737
  maxBindParameters: executionAdapter.profile.maxBindParameters
676
738
  }),
677
- ...options.capabilities
678
- };
739
+ ...capabilityOverrides,
740
+ maxBindParameters: resolveMaxBindParametersCapability(
741
+ executionAdapter.profile,
742
+ capabilityOverrides.maxBindParameters
743
+ ),
744
+ graphAnalytics: resolveSqliteGraphAnalyticsCapabilities(
745
+ executionAdapter.profile,
746
+ capabilityOverrides.graphAnalytics
747
+ )
748
+ });
679
749
  const tableNames = {
680
750
  nodes: drizzleOrm.getTableName(tables2.nodes),
681
751
  edges: drizzleOrm.getTableName(tables2.edges),
@@ -697,11 +767,82 @@ function createSqliteBackend(db, options = {}) {
697
767
  tableNames.recordedEdges,
698
768
  tableNames.recordedClock
699
769
  ];
700
- const operationStrategy = chunk456Z2U7Y_cjs.createSqliteOperationStrategy(
770
+ const operationStrategy = chunkDIQ3AV5W_cjs.createSqliteOperationStrategy(
701
771
  tables2,
702
772
  fulltextStrategy
703
773
  );
704
774
  const serializedQueue = transactionMode === "none" ? void 0 : createSerializedExecutionQueue();
775
+ const matTable = tables2.contributionMaterializations;
776
+ async function ensureContributionMaterializationsTableImpl() {
777
+ await db.run(drizzleOrm.sql.raw(chunkDIQ3AV5W_cjs.generateSqliteCreateTableSQL(matTable)));
778
+ }
779
+ async function getContributionMaterializationRow(identity) {
780
+ const rows = await db.select().from(matTable).where(
781
+ drizzleOrm.and(
782
+ drizzleOrm.eq(matTable.graphId, identity.graphId),
783
+ drizzleOrm.eq(matTable.logicalName, identity.logicalName),
784
+ drizzleOrm.eq(matTable.owner, identity.owner),
785
+ drizzleOrm.eq(matTable.tableName, identity.tableName)
786
+ )
787
+ );
788
+ const row = rows[0];
789
+ if (row === void 0) return void 0;
790
+ return chunkDIQ3AV5W_cjs.mapContributionMaterializationRow(
791
+ row,
792
+ chunkDIQ3AV5W_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.decode
793
+ );
794
+ }
795
+ async function getContributionMaterializationRows(graphId) {
796
+ const rows = await db.select().from(matTable).where(drizzleOrm.eq(matTable.graphId, graphId));
797
+ return rows.map(
798
+ (row) => chunkDIQ3AV5W_cjs.mapContributionMaterializationRow(
799
+ row,
800
+ chunkDIQ3AV5W_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.decode
801
+ )
802
+ );
803
+ }
804
+ async function recordContributionMaterializationRow(params) {
805
+ await db.insert(matTable).values(
806
+ chunkDIQ3AV5W_cjs.buildContributionInsertValues(
807
+ params,
808
+ chunkDIQ3AV5W_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.encode
809
+ )
810
+ ).onConflictDoUpdate({
811
+ target: [
812
+ matTable.graphId,
813
+ matTable.logicalName,
814
+ matTable.owner,
815
+ matTable.tableName
816
+ ],
817
+ set: chunkDIQ3AV5W_cjs.buildContributionOnConflictSet(
818
+ matTable.materializedAt,
819
+ params.materializedAt
820
+ )
821
+ });
822
+ }
823
+ async function deleteContributionMaterializationRow(identity) {
824
+ await db.delete(matTable).where(
825
+ drizzleOrm.and(
826
+ drizzleOrm.eq(matTable.graphId, identity.graphId),
827
+ drizzleOrm.eq(matTable.logicalName, identity.logicalName),
828
+ drizzleOrm.eq(matTable.owner, identity.owner),
829
+ drizzleOrm.eq(matTable.tableName, identity.tableName)
830
+ )
831
+ );
832
+ }
833
+ const contributionMaterializer = chunkDIQ3AV5W_cjs.createContributionMaterializer({
834
+ dialect: "sqlite",
835
+ fulltextStrategy,
836
+ fulltextTableName: tables2.fulltextTableName,
837
+ vectorStrategy,
838
+ execDdl: async (statement) => {
839
+ await db.run(drizzleOrm.sql.raw(statement));
840
+ },
841
+ ensureMarkerTable: ensureContributionMaterializationsTableImpl,
842
+ getMarkers: getContributionMaterializationRows,
843
+ recordMarker: recordContributionMaterializationRow,
844
+ deleteMarker: deleteContributionMaterializationRow
845
+ });
705
846
  const operations = createSqliteOperationBackend({
706
847
  capabilities,
707
848
  db,
@@ -710,20 +851,19 @@ function createSqliteBackend(db, options = {}) {
710
851
  tableNames,
711
852
  fulltextStrategy,
712
853
  vectorStrategy,
713
- vectorSlotLatch,
854
+ contributionMaterializer,
714
855
  ...serializedQueue === void 0 ? {} : { serializedQueue }
715
856
  });
716
857
  function runDoSqliteStorageTransaction(run) {
717
- const storage = db.$client;
718
- const storageTransaction = storage?.transaction;
719
- if (typeof storageTransaction !== "function") {
858
+ const storage = getDurableObjectStorageClient(db);
859
+ if (storage === void 0) {
720
860
  throwSqliteTransactionsDisabled(
721
- "transactionMode 'do-sqlite' requires a Drizzle Durable Objects database (drizzle(ctx.storage)) whose `$client` exposes the async storage `transaction(async () => ...)` runner."
861
+ "transactionMode 'do-sqlite' requires a Drizzle Durable Objects database (drizzle(ctx.storage)) whose `$client` exposes the SQL, transactionSync, and async transaction runners."
722
862
  );
723
863
  }
724
864
  return runWithSerializedQueue(
725
865
  serializedQueue,
726
- async () => storageTransaction.call(storage, run)
866
+ () => storage.transaction(run)
727
867
  );
728
868
  }
729
869
  async function runFrameStatement(query) {
@@ -750,7 +890,9 @@ function createSqliteBackend(db, options = {}) {
750
890
  profileHints: { isSync },
751
891
  tableNames,
752
892
  fulltextStrategy,
753
- vectorStrategy});
893
+ vectorStrategy,
894
+ contributionMaterializer
895
+ });
754
896
  await runFrameStatement(drizzleOrm.sql`BEGIN IMMEDIATE`);
755
897
  try {
756
898
  const result = await fn(txBackend);
@@ -771,7 +913,9 @@ function createSqliteBackend(db, options = {}) {
771
913
  profileHints: { isSync },
772
914
  tableNames,
773
915
  fulltextStrategy,
774
- vectorStrategy});
916
+ vectorStrategy,
917
+ contributionMaterializer
918
+ });
775
919
  return fn(txBackend);
776
920
  });
777
921
  }
@@ -786,63 +930,15 @@ function createSqliteBackend(db, options = {}) {
786
930
  profileHints: { isSync },
787
931
  tableNames,
788
932
  fulltextStrategy,
789
- vectorStrategy});
933
+ vectorStrategy,
934
+ contributionMaterializer
935
+ });
790
936
  return fn(txBackend);
791
937
  },
792
938
  { behavior: "immediate" }
793
939
  )
794
940
  );
795
941
  }
796
- const matTable = tables2.contributionMaterializations;
797
- async function ensureContributionMaterializationsTableImpl() {
798
- await db.run(drizzleOrm.sql.raw(chunk456Z2U7Y_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 chunk456Z2U7Y_cjs.mapContributionMaterializationRow(
812
- row,
813
- chunk456Z2U7Y_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.decode
814
- );
815
- }
816
- async function recordContributionMaterializationRow(params) {
817
- await db.insert(matTable).values(
818
- chunk456Z2U7Y_cjs.buildContributionInsertValues(
819
- params,
820
- chunk456Z2U7Y_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: chunk456Z2U7Y_cjs.buildContributionOnConflictSet(
830
- matTable.materializedAt,
831
- params.materializedAt
832
- )
833
- });
834
- }
835
- const contributionMaterializer = chunk456Z2U7Y_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
942
  function bindTransactionBackend(tx) {
847
943
  const txBackend = createTransactionBackend({
848
944
  capabilities,
@@ -851,20 +947,39 @@ function createSqliteBackend(db, options = {}) {
851
947
  profileHints: { isSync },
852
948
  tableNames,
853
949
  fulltextStrategy,
854
- vectorStrategy});
855
- return chunk456Z2U7Y_cjs.gateFulltext(txBackend, contributionMaterializer.assertInitialized);
950
+ vectorStrategy,
951
+ contributionMaterializer
952
+ });
953
+ return chunkDIQ3AV5W_cjs.gateFulltext(txBackend, contributionMaterializer.assertInitialized);
856
954
  }
857
955
  const backend = {
858
956
  ...operations,
957
+ ...isSync && transactionMode === "sql" && executionAdapter.executePreparedRunBatch !== void 0 ? {
958
+ async trustedImport(fn) {
959
+ return backend.transaction(async (tx) => {
960
+ await chunkDIQ3AV5W_cjs.assertTrustedImportDatabaseEmpty(tx, tableNames);
961
+ const indexDefinitions = await chunkDIQ3AV5W_cjs.suspendSqliteSecondaryIndexes(
962
+ tx,
963
+ tableNames
964
+ );
965
+ const result = await fn(
966
+ chunkDIQ3AV5W_cjs.createSqliteTrustedImportSession(executionAdapter, tableNames)
967
+ );
968
+ await chunkDIQ3AV5W_cjs.restoreSecondaryIndexes(tx, indexDefinitions);
969
+ await chunkDIQ3AV5W_cjs.analyzeImportedTables(tx, tableNames);
970
+ return result;
971
+ });
972
+ }
973
+ } : {},
859
974
  async bootstrapTables() {
860
- const statements = chunk456Z2U7Y_cjs.generateSqliteDDL(tables2, fulltextStrategy);
975
+ const statements = chunkDIQ3AV5W_cjs.generateSqliteDDL(tables2, fulltextStrategy);
861
976
  for (const statement of statements) {
862
977
  await db.run(drizzleOrm.sql.raw(statement));
863
978
  }
864
979
  },
865
980
  async ensureRevisionOriginsTable() {
866
981
  await db.run(
867
- drizzleOrm.sql.raw(chunk456Z2U7Y_cjs.generateSqliteCreateTableSQL(tables2.revisionOrigins))
982
+ drizzleOrm.sql.raw(chunkDIQ3AV5W_cjs.generateSqliteCreateTableSQL(tables2.revisionOrigins))
868
983
  );
869
984
  },
870
985
  // Every fulltext-touching method asserts the durable marker instead
@@ -872,7 +987,7 @@ function createSqliteBackend(db, options = {}) {
872
987
  // uninitialized database throws `StoreNotInitializedError` rather
873
988
  // than self-healing (#135). Shared verbatim with the tx-scoped gate
874
989
  // via `gateFulltextMethods`.
875
- ...chunk456Z2U7Y_cjs.gateFulltextMethods(
990
+ ...chunkDIQ3AV5W_cjs.gateFulltextMethods(
876
991
  operations,
877
992
  contributionMaterializer.assertInitialized
878
993
  ),
@@ -881,7 +996,7 @@ function createSqliteBackend(db, options = {}) {
881
996
  },
882
997
  async ensureIndexMaterializationsTable() {
883
998
  await db.run(
884
- drizzleOrm.sql.raw(chunk456Z2U7Y_cjs.generateSqliteCreateTableSQL(tables2.indexMaterializations))
999
+ drizzleOrm.sql.raw(chunkDIQ3AV5W_cjs.generateSqliteCreateTableSQL(tables2.indexMaterializations))
885
1000
  );
886
1001
  },
887
1002
  async getIndexMaterialization(indexName) {
@@ -889,29 +1004,26 @@ function createSqliteBackend(db, options = {}) {
889
1004
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.indexName, indexName));
890
1005
  const row = rows[0];
891
1006
  if (row === void 0) return void 0;
892
- return chunk456Z2U7Y_cjs.mapMaterializationRow(row, chunk456Z2U7Y_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode);
1007
+ return chunkDIQ3AV5W_cjs.mapMaterializationRow(row, chunkDIQ3AV5W_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode);
893
1008
  },
894
1009
  async getIndexMaterializations(statusKeys) {
895
1010
  if (statusKeys.length === 0) return [];
896
1011
  const t = tables2.indexMaterializations;
897
1012
  const rows = await db.select().from(t).where(drizzleOrm.inArray(t.indexName, [...statusKeys]));
898
1013
  return rows.map(
899
- (row) => chunk456Z2U7Y_cjs.mapMaterializationRow(row, chunk456Z2U7Y_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode)
1014
+ (row) => chunkDIQ3AV5W_cjs.mapMaterializationRow(row, chunkDIQ3AV5W_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode)
900
1015
  );
901
1016
  },
902
1017
  async recordIndexMaterialization(params) {
903
1018
  const t = tables2.indexMaterializations;
904
1019
  await db.insert(t).values(
905
- chunk456Z2U7Y_cjs.buildMaterializationInsertValues(
1020
+ chunkDIQ3AV5W_cjs.buildMaterializationInsertValues(
906
1021
  params,
907
- chunk456Z2U7Y_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.encode
1022
+ chunkDIQ3AV5W_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.encode
908
1023
  )
909
1024
  ).onConflictDoUpdate({
910
1025
  target: t.indexName,
911
- set: chunk456Z2U7Y_cjs.buildMaterializationOnConflictSet(
912
- t.materializedAt,
913
- params.materializedAt
914
- )
1026
+ set: chunkDIQ3AV5W_cjs.buildMaterializationOnConflictSet(params.materializedAt)
915
1027
  });
916
1028
  },
917
1029
  async ensureContributionMaterializationsTable() {
@@ -927,37 +1039,37 @@ function createSqliteBackend(db, options = {}) {
927
1039
  await contributionMaterializer.assertInitialized(graphId);
928
1040
  },
929
1041
  async ensureKindRemovalsTable() {
930
- await db.run(drizzleOrm.sql.raw(chunk456Z2U7Y_cjs.generateSqliteCreateTableSQL(tables2.kindRemovals)));
1042
+ await db.run(drizzleOrm.sql.raw(chunkDIQ3AV5W_cjs.generateSqliteCreateTableSQL(tables2.kindRemovals)));
931
1043
  },
932
1044
  async getPendingKindRemovals(graphId) {
933
1045
  const t = tables2.kindRemovals;
934
1046
  const rows = await db.select().from(t).where(drizzleOrm.and(drizzleOrm.eq(t.graphId, graphId), drizzleOrm.isNull(t.removedAt)));
935
1047
  return rows.map(
936
- (row) => chunk456Z2U7Y_cjs.mapKindRemovalRow(row, chunk456Z2U7Y_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
1048
+ (row) => chunkDIQ3AV5W_cjs.mapKindRemovalRow(row, chunkDIQ3AV5W_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
937
1049
  );
938
1050
  },
939
1051
  async getAllKindRemovals(graphId) {
940
1052
  const t = tables2.kindRemovals;
941
1053
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
942
1054
  return rows.map(
943
- (row) => chunk456Z2U7Y_cjs.mapKindRemovalRow(row, chunk456Z2U7Y_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
1055
+ (row) => chunkDIQ3AV5W_cjs.mapKindRemovalRow(row, chunkDIQ3AV5W_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
944
1056
  );
945
1057
  },
946
1058
  async recordKindRemoval(params) {
947
1059
  const t = tables2.kindRemovals;
948
1060
  await db.insert(t).values(
949
- chunk456Z2U7Y_cjs.buildKindRemovalInsertValues(
1061
+ chunkDIQ3AV5W_cjs.buildKindRemovalInsertValues(
950
1062
  params,
951
- chunk456Z2U7Y_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.encode
1063
+ chunkDIQ3AV5W_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.encode
952
1064
  )
953
1065
  ).onConflictDoUpdate({
954
1066
  target: [t.graphId, t.kindName, t.entity, t.schemaVersion],
955
- set: chunk456Z2U7Y_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
1067
+ set: chunkDIQ3AV5W_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
956
1068
  });
957
1069
  },
958
1070
  async ensureReconciliationMarkersTable() {
959
1071
  await db.run(
960
- drizzleOrm.sql.raw(chunk456Z2U7Y_cjs.generateSqliteCreateTableSQL(tables2.reconciliationMarkers))
1072
+ drizzleOrm.sql.raw(chunkDIQ3AV5W_cjs.generateSqliteCreateTableSQL(tables2.reconciliationMarkers))
961
1073
  );
962
1074
  },
963
1075
  async ensureRuntimeContributions(graphId) {
@@ -971,6 +1083,27 @@ function createSqliteBackend(db, options = {}) {
971
1083
  async ensureFulltextTable(graphId) {
972
1084
  await contributionMaterializer.ensureRuntimeContributions(graphId);
973
1085
  },
1086
+ // Vector counterparts of the runtime-contribution methods. Present
1087
+ // only when a vector strategy is wired (omitted on a plain SQLite
1088
+ // connection with no vector extension), mirroring the embedding/
1089
+ // search methods.
1090
+ ...vectorStrategy === void 0 ? {} : {
1091
+ async ensureVectorSlotContribution(slot, options_) {
1092
+ await contributionMaterializer.ensureVectorSlot(slot, options_);
1093
+ },
1094
+ async ensureVectorSlotContributions(slots, options_) {
1095
+ await contributionMaterializer.ensureVectorSlots(slots, options_);
1096
+ },
1097
+ async assertVectorSlotInitialized(slot) {
1098
+ await contributionMaterializer.assertVectorSlot(slot);
1099
+ },
1100
+ async assertVectorSlotsInitialized(slots) {
1101
+ await contributionMaterializer.assertVectorSlots(slots);
1102
+ },
1103
+ async deleteVectorSlotContribution(slot) {
1104
+ await contributionMaterializer.dropVectorSlot(slot);
1105
+ }
1106
+ },
974
1107
  async getReconciliationMarker(graphId) {
975
1108
  const t = tables2.reconciliationMarkers;
976
1109
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
@@ -988,13 +1121,13 @@ function createSqliteBackend(db, options = {}) {
988
1121
  drizzleOrm.sql`PRAGMA analysis_limit = ${drizzleOrm.sql.raw(String(SQLITE_ANALYZE_ROW_LIMIT))}`
989
1122
  );
990
1123
  for (const tableName of coreAnalyzeTables) {
991
- await db.run(drizzleOrm.sql`ANALYZE ${chunk5W4L6DLF_cjs.quoteIdentifier(tableName)}`);
1124
+ await db.run(drizzleOrm.sql`ANALYZE ${chunkVL2V6PEN_cjs.quoteIdentifier(tableName)}`);
992
1125
  }
993
1126
  for (const tableName of recordedAnalyzeTables) {
994
1127
  try {
995
- await db.run(drizzleOrm.sql`ANALYZE ${chunk5W4L6DLF_cjs.quoteIdentifier(tableName)}`);
1128
+ await db.run(drizzleOrm.sql`ANALYZE ${chunkVL2V6PEN_cjs.quoteIdentifier(tableName)}`);
996
1129
  } catch (error) {
997
- if (!chunkRSSQKPSZ_cjs.isMissingTableError(error)) throw error;
1130
+ if (!chunk3GH67G4Z_cjs.isMissingTableError(error)) throw error;
998
1131
  }
999
1132
  }
1000
1133
  },
@@ -1008,7 +1141,14 @@ function createSqliteBackend(db, options = {}) {
1008
1141
  (target) => target.setActiveVersion(params)
1009
1142
  );
1010
1143
  },
1011
- async transaction(fn, _options) {
1144
+ async transaction(fn, options2) {
1145
+ const temporaryWrites = options2?.temporaryWrites === chunkIPSVVTWT_cjs.INTERNAL_TEMPORARY_WRITES;
1146
+ if (temporaryWrites && options2.accessMode !== "read_only") {
1147
+ throw new chunkBVRDGYXQ_cjs.ConfigurationError(
1148
+ "Temporary-write transactions must be semantically read-only.",
1149
+ { dialect: "sqlite" }
1150
+ );
1151
+ }
1012
1152
  if (transactionMode === "none") {
1013
1153
  throwSqliteTransactionsDisabled(
1014
1154
  "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 +1164,15 @@ function createSqliteBackend(db, options = {}) {
1024
1164
  profileHints: { isSync },
1025
1165
  tableNames,
1026
1166
  fulltextStrategy,
1027
- vectorStrategy});
1028
- await runFrameStatement(drizzleOrm.sql`BEGIN IMMEDIATE`);
1167
+ vectorStrategy,
1168
+ contributionMaterializer
1169
+ });
1170
+ await runFrameStatement(
1171
+ options2?.accessMode === "read_only" || temporaryWrites ? drizzleOrm.sql`BEGIN` : drizzleOrm.sql`BEGIN IMMEDIATE`
1172
+ );
1029
1173
  try {
1030
1174
  const result = await fn(
1031
- chunk456Z2U7Y_cjs.gateFulltext(
1175
+ chunkDIQ3AV5W_cjs.gateFulltext(
1032
1176
  txBackend,
1033
1177
  contributionMaterializer.assertInitialized
1034
1178
  ),
@@ -1050,7 +1194,7 @@ function createSqliteBackend(db, options = {}) {
1050
1194
  return runWithSerializedQueue(
1051
1195
  serializedQueue,
1052
1196
  async () => db.transaction(async (tx) => fn(bindTransactionBackend(tx), tx), {
1053
- behavior: "immediate"
1197
+ behavior: options2?.accessMode === "read_only" || temporaryWrites ? "deferred" : "immediate"
1054
1198
  })
1055
1199
  );
1056
1200
  },
@@ -1060,7 +1204,7 @@ function createSqliteBackend(db, options = {}) {
1060
1204
  "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
1205
  );
1062
1206
  }
1063
- chunk456Z2U7Y_cjs.assertAdoptedDialect(
1207
+ chunkDIQ3AV5W_cjs.assertAdoptedDialect(
1064
1208
  externalTx,
1065
1209
  sqliteCore.BaseSQLiteDatabase,
1066
1210
  "sqlite"
@@ -1086,10 +1230,10 @@ function createTransactionBackend(options) {
1086
1230
  tableNames: options.tableNames,
1087
1231
  fulltextStrategy: options.fulltextStrategy,
1088
1232
  vectorStrategy: options.vectorStrategy,
1089
- ...options.vectorStrategy === void 0 ? {} : { vectorSlotLatch: chunk456Z2U7Y_cjs.createVectorSlotLatch() }
1233
+ contributionMaterializer: options.contributionMaterializer
1090
1234
  });
1091
1235
  }
1092
1236
 
1093
1237
  exports.createSqliteBackend = createSqliteBackend;
1094
- //# sourceMappingURL=chunk-JFMEONLG.cjs.map
1095
- //# sourceMappingURL=chunk-JFMEONLG.cjs.map
1238
+ //# sourceMappingURL=chunk-EJYMTO3K.cjs.map
1239
+ //# sourceMappingURL=chunk-EJYMTO3K.cjs.map