@powersync/common 0.0.0-dev-20260414110516 → 0.0.0-dev-20260504100448

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.
Files changed (67) hide show
  1. package/dist/bundle.cjs +33 -665
  2. package/dist/bundle.cjs.map +1 -1
  3. package/dist/bundle.mjs +34 -654
  4. package/dist/bundle.mjs.map +1 -1
  5. package/dist/bundle.node.cjs +33 -665
  6. package/dist/bundle.node.cjs.map +1 -1
  7. package/dist/bundle.node.mjs +34 -654
  8. package/dist/bundle.node.mjs.map +1 -1
  9. package/dist/index.d.cts +22 -369
  10. package/legacy/sync_protocol.d.ts +103 -0
  11. package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +1 -63
  12. package/lib/client/sync/bucket/BucketStorageAdapter.js.map +1 -1
  13. package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +1 -28
  14. package/lib/client/sync/bucket/SqliteBucketStorage.js +0 -162
  15. package/lib/client/sync/bucket/SqliteBucketStorage.js.map +1 -1
  16. package/lib/client/sync/stream/AbstractRemote.d.ts +2 -12
  17. package/lib/client/sync/stream/AbstractRemote.js +3 -13
  18. package/lib/client/sync/stream/AbstractRemote.js.map +1 -1
  19. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +12 -35
  20. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +29 -337
  21. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +1 -1
  22. package/lib/client/sync/stream/JsonValue.d.ts +7 -0
  23. package/lib/client/sync/stream/JsonValue.js +2 -0
  24. package/lib/client/sync/stream/JsonValue.js.map +1 -0
  25. package/lib/client/sync/stream/core-instruction.d.ts +1 -2
  26. package/lib/client/sync/stream/core-instruction.js.map +1 -1
  27. package/lib/db/crud/SyncStatus.d.ts +0 -4
  28. package/lib/db/crud/SyncStatus.js +0 -4
  29. package/lib/db/crud/SyncStatus.js.map +1 -1
  30. package/lib/db/schema/RawTable.d.ts +0 -5
  31. package/lib/db/schema/Schema.d.ts +0 -2
  32. package/lib/db/schema/Schema.js +0 -2
  33. package/lib/db/schema/Schema.js.map +1 -1
  34. package/lib/index.d.ts +1 -5
  35. package/lib/index.js +1 -5
  36. package/lib/index.js.map +1 -1
  37. package/package.json +7 -4
  38. package/src/client/sync/bucket/BucketStorageAdapter.ts +1 -70
  39. package/src/client/sync/bucket/SqliteBucketStorage.ts +1 -197
  40. package/src/client/sync/stream/AbstractRemote.ts +5 -27
  41. package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +41 -407
  42. package/src/client/sync/stream/JsonValue.ts +8 -0
  43. package/src/client/sync/stream/core-instruction.ts +1 -2
  44. package/src/db/crud/SyncStatus.ts +0 -4
  45. package/src/db/schema/RawTable.ts +0 -5
  46. package/src/db/schema/Schema.ts +0 -2
  47. package/src/index.ts +1 -5
  48. package/lib/client/sync/bucket/OpType.d.ts +0 -16
  49. package/lib/client/sync/bucket/OpType.js +0 -23
  50. package/lib/client/sync/bucket/OpType.js.map +0 -1
  51. package/lib/client/sync/bucket/OplogEntry.d.ts +0 -23
  52. package/lib/client/sync/bucket/OplogEntry.js +0 -36
  53. package/lib/client/sync/bucket/OplogEntry.js.map +0 -1
  54. package/lib/client/sync/bucket/SyncDataBatch.d.ts +0 -6
  55. package/lib/client/sync/bucket/SyncDataBatch.js +0 -12
  56. package/lib/client/sync/bucket/SyncDataBatch.js.map +0 -1
  57. package/lib/client/sync/bucket/SyncDataBucket.d.ts +0 -40
  58. package/lib/client/sync/bucket/SyncDataBucket.js +0 -40
  59. package/lib/client/sync/bucket/SyncDataBucket.js.map +0 -1
  60. package/lib/client/sync/stream/streaming-sync-types.d.ts +0 -143
  61. package/lib/client/sync/stream/streaming-sync-types.js +0 -26
  62. package/lib/client/sync/stream/streaming-sync-types.js.map +0 -1
  63. package/src/client/sync/bucket/OpType.ts +0 -23
  64. package/src/client/sync/bucket/OplogEntry.ts +0 -50
  65. package/src/client/sync/bucket/SyncDataBatch.ts +0 -11
  66. package/src/client/sync/bucket/SyncDataBucket.ts +0 -49
  67. package/src/client/sync/stream/streaming-sync-types.ts +0 -210
@@ -1,16 +0,0 @@
1
- export declare enum OpTypeEnum {
2
- CLEAR = 1,
3
- MOVE = 2,
4
- PUT = 3,
5
- REMOVE = 4
6
- }
7
- export type OpTypeJSON = string;
8
- /**
9
- * Used internally for sync buckets.
10
- */
11
- export declare class OpType {
12
- value: OpTypeEnum;
13
- static fromJSON(jsonValue: OpTypeJSON): OpType;
14
- constructor(value: OpTypeEnum);
15
- toJSON(): string;
16
- }
@@ -1,23 +0,0 @@
1
- export var OpTypeEnum;
2
- (function (OpTypeEnum) {
3
- OpTypeEnum[OpTypeEnum["CLEAR"] = 1] = "CLEAR";
4
- OpTypeEnum[OpTypeEnum["MOVE"] = 2] = "MOVE";
5
- OpTypeEnum[OpTypeEnum["PUT"] = 3] = "PUT";
6
- OpTypeEnum[OpTypeEnum["REMOVE"] = 4] = "REMOVE";
7
- })(OpTypeEnum || (OpTypeEnum = {}));
8
- /**
9
- * Used internally for sync buckets.
10
- */
11
- export class OpType {
12
- value;
13
- static fromJSON(jsonValue) {
14
- return new OpType(OpTypeEnum[jsonValue]);
15
- }
16
- constructor(value) {
17
- this.value = value;
18
- }
19
- toJSON() {
20
- return Object.entries(OpTypeEnum).find(([, value]) => value === this.value)[0];
21
- }
22
- }
23
- //# sourceMappingURL=OpType.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OpType.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/OpType.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,6CAAS,CAAA;IACT,2CAAQ,CAAA;IACR,yCAAO,CAAA;IACP,+CAAU,CAAA;AACZ,CAAC,EALW,UAAU,KAAV,UAAU,QAKrB;AAID;;GAEG;AACH,MAAM,OAAO,MAAM;IAKE;IAJnB,MAAM,CAAC,QAAQ,CAAC,SAAqB;QACnC,OAAO,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,YAAmB,KAAiB;QAAjB,UAAK,GAAL,KAAK,CAAY;IAAG,CAAC;IAExC,MAAM;QACJ,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,CAAE,CAAC,CAAC,CAAC,CAAC;IAClF,CAAC;CACF"}
@@ -1,23 +0,0 @@
1
- import { OpId } from './CrudEntry.js';
2
- import { OpType, OpTypeJSON } from './OpType.js';
3
- export interface OplogEntryJSON {
4
- checksum: number;
5
- data?: string;
6
- object_id?: string;
7
- object_type?: string;
8
- op_id: string;
9
- op: OpTypeJSON;
10
- subkey?: string;
11
- }
12
- export declare class OplogEntry {
13
- op_id: OpId;
14
- op: OpType;
15
- checksum: number;
16
- subkey?: string | undefined;
17
- object_type?: string | undefined;
18
- object_id?: string | undefined;
19
- data?: string | undefined;
20
- static fromRow(row: OplogEntryJSON): OplogEntry;
21
- constructor(op_id: OpId, op: OpType, checksum: number, subkey?: string | undefined, object_type?: string | undefined, object_id?: string | undefined, data?: string | undefined);
22
- toJSON(fixedKeyEncoding?: boolean): OplogEntryJSON;
23
- }
@@ -1,36 +0,0 @@
1
- import { OpType } from './OpType.js';
2
- export class OplogEntry {
3
- op_id;
4
- op;
5
- checksum;
6
- subkey;
7
- object_type;
8
- object_id;
9
- data;
10
- static fromRow(row) {
11
- return new OplogEntry(row.op_id, OpType.fromJSON(row.op), row.checksum, row.subkey, row.object_type, row.object_id, row.data);
12
- }
13
- constructor(op_id, op, checksum, subkey, object_type, object_id, data) {
14
- this.op_id = op_id;
15
- this.op = op;
16
- this.checksum = checksum;
17
- this.subkey = subkey;
18
- this.object_type = object_type;
19
- this.object_id = object_id;
20
- this.data = data;
21
- }
22
- toJSON(fixedKeyEncoding = false) {
23
- return {
24
- op_id: this.op_id,
25
- op: this.op.toJSON(),
26
- object_type: this.object_type,
27
- object_id: this.object_id,
28
- checksum: this.checksum,
29
- data: this.data,
30
- // Older versions of the JS SDK used to always JSON.stringify here. That has always been wrong,
31
- // but we need to migrate gradually to not break existing databases.
32
- subkey: fixedKeyEncoding ? this.subkey : JSON.stringify(this.subkey)
33
- };
34
- }
35
- }
36
- //# sourceMappingURL=OplogEntry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OplogEntry.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/OplogEntry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAc,MAAM,aAAa,CAAC;AAYjD,MAAM,OAAO,UAAU;IAcZ;IACA;IACA;IACA;IACA;IACA;IACA;IAnBT,MAAM,CAAC,OAAO,CAAC,GAAmB;QAChC,OAAO,IAAI,UAAU,CACnB,GAAG,CAAC,KAAK,EACT,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EACvB,GAAG,CAAC,QAAQ,EACZ,GAAG,CAAC,MAAM,EACV,GAAG,CAAC,WAAW,EACf,GAAG,CAAC,SAAS,EACb,GAAG,CAAC,IAAI,CACT,CAAC;IACJ,CAAC;IAED,YACS,KAAW,EACX,EAAU,EACV,QAAgB,EAChB,MAAe,EACf,WAAoB,EACpB,SAAkB,EAClB,IAAa;QANb,UAAK,GAAL,KAAK,CAAM;QACX,OAAE,GAAF,EAAE,CAAQ;QACV,aAAQ,GAAR,QAAQ,CAAQ;QAChB,WAAM,GAAN,MAAM,CAAS;QACf,gBAAW,GAAX,WAAW,CAAS;QACpB,cAAS,GAAT,SAAS,CAAS;QAClB,SAAI,GAAJ,IAAI,CAAS;IACnB,CAAC;IAEJ,MAAM,CAAC,gBAAgB,GAAG,KAAK;QAC7B,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE;YACpB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,+FAA+F;YAC/F,oEAAoE;YACpE,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;SACrE,CAAC;IACJ,CAAC;CACF"}
@@ -1,6 +0,0 @@
1
- import { SyncDataBucket } from './SyncDataBucket.js';
2
- export declare class SyncDataBatch {
3
- buckets: SyncDataBucket[];
4
- static fromJSON(json: any): SyncDataBatch;
5
- constructor(buckets: SyncDataBucket[]);
6
- }
@@ -1,12 +0,0 @@
1
- import { SyncDataBucket } from './SyncDataBucket.js';
2
- // TODO JSON
3
- export class SyncDataBatch {
4
- buckets;
5
- static fromJSON(json) {
6
- return new SyncDataBatch(json.buckets.map((bucket) => SyncDataBucket.fromRow(bucket)));
7
- }
8
- constructor(buckets) {
9
- this.buckets = buckets;
10
- }
11
- }
12
- //# sourceMappingURL=SyncDataBatch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SyncDataBatch.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/SyncDataBatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,YAAY;AAEZ,MAAM,OAAO,aAAa;IAKL;IAJnB,MAAM,CAAC,QAAQ,CAAC,IAAS;QACvB,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAW,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED,YAAmB,OAAyB;QAAzB,YAAO,GAAP,OAAO,CAAkB;IAAG,CAAC;CACjD"}
@@ -1,40 +0,0 @@
1
- import { OpId } from './CrudEntry.js';
2
- import { OplogEntry, OplogEntryJSON } from './OplogEntry.js';
3
- export type SyncDataBucketJSON = {
4
- bucket: string;
5
- has_more?: boolean;
6
- after?: string;
7
- next_after?: string;
8
- data: OplogEntryJSON[];
9
- };
10
- export declare class SyncDataBucket {
11
- bucket: string;
12
- data: OplogEntry[];
13
- /**
14
- * True if the response does not contain all the data for this bucket, and another request must be made.
15
- */
16
- has_more: boolean;
17
- /**
18
- * The `after` specified in the request.
19
- */
20
- after?: OpId | undefined;
21
- /**
22
- * Use this for the next request.
23
- */
24
- next_after?: OpId | undefined;
25
- static fromRow(row: SyncDataBucketJSON): SyncDataBucket;
26
- constructor(bucket: string, data: OplogEntry[],
27
- /**
28
- * True if the response does not contain all the data for this bucket, and another request must be made.
29
- */
30
- has_more: boolean,
31
- /**
32
- * The `after` specified in the request.
33
- */
34
- after?: OpId | undefined,
35
- /**
36
- * Use this for the next request.
37
- */
38
- next_after?: OpId | undefined);
39
- toJSON(fixedKeyEncoding?: boolean): SyncDataBucketJSON;
40
- }
@@ -1,40 +0,0 @@
1
- import { OplogEntry } from './OplogEntry.js';
2
- export class SyncDataBucket {
3
- bucket;
4
- data;
5
- has_more;
6
- after;
7
- next_after;
8
- static fromRow(row) {
9
- return new SyncDataBucket(row.bucket, row.data.map((entry) => OplogEntry.fromRow(entry)), row.has_more ?? false, row.after, row.next_after);
10
- }
11
- constructor(bucket, data,
12
- /**
13
- * True if the response does not contain all the data for this bucket, and another request must be made.
14
- */
15
- has_more,
16
- /**
17
- * The `after` specified in the request.
18
- */
19
- after,
20
- /**
21
- * Use this for the next request.
22
- */
23
- next_after) {
24
- this.bucket = bucket;
25
- this.data = data;
26
- this.has_more = has_more;
27
- this.after = after;
28
- this.next_after = next_after;
29
- }
30
- toJSON(fixedKeyEncoding = false) {
31
- return {
32
- bucket: this.bucket,
33
- has_more: this.has_more,
34
- after: this.after,
35
- next_after: this.next_after,
36
- data: this.data.map((entry) => entry.toJSON(fixedKeyEncoding))
37
- };
38
- }
39
- }
40
- //# sourceMappingURL=SyncDataBucket.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SyncDataBucket.js","sourceRoot":"","sources":["../../../../src/client/sync/bucket/SyncDataBucket.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAkB,MAAM,iBAAiB,CAAC;AAU7D,MAAM,OAAO,cAAc;IAYhB;IACA;IAIA;IAIA;IAIA;IAxBT,MAAM,CAAC,OAAO,CAAC,GAAuB;QACpC,OAAO,IAAI,cAAc,CACvB,GAAG,CAAC,MAAM,EACV,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAClD,GAAG,CAAC,QAAQ,IAAI,KAAK,EACrB,GAAG,CAAC,KAAK,EACT,GAAG,CAAC,UAAU,CACf,CAAC;IACJ,CAAC;IAED,YACS,MAAc,EACd,IAAkB;IACzB;;OAEG;IACI,QAAiB;IACxB;;OAEG;IACI,KAAY;IACnB;;OAEG;IACI,UAAiB;QAbjB,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAc;QAIlB,aAAQ,GAAR,QAAQ,CAAS;QAIjB,UAAK,GAAL,KAAK,CAAO;QAIZ,eAAU,GAAV,UAAU,CAAO;IACvB,CAAC;IAEJ,MAAM,CAAC,gBAAgB,GAAG,KAAK;QAC7B,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;SAC/D,CAAC;IACJ,CAAC;CACF"}
@@ -1,143 +0,0 @@
1
- import { BucketChecksum, Checkpoint } from '../bucket/BucketStorageAdapter.js';
2
- import { CrudEntry, OpId } from '../bucket/CrudEntry.js';
3
- import { SyncDataBucketJSON } from '../bucket/SyncDataBucket.js';
4
- /**
5
- * For sync2.json
6
- */
7
- export interface ContinueCheckpointRequest {
8
- /**
9
- * Existing bucket states. Only these buckets are synchronized.
10
- */
11
- buckets: BucketRequest[];
12
- checkpoint_token: string;
13
- limit?: number;
14
- }
15
- export interface SyncNewCheckpointRequest {
16
- /**
17
- * Existing bucket states. Used if include_data is specified.
18
- */
19
- buckets?: BucketRequest[];
20
- request_checkpoint: {
21
- /**
22
- * Whether or not to include an initial data request.
23
- */
24
- include_data: boolean;
25
- /**
26
- * Whether or not to compute a checksum.
27
- */
28
- include_checksum: boolean;
29
- };
30
- limit?: number;
31
- }
32
- export type SyncRequest = ContinueCheckpointRequest | SyncNewCheckpointRequest;
33
- export interface SyncResponse {
34
- /**
35
- * Data for the buckets returned. May not have an an entry for each bucket in the request.
36
- */
37
- data?: SyncDataBucketJSON[];
38
- /**
39
- * True if the response limit has been reached, and another request must be made.
40
- */
41
- has_more: boolean;
42
- checkpoint_token?: string;
43
- checkpoint?: Checkpoint;
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;
51
- export interface StreamingSyncRequest {
52
- /**
53
- * Existing bucket states.
54
- */
55
- buckets?: BucketRequest[];
56
- /**
57
- * If specified, limit the response to only include these buckets.
58
- */
59
- only?: string[];
60
- /**
61
- * Whether or not to compute a checksum for each checkpoint
62
- */
63
- include_checksum: boolean;
64
- /**
65
- * Changes the response to stringified data in each OplogEntry
66
- */
67
- raw_data: boolean;
68
- /**
69
- * Client parameters to be passed to the sync rules.
70
- */
71
- parameters?: Record<string, StreamingSyncRequestParameterType>;
72
- /**
73
- * Application metadata to be included in service logs.
74
- */
75
- app_metadata?: Record<string, string>;
76
- client_id?: string;
77
- }
78
- export interface StreamingSyncCheckpoint {
79
- checkpoint: Checkpoint;
80
- }
81
- export interface StreamingSyncCheckpointDiff {
82
- checkpoint_diff: {
83
- last_op_id: OpId;
84
- updated_buckets: BucketChecksum[];
85
- removed_buckets: string[];
86
- write_checkpoint?: string;
87
- };
88
- }
89
- export interface StreamingSyncDataJSON {
90
- data: SyncDataBucketJSON;
91
- }
92
- export interface StreamingSyncCheckpointComplete {
93
- checkpoint_complete: {
94
- last_op_id: OpId;
95
- };
96
- }
97
- export interface StreamingSyncCheckpointPartiallyComplete {
98
- partial_checkpoint_complete: {
99
- priority: number;
100
- last_op_id: OpId;
101
- };
102
- }
103
- export interface StreamingSyncKeepalive {
104
- /** If specified, token expires in this many seconds. */
105
- token_expires_in: number;
106
- }
107
- export type StreamingSyncLine = StreamingSyncDataJSON | StreamingSyncCheckpoint | StreamingSyncCheckpointDiff | StreamingSyncCheckpointComplete | StreamingSyncCheckpointPartiallyComplete | StreamingSyncKeepalive;
108
- export type CrudUploadNotification = {
109
- crud_upload_completed: null;
110
- };
111
- export type StreamingSyncLineOrCrudUploadComplete = StreamingSyncLine | CrudUploadNotification;
112
- export interface BucketRequest {
113
- name: string;
114
- /**
115
- * Base-10 number. Sync all data from this bucket with op_id > after.
116
- */
117
- after: OpId;
118
- }
119
- export declare function isStreamingSyncData(line: StreamingSyncLine): line is StreamingSyncDataJSON;
120
- export declare function isStreamingKeepalive(line: StreamingSyncLine): line is StreamingSyncKeepalive;
121
- export declare function isStreamingSyncCheckpoint(line: StreamingSyncLine): line is StreamingSyncCheckpoint;
122
- export declare function isStreamingSyncCheckpointComplete(line: StreamingSyncLine): line is StreamingSyncCheckpointComplete;
123
- export declare function isStreamingSyncCheckpointPartiallyComplete(line: StreamingSyncLine): line is StreamingSyncCheckpointPartiallyComplete;
124
- export declare function isStreamingSyncCheckpointDiff(line: StreamingSyncLine): line is StreamingSyncCheckpointDiff;
125
- export declare function isContinueCheckpointRequest(request: SyncRequest): request is ContinueCheckpointRequest;
126
- export declare function isSyncNewCheckpointRequest(request: SyncRequest): request is SyncNewCheckpointRequest;
127
- /**
128
- * For crud.json
129
- */
130
- export interface CrudRequest {
131
- data: CrudEntry[];
132
- }
133
- export interface CrudResponse {
134
- /**
135
- * A sync response with a checkpoint >= this checkpoint would contain all the changes in this request.
136
- *
137
- * Any earlier checkpoint may or may not contain these changes.
138
- *
139
- * May be empty when the request contains no ops.
140
- */
141
- checkpoint?: OpId;
142
- }
143
- export {};
@@ -1,26 +0,0 @@
1
- export function isStreamingSyncData(line) {
2
- return line.data != null;
3
- }
4
- export function isStreamingKeepalive(line) {
5
- return line.token_expires_in != null;
6
- }
7
- export function isStreamingSyncCheckpoint(line) {
8
- return line.checkpoint != null;
9
- }
10
- export function isStreamingSyncCheckpointComplete(line) {
11
- return line.checkpoint_complete != null;
12
- }
13
- export function isStreamingSyncCheckpointPartiallyComplete(line) {
14
- return line.partial_checkpoint_complete != null;
15
- }
16
- export function isStreamingSyncCheckpointDiff(line) {
17
- return line.checkpoint_diff != null;
18
- }
19
- export function isContinueCheckpointRequest(request) {
20
- return (Array.isArray(request.buckets) &&
21
- typeof request.checkpoint_token == 'string');
22
- }
23
- export function isSyncNewCheckpointRequest(request) {
24
- return typeof request.request_checkpoint == 'object';
25
- }
26
- //# sourceMappingURL=streaming-sync-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"streaming-sync-types.js","sourceRoot":"","sources":["../../../../src/client/sync/stream/streaming-sync-types.ts"],"names":[],"mappings":"AA4JA,MAAM,UAAU,mBAAmB,CAAC,IAAuB;IACzD,OAAQ,IAA8B,CAAC,IAAI,IAAI,IAAI,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAuB;IAC1D,OAAQ,IAA+B,CAAC,gBAAgB,IAAI,IAAI,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,IAAuB;IAC/D,OAAQ,IAAgC,CAAC,UAAU,IAAI,IAAI,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,iCAAiC,CAAC,IAAuB;IACvE,OAAQ,IAAwC,CAAC,mBAAmB,IAAI,IAAI,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,0CAA0C,CACxD,IAAuB;IAEvB,OAAQ,IAAiD,CAAC,2BAA2B,IAAI,IAAI,CAAC;AAChG,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,IAAuB;IACnE,OAAQ,IAAoC,CAAC,eAAe,IAAI,IAAI,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,OAAoB;IAC9D,OAAO,CACL,KAAK,CAAC,OAAO,CAAE,OAAqC,CAAC,OAAO,CAAC;QAC7D,OAAQ,OAAqC,CAAC,gBAAgB,IAAI,QAAQ,CAC3E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,OAAoB;IAC7D,OAAO,OAAQ,OAAoC,CAAC,kBAAkB,IAAI,QAAQ,CAAC;AACrF,CAAC"}
@@ -1,23 +0,0 @@
1
- export enum OpTypeEnum {
2
- CLEAR = 1,
3
- MOVE = 2,
4
- PUT = 3,
5
- REMOVE = 4
6
- }
7
-
8
- export type OpTypeJSON = string;
9
-
10
- /**
11
- * Used internally for sync buckets.
12
- */
13
- export class OpType {
14
- static fromJSON(jsonValue: OpTypeJSON) {
15
- return new OpType(OpTypeEnum[jsonValue]);
16
- }
17
-
18
- constructor(public value: OpTypeEnum) {}
19
-
20
- toJSON() {
21
- return Object.entries(OpTypeEnum).find(([, value]) => value === this.value)![0];
22
- }
23
- }
@@ -1,50 +0,0 @@
1
- import { OpId } from './CrudEntry.js';
2
- import { OpType, OpTypeJSON } from './OpType.js';
3
-
4
- export interface OplogEntryJSON {
5
- checksum: number;
6
- data?: string;
7
- object_id?: string;
8
- object_type?: string;
9
- op_id: string;
10
- op: OpTypeJSON;
11
- subkey?: string;
12
- }
13
-
14
- export class OplogEntry {
15
- static fromRow(row: OplogEntryJSON) {
16
- return new OplogEntry(
17
- row.op_id,
18
- OpType.fromJSON(row.op),
19
- row.checksum,
20
- row.subkey,
21
- row.object_type,
22
- row.object_id,
23
- row.data
24
- );
25
- }
26
-
27
- constructor(
28
- public op_id: OpId,
29
- public op: OpType,
30
- public checksum: number,
31
- public subkey?: string,
32
- public object_type?: string,
33
- public object_id?: string,
34
- public data?: string
35
- ) {}
36
-
37
- toJSON(fixedKeyEncoding = false): OplogEntryJSON {
38
- return {
39
- op_id: this.op_id,
40
- op: this.op.toJSON(),
41
- object_type: this.object_type,
42
- object_id: this.object_id,
43
- checksum: this.checksum,
44
- data: this.data,
45
- // Older versions of the JS SDK used to always JSON.stringify here. That has always been wrong,
46
- // but we need to migrate gradually to not break existing databases.
47
- subkey: fixedKeyEncoding ? this.subkey : JSON.stringify(this.subkey)
48
- };
49
- }
50
- }
@@ -1,11 +0,0 @@
1
- import { SyncDataBucket } from './SyncDataBucket.js';
2
-
3
- // TODO JSON
4
-
5
- export class SyncDataBatch {
6
- static fromJSON(json: any) {
7
- return new SyncDataBatch(json.buckets.map((bucket: any) => SyncDataBucket.fromRow(bucket)));
8
- }
9
-
10
- constructor(public buckets: SyncDataBucket[]) {}
11
- }
@@ -1,49 +0,0 @@
1
- import { OpId } from './CrudEntry.js';
2
- import { OplogEntry, OplogEntryJSON } from './OplogEntry.js';
3
-
4
- export type SyncDataBucketJSON = {
5
- bucket: string;
6
- has_more?: boolean;
7
- after?: string;
8
- next_after?: string;
9
- data: OplogEntryJSON[];
10
- };
11
-
12
- export class SyncDataBucket {
13
- static fromRow(row: SyncDataBucketJSON) {
14
- return new SyncDataBucket(
15
- row.bucket,
16
- row.data.map((entry) => OplogEntry.fromRow(entry)),
17
- row.has_more ?? false,
18
- row.after,
19
- row.next_after
20
- );
21
- }
22
-
23
- constructor(
24
- public bucket: string,
25
- public data: OplogEntry[],
26
- /**
27
- * True if the response does not contain all the data for this bucket, and another request must be made.
28
- */
29
- public has_more: boolean,
30
- /**
31
- * The `after` specified in the request.
32
- */
33
- public after?: OpId,
34
- /**
35
- * Use this for the next request.
36
- */
37
- public next_after?: OpId
38
- ) {}
39
-
40
- toJSON(fixedKeyEncoding = false): SyncDataBucketJSON {
41
- return {
42
- bucket: this.bucket,
43
- has_more: this.has_more,
44
- after: this.after,
45
- next_after: this.next_after,
46
- data: this.data.map((entry) => entry.toJSON(fixedKeyEncoding))
47
- };
48
- }
49
- }