chkit 0.1.2-beta.5 → 0.2.0-beta.8
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/README.md +35 -16
- package/dist/commands/drift/compare.d.ts +1 -1
- package/dist/commands/drift/compare.d.ts.map +1 -1
- package/dist/commands/drift/compare.js +37 -5
- package/dist/commands/drift/compare.js.map +1 -1
- package/dist/commands/generate/command.d.ts.map +1 -1
- package/dist/commands/generate/command.js +15 -5
- package/dist/commands/generate/command.js.map +1 -1
- package/dist/commands/generate/dictionary-password-warnings.d.ts +3 -0
- package/dist/commands/generate/dictionary-password-warnings.d.ts.map +1 -0
- package/dist/commands/generate/dictionary-password-warnings.js +7 -0
- package/dist/commands/generate/dictionary-password-warnings.js.map +1 -0
- package/dist/commands/generate/output.d.ts +2 -2
- package/dist/commands/generate/output.d.ts.map +1 -1
- package/dist/commands/generate/output.js +8 -2
- package/dist/commands/generate/output.js.map +1 -1
- package/dist/commands/generate/plan-pipeline.d.ts +2 -1
- package/dist/commands/generate/plan-pipeline.d.ts.map +1 -1
- package/dist/commands/generate/plan-pipeline.js +44 -1
- package/dist/commands/generate/plan-pipeline.js.map +1 -1
- package/dist/commands/generate/rename-mappings.d.ts +14 -0
- package/dist/commands/generate/rename-mappings.d.ts.map +1 -1
- package/dist/commands/generate/rename-mappings.js +131 -19
- package/dist/commands/generate/rename-mappings.js.map +1 -1
- package/dist/commands/migrate/async-apply.d.ts.map +1 -1
- package/dist/commands/migrate/async-apply.js +1 -3
- package/dist/commands/migrate/async-apply.js.map +1 -1
- package/dist/runtime/config-merge.d.ts.map +1 -1
- package/dist/runtime/config-merge.js +2 -1
- package/dist/runtime/config-merge.js.map +1 -1
- package/dist/runtime/journal-store.d.ts.map +1 -1
- package/dist/runtime/journal-store.js +17 -24
- package/dist/runtime/journal-store.js.map +1 -1
- package/dist/runtime/plugin-runtime/executor-debug.d.ts.map +1 -1
- package/dist/runtime/plugin-runtime/executor-debug.js +2 -0
- package/dist/runtime/plugin-runtime/executor-debug.js.map +1 -1
- package/dist/runtime/safety-markers.d.ts.map +1 -1
- package/dist/runtime/safety-markers.js +10 -1
- package/dist/runtime/safety-markers.js.map +1 -1
- package/package.json +7 -6
- package/dist/bin/clickhouse-resource.d.ts +0 -4
- package/dist/bin/clickhouse-resource.d.ts.map +0 -1
- package/dist/bin/clickhouse-resource.js +0 -11
- package/dist/bin/clickhouse-resource.js.map +0 -1
- package/dist/bin/command-dispatch.d.ts +0 -13
- package/dist/bin/command-dispatch.d.ts.map +0 -1
- package/dist/bin/command-dispatch.js +0 -186
- package/dist/bin/command-dispatch.js.map +0 -1
- package/dist/bin/command-registry.d.ts +0 -34
- package/dist/bin/command-registry.d.ts.map +0 -1
- package/dist/bin/command-registry.js +0 -87
- package/dist/bin/command-registry.js.map +0 -1
- package/dist/bin/commands/check.d.ts +0 -3
- package/dist/bin/commands/check.d.ts.map +0 -1
- package/dist/bin/commands/check.js +0 -181
- package/dist/bin/commands/check.js.map +0 -1
- package/dist/bin/commands/codegen.d.ts +0 -2
- package/dist/bin/commands/codegen.d.ts.map +0 -1
- package/dist/bin/commands/codegen.js +0 -25
- package/dist/bin/commands/codegen.js.map +0 -1
- package/dist/bin/commands/drift.d.ts +0 -27
- package/dist/bin/commands/drift.d.ts.map +0 -1
- package/dist/bin/commands/drift.js +0 -220
- package/dist/bin/commands/drift.js.map +0 -1
- package/dist/bin/commands/generate/output.d.ts +0 -8
- package/dist/bin/commands/generate/output.d.ts.map +0 -1
- package/dist/bin/commands/generate/output.js +0 -58
- package/dist/bin/commands/generate/output.js.map +0 -1
- package/dist/bin/commands/generate/plan-pipeline.d.ts +0 -7
- package/dist/bin/commands/generate/plan-pipeline.d.ts.map +0 -1
- package/dist/bin/commands/generate/plan-pipeline.js +0 -143
- package/dist/bin/commands/generate/plan-pipeline.js.map +0 -1
- package/dist/bin/commands/generate/rename-mappings.d.ts +0 -29
- package/dist/bin/commands/generate/rename-mappings.d.ts.map +0 -1
- package/dist/bin/commands/generate/rename-mappings.js +0 -195
- package/dist/bin/commands/generate/rename-mappings.js.map +0 -1
- package/dist/bin/commands/generate.d.ts +0 -3
- package/dist/bin/commands/generate.d.ts.map +0 -1
- package/dist/bin/commands/generate.js +0 -158
- package/dist/bin/commands/generate.js.map +0 -1
- package/dist/bin/commands/init.d.ts +0 -2
- package/dist/bin/commands/init.d.ts.map +0 -1
- package/dist/bin/commands/init.js +0 -12
- package/dist/bin/commands/init.js.map +0 -1
- package/dist/bin/commands/migrate.d.ts +0 -3
- package/dist/bin/commands/migrate.d.ts.map +0 -1
- package/dist/bin/commands/migrate.js +0 -288
- package/dist/bin/commands/migrate.js.map +0 -1
- package/dist/bin/commands/plugin-like.d.ts +0 -38
- package/dist/bin/commands/plugin-like.d.ts.map +0 -1
- package/dist/bin/commands/plugin-like.js +0 -101
- package/dist/bin/commands/plugin-like.js.map +0 -1
- package/dist/bin/commands/plugin.d.ts +0 -3
- package/dist/bin/commands/plugin.d.ts.map +0 -1
- package/dist/bin/commands/plugin.js +0 -148
- package/dist/bin/commands/plugin.js.map +0 -1
- package/dist/bin/commands/pull.d.ts +0 -2
- package/dist/bin/commands/pull.d.ts.map +0 -1
- package/dist/bin/commands/pull.js +0 -25
- package/dist/bin/commands/pull.js.map +0 -1
- package/dist/bin/commands/status.d.ts +0 -3
- package/dist/bin/commands/status.d.ts.map +0 -1
- package/dist/bin/commands/status.js +0 -63
- package/dist/bin/commands/status.js.map +0 -1
- package/dist/bin/commands/typegen.d.ts +0 -2
- package/dist/bin/commands/typegen.d.ts.map +0 -1
- package/dist/bin/commands/typegen.js +0 -25
- package/dist/bin/commands/typegen.js.map +0 -1
- package/dist/bin/config.d.ts +0 -13
- package/dist/bin/config.d.ts.map +0 -1
- package/dist/bin/config.js +0 -48
- package/dist/bin/config.js.map +0 -1
- package/dist/bin/debug.d.ts +0 -3
- package/dist/bin/debug.d.ts.map +0 -1
- package/dist/bin/debug.js +0 -14
- package/dist/bin/debug.js.map +0 -1
- package/dist/bin/global-flags.d.ts +0 -16
- package/dist/bin/global-flags.d.ts.map +0 -1
- package/dist/bin/global-flags.js +0 -7
- package/dist/bin/global-flags.js.map +0 -1
- package/dist/bin/help.d.ts +0 -5
- package/dist/bin/help.d.ts.map +0 -1
- package/dist/bin/help.js +0 -84
- package/dist/bin/help.js.map +0 -1
- package/dist/bin/internal-plugins/index.d.ts +0 -3
- package/dist/bin/internal-plugins/index.d.ts.map +0 -1
- package/dist/bin/internal-plugins/index.js +0 -5
- package/dist/bin/internal-plugins/index.js.map +0 -1
- package/dist/bin/internal-plugins/skill-hint.d.ts +0 -31
- package/dist/bin/internal-plugins/skill-hint.d.ts.map +0 -1
- package/dist/bin/internal-plugins/skill-hint.js +0 -172
- package/dist/bin/internal-plugins/skill-hint.js.map +0 -1
- package/dist/bin/journal-store.d.ts +0 -10
- package/dist/bin/journal-store.d.ts.map +0 -1
- package/dist/bin/journal-store.js +0 -137
- package/dist/bin/journal-store.js.map +0 -1
- package/dist/bin/json-output.d.ts +0 -5
- package/dist/bin/json-output.d.ts.map +0 -1
- package/dist/bin/json-output.js +0 -21
- package/dist/bin/json-output.js.map +0 -1
- package/dist/bin/lib.d.ts +0 -5
- package/dist/bin/lib.d.ts.map +0 -1
- package/dist/bin/lib.js +0 -5
- package/dist/bin/lib.js.map +0 -1
- package/dist/bin/logging.d.ts +0 -3
- package/dist/bin/logging.d.ts.map +0 -1
- package/dist/bin/logging.js +0 -31
- package/dist/bin/logging.js.map +0 -1
- package/dist/bin/migration-store.d.ts +0 -22
- package/dist/bin/migration-store.d.ts.map +0 -1
- package/dist/bin/migration-store.js +0 -60
- package/dist/bin/migration-store.js.map +0 -1
- package/dist/bin/plugin-runtime.d.ts +0 -45
- package/dist/bin/plugin-runtime.d.ts.map +0 -1
- package/dist/bin/plugin-runtime.js +0 -513
- package/dist/bin/plugin-runtime.js.map +0 -1
- package/dist/bin/safety-markers.d.ts +0 -23
- package/dist/bin/safety-markers.d.ts.map +0 -1
- package/dist/bin/safety-markers.js +0 -85
- package/dist/bin/safety-markers.js.map +0 -1
- package/dist/bin/schema-loader.d.ts +0 -3
- package/dist/bin/schema-loader.d.ts.map +0 -1
- package/dist/bin/schema-loader.js +0 -11
- package/dist/bin/schema-loader.js.map +0 -1
- package/dist/bin/table-scope.d.ts +0 -38
- package/dist/bin/table-scope.d.ts.map +0 -1
- package/dist/bin/table-scope.js +0 -167
- package/dist/bin/table-scope.js.map +0 -1
- package/dist/bin/version.d.ts +0 -2
- package/dist/bin/version.d.ts.map +0 -1
- package/dist/bin/version.js +0 -5
- package/dist/bin/version.js.map +0 -1
- package/dist/drift-diff.d.ts +0 -8
- package/dist/drift-diff.d.ts.map +0 -1
- package/dist/drift-diff.js +0 -46
- package/dist/drift-diff.js.map +0 -1
- package/dist/drift.d.ts +0 -66
- package/dist/drift.d.ts.map +0 -1
- package/dist/drift.js +0 -220
- package/dist/drift.js.map +0 -1
|
@@ -1,513 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'node:path';
|
|
2
|
-
import { pathToFileURL } from 'node:url';
|
|
3
|
-
import { canonicalizeDefinitions, } from '@chkit/core';
|
|
4
|
-
import { createClickHouseExecutor } from '@chkit/clickhouse';
|
|
5
|
-
import { isInlinePluginRegistration } from '../plugins.js';
|
|
6
|
-
import { debug, isDebugEnabled } from './debug.js';
|
|
7
|
-
const UNFILTERED_TABLE_SCOPE = {
|
|
8
|
-
enabled: false,
|
|
9
|
-
matchedTables: [],
|
|
10
|
-
matchCount: 0,
|
|
11
|
-
};
|
|
12
|
-
function parseCliMajor(version) {
|
|
13
|
-
const major = Number(version.split('.')[0] ?? Number.NaN);
|
|
14
|
-
if (!Number.isInteger(major) || major < 0) {
|
|
15
|
-
throw new Error(`Invalid CLI version "${version}" while loading plugins.`);
|
|
16
|
-
}
|
|
17
|
-
return major;
|
|
18
|
-
}
|
|
19
|
-
function normalizePluginRegistration(entry) {
|
|
20
|
-
if (typeof entry === 'string') {
|
|
21
|
-
return {
|
|
22
|
-
kind: 'legacy',
|
|
23
|
-
resolvePath: entry,
|
|
24
|
-
enabled: true,
|
|
25
|
-
options: {},
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
if (isInlinePluginRegistration(entry)) {
|
|
29
|
-
return {
|
|
30
|
-
kind: 'inline',
|
|
31
|
-
resolvePath: '',
|
|
32
|
-
inlinePlugin: entry.plugin,
|
|
33
|
-
nameHint: entry.name,
|
|
34
|
-
enabled: entry.enabled !== false,
|
|
35
|
-
options: entry.options ?? {},
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
const legacy = entry;
|
|
39
|
-
return {
|
|
40
|
-
kind: 'legacy',
|
|
41
|
-
resolvePath: legacy.resolve,
|
|
42
|
-
nameHint: legacy.name,
|
|
43
|
-
enabled: legacy.enabled !== false,
|
|
44
|
-
options: legacy.options ?? {},
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function wrapExecutorWithDebug(executor) {
|
|
48
|
-
if (!isDebugEnabled())
|
|
49
|
-
return executor;
|
|
50
|
-
return {
|
|
51
|
-
async command(sql) {
|
|
52
|
-
debug('clickhouse', `command: ${sql.slice(0, 200)}${sql.length > 200 ? '...' : ''}`);
|
|
53
|
-
const start = performance.now();
|
|
54
|
-
try {
|
|
55
|
-
await executor.command(sql);
|
|
56
|
-
debug('clickhouse', `command OK (${Math.round(performance.now() - start)}ms)`);
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
debug('clickhouse', `command FAILED (${Math.round(performance.now() - start)}ms)`, error instanceof Error ? error.message : error);
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
async query(sql) {
|
|
64
|
-
debug('clickhouse', `query: ${sql.slice(0, 200)}${sql.length > 200 ? '...' : ''}`);
|
|
65
|
-
const start = performance.now();
|
|
66
|
-
try {
|
|
67
|
-
const rows = await executor.query(sql);
|
|
68
|
-
debug('clickhouse', `query OK — ${rows.length} rows (${Math.round(performance.now() - start)}ms)`);
|
|
69
|
-
return rows;
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
debug('clickhouse', `query FAILED (${Math.round(performance.now() - start)}ms)`, error instanceof Error ? error.message : error);
|
|
73
|
-
throw error;
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
async insert(params) {
|
|
77
|
-
debug('clickhouse', `insert into ${params.table} — ${params.values.length} rows`);
|
|
78
|
-
const start = performance.now();
|
|
79
|
-
try {
|
|
80
|
-
await executor.insert(params);
|
|
81
|
-
debug('clickhouse', `insert OK (${Math.round(performance.now() - start)}ms)`);
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
debug('clickhouse', `insert FAILED (${Math.round(performance.now() - start)}ms)`, error instanceof Error ? error.message : error);
|
|
85
|
-
throw error;
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
async submit(sql, queryId) {
|
|
89
|
-
debug('clickhouse', `submit${queryId ? ` (id: ${queryId})` : ''}: ${sql.slice(0, 200)}${sql.length > 200 ? '...' : ''}`);
|
|
90
|
-
const start = performance.now();
|
|
91
|
-
try {
|
|
92
|
-
const id = await executor.submit(sql, queryId);
|
|
93
|
-
debug('clickhouse', `submit OK — id: ${id} (${Math.round(performance.now() - start)}ms)`);
|
|
94
|
-
return id;
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
debug('clickhouse', `submit FAILED (${Math.round(performance.now() - start)}ms)`, error instanceof Error ? error.message : error);
|
|
98
|
-
throw error;
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
async queryStatus(queryId, options) {
|
|
102
|
-
debug('clickhouse', `queryStatus for ${queryId}`);
|
|
103
|
-
const start = performance.now();
|
|
104
|
-
try {
|
|
105
|
-
const status = await executor.queryStatus(queryId, options);
|
|
106
|
-
debug('clickhouse', `queryStatus: ${status.status} (${Math.round(performance.now() - start)}ms)`);
|
|
107
|
-
return status;
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
debug('clickhouse', `queryStatus FAILED (${Math.round(performance.now() - start)}ms)`, error instanceof Error ? error.message : error);
|
|
111
|
-
throw error;
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
async listSchemaObjects() {
|
|
115
|
-
debug('clickhouse', 'listSchemaObjects');
|
|
116
|
-
const start = performance.now();
|
|
117
|
-
try {
|
|
118
|
-
const objects = await executor.listSchemaObjects();
|
|
119
|
-
debug('clickhouse', `listSchemaObjects OK — ${objects.length} objects (${Math.round(performance.now() - start)}ms)`);
|
|
120
|
-
return objects;
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
debug('clickhouse', `listSchemaObjects FAILED (${Math.round(performance.now() - start)}ms)`, error instanceof Error ? error.message : error);
|
|
124
|
-
throw error;
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
async listTableDetails(databases) {
|
|
128
|
-
debug('clickhouse', `listTableDetails for databases: [${databases.join(', ')}]`);
|
|
129
|
-
const start = performance.now();
|
|
130
|
-
try {
|
|
131
|
-
const tables = await executor.listTableDetails(databases);
|
|
132
|
-
debug('clickhouse', `listTableDetails OK — ${tables.length} tables (${Math.round(performance.now() - start)}ms)`);
|
|
133
|
-
return tables;
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
debug('clickhouse', `listTableDetails FAILED (${Math.round(performance.now() - start)}ms)`, error instanceof Error ? error.message : error);
|
|
137
|
-
throw error;
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
async close() {
|
|
141
|
-
debug('clickhouse', 'closing connections');
|
|
142
|
-
await executor.close();
|
|
143
|
-
},
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
function formatPluginError(pluginName, hook, error) {
|
|
147
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
148
|
-
return new Error(`Plugin "${pluginName}" failed in ${hook}: ${message}`);
|
|
149
|
-
}
|
|
150
|
-
function validatePlugin(cliVersion, plugin, sourcePath) {
|
|
151
|
-
const name = plugin.manifest.name;
|
|
152
|
-
if (!name || name.trim().length === 0) {
|
|
153
|
-
throw new Error(`Plugin at ${sourcePath} has an empty manifest.name.`);
|
|
154
|
-
}
|
|
155
|
-
if (plugin.manifest.apiVersion !== 1) {
|
|
156
|
-
throw new Error(`Plugin "${name}" requires apiVersion=${String(plugin.manifest.apiVersion)} but CLI supports apiVersion=1.`);
|
|
157
|
-
}
|
|
158
|
-
const compatibility = plugin.manifest.compatibility?.cli;
|
|
159
|
-
if (!compatibility)
|
|
160
|
-
return;
|
|
161
|
-
const cliMajor = parseCliMajor(cliVersion);
|
|
162
|
-
if (compatibility.minMajor !== undefined && cliMajor < compatibility.minMajor) {
|
|
163
|
-
throw new Error(`Plugin "${name}" is incompatible with CLI ${cliVersion}. Requires cli major >= ${compatibility.minMajor}.`);
|
|
164
|
-
}
|
|
165
|
-
if (compatibility.maxMajor !== undefined && cliMajor > compatibility.maxMajor) {
|
|
166
|
-
throw new Error(`Plugin "${name}" is incompatible with CLI ${cliVersion}. Requires cli major <= ${compatibility.maxMajor}.`);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
async function importPluginModule(absolutePath) {
|
|
170
|
-
const mod = (await import(pathToFileURL(absolutePath).href));
|
|
171
|
-
const candidate = (mod.default ?? mod.plugin);
|
|
172
|
-
if (!candidate || typeof candidate !== 'object') {
|
|
173
|
-
throw new Error(`Plugin module ${absolutePath} must export default definePlugin(...)`);
|
|
174
|
-
}
|
|
175
|
-
if (!candidate.manifest || typeof candidate.manifest !== 'object') {
|
|
176
|
-
throw new Error(`Plugin module ${absolutePath} is missing manifest.`);
|
|
177
|
-
}
|
|
178
|
-
return candidate;
|
|
179
|
-
}
|
|
180
|
-
export async function loadPluginRuntime(input) {
|
|
181
|
-
const registrations = input.config.plugins ?? [];
|
|
182
|
-
const loaded = [];
|
|
183
|
-
const byName = new Map();
|
|
184
|
-
const configDir = resolve(input.configPath, '..');
|
|
185
|
-
for (const registration of registrations) {
|
|
186
|
-
const normalized = normalizePluginRegistration(registration);
|
|
187
|
-
if (!normalized.enabled)
|
|
188
|
-
continue;
|
|
189
|
-
const plugin = normalized.kind === 'inline'
|
|
190
|
-
? normalized.inlinePlugin
|
|
191
|
-
: await importPluginModule(resolve(configDir, normalized.resolvePath));
|
|
192
|
-
if (!plugin)
|
|
193
|
-
continue;
|
|
194
|
-
const sourceLabel = normalized.kind === 'inline'
|
|
195
|
-
? `inline registration${normalized.nameHint ? ` (${normalized.nameHint})` : ''}`
|
|
196
|
-
: resolve(configDir, normalized.resolvePath);
|
|
197
|
-
validatePlugin(input.cliVersion, plugin, sourceLabel);
|
|
198
|
-
if (normalized.nameHint && normalized.nameHint !== plugin.manifest.name) {
|
|
199
|
-
throw new Error(`Plugin name mismatch for ${sourceLabel}: configured "${normalized.nameHint}" but manifest is "${plugin.manifest.name}".`);
|
|
200
|
-
}
|
|
201
|
-
if (byName.has(plugin.manifest.name)) {
|
|
202
|
-
throw new Error(`Duplicate plugin name "${plugin.manifest.name}" in config.plugins.`);
|
|
203
|
-
}
|
|
204
|
-
debug('plugin', `loaded "${plugin.manifest.name}" v${plugin.manifest.version ?? '?'}`, {
|
|
205
|
-
hooks: Object.keys(plugin.hooks ?? {}),
|
|
206
|
-
commands: (plugin.commands ?? []).map((c) => c.name),
|
|
207
|
-
});
|
|
208
|
-
const item = {
|
|
209
|
-
plugin,
|
|
210
|
-
options: normalized.options,
|
|
211
|
-
};
|
|
212
|
-
loaded.push(item);
|
|
213
|
-
byName.set(plugin.manifest.name, item);
|
|
214
|
-
}
|
|
215
|
-
for (const plugin of input.internalPlugins ?? []) {
|
|
216
|
-
if (byName.has(plugin.manifest.name))
|
|
217
|
-
continue;
|
|
218
|
-
const item = { plugin, options: {} };
|
|
219
|
-
loaded.push(item);
|
|
220
|
-
byName.set(plugin.manifest.name, item);
|
|
221
|
-
}
|
|
222
|
-
async function runBeforePluginCommandHooks(pluginName, commandName, context) {
|
|
223
|
-
for (const item of loaded) {
|
|
224
|
-
if (item.plugin.manifest.name === pluginName)
|
|
225
|
-
continue;
|
|
226
|
-
const hook = item.plugin.hooks?.onBeforePluginCommand;
|
|
227
|
-
if (!hook)
|
|
228
|
-
continue;
|
|
229
|
-
debug('hook', `onBeforePluginCommand → ${item.plugin.manifest.name} (target: ${pluginName}:${commandName})`);
|
|
230
|
-
try {
|
|
231
|
-
const result = await hook({
|
|
232
|
-
...context,
|
|
233
|
-
targetPlugin: pluginName,
|
|
234
|
-
command: commandName,
|
|
235
|
-
options: item.options,
|
|
236
|
-
});
|
|
237
|
-
if (result.handled) {
|
|
238
|
-
debug('hook', `onBeforePluginCommand ← ${item.plugin.manifest.name} handled command (exitCode: ${result.exitCode})`);
|
|
239
|
-
return result;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
catch (error) {
|
|
243
|
-
throw formatPluginError(item.plugin.manifest.name, 'onBeforePluginCommand', error);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return { handled: false };
|
|
247
|
-
}
|
|
248
|
-
const NULL_EXECUTOR = (() => {
|
|
249
|
-
const err = () => {
|
|
250
|
-
throw new Error('No ClickHouse connection configured and no plugin provided an executor');
|
|
251
|
-
};
|
|
252
|
-
return {
|
|
253
|
-
command: err,
|
|
254
|
-
query: err,
|
|
255
|
-
insert: err,
|
|
256
|
-
submit: err,
|
|
257
|
-
queryStatus: err,
|
|
258
|
-
listSchemaObjects: err,
|
|
259
|
-
listTableDetails: err,
|
|
260
|
-
close: () => Promise.resolve(),
|
|
261
|
-
};
|
|
262
|
-
})();
|
|
263
|
-
return {
|
|
264
|
-
plugins: loaded,
|
|
265
|
-
async resolveContext(input) {
|
|
266
|
-
const hasClickhouseConfig = !!input.config.clickhouse;
|
|
267
|
-
debug('context', `resolving executor — clickhouse config: ${hasClickhouseConfig ? 'yes' : 'no'}`);
|
|
268
|
-
const rawExecutor = hasClickhouseConfig
|
|
269
|
-
? createClickHouseExecutor(input.config.clickhouse)
|
|
270
|
-
: NULL_EXECUTOR;
|
|
271
|
-
const defaults = {
|
|
272
|
-
executor: wrapExecutorWithDebug(rawExecutor),
|
|
273
|
-
hasExecutor: hasClickhouseConfig,
|
|
274
|
-
};
|
|
275
|
-
let ctx = defaults;
|
|
276
|
-
for (const item of loaded) {
|
|
277
|
-
const hook = item.plugin.hooks?.getContext;
|
|
278
|
-
if (!hook)
|
|
279
|
-
continue;
|
|
280
|
-
try {
|
|
281
|
-
const result = await hook({ ...input, defaults });
|
|
282
|
-
if (result && typeof result === 'object' && 'executor' in result && result.executor) {
|
|
283
|
-
debug('context', `plugin "${item.plugin.manifest.name}" provided executor override`);
|
|
284
|
-
// Plugin returned an executor override — close the default one
|
|
285
|
-
if (ctx.executor !== defaults.executor) {
|
|
286
|
-
// A previous plugin already overrode — close that one
|
|
287
|
-
await ctx.executor.close();
|
|
288
|
-
}
|
|
289
|
-
else if (ctx === defaults && defaults.executor !== NULL_EXECUTOR) {
|
|
290
|
-
// First override — close the default executor
|
|
291
|
-
await defaults.executor.close();
|
|
292
|
-
}
|
|
293
|
-
ctx = { ...ctx, ...result, hasExecutor: true };
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
catch (error) {
|
|
297
|
-
await ctx.executor.close();
|
|
298
|
-
throw formatPluginError(item.plugin.manifest.name, 'getContext', error);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
return ctx;
|
|
302
|
-
},
|
|
303
|
-
async disposeContext(ctx) {
|
|
304
|
-
await ctx.executor.close();
|
|
305
|
-
},
|
|
306
|
-
getCommand(pluginName, commandName) {
|
|
307
|
-
const item = byName.get(pluginName);
|
|
308
|
-
if (!item)
|
|
309
|
-
return null;
|
|
310
|
-
const command = (item.plugin.commands ?? []).find((entry) => entry.name === commandName);
|
|
311
|
-
if (!command)
|
|
312
|
-
return null;
|
|
313
|
-
return { plugin: item, command };
|
|
314
|
-
},
|
|
315
|
-
async runOnInit(context) {
|
|
316
|
-
for (const item of loaded) {
|
|
317
|
-
const hook = item.plugin.hooks?.onInit;
|
|
318
|
-
if (!hook)
|
|
319
|
-
continue;
|
|
320
|
-
debug('hook', `onInit → ${item.plugin.manifest.name}`);
|
|
321
|
-
try {
|
|
322
|
-
await hook({ ...context, options: item.options });
|
|
323
|
-
}
|
|
324
|
-
catch (error) {
|
|
325
|
-
throw formatPluginError(item.plugin.manifest.name, 'onInit', error);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
},
|
|
329
|
-
async runOnComplete(context) {
|
|
330
|
-
const exitCode = context.exitCode ?? 0;
|
|
331
|
-
for (const item of loaded) {
|
|
332
|
-
const hook = item.plugin.hooks?.onComplete;
|
|
333
|
-
if (!hook)
|
|
334
|
-
continue;
|
|
335
|
-
debug('hook', `onComplete → ${item.plugin.manifest.name} (exitCode: ${exitCode})`);
|
|
336
|
-
try {
|
|
337
|
-
await hook({ ...context, exitCode, options: item.options });
|
|
338
|
-
}
|
|
339
|
-
catch (error) {
|
|
340
|
-
throw formatPluginError(item.plugin.manifest.name, 'onComplete', error);
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
},
|
|
344
|
-
async runOnConfigLoaded(context) {
|
|
345
|
-
const tableScope = context.tableScope ?? UNFILTERED_TABLE_SCOPE;
|
|
346
|
-
for (const item of loaded) {
|
|
347
|
-
const hook = item.plugin.hooks?.onConfigLoaded;
|
|
348
|
-
if (!hook)
|
|
349
|
-
continue;
|
|
350
|
-
debug('hook', `onConfigLoaded → ${item.plugin.manifest.name}`);
|
|
351
|
-
try {
|
|
352
|
-
await hook({ ...context, options: item.options, tableScope });
|
|
353
|
-
}
|
|
354
|
-
catch (error) {
|
|
355
|
-
throw formatPluginError(item.plugin.manifest.name, 'onConfigLoaded', error);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
},
|
|
359
|
-
async runOnSchemaLoaded(context) {
|
|
360
|
-
let definitions = context.definitions;
|
|
361
|
-
for (const item of loaded) {
|
|
362
|
-
const hook = item.plugin.hooks?.onSchemaLoaded;
|
|
363
|
-
if (!hook)
|
|
364
|
-
continue;
|
|
365
|
-
debug('hook', `onSchemaLoaded → ${item.plugin.manifest.name} (${definitions.length} definitions)`);
|
|
366
|
-
try {
|
|
367
|
-
const next = await hook({ ...context, definitions });
|
|
368
|
-
if (Array.isArray(next)) {
|
|
369
|
-
debug('hook', `onSchemaLoaded ← ${item.plugin.manifest.name} returned ${next.length} definitions`);
|
|
370
|
-
definitions = canonicalizeDefinitions(next);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
catch (error) {
|
|
374
|
-
throw formatPluginError(item.plugin.manifest.name, 'onSchemaLoaded', error);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
return definitions;
|
|
378
|
-
},
|
|
379
|
-
async runOnPlanCreated(context, initialPlan) {
|
|
380
|
-
const tableScope = context.tableScope ?? UNFILTERED_TABLE_SCOPE;
|
|
381
|
-
let plan = initialPlan;
|
|
382
|
-
for (const item of loaded) {
|
|
383
|
-
const hook = item.plugin.hooks?.onPlanCreated;
|
|
384
|
-
if (!hook)
|
|
385
|
-
continue;
|
|
386
|
-
debug('hook', `onPlanCreated → ${item.plugin.manifest.name} (${plan.operations.length} operations)`);
|
|
387
|
-
try {
|
|
388
|
-
const next = await hook({ ...context, tableScope, plan });
|
|
389
|
-
if (next) {
|
|
390
|
-
debug('hook', `onPlanCreated ← ${item.plugin.manifest.name} modified plan (${next.operations.length} operations)`);
|
|
391
|
-
plan = next;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
catch (error) {
|
|
395
|
-
throw formatPluginError(item.plugin.manifest.name, 'onPlanCreated', error);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
return plan;
|
|
399
|
-
},
|
|
400
|
-
async runOnBeforeApply(context) {
|
|
401
|
-
let statements = context.statements;
|
|
402
|
-
for (const item of loaded) {
|
|
403
|
-
const hook = item.plugin.hooks?.onBeforeApply;
|
|
404
|
-
if (!hook)
|
|
405
|
-
continue;
|
|
406
|
-
debug('hook', `onBeforeApply → ${item.plugin.manifest.name} (${context.migration}, ${statements.length} statements)`);
|
|
407
|
-
try {
|
|
408
|
-
const result = await hook({ ...context, statements });
|
|
409
|
-
if (result?.statements) {
|
|
410
|
-
debug('hook', `onBeforeApply ← ${item.plugin.manifest.name} modified statements (${result.statements.length})`);
|
|
411
|
-
statements = result.statements;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
catch (error) {
|
|
415
|
-
throw formatPluginError(item.plugin.manifest.name, 'onBeforeApply', error);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
return statements;
|
|
419
|
-
},
|
|
420
|
-
async runOnAfterApply(context) {
|
|
421
|
-
for (const item of loaded) {
|
|
422
|
-
const hook = item.plugin.hooks?.onAfterApply;
|
|
423
|
-
if (!hook)
|
|
424
|
-
continue;
|
|
425
|
-
debug('hook', `onAfterApply → ${item.plugin.manifest.name} (${context.migration})`);
|
|
426
|
-
try {
|
|
427
|
-
await hook(context);
|
|
428
|
-
}
|
|
429
|
-
catch (error) {
|
|
430
|
-
throw formatPluginError(item.plugin.manifest.name, 'onAfterApply', error);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
},
|
|
434
|
-
async runOnCheck(context) {
|
|
435
|
-
const tableScope = context.tableScope ?? UNFILTERED_TABLE_SCOPE;
|
|
436
|
-
const results = [];
|
|
437
|
-
for (const item of loaded) {
|
|
438
|
-
const hook = item.plugin.hooks?.onCheck;
|
|
439
|
-
if (!hook)
|
|
440
|
-
continue;
|
|
441
|
-
debug('hook', `onCheck → ${item.plugin.manifest.name}`);
|
|
442
|
-
try {
|
|
443
|
-
const result = await hook({ ...context, options: item.options, tableScope });
|
|
444
|
-
if (!result)
|
|
445
|
-
continue;
|
|
446
|
-
debug('hook', `onCheck ← ${item.plugin.manifest.name}: ok=${result.ok}, findings=${result.findings.length}`);
|
|
447
|
-
results.push({
|
|
448
|
-
plugin: result.plugin || item.plugin.manifest.name,
|
|
449
|
-
evaluated: result.evaluated,
|
|
450
|
-
ok: result.ok,
|
|
451
|
-
findings: result.findings,
|
|
452
|
-
metadata: result.metadata,
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
catch (error) {
|
|
456
|
-
throw formatPluginError(item.plugin.manifest.name, 'onCheck', error);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
return results;
|
|
460
|
-
},
|
|
461
|
-
async runOnCheckReport(results, print) {
|
|
462
|
-
for (const result of results) {
|
|
463
|
-
const item = byName.get(result.plugin);
|
|
464
|
-
if (!item)
|
|
465
|
-
continue;
|
|
466
|
-
const hook = item.plugin.hooks?.onCheckReport;
|
|
467
|
-
if (!hook)
|
|
468
|
-
continue;
|
|
469
|
-
try {
|
|
470
|
-
await hook({ result, print });
|
|
471
|
-
}
|
|
472
|
-
catch (error) {
|
|
473
|
-
throw formatPluginError(item.plugin.manifest.name, 'onCheckReport', error);
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
},
|
|
477
|
-
runOnBeforePluginCommand: runBeforePluginCommandHooks,
|
|
478
|
-
async runPluginCommand(pluginName, commandName, context) {
|
|
479
|
-
debug('command', `running plugin command "${pluginName}:${commandName}"`);
|
|
480
|
-
const item = byName.get(pluginName);
|
|
481
|
-
if (!item)
|
|
482
|
-
return 1;
|
|
483
|
-
const command = (item.plugin.commands ?? []).find((entry) => entry.name === commandName);
|
|
484
|
-
if (!command)
|
|
485
|
-
return 1;
|
|
486
|
-
// Run onBeforePluginCommand hooks — if any returns handled, skip the command
|
|
487
|
-
const beforeResult = await runBeforePluginCommandHooks(pluginName, commandName, {
|
|
488
|
-
config: context.config,
|
|
489
|
-
configPath: context.configPath,
|
|
490
|
-
jsonMode: context.jsonMode,
|
|
491
|
-
args: context.args,
|
|
492
|
-
flags: context.flags,
|
|
493
|
-
tableScope: context.tableScope ?? UNFILTERED_TABLE_SCOPE,
|
|
494
|
-
print: context.print,
|
|
495
|
-
});
|
|
496
|
-
if (beforeResult.handled)
|
|
497
|
-
return beforeResult.exitCode;
|
|
498
|
-
try {
|
|
499
|
-
const code = await command.run({
|
|
500
|
-
...context,
|
|
501
|
-
pluginName,
|
|
502
|
-
options: item.options,
|
|
503
|
-
tableScope: context.tableScope ?? UNFILTERED_TABLE_SCOPE,
|
|
504
|
-
});
|
|
505
|
-
return typeof code === 'number' ? code : 0;
|
|
506
|
-
}
|
|
507
|
-
catch (error) {
|
|
508
|
-
throw formatPluginError(item.plugin.manifest.name, `command:${commandName}`, error);
|
|
509
|
-
}
|
|
510
|
-
},
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
//# sourceMappingURL=plugin-runtime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-runtime.js","sourceRoot":"","sources":["../../src/bin/plugin-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EACL,uBAAuB,GAMxB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,wBAAwB,EAA2B,MAAM,mBAAmB,CAAA;AAoBrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAA;AAE1D,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAOlD,MAAM,sBAAsB,GAAe;IACzC,OAAO,EAAE,KAAK;IACd,aAAa,EAAE,EAAE;IACjB,UAAU,EAAE,CAAC;CACd,CAAA;AAqCD,SAAS,aAAa,CAAC,OAAe;IACpC,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAA;IACzD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,wBAAwB,OAAO,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ExecutableStatements } from '@chkit/core';
|
|
2
|
-
export { extractExecutableStatements };
|
|
3
|
-
export interface DestructiveOperationMarker {
|
|
4
|
-
migration: string;
|
|
5
|
-
type: string;
|
|
6
|
-
key: string;
|
|
7
|
-
risk: string;
|
|
8
|
-
warningCode: string;
|
|
9
|
-
reason: string;
|
|
10
|
-
impact: string;
|
|
11
|
-
recommendation: string;
|
|
12
|
-
summary: string;
|
|
13
|
-
}
|
|
14
|
-
interface MigrationOperationSummary {
|
|
15
|
-
type: string;
|
|
16
|
-
key: string;
|
|
17
|
-
risk: string;
|
|
18
|
-
summary: string;
|
|
19
|
-
}
|
|
20
|
-
export declare function migrationContainsDangerOperation(sql: string): boolean;
|
|
21
|
-
export declare function extractMigrationOperationSummaries(sql: string): MigrationOperationSummary[];
|
|
22
|
-
export declare function collectDestructiveOperationMarkers(migration: string, sql: string): DestructiveOperationMarker[];
|
|
23
|
-
//# sourceMappingURL=safety-markers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"safety-markers.d.ts","sourceRoot":"","sources":["../../src/bin/safety-markers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAEzD,OAAO,EAAE,2BAA2B,EAAE,CAAA;AAEtC,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,UAAU,yBAAyB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAErE;AAqBD,wBAAgB,kCAAkC,CAAC,GAAG,EAAE,MAAM,GAAG,yBAAyB,EAAE,CAQ3F;AAyCD,wBAAgB,kCAAkC,CAChD,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,GACV,0BAA0B,EAAE,CAmB9B"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { extractExecutableStatements } from '@chkit/core';
|
|
2
|
-
export { extractExecutableStatements };
|
|
3
|
-
export function migrationContainsDangerOperation(sql) {
|
|
4
|
-
return extractDestructiveOperationSummaries(sql).length > 0;
|
|
5
|
-
}
|
|
6
|
-
function extractDestructiveOperationSummaries(sql) {
|
|
7
|
-
return sql
|
|
8
|
-
.split('\n')
|
|
9
|
-
.map((line) => line.trim())
|
|
10
|
-
.filter((line) => line.startsWith('-- operation:') && line.includes('risk=danger'))
|
|
11
|
-
.map((line) => line.replace(/^-- operation:\s*/, ''));
|
|
12
|
-
}
|
|
13
|
-
function parseOperationLine(summary) {
|
|
14
|
-
const match = summary.match(/^([a-z_]+)\s+key=([^\s]+)\s+risk=([a-z_]+)$/);
|
|
15
|
-
if (!match)
|
|
16
|
-
return null;
|
|
17
|
-
return {
|
|
18
|
-
type: match[1] ?? 'unknown',
|
|
19
|
-
key: match[2] ?? 'unknown',
|
|
20
|
-
risk: match[3] ?? 'unknown',
|
|
21
|
-
summary,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export function extractMigrationOperationSummaries(sql) {
|
|
25
|
-
return sql
|
|
26
|
-
.split('\n')
|
|
27
|
-
.map((line) => line.trim())
|
|
28
|
-
.filter((line) => line.startsWith('-- operation:'))
|
|
29
|
-
.map((line) => line.replace(/^-- operation:\s*/, ''))
|
|
30
|
-
.map((summary) => parseOperationLine(summary))
|
|
31
|
-
.filter((item) => item !== null);
|
|
32
|
-
}
|
|
33
|
-
function describeDestructiveOperation(type) {
|
|
34
|
-
if (type === 'drop_table') {
|
|
35
|
-
return {
|
|
36
|
-
warningCode: 'drop_table_data_loss',
|
|
37
|
-
reason: 'Dropping a table removes table data and metadata from the target database.',
|
|
38
|
-
impact: 'Queries that depend on this table will fail until it is recreated and repopulated.',
|
|
39
|
-
recommendation: 'Verify backups and downstream dependencies before approving.',
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
if (type === 'alter_table_drop_column') {
|
|
43
|
-
return {
|
|
44
|
-
warningCode: 'drop_column_irreversible',
|
|
45
|
-
reason: 'Dropping a column permanently removes stored values for that column.',
|
|
46
|
-
impact: 'Applications or analytics depending on the column will break or return incomplete data.',
|
|
47
|
-
recommendation: 'Confirm the column is deprecated and no readers still require it.',
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
if (type === 'drop_view' || type === 'drop_materialized_view') {
|
|
51
|
-
return {
|
|
52
|
-
warningCode: 'drop_view_dependency_break',
|
|
53
|
-
reason: 'Dropping a view removes a query interface used by clients and pipelines.',
|
|
54
|
-
impact: 'Dependent workloads may fail until compatible replacements are in place.',
|
|
55
|
-
recommendation: 'Confirm replacement view rollout and dependency readiness.',
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
warningCode: 'destructive_operation_review_required',
|
|
60
|
-
reason: 'This operation is marked destructive by planner risk classification.',
|
|
61
|
-
impact: 'Execution may cause irreversible schema or data changes.',
|
|
62
|
-
recommendation: 'Review SQL and dependency impact before approving.',
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
export function collectDestructiveOperationMarkers(migration, sql) {
|
|
66
|
-
return extractDestructiveOperationSummaries(sql).map((summary) => {
|
|
67
|
-
const parsed = parseOperationLine(summary);
|
|
68
|
-
const type = parsed?.type ?? 'unknown';
|
|
69
|
-
const key = parsed?.key ?? 'unknown';
|
|
70
|
-
const risk = parsed?.risk ?? 'danger';
|
|
71
|
-
const detail = describeDestructiveOperation(type);
|
|
72
|
-
return {
|
|
73
|
-
migration,
|
|
74
|
-
type,
|
|
75
|
-
key,
|
|
76
|
-
risk,
|
|
77
|
-
warningCode: detail.warningCode,
|
|
78
|
-
reason: detail.reason,
|
|
79
|
-
impact: detail.impact,
|
|
80
|
-
recommendation: detail.recommendation,
|
|
81
|
-
summary,
|
|
82
|
-
};
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
//# sourceMappingURL=safety-markers.js.map
|