@powersync/common 0.0.0-dev-20250922105207 → 0.0.0-dev-20250922105508
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.
- package/dist/bundle.cjs +4 -4
- package/dist/bundle.mjs +5 -5
- package/dist/index.d.cts +1047 -838
- package/lib/client/AbstractPowerSyncDatabase.d.ts +16 -4
- package/lib/client/AbstractPowerSyncDatabase.js +36 -26
- package/lib/client/ConnectionManager.d.ts +26 -2
- package/lib/client/ConnectionManager.js +114 -2
- package/lib/client/SQLOpenFactory.d.ts +0 -2
- package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +9 -1
- package/lib/client/sync/bucket/BucketStorageAdapter.js +1 -0
- package/lib/client/sync/stream/AbstractRemote.js +3 -0
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +24 -3
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +54 -39
- package/lib/client/sync/stream/core-instruction.d.ts +20 -1
- package/lib/client/sync/stream/core-instruction.js +26 -1
- package/lib/client/sync/sync-streams.d.ts +98 -0
- package/lib/client/sync/sync-streams.js +1 -0
- package/lib/client/triggers/TriggerManager.d.ts +1 -1
- package/lib/client/watched/WatchedQuery.d.ts +2 -0
- package/lib/client/watched/WatchedQuery.js +1 -0
- package/lib/client/watched/processors/AbstractQueryProcessor.d.ts +2 -1
- package/lib/client/watched/processors/AbstractQueryProcessor.js +30 -15
- package/lib/client/watched/processors/DifferentialQueryProcessor.js +7 -1
- package/lib/client/watched/processors/OnChangeQueryProcessor.js +7 -1
- package/lib/db/crud/SyncStatus.d.ts +37 -1
- package/lib/db/crud/SyncStatus.js +61 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +1 -1
|
@@ -4,6 +4,15 @@ export class SyncStatus {
|
|
|
4
4
|
constructor(options) {
|
|
5
5
|
this.options = options;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Returns the used sync client implementation (either the one implemented in JavaScript or the newer Rust-based
|
|
9
|
+
* implementation).
|
|
10
|
+
*
|
|
11
|
+
* This information is only available after a connection has been requested.
|
|
12
|
+
*/
|
|
13
|
+
get clientImplementation() {
|
|
14
|
+
return this.options.clientImplementation;
|
|
15
|
+
}
|
|
7
16
|
/**
|
|
8
17
|
* Indicates if the client is currently connected to the PowerSync service.
|
|
9
18
|
*
|
|
@@ -59,6 +68,27 @@ export class SyncStatus {
|
|
|
59
68
|
uploading: false
|
|
60
69
|
});
|
|
61
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* All sync streams currently being tracked in teh database.
|
|
73
|
+
*
|
|
74
|
+
* This returns null when the database is currently being opened and we don't have reliable information about all
|
|
75
|
+
* included streams yet.
|
|
76
|
+
*
|
|
77
|
+
* @experimental Sync streams are currently in alpha.
|
|
78
|
+
*/
|
|
79
|
+
get syncStreams() {
|
|
80
|
+
return this.options.dataFlow?.internalStreamSubscriptions?.map((core) => new SyncStreamStatusView(this, core));
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* If the `stream` appears in {@link syncStreams}, returns the current status for that stream.
|
|
84
|
+
*
|
|
85
|
+
* @experimental Sync streams are currently in alpha.
|
|
86
|
+
*/
|
|
87
|
+
forStream(stream) {
|
|
88
|
+
const asJson = JSON.stringify(stream.parameters);
|
|
89
|
+
const raw = this.options.dataFlow?.internalStreamSubscriptions?.find((r) => r.name == stream.name && asJson == JSON.stringify(r.parameters));
|
|
90
|
+
return raw && new SyncStreamStatusView(this, raw);
|
|
91
|
+
}
|
|
62
92
|
/**
|
|
63
93
|
* Provides sync status information for all bucket priorities, sorted by priority (highest first).
|
|
64
94
|
*
|
|
@@ -168,3 +198,34 @@ export class SyncStatus {
|
|
|
168
198
|
return b.priority - a.priority; // Reverse because higher priorities have lower numbers
|
|
169
199
|
}
|
|
170
200
|
}
|
|
201
|
+
class SyncStreamStatusView {
|
|
202
|
+
status;
|
|
203
|
+
core;
|
|
204
|
+
subscription;
|
|
205
|
+
constructor(status, core) {
|
|
206
|
+
this.status = status;
|
|
207
|
+
this.core = core;
|
|
208
|
+
this.subscription = {
|
|
209
|
+
name: core.name,
|
|
210
|
+
parameters: core.parameters,
|
|
211
|
+
active: core.active,
|
|
212
|
+
isDefault: core.is_default,
|
|
213
|
+
hasExplicitSubscription: core.has_explicit_subscription,
|
|
214
|
+
expiresAt: core.expires_at != null ? new Date(core.expires_at * 1000) : null,
|
|
215
|
+
hasSynced: core.last_synced_at != null,
|
|
216
|
+
lastSyncedAt: core.last_synced_at != null ? new Date(core.last_synced_at * 1000) : null
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
get progress() {
|
|
220
|
+
if (this.status.dataFlowStatus.downloadProgress == null) {
|
|
221
|
+
// Don't make download progress public if we're not currently downloading.
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
const { total, downloaded } = this.core.progress;
|
|
225
|
+
const progress = total == 0 ? 0.0 : downloaded / total;
|
|
226
|
+
return { totalOperations: total, downloadedOperations: downloaded, downloadedFraction: progress };
|
|
227
|
+
}
|
|
228
|
+
get priority() {
|
|
229
|
+
return this.core.priority;
|
|
230
|
+
}
|
|
231
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from './client/sync/bucket/SyncDataBucket.js';
|
|
|
18
18
|
export * from './client/sync/stream/AbstractRemote.js';
|
|
19
19
|
export * from './client/sync/stream/AbstractStreamingSyncImplementation.js';
|
|
20
20
|
export * from './client/sync/stream/streaming-sync-types.js';
|
|
21
|
+
export * from './client/sync/sync-streams.js';
|
|
21
22
|
export * from './client/ConnectionManager.js';
|
|
22
23
|
export { ProgressWithOperations, SyncProgress } from './db/crud/SyncProgress.js';
|
|
23
24
|
export * from './db/crud/SyncStatus.js';
|
package/lib/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export * from './client/sync/bucket/SyncDataBucket.js';
|
|
|
18
18
|
export * from './client/sync/stream/AbstractRemote.js';
|
|
19
19
|
export * from './client/sync/stream/AbstractStreamingSyncImplementation.js';
|
|
20
20
|
export * from './client/sync/stream/streaming-sync-types.js';
|
|
21
|
+
export * from './client/sync/sync-streams.js';
|
|
21
22
|
export * from './client/ConnectionManager.js';
|
|
22
23
|
export { SyncProgress } from './db/crud/SyncProgress.js';
|
|
23
24
|
export * from './db/crud/SyncStatus.js';
|