@webda/core 4.0.0-beta.8 → 4.0.0-beta.9
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/lib/application/application.d.ts +1 -0
- package/lib/application/application.d.ts.map +1 -1
- package/lib/application/application.js +9 -3
- package/lib/application/application.js.map +1 -1
- package/lib/application/model-types.d.ts +63 -0
- package/lib/application/model-types.d.ts.map +1 -0
- package/lib/application/model-types.js +59 -0
- package/lib/application/model-types.js.map +1 -0
- package/lib/bin/cli.d.ts +18 -0
- package/lib/bin/cli.d.ts.map +1 -1
- package/lib/bin/cli.js +38 -3
- package/lib/bin/cli.js.map +1 -1
- package/lib/core/operations.d.ts +17 -0
- package/lib/core/operations.d.ts.map +1 -1
- package/lib/core/operations.js +1 -1
- package/lib/core/operations.js.map +1 -1
- package/lib/index.d.ts +5 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/models/decorator.d.ts +21 -0
- package/lib/models/decorator.d.ts.map +1 -1
- package/lib/models/decorator.js +18 -0
- package/lib/models/decorator.js.map +1 -1
- package/lib/rest/restoperationstransport.service.d.ts +6 -0
- package/lib/rest/restoperationstransport.service.d.ts.map +1 -1
- package/lib/rest/restoperationstransport.service.js +19 -1
- package/lib/rest/restoperationstransport.service.js.map +1 -1
- package/lib/services/service.d.ts.map +1 -1
- package/lib/services/service.js +4 -1
- package/lib/services/service.js.map +1 -1
- package/lib/services/servicecommands.d.ts.map +1 -1
- package/lib/services/servicecommands.js +14 -1
- package/lib/services/servicecommands.js.map +1 -1
- package/lib/stores/capability.d.ts +16 -0
- package/lib/stores/capability.d.ts.map +1 -0
- package/lib/stores/capability.js +5 -0
- package/lib/stores/capability.js.map +1 -0
- package/lib/stores/memory.service.d.ts +30 -1
- package/lib/stores/memory.service.d.ts.map +1 -1
- package/lib/stores/memory.service.js +47 -1
- package/lib/stores/memory.service.js.map +1 -1
- package/lib/stores/migration.d.ts +306 -0
- package/lib/stores/migration.d.ts.map +1 -0
- package/lib/stores/migration.js +280 -0
- package/lib/stores/migration.js.map +1 -0
- package/lib/stores/store.d.ts +151 -17
- package/lib/stores/store.d.ts.map +1 -1
- package/lib/stores/store.js +421 -21
- package/lib/stores/store.js.map +1 -1
- package/lib/test/index.d.ts +2 -0
- package/lib/test/index.d.ts.map +1 -1
- package/lib/test/index.js +3 -0
- package/lib/test/index.js.map +1 -1
- package/lib/test/legacy-types.d.ts +146 -0
- package/lib/test/legacy-types.d.ts.map +1 -0
- package/lib/test/legacy-types.fixture.model.d.ts +38 -0
- package/lib/test/legacy-types.fixture.model.d.ts.map +1 -0
- package/lib/test/legacy-types.fixture.model.js +38 -0
- package/lib/test/legacy-types.fixture.model.js.map +1 -0
- package/lib/test/legacy-types.js +481 -0
- package/lib/test/legacy-types.js.map +1 -0
- package/package.json +8 -8
- package/webda.module.json +48 -22
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { getTypeResolver } from "@webda/models";
|
|
2
|
+
import * as WebdaError from "../errors/errors.js";
|
|
3
|
+
import { classifyStoredType, UNTYPED } from "../application/model-types.js";
|
|
4
|
+
/**
|
|
5
|
+
* The store has no raw access yet: it cannot run migrations
|
|
6
|
+
*/
|
|
7
|
+
export class MigrationUnsupported extends WebdaError.CodeError {
|
|
8
|
+
/**
|
|
9
|
+
* @param store - the store name
|
|
10
|
+
*/
|
|
11
|
+
constructor(store) {
|
|
12
|
+
super("MIGRATION_UNSUPPORTED", `Store ${store} has no raw access: it cannot run migrations`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parse a value of a key/value storage as a raw row
|
|
17
|
+
* @param table - table name
|
|
18
|
+
* @param key - storage key
|
|
19
|
+
* @param value - stored JSON string (or object, for old persistence files)
|
|
20
|
+
* @returns the row, flagged unreadable when the value is not a JSON object
|
|
21
|
+
*/
|
|
22
|
+
export function parseRawValue(table, key, value) {
|
|
23
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
24
|
+
return { table, key, data: { ...value } };
|
|
25
|
+
}
|
|
26
|
+
if (typeof value === "string") {
|
|
27
|
+
try {
|
|
28
|
+
const data = JSON.parse(value);
|
|
29
|
+
if (data !== null && typeof data === "object" && !Array.isArray(data)) {
|
|
30
|
+
return { table, key, data };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// Not JSON: reported as unreadable below
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return { table, key, data: {}, unreadable: true };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Read a page of a key/value storage, in key order
|
|
41
|
+
*
|
|
42
|
+
* The token is the last key of the page, so rows added or removed meanwhile do not shift the next page.
|
|
43
|
+
* @param map - the storage
|
|
44
|
+
* @param table - table name of the rows
|
|
45
|
+
* @param batchSize - rows per page
|
|
46
|
+
* @param token - token of the previous page
|
|
47
|
+
* @returns the page
|
|
48
|
+
*/
|
|
49
|
+
export function mapRawPage(map, table, batchSize, token) {
|
|
50
|
+
const keys = [...map.keys()].sort();
|
|
51
|
+
let start = 0;
|
|
52
|
+
if (token !== undefined) {
|
|
53
|
+
start = keys.findIndex(key => key > token);
|
|
54
|
+
if (start < 0)
|
|
55
|
+
start = keys.length;
|
|
56
|
+
}
|
|
57
|
+
const slice = keys.slice(start, start + batchSize);
|
|
58
|
+
const rows = [];
|
|
59
|
+
for (const key of slice) {
|
|
60
|
+
const value = map.get(key);
|
|
61
|
+
if (value !== undefined)
|
|
62
|
+
rows.push(parseRawValue(table, key, value));
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
rows,
|
|
66
|
+
continuationToken: start + batchSize < keys.length ? slice[slice.length - 1] : undefined
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Set top-level fields of a row of a key/value storage
|
|
71
|
+
* @param map - the storage
|
|
72
|
+
* @param key - storage key
|
|
73
|
+
* @param patch - fields to set
|
|
74
|
+
*/
|
|
75
|
+
export function mapRawPatch(map, key, patch) {
|
|
76
|
+
const value = map.get(key);
|
|
77
|
+
if (value === undefined) {
|
|
78
|
+
throw new Error(`Raw row not found: ${key}`);
|
|
79
|
+
}
|
|
80
|
+
const row = parseRawValue("", key, value);
|
|
81
|
+
if (row.unreadable) {
|
|
82
|
+
throw new Error(`Raw row ${key} is not a JSON object: it cannot be patched`);
|
|
83
|
+
}
|
|
84
|
+
map.set(key, JSON.stringify({ ...row.data, ...patch }));
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Default rows per page
|
|
88
|
+
*/
|
|
89
|
+
export const DEFAULT_MIGRATION_BATCH = 500;
|
|
90
|
+
/**
|
|
91
|
+
* Default lease duration: 5 minutes
|
|
92
|
+
*/
|
|
93
|
+
export const DEFAULT_MIGRATION_LEASE = 5 * 60 * 1000;
|
|
94
|
+
/**
|
|
95
|
+
* Another runner holds the lease of the migration
|
|
96
|
+
*/
|
|
97
|
+
export class MigrationAlreadyRunning extends WebdaError.CodeError {
|
|
98
|
+
/**
|
|
99
|
+
* @param id - registry entry
|
|
100
|
+
* @param owner - runner holding the lease
|
|
101
|
+
* @param until - end of its lease, epoch ms
|
|
102
|
+
*/
|
|
103
|
+
constructor(id, owner, until) {
|
|
104
|
+
super("MIGRATION_ALREADY_RUNNING", `Migration ${id} is already running (runner ${owner ?? "unknown"}, lease until ${new Date(until).toISOString()})`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Increment a counter
|
|
109
|
+
* @param counts - the counters
|
|
110
|
+
* @param key - the counter
|
|
111
|
+
* @param n - the increment
|
|
112
|
+
*/
|
|
113
|
+
export function incrementCount(counts, key, n = 1) {
|
|
114
|
+
counts[key] = (counts[key] ?? 0) + n;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* @returns an empty table report
|
|
118
|
+
*/
|
|
119
|
+
export function emptyTableReport() {
|
|
120
|
+
return { scanned: 0, updated: 0, byChange: {}, unknown: {} };
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @returns the progress of a fresh run (the keys set to undefined clear a previous run when saved)
|
|
124
|
+
*/
|
|
125
|
+
export function emptyProgress() {
|
|
126
|
+
const now = Date.now();
|
|
127
|
+
return {
|
|
128
|
+
table: undefined,
|
|
129
|
+
continuationToken: undefined,
|
|
130
|
+
scanned: 0,
|
|
131
|
+
updated: 0,
|
|
132
|
+
unknown: 0,
|
|
133
|
+
done: false,
|
|
134
|
+
startedAt: now,
|
|
135
|
+
updatedAt: now,
|
|
136
|
+
leaseUntil: 0,
|
|
137
|
+
owner: undefined,
|
|
138
|
+
tables: {}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Read a Registry entry as a progress
|
|
143
|
+
* @param entry - the entry
|
|
144
|
+
* @returns the progress
|
|
145
|
+
*/
|
|
146
|
+
export function toMigrationProgress(entry) {
|
|
147
|
+
return {
|
|
148
|
+
continuationToken: entry?.continuationToken,
|
|
149
|
+
table: entry?.table,
|
|
150
|
+
scanned: entry?.scanned ?? 0,
|
|
151
|
+
updated: entry?.updated ?? 0,
|
|
152
|
+
unknown: entry?.unknown ?? 0,
|
|
153
|
+
done: !!entry?.done,
|
|
154
|
+
startedAt: entry?.startedAt ?? 0,
|
|
155
|
+
updatedAt: entry?.updatedAt ?? 0,
|
|
156
|
+
leaseUntil: Number(entry?.leaseUntil ?? 0),
|
|
157
|
+
owner: entry?.owner,
|
|
158
|
+
tables: entry?.tables ?? {}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Totals of a report, for the progress entry
|
|
163
|
+
* @param report - the report
|
|
164
|
+
* @returns the totals and the tables
|
|
165
|
+
*/
|
|
166
|
+
export function migrationTotals(report) {
|
|
167
|
+
let scanned = 0;
|
|
168
|
+
let updated = 0;
|
|
169
|
+
let unknown = 0;
|
|
170
|
+
for (const table of Object.values(report.tables)) {
|
|
171
|
+
scanned += table.scanned;
|
|
172
|
+
updated += table.updated;
|
|
173
|
+
unknown += Object.values(table.unknown).reduce((sum, n) => sum + n, 0);
|
|
174
|
+
}
|
|
175
|
+
return { scanned, updated, unknown, tables: report.tables };
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Entries of a record sorted by key, by UTF-16 code unit (the default sort order)
|
|
179
|
+
* @param record - the record
|
|
180
|
+
* @returns the entries
|
|
181
|
+
*/
|
|
182
|
+
function sortedEntries(record) {
|
|
183
|
+
return Object.keys(record)
|
|
184
|
+
.sort()
|
|
185
|
+
.map(key => [key, record[key]]);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Human-readable report, one line per table and per change
|
|
189
|
+
* @param report - the report
|
|
190
|
+
* @param resolver - resolver telling unknown from ambiguous types
|
|
191
|
+
* @returns the text
|
|
192
|
+
*/
|
|
193
|
+
export function formatMigrationReport(report, resolver = getTypeResolver()) {
|
|
194
|
+
const flags = [report.dryRun ? "dry run" : undefined, report.resumed ? "resumed" : undefined].filter(Boolean);
|
|
195
|
+
const lines = [`Store ${report.store}: migration ${report.name}${flags.length ? ` (${flags.join(", ")})` : ""}`];
|
|
196
|
+
for (const [table, tableReport] of Object.entries(report.tables)) {
|
|
197
|
+
lines.push(` ${table}: ${tableReport.scanned} scanned, ${tableReport.updated} ${report.dryRun ? "to update" : "updated"}`);
|
|
198
|
+
for (const [change, n] of sortedEntries(tableReport.byChange)) {
|
|
199
|
+
lines.push(` ${change}: ${n}`);
|
|
200
|
+
}
|
|
201
|
+
for (const [type, n] of sortedEntries(tableReport.unknown)) {
|
|
202
|
+
lines.push(` ${resolver.resolve(type).status === "ambiguous" ? "ambiguous" : "unknown"} ${type}: ${n}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return lines.join("\n");
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Read the rows of raw tables page by page, in table order, stopping after `maxRows` rows
|
|
209
|
+
* @param pages - reads a page of a table (a store's `rawPages`)
|
|
210
|
+
* @param tables - the tables to read
|
|
211
|
+
* @param maxRows - the row limit
|
|
212
|
+
* @param onRow - called for each row
|
|
213
|
+
* @returns true when rows were left unread because of the limit
|
|
214
|
+
*/
|
|
215
|
+
export async function scanRawRows(pages, tables, maxRows, onRow) {
|
|
216
|
+
let seen = 0;
|
|
217
|
+
for (const [index, table] of tables.entries()) {
|
|
218
|
+
let token;
|
|
219
|
+
do {
|
|
220
|
+
if (seen >= maxRows)
|
|
221
|
+
return true;
|
|
222
|
+
const page = await pages(table.name, Math.min(1000, maxRows - seen), token);
|
|
223
|
+
for (const row of page.rows) {
|
|
224
|
+
onRow(row);
|
|
225
|
+
seen++;
|
|
226
|
+
}
|
|
227
|
+
token = page.continuationToken;
|
|
228
|
+
} while (token);
|
|
229
|
+
if (seen >= maxRows && index < tables.length - 1)
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Default rows scanned by the startup type check of stores without a native count
|
|
236
|
+
*/
|
|
237
|
+
export const DEFAULT_TYPE_CHECK_ROWS = 10000;
|
|
238
|
+
/**
|
|
239
|
+
* Summarize stored type counts into the startup WARN
|
|
240
|
+
* @param store - store name
|
|
241
|
+
* @param counts - the counts
|
|
242
|
+
* @param roots - root model of each table
|
|
243
|
+
* @param maxRows - the scan limit, for the message
|
|
244
|
+
* @param resolver - the resolver
|
|
245
|
+
* @returns the summary
|
|
246
|
+
*/
|
|
247
|
+
export function summarizeStoredTypes(store, counts, roots, maxRows, resolver = getTypeResolver()) {
|
|
248
|
+
const summary = { legacy: 0, untyped: 0, unknown: 0, truncated: counts.truncated };
|
|
249
|
+
const parts = [];
|
|
250
|
+
for (const [table, types] of Object.entries(counts.tables)) {
|
|
251
|
+
const entries = [];
|
|
252
|
+
for (const [type, n] of sortedEntries(types)) {
|
|
253
|
+
const kind = classifyStoredType(type === UNTYPED ? undefined : type, roots.get(table), resolver);
|
|
254
|
+
if (kind.kind === "current" || (kind.kind === "untyped" && !kind.to))
|
|
255
|
+
continue;
|
|
256
|
+
if (kind.kind === "legacy") {
|
|
257
|
+
summary.legacy += n;
|
|
258
|
+
entries.push(`'${type}' → ${kind.to}: ${n}`);
|
|
259
|
+
}
|
|
260
|
+
else if (kind.kind === "untyped") {
|
|
261
|
+
summary.untyped += n;
|
|
262
|
+
entries.push(`untyped → ${kind.to}: ${n}`);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
summary.unknown += n;
|
|
266
|
+
entries.push(`${kind.kind} '${type}': ${n}`);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (entries.length)
|
|
270
|
+
parts.push(`${table} (${entries.join(", ")})`);
|
|
271
|
+
}
|
|
272
|
+
if (parts.length) {
|
|
273
|
+
summary.message =
|
|
274
|
+
`Store ${store} holds rows with legacy, untyped or unknown types: ${parts.join("; ")}` +
|
|
275
|
+
`${counts.truncated ? ` — at least: the check stopped after ${maxRows} rows` : ""}. ` +
|
|
276
|
+
"Run `webda migrate` to rewrite them.";
|
|
277
|
+
}
|
|
278
|
+
return summary;
|
|
279
|
+
}
|
|
280
|
+
//# sourceMappingURL=migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.js","sourceRoot":"","sources":["../../src/stores/migration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA2C,MAAM,eAAe,CAAC;AACzF,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AA0D5E;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,UAAU,CAAC,SAAS;IAC5D;;OAEG;IACH,YAAY,KAAa;QACvB,KAAK,CAAC,uBAAuB,EAAE,SAAS,KAAK,8CAA8C,CAAC,CAAC;IAC/F,CAAC;CACF;AAED;;;;;;GAMG;AACH,MA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AAO,CAAC,OAAO,IAAI,CAAC,CAAC;gBACrB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;QACD,IAAI,OAAO,CAAC,MAAM;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACjB,OAAO,CAAC,OAAO;YACb,SAAS,KAAK,sDAAsD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBACtF,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,wCAAwC,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI;gBACrF,sCAAsC,CAAC;IAC3C,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/lib/stores/store.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { Service } from "../services/service.js";
|
|
|
6
6
|
import * as WebdaQL from "@webda/ql";
|
|
7
7
|
import type { WebdaQLString } from "@webda/ql";
|
|
8
8
|
import type { ModelMetadata } from "@webda/compiler";
|
|
9
|
+
import { type MigrationLease, type MigrationOptions, type MigrationPatcher, type MigrationProgress, type MigrationReport, type RawPage, type RawPatch, type RawTable, type StoredTypeCounts, type TypeCheckSummary } from "./migration.js";
|
|
9
10
|
/** Error thrown when an item is not found in a store */
|
|
10
11
|
export declare class StoreNotFoundError extends WebdaError.CodeError {
|
|
11
12
|
/** Create a new StoreNotFoundError
|
|
@@ -209,19 +210,6 @@ export declare class StoreParameters extends ServiceParameters {
|
|
|
209
210
|
* @default false
|
|
210
211
|
*/
|
|
211
212
|
strict?: boolean;
|
|
212
|
-
/**
|
|
213
|
-
* When __type model not found, use the model
|
|
214
|
-
* If strict is setup this parameter is not used
|
|
215
|
-
*
|
|
216
|
-
* @default true
|
|
217
|
-
*/
|
|
218
|
-
defaultModel?: boolean;
|
|
219
|
-
/**
|
|
220
|
-
* If set, Store will ignore the __type
|
|
221
|
-
*
|
|
222
|
-
* @default false
|
|
223
|
-
*/
|
|
224
|
-
forceModel?: boolean;
|
|
225
213
|
/**
|
|
226
214
|
* Slow query threshold
|
|
227
215
|
*
|
|
@@ -243,17 +231,26 @@ export declare class StoreParameters extends ServiceParameters {
|
|
|
243
231
|
*/
|
|
244
232
|
maxGroups?: number;
|
|
245
233
|
/**
|
|
246
|
-
*
|
|
234
|
+
* Startup check of the stored types: one WARN listing the legacy, untyped and unknown types found
|
|
247
235
|
*/
|
|
248
|
-
|
|
249
|
-
|
|
236
|
+
typeCheck?: {
|
|
237
|
+
/**
|
|
238
|
+
* @default true
|
|
239
|
+
*/
|
|
240
|
+
enabled?: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Rows scanned at most by stores without a native count; beyond, the counts are "at least"
|
|
243
|
+
*
|
|
244
|
+
* @default 10000
|
|
245
|
+
*/
|
|
246
|
+
maxRows?: number;
|
|
250
247
|
};
|
|
251
248
|
/**
|
|
252
249
|
* Disable default memory cache
|
|
253
250
|
*/
|
|
254
251
|
noCache?: boolean;
|
|
255
252
|
/**
|
|
256
|
-
* Load store parameters with defaults for
|
|
253
|
+
* Load store parameters with defaults for models, strict mode and the startup type check
|
|
257
254
|
* @param params - the service parameters
|
|
258
255
|
* @returns the result
|
|
259
256
|
*/
|
|
@@ -361,6 +358,143 @@ declare abstract class Store<K extends StoreParameters = StoreParameters, E exte
|
|
|
361
358
|
* @returns the array of model classes managed by this store
|
|
362
359
|
*/
|
|
363
360
|
getModels(): ModelClass[];
|
|
361
|
+
/**
|
|
362
|
+
* Tables of this store for raw access, each with the model owning its untyped rows
|
|
363
|
+
*
|
|
364
|
+
* Stores without raw access return undefined: `webda migrate` and the startup type check skip them.
|
|
365
|
+
* @returns the tables, or undefined when the store has no raw access
|
|
366
|
+
*/
|
|
367
|
+
getRawTables(): RawTable[] | undefined;
|
|
368
|
+
/**
|
|
369
|
+
* Read a page of raw rows of a table: no type filter, no hydration
|
|
370
|
+
* @param _table - table name, from {@link getRawTables}
|
|
371
|
+
* @param _batchSize - rows per page
|
|
372
|
+
* @param _token - token of the previous page
|
|
373
|
+
* @returns the page
|
|
374
|
+
*/
|
|
375
|
+
rawPages(_table: string, _batchSize: number, _token?: string): Promise<RawPage>;
|
|
376
|
+
/**
|
|
377
|
+
* Set top-level fields of a raw row: no type filter, no hydration, no event
|
|
378
|
+
* @param _table - table name, from {@link getRawTables}
|
|
379
|
+
* @param _key - storage key of the row
|
|
380
|
+
* @param _patch - fields to set
|
|
381
|
+
*/
|
|
382
|
+
rawPatch(_table: string, _key: string, _patch: RawPatch): Promise<void>;
|
|
383
|
+
/**
|
|
384
|
+
* Model owning the untyped rows of a single-table store: the first model of `models`
|
|
385
|
+
* @returns the model, undefined when unknown
|
|
386
|
+
*/
|
|
387
|
+
protected getTableRoot(): ModelClass | undefined;
|
|
388
|
+
/**
|
|
389
|
+
* Refuse a table that is not the single table of this store
|
|
390
|
+
* @param table - the requested table
|
|
391
|
+
*/
|
|
392
|
+
protected checkSingleTable(table: string): void;
|
|
393
|
+
/**
|
|
394
|
+
* @param name - migration name
|
|
395
|
+
* @returns the Registry entry of the migration
|
|
396
|
+
*/
|
|
397
|
+
protected migrationId(name: string): string;
|
|
398
|
+
/**
|
|
399
|
+
* @param name - migration name
|
|
400
|
+
* @returns the stored progress, undefined when the migration never ran
|
|
401
|
+
*/
|
|
402
|
+
getMigrationProgress(name: string): Promise<MigrationProgress | undefined>;
|
|
403
|
+
/**
|
|
404
|
+
* Forget the progress of a migration: the next run starts over
|
|
405
|
+
* @param name - migration name
|
|
406
|
+
*/
|
|
407
|
+
deleteMigrationProgress(name: string): Promise<void>;
|
|
408
|
+
/**
|
|
409
|
+
* Take the lease of a migration: free, or expired (a crashed runner)
|
|
410
|
+
* @param name - migration name
|
|
411
|
+
* @param leaseDuration - lease duration in ms
|
|
412
|
+
* @returns the lease
|
|
413
|
+
* @throws MigrationAlreadyRunning when another runner holds a live lease
|
|
414
|
+
*/
|
|
415
|
+
protected acquireMigrationLease(name: string, leaseDuration?: number): Promise<MigrationLease>;
|
|
416
|
+
/**
|
|
417
|
+
* After a failed conditional patch, tell a competing runner from any other Registry failure
|
|
418
|
+
* @param id - Registry entry of the migration
|
|
419
|
+
* @param owner - lease owner the patch expected
|
|
420
|
+
* @param leaseUntil - lease end the patch expected
|
|
421
|
+
* @param self - owner of this runner: a lease it holds is not a competitor's
|
|
422
|
+
* @returns the lease of another runner when the lease changed under the patch, undefined otherwise (the entry is
|
|
423
|
+
* unchanged, held by this runner, or cannot be read)
|
|
424
|
+
*/
|
|
425
|
+
protected competingMigrationLease(id: string, owner: string | undefined, leaseUntil: number, self: string): Promise<{
|
|
426
|
+
owner?: string;
|
|
427
|
+
leaseUntil: number;
|
|
428
|
+
} | undefined>;
|
|
429
|
+
/**
|
|
430
|
+
* Save the progress and renew the lease, conditionally on the lease this runner holds
|
|
431
|
+
* @param lease - the lease
|
|
432
|
+
* @param update - progress fields to set
|
|
433
|
+
* @throws MigrationAlreadyRunning when the lease was taken over, the Registry error otherwise
|
|
434
|
+
*/
|
|
435
|
+
protected saveMigrationProgress(lease: MigrationLease, update: Partial<MigrationProgress>): Promise<void>;
|
|
436
|
+
/**
|
|
437
|
+
* Renew the lease before writing a page
|
|
438
|
+
* @param lease - the lease
|
|
439
|
+
*/
|
|
440
|
+
protected renewMigrationLease(lease: MigrationLease): Promise<void>;
|
|
441
|
+
/**
|
|
442
|
+
* Release the lease, saving the last progress; a lease lost meanwhile is left to its new owner
|
|
443
|
+
* @param lease - the lease
|
|
444
|
+
* @param update - progress fields to set
|
|
445
|
+
* @throws the Registry error when the release failed while the lease was still this runner's
|
|
446
|
+
*/
|
|
447
|
+
protected releaseMigrationLease(lease: MigrationLease, update?: Partial<MigrationProgress>): Promise<void>;
|
|
448
|
+
/**
|
|
449
|
+
* Run a migration on every raw row of every table of the store, the rows the type filter excludes included
|
|
450
|
+
*
|
|
451
|
+
* Resumable: the progress is saved in the Registry after each page and an interrupted run continues from it.
|
|
452
|
+
* Exclusive: a lease (renewed every page) makes a second runner fail fast with {@link MigrationAlreadyRunning}.
|
|
453
|
+
* Idempotent: patchers return undefined for migrated rows, and a finished migration scans again on the next run.
|
|
454
|
+
* @param name - migration name
|
|
455
|
+
* @param patcher - computes the patch of a row
|
|
456
|
+
* @param options - batch size, dry run, lease duration
|
|
457
|
+
* @returns the report
|
|
458
|
+
*/
|
|
459
|
+
migration(name: string, patcher: MigrationPatcher, options?: MigrationOptions): Promise<MigrationReport>;
|
|
460
|
+
/**
|
|
461
|
+
* Patcher of the built-in `types` migration: untyped rows get the table root identifier, legacy types their
|
|
462
|
+
* current identifier; unknown, ambiguous and unreadable rows are counted and left as they are
|
|
463
|
+
* @returns the patcher
|
|
464
|
+
*/
|
|
465
|
+
protected typesPatcher(): MigrationPatcher;
|
|
466
|
+
/**
|
|
467
|
+
* Rewrite the Webda 3 types of every row to the current identifiers (the built-in `types` migration)
|
|
468
|
+
*
|
|
469
|
+
* Stores with a native bulk update override this method and return the same report.
|
|
470
|
+
* @param options - batch size, dry run, lease duration
|
|
471
|
+
* @returns the report
|
|
472
|
+
*/
|
|
473
|
+
migrateTypes(options?: MigrationOptions): Promise<MigrationReport>;
|
|
474
|
+
/**
|
|
475
|
+
* Count the rows by stored `__type`, scanning at most `maxRows` rows
|
|
476
|
+
*
|
|
477
|
+
* Stores able to `GROUP BY` override it with an exact count.
|
|
478
|
+
* @param maxRows - scan limit
|
|
479
|
+
* @returns the counts
|
|
480
|
+
*/
|
|
481
|
+
countStoredTypes(maxRows: number): Promise<StoredTypeCounts>;
|
|
482
|
+
/**
|
|
483
|
+
* Startup type check: one WARN when rows hold legacy, untyped or unknown types
|
|
484
|
+
* @returns the summary, undefined when disabled or the store has no raw access
|
|
485
|
+
*/
|
|
486
|
+
checkStoredTypes(): Promise<TypeCheckSummary | undefined>;
|
|
487
|
+
/**
|
|
488
|
+
* Body of the `migrate` command of the stores: run the `types` migration and print its report
|
|
489
|
+
*
|
|
490
|
+
* Stores declare `@Command("migrate", { phase: "initialized" }) migrate(dryRun = false, batch = 500,
|
|
491
|
+
* allowUnknown = false)` calling this method: composable commands pass their arguments by position.
|
|
492
|
+
* @param dryRun - count, write nothing
|
|
493
|
+
* @param batch - rows per page
|
|
494
|
+
* @param allowUnknown - exit with 0 even when rows keep an unknown or ambiguous type
|
|
495
|
+
* @returns the exit code
|
|
496
|
+
*/
|
|
497
|
+
migrateCommand(dryRun?: boolean, batch?: number, allowUnknown?: boolean): Promise<number>;
|
|
364
498
|
/**
|
|
365
499
|
* Return if a model is handled by the store
|
|
366
500
|
* @param model - the model to use
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/stores/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,UAAU,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAI/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/stores/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,UAAU,MAA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