@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.
- package/dist/bundle.cjs +33 -665
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +34 -654
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +33 -665
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +34 -654
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +22 -369
- package/legacy/sync_protocol.d.ts +103 -0
- package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +1 -63
- package/lib/client/sync/bucket/BucketStorageAdapter.js.map +1 -1
- package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +1 -28
- package/lib/client/sync/bucket/SqliteBucketStorage.js +0 -162
- package/lib/client/sync/bucket/SqliteBucketStorage.js.map +1 -1
- package/lib/client/sync/stream/AbstractRemote.d.ts +2 -12
- package/lib/client/sync/stream/AbstractRemote.js +3 -13
- package/lib/client/sync/stream/AbstractRemote.js.map +1 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +12 -35
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +29 -337
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +1 -1
- package/lib/client/sync/stream/JsonValue.d.ts +7 -0
- package/lib/client/sync/stream/JsonValue.js +2 -0
- package/lib/client/sync/stream/JsonValue.js.map +1 -0
- package/lib/client/sync/stream/core-instruction.d.ts +1 -2
- package/lib/client/sync/stream/core-instruction.js.map +1 -1
- package/lib/db/crud/SyncStatus.d.ts +0 -4
- package/lib/db/crud/SyncStatus.js +0 -4
- package/lib/db/crud/SyncStatus.js.map +1 -1
- package/lib/db/schema/RawTable.d.ts +0 -5
- package/lib/db/schema/Schema.d.ts +0 -2
- package/lib/db/schema/Schema.js +0 -2
- package/lib/db/schema/Schema.js.map +1 -1
- package/lib/index.d.ts +1 -5
- package/lib/index.js +1 -5
- package/lib/index.js.map +1 -1
- package/package.json +7 -4
- package/src/client/sync/bucket/BucketStorageAdapter.ts +1 -70
- package/src/client/sync/bucket/SqliteBucketStorage.ts +1 -197
- package/src/client/sync/stream/AbstractRemote.ts +5 -27
- package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +41 -407
- package/src/client/sync/stream/JsonValue.ts +8 -0
- package/src/client/sync/stream/core-instruction.ts +1 -2
- package/src/db/crud/SyncStatus.ts +0 -4
- package/src/db/schema/RawTable.ts +0 -5
- package/src/db/schema/Schema.ts +0 -2
- package/src/index.ts +1 -5
- package/lib/client/sync/bucket/OpType.d.ts +0 -16
- package/lib/client/sync/bucket/OpType.js +0 -23
- package/lib/client/sync/bucket/OpType.js.map +0 -1
- package/lib/client/sync/bucket/OplogEntry.d.ts +0 -23
- package/lib/client/sync/bucket/OplogEntry.js +0 -36
- package/lib/client/sync/bucket/OplogEntry.js.map +0 -1
- package/lib/client/sync/bucket/SyncDataBatch.d.ts +0 -6
- package/lib/client/sync/bucket/SyncDataBatch.js +0 -12
- package/lib/client/sync/bucket/SyncDataBatch.js.map +0 -1
- package/lib/client/sync/bucket/SyncDataBucket.d.ts +0 -40
- package/lib/client/sync/bucket/SyncDataBucket.js +0 -40
- package/lib/client/sync/bucket/SyncDataBucket.js.map +0 -1
- package/lib/client/sync/stream/streaming-sync-types.d.ts +0 -143
- package/lib/client/sync/stream/streaming-sync-types.js +0 -26
- package/lib/client/sync/stream/streaming-sync-types.js.map +0 -1
- package/src/client/sync/bucket/OpType.ts +0 -23
- package/src/client/sync/bucket/OplogEntry.ts +0 -50
- package/src/client/sync/bucket/SyncDataBatch.ts +0 -11
- package/src/client/sync/bucket/SyncDataBucket.ts +0 -49
- package/src/client/sync/stream/streaming-sync-types.ts +0 -210
|
@@ -1,210 +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
|
-
/**
|
|
6
|
-
* For sync2.json
|
|
7
|
-
*/
|
|
8
|
-
export interface ContinueCheckpointRequest {
|
|
9
|
-
/**
|
|
10
|
-
* Existing bucket states. Only these buckets are synchronized.
|
|
11
|
-
*/
|
|
12
|
-
buckets: BucketRequest[];
|
|
13
|
-
|
|
14
|
-
checkpoint_token: string;
|
|
15
|
-
|
|
16
|
-
limit?: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface SyncNewCheckpointRequest {
|
|
20
|
-
/**
|
|
21
|
-
* Existing bucket states. Used if include_data is specified.
|
|
22
|
-
*/
|
|
23
|
-
buckets?: BucketRequest[];
|
|
24
|
-
|
|
25
|
-
request_checkpoint: {
|
|
26
|
-
/**
|
|
27
|
-
* Whether or not to include an initial data request.
|
|
28
|
-
*/
|
|
29
|
-
include_data: boolean;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Whether or not to compute a checksum.
|
|
33
|
-
*/
|
|
34
|
-
include_checksum: boolean;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
limit?: number;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type SyncRequest = ContinueCheckpointRequest | SyncNewCheckpointRequest;
|
|
41
|
-
|
|
42
|
-
export interface SyncResponse {
|
|
43
|
-
/**
|
|
44
|
-
* Data for the buckets returned. May not have an an entry for each bucket in the request.
|
|
45
|
-
*/
|
|
46
|
-
data?: SyncDataBucketJSON[];
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* True if the response limit has been reached, and another request must be made.
|
|
50
|
-
*/
|
|
51
|
-
has_more: boolean;
|
|
52
|
-
|
|
53
|
-
checkpoint_token?: string;
|
|
54
|
-
|
|
55
|
-
checkpoint?: Checkpoint;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
type JSONValue = string | number | boolean | null | undefined | JSONObject | JSONArray;
|
|
59
|
-
|
|
60
|
-
interface JSONObject {
|
|
61
|
-
[key: string]: JSONValue;
|
|
62
|
-
}
|
|
63
|
-
type JSONArray = JSONValue[];
|
|
64
|
-
|
|
65
|
-
export type StreamingSyncRequestParameterType = JSONValue;
|
|
66
|
-
|
|
67
|
-
export interface StreamingSyncRequest {
|
|
68
|
-
/**
|
|
69
|
-
* Existing bucket states.
|
|
70
|
-
*/
|
|
71
|
-
buckets?: BucketRequest[];
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* If specified, limit the response to only include these buckets.
|
|
75
|
-
*/
|
|
76
|
-
only?: string[];
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Whether or not to compute a checksum for each checkpoint
|
|
80
|
-
*/
|
|
81
|
-
include_checksum: boolean;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Changes the response to stringified data in each OplogEntry
|
|
85
|
-
*/
|
|
86
|
-
raw_data: boolean;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Client parameters to be passed to the sync rules.
|
|
90
|
-
*/
|
|
91
|
-
parameters?: Record<string, StreamingSyncRequestParameterType>;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Application metadata to be included in service logs.
|
|
95
|
-
*/
|
|
96
|
-
app_metadata?: Record<string, string>;
|
|
97
|
-
|
|
98
|
-
client_id?: string;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export interface StreamingSyncCheckpoint {
|
|
102
|
-
checkpoint: Checkpoint;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export interface StreamingSyncCheckpointDiff {
|
|
106
|
-
checkpoint_diff: {
|
|
107
|
-
last_op_id: OpId;
|
|
108
|
-
updated_buckets: BucketChecksum[];
|
|
109
|
-
removed_buckets: string[];
|
|
110
|
-
write_checkpoint?: string;
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export interface StreamingSyncDataJSON {
|
|
115
|
-
data: SyncDataBucketJSON;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export interface StreamingSyncCheckpointComplete {
|
|
119
|
-
checkpoint_complete: {
|
|
120
|
-
last_op_id: OpId;
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export interface StreamingSyncCheckpointPartiallyComplete {
|
|
125
|
-
partial_checkpoint_complete: {
|
|
126
|
-
priority: number;
|
|
127
|
-
last_op_id: OpId;
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export interface StreamingSyncKeepalive {
|
|
132
|
-
/** If specified, token expires in this many seconds. */
|
|
133
|
-
token_expires_in: number;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export type StreamingSyncLine =
|
|
137
|
-
| StreamingSyncDataJSON
|
|
138
|
-
| StreamingSyncCheckpoint
|
|
139
|
-
| StreamingSyncCheckpointDiff
|
|
140
|
-
| StreamingSyncCheckpointComplete
|
|
141
|
-
| StreamingSyncCheckpointPartiallyComplete
|
|
142
|
-
| StreamingSyncKeepalive;
|
|
143
|
-
|
|
144
|
-
export type CrudUploadNotification = { crud_upload_completed: null };
|
|
145
|
-
|
|
146
|
-
export type StreamingSyncLineOrCrudUploadComplete = StreamingSyncLine | CrudUploadNotification;
|
|
147
|
-
|
|
148
|
-
export interface BucketRequest {
|
|
149
|
-
name: string;
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Base-10 number. Sync all data from this bucket with op_id > after.
|
|
153
|
-
*/
|
|
154
|
-
after: OpId;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export function isStreamingSyncData(line: StreamingSyncLine): line is StreamingSyncDataJSON {
|
|
158
|
-
return (line as StreamingSyncDataJSON).data != null;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export function isStreamingKeepalive(line: StreamingSyncLine): line is StreamingSyncKeepalive {
|
|
162
|
-
return (line as StreamingSyncKeepalive).token_expires_in != null;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export function isStreamingSyncCheckpoint(line: StreamingSyncLine): line is StreamingSyncCheckpoint {
|
|
166
|
-
return (line as StreamingSyncCheckpoint).checkpoint != null;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export function isStreamingSyncCheckpointComplete(line: StreamingSyncLine): line is StreamingSyncCheckpointComplete {
|
|
170
|
-
return (line as StreamingSyncCheckpointComplete).checkpoint_complete != null;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export function isStreamingSyncCheckpointPartiallyComplete(
|
|
174
|
-
line: StreamingSyncLine
|
|
175
|
-
): line is StreamingSyncCheckpointPartiallyComplete {
|
|
176
|
-
return (line as StreamingSyncCheckpointPartiallyComplete).partial_checkpoint_complete != null;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export function isStreamingSyncCheckpointDiff(line: StreamingSyncLine): line is StreamingSyncCheckpointDiff {
|
|
180
|
-
return (line as StreamingSyncCheckpointDiff).checkpoint_diff != null;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export function isContinueCheckpointRequest(request: SyncRequest): request is ContinueCheckpointRequest {
|
|
184
|
-
return (
|
|
185
|
-
Array.isArray((request as ContinueCheckpointRequest).buckets) &&
|
|
186
|
-
typeof (request as ContinueCheckpointRequest).checkpoint_token == 'string'
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export function isSyncNewCheckpointRequest(request: SyncRequest): request is SyncNewCheckpointRequest {
|
|
191
|
-
return typeof (request as SyncNewCheckpointRequest).request_checkpoint == 'object';
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* For crud.json
|
|
196
|
-
*/
|
|
197
|
-
export interface CrudRequest {
|
|
198
|
-
data: CrudEntry[];
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export interface CrudResponse {
|
|
202
|
-
/**
|
|
203
|
-
* A sync response with a checkpoint >= this checkpoint would contain all the changes in this request.
|
|
204
|
-
*
|
|
205
|
-
* Any earlier checkpoint may or may not contain these changes.
|
|
206
|
-
*
|
|
207
|
-
* May be empty when the request contains no ops.
|
|
208
|
-
*/
|
|
209
|
-
checkpoint?: OpId;
|
|
210
|
-
}
|