@diafunc/cli 0.26.0 → 0.27.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.
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  package_default
3
- } from "./chunk-EJ2LNAYV.js";
3
+ } from "./chunk-GNSV63PW.js";
4
4
 
5
5
  // src/index.ts
6
- import chalk39 from "chalk";
6
+ import chalk40 from "chalk";
7
7
 
8
8
  // src/commands/auth/login.ts
9
9
  import chalk4 from "chalk";
@@ -258,19 +258,31 @@ function resolveEndpoint(config, profileOverride) {
258
258
  import chalk from "chalk";
259
259
 
260
260
  // src/client/errors.ts
261
+ var LICENCE_REFUSALS = {
262
+ licence_required: "A public project needs a licence. Name one with --licence <id>.",
263
+ licence_not_selectable: "That licence cannot be chosen: it is not in the catalogue, or it is deprecated or withdrawn.",
264
+ licence_share_alike_mismatch: "This project is a fork of a share-alike project, so it has to carry the licence of the project it was forked from.",
265
+ licence_forbids_fork: "The licence of this project does not allow adaptations, so it cannot be forked."
266
+ };
267
+ var LICENCE_LIST_REFUSALS = /* @__PURE__ */ new Set(["licence_required", "licence_not_selectable"]);
261
268
  var ApiError = class _ApiError extends Error {
262
269
  status;
263
270
  details;
264
- constructor(status, message, details) {
271
+ /** The platform's stable error code, when the body carried one. */
272
+ code;
273
+ constructor(status, message, details, code) {
265
274
  super(message);
266
275
  this.name = "ApiError";
267
276
  this.status = status;
268
277
  this.details = details;
278
+ this.code = code;
269
279
  }
270
280
  static fromBody(status, body) {
271
- return new _ApiError(status, body.message, body.details);
281
+ return new _ApiError(status, body.message, body.details, typeof body.error === "string" ? body.error : void 0);
272
282
  }
273
283
  toUserMessage() {
284
+ const refusal = this.code && Object.prototype.hasOwnProperty.call(LICENCE_REFUSALS, this.code) ? LICENCE_REFUSALS[this.code] : void 0;
285
+ if (refusal) return refusal;
274
286
  const detail2 = this.readableMessage();
275
287
  switch (this.status) {
276
288
  case 401:
@@ -736,6 +748,21 @@ function createAdminService(client) {
736
748
  path: `/projects/${encodeURIComponent(projectId)}`
737
749
  });
738
750
  },
751
+ // Licences: the catalogue answers anyone, signed in or not.
752
+ async listLicences() {
753
+ return client.request({
754
+ method: "GET",
755
+ service: SERVICE,
756
+ path: "/licences"
757
+ });
758
+ },
759
+ async getLicence(licenceId) {
760
+ return client.request({
761
+ method: "GET",
762
+ service: SERVICE,
763
+ path: `/licences/${encodeURIComponent(licenceId)}`
764
+ });
765
+ },
739
766
  async createProject(request) {
740
767
  return client.request({
741
768
  method: "POST",
@@ -1213,6 +1240,7 @@ function handleError(error) {
1213
1240
  failure(error.toUserMessage());
1214
1241
  if (error.status === 401 && !(error instanceof SignInRefusedError)) hint(`Run 'diafunc auth login' to sign in.`);
1215
1242
  if (error.status === 404) hint(`Check the id, or list what exists with the matching 'list' command.`);
1243
+ if (error.code && LICENCE_LIST_REFUSALS.has(error.code)) hint(`List the licences that can be chosen with 'diafunc licence list'.`);
1216
1244
  process.exit(error.status === 401 || error.status === 403 ? EXIT_AUTH : EXIT_FAILURE);
1217
1245
  }
1218
1246
  if (error instanceof NetworkError) {
@@ -4176,14 +4204,20 @@ Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
4176
4204
  handleError(error);
4177
4205
  }
4178
4206
  });
4179
- project.command("create").description("Create a new project").option("--visibility <visibility>", "Project visibility (PRIVATE or PUBLIC)", "PRIVATE").option("--language <language>", "The project's default language for functions (Java, Kotlin, Python, JavaScript, Scala)", DEFAULT_FUNCTION_LANGUAGE).action(async (options, cmd) => {
4207
+ project.command("create").description("Create a new project").option("--visibility <visibility>", "Project visibility (PRIVATE or PUBLIC)", "PRIVATE").option("--language <language>", "The project's default language for functions (Java, Kotlin, Python, JavaScript, Scala)", DEFAULT_FUNCTION_LANGUAGE).option("--licence <licenceId>", "Licence a public project is published under, an id of the licence catalogue (see 'diafunc licence list')").addHelpText("after", `
4208
+ Examples:
4209
+ $ diafunc project create a private project
4210
+ $ diafunc project create --visibility PUBLIC --licence CC-BY-4.0 a public one, open for reuse with attribution
4211
+ $ diafunc licence list the licences that can be chosen
4212
+ `).action(async (options, cmd) => {
4180
4213
  try {
4181
4214
  const outputFormat = getOutputFormat2(cmd);
4182
4215
  const api = createApiClient();
4183
4216
  const p = await api.admin.createProject({
4184
4217
  visibility: options.visibility.toUpperCase(),
4185
4218
  language: options.language,
4186
- active: true
4219
+ active: true,
4220
+ ...options.licence ? { licenceId: options.licence } : {}
4187
4221
  });
4188
4222
  await api.storage.createProjectBranch({
4189
4223
  projectId: p.projectId,
@@ -4195,6 +4229,7 @@ Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
4195
4229
  console.log(` Project ID: ${chalk13.bold(p.projectId)}`);
4196
4230
  console.log(` Visibility: ${p.visibility}`);
4197
4231
  console.log(` Language: ${p.language}`);
4232
+ if (p.licenceId) console.log(` Licence: ${p.licenceId}`);
4198
4233
  } else {
4199
4234
  format(p, { format: outputFormat });
4200
4235
  }
@@ -6180,6 +6215,14 @@ function buildFunctionEntity(args) {
6180
6215
  content: encodeFunctionSource(args.sourceCode)
6181
6216
  };
6182
6217
  }
6218
+ function resultText(result, resultEncoding) {
6219
+ if (result === null || result === void 0) return null;
6220
+ if (resultEncoding === "json") return typeof result === "string" ? result : JSON.stringify(result);
6221
+ if (resultEncoding === "text") return String(result);
6222
+ const bytes = Buffer.from(String(result), "base64");
6223
+ const text2 = bytes.toString("utf-8");
6224
+ return Buffer.from(text2, "utf-8").equals(bytes) ? text2 : String(result);
6225
+ }
6183
6226
 
6184
6227
  // src/commands/function/index.ts
6185
6228
  function getOutputFormat10(cmd) {
@@ -6265,7 +6308,7 @@ Examples:
6265
6308
  if (result.successful) {
6266
6309
  success("Function completed successfully.");
6267
6310
  if (result.result) {
6268
- console.log(` Result: ${result.result}`);
6311
+ console.log(` Result: ${resultText(result.result, result.resultEncoding)}`);
6269
6312
  }
6270
6313
  const duration = result.completed - result.started;
6271
6314
  console.log(` Duration: ${duration}ms`);
@@ -6957,7 +7000,7 @@ var HELP = [
6957
7000
  ];
6958
7001
  async function runChatRepl(options) {
6959
7002
  const { input: promptInput } = await import("@inquirer/prompts");
6960
- const { getUpdateNotice } = await import("./update-check-4345HWGE.js");
7003
+ const { getUpdateNotice } = await import("./update-check-YRTWCRNY.js");
6961
7004
  let sessionId = options.session;
6962
7005
  let lastReportedSession;
6963
7006
  console.log(chalk20.bold("Diafunc chat") + chalk20.dim(" \xB7 /help for commands, /quit to exit"));
@@ -8260,7 +8303,7 @@ function depthOf(hours, budget) {
8260
8303
  const b = budget?.trim();
8261
8304
  return h && b ? { hours: h, budget: b } : null;
8262
8305
  }
8263
- async function promptCreationFields(prompter, supplied, fallbackName) {
8306
+ async function promptCreationFields(prompter, supplied, fallbackName, licences) {
8264
8307
  const name = supplied.name ?? await prompter.input({
8265
8308
  message: "Analysis name",
8266
8309
  default: fallbackName,
@@ -8277,7 +8320,31 @@ async function promptCreationFields(prompter, supplied, fallbackName) {
8277
8320
  { name: "Public", value: "PUBLIC", description: "Anyone with the link can read the notebook." }
8278
8321
  ]
8279
8322
  });
8280
- return { name: name.trim(), description: description.trim() || null, visibility };
8323
+ const answers = { name: name.trim(), description: description.trim() || null, visibility };
8324
+ const licenceId = supplied.licenceId ?? (visibility === "PUBLIC" && licences ? await promptLicence(prompter, await licences()) : void 0);
8325
+ if (licenceId) answers.licenceId = licenceId;
8326
+ return answers;
8327
+ }
8328
+ var ALL_LICENCES = ":all";
8329
+ async function promptLicence(prompter, catalogue) {
8330
+ const selectable = catalogue.filter((l) => l.state === "ACTIVE");
8331
+ if (selectable.length === 0) return void 0;
8332
+ const choice = (l) => ({ name: `${l.name} (${l.licenceId})`, value: l.licenceId, description: l.summary ?? void 0 });
8333
+ const recommended = selectable.filter((l) => l.recommended);
8334
+ const others = selectable.filter((l) => !l.recommended);
8335
+ if (recommended.length === 0 || others.length === 0) {
8336
+ return prompter.select({ message: "Licence", default: selectable[0].licenceId, choices: selectable.map(choice) });
8337
+ }
8338
+ const picked = await prompter.select({
8339
+ message: "Licence",
8340
+ default: recommended[0].licenceId,
8341
+ choices: [
8342
+ ...recommended.map(choice),
8343
+ { name: "Another licence\u2026", value: ALL_LICENCES, description: `${others.length} more in the catalogue.` }
8344
+ ]
8345
+ });
8346
+ if (picked !== ALL_LICENCES) return picked;
8347
+ return prompter.select({ message: "Licence (all)", default: others[0].licenceId, choices: selectable.map(choice) });
8281
8348
  }
8282
8349
  function matchDepthPreset(hours, budget) {
8283
8350
  if (!hours || !budget) return null;
@@ -8314,7 +8381,7 @@ async function promptRunFields(prompter, options) {
8314
8381
  });
8315
8382
  if (preset) {
8316
8383
  supplied = {
8317
- targets: preset.targetKeys.length > 0 ? preset.targetKeys : void 0,
8384
+ targets: preset.targets.length > 0 ? preset.targets : void 0,
8318
8385
  questions: preset.questions.length > 0 ? preset.questions : void 0,
8319
8386
  segment: preset.segmentKey ?? void 0,
8320
8387
  hours: preset.time || void 0,
@@ -8429,16 +8496,17 @@ function describePreset(preset) {
8429
8496
  const parts = [];
8430
8497
  if (preset.time) parts.push(`${preset.time}h`);
8431
8498
  if (preset.budget) parts.push(`${preset.budget} credits`);
8432
- if (preset.targetKeys.length > 0) parts.push(`targets: ${preset.targetKeys.join(", ")}`);
8499
+ if (preset.targets.length > 0) parts.push(`targets: ${preset.targets.join(", ")}`);
8433
8500
  if (preset.segmentKey) parts.push(`segmented by ${preset.segmentKey}`);
8434
8501
  return parts.join(" \xB7 ");
8435
8502
  }
8436
8503
  function summaryLines(creation, run) {
8437
8504
  const lines = [
8438
8505
  `Name: ${creation.name}`,
8439
- `Visibility: ${creation.visibility === "PUBLIC" ? "Public" : "Private"}`,
8440
- `Targets: ${run.targets.join(", ")}`
8506
+ `Visibility: ${creation.visibility === "PUBLIC" ? "Public" : "Private"}`
8441
8507
  ];
8508
+ if (creation.licenceId) lines.push(`Licence: ${creation.licenceId}`);
8509
+ lines.push(`Targets: ${run.targets.join(", ")}`);
8442
8510
  if (run.segment) lines.push(`Segment: ${run.segment}`);
8443
8511
  if (run.questions && run.questions.length > 0) {
8444
8512
  lines.push(`Questions: ${run.questions.length}`);
@@ -8550,6 +8618,7 @@ function analysisDetails(analysis, endpoint) {
8550
8618
  name: analysis.name,
8551
8619
  description: analysis.description,
8552
8620
  visibility: sentenceCase(analysis.visibility),
8621
+ licence: licenceText(analysis),
8553
8622
  introduction: analysis.introduction,
8554
8623
  data: dataShape(analysis.rowCount, analysis.columnCount),
8555
8624
  dataImport: analysis.dataImport?.message ?? null,
@@ -8567,7 +8636,7 @@ function analysisDetails(analysis, endpoint) {
8567
8636
  latestRunState: isImporting(analysis.dataImport) ? importingLabel(analysis.dataImport) : analysis.latestRunState ? sentenceCase(analysis.latestRunState) : null,
8568
8637
  latestRunId: analysis.latestRunId,
8569
8638
  quality: qualityText(analysis),
8570
- outputs: outputsText(analysis),
8639
+ targetResults: targetResultsText(analysis),
8571
8640
  resultRunId: analysis.resultRunId,
8572
8641
  creditsUsed: creditsText(analysis.creditsUsed),
8573
8642
  notebook: analysis.labUrl ? `${endpoint}${analysis.labUrl}` : null,
@@ -8581,13 +8650,14 @@ function analysisDetails(analysis, endpoint) {
8581
8650
  { key: "name", header: "Name" },
8582
8651
  { key: "description", header: "Description" },
8583
8652
  { key: "visibility", header: "Visibility" },
8653
+ { key: "licence", header: "Licence" },
8584
8654
  { key: "introduction", header: "Introduction" },
8585
8655
  { key: "data", header: "Data" },
8586
8656
  { key: "dataImport", header: "Data import" },
8587
8657
  { key: "targets", header: "Targets" },
8588
8658
  { key: "targetKinds", header: "Target kinds" },
8589
- { key: "inputExclusions", header: "Excluded columns" },
8590
- { key: "confirmedInputs", header: "Known before the outcome" },
8659
+ { key: "inputExclusions", header: "Columns left out of the fit" },
8660
+ { key: "confirmedInputs", header: "Known before the target" },
8591
8661
  { key: "questions", header: "Questions" },
8592
8662
  { key: "segment", header: "Segment" },
8593
8663
  { key: "hours", header: "Time limit" },
@@ -8597,7 +8667,7 @@ function analysisDetails(analysis, endpoint) {
8597
8667
  { key: "latestRunState", header: "Latest run", kind: "state" },
8598
8668
  { key: "latestRunId", header: "Latest run ID", kind: "id" },
8599
8669
  { key: "quality", header: "Quality" },
8600
- { key: "outputs", header: "Outputs" },
8670
+ { key: "targetResults", header: "Target results" },
8601
8671
  { key: "resultRunId", header: "Result from run", kind: "id" },
8602
8672
  { key: "creditsUsed", header: "Credits used" },
8603
8673
  { key: "notebook", header: "Notebook" },
@@ -8608,6 +8678,10 @@ function analysisDetails(analysis, endpoint) {
8608
8678
  ];
8609
8679
  return { data, columns };
8610
8680
  }
8681
+ function licenceText(analysis) {
8682
+ if (analysis.licenceId) return analysis.licenceId;
8683
+ return analysis.visibility === "PUBLIC" ? "none chosen" : null;
8684
+ }
8611
8685
  function sentenceCase(token) {
8612
8686
  const words = token.toLowerCase().replace(/_/g, " ");
8613
8687
  return words.charAt(0).toUpperCase() + words.slice(1);
@@ -8636,14 +8710,14 @@ function qualityText(analysis) {
8636
8710
  if (analysis.resultRunQuality != null) return `${qualityPercent(analysis.resultRunQuality)} on the training rows`;
8637
8711
  return null;
8638
8712
  }
8639
- function outputsText(analysis) {
8640
- const outputs = analysis.outputs ?? [];
8641
- if (outputs.length === 0) return null;
8642
- const lines = outputs.map((o) => {
8643
- const name = o.title ?? o.target ?? "output";
8644
- return o.quality != null ? `${name}: ${qualityPercent(o.quality)}` : name;
8713
+ function targetResultsText(analysis) {
8714
+ const results = analysis.targetResults ?? [];
8715
+ if (results.length === 0) return null;
8716
+ const lines = results.map((r) => {
8717
+ const name = r.title ?? r.target ?? "target";
8718
+ return r.quality != null ? `${name}: ${qualityPercent(r.quality)}` : name;
8645
8719
  });
8646
- const more = (analysis.outputCount ?? outputs.length) - outputs.length;
8720
+ const more = (analysis.targetResultCount ?? results.length) - results.length;
8647
8721
  if (more > 0) lines.push(`and ${formatNumber(more)} more`);
8648
8722
  return lines.join("\n");
8649
8723
  }
@@ -9089,7 +9163,7 @@ async function runAnalysis(files, options, cmd) {
9089
9163
  process.exit(EXIT_FAILURE);
9090
9164
  }
9091
9165
  const p = opt.preset;
9092
- if (options.targets === void 0 && p.targetKeys.length > 0) presetTargets = p.targetKeys;
9166
+ if (options.targets === void 0 && p.targets.length > 0) presetTargets = p.targets;
9093
9167
  if (options.question === void 0 && p.questions.length > 0) options.question = [...p.questions];
9094
9168
  if (options.segment === void 0 && p.segmentKey) options.segment = p.segmentKey;
9095
9169
  if (options.hours === void 0 && p.time?.trim()) options.hours = p.time;
@@ -9108,11 +9182,13 @@ async function runAnalysis(files, options, cmd) {
9108
9182
  const creation = interactive ? await promptCreationFields(prompter, {
9109
9183
  name: options.name,
9110
9184
  description: options.description,
9111
- visibility: options.visibility === void 0 ? void 0 : parseVisibility(options.visibility)
9112
- }, fallbackName) : {
9185
+ visibility: options.visibility === void 0 ? void 0 : parseVisibility(options.visibility),
9186
+ licenceId: options.licence
9187
+ }, fallbackName, () => api.admin.listLicences()) : {
9113
9188
  name: options.name ?? fallbackName,
9114
9189
  description: options.description?.trim() || null,
9115
- visibility: options.visibility === void 0 ? "PRIVATE" : parseVisibility(options.visibility)
9190
+ visibility: options.visibility === void 0 ? "PRIVATE" : parseVisibility(options.visibility),
9191
+ licenceId: options.licence
9116
9192
  };
9117
9193
  const request = {
9118
9194
  name: creation.name,
@@ -9126,7 +9202,10 @@ async function runAnalysis(files, options, cmd) {
9126
9202
  questions: questionsOf(options.question),
9127
9203
  segment: null
9128
9204
  };
9129
- const created = await withStatus(`Creating analysis "${creation.name}"`, () => api.analysis.create(request));
9205
+ const created = await withStatus(`Creating analysis "${creation.name}"`, () => api.analysis.create({
9206
+ ...request,
9207
+ ...creation.licenceId ? { licenceId: creation.licenceId } : {}
9208
+ }));
9130
9209
  if (isDryRun()) {
9131
9210
  hint(`Dry run: nothing was created. A real run would upload ${path9.basename(file)}, queue the analysis and follow it.`);
9132
9211
  return;
@@ -9162,7 +9241,7 @@ async function runAnalysis(files, options, cmd) {
9162
9241
  questions: options.question === void 0 ? void 0 : questionsOf(options.question),
9163
9242
  hours: options.hours,
9164
9243
  budget: options.budget
9165
- }, columns);
9244
+ }, columns, creation.licenceId);
9166
9245
  if (configuredHours === null) return;
9167
9246
  runHours = configuredHours;
9168
9247
  } else {
@@ -9201,7 +9280,7 @@ function namedColumns(analysisId, columns, interactive, given) {
9201
9280
  const segment = given.segment === void 0 || given.segment === "" ? void 0 : read(() => resolveColumnArgument(given.segment, names, analysisId));
9202
9281
  return { targets, segment };
9203
9282
  }
9204
- async function configureInteractively(api, prompter, analysisId, recipe, supplied, knownColumns) {
9283
+ async function configureInteractively(api, prompter, analysisId, recipe, supplied, knownColumns, licenceId) {
9205
9284
  const columns = knownColumns ?? await readColumns(api, analysisId);
9206
9285
  const presets = await readPresets(api);
9207
9286
  const depthAsked = supplied.hours === void 0 || supplied.budget === void 0;
@@ -9222,7 +9301,8 @@ async function configureInteractively(api, prompter, analysisId, recipe, supplie
9222
9301
  const identity = {
9223
9302
  name: recipe.name,
9224
9303
  description: recipe.description ?? null,
9225
- visibility: recipe.visibility ?? "PRIVATE"
9304
+ visibility: recipe.visibility ?? "PRIVATE",
9305
+ ...licenceId ? { licenceId } : {}
9226
9306
  };
9227
9307
  const depth = depthOf(saved?.hours, saved?.budget) ?? { hours: answers.hours, budget: answers.budget };
9228
9308
  for (const line of summaryLines(identity, { ...answers, ...depth })) detail(line);
@@ -9561,7 +9641,10 @@ async function createAnalysis(options, cmd) {
9561
9641
  questions: questionsOf(options.question),
9562
9642
  segment: options.segment ?? null
9563
9643
  };
9564
- const created = await api.analysis.create(request);
9644
+ const created = await api.analysis.create({
9645
+ ...request,
9646
+ ...options.licence ? { licenceId: options.licence } : {}
9647
+ });
9565
9648
  if (isDryRun()) {
9566
9649
  hint("Dry run: nothing was created.");
9567
9650
  return;
@@ -9757,7 +9840,7 @@ async function listPresets(cmd) {
9757
9840
  format(presets.map((p) => ({
9758
9841
  presetId: p.presetId,
9759
9842
  name: p.name,
9760
- targets: p.targetKeys.join(", "),
9843
+ targets: p.targets.join(", "),
9761
9844
  questions: p.questions.length,
9762
9845
  segment: p.segmentKey,
9763
9846
  hours: p.time,
@@ -9791,7 +9874,7 @@ async function savePreset(options, cmd) {
9791
9874
  const preset = {
9792
9875
  presetId: options.id ?? null,
9793
9876
  name: options.name,
9794
- targetKeys: typedColumns(options.targets) ?? [],
9877
+ targets: typedColumns(options.targets) ?? [],
9795
9878
  questions: questionsOf(options.question) ?? [],
9796
9879
  segmentKey: options.segment ?? null,
9797
9880
  time: options.hours,
@@ -9885,10 +9968,11 @@ async function updateTriggerCmd(triggerId, options, cmd) {
9885
9968
  format(trigger, { format: outputFormat });
9886
9969
  }
9887
9970
  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";
9971
+ var LICENCE_HELP = "With PUBLIC: the licence the analysis's project is published under, an id of the licence catalogue (see 'diafunc licence list')";
9888
9972
  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`;
9889
9973
  function registerAnalyzeCommand(program) {
9890
9974
  const analyze = program.command("analyze").description("Run and manage automatic analyses");
9891
- 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) => {
9975
+ 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("--licence <licenceId>", LICENCE_HELP).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) => {
9892
9976
  try {
9893
9977
  if (files.length === 0) {
9894
9978
  analyze.help();
@@ -9934,7 +10018,7 @@ function registerAnalyzeCommand(program) {
9934
10018
  reportCommandError(error);
9935
10019
  }
9936
10020
  });
9937
- 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) => {
10021
+ 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("--licence <licenceId>", LICENCE_HELP).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) => {
9938
10022
  try {
9939
10023
  await createAnalysis(options, cmd);
9940
10024
  } catch (error) {
@@ -9975,13 +10059,20 @@ function registerAnalyzeCommand(program) {
9975
10059
  handleError(error);
9976
10060
  }
9977
10061
  });
9978
- analyze.command("visibility").description("Set analysis visibility (PRIVATE or PUBLIC)").argument("<id>", "Analysis ID").argument("<vis>", "PRIVATE or PUBLIC").action(async (id, vis, _options, cmd) => {
10062
+ analyze.command("visibility").description("Set analysis visibility (PRIVATE or PUBLIC)").argument("<id>", "Analysis ID").argument("<vis>", "PRIVATE or PUBLIC").option("--licence <licenceId>", LICENCE_HELP).addHelpText("after", `
10063
+ Examples:
10064
+ $ diafunc analyze visibility <id> PUBLIC --licence CC-BY-4.0 publish under a licence
10065
+ $ diafunc analyze visibility <id> PRIVATE withdraw it; the licence is kept for later
10066
+ `).action(async (id, vis, options, cmd) => {
9979
10067
  try {
9980
10068
  const visibility = parseVisibility(vis);
9981
10069
  await patchAndPrint(
9982
10070
  id,
9983
10071
  visibility,
9984
- (api, aid, v) => api.analysis.patchVisibility(aid, { visibility: v }),
10072
+ (api, aid, v) => api.analysis.patchVisibility(aid, {
10073
+ visibility: v,
10074
+ ...options.licence ? { licenceId: options.licence } : {}
10075
+ }),
9985
10076
  "Visibility",
9986
10077
  cmd
9987
10078
  );
@@ -10054,13 +10145,13 @@ function registerAnalyzeCommand(program) {
10054
10145
  handleError(error);
10055
10146
  }
10056
10147
  });
10057
- analyze.command("confirmed-inputs").description("Set the columns the owner confirms as known before the outcome (a single empty string confirms nothing). A confirmed column raises no leakage concern.").argument("<id>", "Analysis ID").argument("<column...>", `Column names, ${COLUMN_LIST_HELP}`).action(async (id, given, _options, cmd) => {
10148
+ analyze.command("confirmed-inputs").description("Set the columns the owner confirms as known before the target (a single empty string confirms nothing). A confirmed column raises no leakage concern.").argument("<id>", "Analysis ID").argument("<column...>", `Column names, ${COLUMN_LIST_HELP}`).action(async (id, given, _options, cmd) => {
10058
10149
  try {
10059
10150
  await patchColumns(
10060
10151
  id,
10061
10152
  given,
10062
10153
  (api, columns) => api.analysis.patchConfirmedInputs(id, { columns }),
10063
- "Columns known before the outcome",
10154
+ "Columns known before the target",
10064
10155
  cmd
10065
10156
  );
10066
10157
  } catch (error) {
@@ -10271,7 +10362,8 @@ async function listPublicAnalyses(options, cmd) {
10271
10362
  { key: "analysisId", kind: "id" },
10272
10363
  { key: "projectId", kind: "id" },
10273
10364
  { key: "publishedAt", header: "published", kind: "date" },
10274
- { key: "changedAt", header: "changed", kind: "date" }
10365
+ { key: "changedAt", header: "changed", kind: "date" },
10366
+ { key: "licenceId", header: "licence" }
10275
10367
  ]
10276
10368
  });
10277
10369
  }
@@ -10358,13 +10450,140 @@ Examples:
10358
10450
  });
10359
10451
  }
10360
10452
 
10361
- // src/commands/data-sources/index.ts
10453
+ // src/commands/licence/index.ts
10362
10454
  import chalk29 from "chalk";
10363
10455
  function getOutputFormat19(cmd) {
10364
10456
  const config = loadConfig();
10365
10457
  const globalOpts = cmd.optsWithGlobals();
10366
10458
  return globalOpts.output ?? config.defaults.output ?? "human";
10367
10459
  }
10460
+ var LICENCE_MARKS = [
10461
+ { mark: "C", flag: "commercialUse", meaning: "commercial use" },
10462
+ { mark: "D", flag: "derivatives", meaning: "adaptations and forks" },
10463
+ { mark: "R", flag: "redistribution", meaning: "redistribution" },
10464
+ { mark: "BY", flag: "attributionRequired", meaning: "attribution required" },
10465
+ { mark: "SA", flag: "shareAlike", meaning: "share-alike" }
10466
+ ];
10467
+ function licenceMarks(licence) {
10468
+ const marks = LICENCE_MARKS.filter(({ flag }) => licence[flag] === true).map(({ mark }) => mark);
10469
+ return marks.length > 0 ? marks.join(" ") : null;
10470
+ }
10471
+ function stateWord(state) {
10472
+ return state.toLowerCase();
10473
+ }
10474
+ async function listLicences(cmd) {
10475
+ const outputFormat = getOutputFormat19(cmd);
10476
+ const api = createApiClient();
10477
+ const licences = await api.admin.listLicences();
10478
+ if (outputFormat === "json") {
10479
+ format(licences, { format: outputFormat });
10480
+ return;
10481
+ }
10482
+ if (licences.length === 0 && outputFormat === "human") {
10483
+ empty("licences");
10484
+ return;
10485
+ }
10486
+ format(licences.map((l) => ({
10487
+ licenceId: l.licenceId,
10488
+ name: l.name,
10489
+ state: stateWord(l.state),
10490
+ flags: licenceMarks(l),
10491
+ recommended: l.recommended
10492
+ })), {
10493
+ format: outputFormat,
10494
+ columns: [
10495
+ { key: "licenceId", header: "id" },
10496
+ { key: "name" },
10497
+ { key: "state", kind: "state" },
10498
+ { key: "flags" },
10499
+ { key: "recommended", kind: "boolean" }
10500
+ ]
10501
+ });
10502
+ if (outputFormat === "human") {
10503
+ console.error(chalk29.dim(
10504
+ `
10505
+ Flags: ${LICENCE_MARKS.map(({ mark, meaning }) => `${mark} ${meaning}`).join(", ")}. A deprecated licence stays on the projects that carry it and cannot be chosen.`
10506
+ ));
10507
+ }
10508
+ }
10509
+ async function showLicence(licenceId, cmd) {
10510
+ const outputFormat = getOutputFormat19(cmd);
10511
+ const api = createApiClient();
10512
+ let licence;
10513
+ try {
10514
+ licence = await api.admin.getLicence(licenceId);
10515
+ } catch (error) {
10516
+ if (error instanceof ApiError && error.status === 404) {
10517
+ throw new CliError(`No licence "${licenceId}" in the catalogue.`, {
10518
+ hint: `List the licences with 'diafunc licence list'.`
10519
+ });
10520
+ }
10521
+ throw error;
10522
+ }
10523
+ if (outputFormat !== "human") {
10524
+ format(licence, { format: outputFormat });
10525
+ return;
10526
+ }
10527
+ format({
10528
+ licenceId: licence.licenceId,
10529
+ name: licence.name,
10530
+ state: stateWord(licence.state),
10531
+ summary: licence.summary,
10532
+ url: licence.url,
10533
+ commercialUse: licence.commercialUse,
10534
+ derivatives: licence.derivatives,
10535
+ redistribution: licence.redistribution,
10536
+ attributionRequired: licence.attributionRequired,
10537
+ shareAlike: licence.shareAlike,
10538
+ recommended: licence.recommended
10539
+ }, {
10540
+ format: outputFormat,
10541
+ columns: [
10542
+ { key: "licenceId", header: "ID", kind: "id" },
10543
+ { key: "name", header: "Name" },
10544
+ { key: "state", header: "State", kind: "state" },
10545
+ { key: "summary", header: "Summary" },
10546
+ { key: "url", header: "Licence text" },
10547
+ { key: "commercialUse", header: "Commercial use", kind: "boolean" },
10548
+ { key: "derivatives", header: "Adaptations and forks", kind: "boolean" },
10549
+ { key: "redistribution", header: "Redistribution", kind: "boolean" },
10550
+ { key: "attributionRequired", header: "Attribution required", kind: "boolean" },
10551
+ { key: "shareAlike", header: "Share-alike", kind: "boolean" },
10552
+ { key: "recommended", header: "Recommended", kind: "boolean" }
10553
+ ]
10554
+ });
10555
+ }
10556
+ function registerLicenceCommands(program) {
10557
+ const licence = program.command("licence").description("The licences a public project can be published under (no sign-in needed)").addHelpText("after", `
10558
+ Examples:
10559
+ $ diafunc licence list the licences that can be chosen
10560
+ $ diafunc licence show CC-BY-4.0 one licence and what it allows
10561
+ $ diafunc project create --visibility PUBLIC --licence CC-BY-4.0
10562
+ $ diafunc analyze visibility <id> PUBLIC --licence CC0-1.0
10563
+ `);
10564
+ licence.command("list").description("List the licence catalogue: the active and the deprecated licences, in catalogue order").action(async (_options, cmd) => {
10565
+ try {
10566
+ await listLicences(cmd);
10567
+ } catch (error) {
10568
+ handleError(error);
10569
+ }
10570
+ });
10571
+ licence.command("show").description("Show one licence, in any state, and what it allows").argument("<licenceId>", "Licence ID (CC-BY-4.0, CC0-1.0, diafunc-view-only, ...)").action(async (licenceId, _options, cmd) => {
10572
+ try {
10573
+ await showLicence(licenceId, cmd);
10574
+ } catch (error) {
10575
+ handleError(error);
10576
+ }
10577
+ });
10578
+ }
10579
+
10580
+ // src/commands/data-sources/index.ts
10581
+ import chalk30 from "chalk";
10582
+ function getOutputFormat20(cmd) {
10583
+ const config = loadConfig();
10584
+ const globalOpts = cmd.optsWithGlobals();
10585
+ return globalOpts.output ?? config.defaults.output ?? "human";
10586
+ }
10368
10587
  function parseConfigPairs(pairs) {
10369
10588
  const out = {};
10370
10589
  if (!pairs) return out;
@@ -10460,7 +10679,7 @@ function resolveProjectId(cmd) {
10460
10679
  return resolved;
10461
10680
  }
10462
10681
  async function listDataSources(projectId, cmd) {
10463
- const outputFormat = getOutputFormat19(cmd);
10682
+ const outputFormat = getOutputFormat20(cmd);
10464
10683
  const api = createApiClient();
10465
10684
  const sources = await api.storage.listDataSources(projectId);
10466
10685
  if (outputFormat === "human" && sources.length === 0) {
@@ -10481,13 +10700,13 @@ async function listDataSources(projectId, cmd) {
10481
10700
  });
10482
10701
  }
10483
10702
  async function getDataSource(id, cmd) {
10484
- const outputFormat = getOutputFormat19(cmd);
10703
+ const outputFormat = getOutputFormat20(cmd);
10485
10704
  const api = createApiClient();
10486
10705
  const ds = await api.storage.getDataSource(id);
10487
10706
  format(ds, { format: outputFormat });
10488
10707
  }
10489
10708
  async function showDashboard(projectId, cmd) {
10490
- const outputFormat = getOutputFormat19(cmd);
10709
+ const outputFormat = getOutputFormat20(cmd);
10491
10710
  const api = createApiClient();
10492
10711
  const dashboard = await api.storage.getDataSourceDashboard(projectId);
10493
10712
  if (outputFormat !== "human") {
@@ -10495,7 +10714,7 @@ async function showDashboard(projectId, cmd) {
10495
10714
  return;
10496
10715
  }
10497
10716
  const r = dashboard.rollup;
10498
- let line = chalk29.bold(`DataSources in ${projectId}: `) + `${r.totalSources} total, ${r.scheduledSources} scheduled, ${r.sourcesWithRecentFailure} failing recently`;
10717
+ let line = chalk30.bold(`DataSources in ${projectId}: `) + `${r.totalSources} total, ${r.scheduledSources} scheduled, ${r.sourcesWithRecentFailure} failing recently`;
10499
10718
  if (r.lastActivityAt) line += `, last activity ${r.lastActivityAt}`;
10500
10719
  console.log(line);
10501
10720
  if (dashboard.sources.length === 0) {
@@ -10556,14 +10775,14 @@ async function createForAnalysis(api, options, human) {
10556
10775
  if (human) {
10557
10776
  success(`Added ${source.fileName} to analysis ${analysisId} from data source ${source.dataSourceId ?? ""}`.trimEnd());
10558
10777
  for (const line of planLines(build.plan)) {
10559
- console.log(line.caution ? chalk29.yellow(` ${line.text}`) : chalk29.dim(` ${line.text}`));
10778
+ console.log(line.caution ? chalk30.yellow(` ${line.text}`) : chalk30.dim(` ${line.text}`));
10560
10779
  }
10561
- console.log(chalk29.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`)."));
10780
+ console.log(chalk30.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`)."));
10562
10781
  }
10563
10782
  return { source, build };
10564
10783
  }
10565
10784
  async function createDataSource(options, cmd) {
10566
- const outputFormat = getOutputFormat19(cmd);
10785
+ const outputFormat = getOutputFormat20(cmd);
10567
10786
  const target = createTarget(options);
10568
10787
  const api = createApiClient();
10569
10788
  if (target === "analysis") {
@@ -10586,14 +10805,14 @@ async function createDataSource(options, cmd) {
10586
10805
  const ds = await api.storage.createDataSource(request);
10587
10806
  if (outputFormat === "human") {
10588
10807
  success(`Created data source ${ds.id}`);
10589
- console.log(chalk29.dim(` Last run: ${ds.lastRunStatus ?? "\u2014"}`));
10590
- if (ds.lastRunError) console.log(chalk29.dim(` Error: ${ds.lastRunError}`));
10808
+ console.log(chalk30.dim(` Last run: ${ds.lastRunStatus ?? "\u2014"}`));
10809
+ if (ds.lastRunError) console.log(chalk30.dim(` Error: ${ds.lastRunError}`));
10591
10810
  } else {
10592
10811
  format(ds, { format: outputFormat });
10593
10812
  }
10594
10813
  }
10595
10814
  async function updateDataSource(id, options, cmd) {
10596
- const outputFormat = getOutputFormat19(cmd);
10815
+ const outputFormat = getOutputFormat20(cmd);
10597
10816
  if (options.name === void 0 && options.type === void 0 && (!options.config || options.config.length === 0) && options.scheduleCron === void 0 && !options.clearSchedule) {
10598
10817
  throw new Error("Provide at least one of --name, --type, --config, --schedule-cron, or --clear-schedule.");
10599
10818
  }
@@ -10628,18 +10847,18 @@ async function deleteDataSource(id) {
10628
10847
  success(`Deleted data source ${id}`);
10629
10848
  }
10630
10849
  async function refreshDataSource(id, cmd) {
10631
- const outputFormat = getOutputFormat19(cmd);
10850
+ const outputFormat = getOutputFormat20(cmd);
10632
10851
  const api = createApiClient();
10633
10852
  const run = await api.storage.refreshDataSource(id);
10634
10853
  if (outputFormat === "human") {
10635
10854
  success(`Refresh queued: run ${run.runId}, status ${run.status}.`);
10636
- if (run.errorMessage) console.log(chalk29.red(` Error: ${run.errorMessage}`));
10855
+ if (run.errorMessage) console.log(chalk30.red(` Error: ${run.errorMessage}`));
10637
10856
  } else {
10638
10857
  format(run, { format: outputFormat });
10639
10858
  }
10640
10859
  }
10641
10860
  async function listRuns2(id, limit, cmd) {
10642
- const outputFormat = getOutputFormat19(cmd);
10861
+ const outputFormat = getOutputFormat20(cmd);
10643
10862
  const api = createApiClient();
10644
10863
  const runs = await api.storage.listDataSourceRuns(id, limit);
10645
10864
  if (outputFormat === "human" && runs.length === 0) {
@@ -10661,13 +10880,13 @@ async function listRuns2(id, limit, cmd) {
10661
10880
  });
10662
10881
  }
10663
10882
  async function getRun(id, runId, cmd) {
10664
- const outputFormat = getOutputFormat19(cmd);
10883
+ const outputFormat = getOutputFormat20(cmd);
10665
10884
  const api = createApiClient();
10666
10885
  const run = await api.storage.getDataSourceRun(id, runId);
10667
10886
  format(run, { format: outputFormat });
10668
10887
  }
10669
10888
  async function listConnectorTypes(cmd) {
10670
- const outputFormat = getOutputFormat19(cmd);
10889
+ const outputFormat = getOutputFormat20(cmd);
10671
10890
  const api = createApiClient();
10672
10891
  const types = await api.storage.listDataSourceConnectorTypes();
10673
10892
  if (outputFormat === "human") {
@@ -10760,8 +10979,8 @@ Examples:
10760
10979
  }
10761
10980
 
10762
10981
  // src/commands/table-exporters/index.ts
10763
- import chalk30 from "chalk";
10764
- function getOutputFormat20(cmd) {
10982
+ import chalk31 from "chalk";
10983
+ function getOutputFormat21(cmd) {
10765
10984
  const config = loadConfig();
10766
10985
  const globalOpts = cmd.optsWithGlobals();
10767
10986
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -10770,7 +10989,7 @@ function registerTableExportersCommands(program) {
10770
10989
  const exporters = program.command("table-exporters").description("Manage user-defined exporters (UDE); admin only");
10771
10990
  exporters.command("list").description("List all registered user-defined exporters").action(async (_options, cmd) => {
10772
10991
  try {
10773
- const outputFormat = getOutputFormat20(cmd);
10992
+ const outputFormat = getOutputFormat21(cmd);
10774
10993
  const api = createApiClient();
10775
10994
  const list = await api.storage.listUserDefinedExporters();
10776
10995
  if (outputFormat === "json") {
@@ -10791,14 +11010,14 @@ function registerTableExportersCommands(program) {
10791
11010
  format: outputFormat,
10792
11011
  columns: ["id", "name", "format", "extension", "mimeType", "priority", "function", "createdBy"]
10793
11012
  });
10794
- console.log(chalk30.dim(`${list.length} exporter(s)`));
11013
+ console.log(chalk31.dim(`${list.length} exporter(s)`));
10795
11014
  } catch (error) {
10796
11015
  handleError(error);
10797
11016
  }
10798
11017
  });
10799
11018
  exporters.command("get").description("Show a single user-defined exporter by id").argument("<id>", "Exporter id").action(async (id, _options, cmd) => {
10800
11019
  try {
10801
- const outputFormat = getOutputFormat20(cmd);
11020
+ const outputFormat = getOutputFormat21(cmd);
10802
11021
  const api = createApiClient();
10803
11022
  const list = await api.storage.listUserDefinedExporters();
10804
11023
  const exporter = list.find((e) => e.id === id);
@@ -10813,7 +11032,7 @@ function registerTableExportersCommands(program) {
10813
11032
  });
10814
11033
  exporters.command("create").description("Register a new user-defined exporter").requiredOption("--name <name>", 'Display name (e.g. "Acme machine instrument export")').requiredOption("--format <token>", 'Format token used in the dispatch URL (e.g. "acme")').requiredOption("--function-project <id>", "Function entity's project id").requiredOption("--function-entity <id>", "Function entity id").option("--description <text>", "Free-form description").option("--extension <ext>", 'Filename extension (must start with ".")').option("--mime-type <mime>", "MIME type the function produces").option("--function-project-branch <branch>", "Function project branch", "main").option("--function-entity-branch <branch>", "Function entity branch", "main").option("--priority <n>", "Dispatch priority (default 50; > 200 overrides built-ins)", "50").action(async (options, cmd) => {
10815
11034
  try {
10816
- const outputFormat = getOutputFormat20(cmd);
11035
+ const outputFormat = getOutputFormat21(cmd);
10817
11036
  const api = createApiClient();
10818
11037
  const payload = {
10819
11038
  name: options.name,
@@ -10849,9 +11068,9 @@ function registerTableExportersCommands(program) {
10849
11068
  }
10850
11069
 
10851
11070
  // src/commands/skeleton/index.ts
10852
- import chalk31 from "chalk";
11071
+ import chalk32 from "chalk";
10853
11072
  import * as fs12 from "fs";
10854
- function getOutputFormat21(cmd) {
11073
+ function getOutputFormat22(cmd) {
10855
11074
  const config = loadConfig();
10856
11075
  const globalOpts = cmd.optsWithGlobals();
10857
11076
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -10900,7 +11119,7 @@ function skeletonTableRow(s) {
10900
11119
  };
10901
11120
  }
10902
11121
  async function createSkeleton(options, cmd) {
10903
- const outputFormat = getOutputFormat21(cmd);
11122
+ const outputFormat = getOutputFormat22(cmd);
10904
11123
  const projectId = resolveProjectId2(cmd);
10905
11124
  const template = resolveTemplate(options.template);
10906
11125
  const weight = parseWeight(options.weight);
@@ -10916,16 +11135,16 @@ async function createSkeleton(options, cmd) {
10916
11135
  const skeleton = await api.storage.createSkeleton(request);
10917
11136
  if (outputFormat === "human") {
10918
11137
  success(`Created skeleton ${skeleton.id}`);
10919
- console.log(chalk31.dim(` name: ${skeleton.name}`));
10920
- console.log(chalk31.dim(` template: ${skeleton.template}`));
10921
- console.log(chalk31.dim(` paramCount: ${skeleton.paramCount}`));
10922
- console.log(chalk31.dim(` weight: ${skeleton.weight}`));
11138
+ console.log(chalk32.dim(` name: ${skeleton.name}`));
11139
+ console.log(chalk32.dim(` template: ${skeleton.template}`));
11140
+ console.log(chalk32.dim(` paramCount: ${skeleton.paramCount}`));
11141
+ console.log(chalk32.dim(` weight: ${skeleton.weight}`));
10923
11142
  } else {
10924
11143
  format(skeleton, { format: outputFormat });
10925
11144
  }
10926
11145
  }
10927
11146
  async function listSkeletons(cmd) {
10928
- const outputFormat = getOutputFormat21(cmd);
11147
+ const outputFormat = getOutputFormat22(cmd);
10929
11148
  const projectId = resolveProjectId2(cmd);
10930
11149
  const api = createApiClient();
10931
11150
  const skeletons = await api.storage.listSkeletons(projectId);
@@ -10939,13 +11158,13 @@ async function listSkeletons(cmd) {
10939
11158
  });
10940
11159
  }
10941
11160
  async function getSkeleton(id, cmd) {
10942
- const outputFormat = getOutputFormat21(cmd);
11161
+ const outputFormat = getOutputFormat22(cmd);
10943
11162
  const api = createApiClient();
10944
11163
  const skeleton = await api.storage.getSkeleton(id);
10945
11164
  format(skeleton, { format: outputFormat });
10946
11165
  }
10947
11166
  async function updateSkeleton(id, options, cmd) {
10948
- const outputFormat = getOutputFormat21(cmd);
11167
+ const outputFormat = getOutputFormat22(cmd);
10949
11168
  if (options.name === void 0 && options.template === void 0 && options.weight === void 0) {
10950
11169
  throw new Error("Provide at least one of --name, --template, --weight.");
10951
11170
  }
@@ -10958,10 +11177,10 @@ async function updateSkeleton(id, options, cmd) {
10958
11177
  const skeleton = await api.storage.updateSkeleton(id, request);
10959
11178
  if (outputFormat === "human") {
10960
11179
  success(`Updated skeleton ${skeleton.id}`);
10961
- console.log(chalk31.dim(` name: ${skeleton.name}`));
10962
- console.log(chalk31.dim(` template: ${skeleton.template}`));
10963
- console.log(chalk31.dim(` paramCount: ${skeleton.paramCount}`));
10964
- console.log(chalk31.dim(` weight: ${skeleton.weight}`));
11180
+ console.log(chalk32.dim(` name: ${skeleton.name}`));
11181
+ console.log(chalk32.dim(` template: ${skeleton.template}`));
11182
+ console.log(chalk32.dim(` paramCount: ${skeleton.paramCount}`));
11183
+ console.log(chalk32.dim(` weight: ${skeleton.weight}`));
10965
11184
  } else {
10966
11185
  format(skeleton, { format: outputFormat });
10967
11186
  }
@@ -11286,7 +11505,7 @@ function registerCompletionCommand(program) {
11286
11505
  }
11287
11506
 
11288
11507
  // src/commands/whoami/index.ts
11289
- import chalk32 from "chalk";
11508
+ import chalk33 from "chalk";
11290
11509
  function registerWhoamiCommand(program) {
11291
11510
  program.command("whoami").description("Show the currently authenticated user").action(async (_options, cmd) => {
11292
11511
  try {
@@ -11296,8 +11515,8 @@ function registerWhoamiCommand(program) {
11296
11515
  const api = createApiClient();
11297
11516
  const user = await api.admin.getMyUser();
11298
11517
  if (outputFormat === "human") {
11299
- console.log(chalk32.bold(user.name) + chalk32.dim(` <${user.email}>`));
11300
- console.log(chalk32.dim(` Role: ${user.role} \xB7 Remaining credits: ${user.remainingCredits} \xB7 Profile: ${config.currentProfile}`));
11518
+ console.log(chalk33.bold(user.name) + chalk33.dim(` <${user.email}>`));
11519
+ console.log(chalk33.dim(` Role: ${user.role} \xB7 Remaining credits: ${user.remainingCredits} \xB7 Profile: ${config.currentProfile}`));
11301
11520
  } else {
11302
11521
  format(user, { format: outputFormat });
11303
11522
  }
@@ -11308,8 +11527,8 @@ function registerWhoamiCommand(program) {
11308
11527
  }
11309
11528
 
11310
11529
  // src/commands/utilization/index.ts
11311
- import chalk33 from "chalk";
11312
- function getOutputFormat22(cmd) {
11530
+ import chalk34 from "chalk";
11531
+ function getOutputFormat23(cmd) {
11313
11532
  const config = loadConfig();
11314
11533
  const globalOpts = cmd.optsWithGlobals();
11315
11534
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -11325,19 +11544,19 @@ function windowLabel(u) {
11325
11544
  }
11326
11545
  function printUtilizationHuman(u, label) {
11327
11546
  const when2 = windowLabel(u);
11328
- console.log(label ? chalk33.bold(label) + " " + chalk33.dim(when2) : chalk33.bold(when2));
11547
+ console.log(label ? chalk34.bold(label) + " " + chalk34.dim(when2) : chalk34.bold(when2));
11329
11548
  if (u.types.length === 0) {
11330
- console.log(chalk33.dim(" (no usage)"));
11549
+ console.log(chalk34.dim(" (no usage)"));
11331
11550
  return;
11332
11551
  }
11333
11552
  const types = [...u.types].sort((a, b) => b.credits - a.credits);
11334
11553
  const width = Math.max(...types.map((t) => t.type.length));
11335
11554
  for (const t of types) {
11336
- const line = ` ${t.type.padEnd(width)} ${formatNumber(t.quantity).padStart(12)} ${chalk33.dim("credits")} ${t.credits.toFixed(2).padStart(10)}`;
11337
- console.log(t.credits === 0 ? chalk33.dim(line) : line);
11555
+ const line = ` ${t.type.padEnd(width)} ${formatNumber(t.quantity).padStart(12)} ${chalk34.dim("credits")} ${t.credits.toFixed(2).padStart(10)}`;
11556
+ console.log(t.credits === 0 ? chalk34.dim(line) : line);
11338
11557
  }
11339
11558
  const total = u.totalCredits ?? u.types.reduce((s, t) => s + t.credits, 0);
11340
- console.log(chalk33.bold(` ${"Total".padEnd(width)} ${" ".repeat(12)} ${chalk33.dim("credits")} ${total.toFixed(2).padStart(10)}`));
11559
+ console.log(chalk34.bold(` ${"Total".padEnd(width)} ${" ".repeat(12)} ${chalk34.dim("credits")} ${total.toFixed(2).padStart(10)}`));
11341
11560
  }
11342
11561
  function formatDailyHistory(history) {
11343
11562
  const spentOn = (u) => u.dailyCredits ?? u.types.reduce((sum, t) => sum + (t.dailyCredits ?? 0), 0);
@@ -11354,14 +11573,14 @@ function formatDailyHistory(history) {
11354
11573
  for (const u of history) {
11355
11574
  const spent = spentOn(u);
11356
11575
  total += spent;
11357
- const line = `${windowLabel(u).padEnd(width)} ${amount(spent)} ${chalk33.dim("credits")}`;
11358
- lines.push(spent > 0 ? chalk33.bold(line) : chalk33.dim(line));
11576
+ const line = `${windowLabel(u).padEnd(width)} ${amount(spent)} ${chalk34.dim("credits")}`;
11577
+ lines.push(spent > 0 ? chalk34.bold(line) : chalk34.dim(line));
11359
11578
  for (const t of costly(u)) {
11360
11579
  lines.push(` ${t.type.padEnd(width - 2)} ${amount(t.dailyCredits ?? 0)}`);
11361
11580
  }
11362
11581
  }
11363
11582
  lines.push("");
11364
- lines.push(chalk33.bold(`${totalLabel.padEnd(width)} ${amount(total)} ${chalk33.dim("credits")}`));
11583
+ lines.push(chalk34.bold(`${totalLabel.padEnd(width)} ${amount(total)} ${chalk34.dim("credits")}`));
11365
11584
  return lines;
11366
11585
  }
11367
11586
  function registerUtilizationCommand(program) {
@@ -11374,7 +11593,7 @@ Examples:
11374
11593
  `);
11375
11594
  util.command("actual", { isDefault: true }).description("Show current utilization (default subcommand)").action(async (_options, cmd) => {
11376
11595
  try {
11377
- const outputFormat = getOutputFormat22(cmd);
11596
+ const outputFormat = getOutputFormat23(cmd);
11378
11597
  const api = createApiClient();
11379
11598
  const utilization = await api.admin.getActualUtilization();
11380
11599
  if (outputFormat === "human") {
@@ -11388,7 +11607,7 @@ Examples:
11388
11607
  });
11389
11608
  util.command("history").description("Show what each day of the billing cycle cost").action(async (_options, cmd) => {
11390
11609
  try {
11391
- const outputFormat = getOutputFormat22(cmd);
11610
+ const outputFormat = getOutputFormat23(cmd);
11392
11611
  const api = createApiClient();
11393
11612
  const history = await api.admin.getUtilizationHistory();
11394
11613
  if (outputFormat === "human") {
@@ -11409,7 +11628,7 @@ Examples:
11409
11628
  }
11410
11629
 
11411
11630
  // src/commands/entity-branch/index.ts
11412
- function getOutputFormat23(cmd) {
11631
+ function getOutputFormat24(cmd) {
11413
11632
  const config = loadConfig();
11414
11633
  const globalOpts = cmd.optsWithGlobals();
11415
11634
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -11422,7 +11641,7 @@ function registerEntityBranchCommands(program) {
11422
11641
  const eb = program.command("entity-branch").description("Manage entity branches (parallel versions of a single entity)");
11423
11642
  eb.command("list").description("List branches of an entity").argument("<ref>", "Entity reference (projectId/branch/entityId)").action(async (ref, _options, cmd) => {
11424
11643
  try {
11425
- const outputFormat = getOutputFormat23(cmd);
11644
+ const outputFormat = getOutputFormat24(cmd);
11426
11645
  const overrides = getOverrides11(cmd);
11427
11646
  const resolved = parseEntityReference(ref, overrides);
11428
11647
  const api = createApiClient();
@@ -11474,7 +11693,7 @@ function forReader(subscription) {
11474
11693
  Object.entries(subscription).filter(([key]) => !BILLING_INTERNALS.has(key))
11475
11694
  );
11476
11695
  }
11477
- function getOutputFormat24(cmd) {
11696
+ function getOutputFormat25(cmd) {
11478
11697
  const config = loadConfig();
11479
11698
  const globalOpts = cmd.optsWithGlobals();
11480
11699
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -11488,7 +11707,7 @@ Examples:
11488
11707
  sub.command("current", { isDefault: true }).description("Show the current subscription").action(async (_options, cmd) => {
11489
11708
  try {
11490
11709
  const api = createApiClient();
11491
- const outputFormat = getOutputFormat24(cmd);
11710
+ const outputFormat = getOutputFormat25(cmd);
11492
11711
  const s = await api.admin.getCurrentSubscription();
11493
11712
  format(outputFormat === "human" ? forReader(s) : s, { format: outputFormat });
11494
11713
  } catch (error) {
@@ -11498,7 +11717,7 @@ Examples:
11498
11717
  sub.command("next").description("Show the next (upcoming) subscription").action(async (_options, cmd) => {
11499
11718
  try {
11500
11719
  const api = createApiClient();
11501
- const outputFormat = getOutputFormat24(cmd);
11720
+ const outputFormat = getOutputFormat25(cmd);
11502
11721
  const s = await api.admin.getNextSubscription();
11503
11722
  format(outputFormat === "human" ? forReader(s) : s, { format: outputFormat });
11504
11723
  } catch (error) {
@@ -11509,7 +11728,7 @@ Examples:
11509
11728
  try {
11510
11729
  const api = createApiClient();
11511
11730
  const plans = await api.admin.getSubscriptionPlans(subscriptionToken);
11512
- format(plans, { format: getOutputFormat24(cmd) });
11731
+ format(plans, { format: getOutputFormat25(cmd) });
11513
11732
  } catch (error) {
11514
11733
  handleError(error);
11515
11734
  }
@@ -11518,7 +11737,7 @@ Examples:
11518
11737
 
11519
11738
  // src/commands/invoice/index.ts
11520
11739
  import * as fs13 from "fs";
11521
- function getOutputFormat25(cmd) {
11740
+ function getOutputFormat26(cmd) {
11522
11741
  const config = loadConfig();
11523
11742
  const globalOpts = cmd.optsWithGlobals();
11524
11743
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -11535,7 +11754,7 @@ Examples:
11535
11754
  const api = createApiClient();
11536
11755
  const invoices = await api.admin.getInvoices();
11537
11756
  format(invoices, {
11538
- format: getOutputFormat25(cmd),
11757
+ format: getOutputFormat26(cmd),
11539
11758
  columns: [
11540
11759
  { key: "invoiceNumber", header: "number" },
11541
11760
  { key: "issued", kind: "date" },
@@ -11564,7 +11783,7 @@ Examples:
11564
11783
  }
11565
11784
 
11566
11785
  // src/commands/shell/index.ts
11567
- import chalk34 from "chalk";
11786
+ import chalk35 from "chalk";
11568
11787
  import * as fs14 from "fs";
11569
11788
  import * as os4 from "os";
11570
11789
  import * as path10 from "path";
@@ -11630,21 +11849,21 @@ async function evaluate(api, fnRef, language, sourceCode) {
11630
11849
  }, false);
11631
11850
  if (result.outputs?.length) {
11632
11851
  for (const out of result.outputs) {
11633
- console.log(chalk34.dim(` [${out.type}]`) + " " + out.output);
11852
+ console.log(chalk35.dim(` [${out.type}]`) + " " + out.output);
11634
11853
  }
11635
11854
  }
11636
11855
  if (result.successful) {
11637
11856
  if (result.result) {
11638
- console.log(chalk34.green("=>") + " " + result.result);
11857
+ console.log(chalk35.green("=>") + " " + resultText(result.result, result.resultEncoding));
11639
11858
  } else {
11640
- console.log(chalk34.dim("=> (no value)"));
11859
+ console.log(chalk35.dim("=> (no value)"));
11641
11860
  }
11642
11861
  const duration = result.completed - result.started;
11643
- console.log(chalk34.dim(` [${duration}ms \xB7 ${evaluationId}]`));
11862
+ console.log(chalk35.dim(` [${duration}ms \xB7 ${evaluationId}]`));
11644
11863
  } else {
11645
- console.log(chalk34.red("error: ") + result.error);
11864
+ console.log(chalk35.red("error: ") + result.error);
11646
11865
  if (result.lineNumber > 0) {
11647
- console.log(chalk34.dim(` at line ${result.lineNumber}, col ${result.columnNumber}`));
11866
+ console.log(chalk35.dim(` at line ${result.lineNumber}, col ${result.columnNumber}`));
11648
11867
  }
11649
11868
  }
11650
11869
  }
@@ -11665,19 +11884,19 @@ function registerShellCommand(program) {
11665
11884
  });
11666
11885
  const api = createApiClient();
11667
11886
  const { input: promptInput } = await import("@inquirer/prompts");
11668
- const { getUpdateNotice } = await import("./update-check-4345HWGE.js");
11887
+ const { getUpdateNotice } = await import("./update-check-YRTWCRNY.js");
11669
11888
  const resolvedLanguage = await resolveLanguage(api, fnRef.projectId, options.language);
11670
- console.log(chalk34.bold("Diafunc shell") + chalk34.dim(` \xB7 function ${fnRef.entityId} \xB7 ${resolvedLanguage}`));
11671
- console.log(chalk34.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
11672
- console.log(chalk34.dim("Commands: /edit (multi-line in $EDITOR), /lang <name>, /file <path>, /help, /quit"));
11889
+ console.log(chalk35.bold("Diafunc shell") + chalk35.dim(` \xB7 function ${fnRef.entityId} \xB7 ${resolvedLanguage}`));
11890
+ console.log(chalk35.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
11891
+ console.log(chalk35.dim("Commands: /edit (multi-line in $EDITOR), /lang <name>, /file <path>, /help, /quit"));
11673
11892
  const notice = await getUpdateNotice();
11674
- if (notice) console.log(chalk34.dim(notice));
11893
+ if (notice) console.log(chalk35.dim(notice));
11675
11894
  console.log();
11676
11895
  let language = resolvedLanguage;
11677
11896
  for (; ; ) {
11678
11897
  let line;
11679
11898
  try {
11680
- line = await promptInput({ message: chalk34.cyan.bold(`${language} >`) });
11899
+ line = await promptInput({ message: chalk35.cyan.bold(`${language} >`) });
11681
11900
  } catch {
11682
11901
  console.log();
11683
11902
  return;
@@ -11695,54 +11914,54 @@ function registerShellCommand(program) {
11695
11914
  case "help":
11696
11915
  case "h":
11697
11916
  case "?":
11698
- console.log(chalk34.dim(" /edit open $EDITOR for multi-line code"));
11699
- console.log(chalk34.dim(" /file <path> evaluate the contents of a file"));
11700
- console.log(chalk34.dim(" /lang <name> switch language (Java, JavaScript, Kotlin, Python, Scala)"));
11701
- console.log(chalk34.dim(" /quit exit the shell"));
11917
+ console.log(chalk35.dim(" /edit open $EDITOR for multi-line code"));
11918
+ console.log(chalk35.dim(" /file <path> evaluate the contents of a file"));
11919
+ console.log(chalk35.dim(" /lang <name> switch language (Java, JavaScript, Kotlin, Python, Scala)"));
11920
+ console.log(chalk35.dim(" /quit exit the shell"));
11702
11921
  continue;
11703
11922
  case "lang":
11704
11923
  if (arg) language = arg;
11705
- console.log(chalk34.dim(`Language: ${language}`));
11924
+ console.log(chalk35.dim(`Language: ${language}`));
11706
11925
  continue;
11707
11926
  case "edit": {
11708
11927
  const sourceCode = await openInEditor("", extensionFor2(language));
11709
11928
  if (!sourceCode.trim()) {
11710
- console.log(chalk34.dim("(empty; not evaluated)"));
11929
+ console.log(chalk35.dim("(empty; not evaluated)"));
11711
11930
  continue;
11712
11931
  }
11713
11932
  try {
11714
11933
  await evaluate(api, fnRef, language, sourceCode);
11715
11934
  } catch (e) {
11716
- console.error(chalk34.red(e.message));
11935
+ console.error(chalk35.red(e.message));
11717
11936
  }
11718
11937
  continue;
11719
11938
  }
11720
11939
  case "file": {
11721
11940
  if (!arg) {
11722
- console.log(chalk34.dim("usage: /file <path>"));
11941
+ console.log(chalk35.dim("usage: /file <path>"));
11723
11942
  continue;
11724
11943
  }
11725
11944
  if (!fs14.existsSync(arg)) {
11726
- console.log(chalk34.red(`file not found: ${arg}`));
11945
+ console.log(chalk35.red(`file not found: ${arg}`));
11727
11946
  continue;
11728
11947
  }
11729
11948
  const sourceCode = fs14.readFileSync(arg, "utf-8");
11730
11949
  try {
11731
11950
  await evaluate(api, fnRef, language, sourceCode);
11732
11951
  } catch (e) {
11733
- console.error(chalk34.red(e.message));
11952
+ console.error(chalk35.red(e.message));
11734
11953
  }
11735
11954
  continue;
11736
11955
  }
11737
11956
  default:
11738
- console.log(chalk34.dim(`Unknown command: /${cmd2}. Try /help.`));
11957
+ console.log(chalk35.dim(`Unknown command: /${cmd2}. Try /help.`));
11739
11958
  continue;
11740
11959
  }
11741
11960
  }
11742
11961
  try {
11743
11962
  await evaluate(api, fnRef, language, trimmed);
11744
11963
  } catch (e) {
11745
- console.error(chalk34.red(e.message));
11964
+ console.error(chalk35.red(e.message));
11746
11965
  }
11747
11966
  }
11748
11967
  } catch (error) {
@@ -11752,7 +11971,7 @@ function registerShellCommand(program) {
11752
11971
  }
11753
11972
 
11754
11973
  // src/commands/update/index.ts
11755
- import chalk35 from "chalk";
11974
+ import chalk36 from "chalk";
11756
11975
  import * as path11 from "path";
11757
11976
  import { spawn as spawn4 } from "child_process";
11758
11977
 
@@ -11798,14 +12017,14 @@ function registerUpdateCommand(program) {
11798
12017
  const install = detectInstall();
11799
12018
  const latest = await fetchLatestVersion();
11800
12019
  if (latest === package_default.version) {
11801
- console.log(chalk35.dim(`diafunc is already at the latest version (${package_default.version}).`));
12020
+ console.log(chalk36.dim(`diafunc is already at the latest version (${package_default.version}).`));
11802
12021
  return;
11803
12022
  }
11804
- console.log(chalk35.dim(`Current: ${package_default.version} \u2192 Available: ${latest}`));
12023
+ console.log(chalk36.dim(`Current: ${package_default.version} \u2192 Available: ${latest}`));
11805
12024
  if (install.method === "npm") {
11806
12025
  console.log();
11807
12026
  console.log("Installed via npm. Upgrade with:");
11808
- console.log(chalk35.bold(` npm install -g @diafunc/cli@${latest}`));
12027
+ console.log(chalk36.bold(` npm install -g @diafunc/cli@${latest}`));
11809
12028
  return;
11810
12029
  }
11811
12030
  const installDir = path11.dirname(install.binaryPath);
@@ -11819,7 +12038,7 @@ function registerUpdateCommand(program) {
11819
12038
  }
11820
12039
 
11821
12040
  // src/commands/uninstall/index.ts
11822
- import chalk36 from "chalk";
12041
+ import chalk37 from "chalk";
11823
12042
  import { spawn as spawn5 } from "child_process";
11824
12043
  import * as fs16 from "fs";
11825
12044
  import * as os5 from "os";
@@ -11831,11 +12050,11 @@ function registerUninstallCommand(program) {
11831
12050
  const configDir = path12.join(os5.homedir(), ".diafunc");
11832
12051
  if (install.method === "npm") {
11833
12052
  console.log("Installed via npm. Remove with:");
11834
- console.log(chalk36.bold(" npm uninstall -g @diafunc/cli"));
12053
+ console.log(chalk37.bold(" npm uninstall -g @diafunc/cli"));
11835
12054
  if (fs16.existsSync(configDir)) {
11836
12055
  console.log();
11837
12056
  console.log(`Config and credentials live at ${configDir}. Remove them manually with:`);
11838
- console.log(chalk36.bold(` rm -rf ${configDir}`));
12057
+ console.log(chalk37.bold(` rm -rf ${configDir}`));
11839
12058
  }
11840
12059
  return;
11841
12060
  }
@@ -11845,7 +12064,7 @@ function registerUninstallCommand(program) {
11845
12064
  default: false
11846
12065
  });
11847
12066
  if (!removeBinary) {
11848
- console.log(chalk36.dim("Aborted."));
12067
+ console.log(chalk37.dim("Aborted."));
11849
12068
  return;
11850
12069
  }
11851
12070
  let removeConfig = options.purge ?? false;
@@ -11857,7 +12076,7 @@ function registerUninstallCommand(program) {
11857
12076
  }
11858
12077
  if (removeConfig && fs16.existsSync(configDir)) {
11859
12078
  fs16.rmSync(configDir, { recursive: true, force: true });
11860
- console.log(chalk36.dim(`Removed ${configDir}`));
12079
+ console.log(chalk37.dim(`Removed ${configDir}`));
11861
12080
  }
11862
12081
  if (process.platform === "win32") {
11863
12082
  const cmd = `timeout /t 2 /nobreak >nul & del /f /q "${install.binaryPath}"`;
@@ -11867,13 +12086,13 @@ function registerUninstallCommand(program) {
11867
12086
  windowsHide: true
11868
12087
  });
11869
12088
  child.unref();
11870
- console.log(chalk36.dim(`Removing ${install.binaryPath} on exit...`));
12089
+ console.log(chalk37.dim(`Removing ${install.binaryPath} on exit...`));
11871
12090
  console.log();
11872
12091
  console.log("diafunc uninstalled.");
11873
12092
  return;
11874
12093
  }
11875
12094
  fs16.rmSync(install.binaryPath, { force: true });
11876
- console.log(chalk36.dim(`Removed ${install.binaryPath}`));
12095
+ console.log(chalk37.dim(`Removed ${install.binaryPath}`));
11877
12096
  console.log();
11878
12097
  console.log("diafunc uninstalled.");
11879
12098
  } catch (error) {
@@ -11937,7 +12156,7 @@ var DiafuncCommand = class _DiafuncCommand extends Command {
11937
12156
  };
11938
12157
 
11939
12158
  // src/prompting/fill.ts
11940
- import chalk38 from "chalk";
12159
+ import chalk39 from "chalk";
11941
12160
 
11942
12161
  // src/prompting/resolvers.ts
11943
12162
  var PROJECT_ROLES = ["OWNER", "ADMIN", "DEVELOPER", "GUEST"];
@@ -12017,6 +12236,7 @@ var BY_NAME = {
12017
12236
  teamId: { kind: "team" },
12018
12237
  invitationId: { kind: "teamInvitation" },
12019
12238
  analysisId: { kind: "analysis" },
12239
+ licenceId: { kind: "licence" },
12020
12240
  sessionId: { kind: "chatSession" },
12021
12241
  tokenId: { kind: "apiToken" },
12022
12242
  resource: { kind: "tokenResource" },
@@ -12139,7 +12359,7 @@ function dependencies(spec) {
12139
12359
 
12140
12360
  // src/prompting/pickers.ts
12141
12361
  import * as fs17 from "fs";
12142
- import chalk37 from "chalk";
12362
+ import chalk38 from "chalk";
12143
12363
  var SEARCH_THRESHOLD = 10;
12144
12364
  var TYPE_IT = "\0type-it";
12145
12365
  async function askFor(spec, input, ctx) {
@@ -12261,6 +12481,8 @@ async function askFor(spec, input, ctx) {
12261
12481
  return listed(ctx, "profiles", messageFor(input, "Profile"), async () => Object.keys(loadConfig().profiles).map((p) => ({ label: p, value: p })));
12262
12482
  case "statusComponent":
12263
12483
  return listed(ctx, "components", messageFor(input, "Component"), async () => (await createStatusService().getComponents()).map((c) => ({ label: c.id, value: c.id, hint: `${c.state} \xB7 ${c.domainId}` })));
12484
+ case "licence":
12485
+ return listed(ctx, "licences", messageFor(input, "Licence"), async () => (await ctx.api().admin.listLicences()).map((l) => ({ label: l.name, value: l.licenceId, hint: `${l.state.toLowerCase()} \xB7 ${l.licenceId}` })));
12264
12486
  case "choice":
12265
12487
  return choose(ctx, question(input), spec.choices.map((c) => ({ label: c, value: c })));
12266
12488
  case "choices": {
@@ -12487,7 +12709,7 @@ function typedValue(ctx, message) {
12487
12709
  return typed(ctx, message);
12488
12710
  }
12489
12711
  function typeItChoice() {
12490
- return { name: chalk37.dim("Type it instead"), value: TYPE_IT };
12712
+ return { name: chalk38.dim("Type it instead"), value: TYPE_IT };
12491
12713
  }
12492
12714
  function text(ctx, name) {
12493
12715
  const value = ctx.known.get(name);
@@ -12517,7 +12739,7 @@ function capitalize(value) {
12517
12739
  return value.charAt(0).toUpperCase() + value.slice(1);
12518
12740
  }
12519
12741
  function labelled(label, hint2) {
12520
- return hint2 && hint2 !== label ? `${label} ${chalk37.dim(hint2)}` : label;
12742
+ return hint2 && hint2 !== label ? `${label} ${chalk38.dim(hint2)}` : label;
12521
12743
  }
12522
12744
  function numberRule(spec) {
12523
12745
  return (raw) => {
@@ -12563,7 +12785,7 @@ async function fillPendingInputs(actionCommand) {
12563
12785
  known: knownValues(actionCommand),
12564
12786
  globals: actionCommand.optsWithGlobals(),
12565
12787
  prefill: /* @__PURE__ */ new Map(),
12566
- note: (line) => process.stderr.write(chalk38.dim(` ${line}
12788
+ note: (line) => process.stderr.write(chalk39.dim(` ${line}
12567
12789
  `))
12568
12790
  };
12569
12791
  for (const item of orderByDependencies(pending)) {
@@ -12572,7 +12794,7 @@ async function fillPendingInputs(actionCommand) {
12572
12794
  ctx.known.set(item.input.name, value);
12573
12795
  }
12574
12796
  const log = env.log ?? ((line) => console.log(line));
12575
- log(chalk38.dim(` Equivalent: ${equivalentCommand(actionCommand)}`));
12797
+ log(chalk39.dim(` Equivalent: ${equivalentCommand(actionCommand)}`));
12576
12798
  }
12577
12799
  function commandChain(cmd) {
12578
12800
  const chain = [];
@@ -12677,7 +12899,7 @@ function createProgram(environment = {}) {
12677
12899
  const opts = thisCommand.optsWithGlobals();
12678
12900
  if (opts.dryRun) setDryRun(true);
12679
12901
  if (opts.verbose) setVerbose(true);
12680
- if (opts.color === false) chalk39.level = 0;
12902
+ if (opts.color === false) chalk40.level = 0;
12681
12903
  }).hook("preAction", (_thisCommand, actionCommand) => fillPendingInputs(actionCommand));
12682
12904
  program.addHelpText("after", HELP_EPILOGUE);
12683
12905
  registerAuthCommands(program);
@@ -12699,6 +12921,7 @@ function createProgram(environment = {}) {
12699
12921
  registerStatusCommands(program);
12700
12922
  registerAnalyzeCommand(program);
12701
12923
  registerPublicCommands(program);
12924
+ registerLicenceCommands(program);
12702
12925
  registerDataSourcesCommands(program);
12703
12926
  registerTableExportersCommands(program);
12704
12927
  registerSkeletonCommands(program);
@@ -12720,4 +12943,4 @@ export {
12720
12943
  PromptCancelled,
12721
12944
  createProgram
12722
12945
  };
12723
- //# sourceMappingURL=chunk-Q5GOPNYM.js.map
12946
+ //# sourceMappingURL=chunk-HYUMMSA2.js.map