Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/bright-cooks-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@powersync/common': patch
'@powersync/web': patch
---

Added support for user parameters.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export interface PowerSyncCredentials {
endpoint: string;
token: string;
expiresAt?: Date;
params?: Record<string, string>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ export abstract class AbstractStreamingSyncImplementation
let appliedCheckpoint: Checkpoint | null = null;

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

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

Expand All @@ -440,7 +441,8 @@ export abstract class AbstractStreamingSyncImplementation
data: {
buckets: req,
include_checksum: true,
raw_data: true
raw_data: true,
parameters: params
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ export interface StreamingSyncRequest {
* Changes the response to stringified data in each OplogEntry
*/
raw_data: boolean;

/**
* Client parameters to be passed to the sync rules.
*/
parameters?: Record<string, string>;
}

export interface StreamingSyncCheckpoint {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SharedSyncClientProvider extends AbstractSharedSyncClientProvider {
if (credentials == null) {
return null;
}

/**
* The credentials need to be serializable.
* Users might extend [PowerSyncCredentials] to contain
Expand All @@ -38,7 +39,8 @@ class SharedSyncClientProvider extends AbstractSharedSyncClientProvider {
return {
endpoint: credentials.endpoint,
token: credentials.token,
expiresAt: credentials.expiresAt
expiresAt: credentials.expiresAt,
params: credentials.params
};
}

Expand Down