@sqlanvil/cli 1.26.0 → 1.26.1
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/bundle.js +37 -12
- package/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -50646,7 +50646,7 @@ function collectEvaluationQueries(queryOrAction, concatenate, queryModifier = (q
|
|
|
50646
50646
|
.filter(validationQuery => !!validationQuery.query);
|
|
50647
50647
|
}
|
|
50648
50648
|
|
|
50649
|
-
const version = "1.26.
|
|
50649
|
+
const version = "1.26.1";
|
|
50650
50650
|
const dataformVersion = "3.0.61";
|
|
50651
50651
|
|
|
50652
50652
|
async function build(compiledGraph, runConfig, dbadapter) {
|
|
@@ -54722,7 +54722,7 @@ function readSourceConfig(srcDir) {
|
|
|
54722
54722
|
};
|
|
54723
54723
|
}
|
|
54724
54724
|
async function migrateDataform(opts) {
|
|
54725
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
54725
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
54726
54726
|
const srcDir = path__namespace.resolve(opts.srcDir);
|
|
54727
54727
|
const outDir = path__namespace.resolve(opts.outDir);
|
|
54728
54728
|
if (containsPath(srcDir, outDir)) {
|
|
@@ -54770,12 +54770,15 @@ async function migrateDataform(opts) {
|
|
|
54770
54770
|
const declarationSchemas = new Set();
|
|
54771
54771
|
const targetSchemas = new Set();
|
|
54772
54772
|
const connectionMap = new Map();
|
|
54773
|
+
const introspectCommands = [];
|
|
54773
54774
|
for (const f of isBigQueryTarget ? [] : sqlxFiles) {
|
|
54774
54775
|
if (f.parsed.type === "declaration") {
|
|
54775
54776
|
const dataset = (_d = f.parsed.schema) !== null && _d !== void 0 ? _d : sourceConfig.defaultDataset;
|
|
54776
54777
|
const project = resolveDatabase(f.parsed.database);
|
|
54777
54778
|
declarationSchemas.add(dataset);
|
|
54778
54779
|
const name = connectionNameFor(project);
|
|
54780
|
+
const tableName = (_e = f.parsed.name) !== null && _e !== void 0 ? _e : path__namespace.basename(f.rel, ".sqlx");
|
|
54781
|
+
introspectCommands.push(`sqlanvil introspect ${name} ${JSON.stringify(`${dataset}.${tableName}`)} --output ${JSON.stringify(f.rel)}`);
|
|
54779
54782
|
const existing = connectionMap.get(name);
|
|
54780
54783
|
if (existing) {
|
|
54781
54784
|
existing.declarationCount++;
|
|
@@ -54793,7 +54796,7 @@ async function migrateDataform(opts) {
|
|
|
54793
54796
|
}
|
|
54794
54797
|
}
|
|
54795
54798
|
else if (f.parsed.type) {
|
|
54796
|
-
targetSchemas.add((
|
|
54799
|
+
targetSchemas.add((_f = f.parsed.schema) !== null && _f !== void 0 ? _f : sourceConfig.defaultDataset);
|
|
54797
54800
|
}
|
|
54798
54801
|
}
|
|
54799
54802
|
report.connections = [...connectionMap.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -54811,14 +54814,14 @@ async function migrateDataform(opts) {
|
|
|
54811
54814
|
report.files.push({
|
|
54812
54815
|
file: rel,
|
|
54813
54816
|
action: info.parsed.type === "declaration" ? "declaration" : "target",
|
|
54814
|
-
type: (
|
|
54817
|
+
type: (_g = info.parsed.type) !== null && _g !== void 0 ? _g : "(none)",
|
|
54815
54818
|
status: findings.length === 0 ? "clean" : "rewritten",
|
|
54816
54819
|
findings,
|
|
54817
54820
|
});
|
|
54818
54821
|
continue;
|
|
54819
54822
|
}
|
|
54820
54823
|
if (info.parsed.type === "declaration") {
|
|
54821
|
-
const dataset = (
|
|
54824
|
+
const dataset = (_h = info.parsed.schema) !== null && _h !== void 0 ? _h : sourceConfig.defaultDataset;
|
|
54822
54825
|
const project = resolveDatabase(info.parsed.database);
|
|
54823
54826
|
const connection = connectionNameFor(project);
|
|
54824
54827
|
const { content, findings } = convertDeclaration(info.source, info.parsed, connection, dataset, rel);
|
|
@@ -54838,7 +54841,7 @@ async function migrateDataform(opts) {
|
|
|
54838
54841
|
report.files.push({
|
|
54839
54842
|
file: rel,
|
|
54840
54843
|
action: "target",
|
|
54841
|
-
type: (
|
|
54844
|
+
type: (_j = info.parsed.type) !== null && _j !== void 0 ? _j : "(none)",
|
|
54842
54845
|
status: findings.length === 0
|
|
54843
54846
|
? "clean"
|
|
54844
54847
|
: findings.some(f => f.kind === "flag")
|
|
@@ -54875,11 +54878,11 @@ async function migrateDataform(opts) {
|
|
|
54875
54878
|
report.files.push({ file: rel, action: "copied", status: "clean", findings: [] });
|
|
54876
54879
|
}
|
|
54877
54880
|
const settings = isBigQueryTarget
|
|
54878
|
-
? Object.assign(Object.assign(Object.assign({}, (sourceConfig.defaultProject ? { defaultProject: sourceConfig.defaultProject } : {})), (sourceConfig.defaultLocation ? { defaultLocation: sourceConfig.defaultLocation } : {})), { defaultDataset: sourceConfig.defaultDataset, defaultAssertionDataset: (
|
|
54881
|
+
? Object.assign(Object.assign(Object.assign({}, (sourceConfig.defaultProject ? { defaultProject: sourceConfig.defaultProject } : {})), (sourceConfig.defaultLocation ? { defaultLocation: sourceConfig.defaultLocation } : {})), { defaultDataset: sourceConfig.defaultDataset, defaultAssertionDataset: (_k = sourceConfig.defaultAssertionDataset) !== null && _k !== void 0 ? _k : "sqlanvil_assertions", sqlanvilCoreVersion: (_l = opts.coreVersion) !== null && _l !== void 0 ? _l : version }) : {
|
|
54879
54882
|
warehouse: targetWarehouse,
|
|
54880
54883
|
defaultDataset: sourceConfig.defaultDataset.toLowerCase(),
|
|
54881
|
-
defaultAssertionDataset: ((
|
|
54882
|
-
sqlanvilCoreVersion: (
|
|
54884
|
+
defaultAssertionDataset: ((_m = sourceConfig.defaultAssertionDataset) !== null && _m !== void 0 ? _m : "sqlanvil_assertions").toLowerCase(),
|
|
54885
|
+
sqlanvilCoreVersion: (_o = opts.coreVersion) !== null && _o !== void 0 ? _o : version,
|
|
54883
54886
|
};
|
|
54884
54887
|
if (sourceConfig.vars)
|
|
54885
54888
|
settings.vars = sourceConfig.vars;
|
|
@@ -54901,6 +54904,21 @@ async function migrateDataform(opts) {
|
|
|
54901
54904
|
}));
|
|
54902
54905
|
}
|
|
54903
54906
|
writer.write("workflow_settings.yaml", jsYaml.dump(settings));
|
|
54907
|
+
if (!isBigQueryTarget && introspectCommands.length > 0) {
|
|
54908
|
+
writer.write("scripts/introspect_all.sh", `#!/bin/sh\n` +
|
|
54909
|
+
`# Generated by sqlanvil migrate-dataform: scaffold columnTypes for every converted\n` +
|
|
54910
|
+
`# declaration (${introspectCommands.length} commands). Requires BigQuery read access\n` +
|
|
54911
|
+
`# (gcloud auth application-default login). Re-runnable; then commit the changes.\n` +
|
|
54912
|
+
`set -e\n` +
|
|
54913
|
+
introspectCommands.join("\n") +
|
|
54914
|
+
`\n`);
|
|
54915
|
+
report.files.push({
|
|
54916
|
+
file: "scripts/introspect_all.sh",
|
|
54917
|
+
action: "generated",
|
|
54918
|
+
status: "clean",
|
|
54919
|
+
findings: []
|
|
54920
|
+
});
|
|
54921
|
+
}
|
|
54904
54922
|
if (isBigQueryTarget && sourceConfig.defaultProject) {
|
|
54905
54923
|
const adcCredentials = { projectId: sourceConfig.defaultProject };
|
|
54906
54924
|
if (sourceConfig.defaultLocation) {
|
|
@@ -54932,7 +54950,7 @@ async function migrateDataform(opts) {
|
|
|
54932
54950
|
writer.write("AGENTS.md", agentsMdContents({
|
|
54933
54951
|
warehouse: targetWarehouse,
|
|
54934
54952
|
defaultDataset: settings.defaultDataset,
|
|
54935
|
-
version: (
|
|
54953
|
+
version: (_p = opts.coreVersion) !== null && _p !== void 0 ? _p : version,
|
|
54936
54954
|
converted: true
|
|
54937
54955
|
}));
|
|
54938
54956
|
report.files.push({ file: "AGENTS.md", action: "generated", status: "clean", findings: [] });
|
|
@@ -54983,7 +55001,13 @@ function renderReportMd(r) {
|
|
|
54983
55001
|
lines.push("");
|
|
54984
55002
|
lines.push(`Declarations keep reading BigQuery through named \`connections:\` in workflow_settings.yaml ` +
|
|
54985
55003
|
`(mode: runner-extract — no Vault, no wrappers). Each declaration needs \`columnTypes\` ` +
|
|
54986
|
-
`before it can extract
|
|
55004
|
+
`before it can extract. **Every concrete command is in the generated ` +
|
|
55005
|
+
`\`scripts/introspect_all.sh\`** — run it on a machine with BigQuery read access ` +
|
|
55006
|
+
`(\`gcloud auth application-default login\`), then commit what it writes:`);
|
|
55007
|
+
lines.push("");
|
|
55008
|
+
lines.push("```sh");
|
|
55009
|
+
lines.push("sh scripts/introspect_all.sh && git add -A && git commit -m 'columnTypes' && git push");
|
|
55010
|
+
lines.push("```");
|
|
54987
55011
|
lines.push("");
|
|
54988
55012
|
for (const c of r.connections) {
|
|
54989
55013
|
lines.push(`- **${c.name}** — project \`${c.project}\`, ${c.declarationCount} declaration(s) across ` +
|
|
@@ -55053,7 +55077,8 @@ function renderReportMd(r) {
|
|
|
55053
55077
|
}
|
|
55054
55078
|
else {
|
|
55055
55079
|
lines.push(`1. \`sqlanvil compile\` — should already succeed.`);
|
|
55056
|
-
lines.push(`2. Scaffold \`columnTypes\`
|
|
55080
|
+
lines.push(`2. Scaffold \`columnTypes\`: \`sh scripts/introspect_all.sh\` (every declaration's ` +
|
|
55081
|
+
`concrete command, generated), then commit what it writes.`);
|
|
55057
55082
|
lines.push(`3. \`sqlanvil validate\` against your Postgres/Supabase warehouse — PASS/FAILURE/BLOCKED per ` +
|
|
55058
55083
|
`model is the migration to-do list. Work the flagged files until validate is green.`);
|
|
55059
55084
|
lines.push(`4. This report is machine-readable (migration-report.json) — pointing an AI agent at it plus ` +
|