@powersync/service-module-postgres-storage 0.7.4 → 0.8.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 +37 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/migrations/scripts/1749024804042-snapshot-progress.d.ts +3 -0
- package/dist/@types/storage/PostgresSyncRulesStorage.d.ts +1 -2
- package/dist/@types/storage/PostgresTestStorageFactoryGenerator.d.ts +5 -1
- package/dist/@types/storage/batch/PostgresBucketBatch.d.ts +8 -2
- package/dist/@types/storage/checkpoints/PostgresWriteCheckpointAPI.d.ts +2 -3
- package/dist/@types/storage/sync-rules/PostgresPersistedSyncRulesContent.d.ts +1 -0
- package/dist/@types/types/models/SourceTable.d.ts +3 -0
- package/dist/@types/types/models/SyncRules.d.ts +4 -0
- package/dist/migrations/scripts/1684951997326-init.js.map +1 -1
- package/dist/migrations/scripts/1749024804042-snapshot-progress.js +110 -0
- package/dist/migrations/scripts/1749024804042-snapshot-progress.js.map +1 -0
- package/dist/storage/PostgresSyncRulesStorage.js +17 -8
- package/dist/storage/PostgresSyncRulesStorage.js.map +1 -1
- package/dist/storage/PostgresTestStorageFactoryGenerator.js +48 -37
- package/dist/storage/PostgresTestStorageFactoryGenerator.js.map +1 -1
- package/dist/storage/batch/PostgresBucketBatch.js +62 -13
- package/dist/storage/batch/PostgresBucketBatch.js.map +1 -1
- package/dist/storage/batch/PostgresPersistedBatch.js +1 -1
- package/dist/storage/batch/PostgresPersistedBatch.js.map +1 -1
- package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js +1 -5
- package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js.map +1 -1
- package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js +2 -0
- package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js.map +1 -1
- package/dist/types/models/SourceTable.js +5 -2
- package/dist/types/models/SourceTable.js.map +1 -1
- package/dist/types/models/SyncRules.js +4 -0
- package/dist/types/models/SyncRules.js.map +1 -1
- package/package.json +8 -8
- package/src/migrations/scripts/1684951997326-init.ts +0 -1
- package/src/migrations/scripts/1749024804042-snapshot-progress.ts +43 -0
- package/src/storage/PostgresSyncRulesStorage.ts +17 -11
- package/src/storage/PostgresTestStorageFactoryGenerator.ts +48 -36
- package/src/storage/batch/PostgresBucketBatch.ts +76 -16
- package/src/storage/batch/PostgresPersistedBatch.ts +1 -1
- package/src/storage/checkpoints/PostgresWriteCheckpointAPI.ts +5 -10
- package/src/storage/sync-rules/PostgresPersistedSyncRulesContent.ts +2 -0
- package/src/types/models/SourceTable.ts +5 -2
- package/src/types/models/SyncRules.ts +4 -0
- package/test/src/__snapshots__/storage_sync.test.ts.snap +147 -0
- package/test/src/migrations.test.ts +10 -2
- package/test/src/util.ts +7 -2
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
1
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
2
2
|
|
|
3
|
+
import { Direction } from '@powersync/lib-services-framework';
|
|
3
4
|
import { register } from '@powersync/service-core-tests';
|
|
4
5
|
import { PostgresMigrationAgent } from '../../src/migrations/PostgresMigrationAgent.js';
|
|
5
6
|
import { env } from './env.js';
|
|
6
|
-
import { POSTGRES_STORAGE_FACTORY } from './util.js';
|
|
7
|
+
import { POSTGRES_STORAGE_FACTORY, POSTGRES_STORAGE_SETUP } from './util.js';
|
|
7
8
|
|
|
8
9
|
const MIGRATION_AGENT_FACTORY = () => {
|
|
9
10
|
return new PostgresMigrationAgent({ type: 'postgresql', uri: env.PG_STORAGE_TEST_URL, sslmode: 'disable' });
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
describe('Migrations', () => {
|
|
14
|
+
beforeEach(async () => {
|
|
15
|
+
// The migration tests clear the migration store, without running the down migrations.
|
|
16
|
+
// This ensures all the down migrations have been run before.
|
|
17
|
+
const setup = POSTGRES_STORAGE_SETUP;
|
|
18
|
+
await setup.migrate(Direction.Down);
|
|
19
|
+
});
|
|
20
|
+
|
|
13
21
|
register.registerMigrationTests(MIGRATION_AGENT_FACTORY);
|
|
14
22
|
|
|
15
23
|
it('Should have tables declared', async () => {
|
package/test/src/util.ts
CHANGED
|
@@ -2,7 +2,10 @@ import path from 'path';
|
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
import { normalizePostgresStorageConfig } from '../../src//types/types.js';
|
|
4
4
|
import { PostgresMigrationAgent } from '../../src/migrations/PostgresMigrationAgent.js';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
postgresTestSetup,
|
|
7
|
+
PostgresTestStorageFactoryGenerator
|
|
8
|
+
} from '../../src/storage/PostgresTestStorageFactoryGenerator.js';
|
|
6
9
|
import { env } from './env.js';
|
|
7
10
|
|
|
8
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -28,7 +31,9 @@ class TestPostgresMigrationAgent extends PostgresMigrationAgent {
|
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
export const
|
|
34
|
+
export const POSTGRES_STORAGE_SETUP = postgresTestSetup({
|
|
32
35
|
url: env.PG_STORAGE_TEST_URL,
|
|
33
36
|
migrationAgent: (config) => new TestPostgresMigrationAgent(config)
|
|
34
37
|
});
|
|
38
|
+
|
|
39
|
+
export const POSTGRES_STORAGE_FACTORY = POSTGRES_STORAGE_SETUP.factory;
|