@powersync/common 0.0.0-dev-20250925184532 → 0.0.0-dev-20251003085035
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 +3 -3
- package/dist/bundle.mjs +2 -2
- package/dist/index.d.cts +25 -2
- package/lib/client/AbstractPowerSyncDatabase.d.ts +17 -2
- package/lib/client/AbstractPowerSyncDatabase.js +28 -4
- package/lib/client/ConnectionManager.d.ts +9 -1
- package/lib/client/ConnectionManager.js +10 -3
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1854,6 +1854,8 @@ declare class ConnectionManager extends BaseObserver<ConnectionManagerListener>
|
|
|
1854
1854
|
*/
|
|
1855
1855
|
private locallyActiveSubscriptions;
|
|
1856
1856
|
constructor(options: ConnectionManagerOptions);
|
|
1857
|
+
get connector(): PowerSyncBackendConnector | null;
|
|
1858
|
+
get connectionOptions(): InternalConnectionOptions | null;
|
|
1857
1859
|
get logger(): ILogger;
|
|
1858
1860
|
close(): Promise<void>;
|
|
1859
1861
|
connect(connector: PowerSyncBackendConnector, options: InternalConnectionOptions): Promise<void>;
|
|
@@ -1867,7 +1869,13 @@ declare class ConnectionManager extends BaseObserver<ConnectionManagerListener>
|
|
|
1867
1869
|
protected disconnectInternal(): Promise<void>;
|
|
1868
1870
|
protected performDisconnect(): Promise<void>;
|
|
1869
1871
|
stream(adapter: InternalSubscriptionAdapter, name: string, parameters: Record<string, any> | null): SyncStream;
|
|
1870
|
-
|
|
1872
|
+
/**
|
|
1873
|
+
* @internal exposed for testing
|
|
1874
|
+
*/
|
|
1875
|
+
get activeStreams(): {
|
|
1876
|
+
name: string;
|
|
1877
|
+
params: Record<string, any> | null;
|
|
1878
|
+
}[];
|
|
1871
1879
|
private subscriptionsMayHaveChanged;
|
|
1872
1880
|
}
|
|
1873
1881
|
|
|
@@ -2893,6 +2901,18 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
|
|
|
2893
2901
|
protected connectionManager: ConnectionManager;
|
|
2894
2902
|
private subscriptions;
|
|
2895
2903
|
get syncStreamImplementation(): StreamingSyncImplementation | null;
|
|
2904
|
+
/**
|
|
2905
|
+
* The connector used to connect to the PowerSync service.
|
|
2906
|
+
*
|
|
2907
|
+
* @returns The connector used to connect to the PowerSync service or null if `connect()` has not been called.
|
|
2908
|
+
*/
|
|
2909
|
+
get connector(): PowerSyncBackendConnector | null;
|
|
2910
|
+
/**
|
|
2911
|
+
* The resolved connection options used to connect to the PowerSync service.
|
|
2912
|
+
*
|
|
2913
|
+
* @returns The resolved connection options used to connect to the PowerSync service or null if `connect()` has not been called.
|
|
2914
|
+
*/
|
|
2915
|
+
get connectionOptions(): InternalConnectionOptions | null;
|
|
2896
2916
|
protected _schema: Schema;
|
|
2897
2917
|
private _database;
|
|
2898
2918
|
protected runExclusiveMutex: Mutex;
|
|
@@ -2946,7 +2966,10 @@ declare abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncD
|
|
|
2946
2966
|
signal?: AbortSignal;
|
|
2947
2967
|
priority?: number;
|
|
2948
2968
|
}): Promise<void>;
|
|
2949
|
-
|
|
2969
|
+
/**
|
|
2970
|
+
* Waits for the first sync status for which the `status` callback returns a truthy value.
|
|
2971
|
+
*/
|
|
2972
|
+
waitForStatus(predicate: (status: SyncStatus) => any, signal?: AbortSignal): Promise<void>;
|
|
2950
2973
|
/**
|
|
2951
2974
|
* Allows for extended implementations to execute custom initialization
|
|
2952
2975
|
* logic as part of the total init process
|
|
@@ -12,7 +12,7 @@ import { PowerSyncBackendConnector } from './connection/PowerSyncBackendConnecto
|
|
|
12
12
|
import { BucketStorageAdapter } from './sync/bucket/BucketStorageAdapter.js';
|
|
13
13
|
import { CrudBatch } from './sync/bucket/CrudBatch.js';
|
|
14
14
|
import { CrudTransaction } from './sync/bucket/CrudTransaction.js';
|
|
15
|
-
import { StreamingSyncImplementation, StreamingSyncImplementationListener, type AdditionalConnectionOptions, type PowerSyncConnectionOptions, type RequiredAdditionalConnectionOptions } from './sync/stream/AbstractStreamingSyncImplementation.js';
|
|
15
|
+
import { InternalConnectionOptions, StreamingSyncImplementation, StreamingSyncImplementationListener, type AdditionalConnectionOptions, type PowerSyncConnectionOptions, type RequiredAdditionalConnectionOptions } from './sync/stream/AbstractStreamingSyncImplementation.js';
|
|
16
16
|
import { TriggerManager } from './triggers/TriggerManager.js';
|
|
17
17
|
import { WatchCompatibleQuery } from './watched/WatchedQuery.js';
|
|
18
18
|
import { WatchedQueryComparator } from './watched/processors/comparators.js';
|
|
@@ -132,6 +132,18 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
|
|
|
132
132
|
protected connectionManager: ConnectionManager;
|
|
133
133
|
private subscriptions;
|
|
134
134
|
get syncStreamImplementation(): StreamingSyncImplementation | null;
|
|
135
|
+
/**
|
|
136
|
+
* The connector used to connect to the PowerSync service.
|
|
137
|
+
*
|
|
138
|
+
* @returns The connector used to connect to the PowerSync service or null if `connect()` has not been called.
|
|
139
|
+
*/
|
|
140
|
+
get connector(): PowerSyncBackendConnector | null;
|
|
141
|
+
/**
|
|
142
|
+
* The resolved connection options used to connect to the PowerSync service.
|
|
143
|
+
*
|
|
144
|
+
* @returns The resolved connection options used to connect to the PowerSync service or null if `connect()` has not been called.
|
|
145
|
+
*/
|
|
146
|
+
get connectionOptions(): InternalConnectionOptions | null;
|
|
135
147
|
protected _schema: Schema;
|
|
136
148
|
private _database;
|
|
137
149
|
protected runExclusiveMutex: Mutex;
|
|
@@ -185,7 +197,10 @@ export declare abstract class AbstractPowerSyncDatabase extends BaseObserver<Pow
|
|
|
185
197
|
signal?: AbortSignal;
|
|
186
198
|
priority?: number;
|
|
187
199
|
}): Promise<void>;
|
|
188
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Waits for the first sync status for which the `status` callback returns a truthy value.
|
|
202
|
+
*/
|
|
203
|
+
waitForStatus(predicate: (status: SyncStatus) => any, signal?: AbortSignal): Promise<void>;
|
|
189
204
|
/**
|
|
190
205
|
* Allows for extended implementations to execute custom initialization
|
|
191
206
|
* logic as part of the total init process
|
|
@@ -63,6 +63,22 @@ export class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
63
63
|
get syncStreamImplementation() {
|
|
64
64
|
return this.connectionManager.syncStreamImplementation;
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* The connector used to connect to the PowerSync service.
|
|
68
|
+
*
|
|
69
|
+
* @returns The connector used to connect to the PowerSync service or null if `connect()` has not been called.
|
|
70
|
+
*/
|
|
71
|
+
get connector() {
|
|
72
|
+
return this.connectionManager.connector;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The resolved connection options used to connect to the PowerSync service.
|
|
76
|
+
*
|
|
77
|
+
* @returns The resolved connection options used to connect to the PowerSync service or null if `connect()` has not been called.
|
|
78
|
+
*/
|
|
79
|
+
get connectionOptions() {
|
|
80
|
+
return this.connectionManager.connectionOptions;
|
|
81
|
+
}
|
|
66
82
|
_schema;
|
|
67
83
|
_database;
|
|
68
84
|
runExclusiveMutex;
|
|
@@ -188,6 +204,9 @@ export class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
188
204
|
: (status) => status.statusForPriority(priority).hasSynced;
|
|
189
205
|
return this.waitForStatus(statusMatches, signal);
|
|
190
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Waits for the first sync status for which the `status` callback returns a truthy value.
|
|
209
|
+
*/
|
|
191
210
|
async waitForStatus(predicate, signal) {
|
|
192
211
|
if (predicate(this.currentStatus)) {
|
|
193
212
|
return;
|
|
@@ -196,15 +215,20 @@ export class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
196
215
|
const dispose = this.registerListener({
|
|
197
216
|
statusChanged: (status) => {
|
|
198
217
|
if (predicate(status)) {
|
|
199
|
-
|
|
200
|
-
resolve();
|
|
218
|
+
abort();
|
|
201
219
|
}
|
|
202
220
|
}
|
|
203
221
|
});
|
|
204
|
-
|
|
222
|
+
function abort() {
|
|
205
223
|
dispose();
|
|
206
224
|
resolve();
|
|
207
|
-
}
|
|
225
|
+
}
|
|
226
|
+
if (signal?.aborted) {
|
|
227
|
+
abort();
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
signal?.addEventListener('abort', abort);
|
|
231
|
+
}
|
|
208
232
|
});
|
|
209
233
|
}
|
|
210
234
|
/**
|
|
@@ -85,6 +85,8 @@ export declare class ConnectionManager extends BaseObserver<ConnectionManagerLis
|
|
|
85
85
|
*/
|
|
86
86
|
private locallyActiveSubscriptions;
|
|
87
87
|
constructor(options: ConnectionManagerOptions);
|
|
88
|
+
get connector(): PowerSyncBackendConnector | null;
|
|
89
|
+
get connectionOptions(): InternalConnectionOptions | null;
|
|
88
90
|
get logger(): ILogger;
|
|
89
91
|
close(): Promise<void>;
|
|
90
92
|
connect(connector: PowerSyncBackendConnector, options: InternalConnectionOptions): Promise<void>;
|
|
@@ -98,7 +100,13 @@ export declare class ConnectionManager extends BaseObserver<ConnectionManagerLis
|
|
|
98
100
|
protected disconnectInternal(): Promise<void>;
|
|
99
101
|
protected performDisconnect(): Promise<void>;
|
|
100
102
|
stream(adapter: InternalSubscriptionAdapter, name: string, parameters: Record<string, any> | null): SyncStream;
|
|
101
|
-
|
|
103
|
+
/**
|
|
104
|
+
* @internal exposed for testing
|
|
105
|
+
*/
|
|
106
|
+
get activeStreams(): {
|
|
107
|
+
name: string;
|
|
108
|
+
params: Record<string, any> | null;
|
|
109
|
+
}[];
|
|
102
110
|
private subscriptionsMayHaveChanged;
|
|
103
111
|
}
|
|
104
112
|
export {};
|
|
@@ -48,6 +48,12 @@ export class ConnectionManager extends BaseObserver {
|
|
|
48
48
|
this.syncStreamImplementation = null;
|
|
49
49
|
this.syncDisposer = null;
|
|
50
50
|
}
|
|
51
|
+
get connector() {
|
|
52
|
+
return this.pendingConnectionOptions?.connector ?? null;
|
|
53
|
+
}
|
|
54
|
+
get connectionOptions() {
|
|
55
|
+
return this.pendingConnectionOptions?.options ?? null;
|
|
56
|
+
}
|
|
51
57
|
get logger() {
|
|
52
58
|
return this.options.logger;
|
|
53
59
|
}
|
|
@@ -224,13 +230,14 @@ export class ConnectionManager extends BaseObserver {
|
|
|
224
230
|
}
|
|
225
231
|
};
|
|
226
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* @internal exposed for testing
|
|
235
|
+
*/
|
|
227
236
|
get activeStreams() {
|
|
228
237
|
return [...this.locallyActiveSubscriptions.values()].map((a) => ({ name: a.name, params: a.parameters }));
|
|
229
238
|
}
|
|
230
239
|
subscriptionsMayHaveChanged() {
|
|
231
|
-
|
|
232
|
-
this.syncStreamImplementation.updateSubscriptions(this.activeStreams);
|
|
233
|
-
}
|
|
240
|
+
this.syncStreamImplementation?.updateSubscriptions(this.activeStreams);
|
|
234
241
|
}
|
|
235
242
|
}
|
|
236
243
|
class ActiveSubscription {
|