@powersync/service-module-postgres-storage 0.0.0-dev-20260225160713 → 0.0.0-dev-20260511080634
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 +125 -7
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/migrations/scripts/1771424826685-current-data-pending-deletes.d.ts +3 -0
- package/dist/@types/storage/PostgresBucketStorageFactory.d.ts +6 -1
- package/dist/@types/storage/PostgresCompactor.d.ts +8 -2
- package/dist/@types/storage/PostgresReportStorage.d.ts +1 -1
- package/dist/@types/storage/PostgresSyncRulesStorage.d.ts +14 -6
- package/dist/@types/storage/batch/OperationBatch.d.ts +2 -2
- package/dist/@types/storage/batch/PostgresBucketBatch.d.ts +14 -10
- package/dist/@types/storage/batch/PostgresPersistedBatch.d.ts +17 -5
- package/dist/@types/storage/current-data-store.d.ts +85 -0
- package/dist/@types/storage/table-id.d.ts +2 -0
- package/dist/@types/types/models/CurrentData.d.ts +18 -3
- package/dist/@types/types/models/SyncRules.d.ts +9 -0
- package/dist/@types/types/models/models-index.d.ts +1 -1
- package/dist/@types/utils/bson.d.ts +1 -1
- package/dist/@types/utils/test-utils.d.ts +3 -3
- package/dist/@types/utils/utils-index.d.ts +1 -1
- package/dist/migrations/migration-utils.js +2 -2
- package/dist/migrations/migration-utils.js.map +1 -1
- package/dist/migrations/scripts/1684951997326-init.js +24 -100
- package/dist/migrations/scripts/1684951997326-init.js.map +1 -1
- package/dist/migrations/scripts/1749024804042-snapshot-progress.js +12 -88
- package/dist/migrations/scripts/1749024804042-snapshot-progress.js.map +1 -1
- package/dist/migrations/scripts/1756282360128-connection-reporting.js +12 -88
- package/dist/migrations/scripts/1756282360128-connection-reporting.js.map +1 -1
- package/dist/migrations/scripts/1771232439485-storage-version.js +14 -90
- package/dist/migrations/scripts/1771232439485-storage-version.js.map +1 -1
- package/dist/migrations/scripts/1771424826685-current-data-pending-deletes.js +8 -0
- package/dist/migrations/scripts/1771424826685-current-data-pending-deletes.js.map +1 -0
- package/dist/migrations/scripts/1771491856000-sync-plan.js +6 -82
- package/dist/migrations/scripts/1771491856000-sync-plan.js.map +1 -1
- package/dist/storage/PostgresBucketStorageFactory.js +47 -9
- package/dist/storage/PostgresBucketStorageFactory.js.map +1 -1
- package/dist/storage/PostgresCompactor.js +14 -6
- package/dist/storage/PostgresCompactor.js.map +1 -1
- package/dist/storage/PostgresReportStorage.js +3 -3
- package/dist/storage/PostgresReportStorage.js.map +1 -1
- package/dist/storage/PostgresSyncRulesStorage.js +93 -60
- package/dist/storage/PostgresSyncRulesStorage.js.map +1 -1
- package/dist/storage/batch/OperationBatch.js +2 -1
- package/dist/storage/batch/OperationBatch.js.map +1 -1
- package/dist/storage/batch/PostgresBucketBatch.js +297 -215
- package/dist/storage/batch/PostgresBucketBatch.js.map +1 -1
- package/dist/storage/batch/PostgresPersistedBatch.js +86 -81
- package/dist/storage/batch/PostgresPersistedBatch.js.map +1 -1
- package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js +1 -1
- package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js.map +1 -1
- package/dist/storage/current-data-store.js +270 -0
- package/dist/storage/current-data-store.js.map +1 -0
- package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js +3 -3
- package/dist/storage/sync-rules/PostgresPersistedSyncRulesContent.js.map +1 -1
- package/dist/storage/table-id.js +8 -0
- package/dist/storage/table-id.js.map +1 -0
- package/dist/types/models/CurrentData.js +11 -2
- package/dist/types/models/CurrentData.js.map +1 -1
- package/dist/types/models/SyncRules.js +3 -1
- package/dist/types/models/SyncRules.js.map +1 -1
- package/dist/types/models/models-index.js +1 -1
- package/dist/types/models/models-index.js.map +1 -1
- package/dist/utils/bson.js.map +1 -1
- package/dist/utils/db.js +9 -0
- package/dist/utils/db.js.map +1 -1
- package/dist/utils/test-utils.js +39 -108
- package/dist/utils/test-utils.js.map +1 -1
- package/dist/utils/utils-index.js +1 -1
- package/dist/utils/utils-index.js.map +1 -1
- package/package.json +12 -13
- package/src/migrations/migration-utils.ts +2 -2
- package/src/migrations/scripts/1771424826685-current-data-pending-deletes.ts +10 -0
- package/src/storage/PostgresBucketStorageFactory.ts +60 -10
- package/src/storage/PostgresCompactor.ts +17 -8
- package/src/storage/PostgresReportStorage.ts +5 -5
- package/src/storage/PostgresSyncRulesStorage.ts +108 -65
- package/src/storage/batch/OperationBatch.ts +4 -3
- package/src/storage/batch/PostgresBucketBatch.ts +318 -240
- package/src/storage/batch/PostgresPersistedBatch.ts +92 -84
- package/src/storage/checkpoints/PostgresWriteCheckpointAPI.ts +3 -1
- package/src/storage/current-data-store.ts +326 -0
- package/src/storage/sync-rules/PostgresPersistedSyncRulesContent.ts +3 -6
- package/src/storage/table-id.ts +9 -0
- package/src/types/models/CurrentData.ts +17 -4
- package/src/types/models/SyncRules.ts +3 -1
- package/src/types/models/models-index.ts +1 -1
- package/src/utils/bson.ts +1 -1
- package/src/utils/db.ts +10 -0
- package/src/utils/test-utils.ts +16 -9
- package/src/utils/utils-index.ts +1 -1
- package/test/src/__snapshots__/storage.test.ts.snap +151 -0
- package/test/src/__snapshots__/storage_compacting.test.ts.snap +17 -0
- package/test/src/__snapshots__/storage_sync.test.ts.snap +1393 -16
- package/test/src/connection-report-storage.test.ts +4 -4
- package/test/src/env.ts +1 -1
- package/test/src/migrations.test.ts +1 -1
- package/test/src/setup.ts +1 -1
- package/test/src/storage.test.ts +138 -131
- package/test/src/storage_compacting.test.ts +80 -11
- package/test/src/storage_sync.test.ts +57 -54
- package/test/src/util.ts +4 -4
- package/test/tsconfig.json +0 -1
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import * as models from '../types/models/CurrentData.js';
|
|
2
|
+
import { pick } from '../utils/ts-codec.js';
|
|
3
|
+
const TruncateCurrentDataCodec = pick(models.V1CurrentData, ['buckets', 'lookups', 'source_key']);
|
|
4
|
+
const LookupKeyCodec = pick(models.V1CurrentData, ['source_key', 'source_table']);
|
|
5
|
+
export const V1_CURRENT_DATA_TABLE = 'current_data';
|
|
6
|
+
export const V3_CURRENT_DATA_TABLE = 'v3_current_data';
|
|
7
|
+
export class PostgresCurrentDataStore {
|
|
8
|
+
table;
|
|
9
|
+
softDeleteEnabled;
|
|
10
|
+
constructor(storageConfig) {
|
|
11
|
+
this.softDeleteEnabled = storageConfig.softDeleteCurrentData;
|
|
12
|
+
this.table = storageConfig.softDeleteCurrentData ? V3_CURRENT_DATA_TABLE : V1_CURRENT_DATA_TABLE;
|
|
13
|
+
}
|
|
14
|
+
streamTruncateRows(db, options) {
|
|
15
|
+
return db.streamRows({
|
|
16
|
+
statement: `
|
|
17
|
+
SELECT
|
|
18
|
+
buckets,
|
|
19
|
+
lookups,
|
|
20
|
+
source_key
|
|
21
|
+
FROM
|
|
22
|
+
${this.table}
|
|
23
|
+
WHERE
|
|
24
|
+
group_id = $1
|
|
25
|
+
AND source_table = $2
|
|
26
|
+
${this.wherePendingDelete({ onlyLiveRows: true })}
|
|
27
|
+
LIMIT
|
|
28
|
+
$3
|
|
29
|
+
FOR NO KEY UPDATE
|
|
30
|
+
`,
|
|
31
|
+
params: [
|
|
32
|
+
{ type: 'int4', value: options.groupId },
|
|
33
|
+
{ type: 'varchar', value: options.sourceTableId },
|
|
34
|
+
{ type: 'int4', value: options.limit }
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
decodeTruncateRow(row) {
|
|
39
|
+
return TruncateCurrentDataCodec.decode(row);
|
|
40
|
+
}
|
|
41
|
+
streamSizeRows(db, options) {
|
|
42
|
+
return db.streamRows({
|
|
43
|
+
statement: `
|
|
44
|
+
WITH
|
|
45
|
+
filter_data AS (
|
|
46
|
+
SELECT
|
|
47
|
+
decode(FILTER ->> 'source_key', 'hex') AS source_key,
|
|
48
|
+
(FILTER ->> 'source_table') AS source_table_id
|
|
49
|
+
FROM
|
|
50
|
+
jsonb_array_elements($1::jsonb) AS FILTER
|
|
51
|
+
)
|
|
52
|
+
SELECT
|
|
53
|
+
octet_length(c.data) AS data_size,
|
|
54
|
+
c.source_table,
|
|
55
|
+
c.source_key
|
|
56
|
+
FROM
|
|
57
|
+
${this.table} c
|
|
58
|
+
JOIN filter_data f ON c.source_table = f.source_table_id
|
|
59
|
+
AND c.source_key = f.source_key
|
|
60
|
+
WHERE
|
|
61
|
+
c.group_id = $2
|
|
62
|
+
FOR NO KEY UPDATE
|
|
63
|
+
`,
|
|
64
|
+
params: [
|
|
65
|
+
{ type: 'jsonb', value: options.lookups },
|
|
66
|
+
{ type: 'int4', value: options.groupId }
|
|
67
|
+
]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
streamLookupRows(db, options) {
|
|
71
|
+
const selectColumns = options.skipExistingRows ? `c.source_table, c.source_key` : `c.*`;
|
|
72
|
+
return db.streamRows({
|
|
73
|
+
statement: `
|
|
74
|
+
SELECT
|
|
75
|
+
${selectColumns}
|
|
76
|
+
FROM
|
|
77
|
+
${this.table} c
|
|
78
|
+
JOIN (
|
|
79
|
+
SELECT
|
|
80
|
+
decode(FILTER ->> 'source_key', 'hex') AS source_key,
|
|
81
|
+
FILTER ->> 'source_table' AS source_table_id
|
|
82
|
+
FROM
|
|
83
|
+
jsonb_array_elements($1::jsonb) AS FILTER
|
|
84
|
+
) f ON c.source_table = f.source_table_id
|
|
85
|
+
AND c.source_key = f.source_key
|
|
86
|
+
WHERE
|
|
87
|
+
c.group_id = $2
|
|
88
|
+
FOR NO KEY UPDATE;
|
|
89
|
+
`,
|
|
90
|
+
params: [
|
|
91
|
+
{ type: 'jsonb', value: options.lookups },
|
|
92
|
+
{ type: 'int4', value: options.groupId }
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
decodeLookupRow(row, skipExistingRows) {
|
|
97
|
+
if (skipExistingRows) {
|
|
98
|
+
return LookupKeyCodec.decode(row);
|
|
99
|
+
}
|
|
100
|
+
return this.softDeleteEnabled ? models.V3CurrentData.decode(row) : models.V1CurrentData.decode(row);
|
|
101
|
+
}
|
|
102
|
+
async flushUpserts(db, updates) {
|
|
103
|
+
if (updates.length == 0) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (this.softDeleteEnabled) {
|
|
107
|
+
await db.sql `
|
|
108
|
+
INSERT INTO
|
|
109
|
+
v3_current_data (
|
|
110
|
+
group_id,
|
|
111
|
+
source_table,
|
|
112
|
+
source_key,
|
|
113
|
+
buckets,
|
|
114
|
+
data,
|
|
115
|
+
lookups,
|
|
116
|
+
pending_delete
|
|
117
|
+
)
|
|
118
|
+
SELECT
|
|
119
|
+
group_id,
|
|
120
|
+
source_table,
|
|
121
|
+
decode(source_key, 'hex') AS source_key,
|
|
122
|
+
buckets::jsonb AS buckets,
|
|
123
|
+
decode(data, 'hex') AS data,
|
|
124
|
+
array(
|
|
125
|
+
SELECT
|
|
126
|
+
decode(element, 'hex')
|
|
127
|
+
FROM
|
|
128
|
+
unnest(lookups) AS element
|
|
129
|
+
) AS lookups,
|
|
130
|
+
CASE
|
|
131
|
+
WHEN pending_delete IS NOT NULL THEN nextval('op_id_sequence')
|
|
132
|
+
ELSE NULL
|
|
133
|
+
END AS pending_delete
|
|
134
|
+
FROM
|
|
135
|
+
json_to_recordset(${{ type: 'json', value: updates }}::json) AS t (
|
|
136
|
+
group_id integer,
|
|
137
|
+
source_table text,
|
|
138
|
+
source_key text,
|
|
139
|
+
buckets text,
|
|
140
|
+
data text,
|
|
141
|
+
lookups TEXT[],
|
|
142
|
+
pending_delete bigint
|
|
143
|
+
)
|
|
144
|
+
ON CONFLICT (group_id, source_table, source_key) DO UPDATE
|
|
145
|
+
SET
|
|
146
|
+
buckets = EXCLUDED.buckets,
|
|
147
|
+
data = EXCLUDED.data,
|
|
148
|
+
lookups = EXCLUDED.lookups,
|
|
149
|
+
pending_delete = EXCLUDED.pending_delete;
|
|
150
|
+
`.execute();
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
await db.sql `
|
|
154
|
+
INSERT INTO
|
|
155
|
+
current_data (
|
|
156
|
+
group_id,
|
|
157
|
+
source_table,
|
|
158
|
+
source_key,
|
|
159
|
+
buckets,
|
|
160
|
+
data,
|
|
161
|
+
lookups
|
|
162
|
+
)
|
|
163
|
+
SELECT
|
|
164
|
+
group_id,
|
|
165
|
+
source_table,
|
|
166
|
+
decode(source_key, 'hex') AS source_key,
|
|
167
|
+
buckets::jsonb AS buckets,
|
|
168
|
+
decode(data, 'hex') AS data,
|
|
169
|
+
array(
|
|
170
|
+
SELECT
|
|
171
|
+
decode(element, 'hex')
|
|
172
|
+
FROM
|
|
173
|
+
unnest(lookups) AS element
|
|
174
|
+
) AS lookups
|
|
175
|
+
FROM
|
|
176
|
+
json_to_recordset(${{ type: 'json', value: updates }}::json) AS t (
|
|
177
|
+
group_id integer,
|
|
178
|
+
source_table text,
|
|
179
|
+
source_key text,
|
|
180
|
+
buckets text,
|
|
181
|
+
data text,
|
|
182
|
+
lookups TEXT[]
|
|
183
|
+
)
|
|
184
|
+
ON CONFLICT (group_id, source_table, source_key) DO UPDATE
|
|
185
|
+
SET
|
|
186
|
+
buckets = EXCLUDED.buckets,
|
|
187
|
+
data = EXCLUDED.data,
|
|
188
|
+
lookups = EXCLUDED.lookups;
|
|
189
|
+
`.execute();
|
|
190
|
+
}
|
|
191
|
+
async flushDeletes(db, options) {
|
|
192
|
+
if (options.deletes.length == 0) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (this.softDeleteEnabled) {
|
|
196
|
+
await db.sql `
|
|
197
|
+
WITH
|
|
198
|
+
conditions AS (
|
|
199
|
+
SELECT
|
|
200
|
+
source_table,
|
|
201
|
+
decode(source_key_hex, 'hex') AS source_key
|
|
202
|
+
FROM
|
|
203
|
+
jsonb_to_recordset(${{
|
|
204
|
+
type: 'jsonb',
|
|
205
|
+
value: options.deletes
|
|
206
|
+
}}::jsonb) AS t (source_table text, source_key_hex text)
|
|
207
|
+
)
|
|
208
|
+
DELETE FROM v3_current_data USING conditions
|
|
209
|
+
WHERE
|
|
210
|
+
v3_current_data.group_id = ${{ type: 'int4', value: options.groupId }}
|
|
211
|
+
AND v3_current_data.source_table = conditions.source_table
|
|
212
|
+
AND v3_current_data.source_key = conditions.source_key;
|
|
213
|
+
`.execute();
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
await db.sql `
|
|
217
|
+
WITH
|
|
218
|
+
conditions AS (
|
|
219
|
+
SELECT
|
|
220
|
+
source_table,
|
|
221
|
+
decode(source_key_hex, 'hex') AS source_key
|
|
222
|
+
FROM
|
|
223
|
+
jsonb_to_recordset(${{
|
|
224
|
+
type: 'jsonb',
|
|
225
|
+
value: options.deletes
|
|
226
|
+
}}::jsonb) AS t (source_table text, source_key_hex text)
|
|
227
|
+
)
|
|
228
|
+
DELETE FROM current_data USING conditions
|
|
229
|
+
WHERE
|
|
230
|
+
current_data.group_id = ${{ type: 'int4', value: options.groupId }}
|
|
231
|
+
AND current_data.source_table = conditions.source_table
|
|
232
|
+
AND current_data.source_key = conditions.source_key;
|
|
233
|
+
`.execute();
|
|
234
|
+
}
|
|
235
|
+
async cleanupPendingDeletes(db, options) {
|
|
236
|
+
if (!this.softDeleteEnabled) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
await db.sql `
|
|
240
|
+
DELETE FROM v3_current_data
|
|
241
|
+
WHERE
|
|
242
|
+
group_id = ${{ type: 'int4', value: options.groupId }}
|
|
243
|
+
AND pending_delete IS NOT NULL
|
|
244
|
+
AND pending_delete <= ${{ type: 'int8', value: options.lastCheckpoint }}
|
|
245
|
+
`.execute();
|
|
246
|
+
}
|
|
247
|
+
async deleteGroupRows(db, options) {
|
|
248
|
+
if (this.softDeleteEnabled) {
|
|
249
|
+
await db.sql `
|
|
250
|
+
DELETE FROM v3_current_data
|
|
251
|
+
WHERE
|
|
252
|
+
group_id = ${{ type: 'int4', value: options.groupId }}
|
|
253
|
+
`.execute();
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
await db.sql `
|
|
257
|
+
DELETE FROM current_data
|
|
258
|
+
WHERE
|
|
259
|
+
group_id = ${{ type: 'int4', value: options.groupId }}
|
|
260
|
+
`.execute();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
wherePendingDelete(options) {
|
|
264
|
+
if (this.softDeleteEnabled && options.onlyLiveRows) {
|
|
265
|
+
return `AND pending_delete IS NULL`;
|
|
266
|
+
}
|
|
267
|
+
return ``;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=current-data-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-data-store.js","sourceRoot":"","sources":["../../src/storage/current-data-store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAI5C,MAAM,wBAAwB,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;AAClG,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC;AAQlF,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC;AACpD,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEvD,MAAM,OAAO,wBAAwB;IAC1B,KAAK,CAAS;IACd,iBAAiB,CAAU;IAEpC,YAAY,aAA2C;QACrD,IAAI,CAAC,iBAAiB,GAAG,aAAa,CAAC,qBAAqB,CAAC;QAC7D,IAAI,CAAC,KAAK,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,qBAAqB,CAAC;IACnG,CAAC;IAED,kBAAkB,CAChB,EAAa,EACb,OAIC;QAED,OAAO,EAAE,CAAC,UAAU,CAA6C;YAC/D,SAAS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B,CAAC;QACtC,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as lib_postgres from '@powersync/lib-service-postgres';
|
|
2
|
-
import { ErrorCode,
|
|
2
|
+
import { ErrorCode, ServiceError } from '@powersync/lib-services-framework';
|
|
3
3
|
import { storage } from '@powersync/service-core';
|
|
4
4
|
export class PostgresPersistedSyncRulesContent extends storage.PersistedSyncRulesContent {
|
|
5
5
|
db;
|
|
@@ -26,14 +26,14 @@ export class PostgresPersistedSyncRulesContent extends storage.PersistedSyncRule
|
|
|
26
26
|
});
|
|
27
27
|
const lockHandle = await manager.acquire();
|
|
28
28
|
if (!lockHandle) {
|
|
29
|
-
throw new ServiceError(ErrorCode.PSYNC_S1003, `
|
|
29
|
+
throw new ServiceError(ErrorCode.PSYNC_S1003, `Replication stream is locked by another process, standing by.`);
|
|
30
30
|
}
|
|
31
31
|
const interval = setInterval(async () => {
|
|
32
32
|
try {
|
|
33
33
|
await lockHandle.refresh();
|
|
34
34
|
}
|
|
35
35
|
catch (e) {
|
|
36
|
-
logger.error('Failed to refresh lock', e);
|
|
36
|
+
this.logger.error('Failed to refresh lock', e);
|
|
37
37
|
clearInterval(interval);
|
|
38
38
|
}
|
|
39
39
|
}, 30_130);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresPersistedSyncRulesContent.js","sourceRoot":"","sources":["../../../src/storage/sync-rules/PostgresPersistedSyncRulesContent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"PostgresPersistedSyncRulesContent.js","sourceRoot":"","sources":["../../../src/storage/sync-rules/PostgresPersistedSyncRulesContent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,M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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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ServiceAssertionError } from '@powersync/lib-services-framework';
|
|
2
|
+
export function postgresTableId(id) {
|
|
3
|
+
if (typeof id == 'string') {
|
|
4
|
+
return id;
|
|
5
|
+
}
|
|
6
|
+
throw new ServiceAssertionError(`Expected string table id, got ObjectId`);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=table-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-id.js","sourceRoot":"","sources":["../../src/storage/table-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAG1E,MAAM,UAAU,eAAe,CAAC,EAAyB;IACvD,IAAI,OAAO,EAAE,IAAI,QAAQ,EAAE,CAAC;QAC1B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,IAAI,qBAAqB,CAAC,wCAAwC,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as t from 'ts-codec';
|
|
2
|
-
import { hexBuffer, jsonb, pgwire_number } from '../codecs.js';
|
|
2
|
+
import { bigint, hexBuffer, jsonb, pgwire_number } from '../codecs.js';
|
|
3
3
|
export const CurrentBucket = t.object({
|
|
4
4
|
bucket: t.string,
|
|
5
5
|
table: t.string,
|
|
6
6
|
id: t.string
|
|
7
7
|
});
|
|
8
|
-
export const
|
|
8
|
+
export const V1CurrentData = t.object({
|
|
9
9
|
buckets: jsonb(t.array(CurrentBucket)),
|
|
10
10
|
data: hexBuffer,
|
|
11
11
|
group_id: pgwire_number,
|
|
@@ -13,4 +13,13 @@ export const CurrentData = t.object({
|
|
|
13
13
|
source_key: hexBuffer,
|
|
14
14
|
source_table: t.string
|
|
15
15
|
});
|
|
16
|
+
export const V3CurrentData = t.object({
|
|
17
|
+
buckets: jsonb(t.array(CurrentBucket)),
|
|
18
|
+
data: hexBuffer,
|
|
19
|
+
group_id: pgwire_number,
|
|
20
|
+
lookups: t.array(hexBuffer),
|
|
21
|
+
source_key: hexBuffer,
|
|
22
|
+
source_table: t.string,
|
|
23
|
+
pending_delete: t.Null.or(bigint)
|
|
24
|
+
});
|
|
16
25
|
//# sourceMappingURL=CurrentData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrentData.js","sourceRoot":"","sources":["../../../src/types/models/CurrentData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"CurrentData.js","sourceRoot":"","sources":["../../../src/types/models/CurrentData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,MAAM,EAAE,CAAC,CAAC,MAAM;IAChB,KAAK,EAAE,CAAC,CAAC,MAAM;IACf,EAAE,EAAE,CAAC,CAAC,MAAM;CACb,CAAC,CAAC;AAKH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACtC,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,aAAa;IACvB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;IAC3B,UAAU,EAAE,SAAS;IACrB,YAAY,EAAE,CAAC,CAAC,MAAM;CACvB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACtC,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,aAAa;IACvB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;IAC3B,UAAU,EAAE,SAAS;IACrB,YAAY,EAAE,CAAC,CAAC,MAAM;IACtB,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;CAClC,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { framework, storage } from '@powersync/service-core';
|
|
2
|
+
import { ReplicationError } from '@powersync/service-types';
|
|
2
3
|
import * as t from 'ts-codec';
|
|
3
4
|
import { bigint, pgwire_number } from '../codecs.js';
|
|
4
5
|
import { jsonContainerObject } from './json.js';
|
|
@@ -56,7 +57,8 @@ export const SyncRules = t.object({
|
|
|
56
57
|
overrides: t.record(t.boolean),
|
|
57
58
|
maxTimeValuePrecision: t.number.optional()
|
|
58
59
|
}),
|
|
59
|
-
eventDescriptors: t.record(t.array(t.string))
|
|
60
|
+
eventDescriptors: t.record(t.array(t.string)),
|
|
61
|
+
errors: t.array(ReplicationError).optional()
|
|
60
62
|
})))
|
|
61
63
|
});
|
|
62
64
|
//# sourceMappingURL=SyncRules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncRules.js","sourceRoot":"","sources":["../../../src/types/models/SyncRules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,EAAE,EAAE,aAAa;IACjB,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;IACpC;;;;OAIG;IACH,aAAa,EAAE,CAAC,CAAC,OAAO;IACxB;;OAEG;IACH,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IACjC;;;;OAIG;IACH,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;IAClC;;OAEG;IACH,mBAAmB,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IACxC;;OAEG;IACH,oBAAoB,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IACzC,SAAS,EAAE,CAAC,CAAC,MAAM;IACnB;;;;OAIG;IACH,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;IACpD;;;;OAIG;IACH,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CA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AAC,OAAO,CAAC;YAC9B,qBAAqB,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE;SAC3C,CAAC;QACF,gBAAgB,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE;KAC7C,CAAC,CACH,CACF;CACF,CAAC,CAAC"}
|
|
@@ -5,8 +5,8 @@ export * from './BucketParameters.js';
|
|
|
5
5
|
export * from './CurrentData.js';
|
|
6
6
|
export * from './Instance.js';
|
|
7
7
|
export * from './Migration.js';
|
|
8
|
+
export * from './SdkReporting.js';
|
|
8
9
|
export * from './SourceTable.js';
|
|
9
10
|
export * from './SyncRules.js';
|
|
10
11
|
export * from './WriteCheckpoint.js';
|
|
11
|
-
export * from './SdkReporting.js';
|
|
12
12
|
//# sourceMappingURL=models-index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models-index.js","sourceRoot":"","sources":["../../../src/types/models/models-index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC;AAClD,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC
|
|
1
|
+
{"version":3,"file":"models-index.js","sourceRoot":"","sources":["../../../src/types/models/models-index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC;AAClD,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC"}
|
package/dist/utils/bson.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bson.js","sourceRoot":"","sources":["../../src/utils/bson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;;GAGG;AAEH,MAAM,UAAU,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"bson.js","sourceRoot":"","sources":["../../src/utils/bson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;;GAGG;AAEH,MAAM,UAAU,iBAAiB,CAAC,OAA8B,EAAE,EAAqB;IACrF,oCAAoC;IACpC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;QACvB,mDAAmD;QACnD,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;IAC1C,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;IAC3D,OAAO,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;AAC3C,CAAC"}
|
package/dist/utils/db.js
CHANGED
|
@@ -17,6 +17,7 @@ export const dropTables = async (client) => {
|
|
|
17
17
|
await db.sql `DROP TABLE IF EXISTS instance`.execute();
|
|
18
18
|
await db.sql `DROP TABLE IF EXISTS bucket_data`.execute();
|
|
19
19
|
await db.sql `DROP TABLE IF EXISTS current_data`.execute();
|
|
20
|
+
await db.sql `DROP TABLE IF EXISTS v3_current_data`.execute();
|
|
20
21
|
await db.sql `DROP TABLE IF EXISTS source_tables`.execute();
|
|
21
22
|
await db.sql `DROP TABLE IF EXISTS write_checkpoints`.execute();
|
|
22
23
|
await db.sql `DROP TABLE IF EXISTS custom_write_checkpoints`.execute();
|
|
@@ -43,6 +44,14 @@ export const truncateTables = async (db) => {
|
|
|
43
44
|
custom_write_checkpoints,
|
|
44
45
|
connection_report_events RESTART IDENTITY CASCADE
|
|
45
46
|
`
|
|
47
|
+
}, {
|
|
48
|
+
// TRUNCATE if v3_current_data exists
|
|
49
|
+
statement: `DO $$
|
|
50
|
+
BEGIN
|
|
51
|
+
IF to_regclass('v3_current_data') IS NOT NULL THEN
|
|
52
|
+
EXECUTE 'TRUNCATE TABLE v3_current_data RESTART IDENTITY CASCADE';
|
|
53
|
+
END IF;
|
|
54
|
+
END $$;`
|
|
46
55
|
}, {
|
|
47
56
|
statement: `ALTER SEQUENCE IF EXISTS op_id_sequence RESTART
|
|
48
57
|
WITH
|
package/dist/utils/db.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.js","sourceRoot":"","sources":["../../src/utils/db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,iCAAiC,CAAC;AAEhE,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAC;AAE/C,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,MAAmC,EAAE,EAAE;IACtE,sDAAsD;IACtD,MAAM,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;QACvC,MAAM,EAAE,CAAC,GAAG,CAAA,kCAAkC,CAAC,OAAO,EAAE,CAAC;QACzD,MAAM,EAAE,CAA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AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,EAA+B,EAAE,EAAE;IACtE,sDAAsD;IACtD,MAAM,EAAE,CAAC,KAAK,CACZ;QACE,SAAS,EAAE;;;;;;;;;KASZ;KACA,EACD;QACE,qCAAqC;QACrC,SAAS,EAAE;;;;;gBAKD;KACX,EACD;QACE,SAAS,EAAE;;UAEP;KACL,EACD;QACE,SAAS,EAAE;;UAEP;KACL,CACF,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/utils/test-utils.js
CHANGED
|
@@ -1,60 +1,9 @@
|
|
|
1
|
-
|
|
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
|
-
});
|
|
1
|
+
import { createLogger, logger as defaultLogger, transports } from '@powersync/lib-services-framework';
|
|
53
2
|
import { framework } from '@powersync/service-core';
|
|
54
3
|
import { PostgresMigrationAgent } from '../migrations/PostgresMigrationAgent.js';
|
|
55
|
-
import { normalizePostgresStorageConfig } from '../types/types.js';
|
|
56
|
-
import { PostgresReportStorage } from '../storage/PostgresReportStorage.js';
|
|
57
4
|
import { PostgresBucketStorageFactory } from '../storage/PostgresBucketStorageFactory.js';
|
|
5
|
+
import { PostgresReportStorage } from '../storage/PostgresReportStorage.js';
|
|
6
|
+
import { normalizePostgresStorageConfig } from '../types/types.js';
|
|
58
7
|
import { truncateTables } from './db.js';
|
|
59
8
|
export function postgresTestSetup(factoryOptions) {
|
|
60
9
|
const BASE_CONFIG = {
|
|
@@ -64,39 +13,35 @@ export function postgresTestSetup(factoryOptions) {
|
|
|
64
13
|
};
|
|
65
14
|
const TEST_CONNECTION_OPTIONS = normalizePostgresStorageConfig(BASE_CONFIG);
|
|
66
15
|
const runMigrations = async (options) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
service_context: mockServiceContext
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch (e_1) {
|
|
93
|
-
env_1.error = e_1;
|
|
94
|
-
env_1.hasError = true;
|
|
16
|
+
await using migrationManager = new framework.MigrationManager();
|
|
17
|
+
await using migrationAgent = factoryOptions.migrationAgent
|
|
18
|
+
? factoryOptions.migrationAgent(BASE_CONFIG)
|
|
19
|
+
: new PostgresMigrationAgent(BASE_CONFIG);
|
|
20
|
+
migrationManager.registerMigrationAgent(migrationAgent);
|
|
21
|
+
const mockServiceContext = { configuration: { storage: BASE_CONFIG } };
|
|
22
|
+
// Migration logs can get really verbose in tests, so only log warnings and up.
|
|
23
|
+
const logger = createLogger({
|
|
24
|
+
level: 'warn',
|
|
25
|
+
format: defaultLogger.format,
|
|
26
|
+
transports: [new transports.Console()]
|
|
27
|
+
});
|
|
28
|
+
if (options.down) {
|
|
29
|
+
await migrationManager.migrate({
|
|
30
|
+
direction: framework.migrations.Direction.Down,
|
|
31
|
+
migrationContext: {
|
|
32
|
+
service_context: mockServiceContext
|
|
33
|
+
},
|
|
34
|
+
logger
|
|
35
|
+
});
|
|
95
36
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
37
|
+
if (options.up) {
|
|
38
|
+
await migrationManager.migrate({
|
|
39
|
+
direction: framework.migrations.Direction.Up,
|
|
40
|
+
migrationContext: {
|
|
41
|
+
service_context: mockServiceContext
|
|
42
|
+
},
|
|
43
|
+
logger
|
|
44
|
+
});
|
|
100
45
|
}
|
|
101
46
|
};
|
|
102
47
|
const migrate = async (direction) => {
|
|
@@ -106,24 +51,12 @@ export function postgresTestSetup(factoryOptions) {
|
|
|
106
51
|
});
|
|
107
52
|
};
|
|
108
53
|
const clearStorage = async () => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}), true);
|
|
116
|
-
await truncateTables(storageFactory.db);
|
|
117
|
-
}
|
|
118
|
-
catch (e_2) {
|
|
119
|
-
env_2.error = e_2;
|
|
120
|
-
env_2.hasError = true;
|
|
121
|
-
}
|
|
122
|
-
finally {
|
|
123
|
-
const result_2 = __disposeResources(env_2);
|
|
124
|
-
if (result_2)
|
|
125
|
-
await result_2;
|
|
126
|
-
}
|
|
54
|
+
await runMigrations({ down: false, up: true });
|
|
55
|
+
await using storageFactory = new PostgresBucketStorageFactory({
|
|
56
|
+
config: TEST_CONNECTION_OPTIONS,
|
|
57
|
+
slot_name_prefix: 'test_'
|
|
58
|
+
});
|
|
59
|
+
await truncateTables(storageFactory.db);
|
|
127
60
|
};
|
|
128
61
|
return {
|
|
129
62
|
reportFactory: async (options) => {
|
|
@@ -157,10 +90,8 @@ export function postgresTestSetup(factoryOptions) {
|
|
|
157
90
|
throw ex;
|
|
158
91
|
}
|
|
159
92
|
},
|
|
160
|
-
migrate
|
|
93
|
+
migrate,
|
|
94
|
+
tableIdStrings: true
|
|
161
95
|
};
|
|
162
96
|
}
|
|
163
|
-
export function postgresTestStorageFactoryGenerator(factoryOptions) {
|
|
164
|
-
return postgresTestSetup(factoryOptions).factory;
|
|
165
|
-
}
|
|
166
97
|
//# sourceMappingURL=test-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../../src/utils/test-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-utils.js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