@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
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import * as lib_postgres from '@powersync/lib-service-postgres';
|
|
2
|
-
import { ErrorCode, ServiceError } from '@powersync/lib-services-framework';
|
|
3
|
-
import { storage } from '@powersync/service-core';
|
|
4
|
-
export class PostgresPersistedSyncRulesContent extends storage.PersistedSyncRulesContent {
|
|
5
|
-
db;
|
|
6
|
-
current_lock = null;
|
|
7
|
-
constructor(db, row) {
|
|
8
|
-
super({
|
|
9
|
-
id: Number(row.id),
|
|
10
|
-
sync_rules_content: row.content,
|
|
11
|
-
compiled_plan: row.sync_plan,
|
|
12
|
-
last_checkpoint_lsn: row.last_checkpoint_lsn,
|
|
13
|
-
slot_name: row.slot_name,
|
|
14
|
-
last_fatal_error: row.last_fatal_error,
|
|
15
|
-
last_checkpoint_ts: row.last_checkpoint_ts ? new Date(row.last_checkpoint_ts) : null,
|
|
16
|
-
last_keepalive_ts: row.last_keepalive_ts ? new Date(row.last_keepalive_ts) : null,
|
|
17
|
-
active: row.state == 'ACTIVE',
|
|
18
|
-
storageVersion: row.storage_version ?? storage.LEGACY_STORAGE_VERSION
|
|
19
|
-
});
|
|
20
|
-
this.db = db;
|
|
21
|
-
}
|
|
22
|
-
async lock() {
|
|
23
|
-
const manager = new lib_postgres.PostgresLockManager({
|
|
24
|
-
db: this.db,
|
|
25
|
-
name: `sync_rules_${this.id}_${this.slot_name}`
|
|
26
|
-
});
|
|
27
|
-
const lockHandle = await manager.acquire();
|
|
28
|
-
if (!lockHandle) {
|
|
29
|
-
throw new ServiceError(ErrorCode.PSYNC_S1003, `Replication stream is locked by another process, standing by.`);
|
|
30
|
-
}
|
|
31
|
-
const interval = setInterval(async () => {
|
|
32
|
-
try {
|
|
33
|
-
await lockHandle.refresh();
|
|
34
|
-
}
|
|
35
|
-
catch (e) {
|
|
36
|
-
this.logger.error('Failed to refresh lock', e);
|
|
37
|
-
clearInterval(interval);
|
|
38
|
-
}
|
|
39
|
-
}, 30_130);
|
|
40
|
-
return (this.current_lock = {
|
|
41
|
-
sync_rules_id: this.id,
|
|
42
|
-
release: async () => {
|
|
43
|
-
clearInterval(interval);
|
|
44
|
-
return lockHandle.release();
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=PostgresPersistedSyncRulesContent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresPersistedSyncRulesContent.js","sourceRoot":"","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ChD,CAAC,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3C,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,YAAY,CAAC,SAAS,CAAC,WAAW,EAAE,+DAA+D,CAAC,CAAC;QACjH,CAAC;QAED,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;YACtC,IAAI,CAAC;gBACH,MAAM,UAAU,CAAC,OAAO,EAAE,CAAC;YAC7B,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAC;gBAC/C,aAAa,CAAC,QAAQ,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC,EAAE,MAAM,CAAC,CAAC;QAEX,OAAO,CAAC,IAAI,CAAC,YAAY,GAAG;YAC1B,aAAa,EAAE,IAAI,CAAC,EAAE;YACtB,OAAO,EAAE,KAAK,IAAI,EAAE;gBAClB,aAAa,CAAC,QAAQ,CAAC,CAAC;gBACxB,OAAO,UAAU,CAAC,OAAO,EAAE,CAAC;YAC9B,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import * as lib_postgres from '@powersync/lib-service-postgres';
|
|
2
|
-
import { ErrorCode, ServiceError } from '@powersync/lib-services-framework';
|
|
3
|
-
import { storage } from '@powersync/service-core';
|
|
4
|
-
import { models } from '../../types/types.js';
|
|
5
|
-
|
|
6
|
-
export class PostgresPersistedSyncRulesContent extends storage.PersistedSyncRulesContent {
|
|
7
|
-
current_lock: storage.ReplicationLock | null = null;
|
|
8
|
-
|
|
9
|
-
constructor(
|
|
10
|
-
private db: lib_postgres.DatabaseClient,
|
|
11
|
-
row: models.SyncRulesDecoded
|
|
12
|
-
) {
|
|
13
|
-
super({
|
|
14
|
-
id: Number(row.id),
|
|
15
|
-
sync_rules_content: row.content,
|
|
16
|
-
compiled_plan: row.sync_plan,
|
|
17
|
-
last_checkpoint_lsn: row.last_checkpoint_lsn,
|
|
18
|
-
slot_name: row.slot_name,
|
|
19
|
-
last_fatal_error: row.last_fatal_error,
|
|
20
|
-
last_checkpoint_ts: row.last_checkpoint_ts ? new Date(row.last_checkpoint_ts) : null,
|
|
21
|
-
last_keepalive_ts: row.last_keepalive_ts ? new Date(row.last_keepalive_ts) : null,
|
|
22
|
-
active: row.state == 'ACTIVE',
|
|
23
|
-
storageVersion: row.storage_version ?? storage.LEGACY_STORAGE_VERSION
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async lock(): Promise<storage.ReplicationLock> {
|
|
28
|
-
const manager = new lib_postgres.PostgresLockManager({
|
|
29
|
-
db: this.db,
|
|
30
|
-
name: `sync_rules_${this.id}_${this.slot_name}`
|
|
31
|
-
});
|
|
32
|
-
const lockHandle = await manager.acquire();
|
|
33
|
-
if (!lockHandle) {
|
|
34
|
-
throw new ServiceError(ErrorCode.PSYNC_S1003, `Replication stream is locked by another process, standing by.`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const interval = setInterval(async () => {
|
|
38
|
-
try {
|
|
39
|
-
await lockHandle.refresh();
|
|
40
|
-
} catch (e) {
|
|
41
|
-
this.logger.error('Failed to refresh lock', e);
|
|
42
|
-
clearInterval(interval);
|
|
43
|
-
}
|
|
44
|
-
}, 30_130);
|
|
45
|
-
|
|
46
|
-
return (this.current_lock = {
|
|
47
|
-
sync_rules_id: this.id,
|
|
48
|
-
release: async () => {
|
|
49
|
-
clearInterval(interval);
|
|
50
|
-
return lockHandle.release();
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{@types/migrations → migrations}/scripts/1756282360128-connection-reporting.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|