@diafunc/cli 0.22.0 → 0.24.0
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/bin/diafunc.js +3 -3
- package/dist/{chunk-LEDCBZ3S.js → chunk-2YKNPNBM.js} +146 -53
- package/dist/chunk-2YKNPNBM.js.map +1 -0
- package/dist/{chunk-5WKI5YMX.js → chunk-A6PH2CFB.js} +2 -2
- package/dist/{chunk-5WKI5YMX.js.map → chunk-A6PH2CFB.js.map} +1 -1
- package/dist/{chunk-KIHRD6SW.js → chunk-FX557IX3.js} +2 -2
- package/dist/src/index.js +2 -2
- package/dist/update-check-YTIEPB54.js +8 -0
- package/package.json +1 -1
- package/dist/chunk-LEDCBZ3S.js.map +0 -1
- package/dist/update-check-RWCYYDVC.js +0 -8
- /package/dist/{chunk-KIHRD6SW.js.map → chunk-FX557IX3.js.map} +0 -0
- /package/dist/{update-check-RWCYYDVC.js.map → update-check-YTIEPB54.js.map} +0 -0
package/dist/bin/diafunc.js
CHANGED
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
PromptCancelled,
|
|
5
5
|
createProgram,
|
|
6
6
|
handleError
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-2YKNPNBM.js";
|
|
8
8
|
import {
|
|
9
9
|
getUpdateNotice
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-FX557IX3.js";
|
|
11
11
|
import {
|
|
12
12
|
package_default
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-A6PH2CFB.js";
|
|
14
14
|
|
|
15
15
|
// bin/diafunc.ts
|
|
16
16
|
import chalk2 from "chalk";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
package_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-A6PH2CFB.js";
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
6
6
|
import chalk37 from "chalk";
|
|
@@ -1642,11 +1642,11 @@ function createAnalysisService(client) {
|
|
|
1642
1642
|
body: request
|
|
1643
1643
|
});
|
|
1644
1644
|
},
|
|
1645
|
-
async
|
|
1645
|
+
async patchInputExclusions(analysisId, request) {
|
|
1646
1646
|
return client.request({
|
|
1647
1647
|
method: "PATCH",
|
|
1648
1648
|
service: SERVICE2,
|
|
1649
|
-
path: `/${encodeURIComponent(analysisId)}/
|
|
1649
|
+
path: `/${encodeURIComponent(analysisId)}/input-exclusions`,
|
|
1650
1650
|
body: request
|
|
1651
1651
|
});
|
|
1652
1652
|
},
|
|
@@ -1684,6 +1684,18 @@ function createAnalysisService(client) {
|
|
|
1684
1684
|
rawBody: formData
|
|
1685
1685
|
});
|
|
1686
1686
|
},
|
|
1687
|
+
/**
|
|
1688
|
+
* Makes a data source one of the files the analysis's data is built from: the platform fetches once and
|
|
1689
|
+
* stores the file as a source. The data is not built here; see `planSources` and `buildSources`.
|
|
1690
|
+
*/
|
|
1691
|
+
async attachDataSource(analysisId, body) {
|
|
1692
|
+
return client.request({
|
|
1693
|
+
method: "POST",
|
|
1694
|
+
service: SERVICE2,
|
|
1695
|
+
path: `/${encodeURIComponent(analysisId)}/sources/data-source`,
|
|
1696
|
+
body
|
|
1697
|
+
});
|
|
1698
|
+
},
|
|
1687
1699
|
async listSources(analysisId) {
|
|
1688
1700
|
return client.request({
|
|
1689
1701
|
method: "GET",
|
|
@@ -6315,7 +6327,7 @@ var HELP = [
|
|
|
6315
6327
|
];
|
|
6316
6328
|
async function runChatRepl(options) {
|
|
6317
6329
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
6318
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
6330
|
+
const { getUpdateNotice } = await import("./update-check-YTIEPB54.js");
|
|
6319
6331
|
let sessionId = options.session;
|
|
6320
6332
|
let lastReportedSession;
|
|
6321
6333
|
console.log(chalk19.bold("Diafunc chat") + chalk19.dim(" \xB7 /help for commands, /quit to exit"));
|
|
@@ -7622,9 +7634,9 @@ async function promptRunFields(prompter, options) {
|
|
|
7622
7634
|
}
|
|
7623
7635
|
if (hours === void 0) {
|
|
7624
7636
|
hours = await prompter.input({
|
|
7625
|
-
message: "Time
|
|
7637
|
+
message: "Time limit (hours)",
|
|
7626
7638
|
default: depthDefault?.hours,
|
|
7627
|
-
validate: positiveNumber("Time
|
|
7639
|
+
validate: positiveNumber("Time limit")
|
|
7628
7640
|
});
|
|
7629
7641
|
}
|
|
7630
7642
|
if (budget === void 0) {
|
|
@@ -7772,7 +7784,7 @@ function analysisDetails(analysis, endpoint) {
|
|
|
7772
7784
|
dataImport: analysis.dataImport?.message ?? null,
|
|
7773
7785
|
targets: analysis.targets,
|
|
7774
7786
|
targetKinds: analysis.targetKinds && Object.keys(analysis.targetKinds).length > 0 ? analysis.targetKinds : "detected from the data",
|
|
7775
|
-
|
|
7787
|
+
inputExclusions: analysis.inputExclusions,
|
|
7776
7788
|
confirmedInputs: analysis.confirmedInputs,
|
|
7777
7789
|
questions: analysis.questions,
|
|
7778
7790
|
segment: analysis.segment,
|
|
@@ -7803,11 +7815,11 @@ function analysisDetails(analysis, endpoint) {
|
|
|
7803
7815
|
{ key: "dataImport", header: "Data import" },
|
|
7804
7816
|
{ key: "targets", header: "Targets" },
|
|
7805
7817
|
{ key: "targetKinds", header: "Target kinds" },
|
|
7806
|
-
{ key: "
|
|
7818
|
+
{ key: "inputExclusions", header: "Excluded columns" },
|
|
7807
7819
|
{ key: "confirmedInputs", header: "Known before the outcome" },
|
|
7808
7820
|
{ key: "questions", header: "Questions" },
|
|
7809
7821
|
{ key: "segment", header: "Segment" },
|
|
7810
|
-
{ key: "hours", header: "Time
|
|
7822
|
+
{ key: "hours", header: "Time limit" },
|
|
7811
7823
|
{ key: "budget", header: "Credit budget" },
|
|
7812
7824
|
{ key: "constraints", header: "Constraints" },
|
|
7813
7825
|
{ key: "notifyByEmail", header: "Email when done" },
|
|
@@ -7864,13 +7876,16 @@ function outputsText(analysis) {
|
|
|
7864
7876
|
if (more > 0) lines.push(`and ${formatNumber(more)} more`);
|
|
7865
7877
|
return lines.join("\n");
|
|
7866
7878
|
}
|
|
7879
|
+
function errorPercent(error) {
|
|
7880
|
+
return `${formatNumber(Math.round(error * 1e3) / 10)}%`;
|
|
7881
|
+
}
|
|
7867
7882
|
function constraintsText(analysis) {
|
|
7868
7883
|
const parts = [];
|
|
7869
7884
|
if (analysis.minComplexity != null) parts.push(`complexity at least ${formatNumber(analysis.minComplexity)}`);
|
|
7870
7885
|
if (analysis.maxComplexity != null) parts.push(`complexity at most ${formatNumber(analysis.maxComplexity)}`);
|
|
7871
7886
|
if (analysis.targetComplexity != null) parts.push(`aim for complexity ${formatNumber(analysis.targetComplexity)}`);
|
|
7872
7887
|
if (analysis.targetQuality != null) parts.push(`stop at quality ${qualityPercent(analysis.targetQuality)}`);
|
|
7873
|
-
if (analysis.targetError != null) parts.push(`stop at error ${
|
|
7888
|
+
if (analysis.targetError != null) parts.push(`stop at error ${errorPercent(analysis.targetError)}`);
|
|
7874
7889
|
if (analysis.minMilliseconds != null) parts.push(`search at least ${formatDurationPrecise(analysis.minMilliseconds)}`);
|
|
7875
7890
|
return parts.length > 0 ? parts.join(", ") : "none";
|
|
7876
7891
|
}
|
|
@@ -8254,6 +8269,18 @@ function namedDepth(options) {
|
|
|
8254
8269
|
if (options.budget?.trim()) depth.budget = options.budget.trim();
|
|
8255
8270
|
return depth;
|
|
8256
8271
|
}
|
|
8272
|
+
var REPORT_TERMS_HELP = `
|
|
8273
|
+
Terms:
|
|
8274
|
+
Quality How well the model predicts on held-out rows, marked down for the size of its
|
|
8275
|
+
formula. 0% is no better than always predicting the average, 100% is exact.
|
|
8276
|
+
While a search runs, the same measure on the training rows.
|
|
8277
|
+
Error How far the predictions lie from the held-out values, as a share of the miss of
|
|
8278
|
+
always predicting the average. 0% is exact.
|
|
8279
|
+
Complexity How long the formula is. A bound limits the formulas the search may return.
|
|
8280
|
+
Generation One round of the search: candidates are varied, measured and selected.
|
|
8281
|
+
|
|
8282
|
+
Every term: https://diafunc.com/documentation/glossary
|
|
8283
|
+
`;
|
|
8257
8284
|
function budgetHoursOf(hours) {
|
|
8258
8285
|
if (hours === null || hours === void 0) return null;
|
|
8259
8286
|
const parsed = Number(hours);
|
|
@@ -9008,28 +9035,55 @@ async function deletePreset(presetId) {
|
|
|
9008
9035
|
await api.analysis.deletePreset(presetId);
|
|
9009
9036
|
success(`Deleted preset ${presetId}.`);
|
|
9010
9037
|
}
|
|
9011
|
-
|
|
9012
|
-
|
|
9013
|
-
const api = createApiClient();
|
|
9014
|
-
const triggers = await api.analysis.listTriggers(analysisId);
|
|
9015
|
-
format(triggers.map((t) => ({
|
|
9038
|
+
function triggerRow(t) {
|
|
9039
|
+
return {
|
|
9016
9040
|
triggerId: t.triggerId,
|
|
9017
9041
|
kind: t.kind,
|
|
9018
9042
|
schedule: t.scheduleSpec,
|
|
9019
9043
|
active: t.active,
|
|
9020
|
-
|
|
9021
|
-
|
|
9044
|
+
refreshFirst: t.refreshFirst === true,
|
|
9045
|
+
nextFireAt: t.nextFireAt,
|
|
9046
|
+
lastOutcome: t.lastOutcome ?? ""
|
|
9047
|
+
};
|
|
9048
|
+
}
|
|
9049
|
+
function triggerChanges(options) {
|
|
9050
|
+
const flag = (name, value) => {
|
|
9051
|
+
if (value === void 0) return void 0;
|
|
9052
|
+
const lc = value.toLowerCase();
|
|
9053
|
+
if (lc !== "true" && lc !== "false") {
|
|
9054
|
+
throw new CliError(`Invalid --${name} value "${value}". Use true or false.`);
|
|
9055
|
+
}
|
|
9056
|
+
return lc === "true";
|
|
9057
|
+
};
|
|
9058
|
+
const active = flag("active", options.active);
|
|
9059
|
+
const refreshFirst = flag("refresh-first", options.refreshFirst);
|
|
9060
|
+
if (active === void 0 && !options.schedule && refreshFirst === void 0) {
|
|
9061
|
+
throw new CliError("Pass at least one of --active, --schedule or --refresh-first.");
|
|
9062
|
+
}
|
|
9063
|
+
return {
|
|
9064
|
+
active: active ?? null,
|
|
9065
|
+
scheduleSpec: options.schedule ?? null,
|
|
9066
|
+
...refreshFirst === void 0 ? {} : { refreshFirst }
|
|
9067
|
+
};
|
|
9068
|
+
}
|
|
9069
|
+
async function listTriggers(analysisId, cmd) {
|
|
9070
|
+
const outputFormat = getOutputFormat15(cmd);
|
|
9071
|
+
const api = createApiClient();
|
|
9072
|
+
const triggers = await api.analysis.listTriggers(analysisId);
|
|
9073
|
+
format(triggers.map(triggerRow), {
|
|
9022
9074
|
format: outputFormat,
|
|
9023
9075
|
columns: [
|
|
9024
9076
|
{ key: "triggerId", kind: "id" },
|
|
9025
9077
|
"kind",
|
|
9026
9078
|
"schedule",
|
|
9027
9079
|
{ key: "active", kind: "boolean" },
|
|
9028
|
-
{ key: "
|
|
9080
|
+
{ key: "refreshFirst", header: "refresh first", kind: "boolean" },
|
|
9081
|
+
{ key: "nextFireAt", header: "next fire", kind: "date" },
|
|
9082
|
+
{ key: "lastOutcome", header: "last outcome" }
|
|
9029
9083
|
]
|
|
9030
9084
|
});
|
|
9031
9085
|
}
|
|
9032
|
-
async function createTrigger(analysisId, kind, schedule, cmd) {
|
|
9086
|
+
async function createTrigger(analysisId, kind, schedule, cmd, refreshFirst = false) {
|
|
9033
9087
|
const outputFormat = getOutputFormat15(cmd);
|
|
9034
9088
|
const upper = kind.toUpperCase();
|
|
9035
9089
|
if (upper !== "ONCE" && upper !== "CRON") {
|
|
@@ -9039,7 +9093,8 @@ async function createTrigger(analysisId, kind, schedule, cmd) {
|
|
|
9039
9093
|
const api = createApiClient();
|
|
9040
9094
|
const trigger = await api.analysis.createTrigger(analysisId, {
|
|
9041
9095
|
kind: upper,
|
|
9042
|
-
scheduleSpec: schedule
|
|
9096
|
+
scheduleSpec: schedule,
|
|
9097
|
+
...refreshFirst ? { refreshFirst: true } : {}
|
|
9043
9098
|
});
|
|
9044
9099
|
format(trigger, { format: outputFormat });
|
|
9045
9100
|
}
|
|
@@ -9050,31 +9105,16 @@ async function deleteTrigger(triggerId) {
|
|
|
9050
9105
|
}
|
|
9051
9106
|
async function updateTriggerCmd(triggerId, options, cmd) {
|
|
9052
9107
|
const outputFormat = getOutputFormat15(cmd);
|
|
9053
|
-
|
|
9054
|
-
if (options.active !== void 0) {
|
|
9055
|
-
const lc = options.active.toLowerCase();
|
|
9056
|
-
if (lc !== "true" && lc !== "false") {
|
|
9057
|
-
failure(`Invalid --active value "${options.active}". Use true or false.`);
|
|
9058
|
-
process.exit(EXIT_FAILURE);
|
|
9059
|
-
}
|
|
9060
|
-
activeFlag = lc === "true";
|
|
9061
|
-
}
|
|
9062
|
-
if (activeFlag === void 0 && !options.schedule) {
|
|
9063
|
-
failure("Pass at least one of --active or --schedule.");
|
|
9064
|
-
process.exit(EXIT_FAILURE);
|
|
9065
|
-
}
|
|
9108
|
+
const changes = triggerChanges(options);
|
|
9066
9109
|
const api = createApiClient();
|
|
9067
|
-
const trigger = await api.analysis.updateTrigger(triggerId,
|
|
9068
|
-
active: activeFlag ?? null,
|
|
9069
|
-
scheduleSpec: options.schedule ?? null
|
|
9070
|
-
});
|
|
9110
|
+
const trigger = await api.analysis.updateTrigger(triggerId, changes);
|
|
9071
9111
|
format(trigger, { format: outputFormat });
|
|
9072
9112
|
}
|
|
9073
9113
|
var COLUMN_LIST_HELP = "one argument each or comma-separated; a name that contains a comma is an argument of its own, or goes in double quotes inside a list";
|
|
9074
9114
|
var TARGETS_HELP = `Target column names: repeat the flag or separate them with commas; a name that contains a comma is one flag of its own, or goes in double quotes inside a list`;
|
|
9075
9115
|
function registerAnalyzeCommand(program) {
|
|
9076
9116
|
const analyze = program.command("analyze").description("Run and manage automatic analyses");
|
|
9077
|
-
analyze.command("run", { isDefault: true }).description("Create an analysis from a data file, configure it and run it (the default: `analyze <file>`)").argument("[files...]", "Data file to analyze (CSV, Excel and more than 45 file formats; see `table import-formats`). Several files are combined into one table: files with the same columns are stacked, a file that shares a key adds its columns").option("--name <name>", "Analysis name (asked for, or derived from the filename)").option("--description <text>", "Analysis description").option("--visibility <vis>", "PRIVATE or PUBLIC (default: PRIVATE)").option("--hours <hours>", `Time
|
|
9117
|
+
analyze.command("run", { isDefault: true }).description("Create an analysis from a data file, configure it and run it (the default: `analyze <file>`)").argument("[files...]", "Data file to analyze (CSV, Excel and more than 45 file formats; see `table import-formats`). Several files are combined into one table: files with the same columns are stacked, a file that shares a key adds its columns").option("--name <name>", "Analysis name (asked for, or derived from the filename)").option("--description <text>", "Analysis description").option("--visibility <vis>", "PRIVATE or PUBLIC (default: PRIVATE)").option("--hours <hours>", `Time limit (hours). ${STARTING_DEPTH_RULE}`).option("--budget <credits>", `Credit budget. ${STARTING_DEPTH_RULE}`).option("--targets <columns>", `${TARGETS_HELP} (required when not interactive)`, collectColumns).option("--question <text>", "A question for the analysis to answer; repeat the flag for several", collectQuestion).option("--segment <name>", "Column to segment the analysis by").option("--introduction <markdown>", "Markdown introduction shown at the top of the notebook").option("--preset <id>", "Apply a saved preset as defaults (explicit flags override it)").option("--no-file-column", "With several files: do not add the column that records the file each row came from").option("--keep-duplicates", "With several files: keep rows that occur in more than one file").option("--rows-of <file>", "With several files that can be read two ways: the file in which one row is one observation").option("--as-uploaded [file]", AS_UPLOADED_HELP, collectAsUploaded).action(async (files, options, cmd) => {
|
|
9078
9118
|
try {
|
|
9079
9119
|
if (files.length === 0) {
|
|
9080
9120
|
analyze.help();
|
|
@@ -9092,14 +9132,14 @@ function registerAnalyzeCommand(program) {
|
|
|
9092
9132
|
handleError(error);
|
|
9093
9133
|
}
|
|
9094
9134
|
});
|
|
9095
|
-
analyze.command("get").description("Show details of an analysis").argument("[id]", "Analysis ID (defaults to the most recent)").option("--full", "Print the introduction in full instead of abbreviating it").action(async (id, options, cmd) => {
|
|
9135
|
+
analyze.command("get").description("Show details of an analysis").argument("[id]", "Analysis ID (defaults to the most recent)").option("--full", "Print the introduction in full instead of abbreviating it").addHelpText("after", REPORT_TERMS_HELP).action(async (id, options, cmd) => {
|
|
9096
9136
|
try {
|
|
9097
9137
|
await getAnalysisDetails(id, options, cmd);
|
|
9098
9138
|
} catch (error) {
|
|
9099
9139
|
handleError(error);
|
|
9100
9140
|
}
|
|
9101
9141
|
});
|
|
9102
|
-
analyze.command("watch").description("Follow the latest run of an analysis live").argument("[id]", "Analysis ID (defaults to the most recent)").action(async (id, _options, cmd) => {
|
|
9142
|
+
analyze.command("watch").description("Follow the latest run of an analysis live").argument("[id]", "Analysis ID (defaults to the most recent)").addHelpText("after", REPORT_TERMS_HELP).action(async (id, _options, cmd) => {
|
|
9103
9143
|
try {
|
|
9104
9144
|
await watchAnalysis(id, cmd);
|
|
9105
9145
|
} catch (error) {
|
|
@@ -9120,7 +9160,7 @@ function registerAnalyzeCommand(program) {
|
|
|
9120
9160
|
reportCommandError(error);
|
|
9121
9161
|
}
|
|
9122
9162
|
});
|
|
9123
|
-
analyze.command("create").description("Create an analysis without uploading data or running it").option("--name <name>", "Analysis name").option("--description <text>", "Analysis description").option("--visibility <vis>", "PRIVATE or PUBLIC", "PRIVATE").option("--hours <hours>", `Time
|
|
9163
|
+
analyze.command("create").description("Create an analysis without uploading data or running it").option("--name <name>", "Analysis name").option("--description <text>", "Analysis description").option("--visibility <vis>", "PRIVATE or PUBLIC", "PRIVATE").option("--hours <hours>", `Time limit (hours). ${STARTING_DEPTH_RULE}`).option("--budget <credits>", `Credit budget. ${STARTING_DEPTH_RULE}`).option("--targets <columns>", TARGETS_HELP, collectColumns).option("--question <text>", "A question for the analysis to answer; repeat the flag for several", collectQuestion).option("--segment <name>", "Column to segment the analysis by").option("--introduction <markdown>", "Markdown introduction shown at the top of the notebook").action(async (options, cmd) => {
|
|
9124
9164
|
try {
|
|
9125
9165
|
await createAnalysis(options, cmd);
|
|
9126
9166
|
} catch (error) {
|
|
@@ -9188,7 +9228,7 @@ function registerAnalyzeCommand(program) {
|
|
|
9188
9228
|
handleError(error);
|
|
9189
9229
|
}
|
|
9190
9230
|
});
|
|
9191
|
-
analyze.command("hours").description("Set the time
|
|
9231
|
+
analyze.command("hours").description("Set the time limit (hours) for the next run").argument("<id>", "Analysis ID").argument("<hours>", "Time limit (hours), e.g. 4").action(async (id, hours, _options, cmd) => {
|
|
9192
9232
|
try {
|
|
9193
9233
|
await patchAndPrint(
|
|
9194
9234
|
id,
|
|
@@ -9227,12 +9267,12 @@ function registerAnalyzeCommand(program) {
|
|
|
9227
9267
|
handleError(error);
|
|
9228
9268
|
}
|
|
9229
9269
|
});
|
|
9230
|
-
analyze.command("
|
|
9270
|
+
analyze.command("input-exclusions").description("Set the columns every fit leaves out as an input (a single empty string leaves nothing out)").argument("<id>", "Analysis ID").argument("<column...>", `Column names, ${COLUMN_LIST_HELP}`).action(async (id, given, _options, cmd) => {
|
|
9231
9271
|
try {
|
|
9232
9272
|
await patchColumns(
|
|
9233
9273
|
id,
|
|
9234
9274
|
given,
|
|
9235
|
-
(api, columns) => api.analysis.
|
|
9275
|
+
(api, columns) => api.analysis.patchInputExclusions(id, { columns }),
|
|
9236
9276
|
"Columns left out of the fit",
|
|
9237
9277
|
cmd
|
|
9238
9278
|
);
|
|
@@ -9332,7 +9372,7 @@ function registerAnalyzeCommand(program) {
|
|
|
9332
9372
|
handleError(error);
|
|
9333
9373
|
}
|
|
9334
9374
|
});
|
|
9335
|
-
presets.command("save").description("Create a new preset (omit --id) or update an existing one (with --id)").requiredOption("--name <name>", "Preset name").requiredOption("--targets <columns>", TARGETS_HELP, collectColumns).requiredOption("--hours <hours>", "Time
|
|
9375
|
+
presets.command("save").description("Create a new preset (omit --id) or update an existing one (with --id)").requiredOption("--name <name>", "Preset name").requiredOption("--targets <columns>", TARGETS_HELP, collectColumns).requiredOption("--hours <hours>", "Time limit (hours)").requiredOption("--budget <credits>", "Credit budget").option("--question <text>", "A question for the analysis to answer; repeat the flag for several", collectQuestion).option("--segment <name>", "Column to segment the analysis by").option("--id <id>", "Existing preset ID (update mode)").action(async (options, cmd) => {
|
|
9336
9376
|
try {
|
|
9337
9377
|
await savePreset(options, cmd);
|
|
9338
9378
|
} catch (error) {
|
|
@@ -9355,9 +9395,9 @@ function registerAnalyzeCommand(program) {
|
|
|
9355
9395
|
handleError(error);
|
|
9356
9396
|
}
|
|
9357
9397
|
});
|
|
9358
|
-
triggers.command("create").description("Create a trigger (ONCE: ISO-8601 timestamp; CRON: cron expression)").argument("<analysisId>", "Analysis ID").requiredOption("--kind <kind>", "ONCE or CRON").requiredOption("--schedule <spec>", "ISO-8601 timestamp (ONCE) or cron expression (CRON)").action(async (analysisId, options, cmd) => {
|
|
9398
|
+
triggers.command("create").description("Create a trigger (ONCE: ISO-8601 timestamp; CRON: cron expression)").argument("<analysisId>", "Analysis ID").requiredOption("--kind <kind>", "ONCE or CRON").requiredOption("--schedule <spec>", "ISO-8601 timestamp (ONCE) or cron expression (CRON)").option("--refresh-first", "Fetch the data sources that feed the analysis and build its data again before every run this trigger starts. A fetch that fails, or data that no longer fits, starts no run; `triggers list` says why").action(async (analysisId, options, cmd) => {
|
|
9359
9399
|
try {
|
|
9360
|
-
await createTrigger(analysisId, options.kind, options.schedule, cmd);
|
|
9400
|
+
await createTrigger(analysisId, options.kind, options.schedule, cmd, options.refreshFirst === true);
|
|
9361
9401
|
} catch (error) {
|
|
9362
9402
|
handleError(error);
|
|
9363
9403
|
}
|
|
@@ -9370,7 +9410,7 @@ function registerAnalyzeCommand(program) {
|
|
|
9370
9410
|
handleError(error);
|
|
9371
9411
|
}
|
|
9372
9412
|
});
|
|
9373
|
-
triggers.command("update").description("Update a trigger: pause or resume it (--active), reschedule it (--schedule), or
|
|
9413
|
+
triggers.command("update").description("Update a trigger: pause or resume it (--active), reschedule it (--schedule), switch refreshing the data first on or off (--refresh-first), or several at once").argument("<triggerId>", "Trigger ID").option("--active <bool>", "true to resume, false to pause").option("--schedule <spec>", "New schedule spec (ISO-8601 instant for ONCE, Quartz cron for CRON)").option("--refresh-first <bool>", "true to fetch the analysis's data sources before each run, false to run on the data as it is").action(async (triggerId, options, cmd) => {
|
|
9374
9414
|
try {
|
|
9375
9415
|
await updateTriggerCmd(triggerId, options, cmd);
|
|
9376
9416
|
} catch (error) {
|
|
@@ -9573,7 +9613,7 @@ function dataSourceTableRow(ds) {
|
|
|
9573
9613
|
id: ds.id,
|
|
9574
9614
|
name: ds.name,
|
|
9575
9615
|
type: ds.type,
|
|
9576
|
-
target: `${ds.targetEntityId}@${ds.targetEntityBranch}`,
|
|
9616
|
+
target: ds.analysisId ? `analysis ${ds.analysisId}` : `${ds.targetEntityId}@${ds.targetEntityBranch}`,
|
|
9577
9617
|
schedule: ds.scheduleCron ?? "manual",
|
|
9578
9618
|
lastStatus: ds.lastRunStatus ?? "\u2014",
|
|
9579
9619
|
lastRefreshAt: ds.lastRefreshAt ?? "\u2014"
|
|
@@ -9703,9 +9743,62 @@ async function showDashboard(projectId, cmd) {
|
|
|
9703
9743
|
]
|
|
9704
9744
|
});
|
|
9705
9745
|
}
|
|
9746
|
+
var TABLE_TARGET_FLAGS = [
|
|
9747
|
+
["projectId", "--project-id"],
|
|
9748
|
+
["projectBranch", "--project-branch"],
|
|
9749
|
+
["targetEntityId", "--target-entity-id"],
|
|
9750
|
+
["targetEntityBranch", "--target-entity-branch"]
|
|
9751
|
+
];
|
|
9752
|
+
function createTarget(options) {
|
|
9753
|
+
const given = TABLE_TARGET_FLAGS.filter(([key]) => options[key] !== void 0).map(([, flag]) => flag);
|
|
9754
|
+
if (options.analysis !== void 0) {
|
|
9755
|
+
if (given.length > 0) {
|
|
9756
|
+
throw new CliError(
|
|
9757
|
+
`--analysis cannot be combined with ${given.join(", ")}.`,
|
|
9758
|
+
{ exitCode: EXIT_USAGE, hint: "A data source feeds an analysis or overwrites a table, not both." }
|
|
9759
|
+
);
|
|
9760
|
+
}
|
|
9761
|
+
return "analysis";
|
|
9762
|
+
}
|
|
9763
|
+
const missing = TABLE_TARGET_FLAGS.filter(([key]) => options[key] === void 0).map(([, flag]) => flag);
|
|
9764
|
+
if (missing.length > 0) {
|
|
9765
|
+
throw new CliError(
|
|
9766
|
+
`Say what the data source refreshes: --analysis <analysisId>, or a table with ${missing.join(", ")}.`,
|
|
9767
|
+
{ exitCode: EXIT_USAGE }
|
|
9768
|
+
);
|
|
9769
|
+
}
|
|
9770
|
+
return "table";
|
|
9771
|
+
}
|
|
9772
|
+
async function createForAnalysis(api, options, human) {
|
|
9773
|
+
const analysisId = options.analysis;
|
|
9774
|
+
const source = await api.analysis.attachDataSource(analysisId, {
|
|
9775
|
+
name: options.name,
|
|
9776
|
+
type: options.type,
|
|
9777
|
+
config: parseConfigPairs(options.config),
|
|
9778
|
+
scheduleCron: options.scheduleCron ?? null
|
|
9779
|
+
});
|
|
9780
|
+
const plan = await api.analysis.planSources(analysisId, null);
|
|
9781
|
+
const build = await api.analysis.buildSources(analysisId, plan.recipe);
|
|
9782
|
+
if (human) {
|
|
9783
|
+
success(`Added ${source.fileName} to analysis ${analysisId} from data source ${source.dataSourceId ?? ""}`.trimEnd());
|
|
9784
|
+
for (const line of planLines(build.plan)) {
|
|
9785
|
+
console.log(line.caution ? chalk27.yellow(` ${line.text}`) : chalk27.dim(` ${line.text}`));
|
|
9786
|
+
}
|
|
9787
|
+
console.log(chalk27.dim(options.scheduleCron ? ` Refreshes ${humanizeCron(options.scheduleCron)}; each refresh replaces the file and builds the data again.` : " No schedule of its own: refresh it with `data-sources refresh`, or let a trigger fetch it before a run (`analyze triggers create --refresh-first`)."));
|
|
9788
|
+
}
|
|
9789
|
+
return { source, build };
|
|
9790
|
+
}
|
|
9706
9791
|
async function createDataSource(options, cmd) {
|
|
9707
9792
|
const outputFormat = getOutputFormat17(cmd);
|
|
9793
|
+
const target = createTarget(options);
|
|
9708
9794
|
const api = createApiClient();
|
|
9795
|
+
if (target === "analysis") {
|
|
9796
|
+
const created = await createForAnalysis(api, options, outputFormat === "human");
|
|
9797
|
+
if (outputFormat !== "human") {
|
|
9798
|
+
format(created, { format: outputFormat });
|
|
9799
|
+
}
|
|
9800
|
+
return;
|
|
9801
|
+
}
|
|
9709
9802
|
const request = {
|
|
9710
9803
|
projectId: options.projectId,
|
|
9711
9804
|
projectBranch: options.projectBranch,
|
|
@@ -9840,7 +9933,7 @@ Examples:
|
|
|
9840
9933
|
handleError(error);
|
|
9841
9934
|
}
|
|
9842
9935
|
});
|
|
9843
|
-
dataSources.command("create").description("Create a data source (runs the initial fetch synchronously)").
|
|
9936
|
+
dataSources.command("create").description("Create a data source (runs the initial fetch synchronously). With --analysis the fetched file becomes one of the files that analysis is built from, and every refresh builds its data again; otherwise the data source overwrites a table").option("--analysis <analysisId>", "The analysis to feed: the file is stacked, matched by a key or reshaped like an uploaded one. Replaces the four table flags").option("--project-id <id>", "Project ID (for a table)").option("--project-branch <branch>", 'Project branch, usually "main" (for a table)').option("--target-entity-id <id>", "Target table entity ID (for a table)").option("--target-entity-branch <branch>", "Target table entity branch (for a table)").requiredOption("--name <name>", "Display name").requiredOption("--type <type>", "Connector type (google_sheets, s3_url, jdbc)").option("--config <key=value>", "Connector config field; repeat for multiple", (value, prev = []) => prev.concat([value]), []).option("--schedule-cron <expr>", 'Quartz cron expression (e.g. "0 0 2 * * ?" for daily 02:00 UTC); omit for manual-only').action(async (options, cmd) => {
|
|
9844
9937
|
try {
|
|
9845
9938
|
await createDataSource(options, cmd);
|
|
9846
9939
|
} catch (error) {
|
|
@@ -10793,7 +10886,7 @@ function registerShellCommand(program) {
|
|
|
10793
10886
|
});
|
|
10794
10887
|
const api = createApiClient();
|
|
10795
10888
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
10796
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
10889
|
+
const { getUpdateNotice } = await import("./update-check-YTIEPB54.js");
|
|
10797
10890
|
const resolvedLanguage = await resolveLanguage(api, fnRef.projectId, options.language);
|
|
10798
10891
|
console.log(chalk32.bold("Diafunc shell") + chalk32.dim(` \xB7 function ${fnRef.entityId} \xB7 ${resolvedLanguage}`));
|
|
10799
10892
|
console.log(chalk32.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
|
|
@@ -11087,7 +11180,7 @@ var INDEX = { kind: "number", min: 0, integer: true };
|
|
|
11087
11180
|
var BY_COMMAND = {
|
|
11088
11181
|
"analyze segment": { "<name>": { kind: "analysisColumns", multiple: false, allowEmpty: true } },
|
|
11089
11182
|
"analyze targets": { "<column>": { kind: "analysisColumns", multiple: true, allowEmpty: false } },
|
|
11090
|
-
"analyze
|
|
11183
|
+
"analyze input-exclusions": { "<column>": { kind: "analysisColumns", multiple: true, allowEmpty: true } },
|
|
11091
11184
|
"analyze confirmed-inputs": { "<column>": { kind: "analysisColumns", multiple: true, allowEmpty: true } },
|
|
11092
11185
|
"analyze questions": { "<question>": TEXT_OR_EMPTY },
|
|
11093
11186
|
"analyze description": { "<text>": TEXT_OR_EMPTY },
|
|
@@ -11843,4 +11936,4 @@ export {
|
|
|
11843
11936
|
PromptCancelled,
|
|
11844
11937
|
createProgram
|
|
11845
11938
|
};
|
|
11846
|
-
//# sourceMappingURL=chunk-
|
|
11939
|
+
//# sourceMappingURL=chunk-2YKNPNBM.js.map
|