@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.
Files changed (83) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/{@types/storage → storage}/PostgresBucketStorageFactory.d.ts +12 -12
  3. package/dist/storage/PostgresBucketStorageFactory.js +57 -52
  4. package/dist/storage/PostgresBucketStorageFactory.js.map +1 -1
  5. package/dist/storage/PostgresReportStorage.js.map +1 -1
  6. package/dist/storage/PostgresStorageProvider.js +1 -1
  7. package/dist/storage/PostgresStorageProvider.js.map +1 -1
  8. package/dist/{@types/storage → storage}/PostgresSyncRulesStorage.d.ts +16 -8
  9. package/dist/storage/PostgresSyncRulesStorage.js +48 -196
  10. package/dist/storage/PostgresSyncRulesStorage.js.map +1 -1
  11. package/dist/{@types/storage → storage}/batch/PostgresBucketBatch.d.ts +13 -5
  12. package/dist/storage/batch/PostgresBucketBatch.js +280 -29
  13. package/dist/storage/batch/PostgresBucketBatch.js.map +1 -1
  14. package/dist/{@types/storage → storage}/storage-index.d.ts +1 -0
  15. package/dist/storage/storage-index.js +1 -0
  16. package/dist/storage/storage-index.js.map +1 -1
  17. package/dist/storage/sync-rules/PostgresPersistedSyncConfigContent.d.ts +17 -0
  18. package/dist/storage/sync-rules/PostgresPersistedSyncConfigContent.js +89 -0
  19. package/dist/storage/sync-rules/PostgresPersistedSyncConfigContent.js.map +1 -0
  20. package/dist/utils/test-utils.js +2 -2
  21. package/dist/utils/test-utils.js.map +1 -1
  22. package/package.json +10 -22
  23. package/src/storage/PostgresBucketStorageFactory.ts +64 -54
  24. package/src/storage/PostgresReportStorage.ts +1 -2
  25. package/src/storage/PostgresStorageProvider.ts +1 -1
  26. package/src/storage/PostgresSyncRulesStorage.ts +51 -211
  27. package/src/storage/batch/PostgresBucketBatch.ts +325 -45
  28. package/src/storage/storage-index.ts +1 -0
  29. package/src/storage/sync-rules/PostgresPersistedSyncConfigContent.ts +97 -0
  30. package/src/utils/test-utils.ts +2 -2
  31. package/test/src/migrations.test.ts +1 -1
  32. package/test/src/storage.test.ts +7 -2
  33. package/test/src/storage_compacting.test.ts +6 -4
  34. package/test/src/storage_sync.test.ts +2 -1
  35. package/test/tsconfig.json +0 -2
  36. package/tsconfig.json +1 -4
  37. package/tsconfig.tsbuildinfo +1 -0
  38. package/dist/.tsbuildinfo +0 -1
  39. package/dist/@types/storage/sync-rules/PostgresPersistedSyncRulesContent.d.ts +0 -9
  40. package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js +0 -49
  41. package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js.map +0 -1
  42. package/src/storage/sync-rules/PostgresPersistedSyncRulesContent.ts +0 -54
  43. /package/dist/{@types/index.d.ts → index.d.ts} +0 -0
  44. /package/dist/{@types/migrations → migrations}/PostgresMigrationAgent.d.ts +0 -0
  45. /package/dist/{@types/migrations → migrations}/PostgresMigrationStore.d.ts +0 -0
  46. /package/dist/{@types/migrations → migrations}/migration-utils.d.ts +0 -0
  47. /package/dist/{@types/migrations → migrations}/scripts/1684951997326-init.d.ts +0 -0
  48. /package/dist/{@types/migrations → migrations}/scripts/1749024804042-snapshot-progress.d.ts +0 -0
  49. /package/dist/{@types/migrations → migrations}/scripts/1756282360128-connection-reporting.d.ts +0 -0
  50. /package/dist/{@types/migrations → migrations}/scripts/1771232439485-storage-version.d.ts +0 -0
  51. /package/dist/{@types/migrations → migrations}/scripts/1771424826685-current-data-pending-deletes.d.ts +0 -0
  52. /package/dist/{@types/migrations → migrations}/scripts/1771491856000-sync-plan.d.ts +0 -0
  53. /package/dist/{@types/module → module}/PostgresStorageModule.d.ts +0 -0
  54. /package/dist/{@types/storage → storage}/PostgresCompactor.d.ts +0 -0
  55. /package/dist/{@types/storage → storage}/PostgresReportStorage.d.ts +0 -0
  56. /package/dist/{@types/storage → storage}/PostgresStorageProvider.d.ts +0 -0
  57. /package/dist/{@types/storage → storage}/batch/OperationBatch.d.ts +0 -0
  58. /package/dist/{@types/storage → storage}/batch/PostgresPersistedBatch.d.ts +0 -0
  59. /package/dist/{@types/storage → storage}/checkpoints/PostgresWriteCheckpointAPI.d.ts +0 -0
  60. /package/dist/{@types/storage → storage}/current-data-store.d.ts +0 -0
  61. /package/dist/{@types/storage → storage}/table-id.d.ts +0 -0
  62. /package/dist/{@types/types → types}/codecs.d.ts +0 -0
  63. /package/dist/{@types/types → types}/models/ActiveCheckpoint.d.ts +0 -0
  64. /package/dist/{@types/types → types}/models/ActiveCheckpointNotification.d.ts +0 -0
  65. /package/dist/{@types/types → types}/models/BucketData.d.ts +0 -0
  66. /package/dist/{@types/types → types}/models/BucketParameters.d.ts +0 -0
  67. /package/dist/{@types/types → types}/models/CurrentData.d.ts +0 -0
  68. /package/dist/{@types/types → types}/models/Instance.d.ts +0 -0
  69. /package/dist/{@types/types → types}/models/Migration.d.ts +0 -0
  70. /package/dist/{@types/types → types}/models/SdkReporting.d.ts +0 -0
  71. /package/dist/{@types/types → types}/models/SourceTable.d.ts +0 -0
  72. /package/dist/{@types/types → types}/models/SyncRules.d.ts +0 -0
  73. /package/dist/{@types/types → types}/models/WriteCheckpoint.d.ts +0 -0
  74. /package/dist/{@types/types → types}/models/json.d.ts +0 -0
  75. /package/dist/{@types/types → types}/models/models-index.d.ts +0 -0
  76. /package/dist/{@types/types → types}/types.d.ts +0 -0
  77. /package/dist/{@types/utils → utils}/application-name.d.ts +0 -0
  78. /package/dist/{@types/utils → utils}/bson.d.ts +0 -0
  79. /package/dist/{@types/utils → utils}/bucket-data.d.ts +0 -0
  80. /package/dist/{@types/utils → utils}/db.d.ts +0 -0
  81. /package/dist/{@types/utils → utils}/test-utils.d.ts +0 -0
  82. /package/dist/{@types/utils → utils}/ts-codec.d.ts +0 -0
  83. /package/dist/{@types/utils → utils}/utils-index.d.ts +0 -0
@@ -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({ ...POSTGRES_STORAGE_FACTORY, storageVersion }));
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 globalBucket = bucketRequest(syncRules, 'global[]');
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(syncRules, 'global[]').bucket],
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(syncRules, 'global[]', 0n)])
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 request = bucketRequest(syncRules, 'global[]');
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.group_id, {});
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 globalBucket = bucketRequest(syncRules, 'global[]');
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
 
@@ -1,8 +1,6 @@
1
1
  {
2
2
  "extends": "../../../tsconfig.tests.json",
3
3
  "compilerOptions": {
4
- "declarationDir": "dist/@types",
5
- "tsBuildInfoFile": "dist/.tsbuildinfo",
6
4
  "lib": ["ES2022", "esnext.disposable"],
7
5
  "rootDir": "src"
8
6
  },
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
- "skipLibCheck": true
5
+ "outDir": "dist"
9
6
  },
10
7
  "include": ["src"],
11
8
  "references": [