@powersync/web 1.38.7 → 2.0.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/bin/powersync.cjs +1 -1
  2. package/dist/index.react_native_web.js +1893 -0
  3. package/dist/index.react_native_web.js.map +1 -0
  4. package/dist/worker/AccessHandlePoolVFS-BPUHfZME.js +2 -0
  5. package/dist/worker/AccessHandlePoolVFS-BPUHfZME.js.map +1 -0
  6. package/dist/worker/FacadeVFS-d1ZDvud7.js +2 -0
  7. package/dist/worker/FacadeVFS-d1ZDvud7.js.map +1 -0
  8. package/dist/worker/IDBBatchAtomicVFS-DbkDb777.js +2 -0
  9. package/dist/worker/IDBBatchAtomicVFS-DbkDb777.js.map +1 -0
  10. package/dist/worker/MemoryVFS-DVJL5F8j.js +2 -0
  11. package/dist/worker/MemoryVFS-DVJL5F8j.js.map +1 -0
  12. package/dist/worker/OPFSCoopSyncVFS-BgTiWPfa.js +2 -0
  13. package/dist/worker/OPFSCoopSyncVFS-BgTiWPfa.js.map +1 -0
  14. package/dist/worker/OPFSWriteAheadVFS-BzodSqNq.js +2 -0
  15. package/dist/worker/OPFSWriteAheadVFS-BzodSqNq.js.map +1 -0
  16. package/dist/worker/mc-wa-sqlite-DiBqIVE5.js +2 -0
  17. package/dist/worker/mc-wa-sqlite-DiBqIVE5.js.map +1 -0
  18. package/dist/worker/mc-wa-sqlite-async-DUEhO9ef.js +2 -0
  19. package/dist/worker/mc-wa-sqlite-async-DUEhO9ef.js.map +1 -0
  20. package/dist/worker/wa-sqlite-BlSx7-_P.js +2 -0
  21. package/dist/worker/wa-sqlite-BlSx7-_P.js.map +1 -0
  22. package/dist/worker/wa-sqlite-async-BdR24Ucf.js +2 -0
  23. package/dist/worker/wa-sqlite-async-BdR24Ucf.js.map +1 -0
  24. package/dist/worker/websockets-Q8W_lerF.js +9 -0
  25. package/dist/worker/websockets-Q8W_lerF.js.map +1 -0
  26. package/dist/worker/worker.js +7 -0
  27. package/dist/worker/worker.js.map +1 -0
  28. package/lib/attachments/IndexDBFileSystemAdapter.js.map +1 -0
  29. package/lib/{src/db → db}/NavigatorTriggerClaimManager.d.ts +1 -1
  30. package/lib/db/NavigatorTriggerClaimManager.js.map +1 -0
  31. package/lib/db/PowerSyncDatabase.d.ts +67 -0
  32. package/lib/{src/db → db}/PowerSyncDatabase.js +47 -61
  33. package/lib/db/PowerSyncDatabase.js.map +1 -0
  34. package/lib/db/adapters/AsyncWebAdapter.d.ts +32 -0
  35. package/lib/{src/db → db}/adapters/AsyncWebAdapter.js +14 -14
  36. package/lib/db/adapters/AsyncWebAdapter.js.map +1 -0
  37. package/lib/db/adapters/SSRDBAdapter.d.ts +17 -0
  38. package/lib/db/adapters/SSRDBAdapter.js +37 -0
  39. package/lib/db/adapters/SSRDBAdapter.js.map +1 -0
  40. package/lib/{src/db → db}/adapters/WebDBAdapter.d.ts +1 -1
  41. package/lib/db/adapters/WebDBAdapter.js.map +1 -0
  42. package/lib/db/adapters/options.d.ts +87 -0
  43. package/lib/db/adapters/options.js +6 -0
  44. package/lib/db/adapters/options.js.map +1 -0
  45. package/lib/db/adapters/resolveAndValidateOptions.d.ts +5 -0
  46. package/lib/db/adapters/resolveAndValidateOptions.js +33 -0
  47. package/lib/db/adapters/resolveAndValidateOptions.js.map +1 -0
  48. package/lib/{src/db → db}/adapters/wa-sqlite/ConcurrentConnection.d.ts +3 -4
  49. package/lib/{src/db → db}/adapters/wa-sqlite/ConcurrentConnection.js +2 -2
  50. package/lib/db/adapters/wa-sqlite/ConcurrentConnection.js.map +1 -0
  51. package/lib/{src/db → db}/adapters/wa-sqlite/DatabaseClient.d.ts +4 -4
  52. package/lib/{src/db → db}/adapters/wa-sqlite/DatabaseClient.js +11 -37
  53. package/lib/db/adapters/wa-sqlite/DatabaseClient.js.map +1 -0
  54. package/lib/{src/db → db}/adapters/wa-sqlite/DatabaseServer.d.ts +5 -5
  55. package/lib/{src/db → db}/adapters/wa-sqlite/DatabaseServer.js +11 -7
  56. package/lib/db/adapters/wa-sqlite/DatabaseServer.js.map +1 -0
  57. package/lib/{src/db → db}/adapters/wa-sqlite/RawSqliteConnection.d.ts +22 -13
  58. package/lib/{src/db → db}/adapters/wa-sqlite/RawSqliteConnection.js +14 -18
  59. package/lib/db/adapters/wa-sqlite/RawSqliteConnection.js.map +1 -0
  60. package/lib/db/adapters/wa-sqlite/WASQLiteOpenFactory.d.ts +18 -0
  61. package/lib/db/adapters/wa-sqlite/WASQLiteOpenFactory.js +131 -0
  62. package/lib/db/adapters/wa-sqlite/WASQLiteOpenFactory.js.map +1 -0
  63. package/lib/db/adapters/wa-sqlite/vfs.d.ts +47 -0
  64. package/lib/db/adapters/wa-sqlite/vfs.js +95 -0
  65. package/lib/db/adapters/wa-sqlite/vfs.js.map +1 -0
  66. package/lib/{src/db → db}/sync/SSRWebStreamingSyncImplementation.d.ts +4 -8
  67. package/lib/{src/db → db}/sync/SSRWebStreamingSyncImplementation.js +4 -11
  68. package/lib/db/sync/SSRWebStreamingSyncImplementation.js.map +1 -0
  69. package/lib/{src/db → db}/sync/SharedWebStreamingSyncImplementation.d.ts +13 -14
  70. package/lib/{src/db → db}/sync/SharedWebStreamingSyncImplementation.js +31 -66
  71. package/lib/db/sync/SharedWebStreamingSyncImplementation.js.map +1 -0
  72. package/lib/db/sync/WebRemote.d.ts +10 -0
  73. package/lib/db/sync/WebRemote.js +33 -0
  74. package/lib/db/sync/WebRemote.js.map +1 -0
  75. package/lib/{src/db → db}/sync/WebStreamingSyncImplementation.d.ts +2 -4
  76. package/lib/{src/db → db}/sync/WebStreamingSyncImplementation.js +3 -2
  77. package/lib/db/sync/WebStreamingSyncImplementation.js.map +1 -0
  78. package/lib/db/sync/userAgent.js.map +1 -0
  79. package/lib/{src/index.d.ts → index.d.ts} +1 -3
  80. package/lib/{src/index.js → index.js} +1 -3
  81. package/lib/index.js.map +1 -0
  82. package/lib/shared/navigator.js.map +1 -0
  83. package/lib/shared/tab_close_signal.js.map +1 -0
  84. package/lib/worker/SharedWorkerConnectionRequest.d.ts +5 -0
  85. package/lib/worker/SharedWorkerConnectionRequest.js +2 -0
  86. package/lib/worker/SharedWorkerConnectionRequest.js.map +1 -0
  87. package/lib/worker/client.d.ts +15 -0
  88. package/lib/worker/client.js +77 -0
  89. package/lib/worker/client.js.map +1 -0
  90. package/lib/worker/db/MultiDatabaseServer.d.ts +22 -0
  91. package/lib/{src/worker → worker}/db/MultiDatabaseServer.js +28 -16
  92. package/lib/worker/db/MultiDatabaseServer.js.map +1 -0
  93. package/lib/worker/sync/AbstractSharedSyncClientProvider.d.ts +13 -0
  94. package/lib/worker/sync/AbstractSharedSyncClientProvider.js.map +1 -0
  95. package/lib/worker/sync/BroadcastLogger.d.ts +27 -0
  96. package/lib/worker/sync/BroadcastLogger.js +65 -0
  97. package/lib/worker/sync/BroadcastLogger.js.map +1 -0
  98. package/lib/{src/worker → worker}/sync/SharedSyncImplementation.d.ts +11 -15
  99. package/lib/{src/worker → worker}/sync/SharedSyncImplementation.js +42 -43
  100. package/lib/worker/sync/SharedSyncImplementation.js.map +1 -0
  101. package/lib/{src/worker → worker}/sync/WorkerClient.d.ts +3 -3
  102. package/lib/{src/worker → worker}/sync/WorkerClient.js +2 -2
  103. package/lib/worker/sync/WorkerClient.js.map +1 -0
  104. package/lib/worker/worker.js +34 -0
  105. package/lib/worker/worker.js.map +1 -0
  106. package/package.json +22 -29
  107. package/src/db/NavigatorTriggerClaimManager.ts +1 -1
  108. package/src/db/PowerSyncDatabase.ts +80 -122
  109. package/src/db/adapters/AsyncWebAdapter.ts +17 -26
  110. package/src/db/adapters/SSRDBAdapter.ts +14 -64
  111. package/src/db/adapters/WebDBAdapter.ts +1 -1
  112. package/src/db/adapters/options.ts +100 -0
  113. package/src/db/adapters/resolveAndValidateOptions.ts +40 -0
  114. package/src/db/adapters/wa-sqlite/ConcurrentConnection.ts +4 -5
  115. package/src/db/adapters/wa-sqlite/DatabaseClient.ts +20 -56
  116. package/src/db/adapters/wa-sqlite/DatabaseServer.ts +15 -12
  117. package/src/db/adapters/wa-sqlite/RawSqliteConnection.ts +37 -32
  118. package/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.ts +63 -126
  119. package/src/db/adapters/wa-sqlite/vfs.ts +67 -49
  120. package/src/db/sync/SSRWebStreamingSyncImplementation.ts +4 -22
  121. package/src/db/sync/SharedWebStreamingSyncImplementation.ts +38 -77
  122. package/src/db/sync/WebRemote.ts +23 -26
  123. package/src/db/sync/WebStreamingSyncImplementation.ts +4 -5
  124. package/src/index.ts +1 -3
  125. package/src/worker/SharedWorkerConnectionRequest.ts +6 -0
  126. package/src/worker/client.ts +100 -0
  127. package/src/worker/db/MultiDatabaseServer.ts +43 -23
  128. package/src/worker/sync/AbstractSharedSyncClientProvider.ts +4 -10
  129. package/src/worker/sync/BroadcastLogger.ts +35 -103
  130. package/src/worker/sync/SharedSyncImplementation.ts +62 -63
  131. package/src/worker/sync/WorkerClient.ts +4 -4
  132. package/src/worker/worker.ts +38 -0
  133. package/dist/index.umd.js +0 -7613
  134. package/dist/index.umd.js.map +0 -1
  135. package/dist/worker/SharedSyncImplementation.umd.js +0 -16139
  136. package/dist/worker/SharedSyncImplementation.umd.js.map +0 -1
  137. package/dist/worker/WASQLiteDB.umd.js +0 -17418
  138. package/dist/worker/WASQLiteDB.umd.js.map +0 -1
  139. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-9af0a7.umd.js +0 -31
  140. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-9af0a7.umd.js.map +0 -1
  141. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-bbf5a9.umd.js +0 -31
  142. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-bbf5a9.umd.js.map +0 -1
  143. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-c26e0f.umd.js +0 -31
  144. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-c26e0f.umd.js.map +0 -1
  145. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js +0 -31
  146. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js.map +0 -1
  147. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-2fb422.umd.js +0 -3562
  148. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-2fb422.umd.js.map +0 -1
  149. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-96fb23.umd.js +0 -2478
  150. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-96fb23.umd.js.map +0 -1
  151. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-c89911.umd.js +0 -1681
  152. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-c89911.umd.js.map +0 -1
  153. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-ec4eb1.umd.js +0 -1820
  154. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-ec4eb1.umd.js.map +0 -1
  155. package/lib/package.json +0 -91
  156. package/lib/src/attachments/IndexDBFileSystemAdapter.js.map +0 -1
  157. package/lib/src/db/NavigatorTriggerClaimManager.js.map +0 -1
  158. package/lib/src/db/PowerSyncDatabase.d.ts +0 -78
  159. package/lib/src/db/PowerSyncDatabase.js.map +0 -1
  160. package/lib/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.d.ts +0 -23
  161. package/lib/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.js +0 -27
  162. package/lib/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.js.map +0 -1
  163. package/lib/src/db/adapters/AsyncWebAdapter.d.ts +0 -50
  164. package/lib/src/db/adapters/AsyncWebAdapter.js.map +0 -1
  165. package/lib/src/db/adapters/SSRDBAdapter.d.ts +0 -30
  166. package/lib/src/db/adapters/SSRDBAdapter.js +0 -69
  167. package/lib/src/db/adapters/SSRDBAdapter.js.map +0 -1
  168. package/lib/src/db/adapters/WebDBAdapter.js.map +0 -1
  169. package/lib/src/db/adapters/wa-sqlite/ConcurrentConnection.js.map +0 -1
  170. package/lib/src/db/adapters/wa-sqlite/DatabaseClient.js.map +0 -1
  171. package/lib/src/db/adapters/wa-sqlite/DatabaseServer.js.map +0 -1
  172. package/lib/src/db/adapters/wa-sqlite/RawSqliteConnection.js.map +0 -1
  173. package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.d.ts +0 -45
  174. package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.js +0 -146
  175. package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.js.map +0 -1
  176. package/lib/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.d.ts +0 -15
  177. package/lib/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.js +0 -22
  178. package/lib/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.js.map +0 -1
  179. package/lib/src/db/adapters/wa-sqlite/vfs.d.ts +0 -50
  180. package/lib/src/db/adapters/wa-sqlite/vfs.js +0 -77
  181. package/lib/src/db/adapters/wa-sqlite/vfs.js.map +0 -1
  182. package/lib/src/db/adapters/web-sql-flags.d.ts +0 -92
  183. package/lib/src/db/adapters/web-sql-flags.js +0 -37
  184. package/lib/src/db/adapters/web-sql-flags.js.map +0 -1
  185. package/lib/src/db/sync/SSRWebStreamingSyncImplementation.js.map +0 -1
  186. package/lib/src/db/sync/SharedWebStreamingSyncImplementation.js.map +0 -1
  187. package/lib/src/db/sync/WebRemote.d.ts +0 -7
  188. package/lib/src/db/sync/WebRemote.js +0 -33
  189. package/lib/src/db/sync/WebRemote.js.map +0 -1
  190. package/lib/src/db/sync/WebStreamingSyncImplementation.js.map +0 -1
  191. package/lib/src/db/sync/userAgent.js.map +0 -1
  192. package/lib/src/index.js.map +0 -1
  193. package/lib/src/shared/navigator.js.map +0 -1
  194. package/lib/src/shared/tab_close_signal.js.map +0 -1
  195. package/lib/src/worker/db/MultiDatabaseServer.d.ts +0 -17
  196. package/lib/src/worker/db/MultiDatabaseServer.js.map +0 -1
  197. package/lib/src/worker/db/WASQLiteDB.worker.d.ts +0 -4
  198. package/lib/src/worker/db/WASQLiteDB.worker.js +0 -31
  199. package/lib/src/worker/db/WASQLiteDB.worker.js.map +0 -1
  200. package/lib/src/worker/db/open-worker-database.d.ts +0 -14
  201. package/lib/src/worker/db/open-worker-database.js +0 -53
  202. package/lib/src/worker/db/open-worker-database.js.map +0 -1
  203. package/lib/src/worker/sync/AbstractSharedSyncClientProvider.d.ts +0 -19
  204. package/lib/src/worker/sync/AbstractSharedSyncClientProvider.js.map +0 -1
  205. package/lib/src/worker/sync/BroadcastLogger.d.ts +0 -47
  206. package/lib/src/worker/sync/BroadcastLogger.js +0 -129
  207. package/lib/src/worker/sync/BroadcastLogger.js.map +0 -1
  208. package/lib/src/worker/sync/SharedSyncImplementation.js.map +0 -1
  209. package/lib/src/worker/sync/SharedSyncImplementation.worker.js +0 -12
  210. package/lib/src/worker/sync/SharedSyncImplementation.worker.js.map +0 -1
  211. package/lib/src/worker/sync/WorkerClient.js.map +0 -1
  212. package/lib/tsconfig.tsbuildinfo +0 -1
  213. package/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.ts +0 -47
  214. package/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.ts +0 -24
  215. package/src/db/adapters/web-sql-flags.ts +0 -141
  216. package/src/worker/db/WASQLiteDB.worker.ts +0 -35
  217. package/src/worker/db/open-worker-database.ts +0 -62
  218. package/src/worker/sync/SharedSyncImplementation.worker.ts +0 -14
  219. /package/dist/{8e97452e297be23b5e50.wasm → worker/assets/mc-wa-sqlite-CnHbhWvs.wasm} +0 -0
  220. /package/dist/{2075a31bb151adbb9767.wasm → worker/assets/mc-wa-sqlite-async-D6idQS2r.wasm} +0 -0
  221. /package/dist/{3322bc84de986b63c2cd.wasm → worker/assets/wa-sqlite-XZW__iJk.wasm} +0 -0
  222. /package/dist/{fbc178b70d530e8ce02b.wasm → worker/assets/wa-sqlite-async-rHzzC98y.wasm} +0 -0
  223. /package/lib/{src/attachments → attachments}/IndexDBFileSystemAdapter.d.ts +0 -0
  224. /package/lib/{src/attachments → attachments}/IndexDBFileSystemAdapter.js +0 -0
  225. /package/lib/{src/db → db}/NavigatorTriggerClaimManager.js +0 -0
  226. /package/lib/{src/db → db}/adapters/WebDBAdapter.js +0 -0
  227. /package/lib/{src/db → db}/sync/userAgent.d.ts +0 -0
  228. /package/lib/{src/db → db}/sync/userAgent.js +0 -0
  229. /package/lib/{src/shared → shared}/navigator.d.ts +0 -0
  230. /package/lib/{src/shared → shared}/navigator.js +0 -0
  231. /package/lib/{src/shared → shared}/tab_close_signal.d.ts +0 -0
  232. /package/lib/{src/shared → shared}/tab_close_signal.js +0 -0
  233. /package/lib/{src/worker → worker}/sync/AbstractSharedSyncClientProvider.js +0 -0
  234. /package/lib/{src/worker/sync/SharedSyncImplementation.worker.d.ts → worker/worker.d.ts} +0 -0
@@ -1,17 +1,10 @@
1
- import {
2
- BaseObserver,
3
- DBAdapterListener,
4
- DBAdapter,
5
- DBLockOptions,
6
- LockContext,
7
- QueryResult,
8
- Transaction,
9
- Mutex,
10
- timeoutSignal
11
- } from '@powersync/common';
1
+ import { DBAdapter, DBLockOptions, LockContext, RawQueryResult } from '@powersync/common';
2
+ import { Mutex } from '@powersync/shared-internals';
12
3
 
13
- const MOCK_QUERY_RESPONSE: QueryResult = {
14
- rowsAffected: 0
4
+ const MOCK_QUERY_RESPONSE: RawQueryResult = {
5
+ rowsAffected: 0,
6
+ columnNames: [],
7
+ rawRows: []
15
8
  };
16
9
 
17
10
  /**
@@ -19,7 +12,7 @@ const MOCK_QUERY_RESPONSE: QueryResult = {
19
12
  * This adapter will return empty results for queries, which will allow
20
13
  * server rendered views to initially generate scaffolding components
21
14
  */
22
- export class SSRDBAdapter extends BaseObserver<DBAdapterListener> implements DBAdapter {
15
+ export class SSRDBAdapter extends DBAdapter {
23
16
  name: string;
24
17
  readMutex: Mutex;
25
18
  writeMutex: Mutex;
@@ -34,61 +27,18 @@ export class SSRDBAdapter extends BaseObserver<DBAdapterListener> implements DBA
34
27
  close() {}
35
28
 
36
29
  async readLock<T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions) {
37
- return this.readMutex.runExclusive(() => fn(this), timeoutSignal(options?.timeoutMs));
38
- }
39
-
40
- async readTransaction<T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions) {
41
- return this.readLock(() => fn(this.generateMockTransactionContext()), options);
30
+ return fn(new StubLockContext());
42
31
  }
43
32
 
44
33
  async writeLock<T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions) {
45
- return this.writeMutex.runExclusive(() => fn(this), timeoutSignal(options?.timeoutMs));
46
- }
47
-
48
- async writeTransaction<T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions) {
49
- return this.writeLock(() => fn(this.generateMockTransactionContext()), options);
50
- }
51
-
52
- async execute(query: string, params?: any[]): Promise<QueryResult> {
53
- return this.writeMutex.runExclusive(async () => MOCK_QUERY_RESPONSE);
54
- }
55
-
56
- async executeRaw(query: string, params?: any[]): Promise<any[][]> {
57
- return this.writeMutex.runExclusive(async () => []);
58
- }
59
-
60
- async executeBatch(query: string, params?: any[][]): Promise<QueryResult> {
61
- return this.writeMutex.runExclusive(async () => MOCK_QUERY_RESPONSE);
34
+ return fn(new StubLockContext());
62
35
  }
63
36
 
64
- async getAll<T>(sql: string, parameters?: any[]): Promise<T[]> {
65
- return [];
66
- }
67
-
68
- async getOptional<T>(sql: string, parameters?: any[] | undefined): Promise<T | null> {
69
- return null;
70
- }
71
-
72
- async get<T>(sql: string, parameters?: any[] | undefined): Promise<T> {
73
- throw new Error(`No values are returned in SSR mode`);
74
- }
37
+ async refreshSchema(): Promise<void> {}
38
+ }
75
39
 
76
- /**
77
- * Generates a mock context for use in read/write transactions.
78
- * `this` already mocks most of the API, commit and rollback mocks
79
- * are added here
80
- */
81
- private generateMockTransactionContext(): Transaction {
82
- return {
83
- ...this,
84
- commit: async () => {
85
- return MOCK_QUERY_RESPONSE;
86
- },
87
- rollback: async () => {
88
- return MOCK_QUERY_RESPONSE;
89
- }
90
- };
40
+ class StubLockContext extends LockContext {
41
+ async executeRaw(): Promise<RawQueryResult> {
42
+ return MOCK_QUERY_RESPONSE;
91
43
  }
92
-
93
- async refreshSchema(): Promise<void> {}
94
44
  }
@@ -1,5 +1,5 @@
1
1
  import { DBAdapter } from '@powersync/common';
2
- import { ResolvedWebSQLOpenOptions } from './web-sql-flags.js';
2
+ import { ResolvedWebSQLOpenOptions } from './options.js';
3
3
 
4
4
  export type SharedConnectionWorker = {
5
5
  identifier: string;
@@ -0,0 +1,100 @@
1
+ import { LogLevels, SQLOpenOptions } from '@powersync/common';
2
+ import { WASQLiteVFS } from './wa-sqlite/vfs.js';
3
+
4
+ export interface WebSpecificOpenOptions {
5
+ /**
6
+ * SQLite operations are currently not supported in SSR mode.
7
+ * A warning will be logged if attempting to use SQLite in SSR.
8
+ * Setting this to `true` will disabled the warning above.
9
+ */
10
+ disableSSRWarning: boolean;
11
+
12
+ /**
13
+ * Enables multi tab support.
14
+ *
15
+ * Enabling multi-tab support will transparently make PowerSync manage the sync process in a shared worker collecting
16
+ * Sync Streams across tabs. Additionally, it enables a shared worker for IndexedDB databases.
17
+ *
18
+ * It is still valid to open multiple tabs when this option is disabled, but the experience may be degrated as only
19
+ * one tab can sync at the time.
20
+ *
21
+ * This is enabled by default on Desktop browsers if shared workers are enabled, except for Safari.
22
+ */
23
+ enableMultiTabs: boolean;
24
+
25
+ /**
26
+ * The SQLite connection is often executed through a web worker in order to offload computation and because some file
27
+ * system implementations (notably those based on web filesystem APIs like OPFS) are only available in workers.
28
+ *
29
+ * Manually disabling the use of web workers is not recommended, but can be useful for testing or for environments
30
+ * or toolchains where web workers are not supported.
31
+ */
32
+ useWebWorker: boolean;
33
+
34
+ /**
35
+ * Open in SSR placeholder mode. DB operations and Sync operations will be a No-op
36
+ */
37
+ ssrMode: boolean;
38
+
39
+ /**
40
+ * The log level for database workers.
41
+ *
42
+ * Defaults to {@link LogLevels.info}.
43
+ */
44
+ databaseWorkerLogLevel: number;
45
+
46
+ /**
47
+ * Where to store SQLite temporary files. Defaults to 'MEMORY'.
48
+ * Setting this to `FILESYSTEM` can cause issues with larger queries or datasets.
49
+ */
50
+ temporaryStorage: TemporaryStorageOption;
51
+
52
+ /**
53
+ * Maximum SQLite cache size. Defaults to 50MB.
54
+ *
55
+ * For details, see: https://www.sqlite.org/pragma.html#pragma_cache_size
56
+ */
57
+ cacheSizeKb: number;
58
+
59
+ /**
60
+ * Encryption key for the database.
61
+ * If set, the database will be encrypted using ChaCha20.
62
+ */
63
+ encryptionKey: string | undefined;
64
+
65
+ vfs: WASQLiteVFS;
66
+
67
+ /**
68
+ * If the {@link vfs} supports it, an additional amount of read-only connections to open. Using additional read
69
+ * connections can speed up queries by dispatching them to multiple workers running them concurrently.
70
+ *
71
+ * {@link WASQLiteVFS.OPFSWriteAheadVFS} is the only VFS with support for multiple connections, so this option is
72
+ * ignored for other VFS implementations.
73
+ *
74
+ * Defaults to 1.
75
+ */
76
+ additionalReaders: number;
77
+
78
+ /**
79
+ * Allows you to override the default wasqlite db worker.
80
+ *
81
+ * You can either provide a path to the worker script
82
+ * or a factory method that returns a worker.
83
+ */
84
+ worker?: string | URL | ((options: ResolvedWebSQLOpenOptions) => Worker | SharedWorker);
85
+
86
+ /**
87
+ * Use an existing port to an initialized worker.
88
+ * A worker will be initialized if none is provided
89
+ */
90
+ workerPort?: MessagePort | undefined;
91
+ }
92
+
93
+ export interface ResolvedWebSQLOpenOptions extends SQLOpenOptions, WebSpecificOpenOptions {}
94
+
95
+ export interface WebSQLOpenOptions extends SQLOpenOptions, Partial<WebSpecificOpenOptions> {}
96
+
97
+ export enum TemporaryStorageOption {
98
+ MEMORY = 'memory',
99
+ FILESYSTEM = 'file'
100
+ }
@@ -0,0 +1,40 @@
1
+ import { LogLevels } from '@powersync/common';
2
+ import { TemporaryStorageOption, WebSpecificOpenOptions } from './options.js';
3
+ import { vfsRequiresDedicatedWorkers, WASQLiteVFS } from './wa-sqlite/vfs.js';
4
+
5
+ /**
6
+ * @internal
7
+ */
8
+ export function resolveAndValidateOptions<And = {}>(
9
+ options: Partial<WebSpecificOpenOptions> & And
10
+ ): WebSpecificOpenOptions & And {
11
+ const defaults: WebSpecificOpenOptions = {
12
+ disableSSRWarning: false,
13
+ ssrMode: !('window' in globalThis),
14
+ /**
15
+ * Multiple tabs are by default not supported on Android, iOS and Safari.
16
+ * Other platforms will have multiple tabs enabled by default.
17
+ */
18
+ enableMultiTabs:
19
+ typeof globalThis.navigator !== 'undefined' && // For SSR purposes
20
+ typeof SharedWorker !== 'undefined' &&
21
+ !navigator.userAgent.match(/(Android|iPhone|iPod|iPad)/i) &&
22
+ !(window as any).safari,
23
+ useWebWorker: true,
24
+ databaseWorkerLogLevel: LogLevels.info,
25
+ temporaryStorage: TemporaryStorageOption.MEMORY,
26
+ cacheSizeKb: 50 * 1024,
27
+ encryptionKey: undefined,
28
+ vfs: WASQLiteVFS.IDBBatchAtomicVFS,
29
+ additionalReaders: 1
30
+ };
31
+
32
+ const resolved = Object.assign(defaults, options);
33
+ if (vfsRequiresDedicatedWorkers(resolved.vfs) && !resolved.useWebWorker) {
34
+ throw new Error(
35
+ `Invalid configuration: The 'useWebWorker' flag must be true when using an OPFS-based VFS (${resolved.vfs}).`
36
+ );
37
+ }
38
+
39
+ return resolved;
40
+ }
@@ -1,6 +1,5 @@
1
- import { Mutex, UnlockFn } from '@powersync/common';
2
- import { RawSqliteConnection } from './RawSqliteConnection.js';
3
- import { ResolvedWASQLiteOpenFactoryOptions } from './WASQLiteOpenFactory.js';
1
+ import { Mutex, UnlockFn } from '@powersync/shared-internals';
2
+ import { RawSqliteConnection, RawWaSqliteDatabaseOptions } from './RawSqliteConnection.js';
4
3
 
5
4
  /**
6
5
  * A wrapper around a {@link RawSqliteConnection} allowing multiple tabs to access it.
@@ -33,7 +32,7 @@ export class ConcurrentSqliteConnection {
33
32
  this.leaseMutex = needsNavigatorLocks ? null : new Mutex();
34
33
  }
35
34
 
36
- get options(): ResolvedWASQLiteOpenFactoryOptions {
35
+ get options(): RawWaSqliteDatabaseOptions {
37
36
  return this.inner.options;
38
37
  }
39
38
 
@@ -46,7 +45,7 @@ export class ConcurrentSqliteConnection {
46
45
  const options: LockOptions = { signal: abort };
47
46
 
48
47
  navigator.locks
49
- .request(`db-lock-${this.options.dbFilename}`, options, (_) => {
48
+ .request(`db-lock-${this.options.filename}`, options, (_) => {
50
49
  return new Promise<void>((returnLock) => {
51
50
  return resolve(() => {
52
51
  returnLock();
@@ -2,23 +2,22 @@ import {
2
2
  QueryResult,
3
3
  LockContext,
4
4
  DBLockOptions,
5
- DBAdapterListener,
6
- ConnectionPool,
7
5
  SqlExecutor,
8
- DBGetUtilsDefaultMixin,
9
6
  BatchedUpdateNotification,
10
- BaseObserver,
11
- ConnectionClosedError,
12
- SQLOpenOptions
7
+ SQLOpenOptions,
8
+ DBAdapter,
9
+ RawQueryResult,
10
+ queryResultWithoutRows,
11
+ BaseQueryResult
13
12
  } from '@powersync/common';
14
13
  import { SharedConnectionWorker, WebDBAdapterConfiguration } from '../WebDBAdapter.js';
15
14
  import { ClientConnectionView } from './DatabaseServer.js';
16
- import { RawQueryResult } from './RawSqliteConnection.js';
17
15
  import * as Comlink from 'comlink';
18
- import { WorkerDBOpenerOptions } from './WASQLiteOpenFactory.js';
16
+ import type { ConnectToMultiDatabaseServerOptions } from '../../../worker/db/MultiDatabaseServer.js';
17
+ import { ConnectionClosedError } from '@powersync/shared-internals';
19
18
 
20
19
  export interface OpenWorkerConnection {
21
- connect(config: WorkerDBOpenerOptions): Promise<ClientConnectionView>;
20
+ connect(config: ConnectToMultiDatabaseServerOptions): Promise<ClientConnectionView>;
22
21
  connectToExisting(options: { identifier: string; lockName: string }): Promise<ClientConnectionView>;
23
22
  }
24
23
 
@@ -44,10 +43,7 @@ export interface ClientOptions {
44
43
  /**
45
44
  * A single-connection {@link ConnectionPool} implementation based on a worker connection.
46
45
  */
47
- export class DatabaseClient<Config extends SQLOpenOptions = WebDBAdapterConfiguration>
48
- extends BaseObserver<DBAdapterListener>
49
- implements ConnectionPool
50
- {
46
+ export class DatabaseClient<Config extends SQLOpenOptions = WebDBAdapterConfiguration> extends DBAdapter {
51
47
  #connection: ConnectionState;
52
48
  #shareConnectionAbortController = new AbortController();
53
49
  #receiveTableUpdates: MessagePort;
@@ -70,9 +66,7 @@ export class DatabaseClient<Config extends SQLOpenOptions = WebDBAdapterConfigur
70
66
  port2.onmessage = (event) => {
71
67
  const tables = event.data as string[];
72
68
  const notification: BatchedUpdateNotification = {
73
- tables,
74
- groupedUpdates: {},
75
- rawUpdates: []
69
+ tables
76
70
  };
77
71
  this.iterateListeners((l) => {
78
72
  l.tablesUpdated && l.tablesUpdated(notification);
@@ -185,16 +179,17 @@ export class DatabaseClient<Config extends SQLOpenOptions = WebDBAdapterConfigur
185
179
  }
186
180
 
187
181
  /**
188
- * A {@link SqlExecutor} implemented by sending commands to a worker.
182
+ * A {@link LockContext} implemented by sending commands to a worker.
189
183
  *
190
184
  * While an instance is active, it has exclusive access to the underlying database connection (as represented by its
191
185
  * token).
192
186
  */
193
- class ClientSqlExecutor implements SqlExecutor {
187
+ class ClientLockContext extends LockContext {
194
188
  readonly #connection: ConnectionState;
195
189
  readonly #token: string;
196
190
 
197
191
  constructor(connection: ConnectionState, token: string) {
192
+ super();
198
193
  this.#connection = connection;
199
194
  this.#token = token;
200
195
  }
@@ -223,37 +218,8 @@ class ClientSqlExecutor implements SqlExecutor {
223
218
  }
224
219
  }
225
220
 
226
- async execute(query: string, params?: any[] | undefined): Promise<QueryResult> {
227
- const rs = await this.#executeOnWorker(query, params);
228
- let rows: QueryResult['rows'] | undefined;
229
- if (rs.resultSet) {
230
- const resultSet = rs.resultSet;
231
-
232
- function rowToJavaScriptObject(row: any[]): Record<string, any> {
233
- const obj: Record<string, any> = {};
234
- resultSet.columns.forEach((key, idx) => (obj[key] = row[idx]));
235
- return obj;
236
- }
237
-
238
- const mapped = resultSet.rows.map(rowToJavaScriptObject);
239
-
240
- rows = {
241
- _array: mapped,
242
- length: mapped.length,
243
- item: (idx: number) => mapped[idx]
244
- };
245
- }
246
-
247
- return {
248
- rowsAffected: rs.changes,
249
- insertId: rs.lastInsertRowId,
250
- rows
251
- };
252
- }
253
-
254
- async executeRaw(query: string, params?: any[] | undefined): Promise<any[][]> {
255
- const rs = await this.#executeOnWorker(query, params);
256
- return rs.resultSet?.rows ?? [];
221
+ async executeRaw(query: string, params?: any[] | undefined): Promise<RawQueryResult> {
222
+ return await this.#executeOnWorker(query, params);
257
223
  }
258
224
 
259
225
  async #executeOnWorker(query: string, params: any[] | undefined): Promise<RawQueryResult> {
@@ -263,23 +229,21 @@ class ClientSqlExecutor implements SqlExecutor {
263
229
  );
264
230
  }
265
231
 
266
- async executeBatch(query: string, params: any[][] = []): Promise<QueryResult> {
232
+ async executeBatch(query: string, params: any[][] = []): Promise<QueryResult<never>> {
267
233
  const results = await this.maybeTrace(
268
234
  (c) => c.executeBatch(this.#token, query, params),
269
235
  () => `${query} (batch of ${params.length})`
270
236
  );
271
- const result: QueryResult = { insertId: undefined, rowsAffected: 0 };
237
+ const result: BaseQueryResult = { insertId: undefined, rowsAffected: 0 };
272
238
  for (const source of results) {
273
- result.insertId = source.lastInsertRowId;
274
- result.rowsAffected += source.changes;
239
+ result.insertId = source.insertId;
240
+ result.rowsAffected = (result.rowsAffected ?? 0) + source.rowsAffected;
275
241
  }
276
242
 
277
- return result;
243
+ return queryResultWithoutRows(result);
278
244
  }
279
245
  }
280
246
 
281
- class ClientLockContext extends DBGetUtilsDefaultMixin(ClientSqlExecutor) implements LockContext {}
282
-
283
247
  interface ConnectionState {
284
248
  connection: ClientConnectionView;
285
249
  notifyRemoteClosed: AbortController | undefined;
@@ -1,11 +1,11 @@
1
- import { ILogger } from '@powersync/common';
1
+ import { LogLevels, PowerSyncLogger } from '@powersync/common';
2
2
  import { ConcurrentSqliteConnection, ConnectionLeaseToken } from './ConcurrentConnection.js';
3
- import { RawQueryResult } from './RawSqliteConnection.js';
3
+ import { RawWebResult } from './RawSqliteConnection.js';
4
4
 
5
5
  export interface DatabaseServerOptions {
6
6
  inner: ConcurrentSqliteConnection;
7
7
  onClose: () => void;
8
- logger: ILogger;
8
+ logger: PowerSyncLogger;
9
9
  }
10
10
 
11
11
  /**
@@ -24,7 +24,7 @@ export class DatabaseServer {
24
24
  constructor(options: DatabaseServerOptions) {
25
25
  this.#options = options;
26
26
  const inner = options.inner;
27
- this.#updateBroadcastChannel = new BroadcastChannel(`${inner.options.dbFilename}-table-updates`);
27
+ this.#updateBroadcastChannel = new BroadcastChannel(`${inner.options.filename}-table-updates`);
28
28
 
29
29
  this.#updateBroadcastChannel.onmessage = ({ data }) => {
30
30
  this.#pushTableUpdateToClients(data as string[]);
@@ -85,7 +85,7 @@ export class DatabaseServer {
85
85
 
86
86
  // If the client holds a connection lease it hasn't returned, return that now.
87
87
  for (const { lease } of connectionLeases.values()) {
88
- this.#logger.debug(`Closing connection lease that hasn't been returned.`);
88
+ this.#logger.log({ level: LogLevels.debug, message: `Closing connection lease that hasn't been returned.` });
89
89
  await lease.returnLease();
90
90
  }
91
91
 
@@ -94,7 +94,10 @@ export class DatabaseServer {
94
94
  if (this.#activeClients.size == 0) {
95
95
  await this.forceClose();
96
96
  } else {
97
- this.#logger.debug('Keeping underlying connection active since its used by other clients.');
97
+ this.#logger.log({
98
+ level: LogLevels.debug,
99
+ message: 'Keeping underlying connection active since its used by other clients.'
100
+ });
98
101
  }
99
102
  }
100
103
  };
@@ -133,9 +136,9 @@ export class DatabaseServer {
133
136
  try {
134
137
  if (lease.write) {
135
138
  // Collect update hooks invoked while the client had the write connection.
136
- const { resultSet } = await lease.lease.use((conn) => conn.execute(`SELECT powersync_update_hooks('get')`));
137
- if (resultSet) {
138
- const updatedTables: string[] = JSON.parse(resultSet.rows[0][0] as string);
139
+ const { rawRows } = await lease.lease.use((conn) => conn.execute(`SELECT powersync_update_hooks('get')`));
140
+ if (rawRows.length) {
141
+ const updatedTables: string[] = JSON.parse(rawRows[0][0] as string);
139
142
  if (updatedTables.length) {
140
143
  this.#updateBroadcastChannel.postMessage(updatedTables);
141
144
  this.#pushTableUpdateToClients(updatedTables);
@@ -169,7 +172,7 @@ export class DatabaseServer {
169
172
  }
170
173
 
171
174
  async forceClose() {
172
- this.#logger.debug(`Closing connection to ${this.#inner.options}.`);
175
+ this.#logger.log({ level: LogLevels.debug, message: `Closing connection to ${this.#inner.options}.` });
173
176
  const connection = this.#inner;
174
177
  this.#options.onClose();
175
178
  this.#updateBroadcastChannel.close();
@@ -190,8 +193,8 @@ export interface ClientConnectionView {
190
193
  * give other clients access to the database afterwards.
191
194
  */
192
195
  requestAccess(write: boolean, timeoutMs?: number): Promise<string>;
193
- execute(token: string, sql: string, params: any[] | undefined): Promise<RawQueryResult>;
194
- executeBatch(token: string, sql: string, params: any[][]): Promise<RawQueryResult[]>;
196
+ execute(token: string, sql: string, params: any[] | undefined): Promise<RawWebResult>;
197
+ executeBatch(token: string, sql: string, params: any[][]): Promise<RawWebResult[]>;
195
198
  completeAccess(token: string): Promise<void>;
196
199
 
197
200
  /**
@@ -1,18 +1,28 @@
1
1
  import { Factory as WaSqliteFactory, SQLITE_ROW } from '@journeyapps/wa-sqlite';
2
2
 
3
- import { DEFAULT_MODULE_FACTORIES, WASQLiteModuleFactory } from './vfs.js';
4
- import { ResolvedWASQLiteOpenFactoryOptions } from './WASQLiteOpenFactory.js';
3
+ import { loadModuleAndVfs, WASQLiteVFS } from './vfs.js';
4
+ import { TemporaryStorageOption } from '../options.js';
5
+ import { RawQueryResult, SqliteValue } from '@powersync/common';
6
+
7
+ export interface RawWebResult extends Required<RawQueryResult> {
8
+ autocommit: boolean;
9
+ }
5
10
 
6
11
  export interface RawResultSet {
7
- columns: string[];
8
- rows: SQLiteCompatibleType[][];
12
+ columnNames: string[];
13
+ rawRows: SqliteValue[][];
9
14
  }
10
15
 
11
- export interface RawQueryResult {
12
- changes: number;
13
- lastInsertRowId: number;
14
- autocommit: boolean;
15
- resultSet: RawResultSet | undefined;
16
+ /**
17
+ * @internal
18
+ */
19
+ export interface RawWaSqliteDatabaseOptions {
20
+ filename: string;
21
+ readonly: boolean;
22
+ vfs: WASQLiteVFS;
23
+ encryptionKey: string | undefined;
24
+ temporaryStorage: TemporaryStorageOption;
25
+ cacheSizeKb: number;
16
26
  }
17
27
 
18
28
  /**
@@ -27,11 +37,8 @@ export class RawSqliteConnection {
27
37
  * The `sqlite3*` connection pointer.
28
38
  */
29
39
  private db: number = 0;
30
- private _moduleFactory: WASQLiteModuleFactory;
31
40
 
32
- constructor(readonly options: ResolvedWASQLiteOpenFactoryOptions) {
33
- this._moduleFactory = DEFAULT_MODULE_FACTORIES[this.options.vfs];
34
- }
41
+ constructor(readonly options: RawWaSqliteDatabaseOptions) {}
35
42
 
36
43
  get isOpen(): boolean {
37
44
  return this.db != 0;
@@ -40,13 +47,13 @@ export class RawSqliteConnection {
40
47
  async init() {
41
48
  const api = (this._sqliteAPI = await this.openSQLiteAPI());
42
49
  this.db = await api.open_v2(
43
- this.options.dbFilename,
44
- this.options.isReadOnly ? 1 /* SQLITE_OPEN_READONLY */ : 6 /* SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE */
50
+ this.options.filename,
51
+ this.options.readonly ? 1 /* SQLITE_OPEN_READONLY */ : 6 /* SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE */
45
52
  );
46
53
  await this.executeRaw(`PRAGMA temp_store = ${this.options.temporaryStorage};`);
47
54
  if (this.options.encryptionKey) {
48
- const escapedKey = this.options.encryptionKey.replace("'", "''");
49
- await this.executeRaw(`PRAGMA key = '${escapedKey}'`);
55
+ const escapedKey = this.options.encryptionKey.replaceAll("'", "''");
56
+ await this.executeRaw(`PRAGMA key = '${escapedKey}';`);
50
57
  }
51
58
  await this.executeRaw(`PRAGMA cache_size = -${this.options.cacheSizeKb};`);
52
59
 
@@ -54,10 +61,7 @@ export class RawSqliteConnection {
54
61
  }
55
62
 
56
63
  private async openSQLiteAPI(): Promise<SQLiteAPI> {
57
- const { module, vfs } = await this._moduleFactory({
58
- dbFileName: this.options.dbFilename,
59
- encryptionKey: this.options.encryptionKey
60
- });
64
+ const { module, vfs } = await loadModuleAndVfs(this.options);
61
65
  const sqlite3 = WaSqliteFactory(module);
62
66
  sqlite3.vfs_register(vfs, true);
63
67
  /**
@@ -69,7 +73,7 @@ export class RawSqliteConnection {
69
73
  * Create the multiple cipher vfs if an encryption key is provided
70
74
  */
71
75
  if (this.options.encryptionKey) {
72
- const createResult = module.ccall('sqlite3mc_vfs_create', 'int', ['string', 'int'], [this.options.dbFilename, 1]);
76
+ const createResult = module.ccall('sqlite3mc_vfs_create', 'int', ['string', 'int'], [this.options.filename, 1]);
73
77
  if (createResult !== 0) {
74
78
  throw new Error('Failed to create multiple cipher vfs, Database encryption will not work');
75
79
  }
@@ -93,12 +97,12 @@ export class RawSqliteConnection {
93
97
  return this.requireSqlite().get_autocommit(this.db) != 0;
94
98
  }
95
99
 
96
- async execute(sql: string, bindings?: any[]): Promise<RawQueryResult> {
100
+ async execute(sql: string, bindings?: any[]): Promise<RawWebResult> {
97
101
  const resultSet = await this.executeSingleStatementRaw(sql, bindings);
98
102
  return this.wrapQueryResults(this.requireSqlite(), resultSet);
99
103
  }
100
104
 
101
- async executeBatch(sql: string, bindings: any[][]): Promise<RawQueryResult[]> {
105
+ async executeBatch(sql: string, bindings: any[][]): Promise<RawWebResult[]> {
102
106
  const results = [];
103
107
  const api = this.requireSqlite();
104
108
  for await (const stmt of api.statements(this.db, sql)) {
@@ -116,21 +120,22 @@ export class RawSqliteConnection {
116
120
  return results;
117
121
  }
118
122
 
119
- private wrapQueryResults(api: SQLiteAPI, rs: RawResultSet | undefined): RawQueryResult {
123
+ private wrapQueryResults(api: SQLiteAPI, { rawRows, columnNames }: RawResultSet): RawWebResult {
120
124
  return {
121
- changes: api.changes(this.db),
122
- lastInsertRowId: api.last_insert_id(this.db),
125
+ rowsAffected: api.changes(this.db),
126
+ insertId: api.last_insert_id(this.db),
123
127
  autocommit: api.get_autocommit(this.db) != 0,
124
- resultSet: rs
128
+ rawRows,
129
+ columnNames
125
130
  };
126
131
  }
127
132
 
128
133
  /**
129
134
  * This executes a single statement using SQLite3 and returns the results as a {@link RawResultSet}.
130
135
  */
131
- private async executeSingleStatementRaw(sql: string, bindings?: any[]): Promise<RawResultSet | undefined> {
136
+ private async executeSingleStatementRaw(sql: string, bindings?: any[]): Promise<RawResultSet> {
132
137
  const results = await this.executeRaw(sql, bindings);
133
- return results.length ? results[0] : undefined;
138
+ return results.length ? results[0] : { columnNames: [], rawRows: [] };
134
139
  }
135
140
 
136
141
  async executeRaw(sql: string, bindings?: any[]): Promise<RawResultSet[]> {
@@ -140,7 +145,7 @@ export class RawSqliteConnection {
140
145
  let columns;
141
146
 
142
147
  const rs = await this.stepThroughStatement(api, stmt, bindings ?? [], columns);
143
- columns = rs.columns;
148
+ columns = rs.columnNames;
144
149
  if (columns.length) {
145
150
  results.push(rs);
146
151
  }
@@ -182,7 +187,7 @@ export class RawSqliteConnection {
182
187
  }
183
188
 
184
189
  knownColumns ??= api.column_names(stmt);
185
- return { columns: knownColumns, rows };
190
+ return { columnNames: knownColumns, rawRows: rows };
186
191
  }
187
192
 
188
193
  async close() {