@powersync/common 0.0.0-dev-20260503073249 → 0.0.0-dev-20260630141119

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 (284) hide show
  1. package/lib/attachments/AttachmentContext.d.ts +9 -8
  2. package/lib/attachments/AttachmentContext.js +8 -3
  3. package/lib/attachments/AttachmentContext.js.map +1 -1
  4. package/lib/attachments/AttachmentErrorHandler.d.ts +6 -6
  5. package/lib/attachments/AttachmentQueue.d.ts +85 -36
  6. package/lib/attachments/AttachmentQueue.js +19 -21
  7. package/lib/attachments/AttachmentQueue.js.map +1 -1
  8. package/lib/attachments/AttachmentService.d.ts +3 -3
  9. package/lib/attachments/AttachmentService.js +4 -3
  10. package/lib/attachments/AttachmentService.js.map +1 -1
  11. package/lib/attachments/LocalStorageAdapter.d.ts +14 -8
  12. package/lib/attachments/LocalStorageAdapter.js +3 -0
  13. package/lib/attachments/LocalStorageAdapter.js.map +1 -1
  14. package/lib/attachments/RemoteStorageAdapter.d.ts +4 -4
  15. package/lib/attachments/Schema.d.ts +14 -6
  16. package/lib/attachments/Schema.js +8 -3
  17. package/lib/attachments/Schema.js.map +1 -1
  18. package/lib/attachments/SyncingService.d.ts +2 -2
  19. package/lib/attachments/SyncingService.js +8 -3
  20. package/lib/attachments/SyncingService.js.map +1 -1
  21. package/lib/attachments/WatchedAttachmentItem.d.ts +3 -1
  22. package/lib/client/{AbstractPowerSyncDatabase.d.ts → CommonPowerSyncDatabase.d.ts} +112 -238
  23. package/lib/client/CommonPowerSyncDatabase.js +2 -0
  24. package/lib/client/CommonPowerSyncDatabase.js.map +1 -0
  25. package/lib/client/Query.d.ts +9 -0
  26. package/lib/client/SQLOpenFactory.d.ts +44 -10
  27. package/lib/client/SQLOpenFactory.js +1 -19
  28. package/lib/client/SQLOpenFactory.js.map +1 -1
  29. package/lib/client/compilableQueryWatch.d.ts +8 -2
  30. package/lib/client/compilableQueryWatch.js +4 -2
  31. package/lib/client/compilableQueryWatch.js.map +1 -1
  32. package/lib/client/connection/PowerSyncBackendConnector.d.ts +6 -3
  33. package/lib/client/connection/PowerSyncCredentials.d.ts +3 -0
  34. package/lib/client/runOnSchemaChange.d.ts +5 -2
  35. package/lib/client/runOnSchemaChange.js +3 -0
  36. package/lib/client/runOnSchemaChange.js.map +1 -1
  37. package/lib/client/sync/bucket/CrudBatch.d.ts +2 -0
  38. package/lib/client/sync/bucket/CrudBatch.js +2 -0
  39. package/lib/client/sync/bucket/CrudBatch.js.map +1 -1
  40. package/lib/client/sync/bucket/CrudEntry.d.ts +9 -31
  41. package/lib/client/sync/bucket/CrudEntry.js +2 -97
  42. package/lib/client/sync/bucket/CrudEntry.js.map +1 -1
  43. package/lib/client/sync/bucket/CrudTransaction.d.ts +3 -0
  44. package/lib/client/sync/bucket/CrudTransaction.js +3 -0
  45. package/lib/client/sync/bucket/CrudTransaction.js.map +1 -1
  46. package/lib/client/sync/options.d.ts +65 -0
  47. package/lib/client/sync/options.js +25 -0
  48. package/lib/client/sync/options.js.map +1 -0
  49. package/lib/client/sync/stream/JsonValue.d.ts +10 -0
  50. package/lib/client/sync/stream/JsonValue.js +2 -0
  51. package/lib/client/sync/stream/JsonValue.js.map +1 -0
  52. package/lib/client/sync/sync-streams.d.ts +23 -8
  53. package/lib/client/triggers/TriggerManager.d.ts +28 -56
  54. package/lib/client/triggers/TriggerManager.js +2 -1
  55. package/lib/client/triggers/TriggerManager.js.map +1 -1
  56. package/lib/client/triggers/sanitizeSQL.d.ts +4 -0
  57. package/lib/client/triggers/sanitizeSQL.js +4 -0
  58. package/lib/client/triggers/sanitizeSQL.js.map +1 -1
  59. package/lib/client/watched/GetAllQuery.d.ts +7 -3
  60. package/lib/client/watched/GetAllQuery.js +3 -1
  61. package/lib/client/watched/GetAllQuery.js.map +1 -1
  62. package/lib/client/watched/WatchedQuery.d.ts +20 -6
  63. package/lib/client/watched/WatchedQuery.js +3 -5
  64. package/lib/client/watched/WatchedQuery.js.map +1 -1
  65. package/lib/client/watched/processors/DifferentialQueryProcessor.d.ts +15 -45
  66. package/lib/client/watched/processors/DifferentialQueryProcessor.js +1 -172
  67. package/lib/client/watched/processors/DifferentialQueryProcessor.js.map +1 -1
  68. package/lib/client/watched/processors/OnChangeQueryProcessor.d.ts +4 -22
  69. package/lib/client/watched/processors/OnChangeQueryProcessor.js +1 -82
  70. package/lib/client/watched/processors/OnChangeQueryProcessor.js.map +1 -1
  71. package/lib/client/watched/processors/comparators.d.ts +8 -0
  72. package/lib/client/watched/processors/comparators.js +4 -0
  73. package/lib/client/watched/processors/comparators.js.map +1 -1
  74. package/lib/db/DBAdapter.d.ts +90 -113
  75. package/lib/db/DBAdapter.js +70 -89
  76. package/lib/db/DBAdapter.js.map +1 -1
  77. package/lib/db/QueryResult.d.ts +104 -0
  78. package/lib/db/QueryResult.js +96 -0
  79. package/lib/db/QueryResult.js.map +1 -0
  80. package/lib/db/crud/SyncProgress.d.ts +7 -14
  81. package/lib/db/crud/SyncProgress.js +1 -60
  82. package/lib/db/crud/SyncProgress.js.map +1 -1
  83. package/lib/db/crud/SyncStatus.d.ts +54 -91
  84. package/lib/db/crud/SyncStatus.js +1 -245
  85. package/lib/db/crud/SyncStatus.js.map +1 -1
  86. package/lib/db/crud/UploadQueueStatus.d.ts +3 -0
  87. package/lib/db/crud/UploadQueueStatus.js +3 -0
  88. package/lib/db/crud/UploadQueueStatus.js.map +1 -1
  89. package/lib/db/schema/Column.d.ts +22 -1
  90. package/lib/db/schema/Column.js +10 -4
  91. package/lib/db/schema/Column.js.map +1 -1
  92. package/lib/db/schema/Index.d.ts +8 -3
  93. package/lib/db/schema/Index.js +4 -1
  94. package/lib/db/schema/Index.js.map +1 -1
  95. package/lib/db/schema/IndexedColumn.d.ts +8 -3
  96. package/lib/db/schema/IndexedColumn.js +4 -1
  97. package/lib/db/schema/IndexedColumn.js.map +1 -1
  98. package/lib/db/schema/RawTable.d.ts +7 -1
  99. package/lib/db/schema/Schema.d.ts +10 -29
  100. package/lib/db/schema/Schema.js +3 -1
  101. package/lib/db/schema/Schema.js.map +1 -1
  102. package/lib/db/schema/Table.d.ts +69 -91
  103. package/lib/db/schema/Table.js +88 -87
  104. package/lib/db/schema/Table.js.map +1 -1
  105. package/lib/index.d.ts +7 -27
  106. package/lib/index.js +6 -27
  107. package/lib/index.js.map +1 -1
  108. package/lib/types/types.d.ts +6 -0
  109. package/lib/utils/BaseObserver.d.ts +12 -0
  110. package/lib/utils/BaseObserver.js +3 -0
  111. package/lib/utils/BaseObserver.js.map +1 -1
  112. package/lib/utils/Logger.d.ts +60 -22
  113. package/lib/utils/Logger.js +38 -30
  114. package/lib/utils/Logger.js.map +1 -1
  115. package/lib/utils/MetaBaseObserver.d.ts +11 -11
  116. package/lib/utils/MetaBaseObserver.js +1 -50
  117. package/lib/utils/MetaBaseObserver.js.map +1 -1
  118. package/lib/utils/mutex.d.ts +3 -45
  119. package/lib/utils/mutex.js +1 -153
  120. package/lib/utils/mutex.js.map +1 -1
  121. package/package.json +8 -42
  122. package/src/attachments/AttachmentContext.ts +15 -13
  123. package/src/attachments/AttachmentErrorHandler.ts +6 -6
  124. package/src/attachments/AttachmentQueue.ts +99 -42
  125. package/src/attachments/AttachmentService.ts +7 -6
  126. package/src/attachments/LocalStorageAdapter.ts +14 -8
  127. package/src/attachments/README.md +2 -0
  128. package/src/attachments/RemoteStorageAdapter.ts +4 -4
  129. package/src/attachments/Schema.ts +14 -6
  130. package/src/attachments/SyncingService.ts +10 -6
  131. package/src/attachments/WatchedAttachmentItem.ts +3 -1
  132. package/src/client/CommonPowerSyncDatabase.ts +540 -0
  133. package/src/client/Query.ts +9 -0
  134. package/src/client/SQLOpenFactory.ts +47 -19
  135. package/src/client/compilableQueryWatch.ts +9 -4
  136. package/src/client/connection/PowerSyncBackendConnector.ts +6 -3
  137. package/src/client/connection/PowerSyncCredentials.ts +3 -0
  138. package/src/client/runOnSchemaChange.ts +5 -2
  139. package/src/client/sync/bucket/CrudBatch.ts +2 -0
  140. package/src/client/sync/bucket/CrudEntry.ts +10 -101
  141. package/src/client/sync/bucket/CrudTransaction.ts +3 -0
  142. package/src/client/sync/options.ts +77 -0
  143. package/src/client/sync/stream/JsonValue.ts +11 -0
  144. package/src/client/sync/sync-streams.ts +23 -10
  145. package/src/client/triggers/TriggerManager.ts +29 -59
  146. package/src/client/triggers/sanitizeSQL.ts +5 -0
  147. package/src/client/watched/GetAllQuery.ts +8 -4
  148. package/src/client/watched/WatchedQuery.ts +20 -11
  149. package/src/client/watched/processors/DifferentialQueryProcessor.ts +19 -219
  150. package/src/client/watched/processors/OnChangeQueryProcessor.ts +4 -109
  151. package/src/client/watched/processors/comparators.ts +8 -0
  152. package/src/db/DBAdapter.ts +160 -175
  153. package/src/db/QueryResult.ts +195 -0
  154. package/src/db/crud/SyncProgress.ts +8 -43
  155. package/src/db/crud/SyncStatus.ts +66 -216
  156. package/src/db/crud/UploadQueueStatus.ts +3 -0
  157. package/src/db/schema/Column.ts +22 -5
  158. package/src/db/schema/Index.ts +9 -3
  159. package/src/db/schema/IndexedColumn.ts +9 -3
  160. package/src/db/schema/RawTable.ts +7 -1
  161. package/src/db/schema/Schema.ts +12 -7
  162. package/src/db/schema/Table.ts +130 -180
  163. package/src/index.ts +7 -27
  164. package/src/types/types.ts +6 -0
  165. package/src/utils/BaseObserver.ts +12 -0
  166. package/src/utils/Logger.ts +86 -31
  167. package/src/utils/MetaBaseObserver.ts +14 -60
  168. package/src/utils/mutex.ts +4 -189
  169. package/dist/bundle.cjs +0 -14781
  170. package/dist/bundle.cjs.map +0 -1
  171. package/dist/bundle.mjs +0 -14689
  172. package/dist/bundle.mjs.map +0 -1
  173. package/dist/bundle.node.cjs +0 -12258
  174. package/dist/bundle.node.cjs.map +0 -1
  175. package/dist/bundle.node.mjs +0 -12166
  176. package/dist/bundle.node.mjs.map +0 -1
  177. package/dist/index.d.cts +0 -4391
  178. package/lib/client/AbstractPowerSyncDatabase.js +0 -987
  179. package/lib/client/AbstractPowerSyncDatabase.js.map +0 -1
  180. package/lib/client/AbstractPowerSyncOpenFactory.d.ts +0 -22
  181. package/lib/client/AbstractPowerSyncOpenFactory.js +0 -25
  182. package/lib/client/AbstractPowerSyncOpenFactory.js.map +0 -1
  183. package/lib/client/ConnectionManager.d.ts +0 -112
  184. package/lib/client/ConnectionManager.js +0 -294
  185. package/lib/client/ConnectionManager.js.map +0 -1
  186. package/lib/client/CustomQuery.d.ts +0 -22
  187. package/lib/client/CustomQuery.js +0 -43
  188. package/lib/client/CustomQuery.js.map +0 -1
  189. package/lib/client/constants.d.ts +0 -1
  190. package/lib/client/constants.js +0 -2
  191. package/lib/client/constants.js.map +0 -1
  192. package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +0 -102
  193. package/lib/client/sync/bucket/BucketStorageAdapter.js +0 -19
  194. package/lib/client/sync/bucket/BucketStorageAdapter.js.map +0 -1
  195. package/lib/client/sync/bucket/OpType.d.ts +0 -16
  196. package/lib/client/sync/bucket/OpType.js +0 -23
  197. package/lib/client/sync/bucket/OpType.js.map +0 -1
  198. package/lib/client/sync/bucket/OplogEntry.d.ts +0 -23
  199. package/lib/client/sync/bucket/OplogEntry.js +0 -36
  200. package/lib/client/sync/bucket/OplogEntry.js.map +0 -1
  201. package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +0 -61
  202. package/lib/client/sync/bucket/SqliteBucketStorage.js +0 -324
  203. package/lib/client/sync/bucket/SqliteBucketStorage.js.map +0 -1
  204. package/lib/client/sync/bucket/SyncDataBatch.d.ts +0 -6
  205. package/lib/client/sync/bucket/SyncDataBatch.js +0 -12
  206. package/lib/client/sync/bucket/SyncDataBatch.js.map +0 -1
  207. package/lib/client/sync/bucket/SyncDataBucket.d.ts +0 -40
  208. package/lib/client/sync/bucket/SyncDataBucket.js +0 -40
  209. package/lib/client/sync/bucket/SyncDataBucket.js.map +0 -1
  210. package/lib/client/sync/stream/AbstractRemote.d.ts +0 -161
  211. package/lib/client/sync/stream/AbstractRemote.js +0 -483
  212. package/lib/client/sync/stream/AbstractRemote.js.map +0 -1
  213. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +0 -244
  214. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +0 -990
  215. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +0 -1
  216. package/lib/client/sync/stream/WebsocketClientTransport.d.ts +0 -15
  217. package/lib/client/sync/stream/WebsocketClientTransport.js +0 -61
  218. package/lib/client/sync/stream/WebsocketClientTransport.js.map +0 -1
  219. package/lib/client/sync/stream/core-instruction.d.ts +0 -72
  220. package/lib/client/sync/stream/core-instruction.js +0 -27
  221. package/lib/client/sync/stream/core-instruction.js.map +0 -1
  222. package/lib/client/sync/stream/streaming-sync-types.d.ts +0 -143
  223. package/lib/client/sync/stream/streaming-sync-types.js +0 -26
  224. package/lib/client/sync/stream/streaming-sync-types.js.map +0 -1
  225. package/lib/client/triggers/MemoryTriggerClaimManager.d.ts +0 -6
  226. package/lib/client/triggers/MemoryTriggerClaimManager.js +0 -21
  227. package/lib/client/triggers/MemoryTriggerClaimManager.js.map +0 -1
  228. package/lib/client/triggers/TriggerManagerImpl.d.ts +0 -39
  229. package/lib/client/triggers/TriggerManagerImpl.js +0 -405
  230. package/lib/client/triggers/TriggerManagerImpl.js.map +0 -1
  231. package/lib/client/watched/processors/AbstractQueryProcessor.d.ts +0 -68
  232. package/lib/client/watched/processors/AbstractQueryProcessor.js +0 -151
  233. package/lib/client/watched/processors/AbstractQueryProcessor.js.map +0 -1
  234. package/lib/db/ConnectionClosedError.d.ts +0 -10
  235. package/lib/db/ConnectionClosedError.js +0 -21
  236. package/lib/db/ConnectionClosedError.js.map +0 -1
  237. package/lib/db/schema/TableV2.d.ts +0 -9
  238. package/lib/db/schema/TableV2.js +0 -9
  239. package/lib/db/schema/TableV2.js.map +0 -1
  240. package/lib/utils/AbortOperation.d.ts +0 -9
  241. package/lib/utils/AbortOperation.js +0 -19
  242. package/lib/utils/AbortOperation.js.map +0 -1
  243. package/lib/utils/ControlledExecutor.d.ts +0 -25
  244. package/lib/utils/ControlledExecutor.js +0 -51
  245. package/lib/utils/ControlledExecutor.js.map +0 -1
  246. package/lib/utils/async.d.ts +0 -14
  247. package/lib/utils/async.js +0 -46
  248. package/lib/utils/async.js.map +0 -1
  249. package/lib/utils/parseQuery.d.ts +0 -6
  250. package/lib/utils/parseQuery.js +0 -17
  251. package/lib/utils/parseQuery.js.map +0 -1
  252. package/lib/utils/queue.d.ts +0 -16
  253. package/lib/utils/queue.js +0 -42
  254. package/lib/utils/queue.js.map +0 -1
  255. package/lib/utils/stream_transform.d.ts +0 -39
  256. package/lib/utils/stream_transform.js +0 -206
  257. package/lib/utils/stream_transform.js.map +0 -1
  258. package/src/client/AbstractPowerSyncDatabase.ts +0 -1362
  259. package/src/client/AbstractPowerSyncOpenFactory.ts +0 -39
  260. package/src/client/ConnectionManager.ts +0 -402
  261. package/src/client/CustomQuery.ts +0 -56
  262. package/src/client/constants.ts +0 -1
  263. package/src/client/sync/bucket/BucketStorageAdapter.ts +0 -118
  264. package/src/client/sync/bucket/OpType.ts +0 -23
  265. package/src/client/sync/bucket/OplogEntry.ts +0 -50
  266. package/src/client/sync/bucket/SqliteBucketStorage.ts +0 -395
  267. package/src/client/sync/bucket/SyncDataBatch.ts +0 -11
  268. package/src/client/sync/bucket/SyncDataBucket.ts +0 -49
  269. package/src/client/sync/stream/AbstractRemote.ts +0 -624
  270. package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +0 -1285
  271. package/src/client/sync/stream/WebsocketClientTransport.ts +0 -80
  272. package/src/client/sync/stream/core-instruction.ts +0 -99
  273. package/src/client/sync/stream/streaming-sync-types.ts +0 -210
  274. package/src/client/triggers/MemoryTriggerClaimManager.ts +0 -25
  275. package/src/client/triggers/TriggerManagerImpl.ts +0 -496
  276. package/src/client/watched/processors/AbstractQueryProcessor.ts +0 -226
  277. package/src/db/ConnectionClosedError.ts +0 -23
  278. package/src/db/schema/TableV2.ts +0 -9
  279. package/src/utils/AbortOperation.ts +0 -17
  280. package/src/utils/ControlledExecutor.ts +0 -72
  281. package/src/utils/async.ts +0 -50
  282. package/src/utils/parseQuery.ts +0 -25
  283. package/src/utils/queue.ts +0 -48
  284. package/src/utils/stream_transform.ts +0 -252
@@ -1,72 +1,58 @@
1
- import { ILogger } from 'js-logger';
2
- import { DBAdapter, QueryResult, Transaction } from '../db/DBAdapter.js';
1
+ import { DBAdapter, DBGetUtils, LockContext, SqlExecutor, Transaction } from '../db/DBAdapter.js';
3
2
  import { SyncStatus } from '../db/crud/SyncStatus.js';
4
- import { UploadQueueStats } from '../db/crud/UploadQueueStatus.js';
5
3
  import { Schema } from '../db/schema/Schema.js';
6
- import { BaseObserver } from '../utils/BaseObserver.js';
7
- import { ConnectionManager, CreateSyncImplementationOptions } from './ConnectionManager.js';
8
- import { ArrayQueryDefinition, Query } from './Query.js';
9
- import { SQLOpenFactory, SQLOpenOptions } from './SQLOpenFactory.js';
4
+ import { BaseListener, BaseObserverInterface } from '../utils/BaseObserver.js';
5
+ import { WatchedQueryComparator } from './watched/processors/comparators.js';
6
+ import { PowerSyncLogger } from '../utils/Logger.js';
7
+ import { DatabaseSource } from './SQLOpenFactory.js';
8
+ import { TriggerManager } from './triggers/TriggerManager.js';
10
9
  import { PowerSyncBackendConnector } from './connection/PowerSyncBackendConnector.js';
11
- import { BucketStorageAdapter } from './sync/bucket/BucketStorageAdapter.js';
10
+ import { SyncOptions } from './sync/options.js';
11
+ import { SyncStream } from './sync/sync-streams.js';
12
+ import { UploadQueueStats } from '../db/crud/UploadQueueStatus.js';
12
13
  import { CrudBatch } from './sync/bucket/CrudBatch.js';
13
14
  import { CrudTransaction } from './sync/bucket/CrudTransaction.js';
14
- import { InternalConnectionOptions, StreamingSyncImplementation, StreamingSyncImplementationListener, type AdditionalConnectionOptions, type PowerSyncConnectionOptions, type RequiredAdditionalConnectionOptions } from './sync/stream/AbstractStreamingSyncImplementation.js';
15
- import { SyncStream } from './sync/sync-streams.js';
16
- import { TriggerManager, TriggerManagerConfig } from './triggers/TriggerManager.js';
17
- import { TriggerManagerImpl } from './triggers/TriggerManagerImpl.js';
15
+ import { ArrayQueryDefinition, Query } from './Query.js';
18
16
  import { WatchCompatibleQuery } from './watched/WatchedQuery.js';
19
- import { WatchedQueryComparator } from './watched/processors/comparators.js';
20
17
  import { Mutex } from '../utils/mutex.js';
18
+ import { QueryResult } from '../db/QueryResult.js';
19
+ /**
20
+ * @public
21
+ */
21
22
  export interface DisconnectAndClearOptions {
22
23
  /** When set to false, data in local-only tables is preserved. */
23
24
  clearLocal?: boolean;
24
25
  }
25
- export interface BasePowerSyncDatabaseOptions extends AdditionalConnectionOptions {
26
+ /**
27
+ * Options required regardless of how a PowerSync database is opened.
28
+ *
29
+ * @public
30
+ */
31
+ export interface BasePowerSyncDatabaseOptions {
26
32
  /** Schema used for the local database. */
27
33
  schema: Schema;
28
- /**
29
- * @deprecated Use {@link retryDelayMs} instead as this will be removed in future releases.
30
- */
31
- retryDelay?: number;
32
- logger?: ILogger;
33
- }
34
- export interface PowerSyncDatabaseOptions extends BasePowerSyncDatabaseOptions {
35
- /**
36
- * Source for a SQLite database connection.
37
- * This can be either:
38
- * - A {@link DBAdapter} if providing an instantiated SQLite connection
39
- * - A {@link SQLOpenFactory} which will be used to open a SQLite connection
40
- * - {@link SQLOpenOptions} for opening a SQLite connection with a default {@link SQLOpenFactory}
41
- */
42
- database: DBAdapter | SQLOpenFactory | SQLOpenOptions;
43
- }
44
- export interface PowerSyncDatabaseOptionsWithDBAdapter extends BasePowerSyncDatabaseOptions {
45
- database: DBAdapter;
46
- }
47
- export interface PowerSyncDatabaseOptionsWithOpenFactory extends BasePowerSyncDatabaseOptions {
48
- database: SQLOpenFactory;
49
- }
50
- export interface PowerSyncDatabaseOptionsWithSettings extends BasePowerSyncDatabaseOptions {
51
- database: SQLOpenOptions;
34
+ logger?: PowerSyncLogger;
52
35
  }
36
+ /**
37
+ * @public
38
+ */
39
+ export type PowerSyncDatabaseOptions = BasePowerSyncDatabaseOptions & DatabaseSource;
40
+ /**
41
+ * @public
42
+ */
53
43
  export interface SQLOnChangeOptions {
54
44
  signal?: AbortSignal;
55
45
  tables?: string[];
56
46
  /** The minimum interval between queries. */
57
47
  throttleMs?: number;
58
- /**
59
- * @deprecated All tables specified in {@link tables} will be watched, including PowerSync tables with prefixes.
60
- *
61
- * Allows for watching any SQL table
62
- * by not removing PowerSync table name prefixes
63
- */
64
- rawTableNames?: boolean;
65
48
  /**
66
49
  * Emits an empty result set immediately
67
50
  */
68
51
  triggerImmediate?: boolean;
69
52
  }
53
+ /**
54
+ * @public
55
+ */
70
56
  export interface SQLWatchOptions extends SQLOnChangeOptions {
71
57
  /**
72
58
  * Optional comparator which will be used to compare the results of the query.
@@ -74,23 +60,38 @@ export interface SQLWatchOptions extends SQLOnChangeOptions {
74
60
  */
75
61
  comparator?: WatchedQueryComparator<QueryResult>;
76
62
  }
63
+ /**
64
+ * @public
65
+ */
77
66
  export interface WatchOnChangeEvent {
78
67
  changedTables: string[];
79
68
  }
69
+ /**
70
+ * @public
71
+ */
80
72
  export interface WatchHandler {
81
73
  onResult: (results: QueryResult) => void;
82
74
  onError?: (error: Error) => void;
83
75
  }
76
+ /**
77
+ * @public
78
+ */
84
79
  export interface WatchOnChangeHandler {
85
80
  onChange: (event: WatchOnChangeEvent) => Promise<void> | void;
86
- onError?: (error: Error) => void;
87
81
  }
88
- export interface PowerSyncDBListener extends StreamingSyncImplementationListener {
82
+ /**
83
+ * @public
84
+ */
85
+ export interface PowerSyncDBListener extends BaseListener {
89
86
  initialized: () => void;
90
87
  schemaChanged: (schema: Schema) => void;
88
+ statusChanged?: (status: SyncStatus) => void;
91
89
  closing: () => Promise<void> | void;
92
90
  closed: () => Promise<void> | void;
93
91
  }
92
+ /**
93
+ * @public
94
+ */
94
95
  export interface PowerSyncCloseOptions {
95
96
  /**
96
97
  * Disconnect the sync stream client if connected.
@@ -99,76 +100,45 @@ export interface PowerSyncCloseOptions {
99
100
  */
100
101
  disconnect?: boolean;
101
102
  }
102
- export declare const DEFAULT_POWERSYNC_CLOSE_OPTIONS: PowerSyncCloseOptions;
103
- export declare const DEFAULT_POWERSYNC_DB_OPTIONS: {
104
- retryDelayMs: number;
105
- crudUploadThrottleMs: number;
106
- };
107
- export declare const DEFAULT_CRUD_BATCH_LIMIT = 100;
108
103
  /**
109
- * Requesting nested or recursive locks can block the application in some circumstances.
110
- * This default lock timeout will act as a failsafe to throw an error if a lock cannot
111
- * be obtained.
104
+ * @public
112
105
  */
113
- export declare const DEFAULT_LOCK_TIMEOUT_MS = 120000;
106
+ export interface PowerSyncDatabaseConstructor<Options> {
107
+ new (options: Options): CommonPowerSyncDatabase;
108
+ }
114
109
  /**
115
- * Tests if the input is a {@link PowerSyncDatabaseOptionsWithSettings}
116
- * @internal
110
+ * @public
111
+ * @deprecated Use {@link CommonPowerSyncDatabase} instead.
117
112
  */
118
- export declare const isPowerSyncDatabaseOptionsWithSettings: (test: any) => test is PowerSyncDatabaseOptionsWithSettings;
119
- export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDBListener> {
120
- protected options: PowerSyncDatabaseOptions;
113
+ export type AbstractPowerSyncDatabase = CommonPowerSyncDatabase;
114
+ /**
115
+ * @public
116
+ */
117
+ export interface CommonPowerSyncDatabase extends BaseObserverInterface<PowerSyncDBListener>, SqlExecutor, DBGetUtils {
121
118
  /**
122
119
  * Returns true if the connection is closed.
123
120
  */
124
- closed: boolean;
125
- ready: boolean;
121
+ readonly closed: boolean;
122
+ readonly ready: boolean;
126
123
  /**
127
124
  * Current connection status.
128
125
  */
129
- currentStatus: SyncStatus;
130
- sdkVersion: string;
131
- protected bucketStorageAdapter: BucketStorageAdapter;
132
- protected _isReadyPromise: Promise<void>;
133
- protected connectionManager: ConnectionManager;
134
- private subscriptions;
135
- get syncStreamImplementation(): StreamingSyncImplementation | null;
136
- /**
137
- * The connector used to connect to the PowerSync service.
138
- *
139
- * @returns The connector used to connect to the PowerSync service or null if `connect()` has not been called.
140
- */
141
- get connector(): PowerSyncBackendConnector | null;
126
+ readonly currentStatus: SyncStatus;
127
+ readonly sdkVersion: string;
142
128
  /**
143
- * The resolved connection options used to connect to the PowerSync service.
144
- *
145
- * @returns The resolved connection options used to connect to the PowerSync service or null if `connect()` has not been called.
146
- */
147
- get connectionOptions(): InternalConnectionOptions | null;
148
- protected _schema: Schema;
149
- private _database;
150
- protected runExclusiveMutex: Mutex;
151
- /**
152
- * @experimental
129
+ * @experimental @alpha
153
130
  * Allows creating SQLite triggers which can be used to track various operations on SQLite tables.
154
131
  */
155
132
  readonly triggers: TriggerManager;
156
- protected triggersImpl: TriggerManagerImpl;
157
- logger: ILogger;
158
- constructor(options: PowerSyncDatabaseOptionsWithDBAdapter);
159
- constructor(options: PowerSyncDatabaseOptionsWithOpenFactory);
160
- constructor(options: PowerSyncDatabaseOptionsWithSettings);
161
- constructor(options: PowerSyncDatabaseOptions);
133
+ readonly logger: PowerSyncLogger;
162
134
  /**
163
135
  * Schema used for the local database.
164
136
  */
165
- get schema(): Schema<{
166
- [x: string]: import("../index.js").Table<any>;
167
- }>;
137
+ readonly schema: Schema;
168
138
  /**
169
139
  * The underlying database.
170
140
  *
171
- * For the most part, behavior is the same whether querying on the underlying database, or on {@link AbstractPowerSyncDatabase}.
141
+ * For the most part, behavior is the same whether querying on the underlying database, or on {@link CommonPowerSyncDatabase}.
172
142
  */
173
143
  get database(): DBAdapter;
174
144
  /**
@@ -176,17 +146,6 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
176
146
  */
177
147
  get connected(): boolean;
178
148
  get connecting(): boolean;
179
- /**
180
- * Opens the DBAdapter given open options using a default open factory
181
- */
182
- protected abstract openDBAdapter(options: PowerSyncDatabaseOptionsWithSettings): DBAdapter;
183
- /**
184
- * Generates a base configuration for {@link TriggerManagerImpl}.
185
- * Implementations should override this if necessary.
186
- */
187
- protected generateTriggerManagerConfig(): TriggerManagerConfig;
188
- protected abstract generateSyncStreamImplementation(connector: PowerSyncBackendConnector, options: CreateSyncImplementationOptions & RequiredAdditionalConnectionOptions): StreamingSyncImplementation;
189
- protected abstract generateBucketStorageAdapter(): BucketStorageAdapter;
190
149
  /**
191
150
  * @returns A promise which will resolve once initialization is completed.
192
151
  */
@@ -194,7 +153,7 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
194
153
  /**
195
154
  * Wait for the first sync operation to complete.
196
155
  *
197
- * @param request Either an abort signal (after which the promise will complete regardless of
156
+ * @param request - Either an abort signal (after which the promise will complete regardless of
198
157
  * whether a full sync was completed) or an object providing an abort signal and a priority target.
199
158
  * When a priority target is set, the promise may complete when all buckets with the given (or higher)
200
159
  * priorities have been synchronized. This can be earlier than a complete sync.
@@ -208,22 +167,10 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
208
167
  * Waits for the first sync status for which the `status` callback returns a truthy value.
209
168
  */
210
169
  waitForStatus(predicate: (status: SyncStatus) => any, signal?: AbortSignal): Promise<void>;
211
- /**
212
- * Allows for extended implementations to execute custom initialization
213
- * logic as part of the total init process
214
- */
215
- abstract _initialize(): Promise<void>;
216
- /**
217
- * Entry point for executing initialization logic.
218
- * This is to be automatically executed in the constructor.
219
- */
220
- protected initialize(): Promise<void>;
221
- protected loadVersion(): Promise<void>;
222
- protected resolveOfflineSyncStatus(): Promise<void>;
223
170
  /**
224
171
  * Replace the schema with a new version. This is for advanced use cases - typically the schema should just be specified once in the constructor.
225
172
  *
226
- * Cannot be used while connected - this should only be called before {@link AbstractPowerSyncDatabase.connect}.
173
+ * Cannot be used while connected - this should only be called before {@link CommonPowerSyncDatabase.connect}.
227
174
  */
228
175
  updateSchema(schema: Schema): Promise<void>;
229
176
  /**
@@ -231,25 +178,14 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
231
178
  * While initializing is automatic, this helps to catch and report initialization errors.
232
179
  */
233
180
  init(): Promise<void>;
234
- protected resolvedConnectionOptions(options: CreateSyncImplementationOptions): CreateSyncImplementationOptions & RequiredAdditionalConnectionOptions;
235
- /**
236
- * @deprecated Use {@link AbstractPowerSyncDatabase#close} instead.
237
- * Clears all listeners registered by {@link AbstractPowerSyncDatabase#registerListener}.
238
- */
239
- dispose(): void;
240
- /**
241
- * Locking mechanism for exclusively running critical portions of connect/disconnect operations.
242
- * Locking here is mostly only important on web for multiple tab scenarios.
243
- */
244
- protected runExclusive<T>(callback: () => Promise<T>): Promise<T>;
245
181
  /**
246
182
  * Connects to stream of events from the PowerSync instance.
247
183
  */
248
- connect(connector: PowerSyncBackendConnector, options?: PowerSyncConnectionOptions): Promise<void>;
184
+ connect(connector: PowerSyncBackendConnector, options?: SyncOptions): Promise<void>;
249
185
  /**
250
186
  * Close the sync connection.
251
187
  *
252
- * Use {@link connect} to connect again.
188
+ * Use {@link CommonPowerSyncDatabase.connect} to connect again.
253
189
  */
254
190
  disconnect(): Promise<void>;
255
191
  /**
@@ -264,10 +200,9 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
264
200
  /**
265
201
  * Create a sync stream to query its status or to subscribe to it.
266
202
  *
267
- * @param name The name of the stream to subscribe to.
268
- * @param params Optional parameters for the stream subscription.
203
+ * @param name - The name of the stream to subscribe to.
204
+ * @param params - Optional parameters for the stream subscription.
269
205
  * @returns A {@link SyncStream} instance that can be subscribed to.
270
- * @experimental Sync streams are currently in alpha.
271
206
  */
272
207
  syncStream(name: string, params?: Record<string, any>): SyncStream;
273
208
  /**
@@ -293,14 +228,14 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
293
228
  * Once the data have been successfully uploaded, call {@link CrudBatch.complete} before
294
229
  * requesting the next batch.
295
230
  *
296
- * Use {@link limit} to specify the maximum number of updates to return in a single
231
+ * Use the `limit` parameter to specify the maximum number of updates to return in a single
297
232
  * batch.
298
233
  *
299
234
  * This method does include transaction ids in the result, but does not group
300
235
  * data by transaction. One batch may contain data from multiple transactions,
301
236
  * and a single transaction may be split over multiple batches.
302
237
  *
303
- * @param limit Maximum number of CRUD entries to include in the batch
238
+ * @param limit - Maximum number of CRUD entries to include in the batch
304
239
  * @returns A batch of CRUD operations to upload, or null if there are none
305
240
  */
306
241
  getCrudBatch(limit?: number): Promise<CrudBatch | null>;
@@ -314,7 +249,7 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
314
249
  * Once the data have been successfully uploaded, call {@link CrudTransaction.complete} before
315
250
  * requesting the next transaction.
316
251
  *
317
- * Unlike {@link getCrudBatch}, this only returns data from a single transaction at a time.
252
+ * Unlike {@link CommonPowerSyncDatabase.getCrudBatch}, this only returns data from a single transaction at a time.
318
253
  * All data for the transaction is loaded into memory.
319
254
  *
320
255
  * @returns A transaction of CRUD operations to upload, or null if there are none
@@ -326,7 +261,7 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
326
261
  * This is typically used from the {@link PowerSyncBackendConnector.uploadData} callback. Each entry emitted by the
327
262
  * returned iterator is a full transaction containing all local writes made while that transaction was active.
328
263
  *
329
- * Unlike {@link getNextCrudTransaction}, which always returns the oldest transaction that hasn't been
264
+ * Unlike {@link CommonPowerSyncDatabase.getNextCrudTransaction}, which always returns the oldest transaction that hasn't been
330
265
  * {@link CrudTransaction.complete}d yet, this iterator can be used to receive multiple transactions. Calling
331
266
  * {@link CrudTransaction.complete} will mark that and all prior transactions emitted by the iterator as completed.
332
267
  *
@@ -360,82 +295,23 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
360
295
  * @returns A unique identifier for the database instance
361
296
  */
362
297
  getClientId(): Promise<string>;
363
- private handleCrudCheckpoint;
364
- /**
365
- * Execute a SQL write (INSERT/UPDATE/DELETE) query
366
- * and optionally return results.
367
- *
368
- * When using the default client-side [JSON-based view system](https://docs.powersync.com/architecture/client-architecture#client-side-schema-and-sqlite-database-structure),
369
- * the returned result's `rowsAffected` may be `0` for successful `UPDATE` and `DELETE` statements.
370
- * Use a `RETURNING` clause and inspect `result.rows` when you need to confirm which rows changed.
371
- *
372
- * @param sql The SQL query to execute
373
- * @param parameters Optional array of parameters to bind to the query
374
- * @returns The query result as an object with structured key-value pairs
375
- */
376
- execute(sql: string, parameters?: any[]): Promise<QueryResult>;
377
- /**
378
- * Execute a SQL write (INSERT/UPDATE/DELETE) query directly on the database without any PowerSync processing.
379
- * This bypasses certain PowerSync abstractions and is useful for accessing the raw database results.
380
- *
381
- * @param sql The SQL query to execute
382
- * @param parameters Optional array of parameters to bind to the query
383
- * @returns The raw query result from the underlying database as a nested array of raw values, where each row is
384
- * represented as an array of column values without field names.
385
- */
386
- executeRaw(sql: string, parameters?: any[]): Promise<any[][]>;
387
- /**
388
- * Execute a write query (INSERT/UPDATE/DELETE) multiple times with each parameter set
389
- * and optionally return results.
390
- * This is faster than executing separately with each parameter set.
391
- *
392
- * @param sql The SQL query to execute
393
- * @param parameters Optional 2D array of parameter sets, where each inner array is a set of parameters for one execution
394
- * @returns The query result
395
- */
396
- executeBatch(sql: string, parameters?: any[][]): Promise<QueryResult>;
397
- /**
398
- * Execute a read-only query and return results.
399
- *
400
- * @param sql The SQL query to execute
401
- * @param parameters Optional array of parameters to bind to the query
402
- * @returns An array of results
403
- */
404
- getAll<T>(sql: string, parameters?: any[]): Promise<T[]>;
405
- /**
406
- * Execute a read-only query and return the first result, or null if the ResultSet is empty.
407
- *
408
- * @param sql The SQL query to execute
409
- * @param parameters Optional array of parameters to bind to the query
410
- * @returns The first result if found, or null if no results are returned
411
- */
412
- getOptional<T>(sql: string, parameters?: any[]): Promise<T | null>;
413
- /**
414
- * Execute a read-only query and return the first result, error if the ResultSet is empty.
415
- *
416
- * @param sql The SQL query to execute
417
- * @param parameters Optional array of parameters to bind to the query
418
- * @returns The first result matching the query
419
- * @throws Error if no rows are returned
420
- */
421
- get<T>(sql: string, parameters?: any[]): Promise<T>;
422
298
  /**
423
299
  * Takes a read lock, without starting a transaction.
424
- * In most cases, {@link readTransaction} should be used instead.
300
+ * In most cases, {@link CommonPowerSyncDatabase.readTransaction} should be used instead.
425
301
  */
426
- readLock<T>(callback: (db: DBAdapter) => Promise<T>): Promise<T>;
302
+ readLock<T>(callback: (db: LockContext) => Promise<T>): Promise<T>;
427
303
  /**
428
304
  * Takes a global lock, without starting a transaction.
429
- * In most cases, {@link writeTransaction} should be used instead.
305
+ * In most cases, {@link CommonPowerSyncDatabase.writeTransaction} should be used instead.
430
306
  */
431
- writeLock<T>(callback: (db: DBAdapter) => Promise<T>): Promise<T>;
307
+ writeLock<T>(callback: (db: LockContext) => Promise<T>): Promise<T>;
432
308
  /**
433
309
  * Open a read-only transaction.
434
310
  * Read transactions can run concurrently to a write transaction.
435
311
  * Changes from any write transaction are not visible to read transactions started before it.
436
312
  *
437
- * @param callback Function to execute within the transaction
438
- * @param lockTimeout Time in milliseconds to wait for a lock before throwing an error
313
+ * @param callback - Function to execute within the transaction
314
+ * @param lockTimeout - Time in milliseconds to wait for a lock before throwing an error
439
315
  * @returns The result of the callback
440
316
  * @throws Error if the lock cannot be obtained within the timeout period
441
317
  */
@@ -445,15 +321,15 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
445
321
  * This takes a global lock - only one write transaction can execute against the database at a time.
446
322
  * Statements within the transaction must be done on the provided {@link Transaction} interface.
447
323
  *
448
- * @param callback Function to execute within the transaction
449
- * @param lockTimeout Time in milliseconds to wait for a lock before throwing an error
324
+ * @param callback - Function to execute within the transaction
325
+ * @param lockTimeout - Time in milliseconds to wait for a lock before throwing an error
450
326
  * @returns The result of the callback
451
327
  * @throws Error if the lock cannot be obtained within the timeout period
452
328
  */
453
329
  writeTransaction<T>(callback: (tx: Transaction) => Promise<T>, lockTimeout?: number): Promise<T>;
454
330
  /**
455
- * This version of `watch` uses {@link AsyncGenerator}, for documentation see {@link watchWithAsyncGenerator}.
456
- * Can be overloaded to use a callback handler instead, for documentation see {@link watchWithCallback}.
331
+ * This version of `watch` uses `AsyncGenerator`, for documentation see {@link CommonPowerSyncDatabase.watchWithAsyncGenerator}.
332
+ * Can be overloaded to use a callback handler instead, for documentation see {@link CommonPowerSyncDatabase.watchWithCallback}.
457
333
  *
458
334
  * @example
459
335
  * ```javascript
@@ -469,7 +345,7 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
469
345
  */
470
346
  watch(sql: string, parameters?: any[], options?: SQLWatchOptions): AsyncIterable<QueryResult>;
471
347
  /**
472
- * See {@link watchWithCallback}.
348
+ * See {@link CommonPowerSyncDatabase.watchWithCallback}.
473
349
  *
474
350
  * @example
475
351
  * ```javascript
@@ -487,7 +363,7 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
487
363
  watch(sql: string, parameters?: any[], handler?: WatchHandler, options?: SQLWatchOptions): void;
488
364
  /**
489
365
  * Allows defining a query which can be used to build a {@link WatchedQuery}.
490
- * The defined query will be executed with {@link AbstractPowerSyncDatabase#getAll}.
366
+ * The defined query will be executed with {@link CommonPowerSyncDatabase#getAll}.
491
367
  * An optional mapper function can be provided to transform the results.
492
368
  *
493
369
  * @example
@@ -523,25 +399,25 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
523
399
  customQuery<RowType>(query: WatchCompatibleQuery<RowType[]>): Query<RowType>;
524
400
  /**
525
401
  * Execute a read query every time the source tables are modified.
526
- * Use {@link SQLWatchOptions.throttleMs} to specify the minimum interval between queries.
402
+ * Use {@link SQLOnChangeOptions.throttleMs} to specify the minimum interval between queries.
527
403
  * Source tables are automatically detected using `EXPLAIN QUERY PLAN`.
528
404
  *
529
405
  * Note that the `onChange` callback member of the handler is required.
530
406
  *
531
- * @param sql The SQL query to execute
532
- * @param parameters Optional array of parameters to bind to the query
533
- * @param handler Callbacks for handling results and errors
534
- * @param options Options for configuring watch behavior
407
+ * @param sql - The SQL query to execute
408
+ * @param parameters - Optional array of parameters to bind to the query
409
+ * @param handler - Callbacks for handling results and errors
410
+ * @param options - Options for configuring watch behavior
535
411
  */
536
412
  watchWithCallback(sql: string, parameters?: any[], handler?: WatchHandler, options?: SQLWatchOptions): void;
537
413
  /**
538
414
  * Execute a read query every time the source tables are modified.
539
- * Use {@link SQLWatchOptions.throttleMs} to specify the minimum interval between queries.
415
+ * Use {@link SQLOnChangeOptions.throttleMs} to specify the minimum interval between queries.
540
416
  * Source tables are automatically detected using `EXPLAIN QUERY PLAN`.
541
417
  *
542
- * @param sql The SQL query to execute
543
- * @param parameters Optional array of parameters to bind to the query
544
- * @param options Options for configuring watch behavior
418
+ * @param sql - The SQL query to execute
419
+ * @param parameters - Optional array of parameters to bind to the query
420
+ * @param options - Options for configuring watch behavior
545
421
  * @returns An AsyncIterable that yields QueryResults whenever the data changes
546
422
  */
547
423
  watchWithAsyncGenerator(sql: string, parameters?: any[], options?: SQLWatchOptions): AsyncIterable<QueryResult>;
@@ -550,15 +426,15 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
550
426
  * If tables are specified in the options, those are used directly.
551
427
  * Otherwise, analyzes the query using EXPLAIN to determine which tables are accessed.
552
428
  *
553
- * @param sql The SQL query to analyze
554
- * @param parameters Optional parameters for the SQL query
555
- * @param options Optional watch options that may contain explicit table list
429
+ * @param sql - The SQL query to analyze
430
+ * @param parameters - Optional parameters for the SQL query
431
+ * @param options - Optional watch options that may contain explicit table list
556
432
  * @returns Array of table names that the query depends on
557
433
  */
558
434
  resolveTables(sql: string, parameters?: any[], options?: SQLWatchOptions): Promise<string[]>;
559
435
  /**
560
- * This version of `onChange` uses {@link AsyncGenerator}, for documentation see {@link onChangeWithAsyncGenerator}.
561
- * Can be overloaded to use a callback handler instead, for documentation see {@link onChangeWithCallback}.
436
+ * This version of `onChange` uses `AsyncGenerator`, for documentation see {@link CommonPowerSyncDatabase.onChangeWithAsyncGenerator}.
437
+ * Can be overloaded to use a callback handler instead, for documentation see {@link CommonPowerSyncDatabase.onChangeWithCallback}.
562
438
  *
563
439
  * @example
564
440
  * ```javascript
@@ -571,7 +447,7 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
571
447
  */
572
448
  onChange(options?: SQLOnChangeOptions): AsyncIterable<WatchOnChangeEvent>;
573
449
  /**
574
- * See {@link onChangeWithCallback}.
450
+ * See {@link CommonPowerSyncDatabase.onChangeWithCallback}.
575
451
  *
576
452
  * @example
577
453
  * ```javascript
@@ -588,32 +464,30 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
588
464
  /**
589
465
  * Invoke the provided callback on any changes to any of the specified tables.
590
466
  *
591
- * This is preferred over {@link watchWithCallback} when multiple queries need to be performed
467
+ * This is preferred over {@link CommonPowerSyncDatabase.watchWithCallback} when multiple queries need to be performed
592
468
  * together when data is changed.
593
469
  *
594
470
  * Note that the `onChange` callback member of the handler is required.
595
471
  *
596
- * @param handler Callbacks for handling change events and errors
597
- * @param options Options for configuring watch behavior
472
+ * @param handler - Callbacks for handling change events and errors
473
+ * @param options - Options for configuring watch behavior
598
474
  * @returns A dispose function to stop watching for changes
599
475
  */
600
476
  onChangeWithCallback(handler?: WatchOnChangeHandler, options?: SQLOnChangeOptions): () => void;
601
477
  /**
602
478
  * Create a Stream of changes to any of the specified tables.
603
479
  *
604
- * This is preferred over {@link watchWithAsyncGenerator} when multiple queries need to be performed
605
- * together when data is changed.
480
+ * This is preferred over {@link CommonPowerSyncDatabase.watchWithAsyncGenerator} when multiple queries need to be
481
+ * performed together when data is changed.
606
482
  *
607
483
  * Note: do not declare this as `async *onChange` as it will not work in React Native.
608
484
  *
609
- * @param options Options for configuring watch behavior
485
+ * @param options - Options for configuring watch behavior
610
486
  * @returns An AsyncIterable that yields change events whenever the specified tables change
611
487
  */
612
488
  onChangeWithAsyncGenerator(options?: SQLWatchOptions): AsyncIterable<WatchOnChangeEvent>;
613
- private handleTableChanges;
614
- private processTableUpdates;
615
489
  /**
616
- * @ignore
490
+ * @internal
617
491
  */
618
- private executeReadOnly;
492
+ createMutex(): Mutex;
619
493
  }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=CommonPowerSyncDatabase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommonPowerSyncDatabase.js","sourceRoot":"","sources":["../../src/client/CommonPowerSyncDatabase.ts"],"names":[],"mappings":""}
@@ -4,11 +4,15 @@ import { StandardWatchedQuery } from './watched/processors/OnChangeQueryProcesso
4
4
  import { WatchedQueryOptions } from './watched/WatchedQuery.js';
5
5
  /**
6
6
  * Query parameters for {@link ArrayQueryDefinition#parameters}
7
+ *
8
+ * @public
7
9
  */
8
10
  export type QueryParam = string | number | boolean | null | undefined | bigint | Uint8Array;
9
11
  /**
10
12
  * Options for building a query with {@link AbstractPowerSyncDatabase#query}.
11
13
  * This query will be executed with {@link AbstractPowerSyncDatabase#getAll}.
14
+ *
15
+ * @public
12
16
  */
13
17
  export interface ArrayQueryDefinition<RowType = unknown> {
14
18
  sql: string;
@@ -27,6 +31,8 @@ export interface ArrayQueryDefinition<RowType = unknown> {
27
31
  }
28
32
  /**
29
33
  * Options for {@link Query#watch}.
34
+ *
35
+ * @public
30
36
  */
31
37
  export interface StandardWatchedQueryOptions<RowType> extends WatchedQueryOptions {
32
38
  /**
@@ -51,6 +57,9 @@ export interface StandardWatchedQueryOptions<RowType> extends WatchedQueryOption
51
57
  */
52
58
  placeholderData?: RowType[];
53
59
  }
60
+ /**
61
+ * @public
62
+ */
54
63
  export interface Query<RowType> {
55
64
  /**
56
65
  * Creates a {@link WatchedQuery} which watches and emits results of the linked query.