@powersync/common 1.11.1 → 1.12.0

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.
@@ -1,4 +1,5 @@
1
1
  import { ILogger } from 'js-logger';
2
+ import { StreamingSyncRequestParameterType } from './streaming-sync-types';
2
3
  import { AbstractRemote } from './AbstractRemote';
3
4
  import { BucketStorageAdapter } from '../bucket/BucketStorageAdapter';
4
5
  import { SyncStatus, SyncStatusOptions } from '../../../db/crud/SyncStatus';
@@ -54,6 +55,10 @@ export interface PowerSyncConnectionOptions {
54
55
  * Defaults to a HTTP streaming connection.
55
56
  */
56
57
  connectionMethod?: SyncStreamConnectionMethod;
58
+ /**
59
+ * These parameters are passed to the sync rules, and will be available under the`user_parameters` object.
60
+ */
61
+ params?: Record<string, StreamingSyncRequestParameterType>;
57
62
  }
58
63
  export interface StreamingSyncImplementation extends BaseObserver<StreamingSyncImplementationListener>, Disposable {
59
64
  /**
@@ -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;
@@ -315,7 +316,8 @@ export class AbstractStreamingSyncImplementation extends BaseObserver {
315
316
  data: {
316
317
  buckets: req,
317
318
  include_checksum: true,
318
- raw_data: true
319
+ raw_data: true,
320
+ parameters: resolvedOptions.params
319
321
  }
320
322
  };
321
323
  const stream = resolvedOptions?.connectionMethod == SyncStreamConnectionMethod.HTTP
@@ -42,6 +42,12 @@ export interface SyncResponse {
42
42
  checkpoint_token?: string;
43
43
  checkpoint?: Checkpoint;
44
44
  }
45
+ type JSONValue = string | number | boolean | null | undefined | JSONObject | JSONArray;
46
+ interface JSONObject {
47
+ [key: string]: JSONValue;
48
+ }
49
+ type JSONArray = JSONValue[];
50
+ export type StreamingSyncRequestParameterType = JSONValue;
45
51
  export interface StreamingSyncRequest {
46
52
  /**
47
53
  * Existing bucket states.
@@ -59,6 +65,10 @@ export interface StreamingSyncRequest {
59
65
  * Changes the response to stringified data in each OplogEntry
60
66
  */
61
67
  raw_data: boolean;
68
+ /**
69
+ * Client parameters to be passed to the sync rules.
70
+ */
71
+ parameters?: Record<string, StreamingSyncRequestParameterType>;
62
72
  }
63
73
  export interface StreamingSyncCheckpoint {
64
74
  checkpoint: Checkpoint;
@@ -114,3 +124,4 @@ export interface CrudResponse {
114
124
  */
115
125
  checkpoint?: OpId;
116
126
  }
127
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powersync/common",
3
- "version": "1.11.1",
3
+ "version": "1.12.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"