@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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HOT_UPDATER_SCHEMA_VERSION } from "../core/schema.mjs";
|
|
2
|
-
import { HotUpdaterSchemaMigrationRequiredError, SETTINGS_TABLE, isMissingSchemaError } from "../database/fence.mjs";
|
|
2
|
+
import { HotUpdaterSchemaMigrationRequiredError, SETTINGS_TABLE, compareVersions, isMissingSchemaError } from "../database/fence.mjs";
|
|
3
3
|
import { getEmptyMigrationResult } from "./fixedMigratorShared.mjs";
|
|
4
4
|
import { quoteSql } from "../database/sql/sqlSchema.mjs";
|
|
5
5
|
import { settingsStatements } from "./engineSql.mjs";
|
|
6
|
-
import { collationStatements, missingSqlSchema, readSqlSchemaState, targetShapes } from "./sqlSchemaState.mjs";
|
|
6
|
+
import { addColumnStatements, collationStatements, missingSqlSchema, readSqlSchemaState, targetShapes } from "./sqlSchemaState.mjs";
|
|
7
7
|
//#region src/engine/db/settingsMigrator.ts
|
|
8
8
|
/**
|
|
9
9
|
* Every settings row by key and value alone, so a v0 layout reads too; null
|
|
@@ -36,17 +36,6 @@ const refuseV0Database = (adapterName, stored) => {
|
|
|
36
36
|
if (typeof version !== "string" || stored.has("schema.engine")) return;
|
|
37
37
|
throw new HotUpdaterSchemaMigrationRequiredError(adapterName, version);
|
|
38
38
|
};
|
|
39
|
-
/** Compares dotted numeric versions, such as "1" and "1.2.0"; NaN when either is not one. */
|
|
40
|
-
const compareVersions = (left, right) => {
|
|
41
|
-
const parse = (version) => /^\d+(?:\.\d+)*$/u.test(version) ? version.split(".").map(Number) : [NaN];
|
|
42
|
-
const [a, b] = [parse(left), parse(right)];
|
|
43
|
-
if ([...a, ...b].some(Number.isNaN)) return NaN;
|
|
44
|
-
for (let index = 0; index < Math.max(a.length, b.length); index += 1) {
|
|
45
|
-
const difference = (a[index] ?? 0) - (b[index] ?? 0);
|
|
46
|
-
if (difference !== 0) return difference;
|
|
47
|
-
}
|
|
48
|
-
return 0;
|
|
49
|
-
};
|
|
50
39
|
/**
|
|
51
40
|
* The settings whose versions only move forward when a `ToolingTarget` names
|
|
52
41
|
* none. `schema.engine` is a storage layout, not a release: a store refuses
|
|
@@ -77,7 +66,7 @@ const refuseNewerSchema = (adapterName, stored, settings, ordered = DEFAULT_ORDE
|
|
|
77
66
|
throw new Error(`${adapterName}: the database was migrated by Hot Updater ${core.found} (${newer.map(({ key, found, expected }) => `${key} "${found}", this CLI's "${expected}"`).join("; ")}). Upgrade hot-updater to ${core.found} or later; nothing was written.`);
|
|
78
67
|
};
|
|
79
68
|
/**
|
|
80
|
-
* The tables or indexes an ORM has yet to apply, found before `db migrate`
|
|
69
|
+
* The tables, late columns or indexes an ORM has yet to apply, found before `db migrate`
|
|
81
70
|
* writes the settings rows, so the fence never passes over missing tables.
|
|
82
71
|
*/
|
|
83
72
|
var HotUpdaterSchemaTablesMissingError = class extends Error {
|
|
@@ -86,7 +75,11 @@ var HotUpdaterSchemaTablesMissingError = class extends Error {
|
|
|
86
75
|
applyTables;
|
|
87
76
|
constructor(adapterName, missing, applyTables) {
|
|
88
77
|
const all = missing.tables.includes(SETTINGS_TABLE.name);
|
|
89
|
-
const items = [
|
|
78
|
+
const items = [
|
|
79
|
+
...missing.tables.length === 0 ? [] : [`table${missing.tables.length === 1 ? "" : "s"} ${missing.tables.join(", ")}`],
|
|
80
|
+
...missing.columns.length === 0 ? [] : [`column${missing.columns.length === 1 ? "" : "s"} ${missing.columns.map(({ table, column }) => `${table}.${column.name}`).join(", ")}`],
|
|
81
|
+
...missing.indexes.length === 0 ? [] : [`index${missing.indexes.length === 1 ? "" : "es"} ${missing.indexes.map(({ index }) => index).join(", ")}`]
|
|
82
|
+
];
|
|
90
83
|
super(`${adapterName}: ${all ? "the Hot Updater tables are missing" : `the database lacks ${items.join(" and ")}`}. Run \`hot-updater db generate\`, apply it with ${applyTables}, then migrate again.`);
|
|
91
84
|
this.adapterName = adapterName;
|
|
92
85
|
this.missing = missing;
|
|
@@ -112,19 +105,46 @@ const createSettingsMigrator = (options) => {
|
|
|
112
105
|
refuseNewerSchema(options.adapterName, stored, options.settings, options.ordered);
|
|
113
106
|
const shapes = targetShapes(executor.dialect, options.schema);
|
|
114
107
|
const missing = missingSqlSchema(shapes, await readSqlSchemaState(executor));
|
|
115
|
-
|
|
108
|
+
const lateTables = new Set(missing.columns.map(({ table }) => table));
|
|
109
|
+
const lateIndexes = missing.indexes.filter(({ table }) => lateTables.has(table));
|
|
110
|
+
const blocking = missing.indexes.filter(({ table }) => !lateTables.has(table));
|
|
111
|
+
if (missing.tables.length > 0 || blocking.length > 0) throw new HotUpdaterSchemaTablesMissingError(options.adapterName, {
|
|
112
|
+
tables: missing.tables,
|
|
113
|
+
columns: [],
|
|
114
|
+
indexes: blocking
|
|
115
|
+
}, options.applyTables);
|
|
116
|
+
const quote = (name) => quoteSql(executor.dialect, name);
|
|
117
|
+
const lateSchema = [...addColumnStatements(executor.dialect, missing.columns), ...lateIndexes.map(({ table, index: name }) => {
|
|
118
|
+
const index = shapes.find((shape) => shape.name === table).indexes.find((candidate) => candidate.kind === "index" && candidate.name === name);
|
|
119
|
+
return index.kind === "index" ? `CREATE ${index.unique ? "UNIQUE " : ""}INDEX ${quote(name)} ON ${quote(table)} (${index.columns.map(quote).join(", ")})` : "";
|
|
120
|
+
})];
|
|
116
121
|
const collations = options.collate === void 0 ? {
|
|
117
122
|
statements: [],
|
|
118
123
|
columns: 0
|
|
119
124
|
} : await collationStatements(executor, shapes.filter((shape) => shape.name !== SETTINGS_TABLE.name), options.collate);
|
|
120
125
|
const changed = migrate.updateSettings === false ? [] : Object.entries(options.settings).filter(([key, value]) => stored.get(key) !== value);
|
|
121
|
-
if (collations.statements.length === 0 && changed.length === 0) return getEmptyMigrationResult();
|
|
122
|
-
const statements = [
|
|
126
|
+
if (lateSchema.length === 0 && collations.statements.length === 0 && changed.length === 0) return getEmptyMigrationResult();
|
|
127
|
+
const statements = [
|
|
128
|
+
...lateSchema,
|
|
129
|
+
...collations.statements,
|
|
130
|
+
...changed.length === 0 ? [] : settingsStatements(executor.dialect, options.settings)
|
|
131
|
+
];
|
|
123
132
|
return {
|
|
124
|
-
operations: [
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
133
|
+
operations: [
|
|
134
|
+
...missing.columns.map(({ table, column }) => ({
|
|
135
|
+
type: "custom",
|
|
136
|
+
description: `Add column: ${column.name} to ${table}`
|
|
137
|
+
})),
|
|
138
|
+
...lateIndexes.map(({ table, index }) => ({
|
|
139
|
+
type: "custom",
|
|
140
|
+
description: `Create index: ${index} on ${table}`
|
|
141
|
+
})),
|
|
142
|
+
...collations.columns === 0 ? [] : [{
|
|
143
|
+
type: "custom",
|
|
144
|
+
description: `Set the byte-order collation the ORM cannot declare on ${collations.columns} column${collations.columns === 1 ? "" : "s"} of ${collations.statements.length} table${collations.statements.length === 1 ? "" : "s"}`
|
|
145
|
+
}],
|
|
146
|
+
...changed.length === 0 ? [] : [settingsOperation(stored, changed)]
|
|
147
|
+
],
|
|
128
148
|
getSQL: () => statements.map((statement) => `${statement};`).join("\n\n"),
|
|
129
149
|
execute: async () => {
|
|
130
150
|
for (const sql of statements) await executor.execute({
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_schema = require("../core/schema.cjs");
|
|
1
2
|
const require_fence = require("../database/fence.cjs");
|
|
2
3
|
const require_sqlSchema = require("../database/sql/sqlSchema.cjs");
|
|
3
4
|
//#region src/engine/db/sqlSchemaState.ts
|
|
@@ -29,34 +30,54 @@ const fold = (dialect, name) => dialect === "mysql" ? String(name).toLowerCase()
|
|
|
29
30
|
const CATALOG = {
|
|
30
31
|
postgresql: {
|
|
31
32
|
tables: "SELECT c.relname AS t FROM pg_class c WHERE c.relkind IN ('r', 'p') AND pg_table_is_visible(c.oid)",
|
|
32
|
-
indexes: "SELECT t.relname AS t, c.relname AS i FROM pg_index x JOIN pg_class c ON c.oid = x.indexrelid JOIN pg_class t ON t.oid = x.indrelid WHERE pg_table_is_visible(t.oid)"
|
|
33
|
+
indexes: "SELECT t.relname AS t, c.relname AS i FROM pg_index x JOIN pg_class c ON c.oid = x.indexrelid JOIN pg_class t ON t.oid = x.indrelid WHERE pg_table_is_visible(t.oid)",
|
|
34
|
+
columns: "SELECT c.relname AS t, a.attname AS c FROM pg_attribute a JOIN pg_class c ON c.oid = a.attrelid WHERE c.relkind IN ('r', 'p') AND a.attnum > 0 AND NOT a.attisdropped AND pg_table_is_visible(c.oid)"
|
|
33
35
|
},
|
|
34
36
|
mysql: {
|
|
35
37
|
tables: "SELECT TABLE_NAME AS t FROM information_schema.tables WHERE TABLE_SCHEMA = DATABASE()",
|
|
36
|
-
indexes: "SELECT DISTINCT TABLE_NAME AS t, INDEX_NAME AS i FROM information_schema.statistics WHERE TABLE_SCHEMA = DATABASE()"
|
|
38
|
+
indexes: "SELECT DISTINCT TABLE_NAME AS t, INDEX_NAME AS i FROM information_schema.statistics WHERE TABLE_SCHEMA = DATABASE()",
|
|
39
|
+
columns: "SELECT TABLE_NAME AS t, COLUMN_NAME AS c FROM information_schema.columns WHERE TABLE_SCHEMA = DATABASE()"
|
|
37
40
|
},
|
|
38
41
|
sqlite: {
|
|
39
42
|
tables: "SELECT name AS t FROM sqlite_master WHERE type = 'table'",
|
|
40
|
-
indexes: "SELECT tbl_name AS t, name AS i FROM sqlite_master WHERE type = 'index'"
|
|
43
|
+
indexes: "SELECT tbl_name AS t, name AS i FROM sqlite_master WHERE type = 'index'",
|
|
44
|
+
columns: "SELECT m.name AS t, p.name AS c FROM sqlite_master m JOIN pragma_table_info(m.name) p WHERE m.type = 'table'"
|
|
41
45
|
}
|
|
42
46
|
};
|
|
43
|
-
/** Reads which tables and
|
|
47
|
+
/** Reads which tables, indexes and columns exist: three catalog reads. */
|
|
44
48
|
const readSqlSchemaState = async (executor) => {
|
|
45
49
|
const { dialect } = executor;
|
|
46
50
|
const read = (sql) => executor.execute({
|
|
47
51
|
sql,
|
|
48
52
|
params: []
|
|
49
53
|
});
|
|
50
|
-
const [tables, indexes] = await Promise.all([
|
|
54
|
+
const [tables, indexes, columns] = await Promise.all([
|
|
55
|
+
read(CATALOG[dialect].tables),
|
|
56
|
+
read(CATALOG[dialect].indexes),
|
|
57
|
+
read(CATALOG[dialect].columns)
|
|
58
|
+
]);
|
|
59
|
+
const columnNames = new Set(columns.rows.map(({ t, c }) => JSON.stringify([fold(dialect, t), fold(dialect, c)])));
|
|
51
60
|
const tableNames = new Set(tables.rows.map(({ t }) => fold(dialect, t)));
|
|
52
61
|
const indexNames = new Set(indexes.rows.map(({ t, i }) => JSON.stringify([fold(dialect, t), fold(dialect, i)])));
|
|
53
62
|
return {
|
|
54
63
|
hasTable: (table) => tableNames.has(fold(dialect, table)),
|
|
55
|
-
hasIndex: (table, index) => indexNames.has(JSON.stringify([fold(dialect, table), fold(dialect, index)]))
|
|
64
|
+
hasIndex: (table, index) => indexNames.has(JSON.stringify([fold(dialect, table), fold(dialect, index)])),
|
|
65
|
+
hasColumn: (table, column) => columnNames.has(JSON.stringify([fold(dialect, table), fold(dialect, column)]))
|
|
56
66
|
};
|
|
57
67
|
};
|
|
58
|
-
/**
|
|
59
|
-
|
|
68
|
+
/**
|
|
69
|
+
* The declared tables, indexes and late columns the database lacks. An index
|
|
70
|
+
* on a late column is missing too while the column is.
|
|
71
|
+
*/
|
|
72
|
+
const missingSqlSchema = (shapes, state, tablePrefix = "") => ({
|
|
73
|
+
columns: require_schema.LATE_COLUMNS.flatMap(({ table, column }) => {
|
|
74
|
+
const shape = shapes.find(({ name }) => name === tablePrefix + table);
|
|
75
|
+
const declared = shape?.columns.find(({ name }) => name === column);
|
|
76
|
+
return shape === void 0 || declared === void 0 || !state.hasTable(shape.name) || state.hasColumn(shape.name, column) ? [] : [{
|
|
77
|
+
table: shape.name,
|
|
78
|
+
column: declared
|
|
79
|
+
}];
|
|
80
|
+
}),
|
|
60
81
|
tables: shapes.filter((shape) => !state.hasTable(shape.name)).map((shape) => shape.name),
|
|
61
82
|
indexes: shapes.filter((shape) => state.hasTable(shape.name)).flatMap((shape) => shape.indexes.flatMap((index) => index.kind === "index" && !state.hasIndex(shape.name, index.name) ? [{
|
|
62
83
|
table: shape.name,
|
|
@@ -100,7 +121,14 @@ const collationStatements = async (executor, shapes, collate) => {
|
|
|
100
121
|
columns
|
|
101
122
|
};
|
|
102
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* `ALTER TABLE … ADD COLUMN` for each late column a table lacks, which run
|
|
126
|
+
* before the statements that create the table's indexes. Each is nullable,
|
|
127
|
+
* so rows written before it read as null.
|
|
128
|
+
*/
|
|
129
|
+
const addColumnStatements = (dialect, columns) => columns.map(({ table, column }) => `ALTER TABLE ${require_sqlSchema.quoteSql(dialect, table)} ADD COLUMN ${require_sqlSchema.quoteSql(dialect, column.name)} ${column.type}`);
|
|
103
130
|
//#endregion
|
|
131
|
+
exports.addColumnStatements = addColumnStatements;
|
|
104
132
|
exports.collationStatements = collationStatements;
|
|
105
133
|
exports.flattenShapes = flattenShapes;
|
|
106
134
|
exports.missingSqlSchema = missingSqlSchema;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LATE_COLUMNS } from "../core/schema.mjs";
|
|
1
2
|
import { SETTINGS_TABLE } from "../database/fence.mjs";
|
|
2
3
|
import { quoteSql, sqlTableShapes } from "../database/sql/sqlSchema.mjs";
|
|
3
4
|
//#region src/engine/db/sqlSchemaState.ts
|
|
@@ -29,34 +30,54 @@ const fold = (dialect, name) => dialect === "mysql" ? String(name).toLowerCase()
|
|
|
29
30
|
const CATALOG = {
|
|
30
31
|
postgresql: {
|
|
31
32
|
tables: "SELECT c.relname AS t FROM pg_class c WHERE c.relkind IN ('r', 'p') AND pg_table_is_visible(c.oid)",
|
|
32
|
-
indexes: "SELECT t.relname AS t, c.relname AS i FROM pg_index x JOIN pg_class c ON c.oid = x.indexrelid JOIN pg_class t ON t.oid = x.indrelid WHERE pg_table_is_visible(t.oid)"
|
|
33
|
+
indexes: "SELECT t.relname AS t, c.relname AS i FROM pg_index x JOIN pg_class c ON c.oid = x.indexrelid JOIN pg_class t ON t.oid = x.indrelid WHERE pg_table_is_visible(t.oid)",
|
|
34
|
+
columns: "SELECT c.relname AS t, a.attname AS c FROM pg_attribute a JOIN pg_class c ON c.oid = a.attrelid WHERE c.relkind IN ('r', 'p') AND a.attnum > 0 AND NOT a.attisdropped AND pg_table_is_visible(c.oid)"
|
|
33
35
|
},
|
|
34
36
|
mysql: {
|
|
35
37
|
tables: "SELECT TABLE_NAME AS t FROM information_schema.tables WHERE TABLE_SCHEMA = DATABASE()",
|
|
36
|
-
indexes: "SELECT DISTINCT TABLE_NAME AS t, INDEX_NAME AS i FROM information_schema.statistics WHERE TABLE_SCHEMA = DATABASE()"
|
|
38
|
+
indexes: "SELECT DISTINCT TABLE_NAME AS t, INDEX_NAME AS i FROM information_schema.statistics WHERE TABLE_SCHEMA = DATABASE()",
|
|
39
|
+
columns: "SELECT TABLE_NAME AS t, COLUMN_NAME AS c FROM information_schema.columns WHERE TABLE_SCHEMA = DATABASE()"
|
|
37
40
|
},
|
|
38
41
|
sqlite: {
|
|
39
42
|
tables: "SELECT name AS t FROM sqlite_master WHERE type = 'table'",
|
|
40
|
-
indexes: "SELECT tbl_name AS t, name AS i FROM sqlite_master WHERE type = 'index'"
|
|
43
|
+
indexes: "SELECT tbl_name AS t, name AS i FROM sqlite_master WHERE type = 'index'",
|
|
44
|
+
columns: "SELECT m.name AS t, p.name AS c FROM sqlite_master m JOIN pragma_table_info(m.name) p WHERE m.type = 'table'"
|
|
41
45
|
}
|
|
42
46
|
};
|
|
43
|
-
/** Reads which tables and
|
|
47
|
+
/** Reads which tables, indexes and columns exist: three catalog reads. */
|
|
44
48
|
const readSqlSchemaState = async (executor) => {
|
|
45
49
|
const { dialect } = executor;
|
|
46
50
|
const read = (sql) => executor.execute({
|
|
47
51
|
sql,
|
|
48
52
|
params: []
|
|
49
53
|
});
|
|
50
|
-
const [tables, indexes] = await Promise.all([
|
|
54
|
+
const [tables, indexes, columns] = await Promise.all([
|
|
55
|
+
read(CATALOG[dialect].tables),
|
|
56
|
+
read(CATALOG[dialect].indexes),
|
|
57
|
+
read(CATALOG[dialect].columns)
|
|
58
|
+
]);
|
|
59
|
+
const columnNames = new Set(columns.rows.map(({ t, c }) => JSON.stringify([fold(dialect, t), fold(dialect, c)])));
|
|
51
60
|
const tableNames = new Set(tables.rows.map(({ t }) => fold(dialect, t)));
|
|
52
61
|
const indexNames = new Set(indexes.rows.map(({ t, i }) => JSON.stringify([fold(dialect, t), fold(dialect, i)])));
|
|
53
62
|
return {
|
|
54
63
|
hasTable: (table) => tableNames.has(fold(dialect, table)),
|
|
55
|
-
hasIndex: (table, index) => indexNames.has(JSON.stringify([fold(dialect, table), fold(dialect, index)]))
|
|
64
|
+
hasIndex: (table, index) => indexNames.has(JSON.stringify([fold(dialect, table), fold(dialect, index)])),
|
|
65
|
+
hasColumn: (table, column) => columnNames.has(JSON.stringify([fold(dialect, table), fold(dialect, column)]))
|
|
56
66
|
};
|
|
57
67
|
};
|
|
58
|
-
/**
|
|
59
|
-
|
|
68
|
+
/**
|
|
69
|
+
* The declared tables, indexes and late columns the database lacks. An index
|
|
70
|
+
* on a late column is missing too while the column is.
|
|
71
|
+
*/
|
|
72
|
+
const missingSqlSchema = (shapes, state, tablePrefix = "") => ({
|
|
73
|
+
columns: LATE_COLUMNS.flatMap(({ table, column }) => {
|
|
74
|
+
const shape = shapes.find(({ name }) => name === tablePrefix + table);
|
|
75
|
+
const declared = shape?.columns.find(({ name }) => name === column);
|
|
76
|
+
return shape === void 0 || declared === void 0 || !state.hasTable(shape.name) || state.hasColumn(shape.name, column) ? [] : [{
|
|
77
|
+
table: shape.name,
|
|
78
|
+
column: declared
|
|
79
|
+
}];
|
|
80
|
+
}),
|
|
60
81
|
tables: shapes.filter((shape) => !state.hasTable(shape.name)).map((shape) => shape.name),
|
|
61
82
|
indexes: shapes.filter((shape) => state.hasTable(shape.name)).flatMap((shape) => shape.indexes.flatMap((index) => index.kind === "index" && !state.hasIndex(shape.name, index.name) ? [{
|
|
62
83
|
table: shape.name,
|
|
@@ -100,5 +121,11 @@ const collationStatements = async (executor, shapes, collate) => {
|
|
|
100
121
|
columns
|
|
101
122
|
};
|
|
102
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* `ALTER TABLE … ADD COLUMN` for each late column a table lacks, which run
|
|
126
|
+
* before the statements that create the table's indexes. Each is nullable,
|
|
127
|
+
* so rows written before it read as null.
|
|
128
|
+
*/
|
|
129
|
+
const addColumnStatements = (dialect, columns) => columns.map(({ table, column }) => `ALTER TABLE ${quoteSql(dialect, table)} ADD COLUMN ${quoteSql(dialect, column.name)} ${column.type}`);
|
|
103
130
|
//#endregion
|
|
104
|
-
export { collationStatements, flattenShapes, missingSqlSchema, readSqlSchemaState, targetShapes };
|
|
131
|
+
export { addColumnStatements, collationStatements, flattenShapes, missingSqlSchema, readSqlSchemaState, targetShapes };
|
package/dist/index.cjs
CHANGED
|
@@ -126,6 +126,7 @@ Object.defineProperty(exports, "isUUIDv7", {
|
|
|
126
126
|
return _hot_updater_protocol.isUUIDv7;
|
|
127
127
|
}
|
|
128
128
|
});
|
|
129
|
+
exports.lateColumnStatements = require_engineSql.lateColumnStatements;
|
|
129
130
|
exports.mergeDistinct = require_distinct.mergeDistinct;
|
|
130
131
|
exports.meterReads = require_readMeter.meterReads;
|
|
131
132
|
exports.migrateCoreSchema = require_coreDatabase.migrateCoreSchema;
|
|
@@ -135,6 +136,7 @@ exports.parseStorageUri = require_parseStorageUri.parseStorageUri;
|
|
|
135
136
|
exports.projectCompiledCatalog = require_releaseCatalogCompiler.projectCompiledCatalog;
|
|
136
137
|
exports.projectCompiledRollbackCatalog = require_releaseCatalogCompiler.projectCompiledRollbackCatalog;
|
|
137
138
|
exports.quoteSql = require_sqlSchema.quoteSql;
|
|
139
|
+
exports.readCompiledCatalogPayload = require_releaseCatalogCompiler.readCompiledCatalogPayload;
|
|
138
140
|
exports.referenceCompatibleReleases = require_releaseCatalogCompiler.referenceCompatibleReleases;
|
|
139
141
|
exports.releaseRowToRelease = require_databaseRows.releaseRowToRelease;
|
|
140
142
|
exports.releaseToRow = require_databaseRows.releaseToRow;
|
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { BUNDLE_STORAGE_PREFIX, createBundleStorageKey, createStorageRootUriWith
|
|
|
2
2
|
import { createStorageUriWithRelativePath, getManifestAssetDownloadPath, getManifestAssetStoragePath, isBrotliManifestAssetPath, replaceStorageUriKeySuffix, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri } from "./assetStorageLayout.cjs";
|
|
3
3
|
import { CONTENT_ADDRESSED_ASSET_PREFIX, getContentAddressedAssetStoragePath, isContentAddressedAssetFileHash } from "./contentAddressedAssets.cjs";
|
|
4
4
|
import { getContentType } from "./contentType.cjs";
|
|
5
|
-
import { CatalogVersionBound, CompiledCatalogSegment, CompiledReleaseCatalog, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases } from "./releaseCatalogCompiler.cjs";
|
|
5
|
+
import { CatalogVersionBound, CompiledCatalogSegment, CompiledReleaseCatalog, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, readCompiledCatalogPayload, referenceCompatibleReleases } from "./releaseCatalogCompiler.cjs";
|
|
6
6
|
import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, IosDeviceRow, IosDeviceStatus, NativeBuildArtifactKind, NativeBuildExportMethod, NativeBuildRow, NativeBuildSubmissionDestination, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.cjs";
|
|
7
7
|
import { CoreReads, ReleaseCatalogRequest } from "./serverPlugin/coreReads.cjs";
|
|
8
8
|
import { DATABASE_VERSION_COLUMN, DatabaseAdapter, DatabaseJson, DatabaseKey, DatabaseKeyValue, DatabaseSchemaError, DatabaseValue, PhysicalColumn, PhysicalColumnType, PhysicalIndex, PhysicalRetention, PhysicalTable, QueryBound, QueryRequest, StoredRow, WriteGuard, WriteOp, WriteResult, expiresAt, findPhysicalColumn, findPhysicalIndex, indexOrderColumns, rowKey } from "./database/adapter.cjs";
|
|
@@ -21,7 +21,7 @@ import { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult, Nati
|
|
|
21
21
|
import { ApplePlatform, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, Bundle, ConfigInput, FingerprintExtraSources, IosBuildDestination, Lazy, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, NativeBuildSandboxOptions, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, Platform, PlatformConfig, SecretRef, SecretsAdapter, SecretsContext, SigningConfig, StorageAdapter, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StoragePutInput, StoragePutResult, resolveLazy, supportedIosPlatforms } from "./types/index.cjs";
|
|
22
22
|
import { ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, ReleaseCatalogScope } from "./releaseCatalogMutation.cjs";
|
|
23
23
|
import { PromoteReleaseResult, ReleaseManagementError, ReleasePolicyPatch } from "./releaseManagement.cjs";
|
|
24
|
-
import { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, IosDeviceAccount, IosDeviceAccountClaim, IosDeviceOutcome, IosDeviceOutcomeInput, IosDeviceRequestResult, KeysetInput, NativeBuildDistribution, NativeBuildRegistration, NativeBuildSandboxScope, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment } from "./coreApi.cjs";
|
|
24
|
+
import { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, IosDeviceAccount, IosDeviceAccountClaim, IosDeviceOutcome, IosDeviceOutcomeInput, IosDeviceRequestResult, KeysetInput, NativeBuildDistribution, NativeBuildRegistration, NativeBuildSandboxScope, NativeBuildScope, ReleaseFilter, ReleaseLabelFill, ReleaseTarget, StoredBundleDeployment } from "./coreApi.cjs";
|
|
25
25
|
import { DatabaseAdapterInputError, DatabaseAdapterInputErrorCode, DatabaseBundleNotFoundError, DatabaseRowReferencedError } from "./databaseErrors.cjs";
|
|
26
26
|
import { createStorageKeyBuilder } from "./createStorageKeyBuilder.cjs";
|
|
27
27
|
import { CreateStorageAdapterOptions, StorageAdapterWith, StorageOperation, assertStorageOperations, createStorageAdapter } from "./createStorageAdapter.cjs";
|
|
@@ -47,8 +47,8 @@ import { KeyValueStore, KvAdapterOptions, KvCondition, KvItem, KvKey, KvOp, KvRa
|
|
|
47
47
|
import { MeteredDatabase, ReadMeasurement, meterReads } from "./engine/database/readMeter.cjs";
|
|
48
48
|
import { SqlColumnShape, SqlDialect, SqlTableShape, createTableStatements, isMultiIndex, quoteSql, sqlTableShapes } from "./engine/database/sql/sqlSchema.cjs";
|
|
49
49
|
import { SqlAdapterOptions, SqlConnection, SqlExecutor, SqlResult, SqlStatement, WRITE_GUARD_TABLE, createSqlAdapter } from "./engine/database/sql/sqlAdapter.cjs";
|
|
50
|
-
import { EngineSqlOptions, generateEngineSql } from "./engine/db/engineSql.cjs";
|
|
50
|
+
import { EngineSqlOptions, generateEngineSql, lateColumnStatements } from "./engine/db/engineSql.cjs";
|
|
51
51
|
import { EngineSqlMigratorOptions, createEngineSqlMigrator } from "./engine/db/engineSqlMigrator.cjs";
|
|
52
52
|
import { writeSchemaSettings } from "./engine/db/schemaSettings.cjs";
|
|
53
53
|
import { createSettingsMigrator } from "./engine/db/settingsMigrator.cjs";
|
|
54
|
-
export { type AggregateBatching, type AggregateChanges, type AggregateDefinition, type AggregateIdentity, type AggregateRow, type AnyHotUpdaterPlugin, ApplePlatform, BUNDLE_STORAGE_PREFIX, type BaseCandidateQuery, type BaseCandidateTarget, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle, type BundleDeployment, type BundleDetail, type BundlePatchRow, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, type ClientAuth, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type ConfiguredDatabase, type ConstraintReason, type CoreReader, type CoreReads, type CoreSchema, type CreateRow, CreateStorageAdapterOptions, CreateStorageUriInput, DATABASE_VERSION_COLUMN, type DatabaseAdapter, DatabaseAdapterContractError, DatabaseAdapterInputError, type DatabaseAdapterInputErrorCode, DatabaseAmbiguousCommitError, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, type DatabaseJson, type DatabaseJsonObject, type DatabaseJsonValue, type DatabaseKey, type DatabaseKeyValue, DatabaseQueryError, type DatabaseReadCount, type DatabaseReadMeter, DatabaseRowReferencedError, DatabaseSchemaError, type DatabaseTooling, DatabaseTransactionError, type DatabaseValue, type DeployReleasePolicy, type Deployment, type DerivedDefinition, type DerivedFields, type Engine, type EngineColumns, type EngineDatabase, type EngineDatabaseOptions, type EngineOptions, type EngineReadCount, type EngineSqlMigratorOptions, type EngineSqlOptions, type FieldDefinition, type FieldReference, type FieldType, type FieldValue, type FindAggregatesModel, type FindManyModel, FingerprintExtraSources, HasMultipleCallSignatures, HotUpdaterConfigError, type HotUpdaterCoreApi, type HotUpdaterDatabase, type HotUpdaterPlugin, HotUpdaterSchemaMigrationRequiredError, type HotUpdaterTransaction, type IndexDefinition, IosBuildDestination, type IosDeviceAccount, type IosDeviceAccountClaim, type IosDeviceOutcome, type IosDeviceOutcomeInput, type IosDeviceRequestResult, type IosDeviceRow, type IosDeviceStatus, type KeyLookup, type KeyValueStore, type KeysetInput, type KvAdapterOptions, type KvCondition, type KvItem, type KvKey, type KvOp, type KvRange, Lazy, LocalSigningConfig, type Lookup, type MemoryAdapterOptions, type MeteredDatabase, type MigrateOptions, type MigrationResult, type Migrator, type ModelDefinition, type ModuleSchema, NativeBuildAndroidScheme, NativeBuildArgs, type NativeBuildArtifactKind, type NativeBuildDeleteResult, type NativeBuildDistribution, type NativeBuildExportMethod, NativeBuildIosScheme, type NativeBuildMarkResult, NativeBuildOptions, type NativeBuildRegistration, type NativeBuildRow, NativeBuildSandboxOptions, type NativeBuildSandboxScope, type NativeBuildScope, type NativeBuildSubmissionDestination, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, type NormalizeOptions, type Page, ParsedStorageUri, type PhysicalColumn, type PhysicalColumnType, type PhysicalIndex, type PhysicalRetention, type PhysicalTable, type Platform, PlatformConfig, type PluginApis, type PluginCli, type PluginClientCredential, type PluginClientPlugin, type PluginContext, type PluginEndpoint, type PluginEndpointMethod, type PluginInstance, type PluginProvides, type PluginTables, Primitive, PromoteReleaseResult, type QueryBound, type QueryRequest, type ReadMeasurement, type ReadOptions, type ReadRow, type ReferenceAction, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRequest, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, type ReleaseFilter, ReleaseManagementError, ReleasePolicyPatch, type ReleaseRow, type ReleaseRowUpdate, type ReleaseTarget, type RemoteDatabase, RequiredDeep, type ResolvedModel, type ResolvedSchema, type RetentionDefinition, type RetryOptions, type RowOf, SETTINGS_TABLE, type SchemaGenerator, type SchemaSettings, SecretRef, SecretsAdapter, SecretsContext, SigningConfig, type SqlAdapterOptions, type SqlColumnShape, type SqlConnection, type SqlDialect, type SqlExecutor, type SqlResult, type SqlStatement, type SqlTableShape, StorageAdapter, StorageAdapterWith, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePutInput, StoragePutResult, type StoredBundleDeployment, type StoredRow, type TableDefinition, type TableRow, type ToolingDatabase, type ToolingTarget, type UpdateSet, type VerifiedDatabaseAdapter, type VerifyAdapterOptions, WRITE_GUARD_TABLE, type WriteGuard, type WriteOp, type WriteResult, addDistinct, aggregateBatchingTables, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareUtf8, compileReleaseCatalog, coreSchema, coreSettings, coreTarget, countDistinct, createBundleStorageKey, createEngine, createEngineDatabase, createEngineSqlMigrator, createKvAdapter, createMemoryAdapter, createSettingsMigrator, createSqlAdapter, createStorageAdapter, createStorageKeyBuilder, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createTableStatements, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, defineAggregate, definePlugin, defineTable, encodeKvKey, expiresAt, extractTimestampFromUUIDv7, findPhysicalColumn, findPhysicalIndex, generateEngineSql, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, indexOrderColumns, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBusyError, isDatabaseJsonObject, isDatabaseMetadataObject, isMultiIndex, isRemoteDatabase, isUUIDv7, mergeDistinct, meterReads, migrateCoreSchema, normalizeStoredRow, parseBaseCandidateKey, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, quoteSql, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, replaceStorageUriKeySuffix, resolveLazy, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowKey, rowToBundle, rowsToBundles, semverSatisfies, sqlTableShapes, supportedIosPlatforms, targetBaseCandidateKey, toolingTargetOf, verifyAdapter, writeSchemaSettings };
|
|
54
|
+
export { type AggregateBatching, type AggregateChanges, type AggregateDefinition, type AggregateIdentity, type AggregateRow, type AnyHotUpdaterPlugin, ApplePlatform, BUNDLE_STORAGE_PREFIX, type BaseCandidateQuery, type BaseCandidateTarget, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle, type BundleDeployment, type BundleDetail, type BundlePatchRow, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, type ClientAuth, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type ConfiguredDatabase, type ConstraintReason, type CoreReader, type CoreReads, type CoreSchema, type CreateRow, CreateStorageAdapterOptions, CreateStorageUriInput, DATABASE_VERSION_COLUMN, type DatabaseAdapter, DatabaseAdapterContractError, DatabaseAdapterInputError, type DatabaseAdapterInputErrorCode, DatabaseAmbiguousCommitError, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, type DatabaseJson, type DatabaseJsonObject, type DatabaseJsonValue, type DatabaseKey, type DatabaseKeyValue, DatabaseQueryError, type DatabaseReadCount, type DatabaseReadMeter, DatabaseRowReferencedError, DatabaseSchemaError, type DatabaseTooling, DatabaseTransactionError, type DatabaseValue, type DeployReleasePolicy, type Deployment, type DerivedDefinition, type DerivedFields, type Engine, type EngineColumns, type EngineDatabase, type EngineDatabaseOptions, type EngineOptions, type EngineReadCount, type EngineSqlMigratorOptions, type EngineSqlOptions, type FieldDefinition, type FieldReference, type FieldType, type FieldValue, type FindAggregatesModel, type FindManyModel, FingerprintExtraSources, HasMultipleCallSignatures, HotUpdaterConfigError, type HotUpdaterCoreApi, type HotUpdaterDatabase, type HotUpdaterPlugin, HotUpdaterSchemaMigrationRequiredError, type HotUpdaterTransaction, type IndexDefinition, IosBuildDestination, type IosDeviceAccount, type IosDeviceAccountClaim, type IosDeviceOutcome, type IosDeviceOutcomeInput, type IosDeviceRequestResult, type IosDeviceRow, type IosDeviceStatus, type KeyLookup, type KeyValueStore, type KeysetInput, type KvAdapterOptions, type KvCondition, type KvItem, type KvKey, type KvOp, type KvRange, Lazy, LocalSigningConfig, type Lookup, type MemoryAdapterOptions, type MeteredDatabase, type MigrateOptions, type MigrationResult, type Migrator, type ModelDefinition, type ModuleSchema, NativeBuildAndroidScheme, NativeBuildArgs, type NativeBuildArtifactKind, type NativeBuildDeleteResult, type NativeBuildDistribution, type NativeBuildExportMethod, NativeBuildIosScheme, type NativeBuildMarkResult, NativeBuildOptions, type NativeBuildRegistration, type NativeBuildRow, NativeBuildSandboxOptions, type NativeBuildSandboxScope, type NativeBuildScope, type NativeBuildSubmissionDestination, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, type NormalizeOptions, type Page, ParsedStorageUri, type PhysicalColumn, type PhysicalColumnType, type PhysicalIndex, type PhysicalRetention, type PhysicalTable, type Platform, PlatformConfig, type PluginApis, type PluginCli, type PluginClientCredential, type PluginClientPlugin, type PluginContext, type PluginEndpoint, type PluginEndpointMethod, type PluginInstance, type PluginProvides, type PluginTables, Primitive, PromoteReleaseResult, type QueryBound, type QueryRequest, type ReadMeasurement, type ReadOptions, type ReadRow, type ReferenceAction, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRequest, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, type ReleaseFilter, type ReleaseLabelFill, ReleaseManagementError, ReleasePolicyPatch, type ReleaseRow, type ReleaseRowUpdate, type ReleaseTarget, type RemoteDatabase, RequiredDeep, type ResolvedModel, type ResolvedSchema, type RetentionDefinition, type RetryOptions, type RowOf, SETTINGS_TABLE, type SchemaGenerator, type SchemaSettings, SecretRef, SecretsAdapter, SecretsContext, SigningConfig, type SqlAdapterOptions, type SqlColumnShape, type SqlConnection, type SqlDialect, type SqlExecutor, type SqlResult, type SqlStatement, type SqlTableShape, StorageAdapter, StorageAdapterWith, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePutInput, StoragePutResult, type StoredBundleDeployment, type StoredRow, type TableDefinition, type TableRow, type ToolingDatabase, type ToolingTarget, type UpdateSet, type VerifiedDatabaseAdapter, type VerifyAdapterOptions, WRITE_GUARD_TABLE, type WriteGuard, type WriteOp, type WriteResult, addDistinct, aggregateBatchingTables, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareUtf8, compileReleaseCatalog, coreSchema, coreSettings, coreTarget, countDistinct, createBundleStorageKey, createEngine, createEngineDatabase, createEngineSqlMigrator, createKvAdapter, createMemoryAdapter, createSettingsMigrator, createSqlAdapter, createStorageAdapter, createStorageKeyBuilder, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createTableStatements, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, defineAggregate, definePlugin, defineTable, encodeKvKey, expiresAt, extractTimestampFromUUIDv7, findPhysicalColumn, findPhysicalIndex, generateEngineSql, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, indexOrderColumns, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBusyError, isDatabaseJsonObject, isDatabaseMetadataObject, isMultiIndex, isRemoteDatabase, isUUIDv7, lateColumnStatements, mergeDistinct, meterReads, migrateCoreSchema, normalizeStoredRow, parseBaseCandidateKey, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, quoteSql, readCompiledCatalogPayload, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, replaceStorageUriKeySuffix, resolveLazy, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowKey, rowToBundle, rowsToBundles, semverSatisfies, sqlTableShapes, supportedIosPlatforms, targetBaseCandidateKey, toolingTargetOf, verifyAdapter, writeSchemaSettings };
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { BUNDLE_STORAGE_PREFIX, createBundleStorageKey, createStorageRootUriWith
|
|
|
2
2
|
import { createStorageUriWithRelativePath, getManifestAssetDownloadPath, getManifestAssetStoragePath, isBrotliManifestAssetPath, replaceStorageUriKeySuffix, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri } from "./assetStorageLayout.mjs";
|
|
3
3
|
import { CONTENT_ADDRESSED_ASSET_PREFIX, getContentAddressedAssetStoragePath, isContentAddressedAssetFileHash } from "./contentAddressedAssets.mjs";
|
|
4
4
|
import { getContentType } from "./contentType.mjs";
|
|
5
|
-
import { CatalogVersionBound, CompiledCatalogSegment, CompiledReleaseCatalog, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases } from "./releaseCatalogCompiler.mjs";
|
|
5
|
+
import { CatalogVersionBound, CompiledCatalogSegment, CompiledReleaseCatalog, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, readCompiledCatalogPayload, referenceCompatibleReleases } from "./releaseCatalogCompiler.mjs";
|
|
6
6
|
import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, IosDeviceRow, IosDeviceStatus, NativeBuildArtifactKind, NativeBuildExportMethod, NativeBuildRow, NativeBuildSubmissionDestination, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.mjs";
|
|
7
7
|
import { CoreReads, ReleaseCatalogRequest } from "./serverPlugin/coreReads.mjs";
|
|
8
8
|
import { DATABASE_VERSION_COLUMN, DatabaseAdapter, DatabaseJson, DatabaseKey, DatabaseKeyValue, DatabaseSchemaError, DatabaseValue, PhysicalColumn, PhysicalColumnType, PhysicalIndex, PhysicalRetention, PhysicalTable, QueryBound, QueryRequest, StoredRow, WriteGuard, WriteOp, WriteResult, expiresAt, findPhysicalColumn, findPhysicalIndex, indexOrderColumns, rowKey } from "./database/adapter.mjs";
|
|
@@ -21,7 +21,7 @@ import { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult, Nati
|
|
|
21
21
|
import { ApplePlatform, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, Bundle, ConfigInput, FingerprintExtraSources, IosBuildDestination, Lazy, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, NativeBuildSandboxOptions, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, Platform, PlatformConfig, SecretRef, SecretsAdapter, SecretsContext, SigningConfig, StorageAdapter, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StoragePutInput, StoragePutResult, resolveLazy, supportedIosPlatforms } from "./types/index.mjs";
|
|
22
22
|
import { ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, ReleaseCatalogScope } from "./releaseCatalogMutation.mjs";
|
|
23
23
|
import { PromoteReleaseResult, ReleaseManagementError, ReleasePolicyPatch } from "./releaseManagement.mjs";
|
|
24
|
-
import { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, IosDeviceAccount, IosDeviceAccountClaim, IosDeviceOutcome, IosDeviceOutcomeInput, IosDeviceRequestResult, KeysetInput, NativeBuildDistribution, NativeBuildRegistration, NativeBuildSandboxScope, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment } from "./coreApi.mjs";
|
|
24
|
+
import { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, IosDeviceAccount, IosDeviceAccountClaim, IosDeviceOutcome, IosDeviceOutcomeInput, IosDeviceRequestResult, KeysetInput, NativeBuildDistribution, NativeBuildRegistration, NativeBuildSandboxScope, NativeBuildScope, ReleaseFilter, ReleaseLabelFill, ReleaseTarget, StoredBundleDeployment } from "./coreApi.mjs";
|
|
25
25
|
import { DatabaseAdapterInputError, DatabaseAdapterInputErrorCode, DatabaseBundleNotFoundError, DatabaseRowReferencedError } from "./databaseErrors.mjs";
|
|
26
26
|
import { createStorageKeyBuilder } from "./createStorageKeyBuilder.mjs";
|
|
27
27
|
import { CreateStorageAdapterOptions, StorageAdapterWith, StorageOperation, assertStorageOperations, createStorageAdapter } from "./createStorageAdapter.mjs";
|
|
@@ -47,8 +47,8 @@ import { KeyValueStore, KvAdapterOptions, KvCondition, KvItem, KvKey, KvOp, KvRa
|
|
|
47
47
|
import { MeteredDatabase, ReadMeasurement, meterReads } from "./engine/database/readMeter.mjs";
|
|
48
48
|
import { SqlColumnShape, SqlDialect, SqlTableShape, createTableStatements, isMultiIndex, quoteSql, sqlTableShapes } from "./engine/database/sql/sqlSchema.mjs";
|
|
49
49
|
import { SqlAdapterOptions, SqlConnection, SqlExecutor, SqlResult, SqlStatement, WRITE_GUARD_TABLE, createSqlAdapter } from "./engine/database/sql/sqlAdapter.mjs";
|
|
50
|
-
import { EngineSqlOptions, generateEngineSql } from "./engine/db/engineSql.mjs";
|
|
50
|
+
import { EngineSqlOptions, generateEngineSql, lateColumnStatements } from "./engine/db/engineSql.mjs";
|
|
51
51
|
import { EngineSqlMigratorOptions, createEngineSqlMigrator } from "./engine/db/engineSqlMigrator.mjs";
|
|
52
52
|
import { writeSchemaSettings } from "./engine/db/schemaSettings.mjs";
|
|
53
53
|
import { createSettingsMigrator } from "./engine/db/settingsMigrator.mjs";
|
|
54
|
-
export { type AggregateBatching, type AggregateChanges, type AggregateDefinition, type AggregateIdentity, type AggregateRow, type AnyHotUpdaterPlugin, ApplePlatform, BUNDLE_STORAGE_PREFIX, type BaseCandidateQuery, type BaseCandidateTarget, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle, type BundleDeployment, type BundleDetail, type BundlePatchRow, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, type ClientAuth, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type ConfiguredDatabase, type ConstraintReason, type CoreReader, type CoreReads, type CoreSchema, type CreateRow, CreateStorageAdapterOptions, CreateStorageUriInput, DATABASE_VERSION_COLUMN, type DatabaseAdapter, DatabaseAdapterContractError, DatabaseAdapterInputError, type DatabaseAdapterInputErrorCode, DatabaseAmbiguousCommitError, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, type DatabaseJson, type DatabaseJsonObject, type DatabaseJsonValue, type DatabaseKey, type DatabaseKeyValue, DatabaseQueryError, type DatabaseReadCount, type DatabaseReadMeter, DatabaseRowReferencedError, DatabaseSchemaError, type DatabaseTooling, DatabaseTransactionError, type DatabaseValue, type DeployReleasePolicy, type Deployment, type DerivedDefinition, type DerivedFields, type Engine, type EngineColumns, type EngineDatabase, type EngineDatabaseOptions, type EngineOptions, type EngineReadCount, type EngineSqlMigratorOptions, type EngineSqlOptions, type FieldDefinition, type FieldReference, type FieldType, type FieldValue, type FindAggregatesModel, type FindManyModel, FingerprintExtraSources, HasMultipleCallSignatures, HotUpdaterConfigError, type HotUpdaterCoreApi, type HotUpdaterDatabase, type HotUpdaterPlugin, HotUpdaterSchemaMigrationRequiredError, type HotUpdaterTransaction, type IndexDefinition, IosBuildDestination, type IosDeviceAccount, type IosDeviceAccountClaim, type IosDeviceOutcome, type IosDeviceOutcomeInput, type IosDeviceRequestResult, type IosDeviceRow, type IosDeviceStatus, type KeyLookup, type KeyValueStore, type KeysetInput, type KvAdapterOptions, type KvCondition, type KvItem, type KvKey, type KvOp, type KvRange, Lazy, LocalSigningConfig, type Lookup, type MemoryAdapterOptions, type MeteredDatabase, type MigrateOptions, type MigrationResult, type Migrator, type ModelDefinition, type ModuleSchema, NativeBuildAndroidScheme, NativeBuildArgs, type NativeBuildArtifactKind, type NativeBuildDeleteResult, type NativeBuildDistribution, type NativeBuildExportMethod, NativeBuildIosScheme, type NativeBuildMarkResult, NativeBuildOptions, type NativeBuildRegistration, type NativeBuildRow, NativeBuildSandboxOptions, type NativeBuildSandboxScope, type NativeBuildScope, type NativeBuildSubmissionDestination, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, type NormalizeOptions, type Page, ParsedStorageUri, type PhysicalColumn, type PhysicalColumnType, type PhysicalIndex, type PhysicalRetention, type PhysicalTable, type Platform, PlatformConfig, type PluginApis, type PluginCli, type PluginClientCredential, type PluginClientPlugin, type PluginContext, type PluginEndpoint, type PluginEndpointMethod, type PluginInstance, type PluginProvides, type PluginTables, Primitive, PromoteReleaseResult, type QueryBound, type QueryRequest, type ReadMeasurement, type ReadOptions, type ReadRow, type ReferenceAction, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRequest, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, type ReleaseFilter, ReleaseManagementError, ReleasePolicyPatch, type ReleaseRow, type ReleaseRowUpdate, type ReleaseTarget, type RemoteDatabase, RequiredDeep, type ResolvedModel, type ResolvedSchema, type RetentionDefinition, type RetryOptions, type RowOf, SETTINGS_TABLE, type SchemaGenerator, type SchemaSettings, SecretRef, SecretsAdapter, SecretsContext, SigningConfig, type SqlAdapterOptions, type SqlColumnShape, type SqlConnection, type SqlDialect, type SqlExecutor, type SqlResult, type SqlStatement, type SqlTableShape, StorageAdapter, StorageAdapterWith, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePutInput, StoragePutResult, type StoredBundleDeployment, type StoredRow, type TableDefinition, type TableRow, type ToolingDatabase, type ToolingTarget, type UpdateSet, type VerifiedDatabaseAdapter, type VerifyAdapterOptions, WRITE_GUARD_TABLE, type WriteGuard, type WriteOp, type WriteResult, addDistinct, aggregateBatchingTables, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareUtf8, compileReleaseCatalog, coreSchema, coreSettings, coreTarget, countDistinct, createBundleStorageKey, createEngine, createEngineDatabase, createEngineSqlMigrator, createKvAdapter, createMemoryAdapter, createSettingsMigrator, createSqlAdapter, createStorageAdapter, createStorageKeyBuilder, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createTableStatements, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, defineAggregate, definePlugin, defineTable, encodeKvKey, expiresAt, extractTimestampFromUUIDv7, findPhysicalColumn, findPhysicalIndex, generateEngineSql, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, indexOrderColumns, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBusyError, isDatabaseJsonObject, isDatabaseMetadataObject, isMultiIndex, isRemoteDatabase, isUUIDv7, mergeDistinct, meterReads, migrateCoreSchema, normalizeStoredRow, parseBaseCandidateKey, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, quoteSql, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, replaceStorageUriKeySuffix, resolveLazy, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowKey, rowToBundle, rowsToBundles, semverSatisfies, sqlTableShapes, supportedIosPlatforms, targetBaseCandidateKey, toolingTargetOf, verifyAdapter, writeSchemaSettings };
|
|
54
|
+
export { type AggregateBatching, type AggregateChanges, type AggregateDefinition, type AggregateIdentity, type AggregateRow, type AnyHotUpdaterPlugin, ApplePlatform, BUNDLE_STORAGE_PREFIX, type BaseCandidateQuery, type BaseCandidateTarget, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle, type BundleDeployment, type BundleDetail, type BundlePatchRow, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, type ClientAuth, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type ConfiguredDatabase, type ConstraintReason, type CoreReader, type CoreReads, type CoreSchema, type CreateRow, CreateStorageAdapterOptions, CreateStorageUriInput, DATABASE_VERSION_COLUMN, type DatabaseAdapter, DatabaseAdapterContractError, DatabaseAdapterInputError, type DatabaseAdapterInputErrorCode, DatabaseAmbiguousCommitError, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, type DatabaseJson, type DatabaseJsonObject, type DatabaseJsonValue, type DatabaseKey, type DatabaseKeyValue, DatabaseQueryError, type DatabaseReadCount, type DatabaseReadMeter, DatabaseRowReferencedError, DatabaseSchemaError, type DatabaseTooling, DatabaseTransactionError, type DatabaseValue, type DeployReleasePolicy, type Deployment, type DerivedDefinition, type DerivedFields, type Engine, type EngineColumns, type EngineDatabase, type EngineDatabaseOptions, type EngineOptions, type EngineReadCount, type EngineSqlMigratorOptions, type EngineSqlOptions, type FieldDefinition, type FieldReference, type FieldType, type FieldValue, type FindAggregatesModel, type FindManyModel, FingerprintExtraSources, HasMultipleCallSignatures, HotUpdaterConfigError, type HotUpdaterCoreApi, type HotUpdaterDatabase, type HotUpdaterPlugin, HotUpdaterSchemaMigrationRequiredError, type HotUpdaterTransaction, type IndexDefinition, IosBuildDestination, type IosDeviceAccount, type IosDeviceAccountClaim, type IosDeviceOutcome, type IosDeviceOutcomeInput, type IosDeviceRequestResult, type IosDeviceRow, type IosDeviceStatus, type KeyLookup, type KeyValueStore, type KeysetInput, type KvAdapterOptions, type KvCondition, type KvItem, type KvKey, type KvOp, type KvRange, Lazy, LocalSigningConfig, type Lookup, type MemoryAdapterOptions, type MeteredDatabase, type MigrateOptions, type MigrationResult, type Migrator, type ModelDefinition, type ModuleSchema, NativeBuildAndroidScheme, NativeBuildArgs, type NativeBuildArtifactKind, type NativeBuildDeleteResult, type NativeBuildDistribution, type NativeBuildExportMethod, NativeBuildIosScheme, type NativeBuildMarkResult, NativeBuildOptions, type NativeBuildRegistration, type NativeBuildRow, NativeBuildSandboxOptions, type NativeBuildSandboxScope, type NativeBuildScope, type NativeBuildSubmissionDestination, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, type NormalizeOptions, type Page, ParsedStorageUri, type PhysicalColumn, type PhysicalColumnType, type PhysicalIndex, type PhysicalRetention, type PhysicalTable, type Platform, PlatformConfig, type PluginApis, type PluginCli, type PluginClientCredential, type PluginClientPlugin, type PluginContext, type PluginEndpoint, type PluginEndpointMethod, type PluginInstance, type PluginProvides, type PluginTables, Primitive, PromoteReleaseResult, type QueryBound, type QueryRequest, type ReadMeasurement, type ReadOptions, type ReadRow, type ReferenceAction, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRequest, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, type ReleaseFilter, type ReleaseLabelFill, ReleaseManagementError, ReleasePolicyPatch, type ReleaseRow, type ReleaseRowUpdate, type ReleaseTarget, type RemoteDatabase, RequiredDeep, type ResolvedModel, type ResolvedSchema, type RetentionDefinition, type RetryOptions, type RowOf, SETTINGS_TABLE, type SchemaGenerator, type SchemaSettings, SecretRef, SecretsAdapter, SecretsContext, SigningConfig, type SqlAdapterOptions, type SqlColumnShape, type SqlConnection, type SqlDialect, type SqlExecutor, type SqlResult, type SqlStatement, type SqlTableShape, StorageAdapter, StorageAdapterWith, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePutInput, StoragePutResult, type StoredBundleDeployment, type StoredRow, type TableDefinition, type TableRow, type ToolingDatabase, type ToolingTarget, type UpdateSet, type VerifiedDatabaseAdapter, type VerifyAdapterOptions, WRITE_GUARD_TABLE, type WriteGuard, type WriteOp, type WriteResult, addDistinct, aggregateBatchingTables, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareUtf8, compileReleaseCatalog, coreSchema, coreSettings, coreTarget, countDistinct, createBundleStorageKey, createEngine, createEngineDatabase, createEngineSqlMigrator, createKvAdapter, createMemoryAdapter, createSettingsMigrator, createSqlAdapter, createStorageAdapter, createStorageKeyBuilder, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createTableStatements, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, defineAggregate, definePlugin, defineTable, encodeKvKey, expiresAt, extractTimestampFromUUIDv7, findPhysicalColumn, findPhysicalIndex, generateEngineSql, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, indexOrderColumns, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBusyError, isDatabaseJsonObject, isDatabaseMetadataObject, isMultiIndex, isRemoteDatabase, isUUIDv7, lateColumnStatements, mergeDistinct, meterReads, migrateCoreSchema, normalizeStoredRow, parseBaseCandidateKey, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, quoteSql, readCompiledCatalogPayload, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, replaceStorageUriKeySuffix, resolveLazy, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowKey, rowToBundle, rowsToBundles, semverSatisfies, sqlTableShapes, supportedIosPlatforms, targetBaseCandidateKey, toolingTargetOf, verifyAdapter, writeSchemaSettings };
|
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { isDatabaseJsonObject, isDatabaseMetadataObject } from "./databaseJsonVa
|
|
|
10
10
|
import { BundleRowHydrationError, BundleRowHydrationErrorReason, bundleToPatchRows, bundleToRow, releaseRowToRelease, releaseToRow, rowToBundle, rowsToBundles } from "./databaseRows.mjs";
|
|
11
11
|
import { generateMinBundleId } from "./generateMinBundleId.mjs";
|
|
12
12
|
import { createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, extractTimestampFromUUIDv7, isUUIDv7 } from "./uuidv7.mjs";
|
|
13
|
-
import { ReleaseCatalogCompilationError, canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases } from "./releaseCatalogCompiler.mjs";
|
|
13
|
+
import { ReleaseCatalogCompilationError, canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, readCompiledCatalogPayload, referenceCompatibleReleases } from "./releaseCatalogCompiler.mjs";
|
|
14
14
|
import { ReleaseManagementError } from "./releaseManagement.mjs";
|
|
15
15
|
import { ReleaseCatalogMutationError } from "./releaseCatalogMutation.mjs";
|
|
16
16
|
import { semverSatisfies } from "./semverSatisfies.mjs";
|
|
@@ -30,7 +30,7 @@ import { DatabaseAdapterContractError, verifyAdapter } from "./database/verifyAd
|
|
|
30
30
|
import { HotUpdaterSchemaMigrationRequiredError, SETTINGS_TABLE } from "./engine/database/fence.mjs";
|
|
31
31
|
import { meterReads } from "./engine/database/readMeter.mjs";
|
|
32
32
|
import { createTableStatements, isMultiIndex, quoteSql, sqlTableShapes } from "./engine/database/sql/sqlSchema.mjs";
|
|
33
|
-
import { generateEngineSql } from "./engine/db/engineSql.mjs";
|
|
33
|
+
import { generateEngineSql, lateColumnStatements } from "./engine/db/engineSql.mjs";
|
|
34
34
|
import { createSettingsMigrator } from "./engine/db/settingsMigrator.mjs";
|
|
35
35
|
import { writeSchemaSettings } from "./engine/db/schemaSettings.mjs";
|
|
36
36
|
import { aggregateBatchingTables, coreSchema, coreSettings, coreTarget, createEngineDatabase, migrateCoreSchema, toolingTargetOf } from "./engine/db/coreDatabase.mjs";
|
|
@@ -38,4 +38,4 @@ import { createEngine } from "./engine/createEngine.mjs";
|
|
|
38
38
|
import { createKvAdapter, encodeKvKey } from "./engine/database/kv/kvAdapter.mjs";
|
|
39
39
|
import { WRITE_GUARD_TABLE, createSqlAdapter } from "./engine/database/sql/sqlAdapter.mjs";
|
|
40
40
|
import { createEngineSqlMigrator } from "./engine/db/engineSqlMigrator.mjs";
|
|
41
|
-
export { BUNDLE_STORAGE_PREFIX, BundleRowHydrationError, BundleRowHydrationErrorReason, CONTENT_ADDRESSED_ASSET_PREFIX, DATABASE_VERSION_COLUMN, DatabaseAdapterContractError, DatabaseAdapterInputError, DatabaseAmbiguousCommitError, DatabaseBundleNotFoundError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, DatabaseQueryError, DatabaseRowReferencedError, DatabaseSchemaError, DatabaseTransactionError, HotUpdaterConfigError, HotUpdaterSchemaMigrationRequiredError, ReleaseCatalogCompilationError, ReleaseCatalogMutationError, ReleaseManagementError, SETTINGS_TABLE, WRITE_GUARD_TABLE, addDistinct, aggregateBatchingTables, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareUtf8, compileReleaseCatalog, coreSchema, coreSettings, coreTarget, countDistinct, createBundleStorageKey, createEngine, createEngineDatabase, createEngineSqlMigrator, createKvAdapter, createMemoryAdapter, createSettingsMigrator, createSqlAdapter, createStorageAdapter, createStorageKeyBuilder, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createTableStatements, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, defineAggregate, definePlugin, defineTable, encodeKvKey, expiresAt, extractTimestampFromUUIDv7, findPhysicalColumn, findPhysicalIndex, generateEngineSql, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, indexOrderColumns, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBusyError, isDatabaseJsonObject, isDatabaseMetadataObject, isMultiIndex, isRemoteDatabase, isUUIDv7, mergeDistinct, meterReads, migrateCoreSchema, normalizeStoredRow, parseBaseCandidateKey, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, quoteSql, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, replaceStorageUriKeySuffix, resolveLazy, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowKey, rowToBundle, rowsToBundles, semverSatisfies, sqlTableShapes, supportedIosPlatforms, targetBaseCandidateKey, toolingTargetOf, verifyAdapter, writeSchemaSettings };
|
|
41
|
+
export { BUNDLE_STORAGE_PREFIX, BundleRowHydrationError, BundleRowHydrationErrorReason, CONTENT_ADDRESSED_ASSET_PREFIX, DATABASE_VERSION_COLUMN, DatabaseAdapterContractError, DatabaseAdapterInputError, DatabaseAmbiguousCommitError, DatabaseBundleNotFoundError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, DatabaseQueryError, DatabaseRowReferencedError, DatabaseSchemaError, DatabaseTransactionError, HotUpdaterConfigError, HotUpdaterSchemaMigrationRequiredError, ReleaseCatalogCompilationError, ReleaseCatalogMutationError, ReleaseManagementError, SETTINGS_TABLE, WRITE_GUARD_TABLE, addDistinct, aggregateBatchingTables, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareUtf8, compileReleaseCatalog, coreSchema, coreSettings, coreTarget, countDistinct, createBundleStorageKey, createEngine, createEngineDatabase, createEngineSqlMigrator, createKvAdapter, createMemoryAdapter, createSettingsMigrator, createSqlAdapter, createStorageAdapter, createStorageKeyBuilder, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createTableStatements, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, defineAggregate, definePlugin, defineTable, encodeKvKey, expiresAt, extractTimestampFromUUIDv7, findPhysicalColumn, findPhysicalIndex, generateEngineSql, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, indexOrderColumns, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBusyError, isDatabaseJsonObject, isDatabaseMetadataObject, isMultiIndex, isRemoteDatabase, isUUIDv7, lateColumnStatements, mergeDistinct, meterReads, migrateCoreSchema, normalizeStoredRow, parseBaseCandidateKey, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, quoteSql, readCompiledCatalogPayload, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, replaceStorageUriKeySuffix, resolveLazy, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowKey, rowToBundle, rowsToBundles, semverSatisfies, sqlTableShapes, supportedIosPlatforms, targetBaseCandidateKey, toolingTargetOf, verifyAdapter, writeSchemaSettings };
|
|
@@ -90,7 +90,8 @@ function rangeToIntervals(range) {
|
|
|
90
90
|
throw new ReleaseCatalogCompilationError("INVALID_TARGET_RANGE", `Invalid target app-version range: ${range}`);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
/** A release's descriptor; its label only when it has one and `labels`. */
|
|
94
|
+
function releaseDescriptor(release, labels) {
|
|
94
95
|
return {
|
|
95
96
|
releaseId: release.id,
|
|
96
97
|
kind: release.kind,
|
|
@@ -98,7 +99,8 @@ function releaseDescriptor(release) {
|
|
|
98
99
|
rolloutCohortCount: release.rolloutCohortCount,
|
|
99
100
|
targetCohorts: [...new Set(release.targetCohorts)].sort(),
|
|
100
101
|
shouldForceUpdate: release.shouldForceUpdate,
|
|
101
|
-
message: release.message
|
|
102
|
+
message: release.message,
|
|
103
|
+
...labels && typeof release.label === "number" ? { label: release.label } : {}
|
|
102
104
|
};
|
|
103
105
|
}
|
|
104
106
|
function validateReleases(releases, strategy) {
|
|
@@ -306,17 +308,96 @@ function canonicalStringify(value) {
|
|
|
306
308
|
const record = value;
|
|
307
309
|
return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${canonicalStringify(record[key])}`).join(",")}}`;
|
|
308
310
|
}
|
|
311
|
+
const BOUND_SHAPE = {
|
|
312
|
+
inclusive: null,
|
|
313
|
+
version: null
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* Every key this release's compiler writes in a catalog payload, where it
|
|
317
|
+
* writes it: the envelope's, a segment's and its bounds', and a release
|
|
318
|
+
* descriptor's. A key outside it was written by a later release.
|
|
319
|
+
*/
|
|
320
|
+
const COMPILED_CATALOG_SHAPE = {
|
|
321
|
+
fallbackPolicy: null,
|
|
322
|
+
schemaVersion: null,
|
|
323
|
+
strategy: null,
|
|
324
|
+
releaseIndexes: null,
|
|
325
|
+
rollbackReleaseIndexes: null,
|
|
326
|
+
segments: {
|
|
327
|
+
lower: BOUND_SHAPE,
|
|
328
|
+
upper: BOUND_SHAPE,
|
|
329
|
+
releaseIndexes: null,
|
|
330
|
+
rollbackReleaseIndexes: null
|
|
331
|
+
},
|
|
332
|
+
releaseDescriptors: {
|
|
333
|
+
releaseId: null,
|
|
334
|
+
kind: null,
|
|
335
|
+
bundleId: null,
|
|
336
|
+
rolloutCohortCount: null,
|
|
337
|
+
targetCohorts: null,
|
|
338
|
+
shouldForceUpdate: null,
|
|
339
|
+
message: null,
|
|
340
|
+
label: null
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* A stored catalog payload as this release reads it: canonical, with the
|
|
345
|
+
* keys a later release added left out, and whether it had any, a later
|
|
346
|
+
* schema version included. Server core compares a catalog by the fields
|
|
347
|
+
* its compiler writes, and refuses to rewrite one a later release wrote,
|
|
348
|
+
* which would drop what that release added.
|
|
349
|
+
*/
|
|
350
|
+
function readCompiledCatalogPayload(payload) {
|
|
351
|
+
let fromLaterRelease = false;
|
|
352
|
+
const known = (value, shape) => {
|
|
353
|
+
if (Array.isArray(value)) return value.map((item) => known(item, shape));
|
|
354
|
+
if (value === null || typeof value !== "object") return value;
|
|
355
|
+
const entries = Object.entries(value).filter(([key]) => {
|
|
356
|
+
if (Object.hasOwn(shape, key)) return true;
|
|
357
|
+
fromLaterRelease = true;
|
|
358
|
+
return false;
|
|
359
|
+
});
|
|
360
|
+
return Object.fromEntries(entries.map(([key, entry]) => {
|
|
361
|
+
const inner = shape[key];
|
|
362
|
+
return [key, inner === null ? entry : known(entry, inner)];
|
|
363
|
+
}));
|
|
364
|
+
};
|
|
365
|
+
let parsed;
|
|
366
|
+
try {
|
|
367
|
+
parsed = JSON.parse(payload);
|
|
368
|
+
} catch {
|
|
369
|
+
parsed = null;
|
|
370
|
+
}
|
|
371
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return {
|
|
372
|
+
canonicalPayload: payload,
|
|
373
|
+
fromLaterRelease: false
|
|
374
|
+
};
|
|
375
|
+
if ("schemaVersion" in parsed && typeof parsed.schemaVersion === "number" && parsed.schemaVersion > _hot_updater_protocol.RELEASE_CATALOG_SCHEMA_VERSION) fromLaterRelease = true;
|
|
376
|
+
return {
|
|
377
|
+
canonicalPayload: canonicalStringify(known(parsed, COMPILED_CATALOG_SHAPE)),
|
|
378
|
+
fromLaterRelease
|
|
379
|
+
};
|
|
380
|
+
}
|
|
309
381
|
async function compileReleaseCatalog(input) {
|
|
310
382
|
const releases = validateReleases(input.releases, input.strategy);
|
|
311
383
|
const targetCohorts = new Set(releases.flatMap((release) => release.targetCohorts));
|
|
312
384
|
if (targetCohorts.size > _hot_updater_protocol.MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE) throw new ReleaseCatalogCompilationError("DISTINCT_TARGET_COHORT_LIMIT", `Scope exceeds ${_hot_updater_protocol.MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE} distinct target cohorts`);
|
|
313
385
|
const { envelope, retainedReleases } = input.strategy === "APP_VERSION" ? compileAppVersion(releases) : compileFingerprint(releases);
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
|
|
386
|
+
const compile = (labels) => {
|
|
387
|
+
const payload = {
|
|
388
|
+
...envelope,
|
|
389
|
+
releaseDescriptors: retainedReleases.map((release) => releaseDescriptor(release, labels))
|
|
390
|
+
};
|
|
391
|
+
const canonicalPayload = canonicalStringify(payload);
|
|
392
|
+
return {
|
|
393
|
+
payload,
|
|
394
|
+
canonicalPayload,
|
|
395
|
+
byteSize: new TextEncoder().encode(canonicalPayload).byteLength
|
|
396
|
+
};
|
|
317
397
|
};
|
|
318
|
-
|
|
319
|
-
|
|
398
|
+
let compiled = compile(true);
|
|
399
|
+
if (compiled.byteSize > _hot_updater_protocol.MAX_COMPILED_CATALOG_BYTES && retainedReleases.some((release) => typeof release.label === "number")) compiled = compile(false);
|
|
400
|
+
const { payload, canonicalPayload, byteSize } = compiled;
|
|
320
401
|
if (byteSize > _hot_updater_protocol.MAX_COMPILED_CATALOG_BYTES) throw new ReleaseCatalogCompilationError("CATALOG_OVERSIZE", `Compiled Release catalog is ${byteSize} bytes; maximum is ${_hot_updater_protocol.MAX_COMPILED_CATALOG_BYTES}`);
|
|
321
402
|
return {
|
|
322
403
|
byteSize,
|
|
@@ -379,4 +460,5 @@ Object.defineProperty(exports, "canonicalizeAppVersion", {
|
|
|
379
460
|
exports.compileReleaseCatalog = compileReleaseCatalog;
|
|
380
461
|
exports.projectCompiledCatalog = projectCompiledCatalog;
|
|
381
462
|
exports.projectCompiledRollbackCatalog = projectCompiledRollbackCatalog;
|
|
463
|
+
exports.readCompiledCatalogPayload = readCompiledCatalogPayload;
|
|
382
464
|
exports.referenceCompatibleReleases = referenceCompatibleReleases;
|
|
@@ -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, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases };
|
|
64
|
+
export { CatalogVersionBound, CompiledCatalogSegment, CompiledReleaseCatalog, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, readCompiledCatalogPayload, referenceCompatibleReleases };
|