@powersync/service-module-postgres-storage 0.14.0 → 0.16.0
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 +53 -0
- package/dist/{@types/storage → storage}/PostgresBucketStorageFactory.d.ts +12 -12
- package/dist/storage/PostgresBucketStorageFactory.js +57 -52
- package/dist/storage/PostgresBucketStorageFactory.js.map +1 -1
- package/dist/storage/PostgresReportStorage.js.map +1 -1
- package/dist/storage/PostgresStorageProvider.js +1 -1
- package/dist/storage/PostgresStorageProvider.js.map +1 -1
- package/dist/{@types/storage → storage}/PostgresSyncRulesStorage.d.ts +16 -8
- package/dist/storage/PostgresSyncRulesStorage.js +48 -196
- package/dist/storage/PostgresSyncRulesStorage.js.map +1 -1
- package/dist/{@types/storage → storage}/batch/PostgresBucketBatch.d.ts +13 -5
- package/dist/storage/batch/PostgresBucketBatch.js +280 -29
- package/dist/storage/batch/PostgresBucketBatch.js.map +1 -1
- package/dist/{@types/storage → storage}/storage-index.d.ts +1 -0
- package/dist/storage/storage-index.js +1 -0
- package/dist/storage/storage-index.js.map +1 -1
- package/dist/storage/sync-rules/PostgresPersistedSyncConfigContent.d.ts +17 -0
- package/dist/storage/sync-rules/PostgresPersistedSyncConfigContent.js +89 -0
- package/dist/storage/sync-rules/PostgresPersistedSyncConfigContent.js.map +1 -0
- package/dist/utils/test-utils.js +2 -2
- package/dist/utils/test-utils.js.map +1 -1
- package/package.json +10 -22
- package/src/storage/PostgresBucketStorageFactory.ts +64 -54
- package/src/storage/PostgresReportStorage.ts +1 -2
- package/src/storage/PostgresStorageProvider.ts +1 -1
- package/src/storage/PostgresSyncRulesStorage.ts +51 -211
- package/src/storage/batch/PostgresBucketBatch.ts +325 -45
- package/src/storage/storage-index.ts +1 -0
- package/src/storage/sync-rules/PostgresPersistedSyncConfigContent.ts +97 -0
- package/src/utils/test-utils.ts +2 -2
- package/test/src/migrations.test.ts +1 -1
- package/test/src/storage.test.ts +7 -2
- package/test/src/storage_compacting.test.ts +6 -4
- package/test/src/storage_sync.test.ts +2 -1
- package/test/tsconfig.json +0 -2
- package/tsconfig.json +1 -4
- package/tsconfig.tsbuildinfo +1 -0
- package/dist/.tsbuildinfo +0 -1
- package/dist/@types/storage/sync-rules/PostgresPersistedSyncRulesContent.d.ts +0 -9
- package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js +0 -49
- package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js.map +0 -1
- package/src/storage/sync-rules/PostgresPersistedSyncRulesContent.ts +0 -54
- /package/dist/{@types/index.d.ts → index.d.ts} +0 -0
- /package/dist/{@types/migrations → migrations}/PostgresMigrationAgent.d.ts +0 -0
- /package/dist/{@types/migrations → migrations}/PostgresMigrationStore.d.ts +0 -0
- /package/dist/{@types/migrations → migrations}/migration-utils.d.ts +0 -0
- /package/dist/{@types/migrations → migrations}/scripts/1684951997326-init.d.ts +0 -0
- /package/dist/{@types/migrations → migrations}/scripts/1749024804042-snapshot-progress.d.ts +0 -0
- /package/dist/{@types/migrations → migrations}/scripts/1756282360128-connection-reporting.d.ts +0 -0
- /package/dist/{@types/migrations → migrations}/scripts/1771232439485-storage-version.d.ts +0 -0
- /package/dist/{@types/migrations → migrations}/scripts/1771424826685-current-data-pending-deletes.d.ts +0 -0
- /package/dist/{@types/migrations → migrations}/scripts/1771491856000-sync-plan.d.ts +0 -0
- /package/dist/{@types/module → module}/PostgresStorageModule.d.ts +0 -0
- /package/dist/{@types/storage → storage}/PostgresCompactor.d.ts +0 -0
- /package/dist/{@types/storage → storage}/PostgresReportStorage.d.ts +0 -0
- /package/dist/{@types/storage → storage}/PostgresStorageProvider.d.ts +0 -0
- /package/dist/{@types/storage → storage}/batch/OperationBatch.d.ts +0 -0
- /package/dist/{@types/storage → storage}/batch/PostgresPersistedBatch.d.ts +0 -0
- /package/dist/{@types/storage → storage}/checkpoints/PostgresWriteCheckpointAPI.d.ts +0 -0
- /package/dist/{@types/storage → storage}/current-data-store.d.ts +0 -0
- /package/dist/{@types/storage → storage}/table-id.d.ts +0 -0
- /package/dist/{@types/types → types}/codecs.d.ts +0 -0
- /package/dist/{@types/types → types}/models/ActiveCheckpoint.d.ts +0 -0
- /package/dist/{@types/types → types}/models/ActiveCheckpointNotification.d.ts +0 -0
- /package/dist/{@types/types → types}/models/BucketData.d.ts +0 -0
- /package/dist/{@types/types → types}/models/BucketParameters.d.ts +0 -0
- /package/dist/{@types/types → types}/models/CurrentData.d.ts +0 -0
- /package/dist/{@types/types → types}/models/Instance.d.ts +0 -0
- /package/dist/{@types/types → types}/models/Migration.d.ts +0 -0
- /package/dist/{@types/types → types}/models/SdkReporting.d.ts +0 -0
- /package/dist/{@types/types → types}/models/SourceTable.d.ts +0 -0
- /package/dist/{@types/types → types}/models/SyncRules.d.ts +0 -0
- /package/dist/{@types/types → types}/models/WriteCheckpoint.d.ts +0 -0
- /package/dist/{@types/types → types}/models/json.d.ts +0 -0
- /package/dist/{@types/types → types}/models/models-index.d.ts +0 -0
- /package/dist/{@types/types → types}/types.d.ts +0 -0
- /package/dist/{@types/utils → utils}/application-name.d.ts +0 -0
- /package/dist/{@types/utils → utils}/bson.d.ts +0 -0
- /package/dist/{@types/utils → utils}/bucket-data.d.ts +0 -0
- /package/dist/{@types/utils → utils}/db.d.ts +0 -0
- /package/dist/{@types/utils → utils}/test-utils.d.ts +0 -0
- /package/dist/{@types/utils → utils}/ts-codec.d.ts +0 -0
- /package/dist/{@types/utils → utils}/utils-index.d.ts +0 -0
package/test/src/storage.test.ts
CHANGED
|
@@ -10,7 +10,11 @@ for (let storageVersion of TEST_STORAGE_VERSIONS) {
|
|
|
10
10
|
register.registerDataStorageParameterTests({ ...POSTGRES_STORAGE_FACTORY, storageVersion }));
|
|
11
11
|
|
|
12
12
|
describe(`Postgres Sync Bucket Storage - Data - v${storageVersion}`, () =>
|
|
13
|
-
register.registerDataStorageDataTests({
|
|
13
|
+
register.registerDataStorageDataTests({
|
|
14
|
+
...POSTGRES_STORAGE_FACTORY,
|
|
15
|
+
storageVersion,
|
|
16
|
+
compressedBucketStorage: false
|
|
17
|
+
}));
|
|
14
18
|
|
|
15
19
|
describe(`Postgres Sync Bucket Storage - Checkpoints - v${storageVersion}`, () =>
|
|
16
20
|
register.registerDataStorageCheckpointTests({ ...POSTGRES_STORAGE_FACTORY, storageVersion }));
|
|
@@ -39,7 +43,8 @@ for (let storageVersion of TEST_STORAGE_VERSIONS) {
|
|
|
39
43
|
)
|
|
40
44
|
);
|
|
41
45
|
const bucketStorage = factory.getInstance(syncRules);
|
|
42
|
-
const
|
|
46
|
+
const syncRulesContent = syncRules.syncConfigContent[0];
|
|
47
|
+
const globalBucket = bucketRequest(syncRulesContent, 'global[]');
|
|
43
48
|
|
|
44
49
|
const result = await (async () => {
|
|
45
50
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
@@ -17,6 +17,7 @@ bucket_definitions:
|
|
|
17
17
|
`)
|
|
18
18
|
);
|
|
19
19
|
const bucketStorage = factory.getInstance(syncRules);
|
|
20
|
+
const syncRulesContent = syncRules.syncConfigContent[0];
|
|
20
21
|
|
|
21
22
|
const result = await (async () => {
|
|
22
23
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
@@ -44,12 +45,12 @@ bucket_definitions:
|
|
|
44
45
|
// Compact with an explicit bucket name — exercises the this.buckets
|
|
45
46
|
// iteration path, NOT the compactAllBuckets discovery path.
|
|
46
47
|
await bucketStorage.compact({
|
|
47
|
-
compactBuckets: [bucketRequest(
|
|
48
|
+
compactBuckets: [bucketRequest(syncRulesContent, 'global[]').bucket],
|
|
48
49
|
minBucketChanges: 1
|
|
49
50
|
});
|
|
50
51
|
|
|
51
52
|
const batch = await test_utils.oneFromAsync(
|
|
52
|
-
bucketStorage.getBucketDataBatch(checkpoint, [bucketRequest(
|
|
53
|
+
bucketStorage.getBucketDataBatch(checkpoint, [bucketRequest(syncRulesContent, 'global[]', 0n)])
|
|
53
54
|
);
|
|
54
55
|
|
|
55
56
|
expect(batch.chunkData.data).toMatchObject([
|
|
@@ -70,7 +71,8 @@ bucket_definitions:
|
|
|
70
71
|
`)
|
|
71
72
|
);
|
|
72
73
|
const bucketStorage = factory.getInstance(syncRules);
|
|
73
|
-
const
|
|
74
|
+
const syncRulesContent = syncRules.syncConfigContent[0];
|
|
75
|
+
const request = bucketRequest(syncRulesContent, 'global[]');
|
|
74
76
|
|
|
75
77
|
const result = await (async () => {
|
|
76
78
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
@@ -110,7 +112,7 @@ bucket_definitions:
|
|
|
110
112
|
const dataBefore = test_utils.getBatchData(rowsBefore);
|
|
111
113
|
const clearToOpId = BigInt(dataBefore[2].op_id);
|
|
112
114
|
|
|
113
|
-
const compactor = new PostgresCompactor(factory.db, bucketStorage.
|
|
115
|
+
const compactor = new PostgresCompactor(factory.db, bucketStorage.replicationStreamId, {});
|
|
114
116
|
// Trigger the private method directly
|
|
115
117
|
await expect(compactor.clearBucketForTests(request.bucket, clearToOpId)).rejects.toThrow(
|
|
116
118
|
/Unexpected PUT operation/
|
|
@@ -34,7 +34,8 @@ function registerStorageVersionTests(storageVersion: number) {
|
|
|
34
34
|
)
|
|
35
35
|
);
|
|
36
36
|
const bucketStorage = factory.getInstance(syncRules);
|
|
37
|
-
const
|
|
37
|
+
const syncRulesContent = syncRules.syncConfigContent[0];
|
|
38
|
+
const globalBucket = bucketRequest(syncRulesContent, 'global[]');
|
|
38
39
|
|
|
39
40
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
40
41
|
|
package/test/tsconfig.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../tsconfig.base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"outDir": "dist",
|
|
5
|
-
"declarationDir": "dist/@types",
|
|
6
|
-
"tsBuildInfoFile": "dist/.tsbuildinfo",
|
|
7
4
|
"rootDir": "src",
|
|
8
|
-
"
|
|
5
|
+
"outDir": "dist"
|
|
9
6
|
},
|
|
10
7
|
"include": ["src"],
|
|
11
8
|
"references": [
|