@powersync/service-module-postgres-storage 0.0.0-dev-20250818104041 → 0.0.0-dev-20250819134004
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/CHANGELOG.md +10 -9
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/storage/PostgresReportStorageFactory.d.ts +6 -6
- package/dist/storage/PostgresReportStorageFactory.js +5 -5
- package/dist/storage/PostgresReportStorageFactory.js.map +1 -1
- package/package.json +10 -10
- package/src/storage/PostgresReportStorageFactory.ts +9 -15
- package/test/src/__snapshots__/storage_sync.test.ts.snap +197 -0
- package/test/src/sdk-report-storage.test.ts +14 -14
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { storage } from '@powersync/service-core';
|
|
2
2
|
import * as pg_wire from '@powersync/service-jpgwire';
|
|
3
|
+
import { event_types } from '@powersync/service-types';
|
|
3
4
|
import * as lib_postgres from '@powersync/lib-service-postgres';
|
|
4
5
|
import { NormalizedPostgresStorageConfig } from '../types/types.js';
|
|
5
|
-
import { DeleteOldSdkData, ListCurrentConnectionsRequest, ScrapeSdkDataRequest, SdkConnectBucketData, SdkConnections, SdkDisconnectEventData } from '@powersync/service-types/src/events.js';
|
|
6
6
|
export type PostgresReportStorageOptions = {
|
|
7
7
|
config: NormalizedPostgresStorageConfig;
|
|
8
8
|
};
|
|
@@ -14,11 +14,11 @@ export declare class PostgresReportStorageFactory implements storage.ReportStora
|
|
|
14
14
|
private mapListCurrentConnectionsResponse;
|
|
15
15
|
private listConnectionsQuery;
|
|
16
16
|
private updateTableFilter;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
reportClientConnection(data: event_types.ClientConnectionBucketData): Promise<void>;
|
|
18
|
+
reportClientDisconnection(data: event_types.ClientDisconnectionEventData): Promise<void>;
|
|
19
|
+
getConnectedClients(data: event_types.ClientConnectionsRequest): Promise<event_types.ClientConnectionReport>;
|
|
20
|
+
getClientConnectionReports(data: event_types.ClientConnectionReportRequest): Promise<event_types.ClientConnectionReport>;
|
|
21
|
+
deleteOldConnectionData(data: event_types.DeleteOldConnectionData): Promise<void>;
|
|
22
22
|
[Symbol.asyncDispose](): Promise<void>;
|
|
23
23
|
prepareStatements(connection: pg_wire.PgConnection): Promise<void>;
|
|
24
24
|
}
|
|
@@ -149,7 +149,7 @@ export class PostgresReportStorageFactory {
|
|
|
149
149
|
lt: new Date(year, month, nextDay).toISOString()
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
-
async
|
|
152
|
+
async reportClientConnection(data) {
|
|
153
153
|
const { sdk, connected_at, user_id, user_agent, jwt_exp, client_id } = data;
|
|
154
154
|
const connectIsoString = connected_at.toISOString();
|
|
155
155
|
const jwtExpIsoString = jwt_exp.toISOString();
|
|
@@ -194,7 +194,7 @@ export class PostgresReportStorageFactory {
|
|
|
194
194
|
`.execute();
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
-
async
|
|
197
|
+
async reportClientDisconnection(data) {
|
|
198
198
|
const { user_id, client_id, disconnected_at, connected_at } = data;
|
|
199
199
|
const disconnectIsoString = disconnected_at.toISOString();
|
|
200
200
|
const connectIsoString = connected_at.toISOString();
|
|
@@ -209,11 +209,11 @@ export class PostgresReportStorageFactory {
|
|
|
209
209
|
AND connected_at = ${{ type: 1184, value: connectIsoString }}
|
|
210
210
|
`.execute();
|
|
211
211
|
}
|
|
212
|
-
async
|
|
212
|
+
async getConnectedClients(data) {
|
|
213
213
|
const result = await this.listConnectionsQuery(data);
|
|
214
214
|
return this.mapListCurrentConnectionsResponse(result);
|
|
215
215
|
}
|
|
216
|
-
async
|
|
216
|
+
async getClientConnectionReports(data) {
|
|
217
217
|
const { start, end } = data;
|
|
218
218
|
const result = await this.db.sql `
|
|
219
219
|
WITH
|
|
@@ -260,7 +260,7 @@ export class PostgresReportStorageFactory {
|
|
|
260
260
|
.first();
|
|
261
261
|
return this.mapListCurrentConnectionsResponse(result);
|
|
262
262
|
}
|
|
263
|
-
async
|
|
263
|
+
async deleteOldConnectionData(data) {
|
|
264
264
|
const { date } = data;
|
|
265
265
|
const result = await this.db.sql `
|
|
266
266
|
DELETE FROM sdk_report_events
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresReportStorageFactory.js","sourceRoot":"","sources":["../../src/storage/PostgresReportStorageFactory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,KAAK,YAAY,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"PostgresReportStorageFactory.js","sourceRoot":"","sources":["../../src/storage/PostgresReportStorageFactory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,KAAK,YAAY,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAuB,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAMrD,MAAM,OAAO,4BAA4B;IAEjB;IADb,EAAE,CAA8B;IACzC,YAAsB,OAAqC;QAArC,YAAO,GAAP,OAAO,CAA8B;QACzD,IAAI,CAAC,EAAE,GAAG,IAAI,YAAY,CAAC,cAAc,CAAC;YACxC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,mBAAmB;YAC3B,eAAe,EAAE,yBAAyB,EAAE;SAC7C,CAAC,CAAC;QAEH,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC;YACvB,iBAAiB,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC;SAC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,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QACtB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,GAAG,CAAA;;;yBAGX,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE;;;;;;;;KAQ7D,CAAC,OAAO,EAAE,CAAC;QACZ,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;QAC7E,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;YACpB,MAAM,CAAC,IAAI,CACT,YAAY,IAAI,CAAC,WAAW,EAAE,KAAK,WAAW,6DAA6D,CAC5G,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,UAAgC;QACtD,+EAA+E;QAC/E,qCAAqC;IACvC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@powersync/service-module-postgres-storage",
|
|
3
3
|
"repository": "https://github.com/powersync-ja/powersync-service",
|
|
4
4
|
"types": "dist/@types/index.d.ts",
|
|
5
|
-
"version": "0.0.0-dev-
|
|
5
|
+
"version": "0.0.0-dev-20250819134004",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"publishConfig": {
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"p-defer": "^4.0.1",
|
|
29
29
|
"ts-codec": "^1.3.0",
|
|
30
30
|
"uuid": "^11.1.0",
|
|
31
|
-
"@powersync/lib-service-postgres": "0.0.0-dev-
|
|
32
|
-
"@powersync/lib-services-framework": "0.0.0-dev-
|
|
33
|
-
"@powersync/service-core": "0.0.0-dev-
|
|
34
|
-
"@powersync/service-types": "0.0.0-dev-
|
|
35
|
-
"@powersync/service-core-tests": "0.0.0-dev-
|
|
36
|
-
"@powersync/service-jpgwire": "0.0.0-dev-
|
|
37
|
-
"@powersync/service-jsonbig": "0.0.0-dev-
|
|
38
|
-
"@powersync/service-sync-rules": "0.0.0-dev-
|
|
31
|
+
"@powersync/lib-service-postgres": "0.0.0-dev-20250819134004",
|
|
32
|
+
"@powersync/lib-services-framework": "0.0.0-dev-20250819134004",
|
|
33
|
+
"@powersync/service-core": "0.0.0-dev-20250819134004",
|
|
34
|
+
"@powersync/service-types": "0.0.0-dev-20250819134004",
|
|
35
|
+
"@powersync/service-core-tests": "0.0.0-dev-20250819134004",
|
|
36
|
+
"@powersync/service-jpgwire": "0.0.0-dev-20250819134004",
|
|
37
|
+
"@powersync/service-jsonbig": "0.0.0-dev-20250819134004",
|
|
38
|
+
"@powersync/service-sync-rules": "0.0.0-dev-20250819134004"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"typescript": "^5.7.3"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsc -b",
|
|
45
45
|
"build:tests": "tsc -b test/tsconfig.json",
|
|
46
|
-
"clean": "rm -rf ./
|
|
46
|
+
"clean": "rm -rf ./dist && tsc -b --clean",
|
|
47
47
|
"test": "vitest"
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -4,14 +4,6 @@ import { event_types } from '@powersync/service-types';
|
|
|
4
4
|
import { v4 } from 'uuid';
|
|
5
5
|
import * as lib_postgres from '@powersync/lib-service-postgres';
|
|
6
6
|
import { NormalizedPostgresStorageConfig } from '../types/types.js';
|
|
7
|
-
import {
|
|
8
|
-
DeleteOldSdkData,
|
|
9
|
-
ListCurrentConnectionsRequest,
|
|
10
|
-
ScrapeSdkDataRequest,
|
|
11
|
-
SdkConnectBucketData,
|
|
12
|
-
SdkConnections,
|
|
13
|
-
SdkDisconnectEventData
|
|
14
|
-
} from '@powersync/service-types/src/events.js';
|
|
15
7
|
import { SdkReporting, SdkReportingDecoded } from '../types/models/SdkReporting.js';
|
|
16
8
|
import { toInteger } from 'ix/util/tointeger.js';
|
|
17
9
|
import { logger } from '@powersync/lib-services-framework';
|
|
@@ -50,7 +42,7 @@ export class PostgresReportStorageFactory implements storage.ReportStorage {
|
|
|
50
42
|
};
|
|
51
43
|
}
|
|
52
44
|
|
|
53
|
-
private mapListCurrentConnectionsResponse(result: SdkReportingDecoded | null):
|
|
45
|
+
private mapListCurrentConnectionsResponse(result: SdkReportingDecoded | null): event_types.ClientConnectionReport {
|
|
54
46
|
if (!result) {
|
|
55
47
|
return {
|
|
56
48
|
users: 0,
|
|
@@ -62,7 +54,7 @@ export class PostgresReportStorageFactory implements storage.ReportStorage {
|
|
|
62
54
|
sdks: result.sdks?.data || []
|
|
63
55
|
};
|
|
64
56
|
}
|
|
65
|
-
private async listConnectionsQuery(data: event_types.
|
|
57
|
+
private async listConnectionsQuery(data: event_types.ClientConnectionsRequest) {
|
|
66
58
|
const { range } = data;
|
|
67
59
|
if (!range) {
|
|
68
60
|
return this.db.sql`
|
|
@@ -169,7 +161,7 @@ export class PostgresReportStorageFactory implements storage.ReportStorage {
|
|
|
169
161
|
};
|
|
170
162
|
}
|
|
171
163
|
|
|
172
|
-
async
|
|
164
|
+
async reportClientConnection(data: event_types.ClientConnectionBucketData): Promise<void> {
|
|
173
165
|
const { sdk, connected_at, user_id, user_agent, jwt_exp, client_id } = data;
|
|
174
166
|
const connectIsoString = connected_at.toISOString();
|
|
175
167
|
const jwtExpIsoString = jwt_exp!.toISOString();
|
|
@@ -214,7 +206,7 @@ export class PostgresReportStorageFactory implements storage.ReportStorage {
|
|
|
214
206
|
`.execute();
|
|
215
207
|
}
|
|
216
208
|
}
|
|
217
|
-
async
|
|
209
|
+
async reportClientDisconnection(data: event_types.ClientDisconnectionEventData): Promise<void> {
|
|
218
210
|
const { user_id, client_id, disconnected_at, connected_at } = data;
|
|
219
211
|
const disconnectIsoString = disconnected_at.toISOString();
|
|
220
212
|
const connectIsoString = connected_at.toISOString();
|
|
@@ -229,12 +221,14 @@ export class PostgresReportStorageFactory implements storage.ReportStorage {
|
|
|
229
221
|
AND connected_at = ${{ type: 1184, value: connectIsoString }}
|
|
230
222
|
`.execute();
|
|
231
223
|
}
|
|
232
|
-
async
|
|
224
|
+
async getConnectedClients(data: event_types.ClientConnectionsRequest): Promise<event_types.ClientConnectionReport> {
|
|
233
225
|
const result = await this.listConnectionsQuery(data);
|
|
234
226
|
return this.mapListCurrentConnectionsResponse(result);
|
|
235
227
|
}
|
|
236
228
|
|
|
237
|
-
async
|
|
229
|
+
async getClientConnectionReports(
|
|
230
|
+
data: event_types.ClientConnectionReportRequest
|
|
231
|
+
): Promise<event_types.ClientConnectionReport> {
|
|
238
232
|
const { start, end } = data;
|
|
239
233
|
const result = await this.db.sql`
|
|
240
234
|
WITH
|
|
@@ -281,7 +275,7 @@ export class PostgresReportStorageFactory implements storage.ReportStorage {
|
|
|
281
275
|
.first();
|
|
282
276
|
return this.mapListCurrentConnectionsResponse(result);
|
|
283
277
|
}
|
|
284
|
-
async
|
|
278
|
+
async deleteOldConnectionData(data: event_types.DeleteOldConnectionData): Promise<void> {
|
|
285
279
|
const { date } = data;
|
|
286
280
|
const result = await this.db.sql`
|
|
287
281
|
DELETE FROM sdk_report_events
|
|
@@ -10,9 +10,21 @@ exports[`sync - postgres > compacting data - invalidate checkpoint 1`] = `
|
|
|
10
10
|
"checksum": -93886621,
|
|
11
11
|
"count": 2,
|
|
12
12
|
"priority": 3,
|
|
13
|
+
"subscriptions": [
|
|
14
|
+
{
|
|
15
|
+
"default": 0,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
13
18
|
},
|
|
14
19
|
],
|
|
15
20
|
"last_op_id": "2",
|
|
21
|
+
"streams": [
|
|
22
|
+
{
|
|
23
|
+
"errors": [],
|
|
24
|
+
"is_default": true,
|
|
25
|
+
"name": "mybucket",
|
|
26
|
+
},
|
|
27
|
+
],
|
|
16
28
|
"write_checkpoint": undefined,
|
|
17
29
|
},
|
|
18
30
|
},
|
|
@@ -46,6 +58,11 @@ exports[`sync - postgres > compacting data - invalidate checkpoint 2`] = `
|
|
|
46
58
|
"checksum": 499012468,
|
|
47
59
|
"count": 4,
|
|
48
60
|
"priority": 3,
|
|
61
|
+
"subscriptions": [
|
|
62
|
+
{
|
|
63
|
+
"default": 0,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
49
66
|
},
|
|
50
67
|
],
|
|
51
68
|
"write_checkpoint": undefined,
|
|
@@ -105,9 +122,21 @@ exports[`sync - postgres > expiring token 1`] = `
|
|
|
105
122
|
"checksum": 0,
|
|
106
123
|
"count": 0,
|
|
107
124
|
"priority": 3,
|
|
125
|
+
"subscriptions": [
|
|
126
|
+
{
|
|
127
|
+
"default": 0,
|
|
128
|
+
},
|
|
129
|
+
],
|
|
108
130
|
},
|
|
109
131
|
],
|
|
110
132
|
"last_op_id": "0",
|
|
133
|
+
"streams": [
|
|
134
|
+
{
|
|
135
|
+
"errors": [],
|
|
136
|
+
"is_default": true,
|
|
137
|
+
"name": "mybucket",
|
|
138
|
+
},
|
|
139
|
+
],
|
|
111
140
|
"write_checkpoint": undefined,
|
|
112
141
|
},
|
|
113
142
|
},
|
|
@@ -137,9 +166,21 @@ exports[`sync - postgres > sends checkpoint complete line for empty checkpoint 1
|
|
|
137
166
|
"checksum": -1221282404,
|
|
138
167
|
"count": 1,
|
|
139
168
|
"priority": 3,
|
|
169
|
+
"subscriptions": [
|
|
170
|
+
{
|
|
171
|
+
"default": 0,
|
|
172
|
+
},
|
|
173
|
+
],
|
|
140
174
|
},
|
|
141
175
|
],
|
|
142
176
|
"last_op_id": "1",
|
|
177
|
+
"streams": [
|
|
178
|
+
{
|
|
179
|
+
"errors": [],
|
|
180
|
+
"is_default": true,
|
|
181
|
+
"name": "mybucket",
|
|
182
|
+
},
|
|
183
|
+
],
|
|
143
184
|
"write_checkpoint": undefined,
|
|
144
185
|
},
|
|
145
186
|
},
|
|
@@ -193,15 +234,37 @@ exports[`sync - postgres > sync buckets in order 1`] = `
|
|
|
193
234
|
"checksum": 920318466,
|
|
194
235
|
"count": 1,
|
|
195
236
|
"priority": 2,
|
|
237
|
+
"subscriptions": [
|
|
238
|
+
{
|
|
239
|
+
"default": 0,
|
|
240
|
+
},
|
|
241
|
+
],
|
|
196
242
|
},
|
|
197
243
|
{
|
|
198
244
|
"bucket": "b1[]",
|
|
199
245
|
"checksum": -1382098757,
|
|
200
246
|
"count": 1,
|
|
201
247
|
"priority": 1,
|
|
248
|
+
"subscriptions": [
|
|
249
|
+
{
|
|
250
|
+
"default": 1,
|
|
251
|
+
},
|
|
252
|
+
],
|
|
202
253
|
},
|
|
203
254
|
],
|
|
204
255
|
"last_op_id": "2",
|
|
256
|
+
"streams": [
|
|
257
|
+
{
|
|
258
|
+
"errors": [],
|
|
259
|
+
"is_default": true,
|
|
260
|
+
"name": "b0",
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"errors": [],
|
|
264
|
+
"is_default": true,
|
|
265
|
+
"name": "b1",
|
|
266
|
+
},
|
|
267
|
+
],
|
|
205
268
|
"write_checkpoint": undefined,
|
|
206
269
|
},
|
|
207
270
|
},
|
|
@@ -267,9 +330,21 @@ exports[`sync - postgres > sync global data 1`] = `
|
|
|
267
330
|
"checksum": -93886621,
|
|
268
331
|
"count": 2,
|
|
269
332
|
"priority": 3,
|
|
333
|
+
"subscriptions": [
|
|
334
|
+
{
|
|
335
|
+
"default": 0,
|
|
336
|
+
},
|
|
337
|
+
],
|
|
270
338
|
},
|
|
271
339
|
],
|
|
272
340
|
"last_op_id": "2",
|
|
341
|
+
"streams": [
|
|
342
|
+
{
|
|
343
|
+
"errors": [],
|
|
344
|
+
"is_default": true,
|
|
345
|
+
"name": "mybucket",
|
|
346
|
+
},
|
|
347
|
+
],
|
|
273
348
|
"write_checkpoint": undefined,
|
|
274
349
|
},
|
|
275
350
|
},
|
|
@@ -319,21 +394,53 @@ exports[`sync - postgres > sync interrupts low-priority buckets on new checkpoin
|
|
|
319
394
|
"checksum": -659831575,
|
|
320
395
|
"count": 2000,
|
|
321
396
|
"priority": 2,
|
|
397
|
+
"subscriptions": [
|
|
398
|
+
{
|
|
399
|
+
"default": 0,
|
|
400
|
+
},
|
|
401
|
+
],
|
|
322
402
|
},
|
|
323
403
|
{
|
|
324
404
|
"bucket": "b0b[]",
|
|
325
405
|
"checksum": -659831575,
|
|
326
406
|
"count": 2000,
|
|
327
407
|
"priority": 2,
|
|
408
|
+
"subscriptions": [
|
|
409
|
+
{
|
|
410
|
+
"default": 1,
|
|
411
|
+
},
|
|
412
|
+
],
|
|
328
413
|
},
|
|
329
414
|
{
|
|
330
415
|
"bucket": "b1[]",
|
|
331
416
|
"checksum": -1096116670,
|
|
332
417
|
"count": 1,
|
|
333
418
|
"priority": 1,
|
|
419
|
+
"subscriptions": [
|
|
420
|
+
{
|
|
421
|
+
"default": 2,
|
|
422
|
+
},
|
|
423
|
+
],
|
|
334
424
|
},
|
|
335
425
|
],
|
|
336
426
|
"last_op_id": "4001",
|
|
427
|
+
"streams": [
|
|
428
|
+
{
|
|
429
|
+
"errors": [],
|
|
430
|
+
"is_default": true,
|
|
431
|
+
"name": "b0a",
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
"errors": [],
|
|
435
|
+
"is_default": true,
|
|
436
|
+
"name": "b0b",
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
"errors": [],
|
|
440
|
+
"is_default": true,
|
|
441
|
+
"name": "b1",
|
|
442
|
+
},
|
|
443
|
+
],
|
|
337
444
|
"write_checkpoint": undefined,
|
|
338
445
|
},
|
|
339
446
|
},
|
|
@@ -380,18 +487,33 @@ exports[`sync - postgres > sync interrupts low-priority buckets on new checkpoin
|
|
|
380
487
|
"checksum": 883076828,
|
|
381
488
|
"count": 2001,
|
|
382
489
|
"priority": 2,
|
|
490
|
+
"subscriptions": [
|
|
491
|
+
{
|
|
492
|
+
"default": 0,
|
|
493
|
+
},
|
|
494
|
+
],
|
|
383
495
|
},
|
|
384
496
|
{
|
|
385
497
|
"bucket": "b0b[]",
|
|
386
498
|
"checksum": 883076828,
|
|
387
499
|
"count": 2001,
|
|
388
500
|
"priority": 2,
|
|
501
|
+
"subscriptions": [
|
|
502
|
+
{
|
|
503
|
+
"default": 1,
|
|
504
|
+
},
|
|
505
|
+
],
|
|
389
506
|
},
|
|
390
507
|
{
|
|
391
508
|
"bucket": "b1[]",
|
|
392
509
|
"checksum": 1841937527,
|
|
393
510
|
"count": 2,
|
|
394
511
|
"priority": 1,
|
|
512
|
+
"subscriptions": [
|
|
513
|
+
{
|
|
514
|
+
"default": 2,
|
|
515
|
+
},
|
|
516
|
+
],
|
|
395
517
|
},
|
|
396
518
|
],
|
|
397
519
|
"write_checkpoint": undefined,
|
|
@@ -466,9 +588,21 @@ exports[`sync - postgres > sync legacy non-raw data 1`] = `
|
|
|
466
588
|
"checksum": -852817836,
|
|
467
589
|
"count": 1,
|
|
468
590
|
"priority": 3,
|
|
591
|
+
"subscriptions": [
|
|
592
|
+
{
|
|
593
|
+
"default": 0,
|
|
594
|
+
},
|
|
595
|
+
],
|
|
469
596
|
},
|
|
470
597
|
],
|
|
471
598
|
"last_op_id": "1",
|
|
599
|
+
"streams": [
|
|
600
|
+
{
|
|
601
|
+
"errors": [],
|
|
602
|
+
"is_default": true,
|
|
603
|
+
"name": "mybucket",
|
|
604
|
+
},
|
|
605
|
+
],
|
|
472
606
|
"write_checkpoint": undefined,
|
|
473
607
|
},
|
|
474
608
|
},
|
|
@@ -514,9 +648,21 @@ exports[`sync - postgres > sync updates to data query only 1`] = `
|
|
|
514
648
|
"checksum": 0,
|
|
515
649
|
"count": 0,
|
|
516
650
|
"priority": 3,
|
|
651
|
+
"subscriptions": [
|
|
652
|
+
{
|
|
653
|
+
"default": 0,
|
|
654
|
+
},
|
|
655
|
+
],
|
|
517
656
|
},
|
|
518
657
|
],
|
|
519
658
|
"last_op_id": "1",
|
|
659
|
+
"streams": [
|
|
660
|
+
{
|
|
661
|
+
"errors": [],
|
|
662
|
+
"is_default": true,
|
|
663
|
+
"name": "by_user",
|
|
664
|
+
},
|
|
665
|
+
],
|
|
520
666
|
"write_checkpoint": undefined,
|
|
521
667
|
},
|
|
522
668
|
},
|
|
@@ -540,6 +686,11 @@ exports[`sync - postgres > sync updates to data query only 2`] = `
|
|
|
540
686
|
"checksum": 1418351250,
|
|
541
687
|
"count": 1,
|
|
542
688
|
"priority": 3,
|
|
689
|
+
"subscriptions": [
|
|
690
|
+
{
|
|
691
|
+
"default": 0,
|
|
692
|
+
},
|
|
693
|
+
],
|
|
543
694
|
},
|
|
544
695
|
],
|
|
545
696
|
"write_checkpoint": undefined,
|
|
@@ -582,9 +733,21 @@ exports[`sync - postgres > sync updates to global data 1`] = `
|
|
|
582
733
|
"checksum": 0,
|
|
583
734
|
"count": 0,
|
|
584
735
|
"priority": 3,
|
|
736
|
+
"subscriptions": [
|
|
737
|
+
{
|
|
738
|
+
"default": 0,
|
|
739
|
+
},
|
|
740
|
+
],
|
|
585
741
|
},
|
|
586
742
|
],
|
|
587
743
|
"last_op_id": "0",
|
|
744
|
+
"streams": [
|
|
745
|
+
{
|
|
746
|
+
"errors": [],
|
|
747
|
+
"is_default": true,
|
|
748
|
+
"name": "mybucket",
|
|
749
|
+
},
|
|
750
|
+
],
|
|
588
751
|
"write_checkpoint": undefined,
|
|
589
752
|
},
|
|
590
753
|
},
|
|
@@ -608,6 +771,11 @@ exports[`sync - postgres > sync updates to global data 2`] = `
|
|
|
608
771
|
"checksum": 920318466,
|
|
609
772
|
"count": 1,
|
|
610
773
|
"priority": 3,
|
|
774
|
+
"subscriptions": [
|
|
775
|
+
{
|
|
776
|
+
"default": 0,
|
|
777
|
+
},
|
|
778
|
+
],
|
|
611
779
|
},
|
|
612
780
|
],
|
|
613
781
|
"write_checkpoint": undefined,
|
|
@@ -652,6 +820,11 @@ exports[`sync - postgres > sync updates to global data 3`] = `
|
|
|
652
820
|
"checksum": -93886621,
|
|
653
821
|
"count": 2,
|
|
654
822
|
"priority": 3,
|
|
823
|
+
"subscriptions": [
|
|
824
|
+
{
|
|
825
|
+
"default": 0,
|
|
826
|
+
},
|
|
827
|
+
],
|
|
655
828
|
},
|
|
656
829
|
],
|
|
657
830
|
"write_checkpoint": undefined,
|
|
@@ -690,6 +863,13 @@ exports[`sync - postgres > sync updates to parameter query + data 1`] = `
|
|
|
690
863
|
"checkpoint": {
|
|
691
864
|
"buckets": [],
|
|
692
865
|
"last_op_id": "0",
|
|
866
|
+
"streams": [
|
|
867
|
+
{
|
|
868
|
+
"errors": [],
|
|
869
|
+
"is_default": true,
|
|
870
|
+
"name": "by_user",
|
|
871
|
+
},
|
|
872
|
+
],
|
|
693
873
|
"write_checkpoint": undefined,
|
|
694
874
|
},
|
|
695
875
|
},
|
|
@@ -713,6 +893,11 @@ exports[`sync - postgres > sync updates to parameter query + data 2`] = `
|
|
|
713
893
|
"checksum": 1418351250,
|
|
714
894
|
"count": 1,
|
|
715
895
|
"priority": 3,
|
|
896
|
+
"subscriptions": [
|
|
897
|
+
{
|
|
898
|
+
"default": 0,
|
|
899
|
+
},
|
|
900
|
+
],
|
|
716
901
|
},
|
|
717
902
|
],
|
|
718
903
|
"write_checkpoint": undefined,
|
|
@@ -751,6 +936,13 @@ exports[`sync - postgres > sync updates to parameter query only 1`] = `
|
|
|
751
936
|
"checkpoint": {
|
|
752
937
|
"buckets": [],
|
|
753
938
|
"last_op_id": "0",
|
|
939
|
+
"streams": [
|
|
940
|
+
{
|
|
941
|
+
"errors": [],
|
|
942
|
+
"is_default": true,
|
|
943
|
+
"name": "by_user",
|
|
944
|
+
},
|
|
945
|
+
],
|
|
754
946
|
"write_checkpoint": undefined,
|
|
755
947
|
},
|
|
756
948
|
},
|
|
@@ -774,6 +966,11 @@ exports[`sync - postgres > sync updates to parameter query only 2`] = `
|
|
|
774
966
|
"checksum": 0,
|
|
775
967
|
"count": 0,
|
|
776
968
|
"priority": 3,
|
|
969
|
+
"subscriptions": [
|
|
970
|
+
{
|
|
971
|
+
"default": 0,
|
|
972
|
+
},
|
|
973
|
+
],
|
|
777
974
|
},
|
|
778
975
|
],
|
|
779
976
|
"write_checkpoint": undefined,
|