Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
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': minor
'@powersync/web': minor
---

Added support for user parameters. These parameters can be specified as part of the `connect` method's options object.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export interface PowerSyncConnectionOptions {
* Defaults to a HTTP streaming connection.
*/
connectionMethod?: SyncStreamConnectionMethod;

/**
* These parameters are passed to the sync rules, and will be available under the`user_parameters` object.
*/
params?: Record<string, any>;
}

export interface StreamingSyncImplementation extends BaseObserver<StreamingSyncImplementationListener>, Disposable {
Expand Down Expand Up @@ -104,7 +109,8 @@ export const DEFAULT_STREAMING_SYNC_OPTIONS = {
};

export const DEFAULT_STREAM_CONNECTION_OPTIONS: Required<PowerSyncConnectionOptions> = {
connectionMethod: SyncStreamConnectionMethod.HTTP
connectionMethod: SyncStreamConnectionMethod.HTTP,
params: {}
};

export abstract class AbstractStreamingSyncImplementation
Expand Down Expand Up @@ -445,7 +451,8 @@ export abstract class AbstractStreamingSyncImplementation
data: {
buckets: req,
include_checksum: true,
raw_data: true
raw_data: true,
parameters: resolvedOptions.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, any>;
}

export interface StreamingSyncCheckpoint {
Expand Down