@diafunc/cli 0.30.0 → 0.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "./chunk-GZI6AECR.js";
3
+ } from "./chunk-L4XSFORF.js";
4
4
 
5
5
  // src/index.ts
6
6
  import chalk41 from "chalk";
@@ -265,6 +265,17 @@ var LICENSE_REFUSALS = {
265
265
  licence_forbids_fork: "The license of this project does not allow adaptations, so it cannot be forked."
266
266
  };
267
267
  var LICENSE_LIST_REFUSALS = /* @__PURE__ */ new Set(["licence_required", "licence_not_selectable"]);
268
+ var PROJECT_TRANSFER_HINTS = {
269
+ transfer_open: `The project already has an open transfer. See it with 'diafunc project transfer status <projectId>'.`,
270
+ transfer_not_found: `There is no open transfer for this project. List yours with 'diafunc project transfer list'.`,
271
+ transfer_expired: "The offer has expired. The owner can offer the project again.",
272
+ transfer_recipient_invalid: "The recipient needs an active Diafunc account; offers go to existing accounts only.",
273
+ transfer_recipient_not_in_team: `Switch to the team first with 'diafunc team use <teamId>', or accept with --personal.`,
274
+ transfer_team_not_administered: "A project can only go into a team you own or administer.",
275
+ project_busy: "The offer stays open. Accept again once the work has finished.",
276
+ project_transfer_in_progress: "The project is being moved right now. Try again in a minute.",
277
+ team_transfer_pending: "A team involved has a pending ownership transfer; it has to be completed or canceled first."
278
+ };
268
279
  var ApiError = class _ApiError extends Error {
269
280
  status;
270
281
  details;
@@ -763,6 +774,52 @@ function createAdminService(client) {
763
774
  path: `/licences/${encodeURIComponent(licenseId)}`
764
775
  });
765
776
  },
777
+ // Managing the catalog: administrators only.
778
+ async listLicenseCatalog() {
779
+ return client.request({ method: "GET", service: SERVICE, path: "/licence-catalogue/" });
780
+ },
781
+ async createLicense(license) {
782
+ return client.request({ method: "POST", service: SERVICE, path: "/licence-catalogue/", body: license });
783
+ },
784
+ async updateLicense(license) {
785
+ return client.request({
786
+ method: "PUT",
787
+ service: SERVICE,
788
+ path: `/licence-catalogue/${encodeURIComponent(license.licenceId)}`,
789
+ body: license
790
+ });
791
+ },
792
+ async deprecateLicense(licenseId) {
793
+ return client.request({
794
+ method: "POST",
795
+ service: SERVICE,
796
+ path: `/licence-catalogue/${encodeURIComponent(licenseId)}/deprecate`
797
+ });
798
+ },
799
+ async reactivateLicense(licenseId) {
800
+ return client.request({
801
+ method: "POST",
802
+ service: SERVICE,
803
+ path: `/licence-catalogue/${encodeURIComponent(licenseId)}/reactivate`
804
+ });
805
+ },
806
+ /** Ends publication under the license: its public projects become private. `expectedAffected` is the
807
+ * number of them the operator confirmed; the platform refuses when the current number differs. */
808
+ async withdrawLicense(licenseId, expectedAffected) {
809
+ return client.request({
810
+ method: "POST",
811
+ service: SERVICE,
812
+ path: `/licence-catalogue/${encodeURIComponent(licenseId)}/withdraw`,
813
+ body: { expectedAffected }
814
+ });
815
+ },
816
+ async deleteLicense(licenseId) {
817
+ await client.request({
818
+ method: "DELETE",
819
+ service: SERVICE,
820
+ path: `/licence-catalogue/${encodeURIComponent(licenseId)}`
821
+ });
822
+ },
766
823
  async createProject(request) {
767
824
  return client.request({
768
825
  method: "POST",
@@ -1041,6 +1098,111 @@ function createAdminService(client) {
1041
1098
  path: `/teams/${encodeURIComponent(teamId)}/ownership-transfer`
1042
1099
  });
1043
1100
  },
1101
+ // Project ownership transfer: the owner offers, the recipient accepts or declines.
1102
+ async offerProjectTransfer(projectId, offer) {
1103
+ return client.request({
1104
+ method: "POST",
1105
+ service: SERVICE,
1106
+ path: `/projects/${encodeURIComponent(projectId)}/transfer`,
1107
+ body: offer
1108
+ });
1109
+ },
1110
+ /** The open transfer of a project, or `undefined` when there is none (the platform answers 204). */
1111
+ async getProjectTransfer(projectId) {
1112
+ return client.request({
1113
+ method: "GET",
1114
+ service: SERVICE,
1115
+ path: `/projects/${encodeURIComponent(projectId)}/transfer`
1116
+ });
1117
+ },
1118
+ async withdrawProjectTransfer(projectId) {
1119
+ return client.request({
1120
+ method: "DELETE",
1121
+ service: SERVICE,
1122
+ path: `/projects/${encodeURIComponent(projectId)}/transfer`
1123
+ });
1124
+ },
1125
+ /** `toTeamId` null takes the project into the recipient's personal account. */
1126
+ async acceptProjectTransfer(projectId, toTeamId) {
1127
+ return client.request({
1128
+ method: "POST",
1129
+ service: SERVICE,
1130
+ path: `/projects/${encodeURIComponent(projectId)}/transfer/accept`,
1131
+ body: { toTeamId }
1132
+ });
1133
+ },
1134
+ async declineProjectTransfer(projectId) {
1135
+ return client.request({
1136
+ method: "POST",
1137
+ service: SERVICE,
1138
+ path: `/projects/${encodeURIComponent(projectId)}/transfer/decline`
1139
+ });
1140
+ },
1141
+ async listProjectTransfers(direction, status) {
1142
+ return client.request({
1143
+ method: "GET",
1144
+ service: SERVICE,
1145
+ path: "/project-transfers",
1146
+ query: { direction, status }
1147
+ });
1148
+ },
1149
+ // Project moves by an operator: no acceptance step, every call carries the reason.
1150
+ async moveProject(projectId, request) {
1151
+ return client.request({
1152
+ method: "POST",
1153
+ service: SERVICE,
1154
+ path: `/operator/projects/${encodeURIComponent(projectId)}/move`,
1155
+ body: request
1156
+ });
1157
+ },
1158
+ /** A preflight answers the verdicts and writes nothing; otherwise the batch starts in the background. */
1159
+ async moveProjects(request) {
1160
+ return client.request({
1161
+ method: "POST",
1162
+ service: SERVICE,
1163
+ path: "/operator/projects/moves",
1164
+ body: request
1165
+ });
1166
+ },
1167
+ async getProjectMoveBatch(batchId) {
1168
+ return client.request({
1169
+ method: "GET",
1170
+ service: SERVICE,
1171
+ path: `/operator/projects/moves/${encodeURIComponent(batchId)}`
1172
+ });
1173
+ },
1174
+ async listOperatorProjectTransfers(status) {
1175
+ return client.request({
1176
+ method: "GET",
1177
+ service: SERVICE,
1178
+ path: "/operator/projects/transfers",
1179
+ query: { status }
1180
+ });
1181
+ },
1182
+ async resumeProjectTransfer(projectId, reason2) {
1183
+ return client.request({
1184
+ method: "POST",
1185
+ service: SERVICE,
1186
+ path: `/operator/projects/${encodeURIComponent(projectId)}/transfer/resume`,
1187
+ body: { reason: reason2 }
1188
+ });
1189
+ },
1190
+ async abortProjectTransfer(projectId, reason2) {
1191
+ return client.request({
1192
+ method: "POST",
1193
+ service: SERVICE,
1194
+ path: `/operator/projects/${encodeURIComponent(projectId)}/transfer/abort`,
1195
+ body: { reason: reason2 }
1196
+ });
1197
+ },
1198
+ async cancelProjectTransferAsOperator(projectId, reason2) {
1199
+ return client.request({
1200
+ method: "DELETE",
1201
+ service: SERVICE,
1202
+ path: `/operator/projects/${encodeURIComponent(projectId)}/transfer`,
1203
+ body: { reason: reason2 }
1204
+ });
1205
+ },
1044
1206
  // Team contracts (super-admin only)
1045
1207
  async issueTeamContract(teamId, request) {
1046
1208
  return client.request({
@@ -1239,7 +1401,9 @@ function handleError(error) {
1239
1401
  if (error instanceof ApiError) {
1240
1402
  failure(error.toUserMessage());
1241
1403
  if (error.status === 401 && !(error instanceof SignInRefusedError)) hint(`Run 'diafunc auth login' to sign in.`);
1242
- if (error.status === 404) hint(`Check the id, or list what exists with the matching 'list' command.`);
1404
+ const transferHint = error.code && Object.prototype.hasOwnProperty.call(PROJECT_TRANSFER_HINTS, error.code) ? PROJECT_TRANSFER_HINTS[error.code] : void 0;
1405
+ if (transferHint) hint(transferHint);
1406
+ else if (error.status === 404) hint(`Check the id, or list what exists with the matching 'list' command.`);
1243
1407
  if (error.code && LICENSE_LIST_REFUSALS.has(error.code)) hint(`List the licenses that can be chosen with 'diafunc license list'.`);
1244
1408
  process.exit(error.status === 401 || error.status === 403 ? EXIT_AUTH : EXIT_FAILURE);
1245
1409
  }
@@ -3687,7 +3851,7 @@ function getNestedValue(obj, path13) {
3687
3851
  }
3688
3852
 
3689
3853
  // src/commands/project/index.ts
3690
- import chalk13 from "chalk";
3854
+ import chalk14 from "chalk";
3691
3855
 
3692
3856
  // src/util/hidden-aliases.ts
3693
3857
  import { Help, Option } from "commander";
@@ -4379,12 +4543,234 @@ Examples:
4379
4543
  `).action((ref, given, _options, cmd) => guarded(() => change(target, "set", ref, given, cmd)));
4380
4544
  }
4381
4545
 
4382
- // src/commands/project/index.ts
4546
+ // src/util/confirm.ts
4547
+ import * as readline from "readline";
4548
+ import chalk13 from "chalk";
4549
+ async function confirmDestructive(message, opts = {}) {
4550
+ if (!process.stdin.isTTY || opts.yes) return;
4551
+ const expected = opts.resourceId ?? "yes";
4552
+ const hint2 = opts.resourceId ? `"${opts.resourceId}"` : '"yes"';
4553
+ console.log(chalk13.yellow(`! ${message}`));
4554
+ const answer = await new Promise((resolve2) => {
4555
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
4556
+ rl.question(` Type ${hint2} to confirm: `, (ans) => {
4557
+ rl.close();
4558
+ resolve2(ans);
4559
+ });
4560
+ });
4561
+ if (answer.trim() !== expected) {
4562
+ console.log(chalk13.dim("Aborted."));
4563
+ process.exit(1);
4564
+ }
4565
+ }
4566
+
4567
+ // src/commands/project/transfer.ts
4383
4568
  function getOutputFormat2(cmd) {
4384
4569
  const config = loadConfig();
4385
4570
  const globalOpts = cmd.optsWithGlobals();
4386
4571
  return globalOpts.output ?? config.defaults.output ?? "human";
4387
4572
  }
4573
+ var TRANSFER_RECORD = [
4574
+ { key: "projectName", header: "project" },
4575
+ { key: "projectId", kind: "id" },
4576
+ { key: "status", kind: "state" },
4577
+ { key: "fromUserName", header: "from" },
4578
+ { key: "toUserName", header: "to" },
4579
+ { key: "toUserId", kind: "id" },
4580
+ { key: "toTeamName", header: "into team" },
4581
+ { key: "previousOwnerRole", header: "previous owner keeps" },
4582
+ { key: "message" },
4583
+ { key: "visibility" },
4584
+ { key: "licenceId", header: "license" },
4585
+ { key: "storageCreditsPerMonth", header: "storage credits per month", kind: "number" },
4586
+ { key: "lastRunCredits", header: "last run credits", kind: "number" },
4587
+ { key: "offeredAt", kind: "date" },
4588
+ { key: "expiresAt", kind: "date" },
4589
+ { key: "completedAt", kind: "date" }
4590
+ ];
4591
+ var TRANSFER_ROWS = [
4592
+ { key: "projectName", header: "project" },
4593
+ { key: "projectId", kind: "id" },
4594
+ { key: "status", kind: "state" },
4595
+ { key: "fromUserName", header: "from" },
4596
+ { key: "toUserName", header: "to" },
4597
+ { key: "toTeamName", header: "team" },
4598
+ { key: "expiresAt", kind: "date" }
4599
+ ];
4600
+ function previousOwnerRole(keep) {
4601
+ return keep ? "MAINTAINER" : "NONE";
4602
+ }
4603
+ function buildOffer(recipient, options) {
4604
+ const who = recipient.trim();
4605
+ if (!who) throw new CliError("Name the new owner by user ID or e-mail address.", { exitCode: EXIT_USAGE });
4606
+ return {
4607
+ ...who.includes("@") ? { toEmail: who } : { toUserId: who },
4608
+ ...options.team ? { toTeamId: options.team } : {},
4609
+ previousOwnerRole: previousOwnerRole(options.keepMe),
4610
+ ...options.message !== void 0 && options.message.trim() ? { message: options.message.trim() } : {}
4611
+ };
4612
+ }
4613
+ function offerWarning(projectId, offer) {
4614
+ const to = offer.toEmail ?? offer.toUserId;
4615
+ const into = offer.toTeamId ? ` (suggested team: ${offer.toTeamId})` : "";
4616
+ const after = offer.previousOwnerRole === "MAINTAINER" ? "you stay on it as a maintainer, with edit rights" : "you lose access to it";
4617
+ return `This will offer project "${projectId}" to ${to}${into}. Once they accept, the project, its analyses and their costs move to them, and ${after}.`;
4618
+ }
4619
+ function acceptDestination(transfer, options) {
4620
+ if (options.team && options.personal) {
4621
+ throw new CliError("Give --team or --personal, not both.", { exitCode: EXIT_USAGE });
4622
+ }
4623
+ if (options.personal) return null;
4624
+ if (options.team) return options.team;
4625
+ return transfer.toTeamId ?? null;
4626
+ }
4627
+ function acceptWarning(transfer, toTeamId) {
4628
+ const name = transfer.projectName ? `"${transfer.projectName}" (${transfer.projectId})` : `"${transfer.projectId}"`;
4629
+ const into = toTeamId ? ` into team ${toTeamId === transfer.toTeamId && transfer.toTeamName ? transfer.toTeamName : toTeamId}` : " into your personal account";
4630
+ const costs = [];
4631
+ if (typeof transfer.storageCreditsPerMonth === "number") {
4632
+ costs.push(`its storage costs ${formatNumber(transfer.storageCreditsPerMonth)} credits per month`);
4633
+ }
4634
+ if (typeof transfer.lastRunCredits === "number") {
4635
+ costs.push(`its last analysis run cost ${formatNumber(transfer.lastRunCredits)} credits`);
4636
+ }
4637
+ const cost = costs.length > 0 ? ` From now on you pay for it: ${costs.join(", and ")}.` : " From now on you pay for it.";
4638
+ return `This will make you the owner of project ${name}${into}.${cost}`;
4639
+ }
4640
+ function directionsFor(options) {
4641
+ if (options.incoming && options.outgoing) {
4642
+ throw new CliError("Give --incoming or --outgoing, not both; leave both out to see either kind.", { exitCode: EXIT_USAGE });
4643
+ }
4644
+ if (options.incoming) return ["incoming"];
4645
+ if (options.outgoing) return ["outgoing"];
4646
+ return ["incoming", "outgoing"];
4647
+ }
4648
+ function registerProjectTransferCommands(project) {
4649
+ const transfer = project.command("transfer").description("Hand a project over to another account, or take one that is offered to you");
4650
+ transfer.command("start").description("Offer a project to a new owner, who then accepts or declines it").argument("<projectId>", "Project ID").argument("<userIdOrEmail>", "The new owner's user ID or the e-mail address of their account").option("--team <teamId>", "Suggest a team of the new owner the project goes into; they can choose another when accepting").option("--keep-me", "Stay on the project as a maintainer, with edit rights, after the move").option("--message <text>", "A note the new owner sees with the offer").option("-y, --yes", "Skip the confirmation prompt").addHelpText("after", `
4651
+ The offer stays open for 14 days. The project goes on working normally until it is accepted.
4652
+
4653
+ Examples:
4654
+ $ diafunc project transfer start <projectId> ana@example.com hand it over and leave it
4655
+ $ diafunc project transfer start <projectId> <userId> --keep-me hand it over and stay as a maintainer
4656
+ $ diafunc project transfer start <projectId> <userId> --team <teamId> -y suggest a team, no prompt
4657
+ `).action(async (projectId, recipient, options, cmd) => {
4658
+ try {
4659
+ const offer = buildOffer(recipient, options);
4660
+ await confirmDestructive(offerWarning(projectId, offer), { yes: options.yes, resourceId: projectId });
4661
+ const api = createApiClient();
4662
+ const created = await api.admin.offerProjectTransfer(projectId, offer);
4663
+ if (isDryRun()) return;
4664
+ const outputFormat = getOutputFormat2(cmd);
4665
+ if (outputFormat !== "human") {
4666
+ format(created, { format: outputFormat });
4667
+ return;
4668
+ }
4669
+ success(`Offered project "${projectId}" to ${created.toUserName ?? offer.toEmail ?? offer.toUserId}.`);
4670
+ if (created.expiresAt) detail(`The offer is open until ${formatInstant(created.expiresAt)}.`);
4671
+ hint(`Withdraw it with 'diafunc project transfer cancel ${projectId}'.`);
4672
+ } catch (error) {
4673
+ handleError(error);
4674
+ }
4675
+ });
4676
+ transfer.command("status", { isDefault: true }).description("Show the open transfer of a project").argument("<projectId>", "Project ID").action(async (projectId, _options, cmd) => {
4677
+ try {
4678
+ const api = createApiClient();
4679
+ const open = await api.admin.getProjectTransfer(projectId);
4680
+ const outputFormat = getOutputFormat2(cmd);
4681
+ if (!open) {
4682
+ if (outputFormat === "json") {
4683
+ format(null, { format: outputFormat });
4684
+ } else {
4685
+ console.log(`No open transfer for project "${projectId}".`);
4686
+ }
4687
+ return;
4688
+ }
4689
+ format(open, { format: outputFormat, columns: outputFormat === "json" ? void 0 : TRANSFER_RECORD });
4690
+ } catch (error) {
4691
+ handleError(error);
4692
+ }
4693
+ });
4694
+ transfer.command("accept").description("Accept a project offered to you; it moves to your account at once").argument("<projectId>", "Project ID").option("--team <teamId>", "Take the project into this team, which you own or administer and have active").option("--personal", "Take the project into your personal account, whatever team the offer suggests").option("-y, --yes", "Skip the confirmation prompt").addHelpText("after", `
4695
+ Without --team or --personal the project goes where the offer suggests. The move is refused while
4696
+ an analysis of the project runs or waits, or a table import or refresh is running; the offer then
4697
+ stays open, so accept again once that work has finished.
4698
+
4699
+ Examples:
4700
+ $ diafunc project transfer list --incoming the projects offered to you
4701
+ $ diafunc project transfer status <projectId> what it costs, before you accept
4702
+ $ diafunc project transfer accept <projectId> --personal take it into your own account
4703
+ `).action(async (projectId, options, cmd) => {
4704
+ try {
4705
+ const api = createApiClient();
4706
+ const open = await api.admin.getProjectTransfer(projectId);
4707
+ if (!open) {
4708
+ throw new CliError(`No open transfer for project "${projectId}".`, {
4709
+ hint: `List the projects offered to you with 'diafunc project transfer list --incoming'.`
4710
+ });
4711
+ }
4712
+ const toTeamId = acceptDestination(open, options);
4713
+ await confirmDestructive(acceptWarning(open, toTeamId), { yes: options.yes, resourceId: projectId });
4714
+ const accepted = await api.admin.acceptProjectTransfer(projectId, toTeamId);
4715
+ if (isDryRun()) return;
4716
+ const outputFormat = getOutputFormat2(cmd);
4717
+ if (outputFormat !== "human") {
4718
+ format(accepted, { format: outputFormat });
4719
+ return;
4720
+ }
4721
+ if (accepted.status === "COMPLETED") {
4722
+ success(`You now own project "${accepted.projectName ?? projectId}".`);
4723
+ } else {
4724
+ success(`Project transfer ${accepted.status}.`);
4725
+ }
4726
+ } catch (error) {
4727
+ handleError(error);
4728
+ }
4729
+ });
4730
+ transfer.command("decline").description("Decline a project offered to you").argument("<projectId>", "Project ID").action(async (projectId, _options, cmd) => {
4731
+ try {
4732
+ const api = createApiClient();
4733
+ await api.admin.declineProjectTransfer(projectId);
4734
+ success(`Declined the transfer of project "${projectId}".`, { format: getOutputFormat2(cmd) });
4735
+ } catch (error) {
4736
+ handleError(error);
4737
+ }
4738
+ });
4739
+ transfer.command("cancel").description("Withdraw an offer you made, while it is still open").argument("<projectId>", "Project ID").action(async (projectId, _options, cmd) => {
4740
+ try {
4741
+ const api = createApiClient();
4742
+ await api.admin.withdrawProjectTransfer(projectId);
4743
+ success(`Withdrew the transfer of project "${projectId}".`, { format: getOutputFormat2(cmd) });
4744
+ } catch (error) {
4745
+ handleError(error);
4746
+ }
4747
+ });
4748
+ transfer.command("list").description("List the project transfers offered to you and by you").option("--incoming", "Only the projects offered to you").option("--outgoing", "Only the projects you offered").option("--all", "Include finished transfers: accepted, declined, withdrawn and expired").action(async (options, cmd) => {
4749
+ try {
4750
+ const directions = directionsFor(options);
4751
+ const status = options.all ? "all" : "open";
4752
+ const api = createApiClient();
4753
+ const lists = await Promise.all(directions.map(async (direction) => (await api.admin.listProjectTransfers(direction, status) ?? []).map((t) => ({ direction, ...t }))));
4754
+ const rows = lists.flat();
4755
+ const outputFormat = getOutputFormat2(cmd);
4756
+ if (rows.length === 0) {
4757
+ empty(options.all ? "project transfers" : "open project transfers", { format: outputFormat });
4758
+ return;
4759
+ }
4760
+ const columns = directions.length > 1 ? [{ key: "direction" }, ...TRANSFER_ROWS] : TRANSFER_ROWS;
4761
+ format(rows, { format: outputFormat, columns });
4762
+ } catch (error) {
4763
+ handleError(error);
4764
+ }
4765
+ });
4766
+ }
4767
+
4768
+ // src/commands/project/index.ts
4769
+ function getOutputFormat3(cmd) {
4770
+ const config = loadConfig();
4771
+ const globalOpts = cmd.optsWithGlobals();
4772
+ return globalOpts.output ?? config.defaults.output ?? "human";
4773
+ }
4388
4774
  function getOverrides(cmd) {
4389
4775
  const opts = cmd.optsWithGlobals();
4390
4776
  return { project: opts.project, branch: opts.branch };
@@ -4398,7 +4784,7 @@ Examples:
4398
4784
  $ diafunc search "housing" --type project find a project by name
4399
4785
  `).action(async (options, cmd) => {
4400
4786
  try {
4401
- const outputFormat = getOutputFormat2(cmd);
4787
+ const outputFormat = getOutputFormat3(cmd);
4402
4788
  const api = createApiClient();
4403
4789
  const projects = options.all ? await api.admin.getAllProjects() : await api.admin.getProjects();
4404
4790
  const limit = Number.parseInt(options.limit, 10);
@@ -4407,7 +4793,7 @@ Examples:
4407
4793
  try {
4408
4794
  names = await projectNames(api, capped.map((p) => p.projectId));
4409
4795
  } catch {
4410
- console.error(chalk13.dim("Project names are unavailable right now; showing ids."));
4796
+ console.error(chalk14.dim("Project names are unavailable right now; showing ids."));
4411
4797
  }
4412
4798
  const rows = capped.map((p) => ({ name: names.get(p.projectId) ?? null, ...p }));
4413
4799
  format(rows, {
@@ -4424,7 +4810,7 @@ Examples:
4424
4810
  ]
4425
4811
  });
4426
4812
  if (capped.length < projects.length) {
4427
- console.error(chalk13.dim(
4813
+ console.error(chalk14.dim(
4428
4814
  `
4429
4815
  Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
4430
4816
  ));
@@ -4435,7 +4821,7 @@ Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
4435
4821
  });
4436
4822
  project.command("get").description("Get project details").argument("<projectId>", "Project ID").action(async (projectId, _options, cmd) => {
4437
4823
  try {
4438
- const outputFormat = getOutputFormat2(cmd);
4824
+ const outputFormat = getOutputFormat3(cmd);
4439
4825
  const api = createApiClient();
4440
4826
  const p = await api.admin.getProject(projectId);
4441
4827
  format(p, { format: outputFormat });
@@ -4452,7 +4838,7 @@ Examples:
4452
4838
  $ diafunc license list the licenses that can be chosen
4453
4839
  `).action(async (options, cmd) => {
4454
4840
  try {
4455
- const outputFormat = getOutputFormat2(cmd);
4841
+ const outputFormat = getOutputFormat3(cmd);
4456
4842
  const api = createApiClient();
4457
4843
  const p = await api.admin.createProject({
4458
4844
  visibility: options.visibility.toUpperCase(),
@@ -4473,7 +4859,7 @@ Examples:
4473
4859
  if (outputFormat === "human") {
4474
4860
  success("Project created.");
4475
4861
  if (options.name) console.log(` Name: ${options.name}`);
4476
- console.log(` Project ID: ${chalk13.bold(p.projectId)}`);
4862
+ console.log(` Project ID: ${chalk14.bold(p.projectId)}`);
4477
4863
  console.log(` Visibility: ${p.visibility}`);
4478
4864
  console.log(` Language: ${p.language}`);
4479
4865
  if (p.licenceId) console.log(` License: ${p.licenceId}`);
@@ -4535,7 +4921,7 @@ Examples:
4535
4921
  });
4536
4922
  project.command("recent").description("List recently accessed projects").action(async (_options, cmd) => {
4537
4923
  try {
4538
- const outputFormat = getOutputFormat2(cmd);
4924
+ const outputFormat = getOutputFormat3(cmd);
4539
4925
  const api = createApiClient();
4540
4926
  const recent = await api.admin.getRecentProjects();
4541
4927
  format(recent, {
@@ -4578,10 +4964,11 @@ Examples:
4578
4964
  }
4579
4965
  });
4580
4966
  registerTagCommands(project, "project");
4967
+ registerProjectTransferCommands(project);
4581
4968
  const members = project.command("members").description("Manage project members");
4582
4969
  members.command("list").description("List project members").argument("<projectId>", "Project ID").action(async (projectId, _options, cmd) => {
4583
4970
  try {
4584
- const outputFormat = getOutputFormat2(cmd);
4971
+ const outputFormat = getOutputFormat3(cmd);
4585
4972
  const api = createApiClient();
4586
4973
  const memberList = await api.admin.getProjectMembers(projectId);
4587
4974
  format(memberList, {
@@ -4630,7 +5017,7 @@ Examples:
4630
5017
  console.log(`Poll progress: diafunc notebook bundles ${project2}`);
4631
5018
  return;
4632
5019
  }
4633
- console.log(chalk13.dim(`Project export queued (bundle ID: ${bundleId}); waiting for it to finish\u2026`));
5020
+ console.log(chalk14.dim(`Project export queued (bundle ID: ${bundleId}); waiting for it to finish\u2026`));
4634
5021
  const job = await pollUntilFinished(api.storage, ref.projectId, ref.projectBranch, bundleId);
4635
5022
  const response = await api.storage.getBundleContent(ref.projectId, ref.projectBranch, bundleId, job.filename);
4636
5023
  const outFile = options.out ?? "project.dfproj";
@@ -4642,7 +5029,7 @@ Examples:
4642
5029
  });
4643
5030
  project.command("import").description("Import a .dfproj (or any) bundle into a project").argument("<project>", "Target project reference (projectId or projectId/branch)").argument("<file>", "Path to the bundle").option("--on-conflict <policy>", "copy (default; copy only entities whose id already exists, under a new id), overwrite, or skip", "copy").option("--preview", "Show the bundle inventory without importing").action(async (project2, file, options, cmd) => {
4644
5031
  try {
4645
- const outputFormat = getOutputFormat2(cmd);
5032
+ const outputFormat = getOutputFormat3(cmd);
4646
5033
  const overrides = getOverrides(cmd);
4647
5034
  const ref = parseProjectReference(project2, overrides);
4648
5035
  const api = createApiClient();
@@ -4655,32 +5042,9 @@ Examples:
4655
5042
 
4656
5043
  // src/commands/team/index.ts
4657
5044
  import chalk15 from "chalk";
4658
-
4659
- // src/util/confirm.ts
4660
- import * as readline from "readline";
4661
- import chalk14 from "chalk";
4662
- async function confirmDestructive(message, opts = {}) {
4663
- if (!process.stdin.isTTY || opts.yes) return;
4664
- const expected = opts.resourceId ?? "yes";
4665
- const hint2 = opts.resourceId ? `"${opts.resourceId}"` : '"yes"';
4666
- console.log(chalk14.yellow(`! ${message}`));
4667
- const answer = await new Promise((resolve2) => {
4668
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
4669
- rl.question(` Type ${hint2} to confirm: `, (ans) => {
4670
- rl.close();
4671
- resolve2(ans);
4672
- });
4673
- });
4674
- if (answer.trim() !== expected) {
4675
- console.log(chalk14.dim("Aborted."));
4676
- process.exit(1);
4677
- }
4678
- }
4679
-
4680
- // src/commands/team/index.ts
4681
5045
  var ROLES = ["OWNER", "ADMIN", "MEMBER"];
4682
5046
  var INTERVALS = ["MONTHLY", "YEARLY"];
4683
- function getOutputFormat3(cmd) {
5047
+ function getOutputFormat4(cmd) {
4684
5048
  const config = loadConfig();
4685
5049
  const globalOpts = cmd.optsWithGlobals();
4686
5050
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -4745,7 +5109,7 @@ Examples:
4745
5109
  const api = createApiClient();
4746
5110
  const teams = await api.admin.listMyTeams();
4747
5111
  format(teams, {
4748
- format: getOutputFormat3(cmd),
5112
+ format: getOutputFormat4(cmd),
4749
5113
  columns: ["id", "name", "planId", "seatCount", "packCount", "renewal"]
4750
5114
  });
4751
5115
  } catch (error) {
@@ -4756,7 +5120,7 @@ Examples:
4756
5120
  try {
4757
5121
  const api = createApiClient();
4758
5122
  format(await api.admin.getTeam(teamId), {
4759
- format: getOutputFormat3(cmd)
5123
+ format: getOutputFormat4(cmd)
4760
5124
  });
4761
5125
  } catch (error) {
4762
5126
  handleError(error);
@@ -4766,14 +5130,14 @@ Examples:
4766
5130
  try {
4767
5131
  const api = createApiClient();
4768
5132
  await api.admin.setActiveTeam(teamId);
4769
- success(`Active team set to "${teamId}".`, { format: getOutputFormat3(cmd) });
5133
+ success(`Active team set to "${teamId}".`, { format: getOutputFormat4(cmd) });
4770
5134
  } catch (error) {
4771
5135
  handleError(error);
4772
5136
  }
4773
5137
  });
4774
5138
  team.command("usage").description("Show credit usage for a team, broken down by member").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
4775
5139
  try {
4776
- const outputFormat = getOutputFormat3(cmd);
5140
+ const outputFormat = getOutputFormat4(cmd);
4777
5141
  const api = createApiClient();
4778
5142
  const usage = await api.admin.getTeamUsage(teamId);
4779
5143
  if (outputFormat === "json") {
@@ -4802,7 +5166,7 @@ Examples:
4802
5166
  ...options.packs !== void 0 ? { packCount: parseCount(options.packs, "pack count") } : {},
4803
5167
  ...options.currency !== void 0 ? { currency: options.currency.toUpperCase() } : {}
4804
5168
  });
4805
- const outputFormat = getOutputFormat3(cmd);
5169
+ const outputFormat = getOutputFormat4(cmd);
4806
5170
  if (outputFormat === "json") {
4807
5171
  format(session, { format: outputFormat });
4808
5172
  return;
@@ -4817,7 +5181,7 @@ Examples:
4817
5181
  try {
4818
5182
  const api = createApiClient();
4819
5183
  const session = await api.admin.createTeamPortalSession(teamId, options.returnUrl);
4820
- const outputFormat = getOutputFormat3(cmd);
5184
+ const outputFormat = getOutputFormat4(cmd);
4821
5185
  if (outputFormat === "json") {
4822
5186
  format(session, { format: outputFormat });
4823
5187
  return;
@@ -4838,7 +5202,7 @@ Examples:
4838
5202
  const response = await api.admin.cancelTeam(teamId);
4839
5203
  success(
4840
5204
  `Team "${teamId}" canceled. Access ends ${response.endsAt ?? "at the end of the period"}.`,
4841
- { format: getOutputFormat3(cmd) }
5205
+ { format: getOutputFormat4(cmd) }
4842
5206
  );
4843
5207
  } catch (error) {
4844
5208
  handleError(error);
@@ -4852,7 +5216,7 @@ Examples:
4852
5216
  });
4853
5217
  const api = createApiClient();
4854
5218
  await api.admin.leaveTeam(teamId);
4855
- success(`Left team "${teamId}".`, { format: getOutputFormat3(cmd) });
5219
+ success(`Left team "${teamId}".`, { format: getOutputFormat4(cmd) });
4856
5220
  } catch (error) {
4857
5221
  handleError(error);
4858
5222
  }
@@ -4871,7 +5235,7 @@ function registerMemberCommands(team) {
4871
5235
  const all = await api.admin.listTeamMembers(teamId);
4872
5236
  const shown = options.all ? all : all.filter((m) => !m.removedAt);
4873
5237
  format(shown, {
4874
- format: getOutputFormat3(cmd),
5238
+ format: getOutputFormat4(cmd),
4875
5239
  columns: options.all ? ["userId", "name", "email", "role", "joinedAt", "removedAt"] : ["userId", "name", "email", "role", "joinedAt"]
4876
5240
  });
4877
5241
  } catch (error) {
@@ -4884,7 +5248,7 @@ function registerMemberCommands(team) {
4884
5248
  const api = createApiClient();
4885
5249
  await api.admin.inviteTeamMember(teamId, email, role);
4886
5250
  success(`Invited ${email} to team "${teamId}" as ${role}.`, {
4887
- format: getOutputFormat3(cmd)
5251
+ format: getOutputFormat4(cmd)
4888
5252
  });
4889
5253
  } catch (error) {
4890
5254
  handleError(error);
@@ -4899,7 +5263,7 @@ function registerMemberCommands(team) {
4899
5263
  const api = createApiClient();
4900
5264
  await api.admin.removeTeamMember(teamId, userId);
4901
5265
  success(`Removed ${userId} from team "${teamId}".`, {
4902
- format: getOutputFormat3(cmd)
5266
+ format: getOutputFormat4(cmd)
4903
5267
  });
4904
5268
  } catch (error) {
4905
5269
  handleError(error);
@@ -4912,7 +5276,7 @@ function registerInvitationCommands(team) {
4912
5276
  try {
4913
5277
  const api = createApiClient();
4914
5278
  format(await api.admin.listTeamInvitations(teamId), {
4915
- format: getOutputFormat3(cmd),
5279
+ format: getOutputFormat4(cmd),
4916
5280
  columns: ["invitationId", "email", "role", "invitedBy", "expiresAt"]
4917
5281
  });
4918
5282
  } catch (error) {
@@ -4928,7 +5292,7 @@ function registerInvitationCommands(team) {
4928
5292
  const api = createApiClient();
4929
5293
  await api.admin.revokeTeamInvitation(teamId, invitationId);
4930
5294
  success(`Revoked invitation "${invitationId}".`, {
4931
- format: getOutputFormat3(cmd)
5295
+ format: getOutputFormat4(cmd)
4932
5296
  });
4933
5297
  } catch (error) {
4934
5298
  handleError(error);
@@ -4939,7 +5303,7 @@ function registerInvitationCommands(team) {
4939
5303
  const api = createApiClient();
4940
5304
  await api.admin.resendTeamInvitation(teamId, invitationId);
4941
5305
  success(`Resent invitation "${invitationId}".`, {
4942
- format: getOutputFormat3(cmd)
5306
+ format: getOutputFormat4(cmd)
4943
5307
  });
4944
5308
  } catch (error) {
4945
5309
  handleError(error);
@@ -4950,7 +5314,7 @@ function registerInvitationCommands(team) {
4950
5314
  const api = createApiClient();
4951
5315
  const member = await api.admin.acceptTeamInvitation(token);
4952
5316
  success(`Joined the team as ${member.role}.`, {
4953
- format: getOutputFormat3(cmd)
5317
+ format: getOutputFormat4(cmd)
4954
5318
  });
4955
5319
  } catch (error) {
4956
5320
  handleError(error);
@@ -4964,7 +5328,7 @@ function registerSeatCommands(team) {
4964
5328
  const api = createApiClient();
4965
5329
  printInvoicePreview(
4966
5330
  await api.admin.previewTeamSeatCount(teamId, parseCount(count, "seat count")),
4967
- getOutputFormat3(cmd)
5331
+ getOutputFormat4(cmd)
4968
5332
  );
4969
5333
  } catch (error) {
4970
5334
  handleError(error);
@@ -4980,7 +5344,7 @@ function registerSeatCommands(team) {
4980
5344
  const api = createApiClient();
4981
5345
  const change2 = await api.admin.updateTeamSeatCount(teamId, seatCount);
4982
5346
  success(`Seats changed from ${change2.oldSeatCount} to ${change2.newSeatCount}.`, {
4983
- format: getOutputFormat3(cmd)
5347
+ format: getOutputFormat4(cmd)
4984
5348
  });
4985
5349
  } catch (error) {
4986
5350
  handleError(error);
@@ -4994,7 +5358,7 @@ function registerPackCommands(team) {
4994
5358
  const api = createApiClient();
4995
5359
  printInvoicePreview(
4996
5360
  await api.admin.previewTeamPackCount(teamId, parseCount(count, "pack count")),
4997
- getOutputFormat3(cmd)
5361
+ getOutputFormat4(cmd)
4998
5362
  );
4999
5363
  } catch (error) {
5000
5364
  handleError(error);
@@ -5010,7 +5374,7 @@ function registerPackCommands(team) {
5010
5374
  const api = createApiClient();
5011
5375
  const change2 = await api.admin.updateTeamPackCount(teamId, packCount);
5012
5376
  success(`Packs changed from ${change2.oldPackCount} to ${change2.newPackCount}.`, {
5013
- format: getOutputFormat3(cmd)
5377
+ format: getOutputFormat4(cmd)
5014
5378
  });
5015
5379
  } catch (error) {
5016
5380
  handleError(error);
@@ -5027,7 +5391,7 @@ function registerOwnershipCommands(team) {
5027
5391
  );
5028
5392
  const api = createApiClient();
5029
5393
  format(await api.admin.initiateOwnershipTransfer(teamId, userId), {
5030
- format: getOutputFormat3(cmd)
5394
+ format: getOutputFormat4(cmd)
5031
5395
  });
5032
5396
  } catch (error) {
5033
5397
  handleError(error);
@@ -5037,7 +5401,7 @@ function registerOwnershipCommands(team) {
5037
5401
  try {
5038
5402
  const api = createApiClient();
5039
5403
  const pending = await api.admin.getOwnershipTransfer(teamId);
5040
- const outputFormat = getOutputFormat3(cmd);
5404
+ const outputFormat = getOutputFormat4(cmd);
5041
5405
  if (!pending) {
5042
5406
  if (outputFormat === "json") {
5043
5407
  format(null, { format: outputFormat });
@@ -5055,7 +5419,7 @@ function registerOwnershipCommands(team) {
5055
5419
  try {
5056
5420
  const api = createApiClient();
5057
5421
  const response = await api.admin.acceptOwnershipTransfer(teamId);
5058
- const outputFormat = getOutputFormat3(cmd);
5422
+ const outputFormat = getOutputFormat4(cmd);
5059
5423
  if (outputFormat === "json") {
5060
5424
  format(response, { format: outputFormat });
5061
5425
  return;
@@ -5074,7 +5438,7 @@ function registerOwnershipCommands(team) {
5074
5438
  const api = createApiClient();
5075
5439
  await api.admin.cancelOwnershipTransfer(teamId);
5076
5440
  success(`Canceled the ownership transfer for team "${teamId}".`, {
5077
- format: getOutputFormat3(cmd)
5441
+ format: getOutputFormat4(cmd)
5078
5442
  });
5079
5443
  } catch (error) {
5080
5444
  handleError(error);
@@ -5084,7 +5448,7 @@ function registerOwnershipCommands(team) {
5084
5448
 
5085
5449
  // src/commands/entity/index.ts
5086
5450
  import * as fs5 from "fs";
5087
- function getOutputFormat4(cmd) {
5451
+ function getOutputFormat5(cmd) {
5088
5452
  const config = loadConfig();
5089
5453
  const globalOpts = cmd.optsWithGlobals();
5090
5454
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -5107,7 +5471,7 @@ Examples:
5107
5471
  ;
5108
5472
  entity.command("list").description("List entities in a project (via linked entities from project root)").argument("<projectRef>", "Project reference (projectId or projectId/branch)").action(async (projectRef, _options, cmd) => {
5109
5473
  try {
5110
- const outputFormat = getOutputFormat4(cmd);
5474
+ const outputFormat = getOutputFormat5(cmd);
5111
5475
  const overrides = getOverrides2(cmd);
5112
5476
  const ref = parseEntityReference(projectRef + "/" + projectRef, overrides);
5113
5477
  const api = createApiClient();
@@ -5134,7 +5498,7 @@ Examples:
5134
5498
  });
5135
5499
  entity.command("get").description("Get entity metadata").argument("<ref>", "Entity reference").option("--content", "Include content").action(async (ref, options, cmd) => {
5136
5500
  try {
5137
- const outputFormat = getOutputFormat4(cmd);
5501
+ const outputFormat = getOutputFormat5(cmd);
5138
5502
  const overrides = getOverrides2(cmd);
5139
5503
  const resolved = parseEntityReference(ref, overrides);
5140
5504
  const api = createApiClient();
@@ -5177,7 +5541,7 @@ Examples:
5177
5541
  });
5178
5542
  entity.command("history").description("Get entity version history").argument("<ref>", "Entity reference").option("--from <version>", "From version").option("--to <version>", "To version").action(async (ref, options, cmd) => {
5179
5543
  try {
5180
- const outputFormat = getOutputFormat4(cmd);
5544
+ const outputFormat = getOutputFormat5(cmd);
5181
5545
  const overrides = getOverrides2(cmd);
5182
5546
  const resolved = parseEntityReference(ref, overrides);
5183
5547
  const api = createApiClient();
@@ -5294,7 +5658,7 @@ Examples:
5294
5658
  });
5295
5659
  entity.command("import").description("Import a .dfset (or any) bundle into a project").argument("<project>", "Target project reference (projectId or projectId/branch)").argument("<file>", "Path to the bundle").option("--on-conflict <policy>", "copy (default; copy only entities whose id already exists, under a new id), overwrite, or skip", "copy").option("--preview", "Show the bundle inventory without importing").action(async (project, file, options, cmd) => {
5296
5660
  try {
5297
- const outputFormat = getOutputFormat4(cmd);
5661
+ const outputFormat = getOutputFormat5(cmd);
5298
5662
  const overrides = getOverrides2(cmd);
5299
5663
  const ref = parseProjectReference(project, overrides);
5300
5664
  const api = createApiClient();
@@ -5306,7 +5670,7 @@ Examples:
5306
5670
  }
5307
5671
 
5308
5672
  // src/commands/link/index.ts
5309
- function getOutputFormat5(cmd) {
5673
+ function getOutputFormat6(cmd) {
5310
5674
  const config = loadConfig();
5311
5675
  const globalOpts = cmd.optsWithGlobals();
5312
5676
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -5319,7 +5683,7 @@ function registerLinkCommands(program) {
5319
5683
  const link = program.command("link").description("Manage links between entities");
5320
5684
  link.command("list").description("List links for an entity").argument("<ref>", "Source entity reference").option("--direction <dir>", "Link direction: FORWARD or BACKWARD", "FORWARD").action(async (ref, options, cmd) => {
5321
5685
  try {
5322
- const outputFormat = getOutputFormat5(cmd);
5686
+ const outputFormat = getOutputFormat6(cmd);
5323
5687
  const overrides = getOverrides3(cmd);
5324
5688
  const resolved = parseEntityReference(ref, overrides);
5325
5689
  const api = createApiClient();
@@ -5394,7 +5758,7 @@ function registerLinkCommands(program) {
5394
5758
  }
5395
5759
 
5396
5760
  // src/commands/event/index.ts
5397
- function getOutputFormat6(cmd) {
5761
+ function getOutputFormat7(cmd) {
5398
5762
  const config = loadConfig();
5399
5763
  const globalOpts = cmd.optsWithGlobals();
5400
5764
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -5407,7 +5771,7 @@ function registerEventCommands(program) {
5407
5771
  const event = program.command("event").description("Manage events");
5408
5772
  event.command("list").description("List events for an entity").argument("<ref>", "Entity reference").action(async (ref, _options, cmd) => {
5409
5773
  try {
5410
- const outputFormat = getOutputFormat6(cmd);
5774
+ const outputFormat = getOutputFormat7(cmd);
5411
5775
  const overrides = getOverrides4(cmd);
5412
5776
  const resolved = parseEntityReference(ref, overrides);
5413
5777
  const api = createApiClient();
@@ -5429,7 +5793,7 @@ function registerEventCommands(program) {
5429
5793
  });
5430
5794
  event.command("get").description("Get a specific event").argument("<ref>", "Entity reference").argument("<eventId>", "Event ID").argument("<occurrenceId>", "Occurrence ID").action(async (ref, eventId, occurrenceId, _options, cmd) => {
5431
5795
  try {
5432
- const outputFormat = getOutputFormat6(cmd);
5796
+ const outputFormat = getOutputFormat7(cmd);
5433
5797
  const overrides = getOverrides4(cmd);
5434
5798
  const resolved = parseEntityReference(ref, overrides);
5435
5799
  const api = createApiClient();
@@ -5490,7 +5854,7 @@ function registerEventCommands(program) {
5490
5854
  }
5491
5855
 
5492
5856
  // src/commands/branch/index.ts
5493
- function getOutputFormat7(cmd) {
5857
+ function getOutputFormat8(cmd) {
5494
5858
  const config = loadConfig();
5495
5859
  const globalOpts = cmd.optsWithGlobals();
5496
5860
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -5509,7 +5873,7 @@ Examples:
5509
5873
  ;
5510
5874
  branch.command("list").description("List branches for a project").argument("[projectId]", "Project ID (uses default if omitted)").action(async (projectId, _options, cmd) => {
5511
5875
  try {
5512
- const outputFormat = getOutputFormat7(cmd);
5876
+ const outputFormat = getOutputFormat8(cmd);
5513
5877
  const overrides = getOverrides5(cmd);
5514
5878
  const config = loadConfig();
5515
5879
  const pid = projectId ?? overrides.project ?? config.defaults.project;
@@ -5729,7 +6093,7 @@ function buildTableEntity(args) {
5729
6093
 
5730
6094
  // src/commands/table/index.ts
5731
6095
  import { randomUUID as randomUUID2 } from "crypto";
5732
- function getOutputFormat8(cmd) {
6096
+ function getOutputFormat9(cmd) {
5733
6097
  const config = loadConfig();
5734
6098
  const globalOpts = cmd.optsWithGlobals();
5735
6099
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -5792,7 +6156,7 @@ Examples:
5792
6156
  ;
5793
6157
  table.command("view").description("View table data").argument("<ref>", "Table entity reference").option("--rows <range>", "Rows to show, half-open: 0:10 is the first ten, 6490: runs to the end (default: up to 100)").option("--cols <range>", "Columns to show, half-open: 0:5 is the first five (default: up to 50)").action(async (ref, options, cmd) => {
5794
6158
  try {
5795
- const outputFormat = getOutputFormat8(cmd);
6159
+ const outputFormat = getOutputFormat9(cmd);
5796
6160
  const overrides = getOverrides6(cmd);
5797
6161
  const resolved = parseEntityReference(ref, overrides);
5798
6162
  const api = createApiClient();
@@ -5857,7 +6221,7 @@ Examples:
5857
6221
  $ diafunc table create --notebook <notebookId>
5858
6222
  `).action(async (ref, options, cmd) => {
5859
6223
  try {
5860
- const outputFormat = getOutputFormat8(cmd);
6224
+ const outputFormat = getOutputFormat9(cmd);
5861
6225
  const overrides = getOverrides6(cmd);
5862
6226
  const resolved = parseEntityReference(ref ?? randomUUID2(), overrides);
5863
6227
  if (resolved.entityId.includes(".partition.")) {
@@ -5946,7 +6310,7 @@ Examples:
5946
6310
  });
5947
6311
  table.command("import-formats").description("List supported import formats").action(async (_options, cmd) => {
5948
6312
  try {
5949
- const outputFormat = getOutputFormat8(cmd);
6313
+ const outputFormat = getOutputFormat9(cmd);
5950
6314
  const api = createApiClient();
5951
6315
  const response = await api.storage.getSupportedImportFormats();
5952
6316
  if (outputFormat === "json") {
@@ -6037,7 +6401,7 @@ Examples:
6037
6401
  });
6038
6402
  table.command("export-formats").description("List supported export formats").action(async (_options, cmd) => {
6039
6403
  try {
6040
- const outputFormat = getOutputFormat8(cmd);
6404
+ const outputFormat = getOutputFormat9(cmd);
6041
6405
  const api = createApiClient();
6042
6406
  const response = await api.storage.getSupportedExportFormats();
6043
6407
  if (outputFormat === "json") {
@@ -6062,7 +6426,7 @@ Examples:
6062
6426
  const exportsCmd = table.command("exports").description("Track and download async table exports");
6063
6427
  exportsCmd.command("list").description("List async exports for a table entity").argument("<ref>", "Table entity reference").action(async (ref, _options, cmd) => {
6064
6428
  try {
6065
- const outputFormat = getOutputFormat8(cmd);
6429
+ const outputFormat = getOutputFormat9(cmd);
6066
6430
  const overrides = getOverrides6(cmd);
6067
6431
  const resolved = parseEntityReference(ref, overrides);
6068
6432
  const api = createApiClient();
@@ -6090,7 +6454,7 @@ Examples:
6090
6454
  });
6091
6455
  exportsCmd.command("get").description("Get async export status; download the file once the export has succeeded").argument("<exportId>", "Export ID returned by `table export --async`").requiredOption("--ref <ref>", "Table entity reference").option("--out <file>", "Output file path (defaults to the original export filename)").action(async (exportId, options, cmd) => {
6092
6456
  try {
6093
- const outputFormat = getOutputFormat8(cmd);
6457
+ const outputFormat = getOutputFormat9(cmd);
6094
6458
  const overrides = getOverrides6(cmd);
6095
6459
  const resolved = parseEntityReference(options.ref, overrides);
6096
6460
  const api = createApiClient();
@@ -6259,7 +6623,7 @@ Examples:
6259
6623
  import chalk17 from "chalk";
6260
6624
  import * as fs7 from "fs";
6261
6625
  import * as path5 from "path";
6262
- function getOutputFormat9(cmd) {
6626
+ function getOutputFormat10(cmd) {
6263
6627
  const config = loadConfig();
6264
6628
  const globalOpts = cmd.optsWithGlobals();
6265
6629
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -6299,7 +6663,7 @@ Examples:
6299
6663
  });
6300
6664
  notebook.command("import").description("Import a .dfnb bundle into a project").argument("<project>", "Target project reference (projectId or projectId/branch)").argument("<file>", "Path to the .dfnb bundle").option("--on-conflict <policy>", "copy (default; copy only entities whose id already exists, under a new id), overwrite, or skip", "copy").option("--preview", "Show the bundle inventory without importing").action(async (project, file, options, cmd) => {
6301
6665
  try {
6302
- const outputFormat = getOutputFormat9(cmd);
6666
+ const outputFormat = getOutputFormat10(cmd);
6303
6667
  const overrides = getOverrides7(cmd);
6304
6668
  const ref = parseProjectReference(project, overrides);
6305
6669
  const api = createApiClient();
@@ -6345,7 +6709,7 @@ Examples:
6345
6709
  });
6346
6710
  notebook.command("bundles").description("List notebook-bundle export jobs for a project").argument("<project>", "Project reference (projectId or projectId/branch)").action(async (project, _options, cmd) => {
6347
6711
  try {
6348
- const outputFormat = getOutputFormat9(cmd);
6712
+ const outputFormat = getOutputFormat10(cmd);
6349
6713
  const overrides = getOverrides7(cmd);
6350
6714
  const ref = parseProjectReference(project, overrides);
6351
6715
  const api = createApiClient();
@@ -6479,13 +6843,16 @@ function resultText(result, resultEncoding) {
6479
6843
  if (result === null || result === void 0) return null;
6480
6844
  if (resultEncoding === "json") return typeof result === "string" ? result : JSON.stringify(result);
6481
6845
  if (resultEncoding === "text") return String(result);
6846
+ if (resultEncoding !== "base64") {
6847
+ throw new Error(`A function result without a known encoding cannot be read (resultEncoding: ${resultEncoding})`);
6848
+ }
6482
6849
  const bytes = Buffer.from(String(result), "base64");
6483
6850
  const text2 = bytes.toString("utf-8");
6484
6851
  return Buffer.from(text2, "utf-8").equals(bytes) ? text2 : String(result);
6485
6852
  }
6486
6853
 
6487
6854
  // src/commands/function/index.ts
6488
- function getOutputFormat10(cmd) {
6855
+ function getOutputFormat11(cmd) {
6489
6856
  const config = loadConfig();
6490
6857
  const globalOpts = cmd.optsWithGlobals();
6491
6858
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -6515,7 +6882,7 @@ Examples:
6515
6882
  ;
6516
6883
  fn.command("call").description("Execute a function").argument("<ref>", "Function entity reference").option("--async", "Execute asynchronously").option("--args <json>", "Arguments as JSON object").option("--target <ref>", "Target entity reference").action(async (ref, options, cmd) => {
6517
6884
  try {
6518
- const outputFormat = getOutputFormat10(cmd);
6885
+ const outputFormat = getOutputFormat11(cmd);
6519
6886
  const overrides = getOverrides8(cmd);
6520
6887
  const resolved = parseEntityReference(ref, overrides);
6521
6888
  const api = createApiClient();
@@ -6596,7 +6963,7 @@ Examples:
6596
6963
  });
6597
6964
  fn.command("evaluations").description("List evaluations for a function").argument("<ref>", "Function entity reference").requiredOption("--date <date>", "Date and hour (YYYY-MM-DD-HH in UTC)").action(async (ref, options, cmd) => {
6598
6965
  try {
6599
- const outputFormat = getOutputFormat10(cmd);
6966
+ const outputFormat = getOutputFormat11(cmd);
6600
6967
  const overrides = getOverrides8(cmd);
6601
6968
  const resolved = parseEntityReference(ref, overrides);
6602
6969
  const api = createApiClient();
@@ -6637,7 +7004,7 @@ Examples:
6637
7004
  });
6638
7005
  fn.command("outputs").description("Get outputs for an evaluation").argument("<projectId>", "Project ID").argument("<evaluationId>", "Evaluation ID").action(async (projectId, evaluationId, _options, cmd) => {
6639
7006
  try {
6640
- const outputFormat = getOutputFormat10(cmd);
7007
+ const outputFormat = getOutputFormat11(cmd);
6641
7008
  const api = createApiClient();
6642
7009
  const outputs = await api.evaluation.getOutputs(projectId, evaluationId);
6643
7010
  if (outputFormat === "human") {
@@ -6657,7 +7024,7 @@ Examples:
6657
7024
  });
6658
7025
  fn.command("logs").description("Get logs for a function evaluation").argument("<ref>", "Function entity reference").requiredOption("--date <date>", "Date and hour (YYYY-MM-DD-HH in UTC)").action(async (ref, options, cmd) => {
6659
7026
  try {
6660
- const outputFormat = getOutputFormat10(cmd);
7027
+ const outputFormat = getOutputFormat11(cmd);
6661
7028
  const overrides = getOverrides8(cmd);
6662
7029
  const resolved = parseEntityReference(ref, overrides);
6663
7030
  const api = createApiClient();
@@ -6703,7 +7070,7 @@ Examples:
6703
7070
  });
6704
7071
  fn.command("languages").description("List the languages a function can be written in").action(async (_options, cmd) => {
6705
7072
  try {
6706
- const outputFormat = getOutputFormat10(cmd);
7073
+ const outputFormat = getOutputFormat11(cmd);
6707
7074
  format(
6708
7075
  FUNCTION_LANGUAGES.map((language) => ({
6709
7076
  language,
@@ -6717,7 +7084,7 @@ Examples:
6717
7084
  });
6718
7085
  fn.command("last-evaluation").description("Show the most recent evaluation of a function").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
6719
7086
  try {
6720
- const outputFormat = getOutputFormat10(cmd);
7087
+ const outputFormat = getOutputFormat11(cmd);
6721
7088
  const overrides = getOverrides8(cmd);
6722
7089
  const resolved = parseEntityReference(ref, overrides);
6723
7090
  const api = createApiClient();
@@ -7529,9 +7896,11 @@ var BY_COMMAND = {
7529
7896
  "config set": { "<key>": { kind: "choice", choices: CONFIG_KEYS } },
7530
7897
  "project members invite": { "<userId>": TEXT, "<role>": { kind: "choice", choices: PROJECT_ROLES } },
7531
7898
  "project members join": { "<userId>": TEXT },
7899
+ "license create": { "<licenseId>": TEXT, "--name": TEXT, "--flags": TEXT },
7532
7900
  "trigger create": { "--type": { kind: "choice", choices: TRIGGER_TYPES } },
7533
7901
  "analyze triggers create": { "--kind": { kind: "choice", choices: ANALYSIS_TRIGGER_KINDS } },
7534
7902
  "function outputs": { "<evaluationId>": TEXT },
7903
+ "admin project move": { "--to": TEXT },
7535
7904
  "team create": { "--seats": { kind: "number", min: 1, integer: true } },
7536
7905
  "team seats preview": { "<count>": { kind: "number", min: 1, integer: true } },
7537
7906
  "team seats set": { "<count>": { kind: "number", min: 1, integer: true } }
@@ -7589,7 +7958,10 @@ var BY_NAME = {
7589
7958
  consumerType: TEXT,
7590
7959
  consumerId: TEXT,
7591
7960
  format: TEXT,
7592
- key: TEXT
7961
+ key: TEXT,
7962
+ reason: TEXT,
7963
+ batchId: TEXT,
7964
+ userIdOrEmail: TEXT
7593
7965
  };
7594
7966
  function tokenOf(input) {
7595
7967
  return input.kind === "option" ? input.flag ?? `--${input.name}` : `<${input.name}>`;
@@ -7665,7 +8037,7 @@ function dependencies(spec) {
7665
8037
  }
7666
8038
 
7667
8039
  // src/commands/trigger/index.ts
7668
- function getOutputFormat11(cmd) {
8040
+ function getOutputFormat12(cmd) {
7669
8041
  const config = loadConfig();
7670
8042
  const globalOpts = cmd.optsWithGlobals();
7671
8043
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -7684,7 +8056,7 @@ Examples:
7684
8056
  `);
7685
8057
  trigger.command("list").description("List triggers for a function").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
7686
8058
  try {
7687
- const outputFormat = getOutputFormat11(cmd);
8059
+ const outputFormat = getOutputFormat12(cmd);
7688
8060
  const overrides = getOverrides9(cmd);
7689
8061
  const resolved = parseEntityReference(ref, overrides);
7690
8062
  const api = createApiClient();
@@ -7713,7 +8085,7 @@ Examples:
7713
8085
  });
7714
8086
  trigger.command("get").description("Get a specific trigger").argument("<ref>", "Function entity reference").argument("<triggerId>", "Trigger ID").action(async (ref, triggerId, _options, cmd) => {
7715
8087
  try {
7716
- const outputFormat = getOutputFormat11(cmd);
8088
+ const outputFormat = getOutputFormat12(cmd);
7717
8089
  const overrides = getOverrides9(cmd);
7718
8090
  const resolved = parseEntityReference(ref, overrides);
7719
8091
  const api = createApiClient();
@@ -7805,7 +8177,7 @@ Examples:
7805
8177
  }
7806
8178
 
7807
8179
  // src/commands/schedule/index.ts
7808
- function getOutputFormat12(cmd) {
8180
+ function getOutputFormat13(cmd) {
7809
8181
  const config = loadConfig();
7810
8182
  const globalOpts = cmd.optsWithGlobals();
7811
8183
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -7818,7 +8190,7 @@ function registerScheduleCommands(program) {
7818
8190
  const schedule = program.command("schedule").description("Schedule function execution");
7819
8191
  schedule.command("call").description("Schedule a function call").argument("<ref>", "Function entity reference").option("--args <json>", "Arguments as JSON object").option("--target <ref>", "Target entity reference").action(async (ref, options, cmd) => {
7820
8192
  try {
7821
- const outputFormat = getOutputFormat12(cmd);
8193
+ const outputFormat = getOutputFormat13(cmd);
7822
8194
  const overrides = getOverrides10(cmd);
7823
8195
  const resolved = parseEntityReference(ref, overrides);
7824
8196
  const api = createApiClient();
@@ -7887,7 +8259,7 @@ function registerScheduleCommands(program) {
7887
8259
  });
7888
8260
  schedule.command("list").description("List persistent triggers (scheduled functions are modeled as triggers)").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
7889
8261
  try {
7890
- const outputFormat = getOutputFormat12(cmd);
8262
+ const outputFormat = getOutputFormat13(cmd);
7891
8263
  const overrides = getOverrides10(cmd);
7892
8264
  const resolved = parseEntityReference(ref, overrides);
7893
8265
  const api = createApiClient();
@@ -8015,7 +8387,7 @@ function inline(text2) {
8015
8387
  }
8016
8388
 
8017
8389
  // src/commands/chat/index.ts
8018
- function getOutputFormat13(cmd) {
8390
+ function getOutputFormat14(cmd) {
8019
8391
  const config = loadConfig();
8020
8392
  const globalOpts = cmd.optsWithGlobals();
8021
8393
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -8100,7 +8472,7 @@ var HELP = [
8100
8472
  ];
8101
8473
  async function runChatRepl(options) {
8102
8474
  const { input: promptInput } = await import("@inquirer/prompts");
8103
- const { getUpdateNotice } = await import("./update-check-KHHHTIDF.js");
8475
+ const { getUpdateNotice } = await import("./update-check-2GW2RLWY.js");
8104
8476
  let sessionId = options.session;
8105
8477
  let lastReportedSession;
8106
8478
  console.log(chalk21.bold("Diafunc chat") + chalk21.dim(" \xB7 /help for commands, /quit to exit"));
@@ -8207,7 +8579,7 @@ Examples:
8207
8579
  });
8208
8580
  chat.command("send").description("Send a chat message (blocking). Project context: the global --project and --branch").argument("<message>", "Message to send").option("--session <id>", "Session ID to continue").action(async (message, options, cmd) => {
8209
8581
  try {
8210
- const outputFormat = getOutputFormat13(cmd);
8582
+ const outputFormat = getOutputFormat14(cmd);
8211
8583
  const api = createApiClient();
8212
8584
  const context = chatContext(cmd);
8213
8585
  const response = await api.language.chat({
@@ -8231,7 +8603,7 @@ Examples:
8231
8603
  });
8232
8604
  chat.command("stream").description("Send a chat message (streaming). Project context: the global --project and --branch").argument("<message>", "Message to send").option("--session <id>", "Session ID to continue").action(async (message, options, cmd) => {
8233
8605
  try {
8234
- const outputFormat = getOutputFormat13(cmd);
8606
+ const outputFormat = getOutputFormat14(cmd);
8235
8607
  const api = createApiClient();
8236
8608
  const context = chatContext(cmd);
8237
8609
  const response = await api.language.chatStream({
@@ -8321,7 +8693,7 @@ Examples:
8321
8693
  const session = chat.command("session").description("Manage chat sessions");
8322
8694
  session.command("list").description("List chat sessions").action(async (_options, cmd) => {
8323
8695
  try {
8324
- const outputFormat = getOutputFormat13(cmd);
8696
+ const outputFormat = getOutputFormat14(cmd);
8325
8697
  const api = createApiClient();
8326
8698
  const sessions = await api.language.getSessions();
8327
8699
  format(sessions, {
@@ -8343,7 +8715,7 @@ Examples:
8343
8715
  });
8344
8716
  session.command("show").description("Show the message history of a chat session").argument("<sessionId>", "Session ID").action(async (sessionId, _options, cmd) => {
8345
8717
  try {
8346
- const outputFormat = getOutputFormat13(cmd);
8718
+ const outputFormat = getOutputFormat14(cmd);
8347
8719
  const api = createApiClient();
8348
8720
  const detail2 = await api.language.getSession(sessionId);
8349
8721
  if (outputFormat === "human") {
@@ -8373,7 +8745,7 @@ Examples:
8373
8745
  });
8374
8746
  chat.command("usage").description("Show token usage").action(async (_options, cmd) => {
8375
8747
  try {
8376
- const outputFormat = getOutputFormat13(cmd);
8748
+ const outputFormat = getOutputFormat14(cmd);
8377
8749
  const api = createApiClient();
8378
8750
  const usage = await api.language.getUsage();
8379
8751
  format(usage, { format: outputFormat });
@@ -8385,7 +8757,7 @@ Examples:
8385
8757
 
8386
8758
  // src/commands/search/index.ts
8387
8759
  import chalk22 from "chalk";
8388
- function getOutputFormat14(cmd) {
8760
+ function getOutputFormat15(cmd) {
8389
8761
  const config = loadConfig();
8390
8762
  const globalOpts = cmd.optsWithGlobals();
8391
8763
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -8408,7 +8780,7 @@ whose discovered model has the better quality comes first; inside one project th
8408
8780
  `).action(async (query, options, cmd) => {
8409
8781
  const sort = parseSort(options.sort);
8410
8782
  try {
8411
- const outputFormat = getOutputFormat14(cmd);
8783
+ const outputFormat = getOutputFormat15(cmd);
8412
8784
  const overrides = cmd.optsWithGlobals();
8413
8785
  const config = loadConfig();
8414
8786
  const api = createApiClient();
@@ -8502,11 +8874,11 @@ function collapse(text2) {
8502
8874
  }
8503
8875
 
8504
8876
  // src/commands/admin/index.ts
8505
- import { readFile } from "fs/promises";
8877
+ import { readFile as readFile2 } from "fs/promises";
8506
8878
 
8507
8879
  // src/commands/admin/curated-tags.ts
8508
8880
  import chalk23 from "chalk";
8509
- function getOutputFormat15(cmd) {
8881
+ function getOutputFormat16(cmd) {
8510
8882
  const config = loadConfig();
8511
8883
  const globalOpts = cmd.optsWithGlobals();
8512
8884
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -8548,7 +8920,7 @@ Examples:
8548
8920
  $ diafunc admin curated-tags list -o json
8549
8921
  `).action(async (_options, cmd) => {
8550
8922
  try {
8551
- const outputFormat = getOutputFormat15(cmd);
8923
+ const outputFormat = getOutputFormat16(cmd);
8552
8924
  const tags = await createApiClient().index.getCuratedTags(true);
8553
8925
  if (tags.length === 0) {
8554
8926
  empty("curated tags", { format: outputFormat });
@@ -8565,7 +8937,7 @@ Examples:
8565
8937
  $ diafunc admin curated-tags create "Machine Learning" --display-name "Machine learning" --dry-run
8566
8938
  `).action(async (typed2, options, cmd) => {
8567
8939
  try {
8568
- const outputFormat = getOutputFormat15(cmd);
8940
+ const outputFormat = getOutputFormat16(cmd);
8569
8941
  const tag = curatedTagOf(typed2);
8570
8942
  if (isReservedTag(tag)) {
8571
8943
  usageError(`"${tag}" is reserved for the staging content of analysis runs and is never searchable.`);
@@ -8598,7 +8970,7 @@ Examples:
8598
8970
  $ diafunc admin curated-tags update health --sort-order 3 --dry-run
8599
8971
  `).action(async (typed2, options, cmd) => {
8600
8972
  try {
8601
- const outputFormat = getOutputFormat15(cmd);
8973
+ const outputFormat = getOutputFormat16(cmd);
8602
8974
  const tag = curatedTagOf(typed2);
8603
8975
  if (options.displayName === void 0 && options.description === void 0 && options.sortOrder === void 0) {
8604
8976
  usageError("Nothing to change.", "Pass at least one of --display-name, --description, --sort-order.");
@@ -8628,7 +9000,7 @@ Examples:
8628
9000
  $ diafunc admin curated-tags delete health --yes --dry-run
8629
9001
  `).action(async (typed2, options, cmd) => {
8630
9002
  try {
8631
- const outputFormat = getOutputFormat15(cmd);
9003
+ const outputFormat = getOutputFormat16(cmd);
8632
9004
  const tag = curatedTagOf(typed2);
8633
9005
  if (!isDryRun()) {
8634
9006
  await confirmDestructive(`This removes "${tag}" from Explore's data-domain filter.`, { yes: options.yes, resourceId: tag });
@@ -8642,8 +9014,261 @@ Examples:
8642
9014
  });
8643
9015
  }
8644
9016
 
9017
+ // src/util/id-list.ts
9018
+ import { readFile } from "fs/promises";
9019
+ function parseIdList(text2) {
9020
+ const ids = text2.split(/\r?\n/).map((line) => line.replace(/#.*$/, "")).flatMap((line) => line.split(/[\s,]+/)).map((id) => id.trim()).filter((id) => id.length > 0);
9021
+ return [...new Set(ids)];
9022
+ }
9023
+ async function readIdList(source, stdin = process.stdin) {
9024
+ const text2 = source === "-" ? await readAll(stdin) : await readFile(source, "utf-8");
9025
+ return parseIdList(text2);
9026
+ }
9027
+ function readAll(stream) {
9028
+ return new Promise((resolve2, reject) => {
9029
+ let data = "";
9030
+ stream.setEncoding("utf-8");
9031
+ stream.on("data", (chunk) => {
9032
+ data += chunk;
9033
+ });
9034
+ stream.on("end", () => resolve2(data));
9035
+ stream.on("error", reject);
9036
+ });
9037
+ }
9038
+ function mergeIds(...lists) {
9039
+ return [...new Set(lists.flat().map((id) => id.trim()).filter((id) => id.length > 0))];
9040
+ }
9041
+
9042
+ // src/commands/admin/projects.ts
9043
+ function getOutputFormat17(cmd) {
9044
+ const config = loadConfig();
9045
+ const globalOpts = cmd.optsWithGlobals();
9046
+ return globalOpts.output ?? config.defaults.output ?? "human";
9047
+ }
9048
+ var MAX_PROJECTS_PER_MOVE = 500;
9049
+ var OPERATOR_TRANSFER_STATUSES = ["open", "moving", "failed"];
9050
+ async function collectProjectIds(args, idsFile) {
9051
+ const fromFile = idsFile ? await readIdList(idsFile) : [];
9052
+ const ids = mergeIds(args, fromFile);
9053
+ if (ids.length === 0) {
9054
+ throw new CliError("Name the projects to move, as arguments or with --ids-file <path|->.", { exitCode: EXIT_USAGE });
9055
+ }
9056
+ if (ids.length > MAX_PROJECTS_PER_MOVE) {
9057
+ throw new CliError(
9058
+ `${ids.length} projects named; one move takes at most ${MAX_PROJECTS_PER_MOVE}. Split the list.`,
9059
+ { exitCode: EXIT_USAGE }
9060
+ );
9061
+ }
9062
+ return ids;
9063
+ }
9064
+ function moveRequest(options) {
9065
+ const reason2 = options.reason.trim();
9066
+ if (!reason2) throw new CliError("A move needs a reason: --reason <text>.", { exitCode: EXIT_USAGE });
9067
+ const toUserId = options.to.trim();
9068
+ if (!toUserId) throw new CliError("Name the new owner with --to <userId>.", { exitCode: EXIT_USAGE });
9069
+ return {
9070
+ toUserId,
9071
+ ...options.team ? { toTeamId: options.team } : {},
9072
+ previousOwnerRole: options.keepPreviousOwner ? "MAINTAINER" : "NONE",
9073
+ reason: reason2,
9074
+ notify: options.notify
9075
+ };
9076
+ }
9077
+ function moveWarning(projectIds, request) {
9078
+ const what = projectIds.length === 1 ? `project "${projectIds[0]}"` : `${projectIds.length} projects`;
9079
+ const into = request.toTeamId ? ` into team ${request.toTeamId}` : "";
9080
+ const previous = request.previousOwnerRole === "MAINTAINER" ? "Each previous owner stays on as a maintainer" : "Each previous owner loses access";
9081
+ const mail = request.notify ? "both owners are told" : "nobody is notified";
9082
+ return `This will move ${what} to user ${request.toUserId}${into} without asking anyone. ${previous}; ${mail}.`;
9083
+ }
9084
+ function preflightVerdicts(result) {
9085
+ if (!result) return [];
9086
+ if (Array.isArray(result)) return result;
9087
+ return Array.isArray(result.items) ? result.items : [];
9088
+ }
9089
+ function isMovable(verdict) {
9090
+ return verdict.verdict === "ok";
9091
+ }
9092
+ function parseOperatorStatus(value) {
9093
+ if (value === void 0) return void 0;
9094
+ const status = value.trim().toLowerCase();
9095
+ if (!OPERATOR_TRANSFER_STATUSES.includes(status)) {
9096
+ throw new CliError(`Invalid status "${value}". Use one of: ${OPERATOR_TRANSFER_STATUSES.join(", ")}.`, { exitCode: EXIT_USAGE });
9097
+ }
9098
+ return status;
9099
+ }
9100
+ function splitBatch(batch) {
9101
+ const { items, ...summary } = batch;
9102
+ return { summary, items: items ?? [] };
9103
+ }
9104
+ function registerAdminProjectCommands(admin) {
9105
+ const project = admin.command("project").description("Move projects between accounts and repair stuck transfers (admin)");
9106
+ project.command("move").description("Move projects to another owner at once, without an offer or acceptance").argument("[projectIds...]", "Project IDs; more can come from --ids-file").requiredOption("--to <userId>", "User ID of the new owner").requiredOption("--reason <text>", "Why the projects move; stored in the activity log").option("--team <teamId>", "Put the projects into this team of the new owner instead of the new owner's active team").option("--ids-file <path>", 'Read project IDs from a file, or from stdin with "-": one per line, or separated by spaces or commas; "#" starts a comment').option("--keep-previous-owner", "Keep each previous owner on their project as a maintainer, with edit rights").option("--no-notify", "Send no notification or e-mail to the previous and the new owner").option("--preflight", "Only check: print what each project would do and change nothing").option("-y, --yes", "Skip the confirmation prompt").addHelpText("after", `
9107
+ A single project moves right away and the command prints the finished transfer. Several move as a
9108
+ batch in the background (at most ${MAX_PROJECTS_PER_MOVE} per call; super-admin only); follow it with
9109
+ 'diafunc admin project moves status <batchId>'.
9110
+
9111
+ --preflight prints one verdict per project: ok, busy:<what is running>, not_found, already_owner or
9112
+ open_transfer, and exits 1 if any project could not move.
9113
+
9114
+ Examples:
9115
+ $ diafunc admin project move <projectId> --to <userId> --reason "Support ticket 4711"
9116
+ $ diafunc admin project move --ids-file examples.txt --to <userId> --reason "Examples account" --no-notify --preflight
9117
+ $ cat examples.txt | diafunc admin project move --ids-file - --to <userId> --reason "Examples account" --no-notify -y
9118
+ `).action(async (args, options, cmd) => {
9119
+ let blocked = 0;
9120
+ try {
9121
+ const projectIds = await collectProjectIds(args, options.idsFile);
9122
+ const request = moveRequest(options);
9123
+ const outputFormat = getOutputFormat17(cmd);
9124
+ const api = createApiClient();
9125
+ if (options.preflight) {
9126
+ const result = await api.admin.moveProjects({
9127
+ ...request,
9128
+ projectIds,
9129
+ preflight: true,
9130
+ expectedCount: projectIds.length
9131
+ });
9132
+ if (isDryRun()) return;
9133
+ const verdicts = preflightVerdicts(result);
9134
+ blocked = verdicts.filter((v) => !isMovable(v)).length;
9135
+ if (outputFormat !== "human") {
9136
+ format(result, { format: outputFormat });
9137
+ } else {
9138
+ format(verdicts, { format: outputFormat, columns: [{ key: "projectId", kind: "id" }, { key: "verdict" }] });
9139
+ console.log("");
9140
+ const movable = verdicts.length - blocked;
9141
+ if (blocked === 0) success(`All ${movable} projects can move. Nothing was changed.`);
9142
+ else warn(`${movable} of ${verdicts.length} projects can move; ${blocked} cannot. Nothing was changed.`);
9143
+ }
9144
+ } else if (projectIds.length === 1) {
9145
+ await confirmDestructive(moveWarning(projectIds, request), { yes: options.yes, resourceId: projectIds[0] });
9146
+ const moved = await api.admin.moveProject(projectIds[0], request);
9147
+ if (isDryRun()) return;
9148
+ if (outputFormat !== "human") {
9149
+ format(moved, { format: outputFormat });
9150
+ } else {
9151
+ success(`Moved project "${moved.projectName ?? projectIds[0]}" to ${moved.toUserName ?? request.toUserId}.`);
9152
+ }
9153
+ } else {
9154
+ await confirmDestructive(moveWarning(projectIds, request), {
9155
+ yes: options.yes,
9156
+ resourceId: String(projectIds.length)
9157
+ });
9158
+ const started = await api.admin.moveProjects({
9159
+ ...request,
9160
+ projectIds,
9161
+ preflight: false,
9162
+ expectedCount: projectIds.length
9163
+ });
9164
+ if (isDryRun()) return;
9165
+ if (outputFormat !== "human") {
9166
+ format(started, { format: outputFormat });
9167
+ } else {
9168
+ success(`Started moving ${projectIds.length} projects (batch ID: ${started.batchId}).`);
9169
+ hint(`Follow it with 'diafunc admin project moves status ${started.batchId}'.`);
9170
+ }
9171
+ }
9172
+ } catch (error) {
9173
+ handleError(error);
9174
+ }
9175
+ if (blocked > 0) process.exit(EXIT_FAILURE);
9176
+ });
9177
+ const moves = project.command("moves").description("Follow bulk moves");
9178
+ moves.command("status", { isDefault: true }).description("Show the progress of a bulk move and each project in it").argument("<batchId>", "Batch ID, as printed when the move started").action(async (batchId, _options, cmd) => {
9179
+ try {
9180
+ const api = createApiClient();
9181
+ const batch = await api.admin.getProjectMoveBatch(batchId);
9182
+ const outputFormat = getOutputFormat17(cmd);
9183
+ if (outputFormat !== "human") {
9184
+ format(batch, { format: outputFormat });
9185
+ return;
9186
+ }
9187
+ const { summary, items } = splitBatch(batch);
9188
+ format(summary, { format: outputFormat });
9189
+ if (items.length > 0) {
9190
+ console.log("");
9191
+ format(items, { format: outputFormat });
9192
+ }
9193
+ } catch (error) {
9194
+ handleError(error);
9195
+ }
9196
+ });
9197
+ const transfers = project.command("transfers").description("Inspect and repair project transfers");
9198
+ transfers.command("list", { isDefault: true }).description("List open offers and transfers that are moving or failed").option("--status <status>", `Only transfers in this state: ${OPERATOR_TRANSFER_STATUSES.join(", ")}`).action(async (options, cmd) => {
9199
+ try {
9200
+ const status = parseOperatorStatus(options.status);
9201
+ const api = createApiClient();
9202
+ const list = await api.admin.listOperatorProjectTransfers(status) ?? [];
9203
+ const outputFormat = getOutputFormat17(cmd);
9204
+ if (list.length === 0) {
9205
+ empty("project transfers", { format: outputFormat });
9206
+ return;
9207
+ }
9208
+ format(list, {
9209
+ format: outputFormat,
9210
+ columns: [
9211
+ { key: "projectName", header: "project" },
9212
+ { key: "projectId", kind: "id" },
9213
+ { key: "transferId", kind: "id" },
9214
+ { key: "status", kind: "state" },
9215
+ { key: "kind" },
9216
+ { key: "fromUserName", header: "from" },
9217
+ { key: "toUserName", header: "to" },
9218
+ { key: "offeredAt", kind: "date" },
9219
+ { key: "expiresAt", kind: "date" }
9220
+ ]
9221
+ });
9222
+ } catch (error) {
9223
+ handleError(error);
9224
+ }
9225
+ });
9226
+ transfers.command("resume").description("Run a transfer that is stuck while moving again, from the first step it has not done").argument("<projectId>", "Project ID").requiredOption("--reason <text>", "Why it is resumed; stored in the activity log").action(async (projectId, options, cmd) => {
9227
+ try {
9228
+ const api = createApiClient();
9229
+ await api.admin.resumeProjectTransfer(projectId, requireReason(options.reason));
9230
+ success(`Resumed the transfer of project "${projectId}".`, { format: getOutputFormat17(cmd) });
9231
+ } catch (error) {
9232
+ handleError(error);
9233
+ }
9234
+ });
9235
+ transfers.command("abort").description("Undo a stuck transfer that has not reached its commit step; past it, resume instead").argument("<projectId>", "Project ID").requiredOption("--reason <text>", "Why it is aborted; stored in the activity log").option("-y, --yes", "Skip the confirmation prompt").action(async (projectId, options, cmd) => {
9236
+ try {
9237
+ const reason2 = requireReason(options.reason);
9238
+ await confirmDestructive(
9239
+ `This will undo the steps the transfer of project "${projectId}" has done and leave it with its previous owner.`,
9240
+ { yes: options.yes, resourceId: projectId }
9241
+ );
9242
+ const api = createApiClient();
9243
+ await api.admin.abortProjectTransfer(projectId, reason2);
9244
+ success(`Aborted the transfer of project "${projectId}".`, { format: getOutputFormat17(cmd) });
9245
+ } catch (error) {
9246
+ handleError(error);
9247
+ }
9248
+ });
9249
+ transfers.command("cancel").description("Cancel an open offer on the owner's behalf").argument("<projectId>", "Project ID").requiredOption("--reason <text>", "Why it is canceled; stored in the activity log").option("-y, --yes", "Skip the confirmation prompt").action(async (projectId, options, cmd) => {
9250
+ try {
9251
+ const reason2 = requireReason(options.reason);
9252
+ await confirmDestructive(
9253
+ `This will cancel the open offer of project "${projectId}". The owner can offer it again.`,
9254
+ { yes: options.yes, resourceId: projectId }
9255
+ );
9256
+ const api = createApiClient();
9257
+ await api.admin.cancelProjectTransferAsOperator(projectId, reason2);
9258
+ success(`Canceled the open offer of project "${projectId}".`, { format: getOutputFormat17(cmd) });
9259
+ } catch (error) {
9260
+ handleError(error);
9261
+ }
9262
+ });
9263
+ }
9264
+ function requireReason(reason2) {
9265
+ const trimmed = reason2.trim();
9266
+ if (!trimmed) throw new CliError("Give a reason with --reason <text>.", { exitCode: EXIT_USAGE });
9267
+ return trimmed;
9268
+ }
9269
+
8645
9270
  // src/commands/admin/index.ts
8646
- function getOutputFormat16(cmd) {
9271
+ function getOutputFormat18(cmd) {
8647
9272
  const config = loadConfig();
8648
9273
  const globalOpts = cmd.optsWithGlobals();
8649
9274
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -8653,7 +9278,7 @@ function registerAdminCommands(program) {
8653
9278
  const users = admin.command("users").description("Manage users");
8654
9279
  users.command("list").description("List all users (admin)").action(async (_options, cmd) => {
8655
9280
  try {
8656
- const outputFormat = getOutputFormat16(cmd);
9281
+ const outputFormat = getOutputFormat18(cmd);
8657
9282
  const api = createApiClient();
8658
9283
  const userList = await api.admin.getUsers();
8659
9284
  const summary = userList.map((u) => ({
@@ -8679,7 +9304,7 @@ function registerAdminCommands(program) {
8679
9304
  });
8680
9305
  users.command("get").description("Get current user details").action(async (_options, cmd) => {
8681
9306
  try {
8682
- const outputFormat = getOutputFormat16(cmd);
9307
+ const outputFormat = getOutputFormat18(cmd);
8683
9308
  const api = createApiClient();
8684
9309
  const user = await api.admin.getMyUser();
8685
9310
  format(user, { format: outputFormat });
@@ -8689,7 +9314,7 @@ function registerAdminCommands(program) {
8689
9314
  });
8690
9315
  admin.command("subscription").description("Show current subscription").action(async (_options, cmd) => {
8691
9316
  try {
8692
- const outputFormat = getOutputFormat16(cmd);
9317
+ const outputFormat = getOutputFormat18(cmd);
8693
9318
  const api = createApiClient();
8694
9319
  const sub = await api.admin.getCurrentSubscription();
8695
9320
  format(sub, { format: outputFormat });
@@ -8700,7 +9325,7 @@ function registerAdminCommands(program) {
8700
9325
  const settings = admin.command("settings").description("Manage settings");
8701
9326
  settings.command("get").description("Get current settings").action(async (_options, cmd) => {
8702
9327
  try {
8703
- const outputFormat = getOutputFormat16(cmd);
9328
+ const outputFormat = getOutputFormat18(cmd);
8704
9329
  const api = createApiClient();
8705
9330
  const s = await api.admin.getSettings();
8706
9331
  format(s, { format: outputFormat });
@@ -8720,7 +9345,7 @@ function registerAdminCommands(program) {
8720
9345
  const platformSettings = admin.command("platform-settings").description("Manage platform-wide settings (admin only)");
8721
9346
  platformSettings.command("list").description("Show every platform setting with its default and current override").action(async (_options, cmd) => {
8722
9347
  try {
8723
- const outputFormat = getOutputFormat16(cmd);
9348
+ const outputFormat = getOutputFormat18(cmd);
8724
9349
  const api = createApiClient();
8725
9350
  const settingsList = await api.admin.listPlatformSettings();
8726
9351
  format(settingsList, { format: outputFormat });
@@ -8808,9 +9433,10 @@ function registerAdminCommands(program) {
8808
9433
  }
8809
9434
  });
8810
9435
  registerCuratedTagCommands(admin);
9436
+ registerAdminProjectCommands(admin);
8811
9437
  admin.command("permissions").description("Show your permissions on a project").argument("<projectId>", "Project ID").action(async (projectId, _options, cmd) => {
8812
9438
  try {
8813
- const outputFormat = getOutputFormat16(cmd);
9439
+ const outputFormat = getOutputFormat18(cmd);
8814
9440
  const api = createApiClient();
8815
9441
  const perm = await api.admin.getPermissions(projectId);
8816
9442
  format({ projectId, permission: perm }, { format: outputFormat });
@@ -8823,20 +9449,20 @@ function registerAdminCommands(program) {
8823
9449
  contract.command("get", { isDefault: true }).description("Show a team's contract").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
8824
9450
  try {
8825
9451
  const api = createApiClient();
8826
- format(await api.admin.getTeamContract(teamId), { format: getOutputFormat16(cmd) });
9452
+ format(await api.admin.getTeamContract(teamId), { format: getOutputFormat18(cmd) });
8827
9453
  } catch (error) {
8828
9454
  handleError(error);
8829
9455
  }
8830
9456
  });
8831
9457
  contract.command("issue").description("Issue or replace a negotiated contract for a team").argument("<teamId>", "Team ID").requiredOption("--file <path>", "JSON file holding the contract request").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, options, cmd) => {
8832
9458
  try {
8833
- const request = JSON.parse(await readFile(options.file, "utf8"));
9459
+ const request = JSON.parse(await readFile2(options.file, "utf8"));
8834
9460
  await confirmDestructive(
8835
9461
  `This will replace the contract of team "${teamId}" with the terms in ${options.file}.`,
8836
9462
  { yes: options.yes, resourceId: teamId }
8837
9463
  );
8838
9464
  const api = createApiClient();
8839
- format(await api.admin.issueTeamContract(teamId, request), { format: getOutputFormat16(cmd) });
9465
+ format(await api.admin.issueTeamContract(teamId, request), { format: getOutputFormat18(cmd) });
8840
9466
  } catch (error) {
8841
9467
  handleError(error);
8842
9468
  }
@@ -10067,7 +10693,7 @@ function openUrl(url) {
10067
10693
  const args = process.platform === "win32" ? ["/c", "start", '""', url] : [url];
10068
10694
  spawn2(cmd, args, { detached: true, stdio: "ignore" }).unref();
10069
10695
  }
10070
- function getOutputFormat17(cmd) {
10696
+ function getOutputFormat19(cmd) {
10071
10697
  const config = loadConfig();
10072
10698
  const globalOpts = cmd.optsWithGlobals();
10073
10699
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -10076,7 +10702,7 @@ function noInteractiveFlag(cmd) {
10076
10702
  return cmd.optsWithGlobals().interactive === false;
10077
10703
  }
10078
10704
  function importContext(api, analysisId, cmd, machineReport) {
10079
- const outputFormat = getOutputFormat17(cmd);
10705
+ const outputFormat = getOutputFormat19(cmd);
10080
10706
  const noInteractive = noInteractiveFlag(cmd);
10081
10707
  return {
10082
10708
  api,
@@ -10202,7 +10828,7 @@ async function runAnalysis(files, options, cmd) {
10202
10828
  }
10203
10829
  }
10204
10830
  const file = files[0];
10205
- const outputFormat = getOutputFormat17(cmd);
10831
+ const outputFormat = getOutputFormat19(cmd);
10206
10832
  const noInteractive = noInteractiveFlag(cmd);
10207
10833
  const interactive = canPrompt(outputFormat, noInteractive);
10208
10834
  const launch = launchIntentOf(options);
@@ -10477,7 +11103,7 @@ async function readPresets(api) {
10477
11103
  }
10478
11104
  async function monitorRun(api, analysisId, runId, budgetHours, cmd) {
10479
11105
  const config = loadConfig();
10480
- const outputFormat = getOutputFormat17(cmd);
11106
+ const outputFormat = getOutputFormat19(cmd);
10481
11107
  const human = outputFormat === "human";
10482
11108
  const status = new Status();
10483
11109
  const seenOutputs = /* @__PURE__ */ new Set();
@@ -10604,7 +11230,7 @@ async function printNotebookLink(api, config, analysisId) {
10604
11230
  }
10605
11231
  }
10606
11232
  async function listAnalyses(limit, cmd) {
10607
- const outputFormat = getOutputFormat17(cmd);
11233
+ const outputFormat = getOutputFormat19(cmd);
10608
11234
  const api = createApiClient();
10609
11235
  const analyses = await api.analysis.getRecent(limit);
10610
11236
  format(analyses.map((a) => ({
@@ -10634,7 +11260,7 @@ async function listAnalyses(limit, cmd) {
10634
11260
  });
10635
11261
  }
10636
11262
  async function getAnalysisDetails(analysisId, options, cmd) {
10637
- const outputFormat = getOutputFormat17(cmd);
11263
+ const outputFormat = getOutputFormat19(cmd);
10638
11264
  const api = createApiClient();
10639
11265
  const result = analysisId ? await api.analysis.get(analysisId) : await api.analysis.getLast();
10640
11266
  if (!result.analysis) {
@@ -10722,7 +11348,7 @@ async function rerunAnalysis(analysisId, cmd) {
10722
11348
  const analysis = found.analysis;
10723
11349
  const missing = missingRunFields(analysis);
10724
11350
  if (missing.length > 0) {
10725
- const outputFormat = getOutputFormat17(cmd);
11351
+ const outputFormat = getOutputFormat19(cmd);
10726
11352
  const noInteractive = noInteractiveFlag(cmd);
10727
11353
  if (!canPrompt(outputFormat, noInteractive)) {
10728
11354
  const { message, suggestion } = explainMissingRunFields(
@@ -10796,7 +11422,7 @@ function typedColumns(given) {
10796
11422
  return entries === void 0 ? null : resolveColumnArguments(entries, []);
10797
11423
  }
10798
11424
  async function createAnalysis(options, cmd) {
10799
- const outputFormat = getOutputFormat17(cmd);
11425
+ const outputFormat = getOutputFormat19(cmd);
10800
11426
  const launch = launchIntentOf(options);
10801
11427
  const shapes = windowedShapes(launch.shapes);
10802
11428
  const api = createApiClient();
@@ -10838,7 +11464,7 @@ async function deleteAnalysis(analysisId) {
10838
11464
  success(`Deleted analysis ${analysisId}.`);
10839
11465
  }
10840
11466
  async function patchAndPrint(analysisId, value, handler, successLabel, cmd) {
10841
- const outputFormat = getOutputFormat17(cmd);
11467
+ const outputFormat = getOutputFormat19(cmd);
10842
11468
  const api = createApiClient();
10843
11469
  const updated = await handler(api, analysisId, value);
10844
11470
  if (isDryRun()) {
@@ -10868,7 +11494,7 @@ async function ownAnalysis(api, analysisId) {
10868
11494
  return found.analysis;
10869
11495
  }
10870
11496
  async function notesCommand(analysisId, text2, options, cmd) {
10871
- const outputFormat = getOutputFormat17(cmd);
11497
+ const outputFormat = getOutputFormat19(cmd);
10872
11498
  const api = createApiClient();
10873
11499
  const given = [text2 !== void 0, options.file !== void 0, options.clear === true].filter(Boolean).length;
10874
11500
  if (given > 1) usageError("Give the notes as text, with --file, or clear them with --clear: one of the three.");
@@ -10914,7 +11540,7 @@ async function notesCommand(analysisId, text2, options, cmd) {
10914
11540
  hint(`Read them into proposals with 'diafunc analyze intent read ${analysisId}'. Nothing changes until you confirm one.`);
10915
11541
  }
10916
11542
  async function readNotesCommand(analysisId, options, cmd) {
10917
- const outputFormat = getOutputFormat17(cmd);
11543
+ const outputFormat = getOutputFormat19(cmd);
10918
11544
  const api = createApiClient();
10919
11545
  const analysis = await ownAnalysis(api, analysisId);
10920
11546
  if (!analysis.intent) {
@@ -10947,7 +11573,7 @@ async function readNotesCommand(analysisId, options, cmd) {
10947
11573
  printInterpretation(interpretation, analysisId);
10948
11574
  }
10949
11575
  async function decideCommand(state, analysisId, ids, options, cmd) {
10950
- const outputFormat = getOutputFormat17(cmd);
11576
+ const outputFormat = getOutputFormat19(cmd);
10951
11577
  const wanted = [...new Set(ids.flatMap((id) => id.split(",")).map((id) => id.trim()).filter((id) => id.length > 0))];
10952
11578
  if (wanted.length === 0) usageError("Name at least one proposal.", `The ids are in 'diafunc analyze intent read ${analysisId}'.`);
10953
11579
  if (options.steer !== void 0 && state !== "CONFIRMED") {
@@ -10986,7 +11612,7 @@ async function decideCommand(state, analysisId, ids, options, cmd) {
10986
11612
  if (state === "CONFIRMED") hint(`It takes part from the next run: 'diafunc analyze rerun ${analysisId}'.`);
10987
11613
  }
10988
11614
  async function expectationsCommand(analysisId, given, options, cmd) {
10989
- const outputFormat = getOutputFormat17(cmd);
11615
+ const outputFormat = getOutputFormat19(cmd);
10990
11616
  const api = createApiClient();
10991
11617
  const analysis = await ownAnalysis(api, analysisId);
10992
11618
  const current = analysis.shapeExpectations ?? {};
@@ -11107,7 +11733,7 @@ async function uploadOne(api, analysisId, file, asUploaded, human) {
11107
11733
  }
11108
11734
  async function uploadData(analysisId, files, options, cmd) {
11109
11735
  const api = createApiClient();
11110
- const outputFormat = getOutputFormat17(cmd);
11736
+ const outputFormat = getOutputFormat19(cmd);
11111
11737
  const ctx = importContext(api, analysisId, cmd, "none");
11112
11738
  const file = files[0];
11113
11739
  if (files.length > 1) {
@@ -11157,7 +11783,7 @@ async function uploadData(analysisId, files, options, cmd) {
11157
11783
  }
11158
11784
  }
11159
11785
  async function stopDataImport(analysisId, cmd) {
11160
- const outputFormat = getOutputFormat17(cmd);
11786
+ const outputFormat = getOutputFormat19(cmd);
11161
11787
  const api = createApiClient();
11162
11788
  const stopped = await withStatus("Stopping the data import", () => stopImport(api, analysisId));
11163
11789
  if (isDryRun()) {
@@ -11180,7 +11806,7 @@ async function stopDataImport(analysisId, cmd) {
11180
11806
  warn(stopped.dataImport.message);
11181
11807
  }
11182
11808
  async function listColumns(analysisId, cmd) {
11183
- const outputFormat = getOutputFormat17(cmd);
11809
+ const outputFormat = getOutputFormat19(cmd);
11184
11810
  const api = createApiClient();
11185
11811
  const columns = await api.analysis.getColumns(analysisId);
11186
11812
  if (columns.length === 0) {
@@ -11191,7 +11817,7 @@ async function listColumns(analysisId, cmd) {
11191
11817
  format(columns, { format: outputFormat, columns: ["name", "valueType"] });
11192
11818
  }
11193
11819
  async function listRuns(analysisId, count, cmd) {
11194
- const outputFormat = getOutputFormat17(cmd);
11820
+ const outputFormat = getOutputFormat19(cmd);
11195
11821
  const api = createApiClient();
11196
11822
  const runs = await api.analysis.getRunsForAnalysis(analysisId, count);
11197
11823
  format(runs.map((r) => ({
@@ -11216,7 +11842,7 @@ async function listRuns(analysisId, count, cmd) {
11216
11842
  });
11217
11843
  }
11218
11844
  async function cancelRun(runId, cmd) {
11219
- const outputFormat = getOutputFormat17(cmd);
11845
+ const outputFormat = getOutputFormat19(cmd);
11220
11846
  const api = createApiClient();
11221
11847
  const run = await api.analysis.cancelRun(runId);
11222
11848
  if (outputFormat === "human") {
@@ -11230,7 +11856,7 @@ async function cancelRun(runId, cmd) {
11230
11856
  }
11231
11857
  }
11232
11858
  async function listPresets(cmd) {
11233
- const outputFormat = getOutputFormat17(cmd);
11859
+ const outputFormat = getOutputFormat19(cmd);
11234
11860
  const api = createApiClient();
11235
11861
  const presets = await api.analysis.getPresets();
11236
11862
  format(presets.map((p) => ({
@@ -11255,7 +11881,7 @@ async function listPresets(cmd) {
11255
11881
  });
11256
11882
  }
11257
11883
  async function getPreset(presetId, cmd) {
11258
- const outputFormat = getOutputFormat17(cmd);
11884
+ const outputFormat = getOutputFormat19(cmd);
11259
11885
  const api = createApiClient();
11260
11886
  const opt = await api.analysis.getPreset(presetId);
11261
11887
  if (!opt.preset) {
@@ -11265,7 +11891,7 @@ async function getPreset(presetId, cmd) {
11265
11891
  format(opt.preset, { format: outputFormat });
11266
11892
  }
11267
11893
  async function savePreset(options, cmd) {
11268
- const outputFormat = getOutputFormat17(cmd);
11894
+ const outputFormat = getOutputFormat19(cmd);
11269
11895
  const api = createApiClient();
11270
11896
  const preset = {
11271
11897
  presetId: options.id ?? null,
@@ -11320,7 +11946,7 @@ function triggerChanges(options) {
11320
11946
  };
11321
11947
  }
11322
11948
  async function listTriggers(analysisId, cmd) {
11323
- const outputFormat = getOutputFormat17(cmd);
11949
+ const outputFormat = getOutputFormat19(cmd);
11324
11950
  const api = createApiClient();
11325
11951
  const triggers = await api.analysis.listTriggers(analysisId);
11326
11952
  format(triggers.map(triggerRow), {
@@ -11337,7 +11963,7 @@ async function listTriggers(analysisId, cmd) {
11337
11963
  });
11338
11964
  }
11339
11965
  async function createTrigger(analysisId, kind, schedule, cmd, refreshFirst = false) {
11340
- const outputFormat = getOutputFormat17(cmd);
11966
+ const outputFormat = getOutputFormat19(cmd);
11341
11967
  const upper = kind.toUpperCase();
11342
11968
  if (upper !== "ONCE" && upper !== "CRON") {
11343
11969
  failure(`Invalid kind "${kind}". Use ONCE or CRON.`);
@@ -11357,7 +11983,7 @@ async function deleteTrigger(triggerId) {
11357
11983
  success(`Deleted trigger ${triggerId}.`);
11358
11984
  }
11359
11985
  async function updateTriggerCmd(triggerId, options, cmd) {
11360
- const outputFormat = getOutputFormat17(cmd);
11986
+ const outputFormat = getOutputFormat19(cmd);
11361
11987
  const changes = triggerChanges(options);
11362
11988
  const api = createApiClient();
11363
11989
  const trigger = await api.analysis.updateTrigger(triggerId, changes);
@@ -11761,7 +12387,7 @@ Examples:
11761
12387
  // src/commands/public/index.ts
11762
12388
  var MIN_LIMIT = 1;
11763
12389
  var MAX_LIMIT = 500;
11764
- function getOutputFormat18(cmd) {
12390
+ function getOutputFormat20(cmd) {
11765
12391
  const config = loadConfig();
11766
12392
  const globalOpts = cmd.optsWithGlobals();
11767
12393
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -11813,7 +12439,7 @@ async function readPublicAnalyses(analysis, options) {
11813
12439
  }
11814
12440
  }
11815
12441
  async function listPublicAnalyses(options, cmd) {
11816
- const outputFormat = getOutputFormat18(cmd);
12442
+ const outputFormat = getOutputFormat20(cmd);
11817
12443
  const limit = parseLimit(options.limit);
11818
12444
  const changedSince = options.changedSince === void 0 ? void 0 : parseChangedSince(options.changedSince);
11819
12445
  const api = createApiClient();
@@ -11856,7 +12482,7 @@ function newestRunRecord(run) {
11856
12482
  };
11857
12483
  }
11858
12484
  async function showPublicAnalysis(analysisId, cmd) {
11859
- const outputFormat = getOutputFormat18(cmd);
12485
+ const outputFormat = getOutputFormat20(cmd);
11860
12486
  const api = createApiClient();
11861
12487
  const result = await api.analysis.get(analysisId);
11862
12488
  if (!result?.analysis) {
@@ -11926,7 +12552,7 @@ Examples:
11926
12552
 
11927
12553
  // src/commands/license/index.ts
11928
12554
  import chalk30 from "chalk";
11929
- function getOutputFormat19(cmd) {
12555
+ function getOutputFormat21(cmd) {
11930
12556
  const config = loadConfig();
11931
12557
  const globalOpts = cmd.optsWithGlobals();
11932
12558
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -11945,8 +12571,89 @@ function licenseMarks(license) {
11945
12571
  function stateWord(state) {
11946
12572
  return state.toLowerCase();
11947
12573
  }
12574
+ function flagsFromMarks(marks) {
12575
+ const given = marks.trim().toUpperCase().split(/[\s,]+/).filter((m) => m.length > 0);
12576
+ const known = new Set(LICENSE_MARKS.map(({ mark }) => mark));
12577
+ const unknown = given.filter((m) => m !== "NONE" && !known.has(m));
12578
+ if (unknown.length > 0 || given.includes("NONE") && given.length > 1 || given.length === 0) {
12579
+ throw new CliError(`Unknown flags "${marks}".`, {
12580
+ hint: `Use any of ${LICENSE_MARKS.map(({ mark }) => mark).join(", ")} (for example "C D R BY"), or "none".`
12581
+ });
12582
+ }
12583
+ return {
12584
+ commercialUse: given.includes("C"),
12585
+ derivatives: given.includes("D"),
12586
+ redistribution: given.includes("R"),
12587
+ attributionRequired: given.includes("BY"),
12588
+ shareAlike: given.includes("SA")
12589
+ };
12590
+ }
12591
+ function parseSortOrder2(value) {
12592
+ if (value === void 0) return void 0;
12593
+ if (value === "") return null;
12594
+ const order = Number(value);
12595
+ if (!Number.isInteger(order)) {
12596
+ throw new CliError(`--sort-order must be a whole number, not "${value}".`);
12597
+ }
12598
+ return order;
12599
+ }
12600
+ function parseBool(name, value) {
12601
+ if (value === void 0) return void 0;
12602
+ if (value === "true" || value === "false") return value === "true";
12603
+ throw new CliError(`${name} must be true or false, not "${value}".`);
12604
+ }
12605
+ async function catalogEntry(licenseId) {
12606
+ const entries = await createApiClient().admin.listLicenseCatalog();
12607
+ const entry = entries.find((e) => e.licence.licenceId === licenseId);
12608
+ if (!entry) {
12609
+ throw new CliError(`No license "${licenseId}" in the catalog.`, {
12610
+ hint: `List every entry, withdrawn ones included, with 'diafunc license catalog'.`
12611
+ });
12612
+ }
12613
+ return entry;
12614
+ }
12615
+ function printLicense(license, cmd, verb) {
12616
+ const outputFormat = getOutputFormat21(cmd);
12617
+ if (outputFormat !== "human") {
12618
+ format(license, { format: outputFormat });
12619
+ return;
12620
+ }
12621
+ success(`License "${license.licenceId}" ${verb} (${stateWord(license.state)}, flags ${licenseMarks(license) ?? "none"}).`);
12622
+ }
12623
+ async function listCatalog(cmd) {
12624
+ const outputFormat = getOutputFormat21(cmd);
12625
+ const entries = await createApiClient().admin.listLicenseCatalog();
12626
+ if (outputFormat === "json") {
12627
+ format(entries, { format: outputFormat });
12628
+ return;
12629
+ }
12630
+ if (entries.length === 0 && outputFormat === "human") {
12631
+ empty("licenses");
12632
+ return;
12633
+ }
12634
+ format(entries.map((e) => ({
12635
+ licenceId: e.licence.licenceId,
12636
+ name: e.licence.name,
12637
+ state: stateWord(e.licence.state),
12638
+ flags: licenseMarks(e.licence),
12639
+ recommended: e.licence.recommended,
12640
+ publicProjects: e.publicProjects,
12641
+ sortOrder: e.licence.sortOrder
12642
+ })), {
12643
+ format: outputFormat,
12644
+ columns: [
12645
+ { key: "licenceId", header: "id" },
12646
+ { key: "name" },
12647
+ { key: "state", kind: "state" },
12648
+ { key: "flags" },
12649
+ { key: "recommended", kind: "boolean" },
12650
+ { key: "publicProjects", header: "public projects" },
12651
+ { key: "sortOrder", header: "order" }
12652
+ ]
12653
+ });
12654
+ }
11948
12655
  async function listLicenses(cmd) {
11949
- const outputFormat = getOutputFormat19(cmd);
12656
+ const outputFormat = getOutputFormat21(cmd);
11950
12657
  const api = createApiClient();
11951
12658
  const licenses = await api.admin.listLicenses();
11952
12659
  if (outputFormat === "json") {
@@ -11981,7 +12688,7 @@ Flags: ${LICENSE_MARKS.map(({ mark, meaning }) => `${mark} ${meaning}`).join(",
11981
12688
  }
11982
12689
  }
11983
12690
  async function showLicense(licenseId, cmd) {
11984
- const outputFormat = getOutputFormat19(cmd);
12691
+ const outputFormat = getOutputFormat21(cmd);
11985
12692
  const api = createApiClient();
11986
12693
  let license;
11987
12694
  try {
@@ -12028,10 +12735,13 @@ async function showLicense(licenseId, cmd) {
12028
12735
  });
12029
12736
  }
12030
12737
  function registerLicenseCommands(program) {
12031
- const license = hiddenAlias(program.command("license"), "licence").description("The licenses a public project can be published under (no sign-in needed)").addHelpText("after", `
12738
+ const license = hiddenAlias(program.command("license"), "licence").description("The licenses a public project can be published under (reading needs no sign-in; managing the catalog is for administrators)").addHelpText("after", `
12032
12739
  Examples:
12033
12740
  $ diafunc license list the licenses that can be chosen
12034
12741
  $ diafunc license show CC-BY-4.0 one license and what it allows
12742
+ $ diafunc license catalog administrators: every entry, with its public projects
12743
+ $ diafunc license create CC-BY-3.0 --name "Creative Commons Attribution 3.0" --flags "C D R BY"
12744
+ $ diafunc license deprecate CC-BY-3.0 administrators: stop offering it
12035
12745
  $ diafunc project create --visibility PUBLIC --license CC-BY-4.0
12036
12746
  $ diafunc analyze visibility <id> PUBLIC --license CC0-1.0
12037
12747
  `);
@@ -12049,11 +12759,97 @@ Examples:
12049
12759
  handleError(error);
12050
12760
  }
12051
12761
  });
12762
+ license.command("catalog").description("Administrators: every catalog entry, withdrawn ones included, with the number of public projects that carry it").action(async (_options, cmd) => {
12763
+ try {
12764
+ await listCatalog(cmd);
12765
+ } catch (error) {
12766
+ handleError(error);
12767
+ }
12768
+ });
12769
+ license.command("create").description("Administrators: add a license to the catalog (active from the start)").argument("<licenseId>", "SPDX identifier where one exists (CC-BY-3.0), an own slug otherwise; never changes").requiredOption("--name <name>", "Full name").requiredOption("--flags <marks>", 'What it allows: any of C D R BY SA (commercial use, adaptations, redistribution, attribution required, share-alike), or "none"').option("--url <url>", "Address of the license text").option("--summary <text>", "One or two sentences shown where a license is chosen").option("--recommended", "Show it in the short list where a license is chosen").option("--sort-order <n>", "Position in the list; without one it comes last").action(async (licenseId, options, cmd) => {
12770
+ try {
12771
+ const created = await createApiClient().admin.createLicense({
12772
+ licenceId: licenseId,
12773
+ name: options.name,
12774
+ summary: options.summary ?? null,
12775
+ url: options.url ?? null,
12776
+ state: "ACTIVE",
12777
+ ...flagsFromMarks(options.flags),
12778
+ recommended: !!options.recommended,
12779
+ sortOrder: parseSortOrder2(options.sortOrder) ?? null
12780
+ });
12781
+ printLicense(created, cmd, "created");
12782
+ } catch (error) {
12783
+ handleError(error);
12784
+ }
12785
+ });
12786
+ license.command("update").description("Administrators: change a catalog entry; what is not given stays as it is").argument("<licenseId>", "License ID").option("--name <name>", "Full name").option("--flags <marks>", 'What it allows: any of C D R BY SA, or "none"').option("--url <url>", "Address of the license text; an empty value clears it").option("--summary <text>", "Shown where a license is chosen; an empty value clears it").option("--recommended <bool>", "Show it in the short list (true/false)").option("--sort-order <n>", "Position in the list; an empty value clears it").action(async (licenseId, options, cmd) => {
12787
+ try {
12788
+ const current = (await catalogEntry(licenseId)).licence;
12789
+ const sortOrder = parseSortOrder2(options.sortOrder);
12790
+ const recommended = parseBool("--recommended", options.recommended);
12791
+ const updated = await createApiClient().admin.updateLicense({
12792
+ ...current,
12793
+ ...options.name !== void 0 ? { name: options.name } : {},
12794
+ ...options.url !== void 0 ? { url: options.url || null } : {},
12795
+ ...options.summary !== void 0 ? { summary: options.summary || null } : {},
12796
+ ...options.flags !== void 0 ? flagsFromMarks(options.flags) : {},
12797
+ ...recommended !== void 0 ? { recommended } : {},
12798
+ ...sortOrder !== void 0 ? { sortOrder } : {}
12799
+ });
12800
+ printLicense(updated, cmd, "updated");
12801
+ } catch (error) {
12802
+ handleError(error);
12803
+ }
12804
+ });
12805
+ license.command("deprecate").description("Administrators: stop offering a license; the projects that carry it keep it").argument("<licenseId>", "License ID").action(async (licenseId, _options, cmd) => {
12806
+ try {
12807
+ printLicense(await createApiClient().admin.deprecateLicense(licenseId), cmd, "deprecated");
12808
+ } catch (error) {
12809
+ handleError(error);
12810
+ }
12811
+ });
12812
+ license.command("reactivate").description("Administrators: offer a deprecated or withdrawn license again").argument("<licenseId>", "License ID").action(async (licenseId, _options, cmd) => {
12813
+ try {
12814
+ printLicense(await createApiClient().admin.reactivateLicense(licenseId), cmd, "reactivated");
12815
+ } catch (error) {
12816
+ handleError(error);
12817
+ }
12818
+ });
12819
+ license.command("withdraw").description("Administrators: end publication under a license; every public project that carries it becomes private").argument("<licenseId>", "License ID").option("--expected-affected <n>", "The number of public projects that become private, as `license catalog` shows it; the platform refuses when it differs").action(async (licenseId, options, cmd) => {
12820
+ try {
12821
+ const affected = (await catalogEntry(licenseId)).publicProjects;
12822
+ if (options.expectedAffected === void 0) {
12823
+ throw new CliError(`Withdrawing "${licenseId}" makes ${affected} public project(s) private.`, {
12824
+ hint: `Confirm with 'diafunc license withdraw ${licenseId} --expected-affected ${affected}'.`
12825
+ });
12826
+ }
12827
+ const expected = Number(options.expectedAffected);
12828
+ if (!Number.isInteger(expected) || expected < 0) {
12829
+ throw new CliError(`--expected-affected must be a whole number, not "${options.expectedAffected}".`);
12830
+ }
12831
+ printLicense(await createApiClient().admin.withdrawLicense(licenseId, expected), cmd, "withdrawn");
12832
+ } catch (error) {
12833
+ handleError(error);
12834
+ }
12835
+ });
12836
+ license.command("delete").description("Administrators: remove a license no project refers to (otherwise deprecate or withdraw it)").argument("<licenseId>", "License ID").option("-y, --yes", "Skip confirmation prompt (for CI / scripted use)").action(async (licenseId, options) => {
12837
+ try {
12838
+ await confirmDestructive(
12839
+ `This will permanently delete license "${licenseId}" from the catalog.`,
12840
+ { yes: options.yes, resourceId: licenseId }
12841
+ );
12842
+ await createApiClient().admin.deleteLicense(licenseId);
12843
+ success(`License "${licenseId}" deleted.`);
12844
+ } catch (error) {
12845
+ handleError(error);
12846
+ }
12847
+ });
12052
12848
  }
12053
12849
 
12054
12850
  // src/commands/data-sources/index.ts
12055
12851
  import chalk31 from "chalk";
12056
- function getOutputFormat20(cmd) {
12852
+ function getOutputFormat22(cmd) {
12057
12853
  const config = loadConfig();
12058
12854
  const globalOpts = cmd.optsWithGlobals();
12059
12855
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -12153,7 +12949,7 @@ function resolveProjectId(cmd) {
12153
12949
  return resolved;
12154
12950
  }
12155
12951
  async function listDataSources(projectId, cmd) {
12156
- const outputFormat = getOutputFormat20(cmd);
12952
+ const outputFormat = getOutputFormat22(cmd);
12157
12953
  const api = createApiClient();
12158
12954
  const sources = await api.storage.listDataSources(projectId);
12159
12955
  if (outputFormat === "human" && sources.length === 0) {
@@ -12174,13 +12970,13 @@ async function listDataSources(projectId, cmd) {
12174
12970
  });
12175
12971
  }
12176
12972
  async function getDataSource(id, cmd) {
12177
- const outputFormat = getOutputFormat20(cmd);
12973
+ const outputFormat = getOutputFormat22(cmd);
12178
12974
  const api = createApiClient();
12179
12975
  const ds = await api.storage.getDataSource(id);
12180
12976
  format(ds, { format: outputFormat });
12181
12977
  }
12182
12978
  async function showDashboard(projectId, cmd) {
12183
- const outputFormat = getOutputFormat20(cmd);
12979
+ const outputFormat = getOutputFormat22(cmd);
12184
12980
  const api = createApiClient();
12185
12981
  const dashboard = await api.storage.getDataSourceDashboard(projectId);
12186
12982
  if (outputFormat !== "human") {
@@ -12256,7 +13052,7 @@ async function createForAnalysis(api, options, human) {
12256
13052
  return { source, build };
12257
13053
  }
12258
13054
  async function createDataSource(options, cmd) {
12259
- const outputFormat = getOutputFormat20(cmd);
13055
+ const outputFormat = getOutputFormat22(cmd);
12260
13056
  const target = createTarget(options);
12261
13057
  const api = createApiClient();
12262
13058
  if (target === "analysis") {
@@ -12286,7 +13082,7 @@ async function createDataSource(options, cmd) {
12286
13082
  }
12287
13083
  }
12288
13084
  async function updateDataSource(id, options, cmd) {
12289
- const outputFormat = getOutputFormat20(cmd);
13085
+ const outputFormat = getOutputFormat22(cmd);
12290
13086
  if (options.name === void 0 && options.type === void 0 && (!options.config || options.config.length === 0) && options.scheduleCron === void 0 && !options.clearSchedule) {
12291
13087
  throw new Error("Provide at least one of --name, --type, --config, --schedule-cron, or --clear-schedule.");
12292
13088
  }
@@ -12321,7 +13117,7 @@ async function deleteDataSource(id) {
12321
13117
  success(`Deleted data source ${id}`);
12322
13118
  }
12323
13119
  async function refreshDataSource(id, cmd) {
12324
- const outputFormat = getOutputFormat20(cmd);
13120
+ const outputFormat = getOutputFormat22(cmd);
12325
13121
  const api = createApiClient();
12326
13122
  const run = await api.storage.refreshDataSource(id);
12327
13123
  if (outputFormat === "human") {
@@ -12332,7 +13128,7 @@ async function refreshDataSource(id, cmd) {
12332
13128
  }
12333
13129
  }
12334
13130
  async function listRuns2(id, limit, cmd) {
12335
- const outputFormat = getOutputFormat20(cmd);
13131
+ const outputFormat = getOutputFormat22(cmd);
12336
13132
  const api = createApiClient();
12337
13133
  const runs = await api.storage.listDataSourceRuns(id, limit);
12338
13134
  if (outputFormat === "human" && runs.length === 0) {
@@ -12354,13 +13150,13 @@ async function listRuns2(id, limit, cmd) {
12354
13150
  });
12355
13151
  }
12356
13152
  async function getRun(id, runId, cmd) {
12357
- const outputFormat = getOutputFormat20(cmd);
13153
+ const outputFormat = getOutputFormat22(cmd);
12358
13154
  const api = createApiClient();
12359
13155
  const run = await api.storage.getDataSourceRun(id, runId);
12360
13156
  format(run, { format: outputFormat });
12361
13157
  }
12362
13158
  async function listConnectorTypes(cmd) {
12363
- const outputFormat = getOutputFormat20(cmd);
13159
+ const outputFormat = getOutputFormat22(cmd);
12364
13160
  const api = createApiClient();
12365
13161
  const types = await api.storage.listDataSourceConnectorTypes();
12366
13162
  if (outputFormat === "human") {
@@ -12454,7 +13250,7 @@ Examples:
12454
13250
 
12455
13251
  // src/commands/table-exporters/index.ts
12456
13252
  import chalk32 from "chalk";
12457
- function getOutputFormat21(cmd) {
13253
+ function getOutputFormat23(cmd) {
12458
13254
  const config = loadConfig();
12459
13255
  const globalOpts = cmd.optsWithGlobals();
12460
13256
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -12463,7 +13259,7 @@ function registerTableExportersCommands(program) {
12463
13259
  const exporters = program.command("table-exporters").description("Manage user-defined exporters (UDE); admin only");
12464
13260
  exporters.command("list").description("List all registered user-defined exporters").action(async (_options, cmd) => {
12465
13261
  try {
12466
- const outputFormat = getOutputFormat21(cmd);
13262
+ const outputFormat = getOutputFormat23(cmd);
12467
13263
  const api = createApiClient();
12468
13264
  const list = await api.storage.listUserDefinedExporters();
12469
13265
  if (outputFormat === "json") {
@@ -12491,7 +13287,7 @@ function registerTableExportersCommands(program) {
12491
13287
  });
12492
13288
  exporters.command("get").description("Show a single user-defined exporter by id").argument("<id>", "Exporter id").action(async (id, _options, cmd) => {
12493
13289
  try {
12494
- const outputFormat = getOutputFormat21(cmd);
13290
+ const outputFormat = getOutputFormat23(cmd);
12495
13291
  const api = createApiClient();
12496
13292
  const list = await api.storage.listUserDefinedExporters();
12497
13293
  const exporter = list.find((e) => e.id === id);
@@ -12506,7 +13302,7 @@ function registerTableExportersCommands(program) {
12506
13302
  });
12507
13303
  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) => {
12508
13304
  try {
12509
- const outputFormat = getOutputFormat21(cmd);
13305
+ const outputFormat = getOutputFormat23(cmd);
12510
13306
  const api = createApiClient();
12511
13307
  const payload = {
12512
13308
  name: options.name,
@@ -12544,7 +13340,7 @@ function registerTableExportersCommands(program) {
12544
13340
  // src/commands/skeleton/index.ts
12545
13341
  import chalk33 from "chalk";
12546
13342
  import * as fs13 from "fs";
12547
- function getOutputFormat22(cmd) {
13343
+ function getOutputFormat24(cmd) {
12548
13344
  const config = loadConfig();
12549
13345
  const globalOpts = cmd.optsWithGlobals();
12550
13346
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -12593,7 +13389,7 @@ function skeletonTableRow(s) {
12593
13389
  };
12594
13390
  }
12595
13391
  async function createSkeleton(options, cmd) {
12596
- const outputFormat = getOutputFormat22(cmd);
13392
+ const outputFormat = getOutputFormat24(cmd);
12597
13393
  const projectId = resolveProjectId2(cmd);
12598
13394
  const template = resolveTemplate(options.template);
12599
13395
  const weight = parseWeight(options.weight);
@@ -12618,7 +13414,7 @@ async function createSkeleton(options, cmd) {
12618
13414
  }
12619
13415
  }
12620
13416
  async function listSkeletons(cmd) {
12621
- const outputFormat = getOutputFormat22(cmd);
13417
+ const outputFormat = getOutputFormat24(cmd);
12622
13418
  const projectId = resolveProjectId2(cmd);
12623
13419
  const api = createApiClient();
12624
13420
  const skeletons = await api.storage.listSkeletons(projectId);
@@ -12632,13 +13428,13 @@ async function listSkeletons(cmd) {
12632
13428
  });
12633
13429
  }
12634
13430
  async function getSkeleton(id, cmd) {
12635
- const outputFormat = getOutputFormat22(cmd);
13431
+ const outputFormat = getOutputFormat24(cmd);
12636
13432
  const api = createApiClient();
12637
13433
  const skeleton = await api.storage.getSkeleton(id);
12638
13434
  format(skeleton, { format: outputFormat });
12639
13435
  }
12640
13436
  async function updateSkeleton(id, options, cmd) {
12641
- const outputFormat = getOutputFormat22(cmd);
13437
+ const outputFormat = getOutputFormat24(cmd);
12642
13438
  if (options.name === void 0 && options.template === void 0 && options.weight === void 0) {
12643
13439
  throw new Error("Provide at least one of --name, --template, --weight.");
12644
13440
  }
@@ -13002,7 +13798,7 @@ function registerWhoamiCommand(program) {
13002
13798
 
13003
13799
  // src/commands/utilization/index.ts
13004
13800
  import chalk35 from "chalk";
13005
- function getOutputFormat23(cmd) {
13801
+ function getOutputFormat25(cmd) {
13006
13802
  const config = loadConfig();
13007
13803
  const globalOpts = cmd.optsWithGlobals();
13008
13804
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -13067,7 +13863,7 @@ Examples:
13067
13863
  `);
13068
13864
  util.command("actual", { isDefault: true }).description("Show current utilization (default subcommand)").action(async (_options, cmd) => {
13069
13865
  try {
13070
- const outputFormat = getOutputFormat23(cmd);
13866
+ const outputFormat = getOutputFormat25(cmd);
13071
13867
  const api = createApiClient();
13072
13868
  const utilization = await api.admin.getActualUtilization();
13073
13869
  if (outputFormat === "human") {
@@ -13081,7 +13877,7 @@ Examples:
13081
13877
  });
13082
13878
  util.command("history").description("Show what each day of the billing cycle cost").action(async (_options, cmd) => {
13083
13879
  try {
13084
- const outputFormat = getOutputFormat23(cmd);
13880
+ const outputFormat = getOutputFormat25(cmd);
13085
13881
  const api = createApiClient();
13086
13882
  const history = await api.admin.getUtilizationHistory();
13087
13883
  if (outputFormat === "human") {
@@ -13102,7 +13898,7 @@ Examples:
13102
13898
  }
13103
13899
 
13104
13900
  // src/commands/entity-branch/index.ts
13105
- function getOutputFormat24(cmd) {
13901
+ function getOutputFormat26(cmd) {
13106
13902
  const config = loadConfig();
13107
13903
  const globalOpts = cmd.optsWithGlobals();
13108
13904
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -13115,7 +13911,7 @@ function registerEntityBranchCommands(program) {
13115
13911
  const eb = program.command("entity-branch").description("Manage entity branches (parallel versions of a single entity)");
13116
13912
  eb.command("list").description("List branches of an entity").argument("<ref>", "Entity reference (projectId/branch/entityId)").action(async (ref, _options, cmd) => {
13117
13913
  try {
13118
- const outputFormat = getOutputFormat24(cmd);
13914
+ const outputFormat = getOutputFormat26(cmd);
13119
13915
  const overrides = getOverrides11(cmd);
13120
13916
  const resolved = parseEntityReference(ref, overrides);
13121
13917
  const api = createApiClient();
@@ -13167,7 +13963,7 @@ function forReader(subscription) {
13167
13963
  Object.entries(subscription).filter(([key]) => !BILLING_INTERNALS.has(key))
13168
13964
  );
13169
13965
  }
13170
- function getOutputFormat25(cmd) {
13966
+ function getOutputFormat27(cmd) {
13171
13967
  const config = loadConfig();
13172
13968
  const globalOpts = cmd.optsWithGlobals();
13173
13969
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -13181,7 +13977,7 @@ Examples:
13181
13977
  sub.command("current", { isDefault: true }).description("Show the current subscription").action(async (_options, cmd) => {
13182
13978
  try {
13183
13979
  const api = createApiClient();
13184
- const outputFormat = getOutputFormat25(cmd);
13980
+ const outputFormat = getOutputFormat27(cmd);
13185
13981
  const s = await api.admin.getCurrentSubscription();
13186
13982
  format(outputFormat === "human" ? forReader(s) : s, { format: outputFormat });
13187
13983
  } catch (error) {
@@ -13191,7 +13987,7 @@ Examples:
13191
13987
  sub.command("next").description("Show the next (upcoming) subscription").action(async (_options, cmd) => {
13192
13988
  try {
13193
13989
  const api = createApiClient();
13194
- const outputFormat = getOutputFormat25(cmd);
13990
+ const outputFormat = getOutputFormat27(cmd);
13195
13991
  const s = await api.admin.getNextSubscription();
13196
13992
  format(outputFormat === "human" ? forReader(s) : s, { format: outputFormat });
13197
13993
  } catch (error) {
@@ -13202,7 +13998,7 @@ Examples:
13202
13998
  try {
13203
13999
  const api = createApiClient();
13204
14000
  const plans = await api.admin.getSubscriptionPlans(subscriptionToken);
13205
- format(plans, { format: getOutputFormat25(cmd) });
14001
+ format(plans, { format: getOutputFormat27(cmd) });
13206
14002
  } catch (error) {
13207
14003
  handleError(error);
13208
14004
  }
@@ -13211,7 +14007,7 @@ Examples:
13211
14007
 
13212
14008
  // src/commands/invoice/index.ts
13213
14009
  import * as fs14 from "fs";
13214
- function getOutputFormat26(cmd) {
14010
+ function getOutputFormat28(cmd) {
13215
14011
  const config = loadConfig();
13216
14012
  const globalOpts = cmd.optsWithGlobals();
13217
14013
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -13228,7 +14024,7 @@ Examples:
13228
14024
  const api = createApiClient();
13229
14025
  const invoices = await api.admin.getInvoices();
13230
14026
  format(invoices, {
13231
- format: getOutputFormat26(cmd),
14027
+ format: getOutputFormat28(cmd),
13232
14028
  columns: [
13233
14029
  { key: "invoiceNumber", header: "number" },
13234
14030
  { key: "issued", kind: "date" },
@@ -13358,7 +14154,7 @@ function registerShellCommand(program) {
13358
14154
  });
13359
14155
  const api = createApiClient();
13360
14156
  const { input: promptInput } = await import("@inquirer/prompts");
13361
- const { getUpdateNotice } = await import("./update-check-KHHHTIDF.js");
14157
+ const { getUpdateNotice } = await import("./update-check-2GW2RLWY.js");
13362
14158
  const resolvedLanguage = await resolveLanguage(api, fnRef.projectId, options.language);
13363
14159
  console.log(chalk36.bold("Diafunc shell") + chalk36.dim(` \xB7 function ${fnRef.entityId} \xB7 ${resolvedLanguage}`));
13364
14160
  console.log(chalk36.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
@@ -14219,4 +15015,4 @@ export {
14219
15015
  PromptCanceled,
14220
15016
  createProgram
14221
15017
  };
14222
- //# sourceMappingURL=chunk-5AB7E3K4.js.map
15018
+ //# sourceMappingURL=chunk-QBPGK5OC.js.map