@sqlanvil/cli 1.3.0 → 1.4.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 +265 -348
- package/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -38424,9 +38424,16 @@ class PostgresExecutionSql {
|
|
|
38424
38424
|
? ` include (${index.include.map(c => `"${c}"`).join(", ")})`
|
|
38425
38425
|
: "";
|
|
38426
38426
|
const where = index.where ? ` where (${index.where})` : "";
|
|
38427
|
-
|
|
38427
|
+
const indexName = index.name || this.defaultIndexName(table.target.name, index.columns, !!index.unique);
|
|
38428
|
+
return `create ${unique}index "${indexName}" on ${target} using ${method} (${columns})${include}${where}`;
|
|
38428
38429
|
});
|
|
38429
38430
|
}
|
|
38431
|
+
defaultIndexName(tableName, columns, unique) {
|
|
38432
|
+
const parts = [tableName, ...(columns || [])].filter(Boolean);
|
|
38433
|
+
const base = parts.join("_");
|
|
38434
|
+
const suffix = unique ? "_key" : "_idx";
|
|
38435
|
+
return `${base}${suffix}`.slice(0, 63);
|
|
38436
|
+
}
|
|
38430
38437
|
indexMethodAsSql(method) {
|
|
38431
38438
|
switch (method) {
|
|
38432
38439
|
case sqlanvil.PostgresOptions.Index.Method.HASH:
|
|
@@ -38653,7 +38660,7 @@ function collectEvaluationQueries(queryOrAction, concatenate, queryModifier = (q
|
|
|
38653
38660
|
.filter(validationQuery => !!validationQuery.query);
|
|
38654
38661
|
}
|
|
38655
38662
|
|
|
38656
|
-
const version = "1.
|
|
38663
|
+
const version = "1.4.1";
|
|
38657
38664
|
const dataformVersion = "3.0.59";
|
|
38658
38665
|
|
|
38659
38666
|
async function build(compiledGraph, runConfig, dbadapter) {
|
|
@@ -40347,15 +40354,23 @@ class PgPoolExecutor {
|
|
|
40347
40354
|
}
|
|
40348
40355
|
async withClientLock(callback) {
|
|
40349
40356
|
const client = await this.pool.connect();
|
|
40357
|
+
let released = false;
|
|
40358
|
+
const releaseOnce = (err) => {
|
|
40359
|
+
if (released) {
|
|
40360
|
+
return;
|
|
40361
|
+
}
|
|
40362
|
+
released = true;
|
|
40363
|
+
try {
|
|
40364
|
+
client.release(err);
|
|
40365
|
+
}
|
|
40366
|
+
catch (e) {
|
|
40367
|
+
console.error("Error thrown when releasing pg.Client", e.message, e.stack);
|
|
40368
|
+
}
|
|
40369
|
+
};
|
|
40350
40370
|
try {
|
|
40351
40371
|
client.on("error", err => {
|
|
40352
40372
|
console.error("pg.Client client error", err.message, err.stack);
|
|
40353
|
-
|
|
40354
|
-
client.release(err);
|
|
40355
|
-
}
|
|
40356
|
-
catch (e) {
|
|
40357
|
-
console.error("Error thrown when releasing errored pg.Client", e.message, e.stack);
|
|
40358
|
-
}
|
|
40373
|
+
releaseOnce(err);
|
|
40359
40374
|
});
|
|
40360
40375
|
return await callback({
|
|
40361
40376
|
execute: async (statement, options = { rowLimit: 1000, byteLimit: 1024 * 1024 }) => {
|
|
@@ -40380,12 +40395,7 @@ class PgPoolExecutor {
|
|
|
40380
40395
|
}
|
|
40381
40396
|
});
|
|
40382
40397
|
query.on("error", err => {
|
|
40383
|
-
|
|
40384
|
-
client.release(err);
|
|
40385
|
-
}
|
|
40386
|
-
catch (e) {
|
|
40387
|
-
console.error("Error thrown when releasing errored pg.Query", e.message, e.stack);
|
|
40388
|
-
}
|
|
40398
|
+
releaseOnce(err);
|
|
40389
40399
|
reject(err);
|
|
40390
40400
|
});
|
|
40391
40401
|
query.on("end", () => {
|
|
@@ -40396,12 +40406,7 @@ class PgPoolExecutor {
|
|
|
40396
40406
|
});
|
|
40397
40407
|
}
|
|
40398
40408
|
finally {
|
|
40399
|
-
|
|
40400
|
-
client.release();
|
|
40401
|
-
}
|
|
40402
|
-
catch (e) {
|
|
40403
|
-
console.error("Error thrown when releasing ended pg.Client", e.message, e.stack);
|
|
40404
|
-
}
|
|
40409
|
+
releaseOnce();
|
|
40405
40410
|
}
|
|
40406
40411
|
}
|
|
40407
40412
|
async close() {
|
|
@@ -41279,6 +41284,12 @@ function getBigQueryCredentials() {
|
|
|
41279
41284
|
};
|
|
41280
41285
|
}
|
|
41281
41286
|
|
|
41287
|
+
function option(name, opt, check) {
|
|
41288
|
+
return { name, option: opt, check };
|
|
41289
|
+
}
|
|
41290
|
+
function positionalOption(name, opt, check) {
|
|
41291
|
+
return { name, option: opt, check };
|
|
41292
|
+
}
|
|
41282
41293
|
function createYargsCli(cli) {
|
|
41283
41294
|
let yargsChain = yargs__default["default"](fixArgvForHelp());
|
|
41284
41295
|
for (const command of cli.commands) {
|
|
@@ -41984,16 +41995,14 @@ function postProcessFormattedSqlx(formattedSql) {
|
|
|
41984
41995
|
|
|
41985
41996
|
const RECOMPILE_DELAY = 500;
|
|
41986
41997
|
process.on("unhandledRejection", async (reason) => {
|
|
41987
|
-
|
|
41998
|
+
var _a;
|
|
41999
|
+
printError(`Unhandled promise rejection: ${((_a = reason) === null || _a === void 0 ? void 0 : _a.stack) || reason}`);
|
|
42000
|
+
});
|
|
42001
|
+
const projectDirOption = positionalOption("project-dir", {
|
|
42002
|
+
describe: "The sqlanvil project directory.",
|
|
42003
|
+
default: ".",
|
|
42004
|
+
coerce: actuallyResolve
|
|
41988
42005
|
});
|
|
41989
|
-
const projectDirOption = {
|
|
41990
|
-
name: "project-dir",
|
|
41991
|
-
option: {
|
|
41992
|
-
describe: "The sqlanvil project directory.",
|
|
41993
|
-
default: ".",
|
|
41994
|
-
coerce: actuallyResolve
|
|
41995
|
-
}
|
|
41996
|
-
};
|
|
41997
42006
|
const projectDirMustExistOption = Object.assign(Object.assign({}, projectDirOption), { check: (argv) => {
|
|
41998
42007
|
assertPathExists(argv[projectDirOption.name]);
|
|
41999
42008
|
const workflowSettingsYamlPath = path__namespace.resolve(argv[projectDirOption.name], "workflow_settings.yaml");
|
|
@@ -42001,144 +42010,104 @@ const projectDirMustExistOption = Object.assign(Object.assign({}, projectDirOpti
|
|
|
42001
42010
|
throw new Error(`${argv[projectDirOption.name]} does not appear to be a sqlanvil directory (missing workflow_settings.yaml file).`);
|
|
42002
42011
|
}
|
|
42003
42012
|
} });
|
|
42004
|
-
const fullRefreshOption = {
|
|
42005
|
-
|
|
42006
|
-
|
|
42007
|
-
|
|
42008
|
-
|
|
42009
|
-
|
|
42010
|
-
|
|
42011
|
-
|
|
42012
|
-
|
|
42013
|
-
|
|
42014
|
-
|
|
42015
|
-
|
|
42016
|
-
|
|
42017
|
-
|
|
42018
|
-
|
|
42019
|
-
|
|
42020
|
-
|
|
42021
|
-
|
|
42022
|
-
|
|
42023
|
-
|
|
42024
|
-
|
|
42025
|
-
coerce: (rawTags) => rawTags.map(tags => tags.split(",")).flat()
|
|
42026
|
-
}
|
|
42027
|
-
};
|
|
42028
|
-
const includeDepsOption = {
|
|
42029
|
-
name: "include-deps",
|
|
42030
|
-
option: {
|
|
42031
|
-
describe: "If set, dependencies for selected actions will also be run.",
|
|
42032
|
-
type: "boolean"
|
|
42033
|
-
},
|
|
42034
|
-
check: (argv) => {
|
|
42035
|
-
if (argv[includeDepsOption.name] && !(argv[actionsOption.name] || argv[tagsOption.name])) {
|
|
42036
|
-
throw new Error(`The --${includeDepsOption.name} flag should only be supplied along with --${actionsOption.name} or --${tagsOption.name}.`);
|
|
42037
|
-
}
|
|
42038
|
-
}
|
|
42039
|
-
};
|
|
42040
|
-
const includeDependentsOption = {
|
|
42041
|
-
name: "include-dependents",
|
|
42042
|
-
option: {
|
|
42043
|
-
describe: "If set, dependents (downstream) for selected actions will also be run.",
|
|
42044
|
-
type: "boolean"
|
|
42045
|
-
},
|
|
42046
|
-
check: (argv) => {
|
|
42047
|
-
if (argv[includeDependentsOption.name] &&
|
|
42048
|
-
!(argv[actionsOption.name] || argv[tagsOption.name])) {
|
|
42049
|
-
throw new Error(`The --${includeDependentsOption.name} flag should only be supplied along with --${actionsOption.name} or --${tagsOption.name}.`);
|
|
42050
|
-
}
|
|
42051
|
-
}
|
|
42052
|
-
};
|
|
42053
|
-
const credentialsOption = {
|
|
42054
|
-
name: "credentials",
|
|
42055
|
-
option: {
|
|
42056
|
-
describe: "The location of the credentials JSON file to use.",
|
|
42057
|
-
default: CREDENTIALS_FILENAME
|
|
42058
|
-
},
|
|
42059
|
-
check: (argv) => getCredentialsPath(argv[projectDirOption.name], argv[credentialsOption.name])
|
|
42060
|
-
};
|
|
42061
|
-
const jsonOutputOption = {
|
|
42062
|
-
name: "json",
|
|
42063
|
-
option: {
|
|
42064
|
-
describe: "Outputs a JSON representation of the compiled project or test results.",
|
|
42065
|
-
type: "boolean",
|
|
42066
|
-
default: false
|
|
42067
|
-
}
|
|
42068
|
-
};
|
|
42069
|
-
const dotOutputOption = {
|
|
42070
|
-
name: "dot",
|
|
42071
|
-
option: {
|
|
42072
|
-
describe: "Outputs a dot representation of the compiled project.",
|
|
42073
|
-
type: "boolean",
|
|
42074
|
-
default: false,
|
|
42075
|
-
},
|
|
42076
|
-
check: (argv) => {
|
|
42077
|
-
if (argv.json && argv.dot) {
|
|
42078
|
-
throw new Error("Arguments --json and --dot are mutually exclusive.");
|
|
42079
|
-
}
|
|
42080
|
-
}
|
|
42081
|
-
};
|
|
42082
|
-
const timeoutOption = {
|
|
42083
|
-
name: "timeout",
|
|
42084
|
-
option: {
|
|
42085
|
-
describe: "Duration to allow project compilation to complete. Examples: '1s', '10m', etc.",
|
|
42086
|
-
type: "string",
|
|
42087
|
-
default: null,
|
|
42088
|
-
coerce: (rawTimeoutString) => rawTimeoutString ? parseDuration__default["default"](rawTimeoutString) : null
|
|
42089
|
-
}
|
|
42090
|
-
};
|
|
42091
|
-
const jobPrefixOption = {
|
|
42092
|
-
name: "job-prefix",
|
|
42093
|
-
option: {
|
|
42094
|
-
describe: "Adds an additional prefix in the form of `sqlanvil-${jobPrefix}-`.",
|
|
42095
|
-
type: "string",
|
|
42096
|
-
default: null
|
|
42013
|
+
const fullRefreshOption = option("full-refresh", {
|
|
42014
|
+
describe: "Forces incremental tables to be rebuilt from scratch.",
|
|
42015
|
+
type: "boolean",
|
|
42016
|
+
default: false
|
|
42017
|
+
});
|
|
42018
|
+
const actionsOption = option("actions", {
|
|
42019
|
+
describe: "A list of action names or patterns to run. Can include '*' wildcards.",
|
|
42020
|
+
type: "array",
|
|
42021
|
+
coerce: (rawActions) => rawActions.map(actions => actions.split(",")).flat()
|
|
42022
|
+
});
|
|
42023
|
+
const tagsOption = option("tags", {
|
|
42024
|
+
describe: "A list of tags to filter the actions to run.",
|
|
42025
|
+
type: "array",
|
|
42026
|
+
coerce: (rawTags) => rawTags.map(tags => tags.split(",")).flat()
|
|
42027
|
+
});
|
|
42028
|
+
const includeDepsOption = option("include-deps", {
|
|
42029
|
+
describe: "If set, dependencies for selected actions will also be run.",
|
|
42030
|
+
type: "boolean"
|
|
42031
|
+
}, (argv) => {
|
|
42032
|
+
if (argv[includeDepsOption.name] && !(argv[actionsOption.name] || argv[tagsOption.name])) {
|
|
42033
|
+
throw new Error(`The --${includeDepsOption.name} flag should only be supplied along with --${actionsOption.name} or --${tagsOption.name}.`);
|
|
42097
42034
|
}
|
|
42098
|
-
};
|
|
42099
|
-
const
|
|
42100
|
-
|
|
42101
|
-
|
|
42102
|
-
|
|
42103
|
-
|
|
42104
|
-
|
|
42105
|
-
|
|
42106
|
-
raw === null || raw === void 0 ? void 0 : raw.split(",").forEach(kv => {
|
|
42107
|
-
if (!kv) {
|
|
42108
|
-
return;
|
|
42109
|
-
}
|
|
42110
|
-
const [key, ...rest] = kv.split("=");
|
|
42111
|
-
labels[key] = rest.join("=") || "";
|
|
42112
|
-
});
|
|
42113
|
-
return labels;
|
|
42114
|
-
}
|
|
42035
|
+
});
|
|
42036
|
+
const includeDependentsOption = option("include-dependents", {
|
|
42037
|
+
describe: "If set, dependents (downstream) for selected actions will also be run.",
|
|
42038
|
+
type: "boolean"
|
|
42039
|
+
}, (argv) => {
|
|
42040
|
+
if (argv[includeDependentsOption.name] &&
|
|
42041
|
+
!(argv[actionsOption.name] || argv[tagsOption.name])) {
|
|
42042
|
+
throw new Error(`The --${includeDependentsOption.name} flag should only be supplied along with --${actionsOption.name} or --${tagsOption.name}.`);
|
|
42115
42043
|
}
|
|
42116
|
-
};
|
|
42117
|
-
const
|
|
42118
|
-
|
|
42119
|
-
|
|
42120
|
-
|
|
42121
|
-
|
|
42122
|
-
|
|
42044
|
+
});
|
|
42045
|
+
const compileActionsOption = Object.assign(Object.assign({}, actionsOption), { option: Object.assign(Object.assign({}, actionsOption.option), { describe: "A list of action names or patterns to include in the output. Can include '*' wildcards." }) });
|
|
42046
|
+
const compileTagsOption = Object.assign(Object.assign({}, tagsOption), { option: Object.assign(Object.assign({}, tagsOption.option), { describe: "A list of tags to filter the output to." }) });
|
|
42047
|
+
const compileIncludeDepsOption = Object.assign(Object.assign({}, includeDepsOption), { option: Object.assign(Object.assign({}, includeDepsOption.option), { describe: "If set, dependencies of selected actions are also included in the output." }) });
|
|
42048
|
+
const compileIncludeDependentsOption = Object.assign(Object.assign({}, includeDependentsOption), { option: Object.assign(Object.assign({}, includeDependentsOption.option), { describe: "If set, dependents (downstream) of selected actions are also included in the output." }) });
|
|
42049
|
+
const credentialsOption = option("credentials", {
|
|
42050
|
+
describe: "The location of the credentials JSON file to use.",
|
|
42051
|
+
default: CREDENTIALS_FILENAME
|
|
42052
|
+
}, (argv) => {
|
|
42053
|
+
getCredentialsPath(argv[projectDirOption.name], argv.credentials);
|
|
42054
|
+
});
|
|
42055
|
+
const jsonOutputOption = option("json", {
|
|
42056
|
+
describe: "Outputs a JSON representation of the compiled project or test results.",
|
|
42057
|
+
type: "boolean",
|
|
42058
|
+
default: false
|
|
42059
|
+
});
|
|
42060
|
+
const dotOutputOption = option("dot", {
|
|
42061
|
+
describe: "Outputs a dot representation of the compiled project.",
|
|
42062
|
+
type: "boolean",
|
|
42063
|
+
default: false
|
|
42064
|
+
}, (argv) => {
|
|
42065
|
+
if (argv.json && argv.dot) {
|
|
42066
|
+
throw new Error("Arguments --json and --dot are mutually exclusive.");
|
|
42123
42067
|
}
|
|
42124
|
-
};
|
|
42125
|
-
const
|
|
42126
|
-
|
|
42127
|
-
|
|
42128
|
-
|
|
42129
|
-
|
|
42130
|
-
|
|
42131
|
-
|
|
42132
|
-
}
|
|
42133
|
-
|
|
42134
|
-
|
|
42135
|
-
|
|
42136
|
-
|
|
42137
|
-
|
|
42138
|
-
|
|
42139
|
-
|
|
42068
|
+
});
|
|
42069
|
+
const timeoutOption = option("timeout", {
|
|
42070
|
+
describe: "Duration to allow project compilation to complete. Examples: '1s', '10m', etc.",
|
|
42071
|
+
type: "string",
|
|
42072
|
+
default: null,
|
|
42073
|
+
coerce: (rawTimeoutString) => rawTimeoutString ? parseDuration__default["default"](rawTimeoutString) : null
|
|
42074
|
+
});
|
|
42075
|
+
const jobPrefixOption = option("job-prefix", {
|
|
42076
|
+
describe: "Adds an additional prefix in the form of `sqlanvil-${jobPrefix}-`.",
|
|
42077
|
+
type: "string",
|
|
42078
|
+
default: null
|
|
42079
|
+
});
|
|
42080
|
+
const bigqueryJobLabelsOption = option("job-labels", {
|
|
42081
|
+
describe: "Comma-separated list of labels to add to BigQuery jobs, e.g. 'key1=val1,key2=val2'.",
|
|
42082
|
+
type: "string",
|
|
42083
|
+
coerce: (raw) => {
|
|
42084
|
+
const labels = {};
|
|
42085
|
+
raw === null || raw === void 0 ? void 0 : raw.split(",").forEach(kv => {
|
|
42086
|
+
if (!kv) {
|
|
42087
|
+
return;
|
|
42088
|
+
}
|
|
42089
|
+
const [key, ...rest] = kv.split("=");
|
|
42090
|
+
labels[key] = rest.join("=") || "";
|
|
42091
|
+
});
|
|
42092
|
+
return labels;
|
|
42140
42093
|
}
|
|
42141
|
-
};
|
|
42094
|
+
});
|
|
42095
|
+
const quietCompileOption = option("quiet", {
|
|
42096
|
+
describe: "Less verbose compilation output. Example usage: 'sqlanvil compile --quiet'",
|
|
42097
|
+
type: "boolean",
|
|
42098
|
+
default: false
|
|
42099
|
+
});
|
|
42100
|
+
const icebergOption = option("iceberg", {
|
|
42101
|
+
describe: "Initialize the project with workflow-level Iceberg tables configuration.",
|
|
42102
|
+
type: "boolean",
|
|
42103
|
+
default: false
|
|
42104
|
+
});
|
|
42105
|
+
const warehouseOption = option("warehouse", {
|
|
42106
|
+
describe: "Target warehouse for the new project.",
|
|
42107
|
+
type: "string",
|
|
42108
|
+
choices: ["bigquery", "postgres", "supabase"],
|
|
42109
|
+
default: "supabase"
|
|
42110
|
+
});
|
|
42142
42111
|
const testConnectionOptionName = "test-connection";
|
|
42143
42112
|
const watchOptionName = "watch";
|
|
42144
42113
|
const verboseOptionName = "verbose";
|
|
@@ -42157,7 +42126,7 @@ function runCli() {
|
|
|
42157
42126
|
description: "Show help. If [command] is specified, the help is for the given command.",
|
|
42158
42127
|
positionalOptions: [],
|
|
42159
42128
|
options: [],
|
|
42160
|
-
processFn: async (
|
|
42129
|
+
processFn: async () => {
|
|
42161
42130
|
return 0;
|
|
42162
42131
|
}
|
|
42163
42132
|
},
|
|
@@ -42167,33 +42136,25 @@ function runCli() {
|
|
|
42167
42136
|
description: "Create a new sqlanvil project (BigQuery, Postgres, or Supabase).",
|
|
42168
42137
|
positionalOptions: [
|
|
42169
42138
|
projectDirOption,
|
|
42170
|
-
{
|
|
42171
|
-
|
|
42172
|
-
|
|
42173
|
-
|
|
42174
|
-
|
|
42175
|
-
|
|
42176
|
-
|
|
42177
|
-
if (warehouse === "bigquery" && !argv[ProjectConfigOptions.defaultDatabase.name]) {
|
|
42178
|
-
throw new Error(`The ${ProjectConfigOptions.defaultDatabase.name} positional argument is ` +
|
|
42179
|
-
`required for BigQuery projects. Use "sqlanvil help init" for more info.`);
|
|
42180
|
-
}
|
|
42139
|
+
positionalOption(ProjectConfigOptions.defaultDatabase.name, {
|
|
42140
|
+
describe: "The default database to use, equivalent to Google Cloud Project ID."
|
|
42141
|
+
}, (argv) => {
|
|
42142
|
+
const warehouse = argv[warehouseOption.name] || "bigquery";
|
|
42143
|
+
if (warehouse === "bigquery" && !argv[ProjectConfigOptions.defaultDatabase.name]) {
|
|
42144
|
+
throw new Error(`The ${ProjectConfigOptions.defaultDatabase.name} positional argument is ` +
|
|
42145
|
+
`required for BigQuery projects. Use "sqlanvil help init" for more info.`);
|
|
42181
42146
|
}
|
|
42182
|
-
},
|
|
42183
|
-
{
|
|
42184
|
-
|
|
42185
|
-
|
|
42186
|
-
|
|
42187
|
-
|
|
42188
|
-
|
|
42189
|
-
|
|
42190
|
-
|
|
42191
|
-
if (warehouse === "bigquery" && !argv[ProjectConfigOptions.defaultLocation.name]) {
|
|
42192
|
-
throw new Error(`The ${ProjectConfigOptions.defaultLocation.name} positional argument is ` +
|
|
42193
|
-
`required for BigQuery projects. Use "sqlanvil help init" for more info.`);
|
|
42194
|
-
}
|
|
42147
|
+
}),
|
|
42148
|
+
positionalOption(ProjectConfigOptions.defaultLocation.name, {
|
|
42149
|
+
describe: "The default location to use. See " +
|
|
42150
|
+
"https://cloud.google.com/bigquery/docs/locations for supported values."
|
|
42151
|
+
}, (argv) => {
|
|
42152
|
+
const warehouse = argv[warehouseOption.name] || "bigquery";
|
|
42153
|
+
if (warehouse === "bigquery" && !argv[ProjectConfigOptions.defaultLocation.name]) {
|
|
42154
|
+
throw new Error(`The ${ProjectConfigOptions.defaultLocation.name} positional argument is ` +
|
|
42155
|
+
`required for BigQuery projects. Use "sqlanvil help init" for more info.`);
|
|
42195
42156
|
}
|
|
42196
|
-
}
|
|
42157
|
+
})
|
|
42197
42158
|
],
|
|
42198
42159
|
options: [warehouseOption, icebergOption],
|
|
42199
42160
|
processFn: async (argv) => {
|
|
@@ -42234,14 +42195,11 @@ function runCli() {
|
|
|
42234
42195
|
`accessing BigQuery.`,
|
|
42235
42196
|
positionalOptions: [projectDirMustExistOption],
|
|
42236
42197
|
options: [
|
|
42237
|
-
{
|
|
42238
|
-
|
|
42239
|
-
|
|
42240
|
-
|
|
42241
|
-
|
|
42242
|
-
default: true
|
|
42243
|
-
}
|
|
42244
|
-
}
|
|
42198
|
+
option(testConnectionOptionName, {
|
|
42199
|
+
describe: "If true, a test query will be run using your final credentials.",
|
|
42200
|
+
type: "boolean",
|
|
42201
|
+
default: true
|
|
42202
|
+
})
|
|
42245
42203
|
],
|
|
42246
42204
|
processFn: async (argv) => {
|
|
42247
42205
|
const finalCredentials = getBigQueryCredentials();
|
|
@@ -42277,36 +42235,34 @@ function runCli() {
|
|
|
42277
42235
|
description: "Compile the sqlanvil project. Produces JSON output describing the non-executable graph.",
|
|
42278
42236
|
positionalOptions: [projectDirMustExistOption],
|
|
42279
42237
|
options: [
|
|
42280
|
-
{
|
|
42281
|
-
|
|
42282
|
-
|
|
42283
|
-
|
|
42284
|
-
|
|
42285
|
-
default: false
|
|
42286
|
-
}
|
|
42287
|
-
},
|
|
42238
|
+
option(watchOptionName, {
|
|
42239
|
+
describe: "Whether to watch the changes in the project directory.",
|
|
42240
|
+
type: "boolean",
|
|
42241
|
+
default: false
|
|
42242
|
+
}),
|
|
42288
42243
|
jsonOutputOption,
|
|
42289
42244
|
dotOutputOption,
|
|
42290
42245
|
timeoutOption,
|
|
42291
42246
|
quietCompileOption,
|
|
42292
|
-
|
|
42293
|
-
|
|
42294
|
-
|
|
42295
|
-
|
|
42296
|
-
|
|
42297
|
-
|
|
42298
|
-
|
|
42299
|
-
|
|
42300
|
-
|
|
42301
|
-
|
|
42302
|
-
|
|
42247
|
+
compileActionsOption,
|
|
42248
|
+
compileTagsOption,
|
|
42249
|
+
compileIncludeDepsOption,
|
|
42250
|
+
compileIncludeDependentsOption,
|
|
42251
|
+
option(verboseOptionName, {
|
|
42252
|
+
describe: "Enable verbose compilation output. Example usage: 'sqlanvil compile --verbose'",
|
|
42253
|
+
type: "boolean",
|
|
42254
|
+
default: false
|
|
42255
|
+
}, (argv) => {
|
|
42256
|
+
if (argv.quiet && argv.verbose) {
|
|
42257
|
+
throw new Error("Arguments --verbose and --quiet are mutually exclusive.");
|
|
42303
42258
|
}
|
|
42304
|
-
},
|
|
42259
|
+
}),
|
|
42305
42260
|
...ProjectConfigOptions.allYargsOptions
|
|
42306
42261
|
],
|
|
42307
42262
|
processFn: async (argv) => {
|
|
42308
42263
|
const projectDir = argv[projectDirMustExistOption.name];
|
|
42309
42264
|
async function compileAndPrint() {
|
|
42265
|
+
var _a, _b;
|
|
42310
42266
|
let outputType = compiledGraphOutputType.Summary;
|
|
42311
42267
|
if (argv[jsonOutputOption.name]) {
|
|
42312
42268
|
outputType = compiledGraphOutputType.Json;
|
|
@@ -42323,7 +42279,16 @@ function runCli() {
|
|
|
42323
42279
|
timeoutMillis: argv[timeoutOption.name] || undefined,
|
|
42324
42280
|
verbose: argv[verboseOptionName] || false
|
|
42325
42281
|
});
|
|
42326
|
-
|
|
42282
|
+
const hasSelector = ((_a = argv[actionsOption.name]) === null || _a === void 0 ? void 0 : _a.length) > 0 || ((_b = argv[tagsOption.name]) === null || _b === void 0 ? void 0 : _b.length) > 0;
|
|
42283
|
+
const outputGraph = hasSelector && !compiledGraphHasErrors(compiledGraph)
|
|
42284
|
+
? prune(compiledGraph, {
|
|
42285
|
+
actions: argv[actionsOption.name],
|
|
42286
|
+
tags: argv[tagsOption.name],
|
|
42287
|
+
includeDependencies: argv[includeDepsOption.name],
|
|
42288
|
+
includeDependents: argv[includeDependentsOption.name]
|
|
42289
|
+
})
|
|
42290
|
+
: compiledGraph;
|
|
42291
|
+
printCompiledGraph(outputGraph, outputType, argv[quietCompileOption.name]);
|
|
42327
42292
|
if (compiledGraphHasErrors(compiledGraph)) {
|
|
42328
42293
|
print("");
|
|
42329
42294
|
printCompiledGraphErrors(compiledGraph.graphErrors, argv[quietCompileOption.name]);
|
|
@@ -42435,28 +42400,19 @@ function runCli() {
|
|
|
42435
42400
|
description: "Run the sqlanvil project.",
|
|
42436
42401
|
positionalOptions: [projectDirMustExistOption],
|
|
42437
42402
|
options: [
|
|
42438
|
-
{
|
|
42439
|
-
|
|
42440
|
-
|
|
42441
|
-
|
|
42442
|
-
|
|
42443
|
-
|
|
42444
|
-
|
|
42445
|
-
|
|
42446
|
-
|
|
42447
|
-
|
|
42448
|
-
|
|
42449
|
-
|
|
42450
|
-
|
|
42451
|
-
},
|
|
42452
|
-
{
|
|
42453
|
-
name: actionRetryLimitName,
|
|
42454
|
-
option: {
|
|
42455
|
-
describe: "If set, idempotent actions will be retried up to the limit.",
|
|
42456
|
-
type: "number",
|
|
42457
|
-
default: 0
|
|
42458
|
-
}
|
|
42459
|
-
},
|
|
42403
|
+
option(dryRunOptionName, {
|
|
42404
|
+
describe: "If set, BigQuery will validate the run SQL without applying changes to the warehouse.",
|
|
42405
|
+
type: "boolean"
|
|
42406
|
+
}),
|
|
42407
|
+
option(runTestsOptionName, {
|
|
42408
|
+
describe: "If set, the project's unit tests are required to pass before running the project.",
|
|
42409
|
+
type: "boolean"
|
|
42410
|
+
}),
|
|
42411
|
+
option(actionRetryLimitName, {
|
|
42412
|
+
describe: "If set, idempotent actions will be retried up to the limit.",
|
|
42413
|
+
type: "number",
|
|
42414
|
+
default: 0
|
|
42415
|
+
}),
|
|
42460
42416
|
actionsOption,
|
|
42461
42417
|
credentialsOption,
|
|
42462
42418
|
fullRefreshOption,
|
|
@@ -42580,14 +42536,11 @@ function runCli() {
|
|
|
42580
42536
|
positionalOptions: [projectDirMustExistOption],
|
|
42581
42537
|
options: [
|
|
42582
42538
|
actionsOption,
|
|
42583
|
-
{
|
|
42584
|
-
|
|
42585
|
-
|
|
42586
|
-
|
|
42587
|
-
|
|
42588
|
-
default: false
|
|
42589
|
-
}
|
|
42590
|
-
}
|
|
42539
|
+
option(checkOptionName, {
|
|
42540
|
+
describe: "Check if files are formatted correctly without modifying them.",
|
|
42541
|
+
type: "boolean",
|
|
42542
|
+
default: false
|
|
42543
|
+
})
|
|
42591
42544
|
],
|
|
42592
42545
|
processFn: async (argv) => {
|
|
42593
42546
|
let actions = ["{definitions,includes}/**/*.{js,sqlx}"];
|
|
@@ -42648,24 +42601,19 @@ function runCli() {
|
|
|
42648
42601
|
format: `introspect <connection> <tableRef> [${projectDirOption.name}]`,
|
|
42649
42602
|
description: "Read a source table's schema from a connection and write a declaration .sqlx with columnTypes.",
|
|
42650
42603
|
positionalOptions: [
|
|
42651
|
-
{
|
|
42652
|
-
|
|
42653
|
-
|
|
42654
|
-
|
|
42655
|
-
|
|
42656
|
-
|
|
42657
|
-
option: { describe: "Source table as schema.table (or just table)." }
|
|
42658
|
-
},
|
|
42604
|
+
positionalOption("connection", {
|
|
42605
|
+
describe: "Connection name (from workflow_settings.yaml connections)."
|
|
42606
|
+
}),
|
|
42607
|
+
positionalOption("tableRef", {
|
|
42608
|
+
describe: "Source table as schema.table (or just table)."
|
|
42609
|
+
}),
|
|
42659
42610
|
projectDirOption
|
|
42660
42611
|
],
|
|
42661
42612
|
options: [
|
|
42662
|
-
{
|
|
42663
|
-
|
|
42664
|
-
|
|
42665
|
-
|
|
42666
|
-
type: "string"
|
|
42667
|
-
}
|
|
42668
|
-
}
|
|
42613
|
+
option("output", {
|
|
42614
|
+
describe: "File to write the declaration .sqlx to. Prints to stdout if omitted.",
|
|
42615
|
+
type: "string"
|
|
42616
|
+
})
|
|
42669
42617
|
],
|
|
42670
42618
|
processFn: async (argv) => {
|
|
42671
42619
|
const projectDir = argv[projectDirOption.name];
|
|
@@ -42739,93 +42687,62 @@ class ProjectConfigOptions {
|
|
|
42739
42687
|
return projectConfigOptions;
|
|
42740
42688
|
}
|
|
42741
42689
|
}
|
|
42742
|
-
ProjectConfigOptions.defaultDatabase = {
|
|
42743
|
-
|
|
42744
|
-
|
|
42745
|
-
|
|
42746
|
-
|
|
42747
|
-
|
|
42748
|
-
|
|
42749
|
-
};
|
|
42750
|
-
ProjectConfigOptions.
|
|
42751
|
-
|
|
42752
|
-
|
|
42753
|
-
|
|
42754
|
-
|
|
42755
|
-
|
|
42756
|
-
|
|
42757
|
-
|
|
42758
|
-
|
|
42759
|
-
|
|
42760
|
-
|
|
42761
|
-
|
|
42762
|
-
|
|
42763
|
-
|
|
42764
|
-
|
|
42765
|
-
|
|
42766
|
-
|
|
42767
|
-
|
|
42768
|
-
|
|
42769
|
-
|
|
42770
|
-
|
|
42771
|
-
|
|
42772
|
-
|
|
42773
|
-
describe: "Default assertion schema. If unset, the value from workflow_settings.yaml is used."
|
|
42774
|
-
}
|
|
42775
|
-
};
|
|
42776
|
-
ProjectConfigOptions.vars = {
|
|
42777
|
-
name: "vars",
|
|
42778
|
-
option: {
|
|
42779
|
-
describe: "Override for variables to inject via '--vars=someKey=someValue,a=b', referenced by " +
|
|
42780
|
-
"`sqlanvil.projectConfig.vars.someValue`. If unset, the value from workflow_settings.yaml is used.",
|
|
42781
|
-
type: "string",
|
|
42782
|
-
default: null,
|
|
42783
|
-
coerce: (rawVarsString) => {
|
|
42784
|
-
const variables = {};
|
|
42785
|
-
rawVarsString === null || rawVarsString === void 0 ? void 0 : rawVarsString.split(",").forEach(keyValueStr => {
|
|
42786
|
-
const [key, value] = keyValueStr.split("=");
|
|
42787
|
-
variables[key] = value;
|
|
42788
|
-
});
|
|
42789
|
-
return variables;
|
|
42790
|
-
}
|
|
42791
|
-
}
|
|
42792
|
-
};
|
|
42793
|
-
ProjectConfigOptions.schemaSuffix = {
|
|
42794
|
-
name: "schema-suffix",
|
|
42795
|
-
option: {
|
|
42796
|
-
describe: "A suffix to be appended to output schema names. If unset, the value from workflow_settings.yaml " +
|
|
42797
|
-
"is used."
|
|
42798
|
-
},
|
|
42799
|
-
check: (argv) => {
|
|
42800
|
-
if (argv[ProjectConfigOptions.schemaSuffix.name] &&
|
|
42801
|
-
!/^[a-zA-Z_0-9]+$/.test(argv[ProjectConfigOptions.schemaSuffix.name])) {
|
|
42802
|
-
throw new Error(`--${ProjectConfigOptions.schemaSuffix.name} should contain only ` +
|
|
42803
|
-
`alphanumeric characters and/or underscores.`);
|
|
42804
|
-
}
|
|
42805
|
-
}
|
|
42806
|
-
};
|
|
42807
|
-
ProjectConfigOptions.tablePrefix = {
|
|
42808
|
-
name: "table-prefix",
|
|
42809
|
-
option: {
|
|
42810
|
-
describe: "Adds a prefix for all table names. If unset, the value from workflow_settings.yaml is used."
|
|
42811
|
-
}
|
|
42812
|
-
};
|
|
42813
|
-
ProjectConfigOptions.disableAssertions = {
|
|
42814
|
-
name: "disable-assertions",
|
|
42815
|
-
option: {
|
|
42816
|
-
describe: "Disables all assertions including built-in assertions (uniqueKey, nonNull, rowConditions) and manual assertions (type: assertion).",
|
|
42817
|
-
type: "boolean",
|
|
42818
|
-
default: false
|
|
42690
|
+
ProjectConfigOptions.defaultDatabase = option("default-database", {
|
|
42691
|
+
describe: "The default database to use, equivalent to Google Cloud Project ID. If unset, " +
|
|
42692
|
+
"the value from workflow_settings.yaml is used.",
|
|
42693
|
+
type: "string"
|
|
42694
|
+
});
|
|
42695
|
+
ProjectConfigOptions.defaultSchema = option("default-schema", {
|
|
42696
|
+
describe: "Override for the default schema name. If unset, the value from workflow_settings.yaml is used."
|
|
42697
|
+
});
|
|
42698
|
+
ProjectConfigOptions.defaultLocation = option("default-location", {
|
|
42699
|
+
describe: "The default location to use. See " +
|
|
42700
|
+
"https://cloud.google.com/bigquery/docs/locations for supported values. If unset, the " +
|
|
42701
|
+
"value from workflow_settings.yaml is used."
|
|
42702
|
+
});
|
|
42703
|
+
ProjectConfigOptions.assertionSchema = option("assertion-schema", {
|
|
42704
|
+
describe: "Default assertion schema. If unset, the value from workflow_settings.yaml is used."
|
|
42705
|
+
});
|
|
42706
|
+
ProjectConfigOptions.databaseSuffix = option("database-suffix", {
|
|
42707
|
+
describe: "Default assertion schema. If unset, the value from workflow_settings.yaml is used."
|
|
42708
|
+
});
|
|
42709
|
+
ProjectConfigOptions.vars = option("vars", {
|
|
42710
|
+
describe: "Override for variables to inject via '--vars=someKey=someValue,a=b', referenced by " +
|
|
42711
|
+
"`sqlanvil.projectConfig.vars.someValue`. If unset, the value from workflow_settings.yaml is used.",
|
|
42712
|
+
type: "string",
|
|
42713
|
+
default: null,
|
|
42714
|
+
coerce: (rawVarsString) => {
|
|
42715
|
+
const variables = {};
|
|
42716
|
+
rawVarsString === null || rawVarsString === void 0 ? void 0 : rawVarsString.split(",").forEach(keyValueStr => {
|
|
42717
|
+
const [key, value] = keyValueStr.split("=");
|
|
42718
|
+
variables[key] = value;
|
|
42719
|
+
});
|
|
42720
|
+
return variables;
|
|
42819
42721
|
}
|
|
42820
|
-
};
|
|
42821
|
-
ProjectConfigOptions.
|
|
42822
|
-
|
|
42823
|
-
|
|
42824
|
-
|
|
42825
|
-
|
|
42826
|
-
|
|
42722
|
+
});
|
|
42723
|
+
ProjectConfigOptions.schemaSuffix = option("schema-suffix", {
|
|
42724
|
+
describe: "A suffix to be appended to output schema names. If unset, the value from workflow_settings.yaml " +
|
|
42725
|
+
"is used."
|
|
42726
|
+
}, (argv) => {
|
|
42727
|
+
if (argv[ProjectConfigOptions.schemaSuffix.name] &&
|
|
42728
|
+
!/^[a-zA-Z_0-9]+$/.test(argv[ProjectConfigOptions.schemaSuffix.name])) {
|
|
42729
|
+
throw new Error(`--${ProjectConfigOptions.schemaSuffix.name} should contain only ` +
|
|
42730
|
+
`alphanumeric characters and/or underscores.`);
|
|
42827
42731
|
}
|
|
42828
|
-
};
|
|
42732
|
+
});
|
|
42733
|
+
ProjectConfigOptions.tablePrefix = option("table-prefix", {
|
|
42734
|
+
describe: "Adds a prefix for all table names. If unset, the value from workflow_settings.yaml is used."
|
|
42735
|
+
});
|
|
42736
|
+
ProjectConfigOptions.disableAssertions = option("disable-assertions", {
|
|
42737
|
+
describe: "Disables all assertions including built-in assertions (uniqueKey, nonNull, rowConditions) and manual assertions (type: assertion).",
|
|
42738
|
+
type: "boolean",
|
|
42739
|
+
default: false
|
|
42740
|
+
});
|
|
42741
|
+
ProjectConfigOptions.defaultReservation = option("default-reservation", {
|
|
42742
|
+
describe: "The default BigQuery reservation to use for execution. If unset, the value from " +
|
|
42743
|
+
"workflow_settings.yaml is used. If neither is set, default BigQuery behavior applies.",
|
|
42744
|
+
type: "string"
|
|
42745
|
+
});
|
|
42829
42746
|
ProjectConfigOptions.allYargsOptions = [
|
|
42830
42747
|
ProjectConfigOptions.defaultDatabase,
|
|
42831
42748
|
ProjectConfigOptions.defaultSchema,
|