@powersync/common 1.57.3 → 2.1.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 (229) hide show
  1. package/lib/attachments/AttachmentContext.d.ts +5 -5
  2. package/lib/attachments/AttachmentContext.js +6 -2
  3. package/lib/attachments/AttachmentContext.js.map +1 -1
  4. package/lib/attachments/AttachmentQueue.d.ts +85 -47
  5. package/lib/attachments/AttachmentQueue.js +55 -18
  6. package/lib/attachments/AttachmentQueue.js.map +1 -1
  7. package/lib/attachments/AttachmentService.d.ts +3 -3
  8. package/lib/attachments/AttachmentService.js +4 -3
  9. package/lib/attachments/AttachmentService.js.map +1 -1
  10. package/lib/attachments/AttachmentTransportAdapter.d.ts +47 -0
  11. package/lib/attachments/AttachmentTransportAdapter.js +2 -0
  12. package/lib/attachments/AttachmentTransportAdapter.js.map +1 -0
  13. package/lib/attachments/BufferedAttachmentTransport.d.ts +24 -0
  14. package/lib/attachments/BufferedAttachmentTransport.js +32 -0
  15. package/lib/attachments/BufferedAttachmentTransport.js.map +1 -0
  16. package/lib/attachments/LocalStorageAdapter.d.ts +19 -0
  17. package/lib/attachments/Schema.d.ts +2 -2
  18. package/lib/attachments/SyncingService.d.ts +8 -5
  19. package/lib/attachments/SyncingService.js +31 -15
  20. package/lib/attachments/SyncingService.js.map +1 -1
  21. package/lib/client/{AbstractPowerSyncDatabase.d.ts → CommonPowerSyncDatabase.d.ts} +56 -232
  22. package/lib/client/CommonPowerSyncDatabase.js +2 -0
  23. package/lib/client/CommonPowerSyncDatabase.js.map +1 -0
  24. package/lib/client/SQLOpenFactory.d.ts +35 -13
  25. package/lib/client/SQLOpenFactory.js +1 -25
  26. package/lib/client/SQLOpenFactory.js.map +1 -1
  27. package/lib/client/compilableQueryWatch.d.ts +2 -2
  28. package/lib/client/compilableQueryWatch.js +1 -2
  29. package/lib/client/compilableQueryWatch.js.map +1 -1
  30. package/lib/client/connection/PowerSyncBackendConnector.d.ts +3 -3
  31. package/lib/client/runOnSchemaChange.d.ts +2 -2
  32. package/lib/client/runOnSchemaChange.js.map +1 -1
  33. package/lib/client/sync/bucket/CrudEntry.d.ts +3 -34
  34. package/lib/client/sync/bucket/CrudEntry.js +0 -99
  35. package/lib/client/sync/bucket/CrudEntry.js.map +1 -1
  36. package/lib/client/sync/options.d.ts +65 -0
  37. package/lib/client/sync/options.js +25 -0
  38. package/lib/client/sync/options.js.map +1 -0
  39. package/lib/client/sync/sync-streams.d.ts +1 -1
  40. package/lib/client/triggers/TriggerManager.d.ts +9 -38
  41. package/lib/client/watched/GetAllQuery.d.ts +3 -3
  42. package/lib/client/watched/GetAllQuery.js +1 -1
  43. package/lib/client/watched/GetAllQuery.js.map +1 -1
  44. package/lib/client/watched/WatchedQuery.d.ts +2 -10
  45. package/lib/client/watched/WatchedQuery.js +0 -11
  46. package/lib/client/watched/WatchedQuery.js.map +1 -1
  47. package/lib/client/watched/processors/DifferentialQueryProcessor.d.ts +0 -50
  48. package/lib/client/watched/processors/DifferentialQueryProcessor.js +1 -176
  49. package/lib/client/watched/processors/DifferentialQueryProcessor.js.map +1 -1
  50. package/lib/client/watched/processors/OnChangeQueryProcessor.d.ts +0 -22
  51. package/lib/client/watched/processors/OnChangeQueryProcessor.js +1 -82
  52. package/lib/client/watched/processors/OnChangeQueryProcessor.js.map +1 -1
  53. package/lib/db/DBAdapter.d.ts +72 -154
  54. package/lib/db/DBAdapter.js +70 -108
  55. package/lib/db/DBAdapter.js.map +1 -1
  56. package/lib/db/QueryResult.d.ts +104 -0
  57. package/lib/db/QueryResult.js +96 -0
  58. package/lib/db/QueryResult.js.map +1 -0
  59. package/lib/db/crud/SyncProgress.d.ts +1 -13
  60. package/lib/db/crud/SyncProgress.js +1 -62
  61. package/lib/db/crud/SyncProgress.js.map +1 -1
  62. package/lib/db/crud/SyncStatus.d.ts +32 -66
  63. package/lib/db/crud/SyncStatus.js +1 -253
  64. package/lib/db/crud/SyncStatus.js.map +1 -1
  65. package/lib/db/schema/Column.d.ts +0 -7
  66. package/lib/db/schema/Column.js +0 -7
  67. package/lib/db/schema/Column.js.map +1 -1
  68. package/lib/db/schema/Index.d.ts +2 -6
  69. package/lib/db/schema/Index.js +1 -4
  70. package/lib/db/schema/Index.js.map +1 -1
  71. package/lib/db/schema/IndexedColumn.d.ts +2 -6
  72. package/lib/db/schema/IndexedColumn.js +1 -4
  73. package/lib/db/schema/IndexedColumn.js.map +1 -1
  74. package/lib/db/schema/Schema.d.ts +4 -28
  75. package/lib/db/schema/Schema.js.map +1 -1
  76. package/lib/db/schema/Table.d.ts +50 -96
  77. package/lib/db/schema/Table.js +83 -91
  78. package/lib/db/schema/Table.js.map +1 -1
  79. package/lib/index.d.ts +6 -21
  80. package/lib/index.js +6 -22
  81. package/lib/index.js.map +1 -1
  82. package/lib/utils/BaseObserver.d.ts +1 -1
  83. package/lib/utils/BaseObserver.js +1 -1
  84. package/lib/utils/Logger.d.ts +52 -23
  85. package/lib/utils/Logger.js +35 -33
  86. package/lib/utils/Logger.js.map +1 -1
  87. package/lib/utils/MetaBaseObserver.d.ts +11 -11
  88. package/lib/utils/MetaBaseObserver.js +1 -50
  89. package/lib/utils/MetaBaseObserver.js.map +1 -1
  90. package/lib/utils/mutex.d.ts +3 -53
  91. package/lib/utils/mutex.js +1 -156
  92. package/lib/utils/mutex.js.map +1 -1
  93. package/package.json +8 -45
  94. package/src/attachments/AttachmentContext.ts +11 -10
  95. package/src/attachments/AttachmentQueue.ts +129 -70
  96. package/src/attachments/AttachmentService.ts +7 -6
  97. package/src/attachments/AttachmentTransportAdapter.ts +49 -0
  98. package/src/attachments/BufferedAttachmentTransport.ts +37 -0
  99. package/src/attachments/LocalStorageAdapter.ts +20 -0
  100. package/src/attachments/Schema.ts +2 -2
  101. package/src/attachments/SyncingService.ts +34 -20
  102. package/src/client/CommonPowerSyncDatabase.ts +540 -0
  103. package/src/client/SQLOpenFactory.ts +38 -22
  104. package/src/client/compilableQueryWatch.ts +3 -4
  105. package/src/client/connection/PowerSyncBackendConnector.ts +3 -3
  106. package/src/client/runOnSchemaChange.ts +2 -2
  107. package/src/client/sync/bucket/CrudEntry.ts +4 -104
  108. package/src/client/sync/options.ts +77 -0
  109. package/src/client/sync/sync-streams.ts +1 -1
  110. package/src/client/triggers/TriggerManager.ts +10 -41
  111. package/src/client/watched/GetAllQuery.ts +3 -3
  112. package/src/client/watched/WatchedQuery.ts +2 -15
  113. package/src/client/watched/processors/DifferentialQueryProcessor.ts +0 -223
  114. package/src/client/watched/processors/OnChangeQueryProcessor.ts +0 -111
  115. package/src/db/DBAdapter.ts +141 -226
  116. package/src/db/QueryResult.ts +195 -0
  117. package/src/db/crud/SyncProgress.ts +2 -42
  118. package/src/db/crud/SyncStatus.ts +45 -220
  119. package/src/db/schema/Column.ts +0 -8
  120. package/src/db/schema/Index.ts +3 -6
  121. package/src/db/schema/IndexedColumn.ts +3 -6
  122. package/src/db/schema/Schema.ts +4 -4
  123. package/src/db/schema/Table.ts +111 -186
  124. package/src/index.ts +6 -21
  125. package/src/utils/BaseObserver.ts +1 -1
  126. package/src/utils/Logger.ts +80 -42
  127. package/src/utils/MetaBaseObserver.ts +14 -60
  128. package/src/utils/mutex.ts +4 -201
  129. package/dist/bundle.cjs +0 -14398
  130. package/dist/bundle.cjs.map +0 -1
  131. package/dist/bundle.mjs +0 -14317
  132. package/dist/bundle.mjs.map +0 -1
  133. package/dist/bundle.node.cjs +0 -12029
  134. package/dist/bundle.node.cjs.map +0 -1
  135. package/dist/bundle.node.mjs +0 -11948
  136. package/dist/bundle.node.mjs.map +0 -1
  137. package/dist/index.d.cts +0 -4651
  138. package/legacy/sync_protocol.d.ts +0 -103
  139. package/lib/client/AbstractPowerSyncDatabase.js +0 -990
  140. package/lib/client/AbstractPowerSyncDatabase.js.map +0 -1
  141. package/lib/client/AbstractPowerSyncOpenFactory.d.ts +0 -28
  142. package/lib/client/AbstractPowerSyncOpenFactory.js +0 -28
  143. package/lib/client/AbstractPowerSyncOpenFactory.js.map +0 -1
  144. package/lib/client/ConnectionManager.d.ts +0 -115
  145. package/lib/client/ConnectionManager.js +0 -294
  146. package/lib/client/ConnectionManager.js.map +0 -1
  147. package/lib/client/CustomQuery.d.ts +0 -22
  148. package/lib/client/CustomQuery.js +0 -43
  149. package/lib/client/CustomQuery.js.map +0 -1
  150. package/lib/client/constants.d.ts +0 -4
  151. package/lib/client/constants.js +0 -5
  152. package/lib/client/constants.js.map +0 -1
  153. package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +0 -56
  154. package/lib/client/sync/bucket/BucketStorageAdapter.js +0 -29
  155. package/lib/client/sync/bucket/BucketStorageAdapter.js.map +0 -1
  156. package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +0 -37
  157. package/lib/client/sync/bucket/SqliteBucketStorage.js +0 -165
  158. package/lib/client/sync/bucket/SqliteBucketStorage.js.map +0 -1
  159. package/lib/client/sync/stream/AbstractRemote.d.ts +0 -180
  160. package/lib/client/sync/stream/AbstractRemote.js +0 -508
  161. package/lib/client/sync/stream/AbstractRemote.js.map +0 -1
  162. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +0 -265
  163. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +0 -706
  164. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +0 -1
  165. package/lib/client/sync/stream/WebsocketClientTransport.d.ts +0 -15
  166. package/lib/client/sync/stream/WebsocketClientTransport.js +0 -62
  167. package/lib/client/sync/stream/WebsocketClientTransport.js.map +0 -1
  168. package/lib/client/sync/stream/core-instruction.d.ts +0 -77
  169. package/lib/client/sync/stream/core-instruction.js +0 -30
  170. package/lib/client/sync/stream/core-instruction.js.map +0 -1
  171. package/lib/client/triggers/MemoryTriggerClaimManager.d.ts +0 -6
  172. package/lib/client/triggers/MemoryTriggerClaimManager.js +0 -21
  173. package/lib/client/triggers/MemoryTriggerClaimManager.js.map +0 -1
  174. package/lib/client/triggers/TriggerManagerImpl.d.ts +0 -39
  175. package/lib/client/triggers/TriggerManagerImpl.js +0 -410
  176. package/lib/client/triggers/TriggerManagerImpl.js.map +0 -1
  177. package/lib/client/watched/processors/AbstractQueryProcessor.d.ts +0 -68
  178. package/lib/client/watched/processors/AbstractQueryProcessor.js +0 -151
  179. package/lib/client/watched/processors/AbstractQueryProcessor.js.map +0 -1
  180. package/lib/db/ConnectionClosedError.d.ts +0 -12
  181. package/lib/db/ConnectionClosedError.js +0 -23
  182. package/lib/db/ConnectionClosedError.js.map +0 -1
  183. package/lib/db/schema/TableV2.d.ts +0 -11
  184. package/lib/db/schema/TableV2.js +0 -11
  185. package/lib/db/schema/TableV2.js.map +0 -1
  186. package/lib/utils/AbortOperation.d.ts +0 -11
  187. package/lib/utils/AbortOperation.js +0 -21
  188. package/lib/utils/AbortOperation.js.map +0 -1
  189. package/lib/utils/ControlledExecutor.d.ts +0 -31
  190. package/lib/utils/ControlledExecutor.js +0 -58
  191. package/lib/utils/ControlledExecutor.js.map +0 -1
  192. package/lib/utils/async.d.ts +0 -46
  193. package/lib/utils/async.js +0 -147
  194. package/lib/utils/async.js.map +0 -1
  195. package/lib/utils/compatibility.d.ts +0 -8
  196. package/lib/utils/compatibility.js +0 -9
  197. package/lib/utils/compatibility.js.map +0 -1
  198. package/lib/utils/parseQuery.d.ts +0 -12
  199. package/lib/utils/parseQuery.js +0 -20
  200. package/lib/utils/parseQuery.js.map +0 -1
  201. package/lib/utils/queue.d.ts +0 -16
  202. package/lib/utils/queue.js +0 -42
  203. package/lib/utils/queue.js.map +0 -1
  204. package/lib/utils/stream_transform.d.ts +0 -41
  205. package/lib/utils/stream_transform.js +0 -211
  206. package/lib/utils/stream_transform.js.map +0 -1
  207. package/src/client/AbstractPowerSyncDatabase.ts +0 -1408
  208. package/src/client/AbstractPowerSyncOpenFactory.ts +0 -45
  209. package/src/client/ConnectionManager.ts +0 -405
  210. package/src/client/CustomQuery.ts +0 -56
  211. package/src/client/constants.ts +0 -4
  212. package/src/client/sync/bucket/BucketStorageAdapter.ts +0 -65
  213. package/src/client/sync/bucket/SqliteBucketStorage.ts +0 -202
  214. package/src/client/sync/stream/AbstractRemote.ts +0 -648
  215. package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +0 -971
  216. package/src/client/sync/stream/WebsocketClientTransport.ts +0 -82
  217. package/src/client/sync/stream/core-instruction.ts +0 -109
  218. package/src/client/triggers/MemoryTriggerClaimManager.ts +0 -25
  219. package/src/client/triggers/TriggerManagerImpl.ts +0 -501
  220. package/src/client/watched/processors/AbstractQueryProcessor.ts +0 -226
  221. package/src/db/ConnectionClosedError.ts +0 -25
  222. package/src/db/schema/TableV2.ts +0 -11
  223. package/src/utils/AbortOperation.ts +0 -19
  224. package/src/utils/ControlledExecutor.ts +0 -81
  225. package/src/utils/async.ts +0 -185
  226. package/src/utils/compatibility.ts +0 -9
  227. package/src/utils/parseQuery.ts +0 -31
  228. package/src/utils/queue.ts +0 -48
  229. package/src/utils/stream_transform.ts +0 -260
@@ -1,103 +0,0 @@
1
- // TypeScript definitions for sync lines sent by the PowerSync service. These aren't used in the implementation of
2
- // PowerSync SDKs, but we keep them around for:
3
- //
4
- // 1. Tests mocking the PowerSync service.
5
- // 2. The diagnostic app tracking schema updates and bucket sizes by decoding protocol messages.
6
- // 3. The nuxt SDK offering DevTools doing the same.
7
- //
8
- // Uses 2 and 3 should be replaced with the builtin diagnostic collection of the core extension eventually.
9
-
10
- export type SyncDataBucketJSON = {
11
- bucket: string;
12
- has_more?: boolean;
13
- after?: string;
14
- next_after?: string;
15
- data: OplogEntryJSON[];
16
- };
17
- export interface OplogEntryJSON {
18
- checksum: number;
19
- data?: string;
20
- object_id?: string;
21
- object_type?: string;
22
- op_id: string;
23
- op: OpTypeJSON;
24
- subkey?: string;
25
- }
26
- export type OpTypeJSON = 'CLEAR' | 'MOVE' | 'PUT' | 'REMOVE';
27
-
28
- /**
29
- * 64-bit unsigned integer stored as a string in base-10.
30
- *
31
- * Not sortable as a string.
32
- */
33
- export type OpId = string;
34
-
35
- export interface BucketChecksum {
36
- bucket: string;
37
- priority?: number;
38
- /**
39
- * 32-bit unsigned hash.
40
- */
41
- checksum: number;
42
-
43
- /**
44
- * Count of operations - informational only.
45
- */
46
- count?: number;
47
- /**
48
- * The JavaScript client does not use this field, which is why it's defined to be `any`. We rely on the structure of
49
- * this interface to pass custom `BucketChecksum`s to the Rust client in unit tests, which so all fields need to be
50
- * present.
51
- */
52
- subscriptions?: any;
53
- }
54
-
55
- export interface Checkpoint {
56
- last_op_id: OpId;
57
- buckets: BucketChecksum[];
58
- write_checkpoint?: string;
59
- streams?: any[];
60
- }
61
-
62
- export interface StreamingSyncCheckpoint {
63
- checkpoint: Checkpoint;
64
- }
65
-
66
- export interface StreamingSyncCheckpointDiff {
67
- checkpoint_diff: {
68
- last_op_id: OpId;
69
- updated_buckets: BucketChecksum[];
70
- removed_buckets: string[];
71
- write_checkpoint?: string;
72
- };
73
- }
74
-
75
- export interface StreamingSyncDataJSON {
76
- data: SyncDataBucketJSON;
77
- }
78
-
79
- export interface StreamingSyncCheckpointComplete {
80
- checkpoint_complete: {
81
- last_op_id: OpId;
82
- };
83
- }
84
-
85
- export interface StreamingSyncCheckpointPartiallyComplete {
86
- partial_checkpoint_complete: {
87
- priority: number;
88
- last_op_id: OpId;
89
- };
90
- }
91
-
92
- export interface StreamingSyncKeepalive {
93
- /** If specified, token expires in this many seconds. */
94
- token_expires_in: number;
95
- }
96
-
97
- export type StreamingSyncLine =
98
- | StreamingSyncDataJSON
99
- | StreamingSyncCheckpoint
100
- | StreamingSyncCheckpointDiff
101
- | StreamingSyncCheckpointComplete
102
- | StreamingSyncCheckpointPartiallyComplete
103
- | StreamingSyncKeepalive;