@powersync/common 0.0.0-dev-20240606141637 → 0.0.0-dev-20240610133845
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/lib/client/connection/PowerSyncCredentials.d.ts +0 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +4 -0
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +8 -5
- package/lib/client/sync/stream/streaming-sync-types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -54,6 +54,10 @@ export interface PowerSyncConnectionOptions {
|
|
|
54
54
|
* Defaults to a HTTP streaming connection.
|
|
55
55
|
*/
|
|
56
56
|
connectionMethod?: SyncStreamConnectionMethod;
|
|
57
|
+
/**
|
|
58
|
+
* Parameters to be passed to the sync rules. Parameters be available under the`user_parameters` object.
|
|
59
|
+
*/
|
|
60
|
+
params?: Record<string, any>;
|
|
57
61
|
}
|
|
58
62
|
export interface StreamingSyncImplementation extends BaseObserver<StreamingSyncImplementationListener>, Disposable {
|
|
59
63
|
/**
|
|
@@ -22,7 +22,8 @@ export const DEFAULT_STREAMING_SYNC_OPTIONS = {
|
|
|
22
22
|
crudUploadThrottleMs: DEFAULT_CRUD_UPLOAD_THROTTLE_MS
|
|
23
23
|
};
|
|
24
24
|
export const DEFAULT_STREAM_CONNECTION_OPTIONS = {
|
|
25
|
-
connectionMethod: SyncStreamConnectionMethod.HTTP
|
|
25
|
+
connectionMethod: SyncStreamConnectionMethod.HTTP,
|
|
26
|
+
params: {}
|
|
26
27
|
};
|
|
27
28
|
export class AbstractStreamingSyncImplementation extends BaseObserver {
|
|
28
29
|
_lastSyncedAt;
|
|
@@ -116,13 +117,16 @@ export class AbstractStreamingSyncImplementation extends BaseObserver {
|
|
|
116
117
|
}
|
|
117
118
|
catch (ex) {
|
|
118
119
|
this.updateSyncStatus({
|
|
119
|
-
connected: false,
|
|
120
120
|
dataFlow: {
|
|
121
121
|
uploading: false
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
124
|
await this.delayRetry();
|
|
125
|
-
|
|
125
|
+
if (!this.isConnected) {
|
|
126
|
+
// Exit the upload loop if the sync stream is no longer connected
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
this.logger.debug(`Caught exception when uploading. Upload will retry after a delay. Exception: ${ex.message}`);
|
|
126
130
|
}
|
|
127
131
|
finally {
|
|
128
132
|
this.updateSyncStatus({
|
|
@@ -305,7 +309,6 @@ export class AbstractStreamingSyncImplementation extends BaseObserver {
|
|
|
305
309
|
let validatedCheckpoint = null;
|
|
306
310
|
let appliedCheckpoint = null;
|
|
307
311
|
let bucketSet = new Set(initialBuckets.keys());
|
|
308
|
-
const { params = undefined } = (await this.options.remote.getCredentials()) ?? {};
|
|
309
312
|
this.logger.debug('Requesting stream from server');
|
|
310
313
|
const syncOptions = {
|
|
311
314
|
path: '/sync/stream',
|
|
@@ -314,7 +317,7 @@ export class AbstractStreamingSyncImplementation extends BaseObserver {
|
|
|
314
317
|
buckets: req,
|
|
315
318
|
include_checksum: true,
|
|
316
319
|
raw_data: true,
|
|
317
|
-
parameters: params
|
|
320
|
+
parameters: resolvedOptions.params
|
|
318
321
|
}
|
|
319
322
|
};
|
|
320
323
|
const stream = resolvedOptions?.connectionMethod == SyncStreamConnectionMethod.HTTP
|
|
@@ -62,7 +62,7 @@ export interface StreamingSyncRequest {
|
|
|
62
62
|
/**
|
|
63
63
|
* Client parameters to be passed to the sync rules.
|
|
64
64
|
*/
|
|
65
|
-
parameters?: Record<string,
|
|
65
|
+
parameters?: Record<string, any>;
|
|
66
66
|
}
|
|
67
67
|
export interface StreamingSyncCheckpoint {
|
|
68
68
|
checkpoint: Checkpoint;
|