Skip to content

Commit 23d77f8

Browse files
committed
Using connect() instead of fetchCredentials() for passing user params.
1 parent b5b0471 commit 23d77f8

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

packages/common/src/client/connection/PowerSyncCredentials.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ export interface PowerSyncCredentials {
22
endpoint: string;
33
token: string;
44
expiresAt?: Date;
5-
params?: Record<string, any>;
65
}

packages/common/src/client/sync/stream/AbstractStreamingSyncImplementation.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ export interface PowerSyncConnectionOptions {
7373
* Defaults to a HTTP streaming connection.
7474
*/
7575
connectionMethod?: SyncStreamConnectionMethod;
76+
77+
/**
78+
* Parameters to be passed to the sync rules. Parameters be available under the`user_parameters` object.
79+
*/
80+
params?: Record<string, any>;
7681
}
7782

7883
export interface StreamingSyncImplementation extends BaseObserver<StreamingSyncImplementationListener>, Disposable {
@@ -104,7 +109,8 @@ export const DEFAULT_STREAMING_SYNC_OPTIONS = {
104109
};
105110

106111
export const DEFAULT_STREAM_CONNECTION_OPTIONS: Required<PowerSyncConnectionOptions> = {
107-
connectionMethod: SyncStreamConnectionMethod.HTTP
112+
connectionMethod: SyncStreamConnectionMethod.HTTP,
113+
params: {}
108114
};
109115

110116
export abstract class AbstractStreamingSyncImplementation
@@ -436,7 +442,6 @@ export abstract class AbstractStreamingSyncImplementation
436442
let appliedCheckpoint: Checkpoint | null = null;
437443

438444
let bucketSet = new Set<string>(initialBuckets.keys());
439-
const { params = undefined } = (await this.options.remote.getCredentials()) ?? {};
440445

441446
this.logger.debug('Requesting stream from server');
442447

@@ -447,7 +452,7 @@ export abstract class AbstractStreamingSyncImplementation
447452
buckets: req,
448453
include_checksum: true,
449454
raw_data: true,
450-
parameters: params
455+
parameters: resolvedOptions.params
451456
}
452457
};
453458

packages/web/src/db/sync/SharedWebStreamingSyncImplementation.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class SharedSyncClientProvider extends AbstractSharedSyncClientProvider {
2929
if (credentials == null) {
3030
return null;
3131
}
32-
3332
/**
3433
* The credentials need to be serializable.
3534
* Users might extend [PowerSyncCredentials] to contain
@@ -39,8 +38,7 @@ class SharedSyncClientProvider extends AbstractSharedSyncClientProvider {
3938
return {
4039
endpoint: credentials.endpoint,
4140
token: credentials.token,
42-
expiresAt: credentials.expiresAt,
43-
params: credentials.params
41+
expiresAt: credentials.expiresAt
4442
};
4543
}
4644

0 commit comments

Comments
 (0)