@powersync/service-module-postgres-storage 0.11.2 → 0.12.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 +38 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/migrations/scripts/1771232439485-storage-version.d.ts +3 -0
- package/dist/@types/migrations/scripts/1771491856000-sync-plan.d.ts +3 -0
- package/dist/@types/storage/PostgresBucketStorageFactory.d.ts +2 -10
- package/dist/@types/storage/PostgresCompactor.d.ts +2 -1
- package/dist/@types/storage/sync-rules/PostgresPersistedSyncRulesContent.d.ts +1 -10
- package/dist/@types/types/models/SyncRules.d.ts +12 -2
- package/dist/@types/types/models/json.d.ts +11 -0
- package/dist/@types/types/types.d.ts +2 -0
- package/dist/@types/utils/db.d.ts +9 -0
- package/dist/migrations/scripts/1771232439485-storage-version.js +111 -0
- package/dist/migrations/scripts/1771232439485-storage-version.js.map +1 -0
- package/dist/migrations/scripts/1771491856000-sync-plan.js +91 -0
- package/dist/migrations/scripts/1771491856000-sync-plan.js.map +1 -0
- package/dist/storage/PostgresBucketStorageFactory.js +16 -55
- package/dist/storage/PostgresBucketStorageFactory.js.map +1 -1
- package/dist/storage/PostgresCompactor.js +41 -60
- package/dist/storage/PostgresCompactor.js.map +1 -1
- package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js +14 -30
- package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js.map +1 -1
- package/dist/types/models/SyncRules.js +12 -1
- package/dist/types/models/SyncRules.js.map +1 -1
- package/dist/types/models/json.js +21 -0
- package/dist/types/models/json.js.map +1 -0
- package/dist/utils/db.js +32 -0
- package/dist/utils/db.js.map +1 -1
- package/dist/utils/test-utils.js +39 -10
- package/dist/utils/test-utils.js.map +1 -1
- package/package.json +8 -8
- package/src/migrations/scripts/1771232439485-storage-version.ts +44 -0
- package/src/migrations/scripts/1771491856000-sync-plan.ts +21 -0
- package/src/storage/PostgresBucketStorageFactory.ts +18 -65
- package/src/storage/PostgresCompactor.ts +46 -64
- package/src/storage/sync-rules/PostgresPersistedSyncRulesContent.ts +13 -33
- package/src/types/models/SyncRules.ts +16 -1
- package/src/types/models/json.ts +26 -0
- package/src/utils/db.ts +37 -0
- package/src/utils/test-utils.ts +30 -10
- package/test/src/__snapshots__/storage_sync.test.ts.snap +1116 -21
- package/test/src/migrations.test.ts +8 -1
- package/test/src/storage.test.ts +11 -11
- package/test/src/storage_compacting.test.ts +51 -2
- package/test/src/storage_sync.test.ts +146 -4
- package/test/src/util.ts +3 -0
- package/test/src/__snapshots__/storage.test.ts.snap +0 -9
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { GetIntanceOptions, storage, SyncRulesBucketStorage, UpdateSyncRulesOptions } from '@powersync/service-core';
|
|
1
|
+
import { GetIntanceOptions, storage, SyncRulesBucketStorage } from '@powersync/service-core';
|
|
3
2
|
import * as pg_wire from '@powersync/service-jpgwire';
|
|
4
3
|
import * as lib_postgres from '@powersync/lib-service-postgres';
|
|
5
4
|
import { NormalizedPostgresStorageConfig } from '../types/types.js';
|
|
@@ -8,7 +7,7 @@ export type PostgresBucketStorageOptions = {
|
|
|
8
7
|
config: NormalizedPostgresStorageConfig;
|
|
9
8
|
slot_name_prefix: string;
|
|
10
9
|
};
|
|
11
|
-
export declare class PostgresBucketStorageFactory extends
|
|
10
|
+
export declare class PostgresBucketStorageFactory extends storage.BucketStorageFactory {
|
|
12
11
|
protected options: PostgresBucketStorageOptions;
|
|
13
12
|
readonly db: lib_postgres.DatabaseClient;
|
|
14
13
|
readonly slot_name_prefix: string;
|
|
@@ -20,16 +19,9 @@ export declare class PostgresBucketStorageFactory extends framework.BaseObserver
|
|
|
20
19
|
getStorageMetrics(): Promise<storage.StorageMetrics>;
|
|
21
20
|
getPowerSyncInstanceId(): Promise<string>;
|
|
22
21
|
getSystemIdentifier(): Promise<storage.BucketStorageSystemIdentifier>;
|
|
23
|
-
configureSyncRules(options: UpdateSyncRulesOptions): Promise<{
|
|
24
|
-
updated: boolean;
|
|
25
|
-
persisted_sync_rules?: storage.PersistedSyncRulesContent;
|
|
26
|
-
lock?: storage.ReplicationLock;
|
|
27
|
-
}>;
|
|
28
22
|
updateSyncRules(options: storage.UpdateSyncRulesOptions): Promise<PostgresPersistedSyncRulesContent>;
|
|
29
23
|
restartReplication(sync_rules_group_id: number): Promise<void>;
|
|
30
|
-
getActiveSyncRules(options: storage.ParseSyncRulesOptions): Promise<storage.PersistedSyncRules | null>;
|
|
31
24
|
getActiveSyncRulesContent(): Promise<storage.PersistedSyncRulesContent | null>;
|
|
32
|
-
getNextSyncRules(options: storage.ParseSyncRulesOptions): Promise<storage.PersistedSyncRules | null>;
|
|
33
25
|
getNextSyncRulesContent(): Promise<storage.PersistedSyncRulesContent | null>;
|
|
34
26
|
getReplicatingSyncRules(): Promise<storage.PersistedSyncRulesContent[]>;
|
|
35
27
|
getStoppedSyncRules(): Promise<storage.PersistedSyncRulesContent[]>;
|
|
@@ -22,7 +22,8 @@ export declare class PostgresCompactor {
|
|
|
22
22
|
* See /docs/compacting-operations.md for details.
|
|
23
23
|
*/
|
|
24
24
|
compact(): Promise<void>;
|
|
25
|
-
|
|
25
|
+
private compactAllBuckets;
|
|
26
|
+
private compactSingleBucket;
|
|
26
27
|
private flush;
|
|
27
28
|
/**
|
|
28
29
|
* Perform a CLEAR compact for a bucket.
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import * as lib_postgres from '@powersync/lib-service-postgres';
|
|
2
2
|
import { storage } from '@powersync/service-core';
|
|
3
3
|
import { models } from '../../types/types.js';
|
|
4
|
-
export declare class PostgresPersistedSyncRulesContent
|
|
4
|
+
export declare class PostgresPersistedSyncRulesContent extends storage.PersistedSyncRulesContent {
|
|
5
5
|
private db;
|
|
6
|
-
readonly slot_name: string;
|
|
7
|
-
readonly id: number;
|
|
8
|
-
readonly sync_rules_content: string;
|
|
9
|
-
readonly last_checkpoint_lsn: string | null;
|
|
10
|
-
readonly last_fatal_error: string | null;
|
|
11
|
-
readonly last_keepalive_ts: Date | null;
|
|
12
|
-
readonly last_checkpoint_ts: Date | null;
|
|
13
|
-
readonly active: boolean;
|
|
14
6
|
current_lock: storage.ReplicationLock | null;
|
|
15
7
|
constructor(db: lib_postgres.DatabaseClient, row: models.SyncRulesDecoded);
|
|
16
|
-
parsed(options: storage.ParseSyncRulesOptions): storage.PersistedSyncRules;
|
|
17
8
|
lock(): Promise<storage.ReplicationLock>;
|
|
18
9
|
}
|
|
@@ -33,19 +33,29 @@ export declare const SyncRules: t.ObjectCodec<{
|
|
|
33
33
|
*
|
|
34
34
|
* This may be old if no data is incoming.
|
|
35
35
|
*/
|
|
36
|
-
last_checkpoint_ts: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<Date, string | import("@powersync/service-sync-rules
|
|
36
|
+
last_checkpoint_ts: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<Date, string | import("@powersync/service-sync-rules").DateTimeValue, string, t.CodecProps>>;
|
|
37
37
|
/**
|
|
38
38
|
* Last time we persisted a checkpoint or keepalive.
|
|
39
39
|
*
|
|
40
40
|
* This should stay fairly current while replicating.
|
|
41
41
|
*/
|
|
42
|
-
last_keepalive_ts: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<Date, string | import("@powersync/service-sync-rules
|
|
42
|
+
last_keepalive_ts: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<Date, string | import("@powersync/service-sync-rules").DateTimeValue, string, t.CodecProps>>;
|
|
43
43
|
/**
|
|
44
44
|
* If an error is stopping replication, it will be stored here.
|
|
45
45
|
*/
|
|
46
46
|
last_fatal_error: t.Union<t.Codec<null, null, string, t.CodecProps>, t.IdentityCodec<t.CodecType.String>>;
|
|
47
47
|
keepalive_op: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<bigint, string | number, string, t.CodecProps>>;
|
|
48
|
+
storage_version: t.OptionalCodec<t.Codec<number | null, number | null, string, t.CodecProps>>;
|
|
48
49
|
content: t.IdentityCodec<t.CodecType.String>;
|
|
50
|
+
sync_plan: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<{
|
|
51
|
+
plan: any;
|
|
52
|
+
compatibility: {
|
|
53
|
+
edition: number;
|
|
54
|
+
overrides: Record<string, boolean>;
|
|
55
|
+
maxTimeValuePrecision?: number | undefined;
|
|
56
|
+
};
|
|
57
|
+
eventDescriptors: Record<string, string[]>;
|
|
58
|
+
}, import("@powersync/service-jsonbig").JsonContainer>>;
|
|
49
59
|
}>;
|
|
50
60
|
export type SyncRules = t.Encoded<typeof SyncRules>;
|
|
51
61
|
export type SyncRulesDecoded = t.Decoded<typeof SyncRules>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { JsonContainer } from '@powersync/service-jsonbig';
|
|
2
|
+
import { Codec } from 'ts-codec';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a codec to support {@link JsonContainer} values.
|
|
5
|
+
*
|
|
6
|
+
* Because our postgres client implementation wraps JSON objects in a {@link JsonContainer}, this intermediate layer is
|
|
7
|
+
* required to use JSON columns from Postgres in `ts-codec` models.
|
|
8
|
+
*
|
|
9
|
+
* Note that this serializes and deserializes values using {@link JSON}, so bigints are not supported.
|
|
10
|
+
*/
|
|
11
|
+
export declare function jsonContainerObject<I, O>(inner: Codec<I, O>): Codec<I, JsonContainer>;
|
|
@@ -50,6 +50,7 @@ export declare const PostgresStorageConfig: t.Intersection<t.Codec<{
|
|
|
50
50
|
reject_ip_ranges?: string[] | undefined;
|
|
51
51
|
slot_name_prefix?: string | undefined;
|
|
52
52
|
max_pool_size?: number | undefined;
|
|
53
|
+
connect_timeout?: number | undefined;
|
|
53
54
|
}, {
|
|
54
55
|
type: string;
|
|
55
56
|
max_pool_size?: number | undefined;
|
|
@@ -71,6 +72,7 @@ export declare const PostgresStorageConfig: t.Intersection<t.Codec<{
|
|
|
71
72
|
reject_ip_ranges?: string[] | undefined;
|
|
72
73
|
slot_name_prefix?: string | undefined;
|
|
73
74
|
max_pool_size?: number | undefined;
|
|
75
|
+
connect_timeout?: number | undefined;
|
|
74
76
|
}, string, t.CodecProps>, t.ObjectCodec<{
|
|
75
77
|
/**
|
|
76
78
|
* Allow batch operation limits to be configurable.
|
|
@@ -5,4 +5,13 @@ export declare const NOTIFICATION_CHANNEL = "powersynccheckpoints";
|
|
|
5
5
|
* Re export for prettier to detect the tag better
|
|
6
6
|
*/
|
|
7
7
|
export declare const sql: (strings: TemplateStringsArray, ...params: import("@powersync/service-jpgwire").StatementParam[]) => import("@powersync/service-jpgwire").Statement;
|
|
8
|
+
/**
|
|
9
|
+
* Drop all Postgres storage tables used by the service, including migrations.
|
|
10
|
+
*/
|
|
8
11
|
export declare const dropTables: (client: lib_postgres.DatabaseClient) => Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Clear all Postgres storage tables and reset sequences.
|
|
14
|
+
*
|
|
15
|
+
* Does not clear migration state.
|
|
16
|
+
*/
|
|
17
|
+
export declare const truncateTables: (db: lib_postgres.DatabaseClient) => Promise<void>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import { storage } from '@powersync/service-core';
|
|
54
|
+
import { openMigrationDB } from '../migration-utils.js';
|
|
55
|
+
export const up = async (context) => {
|
|
56
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
57
|
+
try {
|
|
58
|
+
const { service_context: { configuration } } = context;
|
|
59
|
+
const client = __addDisposableResource(env_1, openMigrationDB(configuration.storage), true);
|
|
60
|
+
await client.transaction(async (db) => {
|
|
61
|
+
await db.sql `
|
|
62
|
+
ALTER TABLE sync_rules
|
|
63
|
+
ADD COLUMN storage_version integer NOT NULL DEFAULT 1
|
|
64
|
+
`.execute();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (e_1) {
|
|
68
|
+
env_1.error = e_1;
|
|
69
|
+
env_1.hasError = true;
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
const result_1 = __disposeResources(env_1);
|
|
73
|
+
if (result_1)
|
|
74
|
+
await result_1;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
export const down = async (context) => {
|
|
78
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
79
|
+
try {
|
|
80
|
+
const { service_context: { configuration } } = context;
|
|
81
|
+
const client = __addDisposableResource(env_2, openMigrationDB(configuration.storage), true);
|
|
82
|
+
await client.transaction(async (db) => {
|
|
83
|
+
const newRules = await db.sql `
|
|
84
|
+
SELECT
|
|
85
|
+
id,
|
|
86
|
+
storage_version
|
|
87
|
+
FROM
|
|
88
|
+
sync_rules
|
|
89
|
+
WHERE
|
|
90
|
+
storage_version > ${{ type: 'int4', value: storage.LEGACY_STORAGE_VERSION }}
|
|
91
|
+
`.rows();
|
|
92
|
+
if (newRules.length > 0) {
|
|
93
|
+
throw new Error(`Cannot revert migration due to newer storage versions in use: ${newRules.map((r) => `${r.id}: v${r.storage_version}`).join(', ')}`);
|
|
94
|
+
}
|
|
95
|
+
await db.sql `
|
|
96
|
+
ALTER TABLE sync_rules
|
|
97
|
+
DROP COLUMN storage_version
|
|
98
|
+
`.execute();
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch (e_2) {
|
|
102
|
+
env_2.error = e_2;
|
|
103
|
+
env_2.hasError = true;
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
const result_2 = __disposeResources(env_2);
|
|
107
|
+
if (result_2)
|
|
108
|
+
await result_2;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=1771232439485-storage-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1771232439485-storage-version.js","sourceRoot":"","sources":["../../../src/migrations/scripts/1771232439485-storage-version.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAc,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,CAAC,MAAM,EAAE,GAA0C,KAAK,EAAE,OAAO,EAAE,EAAE;;;QACzE,MAAM,EACJ,eAAe,EAAE,EAAE,aAAa,EAAE,EACnC,GAAG,OAAO,CAAC;QACZ,MAAY,MAAM,kCAAG,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,OAAA,CAAC;QAC5D,MAAM,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;YACpC,MAAM,EAAE,CAAC,GAAG,CAAA;;;KAGX,CAAC,OAAO,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;;;;;;;;;;;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAA0C,KAAK,EAAE,OAAO,EAAE,EAAE;;;QAC3E,MAAM,EACJ,eAAe,EAAE,EAAE,aAAa,EAAE,EACnC,GAAG,OAAO,CAAC;QACZ,MAAY,MAAM,kCAAG,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,OAAA,CAAC;QAC5D,MAAM,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;YACpC,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,GAAG,CAAA;;;;;;;4BAOL,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,sBAAsB,EAAE;KAC9E,CAAC,IAAI,EAA6D,CAAC;YAEpE,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CACb,iEAAiE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACpI,CAAC;YACJ,CAAC;YAED,MAAM,EAAE,CAAC,GAAG,CAAA;;;KAGX,CAAC,OAAO,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;;;;;;;;;;;CACJ,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import { openMigrationDB } from '../migration-utils.js';
|
|
54
|
+
export const up = async (context) => {
|
|
55
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
56
|
+
try {
|
|
57
|
+
const { service_context: { configuration } } = context;
|
|
58
|
+
const client = __addDisposableResource(env_1, openMigrationDB(configuration.storage), true);
|
|
59
|
+
await client.sql `
|
|
60
|
+
ALTER TABLE sync_rules
|
|
61
|
+
ADD COLUMN sync_plan JSON;
|
|
62
|
+
`.execute();
|
|
63
|
+
}
|
|
64
|
+
catch (e_1) {
|
|
65
|
+
env_1.error = e_1;
|
|
66
|
+
env_1.hasError = true;
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
const result_1 = __disposeResources(env_1);
|
|
70
|
+
if (result_1)
|
|
71
|
+
await result_1;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export const down = async (context) => {
|
|
75
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
76
|
+
try {
|
|
77
|
+
const { service_context: { configuration } } = context;
|
|
78
|
+
const client = __addDisposableResource(env_2, openMigrationDB(configuration.storage), true);
|
|
79
|
+
await client.sql `ALTER TABLE sync_rules DROP COLUMN sync_plan`.execute();
|
|
80
|
+
}
|
|
81
|
+
catch (e_2) {
|
|
82
|
+
env_2.error = e_2;
|
|
83
|
+
env_2.hasError = true;
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
const result_2 = __disposeResources(env_2);
|
|
87
|
+
if (result_2)
|
|
88
|
+
await result_2;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=1771491856000-sync-plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1771491856000-sync-plan.js","sourceRoot":"","sources":["../../../src/migrations/scripts/1771491856000-sync-plan.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,CAAC,MAAM,EAAE,GAA0C,KAAK,EAAE,OAAO,EAAE,EAAE;;;QACzE,MAAM,EACJ,eAAe,EAAE,EAAE,aAAa,EAAE,EACnC,GAAG,OAAO,CAAC;QACZ,MAAY,MAAM,kCAAG,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,OAAA,CAAC;QAC5D,MAAM,MAAM,CAAC,GAAG,CAAA;;;GAGf,CAAC,OAAO,EAAE,CAAC;;;;;;;;;;;CACb,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAA0C,KAAK,EAAE,OAAO,EAAE,EAAE;;;QAC3E,MAAM,EACJ,eAAe,EAAE,EAAE,aAAa,EAAE,EACnC,GAAG,OAAO,CAAC;QACZ,MAAY,MAAM,kCAAG,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,OAAA,CAAC;QAC5D,MAAM,MAAM,CAAC,GAAG,CAAA,8CAA8C,CAAC,OAAO,EAAE,CAAC;;;;;;;;;;;CAC1E,CAAC"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import * as framework from '@powersync/lib-services-framework';
|
|
2
1
|
import { storage } from '@powersync/service-core';
|
|
3
|
-
import * as sync_rules from '@powersync/service-sync-rules';
|
|
4
2
|
import crypto from 'crypto';
|
|
5
3
|
import * as uuid from 'uuid';
|
|
6
4
|
import * as lib_postgres from '@powersync/lib-service-postgres';
|
|
@@ -10,7 +8,7 @@ import { notifySyncRulesUpdate } from './batch/PostgresBucketBatch.js';
|
|
|
10
8
|
import { PostgresSyncRulesStorage } from './PostgresSyncRulesStorage.js';
|
|
11
9
|
import { PostgresPersistedSyncRulesContent } from './sync-rules/PostgresPersistedSyncRulesContent.js';
|
|
12
10
|
import { getStorageApplicationName } from '../utils/application-name.js';
|
|
13
|
-
export class PostgresBucketStorageFactory extends
|
|
11
|
+
export class PostgresBucketStorageFactory extends storage.BucketStorageFactory {
|
|
14
12
|
options;
|
|
15
13
|
db;
|
|
16
14
|
slot_name_prefix;
|
|
@@ -117,38 +115,8 @@ export class PostgresBucketStorageFactory extends framework.BaseObserver {
|
|
|
117
115
|
type: lib_postgres.POSTGRES_CONNECTION_TYPE
|
|
118
116
|
};
|
|
119
117
|
}
|
|
120
|
-
// TODO possibly share implementation in abstract class
|
|
121
|
-
async configureSyncRules(options) {
|
|
122
|
-
const next = await this.getNextSyncRulesContent();
|
|
123
|
-
const active = await this.getActiveSyncRulesContent();
|
|
124
|
-
if (next?.sync_rules_content == options.content) {
|
|
125
|
-
framework.logger.info('Sync rules from configuration unchanged');
|
|
126
|
-
return { updated: false };
|
|
127
|
-
}
|
|
128
|
-
else if (next == null && active?.sync_rules_content == options.content) {
|
|
129
|
-
framework.logger.info('Sync rules from configuration unchanged');
|
|
130
|
-
return { updated: false };
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
framework.logger.info('Sync rules updated from configuration');
|
|
134
|
-
const persisted_sync_rules = await this.updateSyncRules(options);
|
|
135
|
-
return { updated: true, persisted_sync_rules, lock: persisted_sync_rules.current_lock ?? undefined };
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
118
|
async updateSyncRules(options) {
|
|
139
|
-
|
|
140
|
-
if (options.validate) {
|
|
141
|
-
// Parse and validate before applying any changes
|
|
142
|
-
sync_rules.SqlSyncRules.fromYaml(options.content, {
|
|
143
|
-
// No schema-based validation at this point
|
|
144
|
-
schema: undefined,
|
|
145
|
-
defaultSchema: 'not_applicable', // Not needed for validation
|
|
146
|
-
throwOnError: true
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
// Apply unconditionally. Any errors will be reported via the diagnostics API.
|
|
151
|
-
}
|
|
119
|
+
const storageVersion = options.storageVersion ?? storage.CURRENT_STORAGE_VERSION;
|
|
152
120
|
return this.db.transaction(async (db) => {
|
|
153
121
|
await db.sql `
|
|
154
122
|
UPDATE sync_rules
|
|
@@ -164,7 +132,14 @@ export class PostgresBucketStorageFactory extends framework.BaseObserver {
|
|
|
164
132
|
nextval('sync_rules_id_sequence') AS id
|
|
165
133
|
)
|
|
166
134
|
INSERT INTO
|
|
167
|
-
sync_rules (
|
|
135
|
+
sync_rules (
|
|
136
|
+
id,
|
|
137
|
+
content,
|
|
138
|
+
sync_plan,
|
|
139
|
+
state,
|
|
140
|
+
slot_name,
|
|
141
|
+
storage_version
|
|
142
|
+
)
|
|
168
143
|
VALUES
|
|
169
144
|
(
|
|
170
145
|
(
|
|
@@ -173,7 +148,8 @@ export class PostgresBucketStorageFactory extends framework.BaseObserver {
|
|
|
173
148
|
FROM
|
|
174
149
|
next_id
|
|
175
150
|
),
|
|
176
|
-
${{ type: 'varchar', value: options.
|
|
151
|
+
${{ type: 'varchar', value: options.config.yaml }},
|
|
152
|
+
${{ type: 'json', value: options.config.plan }},
|
|
177
153
|
${{ type: 'varchar', value: storage.SyncRuleState.PROCESSING }},
|
|
178
154
|
CONCAT(
|
|
179
155
|
${{ type: 'varchar', value: this.slot_name_prefix }},
|
|
@@ -185,7 +161,8 @@ export class PostgresBucketStorageFactory extends framework.BaseObserver {
|
|
|
185
161
|
),
|
|
186
162
|
'_',
|
|
187
163
|
${{ type: 'varchar', value: crypto.randomBytes(2).toString('hex') }}
|
|
188
|
-
)
|
|
164
|
+
),
|
|
165
|
+
${{ type: 'int4', value: storageVersion }}
|
|
189
166
|
)
|
|
190
167
|
RETURNING
|
|
191
168
|
*
|
|
@@ -203,10 +180,7 @@ export class PostgresBucketStorageFactory extends framework.BaseObserver {
|
|
|
203
180
|
// The current one will continue serving sync requests until the next one has finished processing.
|
|
204
181
|
if (next != null && next.id == sync_rules_group_id) {
|
|
205
182
|
// We need to redo the "next" sync rules
|
|
206
|
-
await this.updateSyncRules(
|
|
207
|
-
content: next.sync_rules_content,
|
|
208
|
-
validate: false
|
|
209
|
-
});
|
|
183
|
+
await this.updateSyncRules(next.asUpdateOptions());
|
|
210
184
|
// Pro-actively stop replicating
|
|
211
185
|
await this.db.sql `
|
|
212
186
|
UPDATE sync_rules
|
|
@@ -219,10 +193,7 @@ export class PostgresBucketStorageFactory extends framework.BaseObserver {
|
|
|
219
193
|
}
|
|
220
194
|
else if (next == null && active?.id == sync_rules_group_id) {
|
|
221
195
|
// Slot removed for "active" sync rules, while there is no "next" one.
|
|
222
|
-
await this.updateSyncRules(
|
|
223
|
-
content: active.sync_rules_content,
|
|
224
|
-
validate: false
|
|
225
|
-
});
|
|
196
|
+
await this.updateSyncRules(active.asUpdateOptions());
|
|
226
197
|
// Pro-actively stop replicating, but still serve clients with existing data
|
|
227
198
|
await this.db.sql `
|
|
228
199
|
UPDATE sync_rules
|
|
@@ -246,11 +217,6 @@ export class PostgresBucketStorageFactory extends framework.BaseObserver {
|
|
|
246
217
|
`.execute();
|
|
247
218
|
}
|
|
248
219
|
}
|
|
249
|
-
// TODO possibly share via abstract class
|
|
250
|
-
async getActiveSyncRules(options) {
|
|
251
|
-
const content = await this.getActiveSyncRulesContent();
|
|
252
|
-
return content?.parsed(options) ?? null;
|
|
253
|
-
}
|
|
254
220
|
async getActiveSyncRulesContent() {
|
|
255
221
|
const activeRow = await this.db.sql `
|
|
256
222
|
SELECT
|
|
@@ -272,11 +238,6 @@ export class PostgresBucketStorageFactory extends framework.BaseObserver {
|
|
|
272
238
|
}
|
|
273
239
|
return new PostgresPersistedSyncRulesContent(this.db, activeRow);
|
|
274
240
|
}
|
|
275
|
-
// TODO possibly share via abstract class
|
|
276
|
-
async getNextSyncRules(options) {
|
|
277
|
-
const content = await this.getNextSyncRulesContent();
|
|
278
|
-
return content?.parsed(options) ?? null;
|
|
279
|
-
}
|
|
280
241
|
async getNextSyncRulesContent() {
|
|
281
242
|
const nextRow = await this.db.sql `
|
|
282
243
|
SELECT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresBucketStorageFactory.js","sourceRoot":"","sources":["../../src/storage/PostgresBucketStorageFactory.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"PostgresBucketStorageFactory.js","sourceRoot":"","sources":["../../src/storage/PostgresBucketStorageFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,OAAO,EAA0B,MAAM,yBAAyB,CAAC;AAE7F,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,KAAK,YAAY,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAmC,MAAM,mBAAmB,CAAC;AAE5E,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA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