@hot-updater/plugin-core 1.2.0-rc.50 → 1.2.0-rc.52
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/dist/coreApi.d.cts +32 -1
- package/dist/coreApi.d.mts +32 -1
- package/dist/database/adapter.d.cts +12 -0
- package/dist/database/adapter.d.mts +12 -0
- package/dist/databaseRows.cjs +4 -2
- package/dist/databaseRows.mjs +4 -2
- package/dist/engine/core/schema.cjs +55 -3
- package/dist/engine/core/schema.d.cts +27 -0
- package/dist/engine/core/schema.d.mts +27 -0
- package/dist/engine/core/schema.mjs +55 -4
- package/dist/engine/database/fence.cjs +24 -2
- package/dist/engine/database/fence.d.cts +4 -1
- package/dist/engine/database/fence.d.mts +4 -1
- package/dist/engine/database/fence.mjs +24 -3
- package/dist/engine/database/sql/sqlAdapter.cjs +27 -8
- package/dist/engine/database/sql/sqlAdapter.mjs +28 -9
- package/dist/engine/db/engineMigrator.cjs +32 -9
- package/dist/engine/db/engineMigrator.mjs +33 -10
- package/dist/engine/db/engineSql.cjs +25 -0
- package/dist/engine/db/engineSql.d.cts +13 -1
- package/dist/engine/db/engineSql.d.mts +13 -1
- package/dist/engine/db/engineSql.mjs +26 -2
- package/dist/engine/db/engineSqlMigrator.cjs +12 -6
- package/dist/engine/db/engineSqlMigrator.mjs +13 -7
- package/dist/engine/db/schemaSettings.cjs +22 -2
- package/dist/engine/db/schemaSettings.mjs +23 -4
- package/dist/engine/db/settingsMigrator.cjs +41 -21
- package/dist/engine/db/settingsMigrator.mjs +42 -22
- package/dist/engine/db/sqlSchemaState.cjs +36 -8
- package/dist/engine/db/sqlSchemaState.mjs +36 -9
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/releaseCatalogCompiler.cjs +89 -7
- package/dist/releaseCatalogCompiler.d.cts +12 -1
- package/dist/releaseCatalogCompiler.d.mts +12 -1
- package/dist/releaseCatalogCompiler.mjs +89 -8
- package/dist/releaseCatalogMutation.d.cts +8 -2
- package/dist/releaseCatalogMutation.d.mts +8 -2
- package/dist/types/databaseRows.d.cts +7 -0
- package/dist/types/databaseRows.d.mts +7 -0
- package/package.json +2 -2
|
@@ -42,6 +42,17 @@ declare class ReleaseCatalogCompilationError extends Error {
|
|
|
42
42
|
readonly code: "INVALID_RELEASE" | "INVALID_TARGET_RANGE" | "TARGET_COHORT_LIMIT" | "DISTINCT_TARGET_COHORT_LIMIT" | "CATALOG_OVERSIZE";
|
|
43
43
|
constructor(code: "INVALID_RELEASE" | "INVALID_TARGET_RANGE" | "TARGET_COHORT_LIMIT" | "DISTINCT_TARGET_COHORT_LIMIT" | "CATALOG_OVERSIZE", message: string);
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* A stored catalog payload as this release reads it: canonical, with the
|
|
47
|
+
* keys a later release added left out, and whether it had any, a later
|
|
48
|
+
* schema version included. Server core compares a catalog by the fields
|
|
49
|
+
* its compiler writes, and refuses to rewrite one a later release wrote,
|
|
50
|
+
* which would drop what that release added.
|
|
51
|
+
*/
|
|
52
|
+
declare function readCompiledCatalogPayload(payload: string): {
|
|
53
|
+
readonly canonicalPayload: string;
|
|
54
|
+
readonly fromLaterRelease: boolean;
|
|
55
|
+
};
|
|
45
56
|
declare function compileReleaseCatalog(input: {
|
|
46
57
|
readonly strategy: ReleaseStrategy;
|
|
47
58
|
readonly releases: readonly Release[];
|
|
@@ -50,4 +61,4 @@ declare function projectCompiledCatalog(catalog: CompiledReleaseCatalog, appVers
|
|
|
50
61
|
declare function projectCompiledRollbackCatalog(catalog: CompiledReleaseCatalog, appVersion?: string): readonly ReleaseCatalogDescriptor[];
|
|
51
62
|
declare function referenceCompatibleReleases(releases: readonly Release[], appVersion: string): readonly Release[];
|
|
52
63
|
//#endregion
|
|
53
|
-
export { CatalogVersionBound, CompiledCatalogSegment, CompiledReleaseCatalog, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, canonicalizeAppVersion$1 as canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases };
|
|
64
|
+
export { CatalogVersionBound, CompiledCatalogSegment, CompiledReleaseCatalog, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, canonicalizeAppVersion$1 as canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, readCompiledCatalogPayload, referenceCompatibleReleases };
|
|
@@ -91,7 +91,8 @@ function rangeToIntervals(range) {
|
|
|
91
91
|
throw new ReleaseCatalogCompilationError("INVALID_TARGET_RANGE", `Invalid target app-version range: ${range}`);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
/** A release's descriptor; its label only when it has one and `labels`. */
|
|
95
|
+
function releaseDescriptor(release, labels) {
|
|
95
96
|
return {
|
|
96
97
|
releaseId: release.id,
|
|
97
98
|
kind: release.kind,
|
|
@@ -99,7 +100,8 @@ function releaseDescriptor(release) {
|
|
|
99
100
|
rolloutCohortCount: release.rolloutCohortCount,
|
|
100
101
|
targetCohorts: [...new Set(release.targetCohorts)].sort(),
|
|
101
102
|
shouldForceUpdate: release.shouldForceUpdate,
|
|
102
|
-
message: release.message
|
|
103
|
+
message: release.message,
|
|
104
|
+
...labels && typeof release.label === "number" ? { label: release.label } : {}
|
|
103
105
|
};
|
|
104
106
|
}
|
|
105
107
|
function validateReleases(releases, strategy) {
|
|
@@ -307,17 +309,96 @@ function canonicalStringify(value) {
|
|
|
307
309
|
const record = value;
|
|
308
310
|
return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${canonicalStringify(record[key])}`).join(",")}}`;
|
|
309
311
|
}
|
|
312
|
+
const BOUND_SHAPE = {
|
|
313
|
+
inclusive: null,
|
|
314
|
+
version: null
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* Every key this release's compiler writes in a catalog payload, where it
|
|
318
|
+
* writes it: the envelope's, a segment's and its bounds', and a release
|
|
319
|
+
* descriptor's. A key outside it was written by a later release.
|
|
320
|
+
*/
|
|
321
|
+
const COMPILED_CATALOG_SHAPE = {
|
|
322
|
+
fallbackPolicy: null,
|
|
323
|
+
schemaVersion: null,
|
|
324
|
+
strategy: null,
|
|
325
|
+
releaseIndexes: null,
|
|
326
|
+
rollbackReleaseIndexes: null,
|
|
327
|
+
segments: {
|
|
328
|
+
lower: BOUND_SHAPE,
|
|
329
|
+
upper: BOUND_SHAPE,
|
|
330
|
+
releaseIndexes: null,
|
|
331
|
+
rollbackReleaseIndexes: null
|
|
332
|
+
},
|
|
333
|
+
releaseDescriptors: {
|
|
334
|
+
releaseId: null,
|
|
335
|
+
kind: null,
|
|
336
|
+
bundleId: null,
|
|
337
|
+
rolloutCohortCount: null,
|
|
338
|
+
targetCohorts: null,
|
|
339
|
+
shouldForceUpdate: null,
|
|
340
|
+
message: null,
|
|
341
|
+
label: null
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
/**
|
|
345
|
+
* A stored catalog payload as this release reads it: canonical, with the
|
|
346
|
+
* keys a later release added left out, and whether it had any, a later
|
|
347
|
+
* schema version included. Server core compares a catalog by the fields
|
|
348
|
+
* its compiler writes, and refuses to rewrite one a later release wrote,
|
|
349
|
+
* which would drop what that release added.
|
|
350
|
+
*/
|
|
351
|
+
function readCompiledCatalogPayload(payload) {
|
|
352
|
+
let fromLaterRelease = false;
|
|
353
|
+
const known = (value, shape) => {
|
|
354
|
+
if (Array.isArray(value)) return value.map((item) => known(item, shape));
|
|
355
|
+
if (value === null || typeof value !== "object") return value;
|
|
356
|
+
const entries = Object.entries(value).filter(([key]) => {
|
|
357
|
+
if (Object.hasOwn(shape, key)) return true;
|
|
358
|
+
fromLaterRelease = true;
|
|
359
|
+
return false;
|
|
360
|
+
});
|
|
361
|
+
return Object.fromEntries(entries.map(([key, entry]) => {
|
|
362
|
+
const inner = shape[key];
|
|
363
|
+
return [key, inner === null ? entry : known(entry, inner)];
|
|
364
|
+
}));
|
|
365
|
+
};
|
|
366
|
+
let parsed;
|
|
367
|
+
try {
|
|
368
|
+
parsed = JSON.parse(payload);
|
|
369
|
+
} catch {
|
|
370
|
+
parsed = null;
|
|
371
|
+
}
|
|
372
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return {
|
|
373
|
+
canonicalPayload: payload,
|
|
374
|
+
fromLaterRelease: false
|
|
375
|
+
};
|
|
376
|
+
if ("schemaVersion" in parsed && typeof parsed.schemaVersion === "number" && parsed.schemaVersion > RELEASE_CATALOG_SCHEMA_VERSION) fromLaterRelease = true;
|
|
377
|
+
return {
|
|
378
|
+
canonicalPayload: canonicalStringify(known(parsed, COMPILED_CATALOG_SHAPE)),
|
|
379
|
+
fromLaterRelease
|
|
380
|
+
};
|
|
381
|
+
}
|
|
310
382
|
async function compileReleaseCatalog(input) {
|
|
311
383
|
const releases = validateReleases(input.releases, input.strategy);
|
|
312
384
|
const targetCohorts = new Set(releases.flatMap((release) => release.targetCohorts));
|
|
313
385
|
if (targetCohorts.size > MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE) throw new ReleaseCatalogCompilationError("DISTINCT_TARGET_COHORT_LIMIT", `Scope exceeds ${MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE} distinct target cohorts`);
|
|
314
386
|
const { envelope, retainedReleases } = input.strategy === "APP_VERSION" ? compileAppVersion(releases) : compileFingerprint(releases);
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
387
|
+
const compile = (labels) => {
|
|
388
|
+
const payload = {
|
|
389
|
+
...envelope,
|
|
390
|
+
releaseDescriptors: retainedReleases.map((release) => releaseDescriptor(release, labels))
|
|
391
|
+
};
|
|
392
|
+
const canonicalPayload = canonicalStringify(payload);
|
|
393
|
+
return {
|
|
394
|
+
payload,
|
|
395
|
+
canonicalPayload,
|
|
396
|
+
byteSize: new TextEncoder().encode(canonicalPayload).byteLength
|
|
397
|
+
};
|
|
318
398
|
};
|
|
319
|
-
|
|
320
|
-
|
|
399
|
+
let compiled = compile(true);
|
|
400
|
+
if (compiled.byteSize > MAX_COMPILED_CATALOG_BYTES && retainedReleases.some((release) => typeof release.label === "number")) compiled = compile(false);
|
|
401
|
+
const { payload, canonicalPayload, byteSize } = compiled;
|
|
321
402
|
if (byteSize > MAX_COMPILED_CATALOG_BYTES) throw new ReleaseCatalogCompilationError("CATALOG_OVERSIZE", `Compiled Release catalog is ${byteSize} bytes; maximum is ${MAX_COMPILED_CATALOG_BYTES}`);
|
|
322
403
|
return {
|
|
323
404
|
byteSize,
|
|
@@ -370,4 +451,4 @@ function referenceCompatibleReleases(releases, appVersion) {
|
|
|
370
451
|
return releases.filter((release) => release.enabled && release.targetAppVersion !== null && satisfies(canonicalVersion, release.targetAppVersion));
|
|
371
452
|
}
|
|
372
453
|
//#endregion
|
|
373
|
-
export { ReleaseCatalogCompilationError, canonicalizeAppVersion$1 as canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases };
|
|
454
|
+
export { ReleaseCatalogCompilationError, canonicalizeAppVersion$1 as canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, readCompiledCatalogPayload, referenceCompatibleReleases };
|
|
@@ -17,9 +17,9 @@ interface ReleaseCatalogMutationResult {
|
|
|
17
17
|
readonly release: ReleaseRow | null;
|
|
18
18
|
}
|
|
19
19
|
declare class ReleaseCatalogMutationError extends Error {
|
|
20
|
-
readonly code: "CATALOG_GENERATION_EXHAUSTED" | "CATALOG_IDENTITY_MISSING" | "INVALID_SCOPE" | "NON_MONOTONIC_RELEASE_ID" | "RELEASE_NOT_FOUND" | "VERSION_CONFLICT";
|
|
20
|
+
readonly code: "CATALOG_GENERATION_EXHAUSTED" | "CATALOG_IDENTITY_MISSING" | "CATALOG_FROM_LATER_RELEASE" | "INVALID_SCOPE" | "NON_MONOTONIC_RELEASE_ID" | "RELEASE_NOT_FOUND" | "VERSION_CONFLICT";
|
|
21
21
|
readonly name = "ReleaseCatalogMutationError";
|
|
22
|
-
constructor(code: "CATALOG_GENERATION_EXHAUSTED" | "CATALOG_IDENTITY_MISSING" | "INVALID_SCOPE" | "NON_MONOTONIC_RELEASE_ID" | "RELEASE_NOT_FOUND" | "VERSION_CONFLICT", message: string);
|
|
22
|
+
constructor(code: "CATALOG_GENERATION_EXHAUSTED" | "CATALOG_IDENTITY_MISSING" | "CATALOG_FROM_LATER_RELEASE" | "INVALID_SCOPE" | "NON_MONOTONIC_RELEASE_ID" | "RELEASE_NOT_FOUND" | "VERSION_CONFLICT", message: string);
|
|
23
23
|
}
|
|
24
24
|
/** What a release change would write, without writing it. */
|
|
25
25
|
interface ReleaseCatalogMutationPreflight {
|
|
@@ -37,6 +37,12 @@ interface ReleaseCatalogRebuildResult {
|
|
|
37
37
|
}
|
|
38
38
|
interface ReleaseCatalogRebuildPreflight {
|
|
39
39
|
readonly changed: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the rebuild would change only release labels: a catalog
|
|
42
|
+
* compiled before its releases had them. A server before labels leaves it
|
|
43
|
+
* out.
|
|
44
|
+
*/
|
|
45
|
+
readonly labelsOnly?: boolean;
|
|
40
46
|
readonly currentCatalog: ReleaseCatalogRow | null;
|
|
41
47
|
readonly diagnostics: ReleaseCatalogCompilation["diagnostics"];
|
|
42
48
|
readonly projectedCatalog: ReleaseCatalogRow;
|
|
@@ -17,9 +17,9 @@ interface ReleaseCatalogMutationResult {
|
|
|
17
17
|
readonly release: ReleaseRow | null;
|
|
18
18
|
}
|
|
19
19
|
declare class ReleaseCatalogMutationError extends Error {
|
|
20
|
-
readonly code: "CATALOG_GENERATION_EXHAUSTED" | "CATALOG_IDENTITY_MISSING" | "INVALID_SCOPE" | "NON_MONOTONIC_RELEASE_ID" | "RELEASE_NOT_FOUND" | "VERSION_CONFLICT";
|
|
20
|
+
readonly code: "CATALOG_GENERATION_EXHAUSTED" | "CATALOG_IDENTITY_MISSING" | "CATALOG_FROM_LATER_RELEASE" | "INVALID_SCOPE" | "NON_MONOTONIC_RELEASE_ID" | "RELEASE_NOT_FOUND" | "VERSION_CONFLICT";
|
|
21
21
|
readonly name = "ReleaseCatalogMutationError";
|
|
22
|
-
constructor(code: "CATALOG_GENERATION_EXHAUSTED" | "CATALOG_IDENTITY_MISSING" | "INVALID_SCOPE" | "NON_MONOTONIC_RELEASE_ID" | "RELEASE_NOT_FOUND" | "VERSION_CONFLICT", message: string);
|
|
22
|
+
constructor(code: "CATALOG_GENERATION_EXHAUSTED" | "CATALOG_IDENTITY_MISSING" | "CATALOG_FROM_LATER_RELEASE" | "INVALID_SCOPE" | "NON_MONOTONIC_RELEASE_ID" | "RELEASE_NOT_FOUND" | "VERSION_CONFLICT", message: string);
|
|
23
23
|
}
|
|
24
24
|
/** What a release change would write, without writing it. */
|
|
25
25
|
interface ReleaseCatalogMutationPreflight {
|
|
@@ -37,6 +37,12 @@ interface ReleaseCatalogRebuildResult {
|
|
|
37
37
|
}
|
|
38
38
|
interface ReleaseCatalogRebuildPreflight {
|
|
39
39
|
readonly changed: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the rebuild would change only release labels: a catalog
|
|
42
|
+
* compiled before its releases had them. A server before labels leaves it
|
|
43
|
+
* out.
|
|
44
|
+
*/
|
|
45
|
+
readonly labelsOnly?: boolean;
|
|
40
46
|
readonly currentCatalog: ReleaseCatalogRow | null;
|
|
41
47
|
readonly diagnostics: ReleaseCatalogCompilation["diagnostics"];
|
|
42
48
|
readonly projectedCatalog: ReleaseCatalogRow;
|
|
@@ -46,6 +46,13 @@ interface ReleaseRow {
|
|
|
46
46
|
readonly source_release_id: string | null;
|
|
47
47
|
readonly created_at_ms: number;
|
|
48
48
|
readonly updated_at_ms: number;
|
|
49
|
+
/**
|
|
50
|
+
* The release's label, shown `v<label>`: sequential per channel and
|
|
51
|
+
* platform, assigned once and never changed or reused while the channel
|
|
52
|
+
* exists. Null on a row the label fill hasn't reached yet, and left out
|
|
53
|
+
* of a row read through an adapter of an earlier release.
|
|
54
|
+
*/
|
|
55
|
+
readonly label?: number | null;
|
|
49
56
|
}
|
|
50
57
|
interface ReleaseCatalogRow {
|
|
51
58
|
readonly scope_key: string;
|
|
@@ -46,6 +46,13 @@ interface ReleaseRow {
|
|
|
46
46
|
readonly source_release_id: string | null;
|
|
47
47
|
readonly created_at_ms: number;
|
|
48
48
|
readonly updated_at_ms: number;
|
|
49
|
+
/**
|
|
50
|
+
* The release's label, shown `v<label>`: sequential per channel and
|
|
51
|
+
* platform, assigned once and never changed or reused while the channel
|
|
52
|
+
* exists. Null on a row the label fill hasn't reached yet, and left out
|
|
53
|
+
* of a row read through an adapter of an earlier release.
|
|
54
|
+
*/
|
|
55
|
+
readonly label?: number | null;
|
|
49
56
|
}
|
|
50
57
|
interface ReleaseCatalogRow {
|
|
51
58
|
readonly scope_key: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/plugin-core",
|
|
3
|
-
"version": "1.2.0-rc.
|
|
3
|
+
"version": "1.2.0-rc.52",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"es-toolkit": "^1.32.0",
|
|
46
46
|
"mime": "^4.0.4",
|
|
47
47
|
"verkit": "0.4.0",
|
|
48
|
-
"@hot-updater/protocol": "1.2.0-rc.
|
|
48
|
+
"@hot-updater/protocol": "1.2.0-rc.52"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@electric-sql/pglite": "0.4.1",
|