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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/lib/attachments/AttachmentContext.d.ts +9 -8
  2. package/lib/attachments/AttachmentContext.js +8 -3
  3. package/lib/attachments/AttachmentContext.js.map +1 -1
  4. package/lib/attachments/AttachmentErrorHandler.d.ts +6 -6
  5. package/lib/attachments/AttachmentQueue.d.ts +85 -36
  6. package/lib/attachments/AttachmentQueue.js +19 -21
  7. package/lib/attachments/AttachmentQueue.js.map +1 -1
  8. package/lib/attachments/AttachmentService.d.ts +3 -3
  9. package/lib/attachments/AttachmentService.js +4 -3
  10. package/lib/attachments/AttachmentService.js.map +1 -1
  11. package/lib/attachments/LocalStorageAdapter.d.ts +14 -8
  12. package/lib/attachments/LocalStorageAdapter.js +3 -0
  13. package/lib/attachments/LocalStorageAdapter.js.map +1 -1
  14. package/lib/attachments/RemoteStorageAdapter.d.ts +4 -4
  15. package/lib/attachments/Schema.d.ts +14 -6
  16. package/lib/attachments/Schema.js +8 -3
  17. package/lib/attachments/Schema.js.map +1 -1
  18. package/lib/attachments/SyncingService.d.ts +2 -2
  19. package/lib/attachments/SyncingService.js +8 -3
  20. package/lib/attachments/SyncingService.js.map +1 -1
  21. package/lib/attachments/WatchedAttachmentItem.d.ts +3 -1
  22. package/lib/client/{AbstractPowerSyncDatabase.d.ts → CommonPowerSyncDatabase.d.ts} +112 -238
  23. package/lib/client/CommonPowerSyncDatabase.js +2 -0
  24. package/lib/client/CommonPowerSyncDatabase.js.map +1 -0
  25. package/lib/client/Query.d.ts +9 -0
  26. package/lib/client/SQLOpenFactory.d.ts +44 -10
  27. package/lib/client/SQLOpenFactory.js +1 -19
  28. package/lib/client/SQLOpenFactory.js.map +1 -1
  29. package/lib/client/compilableQueryWatch.d.ts +8 -2
  30. package/lib/client/compilableQueryWatch.js +4 -2
  31. package/lib/client/compilableQueryWatch.js.map +1 -1
  32. package/lib/client/connection/PowerSyncBackendConnector.d.ts +6 -3
  33. package/lib/client/connection/PowerSyncCredentials.d.ts +3 -0
  34. package/lib/client/runOnSchemaChange.d.ts +5 -2
  35. package/lib/client/runOnSchemaChange.js +3 -0
  36. package/lib/client/runOnSchemaChange.js.map +1 -1
  37. package/lib/client/sync/bucket/CrudBatch.d.ts +2 -0
  38. package/lib/client/sync/bucket/CrudBatch.js +2 -0
  39. package/lib/client/sync/bucket/CrudBatch.js.map +1 -1
  40. package/lib/client/sync/bucket/CrudEntry.d.ts +9 -31
  41. package/lib/client/sync/bucket/CrudEntry.js +2 -97
  42. package/lib/client/sync/bucket/CrudEntry.js.map +1 -1
  43. package/lib/client/sync/bucket/CrudTransaction.d.ts +3 -0
  44. package/lib/client/sync/bucket/CrudTransaction.js +3 -0
  45. package/lib/client/sync/bucket/CrudTransaction.js.map +1 -1
  46. package/lib/client/sync/options.d.ts +65 -0
  47. package/lib/client/sync/options.js +25 -0
  48. package/lib/client/sync/options.js.map +1 -0
  49. package/lib/client/sync/stream/JsonValue.d.ts +10 -0
  50. package/lib/client/sync/stream/JsonValue.js +2 -0
  51. package/lib/client/sync/stream/JsonValue.js.map +1 -0
  52. package/lib/client/sync/sync-streams.d.ts +23 -8
  53. package/lib/client/triggers/TriggerManager.d.ts +28 -56
  54. package/lib/client/triggers/TriggerManager.js +2 -1
  55. package/lib/client/triggers/TriggerManager.js.map +1 -1
  56. package/lib/client/triggers/sanitizeSQL.d.ts +4 -0
  57. package/lib/client/triggers/sanitizeSQL.js +4 -0
  58. package/lib/client/triggers/sanitizeSQL.js.map +1 -1
  59. package/lib/client/watched/GetAllQuery.d.ts +7 -3
  60. package/lib/client/watched/GetAllQuery.js +3 -1
  61. package/lib/client/watched/GetAllQuery.js.map +1 -1
  62. package/lib/client/watched/WatchedQuery.d.ts +20 -6
  63. package/lib/client/watched/WatchedQuery.js +3 -5
  64. package/lib/client/watched/WatchedQuery.js.map +1 -1
  65. package/lib/client/watched/processors/DifferentialQueryProcessor.d.ts +15 -45
  66. package/lib/client/watched/processors/DifferentialQueryProcessor.js +1 -172
  67. package/lib/client/watched/processors/DifferentialQueryProcessor.js.map +1 -1
  68. package/lib/client/watched/processors/OnChangeQueryProcessor.d.ts +4 -22
  69. package/lib/client/watched/processors/OnChangeQueryProcessor.js +1 -82
  70. package/lib/client/watched/processors/OnChangeQueryProcessor.js.map +1 -1
  71. package/lib/client/watched/processors/comparators.d.ts +8 -0
  72. package/lib/client/watched/processors/comparators.js +4 -0
  73. package/lib/client/watched/processors/comparators.js.map +1 -1
  74. package/lib/db/DBAdapter.d.ts +90 -113
  75. package/lib/db/DBAdapter.js +70 -89
  76. package/lib/db/DBAdapter.js.map +1 -1
  77. package/lib/db/QueryResult.d.ts +104 -0
  78. package/lib/db/QueryResult.js +96 -0
  79. package/lib/db/QueryResult.js.map +1 -0
  80. package/lib/db/crud/SyncProgress.d.ts +7 -14
  81. package/lib/db/crud/SyncProgress.js +1 -60
  82. package/lib/db/crud/SyncProgress.js.map +1 -1
  83. package/lib/db/crud/SyncStatus.d.ts +54 -91
  84. package/lib/db/crud/SyncStatus.js +1 -245
  85. package/lib/db/crud/SyncStatus.js.map +1 -1
  86. package/lib/db/crud/UploadQueueStatus.d.ts +3 -0
  87. package/lib/db/crud/UploadQueueStatus.js +3 -0
  88. package/lib/db/crud/UploadQueueStatus.js.map +1 -1
  89. package/lib/db/schema/Column.d.ts +22 -1
  90. package/lib/db/schema/Column.js +10 -4
  91. package/lib/db/schema/Column.js.map +1 -1
  92. package/lib/db/schema/Index.d.ts +8 -3
  93. package/lib/db/schema/Index.js +4 -1
  94. package/lib/db/schema/Index.js.map +1 -1
  95. package/lib/db/schema/IndexedColumn.d.ts +8 -3
  96. package/lib/db/schema/IndexedColumn.js +4 -1
  97. package/lib/db/schema/IndexedColumn.js.map +1 -1
  98. package/lib/db/schema/RawTable.d.ts +7 -1
  99. package/lib/db/schema/Schema.d.ts +10 -29
  100. package/lib/db/schema/Schema.js +3 -1
  101. package/lib/db/schema/Schema.js.map +1 -1
  102. package/lib/db/schema/Table.d.ts +69 -91
  103. package/lib/db/schema/Table.js +88 -87
  104. package/lib/db/schema/Table.js.map +1 -1
  105. package/lib/index.d.ts +7 -27
  106. package/lib/index.js +6 -27
  107. package/lib/index.js.map +1 -1
  108. package/lib/types/types.d.ts +6 -0
  109. package/lib/utils/BaseObserver.d.ts +12 -0
  110. package/lib/utils/BaseObserver.js +3 -0
  111. package/lib/utils/BaseObserver.js.map +1 -1
  112. package/lib/utils/Logger.d.ts +60 -22
  113. package/lib/utils/Logger.js +38 -30
  114. package/lib/utils/Logger.js.map +1 -1
  115. package/lib/utils/MetaBaseObserver.d.ts +11 -11
  116. package/lib/utils/MetaBaseObserver.js +1 -50
  117. package/lib/utils/MetaBaseObserver.js.map +1 -1
  118. package/lib/utils/mutex.d.ts +3 -45
  119. package/lib/utils/mutex.js +1 -153
  120. package/lib/utils/mutex.js.map +1 -1
  121. package/package.json +8 -42
  122. package/src/attachments/AttachmentContext.ts +15 -13
  123. package/src/attachments/AttachmentErrorHandler.ts +6 -6
  124. package/src/attachments/AttachmentQueue.ts +99 -42
  125. package/src/attachments/AttachmentService.ts +7 -6
  126. package/src/attachments/LocalStorageAdapter.ts +14 -8
  127. package/src/attachments/README.md +2 -0
  128. package/src/attachments/RemoteStorageAdapter.ts +4 -4
  129. package/src/attachments/Schema.ts +14 -6
  130. package/src/attachments/SyncingService.ts +10 -6
  131. package/src/attachments/WatchedAttachmentItem.ts +3 -1
  132. package/src/client/CommonPowerSyncDatabase.ts +540 -0
  133. package/src/client/Query.ts +9 -0
  134. package/src/client/SQLOpenFactory.ts +47 -19
  135. package/src/client/compilableQueryWatch.ts +9 -4
  136. package/src/client/connection/PowerSyncBackendConnector.ts +6 -3
  137. package/src/client/connection/PowerSyncCredentials.ts +3 -0
  138. package/src/client/runOnSchemaChange.ts +5 -2
  139. package/src/client/sync/bucket/CrudBatch.ts +2 -0
  140. package/src/client/sync/bucket/CrudEntry.ts +10 -101
  141. package/src/client/sync/bucket/CrudTransaction.ts +3 -0
  142. package/src/client/sync/options.ts +77 -0
  143. package/src/client/sync/stream/JsonValue.ts +11 -0
  144. package/src/client/sync/sync-streams.ts +23 -10
  145. package/src/client/triggers/TriggerManager.ts +29 -59
  146. package/src/client/triggers/sanitizeSQL.ts +5 -0
  147. package/src/client/watched/GetAllQuery.ts +8 -4
  148. package/src/client/watched/WatchedQuery.ts +20 -11
  149. package/src/client/watched/processors/DifferentialQueryProcessor.ts +19 -219
  150. package/src/client/watched/processors/OnChangeQueryProcessor.ts +4 -109
  151. package/src/client/watched/processors/comparators.ts +8 -0
  152. package/src/db/DBAdapter.ts +160 -175
  153. package/src/db/QueryResult.ts +195 -0
  154. package/src/db/crud/SyncProgress.ts +8 -43
  155. package/src/db/crud/SyncStatus.ts +66 -216
  156. package/src/db/crud/UploadQueueStatus.ts +3 -0
  157. package/src/db/schema/Column.ts +22 -5
  158. package/src/db/schema/Index.ts +9 -3
  159. package/src/db/schema/IndexedColumn.ts +9 -3
  160. package/src/db/schema/RawTable.ts +7 -1
  161. package/src/db/schema/Schema.ts +12 -7
  162. package/src/db/schema/Table.ts +130 -180
  163. package/src/index.ts +7 -27
  164. package/src/types/types.ts +6 -0
  165. package/src/utils/BaseObserver.ts +12 -0
  166. package/src/utils/Logger.ts +86 -31
  167. package/src/utils/MetaBaseObserver.ts +14 -60
  168. package/src/utils/mutex.ts +4 -189
  169. package/dist/bundle.cjs +0 -14781
  170. package/dist/bundle.cjs.map +0 -1
  171. package/dist/bundle.mjs +0 -14689
  172. package/dist/bundle.mjs.map +0 -1
  173. package/dist/bundle.node.cjs +0 -12258
  174. package/dist/bundle.node.cjs.map +0 -1
  175. package/dist/bundle.node.mjs +0 -12166
  176. package/dist/bundle.node.mjs.map +0 -1
  177. package/dist/index.d.cts +0 -4391
  178. package/lib/client/AbstractPowerSyncDatabase.js +0 -987
  179. package/lib/client/AbstractPowerSyncDatabase.js.map +0 -1
  180. package/lib/client/AbstractPowerSyncOpenFactory.d.ts +0 -22
  181. package/lib/client/AbstractPowerSyncOpenFactory.js +0 -25
  182. package/lib/client/AbstractPowerSyncOpenFactory.js.map +0 -1
  183. package/lib/client/ConnectionManager.d.ts +0 -112
  184. package/lib/client/ConnectionManager.js +0 -294
  185. package/lib/client/ConnectionManager.js.map +0 -1
  186. package/lib/client/CustomQuery.d.ts +0 -22
  187. package/lib/client/CustomQuery.js +0 -43
  188. package/lib/client/CustomQuery.js.map +0 -1
  189. package/lib/client/constants.d.ts +0 -1
  190. package/lib/client/constants.js +0 -2
  191. package/lib/client/constants.js.map +0 -1
  192. package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +0 -102
  193. package/lib/client/sync/bucket/BucketStorageAdapter.js +0 -19
  194. package/lib/client/sync/bucket/BucketStorageAdapter.js.map +0 -1
  195. package/lib/client/sync/bucket/OpType.d.ts +0 -16
  196. package/lib/client/sync/bucket/OpType.js +0 -23
  197. package/lib/client/sync/bucket/OpType.js.map +0 -1
  198. package/lib/client/sync/bucket/OplogEntry.d.ts +0 -23
  199. package/lib/client/sync/bucket/OplogEntry.js +0 -36
  200. package/lib/client/sync/bucket/OplogEntry.js.map +0 -1
  201. package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +0 -61
  202. package/lib/client/sync/bucket/SqliteBucketStorage.js +0 -324
  203. package/lib/client/sync/bucket/SqliteBucketStorage.js.map +0 -1
  204. package/lib/client/sync/bucket/SyncDataBatch.d.ts +0 -6
  205. package/lib/client/sync/bucket/SyncDataBatch.js +0 -12
  206. package/lib/client/sync/bucket/SyncDataBatch.js.map +0 -1
  207. package/lib/client/sync/bucket/SyncDataBucket.d.ts +0 -40
  208. package/lib/client/sync/bucket/SyncDataBucket.js +0 -40
  209. package/lib/client/sync/bucket/SyncDataBucket.js.map +0 -1
  210. package/lib/client/sync/stream/AbstractRemote.d.ts +0 -161
  211. package/lib/client/sync/stream/AbstractRemote.js +0 -483
  212. package/lib/client/sync/stream/AbstractRemote.js.map +0 -1
  213. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +0 -244
  214. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +0 -990
  215. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +0 -1
  216. package/lib/client/sync/stream/WebsocketClientTransport.d.ts +0 -15
  217. package/lib/client/sync/stream/WebsocketClientTransport.js +0 -61
  218. package/lib/client/sync/stream/WebsocketClientTransport.js.map +0 -1
  219. package/lib/client/sync/stream/core-instruction.d.ts +0 -72
  220. package/lib/client/sync/stream/core-instruction.js +0 -27
  221. package/lib/client/sync/stream/core-instruction.js.map +0 -1
  222. package/lib/client/sync/stream/streaming-sync-types.d.ts +0 -143
  223. package/lib/client/sync/stream/streaming-sync-types.js +0 -26
  224. package/lib/client/sync/stream/streaming-sync-types.js.map +0 -1
  225. package/lib/client/triggers/MemoryTriggerClaimManager.d.ts +0 -6
  226. package/lib/client/triggers/MemoryTriggerClaimManager.js +0 -21
  227. package/lib/client/triggers/MemoryTriggerClaimManager.js.map +0 -1
  228. package/lib/client/triggers/TriggerManagerImpl.d.ts +0 -39
  229. package/lib/client/triggers/TriggerManagerImpl.js +0 -405
  230. package/lib/client/triggers/TriggerManagerImpl.js.map +0 -1
  231. package/lib/client/watched/processors/AbstractQueryProcessor.d.ts +0 -68
  232. package/lib/client/watched/processors/AbstractQueryProcessor.js +0 -151
  233. package/lib/client/watched/processors/AbstractQueryProcessor.js.map +0 -1
  234. package/lib/db/ConnectionClosedError.d.ts +0 -10
  235. package/lib/db/ConnectionClosedError.js +0 -21
  236. package/lib/db/ConnectionClosedError.js.map +0 -1
  237. package/lib/db/schema/TableV2.d.ts +0 -9
  238. package/lib/db/schema/TableV2.js +0 -9
  239. package/lib/db/schema/TableV2.js.map +0 -1
  240. package/lib/utils/AbortOperation.d.ts +0 -9
  241. package/lib/utils/AbortOperation.js +0 -19
  242. package/lib/utils/AbortOperation.js.map +0 -1
  243. package/lib/utils/ControlledExecutor.d.ts +0 -25
  244. package/lib/utils/ControlledExecutor.js +0 -51
  245. package/lib/utils/ControlledExecutor.js.map +0 -1
  246. package/lib/utils/async.d.ts +0 -14
  247. package/lib/utils/async.js +0 -46
  248. package/lib/utils/async.js.map +0 -1
  249. package/lib/utils/parseQuery.d.ts +0 -6
  250. package/lib/utils/parseQuery.js +0 -17
  251. package/lib/utils/parseQuery.js.map +0 -1
  252. package/lib/utils/queue.d.ts +0 -16
  253. package/lib/utils/queue.js +0 -42
  254. package/lib/utils/queue.js.map +0 -1
  255. package/lib/utils/stream_transform.d.ts +0 -39
  256. package/lib/utils/stream_transform.js +0 -206
  257. package/lib/utils/stream_transform.js.map +0 -1
  258. package/src/client/AbstractPowerSyncDatabase.ts +0 -1362
  259. package/src/client/AbstractPowerSyncOpenFactory.ts +0 -39
  260. package/src/client/ConnectionManager.ts +0 -402
  261. package/src/client/CustomQuery.ts +0 -56
  262. package/src/client/constants.ts +0 -1
  263. package/src/client/sync/bucket/BucketStorageAdapter.ts +0 -118
  264. package/src/client/sync/bucket/OpType.ts +0 -23
  265. package/src/client/sync/bucket/OplogEntry.ts +0 -50
  266. package/src/client/sync/bucket/SqliteBucketStorage.ts +0 -395
  267. package/src/client/sync/bucket/SyncDataBatch.ts +0 -11
  268. package/src/client/sync/bucket/SyncDataBucket.ts +0 -49
  269. package/src/client/sync/stream/AbstractRemote.ts +0 -624
  270. package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +0 -1285
  271. package/src/client/sync/stream/WebsocketClientTransport.ts +0 -80
  272. package/src/client/sync/stream/core-instruction.ts +0 -99
  273. package/src/client/sync/stream/streaming-sync-types.ts +0 -210
  274. package/src/client/triggers/MemoryTriggerClaimManager.ts +0 -25
  275. package/src/client/triggers/TriggerManagerImpl.ts +0 -496
  276. package/src/client/watched/processors/AbstractQueryProcessor.ts +0 -226
  277. package/src/db/ConnectionClosedError.ts +0 -23
  278. package/src/db/schema/TableV2.ts +0 -9
  279. package/src/utils/AbortOperation.ts +0 -17
  280. package/src/utils/ControlledExecutor.ts +0 -72
  281. package/src/utils/async.ts +0 -50
  282. package/src/utils/parseQuery.ts +0 -25
  283. package/src/utils/queue.ts +0 -48
  284. package/src/utils/stream_transform.ts +0 -252
@@ -1 +0,0 @@
1
- {"version":3,"file":"SyncDataBatch.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/SyncDataBatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,YAAY;AAEZ,MAAM,OAAO,aAAa;IAKL;IAJnB,MAAM,CAAC,QAAQ,CAAC,IAAS;QACvB,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAW,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED,YAAmB,OAAyB;QAAzB,YAAO,GAAP,OAAO,CAAkB;IAAG,CAAC;CACjD"}
@@ -1,40 +0,0 @@
1
- import { OpId } from './CrudEntry.js';
2
- import { OplogEntry, OplogEntryJSON } from './OplogEntry.js';
3
- export type SyncDataBucketJSON = {
4
- bucket: string;
5
- has_more?: boolean;
6
- after?: string;
7
- next_after?: string;
8
- data: OplogEntryJSON[];
9
- };
10
- export declare class SyncDataBucket {
11
- bucket: string;
12
- data: OplogEntry[];
13
- /**
14
- * True if the response does not contain all the data for this bucket, and another request must be made.
15
- */
16
- has_more: boolean;
17
- /**
18
- * The `after` specified in the request.
19
- */
20
- after?: OpId | undefined;
21
- /**
22
- * Use this for the next request.
23
- */
24
- next_after?: OpId | undefined;
25
- static fromRow(row: SyncDataBucketJSON): SyncDataBucket;
26
- constructor(bucket: string, data: OplogEntry[],
27
- /**
28
- * True if the response does not contain all the data for this bucket, and another request must be made.
29
- */
30
- has_more: boolean,
31
- /**
32
- * The `after` specified in the request.
33
- */
34
- after?: OpId | undefined,
35
- /**
36
- * Use this for the next request.
37
- */
38
- next_after?: OpId | undefined);
39
- toJSON(fixedKeyEncoding?: boolean): SyncDataBucketJSON;
40
- }
@@ -1,40 +0,0 @@
1
- import { OplogEntry } from './OplogEntry.js';
2
- export class SyncDataBucket {
3
- bucket;
4
- data;
5
- has_more;
6
- after;
7
- next_after;
8
- static fromRow(row) {
9
- return new SyncDataBucket(row.bucket, row.data.map((entry) => OplogEntry.fromRow(entry)), row.has_more ?? false, row.after, row.next_after);
10
- }
11
- constructor(bucket, data,
12
- /**
13
- * True if the response does not contain all the data for this bucket, and another request must be made.
14
- */
15
- has_more,
16
- /**
17
- * The `after` specified in the request.
18
- */
19
- after,
20
- /**
21
- * Use this for the next request.
22
- */
23
- next_after) {
24
- this.bucket = bucket;
25
- this.data = data;
26
- this.has_more = has_more;
27
- this.after = after;
28
- this.next_after = next_after;
29
- }
30
- toJSON(fixedKeyEncoding = false) {
31
- return {
32
- bucket: this.bucket,
33
- has_more: this.has_more,
34
- after: this.after,
35
- next_after: this.next_after,
36
- data: this.data.map((entry) => entry.toJSON(fixedKeyEncoding))
37
- };
38
- }
39
- }
40
- //# sourceMappingURL=SyncDataBucket.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SyncDataBucket.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/SyncDataBucket.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAkB,MAAM,iBAAiB,CAAC;AAU7D,MAAM,OAAO,cAAc;IAYhB;IACA;IAIA;IAIA;IAIA;IAxBT,MAAM,CAAC,OAAO,CAAC,GAAuB;QACpC,OAAO,IAAI,cAAc,CACvB,GAAG,CAAC,MAAM,EACV,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAClD,GAAG,CAAC,QAAQ,IAAI,KAAK,EACrB,GAAG,CAAC,KAAK,EACT,GAAG,CAAC,UAAU,CACf,CAAC;IACJ,CAAC;IAED,YACS,MAAc,EACd,IAAkB;IACzB;;OAEG;IACI,QAAiB;IACxB;;OAEG;IACI,KAAY;IACnB;;OAEG;IACI,UAAiB;QAbjB,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAc;QAIlB,aAAQ,GAAR,QAAQ,CAAS;QAIjB,UAAK,GAAL,KAAK,CAAO;QAIZ,eAAU,GAAV,UAAU,CAAO;IACvB,CAAC;IAEJ,MAAM,CAAC,gBAAgB,GAAG,KAAK;QAC7B,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;SAC/D,CAAC;IACJ,CAAC;CACF"}
@@ -1,161 +0,0 @@
1
- import type { BSON } from 'bson';
2
- import { type fetch } from 'cross-fetch';
3
- import Logger, { ILogger } from 'js-logger';
4
- import { PowerSyncCredentials } from '../../connection/PowerSyncCredentials.js';
5
- import { StreamingSyncRequest } from './streaming-sync-types.js';
6
- import { SimpleAsyncIterator } from '../../../utils/stream_transform.js';
7
- export type BSONImplementation = typeof BSON;
8
- export type RemoteConnector = {
9
- fetchCredentials: () => Promise<PowerSyncCredentials | null>;
10
- invalidateCredentials?: () => void;
11
- };
12
- export declare const DEFAULT_REMOTE_LOGGER: Logger.ILogger;
13
- export type SyncStreamOptions = {
14
- path: string;
15
- data: StreamingSyncRequest;
16
- headers?: Record<string, string>;
17
- abortSignal: AbortSignal;
18
- fetchOptions?: Request;
19
- };
20
- export declare enum FetchStrategy {
21
- /**
22
- * Queues multiple sync events before processing, reducing round-trips.
23
- * This comes at the cost of more processing overhead, which may cause ACK timeouts on older/weaker devices for big enough datasets.
24
- */
25
- Buffered = "buffered",
26
- /**
27
- * Processes each sync event immediately before requesting the next.
28
- * This reduces processing overhead and improves real-time responsiveness.
29
- */
30
- Sequential = "sequential"
31
- }
32
- export type SocketSyncStreamOptions = SyncStreamOptions & {
33
- fetchStrategy: FetchStrategy;
34
- };
35
- export type FetchImplementation = typeof fetch;
36
- /**
37
- * Class wrapper for providing a fetch implementation.
38
- * The class wrapper is used to distinguish the fetchImplementation
39
- * option in [AbstractRemoteOptions] from the general fetch method
40
- * which is typeof "function"
41
- */
42
- export declare class FetchImplementationProvider {
43
- getFetch(): FetchImplementation;
44
- }
45
- export type AbstractRemoteOptions = {
46
- /**
47
- * Transforms the PowerSync base URL which might contain
48
- * `http(s)://` to the corresponding WebSocket variant
49
- * e.g. `ws(s)://`
50
- */
51
- socketUrlTransformer: (url: string) => string;
52
- /**
53
- * Optionally provide the fetch implementation to use.
54
- * Note that this usually needs to be bound to the global scope.
55
- * Binding should be done before passing here.
56
- */
57
- fetchImplementation: FetchImplementation | FetchImplementationProvider;
58
- /**
59
- * Optional options to pass directly to all `fetch` calls.
60
- *
61
- * This can include fields such as `dispatcher` (e.g. for proxy support),
62
- * `cache`, or any other fetch-compatible options.
63
- */
64
- fetchOptions?: {};
65
- };
66
- export declare const DEFAULT_REMOTE_OPTIONS: AbstractRemoteOptions;
67
- export declare abstract class AbstractRemote {
68
- protected connector: RemoteConnector;
69
- protected logger: ILogger;
70
- protected credentials: PowerSyncCredentials | null;
71
- protected options: AbstractRemoteOptions;
72
- constructor(connector: RemoteConnector, logger?: ILogger, options?: Partial<AbstractRemoteOptions>);
73
- /**
74
- * @returns a fetch implementation (function)
75
- * which can be called to perform fetch requests
76
- */
77
- get fetch(): FetchImplementation;
78
- /**
79
- * Get credentials currently cached, or fetch new credentials if none are
80
- * available.
81
- *
82
- * These credentials may have expired already.
83
- */
84
- getCredentials(): Promise<PowerSyncCredentials | null>;
85
- /**
86
- * Fetch a new set of credentials and cache it.
87
- *
88
- * Until this call succeeds, `getCredentials` will still return the
89
- * old credentials.
90
- *
91
- * This may be called before the current credentials have expired.
92
- */
93
- prefetchCredentials(): Promise<PowerSyncCredentials | null>;
94
- /**
95
- * Get credentials for PowerSync.
96
- *
97
- * This should always fetch a fresh set of credentials - don't use cached
98
- * values.
99
- */
100
- fetchCredentials(): Promise<PowerSyncCredentials | null>;
101
- /***
102
- * Immediately invalidate credentials.
103
- *
104
- * This may be called when the current credentials have expired.
105
- */
106
- invalidateCredentials(): void;
107
- getUserAgent(): string;
108
- protected buildRequest(path: string): Promise<{
109
- url: string;
110
- headers: {
111
- 'content-type': string;
112
- Authorization: string;
113
- 'x-user-agent': string;
114
- };
115
- }>;
116
- post(path: string, data: any, headers?: Record<string, string>): Promise<any>;
117
- get(path: string, headers?: Record<string, string>): Promise<any>;
118
- /**
119
- * Provides a BSON implementation. The import nature of this varies depending on the platform
120
- */
121
- abstract getBSON(): Promise<BSONImplementation>;
122
- /**
123
- * @returns A text decoder decoding UTF-8. This is a method to allow patching it for Hermes which doesn't support the
124
- * builtin, without forcing us to bundle a polyfill with `@powersync/common`.
125
- */
126
- createTextDecoder(): TextDecoder;
127
- protected createSocket(url: string): WebSocket;
128
- /**
129
- * Returns a data stream of sync line data, fetched via RSocket-over-WebSocket.
130
- *
131
- * The only mechanism to abort the returned stream is to use the abort signal in {@link SocketSyncStreamOptions}.
132
- *
133
- * @param bson A BSON encoder and decoder. When set, the data stream will be requested with a BSON payload
134
- * (required for compatibility with older sync services).
135
- */
136
- socketStreamRaw(options: SocketSyncStreamOptions, bson?: typeof BSON): Promise<SimpleAsyncIterator<Uint8Array>>;
137
- /**
138
- * @returns Whether the HTTP implementation on this platform can receive streamed binary responses. This is true on
139
- * all platforms except React Native (who would have guessed...), where we must not request BSON responses.
140
- *
141
- * @see https://github.com/react-native-community/fetch?tab=readme-ov-file#motivation
142
- */
143
- protected get supportsStreamingBinaryResponses(): boolean;
144
- /**
145
- * Posts a `/sync/stream` request, asserts that it completes successfully and returns the streaming response as an
146
- * async iterator of byte blobs.
147
- *
148
- * To cancel the async iterator, use the abort signal from {@link SyncStreamOptions} passed to this method.
149
- */
150
- protected fetchStreamRaw(options: SyncStreamOptions): Promise<{
151
- isBson: boolean;
152
- stream: SimpleAsyncIterator<Uint8Array>;
153
- }>;
154
- /**
155
- * Posts a `/sync/stream` request.
156
- *
157
- * Depending on the `Content-Type` of the response, this returns strings for sync lines or encoded BSON documents as
158
- * {@link Uint8Array}s.
159
- */
160
- fetchStream(options: SyncStreamOptions): Promise<SimpleAsyncIterator<Uint8Array | string>>;
161
- }