@sqlanvil/cli 1.26.0 → 1.26.2

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.
Files changed (2) hide show
  1. package/bundle.js +46 -12
  2. 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.0";
50649
+ const version = "1.26.2";
50650
50650
  const dataformVersion = "3.0.61";
50651
50651
 
50652
50652
  async function build(compiledGraph, runConfig, dbadapter) {
@@ -51518,13 +51518,22 @@ function resolveConnection(projectDir, connectionName) {
51518
51518
  if (!definition) {
51519
51519
  throw new Error(`Unknown connection "${connectionName}". Define it under \`connections:\` in workflow_settings.yaml.`);
51520
51520
  }
51521
+ const bigqueryAdcFallback = (definition.platform || "").toLowerCase() === "bigquery"
51522
+ ? { name: connectionName, definition, credentials: {} }
51523
+ : undefined;
51521
51524
  const credsPath = path__namespace.join(path__namespace.resolve(projectDir), ".df-credentials.json");
51522
51525
  if (!fs__namespace.existsSync(credsPath)) {
51526
+ if (bigqueryAdcFallback) {
51527
+ return bigqueryAdcFallback;
51528
+ }
51523
51529
  throw new Error(`Missing .df-credentials.json in ${projectDir}.`);
51524
51530
  }
51525
51531
  const allCreds = JSON.parse(fs__namespace.readFileSync(credsPath, "utf8"));
51526
51532
  const credentials = allCreds.connections && allCreds.connections[connectionName];
51527
51533
  if (!credentials) {
51534
+ if (bigqueryAdcFallback) {
51535
+ return bigqueryAdcFallback;
51536
+ }
51528
51537
  throw new Error(`No credentials for connection "${connectionName}" in .df-credentials.json ` +
51529
51538
  `(expected a "connections.${connectionName}" entry).`);
51530
51539
  }
@@ -54722,7 +54731,7 @@ function readSourceConfig(srcDir) {
54722
54731
  };
54723
54732
  }
54724
54733
  async function migrateDataform(opts) {
54725
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
54734
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
54726
54735
  const srcDir = path__namespace.resolve(opts.srcDir);
54727
54736
  const outDir = path__namespace.resolve(opts.outDir);
54728
54737
  if (containsPath(srcDir, outDir)) {
@@ -54770,12 +54779,15 @@ async function migrateDataform(opts) {
54770
54779
  const declarationSchemas = new Set();
54771
54780
  const targetSchemas = new Set();
54772
54781
  const connectionMap = new Map();
54782
+ const introspectCommands = [];
54773
54783
  for (const f of isBigQueryTarget ? [] : sqlxFiles) {
54774
54784
  if (f.parsed.type === "declaration") {
54775
54785
  const dataset = (_d = f.parsed.schema) !== null && _d !== void 0 ? _d : sourceConfig.defaultDataset;
54776
54786
  const project = resolveDatabase(f.parsed.database);
54777
54787
  declarationSchemas.add(dataset);
54778
54788
  const name = connectionNameFor(project);
54789
+ const tableName = (_e = f.parsed.name) !== null && _e !== void 0 ? _e : path__namespace.basename(f.rel, ".sqlx");
54790
+ introspectCommands.push(`sqlanvil introspect ${name} ${JSON.stringify(`${dataset}.${tableName}`)} --output ${JSON.stringify(f.rel)}`);
54779
54791
  const existing = connectionMap.get(name);
54780
54792
  if (existing) {
54781
54793
  existing.declarationCount++;
@@ -54793,7 +54805,7 @@ async function migrateDataform(opts) {
54793
54805
  }
54794
54806
  }
54795
54807
  else if (f.parsed.type) {
54796
- targetSchemas.add((_e = f.parsed.schema) !== null && _e !== void 0 ? _e : sourceConfig.defaultDataset);
54808
+ targetSchemas.add((_f = f.parsed.schema) !== null && _f !== void 0 ? _f : sourceConfig.defaultDataset);
54797
54809
  }
54798
54810
  }
54799
54811
  report.connections = [...connectionMap.values()].sort((a, b) => a.name.localeCompare(b.name));
@@ -54811,14 +54823,14 @@ async function migrateDataform(opts) {
54811
54823
  report.files.push({
54812
54824
  file: rel,
54813
54825
  action: info.parsed.type === "declaration" ? "declaration" : "target",
54814
- type: (_f = info.parsed.type) !== null && _f !== void 0 ? _f : "(none)",
54826
+ type: (_g = info.parsed.type) !== null && _g !== void 0 ? _g : "(none)",
54815
54827
  status: findings.length === 0 ? "clean" : "rewritten",
54816
54828
  findings,
54817
54829
  });
54818
54830
  continue;
54819
54831
  }
54820
54832
  if (info.parsed.type === "declaration") {
54821
- const dataset = (_g = info.parsed.schema) !== null && _g !== void 0 ? _g : sourceConfig.defaultDataset;
54833
+ const dataset = (_h = info.parsed.schema) !== null && _h !== void 0 ? _h : sourceConfig.defaultDataset;
54822
54834
  const project = resolveDatabase(info.parsed.database);
54823
54835
  const connection = connectionNameFor(project);
54824
54836
  const { content, findings } = convertDeclaration(info.source, info.parsed, connection, dataset, rel);
@@ -54838,7 +54850,7 @@ async function migrateDataform(opts) {
54838
54850
  report.files.push({
54839
54851
  file: rel,
54840
54852
  action: "target",
54841
- type: (_h = info.parsed.type) !== null && _h !== void 0 ? _h : "(none)",
54853
+ type: (_j = info.parsed.type) !== null && _j !== void 0 ? _j : "(none)",
54842
54854
  status: findings.length === 0
54843
54855
  ? "clean"
54844
54856
  : findings.some(f => f.kind === "flag")
@@ -54875,11 +54887,11 @@ async function migrateDataform(opts) {
54875
54887
  report.files.push({ file: rel, action: "copied", status: "clean", findings: [] });
54876
54888
  }
54877
54889
  const settings = isBigQueryTarget
54878
- ? Object.assign(Object.assign(Object.assign({}, (sourceConfig.defaultProject ? { defaultProject: sourceConfig.defaultProject } : {})), (sourceConfig.defaultLocation ? { defaultLocation: sourceConfig.defaultLocation } : {})), { defaultDataset: sourceConfig.defaultDataset, defaultAssertionDataset: (_j = sourceConfig.defaultAssertionDataset) !== null && _j !== void 0 ? _j : "sqlanvil_assertions", sqlanvilCoreVersion: (_k = opts.coreVersion) !== null && _k !== void 0 ? _k : version }) : {
54890
+ ? 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
54891
  warehouse: targetWarehouse,
54880
54892
  defaultDataset: sourceConfig.defaultDataset.toLowerCase(),
54881
- defaultAssertionDataset: ((_l = sourceConfig.defaultAssertionDataset) !== null && _l !== void 0 ? _l : "sqlanvil_assertions").toLowerCase(),
54882
- sqlanvilCoreVersion: (_m = opts.coreVersion) !== null && _m !== void 0 ? _m : version,
54893
+ defaultAssertionDataset: ((_m = sourceConfig.defaultAssertionDataset) !== null && _m !== void 0 ? _m : "sqlanvil_assertions").toLowerCase(),
54894
+ sqlanvilCoreVersion: (_o = opts.coreVersion) !== null && _o !== void 0 ? _o : version,
54883
54895
  };
54884
54896
  if (sourceConfig.vars)
54885
54897
  settings.vars = sourceConfig.vars;
@@ -54901,6 +54913,21 @@ async function migrateDataform(opts) {
54901
54913
  }));
54902
54914
  }
54903
54915
  writer.write("workflow_settings.yaml", jsYaml.dump(settings));
54916
+ if (!isBigQueryTarget && introspectCommands.length > 0) {
54917
+ writer.write("scripts/introspect_all.sh", `#!/bin/sh\n` +
54918
+ `# Generated by sqlanvil migrate-dataform: scaffold columnTypes for every converted\n` +
54919
+ `# declaration (${introspectCommands.length} commands). Requires BigQuery read access\n` +
54920
+ `# (gcloud auth application-default login). Re-runnable; then commit the changes.\n` +
54921
+ `set -e\n` +
54922
+ introspectCommands.join("\n") +
54923
+ `\n`);
54924
+ report.files.push({
54925
+ file: "scripts/introspect_all.sh",
54926
+ action: "generated",
54927
+ status: "clean",
54928
+ findings: []
54929
+ });
54930
+ }
54904
54931
  if (isBigQueryTarget && sourceConfig.defaultProject) {
54905
54932
  const adcCredentials = { projectId: sourceConfig.defaultProject };
54906
54933
  if (sourceConfig.defaultLocation) {
@@ -54932,7 +54959,7 @@ async function migrateDataform(opts) {
54932
54959
  writer.write("AGENTS.md", agentsMdContents({
54933
54960
  warehouse: targetWarehouse,
54934
54961
  defaultDataset: settings.defaultDataset,
54935
- version: (_o = opts.coreVersion) !== null && _o !== void 0 ? _o : version,
54962
+ version: (_p = opts.coreVersion) !== null && _p !== void 0 ? _p : version,
54936
54963
  converted: true
54937
54964
  }));
54938
54965
  report.files.push({ file: "AGENTS.md", action: "generated", status: "clean", findings: [] });
@@ -54983,7 +55010,13 @@ function renderReportMd(r) {
54983
55010
  lines.push("");
54984
55011
  lines.push(`Declarations keep reading BigQuery through named \`connections:\` in workflow_settings.yaml ` +
54985
55012
  `(mode: runner-extract — no Vault, no wrappers). Each declaration needs \`columnTypes\` ` +
54986
- `before it can extract; scaffold them with \`sqlanvil introspect\`:`);
55013
+ `before it can extract. **Every concrete command is in the generated ` +
55014
+ `\`scripts/introspect_all.sh\`** — run it on a machine with BigQuery read access ` +
55015
+ `(\`gcloud auth application-default login\`), then commit what it writes:`);
55016
+ lines.push("");
55017
+ lines.push("```sh");
55018
+ lines.push("sh scripts/introspect_all.sh && git add -A && git commit -m 'columnTypes' && git push");
55019
+ lines.push("```");
54987
55020
  lines.push("");
54988
55021
  for (const c of r.connections) {
54989
55022
  lines.push(`- **${c.name}** — project \`${c.project}\`, ${c.declarationCount} declaration(s) across ` +
@@ -55053,7 +55086,8 @@ function renderReportMd(r) {
55053
55086
  }
55054
55087
  else {
55055
55088
  lines.push(`1. \`sqlanvil compile\` — should already succeed.`);
55056
- lines.push(`2. Scaffold \`columnTypes\` for the declarations you actually read (see connections above).`);
55089
+ lines.push(`2. Scaffold \`columnTypes\`: \`sh scripts/introspect_all.sh\` (every declaration's ` +
55090
+ `concrete command, generated), then commit what it writes.`);
55057
55091
  lines.push(`3. \`sqlanvil validate\` against your Postgres/Supabase warehouse — PASS/FAILURE/BLOCKED per ` +
55058
55092
  `model is the migration to-do list. Work the flagged files until validate is green.`);
55059
55093
  lines.push(`4. This report is machine-readable (migration-report.json) — pointing an AI agent at it plus ` +
package/package.json CHANGED
@@ -71,7 +71,7 @@
71
71
  "bin": {
72
72
  "sqlanvil": "bundle.js"
73
73
  },
74
- "version": "1.26.0",
74
+ "version": "1.26.2",
75
75
  "name": "@sqlanvil/cli",
76
76
  "description": "sqlanvil command line interface.",
77
77
  "main": "bundle.js"