@diafunc/cli 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/bin/diafunc.js +3 -3
- package/dist/{chunk-5AB7E3K4.js → chunk-AH6DCAHU.js} +978 -185
- package/dist/chunk-AH6DCAHU.js.map +1 -0
- package/dist/{chunk-CL2LMFXH.js → chunk-PUTTVRZA.js} +2 -2
- package/dist/{chunk-GZI6AECR.js → chunk-QX7F5YXI.js} +2 -2
- package/dist/{chunk-GZI6AECR.js.map → chunk-QX7F5YXI.js.map} +1 -1
- package/dist/src/index.js +2 -2
- package/dist/update-check-JWT4C4O5.js +8 -0
- package/package.json +1 -1
- package/dist/chunk-5AB7E3K4.js.map +0 -1
- package/dist/update-check-KHHHTIDF.js +0 -8
- /package/dist/{chunk-CL2LMFXH.js.map → chunk-PUTTVRZA.js.map} +0 -0
- /package/dist/{update-check-KHHHTIDF.js.map → update-check-JWT4C4O5.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
package_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QX7F5YXI.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
|
-
|
|
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
|
|
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/
|
|
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 =
|
|
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(
|
|
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(
|
|
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 =
|
|
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 =
|
|
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: ${
|
|
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 =
|
|
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 =
|
|
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(
|
|
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 =
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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 =
|
|
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 =
|
|
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:
|
|
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
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
|
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 =
|
|
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
|
|
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 =
|
|
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 =
|
|
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
|
|
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 =
|
|
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
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
|
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 =
|
|
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 =
|
|
6712
|
+
const outputFormat = getOutputFormat10(cmd);
|
|
6349
6713
|
const overrides = getOverrides7(cmd);
|
|
6350
6714
|
const ref = parseProjectReference(project, overrides);
|
|
6351
6715
|
const api = createApiClient();
|
|
@@ -6485,7 +6849,7 @@ function resultText(result, resultEncoding) {
|
|
|
6485
6849
|
}
|
|
6486
6850
|
|
|
6487
6851
|
// src/commands/function/index.ts
|
|
6488
|
-
function
|
|
6852
|
+
function getOutputFormat11(cmd) {
|
|
6489
6853
|
const config = loadConfig();
|
|
6490
6854
|
const globalOpts = cmd.optsWithGlobals();
|
|
6491
6855
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -6515,7 +6879,7 @@ Examples:
|
|
|
6515
6879
|
;
|
|
6516
6880
|
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
6881
|
try {
|
|
6518
|
-
const outputFormat =
|
|
6882
|
+
const outputFormat = getOutputFormat11(cmd);
|
|
6519
6883
|
const overrides = getOverrides8(cmd);
|
|
6520
6884
|
const resolved = parseEntityReference(ref, overrides);
|
|
6521
6885
|
const api = createApiClient();
|
|
@@ -6596,7 +6960,7 @@ Examples:
|
|
|
6596
6960
|
});
|
|
6597
6961
|
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
6962
|
try {
|
|
6599
|
-
const outputFormat =
|
|
6963
|
+
const outputFormat = getOutputFormat11(cmd);
|
|
6600
6964
|
const overrides = getOverrides8(cmd);
|
|
6601
6965
|
const resolved = parseEntityReference(ref, overrides);
|
|
6602
6966
|
const api = createApiClient();
|
|
@@ -6637,7 +7001,7 @@ Examples:
|
|
|
6637
7001
|
});
|
|
6638
7002
|
fn.command("outputs").description("Get outputs for an evaluation").argument("<projectId>", "Project ID").argument("<evaluationId>", "Evaluation ID").action(async (projectId, evaluationId, _options, cmd) => {
|
|
6639
7003
|
try {
|
|
6640
|
-
const outputFormat =
|
|
7004
|
+
const outputFormat = getOutputFormat11(cmd);
|
|
6641
7005
|
const api = createApiClient();
|
|
6642
7006
|
const outputs = await api.evaluation.getOutputs(projectId, evaluationId);
|
|
6643
7007
|
if (outputFormat === "human") {
|
|
@@ -6657,7 +7021,7 @@ Examples:
|
|
|
6657
7021
|
});
|
|
6658
7022
|
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
7023
|
try {
|
|
6660
|
-
const outputFormat =
|
|
7024
|
+
const outputFormat = getOutputFormat11(cmd);
|
|
6661
7025
|
const overrides = getOverrides8(cmd);
|
|
6662
7026
|
const resolved = parseEntityReference(ref, overrides);
|
|
6663
7027
|
const api = createApiClient();
|
|
@@ -6703,7 +7067,7 @@ Examples:
|
|
|
6703
7067
|
});
|
|
6704
7068
|
fn.command("languages").description("List the languages a function can be written in").action(async (_options, cmd) => {
|
|
6705
7069
|
try {
|
|
6706
|
-
const outputFormat =
|
|
7070
|
+
const outputFormat = getOutputFormat11(cmd);
|
|
6707
7071
|
format(
|
|
6708
7072
|
FUNCTION_LANGUAGES.map((language) => ({
|
|
6709
7073
|
language,
|
|
@@ -6717,7 +7081,7 @@ Examples:
|
|
|
6717
7081
|
});
|
|
6718
7082
|
fn.command("last-evaluation").description("Show the most recent evaluation of a function").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
|
|
6719
7083
|
try {
|
|
6720
|
-
const outputFormat =
|
|
7084
|
+
const outputFormat = getOutputFormat11(cmd);
|
|
6721
7085
|
const overrides = getOverrides8(cmd);
|
|
6722
7086
|
const resolved = parseEntityReference(ref, overrides);
|
|
6723
7087
|
const api = createApiClient();
|
|
@@ -7529,9 +7893,11 @@ var BY_COMMAND = {
|
|
|
7529
7893
|
"config set": { "<key>": { kind: "choice", choices: CONFIG_KEYS } },
|
|
7530
7894
|
"project members invite": { "<userId>": TEXT, "<role>": { kind: "choice", choices: PROJECT_ROLES } },
|
|
7531
7895
|
"project members join": { "<userId>": TEXT },
|
|
7896
|
+
"license create": { "<licenseId>": TEXT, "--name": TEXT, "--flags": TEXT },
|
|
7532
7897
|
"trigger create": { "--type": { kind: "choice", choices: TRIGGER_TYPES } },
|
|
7533
7898
|
"analyze triggers create": { "--kind": { kind: "choice", choices: ANALYSIS_TRIGGER_KINDS } },
|
|
7534
7899
|
"function outputs": { "<evaluationId>": TEXT },
|
|
7900
|
+
"admin project move": { "--to": TEXT },
|
|
7535
7901
|
"team create": { "--seats": { kind: "number", min: 1, integer: true } },
|
|
7536
7902
|
"team seats preview": { "<count>": { kind: "number", min: 1, integer: true } },
|
|
7537
7903
|
"team seats set": { "<count>": { kind: "number", min: 1, integer: true } }
|
|
@@ -7589,7 +7955,10 @@ var BY_NAME = {
|
|
|
7589
7955
|
consumerType: TEXT,
|
|
7590
7956
|
consumerId: TEXT,
|
|
7591
7957
|
format: TEXT,
|
|
7592
|
-
key: TEXT
|
|
7958
|
+
key: TEXT,
|
|
7959
|
+
reason: TEXT,
|
|
7960
|
+
batchId: TEXT,
|
|
7961
|
+
userIdOrEmail: TEXT
|
|
7593
7962
|
};
|
|
7594
7963
|
function tokenOf(input) {
|
|
7595
7964
|
return input.kind === "option" ? input.flag ?? `--${input.name}` : `<${input.name}>`;
|
|
@@ -7665,7 +8034,7 @@ function dependencies(spec) {
|
|
|
7665
8034
|
}
|
|
7666
8035
|
|
|
7667
8036
|
// src/commands/trigger/index.ts
|
|
7668
|
-
function
|
|
8037
|
+
function getOutputFormat12(cmd) {
|
|
7669
8038
|
const config = loadConfig();
|
|
7670
8039
|
const globalOpts = cmd.optsWithGlobals();
|
|
7671
8040
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -7684,7 +8053,7 @@ Examples:
|
|
|
7684
8053
|
`);
|
|
7685
8054
|
trigger.command("list").description("List triggers for a function").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
|
|
7686
8055
|
try {
|
|
7687
|
-
const outputFormat =
|
|
8056
|
+
const outputFormat = getOutputFormat12(cmd);
|
|
7688
8057
|
const overrides = getOverrides9(cmd);
|
|
7689
8058
|
const resolved = parseEntityReference(ref, overrides);
|
|
7690
8059
|
const api = createApiClient();
|
|
@@ -7713,7 +8082,7 @@ Examples:
|
|
|
7713
8082
|
});
|
|
7714
8083
|
trigger.command("get").description("Get a specific trigger").argument("<ref>", "Function entity reference").argument("<triggerId>", "Trigger ID").action(async (ref, triggerId, _options, cmd) => {
|
|
7715
8084
|
try {
|
|
7716
|
-
const outputFormat =
|
|
8085
|
+
const outputFormat = getOutputFormat12(cmd);
|
|
7717
8086
|
const overrides = getOverrides9(cmd);
|
|
7718
8087
|
const resolved = parseEntityReference(ref, overrides);
|
|
7719
8088
|
const api = createApiClient();
|
|
@@ -7805,7 +8174,7 @@ Examples:
|
|
|
7805
8174
|
}
|
|
7806
8175
|
|
|
7807
8176
|
// src/commands/schedule/index.ts
|
|
7808
|
-
function
|
|
8177
|
+
function getOutputFormat13(cmd) {
|
|
7809
8178
|
const config = loadConfig();
|
|
7810
8179
|
const globalOpts = cmd.optsWithGlobals();
|
|
7811
8180
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -7818,7 +8187,7 @@ function registerScheduleCommands(program) {
|
|
|
7818
8187
|
const schedule = program.command("schedule").description("Schedule function execution");
|
|
7819
8188
|
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
8189
|
try {
|
|
7821
|
-
const outputFormat =
|
|
8190
|
+
const outputFormat = getOutputFormat13(cmd);
|
|
7822
8191
|
const overrides = getOverrides10(cmd);
|
|
7823
8192
|
const resolved = parseEntityReference(ref, overrides);
|
|
7824
8193
|
const api = createApiClient();
|
|
@@ -7887,7 +8256,7 @@ function registerScheduleCommands(program) {
|
|
|
7887
8256
|
});
|
|
7888
8257
|
schedule.command("list").description("List persistent triggers (scheduled functions are modeled as triggers)").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
|
|
7889
8258
|
try {
|
|
7890
|
-
const outputFormat =
|
|
8259
|
+
const outputFormat = getOutputFormat13(cmd);
|
|
7891
8260
|
const overrides = getOverrides10(cmd);
|
|
7892
8261
|
const resolved = parseEntityReference(ref, overrides);
|
|
7893
8262
|
const api = createApiClient();
|
|
@@ -8015,7 +8384,7 @@ function inline(text2) {
|
|
|
8015
8384
|
}
|
|
8016
8385
|
|
|
8017
8386
|
// src/commands/chat/index.ts
|
|
8018
|
-
function
|
|
8387
|
+
function getOutputFormat14(cmd) {
|
|
8019
8388
|
const config = loadConfig();
|
|
8020
8389
|
const globalOpts = cmd.optsWithGlobals();
|
|
8021
8390
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -8100,7 +8469,7 @@ var HELP = [
|
|
|
8100
8469
|
];
|
|
8101
8470
|
async function runChatRepl(options) {
|
|
8102
8471
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
8103
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
8472
|
+
const { getUpdateNotice } = await import("./update-check-JWT4C4O5.js");
|
|
8104
8473
|
let sessionId = options.session;
|
|
8105
8474
|
let lastReportedSession;
|
|
8106
8475
|
console.log(chalk21.bold("Diafunc chat") + chalk21.dim(" \xB7 /help for commands, /quit to exit"));
|
|
@@ -8207,7 +8576,7 @@ Examples:
|
|
|
8207
8576
|
});
|
|
8208
8577
|
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
8578
|
try {
|
|
8210
|
-
const outputFormat =
|
|
8579
|
+
const outputFormat = getOutputFormat14(cmd);
|
|
8211
8580
|
const api = createApiClient();
|
|
8212
8581
|
const context = chatContext(cmd);
|
|
8213
8582
|
const response = await api.language.chat({
|
|
@@ -8231,7 +8600,7 @@ Examples:
|
|
|
8231
8600
|
});
|
|
8232
8601
|
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
8602
|
try {
|
|
8234
|
-
const outputFormat =
|
|
8603
|
+
const outputFormat = getOutputFormat14(cmd);
|
|
8235
8604
|
const api = createApiClient();
|
|
8236
8605
|
const context = chatContext(cmd);
|
|
8237
8606
|
const response = await api.language.chatStream({
|
|
@@ -8321,7 +8690,7 @@ Examples:
|
|
|
8321
8690
|
const session = chat.command("session").description("Manage chat sessions");
|
|
8322
8691
|
session.command("list").description("List chat sessions").action(async (_options, cmd) => {
|
|
8323
8692
|
try {
|
|
8324
|
-
const outputFormat =
|
|
8693
|
+
const outputFormat = getOutputFormat14(cmd);
|
|
8325
8694
|
const api = createApiClient();
|
|
8326
8695
|
const sessions = await api.language.getSessions();
|
|
8327
8696
|
format(sessions, {
|
|
@@ -8343,7 +8712,7 @@ Examples:
|
|
|
8343
8712
|
});
|
|
8344
8713
|
session.command("show").description("Show the message history of a chat session").argument("<sessionId>", "Session ID").action(async (sessionId, _options, cmd) => {
|
|
8345
8714
|
try {
|
|
8346
|
-
const outputFormat =
|
|
8715
|
+
const outputFormat = getOutputFormat14(cmd);
|
|
8347
8716
|
const api = createApiClient();
|
|
8348
8717
|
const detail2 = await api.language.getSession(sessionId);
|
|
8349
8718
|
if (outputFormat === "human") {
|
|
@@ -8373,7 +8742,7 @@ Examples:
|
|
|
8373
8742
|
});
|
|
8374
8743
|
chat.command("usage").description("Show token usage").action(async (_options, cmd) => {
|
|
8375
8744
|
try {
|
|
8376
|
-
const outputFormat =
|
|
8745
|
+
const outputFormat = getOutputFormat14(cmd);
|
|
8377
8746
|
const api = createApiClient();
|
|
8378
8747
|
const usage = await api.language.getUsage();
|
|
8379
8748
|
format(usage, { format: outputFormat });
|
|
@@ -8385,7 +8754,7 @@ Examples:
|
|
|
8385
8754
|
|
|
8386
8755
|
// src/commands/search/index.ts
|
|
8387
8756
|
import chalk22 from "chalk";
|
|
8388
|
-
function
|
|
8757
|
+
function getOutputFormat15(cmd) {
|
|
8389
8758
|
const config = loadConfig();
|
|
8390
8759
|
const globalOpts = cmd.optsWithGlobals();
|
|
8391
8760
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -8408,7 +8777,7 @@ whose discovered model has the better quality comes first; inside one project th
|
|
|
8408
8777
|
`).action(async (query, options, cmd) => {
|
|
8409
8778
|
const sort = parseSort(options.sort);
|
|
8410
8779
|
try {
|
|
8411
|
-
const outputFormat =
|
|
8780
|
+
const outputFormat = getOutputFormat15(cmd);
|
|
8412
8781
|
const overrides = cmd.optsWithGlobals();
|
|
8413
8782
|
const config = loadConfig();
|
|
8414
8783
|
const api = createApiClient();
|
|
@@ -8502,11 +8871,11 @@ function collapse(text2) {
|
|
|
8502
8871
|
}
|
|
8503
8872
|
|
|
8504
8873
|
// src/commands/admin/index.ts
|
|
8505
|
-
import { readFile } from "fs/promises";
|
|
8874
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
8506
8875
|
|
|
8507
8876
|
// src/commands/admin/curated-tags.ts
|
|
8508
8877
|
import chalk23 from "chalk";
|
|
8509
|
-
function
|
|
8878
|
+
function getOutputFormat16(cmd) {
|
|
8510
8879
|
const config = loadConfig();
|
|
8511
8880
|
const globalOpts = cmd.optsWithGlobals();
|
|
8512
8881
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -8548,7 +8917,7 @@ Examples:
|
|
|
8548
8917
|
$ diafunc admin curated-tags list -o json
|
|
8549
8918
|
`).action(async (_options, cmd) => {
|
|
8550
8919
|
try {
|
|
8551
|
-
const outputFormat =
|
|
8920
|
+
const outputFormat = getOutputFormat16(cmd);
|
|
8552
8921
|
const tags = await createApiClient().index.getCuratedTags(true);
|
|
8553
8922
|
if (tags.length === 0) {
|
|
8554
8923
|
empty("curated tags", { format: outputFormat });
|
|
@@ -8565,7 +8934,7 @@ Examples:
|
|
|
8565
8934
|
$ diafunc admin curated-tags create "Machine Learning" --display-name "Machine learning" --dry-run
|
|
8566
8935
|
`).action(async (typed2, options, cmd) => {
|
|
8567
8936
|
try {
|
|
8568
|
-
const outputFormat =
|
|
8937
|
+
const outputFormat = getOutputFormat16(cmd);
|
|
8569
8938
|
const tag = curatedTagOf(typed2);
|
|
8570
8939
|
if (isReservedTag(tag)) {
|
|
8571
8940
|
usageError(`"${tag}" is reserved for the staging content of analysis runs and is never searchable.`);
|
|
@@ -8598,7 +8967,7 @@ Examples:
|
|
|
8598
8967
|
$ diafunc admin curated-tags update health --sort-order 3 --dry-run
|
|
8599
8968
|
`).action(async (typed2, options, cmd) => {
|
|
8600
8969
|
try {
|
|
8601
|
-
const outputFormat =
|
|
8970
|
+
const outputFormat = getOutputFormat16(cmd);
|
|
8602
8971
|
const tag = curatedTagOf(typed2);
|
|
8603
8972
|
if (options.displayName === void 0 && options.description === void 0 && options.sortOrder === void 0) {
|
|
8604
8973
|
usageError("Nothing to change.", "Pass at least one of --display-name, --description, --sort-order.");
|
|
@@ -8628,7 +8997,7 @@ Examples:
|
|
|
8628
8997
|
$ diafunc admin curated-tags delete health --yes --dry-run
|
|
8629
8998
|
`).action(async (typed2, options, cmd) => {
|
|
8630
8999
|
try {
|
|
8631
|
-
const outputFormat =
|
|
9000
|
+
const outputFormat = getOutputFormat16(cmd);
|
|
8632
9001
|
const tag = curatedTagOf(typed2);
|
|
8633
9002
|
if (!isDryRun()) {
|
|
8634
9003
|
await confirmDestructive(`This removes "${tag}" from Explore's data-domain filter.`, { yes: options.yes, resourceId: tag });
|
|
@@ -8642,8 +9011,261 @@ Examples:
|
|
|
8642
9011
|
});
|
|
8643
9012
|
}
|
|
8644
9013
|
|
|
9014
|
+
// src/util/id-list.ts
|
|
9015
|
+
import { readFile } from "fs/promises";
|
|
9016
|
+
function parseIdList(text2) {
|
|
9017
|
+
const ids = text2.split(/\r?\n/).map((line) => line.replace(/#.*$/, "")).flatMap((line) => line.split(/[\s,]+/)).map((id) => id.trim()).filter((id) => id.length > 0);
|
|
9018
|
+
return [...new Set(ids)];
|
|
9019
|
+
}
|
|
9020
|
+
async function readIdList(source, stdin = process.stdin) {
|
|
9021
|
+
const text2 = source === "-" ? await readAll(stdin) : await readFile(source, "utf-8");
|
|
9022
|
+
return parseIdList(text2);
|
|
9023
|
+
}
|
|
9024
|
+
function readAll(stream) {
|
|
9025
|
+
return new Promise((resolve2, reject) => {
|
|
9026
|
+
let data = "";
|
|
9027
|
+
stream.setEncoding("utf-8");
|
|
9028
|
+
stream.on("data", (chunk) => {
|
|
9029
|
+
data += chunk;
|
|
9030
|
+
});
|
|
9031
|
+
stream.on("end", () => resolve2(data));
|
|
9032
|
+
stream.on("error", reject);
|
|
9033
|
+
});
|
|
9034
|
+
}
|
|
9035
|
+
function mergeIds(...lists) {
|
|
9036
|
+
return [...new Set(lists.flat().map((id) => id.trim()).filter((id) => id.length > 0))];
|
|
9037
|
+
}
|
|
9038
|
+
|
|
9039
|
+
// src/commands/admin/projects.ts
|
|
9040
|
+
function getOutputFormat17(cmd) {
|
|
9041
|
+
const config = loadConfig();
|
|
9042
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
9043
|
+
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
9044
|
+
}
|
|
9045
|
+
var MAX_PROJECTS_PER_MOVE = 500;
|
|
9046
|
+
var OPERATOR_TRANSFER_STATUSES = ["open", "moving", "failed"];
|
|
9047
|
+
async function collectProjectIds(args, idsFile) {
|
|
9048
|
+
const fromFile = idsFile ? await readIdList(idsFile) : [];
|
|
9049
|
+
const ids = mergeIds(args, fromFile);
|
|
9050
|
+
if (ids.length === 0) {
|
|
9051
|
+
throw new CliError("Name the projects to move, as arguments or with --ids-file <path|->.", { exitCode: EXIT_USAGE });
|
|
9052
|
+
}
|
|
9053
|
+
if (ids.length > MAX_PROJECTS_PER_MOVE) {
|
|
9054
|
+
throw new CliError(
|
|
9055
|
+
`${ids.length} projects named; one move takes at most ${MAX_PROJECTS_PER_MOVE}. Split the list.`,
|
|
9056
|
+
{ exitCode: EXIT_USAGE }
|
|
9057
|
+
);
|
|
9058
|
+
}
|
|
9059
|
+
return ids;
|
|
9060
|
+
}
|
|
9061
|
+
function moveRequest(options) {
|
|
9062
|
+
const reason2 = options.reason.trim();
|
|
9063
|
+
if (!reason2) throw new CliError("A move needs a reason: --reason <text>.", { exitCode: EXIT_USAGE });
|
|
9064
|
+
const toUserId = options.to.trim();
|
|
9065
|
+
if (!toUserId) throw new CliError("Name the new owner with --to <userId>.", { exitCode: EXIT_USAGE });
|
|
9066
|
+
return {
|
|
9067
|
+
toUserId,
|
|
9068
|
+
...options.team ? { toTeamId: options.team } : {},
|
|
9069
|
+
previousOwnerRole: options.keepPreviousOwner ? "MAINTAINER" : "NONE",
|
|
9070
|
+
reason: reason2,
|
|
9071
|
+
notify: options.notify
|
|
9072
|
+
};
|
|
9073
|
+
}
|
|
9074
|
+
function moveWarning(projectIds, request) {
|
|
9075
|
+
const what = projectIds.length === 1 ? `project "${projectIds[0]}"` : `${projectIds.length} projects`;
|
|
9076
|
+
const into = request.toTeamId ? ` into team ${request.toTeamId}` : "";
|
|
9077
|
+
const previous = request.previousOwnerRole === "MAINTAINER" ? "Each previous owner stays on as a maintainer" : "Each previous owner loses access";
|
|
9078
|
+
const mail = request.notify ? "both owners are told" : "nobody is notified";
|
|
9079
|
+
return `This will move ${what} to user ${request.toUserId}${into} without asking anyone. ${previous}; ${mail}.`;
|
|
9080
|
+
}
|
|
9081
|
+
function preflightVerdicts(result) {
|
|
9082
|
+
if (!result) return [];
|
|
9083
|
+
if (Array.isArray(result)) return result;
|
|
9084
|
+
return Array.isArray(result.items) ? result.items : [];
|
|
9085
|
+
}
|
|
9086
|
+
function isMovable(verdict) {
|
|
9087
|
+
return verdict.verdict === "ok";
|
|
9088
|
+
}
|
|
9089
|
+
function parseOperatorStatus(value) {
|
|
9090
|
+
if (value === void 0) return void 0;
|
|
9091
|
+
const status = value.trim().toLowerCase();
|
|
9092
|
+
if (!OPERATOR_TRANSFER_STATUSES.includes(status)) {
|
|
9093
|
+
throw new CliError(`Invalid status "${value}". Use one of: ${OPERATOR_TRANSFER_STATUSES.join(", ")}.`, { exitCode: EXIT_USAGE });
|
|
9094
|
+
}
|
|
9095
|
+
return status;
|
|
9096
|
+
}
|
|
9097
|
+
function splitBatch(batch) {
|
|
9098
|
+
const { items, ...summary } = batch;
|
|
9099
|
+
return { summary, items: items ?? [] };
|
|
9100
|
+
}
|
|
9101
|
+
function registerAdminProjectCommands(admin) {
|
|
9102
|
+
const project = admin.command("project").description("Move projects between accounts and repair stuck transfers (admin)");
|
|
9103
|
+
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", `
|
|
9104
|
+
A single project moves right away and the command prints the finished transfer. Several move as a
|
|
9105
|
+
batch in the background (at most ${MAX_PROJECTS_PER_MOVE} per call; super-admin only); follow it with
|
|
9106
|
+
'diafunc admin project moves status <batchId>'.
|
|
9107
|
+
|
|
9108
|
+
--preflight prints one verdict per project: ok, busy:<what is running>, not_found, already_owner or
|
|
9109
|
+
open_transfer, and exits 1 if any project could not move.
|
|
9110
|
+
|
|
9111
|
+
Examples:
|
|
9112
|
+
$ diafunc admin project move <projectId> --to <userId> --reason "Support ticket 4711"
|
|
9113
|
+
$ diafunc admin project move --ids-file examples.txt --to <userId> --reason "Examples account" --no-notify --preflight
|
|
9114
|
+
$ cat examples.txt | diafunc admin project move --ids-file - --to <userId> --reason "Examples account" --no-notify -y
|
|
9115
|
+
`).action(async (args, options, cmd) => {
|
|
9116
|
+
let blocked = 0;
|
|
9117
|
+
try {
|
|
9118
|
+
const projectIds = await collectProjectIds(args, options.idsFile);
|
|
9119
|
+
const request = moveRequest(options);
|
|
9120
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
9121
|
+
const api = createApiClient();
|
|
9122
|
+
if (options.preflight) {
|
|
9123
|
+
const result = await api.admin.moveProjects({
|
|
9124
|
+
...request,
|
|
9125
|
+
projectIds,
|
|
9126
|
+
preflight: true,
|
|
9127
|
+
expectedCount: projectIds.length
|
|
9128
|
+
});
|
|
9129
|
+
if (isDryRun()) return;
|
|
9130
|
+
const verdicts = preflightVerdicts(result);
|
|
9131
|
+
blocked = verdicts.filter((v) => !isMovable(v)).length;
|
|
9132
|
+
if (outputFormat !== "human") {
|
|
9133
|
+
format(result, { format: outputFormat });
|
|
9134
|
+
} else {
|
|
9135
|
+
format(verdicts, { format: outputFormat, columns: [{ key: "projectId", kind: "id" }, { key: "verdict" }] });
|
|
9136
|
+
console.log("");
|
|
9137
|
+
const movable = verdicts.length - blocked;
|
|
9138
|
+
if (blocked === 0) success(`All ${movable} projects can move. Nothing was changed.`);
|
|
9139
|
+
else warn(`${movable} of ${verdicts.length} projects can move; ${blocked} cannot. Nothing was changed.`);
|
|
9140
|
+
}
|
|
9141
|
+
} else if (projectIds.length === 1) {
|
|
9142
|
+
await confirmDestructive(moveWarning(projectIds, request), { yes: options.yes, resourceId: projectIds[0] });
|
|
9143
|
+
const moved = await api.admin.moveProject(projectIds[0], request);
|
|
9144
|
+
if (isDryRun()) return;
|
|
9145
|
+
if (outputFormat !== "human") {
|
|
9146
|
+
format(moved, { format: outputFormat });
|
|
9147
|
+
} else {
|
|
9148
|
+
success(`Moved project "${moved.projectName ?? projectIds[0]}" to ${moved.toUserName ?? request.toUserId}.`);
|
|
9149
|
+
}
|
|
9150
|
+
} else {
|
|
9151
|
+
await confirmDestructive(moveWarning(projectIds, request), {
|
|
9152
|
+
yes: options.yes,
|
|
9153
|
+
resourceId: String(projectIds.length)
|
|
9154
|
+
});
|
|
9155
|
+
const started = await api.admin.moveProjects({
|
|
9156
|
+
...request,
|
|
9157
|
+
projectIds,
|
|
9158
|
+
preflight: false,
|
|
9159
|
+
expectedCount: projectIds.length
|
|
9160
|
+
});
|
|
9161
|
+
if (isDryRun()) return;
|
|
9162
|
+
if (outputFormat !== "human") {
|
|
9163
|
+
format(started, { format: outputFormat });
|
|
9164
|
+
} else {
|
|
9165
|
+
success(`Started moving ${projectIds.length} projects (batch ID: ${started.batchId}).`);
|
|
9166
|
+
hint(`Follow it with 'diafunc admin project moves status ${started.batchId}'.`);
|
|
9167
|
+
}
|
|
9168
|
+
}
|
|
9169
|
+
} catch (error) {
|
|
9170
|
+
handleError(error);
|
|
9171
|
+
}
|
|
9172
|
+
if (blocked > 0) process.exit(EXIT_FAILURE);
|
|
9173
|
+
});
|
|
9174
|
+
const moves = project.command("moves").description("Follow bulk moves");
|
|
9175
|
+
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) => {
|
|
9176
|
+
try {
|
|
9177
|
+
const api = createApiClient();
|
|
9178
|
+
const batch = await api.admin.getProjectMoveBatch(batchId);
|
|
9179
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
9180
|
+
if (outputFormat !== "human") {
|
|
9181
|
+
format(batch, { format: outputFormat });
|
|
9182
|
+
return;
|
|
9183
|
+
}
|
|
9184
|
+
const { summary, items } = splitBatch(batch);
|
|
9185
|
+
format(summary, { format: outputFormat });
|
|
9186
|
+
if (items.length > 0) {
|
|
9187
|
+
console.log("");
|
|
9188
|
+
format(items, { format: outputFormat });
|
|
9189
|
+
}
|
|
9190
|
+
} catch (error) {
|
|
9191
|
+
handleError(error);
|
|
9192
|
+
}
|
|
9193
|
+
});
|
|
9194
|
+
const transfers = project.command("transfers").description("Inspect and repair project transfers");
|
|
9195
|
+
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) => {
|
|
9196
|
+
try {
|
|
9197
|
+
const status = parseOperatorStatus(options.status);
|
|
9198
|
+
const api = createApiClient();
|
|
9199
|
+
const list = await api.admin.listOperatorProjectTransfers(status) ?? [];
|
|
9200
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
9201
|
+
if (list.length === 0) {
|
|
9202
|
+
empty("project transfers", { format: outputFormat });
|
|
9203
|
+
return;
|
|
9204
|
+
}
|
|
9205
|
+
format(list, {
|
|
9206
|
+
format: outputFormat,
|
|
9207
|
+
columns: [
|
|
9208
|
+
{ key: "projectName", header: "project" },
|
|
9209
|
+
{ key: "projectId", kind: "id" },
|
|
9210
|
+
{ key: "transferId", kind: "id" },
|
|
9211
|
+
{ key: "status", kind: "state" },
|
|
9212
|
+
{ key: "kind" },
|
|
9213
|
+
{ key: "fromUserName", header: "from" },
|
|
9214
|
+
{ key: "toUserName", header: "to" },
|
|
9215
|
+
{ key: "offeredAt", kind: "date" },
|
|
9216
|
+
{ key: "expiresAt", kind: "date" }
|
|
9217
|
+
]
|
|
9218
|
+
});
|
|
9219
|
+
} catch (error) {
|
|
9220
|
+
handleError(error);
|
|
9221
|
+
}
|
|
9222
|
+
});
|
|
9223
|
+
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) => {
|
|
9224
|
+
try {
|
|
9225
|
+
const api = createApiClient();
|
|
9226
|
+
await api.admin.resumeProjectTransfer(projectId, requireReason(options.reason));
|
|
9227
|
+
success(`Resumed the transfer of project "${projectId}".`, { format: getOutputFormat17(cmd) });
|
|
9228
|
+
} catch (error) {
|
|
9229
|
+
handleError(error);
|
|
9230
|
+
}
|
|
9231
|
+
});
|
|
9232
|
+
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) => {
|
|
9233
|
+
try {
|
|
9234
|
+
const reason2 = requireReason(options.reason);
|
|
9235
|
+
await confirmDestructive(
|
|
9236
|
+
`This will undo the steps the transfer of project "${projectId}" has done and leave it with its previous owner.`,
|
|
9237
|
+
{ yes: options.yes, resourceId: projectId }
|
|
9238
|
+
);
|
|
9239
|
+
const api = createApiClient();
|
|
9240
|
+
await api.admin.abortProjectTransfer(projectId, reason2);
|
|
9241
|
+
success(`Aborted the transfer of project "${projectId}".`, { format: getOutputFormat17(cmd) });
|
|
9242
|
+
} catch (error) {
|
|
9243
|
+
handleError(error);
|
|
9244
|
+
}
|
|
9245
|
+
});
|
|
9246
|
+
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) => {
|
|
9247
|
+
try {
|
|
9248
|
+
const reason2 = requireReason(options.reason);
|
|
9249
|
+
await confirmDestructive(
|
|
9250
|
+
`This will cancel the open offer of project "${projectId}". The owner can offer it again.`,
|
|
9251
|
+
{ yes: options.yes, resourceId: projectId }
|
|
9252
|
+
);
|
|
9253
|
+
const api = createApiClient();
|
|
9254
|
+
await api.admin.cancelProjectTransferAsOperator(projectId, reason2);
|
|
9255
|
+
success(`Canceled the open offer of project "${projectId}".`, { format: getOutputFormat17(cmd) });
|
|
9256
|
+
} catch (error) {
|
|
9257
|
+
handleError(error);
|
|
9258
|
+
}
|
|
9259
|
+
});
|
|
9260
|
+
}
|
|
9261
|
+
function requireReason(reason2) {
|
|
9262
|
+
const trimmed = reason2.trim();
|
|
9263
|
+
if (!trimmed) throw new CliError("Give a reason with --reason <text>.", { exitCode: EXIT_USAGE });
|
|
9264
|
+
return trimmed;
|
|
9265
|
+
}
|
|
9266
|
+
|
|
8645
9267
|
// src/commands/admin/index.ts
|
|
8646
|
-
function
|
|
9268
|
+
function getOutputFormat18(cmd) {
|
|
8647
9269
|
const config = loadConfig();
|
|
8648
9270
|
const globalOpts = cmd.optsWithGlobals();
|
|
8649
9271
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -8653,7 +9275,7 @@ function registerAdminCommands(program) {
|
|
|
8653
9275
|
const users = admin.command("users").description("Manage users");
|
|
8654
9276
|
users.command("list").description("List all users (admin)").action(async (_options, cmd) => {
|
|
8655
9277
|
try {
|
|
8656
|
-
const outputFormat =
|
|
9278
|
+
const outputFormat = getOutputFormat18(cmd);
|
|
8657
9279
|
const api = createApiClient();
|
|
8658
9280
|
const userList = await api.admin.getUsers();
|
|
8659
9281
|
const summary = userList.map((u) => ({
|
|
@@ -8679,7 +9301,7 @@ function registerAdminCommands(program) {
|
|
|
8679
9301
|
});
|
|
8680
9302
|
users.command("get").description("Get current user details").action(async (_options, cmd) => {
|
|
8681
9303
|
try {
|
|
8682
|
-
const outputFormat =
|
|
9304
|
+
const outputFormat = getOutputFormat18(cmd);
|
|
8683
9305
|
const api = createApiClient();
|
|
8684
9306
|
const user = await api.admin.getMyUser();
|
|
8685
9307
|
format(user, { format: outputFormat });
|
|
@@ -8689,7 +9311,7 @@ function registerAdminCommands(program) {
|
|
|
8689
9311
|
});
|
|
8690
9312
|
admin.command("subscription").description("Show current subscription").action(async (_options, cmd) => {
|
|
8691
9313
|
try {
|
|
8692
|
-
const outputFormat =
|
|
9314
|
+
const outputFormat = getOutputFormat18(cmd);
|
|
8693
9315
|
const api = createApiClient();
|
|
8694
9316
|
const sub = await api.admin.getCurrentSubscription();
|
|
8695
9317
|
format(sub, { format: outputFormat });
|
|
@@ -8700,7 +9322,7 @@ function registerAdminCommands(program) {
|
|
|
8700
9322
|
const settings = admin.command("settings").description("Manage settings");
|
|
8701
9323
|
settings.command("get").description("Get current settings").action(async (_options, cmd) => {
|
|
8702
9324
|
try {
|
|
8703
|
-
const outputFormat =
|
|
9325
|
+
const outputFormat = getOutputFormat18(cmd);
|
|
8704
9326
|
const api = createApiClient();
|
|
8705
9327
|
const s = await api.admin.getSettings();
|
|
8706
9328
|
format(s, { format: outputFormat });
|
|
@@ -8720,7 +9342,7 @@ function registerAdminCommands(program) {
|
|
|
8720
9342
|
const platformSettings = admin.command("platform-settings").description("Manage platform-wide settings (admin only)");
|
|
8721
9343
|
platformSettings.command("list").description("Show every platform setting with its default and current override").action(async (_options, cmd) => {
|
|
8722
9344
|
try {
|
|
8723
|
-
const outputFormat =
|
|
9345
|
+
const outputFormat = getOutputFormat18(cmd);
|
|
8724
9346
|
const api = createApiClient();
|
|
8725
9347
|
const settingsList = await api.admin.listPlatformSettings();
|
|
8726
9348
|
format(settingsList, { format: outputFormat });
|
|
@@ -8808,9 +9430,10 @@ function registerAdminCommands(program) {
|
|
|
8808
9430
|
}
|
|
8809
9431
|
});
|
|
8810
9432
|
registerCuratedTagCommands(admin);
|
|
9433
|
+
registerAdminProjectCommands(admin);
|
|
8811
9434
|
admin.command("permissions").description("Show your permissions on a project").argument("<projectId>", "Project ID").action(async (projectId, _options, cmd) => {
|
|
8812
9435
|
try {
|
|
8813
|
-
const outputFormat =
|
|
9436
|
+
const outputFormat = getOutputFormat18(cmd);
|
|
8814
9437
|
const api = createApiClient();
|
|
8815
9438
|
const perm = await api.admin.getPermissions(projectId);
|
|
8816
9439
|
format({ projectId, permission: perm }, { format: outputFormat });
|
|
@@ -8823,20 +9446,20 @@ function registerAdminCommands(program) {
|
|
|
8823
9446
|
contract.command("get", { isDefault: true }).description("Show a team's contract").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
|
|
8824
9447
|
try {
|
|
8825
9448
|
const api = createApiClient();
|
|
8826
|
-
format(await api.admin.getTeamContract(teamId), { format:
|
|
9449
|
+
format(await api.admin.getTeamContract(teamId), { format: getOutputFormat18(cmd) });
|
|
8827
9450
|
} catch (error) {
|
|
8828
9451
|
handleError(error);
|
|
8829
9452
|
}
|
|
8830
9453
|
});
|
|
8831
9454
|
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
9455
|
try {
|
|
8833
|
-
const request = JSON.parse(await
|
|
9456
|
+
const request = JSON.parse(await readFile2(options.file, "utf8"));
|
|
8834
9457
|
await confirmDestructive(
|
|
8835
9458
|
`This will replace the contract of team "${teamId}" with the terms in ${options.file}.`,
|
|
8836
9459
|
{ yes: options.yes, resourceId: teamId }
|
|
8837
9460
|
);
|
|
8838
9461
|
const api = createApiClient();
|
|
8839
|
-
format(await api.admin.issueTeamContract(teamId, request), { format:
|
|
9462
|
+
format(await api.admin.issueTeamContract(teamId, request), { format: getOutputFormat18(cmd) });
|
|
8840
9463
|
} catch (error) {
|
|
8841
9464
|
handleError(error);
|
|
8842
9465
|
}
|
|
@@ -10067,7 +10690,7 @@ function openUrl(url) {
|
|
|
10067
10690
|
const args = process.platform === "win32" ? ["/c", "start", '""', url] : [url];
|
|
10068
10691
|
spawn2(cmd, args, { detached: true, stdio: "ignore" }).unref();
|
|
10069
10692
|
}
|
|
10070
|
-
function
|
|
10693
|
+
function getOutputFormat19(cmd) {
|
|
10071
10694
|
const config = loadConfig();
|
|
10072
10695
|
const globalOpts = cmd.optsWithGlobals();
|
|
10073
10696
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -10076,7 +10699,7 @@ function noInteractiveFlag(cmd) {
|
|
|
10076
10699
|
return cmd.optsWithGlobals().interactive === false;
|
|
10077
10700
|
}
|
|
10078
10701
|
function importContext(api, analysisId, cmd, machineReport) {
|
|
10079
|
-
const outputFormat =
|
|
10702
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10080
10703
|
const noInteractive = noInteractiveFlag(cmd);
|
|
10081
10704
|
return {
|
|
10082
10705
|
api,
|
|
@@ -10202,7 +10825,7 @@ async function runAnalysis(files, options, cmd) {
|
|
|
10202
10825
|
}
|
|
10203
10826
|
}
|
|
10204
10827
|
const file = files[0];
|
|
10205
|
-
const outputFormat =
|
|
10828
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10206
10829
|
const noInteractive = noInteractiveFlag(cmd);
|
|
10207
10830
|
const interactive = canPrompt(outputFormat, noInteractive);
|
|
10208
10831
|
const launch = launchIntentOf(options);
|
|
@@ -10477,7 +11100,7 @@ async function readPresets(api) {
|
|
|
10477
11100
|
}
|
|
10478
11101
|
async function monitorRun(api, analysisId, runId, budgetHours, cmd) {
|
|
10479
11102
|
const config = loadConfig();
|
|
10480
|
-
const outputFormat =
|
|
11103
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10481
11104
|
const human = outputFormat === "human";
|
|
10482
11105
|
const status = new Status();
|
|
10483
11106
|
const seenOutputs = /* @__PURE__ */ new Set();
|
|
@@ -10604,7 +11227,7 @@ async function printNotebookLink(api, config, analysisId) {
|
|
|
10604
11227
|
}
|
|
10605
11228
|
}
|
|
10606
11229
|
async function listAnalyses(limit, cmd) {
|
|
10607
|
-
const outputFormat =
|
|
11230
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10608
11231
|
const api = createApiClient();
|
|
10609
11232
|
const analyses = await api.analysis.getRecent(limit);
|
|
10610
11233
|
format(analyses.map((a) => ({
|
|
@@ -10634,7 +11257,7 @@ async function listAnalyses(limit, cmd) {
|
|
|
10634
11257
|
});
|
|
10635
11258
|
}
|
|
10636
11259
|
async function getAnalysisDetails(analysisId, options, cmd) {
|
|
10637
|
-
const outputFormat =
|
|
11260
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10638
11261
|
const api = createApiClient();
|
|
10639
11262
|
const result = analysisId ? await api.analysis.get(analysisId) : await api.analysis.getLast();
|
|
10640
11263
|
if (!result.analysis) {
|
|
@@ -10722,7 +11345,7 @@ async function rerunAnalysis(analysisId, cmd) {
|
|
|
10722
11345
|
const analysis = found.analysis;
|
|
10723
11346
|
const missing = missingRunFields(analysis);
|
|
10724
11347
|
if (missing.length > 0) {
|
|
10725
|
-
const outputFormat =
|
|
11348
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10726
11349
|
const noInteractive = noInteractiveFlag(cmd);
|
|
10727
11350
|
if (!canPrompt(outputFormat, noInteractive)) {
|
|
10728
11351
|
const { message, suggestion } = explainMissingRunFields(
|
|
@@ -10796,7 +11419,7 @@ function typedColumns(given) {
|
|
|
10796
11419
|
return entries === void 0 ? null : resolveColumnArguments(entries, []);
|
|
10797
11420
|
}
|
|
10798
11421
|
async function createAnalysis(options, cmd) {
|
|
10799
|
-
const outputFormat =
|
|
11422
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10800
11423
|
const launch = launchIntentOf(options);
|
|
10801
11424
|
const shapes = windowedShapes(launch.shapes);
|
|
10802
11425
|
const api = createApiClient();
|
|
@@ -10838,7 +11461,7 @@ async function deleteAnalysis(analysisId) {
|
|
|
10838
11461
|
success(`Deleted analysis ${analysisId}.`);
|
|
10839
11462
|
}
|
|
10840
11463
|
async function patchAndPrint(analysisId, value, handler, successLabel, cmd) {
|
|
10841
|
-
const outputFormat =
|
|
11464
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10842
11465
|
const api = createApiClient();
|
|
10843
11466
|
const updated = await handler(api, analysisId, value);
|
|
10844
11467
|
if (isDryRun()) {
|
|
@@ -10868,7 +11491,7 @@ async function ownAnalysis(api, analysisId) {
|
|
|
10868
11491
|
return found.analysis;
|
|
10869
11492
|
}
|
|
10870
11493
|
async function notesCommand(analysisId, text2, options, cmd) {
|
|
10871
|
-
const outputFormat =
|
|
11494
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10872
11495
|
const api = createApiClient();
|
|
10873
11496
|
const given = [text2 !== void 0, options.file !== void 0, options.clear === true].filter(Boolean).length;
|
|
10874
11497
|
if (given > 1) usageError("Give the notes as text, with --file, or clear them with --clear: one of the three.");
|
|
@@ -10914,7 +11537,7 @@ async function notesCommand(analysisId, text2, options, cmd) {
|
|
|
10914
11537
|
hint(`Read them into proposals with 'diafunc analyze intent read ${analysisId}'. Nothing changes until you confirm one.`);
|
|
10915
11538
|
}
|
|
10916
11539
|
async function readNotesCommand(analysisId, options, cmd) {
|
|
10917
|
-
const outputFormat =
|
|
11540
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10918
11541
|
const api = createApiClient();
|
|
10919
11542
|
const analysis = await ownAnalysis(api, analysisId);
|
|
10920
11543
|
if (!analysis.intent) {
|
|
@@ -10947,7 +11570,7 @@ async function readNotesCommand(analysisId, options, cmd) {
|
|
|
10947
11570
|
printInterpretation(interpretation, analysisId);
|
|
10948
11571
|
}
|
|
10949
11572
|
async function decideCommand(state, analysisId, ids, options, cmd) {
|
|
10950
|
-
const outputFormat =
|
|
11573
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10951
11574
|
const wanted = [...new Set(ids.flatMap((id) => id.split(",")).map((id) => id.trim()).filter((id) => id.length > 0))];
|
|
10952
11575
|
if (wanted.length === 0) usageError("Name at least one proposal.", `The ids are in 'diafunc analyze intent read ${analysisId}'.`);
|
|
10953
11576
|
if (options.steer !== void 0 && state !== "CONFIRMED") {
|
|
@@ -10986,7 +11609,7 @@ async function decideCommand(state, analysisId, ids, options, cmd) {
|
|
|
10986
11609
|
if (state === "CONFIRMED") hint(`It takes part from the next run: 'diafunc analyze rerun ${analysisId}'.`);
|
|
10987
11610
|
}
|
|
10988
11611
|
async function expectationsCommand(analysisId, given, options, cmd) {
|
|
10989
|
-
const outputFormat =
|
|
11612
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10990
11613
|
const api = createApiClient();
|
|
10991
11614
|
const analysis = await ownAnalysis(api, analysisId);
|
|
10992
11615
|
const current = analysis.shapeExpectations ?? {};
|
|
@@ -11107,7 +11730,7 @@ async function uploadOne(api, analysisId, file, asUploaded, human) {
|
|
|
11107
11730
|
}
|
|
11108
11731
|
async function uploadData(analysisId, files, options, cmd) {
|
|
11109
11732
|
const api = createApiClient();
|
|
11110
|
-
const outputFormat =
|
|
11733
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11111
11734
|
const ctx = importContext(api, analysisId, cmd, "none");
|
|
11112
11735
|
const file = files[0];
|
|
11113
11736
|
if (files.length > 1) {
|
|
@@ -11157,7 +11780,7 @@ async function uploadData(analysisId, files, options, cmd) {
|
|
|
11157
11780
|
}
|
|
11158
11781
|
}
|
|
11159
11782
|
async function stopDataImport(analysisId, cmd) {
|
|
11160
|
-
const outputFormat =
|
|
11783
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11161
11784
|
const api = createApiClient();
|
|
11162
11785
|
const stopped = await withStatus("Stopping the data import", () => stopImport(api, analysisId));
|
|
11163
11786
|
if (isDryRun()) {
|
|
@@ -11180,7 +11803,7 @@ async function stopDataImport(analysisId, cmd) {
|
|
|
11180
11803
|
warn(stopped.dataImport.message);
|
|
11181
11804
|
}
|
|
11182
11805
|
async function listColumns(analysisId, cmd) {
|
|
11183
|
-
const outputFormat =
|
|
11806
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11184
11807
|
const api = createApiClient();
|
|
11185
11808
|
const columns = await api.analysis.getColumns(analysisId);
|
|
11186
11809
|
if (columns.length === 0) {
|
|
@@ -11191,7 +11814,7 @@ async function listColumns(analysisId, cmd) {
|
|
|
11191
11814
|
format(columns, { format: outputFormat, columns: ["name", "valueType"] });
|
|
11192
11815
|
}
|
|
11193
11816
|
async function listRuns(analysisId, count, cmd) {
|
|
11194
|
-
const outputFormat =
|
|
11817
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11195
11818
|
const api = createApiClient();
|
|
11196
11819
|
const runs = await api.analysis.getRunsForAnalysis(analysisId, count);
|
|
11197
11820
|
format(runs.map((r) => ({
|
|
@@ -11216,7 +11839,7 @@ async function listRuns(analysisId, count, cmd) {
|
|
|
11216
11839
|
});
|
|
11217
11840
|
}
|
|
11218
11841
|
async function cancelRun(runId, cmd) {
|
|
11219
|
-
const outputFormat =
|
|
11842
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11220
11843
|
const api = createApiClient();
|
|
11221
11844
|
const run = await api.analysis.cancelRun(runId);
|
|
11222
11845
|
if (outputFormat === "human") {
|
|
@@ -11230,7 +11853,7 @@ async function cancelRun(runId, cmd) {
|
|
|
11230
11853
|
}
|
|
11231
11854
|
}
|
|
11232
11855
|
async function listPresets(cmd) {
|
|
11233
|
-
const outputFormat =
|
|
11856
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11234
11857
|
const api = createApiClient();
|
|
11235
11858
|
const presets = await api.analysis.getPresets();
|
|
11236
11859
|
format(presets.map((p) => ({
|
|
@@ -11255,7 +11878,7 @@ async function listPresets(cmd) {
|
|
|
11255
11878
|
});
|
|
11256
11879
|
}
|
|
11257
11880
|
async function getPreset(presetId, cmd) {
|
|
11258
|
-
const outputFormat =
|
|
11881
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11259
11882
|
const api = createApiClient();
|
|
11260
11883
|
const opt = await api.analysis.getPreset(presetId);
|
|
11261
11884
|
if (!opt.preset) {
|
|
@@ -11265,7 +11888,7 @@ async function getPreset(presetId, cmd) {
|
|
|
11265
11888
|
format(opt.preset, { format: outputFormat });
|
|
11266
11889
|
}
|
|
11267
11890
|
async function savePreset(options, cmd) {
|
|
11268
|
-
const outputFormat =
|
|
11891
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11269
11892
|
const api = createApiClient();
|
|
11270
11893
|
const preset = {
|
|
11271
11894
|
presetId: options.id ?? null,
|
|
@@ -11320,7 +11943,7 @@ function triggerChanges(options) {
|
|
|
11320
11943
|
};
|
|
11321
11944
|
}
|
|
11322
11945
|
async function listTriggers(analysisId, cmd) {
|
|
11323
|
-
const outputFormat =
|
|
11946
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11324
11947
|
const api = createApiClient();
|
|
11325
11948
|
const triggers = await api.analysis.listTriggers(analysisId);
|
|
11326
11949
|
format(triggers.map(triggerRow), {
|
|
@@ -11337,7 +11960,7 @@ async function listTriggers(analysisId, cmd) {
|
|
|
11337
11960
|
});
|
|
11338
11961
|
}
|
|
11339
11962
|
async function createTrigger(analysisId, kind, schedule, cmd, refreshFirst = false) {
|
|
11340
|
-
const outputFormat =
|
|
11963
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11341
11964
|
const upper = kind.toUpperCase();
|
|
11342
11965
|
if (upper !== "ONCE" && upper !== "CRON") {
|
|
11343
11966
|
failure(`Invalid kind "${kind}". Use ONCE or CRON.`);
|
|
@@ -11357,7 +11980,7 @@ async function deleteTrigger(triggerId) {
|
|
|
11357
11980
|
success(`Deleted trigger ${triggerId}.`);
|
|
11358
11981
|
}
|
|
11359
11982
|
async function updateTriggerCmd(triggerId, options, cmd) {
|
|
11360
|
-
const outputFormat =
|
|
11983
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11361
11984
|
const changes = triggerChanges(options);
|
|
11362
11985
|
const api = createApiClient();
|
|
11363
11986
|
const trigger = await api.analysis.updateTrigger(triggerId, changes);
|
|
@@ -11761,7 +12384,7 @@ Examples:
|
|
|
11761
12384
|
// src/commands/public/index.ts
|
|
11762
12385
|
var MIN_LIMIT = 1;
|
|
11763
12386
|
var MAX_LIMIT = 500;
|
|
11764
|
-
function
|
|
12387
|
+
function getOutputFormat20(cmd) {
|
|
11765
12388
|
const config = loadConfig();
|
|
11766
12389
|
const globalOpts = cmd.optsWithGlobals();
|
|
11767
12390
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -11813,7 +12436,7 @@ async function readPublicAnalyses(analysis, options) {
|
|
|
11813
12436
|
}
|
|
11814
12437
|
}
|
|
11815
12438
|
async function listPublicAnalyses(options, cmd) {
|
|
11816
|
-
const outputFormat =
|
|
12439
|
+
const outputFormat = getOutputFormat20(cmd);
|
|
11817
12440
|
const limit = parseLimit(options.limit);
|
|
11818
12441
|
const changedSince = options.changedSince === void 0 ? void 0 : parseChangedSince(options.changedSince);
|
|
11819
12442
|
const api = createApiClient();
|
|
@@ -11856,7 +12479,7 @@ function newestRunRecord(run) {
|
|
|
11856
12479
|
};
|
|
11857
12480
|
}
|
|
11858
12481
|
async function showPublicAnalysis(analysisId, cmd) {
|
|
11859
|
-
const outputFormat =
|
|
12482
|
+
const outputFormat = getOutputFormat20(cmd);
|
|
11860
12483
|
const api = createApiClient();
|
|
11861
12484
|
const result = await api.analysis.get(analysisId);
|
|
11862
12485
|
if (!result?.analysis) {
|
|
@@ -11926,7 +12549,7 @@ Examples:
|
|
|
11926
12549
|
|
|
11927
12550
|
// src/commands/license/index.ts
|
|
11928
12551
|
import chalk30 from "chalk";
|
|
11929
|
-
function
|
|
12552
|
+
function getOutputFormat21(cmd) {
|
|
11930
12553
|
const config = loadConfig();
|
|
11931
12554
|
const globalOpts = cmd.optsWithGlobals();
|
|
11932
12555
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -11945,8 +12568,89 @@ function licenseMarks(license) {
|
|
|
11945
12568
|
function stateWord(state) {
|
|
11946
12569
|
return state.toLowerCase();
|
|
11947
12570
|
}
|
|
12571
|
+
function flagsFromMarks(marks) {
|
|
12572
|
+
const given = marks.trim().toUpperCase().split(/[\s,]+/).filter((m) => m.length > 0);
|
|
12573
|
+
const known = new Set(LICENSE_MARKS.map(({ mark }) => mark));
|
|
12574
|
+
const unknown = given.filter((m) => m !== "NONE" && !known.has(m));
|
|
12575
|
+
if (unknown.length > 0 || given.includes("NONE") && given.length > 1 || given.length === 0) {
|
|
12576
|
+
throw new CliError(`Unknown flags "${marks}".`, {
|
|
12577
|
+
hint: `Use any of ${LICENSE_MARKS.map(({ mark }) => mark).join(", ")} (for example "C D R BY"), or "none".`
|
|
12578
|
+
});
|
|
12579
|
+
}
|
|
12580
|
+
return {
|
|
12581
|
+
commercialUse: given.includes("C"),
|
|
12582
|
+
derivatives: given.includes("D"),
|
|
12583
|
+
redistribution: given.includes("R"),
|
|
12584
|
+
attributionRequired: given.includes("BY"),
|
|
12585
|
+
shareAlike: given.includes("SA")
|
|
12586
|
+
};
|
|
12587
|
+
}
|
|
12588
|
+
function parseSortOrder2(value) {
|
|
12589
|
+
if (value === void 0) return void 0;
|
|
12590
|
+
if (value === "") return null;
|
|
12591
|
+
const order = Number(value);
|
|
12592
|
+
if (!Number.isInteger(order)) {
|
|
12593
|
+
throw new CliError(`--sort-order must be a whole number, not "${value}".`);
|
|
12594
|
+
}
|
|
12595
|
+
return order;
|
|
12596
|
+
}
|
|
12597
|
+
function parseBool(name, value) {
|
|
12598
|
+
if (value === void 0) return void 0;
|
|
12599
|
+
if (value === "true" || value === "false") return value === "true";
|
|
12600
|
+
throw new CliError(`${name} must be true or false, not "${value}".`);
|
|
12601
|
+
}
|
|
12602
|
+
async function catalogEntry(licenseId) {
|
|
12603
|
+
const entries = await createApiClient().admin.listLicenseCatalog();
|
|
12604
|
+
const entry = entries.find((e) => e.licence.licenceId === licenseId);
|
|
12605
|
+
if (!entry) {
|
|
12606
|
+
throw new CliError(`No license "${licenseId}" in the catalog.`, {
|
|
12607
|
+
hint: `List every entry, withdrawn ones included, with 'diafunc license catalog'.`
|
|
12608
|
+
});
|
|
12609
|
+
}
|
|
12610
|
+
return entry;
|
|
12611
|
+
}
|
|
12612
|
+
function printLicense(license, cmd, verb) {
|
|
12613
|
+
const outputFormat = getOutputFormat21(cmd);
|
|
12614
|
+
if (outputFormat !== "human") {
|
|
12615
|
+
format(license, { format: outputFormat });
|
|
12616
|
+
return;
|
|
12617
|
+
}
|
|
12618
|
+
success(`License "${license.licenceId}" ${verb} (${stateWord(license.state)}, flags ${licenseMarks(license) ?? "none"}).`);
|
|
12619
|
+
}
|
|
12620
|
+
async function listCatalog(cmd) {
|
|
12621
|
+
const outputFormat = getOutputFormat21(cmd);
|
|
12622
|
+
const entries = await createApiClient().admin.listLicenseCatalog();
|
|
12623
|
+
if (outputFormat === "json") {
|
|
12624
|
+
format(entries, { format: outputFormat });
|
|
12625
|
+
return;
|
|
12626
|
+
}
|
|
12627
|
+
if (entries.length === 0 && outputFormat === "human") {
|
|
12628
|
+
empty("licenses");
|
|
12629
|
+
return;
|
|
12630
|
+
}
|
|
12631
|
+
format(entries.map((e) => ({
|
|
12632
|
+
licenceId: e.licence.licenceId,
|
|
12633
|
+
name: e.licence.name,
|
|
12634
|
+
state: stateWord(e.licence.state),
|
|
12635
|
+
flags: licenseMarks(e.licence),
|
|
12636
|
+
recommended: e.licence.recommended,
|
|
12637
|
+
publicProjects: e.publicProjects,
|
|
12638
|
+
sortOrder: e.licence.sortOrder
|
|
12639
|
+
})), {
|
|
12640
|
+
format: outputFormat,
|
|
12641
|
+
columns: [
|
|
12642
|
+
{ key: "licenceId", header: "id" },
|
|
12643
|
+
{ key: "name" },
|
|
12644
|
+
{ key: "state", kind: "state" },
|
|
12645
|
+
{ key: "flags" },
|
|
12646
|
+
{ key: "recommended", kind: "boolean" },
|
|
12647
|
+
{ key: "publicProjects", header: "public projects" },
|
|
12648
|
+
{ key: "sortOrder", header: "order" }
|
|
12649
|
+
]
|
|
12650
|
+
});
|
|
12651
|
+
}
|
|
11948
12652
|
async function listLicenses(cmd) {
|
|
11949
|
-
const outputFormat =
|
|
12653
|
+
const outputFormat = getOutputFormat21(cmd);
|
|
11950
12654
|
const api = createApiClient();
|
|
11951
12655
|
const licenses = await api.admin.listLicenses();
|
|
11952
12656
|
if (outputFormat === "json") {
|
|
@@ -11981,7 +12685,7 @@ Flags: ${LICENSE_MARKS.map(({ mark, meaning }) => `${mark} ${meaning}`).join(",
|
|
|
11981
12685
|
}
|
|
11982
12686
|
}
|
|
11983
12687
|
async function showLicense(licenseId, cmd) {
|
|
11984
|
-
const outputFormat =
|
|
12688
|
+
const outputFormat = getOutputFormat21(cmd);
|
|
11985
12689
|
const api = createApiClient();
|
|
11986
12690
|
let license;
|
|
11987
12691
|
try {
|
|
@@ -12028,10 +12732,13 @@ async function showLicense(licenseId, cmd) {
|
|
|
12028
12732
|
});
|
|
12029
12733
|
}
|
|
12030
12734
|
function registerLicenseCommands(program) {
|
|
12031
|
-
const license = hiddenAlias(program.command("license"), "licence").description("The licenses a public project can be published under (no sign-in
|
|
12735
|
+
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
12736
|
Examples:
|
|
12033
12737
|
$ diafunc license list the licenses that can be chosen
|
|
12034
12738
|
$ diafunc license show CC-BY-4.0 one license and what it allows
|
|
12739
|
+
$ diafunc license catalog administrators: every entry, with its public projects
|
|
12740
|
+
$ diafunc license create CC-BY-3.0 --name "Creative Commons Attribution 3.0" --flags "C D R BY"
|
|
12741
|
+
$ diafunc license deprecate CC-BY-3.0 administrators: stop offering it
|
|
12035
12742
|
$ diafunc project create --visibility PUBLIC --license CC-BY-4.0
|
|
12036
12743
|
$ diafunc analyze visibility <id> PUBLIC --license CC0-1.0
|
|
12037
12744
|
`);
|
|
@@ -12049,11 +12756,97 @@ Examples:
|
|
|
12049
12756
|
handleError(error);
|
|
12050
12757
|
}
|
|
12051
12758
|
});
|
|
12759
|
+
license.command("catalog").description("Administrators: every catalog entry, withdrawn ones included, with the number of public projects that carry it").action(async (_options, cmd) => {
|
|
12760
|
+
try {
|
|
12761
|
+
await listCatalog(cmd);
|
|
12762
|
+
} catch (error) {
|
|
12763
|
+
handleError(error);
|
|
12764
|
+
}
|
|
12765
|
+
});
|
|
12766
|
+
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) => {
|
|
12767
|
+
try {
|
|
12768
|
+
const created = await createApiClient().admin.createLicense({
|
|
12769
|
+
licenceId: licenseId,
|
|
12770
|
+
name: options.name,
|
|
12771
|
+
summary: options.summary ?? null,
|
|
12772
|
+
url: options.url ?? null,
|
|
12773
|
+
state: "ACTIVE",
|
|
12774
|
+
...flagsFromMarks(options.flags),
|
|
12775
|
+
recommended: !!options.recommended,
|
|
12776
|
+
sortOrder: parseSortOrder2(options.sortOrder) ?? null
|
|
12777
|
+
});
|
|
12778
|
+
printLicense(created, cmd, "created");
|
|
12779
|
+
} catch (error) {
|
|
12780
|
+
handleError(error);
|
|
12781
|
+
}
|
|
12782
|
+
});
|
|
12783
|
+
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) => {
|
|
12784
|
+
try {
|
|
12785
|
+
const current = (await catalogEntry(licenseId)).licence;
|
|
12786
|
+
const sortOrder = parseSortOrder2(options.sortOrder);
|
|
12787
|
+
const recommended = parseBool("--recommended", options.recommended);
|
|
12788
|
+
const updated = await createApiClient().admin.updateLicense({
|
|
12789
|
+
...current,
|
|
12790
|
+
...options.name !== void 0 ? { name: options.name } : {},
|
|
12791
|
+
...options.url !== void 0 ? { url: options.url || null } : {},
|
|
12792
|
+
...options.summary !== void 0 ? { summary: options.summary || null } : {},
|
|
12793
|
+
...options.flags !== void 0 ? flagsFromMarks(options.flags) : {},
|
|
12794
|
+
...recommended !== void 0 ? { recommended } : {},
|
|
12795
|
+
...sortOrder !== void 0 ? { sortOrder } : {}
|
|
12796
|
+
});
|
|
12797
|
+
printLicense(updated, cmd, "updated");
|
|
12798
|
+
} catch (error) {
|
|
12799
|
+
handleError(error);
|
|
12800
|
+
}
|
|
12801
|
+
});
|
|
12802
|
+
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) => {
|
|
12803
|
+
try {
|
|
12804
|
+
printLicense(await createApiClient().admin.deprecateLicense(licenseId), cmd, "deprecated");
|
|
12805
|
+
} catch (error) {
|
|
12806
|
+
handleError(error);
|
|
12807
|
+
}
|
|
12808
|
+
});
|
|
12809
|
+
license.command("reactivate").description("Administrators: offer a deprecated or withdrawn license again").argument("<licenseId>", "License ID").action(async (licenseId, _options, cmd) => {
|
|
12810
|
+
try {
|
|
12811
|
+
printLicense(await createApiClient().admin.reactivateLicense(licenseId), cmd, "reactivated");
|
|
12812
|
+
} catch (error) {
|
|
12813
|
+
handleError(error);
|
|
12814
|
+
}
|
|
12815
|
+
});
|
|
12816
|
+
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) => {
|
|
12817
|
+
try {
|
|
12818
|
+
const affected = (await catalogEntry(licenseId)).publicProjects;
|
|
12819
|
+
if (options.expectedAffected === void 0) {
|
|
12820
|
+
throw new CliError(`Withdrawing "${licenseId}" makes ${affected} public project(s) private.`, {
|
|
12821
|
+
hint: `Confirm with 'diafunc license withdraw ${licenseId} --expected-affected ${affected}'.`
|
|
12822
|
+
});
|
|
12823
|
+
}
|
|
12824
|
+
const expected = Number(options.expectedAffected);
|
|
12825
|
+
if (!Number.isInteger(expected) || expected < 0) {
|
|
12826
|
+
throw new CliError(`--expected-affected must be a whole number, not "${options.expectedAffected}".`);
|
|
12827
|
+
}
|
|
12828
|
+
printLicense(await createApiClient().admin.withdrawLicense(licenseId, expected), cmd, "withdrawn");
|
|
12829
|
+
} catch (error) {
|
|
12830
|
+
handleError(error);
|
|
12831
|
+
}
|
|
12832
|
+
});
|
|
12833
|
+
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) => {
|
|
12834
|
+
try {
|
|
12835
|
+
await confirmDestructive(
|
|
12836
|
+
`This will permanently delete license "${licenseId}" from the catalog.`,
|
|
12837
|
+
{ yes: options.yes, resourceId: licenseId }
|
|
12838
|
+
);
|
|
12839
|
+
await createApiClient().admin.deleteLicense(licenseId);
|
|
12840
|
+
success(`License "${licenseId}" deleted.`);
|
|
12841
|
+
} catch (error) {
|
|
12842
|
+
handleError(error);
|
|
12843
|
+
}
|
|
12844
|
+
});
|
|
12052
12845
|
}
|
|
12053
12846
|
|
|
12054
12847
|
// src/commands/data-sources/index.ts
|
|
12055
12848
|
import chalk31 from "chalk";
|
|
12056
|
-
function
|
|
12849
|
+
function getOutputFormat22(cmd) {
|
|
12057
12850
|
const config = loadConfig();
|
|
12058
12851
|
const globalOpts = cmd.optsWithGlobals();
|
|
12059
12852
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -12153,7 +12946,7 @@ function resolveProjectId(cmd) {
|
|
|
12153
12946
|
return resolved;
|
|
12154
12947
|
}
|
|
12155
12948
|
async function listDataSources(projectId, cmd) {
|
|
12156
|
-
const outputFormat =
|
|
12949
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12157
12950
|
const api = createApiClient();
|
|
12158
12951
|
const sources = await api.storage.listDataSources(projectId);
|
|
12159
12952
|
if (outputFormat === "human" && sources.length === 0) {
|
|
@@ -12174,13 +12967,13 @@ async function listDataSources(projectId, cmd) {
|
|
|
12174
12967
|
});
|
|
12175
12968
|
}
|
|
12176
12969
|
async function getDataSource(id, cmd) {
|
|
12177
|
-
const outputFormat =
|
|
12970
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12178
12971
|
const api = createApiClient();
|
|
12179
12972
|
const ds = await api.storage.getDataSource(id);
|
|
12180
12973
|
format(ds, { format: outputFormat });
|
|
12181
12974
|
}
|
|
12182
12975
|
async function showDashboard(projectId, cmd) {
|
|
12183
|
-
const outputFormat =
|
|
12976
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12184
12977
|
const api = createApiClient();
|
|
12185
12978
|
const dashboard = await api.storage.getDataSourceDashboard(projectId);
|
|
12186
12979
|
if (outputFormat !== "human") {
|
|
@@ -12256,7 +13049,7 @@ async function createForAnalysis(api, options, human) {
|
|
|
12256
13049
|
return { source, build };
|
|
12257
13050
|
}
|
|
12258
13051
|
async function createDataSource(options, cmd) {
|
|
12259
|
-
const outputFormat =
|
|
13052
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12260
13053
|
const target = createTarget(options);
|
|
12261
13054
|
const api = createApiClient();
|
|
12262
13055
|
if (target === "analysis") {
|
|
@@ -12286,7 +13079,7 @@ async function createDataSource(options, cmd) {
|
|
|
12286
13079
|
}
|
|
12287
13080
|
}
|
|
12288
13081
|
async function updateDataSource(id, options, cmd) {
|
|
12289
|
-
const outputFormat =
|
|
13082
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12290
13083
|
if (options.name === void 0 && options.type === void 0 && (!options.config || options.config.length === 0) && options.scheduleCron === void 0 && !options.clearSchedule) {
|
|
12291
13084
|
throw new Error("Provide at least one of --name, --type, --config, --schedule-cron, or --clear-schedule.");
|
|
12292
13085
|
}
|
|
@@ -12321,7 +13114,7 @@ async function deleteDataSource(id) {
|
|
|
12321
13114
|
success(`Deleted data source ${id}`);
|
|
12322
13115
|
}
|
|
12323
13116
|
async function refreshDataSource(id, cmd) {
|
|
12324
|
-
const outputFormat =
|
|
13117
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12325
13118
|
const api = createApiClient();
|
|
12326
13119
|
const run = await api.storage.refreshDataSource(id);
|
|
12327
13120
|
if (outputFormat === "human") {
|
|
@@ -12332,7 +13125,7 @@ async function refreshDataSource(id, cmd) {
|
|
|
12332
13125
|
}
|
|
12333
13126
|
}
|
|
12334
13127
|
async function listRuns2(id, limit, cmd) {
|
|
12335
|
-
const outputFormat =
|
|
13128
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12336
13129
|
const api = createApiClient();
|
|
12337
13130
|
const runs = await api.storage.listDataSourceRuns(id, limit);
|
|
12338
13131
|
if (outputFormat === "human" && runs.length === 0) {
|
|
@@ -12354,13 +13147,13 @@ async function listRuns2(id, limit, cmd) {
|
|
|
12354
13147
|
});
|
|
12355
13148
|
}
|
|
12356
13149
|
async function getRun(id, runId, cmd) {
|
|
12357
|
-
const outputFormat =
|
|
13150
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12358
13151
|
const api = createApiClient();
|
|
12359
13152
|
const run = await api.storage.getDataSourceRun(id, runId);
|
|
12360
13153
|
format(run, { format: outputFormat });
|
|
12361
13154
|
}
|
|
12362
13155
|
async function listConnectorTypes(cmd) {
|
|
12363
|
-
const outputFormat =
|
|
13156
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12364
13157
|
const api = createApiClient();
|
|
12365
13158
|
const types = await api.storage.listDataSourceConnectorTypes();
|
|
12366
13159
|
if (outputFormat === "human") {
|
|
@@ -12454,7 +13247,7 @@ Examples:
|
|
|
12454
13247
|
|
|
12455
13248
|
// src/commands/table-exporters/index.ts
|
|
12456
13249
|
import chalk32 from "chalk";
|
|
12457
|
-
function
|
|
13250
|
+
function getOutputFormat23(cmd) {
|
|
12458
13251
|
const config = loadConfig();
|
|
12459
13252
|
const globalOpts = cmd.optsWithGlobals();
|
|
12460
13253
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -12463,7 +13256,7 @@ function registerTableExportersCommands(program) {
|
|
|
12463
13256
|
const exporters = program.command("table-exporters").description("Manage user-defined exporters (UDE); admin only");
|
|
12464
13257
|
exporters.command("list").description("List all registered user-defined exporters").action(async (_options, cmd) => {
|
|
12465
13258
|
try {
|
|
12466
|
-
const outputFormat =
|
|
13259
|
+
const outputFormat = getOutputFormat23(cmd);
|
|
12467
13260
|
const api = createApiClient();
|
|
12468
13261
|
const list = await api.storage.listUserDefinedExporters();
|
|
12469
13262
|
if (outputFormat === "json") {
|
|
@@ -12491,7 +13284,7 @@ function registerTableExportersCommands(program) {
|
|
|
12491
13284
|
});
|
|
12492
13285
|
exporters.command("get").description("Show a single user-defined exporter by id").argument("<id>", "Exporter id").action(async (id, _options, cmd) => {
|
|
12493
13286
|
try {
|
|
12494
|
-
const outputFormat =
|
|
13287
|
+
const outputFormat = getOutputFormat23(cmd);
|
|
12495
13288
|
const api = createApiClient();
|
|
12496
13289
|
const list = await api.storage.listUserDefinedExporters();
|
|
12497
13290
|
const exporter = list.find((e) => e.id === id);
|
|
@@ -12506,7 +13299,7 @@ function registerTableExportersCommands(program) {
|
|
|
12506
13299
|
});
|
|
12507
13300
|
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
13301
|
try {
|
|
12509
|
-
const outputFormat =
|
|
13302
|
+
const outputFormat = getOutputFormat23(cmd);
|
|
12510
13303
|
const api = createApiClient();
|
|
12511
13304
|
const payload = {
|
|
12512
13305
|
name: options.name,
|
|
@@ -12544,7 +13337,7 @@ function registerTableExportersCommands(program) {
|
|
|
12544
13337
|
// src/commands/skeleton/index.ts
|
|
12545
13338
|
import chalk33 from "chalk";
|
|
12546
13339
|
import * as fs13 from "fs";
|
|
12547
|
-
function
|
|
13340
|
+
function getOutputFormat24(cmd) {
|
|
12548
13341
|
const config = loadConfig();
|
|
12549
13342
|
const globalOpts = cmd.optsWithGlobals();
|
|
12550
13343
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -12593,7 +13386,7 @@ function skeletonTableRow(s) {
|
|
|
12593
13386
|
};
|
|
12594
13387
|
}
|
|
12595
13388
|
async function createSkeleton(options, cmd) {
|
|
12596
|
-
const outputFormat =
|
|
13389
|
+
const outputFormat = getOutputFormat24(cmd);
|
|
12597
13390
|
const projectId = resolveProjectId2(cmd);
|
|
12598
13391
|
const template = resolveTemplate(options.template);
|
|
12599
13392
|
const weight = parseWeight(options.weight);
|
|
@@ -12618,7 +13411,7 @@ async function createSkeleton(options, cmd) {
|
|
|
12618
13411
|
}
|
|
12619
13412
|
}
|
|
12620
13413
|
async function listSkeletons(cmd) {
|
|
12621
|
-
const outputFormat =
|
|
13414
|
+
const outputFormat = getOutputFormat24(cmd);
|
|
12622
13415
|
const projectId = resolveProjectId2(cmd);
|
|
12623
13416
|
const api = createApiClient();
|
|
12624
13417
|
const skeletons = await api.storage.listSkeletons(projectId);
|
|
@@ -12632,13 +13425,13 @@ async function listSkeletons(cmd) {
|
|
|
12632
13425
|
});
|
|
12633
13426
|
}
|
|
12634
13427
|
async function getSkeleton(id, cmd) {
|
|
12635
|
-
const outputFormat =
|
|
13428
|
+
const outputFormat = getOutputFormat24(cmd);
|
|
12636
13429
|
const api = createApiClient();
|
|
12637
13430
|
const skeleton = await api.storage.getSkeleton(id);
|
|
12638
13431
|
format(skeleton, { format: outputFormat });
|
|
12639
13432
|
}
|
|
12640
13433
|
async function updateSkeleton(id, options, cmd) {
|
|
12641
|
-
const outputFormat =
|
|
13434
|
+
const outputFormat = getOutputFormat24(cmd);
|
|
12642
13435
|
if (options.name === void 0 && options.template === void 0 && options.weight === void 0) {
|
|
12643
13436
|
throw new Error("Provide at least one of --name, --template, --weight.");
|
|
12644
13437
|
}
|
|
@@ -13002,7 +13795,7 @@ function registerWhoamiCommand(program) {
|
|
|
13002
13795
|
|
|
13003
13796
|
// src/commands/utilization/index.ts
|
|
13004
13797
|
import chalk35 from "chalk";
|
|
13005
|
-
function
|
|
13798
|
+
function getOutputFormat25(cmd) {
|
|
13006
13799
|
const config = loadConfig();
|
|
13007
13800
|
const globalOpts = cmd.optsWithGlobals();
|
|
13008
13801
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -13067,7 +13860,7 @@ Examples:
|
|
|
13067
13860
|
`);
|
|
13068
13861
|
util.command("actual", { isDefault: true }).description("Show current utilization (default subcommand)").action(async (_options, cmd) => {
|
|
13069
13862
|
try {
|
|
13070
|
-
const outputFormat =
|
|
13863
|
+
const outputFormat = getOutputFormat25(cmd);
|
|
13071
13864
|
const api = createApiClient();
|
|
13072
13865
|
const utilization = await api.admin.getActualUtilization();
|
|
13073
13866
|
if (outputFormat === "human") {
|
|
@@ -13081,7 +13874,7 @@ Examples:
|
|
|
13081
13874
|
});
|
|
13082
13875
|
util.command("history").description("Show what each day of the billing cycle cost").action(async (_options, cmd) => {
|
|
13083
13876
|
try {
|
|
13084
|
-
const outputFormat =
|
|
13877
|
+
const outputFormat = getOutputFormat25(cmd);
|
|
13085
13878
|
const api = createApiClient();
|
|
13086
13879
|
const history = await api.admin.getUtilizationHistory();
|
|
13087
13880
|
if (outputFormat === "human") {
|
|
@@ -13102,7 +13895,7 @@ Examples:
|
|
|
13102
13895
|
}
|
|
13103
13896
|
|
|
13104
13897
|
// src/commands/entity-branch/index.ts
|
|
13105
|
-
function
|
|
13898
|
+
function getOutputFormat26(cmd) {
|
|
13106
13899
|
const config = loadConfig();
|
|
13107
13900
|
const globalOpts = cmd.optsWithGlobals();
|
|
13108
13901
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -13115,7 +13908,7 @@ function registerEntityBranchCommands(program) {
|
|
|
13115
13908
|
const eb = program.command("entity-branch").description("Manage entity branches (parallel versions of a single entity)");
|
|
13116
13909
|
eb.command("list").description("List branches of an entity").argument("<ref>", "Entity reference (projectId/branch/entityId)").action(async (ref, _options, cmd) => {
|
|
13117
13910
|
try {
|
|
13118
|
-
const outputFormat =
|
|
13911
|
+
const outputFormat = getOutputFormat26(cmd);
|
|
13119
13912
|
const overrides = getOverrides11(cmd);
|
|
13120
13913
|
const resolved = parseEntityReference(ref, overrides);
|
|
13121
13914
|
const api = createApiClient();
|
|
@@ -13167,7 +13960,7 @@ function forReader(subscription) {
|
|
|
13167
13960
|
Object.entries(subscription).filter(([key]) => !BILLING_INTERNALS.has(key))
|
|
13168
13961
|
);
|
|
13169
13962
|
}
|
|
13170
|
-
function
|
|
13963
|
+
function getOutputFormat27(cmd) {
|
|
13171
13964
|
const config = loadConfig();
|
|
13172
13965
|
const globalOpts = cmd.optsWithGlobals();
|
|
13173
13966
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -13181,7 +13974,7 @@ Examples:
|
|
|
13181
13974
|
sub.command("current", { isDefault: true }).description("Show the current subscription").action(async (_options, cmd) => {
|
|
13182
13975
|
try {
|
|
13183
13976
|
const api = createApiClient();
|
|
13184
|
-
const outputFormat =
|
|
13977
|
+
const outputFormat = getOutputFormat27(cmd);
|
|
13185
13978
|
const s = await api.admin.getCurrentSubscription();
|
|
13186
13979
|
format(outputFormat === "human" ? forReader(s) : s, { format: outputFormat });
|
|
13187
13980
|
} catch (error) {
|
|
@@ -13191,7 +13984,7 @@ Examples:
|
|
|
13191
13984
|
sub.command("next").description("Show the next (upcoming) subscription").action(async (_options, cmd) => {
|
|
13192
13985
|
try {
|
|
13193
13986
|
const api = createApiClient();
|
|
13194
|
-
const outputFormat =
|
|
13987
|
+
const outputFormat = getOutputFormat27(cmd);
|
|
13195
13988
|
const s = await api.admin.getNextSubscription();
|
|
13196
13989
|
format(outputFormat === "human" ? forReader(s) : s, { format: outputFormat });
|
|
13197
13990
|
} catch (error) {
|
|
@@ -13202,7 +13995,7 @@ Examples:
|
|
|
13202
13995
|
try {
|
|
13203
13996
|
const api = createApiClient();
|
|
13204
13997
|
const plans = await api.admin.getSubscriptionPlans(subscriptionToken);
|
|
13205
|
-
format(plans, { format:
|
|
13998
|
+
format(plans, { format: getOutputFormat27(cmd) });
|
|
13206
13999
|
} catch (error) {
|
|
13207
14000
|
handleError(error);
|
|
13208
14001
|
}
|
|
@@ -13211,7 +14004,7 @@ Examples:
|
|
|
13211
14004
|
|
|
13212
14005
|
// src/commands/invoice/index.ts
|
|
13213
14006
|
import * as fs14 from "fs";
|
|
13214
|
-
function
|
|
14007
|
+
function getOutputFormat28(cmd) {
|
|
13215
14008
|
const config = loadConfig();
|
|
13216
14009
|
const globalOpts = cmd.optsWithGlobals();
|
|
13217
14010
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -13228,7 +14021,7 @@ Examples:
|
|
|
13228
14021
|
const api = createApiClient();
|
|
13229
14022
|
const invoices = await api.admin.getInvoices();
|
|
13230
14023
|
format(invoices, {
|
|
13231
|
-
format:
|
|
14024
|
+
format: getOutputFormat28(cmd),
|
|
13232
14025
|
columns: [
|
|
13233
14026
|
{ key: "invoiceNumber", header: "number" },
|
|
13234
14027
|
{ key: "issued", kind: "date" },
|
|
@@ -13358,7 +14151,7 @@ function registerShellCommand(program) {
|
|
|
13358
14151
|
});
|
|
13359
14152
|
const api = createApiClient();
|
|
13360
14153
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
13361
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
14154
|
+
const { getUpdateNotice } = await import("./update-check-JWT4C4O5.js");
|
|
13362
14155
|
const resolvedLanguage = await resolveLanguage(api, fnRef.projectId, options.language);
|
|
13363
14156
|
console.log(chalk36.bold("Diafunc shell") + chalk36.dim(` \xB7 function ${fnRef.entityId} \xB7 ${resolvedLanguage}`));
|
|
13364
14157
|
console.log(chalk36.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
|
|
@@ -14219,4 +15012,4 @@ export {
|
|
|
14219
15012
|
PromptCanceled,
|
|
14220
15013
|
createProgram
|
|
14221
15014
|
};
|
|
14222
|
-
//# sourceMappingURL=chunk-
|
|
15015
|
+
//# sourceMappingURL=chunk-AH6DCAHU.js.map
|