@powersync/common 1.53.2 → 1.54.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 (213) hide show
  1. package/dist/bundle.cjs +548 -345
  2. package/dist/bundle.cjs.map +1 -1
  3. package/dist/bundle.mjs +548 -345
  4. package/dist/bundle.mjs.map +1 -1
  5. package/dist/bundle.node.cjs +548 -345
  6. package/dist/bundle.node.cjs.map +1 -1
  7. package/dist/bundle.node.mjs +548 -345
  8. package/dist/bundle.node.mjs.map +1 -1
  9. package/dist/index.d.cts +727 -189
  10. package/lib/attachments/AttachmentContext.d.ts +7 -6
  11. package/lib/attachments/AttachmentContext.js +2 -1
  12. package/lib/attachments/AttachmentContext.js.map +1 -1
  13. package/lib/attachments/AttachmentErrorHandler.d.ts +6 -6
  14. package/lib/attachments/AttachmentQueue.d.ts +61 -20
  15. package/lib/attachments/AttachmentQueue.js +16 -18
  16. package/lib/attachments/AttachmentQueue.js.map +1 -1
  17. package/lib/attachments/LocalStorageAdapter.d.ts +14 -8
  18. package/lib/attachments/LocalStorageAdapter.js +3 -0
  19. package/lib/attachments/LocalStorageAdapter.js.map +1 -1
  20. package/lib/attachments/RemoteStorageAdapter.d.ts +4 -4
  21. package/lib/attachments/Schema.d.ts +12 -4
  22. package/lib/attachments/Schema.js +8 -3
  23. package/lib/attachments/Schema.js.map +1 -1
  24. package/lib/attachments/WatchedAttachmentItem.d.ts +3 -1
  25. package/lib/client/AbstractPowerSyncDatabase.d.ts +110 -58
  26. package/lib/client/AbstractPowerSyncDatabase.js +59 -48
  27. package/lib/client/AbstractPowerSyncDatabase.js.map +1 -1
  28. package/lib/client/AbstractPowerSyncOpenFactory.d.ts +6 -0
  29. package/lib/client/AbstractPowerSyncOpenFactory.js +3 -0
  30. package/lib/client/AbstractPowerSyncOpenFactory.js.map +1 -1
  31. package/lib/client/ConnectionManager.d.ts +4 -1
  32. package/lib/client/ConnectionManager.js +1 -1
  33. package/lib/client/ConnectionManager.js.map +1 -1
  34. package/lib/client/Query.d.ts +9 -0
  35. package/lib/client/SQLOpenFactory.d.ts +12 -0
  36. package/lib/client/SQLOpenFactory.js +6 -0
  37. package/lib/client/SQLOpenFactory.js.map +1 -1
  38. package/lib/client/compilableQueryWatch.d.ts +6 -0
  39. package/lib/client/compilableQueryWatch.js +3 -0
  40. package/lib/client/compilableQueryWatch.js.map +1 -1
  41. package/lib/client/connection/PowerSyncBackendConnector.d.ts +3 -0
  42. package/lib/client/connection/PowerSyncCredentials.d.ts +3 -0
  43. package/lib/client/constants.d.ts +3 -0
  44. package/lib/client/constants.js +3 -0
  45. package/lib/client/constants.js.map +1 -1
  46. package/lib/client/runOnSchemaChange.d.ts +3 -0
  47. package/lib/client/runOnSchemaChange.js +3 -0
  48. package/lib/client/runOnSchemaChange.js.map +1 -1
  49. package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +12 -0
  50. package/lib/client/sync/bucket/BucketStorageAdapter.js +6 -0
  51. package/lib/client/sync/bucket/BucketStorageAdapter.js.map +1 -1
  52. package/lib/client/sync/bucket/CrudBatch.d.ts +2 -0
  53. package/lib/client/sync/bucket/CrudBatch.js +2 -0
  54. package/lib/client/sync/bucket/CrudBatch.js.map +1 -1
  55. package/lib/client/sync/bucket/CrudEntry.d.ts +9 -0
  56. package/lib/client/sync/bucket/CrudEntry.js +4 -0
  57. package/lib/client/sync/bucket/CrudEntry.js.map +1 -1
  58. package/lib/client/sync/bucket/CrudTransaction.d.ts +3 -0
  59. package/lib/client/sync/bucket/CrudTransaction.js +3 -0
  60. package/lib/client/sync/bucket/CrudTransaction.js.map +1 -1
  61. package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +3 -0
  62. package/lib/client/sync/bucket/SqliteBucketStorage.js +3 -0
  63. package/lib/client/sync/bucket/SqliteBucketStorage.js.map +1 -1
  64. package/lib/client/sync/stream/AbstractRemote.d.ts +30 -1
  65. package/lib/client/sync/stream/AbstractRemote.js +15 -1
  66. package/lib/client/sync/stream/AbstractRemote.js.map +1 -1
  67. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +55 -5
  68. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +32 -4
  69. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +1 -1
  70. package/lib/client/sync/stream/JsonValue.d.ts +3 -0
  71. package/lib/client/sync/stream/WebsocketClientTransport.js +2 -1
  72. package/lib/client/sync/stream/WebsocketClientTransport.js.map +1 -1
  73. package/lib/client/sync/sync-streams.d.ts +22 -7
  74. package/lib/client/triggers/TriggerManager.d.ts +19 -18
  75. package/lib/client/triggers/TriggerManager.js +2 -1
  76. package/lib/client/triggers/TriggerManager.js.map +1 -1
  77. package/lib/client/triggers/TriggerManagerImpl.d.ts +1 -1
  78. package/lib/client/triggers/TriggerManagerImpl.js +3 -3
  79. package/lib/client/triggers/TriggerManagerImpl.js.map +1 -1
  80. package/lib/client/triggers/sanitizeSQL.d.ts +4 -0
  81. package/lib/client/triggers/sanitizeSQL.js +4 -0
  82. package/lib/client/triggers/sanitizeSQL.js.map +1 -1
  83. package/lib/client/watched/GetAllQuery.d.ts +4 -0
  84. package/lib/client/watched/GetAllQuery.js +2 -0
  85. package/lib/client/watched/GetAllQuery.js.map +1 -1
  86. package/lib/client/watched/WatchedQuery.d.ts +24 -2
  87. package/lib/client/watched/WatchedQuery.js +9 -0
  88. package/lib/client/watched/WatchedQuery.js.map +1 -1
  89. package/lib/client/watched/processors/AbstractQueryProcessor.d.ts +1 -1
  90. package/lib/client/watched/processors/AbstractQueryProcessor.js.map +1 -1
  91. package/lib/client/watched/processors/DifferentialQueryProcessor.d.ts +20 -0
  92. package/lib/client/watched/processors/DifferentialQueryProcessor.js +4 -0
  93. package/lib/client/watched/processors/DifferentialQueryProcessor.js.map +1 -1
  94. package/lib/client/watched/processors/OnChangeQueryProcessor.d.ts +4 -0
  95. package/lib/client/watched/processors/OnChangeQueryProcessor.js.map +1 -1
  96. package/lib/client/watched/processors/comparators.d.ts +8 -0
  97. package/lib/client/watched/processors/comparators.js +4 -0
  98. package/lib/client/watched/processors/comparators.js.map +1 -1
  99. package/lib/db/ConnectionClosedError.d.ts +2 -0
  100. package/lib/db/ConnectionClosedError.js +2 -0
  101. package/lib/db/ConnectionClosedError.js.map +1 -1
  102. package/lib/db/DBAdapter.d.ts +56 -6
  103. package/lib/db/DBAdapter.js +15 -3
  104. package/lib/db/DBAdapter.js.map +1 -1
  105. package/lib/db/crud/SyncProgress.d.ts +6 -1
  106. package/lib/db/crud/SyncProgress.js +2 -0
  107. package/lib/db/crud/SyncProgress.js.map +1 -1
  108. package/lib/db/crud/SyncStatus.d.ts +36 -38
  109. package/lib/db/crud/SyncStatus.js +19 -14
  110. package/lib/db/crud/SyncStatus.js.map +1 -1
  111. package/lib/db/crud/UploadQueueStatus.d.ts +3 -0
  112. package/lib/db/crud/UploadQueueStatus.js +3 -0
  113. package/lib/db/crud/UploadQueueStatus.js.map +1 -1
  114. package/lib/db/schema/Column.d.ts +28 -0
  115. package/lib/db/schema/Column.js +16 -3
  116. package/lib/db/schema/Column.js.map +1 -1
  117. package/lib/db/schema/Index.d.ts +9 -0
  118. package/lib/db/schema/Index.js +6 -0
  119. package/lib/db/schema/Index.js.map +1 -1
  120. package/lib/db/schema/IndexedColumn.d.ts +9 -0
  121. package/lib/db/schema/IndexedColumn.js +6 -0
  122. package/lib/db/schema/IndexedColumn.js.map +1 -1
  123. package/lib/db/schema/RawTable.d.ts +7 -1
  124. package/lib/db/schema/Schema.d.ts +6 -1
  125. package/lib/db/schema/Schema.js +3 -1
  126. package/lib/db/schema/Schema.js.map +1 -1
  127. package/lib/db/schema/Table.d.ts +27 -3
  128. package/lib/db/schema/Table.js +9 -0
  129. package/lib/db/schema/Table.js.map +1 -1
  130. package/lib/db/schema/TableV2.d.ts +2 -0
  131. package/lib/db/schema/TableV2.js +2 -0
  132. package/lib/db/schema/TableV2.js.map +1 -1
  133. package/lib/index.d.ts +1 -1
  134. package/lib/types/types.d.ts +6 -0
  135. package/lib/utils/AbortOperation.d.ts +2 -0
  136. package/lib/utils/AbortOperation.js +2 -0
  137. package/lib/utils/AbortOperation.js.map +1 -1
  138. package/lib/utils/BaseObserver.d.ts +12 -0
  139. package/lib/utils/BaseObserver.js +3 -0
  140. package/lib/utils/BaseObserver.js.map +1 -1
  141. package/lib/utils/ControlledExecutor.d.ts +6 -0
  142. package/lib/utils/ControlledExecutor.js +3 -0
  143. package/lib/utils/ControlledExecutor.js.map +1 -1
  144. package/lib/utils/Logger.d.ts +9 -0
  145. package/lib/utils/Logger.js +6 -0
  146. package/lib/utils/Logger.js.map +1 -1
  147. package/lib/utils/mutex.d.ts +8 -0
  148. package/lib/utils/mutex.js +3 -0
  149. package/lib/utils/mutex.js.map +1 -1
  150. package/lib/utils/parseQuery.d.ts +6 -0
  151. package/lib/utils/parseQuery.js +3 -0
  152. package/lib/utils/parseQuery.js.map +1 -1
  153. package/lib/utils/stream_transform.d.ts +3 -1
  154. package/lib/utils/stream_transform.js.map +1 -1
  155. package/package.json +3 -2
  156. package/src/attachments/AttachmentContext.ts +7 -6
  157. package/src/attachments/AttachmentErrorHandler.ts +6 -6
  158. package/src/attachments/AttachmentQueue.ts +71 -23
  159. package/src/attachments/LocalStorageAdapter.ts +14 -8
  160. package/src/attachments/README.md +2 -0
  161. package/src/attachments/RemoteStorageAdapter.ts +4 -4
  162. package/src/attachments/Schema.ts +12 -4
  163. package/src/attachments/WatchedAttachmentItem.ts +3 -1
  164. package/src/client/AbstractPowerSyncDatabase.ts +117 -62
  165. package/src/client/AbstractPowerSyncOpenFactory.ts +6 -0
  166. package/src/client/ConnectionManager.ts +4 -1
  167. package/src/client/Query.ts +9 -0
  168. package/src/client/SQLOpenFactory.ts +12 -0
  169. package/src/client/compilableQueryWatch.ts +6 -0
  170. package/src/client/connection/PowerSyncBackendConnector.ts +3 -0
  171. package/src/client/connection/PowerSyncCredentials.ts +3 -0
  172. package/src/client/constants.ts +3 -0
  173. package/src/client/runOnSchemaChange.ts +3 -0
  174. package/src/client/sync/bucket/BucketStorageAdapter.ts +12 -0
  175. package/src/client/sync/bucket/CrudBatch.ts +2 -0
  176. package/src/client/sync/bucket/CrudEntry.ts +9 -0
  177. package/src/client/sync/bucket/CrudTransaction.ts +3 -0
  178. package/src/client/sync/bucket/SqliteBucketStorage.ts +3 -0
  179. package/src/client/sync/stream/AbstractRemote.ts +30 -1
  180. package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +55 -5
  181. package/src/client/sync/stream/JsonValue.ts +3 -0
  182. package/src/client/sync/stream/WebsocketClientTransport.ts +3 -1
  183. package/src/client/sync/sync-streams.ts +22 -9
  184. package/src/client/triggers/TriggerManager.ts +19 -18
  185. package/src/client/triggers/TriggerManagerImpl.ts +5 -5
  186. package/src/client/triggers/sanitizeSQL.ts +5 -0
  187. package/src/client/watched/GetAllQuery.ts +5 -1
  188. package/src/client/watched/WatchedQuery.ts +24 -2
  189. package/src/client/watched/processors/AbstractQueryProcessor.ts +6 -6
  190. package/src/client/watched/processors/DifferentialQueryProcessor.ts +28 -5
  191. package/src/client/watched/processors/OnChangeQueryProcessor.ts +9 -3
  192. package/src/client/watched/processors/comparators.ts +8 -0
  193. package/src/db/ConnectionClosedError.ts +2 -0
  194. package/src/db/DBAdapter.ts +58 -6
  195. package/src/db/crud/SyncProgress.ts +6 -1
  196. package/src/db/crud/SyncStatus.ts +40 -21
  197. package/src/db/crud/UploadQueueStatus.ts +3 -0
  198. package/src/db/schema/Column.ts +28 -3
  199. package/src/db/schema/Index.ts +9 -0
  200. package/src/db/schema/IndexedColumn.ts +9 -0
  201. package/src/db/schema/RawTable.ts +7 -1
  202. package/src/db/schema/Schema.ts +8 -3
  203. package/src/db/schema/Table.ts +30 -5
  204. package/src/db/schema/TableV2.ts +2 -0
  205. package/src/index.ts +1 -1
  206. package/src/types/types.ts +6 -0
  207. package/src/utils/AbortOperation.ts +2 -0
  208. package/src/utils/BaseObserver.ts +12 -0
  209. package/src/utils/ControlledExecutor.ts +6 -0
  210. package/src/utils/Logger.ts +9 -0
  211. package/src/utils/mutex.ts +12 -0
  212. package/src/utils/parseQuery.ts +6 -0
  213. package/src/utils/stream_transform.ts +3 -1
package/dist/index.d.cts CHANGED
@@ -2,13 +2,25 @@ import Logger, { ILogger, ILogLevel } from 'js-logger';
2
2
  export { GlobalLogger, ILogHandler, ILogLevel, ILogger, ILoggerOpts } from 'js-logger';
3
3
  import { fetch } from 'cross-fetch';
4
4
 
5
+ /**
6
+ * @public
7
+ */
5
8
  interface Disposable {
6
9
  dispose: () => Promise<void> | void;
7
10
  }
11
+ /**
12
+ * @public
13
+ */
8
14
  type BaseListener = Record<string, ((...event: any) => any) | undefined>;
15
+ /**
16
+ * @public
17
+ */
9
18
  interface BaseObserverInterface<T extends BaseListener> {
10
19
  registerListener(listener: Partial<T>): () => void;
11
20
  }
21
+ /**
22
+ * @internal
23
+ */
12
24
  declare class BaseObserver<T extends BaseListener = BaseListener> implements BaseObserverInterface<T> {
13
25
  protected listeners: Set<Partial<T>>;
14
26
  constructor();
@@ -32,6 +44,8 @@ declare class BaseObserver<T extends BaseListener = BaseListener> implements Bas
32
44
  */
33
45
  /**
34
46
  * Object returned by SQL Query executions.
47
+ *
48
+ * @public
35
49
  */
36
50
  type QueryResult = {
37
51
  /** Represents the auto-generated row id if applicable. */
@@ -51,12 +65,15 @@ type QueryResult = {
51
65
  /** The length of the dataset */
52
66
  length: number;
53
67
  /** A convenience function to acess the index based the row object
54
- * @param idx the row index
68
+ * @param idx - the row index
55
69
  * @returns the row structure identified by column names
56
70
  */
57
71
  item: (idx: number) => any;
58
72
  };
59
73
  };
74
+ /**
75
+ * @public
76
+ */
60
77
  interface DBGetUtils {
61
78
  /** Execute a read-only query and return results. */
62
79
  getAll<T>(sql: string, parameters?: any[]): Promise<T[]>;
@@ -65,6 +82,9 @@ interface DBGetUtils {
65
82
  /** Execute a read-only query and return the first result, error if the ResultSet is empty. */
66
83
  get<T>(sql: string, parameters?: any[]): Promise<T>;
67
84
  }
85
+ /**
86
+ * @public
87
+ */
68
88
  interface SqlExecutor {
69
89
  /** Execute a single write statement. */
70
90
  execute: (query: string, params?: any[] | undefined) => Promise<QueryResult>;
@@ -76,15 +96,22 @@ interface SqlExecutor {
76
96
  *
77
97
  * Example result:
78
98
  *
79
- * ```[ [ '1', 'list 1', '33', 'Post content', '1' ] ]```
99
+ * ```JavaScript
100
+ * [ [ '1', 'list 1', '33', 'Post content', '1' ] ]
101
+ * ```
80
102
  *
81
103
  * Where as `execute`'s `rows._array` would have been:
82
104
  *
83
- * ```[ { id: '33', name: 'list 1', content: 'Post content', list_id: '1' } ]```
105
+ * ```JavaScript
106
+ * [ { id: '33', name: 'list 1', content: 'Post content', list_id: '1' } ]
107
+ * ```
84
108
  */
85
109
  executeRaw: (query: string, params?: any[] | undefined) => Promise<any[][]>;
86
110
  executeBatch: (query: string, params?: any[][]) => Promise<QueryResult>;
87
111
  }
112
+ /**
113
+ * @public
114
+ */
88
115
  interface LockContext extends SqlExecutor, DBGetUtils {
89
116
  /**
90
117
  * How the connection has been opened.
@@ -97,7 +124,9 @@ interface LockContext extends SqlExecutor, DBGetUtils {
97
124
  connectionType?: 'writer' | 'queryOnly' | 'readOnly';
98
125
  }
99
126
  /**
100
- * Implements {@link DBGetUtils} on a {@link SqlRunner}.
127
+ * Implements {@link DBGetUtils} on a {@link SqlExecutor}.
128
+ *
129
+ * @internal
101
130
  */
102
131
  declare function DBGetUtilsDefaultMixin<TBase extends new (...args: any[]) => Omit<SqlExecutor, 'executeBatch'>>(Base: TBase): {
103
132
  new (...args: any[]): {
@@ -109,6 +138,9 @@ declare function DBGetUtilsDefaultMixin<TBase extends new (...args: any[]) => Om
109
138
  executeRaw: (query: string, params?: any[] | undefined) => Promise<any[][]>;
110
139
  };
111
140
  } & TBase;
141
+ /**
142
+ * @public
143
+ */
112
144
  interface Transaction extends LockContext {
113
145
  /** Commit multiple changes to the local DB using the Transaction context. */
114
146
  commit: () => Promise<QueryResult>;
@@ -117,27 +149,40 @@ interface Transaction extends LockContext {
117
149
  }
118
150
  /**
119
151
  * Update table operation numbers from SQLite
152
+ *
153
+ * @public
120
154
  */
121
155
  declare enum RowUpdateType {
122
156
  SQLITE_INSERT = 18,
123
157
  SQLITE_DELETE = 9,
124
158
  SQLITE_UPDATE = 23
125
159
  }
160
+ /**
161
+ * @public
162
+ */
126
163
  interface TableUpdateOperation {
127
164
  opType: RowUpdateType;
128
165
  rowId: number;
129
166
  }
130
167
  /**
131
168
  * Notification of an update to one or more tables, for the purpose of realtime change notifications.
169
+ *
170
+ * @public
132
171
  */
133
172
  interface UpdateNotification extends TableUpdateOperation {
134
173
  table: string;
135
174
  }
175
+ /**
176
+ * @public
177
+ */
136
178
  interface BatchedUpdateNotification {
137
179
  rawUpdates: UpdateNotification[];
138
180
  tables: string[];
139
181
  groupedUpdates: Record<string, TableUpdateOperation[]>;
140
182
  }
183
+ /**
184
+ * @public
185
+ */
141
186
  interface DBAdapterListener extends BaseListener {
142
187
  /**
143
188
  * Listener for table updates.
@@ -147,9 +192,15 @@ interface DBAdapterListener extends BaseListener {
147
192
  */
148
193
  tablesUpdated: (updateNotification: BatchedUpdateNotification | UpdateNotification) => void;
149
194
  }
195
+ /**
196
+ * @public
197
+ */
150
198
  interface DBLockOptions {
151
199
  timeoutMs?: number;
152
200
  }
201
+ /**
202
+ * @public
203
+ */
153
204
  interface ConnectionPool extends BaseObserverInterface<DBAdapterListener> {
154
205
  name: string;
155
206
  close: () => void | Promise<void>;
@@ -160,13 +211,18 @@ interface ConnectionPool extends BaseObserverInterface<DBAdapterListener> {
160
211
  */
161
212
  refreshSchema: () => Promise<void>;
162
213
  }
214
+ /**
215
+ * @public
216
+ */
163
217
  interface DBAdapter extends ConnectionPool, SqlExecutor, DBGetUtils {
164
218
  readTransaction: <T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions) => Promise<T>;
165
219
  writeTransaction: <T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions) => Promise<T>;
166
220
  }
167
221
  /**
168
- * A mixin to implement {@link DBAdapter} by delegating to {@link ConnectionPool.readLock} and
169
- * {@link ConnectionPool.writeLock}.
222
+ * A mixin to implement {@link DBAdapter} by delegating to {@link ConnectionPool#readLock} and
223
+ * {@link ConnectionPool#writeLock}.
224
+ *
225
+ * @internal
170
226
  */
171
227
  declare function DBAdapterDefaultMixin<TBase extends new (...args: any[]) => ConnectionPool>(Base: TBase): {
172
228
  new (...args: any[]): {
@@ -189,17 +245,27 @@ declare function DBAdapterDefaultMixin<TBase extends new (...args: any[]) => Con
189
245
  registerListener(listener: Partial<DBAdapterListener>): () => void;
190
246
  };
191
247
  } & TBase;
248
+ /**
249
+ * @internal
250
+ */
192
251
  declare function isBatchedUpdateNotification(update: BatchedUpdateNotification | UpdateNotification): update is BatchedUpdateNotification;
252
+ /**
253
+ * @internal
254
+ */
193
255
  declare function extractTableUpdates(update: BatchedUpdateNotification | UpdateNotification): string[];
194
256
 
195
257
  /**
196
258
  * 64-bit unsigned integer stored as a string in base-10.
197
259
  *
198
260
  * Not sortable as a string.
261
+ *
262
+ * @public
199
263
  */
200
264
  type OpId = string;
201
265
  /**
202
266
  * Type of local change.
267
+ *
268
+ * @public
203
269
  */
204
270
  declare enum UpdateType {
205
271
  /** Insert or replace existing row. All non-null columns are included in the data. Generated by INSERT statements. */
@@ -209,6 +275,9 @@ declare enum UpdateType {
209
275
  /** Delete existing row. Contains the id. Generated by DELETE statements. */
210
276
  DELETE = "DELETE"
211
277
  }
278
+ /**
279
+ * @internal
280
+ */
212
281
  type CrudEntryJSON = {
213
282
  id: string;
214
283
  data: string;
@@ -229,6 +298,8 @@ type CrudEntryOutputJSON = {
229
298
  };
230
299
  /**
231
300
  * A single client-side change.
301
+ *
302
+ * @public
232
303
  */
233
304
  declare class CrudEntry {
234
305
  /**
@@ -289,6 +360,8 @@ declare class CrudEntry {
289
360
 
290
361
  /**
291
362
  * A batch of client-side changes.
363
+ *
364
+ * @public
292
365
  */
293
366
  declare class CrudBatch {
294
367
  /**
@@ -318,6 +391,9 @@ declare class CrudBatch {
318
391
  complete: (writeCheckpoint?: string) => Promise<void>);
319
392
  }
320
393
 
394
+ /**
395
+ * @internal
396
+ */
321
397
  declare enum PSInternalTable {
322
398
  DATA = "ps_data",
323
399
  CRUD = "ps_crud",
@@ -325,6 +401,9 @@ declare enum PSInternalTable {
325
401
  OPLOG = "ps_oplog",
326
402
  UNTYPED = "ps_untyped"
327
403
  }
404
+ /**
405
+ * @internal
406
+ */
328
407
  declare enum PowerSyncControlCommand {
329
408
  PROCESS_TEXT_LINE = "line_text",
330
409
  PROCESS_BSON_LINE = "line_binary",
@@ -338,9 +417,15 @@ declare enum PowerSyncControlCommand {
338
417
  */
339
418
  CONNECTION_STATE = "connection"
340
419
  }
420
+ /**
421
+ * @internal
422
+ */
341
423
  interface BucketStorageListener extends BaseListener {
342
424
  crudUpdate: () => void;
343
425
  }
426
+ /**
427
+ * @internal
428
+ */
344
429
  interface BucketStorageAdapter extends BaseObserverInterface<BucketStorageListener>, Disposable {
345
430
  init(): Promise<void>;
346
431
  hasMigratedSubkeys(): Promise<boolean>;
@@ -360,6 +445,9 @@ interface BucketStorageAdapter extends BaseObserverInterface<BucketStorageListen
360
445
  control(op: PowerSyncControlCommand, payload: string | Uint8Array | null): Promise<string>;
361
446
  }
362
447
 
448
+ /**
449
+ * @public
450
+ */
363
451
  interface PowerSyncCredentials {
364
452
  endpoint: string;
365
453
  token: string;
@@ -370,17 +458,28 @@ interface PowerSyncCredentials {
370
458
  * An async iterator that can't be cancelled.
371
459
  *
372
460
  * To keep data flow simple, we always pass an explicit cancellation token when subscribing to async streams. Once the
373
- * {@link AbortSignal} aborts, iterators are supposed to clean up and then emit a final `{done: true}` event. This means
461
+ * `AbortSignal` aborts, iterators are supposed to clean up and then emit a final `{done: true}` event. This means
374
462
  * that there's no way to distinguish between streams that have completed normally and streams that have been cancelled,
375
463
  * but that is acceptable for our uses of this.
464
+ *
465
+ * @internal
376
466
  */
377
467
  type SimpleAsyncIterator<T> = Pick<AsyncIterator<T>, 'next'>;
378
468
 
469
+ /**
470
+ * @internal
471
+ */
379
472
  type RemoteConnector = {
380
473
  fetchCredentials: () => Promise<PowerSyncCredentials | null>;
381
474
  invalidateCredentials?: () => void;
382
475
  };
476
+ /**
477
+ * @internal
478
+ */
383
479
  declare const DEFAULT_REMOTE_LOGGER: Logger.ILogger;
480
+ /**
481
+ * @internal
482
+ */
384
483
  type SyncStreamOptions = {
385
484
  path: string;
386
485
  data: unknown;
@@ -388,6 +487,9 @@ type SyncStreamOptions = {
388
487
  abortSignal: AbortSignal;
389
488
  fetchOptions?: Request;
390
489
  };
490
+ /**
491
+ * @public
492
+ */
391
493
  declare enum FetchStrategy {
392
494
  /**
393
495
  * Queues multiple sync events before processing, reducing round-trips.
@@ -400,19 +502,30 @@ declare enum FetchStrategy {
400
502
  */
401
503
  Sequential = "sequential"
402
504
  }
505
+ /**
506
+ * @internal
507
+ */
403
508
  type SocketSyncStreamOptions = SyncStreamOptions & {
404
509
  fetchStrategy: FetchStrategy;
405
510
  };
511
+ /**
512
+ * @internal
513
+ */
406
514
  type FetchImplementation = typeof fetch;
407
515
  /**
408
516
  * Class wrapper for providing a fetch implementation.
409
517
  * The class wrapper is used to distinguish the fetchImplementation
410
518
  * option in [AbstractRemoteOptions] from the general fetch method
411
519
  * which is typeof "function"
520
+ *
521
+ * @internal
412
522
  */
413
523
  declare class FetchImplementationProvider {
414
524
  getFetch(): FetchImplementation;
415
525
  }
526
+ /**
527
+ * @internal
528
+ */
416
529
  type AbstractRemoteOptions = {
417
530
  /**
418
531
  * Transforms the PowerSync base URL which might contain
@@ -434,7 +547,13 @@ type AbstractRemoteOptions = {
434
547
  */
435
548
  fetchOptions?: {};
436
549
  };
550
+ /**
551
+ * @internal
552
+ */
437
553
  declare const DEFAULT_REMOTE_OPTIONS: AbstractRemoteOptions;
554
+ /**
555
+ * @internal
556
+ */
438
557
  declare abstract class AbstractRemote {
439
558
  protected connector: RemoteConnector;
440
559
  protected logger: ILogger;
@@ -519,7 +638,7 @@ declare abstract class AbstractRemote {
519
638
  * Posts a `/sync/stream` request.
520
639
  *
521
640
  * Depending on the `Content-Type` of the response, this returns strings for sync lines or encoded BSON documents as
522
- * {@link Uint8Array}s.
641
+ * `Uint8Array`s.
523
642
  */
524
643
  fetchStream(options: SyncStreamOptions): Promise<SimpleAsyncIterator<Uint8Array | string>>;
525
644
  }
@@ -529,16 +648,29 @@ interface JSONObject {
529
648
  [key: string]: JSONValue;
530
649
  }
531
650
  type JSONArray = JSONValue[];
651
+ /**
652
+ * @public
653
+ */
532
654
  type StreamingSyncRequestParameterType = JSONValue;
533
655
 
656
+ /**
657
+ * @internal
658
+ */
534
659
  declare enum LockType {
535
660
  CRUD = "crud",
536
661
  SYNC = "sync"
537
662
  }
663
+ /**
664
+ * @public
665
+ */
538
666
  declare enum SyncStreamConnectionMethod {
539
667
  HTTP = "http",
540
668
  WEB_SOCKET = "web-socket"
541
669
  }
670
+ /**
671
+ * @deprecated Deprecated since {@link SyncClientImplementation.RUST} is the only option.
672
+ * @public
673
+ */
542
674
  declare enum SyncClientImplementation {
543
675
  /**
544
676
  * This implementation offloads the sync line decoding and handling into the PowerSync
@@ -549,8 +681,8 @@ declare enum SyncClientImplementation {
549
681
  * ## Compatibility warning
550
682
  *
551
683
  * The Rust sync client stores sync data in a format that is slightly different than the one used
552
- * by the old JavaScript client. When adopting the {@link RUST} client on existing databases, the PowerSync SDK will
553
- * migrate the format automatically.
684
+ * by the old JavaScript client. When adopting the {@link SyncClientImplementation.RUST} client on existing databases,
685
+ * the PowerSync SDK will migrate the format automatically.
554
686
  *
555
687
  * SDK versions supporting both the JavaScript and the Rust client support both formats with the JavaScript client
556
688
  * implementaiton. However, downgrading to an SDK version that only supports the JavaScript client would not be
@@ -560,16 +692,24 @@ declare enum SyncClientImplementation {
560
692
  }
561
693
  /**
562
694
  * The default {@link SyncClientImplementation} to use, {@link SyncClientImplementation.RUST}.
695
+ *
696
+ * @deprecated Deprecated since {@link SyncClientImplementation.RUST} is the only option.
697
+ * @public
563
698
  */
564
699
  declare const DEFAULT_SYNC_CLIENT_IMPLEMENTATION = SyncClientImplementation.RUST;
565
700
  /**
566
701
  * Abstract Lock to be implemented by various JS environments
702
+ *
703
+ * @internal
567
704
  */
568
705
  interface LockOptions<T> {
569
706
  callback: () => Promise<T>;
570
707
  type: LockType;
571
708
  signal?: AbortSignal;
572
709
  }
710
+ /**
711
+ * @internal
712
+ */
573
713
  interface AbstractStreamingSyncImplementationOptions extends RequiredAdditionalConnectionOptions {
574
714
  adapter: BucketStorageAdapter;
575
715
  subscriptions: SubscribedStream[];
@@ -582,6 +722,9 @@ interface AbstractStreamingSyncImplementationOptions extends RequiredAdditionalC
582
722
  logger?: ILogger;
583
723
  remote: AbstractRemote;
584
724
  }
725
+ /**
726
+ * @internal
727
+ */
585
728
  interface StreamingSyncImplementationListener extends BaseListener {
586
729
  /**
587
730
  * Triggered whenever a status update has been attempted to be made or
@@ -596,11 +739,16 @@ interface StreamingSyncImplementationListener extends BaseListener {
596
739
  /**
597
740
  * Configurable options to be used when connecting to the PowerSync
598
741
  * backend instance.
742
+ *
743
+ * @public
599
744
  */
600
745
  type PowerSyncConnectionOptions = Omit<InternalConnectionOptions, 'serializedSchema'>;
746
+ /**
747
+ * @internal
748
+ */
601
749
  interface InternalConnectionOptions extends BaseConnectionOptions, AdditionalConnectionOptions {
602
750
  }
603
- /** @internal */
751
+ /** @public */
604
752
  interface BaseConnectionOptions {
605
753
  /**
606
754
  * A set of metadata to be included in service logs.
@@ -653,6 +801,9 @@ interface AdditionalConnectionOptions {
653
801
  interface RequiredAdditionalConnectionOptions extends Required<AdditionalConnectionOptions> {
654
802
  subscriptions: SubscribedStream[];
655
803
  }
804
+ /**
805
+ * @internal
806
+ */
656
807
  interface StreamingSyncImplementation extends BaseObserverInterface<StreamingSyncImplementationListener>, Disposable {
657
808
  /**
658
809
  * Connects to the sync service
@@ -673,18 +824,39 @@ interface StreamingSyncImplementation extends BaseObserverInterface<StreamingSyn
673
824
  updateSubscriptions(subscriptions: SubscribedStream[]): void;
674
825
  markConnectionMayHaveChanged(): void;
675
826
  }
827
+ /**
828
+ * @internal
829
+ */
676
830
  declare const DEFAULT_CRUD_UPLOAD_THROTTLE_MS = 1000;
831
+ /**
832
+ * @internal
833
+ */
677
834
  declare const DEFAULT_RETRY_DELAY_MS = 5000;
835
+ /**
836
+ * @internal
837
+ */
678
838
  declare const DEFAULT_STREAMING_SYNC_OPTIONS: {
679
839
  retryDelayMs: number;
680
840
  crudUploadThrottleMs: number;
681
841
  };
842
+ /**
843
+ * @internal
844
+ */
682
845
  type RequiredPowerSyncConnectionOptions = Required<BaseConnectionOptions>;
846
+ /**
847
+ * @internal
848
+ */
683
849
  declare const DEFAULT_STREAM_CONNECTION_OPTIONS: RequiredPowerSyncConnectionOptions;
850
+ /**
851
+ * @internal
852
+ */
684
853
  type SubscribedStream = {
685
854
  name: string;
686
855
  params: Record<string, any> | null;
687
856
  };
857
+ /**
858
+ * @internal
859
+ */
688
860
  declare abstract class AbstractStreamingSyncImplementation extends BaseObserver<StreamingSyncImplementationListener> implements StreamingSyncImplementation {
689
861
  protected options: AbstractStreamingSyncImplementationOptions;
690
862
  protected abortController: AbortController | null;
@@ -714,7 +886,7 @@ declare abstract class AbstractStreamingSyncImplementation extends BaseObserver<
714
886
  private streamingSync;
715
887
  markConnectionMayHaveChanged(): void;
716
888
  /**
717
- * Older versions of the JS SDK used to encode subkeys as JSON in {@link OplogEntry.toJSON}.
889
+ * Older versions of the JS SDK used to encode subkeys as JSON in `OplogEntry.toJSON`.
718
890
  * Because subkeys are always strings, this leads to quotes being added around them in `ps_oplog`.
719
891
  * While this is not a problem as long as it's done consistently, it causes issues when a database
720
892
  * created by the JS SDK is used with other SDKs, or (more likely) when the new Rust sync client
@@ -724,7 +896,7 @@ declare abstract class AbstractStreamingSyncImplementation extends BaseObserver<
724
896
  * migration is only triggered when necessary (for now). The function returns whether the new format
725
897
  * should be used, so that the JS SDK is able to write to updated databases.
726
898
  *
727
- * @param requireFixedKeyFormat Whether we require the new format or also support the old one.
899
+ * @param requireFixedKeyFormat - Whether we require the new format or also support the old one.
728
900
  * The Rust client requires the new subkey format.
729
901
  * @returns Whether the database is now using the new, fixed subkey format.
730
902
  */
@@ -762,7 +934,10 @@ interface BucketProgress {
762
934
  }
763
935
 
764
936
  /**
765
- * A description of a sync stream, consisting of its {@link name} and the {@link parameters} used when subscribing.
937
+ * A description of a sync stream, consisting of its {@link SyncStreamDescription.name} and the
938
+ * {@link SyncStreamDescription.parameters} used when subscribing.
939
+ *
940
+ * @public
766
941
  */
767
942
  interface SyncStreamDescription {
768
943
  /**
@@ -780,6 +955,8 @@ interface SyncStreamDescription {
780
955
  * Information about a subscribed sync stream.
781
956
  *
782
957
  * This includes the {@link SyncStreamDescription}, along with information about the current sync status.
958
+ *
959
+ * @public
783
960
  */
784
961
  interface SyncSubscriptionDescription extends SyncStreamDescription {
785
962
  active: boolean;
@@ -787,15 +964,17 @@ interface SyncSubscriptionDescription extends SyncStreamDescription {
787
964
  * Whether this stream subscription is included by default, regardless of whether the stream has explicitly been
788
965
  * subscribed to or not.
789
966
  *
790
- * It's possible for both {@link isDefault} and {@link hasExplicitSubscription} to be true at the same time - this
791
- * happens when a default stream was subscribed explicitly.
967
+ * It's possible for both {@link SyncSubscriptionDescription.isDefault} and
968
+ * {@link SyncSubscriptionDescription.hasExplicitSubscription} to be true at the same time - this happens when a
969
+ * default stream was subscribed explicitly.
792
970
  */
793
971
  isDefault: boolean;
794
972
  /**
795
973
  * Whether this stream has been subscribed to explicitly.
796
974
  *
797
- * It's possible for both {@link isDefault} and {@link hasExplicitSubscription} to be true at the same time - this
798
- * happens when a default stream was subscribed explicitly.
975
+ * It's possible for both {@link SyncSubscriptionDescription.isDefault} and
976
+ * {@link SyncSubscriptionDescription.hasExplicitSubscription} to be true at the same time - this happens when a
977
+ * default stream was subscribed explicitly.
799
978
  */
800
979
  hasExplicitSubscription: boolean;
801
980
  /**
@@ -808,10 +987,13 @@ interface SyncSubscriptionDescription extends SyncStreamDescription {
808
987
  */
809
988
  hasSynced: boolean;
810
989
  /**
811
- * If {@link hasSynced} is true, the last time data from this stream has been synced.
990
+ * If {@link SyncSubscriptionDescription.hasSynced} is true, the last time data from this stream has been synced.
812
991
  */
813
992
  lastSyncedAt: Date | null;
814
993
  }
994
+ /**
995
+ * @public
996
+ */
815
997
  interface SyncStreamSubscribeOptions {
816
998
  /**
817
999
  * A "time to live" for this stream subscription, in seconds.
@@ -831,6 +1013,8 @@ interface SyncStreamSubscribeOptions {
831
1013
  * A handle to a {@link SyncStreamDescription} that allows subscribing to the stream.
832
1014
  *
833
1015
  * To obtain an instance of {@link SyncStream}, call {@link AbstractPowerSyncDatabase.syncStream}.
1016
+ *
1017
+ * @public
834
1018
  */
835
1019
  interface SyncStream extends SyncStreamDescription {
836
1020
  /**
@@ -839,7 +1023,7 @@ interface SyncStream extends SyncStreamDescription {
839
1023
  * You should keep a reference to the returned {@link SyncStreamSubscription} object along as you need data for that
840
1024
  * stream. As soon as {@link SyncStreamSubscription.unsubscribe} is called for all subscriptions on this stream
841
1025
  * (including subscriptions created on other tabs), the {@link SyncStreamSubscribeOptions.ttl} starts ticking and will
842
- * eventually evict the stream (unless {@link subscribe} is called again).
1026
+ * eventually evict the stream (unless {@link SyncStream.subscribe} is called again).
843
1027
  */
844
1028
  subscribe(options?: SyncStreamSubscribeOptions): Promise<SyncStreamSubscription>;
845
1029
  /**
@@ -849,6 +1033,9 @@ interface SyncStream extends SyncStreamDescription {
849
1033
  */
850
1034
  unsubscribeAll(): Promise<void>;
851
1035
  }
1036
+ /**
1037
+ * @public
1038
+ */
852
1039
  interface SyncStreamSubscription extends SyncStreamDescription {
853
1040
  /**
854
1041
  * A promise that resolves once data from in this sync stream has been synced and applied.
@@ -867,6 +1054,8 @@ type InternalProgressInformation = Record<string, BucketProgress>;
867
1054
  *
868
1055
  * To obtain these values, use {@link SyncProgress}, available through
869
1056
  * {@link SyncStatus#downloadProgress}.
1057
+ *
1058
+ * @public
870
1059
  */
871
1060
  interface ProgressWithOperations {
872
1061
  /**
@@ -879,7 +1068,8 @@ interface ProgressWithOperations {
879
1068
  */
880
1069
  downloadedOperations: number;
881
1070
  /**
882
- * Relative progress, as {@link downloadedOperations} of {@link totalOperations}.
1071
+ * Relative progress, as {@link ProgressWithOperations.downloadedOperations} of
1072
+ * {@link ProgressWithOperations.totalOperations}.
883
1073
  *
884
1074
  * This will be a number between `0.0` and `1.0` (inclusive).
885
1075
  *
@@ -908,6 +1098,8 @@ interface ProgressWithOperations {
908
1098
  *
909
1099
  * Also note that data is downloaded in bulk, which means that individual counters are unlikely
910
1100
  * to be updated one-by-one.
1101
+ *
1102
+ * @public
911
1103
  */
912
1104
  declare class SyncProgress implements ProgressWithOperations {
913
1105
  protected internal: InternalProgressInformation;
@@ -924,6 +1116,9 @@ declare class SyncProgress implements ProgressWithOperations {
924
1116
  untilPriority(priority: number): ProgressWithOperations;
925
1117
  }
926
1118
 
1119
+ /**
1120
+ * @public
1121
+ */
927
1122
  type SyncDataFlowStatus = Partial<{
928
1123
  downloading: boolean;
929
1124
  uploading: boolean;
@@ -941,16 +1136,25 @@ type SyncDataFlowStatus = Partial<{
941
1136
  /**
942
1137
  * Internal information about how far we are downloading operations in buckets.
943
1138
  *
944
- * Please use the {@link SyncStatus#downloadProgress} property to track sync progress.
1139
+ * @internal Please use the {@link SyncStatus#downloadProgress} property to track sync progress.
945
1140
  */
946
1141
  downloadProgress: InternalProgressInformation | null;
1142
+ /**
1143
+ * @internal
1144
+ */
947
1145
  internalStreamSubscriptions: CoreStreamSubscription[] | null;
948
1146
  }>;
1147
+ /**
1148
+ * @public
1149
+ */
949
1150
  interface SyncPriorityStatus {
950
1151
  priority: number;
951
1152
  lastSyncedAt?: Date;
952
1153
  hasSynced?: boolean;
953
1154
  }
1155
+ /**
1156
+ * @internal
1157
+ */
954
1158
  type SyncStatusOptions = {
955
1159
  connected?: boolean;
956
1160
  connecting?: boolean;
@@ -963,6 +1167,9 @@ type SyncStatusOptions = {
963
1167
  */
964
1168
  clientImplementation?: SyncClientImplementation;
965
1169
  };
1170
+ /**
1171
+ * @public
1172
+ */
966
1173
  declare class SyncStatus {
967
1174
  protected options: SyncStatusOptions;
968
1175
  constructor(options: SyncStatusOptions);
@@ -971,64 +1178,45 @@ declare class SyncStatus {
971
1178
  * implementation).
972
1179
  *
973
1180
  * This information is only available after a connection has been requested.
1181
+ *
1182
+ * @deprecated This always returns the Rust client (the only option).
974
1183
  */
975
1184
  get clientImplementation(): SyncClientImplementation | undefined;
976
1185
  /**
977
1186
  * Indicates if the client is currently connected to the PowerSync service.
978
1187
  *
979
- * @returns {boolean} True if connected, false otherwise. Defaults to false if not specified.
1188
+ * @returns True if connected, false otherwise. Defaults to false if not specified.
980
1189
  */
981
1190
  get connected(): boolean;
982
1191
  /**
983
1192
  * Indicates if the client is in the process of establishing a connection to the PowerSync service.
984
1193
  *
985
- * @returns {boolean} True if connecting, false otherwise. Defaults to false if not specified.
1194
+ * @returns True if connecting, false otherwise. Defaults to false if not specified.
986
1195
  */
987
1196
  get connecting(): boolean;
988
1197
  /**
989
1198
  * Time that a last sync has fully completed, if any.
990
1199
  * This timestamp is reset to null after a restart of the PowerSync service.
991
1200
  *
992
- * @returns {Date | undefined} The timestamp of the last successful sync, or undefined if no sync has completed.
1201
+ * @returns The timestamp of the last successful sync, or undefined if no sync has completed.
993
1202
  */
994
1203
  get lastSyncedAt(): Date | undefined;
995
1204
  /**
996
1205
  * Indicates whether there has been at least one full sync completed since initialization.
997
1206
  *
998
- * @returns {boolean | undefined} True if at least one sync has completed, false if no sync has completed,
1207
+ * @returns True if at least one sync has completed, false if no sync has completed,
999
1208
  * or undefined when the state is still being loaded from the database.
1000
1209
  */
1001
1210
  get hasSynced(): boolean | undefined;
1002
1211
  /**
1003
1212
  * Provides the current data flow status regarding uploads and downloads.
1004
1213
  *
1005
- * @returns {SyncDataFlowStatus} An object containing:
1214
+ * @returns An object containing:
1006
1215
  * - downloading: True if actively downloading changes (only when connected is also true)
1007
1216
  * - uploading: True if actively uploading changes
1008
- * Defaults to {downloading: false, uploading: false} if not specified.
1217
+ * Defaults to `{downloading: false, uploading: false}` if not specified.
1009
1218
  */
1010
- get dataFlowStatus(): Partial<{
1011
- downloading: boolean;
1012
- uploading: boolean;
1013
- /**
1014
- * Error during downloading (including connecting).
1015
- *
1016
- * Cleared on the next successful data download.
1017
- */
1018
- downloadError?: Error;
1019
- /**
1020
- * Error during uploading.
1021
- * Cleared on the next successful upload.
1022
- */
1023
- uploadError?: Error;
1024
- /**
1025
- * Internal information about how far we are downloading operations in buckets.
1026
- *
1027
- * Please use the {@link SyncStatus#downloadProgress} property to track sync progress.
1028
- */
1029
- downloadProgress: InternalProgressInformation | null;
1030
- internalStreamSubscriptions: CoreStreamSubscription[] | null;
1031
- }>;
1219
+ get dataFlowStatus(): SyncDataFlowStatus;
1032
1220
  /**
1033
1221
  * All sync streams currently being tracked in teh database.
1034
1222
  *
@@ -1037,13 +1225,13 @@ declare class SyncStatus {
1037
1225
  */
1038
1226
  get syncStreams(): SyncStreamStatus[] | undefined;
1039
1227
  /**
1040
- * If the `stream` appears in {@link syncStreams}, returns the current status for that stream.
1228
+ * If the `stream` appears in {@link SyncStatus.syncStreams}, returns the current status for that stream.
1041
1229
  */
1042
1230
  forStream(stream: SyncStreamDescription): SyncStreamStatus | undefined;
1043
1231
  /**
1044
1232
  * Provides sync status information for all bucket priorities, sorted by priority (highest first).
1045
1233
  *
1046
- * @returns {SyncPriorityStatus[]} An array of status entries for different sync priority levels,
1234
+ * @returns An array of status entries for different sync priority levels,
1047
1235
  * sorted with highest priorities (lower numbers) first.
1048
1236
  */
1049
1237
  get priorityStatusEntries(): SyncPriorityStatus[];
@@ -1070,29 +1258,29 @@ declare class SyncStatus {
1070
1258
  * For example, if PowerSync just finished synchronizing buckets in priority level 3, calling this method
1071
1259
  * with a priority of 1 may return information for priority level 3.
1072
1260
  *
1073
- * @param {number} priority The bucket priority for which the status should be reported
1074
- * @returns {SyncPriorityStatus} Status information for the requested priority level or the next higher level with available status
1261
+ * @param priority - The bucket priority for which the status should be reported
1262
+ * @returns Status information for the requested priority level or the next higher level with available status
1075
1263
  */
1076
1264
  statusForPriority(priority: number): SyncPriorityStatus;
1077
1265
  /**
1078
1266
  * Compares this SyncStatus instance with another to determine if they are equal.
1079
1267
  * Equality is determined by comparing the serialized JSON representation of both instances.
1080
1268
  *
1081
- * @param {SyncStatus} status The SyncStatus instance to compare against
1082
- * @returns {boolean} True if the instances are considered equal, false otherwise
1269
+ * @param status - The SyncStatus instance to compare against
1270
+ * @returns True if the instances are considered equal, false otherwise
1083
1271
  */
1084
1272
  isEqual(status: SyncStatus): boolean;
1085
1273
  /**
1086
1274
  * Creates a human-readable string representation of the current sync status.
1087
1275
  * Includes information about connection state, sync completion, and data flow.
1088
1276
  *
1089
- * @returns {string} A string representation of the sync status
1277
+ * @returns A string representation of the sync status
1090
1278
  */
1091
1279
  getMessage(): string;
1092
1280
  /**
1093
1281
  * Serializes the SyncStatus instance to a plain object.
1094
1282
  *
1095
- * @returns {SyncStatusOptions} A plain object representation of the sync status
1283
+ * @returns A plain object representation of the sync status
1096
1284
  */
1097
1285
  toJSON(): SyncStatusOptions;
1098
1286
  /**
@@ -1108,6 +1296,8 @@ declare class SyncStatus {
1108
1296
  }
1109
1297
  /**
1110
1298
  * Information about a sync stream subscription.
1299
+ *
1300
+ * @public
1111
1301
  */
1112
1302
  interface SyncStreamStatus {
1113
1303
  progress: ProgressWithOperations | null;
@@ -1115,6 +1305,9 @@ interface SyncStreamStatus {
1115
1305
  priority: number | null;
1116
1306
  }
1117
1307
 
1308
+ /**
1309
+ * @public
1310
+ */
1118
1311
  declare class UploadQueueStats {
1119
1312
  /**
1120
1313
  * Number of records in the upload queue.
@@ -1136,26 +1329,54 @@ declare class UploadQueueStats {
1136
1329
  toString(): string;
1137
1330
  }
1138
1331
 
1332
+ /**
1333
+ * @see https://www.sqlite.org/lang_expr.html#castexpr
1334
+ * @public
1335
+ */
1139
1336
  declare enum ColumnType {
1140
1337
  TEXT = "TEXT",
1141
1338
  INTEGER = "INTEGER",
1142
1339
  REAL = "REAL"
1143
1340
  }
1341
+ /**
1342
+ * @public
1343
+ */
1144
1344
  interface ColumnOptions {
1145
1345
  name: string;
1146
1346
  type?: ColumnType;
1147
1347
  }
1348
+ /**
1349
+ * @public
1350
+ */
1148
1351
  type BaseColumnType<T extends number | string | null> = {
1149
1352
  type: ColumnType;
1150
1353
  };
1354
+ /**
1355
+ * @public
1356
+ */
1151
1357
  type ColumnsType = Record<string, BaseColumnType<any>>;
1358
+ /**
1359
+ * @public
1360
+ */
1152
1361
  type ExtractColumnValueType<T extends BaseColumnType<any>> = T extends BaseColumnType<infer R> ? R : unknown;
1362
+ /**
1363
+ * powersync-sqlite-core limits the number of column per table to 1999, due to internal SQLite limits.
1364
+ * In earlier versions this was limited to 63.
1365
+ *
1366
+ * @internal
1367
+ */
1153
1368
  declare const MAX_AMOUNT_OF_COLUMNS = 1999;
1369
+ /**
1370
+ * @public
1371
+ */
1154
1372
  declare const column: {
1155
1373
  text: BaseColumnType<string | null>;
1156
1374
  integer: BaseColumnType<number | null>;
1157
1375
  real: BaseColumnType<number | null>;
1158
1376
  };
1377
+ /**
1378
+ * @public
1379
+ */
1159
1380
  declare class Column {
1160
1381
  protected options: ColumnOptions;
1161
1382
  constructor(options: ColumnOptions);
@@ -1167,11 +1388,20 @@ declare class Column {
1167
1388
  };
1168
1389
  }
1169
1390
 
1391
+ /**
1392
+ * @public
1393
+ */
1170
1394
  interface IndexColumnOptions {
1171
1395
  name: string;
1172
1396
  ascending?: boolean;
1173
1397
  }
1398
+ /**
1399
+ * @internal
1400
+ */
1174
1401
  declare const DEFAULT_INDEX_COLUMN_OPTIONS: Partial<IndexColumnOptions>;
1402
+ /**
1403
+ * @public
1404
+ */
1175
1405
  declare class IndexedColumn {
1176
1406
  protected options: IndexColumnOptions;
1177
1407
  static createAscending(column: string): IndexedColumn;
@@ -1185,11 +1415,20 @@ declare class IndexedColumn {
1185
1415
  };
1186
1416
  }
1187
1417
 
1418
+ /**
1419
+ * @public
1420
+ */
1188
1421
  interface IndexOptions {
1189
1422
  name: string;
1190
1423
  columns?: IndexedColumn[];
1191
1424
  }
1425
+ /**
1426
+ * @internal
1427
+ */
1192
1428
  declare const DEFAULT_INDEX_OPTIONS: Partial<IndexOptions>;
1429
+ /**
1430
+ * @public
1431
+ */
1193
1432
  declare class Index {
1194
1433
  protected options: IndexOptions;
1195
1434
  static createAscending(options: IndexOptions, columnNames: string[]): Index;
@@ -1210,12 +1449,16 @@ declare class Index {
1210
1449
  Generate a new table from the columns and indexes
1211
1450
  @deprecated You should use {@link Table} instead as it now allows TableV2 syntax.
1212
1451
  This will be removed in the next major release.
1452
+
1453
+ @public
1213
1454
  */
1214
1455
  declare class TableV2<Columns extends ColumnsType = ColumnsType> extends Table<Columns> {
1215
1456
  }
1216
1457
 
1217
1458
  /**
1218
1459
  * Options that apply both to JSON-based tables and raw tables.
1460
+ *
1461
+ * @public
1219
1462
  */
1220
1463
  interface TableOrRawTableOptions {
1221
1464
  localOnly?: boolean;
@@ -1231,6 +1474,8 @@ interface SharedTableOptions extends TableOrRawTableOptions {
1231
1474
  *
1232
1475
  * Including old values may be helpful for some backend connector implementations, which is
1233
1476
  * why it can be enabled on per-table or per-columm basis.
1477
+ *
1478
+ * @public
1234
1479
  */
1235
1480
  interface TrackPreviousOptions {
1236
1481
  /** When defined, a list of column names for which old values should be tracked. */
@@ -1238,6 +1483,9 @@ interface TrackPreviousOptions {
1238
1483
  /** When enabled, only include values that have actually been changed by an update. */
1239
1484
  onlyWhenChanged?: boolean;
1240
1485
  }
1486
+ /**
1487
+ * @public
1488
+ */
1241
1489
  interface TableOptions extends SharedTableOptions {
1242
1490
  /**
1243
1491
  * The synced table name, matching sync rules
@@ -1246,15 +1494,27 @@ interface TableOptions extends SharedTableOptions {
1246
1494
  columns: Column[];
1247
1495
  indexes?: Index[];
1248
1496
  }
1497
+ /**
1498
+ * @public
1499
+ */
1249
1500
  type RowType<T extends TableV2<any>> = {
1250
1501
  [K in keyof T['columnMap']]: ExtractColumnValueType<T['columnMap'][K]>;
1251
1502
  } & {
1252
1503
  id: string;
1253
1504
  };
1505
+ /**
1506
+ * @public
1507
+ */
1254
1508
  type IndexShorthand = Record<string, string[]>;
1509
+ /**
1510
+ * @public
1511
+ */
1255
1512
  interface TableV2Options extends SharedTableOptions {
1256
1513
  indexes?: IndexShorthand;
1257
1514
  }
1515
+ /**
1516
+ * @internal
1517
+ */
1258
1518
  declare const DEFAULT_TABLE_OPTIONS: {
1259
1519
  indexes: never[];
1260
1520
  insertOnly: boolean;
@@ -1263,7 +1523,13 @@ declare const DEFAULT_TABLE_OPTIONS: {
1263
1523
  trackMetadata: boolean;
1264
1524
  ignoreEmptyUpdates: boolean;
1265
1525
  };
1526
+ /**
1527
+ * @internal
1528
+ */
1266
1529
  declare const InvalidSQLCharacters: RegExp;
1530
+ /**
1531
+ * @public
1532
+ */
1267
1533
  declare class Table<Columns extends ColumnsType = ColumnsType> {
1268
1534
  protected options: TableOptions;
1269
1535
  protected _mappedColumns: Columns;
@@ -1284,9 +1550,8 @@ declare class Table<Columns extends ColumnsType = ColumnsType> {
1284
1550
  * 1. New constructor: Using a Columns object and an optional TableV2Options object
1285
1551
  * 2. Deprecated constructor: Using a TableOptions object (will be removed in the next major release)
1286
1552
  *
1287
- * @constructor
1288
- * @param {Columns | TableOptions} optionsOrColumns - Either a Columns object (for V2 syntax) or a TableOptions object (for V1 syntax)
1289
- * @param {TableV2Options} [v2Options] - Optional configuration options for V2 syntax
1553
+ * @param columns - Either a Columns object (for V2 syntax) or a TableOptions object (for V1 syntax)
1554
+ * @param options - Optional configuration options for V2 syntax
1290
1555
  *
1291
1556
  * @example
1292
1557
  * ```javascript
@@ -1380,8 +1645,10 @@ declare class Table<Columns extends ColumnsType = ColumnsType> {
1380
1645
  * using client-side table and column constraints.
1381
1646
  *
1382
1647
  * To collect local writes to raw tables with PowerSync, custom triggers are required. See
1383
- * {@link https://docs.powersync.com/usage/use-case-examples/raw-tables the documentation} for details and an example on
1648
+ * {@link https://docs.powersync.com/usage/use-case-examples/raw-tables} for details and an example on
1384
1649
  * using raw tables.
1650
+ *
1651
+ * @public
1385
1652
  */
1386
1653
  type RawTableType = RawTableTypeWithStatements | InferredRawTableType;
1387
1654
  interface RawTableTypeWithStatements {
@@ -1437,12 +1704,16 @@ interface InferredRawTableType extends Partial<RawTableTypeWithStatements> {
1437
1704
  * `{Column: 'name'}`.
1438
1705
  * The `"Rest"` parameter gets resolved to a JSON object covering all values from the synced row that haven't been
1439
1706
  * covered by a `Column` parameter.
1707
+ *
1708
+ * @public
1440
1709
  */
1441
1710
  type PendingStatementParameter = 'Id' | {
1442
1711
  Column: string;
1443
1712
  } | 'Rest';
1444
1713
  /**
1445
1714
  * A statement that the PowerSync client should use to insert or delete data into a table managed by the user.
1715
+ *
1716
+ * @public
1446
1717
  */
1447
1718
  type PendingStatement = {
1448
1719
  sql: string;
@@ -1464,11 +1735,16 @@ type RawTable<T extends RawTableType = RawTableType> = T & {
1464
1735
  };
1465
1736
 
1466
1737
  type SchemaType = Record<string, Table<any>>;
1738
+ /**
1739
+ * @public
1740
+ */
1467
1741
  type SchemaTableType<S extends SchemaType> = {
1468
1742
  [K in keyof S]: RowType<S[K]>;
1469
1743
  };
1470
1744
  /**
1471
1745
  * A schema is a collection of tables. It is used to define the structure of a database.
1746
+ *
1747
+ * @public
1472
1748
  */
1473
1749
  declare class Schema<S extends SchemaType = SchemaType> {
1474
1750
  readonly types: SchemaTableType<S>;
@@ -1482,7 +1758,7 @@ declare class Schema<S extends SchemaType = SchemaType> {
1482
1758
  * Since raw tables are not backed by JSON, running complex queries on them may be more efficient. Further, they allow
1483
1759
  * using client-side table and column constraints.
1484
1760
  *
1485
- * @param tables An object of (table name, raw table definition) entries.
1761
+ * @param tables - An object of (table name, raw table definition) entries.
1486
1762
  */
1487
1763
  withRawTables(tables: Record<string, RawTableType>): void;
1488
1764
  validate(): void;
@@ -1520,6 +1796,9 @@ declare class Schema<S extends SchemaType = SchemaType> {
1520
1796
  static rawTableToJson(table: RawTable): unknown;
1521
1797
  }
1522
1798
 
1799
+ /**
1800
+ * @public
1801
+ */
1523
1802
  interface PowerSyncBackendConnector {
1524
1803
  /** Allows the PowerSync client to retrieve an authentication token from your backend
1525
1804
  * which is used to authenticate against the PowerSync service.
@@ -1561,6 +1840,9 @@ interface ConnectionManagerSyncImplementationResult {
1561
1840
  interface CreateSyncImplementationOptions extends AdditionalConnectionOptions {
1562
1841
  subscriptions: SubscribedStream[];
1563
1842
  }
1843
+ /**
1844
+ * @internal
1845
+ */
1564
1846
  interface InternalSubscriptionAdapter {
1565
1847
  firstStatusMatching(predicate: (status: SyncStatus) => any, abort?: AbortSignal): Promise<void>;
1566
1848
  resolveOfflineSyncStatus(): Promise<void>;
@@ -1632,7 +1914,7 @@ declare class ConnectionManager extends BaseObserver<ConnectionManagerListener>
1632
1914
  /**
1633
1915
  * Close the sync connection.
1634
1916
  *
1635
- * Use {@link connect} to connect again.
1917
+ * Use {@link ConnectionManager.connect} to connect again.
1636
1918
  */
1637
1919
  disconnect(): Promise<void>;
1638
1920
  protected disconnectInternal(): Promise<void>;
@@ -1652,12 +1934,16 @@ declare class ConnectionManager extends BaseObserver<ConnectionManagerListener>
1652
1934
  * A basic comparator for incrementally watched queries. This performs a single comparison which
1653
1935
  * determines if the result set has changed. The {@link WatchedQuery} will only emit the new result
1654
1936
  * if a change has been detected.
1937
+ *
1938
+ * @public
1655
1939
  */
1656
1940
  interface WatchedQueryComparator<Data> {
1657
1941
  checkEquality: (current: Data, previous: Data) => boolean;
1658
1942
  }
1659
1943
  /**
1660
1944
  * Options for {@link ArrayComparator}
1945
+ *
1946
+ * @public
1661
1947
  */
1662
1948
  type ArrayComparatorOptions<ItemType> = {
1663
1949
  /**
@@ -1668,6 +1954,8 @@ type ArrayComparatorOptions<ItemType> = {
1668
1954
  /**
1669
1955
  * An efficient comparator for {@link WatchedQuery} created with {@link Query#watch}. This has the ability to determine if a query
1670
1956
  * result has changes without necessarily processing all items in the result.
1957
+ *
1958
+ * @public
1671
1959
  */
1672
1960
  declare class ArrayComparator<ItemType> implements WatchedQueryComparator<ItemType[]> {
1673
1961
  protected options: ArrayComparatorOptions<ItemType>;
@@ -1676,13 +1964,21 @@ declare class ArrayComparator<ItemType> implements WatchedQueryComparator<ItemTy
1676
1964
  }
1677
1965
  /**
1678
1966
  * Watched query comparator that always reports changed result sets.
1967
+ *
1968
+ * @public
1679
1969
  */
1680
1970
  declare const FalsyComparator: WatchedQueryComparator<unknown>;
1681
1971
 
1972
+ /**
1973
+ * @public
1974
+ */
1682
1975
  interface CompilableQuery<T> {
1683
1976
  execute(): Promise<T[]>;
1684
1977
  compile(): CompiledQuery;
1685
1978
  }
1979
+ /**
1980
+ * @public
1981
+ */
1686
1982
  interface CompiledQuery {
1687
1983
  readonly sql: string;
1688
1984
  readonly parameters: ReadonlyArray<unknown>;
@@ -1719,6 +2015,8 @@ declare class MetaBaseObserver<Listener extends BaseListener> extends BaseObserv
1719
2015
 
1720
2016
  /**
1721
2017
  * State for {@link WatchedQuery} instances.
2018
+ *
2019
+ * @public
1722
2020
  */
1723
2021
  interface WatchedQueryState<Data> {
1724
2022
  /**
@@ -1746,6 +2044,8 @@ interface WatchedQueryState<Data> {
1746
2044
  }
1747
2045
  /**
1748
2046
  * Options provided to the `execute` method of a {@link WatchCompatibleQuery}.
2047
+ *
2048
+ * @public
1749
2049
  */
1750
2050
  interface WatchExecuteOptions {
1751
2051
  sql: string;
@@ -1753,13 +2053,16 @@ interface WatchExecuteOptions {
1753
2053
  db: AbstractPowerSyncDatabase;
1754
2054
  }
1755
2055
  /**
1756
- * Similar to {@link CompatibleQuery}, except the `execute` method
1757
- * does not enforce an Array result type.
2056
+ *
2057
+ * @public
1758
2058
  */
1759
2059
  interface WatchCompatibleQuery<ResultType> {
1760
2060
  execute(options: WatchExecuteOptions): Promise<ResultType>;
1761
2061
  compile(): CompiledQuery;
1762
2062
  }
2063
+ /**
2064
+ * @public
2065
+ */
1763
2066
  interface WatchedQueryOptions {
1764
2067
  /** The minimum interval between queries. */
1765
2068
  throttleMs?: number;
@@ -1776,6 +2079,9 @@ interface WatchedQueryOptions {
1776
2079
  */
1777
2080
  triggerOnTables?: string[];
1778
2081
  }
2082
+ /**
2083
+ * @public
2084
+ */
1779
2085
  declare enum WatchedQueryListenerEvent {
1780
2086
  ON_DATA = "onData",
1781
2087
  ON_ERROR = "onError",
@@ -1783,6 +2089,9 @@ declare enum WatchedQueryListenerEvent {
1783
2089
  SETTINGS_WILL_UPDATE = "settingsWillUpdate",
1784
2090
  CLOSED = "closed"
1785
2091
  }
2092
+ /**
2093
+ * @public
2094
+ */
1786
2095
  interface WatchedQueryListener<Data> extends BaseListener {
1787
2096
  [WatchedQueryListenerEvent.ON_DATA]?: (data: Data) => void | Promise<void>;
1788
2097
  [WatchedQueryListenerEvent.ON_ERROR]?: (error: Error) => void | Promise<void>;
@@ -1790,8 +2099,17 @@ interface WatchedQueryListener<Data> extends BaseListener {
1790
2099
  [WatchedQueryListenerEvent.SETTINGS_WILL_UPDATE]?: () => void;
1791
2100
  [WatchedQueryListenerEvent.CLOSED]?: () => void | Promise<void>;
1792
2101
  }
2102
+ /**
2103
+ * @internal
2104
+ */
1793
2105
  declare const DEFAULT_WATCH_THROTTLE_MS = 30;
2106
+ /**
2107
+ * @internal
2108
+ */
1794
2109
  declare const DEFAULT_WATCH_QUERY_OPTIONS: WatchedQueryOptions;
2110
+ /**
2111
+ * @public
2112
+ */
1795
2113
  interface WatchedQuery<Data = unknown, Settings extends WatchedQueryOptions = WatchedQueryOptions, Listener extends WatchedQueryListener<Data> = WatchedQueryListener<Data>> extends MetaBaseObserverInterface<Listener> {
1796
2114
  /**
1797
2115
  * Current state of the watched query.
@@ -1860,7 +2178,7 @@ declare abstract class AbstractQueryProcessor<Data = unknown[], Settings extends
1860
2178
  updateSettings(settings: Settings): Promise<void>;
1861
2179
  /**
1862
2180
  * This method is used to link a query to the subscribers of this listener class.
1863
- * This method should perform actual query watching and report results via {@link updateState} method.
2181
+ * This method should perform actual query watching and report results via {@link AbstractQueryProcessor.updateState} method.
1864
2182
  */
1865
2183
  protected abstract linkQuery(options: LinkQueryOptions<Data>): Promise<void>;
1866
2184
  protected updateState(update: Partial<MutableWatchedQueryState<Data>>): Promise<void>;
@@ -1882,6 +2200,8 @@ declare abstract class AbstractQueryProcessor<Data = unknown[], Settings extends
1882
2200
  /**
1883
2201
  * Represents an updated row in a differential watched query.
1884
2202
  * It contains both the current and previous state of the row.
2203
+ *
2204
+ * @public
1885
2205
  */
1886
2206
  interface WatchedQueryRowDifferential<RowType> {
1887
2207
  readonly current: RowType;
@@ -1890,6 +2210,8 @@ interface WatchedQueryRowDifferential<RowType> {
1890
2210
  /**
1891
2211
  * Represents the result of a watched query that has been diffed.
1892
2212
  * {@link DifferentialWatchedQueryState#diff} is of the {@link WatchedQueryDifferential} form.
2213
+ *
2214
+ * @public
1893
2215
  */
1894
2216
  interface WatchedQueryDifferential<RowType> {
1895
2217
  readonly added: ReadonlyArray<Readonly<RowType>>;
@@ -1914,6 +2236,8 @@ interface WatchedQueryDifferential<RowType> {
1914
2236
  }
1915
2237
  /**
1916
2238
  * Row comparator for differentially watched queries which keys and compares items in the result set.
2239
+ *
2240
+ * @public
1917
2241
  */
1918
2242
  interface DifferentialWatchedQueryComparator<RowType> {
1919
2243
  /**
@@ -1927,6 +2251,8 @@ interface DifferentialWatchedQueryComparator<RowType> {
1927
2251
  }
1928
2252
  /**
1929
2253
  * Options for building a differential watched query with the {@link Query} builder.
2254
+ *
2255
+ * @public
1930
2256
  */
1931
2257
  interface DifferentialWatchedQueryOptions<RowType> extends WatchedQueryOptions {
1932
2258
  /**
@@ -1943,6 +2269,8 @@ interface DifferentialWatchedQueryOptions<RowType> extends WatchedQueryOptions {
1943
2269
  }
1944
2270
  /**
1945
2271
  * Settings for differential incremental watched queries using.
2272
+ *
2273
+ * @public
1946
2274
  */
1947
2275
  interface DifferentialWatchedQuerySettings<RowType> extends DifferentialWatchedQueryOptions<RowType> {
1948
2276
  /**
@@ -1950,9 +2278,15 @@ interface DifferentialWatchedQuerySettings<RowType> extends DifferentialWatchedQ
1950
2278
  */
1951
2279
  query: WatchCompatibleQuery<RowType[]>;
1952
2280
  }
2281
+ /**
2282
+ * @public
2283
+ */
1953
2284
  interface DifferentialWatchedQueryListener<RowType> extends WatchedQueryListener<ReadonlyArray<Readonly<RowType>>> {
1954
2285
  onDiff?: (diff: WatchedQueryDifferential<RowType>) => void | Promise<void>;
1955
2286
  }
2287
+ /**
2288
+ * @public
2289
+ */
1956
2290
  type DifferentialWatchedQuery<RowType> = WatchedQuery<ReadonlyArray<Readonly<RowType>>, DifferentialWatchedQuerySettings<RowType>, DifferentialWatchedQueryListener<RowType>>;
1957
2291
  /**
1958
2292
  * @internal
@@ -1967,6 +2301,8 @@ type DataHashMap<RowType> = Map<string, {
1967
2301
  /**
1968
2302
  * An empty differential result set.
1969
2303
  * This is used as the initial state for differential incrementally watched queries.
2304
+ *
2305
+ * @internal
1970
2306
  */
1971
2307
  declare const EMPTY_DIFFERENTIAL: {
1972
2308
  added: never[];
@@ -1979,6 +2315,8 @@ declare const EMPTY_DIFFERENTIAL: {
1979
2315
  * Default implementation of the {@link DifferentialWatchedQueryComparator} for watched queries.
1980
2316
  * It keys items by their `id` property if available, alternatively it uses JSON stringification
1981
2317
  * of the entire item for the key and comparison.
2318
+ *
2319
+ * @internal
1982
2320
  */
1983
2321
  declare const DEFAULT_ROW_COMPARATOR: DifferentialWatchedQueryComparator<any>;
1984
2322
  /**
@@ -2000,12 +2338,16 @@ declare class DifferentialQueryProcessor<RowType> extends AbstractQueryProcessor
2000
2338
 
2001
2339
  /**
2002
2340
  * Settings for {@link WatchedQuery} instances created via {@link Query#watch}.
2341
+ *
2342
+ * @public
2003
2343
  */
2004
2344
  interface WatchedQuerySettings<DataType> extends WatchedQueryOptions {
2005
2345
  query: WatchCompatibleQuery<DataType>;
2006
2346
  }
2007
2347
  /**
2008
2348
  * {@link WatchedQuery} returned from {@link Query#watch}.
2349
+ *
2350
+ * @public
2009
2351
  */
2010
2352
  type StandardWatchedQuery<DataType> = WatchedQuery<DataType, WatchedQuerySettings<DataType>>;
2011
2353
  /**
@@ -2031,11 +2373,15 @@ declare class OnChangeQueryProcessor<Data> extends AbstractQueryProcessor<Data,
2031
2373
 
2032
2374
  /**
2033
2375
  * Query parameters for {@link ArrayQueryDefinition#parameters}
2376
+ *
2377
+ * @public
2034
2378
  */
2035
2379
  type QueryParam = string | number | boolean | null | undefined | bigint | Uint8Array;
2036
2380
  /**
2037
2381
  * Options for building a query with {@link AbstractPowerSyncDatabase#query}.
2038
2382
  * This query will be executed with {@link AbstractPowerSyncDatabase#getAll}.
2383
+ *
2384
+ * @public
2039
2385
  */
2040
2386
  interface ArrayQueryDefinition<RowType = unknown> {
2041
2387
  sql: string;
@@ -2054,6 +2400,8 @@ interface ArrayQueryDefinition<RowType = unknown> {
2054
2400
  }
2055
2401
  /**
2056
2402
  * Options for {@link Query#watch}.
2403
+ *
2404
+ * @public
2057
2405
  */
2058
2406
  interface StandardWatchedQueryOptions<RowType> extends WatchedQueryOptions {
2059
2407
  /**
@@ -2078,6 +2426,9 @@ interface StandardWatchedQueryOptions<RowType> extends WatchedQueryOptions {
2078
2426
  */
2079
2427
  placeholderData?: RowType[];
2080
2428
  }
2429
+ /**
2430
+ * @public
2431
+ */
2081
2432
  interface Query<RowType> {
2082
2433
  /**
2083
2434
  * Creates a {@link WatchedQuery} which watches and emits results of the linked query.
@@ -2123,6 +2474,9 @@ interface Query<RowType> {
2123
2474
  differentialWatch(options?: DifferentialWatchedQueryOptions<RowType>): DifferentialWatchedQuery<RowType>;
2124
2475
  }
2125
2476
 
2477
+ /**
2478
+ * @public
2479
+ */
2126
2480
  interface SQLOpenOptions {
2127
2481
  /**
2128
2482
  * Filename for the database.
@@ -2146,6 +2500,9 @@ interface SQLOpenOptions {
2146
2500
  */
2147
2501
  debugMode?: boolean;
2148
2502
  }
2503
+ /**
2504
+ * @public
2505
+ */
2149
2506
  interface SQLOpenFactory {
2150
2507
  /**
2151
2508
  * Opens a connection adapter to a SQLite DB
@@ -2154,17 +2511,26 @@ interface SQLOpenFactory {
2154
2511
  }
2155
2512
  /**
2156
2513
  * Tests if the input is a {@link SQLOpenOptions}
2514
+ *
2515
+ * @internal
2157
2516
  */
2158
2517
  declare const isSQLOpenOptions: (test: any) => test is SQLOpenOptions;
2159
2518
  /**
2160
2519
  * Tests if input is a {@link SQLOpenFactory}
2520
+ *
2521
+ * @internal
2161
2522
  */
2162
2523
  declare const isSQLOpenFactory: (test: any) => test is SQLOpenFactory;
2163
2524
  /**
2164
2525
  * Tests if input is a {@link DBAdapter}
2526
+ *
2527
+ * @internal
2165
2528
  */
2166
2529
  declare const isDBAdapter: (test: any) => test is DBAdapter;
2167
2530
 
2531
+ /**
2532
+ * @public
2533
+ */
2168
2534
  declare class CrudTransaction extends CrudBatch {
2169
2535
  /**
2170
2536
  * List of client-side changes.
@@ -2195,7 +2561,8 @@ declare class CrudTransaction extends CrudBatch {
2195
2561
 
2196
2562
  /**
2197
2563
  * SQLite operations to track changes for with {@link TriggerManager}
2198
- * @experimental
2564
+ *
2565
+ * @experimental @alpha
2199
2566
  */
2200
2567
  declare enum DiffTriggerOperation {
2201
2568
  INSERT = "INSERT",
@@ -2203,7 +2570,7 @@ declare enum DiffTriggerOperation {
2203
2570
  DELETE = "DELETE"
2204
2571
  }
2205
2572
  /**
2206
- * @experimental
2573
+ * @experimental @alpha
2207
2574
  * Diffs created by {@link TriggerManager#createDiffTrigger} are stored in a temporary table.
2208
2575
  * This is the base record structure for all diff records.
2209
2576
  *
@@ -2232,7 +2599,7 @@ interface BaseTriggerDiffRecord<TOperationId extends string | number = number> {
2232
2599
  timestamp: string;
2233
2600
  }
2234
2601
  /**
2235
- * @experimental
2602
+ * @experimental @alpha
2236
2603
  * Represents a diff record for a SQLite UPDATE operation.
2237
2604
  * This record contains the new value and optionally the previous value.
2238
2605
  * Values are stored as JSON strings.
@@ -2249,7 +2616,7 @@ interface TriggerDiffUpdateRecord<TOperationId extends string | number = number>
2249
2616
  previous_value: string;
2250
2617
  }
2251
2618
  /**
2252
- * @experimental
2619
+ * @experimental @alpha
2253
2620
  * Represents a diff record for a SQLite INSERT operation.
2254
2621
  * This record contains the new value represented as a JSON string.
2255
2622
  */
@@ -2261,7 +2628,7 @@ interface TriggerDiffInsertRecord<TOperationId extends string | number = number>
2261
2628
  value: string;
2262
2629
  }
2263
2630
  /**
2264
- * @experimental
2631
+ * @experimental @alpha
2265
2632
  * Represents a diff record for a SQLite DELETE operation.
2266
2633
  * This record contains the new value represented as a JSON string.
2267
2634
  */
@@ -2273,7 +2640,7 @@ interface TriggerDiffDeleteRecord<TOperationId extends string | number = number>
2273
2640
  value: string;
2274
2641
  }
2275
2642
  /**
2276
- * @experimental
2643
+ * @experimental @alpha
2277
2644
  * Diffs created by {@link TriggerManager#createDiffTrigger} are stored in a temporary table.
2278
2645
  * This is the record structure for all diff records.
2279
2646
  *
@@ -2298,7 +2665,7 @@ interface TriggerDiffDeleteRecord<TOperationId extends string | number = number>
2298
2665
  */
2299
2666
  type TriggerDiffRecord<TOperationId extends string | number = number> = TriggerDiffUpdateRecord<TOperationId> | TriggerDiffInsertRecord<TOperationId> | TriggerDiffDeleteRecord<TOperationId>;
2300
2667
  /**
2301
- * @experimental
2668
+ * @experimental @alpha
2302
2669
  * Querying the DIFF table directly with {@link TriggerDiffHandlerContext#withExtractedDiff} will return records
2303
2670
  * with the tracked columns extracted from the JSON value.
2304
2671
  * This type represents the structure of such records.
@@ -2326,7 +2693,7 @@ type ExtractedTriggerDiffRecord<T, TOperationId extends string | number = number
2326
2693
  __previous_value?: string;
2327
2694
  };
2328
2695
  /**
2329
- * @experimental
2696
+ * @experimental @alpha
2330
2697
  * Hooks used in the creation of a table diff trigger.
2331
2698
  */
2332
2699
  interface TriggerCreationHooks {
@@ -2382,7 +2749,7 @@ interface BaseCreateDiffTriggerOptions {
2382
2749
  useStorage?: boolean;
2383
2750
  }
2384
2751
  /**
2385
- * @experimental
2752
+ * @experimental @alpha
2386
2753
  * Options for {@link TriggerManager#createDiffTrigger}.
2387
2754
  */
2388
2755
  interface CreateDiffTriggerOptions extends BaseCreateDiffTriggerOptions {
@@ -2399,19 +2766,19 @@ interface CreateDiffTriggerOptions extends BaseCreateDiffTriggerOptions {
2399
2766
  setupContext?: LockContext;
2400
2767
  }
2401
2768
  /**
2402
- * @experimental
2769
+ * @experimental @alpha
2403
2770
  * Options for {@link TriggerRemoveCallback}.
2404
2771
  */
2405
2772
  interface TriggerRemoveCallbackOptions {
2406
2773
  context?: LockContext;
2407
2774
  }
2408
2775
  /**
2409
- * @experimental
2776
+ * @experimental @alpha
2410
2777
  * Callback to drop a trigger after it has been created.
2411
2778
  */
2412
2779
  type TriggerRemoveCallback = (options?: TriggerRemoveCallbackOptions) => Promise<void>;
2413
2780
  /**
2414
- * @experimental
2781
+ * @experimental @alpha
2415
2782
  * Options for {@link TriggerDiffHandlerContext#withDiff}.
2416
2783
  */
2417
2784
  interface WithDiffOptions {
@@ -2425,7 +2792,7 @@ interface WithDiffOptions {
2425
2792
  castOperationIdAsText?: boolean;
2426
2793
  }
2427
2794
  /**
2428
- * @experimental
2795
+ * @experimental @alpha
2429
2796
  * Context for the `onChange` handler provided to {@link TriggerManager#trackTableDiff}.
2430
2797
  */
2431
2798
  interface TriggerDiffHandlerContext extends LockContext {
@@ -2480,7 +2847,7 @@ interface TriggerDiffHandlerContext extends LockContext {
2480
2847
  * Allows querying the database with access to the table containing diff records.
2481
2848
  * The diff table is accessible via the `DIFF` accessor.
2482
2849
  *
2483
- * This is similar to {@link withDiff} but extracts the row columns from the tracked JSON value. The diff operation
2850
+ * This is similar to {@link TriggerDiffHandlerContext#withDiff} but extracts the row columns from the tracked JSON value. The diff operation
2484
2851
  * data is aliased as `__` columns to avoid column conflicts.
2485
2852
  *
2486
2853
  * For {@link DiffTriggerOperation#DELETE} operations the previous_value columns are extracted for convenience.
@@ -2511,7 +2878,7 @@ interface TriggerDiffHandlerContext extends LockContext {
2511
2878
  withExtractedDiff: <T = any>(query: string, params?: ReadonlyArray<Readonly<any>>) => Promise<T[]>;
2512
2879
  }
2513
2880
  /**
2514
- * @experimental
2881
+ * @experimental @alpha
2515
2882
  * Options for tracking changes to a table with {@link TriggerManager#trackTableDiff}.
2516
2883
  */
2517
2884
  interface TrackDiffOptions extends BaseCreateDiffTriggerOptions {
@@ -2522,13 +2889,13 @@ interface TrackDiffOptions extends BaseCreateDiffTriggerOptions {
2522
2889
  */
2523
2890
  onChange: (context: TriggerDiffHandlerContext) => Promise<void>;
2524
2891
  /**
2525
- * The minimum interval, in milliseconds, between {@link onChange} invocations.
2892
+ * The minimum interval, in milliseconds, between {@link TrackDiffOptions.onChange} invocations.
2526
2893
  * @default {@link DEFAULT_WATCH_THROTTLE_MS}
2527
2894
  */
2528
2895
  throttleMs?: number;
2529
2896
  }
2530
2897
  /**
2531
- * @experimental
2898
+ * @experimental @alpha
2532
2899
  */
2533
2900
  interface TriggerManager {
2534
2901
  /**
@@ -2576,7 +2943,7 @@ interface TriggerManager {
2576
2943
  /**
2577
2944
  * @experimental
2578
2945
  * Tracks changes for a table. Triggering a provided handler on changes.
2579
- * Uses {@link createDiffTrigger} internally to create a temporary destination table.
2946
+ * Uses {@link TriggerManager.createDiffTrigger} internally to create a temporary destination table.
2580
2947
  *
2581
2948
  * @returns A callback to cleanup the trigger and stop tracking changes.
2582
2949
  *
@@ -2682,7 +3049,7 @@ declare class TriggerManagerImpl implements TriggerManager {
2682
3049
  protected isDisposed: boolean;
2683
3050
  constructor(options: TriggerManagerImplOptions);
2684
3051
  protected get db(): AbstractPowerSyncDatabase;
2685
- protected getUUID(): Promise<string>;
3052
+ protected getUUID(ctx?: LockContext): Promise<string>;
2686
3053
  protected removeTriggers(tx: LockContext, triggerIds: string[]): Promise<void>;
2687
3054
  dispose(): void;
2688
3055
  /**
@@ -2698,6 +3065,9 @@ declare class TriggerManagerImpl implements TriggerManager {
2698
3065
  trackTableDiff(options: TrackDiffOptions): Promise<TriggerRemoveCallback>;
2699
3066
  }
2700
3067
 
3068
+ /**
3069
+ * @internal
3070
+ */
2701
3071
  type UnlockFn = () => void;
2702
3072
  /**
2703
3073
  * An asynchronous semaphore implementation with associated items per lease.
@@ -2744,23 +3114,38 @@ declare class Mutex {
2744
3114
  }
2745
3115
  /**
2746
3116
  * Creates a signal aborting after the set timeout.
3117
+ *
3118
+ * @internal
2747
3119
  */
2748
3120
  declare function timeoutSignal(timeout: number): AbortSignal;
3121
+ /**
3122
+ * @internal
3123
+ */
2749
3124
  declare function timeoutSignal(timeout?: number): AbortSignal | undefined;
2750
3125
 
3126
+ /**
3127
+ * @public
3128
+ */
2751
3129
  interface DisconnectAndClearOptions {
2752
3130
  /** When set to false, data in local-only tables is preserved. */
2753
3131
  clearLocal?: boolean;
2754
3132
  }
3133
+ /**
3134
+ * @public
3135
+ */
2755
3136
  interface BasePowerSyncDatabaseOptions extends AdditionalConnectionOptions {
2756
3137
  /** Schema used for the local database. */
2757
3138
  schema: Schema;
2758
3139
  /**
2759
- * @deprecated Use {@link retryDelayMs} instead as this will be removed in future releases.
3140
+ * @deprecated Use {@link AdditionalConnectionOptions.retryDelayMs} instead as this will be removed in future
3141
+ * releases.
2760
3142
  */
2761
3143
  retryDelay?: number;
2762
3144
  logger?: ILogger;
2763
3145
  }
3146
+ /**
3147
+ * @public
3148
+ */
2764
3149
  interface PowerSyncDatabaseOptions extends BasePowerSyncDatabaseOptions {
2765
3150
  /**
2766
3151
  * Source for a SQLite database connection.
@@ -2771,22 +3156,35 @@ interface PowerSyncDatabaseOptions extends BasePowerSyncDatabaseOptions {
2771
3156
  */
2772
3157
  database: DBAdapter | SQLOpenFactory | SQLOpenOptions;
2773
3158
  }
3159
+ /**
3160
+ * @public
3161
+ */
2774
3162
  interface PowerSyncDatabaseOptionsWithDBAdapter extends BasePowerSyncDatabaseOptions {
2775
3163
  database: DBAdapter;
2776
3164
  }
3165
+ /**
3166
+ * @public
3167
+ */
2777
3168
  interface PowerSyncDatabaseOptionsWithOpenFactory extends BasePowerSyncDatabaseOptions {
2778
3169
  database: SQLOpenFactory;
2779
3170
  }
3171
+ /**
3172
+ * @public
3173
+ */
2780
3174
  interface PowerSyncDatabaseOptionsWithSettings extends BasePowerSyncDatabaseOptions {
2781
3175
  database: SQLOpenOptions;
2782
3176
  }
3177
+ /**
3178
+ * @public
3179
+ */
2783
3180
  interface SQLOnChangeOptions {
2784
3181
  signal?: AbortSignal;
2785
3182
  tables?: string[];
2786
3183
  /** The minimum interval between queries. */
2787
3184
  throttleMs?: number;
2788
3185
  /**
2789
- * @deprecated All tables specified in {@link tables} will be watched, including PowerSync tables with prefixes.
3186
+ * @deprecated All tables specified in {@link SQLOnChangeOptions.tables} will be watched, including PowerSync tables
3187
+ * with prefixes.
2790
3188
  *
2791
3189
  * Allows for watching any SQL table
2792
3190
  * by not removing PowerSync table name prefixes
@@ -2797,6 +3195,9 @@ interface SQLOnChangeOptions {
2797
3195
  */
2798
3196
  triggerImmediate?: boolean;
2799
3197
  }
3198
+ /**
3199
+ * @public
3200
+ */
2800
3201
  interface SQLWatchOptions extends SQLOnChangeOptions {
2801
3202
  /**
2802
3203
  * Optional comparator which will be used to compare the results of the query.
@@ -2804,23 +3205,38 @@ interface SQLWatchOptions extends SQLOnChangeOptions {
2804
3205
  */
2805
3206
  comparator?: WatchedQueryComparator<QueryResult>;
2806
3207
  }
3208
+ /**
3209
+ * @public
3210
+ */
2807
3211
  interface WatchOnChangeEvent {
2808
3212
  changedTables: string[];
2809
3213
  }
3214
+ /**
3215
+ * @public
3216
+ */
2810
3217
  interface WatchHandler {
2811
3218
  onResult: (results: QueryResult) => void;
2812
3219
  onError?: (error: Error) => void;
2813
3220
  }
3221
+ /**
3222
+ * @public
3223
+ */
2814
3224
  interface WatchOnChangeHandler {
2815
3225
  onChange: (event: WatchOnChangeEvent) => Promise<void> | void;
2816
3226
  onError?: (error: Error) => void;
2817
3227
  }
3228
+ /**
3229
+ * @public
3230
+ */
2818
3231
  interface PowerSyncDBListener extends StreamingSyncImplementationListener {
2819
3232
  initialized: () => void;
2820
3233
  schemaChanged: (schema: Schema) => void;
2821
3234
  closing: () => Promise<void> | void;
2822
3235
  closed: () => Promise<void> | void;
2823
3236
  }
3237
+ /**
3238
+ * @public
3239
+ */
2824
3240
  interface PowerSyncCloseOptions {
2825
3241
  /**
2826
3242
  * Disconnect the sync stream client if connected.
@@ -2829,16 +3245,27 @@ interface PowerSyncCloseOptions {
2829
3245
  */
2830
3246
  disconnect?: boolean;
2831
3247
  }
3248
+ /**
3249
+ * @internal
3250
+ */
2832
3251
  declare const DEFAULT_POWERSYNC_CLOSE_OPTIONS: PowerSyncCloseOptions;
3252
+ /**
3253
+ * @internal
3254
+ */
2833
3255
  declare const DEFAULT_POWERSYNC_DB_OPTIONS: {
2834
3256
  retryDelayMs: number;
2835
3257
  crudUploadThrottleMs: number;
2836
3258
  };
3259
+ /**
3260
+ * @internal
3261
+ */
2837
3262
  declare const DEFAULT_CRUD_BATCH_LIMIT = 100;
2838
3263
  /**
2839
3264
  * Requesting nested or recursive locks can block the application in some circumstances.
2840
3265
  * This default lock timeout will act as a failsafe to throw an error if a lock cannot
2841
3266
  * be obtained.
3267
+ *
3268
+ * @internal
2842
3269
  */
2843
3270
  declare const DEFAULT_LOCK_TIMEOUT_MS = 120000;
2844
3271
  /**
@@ -2846,6 +3273,9 @@ declare const DEFAULT_LOCK_TIMEOUT_MS = 120000;
2846
3273
  * @internal
2847
3274
  */
2848
3275
  declare const isPowerSyncDatabaseOptionsWithSettings: (test: any) => test is PowerSyncDatabaseOptionsWithSettings;
3276
+ /**
3277
+ * @public
3278
+ */
2849
3279
  declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDBListener> {
2850
3280
  protected options: PowerSyncDatabaseOptions;
2851
3281
  /**
@@ -2924,7 +3354,7 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
2924
3354
  /**
2925
3355
  * Wait for the first sync operation to complete.
2926
3356
  *
2927
- * @param request Either an abort signal (after which the promise will complete regardless of
3357
+ * @param request - Either an abort signal (after which the promise will complete regardless of
2928
3358
  * whether a full sync was completed) or an object providing an abort signal and a priority target.
2929
3359
  * When a priority target is set, the promise may complete when all buckets with the given (or higher)
2930
3360
  * priorities have been synchronized. This can be earlier than a complete sync.
@@ -2979,7 +3409,7 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
2979
3409
  /**
2980
3410
  * Close the sync connection.
2981
3411
  *
2982
- * Use {@link connect} to connect again.
3412
+ * Use {@link AbstractPowerSyncDatabase.connect} to connect again.
2983
3413
  */
2984
3414
  disconnect(): Promise<void>;
2985
3415
  /**
@@ -2994,8 +3424,8 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
2994
3424
  /**
2995
3425
  * Create a sync stream to query its status or to subscribe to it.
2996
3426
  *
2997
- * @param name The name of the stream to subscribe to.
2998
- * @param params Optional parameters for the stream subscription.
3427
+ * @param name - The name of the stream to subscribe to.
3428
+ * @param params - Optional parameters for the stream subscription.
2999
3429
  * @returns A {@link SyncStream} instance that can be subscribed to.
3000
3430
  * @experimental Sync streams are currently in alpha.
3001
3431
  */
@@ -3023,14 +3453,14 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
3023
3453
  * Once the data have been successfully uploaded, call {@link CrudBatch.complete} before
3024
3454
  * requesting the next batch.
3025
3455
  *
3026
- * Use {@link limit} to specify the maximum number of updates to return in a single
3456
+ * Use the `limit` parameter to specify the maximum number of updates to return in a single
3027
3457
  * batch.
3028
3458
  *
3029
3459
  * This method does include transaction ids in the result, but does not group
3030
3460
  * data by transaction. One batch may contain data from multiple transactions,
3031
3461
  * and a single transaction may be split over multiple batches.
3032
3462
  *
3033
- * @param limit Maximum number of CRUD entries to include in the batch
3463
+ * @param limit - Maximum number of CRUD entries to include in the batch
3034
3464
  * @returns A batch of CRUD operations to upload, or null if there are none
3035
3465
  */
3036
3466
  getCrudBatch(limit?: number): Promise<CrudBatch | null>;
@@ -3044,7 +3474,7 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
3044
3474
  * Once the data have been successfully uploaded, call {@link CrudTransaction.complete} before
3045
3475
  * requesting the next transaction.
3046
3476
  *
3047
- * Unlike {@link getCrudBatch}, this only returns data from a single transaction at a time.
3477
+ * Unlike {@link AbstractPowerSyncDatabase.getCrudBatch}, this only returns data from a single transaction at a time.
3048
3478
  * All data for the transaction is loaded into memory.
3049
3479
  *
3050
3480
  * @returns A transaction of CRUD operations to upload, or null if there are none
@@ -3056,7 +3486,7 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
3056
3486
  * This is typically used from the {@link PowerSyncBackendConnector.uploadData} callback. Each entry emitted by the
3057
3487
  * returned iterator is a full transaction containing all local writes made while that transaction was active.
3058
3488
  *
3059
- * Unlike {@link getNextCrudTransaction}, which always returns the oldest transaction that hasn't been
3489
+ * Unlike {@link AbstractPowerSyncDatabase.getNextCrudTransaction}, which always returns the oldest transaction that hasn't been
3060
3490
  * {@link CrudTransaction.complete}d yet, this iterator can be used to receive multiple transactions. Calling
3061
3491
  * {@link CrudTransaction.complete} will mark that and all prior transactions emitted by the iterator as completed.
3062
3492
  *
@@ -3099,8 +3529,8 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
3099
3529
  * the returned result's `rowsAffected` may be `0` for successful `UPDATE` and `DELETE` statements.
3100
3530
  * Use a `RETURNING` clause and inspect `result.rows` when you need to confirm which rows changed.
3101
3531
  *
3102
- * @param sql The SQL query to execute
3103
- * @param parameters Optional array of parameters to bind to the query
3532
+ * @param sql - The SQL query to execute
3533
+ * @param parameters - Optional array of parameters to bind to the query
3104
3534
  * @returns The query result as an object with structured key-value pairs
3105
3535
  */
3106
3536
  execute(sql: string, parameters?: any[]): Promise<QueryResult>;
@@ -3108,8 +3538,8 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
3108
3538
  * Execute a SQL write (INSERT/UPDATE/DELETE) query directly on the database without any PowerSync processing.
3109
3539
  * This bypasses certain PowerSync abstractions and is useful for accessing the raw database results.
3110
3540
  *
3111
- * @param sql The SQL query to execute
3112
- * @param parameters Optional array of parameters to bind to the query
3541
+ * @param sql - The SQL query to execute
3542
+ * @param parameters - Optional array of parameters to bind to the query
3113
3543
  * @returns The raw query result from the underlying database as a nested array of raw values, where each row is
3114
3544
  * represented as an array of column values without field names.
3115
3545
  */
@@ -3119,53 +3549,53 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
3119
3549
  * and optionally return results.
3120
3550
  * This is faster than executing separately with each parameter set.
3121
3551
  *
3122
- * @param sql The SQL query to execute
3123
- * @param parameters Optional 2D array of parameter sets, where each inner array is a set of parameters for one execution
3552
+ * @param sql - The SQL query to execute
3553
+ * @param parameters - Optional 2D array of parameter sets, where each inner array is a set of parameters for one execution
3124
3554
  * @returns The query result
3125
3555
  */
3126
3556
  executeBatch(sql: string, parameters?: any[][]): Promise<QueryResult>;
3127
3557
  /**
3128
3558
  * Execute a read-only query and return results.
3129
3559
  *
3130
- * @param sql The SQL query to execute
3131
- * @param parameters Optional array of parameters to bind to the query
3560
+ * @param sql - The SQL query to execute
3561
+ * @param parameters - Optional array of parameters to bind to the query
3132
3562
  * @returns An array of results
3133
3563
  */
3134
3564
  getAll<T>(sql: string, parameters?: any[]): Promise<T[]>;
3135
3565
  /**
3136
3566
  * Execute a read-only query and return the first result, or null if the ResultSet is empty.
3137
3567
  *
3138
- * @param sql The SQL query to execute
3139
- * @param parameters Optional array of parameters to bind to the query
3568
+ * @param sql - The SQL query to execute
3569
+ * @param parameters - Optional array of parameters to bind to the query
3140
3570
  * @returns The first result if found, or null if no results are returned
3141
3571
  */
3142
3572
  getOptional<T>(sql: string, parameters?: any[]): Promise<T | null>;
3143
3573
  /**
3144
3574
  * Execute a read-only query and return the first result, error if the ResultSet is empty.
3145
3575
  *
3146
- * @param sql The SQL query to execute
3147
- * @param parameters Optional array of parameters to bind to the query
3576
+ * @param sql - The SQL query to execute
3577
+ * @param parameters - Optional array of parameters to bind to the query
3148
3578
  * @returns The first result matching the query
3149
3579
  * @throws Error if no rows are returned
3150
3580
  */
3151
3581
  get<T>(sql: string, parameters?: any[]): Promise<T>;
3152
3582
  /**
3153
3583
  * Takes a read lock, without starting a transaction.
3154
- * In most cases, {@link readTransaction} should be used instead.
3584
+ * In most cases, {@link AbstractPowerSyncDatabase.readTransaction} should be used instead.
3155
3585
  */
3156
- readLock<T>(callback: (db: DBAdapter) => Promise<T>): Promise<T>;
3586
+ readLock<T>(callback: (db: LockContext) => Promise<T>): Promise<T>;
3157
3587
  /**
3158
3588
  * Takes a global lock, without starting a transaction.
3159
- * In most cases, {@link writeTransaction} should be used instead.
3589
+ * In most cases, {@link AbstractPowerSyncDatabase.writeTransaction} should be used instead.
3160
3590
  */
3161
- writeLock<T>(callback: (db: DBAdapter) => Promise<T>): Promise<T>;
3591
+ writeLock<T>(callback: (db: LockContext) => Promise<T>): Promise<T>;
3162
3592
  /**
3163
3593
  * Open a read-only transaction.
3164
3594
  * Read transactions can run concurrently to a write transaction.
3165
3595
  * Changes from any write transaction are not visible to read transactions started before it.
3166
3596
  *
3167
- * @param callback Function to execute within the transaction
3168
- * @param lockTimeout Time in milliseconds to wait for a lock before throwing an error
3597
+ * @param callback - Function to execute within the transaction
3598
+ * @param lockTimeout - Time in milliseconds to wait for a lock before throwing an error
3169
3599
  * @returns The result of the callback
3170
3600
  * @throws Error if the lock cannot be obtained within the timeout period
3171
3601
  */
@@ -3175,15 +3605,15 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
3175
3605
  * This takes a global lock - only one write transaction can execute against the database at a time.
3176
3606
  * Statements within the transaction must be done on the provided {@link Transaction} interface.
3177
3607
  *
3178
- * @param callback Function to execute within the transaction
3179
- * @param lockTimeout Time in milliseconds to wait for a lock before throwing an error
3608
+ * @param callback - Function to execute within the transaction
3609
+ * @param lockTimeout - Time in milliseconds to wait for a lock before throwing an error
3180
3610
  * @returns The result of the callback
3181
3611
  * @throws Error if the lock cannot be obtained within the timeout period
3182
3612
  */
3183
3613
  writeTransaction<T>(callback: (tx: Transaction) => Promise<T>, lockTimeout?: number): Promise<T>;
3184
3614
  /**
3185
- * This version of `watch` uses {@link AsyncGenerator}, for documentation see {@link watchWithAsyncGenerator}.
3186
- * Can be overloaded to use a callback handler instead, for documentation see {@link watchWithCallback}.
3615
+ * This version of `watch` uses `AsyncGenerator`, for documentation see {@link AbstractPowerSyncDatabase.watchWithAsyncGenerator}.
3616
+ * Can be overloaded to use a callback handler instead, for documentation see {@link AbstractPowerSyncDatabase.watchWithCallback}.
3187
3617
  *
3188
3618
  * @example
3189
3619
  * ```javascript
@@ -3199,7 +3629,7 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
3199
3629
  */
3200
3630
  watch(sql: string, parameters?: any[], options?: SQLWatchOptions): AsyncIterable<QueryResult>;
3201
3631
  /**
3202
- * See {@link watchWithCallback}.
3632
+ * See {@link AbstractPowerSyncDatabase.watchWithCallback}.
3203
3633
  *
3204
3634
  * @example
3205
3635
  * ```javascript
@@ -3253,25 +3683,25 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
3253
3683
  customQuery<RowType>(query: WatchCompatibleQuery<RowType[]>): Query<RowType>;
3254
3684
  /**
3255
3685
  * Execute a read query every time the source tables are modified.
3256
- * Use {@link SQLWatchOptions.throttleMs} to specify the minimum interval between queries.
3686
+ * Use {@link SQLOnChangeOptions.throttleMs} to specify the minimum interval between queries.
3257
3687
  * Source tables are automatically detected using `EXPLAIN QUERY PLAN`.
3258
3688
  *
3259
3689
  * Note that the `onChange` callback member of the handler is required.
3260
3690
  *
3261
- * @param sql The SQL query to execute
3262
- * @param parameters Optional array of parameters to bind to the query
3263
- * @param handler Callbacks for handling results and errors
3264
- * @param options Options for configuring watch behavior
3691
+ * @param sql - The SQL query to execute
3692
+ * @param parameters - Optional array of parameters to bind to the query
3693
+ * @param handler - Callbacks for handling results and errors
3694
+ * @param options - Options for configuring watch behavior
3265
3695
  */
3266
3696
  watchWithCallback(sql: string, parameters?: any[], handler?: WatchHandler, options?: SQLWatchOptions): void;
3267
3697
  /**
3268
3698
  * Execute a read query every time the source tables are modified.
3269
- * Use {@link SQLWatchOptions.throttleMs} to specify the minimum interval between queries.
3699
+ * Use {@link SQLOnChangeOptions.throttleMs} to specify the minimum interval between queries.
3270
3700
  * Source tables are automatically detected using `EXPLAIN QUERY PLAN`.
3271
3701
  *
3272
- * @param sql The SQL query to execute
3273
- * @param parameters Optional array of parameters to bind to the query
3274
- * @param options Options for configuring watch behavior
3702
+ * @param sql - The SQL query to execute
3703
+ * @param parameters - Optional array of parameters to bind to the query
3704
+ * @param options - Options for configuring watch behavior
3275
3705
  * @returns An AsyncIterable that yields QueryResults whenever the data changes
3276
3706
  */
3277
3707
  watchWithAsyncGenerator(sql: string, parameters?: any[], options?: SQLWatchOptions): AsyncIterable<QueryResult>;
@@ -3280,15 +3710,15 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
3280
3710
  * If tables are specified in the options, those are used directly.
3281
3711
  * Otherwise, analyzes the query using EXPLAIN to determine which tables are accessed.
3282
3712
  *
3283
- * @param sql The SQL query to analyze
3284
- * @param parameters Optional parameters for the SQL query
3285
- * @param options Optional watch options that may contain explicit table list
3713
+ * @param sql - The SQL query to analyze
3714
+ * @param parameters - Optional parameters for the SQL query
3715
+ * @param options - Optional watch options that may contain explicit table list
3286
3716
  * @returns Array of table names that the query depends on
3287
3717
  */
3288
3718
  resolveTables(sql: string, parameters?: any[], options?: SQLWatchOptions): Promise<string[]>;
3289
3719
  /**
3290
- * This version of `onChange` uses {@link AsyncGenerator}, for documentation see {@link onChangeWithAsyncGenerator}.
3291
- * Can be overloaded to use a callback handler instead, for documentation see {@link onChangeWithCallback}.
3720
+ * This version of `onChange` uses `AsyncGenerator`, for documentation see {@link AbstractPowerSyncDatabase.onChangeWithAsyncGenerator}.
3721
+ * Can be overloaded to use a callback handler instead, for documentation see {@link AbstractPowerSyncDatabase.onChangeWithCallback}.
3292
3722
  *
3293
3723
  * @example
3294
3724
  * ```javascript
@@ -3301,7 +3731,7 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
3301
3731
  */
3302
3732
  onChange(options?: SQLOnChangeOptions): AsyncIterable<WatchOnChangeEvent>;
3303
3733
  /**
3304
- * See {@link onChangeWithCallback}.
3734
+ * See {@link AbstractPowerSyncDatabase.onChangeWithCallback}.
3305
3735
  *
3306
3736
  * @example
3307
3737
  * ```javascript
@@ -3318,36 +3748,36 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
3318
3748
  /**
3319
3749
  * Invoke the provided callback on any changes to any of the specified tables.
3320
3750
  *
3321
- * This is preferred over {@link watchWithCallback} when multiple queries need to be performed
3751
+ * This is preferred over {@link AbstractPowerSyncDatabase.watchWithCallback} when multiple queries need to be performed
3322
3752
  * together when data is changed.
3323
3753
  *
3324
3754
  * Note that the `onChange` callback member of the handler is required.
3325
3755
  *
3326
- * @param handler Callbacks for handling change events and errors
3327
- * @param options Options for configuring watch behavior
3756
+ * @param handler - Callbacks for handling change events and errors
3757
+ * @param options - Options for configuring watch behavior
3328
3758
  * @returns A dispose function to stop watching for changes
3329
3759
  */
3330
3760
  onChangeWithCallback(handler?: WatchOnChangeHandler, options?: SQLOnChangeOptions): () => void;
3331
3761
  /**
3332
3762
  * Create a Stream of changes to any of the specified tables.
3333
3763
  *
3334
- * This is preferred over {@link watchWithAsyncGenerator} when multiple queries need to be performed
3335
- * together when data is changed.
3764
+ * This is preferred over {@link AbstractPowerSyncDatabase.watchWithAsyncGenerator} when multiple queries need to be
3765
+ * performed together when data is changed.
3336
3766
  *
3337
3767
  * Note: do not declare this as `async *onChange` as it will not work in React Native.
3338
3768
  *
3339
- * @param options Options for configuring watch behavior
3769
+ * @param options - Options for configuring watch behavior
3340
3770
  * @returns An AsyncIterable that yields change events whenever the specified tables change
3341
3771
  */
3342
3772
  onChangeWithAsyncGenerator(options?: SQLWatchOptions): AsyncIterable<WatchOnChangeEvent>;
3343
3773
  private handleTableChanges;
3344
3774
  private processTableUpdates;
3345
- /**
3346
- * @ignore
3347
- */
3348
3775
  private executeReadOnly;
3349
3776
  }
3350
3777
 
3778
+ /**
3779
+ * @public
3780
+ */
3351
3781
  declare const LogLevel: {
3352
3782
  TRACE: Logger.ILogLevel;
3353
3783
  DEBUG: Logger.ILogLevel;
@@ -3357,6 +3787,9 @@ declare const LogLevel: {
3357
3787
  ERROR: Logger.ILogLevel;
3358
3788
  OFF: Logger.ILogLevel;
3359
3789
  };
3790
+ /**
3791
+ * @public
3792
+ */
3360
3793
  interface CreateLoggerOptions {
3361
3794
  logLevel?: ILogLevel;
3362
3795
  }
@@ -3367,6 +3800,7 @@ interface CreateLoggerOptions {
3367
3800
  * across all loggers created with `createLogger`. Adjusting settings on this
3368
3801
  * base logger affects all loggers derived from it unless explicitly overridden.
3369
3802
  *
3803
+ * @public
3370
3804
  */
3371
3805
  declare function createBaseLogger(): typeof Logger;
3372
3806
  /**
@@ -3375,14 +3809,21 @@ declare function createBaseLogger(): typeof Logger;
3375
3809
  * Named loggers allow specific modules or areas of your application to have
3376
3810
  * their own logging levels and behaviors. These loggers inherit configuration
3377
3811
  * from the base logger by default but can override settings independently.
3812
+ *
3813
+ * @public
3378
3814
  */
3379
3815
  declare function createLogger(name: string, options?: CreateLoggerOptions): ILogger;
3380
3816
 
3817
+ /**
3818
+ * The default name of the local table storing attachment data.
3819
+ *
3820
+ * @alpha
3821
+ */
3381
3822
  declare const ATTACHMENT_TABLE = "attachments";
3382
3823
  /**
3383
3824
  * AttachmentRecord represents an attachment in the local database.
3384
3825
  *
3385
- * @experimental
3826
+ * @alpha
3386
3827
  */
3387
3828
  interface AttachmentRecord {
3388
3829
  id: string;
@@ -3401,13 +3842,13 @@ interface AttachmentRecord {
3401
3842
  * @param row - The database row object
3402
3843
  * @returns The corresponding AttachmentRecord
3403
3844
  *
3404
- * @experimental
3845
+ * @alpha
3405
3846
  */
3406
3847
  declare function attachmentFromSql(row: any): AttachmentRecord;
3407
3848
  /**
3408
3849
  * AttachmentState represents the current synchronization state of an attachment.
3409
3850
  *
3410
- * @experimental
3851
+ * @alpha
3411
3852
  */
3412
3853
  declare enum AttachmentState {
3413
3854
  QUEUED_UPLOAD = 0,// Attachment to be uploaded
@@ -3416,12 +3857,15 @@ declare enum AttachmentState {
3416
3857
  SYNCED = 3,// Attachment has been synced
3417
3858
  ARCHIVED = 4
3418
3859
  }
3860
+ /**
3861
+ * @alpha
3862
+ */
3419
3863
  interface AttachmentTableOptions extends Omit<TableV2Options, 'name' | 'columns'> {
3420
3864
  }
3421
3865
  /**
3422
3866
  * AttachmentTable defines the schema for the attachment queue table.
3423
3867
  *
3424
- * @internal
3868
+ * @alpha
3425
3869
  */
3426
3870
  declare class AttachmentTable extends Table {
3427
3871
  constructor(options?: AttachmentTableOptions);
@@ -3433,17 +3877,18 @@ declare class AttachmentTable extends Table {
3433
3877
  * Provides methods to query, insert, update, and delete attachment records with
3434
3878
  * proper transaction management through PowerSync.
3435
3879
  *
3436
- * @internal
3880
+ * @experimental
3881
+ * @alpha
3437
3882
  */
3438
3883
  declare class AttachmentContext {
3439
3884
  /** PowerSync database instance for executing queries */
3440
- db: AbstractPowerSyncDatabase;
3885
+ readonly db: AbstractPowerSyncDatabase;
3441
3886
  /** Name of the database table storing attachment records */
3442
- tableName: string;
3887
+ readonly tableName: string;
3443
3888
  /** Logger instance for diagnostic information */
3444
- logger: ILogger;
3889
+ readonly logger: ILogger;
3445
3890
  /** Maximum number of archived attachments to keep before cleanup */
3446
- archivedCacheLimit: number;
3891
+ readonly archivedCacheLimit: number;
3447
3892
  /**
3448
3893
  * Creates a new AttachmentContext instance.
3449
3894
  *
@@ -3520,28 +3965,34 @@ declare class AttachmentContext {
3520
3965
  interface AttachmentErrorHandler {
3521
3966
  /**
3522
3967
  * Handles a download error for a specific attachment.
3523
- * @param attachment The attachment that failed to download
3524
- * @param error The error encountered during the download
3968
+ * @param attachment - The attachment that failed to download
3969
+ * @param error - The error encountered during the download
3525
3970
  * @returns `true` to retry the operation, `false` to archive the attachment
3526
3971
  */
3527
3972
  onDownloadError(attachment: AttachmentRecord, error: unknown): Promise<boolean>;
3528
3973
  /**
3529
3974
  * Handles an upload error for a specific attachment.
3530
- * @param attachment The attachment that failed to upload
3531
- * @param error The error encountered during the upload
3975
+ * @param attachment - The attachment that failed to upload
3976
+ * @param error - The error encountered during the upload
3532
3977
  * @returns `true` to retry the operation, `false` to archive the attachment
3533
3978
  */
3534
3979
  onUploadError(attachment: AttachmentRecord, error: unknown): Promise<boolean>;
3535
3980
  /**
3536
3981
  * Handles a delete error for a specific attachment.
3537
- * @param attachment The attachment that failed to delete
3538
- * @param error The error encountered during the delete
3982
+ * @param attachment - The attachment that failed to delete
3983
+ * @param error - The error encountered during the delete
3539
3984
  * @returns `true` to retry the operation, `false` to archive the attachment
3540
3985
  */
3541
3986
  onDeleteError(attachment: AttachmentRecord, error: unknown): Promise<boolean>;
3542
3987
  }
3543
3988
 
3989
+ /**
3990
+ * @alpha
3991
+ */
3544
3992
  type AttachmentData = ArrayBuffer | string;
3993
+ /**
3994
+ * @alpha
3995
+ */
3545
3996
  declare enum EncodingType {
3546
3997
  UTF8 = "utf8",
3547
3998
  Base64 = "base64"
@@ -3556,36 +4007,36 @@ declare enum EncodingType {
3556
4007
  interface LocalStorageAdapter {
3557
4008
  /**
3558
4009
  * Saves data to a local file.
3559
- * @param filePath Path where the file will be stored
3560
- * @param data Data to store (ArrayBuffer, Blob, or string)
4010
+ * @param filePath - Path where the file will be stored
4011
+ * @param data - Data to store (ArrayBuffer, Blob, or string)
3561
4012
  * @returns Number of bytes written
3562
4013
  */
3563
4014
  saveFile(filePath: string, data: AttachmentData): Promise<number>;
3564
4015
  /**
3565
4016
  * Retrieves file data as an ArrayBuffer.
3566
- * @param filePath Path where the file is stored
4017
+ * @param filePath - Path where the file is stored
3567
4018
  * @returns ArrayBuffer containing the file data
3568
4019
  */
3569
4020
  readFile(filePath: string): Promise<ArrayBuffer>;
3570
4021
  /**
3571
4022
  * Deletes the file at the given path.
3572
- * @param filePath Path where the file is stored
4023
+ * @param filePath - Path where the file is stored
3573
4024
  */
3574
4025
  deleteFile(filePath: string): Promise<void>;
3575
4026
  /**
3576
4027
  * Checks if a file exists at the given path.
3577
- * @param filePath Path where the file is stored
4028
+ * @param filePath - Path where the file is stored
3578
4029
  * @returns True if the file exists, false otherwise
3579
4030
  */
3580
4031
  fileExists(filePath: string): Promise<boolean>;
3581
4032
  /**
3582
4033
  * Creates a directory at the specified path.
3583
- * @param path The full path to the directory
4034
+ * @param path - The full path to the directory
3584
4035
  */
3585
4036
  makeDir(path: string): Promise<void>;
3586
4037
  /**
3587
4038
  * Removes a directory at the specified path.
3588
- * @param path The full path to the directory
4039
+ * @param path - The full path to the directory
3589
4040
  */
3590
4041
  rmDir(path: string): Promise<void>;
3591
4042
  /**
@@ -3598,7 +4049,7 @@ interface LocalStorageAdapter {
3598
4049
  clear(): Promise<void>;
3599
4050
  /**
3600
4051
  * Returns the file path for the provided filename in the storage directory.
3601
- * @param filename The filename to get the path for
4052
+ * @param filename - The filename to get the path for
3602
4053
  * @returns The full file path
3603
4054
  */
3604
4055
  getLocalUri(filename: string): string;
@@ -3614,19 +4065,19 @@ interface LocalStorageAdapter {
3614
4065
  interface RemoteStorageAdapter {
3615
4066
  /**
3616
4067
  * Uploads a file to remote storage.
3617
- * @param fileData The binary content of the file to upload
3618
- * @param attachment The associated attachment metadata
4068
+ * @param fileData - The binary content of the file to upload
4069
+ * @param attachment - The associated attachment metadata
3619
4070
  */
3620
4071
  uploadFile(fileData: ArrayBuffer, attachment: AttachmentRecord): Promise<void>;
3621
4072
  /**
3622
4073
  * Downloads a file from remote storage.
3623
- * @param attachment The attachment describing the file to download
4074
+ * @param attachment - The attachment describing the file to download
3624
4075
  * @returns The binary data of the downloaded file
3625
4076
  */
3626
4077
  downloadFile(attachment: AttachmentRecord): Promise<ArrayBuffer>;
3627
4078
  /**
3628
4079
  * Deletes a file from remote storage.
3629
- * @param attachment The attachment describing the file to delete
4080
+ * @param attachment - The attachment describing the file to delete
3630
4081
  */
3631
4082
  deleteFile(attachment: AttachmentRecord): Promise<void>;
3632
4083
  }
@@ -3635,18 +4086,20 @@ interface RemoteStorageAdapter {
3635
4086
  * WatchedAttachmentItem represents an attachment reference in your application's data model.
3636
4087
  * Use either filename OR fileExtension (not both).
3637
4088
  *
3638
- * @experimental
4089
+ * @alpha
3639
4090
  */
3640
4091
  type WatchedAttachmentItem = {
3641
4092
  id: string;
3642
4093
  filename: string;
3643
4094
  fileExtension?: never;
3644
4095
  metaData?: string;
4096
+ mediaType?: string;
3645
4097
  } | {
3646
4098
  id: string;
3647
4099
  fileExtension: string;
3648
4100
  filename?: never;
3649
4101
  metaData?: string;
4102
+ mediaType?: string;
3650
4103
  };
3651
4104
 
3652
4105
  /**
@@ -3658,7 +4111,7 @@ type WatchedAttachmentItem = {
3658
4111
  * @experimental
3659
4112
  * @alpha This is currently experimental and may change without a major version bump.
3660
4113
  */
3661
- declare class AttachmentQueue {
4114
+ declare class AttachmentQueue implements AttachmentQueue {
3662
4115
  /** Timer for periodic synchronization operations */
3663
4116
  private periodicSyncTimer?;
3664
4117
  /** Service for synchronizing attachments between local and remote storage */
@@ -3705,27 +4158,47 @@ declare class AttachmentQueue {
3705
4158
  * Creates a new AttachmentQueue instance.
3706
4159
  *
3707
4160
  * @param options - Configuration options
3708
- * @param options.db - PowerSync database instance
3709
- * @param options.remoteStorage - Remote storage adapter for upload/download operations
3710
- * @param options.localStorage - Local storage adapter for file persistence
3711
- * @param options.watchAttachments - Callback for monitoring attachment changes in your data model
3712
- * @param options.tableName - Name of the table to store attachment records. Default: 'ps_attachment_queue'
3713
- * @param options.logger - Logger instance. Defaults to db.logger
3714
- * @param options.syncIntervalMs - Periodic polling interval in milliseconds for retrying failed uploads/downloads. Default: 30000
3715
- * @param options.syncThrottleDuration - Throttle duration in milliseconds for the reactive watch query that detects attachment changes. Prevents rapid-fire syncs during bulk changes. Default: 30
3716
- * @param options.downloadAttachments - Whether to automatically download remote attachments. Default: true
3717
- * @param options.archivedCacheLimit - Maximum archived attachments before cleanup. Default: 100
3718
4161
  */
3719
4162
  constructor({ db, localStorage, remoteStorage, watchAttachments, logger, tableName, syncIntervalMs, syncThrottleDuration, downloadAttachments, archivedCacheLimit, errorHandler }: {
4163
+ /**
4164
+ * PowerSync database instance
4165
+ */
3720
4166
  db: AbstractPowerSyncDatabase;
4167
+ /**
4168
+ * Remote storage adapter for upload/download operations
4169
+ */
3721
4170
  remoteStorage: RemoteStorageAdapter;
4171
+ /**
4172
+ * Local storage adapter for file persistence
4173
+ */
3722
4174
  localStorage: LocalStorageAdapter;
4175
+ /**
4176
+ * Callback for monitoring attachment changes in your data model
4177
+ */
3723
4178
  watchAttachments: (onUpdate: (attachment: WatchedAttachmentItem[]) => Promise<void>, signal: AbortSignal) => void;
4179
+ /**
4180
+ * Name of the table to store attachment records. Default: 'ps_attachment_queue'
4181
+ */
3724
4182
  tableName?: string;
4183
+ /**
4184
+ * Logger instance. Defaults to db.logger
4185
+ */
3725
4186
  logger?: ILogger;
4187
+ /**
4188
+ * Periodic polling interval in milliseconds for retrying failed uploads/downloads. Default: 30000
4189
+ */
3726
4190
  syncIntervalMs?: number;
4191
+ /**
4192
+ * Throttle duration in milliseconds for the reactive watch query that detects attachment changes. Prevents rapid-fire syncs during bulk changes. Default: 30
4193
+ */
3727
4194
  syncThrottleDuration?: number;
4195
+ /**
4196
+ * Whether to automatically download remote attachments. Default: true
4197
+ */
3728
4198
  downloadAttachments?: boolean;
4199
+ /**
4200
+ * Maximum archived attachments before cleanup. Default: 100
4201
+ */
3729
4202
  archivedCacheLimit?: number;
3730
4203
  errorHandler?: AttachmentErrorHandler;
3731
4204
  });
@@ -3759,25 +4232,45 @@ declare class AttachmentQueue {
3759
4232
  * Clears the periodic sync timer and closes all active attachment watchers.
3760
4233
  */
3761
4234
  stopSync(): Promise<void>;
4235
+ /**
4236
+ * Provides an {@link AttachmentContext} to a callback.
4237
+ *
4238
+ * The callback runs while the attachment queue mutex is held. Do not call
4239
+ * other {@link AttachmentQueue} methods from within the callback, as they may
4240
+ * attempt to acquire the same mutex and block indefinitely.
4241
+ */
4242
+ withAttachmentContext<T>(callback: (context: AttachmentContext) => Promise<T>): Promise<T>;
3762
4243
  /**
3763
4244
  * Saves a file to local storage and queues it for upload to remote storage.
3764
4245
  *
3765
4246
  * @param options - File save options
3766
- * @param options.data - The file data as ArrayBuffer, Blob, or base64 string
3767
- * @param options.fileExtension - File extension (e.g., 'jpg', 'pdf')
3768
- * @param options.mediaType - MIME type of the file (e.g., 'image/jpeg')
3769
- * @param options.metaData - Optional metadata to associate with the attachment
3770
- * @param options.id - Optional custom ID. If not provided, a UUID will be generated
3771
- * @param options.updateHook - Optional callback to execute additional database operations
3772
- * within the same transaction as the attachment creation
3773
4247
  * @returns Promise resolving to the created attachment record
3774
4248
  */
3775
4249
  saveFile({ data, fileExtension, mediaType, metaData, id, updateHook }: {
4250
+ /**
4251
+ * The file data as ArrayBuffer, Blob, or base64 string
4252
+ */
3776
4253
  data: AttachmentData;
4254
+ /**
4255
+ * File extension (e.g., 'jpg', 'pdf')
4256
+ */
3777
4257
  fileExtension: string;
4258
+ /**
4259
+ * MIME type of the file (e.g., 'image/jpeg')
4260
+ */
3778
4261
  mediaType?: string;
4262
+ /**
4263
+ * Optional metadata to associate with the attachment
4264
+ */
3779
4265
  metaData?: string;
4266
+ /**
4267
+ * Optional custom ID. If not provided, a UUID will be generated
4268
+ */
3780
4269
  id?: string;
4270
+ /**
4271
+ * Optional callback to execute additional database operations within the same transaction as the attachment
4272
+ * creation.
4273
+ */
3781
4274
  updateHook?: (transaction: Transaction, attachment: AttachmentRecord) => Promise<void>;
3782
4275
  }): Promise<AttachmentRecord>;
3783
4276
  deleteFile({ id, updateHook }: {
@@ -3879,10 +4372,16 @@ declare class SyncingService {
3879
4372
  deleteArchivedAttachments(context: AttachmentContext): Promise<boolean>;
3880
4373
  }
3881
4374
 
4375
+ /**
4376
+ * @internal
4377
+ */
3882
4378
  interface PowerSyncOpenFactoryOptions extends Partial<PowerSyncDatabaseOptions>, SQLOpenOptions {
3883
4379
  /** Schema used for the local database. */
3884
4380
  schema: Schema;
3885
4381
  }
4382
+ /**
4383
+ * @internal
4384
+ */
3886
4385
  declare abstract class AbstractPowerSyncDatabaseOpenFactory {
3887
4386
  protected options: PowerSyncOpenFactoryOptions;
3888
4387
  constructor(options: PowerSyncOpenFactoryOptions);
@@ -3898,16 +4397,31 @@ declare abstract class AbstractPowerSyncDatabaseOpenFactory {
3898
4397
  getInstance(): AbstractPowerSyncDatabase;
3899
4398
  }
3900
4399
 
4400
+ /**
4401
+ * @public
4402
+ */
3901
4403
  interface CompilableQueryWatchHandler<T> {
3902
4404
  onResult: (results: T[]) => void;
3903
4405
  onError?: (error: Error) => void;
3904
4406
  }
4407
+ /**
4408
+ * @public
4409
+ */
3905
4410
  declare function compilableQueryWatch<T>(db: AbstractPowerSyncDatabase, query: CompilableQuery<T>, handler: CompilableQueryWatchHandler<T>, options?: SQLWatchOptions): void;
3906
4411
 
4412
+ /**
4413
+ * @internal
4414
+ */
3907
4415
  declare const MAX_OP_ID = "9223372036854775807";
3908
4416
 
4417
+ /**
4418
+ * @internal
4419
+ */
3909
4420
  declare function runOnSchemaChange(callback: (signal: AbortSignal) => void, db: AbstractPowerSyncDatabase, options?: SQLWatchOptions): void;
3910
4421
 
4422
+ /**
4423
+ * @internal
4424
+ */
3911
4425
  declare class SqliteBucketStorage extends BaseObserver<BucketStorageListener> implements BucketStorageAdapter {
3912
4426
  private db;
3913
4427
  private logger;
@@ -3941,6 +4455,8 @@ declare class SqliteBucketStorage extends BaseObserver<BucketStorageListener> im
3941
4455
  * Thrown when an underlying database connection is closed.
3942
4456
  * This is particularly relevant when worker connections are marked as closed while
3943
4457
  * operations are still in progress.
4458
+ *
4459
+ * @internal
3944
4460
  */
3945
4461
  declare class ConnectionClosedError extends Error {
3946
4462
  static NAME: string;
@@ -3957,6 +4473,8 @@ declare const MEMORY_TRIGGER_CLAIM_MANAGER: TriggerClaimManager;
3957
4473
  /**
3958
4474
  * Helper function for sanitizing UUID input strings.
3959
4475
  * Typically used with {@link sanitizeSQL}.
4476
+ *
4477
+ * @alpha
3960
4478
  */
3961
4479
  declare function sanitizeUUID(uuid: string): string;
3962
4480
  /**
@@ -3986,11 +4504,15 @@ declare function sanitizeUUID(uuid: string): string;
3986
4504
  * // Incorrect:
3987
4505
  * sanitizeSQL`New.id = '${myID}'` // Produces double quotes: New.id = ''O''Reilly''
3988
4506
  * ```
4507
+ *
4508
+ * @alpha
3989
4509
  */
3990
4510
  declare function sanitizeSQL(strings: TemplateStringsArray, ...values: any[]): string;
3991
4511
 
3992
4512
  /**
3993
4513
  * Options for {@link GetAllQuery}.
4514
+ *
4515
+ * @public
3994
4516
  */
3995
4517
  type GetAllQueryOptions<RowType = unknown> = {
3996
4518
  sql: string;
@@ -4009,6 +4531,8 @@ type GetAllQueryOptions<RowType = unknown> = {
4009
4531
  };
4010
4532
  /**
4011
4533
  * Performs a {@link AbstractPowerSyncDatabase.getAll} operation for a watched query.
4534
+ *
4535
+ * @public
4012
4536
  */
4013
4537
  declare class GetAllQuery<RowType = unknown> implements WatchCompatibleQuery<RowType[]> {
4014
4538
  protected options: GetAllQueryOptions<RowType>;
@@ -4023,12 +4547,17 @@ declare class GetAllQuery<RowType = unknown> implements WatchCompatibleQuery<Row
4023
4547
  * Calls to Abortcontroller.abort(reason: any) will result in the
4024
4548
  * `reason` being thrown. This is not necessarily an error,
4025
4549
  * but extends error for better logging purposes.
4550
+ *
4551
+ * @internal
4026
4552
  */
4027
4553
  declare class AbortOperation extends Error {
4028
4554
  protected reason: string;
4029
4555
  constructor(reason: string);
4030
4556
  }
4031
4557
 
4558
+ /**
4559
+ * @internal
4560
+ */
4032
4561
  interface ControlledExecutorOptions {
4033
4562
  /**
4034
4563
  * If throttling is enabled, it ensures only one task runs at a time,
@@ -4037,6 +4566,9 @@ interface ControlledExecutorOptions {
4037
4566
  */
4038
4567
  throttleEnabled?: boolean;
4039
4568
  }
4569
+ /**
4570
+ * @internal
4571
+ */
4040
4572
  declare class ControlledExecutor<T> {
4041
4573
  private task;
4042
4574
  /**
@@ -4055,10 +4587,16 @@ declare class ControlledExecutor<T> {
4055
4587
  private execute;
4056
4588
  }
4057
4589
 
4590
+ /**
4591
+ * @internal
4592
+ */
4058
4593
  interface ParsedQuery {
4059
4594
  sqlStatement: string;
4060
4595
  parameters: any[];
4061
4596
  }
4597
+ /**
4598
+ * @internal
4599
+ */
4062
4600
  declare const parseQuery: <T>(query: string | CompilableQuery<T>, parameters: any[]) => ParsedQuery;
4063
4601
 
4064
4602
  export { ATTACHMENT_TABLE, AbortOperation, AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, AbstractQueryProcessor, AbstractRemote, AbstractStreamingSyncImplementation, ArrayComparator, AttachmentContext, AttachmentQueue, AttachmentService, AttachmentState, AttachmentTable, BaseObserver, Column, ColumnType, ConnectionClosedError, ConnectionManager, ControlledExecutor, CrudBatch, CrudEntry, CrudTransaction, DBAdapterDefaultMixin, DBGetUtilsDefaultMixin, DEFAULT_CRUD_BATCH_LIMIT, DEFAULT_CRUD_UPLOAD_THROTTLE_MS, DEFAULT_INDEX_COLUMN_OPTIONS, DEFAULT_INDEX_OPTIONS, DEFAULT_LOCK_TIMEOUT_MS, DEFAULT_POWERSYNC_CLOSE_OPTIONS, DEFAULT_POWERSYNC_DB_OPTIONS, DEFAULT_REMOTE_LOGGER, DEFAULT_REMOTE_OPTIONS, DEFAULT_RETRY_DELAY_MS, DEFAULT_ROW_COMPARATOR, DEFAULT_STREAMING_SYNC_OPTIONS, DEFAULT_STREAM_CONNECTION_OPTIONS, DEFAULT_SYNC_CLIENT_IMPLEMENTATION, DEFAULT_TABLE_OPTIONS, DEFAULT_WATCH_QUERY_OPTIONS, DEFAULT_WATCH_THROTTLE_MS, DiffTriggerOperation, DifferentialQueryProcessor, EMPTY_DIFFERENTIAL, EncodingType, FalsyComparator, FetchImplementationProvider, FetchStrategy, GetAllQuery, Index, IndexedColumn, InvalidSQLCharacters, LockType, LogLevel, MAX_AMOUNT_OF_COLUMNS, MAX_OP_ID, MEMORY_TRIGGER_CLAIM_MANAGER, Mutex, OnChangeQueryProcessor, PSInternalTable, PowerSyncControlCommand, RowUpdateType, Schema, Semaphore, SqliteBucketStorage, SyncClientImplementation, SyncProgress, SyncStatus, SyncStreamConnectionMethod, SyncingService, Table, TableV2, TriggerManagerImpl, UpdateType, UploadQueueStats, WatchedQueryListenerEvent, attachmentFromSql, column, compilableQueryWatch, createBaseLogger, createLogger, extractTableUpdates, isBatchedUpdateNotification, isDBAdapter, isPowerSyncDatabaseOptionsWithSettings, isSQLOpenFactory, isSQLOpenOptions, parseQuery, runOnSchemaChange, sanitizeSQL, sanitizeUUID, timeoutSignal };