@powersync/service-module-postgres-storage 0.0.0-dev-20260313100403 → 0.0.0-dev-20260511080634
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 +84 -9
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/storage/PostgresBucketStorageFactory.d.ts +2 -1
- package/dist/@types/storage/PostgresReportStorage.d.ts +4 -4
- package/dist/@types/storage/PostgresSyncRulesStorage.d.ts +4 -2
- package/dist/@types/storage/batch/PostgresBucketBatch.d.ts +1 -1
- package/dist/@types/types/models/SyncRules.d.ts +9 -0
- package/dist/@types/types/models/models-index.d.ts +1 -1
- package/dist/@types/utils/test-utils.d.ts +2 -2
- package/dist/@types/utils/utils-index.d.ts +1 -1
- package/dist/migrations/migration-utils.js +2 -2
- package/dist/migrations/migration-utils.js.map +1 -1
- package/dist/migrations/scripts/1684951997326-init.js +24 -100
- package/dist/migrations/scripts/1684951997326-init.js.map +1 -1
- package/dist/migrations/scripts/1749024804042-snapshot-progress.js +12 -88
- package/dist/migrations/scripts/1749024804042-snapshot-progress.js.map +1 -1
- package/dist/migrations/scripts/1756282360128-connection-reporting.js +12 -88
- package/dist/migrations/scripts/1756282360128-connection-reporting.js.map +1 -1
- package/dist/migrations/scripts/1771232439485-storage-version.js +14 -90
- package/dist/migrations/scripts/1771232439485-storage-version.js.map +1 -1
- package/dist/migrations/scripts/1771424826685-current-data-pending-deletes.js +1 -1
- package/dist/migrations/scripts/1771491856000-sync-plan.js +6 -82
- package/dist/migrations/scripts/1771491856000-sync-plan.js.map +1 -1
- package/dist/storage/PostgresBucketStorageFactory.js +6 -5
- package/dist/storage/PostgresBucketStorageFactory.js.map +1 -1
- package/dist/storage/PostgresReportStorage.js +10 -10
- package/dist/storage/PostgresReportStorage.js.map +1 -1
- package/dist/storage/PostgresSyncRulesStorage.js +63 -104
- package/dist/storage/PostgresSyncRulesStorage.js.map +1 -1
- package/dist/storage/batch/PostgresBucketBatch.js +5 -5
- package/dist/storage/batch/PostgresBucketBatch.js.map +1 -1
- package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js +1 -1
- package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js.map +1 -1
- package/dist/storage/current-data-store.js +1 -1
- package/dist/storage/current-data-store.js.map +1 -1
- package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js +3 -3
- package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js.map +1 -1
- package/dist/types/models/SyncRules.js +3 -1
- package/dist/types/models/SyncRules.js.map +1 -1
- package/dist/types/models/models-index.js +1 -1
- package/dist/types/models/models-index.js.map +1 -1
- package/dist/utils/test-utils.js +36 -112
- package/dist/utils/test-utils.js.map +1 -1
- package/dist/utils/utils-index.js +1 -1
- package/dist/utils/utils-index.js.map +1 -1
- package/package.json +11 -12
- package/src/migrations/migration-utils.ts +2 -2
- package/src/migrations/scripts/1771424826685-current-data-pending-deletes.ts +1 -1
- package/src/storage/PostgresBucketStorageFactory.ts +7 -5
- package/src/storage/PostgresReportStorage.ts +12 -12
- package/src/storage/PostgresSyncRulesStorage.ts +63 -36
- package/src/storage/batch/PostgresBucketBatch.ts +5 -5
- package/src/storage/checkpoints/PostgresWriteCheckpointAPI.ts +3 -1
- package/src/storage/current-data-store.ts +1 -1
- package/src/storage/sync-rules/PostgresPersistedSyncRulesContent.ts +3 -6
- package/src/types/models/SyncRules.ts +3 -1
- package/src/types/models/models-index.ts +1 -1
- package/src/utils/test-utils.ts +3 -3
- package/src/utils/utils-index.ts +1 -1
- package/test/src/__snapshots__/{client-connections-storage.test.ts.snap → connection-report-storage.test.ts.snap} +22 -22
- package/test/src/__snapshots__/storage_sync.test.ts.snap +282 -0
- package/test/src/{client-connections-storage.test.ts → connection-report-storage.test.ts} +5 -5
- package/test/src/setup.ts +1 -1
- package/test/tsconfig.json +0 -1
- package/dist/@types/storage/current-data-table.d.ts +0 -9
- package/dist/storage/current-data-table.js +0 -22
- package/dist/storage/current-data-table.js.map +0 -1
- package/src/storage/current-data-table.ts +0 -26
|
@@ -64,7 +64,9 @@ export class PostgresWriteCheckpointAPI implements storage.WriteCheckpointAPI {
|
|
|
64
64
|
switch (this.writeCheckpointMode) {
|
|
65
65
|
case storage.WriteCheckpointMode.CUSTOM:
|
|
66
66
|
if (false == 'sync_rules_id' in filters) {
|
|
67
|
-
throw new framework.errors.ValidationError(
|
|
67
|
+
throw new framework.errors.ValidationError(
|
|
68
|
+
`Replication stream ID is required for custom Write Checkpoint filtering`
|
|
69
|
+
);
|
|
68
70
|
}
|
|
69
71
|
return this.lastCustomWriteCheckpoint(filters as storage.CustomWriteCheckpointFilters);
|
|
70
72
|
case storage.WriteCheckpointMode.MANAGED:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as lib_postgres from '@powersync/lib-service-postgres';
|
|
2
2
|
import { storage } from '@powersync/service-core';
|
|
3
3
|
import * as t from 'ts-codec';
|
|
4
|
-
import { pick } from '../utils/ts-codec.js';
|
|
5
4
|
import * as models from '../types/models/CurrentData.js';
|
|
5
|
+
import { pick } from '../utils/ts-codec.js';
|
|
6
6
|
|
|
7
7
|
type Queryable = Pick<lib_postgres.DatabaseClient, 'sql' | 'streamRows'>;
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as lib_postgres from '@powersync/lib-service-postgres';
|
|
2
|
-
import { ErrorCode,
|
|
2
|
+
import { ErrorCode, ServiceError } from '@powersync/lib-services-framework';
|
|
3
3
|
import { storage } from '@powersync/service-core';
|
|
4
4
|
import { models } from '../../types/types.js';
|
|
5
5
|
|
|
@@ -31,17 +31,14 @@ export class PostgresPersistedSyncRulesContent extends storage.PersistedSyncRule
|
|
|
31
31
|
});
|
|
32
32
|
const lockHandle = await manager.acquire();
|
|
33
33
|
if (!lockHandle) {
|
|
34
|
-
throw new ServiceError(
|
|
35
|
-
ErrorCode.PSYNC_S1003,
|
|
36
|
-
`Sync rules: ${this.id} have been locked by another process for replication.`
|
|
37
|
-
);
|
|
34
|
+
throw new ServiceError(ErrorCode.PSYNC_S1003, `Replication stream is locked by another process, standing by.`);
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
const interval = setInterval(async () => {
|
|
41
38
|
try {
|
|
42
39
|
await lockHandle.refresh();
|
|
43
40
|
} catch (e) {
|
|
44
|
-
logger.error('Failed to refresh lock', e);
|
|
41
|
+
this.logger.error('Failed to refresh lock', e);
|
|
45
42
|
clearInterval(interval);
|
|
46
43
|
}
|
|
47
44
|
}, 30_130);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { framework, storage } from '@powersync/service-core';
|
|
2
|
+
import { ReplicationError } from '@powersync/service-types';
|
|
2
3
|
import * as t from 'ts-codec';
|
|
3
4
|
import { bigint, pgwire_number } from '../codecs.js';
|
|
4
5
|
import { jsonContainerObject } from './json.js';
|
|
@@ -59,7 +60,8 @@ export const SyncRules = t.object({
|
|
|
59
60
|
overrides: t.record(t.boolean),
|
|
60
61
|
maxTimeValuePrecision: t.number.optional()
|
|
61
62
|
}),
|
|
62
|
-
eventDescriptors: t.record(t.array(t.string))
|
|
63
|
+
eventDescriptors: t.record(t.array(t.string)),
|
|
64
|
+
errors: t.array(ReplicationError).optional()
|
|
63
65
|
})
|
|
64
66
|
)
|
|
65
67
|
)
|
|
@@ -5,7 +5,7 @@ export * from './BucketParameters.js';
|
|
|
5
5
|
export * from './CurrentData.js';
|
|
6
6
|
export * from './Instance.js';
|
|
7
7
|
export * from './Migration.js';
|
|
8
|
+
export * from './SdkReporting.js';
|
|
8
9
|
export * from './SourceTable.js';
|
|
9
10
|
export * from './SyncRules.js';
|
|
10
11
|
export * from './WriteCheckpoint.js';
|
|
11
|
-
export * from './SdkReporting.js';
|
package/src/utils/test-utils.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { createLogger, logger as defaultLogger, transports } from '@powersync/lib-services-framework';
|
|
1
2
|
import { framework, PowerSyncMigrationManager, ServiceContext, TestStorageOptions } from '@powersync/service-core';
|
|
2
3
|
import { PostgresMigrationAgent } from '../migrations/PostgresMigrationAgent.js';
|
|
3
|
-
import { normalizePostgresStorageConfig, PostgresStorageConfigDecoded } from '../types/types.js';
|
|
4
|
-
import { PostgresReportStorage } from '../storage/PostgresReportStorage.js';
|
|
5
4
|
import { PostgresBucketStorageFactory } from '../storage/PostgresBucketStorageFactory.js';
|
|
6
|
-
import {
|
|
5
|
+
import { PostgresReportStorage } from '../storage/PostgresReportStorage.js';
|
|
6
|
+
import { normalizePostgresStorageConfig, PostgresStorageConfigDecoded } from '../types/types.js';
|
|
7
7
|
import { truncateTables } from './db.js';
|
|
8
8
|
|
|
9
9
|
export type PostgresTestStorageOptions = {
|
package/src/utils/utils-index.ts
CHANGED
|
@@ -19,7 +19,7 @@ exports[`Connection report storage > Should create a connection event if its aft
|
|
|
19
19
|
|
|
20
20
|
exports[`Connection report storage > Should delete rows older than specified range 1`] = `
|
|
21
21
|
{
|
|
22
|
-
"
|
|
22
|
+
"sdks": [
|
|
23
23
|
{
|
|
24
24
|
"clients": 1,
|
|
25
25
|
"sdk": "powersync-dart/1.6.4",
|
|
@@ -51,7 +51,7 @@ exports[`Connection report storage > Should delete rows older than specified ran
|
|
|
51
51
|
"users": 1,
|
|
52
52
|
},
|
|
53
53
|
],
|
|
54
|
-
"
|
|
54
|
+
"users": 5,
|
|
55
55
|
}
|
|
56
56
|
`;
|
|
57
57
|
|
|
@@ -77,9 +77,9 @@ exports[`Connection report storage > Should update a connection event if its wit
|
|
|
77
77
|
]
|
|
78
78
|
`;
|
|
79
79
|
|
|
80
|
-
exports[`Report storage tests >
|
|
80
|
+
exports[`Report storage tests > Should show connection report data for user over the past day 1`] = `
|
|
81
81
|
{
|
|
82
|
-
"
|
|
82
|
+
"sdks": [
|
|
83
83
|
{
|
|
84
84
|
"clients": 1,
|
|
85
85
|
"sdk": "powersync-dart/1.6.4",
|
|
@@ -101,13 +101,13 @@ exports[`Report storage tests > getClientConnectionsSummary returns the past day
|
|
|
101
101
|
"users": 1,
|
|
102
102
|
},
|
|
103
103
|
],
|
|
104
|
-
"
|
|
104
|
+
"users": 3,
|
|
105
105
|
}
|
|
106
106
|
`;
|
|
107
107
|
|
|
108
|
-
exports[`Report storage tests >
|
|
108
|
+
exports[`Report storage tests > Should show connection report data for user over the past month 1`] = `
|
|
109
109
|
{
|
|
110
|
-
"
|
|
110
|
+
"sdks": [
|
|
111
111
|
{
|
|
112
112
|
"clients": 1,
|
|
113
113
|
"sdk": "powersync-dart/1.6.4",
|
|
@@ -149,13 +149,13 @@ exports[`Report storage tests > getClientConnectionsSummary returns the past mon
|
|
|
149
149
|
"users": 1,
|
|
150
150
|
},
|
|
151
151
|
],
|
|
152
|
-
"
|
|
152
|
+
"users": 7,
|
|
153
153
|
}
|
|
154
154
|
`;
|
|
155
155
|
|
|
156
|
-
exports[`Report storage tests >
|
|
156
|
+
exports[`Report storage tests > Should show connection report data for user over the past week 1`] = `
|
|
157
157
|
{
|
|
158
|
-
"
|
|
158
|
+
"sdks": [
|
|
159
159
|
{
|
|
160
160
|
"clients": 1,
|
|
161
161
|
"sdk": "powersync-dart/1.6.4",
|
|
@@ -187,13 +187,13 @@ exports[`Report storage tests > getClientConnectionsSummary returns the past wee
|
|
|
187
187
|
"users": 1,
|
|
188
188
|
},
|
|
189
189
|
],
|
|
190
|
-
"
|
|
190
|
+
"users": 5,
|
|
191
191
|
}
|
|
192
192
|
`;
|
|
193
193
|
|
|
194
|
-
exports[`Report storage tests >
|
|
194
|
+
exports[`Report storage tests > Should show currently connected users 1`] = `
|
|
195
195
|
{
|
|
196
|
-
"
|
|
196
|
+
"sdks": [
|
|
197
197
|
{
|
|
198
198
|
"clients": 1,
|
|
199
199
|
"sdk": "powersync-dart/1.6.4",
|
|
@@ -210,11 +210,11 @@ exports[`Report storage tests > getCurrentConnections returns current connection
|
|
|
210
210
|
"users": 1,
|
|
211
211
|
},
|
|
212
212
|
],
|
|
213
|
-
"
|
|
213
|
+
"users": 2,
|
|
214
214
|
}
|
|
215
215
|
`;
|
|
216
216
|
|
|
217
|
-
exports[`Report storage tests >
|
|
217
|
+
exports[`Report storage tests > Should show paginated response of all connections of specified client_id 1`] = `
|
|
218
218
|
{
|
|
219
219
|
"count": 1,
|
|
220
220
|
"cursor": undefined,
|
|
@@ -231,7 +231,7 @@ exports[`Report storage tests > getClientSessions returns sessions for a client_
|
|
|
231
231
|
}
|
|
232
232
|
`;
|
|
233
233
|
|
|
234
|
-
exports[`Report storage tests >
|
|
234
|
+
exports[`Report storage tests > Should show paginated response of all connections with a limit 1`] = `
|
|
235
235
|
{
|
|
236
236
|
"count": 4,
|
|
237
237
|
"cursor": "<removed-for-snapshot>",
|
|
@@ -269,7 +269,7 @@ exports[`Report storage tests > getClientSessions returns paginated sessions wit
|
|
|
269
269
|
}
|
|
270
270
|
`;
|
|
271
271
|
|
|
272
|
-
exports[`Report storage tests >
|
|
272
|
+
exports[`Report storage tests > Should show paginated response of all connections with a limit 2`] = `
|
|
273
273
|
{
|
|
274
274
|
"count": 4,
|
|
275
275
|
"cursor": undefined,
|
|
@@ -307,7 +307,7 @@ exports[`Report storage tests > getClientSessions returns paginated sessions wit
|
|
|
307
307
|
}
|
|
308
308
|
`;
|
|
309
309
|
|
|
310
|
-
exports[`Report storage tests >
|
|
310
|
+
exports[`Report storage tests > Should show paginated response of all connections with a limit with date range 1`] = `
|
|
311
311
|
{
|
|
312
312
|
"count": 4,
|
|
313
313
|
"cursor": "<removed-for-snapshot>",
|
|
@@ -345,7 +345,7 @@ exports[`Report storage tests > getClientSessions returns paginated sessions wit
|
|
|
345
345
|
}
|
|
346
346
|
`;
|
|
347
347
|
|
|
348
|
-
exports[`Report storage tests >
|
|
348
|
+
exports[`Report storage tests > Should show paginated response of all connections with a limit with date range 2`] = `
|
|
349
349
|
{
|
|
350
350
|
"count": 2,
|
|
351
351
|
"cursor": undefined,
|
|
@@ -383,7 +383,7 @@ exports[`Report storage tests > getClientSessions returns paginated sessions wit
|
|
|
383
383
|
}
|
|
384
384
|
`;
|
|
385
385
|
|
|
386
|
-
exports[`Report storage tests >
|
|
386
|
+
exports[`Report storage tests > Should show paginated response of connections of specified user_id 1`] = `
|
|
387
387
|
{
|
|
388
388
|
"count": 2,
|
|
389
389
|
"cursor": undefined,
|
|
@@ -407,7 +407,7 @@ exports[`Report storage tests > getClientSessions returns sessions for a user_id
|
|
|
407
407
|
}
|
|
408
408
|
`;
|
|
409
409
|
|
|
410
|
-
exports[`Report storage tests >
|
|
410
|
+
exports[`Report storage tests > Should show paginated response of connections over a date range 1`] = `
|
|
411
411
|
{
|
|
412
412
|
"count": 6,
|
|
413
413
|
"cursor": undefined,
|
|
@@ -459,7 +459,7 @@ exports[`Report storage tests > getClientSessions returns sessions for a date ra
|
|
|
459
459
|
}
|
|
460
460
|
`;
|
|
461
461
|
|
|
462
|
-
exports[`Report storage tests >
|
|
462
|
+
exports[`Report storage tests > Should show paginated response of connections over a date range of specified client_id and user_id 1`] = `
|
|
463
463
|
{
|
|
464
464
|
"count": 1,
|
|
465
465
|
"cursor": undefined,
|
|
@@ -1,5 +1,99 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
+
exports[`sync - postgres > storage v1 > can override priority when subscribing to stream 1`] = `
|
|
4
|
+
[
|
|
5
|
+
{
|
|
6
|
+
"checkpoint": {
|
|
7
|
+
"buckets": [
|
|
8
|
+
{
|
|
9
|
+
"bucket": "1#todos|0["a"]",
|
|
10
|
+
"checksum": -1712802421,
|
|
11
|
+
"count": 1,
|
|
12
|
+
"priority": 0,
|
|
13
|
+
"subscriptions": [
|
|
14
|
+
{
|
|
15
|
+
"sub": 0,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"sub": 1,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"bucket": "1#todos|0["b"]",
|
|
24
|
+
"checksum": -1291414318,
|
|
25
|
+
"count": 1,
|
|
26
|
+
"priority": 3,
|
|
27
|
+
"subscriptions": [
|
|
28
|
+
{
|
|
29
|
+
"sub": 1,
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
"last_op_id": "2",
|
|
35
|
+
"streams": [
|
|
36
|
+
{
|
|
37
|
+
"errors": [],
|
|
38
|
+
"is_default": false,
|
|
39
|
+
"name": "todos",
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
"write_checkpoint": undefined,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"data": {
|
|
47
|
+
"after": "0",
|
|
48
|
+
"bucket": "1#todos|0["a"]",
|
|
49
|
+
"data": [
|
|
50
|
+
{
|
|
51
|
+
"checksum": 2582164875,
|
|
52
|
+
"data": "{"id":"a","description":"Test 1"}",
|
|
53
|
+
"object_id": "a",
|
|
54
|
+
"object_type": "test",
|
|
55
|
+
"op": "PUT",
|
|
56
|
+
"op_id": "1",
|
|
57
|
+
"subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
"has_more": false,
|
|
61
|
+
"next_after": "1",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"partial_checkpoint_complete": {
|
|
66
|
+
"last_op_id": "2",
|
|
67
|
+
"priority": 0,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"data": {
|
|
72
|
+
"after": "0",
|
|
73
|
+
"bucket": "1#todos|0["b"]",
|
|
74
|
+
"data": [
|
|
75
|
+
{
|
|
76
|
+
"checksum": 3003552978,
|
|
77
|
+
"data": "{"id":"b","description":"Test 2"}",
|
|
78
|
+
"object_id": "b",
|
|
79
|
+
"object_type": "test",
|
|
80
|
+
"op": "PUT",
|
|
81
|
+
"op_id": "2",
|
|
82
|
+
"subkey": "243b0e26-87b2-578a-993c-5ac5b6f7fd64",
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
"has_more": false,
|
|
86
|
+
"next_after": "2",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"checkpoint_complete": {
|
|
91
|
+
"last_op_id": "2",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
]
|
|
95
|
+
`;
|
|
96
|
+
|
|
3
97
|
exports[`sync - postgres > storage v1 > compacting data - invalidate checkpoint 1`] = `
|
|
4
98
|
[
|
|
5
99
|
{
|
|
@@ -1095,6 +1189,100 @@ exports[`sync - postgres > storage v1 > sync updates to parameter query only 2`]
|
|
|
1095
1189
|
]
|
|
1096
1190
|
`;
|
|
1097
1191
|
|
|
1192
|
+
exports[`sync - postgres > storage v2 > can override priority when subscribing to stream 1`] = `
|
|
1193
|
+
[
|
|
1194
|
+
{
|
|
1195
|
+
"checkpoint": {
|
|
1196
|
+
"buckets": [
|
|
1197
|
+
{
|
|
1198
|
+
"bucket": "1#todos|0["a"]",
|
|
1199
|
+
"checksum": -1712802421,
|
|
1200
|
+
"count": 1,
|
|
1201
|
+
"priority": 0,
|
|
1202
|
+
"subscriptions": [
|
|
1203
|
+
{
|
|
1204
|
+
"sub": 0,
|
|
1205
|
+
},
|
|
1206
|
+
{
|
|
1207
|
+
"sub": 1,
|
|
1208
|
+
},
|
|
1209
|
+
],
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
"bucket": "1#todos|0["b"]",
|
|
1213
|
+
"checksum": -1291414318,
|
|
1214
|
+
"count": 1,
|
|
1215
|
+
"priority": 3,
|
|
1216
|
+
"subscriptions": [
|
|
1217
|
+
{
|
|
1218
|
+
"sub": 1,
|
|
1219
|
+
},
|
|
1220
|
+
],
|
|
1221
|
+
},
|
|
1222
|
+
],
|
|
1223
|
+
"last_op_id": "2",
|
|
1224
|
+
"streams": [
|
|
1225
|
+
{
|
|
1226
|
+
"errors": [],
|
|
1227
|
+
"is_default": false,
|
|
1228
|
+
"name": "todos",
|
|
1229
|
+
},
|
|
1230
|
+
],
|
|
1231
|
+
"write_checkpoint": undefined,
|
|
1232
|
+
},
|
|
1233
|
+
},
|
|
1234
|
+
{
|
|
1235
|
+
"data": {
|
|
1236
|
+
"after": "0",
|
|
1237
|
+
"bucket": "1#todos|0["a"]",
|
|
1238
|
+
"data": [
|
|
1239
|
+
{
|
|
1240
|
+
"checksum": 2582164875,
|
|
1241
|
+
"data": "{"id":"a","description":"Test 1"}",
|
|
1242
|
+
"object_id": "a",
|
|
1243
|
+
"object_type": "test",
|
|
1244
|
+
"op": "PUT",
|
|
1245
|
+
"op_id": "1",
|
|
1246
|
+
"subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
|
|
1247
|
+
},
|
|
1248
|
+
],
|
|
1249
|
+
"has_more": false,
|
|
1250
|
+
"next_after": "1",
|
|
1251
|
+
},
|
|
1252
|
+
},
|
|
1253
|
+
{
|
|
1254
|
+
"partial_checkpoint_complete": {
|
|
1255
|
+
"last_op_id": "2",
|
|
1256
|
+
"priority": 0,
|
|
1257
|
+
},
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
"data": {
|
|
1261
|
+
"after": "0",
|
|
1262
|
+
"bucket": "1#todos|0["b"]",
|
|
1263
|
+
"data": [
|
|
1264
|
+
{
|
|
1265
|
+
"checksum": 3003552978,
|
|
1266
|
+
"data": "{"id":"b","description":"Test 2"}",
|
|
1267
|
+
"object_id": "b",
|
|
1268
|
+
"object_type": "test",
|
|
1269
|
+
"op": "PUT",
|
|
1270
|
+
"op_id": "2",
|
|
1271
|
+
"subkey": "243b0e26-87b2-578a-993c-5ac5b6f7fd64",
|
|
1272
|
+
},
|
|
1273
|
+
],
|
|
1274
|
+
"has_more": false,
|
|
1275
|
+
"next_after": "2",
|
|
1276
|
+
},
|
|
1277
|
+
},
|
|
1278
|
+
{
|
|
1279
|
+
"checkpoint_complete": {
|
|
1280
|
+
"last_op_id": "2",
|
|
1281
|
+
},
|
|
1282
|
+
},
|
|
1283
|
+
]
|
|
1284
|
+
`;
|
|
1285
|
+
|
|
1098
1286
|
exports[`sync - postgres > storage v2 > compacting data - invalidate checkpoint 1`] = `
|
|
1099
1287
|
[
|
|
1100
1288
|
{
|
|
@@ -2190,6 +2378,100 @@ exports[`sync - postgres > storage v2 > sync updates to parameter query only 2`]
|
|
|
2190
2378
|
]
|
|
2191
2379
|
`;
|
|
2192
2380
|
|
|
2381
|
+
exports[`sync - postgres > storage v3 > can override priority when subscribing to stream 1`] = `
|
|
2382
|
+
[
|
|
2383
|
+
{
|
|
2384
|
+
"checkpoint": {
|
|
2385
|
+
"buckets": [
|
|
2386
|
+
{
|
|
2387
|
+
"bucket": "1#todos|0["a"]",
|
|
2388
|
+
"checksum": -1712802421,
|
|
2389
|
+
"count": 1,
|
|
2390
|
+
"priority": 0,
|
|
2391
|
+
"subscriptions": [
|
|
2392
|
+
{
|
|
2393
|
+
"sub": 0,
|
|
2394
|
+
},
|
|
2395
|
+
{
|
|
2396
|
+
"sub": 1,
|
|
2397
|
+
},
|
|
2398
|
+
],
|
|
2399
|
+
},
|
|
2400
|
+
{
|
|
2401
|
+
"bucket": "1#todos|0["b"]",
|
|
2402
|
+
"checksum": -1291414318,
|
|
2403
|
+
"count": 1,
|
|
2404
|
+
"priority": 3,
|
|
2405
|
+
"subscriptions": [
|
|
2406
|
+
{
|
|
2407
|
+
"sub": 1,
|
|
2408
|
+
},
|
|
2409
|
+
],
|
|
2410
|
+
},
|
|
2411
|
+
],
|
|
2412
|
+
"last_op_id": "2",
|
|
2413
|
+
"streams": [
|
|
2414
|
+
{
|
|
2415
|
+
"errors": [],
|
|
2416
|
+
"is_default": false,
|
|
2417
|
+
"name": "todos",
|
|
2418
|
+
},
|
|
2419
|
+
],
|
|
2420
|
+
"write_checkpoint": undefined,
|
|
2421
|
+
},
|
|
2422
|
+
},
|
|
2423
|
+
{
|
|
2424
|
+
"data": {
|
|
2425
|
+
"after": "0",
|
|
2426
|
+
"bucket": "1#todos|0["a"]",
|
|
2427
|
+
"data": [
|
|
2428
|
+
{
|
|
2429
|
+
"checksum": 2582164875,
|
|
2430
|
+
"data": "{"id":"a","description":"Test 1"}",
|
|
2431
|
+
"object_id": "a",
|
|
2432
|
+
"object_type": "test",
|
|
2433
|
+
"op": "PUT",
|
|
2434
|
+
"op_id": "1",
|
|
2435
|
+
"subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
|
|
2436
|
+
},
|
|
2437
|
+
],
|
|
2438
|
+
"has_more": false,
|
|
2439
|
+
"next_after": "1",
|
|
2440
|
+
},
|
|
2441
|
+
},
|
|
2442
|
+
{
|
|
2443
|
+
"partial_checkpoint_complete": {
|
|
2444
|
+
"last_op_id": "2",
|
|
2445
|
+
"priority": 0,
|
|
2446
|
+
},
|
|
2447
|
+
},
|
|
2448
|
+
{
|
|
2449
|
+
"data": {
|
|
2450
|
+
"after": "0",
|
|
2451
|
+
"bucket": "1#todos|0["b"]",
|
|
2452
|
+
"data": [
|
|
2453
|
+
{
|
|
2454
|
+
"checksum": 3003552978,
|
|
2455
|
+
"data": "{"id":"b","description":"Test 2"}",
|
|
2456
|
+
"object_id": "b",
|
|
2457
|
+
"object_type": "test",
|
|
2458
|
+
"op": "PUT",
|
|
2459
|
+
"op_id": "2",
|
|
2460
|
+
"subkey": "243b0e26-87b2-578a-993c-5ac5b6f7fd64",
|
|
2461
|
+
},
|
|
2462
|
+
],
|
|
2463
|
+
"has_more": false,
|
|
2464
|
+
"next_after": "2",
|
|
2465
|
+
},
|
|
2466
|
+
},
|
|
2467
|
+
{
|
|
2468
|
+
"checkpoint_complete": {
|
|
2469
|
+
"last_op_id": "2",
|
|
2470
|
+
},
|
|
2471
|
+
},
|
|
2472
|
+
]
|
|
2473
|
+
`;
|
|
2474
|
+
|
|
2193
2475
|
exports[`sync - postgres > storage v3 > compacting data - invalidate checkpoint 1`] = `
|
|
2194
2476
|
[
|
|
2195
2477
|
{
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
|
2
|
-
import { POSTGRES_REPORT_STORAGE_FACTORY } from './util.js';
|
|
3
|
-
import { event_types } from '@powersync/service-types';
|
|
4
1
|
import { register, ReportUserData } from '@powersync/service-core-tests';
|
|
5
|
-
import { PostgresReportStorage } from '../../src/storage/PostgresReportStorage.js';
|
|
6
2
|
import { DateTimeValue } from '@powersync/service-sync-rules';
|
|
3
|
+
import { event_types } from '@powersync/service-types';
|
|
4
|
+
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
|
5
|
+
import { PostgresReportStorage } from '../../src/storage/PostgresReportStorage.js';
|
|
6
|
+
import { POSTGRES_REPORT_STORAGE_FACTORY } from './util.js';
|
|
7
7
|
|
|
8
8
|
const factory = await POSTGRES_REPORT_STORAGE_FACTORY();
|
|
9
9
|
const userData = register.REPORT_TEST_USERS;
|
|
@@ -223,7 +223,7 @@ describe('Connection report storage', async () => {
|
|
|
223
223
|
await factory.deleteOldConnectionData({
|
|
224
224
|
date: dates.weekAgo
|
|
225
225
|
});
|
|
226
|
-
const sdk = await factory.
|
|
226
|
+
const sdk = await factory.getClientConnectionReports({
|
|
227
227
|
start: dates.monthAgo,
|
|
228
228
|
end: dates.now
|
|
229
229
|
});
|
package/test/src/setup.ts
CHANGED
package/test/tsconfig.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { storage } from '@powersync/service-core';
|
|
2
|
-
export declare const V1_CURRENT_DATA_TABLE = "current_data";
|
|
3
|
-
export declare const V3_CURRENT_DATA_TABLE = "v3_current_data";
|
|
4
|
-
/**
|
|
5
|
-
* The table used by a specific storage version for general current_data access.
|
|
6
|
-
*/
|
|
7
|
-
export declare function getCommonCurrentDataTable(storageConfig: storage.StorageVersionConfig): "current_data" | "v3_current_data";
|
|
8
|
-
export declare function getV1CurrentDataTable(storageConfig: storage.StorageVersionConfig): string;
|
|
9
|
-
export declare function getV3CurrentDataTable(storageConfig: storage.StorageVersionConfig): string;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ServiceAssertionError } from '@powersync/lib-services-framework';
|
|
2
|
-
export const V1_CURRENT_DATA_TABLE = 'current_data';
|
|
3
|
-
export const V3_CURRENT_DATA_TABLE = 'v3_current_data';
|
|
4
|
-
/**
|
|
5
|
-
* The table used by a specific storage version for general current_data access.
|
|
6
|
-
*/
|
|
7
|
-
export function getCommonCurrentDataTable(storageConfig) {
|
|
8
|
-
return storageConfig.softDeleteCurrentData ? V3_CURRENT_DATA_TABLE : V1_CURRENT_DATA_TABLE;
|
|
9
|
-
}
|
|
10
|
-
export function getV1CurrentDataTable(storageConfig) {
|
|
11
|
-
if (storageConfig.softDeleteCurrentData) {
|
|
12
|
-
throw new ServiceAssertionError('current_data table cannot be used when softDeleteCurrentData is enabled');
|
|
13
|
-
}
|
|
14
|
-
return V1_CURRENT_DATA_TABLE;
|
|
15
|
-
}
|
|
16
|
-
export function getV3CurrentDataTable(storageConfig) {
|
|
17
|
-
if (!storageConfig.softDeleteCurrentData) {
|
|
18
|
-
throw new ServiceAssertionError('v3_current_data table cannot be used when softDeleteCurrentData is disabled');
|
|
19
|
-
}
|
|
20
|
-
return V3_CURRENT_DATA_TABLE;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=current-data-table.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"current-data-table.js","sourceRoot":"","sources":["../../src/storage/current-data-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAG1E,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC;AACpD,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEvD;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,aAA2C;IACnF,OAAO,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,qBAAqB,CAAC;AAC7F,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,aAA2C;IAC/E,IAAI,aAAa,CAAC,qBAAqB,EAAE,CAAC;QACxC,MAAM,IAAI,qBAAqB,CAAC,yEAAyE,CAAC,CAAC;IAC7G,CAAC;IACD,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,aAA2C;IAC/E,IAAI,CAAC,aAAa,CAAC,qBAAqB,EAAE,CAAC;QACzC,MAAM,IAAI,qBAAqB,CAAC,6EAA6E,CAAC,CAAC;IACjH,CAAC;IACD,OAAO,qBAAqB,CAAC;AAC/B,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ServiceAssertionError } from '@powersync/lib-services-framework';
|
|
2
|
-
import { storage } from '@powersync/service-core';
|
|
3
|
-
|
|
4
|
-
export const V1_CURRENT_DATA_TABLE = 'current_data';
|
|
5
|
-
export const V3_CURRENT_DATA_TABLE = 'v3_current_data';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The table used by a specific storage version for general current_data access.
|
|
9
|
-
*/
|
|
10
|
-
export function getCommonCurrentDataTable(storageConfig: storage.StorageVersionConfig) {
|
|
11
|
-
return storageConfig.softDeleteCurrentData ? V3_CURRENT_DATA_TABLE : V1_CURRENT_DATA_TABLE;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function getV1CurrentDataTable(storageConfig: storage.StorageVersionConfig) {
|
|
15
|
-
if (storageConfig.softDeleteCurrentData) {
|
|
16
|
-
throw new ServiceAssertionError('current_data table cannot be used when softDeleteCurrentData is enabled');
|
|
17
|
-
}
|
|
18
|
-
return V1_CURRENT_DATA_TABLE;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function getV3CurrentDataTable(storageConfig: storage.StorageVersionConfig) {
|
|
22
|
-
if (!storageConfig.softDeleteCurrentData) {
|
|
23
|
-
throw new ServiceAssertionError('v3_current_data table cannot be used when softDeleteCurrentData is disabled');
|
|
24
|
-
}
|
|
25
|
-
return V3_CURRENT_DATA_TABLE;
|
|
26
|
-
}
|