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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/lib/attachments/AttachmentContext.d.ts +9 -8
  2. package/lib/attachments/AttachmentContext.js +8 -3
  3. package/lib/attachments/AttachmentContext.js.map +1 -1
  4. package/lib/attachments/AttachmentErrorHandler.d.ts +6 -6
  5. package/lib/attachments/AttachmentQueue.d.ts +85 -36
  6. package/lib/attachments/AttachmentQueue.js +19 -21
  7. package/lib/attachments/AttachmentQueue.js.map +1 -1
  8. package/lib/attachments/AttachmentService.d.ts +3 -3
  9. package/lib/attachments/AttachmentService.js +4 -3
  10. package/lib/attachments/AttachmentService.js.map +1 -1
  11. package/lib/attachments/LocalStorageAdapter.d.ts +14 -8
  12. package/lib/attachments/LocalStorageAdapter.js +3 -0
  13. package/lib/attachments/LocalStorageAdapter.js.map +1 -1
  14. package/lib/attachments/RemoteStorageAdapter.d.ts +4 -4
  15. package/lib/attachments/Schema.d.ts +14 -6
  16. package/lib/attachments/Schema.js +8 -3
  17. package/lib/attachments/Schema.js.map +1 -1
  18. package/lib/attachments/SyncingService.d.ts +2 -2
  19. package/lib/attachments/SyncingService.js +8 -3
  20. package/lib/attachments/SyncingService.js.map +1 -1
  21. package/lib/attachments/WatchedAttachmentItem.d.ts +3 -1
  22. package/lib/client/{AbstractPowerSyncDatabase.d.ts → CommonPowerSyncDatabase.d.ts} +112 -238
  23. package/lib/client/CommonPowerSyncDatabase.js +2 -0
  24. package/lib/client/CommonPowerSyncDatabase.js.map +1 -0
  25. package/lib/client/Query.d.ts +9 -0
  26. package/lib/client/SQLOpenFactory.d.ts +44 -10
  27. package/lib/client/SQLOpenFactory.js +1 -19
  28. package/lib/client/SQLOpenFactory.js.map +1 -1
  29. package/lib/client/compilableQueryWatch.d.ts +8 -2
  30. package/lib/client/compilableQueryWatch.js +4 -2
  31. package/lib/client/compilableQueryWatch.js.map +1 -1
  32. package/lib/client/connection/PowerSyncBackendConnector.d.ts +6 -3
  33. package/lib/client/connection/PowerSyncCredentials.d.ts +3 -0
  34. package/lib/client/runOnSchemaChange.d.ts +5 -2
  35. package/lib/client/runOnSchemaChange.js +3 -0
  36. package/lib/client/runOnSchemaChange.js.map +1 -1
  37. package/lib/client/sync/bucket/CrudBatch.d.ts +2 -0
  38. package/lib/client/sync/bucket/CrudBatch.js +2 -0
  39. package/lib/client/sync/bucket/CrudBatch.js.map +1 -1
  40. package/lib/client/sync/bucket/CrudEntry.d.ts +9 -31
  41. package/lib/client/sync/bucket/CrudEntry.js +2 -97
  42. package/lib/client/sync/bucket/CrudEntry.js.map +1 -1
  43. package/lib/client/sync/bucket/CrudTransaction.d.ts +3 -0
  44. package/lib/client/sync/bucket/CrudTransaction.js +3 -0
  45. package/lib/client/sync/bucket/CrudTransaction.js.map +1 -1
  46. package/lib/client/sync/options.d.ts +65 -0
  47. package/lib/client/sync/options.js +25 -0
  48. package/lib/client/sync/options.js.map +1 -0
  49. package/lib/client/sync/stream/JsonValue.d.ts +3 -0
  50. package/lib/client/sync/sync-streams.d.ts +23 -8
  51. package/lib/client/triggers/TriggerManager.d.ts +28 -56
  52. package/lib/client/triggers/TriggerManager.js +2 -1
  53. package/lib/client/triggers/TriggerManager.js.map +1 -1
  54. package/lib/client/triggers/sanitizeSQL.d.ts +4 -0
  55. package/lib/client/triggers/sanitizeSQL.js +4 -0
  56. package/lib/client/triggers/sanitizeSQL.js.map +1 -1
  57. package/lib/client/watched/GetAllQuery.d.ts +7 -3
  58. package/lib/client/watched/GetAllQuery.js +3 -1
  59. package/lib/client/watched/GetAllQuery.js.map +1 -1
  60. package/lib/client/watched/WatchedQuery.d.ts +20 -6
  61. package/lib/client/watched/WatchedQuery.js +3 -5
  62. package/lib/client/watched/WatchedQuery.js.map +1 -1
  63. package/lib/client/watched/processors/DifferentialQueryProcessor.d.ts +15 -45
  64. package/lib/client/watched/processors/DifferentialQueryProcessor.js +1 -172
  65. package/lib/client/watched/processors/DifferentialQueryProcessor.js.map +1 -1
  66. package/lib/client/watched/processors/OnChangeQueryProcessor.d.ts +4 -22
  67. package/lib/client/watched/processors/OnChangeQueryProcessor.js +1 -82
  68. package/lib/client/watched/processors/OnChangeQueryProcessor.js.map +1 -1
  69. package/lib/client/watched/processors/comparators.d.ts +8 -0
  70. package/lib/client/watched/processors/comparators.js +4 -0
  71. package/lib/client/watched/processors/comparators.js.map +1 -1
  72. package/lib/db/DBAdapter.d.ts +90 -113
  73. package/lib/db/DBAdapter.js +70 -89
  74. package/lib/db/DBAdapter.js.map +1 -1
  75. package/lib/db/QueryResult.d.ts +104 -0
  76. package/lib/db/QueryResult.js +96 -0
  77. package/lib/db/QueryResult.js.map +1 -0
  78. package/lib/db/crud/SyncProgress.d.ts +7 -14
  79. package/lib/db/crud/SyncProgress.js +1 -60
  80. package/lib/db/crud/SyncProgress.js.map +1 -1
  81. package/lib/db/crud/SyncStatus.d.ts +54 -91
  82. package/lib/db/crud/SyncStatus.js +1 -245
  83. package/lib/db/crud/SyncStatus.js.map +1 -1
  84. package/lib/db/crud/UploadQueueStatus.d.ts +3 -0
  85. package/lib/db/crud/UploadQueueStatus.js +3 -0
  86. package/lib/db/crud/UploadQueueStatus.js.map +1 -1
  87. package/lib/db/schema/Column.d.ts +22 -1
  88. package/lib/db/schema/Column.js +10 -4
  89. package/lib/db/schema/Column.js.map +1 -1
  90. package/lib/db/schema/Index.d.ts +8 -3
  91. package/lib/db/schema/Index.js +4 -1
  92. package/lib/db/schema/Index.js.map +1 -1
  93. package/lib/db/schema/IndexedColumn.d.ts +8 -3
  94. package/lib/db/schema/IndexedColumn.js +4 -1
  95. package/lib/db/schema/IndexedColumn.js.map +1 -1
  96. package/lib/db/schema/RawTable.d.ts +7 -1
  97. package/lib/db/schema/Schema.d.ts +10 -29
  98. package/lib/db/schema/Schema.js +3 -1
  99. package/lib/db/schema/Schema.js.map +1 -1
  100. package/lib/db/schema/Table.d.ts +69 -91
  101. package/lib/db/schema/Table.js +88 -87
  102. package/lib/db/schema/Table.js.map +1 -1
  103. package/lib/index.d.ts +6 -22
  104. package/lib/index.js +5 -22
  105. package/lib/index.js.map +1 -1
  106. package/lib/types/types.d.ts +6 -0
  107. package/lib/utils/BaseObserver.d.ts +12 -0
  108. package/lib/utils/BaseObserver.js +3 -0
  109. package/lib/utils/BaseObserver.js.map +1 -1
  110. package/lib/utils/Logger.d.ts +60 -22
  111. package/lib/utils/Logger.js +38 -30
  112. package/lib/utils/Logger.js.map +1 -1
  113. package/lib/utils/MetaBaseObserver.d.ts +11 -11
  114. package/lib/utils/MetaBaseObserver.js +1 -50
  115. package/lib/utils/MetaBaseObserver.js.map +1 -1
  116. package/lib/utils/mutex.d.ts +3 -45
  117. package/lib/utils/mutex.js +1 -153
  118. package/lib/utils/mutex.js.map +1 -1
  119. package/package.json +9 -46
  120. package/src/attachments/AttachmentContext.ts +15 -13
  121. package/src/attachments/AttachmentErrorHandler.ts +6 -6
  122. package/src/attachments/AttachmentQueue.ts +99 -42
  123. package/src/attachments/AttachmentService.ts +7 -6
  124. package/src/attachments/LocalStorageAdapter.ts +14 -8
  125. package/src/attachments/README.md +2 -0
  126. package/src/attachments/RemoteStorageAdapter.ts +4 -4
  127. package/src/attachments/Schema.ts +14 -6
  128. package/src/attachments/SyncingService.ts +10 -6
  129. package/src/attachments/WatchedAttachmentItem.ts +3 -1
  130. package/src/client/CommonPowerSyncDatabase.ts +540 -0
  131. package/src/client/Query.ts +9 -0
  132. package/src/client/SQLOpenFactory.ts +47 -19
  133. package/src/client/compilableQueryWatch.ts +9 -4
  134. package/src/client/connection/PowerSyncBackendConnector.ts +6 -3
  135. package/src/client/connection/PowerSyncCredentials.ts +3 -0
  136. package/src/client/runOnSchemaChange.ts +5 -2
  137. package/src/client/sync/bucket/CrudBatch.ts +2 -0
  138. package/src/client/sync/bucket/CrudEntry.ts +10 -101
  139. package/src/client/sync/bucket/CrudTransaction.ts +3 -0
  140. package/src/client/sync/options.ts +77 -0
  141. package/src/client/sync/stream/JsonValue.ts +3 -0
  142. package/src/client/sync/sync-streams.ts +23 -10
  143. package/src/client/triggers/TriggerManager.ts +29 -59
  144. package/src/client/triggers/sanitizeSQL.ts +5 -0
  145. package/src/client/watched/GetAllQuery.ts +8 -4
  146. package/src/client/watched/WatchedQuery.ts +20 -11
  147. package/src/client/watched/processors/DifferentialQueryProcessor.ts +19 -219
  148. package/src/client/watched/processors/OnChangeQueryProcessor.ts +4 -109
  149. package/src/client/watched/processors/comparators.ts +8 -0
  150. package/src/db/DBAdapter.ts +160 -175
  151. package/src/db/QueryResult.ts +195 -0
  152. package/src/db/crud/SyncProgress.ts +8 -43
  153. package/src/db/crud/SyncStatus.ts +66 -216
  154. package/src/db/crud/UploadQueueStatus.ts +3 -0
  155. package/src/db/schema/Column.ts +22 -5
  156. package/src/db/schema/Index.ts +9 -3
  157. package/src/db/schema/IndexedColumn.ts +9 -3
  158. package/src/db/schema/RawTable.ts +7 -1
  159. package/src/db/schema/Schema.ts +12 -7
  160. package/src/db/schema/Table.ts +130 -180
  161. package/src/index.ts +6 -22
  162. package/src/types/types.ts +6 -0
  163. package/src/utils/BaseObserver.ts +12 -0
  164. package/src/utils/Logger.ts +86 -31
  165. package/src/utils/MetaBaseObserver.ts +14 -60
  166. package/src/utils/mutex.ts +4 -189
  167. package/dist/bundle.cjs +0 -14136
  168. package/dist/bundle.cjs.map +0 -1
  169. package/dist/bundle.mjs +0 -14056
  170. package/dist/bundle.mjs.map +0 -1
  171. package/dist/bundle.node.cjs +0 -11613
  172. package/dist/bundle.node.cjs.map +0 -1
  173. package/dist/bundle.node.mjs +0 -11533
  174. package/dist/bundle.node.mjs.map +0 -1
  175. package/dist/index.d.cts +0 -4052
  176. package/legacy/sync_protocol.d.ts +0 -103
  177. package/lib/client/AbstractPowerSyncDatabase.js +0 -987
  178. package/lib/client/AbstractPowerSyncDatabase.js.map +0 -1
  179. package/lib/client/AbstractPowerSyncOpenFactory.d.ts +0 -22
  180. package/lib/client/AbstractPowerSyncOpenFactory.js +0 -25
  181. package/lib/client/AbstractPowerSyncOpenFactory.js.map +0 -1
  182. package/lib/client/ConnectionManager.d.ts +0 -112
  183. package/lib/client/ConnectionManager.js +0 -294
  184. package/lib/client/ConnectionManager.js.map +0 -1
  185. package/lib/client/CustomQuery.d.ts +0 -22
  186. package/lib/client/CustomQuery.js +0 -43
  187. package/lib/client/CustomQuery.js.map +0 -1
  188. package/lib/client/constants.d.ts +0 -1
  189. package/lib/client/constants.js +0 -2
  190. package/lib/client/constants.js.map +0 -1
  191. package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +0 -40
  192. package/lib/client/sync/bucket/BucketStorageAdapter.js +0 -19
  193. package/lib/client/sync/bucket/BucketStorageAdapter.js.map +0 -1
  194. package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +0 -34
  195. package/lib/client/sync/bucket/SqliteBucketStorage.js +0 -162
  196. package/lib/client/sync/bucket/SqliteBucketStorage.js.map +0 -1
  197. package/lib/client/sync/stream/AbstractRemote.d.ts +0 -151
  198. package/lib/client/sync/stream/AbstractRemote.js +0 -473
  199. package/lib/client/sync/stream/AbstractRemote.js.map +0 -1
  200. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +0 -218
  201. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +0 -663
  202. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +0 -1
  203. package/lib/client/sync/stream/WebsocketClientTransport.d.ts +0 -15
  204. package/lib/client/sync/stream/WebsocketClientTransport.js +0 -61
  205. package/lib/client/sync/stream/WebsocketClientTransport.js.map +0 -1
  206. package/lib/client/sync/stream/core-instruction.d.ts +0 -71
  207. package/lib/client/sync/stream/core-instruction.js +0 -27
  208. package/lib/client/sync/stream/core-instruction.js.map +0 -1
  209. package/lib/client/triggers/MemoryTriggerClaimManager.d.ts +0 -6
  210. package/lib/client/triggers/MemoryTriggerClaimManager.js +0 -21
  211. package/lib/client/triggers/MemoryTriggerClaimManager.js.map +0 -1
  212. package/lib/client/triggers/TriggerManagerImpl.d.ts +0 -39
  213. package/lib/client/triggers/TriggerManagerImpl.js +0 -405
  214. package/lib/client/triggers/TriggerManagerImpl.js.map +0 -1
  215. package/lib/client/watched/processors/AbstractQueryProcessor.d.ts +0 -68
  216. package/lib/client/watched/processors/AbstractQueryProcessor.js +0 -151
  217. package/lib/client/watched/processors/AbstractQueryProcessor.js.map +0 -1
  218. package/lib/db/ConnectionClosedError.d.ts +0 -10
  219. package/lib/db/ConnectionClosedError.js +0 -21
  220. package/lib/db/ConnectionClosedError.js.map +0 -1
  221. package/lib/db/schema/TableV2.d.ts +0 -9
  222. package/lib/db/schema/TableV2.js +0 -9
  223. package/lib/db/schema/TableV2.js.map +0 -1
  224. package/lib/utils/AbortOperation.d.ts +0 -9
  225. package/lib/utils/AbortOperation.js +0 -19
  226. package/lib/utils/AbortOperation.js.map +0 -1
  227. package/lib/utils/ControlledExecutor.d.ts +0 -25
  228. package/lib/utils/ControlledExecutor.js +0 -51
  229. package/lib/utils/ControlledExecutor.js.map +0 -1
  230. package/lib/utils/async.d.ts +0 -14
  231. package/lib/utils/async.js +0 -46
  232. package/lib/utils/async.js.map +0 -1
  233. package/lib/utils/parseQuery.d.ts +0 -6
  234. package/lib/utils/parseQuery.js +0 -17
  235. package/lib/utils/parseQuery.js.map +0 -1
  236. package/lib/utils/queue.d.ts +0 -16
  237. package/lib/utils/queue.js +0 -42
  238. package/lib/utils/queue.js.map +0 -1
  239. package/lib/utils/stream_transform.d.ts +0 -39
  240. package/lib/utils/stream_transform.js +0 -206
  241. package/lib/utils/stream_transform.js.map +0 -1
  242. package/src/client/AbstractPowerSyncDatabase.ts +0 -1362
  243. package/src/client/AbstractPowerSyncOpenFactory.ts +0 -39
  244. package/src/client/ConnectionManager.ts +0 -402
  245. package/src/client/CustomQuery.ts +0 -56
  246. package/src/client/constants.ts +0 -1
  247. package/src/client/sync/bucket/BucketStorageAdapter.ts +0 -49
  248. package/src/client/sync/bucket/SqliteBucketStorage.ts +0 -199
  249. package/src/client/sync/stream/AbstractRemote.ts +0 -602
  250. package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +0 -905
  251. package/src/client/sync/stream/WebsocketClientTransport.ts +0 -80
  252. package/src/client/sync/stream/core-instruction.ts +0 -98
  253. package/src/client/triggers/MemoryTriggerClaimManager.ts +0 -25
  254. package/src/client/triggers/TriggerManagerImpl.ts +0 -496
  255. package/src/client/watched/processors/AbstractQueryProcessor.ts +0 -226
  256. package/src/db/ConnectionClosedError.ts +0 -23
  257. package/src/db/schema/TableV2.ts +0 -9
  258. package/src/utils/AbortOperation.ts +0 -17
  259. package/src/utils/ControlledExecutor.ts +0 -72
  260. package/src/utils/async.ts +0 -50
  261. package/src/utils/parseQuery.ts +0 -25
  262. package/src/utils/queue.ts +0 -48
  263. package/src/utils/stream_transform.ts +0 -252
@@ -1,4 +1,7 @@
1
1
  import { DBAdapter } from '../db/DBAdapter.js';
2
+ /**
3
+ * @public
4
+ */
2
5
  export interface SQLOpenOptions {
3
6
  /**
4
7
  * Filename for the database.
@@ -22,6 +25,9 @@ export interface SQLOpenOptions {
22
25
  */
23
26
  debugMode?: boolean;
24
27
  }
28
+ /**
29
+ * @public
30
+ */
25
31
  export interface SQLOpenFactory {
26
32
  /**
27
33
  * Opens a connection adapter to a SQLite DB
@@ -29,14 +35,42 @@ export interface SQLOpenFactory {
29
35
  openDB(): DBAdapter;
30
36
  }
31
37
  /**
32
- * Tests if the input is a {@link SQLOpenOptions}
38
+ * A source describing how to open databases.
39
+ *
40
+ * - A {@link DBAdapter} providing access to an opened SQLite connection pool.
41
+ * - A {@link SQLOpenFactory} which will be used to open a SQLite connection pool lazily.
42
+ * - A {@link SQLOpenOptions} for opening a SQLite connection with a default {@link SQLOpenFactory} for the current
43
+ * platform.
44
+ *
45
+ * For most apps, using the `database` key with {@link SQLOpenOptions} is the easiest and recommended option.
46
+ *
47
+ * @public
33
48
  */
34
- export declare const isSQLOpenOptions: (test: any) => test is SQLOpenOptions;
35
- /**
36
- * Tests if input is a {@link SQLOpenFactory}
37
- */
38
- export declare const isSQLOpenFactory: (test: any) => test is SQLOpenFactory;
39
- /**
40
- * Tests if input is a {@link DBAdapter}
41
- */
42
- export declare const isDBAdapter: (test: any) => test is DBAdapter;
49
+ export type DatabaseSource<OpenOptions extends SQLOpenOptions = SQLOpenOptions> = {
50
+ /**
51
+ * Wrap an opened {@link DBAdapter} as a PowerSync database instance.
52
+ *
53
+ * This is primarily useful for testing. On most platforms, PowerSync would open a pool of SQLite connections by
54
+ * default. This option allows using a single in-memory instance instead. It can also be used to customize the
55
+ * database used by default, e.g. to install additional logging on SQL statements by intercepting methods.
56
+ */
57
+ opened: DBAdapter;
58
+ } | {
59
+ /**
60
+ * Construct a PowerSync database that will call {@link SQLOpenFactory.openDB} when opened.
61
+ *
62
+ * On most SDKs, passing {@link SQLOpenOptions} is a better option. An exception is React Native, where using an
63
+ * [OP-SQLite factory](https://docs.powersync.com/client-sdks/reference/react-native-and-expo#op-sqlite) is
64
+ * recommended.
65
+ */
66
+ factory: SQLOpenFactory;
67
+ } | {
68
+ /**
69
+ * Construct a PowerSync database opening a connection pool from the {@link SQLOpenOptions}.
70
+ *
71
+ * At the very least, options include the {@link SQLOpenOptions.dbFilename} to open. Depending on the PowerSync
72
+ * SDK used, additional options are available. For example, the web SDK allows configuring the virtual file system
73
+ * implementation used to persist files on the web too.
74
+ */
75
+ database: OpenOptions;
76
+ };
@@ -1,20 +1,2 @@
1
- /**
2
- * Tests if the input is a {@link SQLOpenOptions}
3
- */
4
- export const isSQLOpenOptions = (test) => {
5
- // typeof null is `object`, but you cannot use the `in` operator on `null.
6
- return test && typeof test == 'object' && 'dbFilename' in test;
7
- };
8
- /**
9
- * Tests if input is a {@link SQLOpenFactory}
10
- */
11
- export const isSQLOpenFactory = (test) => {
12
- return typeof test?.openDB == 'function';
13
- };
14
- /**
15
- * Tests if input is a {@link DBAdapter}
16
- */
17
- export const isDBAdapter = (test) => {
18
- return typeof test?.writeTransaction == 'function';
19
- };
1
+ export {};
20
2
  //# sourceMappingURL=SQLOpenFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SQLOpenFactory.js","sourceRoot":"","sources":["../../src/client/SQLOpenFactory.ts"],"names":[],"mappings":"AAkCA;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAS,EAA0B,EAAE;IACpE,0EAA0E;IAC1E,OAAO,IAAI,IAAI,OAAO,IAAI,IAAI,QAAQ,IAAI,YAAY,IAAI,IAAI,CAAC;AACjE,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAS,EAA0B,EAAE;IACpE,OAAO,OAAO,IAAI,EAAE,MAAM,IAAI,UAAU,CAAC;AAC3C,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAS,EAAqB,EAAE;IAC1D,OAAO,OAAO,IAAI,EAAE,gBAAgB,IAAI,UAAU,CAAC;AACrD,CAAC,CAAC"}
1
+ {"version":3,"file":"SQLOpenFactory.js","sourceRoot":"","sources":["../../src/client/SQLOpenFactory.ts"],"names":[],"mappings":""}
@@ -1,7 +1,13 @@
1
1
  import { CompilableQuery } from './../types/types.js';
2
- import { AbstractPowerSyncDatabase, SQLWatchOptions } from './AbstractPowerSyncDatabase.js';
2
+ import { CommonPowerSyncDatabase, SQLWatchOptions } from './CommonPowerSyncDatabase.js';
3
+ /**
4
+ * @public
5
+ */
3
6
  export interface CompilableQueryWatchHandler<T> {
4
7
  onResult: (results: T[]) => void;
5
8
  onError?: (error: Error) => void;
6
9
  }
7
- export declare function compilableQueryWatch<T>(db: AbstractPowerSyncDatabase, query: CompilableQuery<T>, handler: CompilableQueryWatchHandler<T>, options?: SQLWatchOptions): void;
10
+ /**
11
+ * @public
12
+ */
13
+ export declare function compilableQueryWatch<T>(db: CommonPowerSyncDatabase, query: CompilableQuery<T>, handler: CompilableQueryWatchHandler<T>, options?: SQLWatchOptions): void;
@@ -1,4 +1,7 @@
1
1
  import { runOnSchemaChange } from './runOnSchemaChange.js';
2
+ /**
3
+ * @public
4
+ */
2
5
  export function compilableQueryWatch(db, query, handler, options) {
3
6
  const { onResult, onError = (e) => { } } = handler ?? {};
4
7
  if (!onResult) {
@@ -20,8 +23,7 @@ export function compilableQueryWatch(db, query, handler, options) {
20
23
  catch (error) {
21
24
  onError(error);
22
25
  }
23
- },
24
- onError
26
+ }
25
27
  }, {
26
28
  ...(options ?? {}),
27
29
  tables: resolvedTables,
@@ -1 +1 @@
1
- {"version":3,"file":"compilableQueryWatch.js","sourceRoot":"","sources":["../../src/client/compilableQueryWatch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAO3D,MAAM,UAAU,oBAAoB,CAClC,EAA6B,EAC7B,KAAyB,EACzB,OAAuC,EACvC,OAAyB;IAEzB,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,CAAC,CAAQ,EAAE,EAAE,GAAE,CAAC,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAC/D,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,EAAE,WAAwB,EAAE,EAAE;QACpD,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;YAC9B,MAAM,cAAc,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,UAAgB,EAAE,OAAO,CAAC,CAAC;YAE1F,qBAAqB;YACrB,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;YACrC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAEjB,EAAE,CAAC,oBAAoB,CAC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K,CAAC,GAAG,EAAE,KAAK,CAAC,UAAgB,EAAE,OAAO,CAAC,CAAC;YAE1F,qBAAqB;YACrB,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;YACrC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAEjB,EAAE,CAAC,oBAAoB,CACrB;gBACE,QAAQ,EAAE,KAAK,IAAI,EAAE;oBACnB,IAAI,CAAC;wBACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;wBACrC,QAAQ,CAAC,MAAM,CAAC,CAAC;oBACnB,CAAC;oBAAC,OAAO,KAAU,EAAE,CAAC;wBACpB,OAAO,CAAC,KAAK,CAAC,CAAC;oBACjB,CAAC;gBACH,CAAC;aACF,EACD;gBACE,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;gBAClB,MAAM,EAAE,cAAc;gBACtB,kDAAkD;gBAClD,MAAM,EAAE,WAAW;aACpB,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC;IACH,CAAC,CAAC;IAEF,iBAAiB,CAAC,UAAU,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC"}
@@ -1,5 +1,8 @@
1
1
  import { PowerSyncCredentials } from './PowerSyncCredentials.js';
2
- import type { AbstractPowerSyncDatabase } from '../AbstractPowerSyncDatabase.js';
2
+ import { CommonPowerSyncDatabase } from '../CommonPowerSyncDatabase.js';
3
+ /**
4
+ * @public
5
+ */
3
6
  export interface PowerSyncBackendConnector {
4
7
  /** Allows the PowerSync client to retrieve an authentication token from your backend
5
8
  * which is used to authenticate against the PowerSync service.
@@ -15,9 +18,9 @@ export interface PowerSyncBackendConnector {
15
18
  fetchCredentials: () => Promise<PowerSyncCredentials | null>;
16
19
  /** Upload local changes to the app backend.
17
20
  *
18
- * Use {@link AbstractPowerSyncDatabase.getCrudBatch} to get a batch of changes to upload.
21
+ * Use {@link CommonPowerSyncDatabase.getCrudBatch} to get a batch of changes to upload.
19
22
  *
20
23
  * Any thrown errors will result in a retry after the configured wait period (default: 5 seconds).
21
24
  */
22
- uploadData: (database: AbstractPowerSyncDatabase) => Promise<void>;
25
+ uploadData: (database: CommonPowerSyncDatabase) => Promise<void>;
23
26
  }
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @public
3
+ */
1
4
  export interface PowerSyncCredentials {
2
5
  endpoint: string;
3
6
  token: string;
@@ -1,2 +1,5 @@
1
- import { AbstractPowerSyncDatabase, SQLWatchOptions } from './AbstractPowerSyncDatabase.js';
2
- export declare function runOnSchemaChange(callback: (signal: AbortSignal) => void, db: AbstractPowerSyncDatabase, options?: SQLWatchOptions): void;
1
+ import { CommonPowerSyncDatabase, SQLWatchOptions } from './CommonPowerSyncDatabase.js';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare function runOnSchemaChange(callback: (signal: AbortSignal) => void, db: CommonPowerSyncDatabase, options?: SQLWatchOptions): void;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @internal
3
+ */
1
4
  export function runOnSchemaChange(callback, db, options) {
2
5
  const triggerWatchedQuery = () => {
3
6
  const abortController = new AbortController();
@@ -1 +1 @@
1
- {"version":3,"file":"runOnSchemaChange.js","sourceRoot":"","sources":["../../src/client/runOnSchemaChange.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iBAAiB,CAC/B,QAAuC,EACvC,EAA6B,EAC7B,OAAyB;IAEzB,MAAM,mBAAmB,GAAG,GAAG,EAAE;QAC/B,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;QAC9C,IAAI,qBAAqB,GAAwB,IAAI,CAAC;QACtD,MAAM,YAAY,GAAG,GAAG,EAAE;YACxB,eAAe,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;YACzC,qBAAqB,EAAE,EAAE,CAAC;YAC1B,qBAAqB,GAAG,IAAI,CAAC;YAC7B,kDAAkD;YAClD,OA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CAAC;gBACf,yIAAyI;gBACzI,UAAU,CAAC,GAAG,EAAE,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC,CAAC;YAC7C,CAAC;SACF,CAAC,CAAC;QACH,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC,CAAC;IAEF,mBAAmB,EAAE,CAAC;AACxB,CAAC"}
@@ -1,6 +1,8 @@
1
1
  import { CrudEntry } from './CrudEntry.js';
2
2
  /**
3
3
  * A batch of client-side changes.
4
+ *
5
+ * @public
4
6
  */
5
7
  export declare class CrudBatch {
6
8
  /**
@@ -1,5 +1,7 @@
1
1
  /**
2
2
  * A batch of client-side changes.
3
+ *
4
+ * @public
3
5
  */
4
6
  export class CrudBatch {
5
7
  crud;
@@ -1 +1 @@
1
- {"version":3,"file":"CrudBatch.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/CrudBatch.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,SAAS;IAKX;IAIA;IAIA;IAZT;IACE;;OAEG;IACI,IAAiB;IACxB;;OAEG;IACI,QAAiB;IACxB;;OAEG;IACI,QAAqD;QARrD,SAAI,GAAJ,IAAI,CAAa;QAIjB,aAAQ,GAAR,QAAQ,CAAS;QAIjB,aAAQ,GAAR,QAAQ,CAA6C;IAC3D,CAAC;CACL"}
1
+ {"version":3,"file":"CrudBatch.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/CrudBatch.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,SAAS;IAKX;IAIA;IAIA;IAZT;IACE;;OAEG;IACI,IAAiB;IACxB;;OAEG;IACI,QAAiB;IACxB;;OAEG;IACI,QAAqD;QARrD,SAAI,GAAJ,IAAI,CAAa;QAIjB,aAAQ,GAAR,QAAQ,CAAS;QAIjB,aAAQ,GAAR,QAAQ,CAA6C;IAC3D,CAAC;CACL"}
@@ -2,10 +2,14 @@
2
2
  * 64-bit unsigned integer stored as a string in base-10.
3
3
  *
4
4
  * Not sortable as a string.
5
+ *
6
+ * @public
5
7
  */
6
8
  export type OpId = string;
7
9
  /**
8
10
  * Type of local change.
11
+ *
12
+ * @public
9
13
  */
10
14
  export declare enum UpdateType {
11
15
  /** Insert or replace existing row. All non-null columns are included in the data. Generated by INSERT statements. */
@@ -15,28 +19,12 @@ export declare enum UpdateType {
15
19
  /** Delete existing row. Contains the id. Generated by DELETE statements. */
16
20
  DELETE = "DELETE"
17
21
  }
18
- export type CrudEntryJSON = {
19
- id: string;
20
- data: string;
21
- tx_id?: number;
22
- };
23
- /**
24
- * The output JSON seems to be a third type of JSON, not the same as the input JSON.
25
- */
26
- type CrudEntryOutputJSON = {
27
- op_id: number;
28
- op: UpdateType;
29
- type: string;
30
- id: string;
31
- tx_id?: number;
32
- data?: Record<string, any>;
33
- old?: Record<string, any>;
34
- metadata?: string;
35
- };
36
22
  /**
37
23
  * A single client-side change.
24
+ *
25
+ * @public
38
26
  */
39
- export declare class CrudEntry {
27
+ export interface CrudEntry {
40
28
  /**
41
29
  * Auto-incrementing client-side id.
42
30
  */
@@ -73,23 +61,13 @@ export declare class CrudEntry {
73
61
  * and the insert or update statement set the `_metadata` column.
74
62
  */
75
63
  metadata?: string;
76
- static fromRow(dbRow: CrudEntryJSON): CrudEntry;
77
- constructor(clientId: number, op: UpdateType, table: string, id: string, transactionId?: number, opData?: Record<string, any>, previousValues?: Record<string, any>, metadata?: string);
78
64
  /**
79
65
  * Converts the change to JSON format.
80
66
  */
81
- toJSON(): CrudEntryOutputJSON;
67
+ toJSON(): unknown;
82
68
  equals(entry: CrudEntry): boolean;
83
- /**
84
- * The hash code for this object.
85
- * @deprecated This should not be necessary in the JS SDK.
86
- * Use the @see CrudEntry#equals method instead.
87
- * TODO remove in the next major release.
88
- */
89
- hashCode(): string;
90
69
  /**
91
70
  * Generates an array for use in deep comparison operations
92
71
  */
93
- toComparisonArray(): (string | number | Record<string, any> | undefined)[];
72
+ toComparisonArray(): unknown[];
94
73
  }
95
- export {};
@@ -1,5 +1,7 @@
1
1
  /**
2
2
  * Type of local change.
3
+ *
4
+ * @public
3
5
  */
4
6
  export var UpdateType;
5
7
  (function (UpdateType) {
@@ -10,101 +12,4 @@ export var UpdateType;
10
12
  /** Delete existing row. Contains the id. Generated by DELETE statements. */
11
13
  UpdateType["DELETE"] = "DELETE";
12
14
  })(UpdateType || (UpdateType = {}));
13
- /**
14
- * A single client-side change.
15
- */
16
- export class CrudEntry {
17
- /**
18
- * Auto-incrementing client-side id.
19
- */
20
- clientId;
21
- /**
22
- * ID of the changed row.
23
- */
24
- id;
25
- /**
26
- * Type of change.
27
- */
28
- op;
29
- /**
30
- * Data associated with the change.
31
- */
32
- opData;
33
- /**
34
- * For tables where the `trackPreviousValues` option has been enabled, this tracks previous values for
35
- * `UPDATE` and `DELETE` statements.
36
- */
37
- previousValues;
38
- /**
39
- * Table that contained the change.
40
- */
41
- table;
42
- /**
43
- * Auto-incrementing transaction id. This is the same for all operations within the same transaction.
44
- */
45
- transactionId;
46
- /**
47
- * Client-side metadata attached with this write.
48
- *
49
- * This field is only available when the `trackMetadata` option was set to `true` when creating a table
50
- * and the insert or update statement set the `_metadata` column.
51
- */
52
- metadata;
53
- static fromRow(dbRow) {
54
- const data = JSON.parse(dbRow.data);
55
- return new CrudEntry(parseInt(dbRow.id), data.op, data.type, data.id, dbRow.tx_id, data.data, data.old, data.metadata);
56
- }
57
- constructor(clientId, op, table, id, transactionId, opData, previousValues, metadata) {
58
- this.clientId = clientId;
59
- this.id = id;
60
- this.op = op;
61
- this.opData = opData;
62
- this.table = table;
63
- this.transactionId = transactionId;
64
- this.previousValues = previousValues;
65
- this.metadata = metadata;
66
- }
67
- /**
68
- * Converts the change to JSON format.
69
- */
70
- toJSON() {
71
- return {
72
- op_id: this.clientId,
73
- op: this.op,
74
- type: this.table,
75
- id: this.id,
76
- tx_id: this.transactionId,
77
- data: this.opData,
78
- old: this.previousValues,
79
- metadata: this.metadata
80
- };
81
- }
82
- equals(entry) {
83
- return JSON.stringify(this.toComparisonArray()) == JSON.stringify(entry.toComparisonArray());
84
- }
85
- /**
86
- * The hash code for this object.
87
- * @deprecated This should not be necessary in the JS SDK.
88
- * Use the @see CrudEntry#equals method instead.
89
- * TODO remove in the next major release.
90
- */
91
- hashCode() {
92
- return JSON.stringify(this.toComparisonArray());
93
- }
94
- /**
95
- * Generates an array for use in deep comparison operations
96
- */
97
- toComparisonArray() {
98
- return [
99
- this.transactionId,
100
- this.clientId,
101
- this.op,
102
- this.table,
103
- this.id,
104
- this.opData,
105
- this.previousValues,
106
- this.metadata
107
- ];
108
- }
109
- }
110
15
  //# sourceMappingURL=CrudEntry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CrudEntry.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/CrudEntry.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,CAAN,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,qHAAqH;IACrH,yBAAW,CAAA;IACX,8GAA8G;IAC9G,6BAAe,CAAA;IACf,4EAA4E;IAC5E,+BAAiB,CAAA;AACnB,CAAC,EAPW,UAAU,KAAV,UAAU,QAOrB;AA+BD;;GAEG;AACH,MAAM,OAAO,SAAS;IACpB;;OAEG;IACH,QAAQ,CAAS;IACjB;;OAEG;IACH,EAAE,CAAS;IACX;;OAEG;IACH,EAAE,CAAa;IACf;;OAEG;IACH,MAAM,CAAuB;IAE7B;;;OAGG;IACH,cAAc,CAAuB;IAErC;;OAEG;IACH,KAAK,CAAS;IACd;;OAEG;IACH,aAAa,CAAU;IAEvB;;;;;OAKG;IACH,QAAQ,CAAU;IAElB,MAAM,CAAC,OAAO,CAAC,KAAoB;QACjC,MAAM,IAAI,GAAsB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvD,OAAO,IAAI,SAAS,CAClB,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,EAClB,IAAI,CAAC,EAAE,EACP,IAAI,CAAC,IA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C;IAED;;OAEG;IACH,iBAAiB;QACf,OAAO;YACL,IAAI,CAAC,aAAa;YAClB,IAAI,CAAC,QAAQ;YACb,IAAI,CAAC,EAAE;YACP,IAAI,CAAC,KAAK;YACV,IAAI,CAAC,EAAE;YACP,IAAI,CAAC,MAAM;YACX,IAAI,CAAC,cAAc;YACnB,IAAI,CAAC,QAAQ;SACd,CAAC;IACJ,CAAC;CACF"}
1
+ {"version":3,"file":"CrudEntry.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/CrudEntry.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,MAAM,CAAN,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,qHAAqH;IACrH,yBAAW,CAAA;IACX,8GAA8G;IAC9G,6BAAe,CAAA;IACf,4EAA4E;IAC5E,+BAAiB,CAAA;AACnB,CAAC,EAPW,UAAU,KAAV,UAAU,QAOrB"}
@@ -1,5 +1,8 @@
1
1
  import { CrudBatch } from './CrudBatch.js';
2
2
  import { CrudEntry } from './CrudEntry.js';
3
+ /**
4
+ * @public
5
+ */
3
6
  export declare class CrudTransaction extends CrudBatch {
4
7
  /**
5
8
  * List of client-side changes.
@@ -1,4 +1,7 @@
1
1
  import { CrudBatch } from './CrudBatch.js';
2
+ /**
3
+ * @public
4
+ */
2
5
  export class CrudTransaction extends CrudBatch {
3
6
  crud;
4
7
  complete;
@@ -1 +1 @@
1
- {"version":3,"file":"CrudTransaction.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/CrudTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAKnC;IAIA;IAIA;IAZT;IACE;;OAEG;IACI,IAAiB;IACxB;;OAEG;IACI,QAAgD;IACvD;;OAEG;IACI,aAAsB;QAE7B,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAVtB,SAAI,GAAJ,IAAI,CAAa;QAIjB,aAAQ,GAAR,QAAQ,CAAwC;QAIhD,kBAAa,GAAb,aAAa,CAAS;IAG/B,CAAC;CACF"}
1
+ {"version":3,"file":"CrudTransaction.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/CrudTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAKnC;IAIA;IAIA;IAZT;IACE;;OAEG;IACI,IAAiB;IACxB;;OAEG;IACI,QAAgD;IACvD;;OAEG;IACI,aAAsB;QAE7B,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAVtB,SAAI,GAAJ,IAAI,CAAa;QAIjB,aAAQ,GAAR,QAAQ,CAAwC;QAIhD,kBAAa,GAAb,aAAa,CAAS;IAG/B,CAAC;CACF"}
@@ -0,0 +1,65 @@
1
+ import { StreamingSyncRequestParameterType } from './stream/JsonValue.js';
2
+ /**
3
+ * Options that affect how the PowerSync SDK connects to the PowerSync Service.
4
+ *
5
+ * @public
6
+ */
7
+ export interface SyncOptions {
8
+ /**
9
+ * A set of metadata to be included in service logs.
10
+ */
11
+ appMetadata?: Record<string, string>;
12
+ /**
13
+ * These parameters are passed to the sync rules, and will be available under the`user_parameters` object.
14
+ */
15
+ params?: Record<string, StreamingSyncRequestParameterType>;
16
+ /**
17
+ * The connection method to use when streaming updates from
18
+ * the PowerSync backend instance.
19
+ *
20
+ * The default value is SDK-specific. {@link SyncStreamConnectionMethod.HTTP} is the preferred implementation and used
21
+ * by default, except for React Native apps without Expo. Those don't support streaming HTTP responses, which is why
22
+ * {@link SyncStreamConnectionMethod.WEB_SOCKET} is used as a workaround.
23
+ */
24
+ connectionMethod?: SyncStreamConnectionMethod;
25
+ fetchStrategy?: FetchStrategy;
26
+ /**
27
+ * Whether to include streams that have `auto_subscribe: true` in their definition.
28
+ *
29
+ * This defaults to `true`.
30
+ */
31
+ includeDefaultStreams?: boolean;
32
+ /**
33
+ * Delay for retrying sync streaming operations
34
+ * from the PowerSync backend after an error occurs.
35
+ */
36
+ retryDelayMs?: number;
37
+ /**
38
+ * Backend Connector CRUD operations are throttled
39
+ * to occur at most every `crudUploadThrottleMs`
40
+ * milliseconds.
41
+ */
42
+ crudUploadThrottleMs?: number;
43
+ }
44
+ /**
45
+ * @public
46
+ */
47
+ export declare enum SyncStreamConnectionMethod {
48
+ HTTP = "http",
49
+ WEB_SOCKET = "web-socket"
50
+ }
51
+ /**
52
+ * @public
53
+ */
54
+ export declare enum FetchStrategy {
55
+ /**
56
+ * Queues multiple sync events before processing, reducing round-trips.
57
+ * This comes at the cost of more processing overhead, which may cause ACK timeouts on older/weaker devices for big enough datasets.
58
+ */
59
+ Buffered = "buffered",
60
+ /**
61
+ * Processes each sync event immediately before requesting the next.
62
+ * This reduces processing overhead and improves real-time responsiveness.
63
+ */
64
+ Sequential = "sequential"
65
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @public
3
+ */
4
+ export var SyncStreamConnectionMethod;
5
+ (function (SyncStreamConnectionMethod) {
6
+ SyncStreamConnectionMethod["HTTP"] = "http";
7
+ SyncStreamConnectionMethod["WEB_SOCKET"] = "web-socket";
8
+ })(SyncStreamConnectionMethod || (SyncStreamConnectionMethod = {}));
9
+ /**
10
+ * @public
11
+ */
12
+ export var FetchStrategy;
13
+ (function (FetchStrategy) {
14
+ /**
15
+ * Queues multiple sync events before processing, reducing round-trips.
16
+ * This comes at the cost of more processing overhead, which may cause ACK timeouts on older/weaker devices for big enough datasets.
17
+ */
18
+ FetchStrategy["Buffered"] = "buffered";
19
+ /**
20
+ * Processes each sync event immediately before requesting the next.
21
+ * This reduces processing overhead and improves real-time responsiveness.
22
+ */
23
+ FetchStrategy["Sequential"] = "sequential";
24
+ })(FetchStrategy || (FetchStrategy = {}));
25
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/client/sync/options.ts"],"names":[],"mappings":"AAqDA;;GAEG;AACH,MAAM,CAAN,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,2CAAa,CAAA;IACb,uDAAyB,CAAA;AAC3B,CAAC,EAHW,0BAA0B,KAA1B,0BAA0B,QAGrC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,aAYX;AAZD,WAAY,aAAa;IACvB;;;OAGG;IACH,sCAAqB,CAAA;IAErB;;;OAGG;IACH,0CAAyB,CAAA;AAC3B,CAAC,EAZW,aAAa,KAAb,aAAa,QAYxB"}
@@ -3,5 +3,8 @@ interface JSONObject {
3
3
  [key: string]: JSONValue;
4
4
  }
5
5
  type JSONArray = JSONValue[];
6
+ /**
7
+ * @public
8
+ */
6
9
  export type StreamingSyncRequestParameterType = JSONValue;
7
10
  export {};
@@ -1,5 +1,8 @@
1
1
  /**
2
- * A description of a sync stream, consisting of its {@link name} and the {@link parameters} used when subscribing.
2
+ * A description of a sync stream, consisting of its {@link SyncStreamDescription.name} and the
3
+ * {@link SyncStreamDescription.parameters} used when subscribing.
4
+ *
5
+ * @public
3
6
  */
4
7
  export interface SyncStreamDescription {
5
8
  /**
@@ -17,6 +20,8 @@ export interface SyncStreamDescription {
17
20
  * Information about a subscribed sync stream.
18
21
  *
19
22
  * This includes the {@link SyncStreamDescription}, along with information about the current sync status.
23
+ *
24
+ * @public
20
25
  */
21
26
  export interface SyncSubscriptionDescription extends SyncStreamDescription {
22
27
  active: boolean;
@@ -24,15 +29,17 @@ export interface SyncSubscriptionDescription extends SyncStreamDescription {
24
29
  * Whether this stream subscription is included by default, regardless of whether the stream has explicitly been
25
30
  * subscribed to or not.
26
31
  *
27
- * It's possible for both {@link isDefault} and {@link hasExplicitSubscription} to be true at the same time - this
28
- * happens when a default stream was subscribed explicitly.
32
+ * It's possible for both {@link SyncSubscriptionDescription.isDefault} and
33
+ * {@link SyncSubscriptionDescription.hasExplicitSubscription} to be true at the same time - this happens when a
34
+ * default stream was subscribed explicitly.
29
35
  */
30
36
  isDefault: boolean;
31
37
  /**
32
38
  * Whether this stream has been subscribed to explicitly.
33
39
  *
34
- * It's possible for both {@link isDefault} and {@link hasExplicitSubscription} to be true at the same time - this
35
- * happens when a default stream was subscribed explicitly.
40
+ * It's possible for both {@link SyncSubscriptionDescription.isDefault} and
41
+ * {@link SyncSubscriptionDescription.hasExplicitSubscription} to be true at the same time - this happens when a
42
+ * default stream was subscribed explicitly.
36
43
  */
37
44
  hasExplicitSubscription: boolean;
38
45
  /**
@@ -45,10 +52,13 @@ export interface SyncSubscriptionDescription extends SyncStreamDescription {
45
52
  */
46
53
  hasSynced: boolean;
47
54
  /**
48
- * If {@link hasSynced} is true, the last time data from this stream has been synced.
55
+ * If {@link SyncSubscriptionDescription.hasSynced} is true, the last time data from this stream has been synced.
49
56
  */
50
57
  lastSyncedAt: Date | null;
51
58
  }
59
+ /**
60
+ * @public
61
+ */
52
62
  export interface SyncStreamSubscribeOptions {
53
63
  /**
54
64
  * A "time to live" for this stream subscription, in seconds.
@@ -67,7 +77,9 @@ export interface SyncStreamSubscribeOptions {
67
77
  /**
68
78
  * A handle to a {@link SyncStreamDescription} that allows subscribing to the stream.
69
79
  *
70
- * To obtain an instance of {@link SyncStream}, call {@link AbstractPowerSyncDatabase.syncStream}.
80
+ * To obtain an instance of {@link SyncStream}, call {@link CommonPowerSyncDatabase.syncStream}.
81
+ *
82
+ * @public
71
83
  */
72
84
  export interface SyncStream extends SyncStreamDescription {
73
85
  /**
@@ -76,7 +88,7 @@ export interface SyncStream extends SyncStreamDescription {
76
88
  * You should keep a reference to the returned {@link SyncStreamSubscription} object along as you need data for that
77
89
  * stream. As soon as {@link SyncStreamSubscription.unsubscribe} is called for all subscriptions on this stream
78
90
  * (including subscriptions created on other tabs), the {@link SyncStreamSubscribeOptions.ttl} starts ticking and will
79
- * eventually evict the stream (unless {@link subscribe} is called again).
91
+ * eventually evict the stream (unless {@link SyncStream.subscribe} is called again).
80
92
  */
81
93
  subscribe(options?: SyncStreamSubscribeOptions): Promise<SyncStreamSubscription>;
82
94
  /**
@@ -86,6 +98,9 @@ export interface SyncStream extends SyncStreamDescription {
86
98
  */
87
99
  unsubscribeAll(): Promise<void>;
88
100
  }
101
+ /**
102
+ * @public
103
+ */
89
104
  export interface SyncStreamSubscription extends SyncStreamDescription {
90
105
  /**
91
106
  * A promise that resolves once data from in this sync stream has been synced and applied.