@diafunc/cli 0.23.0 → 0.25.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.
@@ -4,13 +4,13 @@ import {
4
4
  PromptCancelled,
5
5
  createProgram,
6
6
  handleError
7
- } from "../chunk-DXZN6YJJ.js";
7
+ } from "../chunk-RJM7OBRF.js";
8
8
  import {
9
9
  getUpdateNotice
10
- } from "../chunk-CBQ5OGX3.js";
10
+ } from "../chunk-2RII4SNX.js";
11
11
  import {
12
12
  package_default
13
- } from "../chunk-KND3I4AN.js";
13
+ } from "../chunk-DOVJKPLM.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-KND3I4AN.js";
3
+ } from "./chunk-DOVJKPLM.js";
4
4
 
5
5
  // src/util/update-check.ts
6
6
  import * as fs from "fs";
@@ -72,4 +72,4 @@ async function getUpdateNotice() {
72
72
  export {
73
73
  getUpdateNotice
74
74
  };
75
- //# sourceMappingURL=chunk-CBQ5OGX3.js.map
75
+ //# sourceMappingURL=chunk-2RII4SNX.js.map
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@diafunc/cli",
4
- version: "0.23.0",
4
+ version: "0.25.0",
5
5
  description: "Diafunc CLI: the command-line interface for the Diafunc platform",
6
6
  type: "module",
7
7
  bin: {
@@ -62,4 +62,4 @@ var package_default = {
62
62
  export {
63
63
  package_default
64
64
  };
65
- //# sourceMappingURL=chunk-KND3I4AN.js.map
65
+ //# sourceMappingURL=chunk-DOVJKPLM.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@diafunc/cli\",\n \"version\": \"0.23.0\",\n \"description\": \"Diafunc CLI: the command-line interface for the Diafunc platform\",\n \"type\": \"module\",\n \"bin\": {\n \"diafunc\": \"./dist/bin/diafunc.js\"\n },\n \"homepage\": \"https://diafunc.com\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://gitlab.com/diafunc/cli.git\"\n },\n \"bugs\": {\n \"url\": \"https://gitlab.com/diafunc/cli/-/issues\"\n },\n \"author\": \"Markus Pollak <markus.pollak@diafunc.com>\",\n \"scripts\": {\n \"build\": \"tsup && node -e \\\"const fs=require('fs');const f='dist/bin/diafunc.js';fs.writeFileSync(f,'#!/usr/bin/env node\\\\n'+fs.readFileSync(f,'utf8'))\\\"\",\n \"dev\": \"tsup --watch\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"lint\": \"tsc --noEmit\",\n \"start\": \"node dist/bin/diafunc.js\",\n \"prepublishOnly\": \"npm run lint && npm test && npm run build\"\n },\n \"files\": [\n \"dist\",\n \"LICENSE\",\n \"README.md\"\n ],\n \"keywords\": [\n \"diafunc\",\n \"cli\",\n \"data-science\",\n \"symbolic-regression\"\n ],\n \"license\": \"Apache-2.0\",\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"dependencies\": {\n \"@inquirer/prompts\": \"^7.0.0\",\n \"chalk\": \"^5.4.0\",\n \"cli-table3\": \"^0.6.5\",\n \"commander\": \"^12.1.0\",\n \"ora\": \"^8.1.0\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^22.0.0\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.6.0\",\n \"vitest\": \"^2.1.0\"\n }\n}\n"],"mappings":";AAAA;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,KAAO;AAAA,IACL,SAAW;AAAA,EACb;AAAA,EACA,UAAY;AAAA,EACZ,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,EACT;AAAA,EACA,MAAQ;AAAA,IACN,KAAO;AAAA,EACT;AAAA,EACA,QAAU;AAAA,EACV,SAAW;AAAA,IACT,OAAS;AAAA,IACT,KAAO;AAAA,IACP,MAAQ;AAAA,IACR,cAAc;AAAA,IACd,MAAQ;AAAA,IACR,OAAS;AAAA,IACT,gBAAkB;AAAA,EACpB;AAAA,EACA,OAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,SAAW;AAAA,EACX,eAAiB;AAAA,IACf,QAAU;AAAA,IACV,UAAY;AAAA,EACd;AAAA,EACA,SAAW;AAAA,IACT,MAAQ;AAAA,EACV;AAAA,EACA,cAAgB;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAS;AAAA,IACT,cAAc;AAAA,IACd,WAAa;AAAA,IACb,KAAO;AAAA,EACT;AAAA,EACA,iBAAmB;AAAA,IACjB,eAAe;AAAA,IACf,MAAQ;AAAA,IACR,YAAc;AAAA,IACd,QAAU;AAAA,EACZ;AACF;","names":[]}
1
+ {"version":3,"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@diafunc/cli\",\n \"version\": \"0.25.0\",\n \"description\": \"Diafunc CLI: the command-line interface for the Diafunc platform\",\n \"type\": \"module\",\n \"bin\": {\n \"diafunc\": \"./dist/bin/diafunc.js\"\n },\n \"homepage\": \"https://diafunc.com\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://gitlab.com/diafunc/cli.git\"\n },\n \"bugs\": {\n \"url\": \"https://gitlab.com/diafunc/cli/-/issues\"\n },\n \"author\": \"Markus Pollak <markus.pollak@diafunc.com>\",\n \"scripts\": {\n \"build\": \"tsup && node -e \\\"const fs=require('fs');const f='dist/bin/diafunc.js';fs.writeFileSync(f,'#!/usr/bin/env node\\\\n'+fs.readFileSync(f,'utf8'))\\\"\",\n \"dev\": \"tsup --watch\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"lint\": \"tsc --noEmit\",\n \"start\": \"node dist/bin/diafunc.js\",\n \"prepublishOnly\": \"npm run lint && npm test && npm run build\"\n },\n \"files\": [\n \"dist\",\n \"LICENSE\",\n \"README.md\"\n ],\n \"keywords\": [\n \"diafunc\",\n \"cli\",\n \"data-science\",\n \"symbolic-regression\"\n ],\n \"license\": \"Apache-2.0\",\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"dependencies\": {\n \"@inquirer/prompts\": \"^7.0.0\",\n \"chalk\": \"^5.4.0\",\n \"cli-table3\": \"^0.6.5\",\n \"commander\": \"^12.1.0\",\n \"ora\": \"^8.1.0\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^22.0.0\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.6.0\",\n \"vitest\": \"^2.1.0\"\n }\n}\n"],"mappings":";AAAA;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,KAAO;AAAA,IACL,SAAW;AAAA,EACb;AAAA,EACA,UAAY;AAAA,EACZ,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,EACT;AAAA,EACA,MAAQ;AAAA,IACN,KAAO;AAAA,EACT;AAAA,EACA,QAAU;AAAA,EACV,SAAW;AAAA,IACT,OAAS;AAAA,IACT,KAAO;AAAA,IACP,MAAQ;AAAA,IACR,cAAc;AAAA,IACd,MAAQ;AAAA,IACR,OAAS;AAAA,IACT,gBAAkB;AAAA,EACpB;AAAA,EACA,OAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,SAAW;AAAA,EACX,eAAiB;AAAA,IACf,QAAU;AAAA,IACV,UAAY;AAAA,EACd;AAAA,EACA,SAAW;AAAA,IACT,MAAQ;AAAA,EACV;AAAA,EACA,cAAgB;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAS;AAAA,IACT,cAAc;AAAA,IACd,WAAa;AAAA,IACb,KAAO;AAAA,EACT;AAAA,EACA,iBAAmB;AAAA,IACjB,eAAe;AAAA,IACf,MAAQ;AAAA,IACR,YAAc;AAAA,IACd,QAAU;AAAA,EACZ;AACF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "./chunk-KND3I4AN.js";
3
+ } from "./chunk-DOVJKPLM.js";
4
4
 
5
5
  // src/index.ts
6
6
  import chalk37 from "chalk";
@@ -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",
@@ -3566,7 +3578,7 @@ Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
3566
3578
  handleError(error);
3567
3579
  }
3568
3580
  });
3569
- project.command("update").description("Update a project").argument("<projectId>", "Project ID").option("--visibility <visibility>", "PRIVATE or PUBLIC").option("--language <language>", "Project language").option("--active <bool>", "Whether the project is active (true/false)").action(async (projectId, options) => {
3581
+ project.command("update").description("Update a project").argument("<projectId>", "Project ID").option("--visibility <visibility>", "PRIVATE or PUBLIC").option("--language <language>", "Project language").option("--active <bool>", "Whether the project is active (true/false)").option("--licence <licenceId>", "Licence a public project is published under, an id of the licence catalogue (CC-BY-4.0, CC0-1.0, diafunc-view-only, ...)").option("--data-source-name <name>", "Who published the data the project analyses; an empty value clears it").option("--data-source-url <url>", "Where the data was obtained, an http(s) address; an empty value clears it").action(async (projectId, options) => {
3570
3582
  try {
3571
3583
  const api = createApiClient();
3572
3584
  const current = await api.admin.getProject(projectId);
@@ -3574,7 +3586,10 @@ Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
3574
3586
  ...current,
3575
3587
  ...options.visibility ? { visibility: options.visibility.toUpperCase() } : {},
3576
3588
  ...options.language ? { language: options.language } : {},
3577
- ...options.active !== void 0 ? { active: options.active === "true" } : {}
3589
+ ...options.active !== void 0 ? { active: options.active === "true" } : {},
3590
+ ...options.licence ? { licenceId: options.licence } : {},
3591
+ ...options.dataSourceName !== void 0 ? { dataSourceName: options.dataSourceName } : {},
3592
+ ...options.dataSourceUrl !== void 0 ? { dataSourceUrl: options.dataSourceUrl } : {}
3578
3593
  };
3579
3594
  await api.admin.updateProject(updated);
3580
3595
  success(`Project "${projectId}" updated.`);
@@ -6315,7 +6330,7 @@ var HELP = [
6315
6330
  ];
6316
6331
  async function runChatRepl(options) {
6317
6332
  const { input: promptInput } = await import("@inquirer/prompts");
6318
- const { getUpdateNotice } = await import("./update-check-PBX3DE56.js");
6333
+ const { getUpdateNotice } = await import("./update-check-F2A6LMK6.js");
6319
6334
  let sessionId = options.session;
6320
6335
  let lastReportedSession;
6321
6336
  console.log(chalk19.bold("Diafunc chat") + chalk19.dim(" \xB7 /help for commands, /quit to exit"));
@@ -9023,28 +9038,55 @@ async function deletePreset(presetId) {
9023
9038
  await api.analysis.deletePreset(presetId);
9024
9039
  success(`Deleted preset ${presetId}.`);
9025
9040
  }
9026
- async function listTriggers(analysisId, cmd) {
9027
- const outputFormat = getOutputFormat15(cmd);
9028
- const api = createApiClient();
9029
- const triggers = await api.analysis.listTriggers(analysisId);
9030
- format(triggers.map((t) => ({
9041
+ function triggerRow(t) {
9042
+ return {
9031
9043
  triggerId: t.triggerId,
9032
9044
  kind: t.kind,
9033
9045
  schedule: t.scheduleSpec,
9034
9046
  active: t.active,
9035
- nextFireAt: t.nextFireAt
9036
- })), {
9047
+ refreshFirst: t.refreshFirst === true,
9048
+ nextFireAt: t.nextFireAt,
9049
+ lastOutcome: t.lastOutcome ?? ""
9050
+ };
9051
+ }
9052
+ function triggerChanges(options) {
9053
+ const flag = (name, value) => {
9054
+ if (value === void 0) return void 0;
9055
+ const lc = value.toLowerCase();
9056
+ if (lc !== "true" && lc !== "false") {
9057
+ throw new CliError(`Invalid --${name} value "${value}". Use true or false.`);
9058
+ }
9059
+ return lc === "true";
9060
+ };
9061
+ const active = flag("active", options.active);
9062
+ const refreshFirst = flag("refresh-first", options.refreshFirst);
9063
+ if (active === void 0 && !options.schedule && refreshFirst === void 0) {
9064
+ throw new CliError("Pass at least one of --active, --schedule or --refresh-first.");
9065
+ }
9066
+ return {
9067
+ active: active ?? null,
9068
+ scheduleSpec: options.schedule ?? null,
9069
+ ...refreshFirst === void 0 ? {} : { refreshFirst }
9070
+ };
9071
+ }
9072
+ async function listTriggers(analysisId, cmd) {
9073
+ const outputFormat = getOutputFormat15(cmd);
9074
+ const api = createApiClient();
9075
+ const triggers = await api.analysis.listTriggers(analysisId);
9076
+ format(triggers.map(triggerRow), {
9037
9077
  format: outputFormat,
9038
9078
  columns: [
9039
9079
  { key: "triggerId", kind: "id" },
9040
9080
  "kind",
9041
9081
  "schedule",
9042
9082
  { key: "active", kind: "boolean" },
9043
- { key: "nextFireAt", header: "next fire", kind: "date" }
9083
+ { key: "refreshFirst", header: "refresh first", kind: "boolean" },
9084
+ { key: "nextFireAt", header: "next fire", kind: "date" },
9085
+ { key: "lastOutcome", header: "last outcome" }
9044
9086
  ]
9045
9087
  });
9046
9088
  }
9047
- async function createTrigger(analysisId, kind, schedule, cmd) {
9089
+ async function createTrigger(analysisId, kind, schedule, cmd, refreshFirst = false) {
9048
9090
  const outputFormat = getOutputFormat15(cmd);
9049
9091
  const upper = kind.toUpperCase();
9050
9092
  if (upper !== "ONCE" && upper !== "CRON") {
@@ -9054,7 +9096,8 @@ async function createTrigger(analysisId, kind, schedule, cmd) {
9054
9096
  const api = createApiClient();
9055
9097
  const trigger = await api.analysis.createTrigger(analysisId, {
9056
9098
  kind: upper,
9057
- scheduleSpec: schedule
9099
+ scheduleSpec: schedule,
9100
+ ...refreshFirst ? { refreshFirst: true } : {}
9058
9101
  });
9059
9102
  format(trigger, { format: outputFormat });
9060
9103
  }
@@ -9065,24 +9108,9 @@ async function deleteTrigger(triggerId) {
9065
9108
  }
9066
9109
  async function updateTriggerCmd(triggerId, options, cmd) {
9067
9110
  const outputFormat = getOutputFormat15(cmd);
9068
- let activeFlag;
9069
- if (options.active !== void 0) {
9070
- const lc = options.active.toLowerCase();
9071
- if (lc !== "true" && lc !== "false") {
9072
- failure(`Invalid --active value "${options.active}". Use true or false.`);
9073
- process.exit(EXIT_FAILURE);
9074
- }
9075
- activeFlag = lc === "true";
9076
- }
9077
- if (activeFlag === void 0 && !options.schedule) {
9078
- failure("Pass at least one of --active or --schedule.");
9079
- process.exit(EXIT_FAILURE);
9080
- }
9111
+ const changes = triggerChanges(options);
9081
9112
  const api = createApiClient();
9082
- const trigger = await api.analysis.updateTrigger(triggerId, {
9083
- active: activeFlag ?? null,
9084
- scheduleSpec: options.schedule ?? null
9085
- });
9113
+ const trigger = await api.analysis.updateTrigger(triggerId, changes);
9086
9114
  format(trigger, { format: outputFormat });
9087
9115
  }
9088
9116
  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";
@@ -9370,9 +9398,9 @@ function registerAnalyzeCommand(program) {
9370
9398
  handleError(error);
9371
9399
  }
9372
9400
  });
9373
- 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) => {
9401
+ 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) => {
9374
9402
  try {
9375
- await createTrigger(analysisId, options.kind, options.schedule, cmd);
9403
+ await createTrigger(analysisId, options.kind, options.schedule, cmd, options.refreshFirst === true);
9376
9404
  } catch (error) {
9377
9405
  handleError(error);
9378
9406
  }
@@ -9385,7 +9413,7 @@ function registerAnalyzeCommand(program) {
9385
9413
  handleError(error);
9386
9414
  }
9387
9415
  });
9388
- triggers.command("update").description("Update a trigger: pause or resume it (--active), reschedule it (--schedule), or both").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)").action(async (triggerId, options, cmd) => {
9416
+ 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) => {
9389
9417
  try {
9390
9418
  await updateTriggerCmd(triggerId, options, cmd);
9391
9419
  } catch (error) {
@@ -9588,7 +9616,7 @@ function dataSourceTableRow(ds) {
9588
9616
  id: ds.id,
9589
9617
  name: ds.name,
9590
9618
  type: ds.type,
9591
- target: `${ds.targetEntityId}@${ds.targetEntityBranch}`,
9619
+ target: ds.analysisId ? `analysis ${ds.analysisId}` : `${ds.targetEntityId}@${ds.targetEntityBranch}`,
9592
9620
  schedule: ds.scheduleCron ?? "manual",
9593
9621
  lastStatus: ds.lastRunStatus ?? "\u2014",
9594
9622
  lastRefreshAt: ds.lastRefreshAt ?? "\u2014"
@@ -9718,9 +9746,62 @@ async function showDashboard(projectId, cmd) {
9718
9746
  ]
9719
9747
  });
9720
9748
  }
9749
+ var TABLE_TARGET_FLAGS = [
9750
+ ["projectId", "--project-id"],
9751
+ ["projectBranch", "--project-branch"],
9752
+ ["targetEntityId", "--target-entity-id"],
9753
+ ["targetEntityBranch", "--target-entity-branch"]
9754
+ ];
9755
+ function createTarget(options) {
9756
+ const given = TABLE_TARGET_FLAGS.filter(([key]) => options[key] !== void 0).map(([, flag]) => flag);
9757
+ if (options.analysis !== void 0) {
9758
+ if (given.length > 0) {
9759
+ throw new CliError(
9760
+ `--analysis cannot be combined with ${given.join(", ")}.`,
9761
+ { exitCode: EXIT_USAGE, hint: "A data source feeds an analysis or overwrites a table, not both." }
9762
+ );
9763
+ }
9764
+ return "analysis";
9765
+ }
9766
+ const missing = TABLE_TARGET_FLAGS.filter(([key]) => options[key] === void 0).map(([, flag]) => flag);
9767
+ if (missing.length > 0) {
9768
+ throw new CliError(
9769
+ `Say what the data source refreshes: --analysis <analysisId>, or a table with ${missing.join(", ")}.`,
9770
+ { exitCode: EXIT_USAGE }
9771
+ );
9772
+ }
9773
+ return "table";
9774
+ }
9775
+ async function createForAnalysis(api, options, human) {
9776
+ const analysisId = options.analysis;
9777
+ const source = await api.analysis.attachDataSource(analysisId, {
9778
+ name: options.name,
9779
+ type: options.type,
9780
+ config: parseConfigPairs(options.config),
9781
+ scheduleCron: options.scheduleCron ?? null
9782
+ });
9783
+ const plan = await api.analysis.planSources(analysisId, null);
9784
+ const build = await api.analysis.buildSources(analysisId, plan.recipe);
9785
+ if (human) {
9786
+ success(`Added ${source.fileName} to analysis ${analysisId} from data source ${source.dataSourceId ?? ""}`.trimEnd());
9787
+ for (const line of planLines(build.plan)) {
9788
+ console.log(line.caution ? chalk27.yellow(` ${line.text}`) : chalk27.dim(` ${line.text}`));
9789
+ }
9790
+ 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`)."));
9791
+ }
9792
+ return { source, build };
9793
+ }
9721
9794
  async function createDataSource(options, cmd) {
9722
9795
  const outputFormat = getOutputFormat17(cmd);
9796
+ const target = createTarget(options);
9723
9797
  const api = createApiClient();
9798
+ if (target === "analysis") {
9799
+ const created = await createForAnalysis(api, options, outputFormat === "human");
9800
+ if (outputFormat !== "human") {
9801
+ format(created, { format: outputFormat });
9802
+ }
9803
+ return;
9804
+ }
9724
9805
  const request = {
9725
9806
  projectId: options.projectId,
9726
9807
  projectBranch: options.projectBranch,
@@ -9855,7 +9936,7 @@ Examples:
9855
9936
  handleError(error);
9856
9937
  }
9857
9938
  });
9858
- dataSources.command("create").description("Create a data source (runs the initial fetch synchronously)").requiredOption("--project-id <id>", "Project ID").requiredOption("--project-branch <branch>", 'Project branch (usually "main")').requiredOption("--target-entity-id <id>", "Target table entity ID").requiredOption("--target-entity-branch <branch>", "Target table entity branch").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) => {
9939
+ 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) => {
9859
9940
  try {
9860
9941
  await createDataSource(options, cmd);
9861
9942
  } catch (error) {
@@ -10808,7 +10889,7 @@ function registerShellCommand(program) {
10808
10889
  });
10809
10890
  const api = createApiClient();
10810
10891
  const { input: promptInput } = await import("@inquirer/prompts");
10811
- const { getUpdateNotice } = await import("./update-check-PBX3DE56.js");
10892
+ const { getUpdateNotice } = await import("./update-check-F2A6LMK6.js");
10812
10893
  const resolvedLanguage = await resolveLanguage(api, fnRef.projectId, options.language);
10813
10894
  console.log(chalk32.bold("Diafunc shell") + chalk32.dim(` \xB7 function ${fnRef.entityId} \xB7 ${resolvedLanguage}`));
10814
10895
  console.log(chalk32.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
@@ -11858,4 +11939,4 @@ export {
11858
11939
  PromptCancelled,
11859
11940
  createProgram
11860
11941
  };
11861
- //# sourceMappingURL=chunk-DXZN6YJJ.js.map
11942
+ //# sourceMappingURL=chunk-RJM7OBRF.js.map