@powersync/service-module-postgres-storage 0.18.0 → 0.19.1
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 +51 -0
- package/dist/migrations/scripts/1788000000000-sync-config-version-label.d.ts +3 -0
- package/dist/migrations/scripts/1788000000000-sync-config-version-label.js +12 -0
- package/dist/migrations/scripts/1788000000000-sync-config-version-label.js.map +1 -0
- package/dist/storage/PostgresBucketStorageFactory.d.ts +1 -0
- package/dist/storage/PostgresBucketStorageFactory.js +14 -7
- package/dist/storage/PostgresBucketStorageFactory.js.map +1 -1
- package/dist/storage/PostgresStorageProvider.js +2 -1
- package/dist/storage/PostgresStorageProvider.js.map +1 -1
- package/dist/storage/PostgresSyncRulesStorage.d.ts +4 -3
- package/dist/storage/PostgresSyncRulesStorage.js +17 -5
- package/dist/storage/PostgresSyncRulesStorage.js.map +1 -1
- package/dist/storage/batch/PostgresBucketBatch.d.ts +2 -2
- package/dist/storage/batch/PostgresBucketBatch.js +8 -5
- package/dist/storage/batch/PostgresBucketBatch.js.map +1 -1
- package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.d.ts +1 -1
- package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js +2 -2
- package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js.map +1 -1
- package/dist/storage/sync-rules/PostgresPersistedSyncConfigContent.js +5 -1
- package/dist/storage/sync-rules/PostgresPersistedSyncConfigContent.js.map +1 -1
- package/dist/types/models/ActiveCheckpoint.d.ts +2 -2
- package/dist/types/models/ActiveCheckpoint.js +3 -2
- package/dist/types/models/ActiveCheckpoint.js.map +1 -1
- package/dist/types/models/ActiveCheckpointNotification.d.ts +2 -2
- package/dist/types/models/BucketData.d.ts +6 -6
- package/dist/types/models/BucketData.js +7 -6
- package/dist/types/models/BucketData.js.map +1 -1
- package/dist/types/models/CurrentData.d.ts +1 -1
- package/dist/types/models/CurrentData.js +2 -1
- package/dist/types/models/CurrentData.js.map +1 -1
- package/dist/types/models/SdkReporting.d.ts +3 -3
- package/dist/types/models/SdkReporting.js +3 -5
- package/dist/types/models/SdkReporting.js.map +1 -1
- package/dist/types/models/SourceTable.d.ts +7 -7
- package/dist/types/models/SourceTable.js +7 -6
- package/dist/types/models/SourceTable.js.map +1 -1
- package/dist/types/models/SyncRules.d.ts +11 -10
- package/dist/types/models/SyncRules.js +12 -11
- package/dist/types/models/SyncRules.js.map +1 -1
- package/dist/types/models/WriteCheckpoint.d.ts +2 -2
- package/dist/types/models/WriteCheckpoint.js +3 -2
- package/dist/types/models/WriteCheckpoint.js.map +1 -1
- package/dist/types/types.d.ts +2 -0
- package/package.json +8 -8
- package/src/migrations/scripts/1788000000000-sync-config-version-label.ts +18 -0
- package/src/storage/PostgresBucketStorageFactory.ts +15 -7
- package/src/storage/PostgresStorageProvider.ts +2 -1
- package/src/storage/PostgresSyncRulesStorage.ts +21 -6
- package/src/storage/batch/PostgresBucketBatch.ts +9 -6
- package/src/storage/checkpoints/PostgresWriteCheckpointAPI.ts +2 -2
- package/src/storage/sync-rules/PostgresPersistedSyncConfigContent.ts +8 -1
- package/src/types/models/ActiveCheckpoint.ts +3 -2
- package/src/types/models/BucketData.ts +7 -6
- package/src/types/models/CurrentData.ts +2 -1
- package/src/types/models/SdkReporting.ts +4 -4
- package/src/types/models/SourceTable.ts +7 -6
- package/src/types/models/SyncRules.ts +12 -11
- package/src/types/models/WriteCheckpoint.ts +3 -2
- package/test/src/__snapshots__/storage_sync.test.ts.snap +0 -995
- package/test/src/checkpoint_notifications.test.ts +8 -2
- package/test/src/storage.test.ts +12 -4
- package/test/src/storage_compacting.test.ts +2 -2
- package/test/src/util.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -44,7 +44,10 @@ bucket_definitions:
|
|
|
44
44
|
const abortController = new AbortController();
|
|
45
45
|
context.onTestFinished(() => abortController.abort());
|
|
46
46
|
const iterator = bucketStorage
|
|
47
|
-
.watchCheckpointChanges({
|
|
47
|
+
.watchCheckpointChanges({
|
|
48
|
+
user_id: 'user',
|
|
49
|
+
signal: abortController.signal
|
|
50
|
+
})
|
|
48
51
|
[Symbol.asyncIterator]();
|
|
49
52
|
|
|
50
53
|
await expect(
|
|
@@ -149,7 +152,10 @@ bucket_definitions:
|
|
|
149
152
|
const abortController = new AbortController();
|
|
150
153
|
context.onTestFinished(() => abortController.abort());
|
|
151
154
|
const iterator = bucketStorage
|
|
152
|
-
.watchCheckpointChanges({
|
|
155
|
+
.watchCheckpointChanges({
|
|
156
|
+
user_id: 'user',
|
|
157
|
+
signal: abortController.signal
|
|
158
|
+
})
|
|
153
159
|
[Symbol.asyncIterator]();
|
|
154
160
|
|
|
155
161
|
await expect(
|
package/test/src/storage.test.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { framework, storage, updateSyncRulesFromYaml } from '@powersync/service-core';
|
|
2
|
-
import { bucketRequest, register, test_utils } from '@powersync/service-core-tests';
|
|
2
|
+
import { bucketRequest, compactActive, register, test_utils } from '@powersync/service-core-tests';
|
|
3
|
+
import { orNull } from '@powersync/service-types';
|
|
3
4
|
import * as t from 'ts-codec';
|
|
4
5
|
import { describe, expect, test } from 'vitest';
|
|
5
6
|
import { CLEAR_BATCH_LIMIT } from '../../src/storage/PostgresSyncRulesStorage.js';
|
|
6
7
|
import { POSTGRES_STORAGE_FACTORY, TEST_STORAGE_VERSIONS } from './util.js';
|
|
7
8
|
|
|
8
9
|
const CheckpointRequestedAtRow = t.object({
|
|
9
|
-
checkpoint_requested_at:
|
|
10
|
+
checkpoint_requested_at: orNull(framework.codecs.date)
|
|
10
11
|
});
|
|
11
12
|
|
|
12
13
|
describe('Sync Bucket Validation', register.registerBucketValidationTests);
|
|
@@ -105,7 +106,12 @@ bucket_definitions:
|
|
|
105
106
|
WHERE
|
|
106
107
|
user_id = 'user2'
|
|
107
108
|
`.execute();
|
|
108
|
-
|
|
109
|
+
{
|
|
110
|
+
await using activationWriter = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
111
|
+
await activationWriter.markAllSnapshotDone('1/1');
|
|
112
|
+
await activationWriter.keepalive('1/1');
|
|
113
|
+
}
|
|
114
|
+
await compactActive(factory, {
|
|
109
115
|
compactBuckets: [],
|
|
110
116
|
deleteCheckpointRequestsBefore: new Date('2024-02-01T00:00:00.000Z')
|
|
111
117
|
});
|
|
@@ -126,7 +132,9 @@ bucket_definitions:
|
|
|
126
132
|
.first()
|
|
127
133
|
)?.checkpoint_requested_at;
|
|
128
134
|
|
|
129
|
-
bucketStorage.setWriteCheckpointMode(
|
|
135
|
+
bucketStorage.setWriteCheckpointMode({
|
|
136
|
+
mode: storage.WriteCheckpointMode.CUSTOM
|
|
137
|
+
});
|
|
130
138
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
131
139
|
await writer.markAllSnapshotDone('1/1');
|
|
132
140
|
const customCheckpointRequestedAt = new Date('2024-01-01T00:00:00.000Z');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { storage, updateSyncRulesFromYaml } from '@powersync/service-core';
|
|
2
|
-
import { bucketRequest, register, test_utils } from '@powersync/service-core-tests';
|
|
2
|
+
import { bucketRequest, compactActive, register, test_utils } from '@powersync/service-core-tests';
|
|
3
3
|
import { describe, expect, test } from 'vitest';
|
|
4
4
|
import { PostgresCompactor } from '../../src/storage/PostgresCompactor.js';
|
|
5
5
|
import { POSTGRES_STORAGE_FACTORY } from './util.js';
|
|
@@ -44,7 +44,7 @@ bucket_definitions:
|
|
|
44
44
|
|
|
45
45
|
// Compact with an explicit bucket name — exercises the this.buckets
|
|
46
46
|
// iteration path, NOT the compactAllBuckets discovery path.
|
|
47
|
-
await
|
|
47
|
+
await compactActive(factory, {
|
|
48
48
|
compactBuckets: [bucketRequest(syncRulesContent, 'global[]').bucket],
|
|
49
49
|
minBucketChanges: 1
|
|
50
50
|
});
|
package/test/src/util.ts
CHANGED
|
@@ -36,4 +36,4 @@ export const POSTGRES_STORAGE_SETUP = postgresTestSetup({
|
|
|
36
36
|
export const POSTGRES_STORAGE_FACTORY = POSTGRES_STORAGE_SETUP;
|
|
37
37
|
export const POSTGRES_REPORT_STORAGE_FACTORY = POSTGRES_STORAGE_SETUP.reportFactory;
|
|
38
38
|
|
|
39
|
-
export const TEST_STORAGE_VERSIONS = SUPPORTED_STORAGE_VERSIONS;
|
|
39
|
+
export const TEST_STORAGE_VERSIONS = SUPPORTED_STORAGE_VERSIONS.filter((v) => v < 3);
|