@diafunc/cli 0.29.1 → 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 +3 -3
- package/dist/bin/diafunc.js +3 -3
- package/dist/{chunk-6QBACH4J.js → chunk-AH6DCAHU.js} +1207 -258
- package/dist/chunk-AH6DCAHU.js.map +1 -0
- package/dist/{chunk-CSLLHHQU.js → chunk-PUTTVRZA.js} +2 -2
- package/dist/{chunk-WZQ5LS2M.js → chunk-QX7F5YXI.js} +2 -2
- package/dist/{chunk-WZQ5LS2M.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-6QBACH4J.js.map +0 -1
- package/dist/update-check-BH7IMKZN.js +0 -8
- /package/dist/{chunk-CSLLHHQU.js.map → chunk-PUTTVRZA.js.map} +0 -0
- /package/dist/{update-check-BH7IMKZN.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
|
}
|
|
@@ -2244,6 +2408,29 @@ function createAnalysisService(client) {
|
|
|
2244
2408
|
path: `/${encodeURIComponent(analysisId)}/navigation`
|
|
2245
2409
|
});
|
|
2246
2410
|
},
|
|
2411
|
+
/**
|
|
2412
|
+
* The report as Markdown. Without `chapter`: the summary and the outline of chapter titles.
|
|
2413
|
+
* `chapter` is a title, or a path of titles separated by `>` (`Age > Correlation`). `maxBytes` is
|
|
2414
|
+
* clamped by the platform to 4-256 KiB, 32 KiB when absent. A chapter that does not fit comes in
|
|
2415
|
+
* parts; `part` (from 1) names the one to read and is ignored without `chapter`.
|
|
2416
|
+
*/
|
|
2417
|
+
async getReportMarkdown(analysisId, options = {}) {
|
|
2418
|
+
return client.request({
|
|
2419
|
+
method: "GET",
|
|
2420
|
+
service: SERVICE2,
|
|
2421
|
+
path: `/${encodeURIComponent(analysisId)}/report.md`,
|
|
2422
|
+
query: { chapter: options.chapter, part: options.part, maxBytes: options.maxBytes }
|
|
2423
|
+
});
|
|
2424
|
+
},
|
|
2425
|
+
/** The model of one target as source code or a formula in `language`; `target` is needed when there are several. */
|
|
2426
|
+
async exportModel(analysisId, options) {
|
|
2427
|
+
return client.request({
|
|
2428
|
+
method: "GET",
|
|
2429
|
+
service: SERVICE2,
|
|
2430
|
+
path: `/${encodeURIComponent(analysisId)}/model-export`,
|
|
2431
|
+
query: { language: options.language, target: options.target }
|
|
2432
|
+
});
|
|
2433
|
+
},
|
|
2247
2434
|
// ----- Runs -----------------------------------------------------------------------
|
|
2248
2435
|
async runAnalysis(analysisId) {
|
|
2249
2436
|
return client.request({
|
|
@@ -3411,7 +3598,16 @@ function createApiClient(options = {}) {
|
|
|
3411
3598
|
}
|
|
3412
3599
|
|
|
3413
3600
|
// src/commands/auth/token.ts
|
|
3414
|
-
var VALID_RESOURCE_TYPES = ["project", "team"];
|
|
3601
|
+
var VALID_RESOURCE_TYPES = ["project", "team", "user"];
|
|
3602
|
+
function requireResourceUnlessPersonal(create) {
|
|
3603
|
+
const internals = create;
|
|
3604
|
+
const report = internals.missingMandatoryOptionValue.bind(create);
|
|
3605
|
+
internals.missingMandatoryOptionValue = (option) => {
|
|
3606
|
+
const type = String(create.getOptionValue("resourceType") ?? "").trim().toLowerCase();
|
|
3607
|
+
if (option.attributeName() === "resource" && type === "user") return;
|
|
3608
|
+
report(option);
|
|
3609
|
+
};
|
|
3610
|
+
}
|
|
3415
3611
|
var VALID_SCOPES = [
|
|
3416
3612
|
"project:read",
|
|
3417
3613
|
"project:write",
|
|
@@ -3420,9 +3616,19 @@ var VALID_SCOPES = [
|
|
|
3420
3616
|
"evaluation:read",
|
|
3421
3617
|
"evaluation:execute"
|
|
3422
3618
|
];
|
|
3619
|
+
var TOKEN_CREATE_HELP = `
|
|
3620
|
+
A project token reaches one project, a team token the projects of one team. A personal token
|
|
3621
|
+
(--resource-type user) acts for your own account across the projects you can reach, limited by
|
|
3622
|
+
its scopes. No API token reaches account settings: password, sign-in methods, billing and tokens.
|
|
3623
|
+
|
|
3624
|
+
$ diafunc auth token create --name ci --resource <projectId> --scopes project:read,storage:read
|
|
3625
|
+
$ diafunc auth token create --name assistant --resource-type user --scopes project:read,project:write
|
|
3626
|
+
`;
|
|
3423
3627
|
function registerTokenCommands(parent) {
|
|
3424
3628
|
const token = parent.command("token").description("Manage API tokens");
|
|
3425
|
-
token.command("create").description("Create a new API token").requiredOption("--name <name>", "Token name").requiredOption("--resource <id>", "
|
|
3629
|
+
const create = token.command("create").description("Create a new API token for a project, a team, or your own account").requiredOption("--name <name>", "Token name").requiredOption("--resource <id>", "Project or team ID (not needed with --resource-type user)").requiredOption("--scopes <scopes>", `Comma-separated scopes: ${VALID_SCOPES.join(", ")}`).option("--resource-type <type>", `Resource type: ${VALID_RESOURCE_TYPES.join(", ")}`, "project").option("--days <days>", "Validity in days (default: 365)", "365").addHelpText("after", TOKEN_CREATE_HELP);
|
|
3630
|
+
requireResourceUnlessPersonal(create);
|
|
3631
|
+
create.action(async (options, cmd) => {
|
|
3426
3632
|
try {
|
|
3427
3633
|
const config = loadConfig();
|
|
3428
3634
|
const globalOpts = cmd.optsWithGlobals();
|
|
@@ -3445,7 +3651,9 @@ function registerTokenCommands(parent) {
|
|
|
3445
3651
|
const api = createApiClient();
|
|
3446
3652
|
const result = await api.admin.createApiToken({
|
|
3447
3653
|
name: options.name,
|
|
3448
|
-
|
|
3654
|
+
// A personal token's resource is the caller's own account, which the platform fills in.
|
|
3655
|
+
// A given id is passed on; the platform refuses one that is not the caller's.
|
|
3656
|
+
...options.resource !== void 0 ? { resourceId: options.resource } : {},
|
|
3449
3657
|
resourceType,
|
|
3450
3658
|
scopes,
|
|
3451
3659
|
validityDays: parseInt(options.days, 10)
|
|
@@ -3475,7 +3683,7 @@ function registerTokenCommands(parent) {
|
|
|
3475
3683
|
const tokens = options.resource ? await api.admin.getApiTokensByResource(options.resource) : await api.admin.getApiTokens();
|
|
3476
3684
|
format(tokens, {
|
|
3477
3685
|
format: outputFormat,
|
|
3478
|
-
columns: ["tokenId", "name", "resourceId", "scopes", "createdAt", "expiresAt"]
|
|
3686
|
+
columns: ["tokenId", "name", "resourceType", "resourceId", "scopes", "createdAt", "expiresAt"]
|
|
3479
3687
|
});
|
|
3480
3688
|
} catch (error) {
|
|
3481
3689
|
handleError(error);
|
|
@@ -3643,7 +3851,7 @@ function getNestedValue(obj, path13) {
|
|
|
3643
3851
|
}
|
|
3644
3852
|
|
|
3645
3853
|
// src/commands/project/index.ts
|
|
3646
|
-
import
|
|
3854
|
+
import chalk14 from "chalk";
|
|
3647
3855
|
|
|
3648
3856
|
// src/util/hidden-aliases.ts
|
|
3649
3857
|
import { Help, Option } from "commander";
|
|
@@ -4335,12 +4543,234 @@ Examples:
|
|
|
4335
4543
|
`).action((ref, given, _options, cmd) => guarded(() => change(target, "set", ref, given, cmd)));
|
|
4336
4544
|
}
|
|
4337
4545
|
|
|
4338
|
-
// 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
|
|
4339
4568
|
function getOutputFormat2(cmd) {
|
|
4340
4569
|
const config = loadConfig();
|
|
4341
4570
|
const globalOpts = cmd.optsWithGlobals();
|
|
4342
4571
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
4343
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
|
+
}
|
|
4344
4774
|
function getOverrides(cmd) {
|
|
4345
4775
|
const opts = cmd.optsWithGlobals();
|
|
4346
4776
|
return { project: opts.project, branch: opts.branch };
|
|
@@ -4354,7 +4784,7 @@ Examples:
|
|
|
4354
4784
|
$ diafunc search "housing" --type project find a project by name
|
|
4355
4785
|
`).action(async (options, cmd) => {
|
|
4356
4786
|
try {
|
|
4357
|
-
const outputFormat =
|
|
4787
|
+
const outputFormat = getOutputFormat3(cmd);
|
|
4358
4788
|
const api = createApiClient();
|
|
4359
4789
|
const projects = options.all ? await api.admin.getAllProjects() : await api.admin.getProjects();
|
|
4360
4790
|
const limit = Number.parseInt(options.limit, 10);
|
|
@@ -4363,7 +4793,7 @@ Examples:
|
|
|
4363
4793
|
try {
|
|
4364
4794
|
names = await projectNames(api, capped.map((p) => p.projectId));
|
|
4365
4795
|
} catch {
|
|
4366
|
-
console.error(
|
|
4796
|
+
console.error(chalk14.dim("Project names are unavailable right now; showing ids."));
|
|
4367
4797
|
}
|
|
4368
4798
|
const rows = capped.map((p) => ({ name: names.get(p.projectId) ?? null, ...p }));
|
|
4369
4799
|
format(rows, {
|
|
@@ -4380,7 +4810,7 @@ Examples:
|
|
|
4380
4810
|
]
|
|
4381
4811
|
});
|
|
4382
4812
|
if (capped.length < projects.length) {
|
|
4383
|
-
console.error(
|
|
4813
|
+
console.error(chalk14.dim(
|
|
4384
4814
|
`
|
|
4385
4815
|
Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
|
|
4386
4816
|
));
|
|
@@ -4391,7 +4821,7 @@ Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
|
|
|
4391
4821
|
});
|
|
4392
4822
|
project.command("get").description("Get project details").argument("<projectId>", "Project ID").action(async (projectId, _options, cmd) => {
|
|
4393
4823
|
try {
|
|
4394
|
-
const outputFormat =
|
|
4824
|
+
const outputFormat = getOutputFormat3(cmd);
|
|
4395
4825
|
const api = createApiClient();
|
|
4396
4826
|
const p = await api.admin.getProject(projectId);
|
|
4397
4827
|
format(p, { format: outputFormat });
|
|
@@ -4408,7 +4838,7 @@ Examples:
|
|
|
4408
4838
|
$ diafunc license list the licenses that can be chosen
|
|
4409
4839
|
`).action(async (options, cmd) => {
|
|
4410
4840
|
try {
|
|
4411
|
-
const outputFormat =
|
|
4841
|
+
const outputFormat = getOutputFormat3(cmd);
|
|
4412
4842
|
const api = createApiClient();
|
|
4413
4843
|
const p = await api.admin.createProject({
|
|
4414
4844
|
visibility: options.visibility.toUpperCase(),
|
|
@@ -4429,7 +4859,7 @@ Examples:
|
|
|
4429
4859
|
if (outputFormat === "human") {
|
|
4430
4860
|
success("Project created.");
|
|
4431
4861
|
if (options.name) console.log(` Name: ${options.name}`);
|
|
4432
|
-
console.log(` Project ID: ${
|
|
4862
|
+
console.log(` Project ID: ${chalk14.bold(p.projectId)}`);
|
|
4433
4863
|
console.log(` Visibility: ${p.visibility}`);
|
|
4434
4864
|
console.log(` Language: ${p.language}`);
|
|
4435
4865
|
if (p.licenceId) console.log(` License: ${p.licenceId}`);
|
|
@@ -4491,7 +4921,7 @@ Examples:
|
|
|
4491
4921
|
});
|
|
4492
4922
|
project.command("recent").description("List recently accessed projects").action(async (_options, cmd) => {
|
|
4493
4923
|
try {
|
|
4494
|
-
const outputFormat =
|
|
4924
|
+
const outputFormat = getOutputFormat3(cmd);
|
|
4495
4925
|
const api = createApiClient();
|
|
4496
4926
|
const recent = await api.admin.getRecentProjects();
|
|
4497
4927
|
format(recent, {
|
|
@@ -4534,10 +4964,11 @@ Examples:
|
|
|
4534
4964
|
}
|
|
4535
4965
|
});
|
|
4536
4966
|
registerTagCommands(project, "project");
|
|
4967
|
+
registerProjectTransferCommands(project);
|
|
4537
4968
|
const members = project.command("members").description("Manage project members");
|
|
4538
4969
|
members.command("list").description("List project members").argument("<projectId>", "Project ID").action(async (projectId, _options, cmd) => {
|
|
4539
4970
|
try {
|
|
4540
|
-
const outputFormat =
|
|
4971
|
+
const outputFormat = getOutputFormat3(cmd);
|
|
4541
4972
|
const api = createApiClient();
|
|
4542
4973
|
const memberList = await api.admin.getProjectMembers(projectId);
|
|
4543
4974
|
format(memberList, {
|
|
@@ -4586,7 +5017,7 @@ Examples:
|
|
|
4586
5017
|
console.log(`Poll progress: diafunc notebook bundles ${project2}`);
|
|
4587
5018
|
return;
|
|
4588
5019
|
}
|
|
4589
|
-
console.log(
|
|
5020
|
+
console.log(chalk14.dim(`Project export queued (bundle ID: ${bundleId}); waiting for it to finish\u2026`));
|
|
4590
5021
|
const job = await pollUntilFinished(api.storage, ref.projectId, ref.projectBranch, bundleId);
|
|
4591
5022
|
const response = await api.storage.getBundleContent(ref.projectId, ref.projectBranch, bundleId, job.filename);
|
|
4592
5023
|
const outFile = options.out ?? "project.dfproj";
|
|
@@ -4598,7 +5029,7 @@ Examples:
|
|
|
4598
5029
|
});
|
|
4599
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) => {
|
|
4600
5031
|
try {
|
|
4601
|
-
const outputFormat =
|
|
5032
|
+
const outputFormat = getOutputFormat3(cmd);
|
|
4602
5033
|
const overrides = getOverrides(cmd);
|
|
4603
5034
|
const ref = parseProjectReference(project2, overrides);
|
|
4604
5035
|
const api = createApiClient();
|
|
@@ -4611,32 +5042,9 @@ Examples:
|
|
|
4611
5042
|
|
|
4612
5043
|
// src/commands/team/index.ts
|
|
4613
5044
|
import chalk15 from "chalk";
|
|
4614
|
-
|
|
4615
|
-
// src/util/confirm.ts
|
|
4616
|
-
import * as readline from "readline";
|
|
4617
|
-
import chalk14 from "chalk";
|
|
4618
|
-
async function confirmDestructive(message, opts = {}) {
|
|
4619
|
-
if (!process.stdin.isTTY || opts.yes) return;
|
|
4620
|
-
const expected = opts.resourceId ?? "yes";
|
|
4621
|
-
const hint2 = opts.resourceId ? `"${opts.resourceId}"` : '"yes"';
|
|
4622
|
-
console.log(chalk14.yellow(`! ${message}`));
|
|
4623
|
-
const answer = await new Promise((resolve2) => {
|
|
4624
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
4625
|
-
rl.question(` Type ${hint2} to confirm: `, (ans) => {
|
|
4626
|
-
rl.close();
|
|
4627
|
-
resolve2(ans);
|
|
4628
|
-
});
|
|
4629
|
-
});
|
|
4630
|
-
if (answer.trim() !== expected) {
|
|
4631
|
-
console.log(chalk14.dim("Aborted."));
|
|
4632
|
-
process.exit(1);
|
|
4633
|
-
}
|
|
4634
|
-
}
|
|
4635
|
-
|
|
4636
|
-
// src/commands/team/index.ts
|
|
4637
5045
|
var ROLES = ["OWNER", "ADMIN", "MEMBER"];
|
|
4638
5046
|
var INTERVALS = ["MONTHLY", "YEARLY"];
|
|
4639
|
-
function
|
|
5047
|
+
function getOutputFormat4(cmd) {
|
|
4640
5048
|
const config = loadConfig();
|
|
4641
5049
|
const globalOpts = cmd.optsWithGlobals();
|
|
4642
5050
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -4701,7 +5109,7 @@ Examples:
|
|
|
4701
5109
|
const api = createApiClient();
|
|
4702
5110
|
const teams = await api.admin.listMyTeams();
|
|
4703
5111
|
format(teams, {
|
|
4704
|
-
format:
|
|
5112
|
+
format: getOutputFormat4(cmd),
|
|
4705
5113
|
columns: ["id", "name", "planId", "seatCount", "packCount", "renewal"]
|
|
4706
5114
|
});
|
|
4707
5115
|
} catch (error) {
|
|
@@ -4712,7 +5120,7 @@ Examples:
|
|
|
4712
5120
|
try {
|
|
4713
5121
|
const api = createApiClient();
|
|
4714
5122
|
format(await api.admin.getTeam(teamId), {
|
|
4715
|
-
format:
|
|
5123
|
+
format: getOutputFormat4(cmd)
|
|
4716
5124
|
});
|
|
4717
5125
|
} catch (error) {
|
|
4718
5126
|
handleError(error);
|
|
@@ -4722,14 +5130,14 @@ Examples:
|
|
|
4722
5130
|
try {
|
|
4723
5131
|
const api = createApiClient();
|
|
4724
5132
|
await api.admin.setActiveTeam(teamId);
|
|
4725
|
-
success(`Active team set to "${teamId}".`, { format:
|
|
5133
|
+
success(`Active team set to "${teamId}".`, { format: getOutputFormat4(cmd) });
|
|
4726
5134
|
} catch (error) {
|
|
4727
5135
|
handleError(error);
|
|
4728
5136
|
}
|
|
4729
5137
|
});
|
|
4730
5138
|
team.command("usage").description("Show credit usage for a team, broken down by member").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
|
|
4731
5139
|
try {
|
|
4732
|
-
const outputFormat =
|
|
5140
|
+
const outputFormat = getOutputFormat4(cmd);
|
|
4733
5141
|
const api = createApiClient();
|
|
4734
5142
|
const usage = await api.admin.getTeamUsage(teamId);
|
|
4735
5143
|
if (outputFormat === "json") {
|
|
@@ -4758,7 +5166,7 @@ Examples:
|
|
|
4758
5166
|
...options.packs !== void 0 ? { packCount: parseCount(options.packs, "pack count") } : {},
|
|
4759
5167
|
...options.currency !== void 0 ? { currency: options.currency.toUpperCase() } : {}
|
|
4760
5168
|
});
|
|
4761
|
-
const outputFormat =
|
|
5169
|
+
const outputFormat = getOutputFormat4(cmd);
|
|
4762
5170
|
if (outputFormat === "json") {
|
|
4763
5171
|
format(session, { format: outputFormat });
|
|
4764
5172
|
return;
|
|
@@ -4773,7 +5181,7 @@ Examples:
|
|
|
4773
5181
|
try {
|
|
4774
5182
|
const api = createApiClient();
|
|
4775
5183
|
const session = await api.admin.createTeamPortalSession(teamId, options.returnUrl);
|
|
4776
|
-
const outputFormat =
|
|
5184
|
+
const outputFormat = getOutputFormat4(cmd);
|
|
4777
5185
|
if (outputFormat === "json") {
|
|
4778
5186
|
format(session, { format: outputFormat });
|
|
4779
5187
|
return;
|
|
@@ -4794,7 +5202,7 @@ Examples:
|
|
|
4794
5202
|
const response = await api.admin.cancelTeam(teamId);
|
|
4795
5203
|
success(
|
|
4796
5204
|
`Team "${teamId}" canceled. Access ends ${response.endsAt ?? "at the end of the period"}.`,
|
|
4797
|
-
{ format:
|
|
5205
|
+
{ format: getOutputFormat4(cmd) }
|
|
4798
5206
|
);
|
|
4799
5207
|
} catch (error) {
|
|
4800
5208
|
handleError(error);
|
|
@@ -4808,7 +5216,7 @@ Examples:
|
|
|
4808
5216
|
});
|
|
4809
5217
|
const api = createApiClient();
|
|
4810
5218
|
await api.admin.leaveTeam(teamId);
|
|
4811
|
-
success(`Left team "${teamId}".`, { format:
|
|
5219
|
+
success(`Left team "${teamId}".`, { format: getOutputFormat4(cmd) });
|
|
4812
5220
|
} catch (error) {
|
|
4813
5221
|
handleError(error);
|
|
4814
5222
|
}
|
|
@@ -4827,7 +5235,7 @@ function registerMemberCommands(team) {
|
|
|
4827
5235
|
const all = await api.admin.listTeamMembers(teamId);
|
|
4828
5236
|
const shown = options.all ? all : all.filter((m) => !m.removedAt);
|
|
4829
5237
|
format(shown, {
|
|
4830
|
-
format:
|
|
5238
|
+
format: getOutputFormat4(cmd),
|
|
4831
5239
|
columns: options.all ? ["userId", "name", "email", "role", "joinedAt", "removedAt"] : ["userId", "name", "email", "role", "joinedAt"]
|
|
4832
5240
|
});
|
|
4833
5241
|
} catch (error) {
|
|
@@ -4840,7 +5248,7 @@ function registerMemberCommands(team) {
|
|
|
4840
5248
|
const api = createApiClient();
|
|
4841
5249
|
await api.admin.inviteTeamMember(teamId, email, role);
|
|
4842
5250
|
success(`Invited ${email} to team "${teamId}" as ${role}.`, {
|
|
4843
|
-
format:
|
|
5251
|
+
format: getOutputFormat4(cmd)
|
|
4844
5252
|
});
|
|
4845
5253
|
} catch (error) {
|
|
4846
5254
|
handleError(error);
|
|
@@ -4855,7 +5263,7 @@ function registerMemberCommands(team) {
|
|
|
4855
5263
|
const api = createApiClient();
|
|
4856
5264
|
await api.admin.removeTeamMember(teamId, userId);
|
|
4857
5265
|
success(`Removed ${userId} from team "${teamId}".`, {
|
|
4858
|
-
format:
|
|
5266
|
+
format: getOutputFormat4(cmd)
|
|
4859
5267
|
});
|
|
4860
5268
|
} catch (error) {
|
|
4861
5269
|
handleError(error);
|
|
@@ -4868,7 +5276,7 @@ function registerInvitationCommands(team) {
|
|
|
4868
5276
|
try {
|
|
4869
5277
|
const api = createApiClient();
|
|
4870
5278
|
format(await api.admin.listTeamInvitations(teamId), {
|
|
4871
|
-
format:
|
|
5279
|
+
format: getOutputFormat4(cmd),
|
|
4872
5280
|
columns: ["invitationId", "email", "role", "invitedBy", "expiresAt"]
|
|
4873
5281
|
});
|
|
4874
5282
|
} catch (error) {
|
|
@@ -4884,7 +5292,7 @@ function registerInvitationCommands(team) {
|
|
|
4884
5292
|
const api = createApiClient();
|
|
4885
5293
|
await api.admin.revokeTeamInvitation(teamId, invitationId);
|
|
4886
5294
|
success(`Revoked invitation "${invitationId}".`, {
|
|
4887
|
-
format:
|
|
5295
|
+
format: getOutputFormat4(cmd)
|
|
4888
5296
|
});
|
|
4889
5297
|
} catch (error) {
|
|
4890
5298
|
handleError(error);
|
|
@@ -4895,7 +5303,7 @@ function registerInvitationCommands(team) {
|
|
|
4895
5303
|
const api = createApiClient();
|
|
4896
5304
|
await api.admin.resendTeamInvitation(teamId, invitationId);
|
|
4897
5305
|
success(`Resent invitation "${invitationId}".`, {
|
|
4898
|
-
format:
|
|
5306
|
+
format: getOutputFormat4(cmd)
|
|
4899
5307
|
});
|
|
4900
5308
|
} catch (error) {
|
|
4901
5309
|
handleError(error);
|
|
@@ -4906,7 +5314,7 @@ function registerInvitationCommands(team) {
|
|
|
4906
5314
|
const api = createApiClient();
|
|
4907
5315
|
const member = await api.admin.acceptTeamInvitation(token);
|
|
4908
5316
|
success(`Joined the team as ${member.role}.`, {
|
|
4909
|
-
format:
|
|
5317
|
+
format: getOutputFormat4(cmd)
|
|
4910
5318
|
});
|
|
4911
5319
|
} catch (error) {
|
|
4912
5320
|
handleError(error);
|
|
@@ -4920,7 +5328,7 @@ function registerSeatCommands(team) {
|
|
|
4920
5328
|
const api = createApiClient();
|
|
4921
5329
|
printInvoicePreview(
|
|
4922
5330
|
await api.admin.previewTeamSeatCount(teamId, parseCount(count, "seat count")),
|
|
4923
|
-
|
|
5331
|
+
getOutputFormat4(cmd)
|
|
4924
5332
|
);
|
|
4925
5333
|
} catch (error) {
|
|
4926
5334
|
handleError(error);
|
|
@@ -4936,7 +5344,7 @@ function registerSeatCommands(team) {
|
|
|
4936
5344
|
const api = createApiClient();
|
|
4937
5345
|
const change2 = await api.admin.updateTeamSeatCount(teamId, seatCount);
|
|
4938
5346
|
success(`Seats changed from ${change2.oldSeatCount} to ${change2.newSeatCount}.`, {
|
|
4939
|
-
format:
|
|
5347
|
+
format: getOutputFormat4(cmd)
|
|
4940
5348
|
});
|
|
4941
5349
|
} catch (error) {
|
|
4942
5350
|
handleError(error);
|
|
@@ -4950,7 +5358,7 @@ function registerPackCommands(team) {
|
|
|
4950
5358
|
const api = createApiClient();
|
|
4951
5359
|
printInvoicePreview(
|
|
4952
5360
|
await api.admin.previewTeamPackCount(teamId, parseCount(count, "pack count")),
|
|
4953
|
-
|
|
5361
|
+
getOutputFormat4(cmd)
|
|
4954
5362
|
);
|
|
4955
5363
|
} catch (error) {
|
|
4956
5364
|
handleError(error);
|
|
@@ -4966,7 +5374,7 @@ function registerPackCommands(team) {
|
|
|
4966
5374
|
const api = createApiClient();
|
|
4967
5375
|
const change2 = await api.admin.updateTeamPackCount(teamId, packCount);
|
|
4968
5376
|
success(`Packs changed from ${change2.oldPackCount} to ${change2.newPackCount}.`, {
|
|
4969
|
-
format:
|
|
5377
|
+
format: getOutputFormat4(cmd)
|
|
4970
5378
|
});
|
|
4971
5379
|
} catch (error) {
|
|
4972
5380
|
handleError(error);
|
|
@@ -4983,7 +5391,7 @@ function registerOwnershipCommands(team) {
|
|
|
4983
5391
|
);
|
|
4984
5392
|
const api = createApiClient();
|
|
4985
5393
|
format(await api.admin.initiateOwnershipTransfer(teamId, userId), {
|
|
4986
|
-
format:
|
|
5394
|
+
format: getOutputFormat4(cmd)
|
|
4987
5395
|
});
|
|
4988
5396
|
} catch (error) {
|
|
4989
5397
|
handleError(error);
|
|
@@ -4993,7 +5401,7 @@ function registerOwnershipCommands(team) {
|
|
|
4993
5401
|
try {
|
|
4994
5402
|
const api = createApiClient();
|
|
4995
5403
|
const pending = await api.admin.getOwnershipTransfer(teamId);
|
|
4996
|
-
const outputFormat =
|
|
5404
|
+
const outputFormat = getOutputFormat4(cmd);
|
|
4997
5405
|
if (!pending) {
|
|
4998
5406
|
if (outputFormat === "json") {
|
|
4999
5407
|
format(null, { format: outputFormat });
|
|
@@ -5011,7 +5419,7 @@ function registerOwnershipCommands(team) {
|
|
|
5011
5419
|
try {
|
|
5012
5420
|
const api = createApiClient();
|
|
5013
5421
|
const response = await api.admin.acceptOwnershipTransfer(teamId);
|
|
5014
|
-
const outputFormat =
|
|
5422
|
+
const outputFormat = getOutputFormat4(cmd);
|
|
5015
5423
|
if (outputFormat === "json") {
|
|
5016
5424
|
format(response, { format: outputFormat });
|
|
5017
5425
|
return;
|
|
@@ -5030,7 +5438,7 @@ function registerOwnershipCommands(team) {
|
|
|
5030
5438
|
const api = createApiClient();
|
|
5031
5439
|
await api.admin.cancelOwnershipTransfer(teamId);
|
|
5032
5440
|
success(`Canceled the ownership transfer for team "${teamId}".`, {
|
|
5033
|
-
format:
|
|
5441
|
+
format: getOutputFormat4(cmd)
|
|
5034
5442
|
});
|
|
5035
5443
|
} catch (error) {
|
|
5036
5444
|
handleError(error);
|
|
@@ -5040,7 +5448,7 @@ function registerOwnershipCommands(team) {
|
|
|
5040
5448
|
|
|
5041
5449
|
// src/commands/entity/index.ts
|
|
5042
5450
|
import * as fs5 from "fs";
|
|
5043
|
-
function
|
|
5451
|
+
function getOutputFormat5(cmd) {
|
|
5044
5452
|
const config = loadConfig();
|
|
5045
5453
|
const globalOpts = cmd.optsWithGlobals();
|
|
5046
5454
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -5063,7 +5471,7 @@ Examples:
|
|
|
5063
5471
|
;
|
|
5064
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) => {
|
|
5065
5473
|
try {
|
|
5066
|
-
const outputFormat =
|
|
5474
|
+
const outputFormat = getOutputFormat5(cmd);
|
|
5067
5475
|
const overrides = getOverrides2(cmd);
|
|
5068
5476
|
const ref = parseEntityReference(projectRef + "/" + projectRef, overrides);
|
|
5069
5477
|
const api = createApiClient();
|
|
@@ -5090,7 +5498,7 @@ Examples:
|
|
|
5090
5498
|
});
|
|
5091
5499
|
entity.command("get").description("Get entity metadata").argument("<ref>", "Entity reference").option("--content", "Include content").action(async (ref, options, cmd) => {
|
|
5092
5500
|
try {
|
|
5093
|
-
const outputFormat =
|
|
5501
|
+
const outputFormat = getOutputFormat5(cmd);
|
|
5094
5502
|
const overrides = getOverrides2(cmd);
|
|
5095
5503
|
const resolved = parseEntityReference(ref, overrides);
|
|
5096
5504
|
const api = createApiClient();
|
|
@@ -5133,7 +5541,7 @@ Examples:
|
|
|
5133
5541
|
});
|
|
5134
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) => {
|
|
5135
5543
|
try {
|
|
5136
|
-
const outputFormat =
|
|
5544
|
+
const outputFormat = getOutputFormat5(cmd);
|
|
5137
5545
|
const overrides = getOverrides2(cmd);
|
|
5138
5546
|
const resolved = parseEntityReference(ref, overrides);
|
|
5139
5547
|
const api = createApiClient();
|
|
@@ -5250,7 +5658,7 @@ Examples:
|
|
|
5250
5658
|
});
|
|
5251
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) => {
|
|
5252
5660
|
try {
|
|
5253
|
-
const outputFormat =
|
|
5661
|
+
const outputFormat = getOutputFormat5(cmd);
|
|
5254
5662
|
const overrides = getOverrides2(cmd);
|
|
5255
5663
|
const ref = parseProjectReference(project, overrides);
|
|
5256
5664
|
const api = createApiClient();
|
|
@@ -5262,7 +5670,7 @@ Examples:
|
|
|
5262
5670
|
}
|
|
5263
5671
|
|
|
5264
5672
|
// src/commands/link/index.ts
|
|
5265
|
-
function
|
|
5673
|
+
function getOutputFormat6(cmd) {
|
|
5266
5674
|
const config = loadConfig();
|
|
5267
5675
|
const globalOpts = cmd.optsWithGlobals();
|
|
5268
5676
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -5275,7 +5683,7 @@ function registerLinkCommands(program) {
|
|
|
5275
5683
|
const link = program.command("link").description("Manage links between entities");
|
|
5276
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) => {
|
|
5277
5685
|
try {
|
|
5278
|
-
const outputFormat =
|
|
5686
|
+
const outputFormat = getOutputFormat6(cmd);
|
|
5279
5687
|
const overrides = getOverrides3(cmd);
|
|
5280
5688
|
const resolved = parseEntityReference(ref, overrides);
|
|
5281
5689
|
const api = createApiClient();
|
|
@@ -5350,7 +5758,7 @@ function registerLinkCommands(program) {
|
|
|
5350
5758
|
}
|
|
5351
5759
|
|
|
5352
5760
|
// src/commands/event/index.ts
|
|
5353
|
-
function
|
|
5761
|
+
function getOutputFormat7(cmd) {
|
|
5354
5762
|
const config = loadConfig();
|
|
5355
5763
|
const globalOpts = cmd.optsWithGlobals();
|
|
5356
5764
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -5363,7 +5771,7 @@ function registerEventCommands(program) {
|
|
|
5363
5771
|
const event = program.command("event").description("Manage events");
|
|
5364
5772
|
event.command("list").description("List events for an entity").argument("<ref>", "Entity reference").action(async (ref, _options, cmd) => {
|
|
5365
5773
|
try {
|
|
5366
|
-
const outputFormat =
|
|
5774
|
+
const outputFormat = getOutputFormat7(cmd);
|
|
5367
5775
|
const overrides = getOverrides4(cmd);
|
|
5368
5776
|
const resolved = parseEntityReference(ref, overrides);
|
|
5369
5777
|
const api = createApiClient();
|
|
@@ -5385,7 +5793,7 @@ function registerEventCommands(program) {
|
|
|
5385
5793
|
});
|
|
5386
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) => {
|
|
5387
5795
|
try {
|
|
5388
|
-
const outputFormat =
|
|
5796
|
+
const outputFormat = getOutputFormat7(cmd);
|
|
5389
5797
|
const overrides = getOverrides4(cmd);
|
|
5390
5798
|
const resolved = parseEntityReference(ref, overrides);
|
|
5391
5799
|
const api = createApiClient();
|
|
@@ -5446,7 +5854,7 @@ function registerEventCommands(program) {
|
|
|
5446
5854
|
}
|
|
5447
5855
|
|
|
5448
5856
|
// src/commands/branch/index.ts
|
|
5449
|
-
function
|
|
5857
|
+
function getOutputFormat8(cmd) {
|
|
5450
5858
|
const config = loadConfig();
|
|
5451
5859
|
const globalOpts = cmd.optsWithGlobals();
|
|
5452
5860
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -5465,7 +5873,7 @@ Examples:
|
|
|
5465
5873
|
;
|
|
5466
5874
|
branch.command("list").description("List branches for a project").argument("[projectId]", "Project ID (uses default if omitted)").action(async (projectId, _options, cmd) => {
|
|
5467
5875
|
try {
|
|
5468
|
-
const outputFormat =
|
|
5876
|
+
const outputFormat = getOutputFormat8(cmd);
|
|
5469
5877
|
const overrides = getOverrides5(cmd);
|
|
5470
5878
|
const config = loadConfig();
|
|
5471
5879
|
const pid = projectId ?? overrides.project ?? config.defaults.project;
|
|
@@ -5685,7 +6093,7 @@ function buildTableEntity(args) {
|
|
|
5685
6093
|
|
|
5686
6094
|
// src/commands/table/index.ts
|
|
5687
6095
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
5688
|
-
function
|
|
6096
|
+
function getOutputFormat9(cmd) {
|
|
5689
6097
|
const config = loadConfig();
|
|
5690
6098
|
const globalOpts = cmd.optsWithGlobals();
|
|
5691
6099
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -5748,7 +6156,7 @@ Examples:
|
|
|
5748
6156
|
;
|
|
5749
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) => {
|
|
5750
6158
|
try {
|
|
5751
|
-
const outputFormat =
|
|
6159
|
+
const outputFormat = getOutputFormat9(cmd);
|
|
5752
6160
|
const overrides = getOverrides6(cmd);
|
|
5753
6161
|
const resolved = parseEntityReference(ref, overrides);
|
|
5754
6162
|
const api = createApiClient();
|
|
@@ -5813,7 +6221,7 @@ Examples:
|
|
|
5813
6221
|
$ diafunc table create --notebook <notebookId>
|
|
5814
6222
|
`).action(async (ref, options, cmd) => {
|
|
5815
6223
|
try {
|
|
5816
|
-
const outputFormat =
|
|
6224
|
+
const outputFormat = getOutputFormat9(cmd);
|
|
5817
6225
|
const overrides = getOverrides6(cmd);
|
|
5818
6226
|
const resolved = parseEntityReference(ref ?? randomUUID2(), overrides);
|
|
5819
6227
|
if (resolved.entityId.includes(".partition.")) {
|
|
@@ -5902,7 +6310,7 @@ Examples:
|
|
|
5902
6310
|
});
|
|
5903
6311
|
table.command("import-formats").description("List supported import formats").action(async (_options, cmd) => {
|
|
5904
6312
|
try {
|
|
5905
|
-
const outputFormat =
|
|
6313
|
+
const outputFormat = getOutputFormat9(cmd);
|
|
5906
6314
|
const api = createApiClient();
|
|
5907
6315
|
const response = await api.storage.getSupportedImportFormats();
|
|
5908
6316
|
if (outputFormat === "json") {
|
|
@@ -5993,7 +6401,7 @@ Examples:
|
|
|
5993
6401
|
});
|
|
5994
6402
|
table.command("export-formats").description("List supported export formats").action(async (_options, cmd) => {
|
|
5995
6403
|
try {
|
|
5996
|
-
const outputFormat =
|
|
6404
|
+
const outputFormat = getOutputFormat9(cmd);
|
|
5997
6405
|
const api = createApiClient();
|
|
5998
6406
|
const response = await api.storage.getSupportedExportFormats();
|
|
5999
6407
|
if (outputFormat === "json") {
|
|
@@ -6018,7 +6426,7 @@ Examples:
|
|
|
6018
6426
|
const exportsCmd = table.command("exports").description("Track and download async table exports");
|
|
6019
6427
|
exportsCmd.command("list").description("List async exports for a table entity").argument("<ref>", "Table entity reference").action(async (ref, _options, cmd) => {
|
|
6020
6428
|
try {
|
|
6021
|
-
const outputFormat =
|
|
6429
|
+
const outputFormat = getOutputFormat9(cmd);
|
|
6022
6430
|
const overrides = getOverrides6(cmd);
|
|
6023
6431
|
const resolved = parseEntityReference(ref, overrides);
|
|
6024
6432
|
const api = createApiClient();
|
|
@@ -6046,7 +6454,7 @@ Examples:
|
|
|
6046
6454
|
});
|
|
6047
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) => {
|
|
6048
6456
|
try {
|
|
6049
|
-
const outputFormat =
|
|
6457
|
+
const outputFormat = getOutputFormat9(cmd);
|
|
6050
6458
|
const overrides = getOverrides6(cmd);
|
|
6051
6459
|
const resolved = parseEntityReference(options.ref, overrides);
|
|
6052
6460
|
const api = createApiClient();
|
|
@@ -6215,7 +6623,7 @@ Examples:
|
|
|
6215
6623
|
import chalk17 from "chalk";
|
|
6216
6624
|
import * as fs7 from "fs";
|
|
6217
6625
|
import * as path5 from "path";
|
|
6218
|
-
function
|
|
6626
|
+
function getOutputFormat10(cmd) {
|
|
6219
6627
|
const config = loadConfig();
|
|
6220
6628
|
const globalOpts = cmd.optsWithGlobals();
|
|
6221
6629
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -6255,7 +6663,7 @@ Examples:
|
|
|
6255
6663
|
});
|
|
6256
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) => {
|
|
6257
6665
|
try {
|
|
6258
|
-
const outputFormat =
|
|
6666
|
+
const outputFormat = getOutputFormat10(cmd);
|
|
6259
6667
|
const overrides = getOverrides7(cmd);
|
|
6260
6668
|
const ref = parseProjectReference(project, overrides);
|
|
6261
6669
|
const api = createApiClient();
|
|
@@ -6301,7 +6709,7 @@ Examples:
|
|
|
6301
6709
|
});
|
|
6302
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) => {
|
|
6303
6711
|
try {
|
|
6304
|
-
const outputFormat =
|
|
6712
|
+
const outputFormat = getOutputFormat10(cmd);
|
|
6305
6713
|
const overrides = getOverrides7(cmd);
|
|
6306
6714
|
const ref = parseProjectReference(project, overrides);
|
|
6307
6715
|
const api = createApiClient();
|
|
@@ -6441,7 +6849,7 @@ function resultText(result, resultEncoding) {
|
|
|
6441
6849
|
}
|
|
6442
6850
|
|
|
6443
6851
|
// src/commands/function/index.ts
|
|
6444
|
-
function
|
|
6852
|
+
function getOutputFormat11(cmd) {
|
|
6445
6853
|
const config = loadConfig();
|
|
6446
6854
|
const globalOpts = cmd.optsWithGlobals();
|
|
6447
6855
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -6471,7 +6879,7 @@ Examples:
|
|
|
6471
6879
|
;
|
|
6472
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) => {
|
|
6473
6881
|
try {
|
|
6474
|
-
const outputFormat =
|
|
6882
|
+
const outputFormat = getOutputFormat11(cmd);
|
|
6475
6883
|
const overrides = getOverrides8(cmd);
|
|
6476
6884
|
const resolved = parseEntityReference(ref, overrides);
|
|
6477
6885
|
const api = createApiClient();
|
|
@@ -6552,7 +6960,7 @@ Examples:
|
|
|
6552
6960
|
});
|
|
6553
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) => {
|
|
6554
6962
|
try {
|
|
6555
|
-
const outputFormat =
|
|
6963
|
+
const outputFormat = getOutputFormat11(cmd);
|
|
6556
6964
|
const overrides = getOverrides8(cmd);
|
|
6557
6965
|
const resolved = parseEntityReference(ref, overrides);
|
|
6558
6966
|
const api = createApiClient();
|
|
@@ -6593,7 +7001,7 @@ Examples:
|
|
|
6593
7001
|
});
|
|
6594
7002
|
fn.command("outputs").description("Get outputs for an evaluation").argument("<projectId>", "Project ID").argument("<evaluationId>", "Evaluation ID").action(async (projectId, evaluationId, _options, cmd) => {
|
|
6595
7003
|
try {
|
|
6596
|
-
const outputFormat =
|
|
7004
|
+
const outputFormat = getOutputFormat11(cmd);
|
|
6597
7005
|
const api = createApiClient();
|
|
6598
7006
|
const outputs = await api.evaluation.getOutputs(projectId, evaluationId);
|
|
6599
7007
|
if (outputFormat === "human") {
|
|
@@ -6613,7 +7021,7 @@ Examples:
|
|
|
6613
7021
|
});
|
|
6614
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) => {
|
|
6615
7023
|
try {
|
|
6616
|
-
const outputFormat =
|
|
7024
|
+
const outputFormat = getOutputFormat11(cmd);
|
|
6617
7025
|
const overrides = getOverrides8(cmd);
|
|
6618
7026
|
const resolved = parseEntityReference(ref, overrides);
|
|
6619
7027
|
const api = createApiClient();
|
|
@@ -6659,7 +7067,7 @@ Examples:
|
|
|
6659
7067
|
});
|
|
6660
7068
|
fn.command("languages").description("List the languages a function can be written in").action(async (_options, cmd) => {
|
|
6661
7069
|
try {
|
|
6662
|
-
const outputFormat =
|
|
7070
|
+
const outputFormat = getOutputFormat11(cmd);
|
|
6663
7071
|
format(
|
|
6664
7072
|
FUNCTION_LANGUAGES.map((language) => ({
|
|
6665
7073
|
language,
|
|
@@ -6673,7 +7081,7 @@ Examples:
|
|
|
6673
7081
|
});
|
|
6674
7082
|
fn.command("last-evaluation").description("Show the most recent evaluation of a function").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
|
|
6675
7083
|
try {
|
|
6676
|
-
const outputFormat =
|
|
7084
|
+
const outputFormat = getOutputFormat11(cmd);
|
|
6677
7085
|
const overrides = getOverrides8(cmd);
|
|
6678
7086
|
const resolved = parseEntityReference(ref, overrides);
|
|
6679
7087
|
const api = createApiClient();
|
|
@@ -7323,6 +7731,98 @@ function printUnavailable(interpretation) {
|
|
|
7323
7731
|
}
|
|
7324
7732
|
}
|
|
7325
7733
|
|
|
7734
|
+
// src/commands/analyze/report.ts
|
|
7735
|
+
var EXPORT_LANGUAGES = [
|
|
7736
|
+
"formula",
|
|
7737
|
+
"python",
|
|
7738
|
+
"r",
|
|
7739
|
+
"sql",
|
|
7740
|
+
"javascript",
|
|
7741
|
+
"java",
|
|
7742
|
+
"kotlin",
|
|
7743
|
+
"c",
|
|
7744
|
+
"latex"
|
|
7745
|
+
];
|
|
7746
|
+
function writeText(text2) {
|
|
7747
|
+
if (text2.length === 0) return;
|
|
7748
|
+
process.stdout.write(text2);
|
|
7749
|
+
if (!text2.endsWith("\n")) process.stdout.write("\n");
|
|
7750
|
+
}
|
|
7751
|
+
function parseMaxBytes(given) {
|
|
7752
|
+
if (given === void 0) return void 0;
|
|
7753
|
+
const trimmed = given.trim();
|
|
7754
|
+
if (!/^\d+$/.test(trimmed) || Number(trimmed) <= 0) {
|
|
7755
|
+
usageError(
|
|
7756
|
+
`--max-bytes must be a whole number of bytes, not "${given}".`,
|
|
7757
|
+
"The platform reads between 4096 and 262144; without the flag it reads 32768."
|
|
7758
|
+
);
|
|
7759
|
+
}
|
|
7760
|
+
return Number(trimmed);
|
|
7761
|
+
}
|
|
7762
|
+
function parsePart(given, chapter) {
|
|
7763
|
+
if (given === void 0) return void 0;
|
|
7764
|
+
const trimmed = given.trim();
|
|
7765
|
+
if (!/^\d+$/.test(trimmed) || Number(trimmed) < 1) {
|
|
7766
|
+
usageError(`--part must be a whole number from 1, not "${given}".`);
|
|
7767
|
+
}
|
|
7768
|
+
if (chapter === void 0) {
|
|
7769
|
+
usageError(
|
|
7770
|
+
"--part reads one part of a chapter, so it needs --chapter.",
|
|
7771
|
+
"Without --chapter the command prints the summary, which does not come in parts."
|
|
7772
|
+
);
|
|
7773
|
+
}
|
|
7774
|
+
return Number(trimmed);
|
|
7775
|
+
}
|
|
7776
|
+
function parseExportLanguage(given) {
|
|
7777
|
+
const language = given.trim().toLowerCase();
|
|
7778
|
+
if (!EXPORT_LANGUAGES.includes(language)) {
|
|
7779
|
+
usageError(
|
|
7780
|
+
`"${given}" is not a language a model can be exported in.`,
|
|
7781
|
+
`Choose one of: ${EXPORT_LANGUAGES.join(", ")}.`
|
|
7782
|
+
);
|
|
7783
|
+
}
|
|
7784
|
+
return language;
|
|
7785
|
+
}
|
|
7786
|
+
async function printReport(analysisId, options) {
|
|
7787
|
+
const maxBytes = parseMaxBytes(options.maxBytes);
|
|
7788
|
+
const chapter = options.chapter?.trim() || void 0;
|
|
7789
|
+
const part = parsePart(options.part, chapter);
|
|
7790
|
+
const api = createApiClient();
|
|
7791
|
+
const markdown = await api.analysis.getReportMarkdown(analysisId, { chapter, part, maxBytes });
|
|
7792
|
+
writeText(markdown);
|
|
7793
|
+
}
|
|
7794
|
+
async function printModelExport(analysisId, options) {
|
|
7795
|
+
const language = parseExportLanguage(options.language);
|
|
7796
|
+
const target = options.target?.trim() || void 0;
|
|
7797
|
+
const api = createApiClient();
|
|
7798
|
+
const source = await api.analysis.exportModel(analysisId, { language, target });
|
|
7799
|
+
writeText(source);
|
|
7800
|
+
}
|
|
7801
|
+
var REPORT_HELP = `
|
|
7802
|
+
Without --chapter it prints the summary of the report and the titles of its chapters. Name a
|
|
7803
|
+
chapter to read it whole with the chapters below it. A title several chapters share is narrowed
|
|
7804
|
+
by naming chapters above it, separated by ">":
|
|
7805
|
+
|
|
7806
|
+
$ diafunc analyze report <id>
|
|
7807
|
+
$ diafunc analyze report <id> --chapter "Age > Correlation"
|
|
7808
|
+
$ diafunc analyze report <id> --max-bytes 131072 > report.md
|
|
7809
|
+
|
|
7810
|
+
A chapter larger than --max-bytes comes in parts. Each part ends with a line naming the next;
|
|
7811
|
+
read it with --part:
|
|
7812
|
+
|
|
7813
|
+
$ diafunc analyze report <id> --chapter Data --part 2
|
|
7814
|
+
|
|
7815
|
+
A title no chapter carries prints a sentence saying so, followed by the titles there are.
|
|
7816
|
+
Figures are not drawn; the numbers behind them are in the chapter's tables and values.
|
|
7817
|
+
`;
|
|
7818
|
+
var EXPORT_MODEL_HELP = `
|
|
7819
|
+
Prints the model the analysis found for one target, as a formula or as source code. With
|
|
7820
|
+
several targets, name one with --target. Public analyses can be exported too.
|
|
7821
|
+
|
|
7822
|
+
$ diafunc analyze export-model <id> --language formula
|
|
7823
|
+
$ diafunc analyze export-model <id> --language python --target price > model.py
|
|
7824
|
+
`;
|
|
7825
|
+
|
|
7326
7826
|
// src/prompting/resolvers.ts
|
|
7327
7827
|
var PROJECT_ROLES = ["OWNER", "ADMIN", "DEVELOPER", "GUEST"];
|
|
7328
7828
|
var TRIGGER_TYPES = ["CRON", "INTERVAL", "CONTINUOUS", "EVENT"];
|
|
@@ -7355,6 +7855,7 @@ var BY_COMMAND = {
|
|
|
7355
7855
|
"analyze focus": { "<family>": { kind: "choices", choices: FOCUS_FAMILIES.map((f) => f.id) } },
|
|
7356
7856
|
// Not the analysis picker: that one offers the reader's own analyses, and this command needs no account.
|
|
7357
7857
|
"public show": { "<analysisId>": TEXT },
|
|
7858
|
+
"analyze export-model": { "--language": { kind: "choice", choices: EXPORT_LANGUAGES } },
|
|
7358
7859
|
"analyze presets save": { "--targets": TEXT, "--hours": POSITIVE, "--budget": POSITIVE },
|
|
7359
7860
|
"branch merge": {
|
|
7360
7861
|
"--source": { kind: "entity", form: "ref" },
|
|
@@ -7392,9 +7893,11 @@ var BY_COMMAND = {
|
|
|
7392
7893
|
"config set": { "<key>": { kind: "choice", choices: CONFIG_KEYS } },
|
|
7393
7894
|
"project members invite": { "<userId>": TEXT, "<role>": { kind: "choice", choices: PROJECT_ROLES } },
|
|
7394
7895
|
"project members join": { "<userId>": TEXT },
|
|
7896
|
+
"license create": { "<licenseId>": TEXT, "--name": TEXT, "--flags": TEXT },
|
|
7395
7897
|
"trigger create": { "--type": { kind: "choice", choices: TRIGGER_TYPES } },
|
|
7396
7898
|
"analyze triggers create": { "--kind": { kind: "choice", choices: ANALYSIS_TRIGGER_KINDS } },
|
|
7397
7899
|
"function outputs": { "<evaluationId>": TEXT },
|
|
7900
|
+
"admin project move": { "--to": TEXT },
|
|
7398
7901
|
"team create": { "--seats": { kind: "number", min: 1, integer: true } },
|
|
7399
7902
|
"team seats preview": { "<count>": { kind: "number", min: 1, integer: true } },
|
|
7400
7903
|
"team seats set": { "<count>": { kind: "number", min: 1, integer: true } }
|
|
@@ -7452,7 +7955,10 @@ var BY_NAME = {
|
|
|
7452
7955
|
consumerType: TEXT,
|
|
7453
7956
|
consumerId: TEXT,
|
|
7454
7957
|
format: TEXT,
|
|
7455
|
-
key: TEXT
|
|
7958
|
+
key: TEXT,
|
|
7959
|
+
reason: TEXT,
|
|
7960
|
+
batchId: TEXT,
|
|
7961
|
+
userIdOrEmail: TEXT
|
|
7456
7962
|
};
|
|
7457
7963
|
function tokenOf(input) {
|
|
7458
7964
|
return input.kind === "option" ? input.flag ?? `--${input.name}` : `<${input.name}>`;
|
|
@@ -7528,7 +8034,7 @@ function dependencies(spec) {
|
|
|
7528
8034
|
}
|
|
7529
8035
|
|
|
7530
8036
|
// src/commands/trigger/index.ts
|
|
7531
|
-
function
|
|
8037
|
+
function getOutputFormat12(cmd) {
|
|
7532
8038
|
const config = loadConfig();
|
|
7533
8039
|
const globalOpts = cmd.optsWithGlobals();
|
|
7534
8040
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -7547,7 +8053,7 @@ Examples:
|
|
|
7547
8053
|
`);
|
|
7548
8054
|
trigger.command("list").description("List triggers for a function").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
|
|
7549
8055
|
try {
|
|
7550
|
-
const outputFormat =
|
|
8056
|
+
const outputFormat = getOutputFormat12(cmd);
|
|
7551
8057
|
const overrides = getOverrides9(cmd);
|
|
7552
8058
|
const resolved = parseEntityReference(ref, overrides);
|
|
7553
8059
|
const api = createApiClient();
|
|
@@ -7576,7 +8082,7 @@ Examples:
|
|
|
7576
8082
|
});
|
|
7577
8083
|
trigger.command("get").description("Get a specific trigger").argument("<ref>", "Function entity reference").argument("<triggerId>", "Trigger ID").action(async (ref, triggerId, _options, cmd) => {
|
|
7578
8084
|
try {
|
|
7579
|
-
const outputFormat =
|
|
8085
|
+
const outputFormat = getOutputFormat12(cmd);
|
|
7580
8086
|
const overrides = getOverrides9(cmd);
|
|
7581
8087
|
const resolved = parseEntityReference(ref, overrides);
|
|
7582
8088
|
const api = createApiClient();
|
|
@@ -7668,7 +8174,7 @@ Examples:
|
|
|
7668
8174
|
}
|
|
7669
8175
|
|
|
7670
8176
|
// src/commands/schedule/index.ts
|
|
7671
|
-
function
|
|
8177
|
+
function getOutputFormat13(cmd) {
|
|
7672
8178
|
const config = loadConfig();
|
|
7673
8179
|
const globalOpts = cmd.optsWithGlobals();
|
|
7674
8180
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -7681,7 +8187,7 @@ function registerScheduleCommands(program) {
|
|
|
7681
8187
|
const schedule = program.command("schedule").description("Schedule function execution");
|
|
7682
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) => {
|
|
7683
8189
|
try {
|
|
7684
|
-
const outputFormat =
|
|
8190
|
+
const outputFormat = getOutputFormat13(cmd);
|
|
7685
8191
|
const overrides = getOverrides10(cmd);
|
|
7686
8192
|
const resolved = parseEntityReference(ref, overrides);
|
|
7687
8193
|
const api = createApiClient();
|
|
@@ -7750,7 +8256,7 @@ function registerScheduleCommands(program) {
|
|
|
7750
8256
|
});
|
|
7751
8257
|
schedule.command("list").description("List persistent triggers (scheduled functions are modeled as triggers)").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
|
|
7752
8258
|
try {
|
|
7753
|
-
const outputFormat =
|
|
8259
|
+
const outputFormat = getOutputFormat13(cmd);
|
|
7754
8260
|
const overrides = getOverrides10(cmd);
|
|
7755
8261
|
const resolved = parseEntityReference(ref, overrides);
|
|
7756
8262
|
const api = createApiClient();
|
|
@@ -7878,7 +8384,7 @@ function inline(text2) {
|
|
|
7878
8384
|
}
|
|
7879
8385
|
|
|
7880
8386
|
// src/commands/chat/index.ts
|
|
7881
|
-
function
|
|
8387
|
+
function getOutputFormat14(cmd) {
|
|
7882
8388
|
const config = loadConfig();
|
|
7883
8389
|
const globalOpts = cmd.optsWithGlobals();
|
|
7884
8390
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -7963,7 +8469,7 @@ var HELP = [
|
|
|
7963
8469
|
];
|
|
7964
8470
|
async function runChatRepl(options) {
|
|
7965
8471
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
7966
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
8472
|
+
const { getUpdateNotice } = await import("./update-check-JWT4C4O5.js");
|
|
7967
8473
|
let sessionId = options.session;
|
|
7968
8474
|
let lastReportedSession;
|
|
7969
8475
|
console.log(chalk21.bold("Diafunc chat") + chalk21.dim(" \xB7 /help for commands, /quit to exit"));
|
|
@@ -8070,7 +8576,7 @@ Examples:
|
|
|
8070
8576
|
});
|
|
8071
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) => {
|
|
8072
8578
|
try {
|
|
8073
|
-
const outputFormat =
|
|
8579
|
+
const outputFormat = getOutputFormat14(cmd);
|
|
8074
8580
|
const api = createApiClient();
|
|
8075
8581
|
const context = chatContext(cmd);
|
|
8076
8582
|
const response = await api.language.chat({
|
|
@@ -8094,7 +8600,7 @@ Examples:
|
|
|
8094
8600
|
});
|
|
8095
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) => {
|
|
8096
8602
|
try {
|
|
8097
|
-
const outputFormat =
|
|
8603
|
+
const outputFormat = getOutputFormat14(cmd);
|
|
8098
8604
|
const api = createApiClient();
|
|
8099
8605
|
const context = chatContext(cmd);
|
|
8100
8606
|
const response = await api.language.chatStream({
|
|
@@ -8184,7 +8690,7 @@ Examples:
|
|
|
8184
8690
|
const session = chat.command("session").description("Manage chat sessions");
|
|
8185
8691
|
session.command("list").description("List chat sessions").action(async (_options, cmd) => {
|
|
8186
8692
|
try {
|
|
8187
|
-
const outputFormat =
|
|
8693
|
+
const outputFormat = getOutputFormat14(cmd);
|
|
8188
8694
|
const api = createApiClient();
|
|
8189
8695
|
const sessions = await api.language.getSessions();
|
|
8190
8696
|
format(sessions, {
|
|
@@ -8206,7 +8712,7 @@ Examples:
|
|
|
8206
8712
|
});
|
|
8207
8713
|
session.command("show").description("Show the message history of a chat session").argument("<sessionId>", "Session ID").action(async (sessionId, _options, cmd) => {
|
|
8208
8714
|
try {
|
|
8209
|
-
const outputFormat =
|
|
8715
|
+
const outputFormat = getOutputFormat14(cmd);
|
|
8210
8716
|
const api = createApiClient();
|
|
8211
8717
|
const detail2 = await api.language.getSession(sessionId);
|
|
8212
8718
|
if (outputFormat === "human") {
|
|
@@ -8236,7 +8742,7 @@ Examples:
|
|
|
8236
8742
|
});
|
|
8237
8743
|
chat.command("usage").description("Show token usage").action(async (_options, cmd) => {
|
|
8238
8744
|
try {
|
|
8239
|
-
const outputFormat =
|
|
8745
|
+
const outputFormat = getOutputFormat14(cmd);
|
|
8240
8746
|
const api = createApiClient();
|
|
8241
8747
|
const usage = await api.language.getUsage();
|
|
8242
8748
|
format(usage, { format: outputFormat });
|
|
@@ -8248,7 +8754,7 @@ Examples:
|
|
|
8248
8754
|
|
|
8249
8755
|
// src/commands/search/index.ts
|
|
8250
8756
|
import chalk22 from "chalk";
|
|
8251
|
-
function
|
|
8757
|
+
function getOutputFormat15(cmd) {
|
|
8252
8758
|
const config = loadConfig();
|
|
8253
8759
|
const globalOpts = cmd.optsWithGlobals();
|
|
8254
8760
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -8271,7 +8777,7 @@ whose discovered model has the better quality comes first; inside one project th
|
|
|
8271
8777
|
`).action(async (query, options, cmd) => {
|
|
8272
8778
|
const sort = parseSort(options.sort);
|
|
8273
8779
|
try {
|
|
8274
|
-
const outputFormat =
|
|
8780
|
+
const outputFormat = getOutputFormat15(cmd);
|
|
8275
8781
|
const overrides = cmd.optsWithGlobals();
|
|
8276
8782
|
const config = loadConfig();
|
|
8277
8783
|
const api = createApiClient();
|
|
@@ -8365,11 +8871,11 @@ function collapse(text2) {
|
|
|
8365
8871
|
}
|
|
8366
8872
|
|
|
8367
8873
|
// src/commands/admin/index.ts
|
|
8368
|
-
import { readFile } from "fs/promises";
|
|
8874
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
8369
8875
|
|
|
8370
8876
|
// src/commands/admin/curated-tags.ts
|
|
8371
8877
|
import chalk23 from "chalk";
|
|
8372
|
-
function
|
|
8878
|
+
function getOutputFormat16(cmd) {
|
|
8373
8879
|
const config = loadConfig();
|
|
8374
8880
|
const globalOpts = cmd.optsWithGlobals();
|
|
8375
8881
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -8411,102 +8917,355 @@ Examples:
|
|
|
8411
8917
|
$ diafunc admin curated-tags list -o json
|
|
8412
8918
|
`).action(async (_options, cmd) => {
|
|
8413
8919
|
try {
|
|
8414
|
-
const outputFormat =
|
|
8415
|
-
const tags = await createApiClient().index.getCuratedTags(true);
|
|
8416
|
-
if (tags.length === 0) {
|
|
8417
|
-
empty("curated tags", { format: outputFormat });
|
|
8920
|
+
const outputFormat = getOutputFormat16(cmd);
|
|
8921
|
+
const tags = await createApiClient().index.getCuratedTags(true);
|
|
8922
|
+
if (tags.length === 0) {
|
|
8923
|
+
empty("curated tags", { format: outputFormat });
|
|
8924
|
+
return;
|
|
8925
|
+
}
|
|
8926
|
+
format(tags, { format: outputFormat, columns: COLUMNS });
|
|
8927
|
+
} catch (error) {
|
|
8928
|
+
handleError(error);
|
|
8929
|
+
}
|
|
8930
|
+
});
|
|
8931
|
+
curated.command("create").description("Create a curated tag (admin)").argument("<tag>", 'The tag projects carry, stored in its canonical form ("Machine Learning" becomes "machine-learning")').requiredOption("--display-name <name>", "The name Explore shows for it").option("--description <text>", "What belongs under it").option("--sort-order <n>", "Position in the filter, lowest first; tags without one come last").addHelpText("after", `
|
|
8932
|
+
Examples:
|
|
8933
|
+
$ diafunc admin curated-tags create health --display-name "Health" --sort-order 1
|
|
8934
|
+
$ diafunc admin curated-tags create "Machine Learning" --display-name "Machine learning" --dry-run
|
|
8935
|
+
`).action(async (typed2, options, cmd) => {
|
|
8936
|
+
try {
|
|
8937
|
+
const outputFormat = getOutputFormat16(cmd);
|
|
8938
|
+
const tag = curatedTagOf(typed2);
|
|
8939
|
+
if (isReservedTag(tag)) {
|
|
8940
|
+
usageError(`"${tag}" is reserved for the staging content of analysis runs and is never searchable.`);
|
|
8941
|
+
}
|
|
8942
|
+
const displayName = (options.displayName ?? "").trim();
|
|
8943
|
+
if (displayName === "") usageError("--display-name must not be empty.");
|
|
8944
|
+
const request = {
|
|
8945
|
+
tag,
|
|
8946
|
+
displayName,
|
|
8947
|
+
...options.description !== void 0 && options.description.trim() !== "" ? { description: options.description } : {},
|
|
8948
|
+
...options.sortOrder !== void 0 ? { sortOrder: parseSortOrder(options.sortOrder) } : {}
|
|
8949
|
+
};
|
|
8950
|
+
const created = await createApiClient().index.createCuratedTag(request);
|
|
8951
|
+
if (isDryRun()) return;
|
|
8952
|
+
if (outputFormat === "human") {
|
|
8953
|
+
success(`Curated tag "${created.tag}" created.`);
|
|
8954
|
+
} else {
|
|
8955
|
+
format(created, { format: outputFormat });
|
|
8956
|
+
}
|
|
8957
|
+
} catch (error) {
|
|
8958
|
+
handleError(error);
|
|
8959
|
+
}
|
|
8960
|
+
});
|
|
8961
|
+
curated.command("update").description("Change the name, description or position of a curated tag (admin)").argument("<tag>", "The curated tag").option("--display-name <name>", "The name Explore shows for it").option("--description <text>", "What belongs under it; an empty value clears it").option("--sort-order <n>", "Position in the filter, lowest first").addHelpText("after", `
|
|
8962
|
+
Only what is given changes. The tag itself cannot be renamed: delete it and create the new one.
|
|
8963
|
+
|
|
8964
|
+
Examples:
|
|
8965
|
+
$ diafunc admin curated-tags update health --display-name "Health and medicine"
|
|
8966
|
+
$ diafunc admin curated-tags update health --description "" clears the description
|
|
8967
|
+
$ diafunc admin curated-tags update health --sort-order 3 --dry-run
|
|
8968
|
+
`).action(async (typed2, options, cmd) => {
|
|
8969
|
+
try {
|
|
8970
|
+
const outputFormat = getOutputFormat16(cmd);
|
|
8971
|
+
const tag = curatedTagOf(typed2);
|
|
8972
|
+
if (options.displayName === void 0 && options.description === void 0 && options.sortOrder === void 0) {
|
|
8973
|
+
usageError("Nothing to change.", "Pass at least one of --display-name, --description, --sort-order.");
|
|
8974
|
+
}
|
|
8975
|
+
if (options.displayName !== void 0 && options.displayName.trim() === "") {
|
|
8976
|
+
usageError("--display-name must not be empty.");
|
|
8977
|
+
}
|
|
8978
|
+
const request = {
|
|
8979
|
+
...options.displayName !== void 0 ? { displayName: options.displayName.trim() } : {},
|
|
8980
|
+
...options.description !== void 0 ? { description: options.description } : {},
|
|
8981
|
+
...options.sortOrder !== void 0 ? { sortOrder: parseSortOrder(options.sortOrder) } : {}
|
|
8982
|
+
};
|
|
8983
|
+
const updated = await createApiClient().index.updateCuratedTag(tag, request);
|
|
8984
|
+
if (isDryRun()) return;
|
|
8985
|
+
if (outputFormat === "human") {
|
|
8986
|
+
success(`Curated tag "${tag}" updated.`);
|
|
8987
|
+
} else {
|
|
8988
|
+
format(updated, { format: outputFormat });
|
|
8989
|
+
}
|
|
8990
|
+
} catch (error) {
|
|
8991
|
+
handleError(error);
|
|
8992
|
+
}
|
|
8993
|
+
});
|
|
8994
|
+
curated.command("delete").description("Delete a curated tag (admin); projects that carry the tag keep it").argument("<tag>", "The curated tag").option("-y, --yes", "Skip confirmation prompt (for CI / scripted use)").addHelpText("after", `
|
|
8995
|
+
Examples:
|
|
8996
|
+
$ diafunc admin curated-tags delete health
|
|
8997
|
+
$ diafunc admin curated-tags delete health --yes --dry-run
|
|
8998
|
+
`).action(async (typed2, options, cmd) => {
|
|
8999
|
+
try {
|
|
9000
|
+
const outputFormat = getOutputFormat16(cmd);
|
|
9001
|
+
const tag = curatedTagOf(typed2);
|
|
9002
|
+
if (!isDryRun()) {
|
|
9003
|
+
await confirmDestructive(`This removes "${tag}" from Explore's data-domain filter.`, { yes: options.yes, resourceId: tag });
|
|
9004
|
+
}
|
|
9005
|
+
await createApiClient().index.deleteCuratedTag(tag);
|
|
9006
|
+
if (isDryRun()) return;
|
|
9007
|
+
success(`Curated tag "${tag}" deleted.`, { format: outputFormat });
|
|
9008
|
+
} catch (error) {
|
|
9009
|
+
handleError(error);
|
|
9010
|
+
}
|
|
9011
|
+
});
|
|
9012
|
+
}
|
|
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 });
|
|
8418
9203
|
return;
|
|
8419
9204
|
}
|
|
8420
|
-
format(
|
|
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
|
+
});
|
|
8421
9219
|
} catch (error) {
|
|
8422
9220
|
handleError(error);
|
|
8423
9221
|
}
|
|
8424
9222
|
});
|
|
8425
|
-
|
|
8426
|
-
Examples:
|
|
8427
|
-
$ diafunc admin curated-tags create health --display-name "Health" --sort-order 1
|
|
8428
|
-
$ diafunc admin curated-tags create "Machine Learning" --display-name "Machine learning" --dry-run
|
|
8429
|
-
`).action(async (typed2, options, cmd) => {
|
|
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) => {
|
|
8430
9224
|
try {
|
|
8431
|
-
const
|
|
8432
|
-
|
|
8433
|
-
|
|
8434
|
-
usageError(`"${tag}" is reserved for the staging content of analysis runs and is never searchable.`);
|
|
8435
|
-
}
|
|
8436
|
-
const displayName = (options.displayName ?? "").trim();
|
|
8437
|
-
if (displayName === "") usageError("--display-name must not be empty.");
|
|
8438
|
-
const request = {
|
|
8439
|
-
tag,
|
|
8440
|
-
displayName,
|
|
8441
|
-
...options.description !== void 0 && options.description.trim() !== "" ? { description: options.description } : {},
|
|
8442
|
-
...options.sortOrder !== void 0 ? { sortOrder: parseSortOrder(options.sortOrder) } : {}
|
|
8443
|
-
};
|
|
8444
|
-
const created = await createApiClient().index.createCuratedTag(request);
|
|
8445
|
-
if (isDryRun()) return;
|
|
8446
|
-
if (outputFormat === "human") {
|
|
8447
|
-
success(`Curated tag "${created.tag}" created.`);
|
|
8448
|
-
} else {
|
|
8449
|
-
format(created, { format: outputFormat });
|
|
8450
|
-
}
|
|
9225
|
+
const api = createApiClient();
|
|
9226
|
+
await api.admin.resumeProjectTransfer(projectId, requireReason(options.reason));
|
|
9227
|
+
success(`Resumed the transfer of project "${projectId}".`, { format: getOutputFormat17(cmd) });
|
|
8451
9228
|
} catch (error) {
|
|
8452
9229
|
handleError(error);
|
|
8453
9230
|
}
|
|
8454
9231
|
});
|
|
8455
|
-
|
|
8456
|
-
Only what is given changes. The tag itself cannot be renamed: delete it and create the new one.
|
|
8457
|
-
|
|
8458
|
-
Examples:
|
|
8459
|
-
$ diafunc admin curated-tags update health --display-name "Health and medicine"
|
|
8460
|
-
$ diafunc admin curated-tags update health --description "" clears the description
|
|
8461
|
-
$ diafunc admin curated-tags update health --sort-order 3 --dry-run
|
|
8462
|
-
`).action(async (typed2, options, cmd) => {
|
|
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) => {
|
|
8463
9233
|
try {
|
|
8464
|
-
const
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
}
|
|
8472
|
-
const request = {
|
|
8473
|
-
...options.displayName !== void 0 ? { displayName: options.displayName.trim() } : {},
|
|
8474
|
-
...options.description !== void 0 ? { description: options.description } : {},
|
|
8475
|
-
...options.sortOrder !== void 0 ? { sortOrder: parseSortOrder(options.sortOrder) } : {}
|
|
8476
|
-
};
|
|
8477
|
-
const updated = await createApiClient().index.updateCuratedTag(tag, request);
|
|
8478
|
-
if (isDryRun()) return;
|
|
8479
|
-
if (outputFormat === "human") {
|
|
8480
|
-
success(`Curated tag "${tag}" updated.`);
|
|
8481
|
-
} else {
|
|
8482
|
-
format(updated, { format: outputFormat });
|
|
8483
|
-
}
|
|
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) });
|
|
8484
9242
|
} catch (error) {
|
|
8485
9243
|
handleError(error);
|
|
8486
9244
|
}
|
|
8487
9245
|
});
|
|
8488
|
-
|
|
8489
|
-
Examples:
|
|
8490
|
-
$ diafunc admin curated-tags delete health
|
|
8491
|
-
$ diafunc admin curated-tags delete health --yes --dry-run
|
|
8492
|
-
`).action(async (typed2, options, cmd) => {
|
|
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) => {
|
|
8493
9247
|
try {
|
|
8494
|
-
const
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
success(`
|
|
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) });
|
|
8502
9256
|
} catch (error) {
|
|
8503
9257
|
handleError(error);
|
|
8504
9258
|
}
|
|
8505
9259
|
});
|
|
8506
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
|
+
}
|
|
8507
9266
|
|
|
8508
9267
|
// src/commands/admin/index.ts
|
|
8509
|
-
function
|
|
9268
|
+
function getOutputFormat18(cmd) {
|
|
8510
9269
|
const config = loadConfig();
|
|
8511
9270
|
const globalOpts = cmd.optsWithGlobals();
|
|
8512
9271
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -8516,7 +9275,7 @@ function registerAdminCommands(program) {
|
|
|
8516
9275
|
const users = admin.command("users").description("Manage users");
|
|
8517
9276
|
users.command("list").description("List all users (admin)").action(async (_options, cmd) => {
|
|
8518
9277
|
try {
|
|
8519
|
-
const outputFormat =
|
|
9278
|
+
const outputFormat = getOutputFormat18(cmd);
|
|
8520
9279
|
const api = createApiClient();
|
|
8521
9280
|
const userList = await api.admin.getUsers();
|
|
8522
9281
|
const summary = userList.map((u) => ({
|
|
@@ -8542,7 +9301,7 @@ function registerAdminCommands(program) {
|
|
|
8542
9301
|
});
|
|
8543
9302
|
users.command("get").description("Get current user details").action(async (_options, cmd) => {
|
|
8544
9303
|
try {
|
|
8545
|
-
const outputFormat =
|
|
9304
|
+
const outputFormat = getOutputFormat18(cmd);
|
|
8546
9305
|
const api = createApiClient();
|
|
8547
9306
|
const user = await api.admin.getMyUser();
|
|
8548
9307
|
format(user, { format: outputFormat });
|
|
@@ -8552,7 +9311,7 @@ function registerAdminCommands(program) {
|
|
|
8552
9311
|
});
|
|
8553
9312
|
admin.command("subscription").description("Show current subscription").action(async (_options, cmd) => {
|
|
8554
9313
|
try {
|
|
8555
|
-
const outputFormat =
|
|
9314
|
+
const outputFormat = getOutputFormat18(cmd);
|
|
8556
9315
|
const api = createApiClient();
|
|
8557
9316
|
const sub = await api.admin.getCurrentSubscription();
|
|
8558
9317
|
format(sub, { format: outputFormat });
|
|
@@ -8563,7 +9322,7 @@ function registerAdminCommands(program) {
|
|
|
8563
9322
|
const settings = admin.command("settings").description("Manage settings");
|
|
8564
9323
|
settings.command("get").description("Get current settings").action(async (_options, cmd) => {
|
|
8565
9324
|
try {
|
|
8566
|
-
const outputFormat =
|
|
9325
|
+
const outputFormat = getOutputFormat18(cmd);
|
|
8567
9326
|
const api = createApiClient();
|
|
8568
9327
|
const s = await api.admin.getSettings();
|
|
8569
9328
|
format(s, { format: outputFormat });
|
|
@@ -8583,7 +9342,7 @@ function registerAdminCommands(program) {
|
|
|
8583
9342
|
const platformSettings = admin.command("platform-settings").description("Manage platform-wide settings (admin only)");
|
|
8584
9343
|
platformSettings.command("list").description("Show every platform setting with its default and current override").action(async (_options, cmd) => {
|
|
8585
9344
|
try {
|
|
8586
|
-
const outputFormat =
|
|
9345
|
+
const outputFormat = getOutputFormat18(cmd);
|
|
8587
9346
|
const api = createApiClient();
|
|
8588
9347
|
const settingsList = await api.admin.listPlatformSettings();
|
|
8589
9348
|
format(settingsList, { format: outputFormat });
|
|
@@ -8671,9 +9430,10 @@ function registerAdminCommands(program) {
|
|
|
8671
9430
|
}
|
|
8672
9431
|
});
|
|
8673
9432
|
registerCuratedTagCommands(admin);
|
|
9433
|
+
registerAdminProjectCommands(admin);
|
|
8674
9434
|
admin.command("permissions").description("Show your permissions on a project").argument("<projectId>", "Project ID").action(async (projectId, _options, cmd) => {
|
|
8675
9435
|
try {
|
|
8676
|
-
const outputFormat =
|
|
9436
|
+
const outputFormat = getOutputFormat18(cmd);
|
|
8677
9437
|
const api = createApiClient();
|
|
8678
9438
|
const perm = await api.admin.getPermissions(projectId);
|
|
8679
9439
|
format({ projectId, permission: perm }, { format: outputFormat });
|
|
@@ -8686,20 +9446,20 @@ function registerAdminCommands(program) {
|
|
|
8686
9446
|
contract.command("get", { isDefault: true }).description("Show a team's contract").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
|
|
8687
9447
|
try {
|
|
8688
9448
|
const api = createApiClient();
|
|
8689
|
-
format(await api.admin.getTeamContract(teamId), { format:
|
|
9449
|
+
format(await api.admin.getTeamContract(teamId), { format: getOutputFormat18(cmd) });
|
|
8690
9450
|
} catch (error) {
|
|
8691
9451
|
handleError(error);
|
|
8692
9452
|
}
|
|
8693
9453
|
});
|
|
8694
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) => {
|
|
8695
9455
|
try {
|
|
8696
|
-
const request = JSON.parse(await
|
|
9456
|
+
const request = JSON.parse(await readFile2(options.file, "utf8"));
|
|
8697
9457
|
await confirmDestructive(
|
|
8698
9458
|
`This will replace the contract of team "${teamId}" with the terms in ${options.file}.`,
|
|
8699
9459
|
{ yes: options.yes, resourceId: teamId }
|
|
8700
9460
|
);
|
|
8701
9461
|
const api = createApiClient();
|
|
8702
|
-
format(await api.admin.issueTeamContract(teamId, request), { format:
|
|
9462
|
+
format(await api.admin.issueTeamContract(teamId, request), { format: getOutputFormat18(cmd) });
|
|
8703
9463
|
} catch (error) {
|
|
8704
9464
|
handleError(error);
|
|
8705
9465
|
}
|
|
@@ -9560,7 +10320,7 @@ function dataShape(rows, columns) {
|
|
|
9560
10320
|
}
|
|
9561
10321
|
function qualityText(analysis, verdict) {
|
|
9562
10322
|
if (verdict?.validity === "not_valid") return "not shown: the result is not valid";
|
|
9563
|
-
const figure = analysis.heldOutQuality != null ? qualityPercent(analysis.heldOutQuality) : analysis.resultRunQuality != null ? `${qualityPercent(analysis.resultRunQuality)} on the training rows` : null;
|
|
10323
|
+
const figure = analysis.heldOutQuality != null ? qualityPercent(analysis.heldOutQuality) + rowsText(analysis.heldOutRows, analysis.searchRows) : analysis.resultRunQuality != null ? `${qualityPercent(analysis.resultRunQuality)} on the training rows` : null;
|
|
9564
10324
|
if (figure == null) return null;
|
|
9565
10325
|
return verdict?.validity === "needs_review" ? `${figure}, needs review` : figure;
|
|
9566
10326
|
}
|
|
@@ -9569,12 +10329,17 @@ function targetResultsText(analysis) {
|
|
|
9569
10329
|
if (results.length === 0) return null;
|
|
9570
10330
|
const lines = results.map((r) => {
|
|
9571
10331
|
const name = r.title ?? r.target ?? "target";
|
|
9572
|
-
return r.quality != null ? `${name}: ${qualityPercent(r.quality)}` : name;
|
|
10332
|
+
return r.quality != null ? `${name}: ${qualityPercent(r.quality)}${rowsText(r.heldOutRows, r.searchRows)}` : name;
|
|
9573
10333
|
});
|
|
9574
10334
|
const more = (analysis.targetResultCount ?? results.length) - results.length;
|
|
9575
10335
|
if (more > 0) lines.push(`and ${formatNumber(more)} more`);
|
|
9576
10336
|
return lines.join("\n");
|
|
9577
10337
|
}
|
|
10338
|
+
function rowsText(heldOutRows, searchRows) {
|
|
10339
|
+
if (heldOutRows == null || !(heldOutRows > 0)) return "";
|
|
10340
|
+
const measured = ` on ${formatNumber(heldOutRows)} held-out ${heldOutRows === 1 ? "row" : "rows"}`;
|
|
10341
|
+
return searchRows != null && searchRows > 0 ? `${measured}, found on ${formatNumber(searchRows)} ${searchRows === 1 ? "row" : "rows"}` : measured;
|
|
10342
|
+
}
|
|
9578
10343
|
function errorPercent(error) {
|
|
9579
10344
|
return `${formatNumber(Math.round(error * 1e3) / 10)}%`;
|
|
9580
10345
|
}
|
|
@@ -9925,7 +10690,7 @@ function openUrl(url) {
|
|
|
9925
10690
|
const args = process.platform === "win32" ? ["/c", "start", '""', url] : [url];
|
|
9926
10691
|
spawn2(cmd, args, { detached: true, stdio: "ignore" }).unref();
|
|
9927
10692
|
}
|
|
9928
|
-
function
|
|
10693
|
+
function getOutputFormat19(cmd) {
|
|
9929
10694
|
const config = loadConfig();
|
|
9930
10695
|
const globalOpts = cmd.optsWithGlobals();
|
|
9931
10696
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -9934,7 +10699,7 @@ function noInteractiveFlag(cmd) {
|
|
|
9934
10699
|
return cmd.optsWithGlobals().interactive === false;
|
|
9935
10700
|
}
|
|
9936
10701
|
function importContext(api, analysisId, cmd, machineReport) {
|
|
9937
|
-
const outputFormat =
|
|
10702
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
9938
10703
|
const noInteractive = noInteractiveFlag(cmd);
|
|
9939
10704
|
return {
|
|
9940
10705
|
api,
|
|
@@ -10060,7 +10825,7 @@ async function runAnalysis(files, options, cmd) {
|
|
|
10060
10825
|
}
|
|
10061
10826
|
}
|
|
10062
10827
|
const file = files[0];
|
|
10063
|
-
const outputFormat =
|
|
10828
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10064
10829
|
const noInteractive = noInteractiveFlag(cmd);
|
|
10065
10830
|
const interactive = canPrompt(outputFormat, noInteractive);
|
|
10066
10831
|
const launch = launchIntentOf(options);
|
|
@@ -10335,7 +11100,7 @@ async function readPresets(api) {
|
|
|
10335
11100
|
}
|
|
10336
11101
|
async function monitorRun(api, analysisId, runId, budgetHours, cmd) {
|
|
10337
11102
|
const config = loadConfig();
|
|
10338
|
-
const outputFormat =
|
|
11103
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10339
11104
|
const human = outputFormat === "human";
|
|
10340
11105
|
const status = new Status();
|
|
10341
11106
|
const seenOutputs = /* @__PURE__ */ new Set();
|
|
@@ -10462,7 +11227,7 @@ async function printNotebookLink(api, config, analysisId) {
|
|
|
10462
11227
|
}
|
|
10463
11228
|
}
|
|
10464
11229
|
async function listAnalyses(limit, cmd) {
|
|
10465
|
-
const outputFormat =
|
|
11230
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10466
11231
|
const api = createApiClient();
|
|
10467
11232
|
const analyses = await api.analysis.getRecent(limit);
|
|
10468
11233
|
format(analyses.map((a) => ({
|
|
@@ -10492,7 +11257,7 @@ async function listAnalyses(limit, cmd) {
|
|
|
10492
11257
|
});
|
|
10493
11258
|
}
|
|
10494
11259
|
async function getAnalysisDetails(analysisId, options, cmd) {
|
|
10495
|
-
const outputFormat =
|
|
11260
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10496
11261
|
const api = createApiClient();
|
|
10497
11262
|
const result = analysisId ? await api.analysis.get(analysisId) : await api.analysis.getLast();
|
|
10498
11263
|
if (!result.analysis) {
|
|
@@ -10580,7 +11345,7 @@ async function rerunAnalysis(analysisId, cmd) {
|
|
|
10580
11345
|
const analysis = found.analysis;
|
|
10581
11346
|
const missing = missingRunFields(analysis);
|
|
10582
11347
|
if (missing.length > 0) {
|
|
10583
|
-
const outputFormat =
|
|
11348
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10584
11349
|
const noInteractive = noInteractiveFlag(cmd);
|
|
10585
11350
|
if (!canPrompt(outputFormat, noInteractive)) {
|
|
10586
11351
|
const { message, suggestion } = explainMissingRunFields(
|
|
@@ -10654,7 +11419,7 @@ function typedColumns(given) {
|
|
|
10654
11419
|
return entries === void 0 ? null : resolveColumnArguments(entries, []);
|
|
10655
11420
|
}
|
|
10656
11421
|
async function createAnalysis(options, cmd) {
|
|
10657
|
-
const outputFormat =
|
|
11422
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10658
11423
|
const launch = launchIntentOf(options);
|
|
10659
11424
|
const shapes = windowedShapes(launch.shapes);
|
|
10660
11425
|
const api = createApiClient();
|
|
@@ -10696,7 +11461,7 @@ async function deleteAnalysis(analysisId) {
|
|
|
10696
11461
|
success(`Deleted analysis ${analysisId}.`);
|
|
10697
11462
|
}
|
|
10698
11463
|
async function patchAndPrint(analysisId, value, handler, successLabel, cmd) {
|
|
10699
|
-
const outputFormat =
|
|
11464
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10700
11465
|
const api = createApiClient();
|
|
10701
11466
|
const updated = await handler(api, analysisId, value);
|
|
10702
11467
|
if (isDryRun()) {
|
|
@@ -10726,7 +11491,7 @@ async function ownAnalysis(api, analysisId) {
|
|
|
10726
11491
|
return found.analysis;
|
|
10727
11492
|
}
|
|
10728
11493
|
async function notesCommand(analysisId, text2, options, cmd) {
|
|
10729
|
-
const outputFormat =
|
|
11494
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10730
11495
|
const api = createApiClient();
|
|
10731
11496
|
const given = [text2 !== void 0, options.file !== void 0, options.clear === true].filter(Boolean).length;
|
|
10732
11497
|
if (given > 1) usageError("Give the notes as text, with --file, or clear them with --clear: one of the three.");
|
|
@@ -10772,7 +11537,7 @@ async function notesCommand(analysisId, text2, options, cmd) {
|
|
|
10772
11537
|
hint(`Read them into proposals with 'diafunc analyze intent read ${analysisId}'. Nothing changes until you confirm one.`);
|
|
10773
11538
|
}
|
|
10774
11539
|
async function readNotesCommand(analysisId, options, cmd) {
|
|
10775
|
-
const outputFormat =
|
|
11540
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10776
11541
|
const api = createApiClient();
|
|
10777
11542
|
const analysis = await ownAnalysis(api, analysisId);
|
|
10778
11543
|
if (!analysis.intent) {
|
|
@@ -10805,7 +11570,7 @@ async function readNotesCommand(analysisId, options, cmd) {
|
|
|
10805
11570
|
printInterpretation(interpretation, analysisId);
|
|
10806
11571
|
}
|
|
10807
11572
|
async function decideCommand(state, analysisId, ids, options, cmd) {
|
|
10808
|
-
const outputFormat =
|
|
11573
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10809
11574
|
const wanted = [...new Set(ids.flatMap((id) => id.split(",")).map((id) => id.trim()).filter((id) => id.length > 0))];
|
|
10810
11575
|
if (wanted.length === 0) usageError("Name at least one proposal.", `The ids are in 'diafunc analyze intent read ${analysisId}'.`);
|
|
10811
11576
|
if (options.steer !== void 0 && state !== "CONFIRMED") {
|
|
@@ -10844,7 +11609,7 @@ async function decideCommand(state, analysisId, ids, options, cmd) {
|
|
|
10844
11609
|
if (state === "CONFIRMED") hint(`It takes part from the next run: 'diafunc analyze rerun ${analysisId}'.`);
|
|
10845
11610
|
}
|
|
10846
11611
|
async function expectationsCommand(analysisId, given, options, cmd) {
|
|
10847
|
-
const outputFormat =
|
|
11612
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10848
11613
|
const api = createApiClient();
|
|
10849
11614
|
const analysis = await ownAnalysis(api, analysisId);
|
|
10850
11615
|
const current = analysis.shapeExpectations ?? {};
|
|
@@ -10965,7 +11730,7 @@ async function uploadOne(api, analysisId, file, asUploaded, human) {
|
|
|
10965
11730
|
}
|
|
10966
11731
|
async function uploadData(analysisId, files, options, cmd) {
|
|
10967
11732
|
const api = createApiClient();
|
|
10968
|
-
const outputFormat =
|
|
11733
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
10969
11734
|
const ctx = importContext(api, analysisId, cmd, "none");
|
|
10970
11735
|
const file = files[0];
|
|
10971
11736
|
if (files.length > 1) {
|
|
@@ -11015,7 +11780,7 @@ async function uploadData(analysisId, files, options, cmd) {
|
|
|
11015
11780
|
}
|
|
11016
11781
|
}
|
|
11017
11782
|
async function stopDataImport(analysisId, cmd) {
|
|
11018
|
-
const outputFormat =
|
|
11783
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11019
11784
|
const api = createApiClient();
|
|
11020
11785
|
const stopped = await withStatus("Stopping the data import", () => stopImport(api, analysisId));
|
|
11021
11786
|
if (isDryRun()) {
|
|
@@ -11038,7 +11803,7 @@ async function stopDataImport(analysisId, cmd) {
|
|
|
11038
11803
|
warn(stopped.dataImport.message);
|
|
11039
11804
|
}
|
|
11040
11805
|
async function listColumns(analysisId, cmd) {
|
|
11041
|
-
const outputFormat =
|
|
11806
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11042
11807
|
const api = createApiClient();
|
|
11043
11808
|
const columns = await api.analysis.getColumns(analysisId);
|
|
11044
11809
|
if (columns.length === 0) {
|
|
@@ -11049,7 +11814,7 @@ async function listColumns(analysisId, cmd) {
|
|
|
11049
11814
|
format(columns, { format: outputFormat, columns: ["name", "valueType"] });
|
|
11050
11815
|
}
|
|
11051
11816
|
async function listRuns(analysisId, count, cmd) {
|
|
11052
|
-
const outputFormat =
|
|
11817
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11053
11818
|
const api = createApiClient();
|
|
11054
11819
|
const runs = await api.analysis.getRunsForAnalysis(analysisId, count);
|
|
11055
11820
|
format(runs.map((r) => ({
|
|
@@ -11074,7 +11839,7 @@ async function listRuns(analysisId, count, cmd) {
|
|
|
11074
11839
|
});
|
|
11075
11840
|
}
|
|
11076
11841
|
async function cancelRun(runId, cmd) {
|
|
11077
|
-
const outputFormat =
|
|
11842
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11078
11843
|
const api = createApiClient();
|
|
11079
11844
|
const run = await api.analysis.cancelRun(runId);
|
|
11080
11845
|
if (outputFormat === "human") {
|
|
@@ -11088,7 +11853,7 @@ async function cancelRun(runId, cmd) {
|
|
|
11088
11853
|
}
|
|
11089
11854
|
}
|
|
11090
11855
|
async function listPresets(cmd) {
|
|
11091
|
-
const outputFormat =
|
|
11856
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11092
11857
|
const api = createApiClient();
|
|
11093
11858
|
const presets = await api.analysis.getPresets();
|
|
11094
11859
|
format(presets.map((p) => ({
|
|
@@ -11113,7 +11878,7 @@ async function listPresets(cmd) {
|
|
|
11113
11878
|
});
|
|
11114
11879
|
}
|
|
11115
11880
|
async function getPreset(presetId, cmd) {
|
|
11116
|
-
const outputFormat =
|
|
11881
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11117
11882
|
const api = createApiClient();
|
|
11118
11883
|
const opt = await api.analysis.getPreset(presetId);
|
|
11119
11884
|
if (!opt.preset) {
|
|
@@ -11123,7 +11888,7 @@ async function getPreset(presetId, cmd) {
|
|
|
11123
11888
|
format(opt.preset, { format: outputFormat });
|
|
11124
11889
|
}
|
|
11125
11890
|
async function savePreset(options, cmd) {
|
|
11126
|
-
const outputFormat =
|
|
11891
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11127
11892
|
const api = createApiClient();
|
|
11128
11893
|
const preset = {
|
|
11129
11894
|
presetId: options.id ?? null,
|
|
@@ -11178,7 +11943,7 @@ function triggerChanges(options) {
|
|
|
11178
11943
|
};
|
|
11179
11944
|
}
|
|
11180
11945
|
async function listTriggers(analysisId, cmd) {
|
|
11181
|
-
const outputFormat =
|
|
11946
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11182
11947
|
const api = createApiClient();
|
|
11183
11948
|
const triggers = await api.analysis.listTriggers(analysisId);
|
|
11184
11949
|
format(triggers.map(triggerRow), {
|
|
@@ -11195,7 +11960,7 @@ async function listTriggers(analysisId, cmd) {
|
|
|
11195
11960
|
});
|
|
11196
11961
|
}
|
|
11197
11962
|
async function createTrigger(analysisId, kind, schedule, cmd, refreshFirst = false) {
|
|
11198
|
-
const outputFormat =
|
|
11963
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11199
11964
|
const upper = kind.toUpperCase();
|
|
11200
11965
|
if (upper !== "ONCE" && upper !== "CRON") {
|
|
11201
11966
|
failure(`Invalid kind "${kind}". Use ONCE or CRON.`);
|
|
@@ -11215,7 +11980,7 @@ async function deleteTrigger(triggerId) {
|
|
|
11215
11980
|
success(`Deleted trigger ${triggerId}.`);
|
|
11216
11981
|
}
|
|
11217
11982
|
async function updateTriggerCmd(triggerId, options, cmd) {
|
|
11218
|
-
const outputFormat =
|
|
11983
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
11219
11984
|
const changes = triggerChanges(options);
|
|
11220
11985
|
const api = createApiClient();
|
|
11221
11986
|
const trigger = await api.analysis.updateTrigger(triggerId, changes);
|
|
@@ -11275,6 +12040,20 @@ function registerAnalyzeCommand(program) {
|
|
|
11275
12040
|
handleError(error);
|
|
11276
12041
|
}
|
|
11277
12042
|
});
|
|
12043
|
+
analyze.command("report").description("Print the report of an analysis as Markdown: the summary and the chapter titles, or one chapter").argument("<id>", "Analysis ID").option("--chapter <title or path>", 'A chapter title, or a path of titles separated by ">" (for example "Age > Correlation")').option("--part <n>", "With --chapter: the part to read of a chapter that comes in parts, from 1 (default: 1)").option("--max-bytes <n>", "Largest answer in bytes; the platform reads 4096 to 262144 (default: 32768)").addHelpText("after", REPORT_HELP).action(async (id, options) => {
|
|
12044
|
+
try {
|
|
12045
|
+
await printReport(id, options);
|
|
12046
|
+
} catch (error) {
|
|
12047
|
+
handleError(error);
|
|
12048
|
+
}
|
|
12049
|
+
});
|
|
12050
|
+
analyze.command("export-model").description("Print the model of a target as a formula or as source code").argument("<id>", "Analysis ID").requiredOption("--language <language>", `One of: ${EXPORT_LANGUAGES.join(", ")}`).option("--target <name>", "The target whose model to export (required when the analysis has several)").addHelpText("after", EXPORT_MODEL_HELP).action(async (id, options) => {
|
|
12051
|
+
try {
|
|
12052
|
+
await printModelExport(id, options);
|
|
12053
|
+
} catch (error) {
|
|
12054
|
+
handleError(error);
|
|
12055
|
+
}
|
|
12056
|
+
});
|
|
11278
12057
|
analyze.command("rerun").description("Queue a fresh run on an existing analysis (asks for anything a run still needs). A run cannot start while the data is still being imported").argument("<id>", "Analysis ID to rerun").action(async (id, _options, cmd) => {
|
|
11279
12058
|
try {
|
|
11280
12059
|
await rerunAnalysis(id, cmd);
|
|
@@ -11605,7 +12384,7 @@ Examples:
|
|
|
11605
12384
|
// src/commands/public/index.ts
|
|
11606
12385
|
var MIN_LIMIT = 1;
|
|
11607
12386
|
var MAX_LIMIT = 500;
|
|
11608
|
-
function
|
|
12387
|
+
function getOutputFormat20(cmd) {
|
|
11609
12388
|
const config = loadConfig();
|
|
11610
12389
|
const globalOpts = cmd.optsWithGlobals();
|
|
11611
12390
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -11657,7 +12436,7 @@ async function readPublicAnalyses(analysis, options) {
|
|
|
11657
12436
|
}
|
|
11658
12437
|
}
|
|
11659
12438
|
async function listPublicAnalyses(options, cmd) {
|
|
11660
|
-
const outputFormat =
|
|
12439
|
+
const outputFormat = getOutputFormat20(cmd);
|
|
11661
12440
|
const limit = parseLimit(options.limit);
|
|
11662
12441
|
const changedSince = options.changedSince === void 0 ? void 0 : parseChangedSince(options.changedSince);
|
|
11663
12442
|
const api = createApiClient();
|
|
@@ -11700,7 +12479,7 @@ function newestRunRecord(run) {
|
|
|
11700
12479
|
};
|
|
11701
12480
|
}
|
|
11702
12481
|
async function showPublicAnalysis(analysisId, cmd) {
|
|
11703
|
-
const outputFormat =
|
|
12482
|
+
const outputFormat = getOutputFormat20(cmd);
|
|
11704
12483
|
const api = createApiClient();
|
|
11705
12484
|
const result = await api.analysis.get(analysisId);
|
|
11706
12485
|
if (!result?.analysis) {
|
|
@@ -11770,7 +12549,7 @@ Examples:
|
|
|
11770
12549
|
|
|
11771
12550
|
// src/commands/license/index.ts
|
|
11772
12551
|
import chalk30 from "chalk";
|
|
11773
|
-
function
|
|
12552
|
+
function getOutputFormat21(cmd) {
|
|
11774
12553
|
const config = loadConfig();
|
|
11775
12554
|
const globalOpts = cmd.optsWithGlobals();
|
|
11776
12555
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -11789,8 +12568,89 @@ function licenseMarks(license) {
|
|
|
11789
12568
|
function stateWord(state) {
|
|
11790
12569
|
return state.toLowerCase();
|
|
11791
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
|
+
}
|
|
11792
12652
|
async function listLicenses(cmd) {
|
|
11793
|
-
const outputFormat =
|
|
12653
|
+
const outputFormat = getOutputFormat21(cmd);
|
|
11794
12654
|
const api = createApiClient();
|
|
11795
12655
|
const licenses = await api.admin.listLicenses();
|
|
11796
12656
|
if (outputFormat === "json") {
|
|
@@ -11825,7 +12685,7 @@ Flags: ${LICENSE_MARKS.map(({ mark, meaning }) => `${mark} ${meaning}`).join(",
|
|
|
11825
12685
|
}
|
|
11826
12686
|
}
|
|
11827
12687
|
async function showLicense(licenseId, cmd) {
|
|
11828
|
-
const outputFormat =
|
|
12688
|
+
const outputFormat = getOutputFormat21(cmd);
|
|
11829
12689
|
const api = createApiClient();
|
|
11830
12690
|
let license;
|
|
11831
12691
|
try {
|
|
@@ -11872,10 +12732,13 @@ async function showLicense(licenseId, cmd) {
|
|
|
11872
12732
|
});
|
|
11873
12733
|
}
|
|
11874
12734
|
function registerLicenseCommands(program) {
|
|
11875
|
-
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", `
|
|
11876
12736
|
Examples:
|
|
11877
12737
|
$ diafunc license list the licenses that can be chosen
|
|
11878
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
|
|
11879
12742
|
$ diafunc project create --visibility PUBLIC --license CC-BY-4.0
|
|
11880
12743
|
$ diafunc analyze visibility <id> PUBLIC --license CC0-1.0
|
|
11881
12744
|
`);
|
|
@@ -11893,11 +12756,97 @@ Examples:
|
|
|
11893
12756
|
handleError(error);
|
|
11894
12757
|
}
|
|
11895
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
|
+
});
|
|
11896
12845
|
}
|
|
11897
12846
|
|
|
11898
12847
|
// src/commands/data-sources/index.ts
|
|
11899
12848
|
import chalk31 from "chalk";
|
|
11900
|
-
function
|
|
12849
|
+
function getOutputFormat22(cmd) {
|
|
11901
12850
|
const config = loadConfig();
|
|
11902
12851
|
const globalOpts = cmd.optsWithGlobals();
|
|
11903
12852
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -11997,7 +12946,7 @@ function resolveProjectId(cmd) {
|
|
|
11997
12946
|
return resolved;
|
|
11998
12947
|
}
|
|
11999
12948
|
async function listDataSources(projectId, cmd) {
|
|
12000
|
-
const outputFormat =
|
|
12949
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12001
12950
|
const api = createApiClient();
|
|
12002
12951
|
const sources = await api.storage.listDataSources(projectId);
|
|
12003
12952
|
if (outputFormat === "human" && sources.length === 0) {
|
|
@@ -12018,13 +12967,13 @@ async function listDataSources(projectId, cmd) {
|
|
|
12018
12967
|
});
|
|
12019
12968
|
}
|
|
12020
12969
|
async function getDataSource(id, cmd) {
|
|
12021
|
-
const outputFormat =
|
|
12970
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12022
12971
|
const api = createApiClient();
|
|
12023
12972
|
const ds = await api.storage.getDataSource(id);
|
|
12024
12973
|
format(ds, { format: outputFormat });
|
|
12025
12974
|
}
|
|
12026
12975
|
async function showDashboard(projectId, cmd) {
|
|
12027
|
-
const outputFormat =
|
|
12976
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12028
12977
|
const api = createApiClient();
|
|
12029
12978
|
const dashboard = await api.storage.getDataSourceDashboard(projectId);
|
|
12030
12979
|
if (outputFormat !== "human") {
|
|
@@ -12100,7 +13049,7 @@ async function createForAnalysis(api, options, human) {
|
|
|
12100
13049
|
return { source, build };
|
|
12101
13050
|
}
|
|
12102
13051
|
async function createDataSource(options, cmd) {
|
|
12103
|
-
const outputFormat =
|
|
13052
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12104
13053
|
const target = createTarget(options);
|
|
12105
13054
|
const api = createApiClient();
|
|
12106
13055
|
if (target === "analysis") {
|
|
@@ -12130,7 +13079,7 @@ async function createDataSource(options, cmd) {
|
|
|
12130
13079
|
}
|
|
12131
13080
|
}
|
|
12132
13081
|
async function updateDataSource(id, options, cmd) {
|
|
12133
|
-
const outputFormat =
|
|
13082
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12134
13083
|
if (options.name === void 0 && options.type === void 0 && (!options.config || options.config.length === 0) && options.scheduleCron === void 0 && !options.clearSchedule) {
|
|
12135
13084
|
throw new Error("Provide at least one of --name, --type, --config, --schedule-cron, or --clear-schedule.");
|
|
12136
13085
|
}
|
|
@@ -12165,7 +13114,7 @@ async function deleteDataSource(id) {
|
|
|
12165
13114
|
success(`Deleted data source ${id}`);
|
|
12166
13115
|
}
|
|
12167
13116
|
async function refreshDataSource(id, cmd) {
|
|
12168
|
-
const outputFormat =
|
|
13117
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12169
13118
|
const api = createApiClient();
|
|
12170
13119
|
const run = await api.storage.refreshDataSource(id);
|
|
12171
13120
|
if (outputFormat === "human") {
|
|
@@ -12176,7 +13125,7 @@ async function refreshDataSource(id, cmd) {
|
|
|
12176
13125
|
}
|
|
12177
13126
|
}
|
|
12178
13127
|
async function listRuns2(id, limit, cmd) {
|
|
12179
|
-
const outputFormat =
|
|
13128
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12180
13129
|
const api = createApiClient();
|
|
12181
13130
|
const runs = await api.storage.listDataSourceRuns(id, limit);
|
|
12182
13131
|
if (outputFormat === "human" && runs.length === 0) {
|
|
@@ -12198,13 +13147,13 @@ async function listRuns2(id, limit, cmd) {
|
|
|
12198
13147
|
});
|
|
12199
13148
|
}
|
|
12200
13149
|
async function getRun(id, runId, cmd) {
|
|
12201
|
-
const outputFormat =
|
|
13150
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12202
13151
|
const api = createApiClient();
|
|
12203
13152
|
const run = await api.storage.getDataSourceRun(id, runId);
|
|
12204
13153
|
format(run, { format: outputFormat });
|
|
12205
13154
|
}
|
|
12206
13155
|
async function listConnectorTypes(cmd) {
|
|
12207
|
-
const outputFormat =
|
|
13156
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12208
13157
|
const api = createApiClient();
|
|
12209
13158
|
const types = await api.storage.listDataSourceConnectorTypes();
|
|
12210
13159
|
if (outputFormat === "human") {
|
|
@@ -12298,7 +13247,7 @@ Examples:
|
|
|
12298
13247
|
|
|
12299
13248
|
// src/commands/table-exporters/index.ts
|
|
12300
13249
|
import chalk32 from "chalk";
|
|
12301
|
-
function
|
|
13250
|
+
function getOutputFormat23(cmd) {
|
|
12302
13251
|
const config = loadConfig();
|
|
12303
13252
|
const globalOpts = cmd.optsWithGlobals();
|
|
12304
13253
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -12307,7 +13256,7 @@ function registerTableExportersCommands(program) {
|
|
|
12307
13256
|
const exporters = program.command("table-exporters").description("Manage user-defined exporters (UDE); admin only");
|
|
12308
13257
|
exporters.command("list").description("List all registered user-defined exporters").action(async (_options, cmd) => {
|
|
12309
13258
|
try {
|
|
12310
|
-
const outputFormat =
|
|
13259
|
+
const outputFormat = getOutputFormat23(cmd);
|
|
12311
13260
|
const api = createApiClient();
|
|
12312
13261
|
const list = await api.storage.listUserDefinedExporters();
|
|
12313
13262
|
if (outputFormat === "json") {
|
|
@@ -12335,7 +13284,7 @@ function registerTableExportersCommands(program) {
|
|
|
12335
13284
|
});
|
|
12336
13285
|
exporters.command("get").description("Show a single user-defined exporter by id").argument("<id>", "Exporter id").action(async (id, _options, cmd) => {
|
|
12337
13286
|
try {
|
|
12338
|
-
const outputFormat =
|
|
13287
|
+
const outputFormat = getOutputFormat23(cmd);
|
|
12339
13288
|
const api = createApiClient();
|
|
12340
13289
|
const list = await api.storage.listUserDefinedExporters();
|
|
12341
13290
|
const exporter = list.find((e) => e.id === id);
|
|
@@ -12350,7 +13299,7 @@ function registerTableExportersCommands(program) {
|
|
|
12350
13299
|
});
|
|
12351
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) => {
|
|
12352
13301
|
try {
|
|
12353
|
-
const outputFormat =
|
|
13302
|
+
const outputFormat = getOutputFormat23(cmd);
|
|
12354
13303
|
const api = createApiClient();
|
|
12355
13304
|
const payload = {
|
|
12356
13305
|
name: options.name,
|
|
@@ -12388,7 +13337,7 @@ function registerTableExportersCommands(program) {
|
|
|
12388
13337
|
// src/commands/skeleton/index.ts
|
|
12389
13338
|
import chalk33 from "chalk";
|
|
12390
13339
|
import * as fs13 from "fs";
|
|
12391
|
-
function
|
|
13340
|
+
function getOutputFormat24(cmd) {
|
|
12392
13341
|
const config = loadConfig();
|
|
12393
13342
|
const globalOpts = cmd.optsWithGlobals();
|
|
12394
13343
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -12437,7 +13386,7 @@ function skeletonTableRow(s) {
|
|
|
12437
13386
|
};
|
|
12438
13387
|
}
|
|
12439
13388
|
async function createSkeleton(options, cmd) {
|
|
12440
|
-
const outputFormat =
|
|
13389
|
+
const outputFormat = getOutputFormat24(cmd);
|
|
12441
13390
|
const projectId = resolveProjectId2(cmd);
|
|
12442
13391
|
const template = resolveTemplate(options.template);
|
|
12443
13392
|
const weight = parseWeight(options.weight);
|
|
@@ -12462,7 +13411,7 @@ async function createSkeleton(options, cmd) {
|
|
|
12462
13411
|
}
|
|
12463
13412
|
}
|
|
12464
13413
|
async function listSkeletons(cmd) {
|
|
12465
|
-
const outputFormat =
|
|
13414
|
+
const outputFormat = getOutputFormat24(cmd);
|
|
12466
13415
|
const projectId = resolveProjectId2(cmd);
|
|
12467
13416
|
const api = createApiClient();
|
|
12468
13417
|
const skeletons = await api.storage.listSkeletons(projectId);
|
|
@@ -12476,13 +13425,13 @@ async function listSkeletons(cmd) {
|
|
|
12476
13425
|
});
|
|
12477
13426
|
}
|
|
12478
13427
|
async function getSkeleton(id, cmd) {
|
|
12479
|
-
const outputFormat =
|
|
13428
|
+
const outputFormat = getOutputFormat24(cmd);
|
|
12480
13429
|
const api = createApiClient();
|
|
12481
13430
|
const skeleton = await api.storage.getSkeleton(id);
|
|
12482
13431
|
format(skeleton, { format: outputFormat });
|
|
12483
13432
|
}
|
|
12484
13433
|
async function updateSkeleton(id, options, cmd) {
|
|
12485
|
-
const outputFormat =
|
|
13434
|
+
const outputFormat = getOutputFormat24(cmd);
|
|
12486
13435
|
if (options.name === void 0 && options.template === void 0 && options.weight === void 0) {
|
|
12487
13436
|
throw new Error("Provide at least one of --name, --template, --weight.");
|
|
12488
13437
|
}
|
|
@@ -12846,7 +13795,7 @@ function registerWhoamiCommand(program) {
|
|
|
12846
13795
|
|
|
12847
13796
|
// src/commands/utilization/index.ts
|
|
12848
13797
|
import chalk35 from "chalk";
|
|
12849
|
-
function
|
|
13798
|
+
function getOutputFormat25(cmd) {
|
|
12850
13799
|
const config = loadConfig();
|
|
12851
13800
|
const globalOpts = cmd.optsWithGlobals();
|
|
12852
13801
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -12911,7 +13860,7 @@ Examples:
|
|
|
12911
13860
|
`);
|
|
12912
13861
|
util.command("actual", { isDefault: true }).description("Show current utilization (default subcommand)").action(async (_options, cmd) => {
|
|
12913
13862
|
try {
|
|
12914
|
-
const outputFormat =
|
|
13863
|
+
const outputFormat = getOutputFormat25(cmd);
|
|
12915
13864
|
const api = createApiClient();
|
|
12916
13865
|
const utilization = await api.admin.getActualUtilization();
|
|
12917
13866
|
if (outputFormat === "human") {
|
|
@@ -12925,7 +13874,7 @@ Examples:
|
|
|
12925
13874
|
});
|
|
12926
13875
|
util.command("history").description("Show what each day of the billing cycle cost").action(async (_options, cmd) => {
|
|
12927
13876
|
try {
|
|
12928
|
-
const outputFormat =
|
|
13877
|
+
const outputFormat = getOutputFormat25(cmd);
|
|
12929
13878
|
const api = createApiClient();
|
|
12930
13879
|
const history = await api.admin.getUtilizationHistory();
|
|
12931
13880
|
if (outputFormat === "human") {
|
|
@@ -12946,7 +13895,7 @@ Examples:
|
|
|
12946
13895
|
}
|
|
12947
13896
|
|
|
12948
13897
|
// src/commands/entity-branch/index.ts
|
|
12949
|
-
function
|
|
13898
|
+
function getOutputFormat26(cmd) {
|
|
12950
13899
|
const config = loadConfig();
|
|
12951
13900
|
const globalOpts = cmd.optsWithGlobals();
|
|
12952
13901
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -12959,7 +13908,7 @@ function registerEntityBranchCommands(program) {
|
|
|
12959
13908
|
const eb = program.command("entity-branch").description("Manage entity branches (parallel versions of a single entity)");
|
|
12960
13909
|
eb.command("list").description("List branches of an entity").argument("<ref>", "Entity reference (projectId/branch/entityId)").action(async (ref, _options, cmd) => {
|
|
12961
13910
|
try {
|
|
12962
|
-
const outputFormat =
|
|
13911
|
+
const outputFormat = getOutputFormat26(cmd);
|
|
12963
13912
|
const overrides = getOverrides11(cmd);
|
|
12964
13913
|
const resolved = parseEntityReference(ref, overrides);
|
|
12965
13914
|
const api = createApiClient();
|
|
@@ -13011,7 +13960,7 @@ function forReader(subscription) {
|
|
|
13011
13960
|
Object.entries(subscription).filter(([key]) => !BILLING_INTERNALS.has(key))
|
|
13012
13961
|
);
|
|
13013
13962
|
}
|
|
13014
|
-
function
|
|
13963
|
+
function getOutputFormat27(cmd) {
|
|
13015
13964
|
const config = loadConfig();
|
|
13016
13965
|
const globalOpts = cmd.optsWithGlobals();
|
|
13017
13966
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -13025,7 +13974,7 @@ Examples:
|
|
|
13025
13974
|
sub.command("current", { isDefault: true }).description("Show the current subscription").action(async (_options, cmd) => {
|
|
13026
13975
|
try {
|
|
13027
13976
|
const api = createApiClient();
|
|
13028
|
-
const outputFormat =
|
|
13977
|
+
const outputFormat = getOutputFormat27(cmd);
|
|
13029
13978
|
const s = await api.admin.getCurrentSubscription();
|
|
13030
13979
|
format(outputFormat === "human" ? forReader(s) : s, { format: outputFormat });
|
|
13031
13980
|
} catch (error) {
|
|
@@ -13035,7 +13984,7 @@ Examples:
|
|
|
13035
13984
|
sub.command("next").description("Show the next (upcoming) subscription").action(async (_options, cmd) => {
|
|
13036
13985
|
try {
|
|
13037
13986
|
const api = createApiClient();
|
|
13038
|
-
const outputFormat =
|
|
13987
|
+
const outputFormat = getOutputFormat27(cmd);
|
|
13039
13988
|
const s = await api.admin.getNextSubscription();
|
|
13040
13989
|
format(outputFormat === "human" ? forReader(s) : s, { format: outputFormat });
|
|
13041
13990
|
} catch (error) {
|
|
@@ -13046,7 +13995,7 @@ Examples:
|
|
|
13046
13995
|
try {
|
|
13047
13996
|
const api = createApiClient();
|
|
13048
13997
|
const plans = await api.admin.getSubscriptionPlans(subscriptionToken);
|
|
13049
|
-
format(plans, { format:
|
|
13998
|
+
format(plans, { format: getOutputFormat27(cmd) });
|
|
13050
13999
|
} catch (error) {
|
|
13051
14000
|
handleError(error);
|
|
13052
14001
|
}
|
|
@@ -13055,7 +14004,7 @@ Examples:
|
|
|
13055
14004
|
|
|
13056
14005
|
// src/commands/invoice/index.ts
|
|
13057
14006
|
import * as fs14 from "fs";
|
|
13058
|
-
function
|
|
14007
|
+
function getOutputFormat28(cmd) {
|
|
13059
14008
|
const config = loadConfig();
|
|
13060
14009
|
const globalOpts = cmd.optsWithGlobals();
|
|
13061
14010
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -13072,7 +14021,7 @@ Examples:
|
|
|
13072
14021
|
const api = createApiClient();
|
|
13073
14022
|
const invoices = await api.admin.getInvoices();
|
|
13074
14023
|
format(invoices, {
|
|
13075
|
-
format:
|
|
14024
|
+
format: getOutputFormat28(cmd),
|
|
13076
14025
|
columns: [
|
|
13077
14026
|
{ key: "invoiceNumber", header: "number" },
|
|
13078
14027
|
{ key: "issued", kind: "date" },
|
|
@@ -13202,7 +14151,7 @@ function registerShellCommand(program) {
|
|
|
13202
14151
|
});
|
|
13203
14152
|
const api = createApiClient();
|
|
13204
14153
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
13205
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
14154
|
+
const { getUpdateNotice } = await import("./update-check-JWT4C4O5.js");
|
|
13206
14155
|
const resolvedLanguage = await resolveLanguage(api, fnRef.projectId, options.language);
|
|
13207
14156
|
console.log(chalk36.bold("Diafunc shell") + chalk36.dim(` \xB7 function ${fnRef.entityId} \xB7 ${resolvedLanguage}`));
|
|
13208
14157
|
console.log(chalk36.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
|
|
@@ -14063,4 +15012,4 @@ export {
|
|
|
14063
15012
|
PromptCanceled,
|
|
14064
15013
|
createProgram
|
|
14065
15014
|
};
|
|
14066
|
-
//# sourceMappingURL=chunk-
|
|
15015
|
+
//# sourceMappingURL=chunk-AH6DCAHU.js.map
|