@diafunc/cli 0.8.1 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/bin/diafunc.js +3 -3
- package/dist/{chunk-WHWVHDRF.js → chunk-2WJQPO4V.js} +1011 -554
- package/dist/chunk-2WJQPO4V.js.map +1 -0
- package/dist/{chunk-SCDOFUA4.js → chunk-67PBARIH.js} +2 -2
- package/dist/{chunk-GIWRWVU6.js → chunk-VKUAIYZZ.js} +2 -2
- package/dist/{chunk-GIWRWVU6.js.map → chunk-VKUAIYZZ.js.map} +1 -1
- package/dist/src/index.js +2 -2
- package/dist/update-check-L55QNPYQ.js +8 -0
- package/package.json +1 -1
- package/dist/chunk-WHWVHDRF.js.map +0 -1
- package/dist/update-check-2X2AIL52.js +0 -8
- /package/dist/{chunk-SCDOFUA4.js.map → chunk-67PBARIH.js.map} +0 -0
- /package/dist/{update-check-2X2AIL52.js.map → update-check-L55QNPYQ.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
package_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VKUAIYZZ.js";
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
6
6
|
import { Command } from "commander";
|
|
@@ -71,7 +71,7 @@ var ApiError = class _ApiError extends Error {
|
|
|
71
71
|
case 401:
|
|
72
72
|
return `Authentication failed. Run 'diafunc auth login' to configure your credentials.`;
|
|
73
73
|
case 403:
|
|
74
|
-
return `Permission denied
|
|
74
|
+
return this.message ? `Permission denied: ${this.message}${this.details ? ` (${this.details})` : ""}` : `Permission denied. Your token may not have the required scope.`;
|
|
75
75
|
case 404:
|
|
76
76
|
return `Not found: ${this.message}`;
|
|
77
77
|
case 409:
|
|
@@ -243,11 +243,15 @@ ${bodyPreview}`);
|
|
|
243
243
|
if (!response.ok) {
|
|
244
244
|
throw await parseErrorBody(response);
|
|
245
245
|
}
|
|
246
|
+
if (response.status === 204) {
|
|
247
|
+
return void 0;
|
|
248
|
+
}
|
|
246
249
|
const contentType = response.headers.get("content-type") ?? "";
|
|
250
|
+
const text = await response.text();
|
|
247
251
|
if (contentType.includes("application/json")) {
|
|
248
|
-
return
|
|
252
|
+
return text ? JSON.parse(text) : void 0;
|
|
249
253
|
}
|
|
250
|
-
return
|
|
254
|
+
return text;
|
|
251
255
|
},
|
|
252
256
|
async requestRaw(opts) {
|
|
253
257
|
const response = await doRequest(opts);
|
|
@@ -411,91 +415,194 @@ function createAdminService(client) {
|
|
|
411
415
|
path: `/api-tokens/${encodeURIComponent(tokenId)}`
|
|
412
416
|
});
|
|
413
417
|
},
|
|
414
|
-
//
|
|
415
|
-
async
|
|
418
|
+
// Teams
|
|
419
|
+
async listMyTeams() {
|
|
416
420
|
return client.request({
|
|
417
421
|
method: "GET",
|
|
418
422
|
service: SERVICE,
|
|
419
|
-
path: "/
|
|
423
|
+
path: "/me/teams"
|
|
420
424
|
});
|
|
421
425
|
},
|
|
422
|
-
async
|
|
426
|
+
async getTeam(teamId) {
|
|
423
427
|
return client.request({
|
|
424
428
|
method: "GET",
|
|
425
429
|
service: SERVICE,
|
|
426
|
-
path:
|
|
430
|
+
path: `/teams/${encodeURIComponent(teamId)}`
|
|
427
431
|
});
|
|
428
432
|
},
|
|
429
|
-
async
|
|
433
|
+
async setActiveTeam(teamId) {
|
|
430
434
|
return client.request({
|
|
431
|
-
method: "
|
|
435
|
+
method: "POST",
|
|
432
436
|
service: SERVICE,
|
|
433
|
-
path: `/
|
|
437
|
+
path: `/me/active-team/${encodeURIComponent(teamId)}`
|
|
434
438
|
});
|
|
435
439
|
},
|
|
436
|
-
async
|
|
440
|
+
async startTeamCheckout(request) {
|
|
437
441
|
return client.request({
|
|
438
442
|
method: "POST",
|
|
439
443
|
service: SERVICE,
|
|
440
|
-
path: "/
|
|
441
|
-
body:
|
|
444
|
+
path: "/teams/checkout",
|
|
445
|
+
body: request
|
|
442
446
|
});
|
|
443
447
|
},
|
|
444
|
-
async
|
|
448
|
+
async createTeamPortalSession(teamId, returnUrl) {
|
|
445
449
|
return client.request({
|
|
446
|
-
method: "
|
|
450
|
+
method: "POST",
|
|
447
451
|
service: SERVICE,
|
|
448
|
-
path:
|
|
449
|
-
body:
|
|
452
|
+
path: `/teams/${encodeURIComponent(teamId)}/portal-session`,
|
|
453
|
+
body: { returnUrl }
|
|
450
454
|
});
|
|
451
455
|
},
|
|
452
|
-
async
|
|
456
|
+
async cancelTeam(teamId) {
|
|
453
457
|
return client.request({
|
|
454
458
|
method: "DELETE",
|
|
455
459
|
service: SERVICE,
|
|
456
|
-
path: `/
|
|
460
|
+
path: `/teams/${encodeURIComponent(teamId)}`
|
|
461
|
+
});
|
|
462
|
+
},
|
|
463
|
+
async getTeamUsage(teamId) {
|
|
464
|
+
return client.request({
|
|
465
|
+
method: "GET",
|
|
466
|
+
service: SERVICE,
|
|
467
|
+
path: `/teams/${encodeURIComponent(teamId)}/usage`
|
|
457
468
|
});
|
|
458
469
|
},
|
|
459
|
-
|
|
470
|
+
// Team members
|
|
471
|
+
async listTeamMembers(teamId) {
|
|
460
472
|
return client.request({
|
|
461
473
|
method: "GET",
|
|
462
474
|
service: SERVICE,
|
|
463
|
-
path: `/
|
|
475
|
+
path: `/teams/${encodeURIComponent(teamId)}/members`
|
|
464
476
|
});
|
|
465
477
|
},
|
|
466
|
-
async
|
|
478
|
+
async inviteTeamMember(teamId, email, role) {
|
|
467
479
|
return client.request({
|
|
468
480
|
method: "POST",
|
|
469
481
|
service: SERVICE,
|
|
470
|
-
path: `/
|
|
482
|
+
path: `/teams/${encodeURIComponent(teamId)}/members/invite`,
|
|
483
|
+
body: { email, role }
|
|
471
484
|
});
|
|
472
485
|
},
|
|
473
|
-
async
|
|
486
|
+
async removeTeamMember(teamId, userId) {
|
|
474
487
|
return client.request({
|
|
475
488
|
method: "DELETE",
|
|
476
489
|
service: SERVICE,
|
|
477
|
-
path: `/
|
|
490
|
+
path: `/teams/${encodeURIComponent(teamId)}/members/${encodeURIComponent(userId)}`
|
|
478
491
|
});
|
|
479
492
|
},
|
|
480
|
-
async
|
|
493
|
+
async leaveTeam(teamId) {
|
|
494
|
+
return client.request({
|
|
495
|
+
method: "DELETE",
|
|
496
|
+
service: SERVICE,
|
|
497
|
+
path: `/me/teams/${encodeURIComponent(teamId)}`
|
|
498
|
+
});
|
|
499
|
+
},
|
|
500
|
+
// Team invitations
|
|
501
|
+
async listTeamInvitations(teamId) {
|
|
481
502
|
return client.request({
|
|
482
503
|
method: "GET",
|
|
483
504
|
service: SERVICE,
|
|
484
|
-
path: `/
|
|
505
|
+
path: `/teams/${encodeURIComponent(teamId)}/invitations`
|
|
485
506
|
});
|
|
486
507
|
},
|
|
487
|
-
async
|
|
508
|
+
async revokeTeamInvitation(teamId, invitationId) {
|
|
509
|
+
return client.request({
|
|
510
|
+
method: "DELETE",
|
|
511
|
+
service: SERVICE,
|
|
512
|
+
path: `/teams/${encodeURIComponent(teamId)}/invitations/${encodeURIComponent(invitationId)}`
|
|
513
|
+
});
|
|
514
|
+
},
|
|
515
|
+
async resendTeamInvitation(teamId, invitationId) {
|
|
488
516
|
return client.request({
|
|
489
517
|
method: "POST",
|
|
490
518
|
service: SERVICE,
|
|
491
|
-
path: `/
|
|
519
|
+
path: `/teams/${encodeURIComponent(teamId)}/invitations/${encodeURIComponent(invitationId)}/resend`
|
|
492
520
|
});
|
|
493
521
|
},
|
|
494
|
-
async
|
|
522
|
+
async acceptTeamInvitation(token) {
|
|
523
|
+
return client.request({
|
|
524
|
+
method: "POST",
|
|
525
|
+
service: SERVICE,
|
|
526
|
+
path: `/invitations/${encodeURIComponent(token)}/accept`
|
|
527
|
+
});
|
|
528
|
+
},
|
|
529
|
+
// Seats and extension packs
|
|
530
|
+
async previewTeamSeatCount(teamId, seatCount) {
|
|
531
|
+
return client.request({
|
|
532
|
+
method: "POST",
|
|
533
|
+
service: SERVICE,
|
|
534
|
+
path: `/teams/${encodeURIComponent(teamId)}/seat-count/preview`,
|
|
535
|
+
body: { seatCount }
|
|
536
|
+
});
|
|
537
|
+
},
|
|
538
|
+
async updateTeamSeatCount(teamId, seatCount) {
|
|
539
|
+
return client.request({
|
|
540
|
+
method: "POST",
|
|
541
|
+
service: SERVICE,
|
|
542
|
+
path: `/teams/${encodeURIComponent(teamId)}/seat-count`,
|
|
543
|
+
body: { seatCount }
|
|
544
|
+
});
|
|
545
|
+
},
|
|
546
|
+
async previewTeamPackCount(teamId, packCount) {
|
|
547
|
+
return client.request({
|
|
548
|
+
method: "POST",
|
|
549
|
+
service: SERVICE,
|
|
550
|
+
path: `/teams/${encodeURIComponent(teamId)}/pack-count/preview`,
|
|
551
|
+
body: { packCount }
|
|
552
|
+
});
|
|
553
|
+
},
|
|
554
|
+
async updateTeamPackCount(teamId, packCount) {
|
|
555
|
+
return client.request({
|
|
556
|
+
method: "POST",
|
|
557
|
+
service: SERVICE,
|
|
558
|
+
path: `/teams/${encodeURIComponent(teamId)}/pack-count`,
|
|
559
|
+
body: { packCount }
|
|
560
|
+
});
|
|
561
|
+
},
|
|
562
|
+
// Ownership transfer
|
|
563
|
+
async initiateOwnershipTransfer(teamId, newOwnerUserId) {
|
|
564
|
+
return client.request({
|
|
565
|
+
method: "POST",
|
|
566
|
+
service: SERVICE,
|
|
567
|
+
path: `/teams/${encodeURIComponent(teamId)}/ownership-transfer`,
|
|
568
|
+
body: { newOwnerUserId }
|
|
569
|
+
});
|
|
570
|
+
},
|
|
571
|
+
async getOwnershipTransfer(teamId) {
|
|
572
|
+
return client.request({
|
|
573
|
+
method: "GET",
|
|
574
|
+
service: SERVICE,
|
|
575
|
+
path: `/teams/${encodeURIComponent(teamId)}/ownership-transfer`
|
|
576
|
+
});
|
|
577
|
+
},
|
|
578
|
+
async acceptOwnershipTransfer(teamId) {
|
|
579
|
+
return client.request({
|
|
580
|
+
method: "POST",
|
|
581
|
+
service: SERVICE,
|
|
582
|
+
path: `/teams/${encodeURIComponent(teamId)}/ownership-transfer/accept`
|
|
583
|
+
});
|
|
584
|
+
},
|
|
585
|
+
async cancelOwnershipTransfer(teamId) {
|
|
495
586
|
return client.request({
|
|
496
587
|
method: "DELETE",
|
|
497
588
|
service: SERVICE,
|
|
498
|
-
path: `/
|
|
589
|
+
path: `/teams/${encodeURIComponent(teamId)}/ownership-transfer`
|
|
590
|
+
});
|
|
591
|
+
},
|
|
592
|
+
// Team contracts (super-admin only)
|
|
593
|
+
async issueTeamContract(teamId, request) {
|
|
594
|
+
return client.request({
|
|
595
|
+
method: "POST",
|
|
596
|
+
service: SERVICE,
|
|
597
|
+
path: `/teams/${encodeURIComponent(teamId)}/contract`,
|
|
598
|
+
body: request
|
|
599
|
+
});
|
|
600
|
+
},
|
|
601
|
+
async getTeamContract(teamId) {
|
|
602
|
+
return client.request({
|
|
603
|
+
method: "GET",
|
|
604
|
+
service: SERVICE,
|
|
605
|
+
path: `/teams/${encodeURIComponent(teamId)}/contract`
|
|
499
606
|
});
|
|
500
607
|
},
|
|
501
608
|
// Settings
|
|
@@ -774,12 +881,16 @@ function registerLogoutCommand(parent) {
|
|
|
774
881
|
}
|
|
775
882
|
|
|
776
883
|
// src/commands/auth/status.ts
|
|
884
|
+
import chalk6 from "chalk";
|
|
885
|
+
|
|
886
|
+
// src/output/formatter.ts
|
|
777
887
|
import chalk5 from "chalk";
|
|
778
888
|
|
|
779
889
|
// src/output/human.ts
|
|
780
890
|
import chalk4 from "chalk";
|
|
781
891
|
import Table from "cli-table3";
|
|
782
|
-
function formatHuman(data, columns) {
|
|
892
|
+
function formatHuman(data, columns, dateColumns) {
|
|
893
|
+
const isDate = (key) => dateColumns?.includes(key) ?? false;
|
|
783
894
|
if (Array.isArray(data)) {
|
|
784
895
|
if (data.length === 0) {
|
|
785
896
|
console.log(chalk4.dim("No results."));
|
|
@@ -792,7 +903,7 @@ function formatHuman(data, columns) {
|
|
|
792
903
|
});
|
|
793
904
|
for (const row of data) {
|
|
794
905
|
const r = row;
|
|
795
|
-
table.push(cols.map((c) => formatValue(r[c])));
|
|
906
|
+
table.push(cols.map((c) => formatValue(r[c], isDate(c))));
|
|
796
907
|
}
|
|
797
908
|
console.log(table.toString());
|
|
798
909
|
} else if (data && typeof data === "object") {
|
|
@@ -801,17 +912,27 @@ function formatHuman(data, columns) {
|
|
|
801
912
|
style: { head: [], border: [] }
|
|
802
913
|
});
|
|
803
914
|
for (const [key, value] of Object.entries(obj)) {
|
|
804
|
-
table.push({ [chalk4.bold(key)]: formatValue(value) });
|
|
915
|
+
table.push({ [chalk4.bold(key)]: formatValue(value, isDate(key)) });
|
|
805
916
|
}
|
|
806
917
|
console.log(table.toString());
|
|
807
918
|
} else {
|
|
808
919
|
console.log(String(data));
|
|
809
920
|
}
|
|
810
921
|
}
|
|
811
|
-
function formatValue(value) {
|
|
922
|
+
function formatValue(value, asDate = false) {
|
|
812
923
|
if (value === null || value === void 0) return chalk4.dim("\u2014");
|
|
924
|
+
if (asDate) return formatInstant(value);
|
|
813
925
|
if (typeof value === "boolean") return value ? chalk4.green("true") : chalk4.red("false");
|
|
814
926
|
if (typeof value === "number") return chalk4.cyan(String(value));
|
|
927
|
+
if (typeof value === "object") return JSON.stringify(value);
|
|
928
|
+
return String(value);
|
|
929
|
+
}
|
|
930
|
+
function formatInstant(value) {
|
|
931
|
+
if (value === null || value === void 0) return chalk4.dim("\u2014");
|
|
932
|
+
if (typeof value === "number") {
|
|
933
|
+
const d = new Date(value);
|
|
934
|
+
return Number.isNaN(d.getTime()) ? String(value) : d.toISOString().replace("T", " ").slice(0, 19);
|
|
935
|
+
}
|
|
815
936
|
return String(value);
|
|
816
937
|
}
|
|
817
938
|
|
|
@@ -828,17 +949,22 @@ function formatTable(data, columns) {
|
|
|
828
949
|
console.log(cols.join(" "));
|
|
829
950
|
for (const row of data) {
|
|
830
951
|
const r = row;
|
|
831
|
-
console.log(cols.map((c) =>
|
|
952
|
+
console.log(cols.map((c) => cell(r[c])).join(" "));
|
|
832
953
|
}
|
|
833
954
|
} else if (data && typeof data === "object") {
|
|
834
955
|
const obj = data;
|
|
835
956
|
for (const [key, value] of Object.entries(obj)) {
|
|
836
|
-
console.log(`${key} ${
|
|
957
|
+
console.log(`${key} ${cell(value)}`);
|
|
837
958
|
}
|
|
838
959
|
} else {
|
|
839
960
|
console.log(String(data));
|
|
840
961
|
}
|
|
841
962
|
}
|
|
963
|
+
function cell(value) {
|
|
964
|
+
if (value === null || value === void 0) return "";
|
|
965
|
+
if (typeof value === "object") return JSON.stringify(value);
|
|
966
|
+
return String(value);
|
|
967
|
+
}
|
|
842
968
|
|
|
843
969
|
// src/output/formatter.ts
|
|
844
970
|
function format(data, options) {
|
|
@@ -851,10 +977,17 @@ function format(data, options) {
|
|
|
851
977
|
break;
|
|
852
978
|
case "human":
|
|
853
979
|
default:
|
|
854
|
-
formatHuman(data, options.columns);
|
|
980
|
+
formatHuman(data, options.columns, options.dateColumns);
|
|
855
981
|
break;
|
|
856
982
|
}
|
|
857
983
|
}
|
|
984
|
+
function formatMessage(message, options) {
|
|
985
|
+
if (options.format === "json") {
|
|
986
|
+
formatJson({ message });
|
|
987
|
+
} else {
|
|
988
|
+
console.log(chalk5.green(message));
|
|
989
|
+
}
|
|
990
|
+
}
|
|
858
991
|
|
|
859
992
|
// src/commands/auth/status.ts
|
|
860
993
|
function registerStatusCommand(parent) {
|
|
@@ -868,7 +1001,7 @@ function registerStatusCommand(parent) {
|
|
|
868
1001
|
if (outputFormat === "json") {
|
|
869
1002
|
console.log(JSON.stringify({ authenticated: false, profile: config.currentProfile }));
|
|
870
1003
|
} else {
|
|
871
|
-
console.log(
|
|
1004
|
+
console.log(chalk6.yellow("Not authenticated."), `Run 'diafunc auth login' to configure credentials.`);
|
|
872
1005
|
console.log(` Profile: ${config.currentProfile}`);
|
|
873
1006
|
console.log(` Endpoint: ${profile?.endpoint ?? "not configured"}`);
|
|
874
1007
|
}
|
|
@@ -896,7 +1029,7 @@ function registerStatusCommand(parent) {
|
|
|
896
1029
|
}
|
|
897
1030
|
|
|
898
1031
|
// src/commands/auth/token.ts
|
|
899
|
-
import
|
|
1032
|
+
import chalk7 from "chalk";
|
|
900
1033
|
|
|
901
1034
|
// src/client/services/analysis.ts
|
|
902
1035
|
var SERVICE2 = "analyses";
|
|
@@ -2152,6 +2285,7 @@ function createApiClient(options = {}) {
|
|
|
2152
2285
|
}
|
|
2153
2286
|
|
|
2154
2287
|
// src/commands/auth/token.ts
|
|
2288
|
+
var VALID_RESOURCE_TYPES = ["project", "team"];
|
|
2155
2289
|
var VALID_SCOPES = [
|
|
2156
2290
|
"project:read",
|
|
2157
2291
|
"project:write",
|
|
@@ -2162,15 +2296,23 @@ var VALID_SCOPES = [
|
|
|
2162
2296
|
];
|
|
2163
2297
|
function registerTokenCommands(parent) {
|
|
2164
2298
|
const token = parent.command("token").description("Manage API tokens");
|
|
2165
|
-
token.command("create").description("Create a new API token").requiredOption("--name <name>", "Token name").requiredOption("--resource <id>", "Resource ID (project or
|
|
2299
|
+
token.command("create").description("Create a new API token").requiredOption("--name <name>", "Token name").requiredOption("--resource <id>", "Resource ID (project or team)").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").action(async (options, cmd) => {
|
|
2166
2300
|
try {
|
|
2167
2301
|
const config = loadConfig();
|
|
2168
2302
|
const globalOpts = cmd.optsWithGlobals();
|
|
2169
2303
|
const outputFormat = globalOpts.output ?? config.defaults.output ?? "human";
|
|
2304
|
+
const resourceType = options.resourceType.trim().toLowerCase();
|
|
2305
|
+
if (!VALID_RESOURCE_TYPES.includes(resourceType)) {
|
|
2306
|
+
console.error(
|
|
2307
|
+
chalk7.red(`Invalid resource type: "${options.resourceType}".`),
|
|
2308
|
+
`Valid resource types: ${VALID_RESOURCE_TYPES.join(", ")}`
|
|
2309
|
+
);
|
|
2310
|
+
process.exit(1);
|
|
2311
|
+
}
|
|
2170
2312
|
const scopes = options.scopes.split(",").map((s) => s.trim());
|
|
2171
2313
|
for (const scope of scopes) {
|
|
2172
2314
|
if (!VALID_SCOPES.includes(scope)) {
|
|
2173
|
-
console.error(
|
|
2315
|
+
console.error(chalk7.red(`Invalid scope: "${scope}".`), `Valid scopes: ${VALID_SCOPES.join(", ")}`);
|
|
2174
2316
|
process.exit(1);
|
|
2175
2317
|
}
|
|
2176
2318
|
}
|
|
@@ -2178,19 +2320,19 @@ function registerTokenCommands(parent) {
|
|
|
2178
2320
|
const result = await api.admin.createApiToken({
|
|
2179
2321
|
name: options.name,
|
|
2180
2322
|
resourceId: options.resource,
|
|
2181
|
-
resourceType
|
|
2323
|
+
resourceType,
|
|
2182
2324
|
scopes,
|
|
2183
2325
|
validityDays: parseInt(options.days, 10)
|
|
2184
2326
|
});
|
|
2185
2327
|
if (outputFormat === "human") {
|
|
2186
|
-
console.log(
|
|
2328
|
+
console.log(chalk7.green("API token created successfully."));
|
|
2187
2329
|
console.log();
|
|
2188
|
-
console.log(` Token: ${
|
|
2330
|
+
console.log(` Token: ${chalk7.bold(result.token)}`);
|
|
2189
2331
|
console.log(` Token ID: ${result.tokenId}`);
|
|
2190
2332
|
console.log(` Name: ${result.name}`);
|
|
2191
2333
|
console.log(` Expires: ${result.expiresAt}`);
|
|
2192
2334
|
console.log();
|
|
2193
|
-
console.log(
|
|
2335
|
+
console.log(chalk7.yellow("Save this token \u2014 it will not be shown again."));
|
|
2194
2336
|
} else {
|
|
2195
2337
|
format(result, { format: outputFormat });
|
|
2196
2338
|
}
|
|
@@ -2217,7 +2359,7 @@ function registerTokenCommands(parent) {
|
|
|
2217
2359
|
try {
|
|
2218
2360
|
const api = createApiClient();
|
|
2219
2361
|
await api.admin.revokeApiToken(tokenId);
|
|
2220
|
-
console.log(
|
|
2362
|
+
console.log(chalk7.green(`Token ${tokenId} revoked.`));
|
|
2221
2363
|
} catch (error) {
|
|
2222
2364
|
handleError(error);
|
|
2223
2365
|
}
|
|
@@ -2234,20 +2376,20 @@ function registerAuthCommands(program) {
|
|
|
2234
2376
|
}
|
|
2235
2377
|
|
|
2236
2378
|
// src/commands/config/index.ts
|
|
2237
|
-
import
|
|
2379
|
+
import chalk8 from "chalk";
|
|
2238
2380
|
function registerConfigCommands(program) {
|
|
2239
2381
|
const config = program.command("config").description("Manage CLI configuration");
|
|
2240
2382
|
config.command("set").description("Set a configuration value").argument("<key>", "Config key (e.g., defaults.project, defaults.branch, defaults.output)").argument("<value>", "Config value").action((key, value) => {
|
|
2241
2383
|
const cfg = loadConfig();
|
|
2242
2384
|
setNestedValue(cfg, key, value);
|
|
2243
2385
|
saveConfig(cfg);
|
|
2244
|
-
console.log(
|
|
2386
|
+
console.log(chalk8.green(`Set ${key} = ${value}`));
|
|
2245
2387
|
});
|
|
2246
2388
|
config.command("get").description("Get a configuration value").argument("<key>", "Config key").action((key) => {
|
|
2247
2389
|
const cfg = loadConfig();
|
|
2248
2390
|
const value = getNestedValue(cfg, key);
|
|
2249
2391
|
if (value === void 0) {
|
|
2250
|
-
console.log(
|
|
2392
|
+
console.log(chalk8.dim("(not set)"));
|
|
2251
2393
|
} else {
|
|
2252
2394
|
console.log(String(value));
|
|
2253
2395
|
}
|
|
@@ -2257,20 +2399,20 @@ function registerConfigCommands(program) {
|
|
|
2257
2399
|
const globalOpts = cmd.optsWithGlobals();
|
|
2258
2400
|
const outputFormat = globalOpts.output ?? "human";
|
|
2259
2401
|
if (outputFormat === "human") {
|
|
2260
|
-
console.log(
|
|
2261
|
-
console.log(
|
|
2402
|
+
console.log(chalk8.bold("Config file:"), CONFIG_FILE);
|
|
2403
|
+
console.log(chalk8.bold("Active profile:"), cfg.currentProfile);
|
|
2262
2404
|
console.log();
|
|
2263
|
-
console.log(
|
|
2405
|
+
console.log(chalk8.bold("Profiles:"));
|
|
2264
2406
|
for (const [name, profile2] of Object.entries(cfg.profiles)) {
|
|
2265
|
-
const active = name === cfg.currentProfile ?
|
|
2407
|
+
const active = name === cfg.currentProfile ? chalk8.green(" (active)") : "";
|
|
2266
2408
|
const authType = profile2.auth?.type ?? "none";
|
|
2267
|
-
console.log(` ${
|
|
2409
|
+
console.log(` ${chalk8.bold(name)}${active}`);
|
|
2268
2410
|
console.log(` Endpoint: ${profile2.endpoint}`);
|
|
2269
2411
|
console.log(` Auth: ${authType}`);
|
|
2270
2412
|
}
|
|
2271
2413
|
if (Object.keys(cfg.defaults).length > 0) {
|
|
2272
2414
|
console.log();
|
|
2273
|
-
console.log(
|
|
2415
|
+
console.log(chalk8.bold("Defaults:"));
|
|
2274
2416
|
for (const [key, value] of Object.entries(cfg.defaults)) {
|
|
2275
2417
|
console.log(` ${key}: ${value}`);
|
|
2276
2418
|
}
|
|
@@ -2283,7 +2425,7 @@ function registerConfigCommands(program) {
|
|
|
2283
2425
|
profile.command("add").description("Add a new profile").argument("<name>", "Profile name").option("--endpoint <url>", "API endpoint URL", "https://diafunc.com").option("--token <token>", "API token to store").action((name, options) => {
|
|
2284
2426
|
const cfg = loadConfig();
|
|
2285
2427
|
if (cfg.profiles[name]) {
|
|
2286
|
-
console.error(
|
|
2428
|
+
console.error(chalk8.red(`Profile "${name}" already exists. Use 'diafunc config profile use' to switch to it.`));
|
|
2287
2429
|
process.exit(1);
|
|
2288
2430
|
}
|
|
2289
2431
|
cfg.profiles[name] = {
|
|
@@ -2291,18 +2433,18 @@ function registerConfigCommands(program) {
|
|
|
2291
2433
|
...options.token ? { auth: { type: "api-token", token: options.token } } : {}
|
|
2292
2434
|
};
|
|
2293
2435
|
saveConfig(cfg);
|
|
2294
|
-
console.log(
|
|
2436
|
+
console.log(chalk8.green(`Profile "${name}" added.`));
|
|
2295
2437
|
});
|
|
2296
2438
|
profile.command("use").description("Switch to a profile").argument("<name>", "Profile name").action((name) => {
|
|
2297
2439
|
const cfg = loadConfig();
|
|
2298
2440
|
if (!cfg.profiles[name]) {
|
|
2299
|
-
console.error(
|
|
2441
|
+
console.error(chalk8.red(`Profile "${name}" not found.`));
|
|
2300
2442
|
console.log(`Available profiles: ${Object.keys(cfg.profiles).join(", ")}`);
|
|
2301
2443
|
process.exit(1);
|
|
2302
2444
|
}
|
|
2303
2445
|
cfg.currentProfile = name;
|
|
2304
2446
|
saveConfig(cfg);
|
|
2305
|
-
console.log(
|
|
2447
|
+
console.log(chalk8.green(`Switched to profile "${name}".`));
|
|
2306
2448
|
});
|
|
2307
2449
|
profile.command("list").description("List all profiles").action((_options, cmd) => {
|
|
2308
2450
|
const cfg = loadConfig();
|
|
@@ -2322,16 +2464,16 @@ function registerConfigCommands(program) {
|
|
|
2322
2464
|
profile.command("remove").description("Remove a profile").argument("<name>", "Profile name").action((name) => {
|
|
2323
2465
|
const cfg = loadConfig();
|
|
2324
2466
|
if (!cfg.profiles[name]) {
|
|
2325
|
-
console.error(
|
|
2467
|
+
console.error(chalk8.red(`Profile "${name}" not found.`));
|
|
2326
2468
|
process.exit(1);
|
|
2327
2469
|
}
|
|
2328
2470
|
if (name === cfg.currentProfile) {
|
|
2329
|
-
console.error(
|
|
2471
|
+
console.error(chalk8.red(`Cannot remove the active profile. Switch to another profile first.`));
|
|
2330
2472
|
process.exit(1);
|
|
2331
2473
|
}
|
|
2332
2474
|
delete cfg.profiles[name];
|
|
2333
2475
|
saveConfig(cfg);
|
|
2334
|
-
console.log(
|
|
2476
|
+
console.log(chalk8.green(`Profile "${name}" removed.`));
|
|
2335
2477
|
});
|
|
2336
2478
|
}
|
|
2337
2479
|
function setNestedValue(obj, path11, value) {
|
|
@@ -2359,7 +2501,7 @@ function getNestedValue(obj, path11) {
|
|
|
2359
2501
|
}
|
|
2360
2502
|
|
|
2361
2503
|
// src/commands/project/index.ts
|
|
2362
|
-
import
|
|
2504
|
+
import chalk10 from "chalk";
|
|
2363
2505
|
|
|
2364
2506
|
// src/util/references.ts
|
|
2365
2507
|
function parseEntityReference(ref, overrides) {
|
|
@@ -2444,7 +2586,7 @@ function parseProjectReference(ref, overrides) {
|
|
|
2444
2586
|
}
|
|
2445
2587
|
|
|
2446
2588
|
// src/commands/bundle-helpers.ts
|
|
2447
|
-
import
|
|
2589
|
+
import chalk9 from "chalk";
|
|
2448
2590
|
import * as fs2 from "fs";
|
|
2449
2591
|
import * as path2 from "path";
|
|
2450
2592
|
async function streamResponseToFile(response, outFile) {
|
|
@@ -2454,19 +2596,19 @@ async function streamResponseToFile(response, outFile) {
|
|
|
2454
2596
|
}
|
|
2455
2597
|
function printLossiness(notes) {
|
|
2456
2598
|
if (notes && notes.length > 0) {
|
|
2457
|
-
console.log(
|
|
2599
|
+
console.log(chalk9.yellow("Lossiness:"));
|
|
2458
2600
|
for (const note of notes) {
|
|
2459
|
-
console.log(
|
|
2601
|
+
console.log(chalk9.yellow(` - ${note}`));
|
|
2460
2602
|
}
|
|
2461
2603
|
}
|
|
2462
2604
|
}
|
|
2463
2605
|
function printImportPreview(preview) {
|
|
2464
|
-
console.log(
|
|
2606
|
+
console.log(chalk9.bold(`${preview.kind} bundle \xB7 ${preview.entityCount} entities`));
|
|
2465
2607
|
if (preview.projectName) {
|
|
2466
|
-
console.log(
|
|
2608
|
+
console.log(chalk9.dim(preview.projectName));
|
|
2467
2609
|
}
|
|
2468
2610
|
if (preview.sourceProjectId) {
|
|
2469
|
-
console.log(
|
|
2611
|
+
console.log(chalk9.dim(`from ${preview.sourceProjectId}/${preview.sourceProjectBranch}` + (preview.createdBy ? ` \xB7 by ${preview.createdBy}` : "")));
|
|
2470
2612
|
}
|
|
2471
2613
|
const counts = /* @__PURE__ */ new Map();
|
|
2472
2614
|
for (const e of preview.entities ?? []) {
|
|
@@ -2487,7 +2629,7 @@ function printImportPreview(preview) {
|
|
|
2487
2629
|
printLossiness(preview.lossinessNotes);
|
|
2488
2630
|
}
|
|
2489
2631
|
function printImportResult(result) {
|
|
2490
|
-
console.log(
|
|
2632
|
+
console.log(chalk9.green(`Imported ${result.entityCount} entities, ${result.linkCount} links.`));
|
|
2491
2633
|
if (result.skeletonCount) {
|
|
2492
2634
|
console.log(`Skeletons: ${result.skeletonCount}`);
|
|
2493
2635
|
}
|
|
@@ -2558,7 +2700,7 @@ function registerProjectCommands(program) {
|
|
|
2558
2700
|
const projects = options.all ? await api.admin.getAllProjects() : await api.admin.getProjects();
|
|
2559
2701
|
format(projects, {
|
|
2560
2702
|
format: outputFormat,
|
|
2561
|
-
columns: ["projectId", "
|
|
2703
|
+
columns: ["projectId", "teamName", "visibility", "language", "active", "locked"]
|
|
2562
2704
|
});
|
|
2563
2705
|
} catch (error) {
|
|
2564
2706
|
handleError(error);
|
|
@@ -2584,8 +2726,8 @@ function registerProjectCommands(program) {
|
|
|
2584
2726
|
active: true
|
|
2585
2727
|
});
|
|
2586
2728
|
if (outputFormat === "human") {
|
|
2587
|
-
console.log(
|
|
2588
|
-
console.log(` Project ID: ${
|
|
2729
|
+
console.log(chalk10.green("Project created."));
|
|
2730
|
+
console.log(` Project ID: ${chalk10.bold(p.projectId)}`);
|
|
2589
2731
|
console.log(` Visibility: ${p.visibility}`);
|
|
2590
2732
|
console.log(` Language: ${p.language}`);
|
|
2591
2733
|
} else {
|
|
@@ -2595,7 +2737,7 @@ function registerProjectCommands(program) {
|
|
|
2595
2737
|
handleError(error);
|
|
2596
2738
|
}
|
|
2597
2739
|
});
|
|
2598
|
-
project.command("update").description("Update a project").argument("<projectId>", "Project ID").option("--visibility <visibility>", "PRIVATE or PUBLIC").option("--language <language>", "Project language").option("--
|
|
2740
|
+
project.command("update").description("Update a project").argument("<projectId>", "Project ID").option("--visibility <visibility>", "PRIVATE or PUBLIC").option("--language <language>", "Project language").option("--active <bool>", "Whether the project is active (true/false)").action(async (projectId, options) => {
|
|
2599
2741
|
try {
|
|
2600
2742
|
const api = createApiClient();
|
|
2601
2743
|
const current = await api.admin.getProject(projectId);
|
|
@@ -2603,11 +2745,10 @@ function registerProjectCommands(program) {
|
|
|
2603
2745
|
...current,
|
|
2604
2746
|
...options.visibility ? { visibility: options.visibility.toUpperCase() } : {},
|
|
2605
2747
|
...options.language ? { language: options.language } : {},
|
|
2606
|
-
...options.group !== void 0 ? { groupId: options.group || null } : {},
|
|
2607
2748
|
...options.active !== void 0 ? { active: options.active === "true" } : {}
|
|
2608
2749
|
};
|
|
2609
2750
|
await api.admin.updateProject(updated);
|
|
2610
|
-
console.log(
|
|
2751
|
+
console.log(chalk10.green(`Project "${projectId}" updated.`));
|
|
2611
2752
|
} catch (error) {
|
|
2612
2753
|
handleError(error);
|
|
2613
2754
|
}
|
|
@@ -2629,7 +2770,7 @@ function registerProjectCommands(program) {
|
|
|
2629
2770
|
try {
|
|
2630
2771
|
const api = createApiClient();
|
|
2631
2772
|
await api.admin.deleteProject(projectId);
|
|
2632
|
-
console.log(
|
|
2773
|
+
console.log(chalk10.green(`Project "${projectId}" deleted.`));
|
|
2633
2774
|
} catch (error) {
|
|
2634
2775
|
handleError(error);
|
|
2635
2776
|
}
|
|
@@ -2638,7 +2779,7 @@ function registerProjectCommands(program) {
|
|
|
2638
2779
|
try {
|
|
2639
2780
|
const api = createApiClient();
|
|
2640
2781
|
await api.admin.lockProject(projectId);
|
|
2641
|
-
console.log(
|
|
2782
|
+
console.log(chalk10.green(`Project "${projectId}" locked.`));
|
|
2642
2783
|
} catch (error) {
|
|
2643
2784
|
handleError(error);
|
|
2644
2785
|
}
|
|
@@ -2647,7 +2788,7 @@ function registerProjectCommands(program) {
|
|
|
2647
2788
|
try {
|
|
2648
2789
|
const api = createApiClient();
|
|
2649
2790
|
await api.admin.unlockProject(projectId);
|
|
2650
|
-
console.log(
|
|
2791
|
+
console.log(chalk10.green(`Project "${projectId}" unlocked.`));
|
|
2651
2792
|
} catch (error) {
|
|
2652
2793
|
handleError(error);
|
|
2653
2794
|
}
|
|
@@ -2670,7 +2811,7 @@ function registerProjectCommands(program) {
|
|
|
2670
2811
|
try {
|
|
2671
2812
|
const api = createApiClient();
|
|
2672
2813
|
await api.admin.inviteProjectMember(projectId, userId, role.toUpperCase());
|
|
2673
|
-
console.log(
|
|
2814
|
+
console.log(chalk10.green(`Invited ${userId} to "${projectId}" as ${role.toUpperCase()}.`));
|
|
2674
2815
|
} catch (error) {
|
|
2675
2816
|
handleError(error);
|
|
2676
2817
|
}
|
|
@@ -2679,7 +2820,7 @@ function registerProjectCommands(program) {
|
|
|
2679
2820
|
try {
|
|
2680
2821
|
const api = createApiClient();
|
|
2681
2822
|
await api.admin.joinProject(projectId, userId);
|
|
2682
|
-
console.log(
|
|
2823
|
+
console.log(chalk10.green(`Joined project "${projectId}".`));
|
|
2683
2824
|
} catch (error) {
|
|
2684
2825
|
handleError(error);
|
|
2685
2826
|
}
|
|
@@ -2688,7 +2829,7 @@ function registerProjectCommands(program) {
|
|
|
2688
2829
|
try {
|
|
2689
2830
|
const api = createApiClient();
|
|
2690
2831
|
await api.admin.removeProjectMember(projectId, userId);
|
|
2691
|
-
console.log(
|
|
2832
|
+
console.log(chalk10.green(`Removed ${userId} from "${projectId}".`));
|
|
2692
2833
|
} catch (error) {
|
|
2693
2834
|
handleError(error);
|
|
2694
2835
|
}
|
|
@@ -2700,16 +2841,16 @@ function registerProjectCommands(program) {
|
|
|
2700
2841
|
const api = createApiClient();
|
|
2701
2842
|
const bundleId = await api.storage.exportProjectBundle(ref.projectId, ref.projectBranch);
|
|
2702
2843
|
if (options.async) {
|
|
2703
|
-
console.log(
|
|
2844
|
+
console.log(chalk10.green(`Project export queued (bundle ID: ${bundleId}).`));
|
|
2704
2845
|
console.log(`Poll progress: diafunc notebook bundles ${project2}`);
|
|
2705
2846
|
return;
|
|
2706
2847
|
}
|
|
2707
|
-
console.log(
|
|
2848
|
+
console.log(chalk10.dim(`Project export queued (bundle ID: ${bundleId}); waiting for it to finish\u2026`));
|
|
2708
2849
|
const job = await pollUntilFinished(api.storage, ref.projectId, ref.projectBranch, bundleId);
|
|
2709
2850
|
const response = await api.storage.getBundleContent(ref.projectId, ref.projectBranch, bundleId, job.filename);
|
|
2710
2851
|
const outFile = options.out ?? "project.dfproj";
|
|
2711
2852
|
const bytes = await streamResponseToFile(response, outFile);
|
|
2712
|
-
console.log(
|
|
2853
|
+
console.log(chalk10.green(`Bundle written to ${outFile} (${bytes} bytes, ${job.entityCount ?? "?"} entities).`));
|
|
2713
2854
|
} catch (error) {
|
|
2714
2855
|
handleError(error);
|
|
2715
2856
|
}
|
|
@@ -2720,7 +2861,433 @@ function registerProjectCommands(program) {
|
|
|
2720
2861
|
const overrides = getOverrides(cmd);
|
|
2721
2862
|
const ref = parseProjectReference(project2, overrides);
|
|
2722
2863
|
const api = createApiClient();
|
|
2723
|
-
await runBundleImport(api.storage, ref.projectId, ref.projectBranch, file, options, outputFormat);
|
|
2864
|
+
await runBundleImport(api.storage, ref.projectId, ref.projectBranch, file, options, outputFormat);
|
|
2865
|
+
} catch (error) {
|
|
2866
|
+
handleError(error);
|
|
2867
|
+
}
|
|
2868
|
+
});
|
|
2869
|
+
}
|
|
2870
|
+
|
|
2871
|
+
// src/commands/team/index.ts
|
|
2872
|
+
import chalk12 from "chalk";
|
|
2873
|
+
|
|
2874
|
+
// src/util/confirm.ts
|
|
2875
|
+
import * as readline from "readline";
|
|
2876
|
+
import chalk11 from "chalk";
|
|
2877
|
+
async function confirmDestructive(message, opts = {}) {
|
|
2878
|
+
if (!process.stdin.isTTY || opts.yes) return;
|
|
2879
|
+
const expected = opts.resourceId ?? "yes";
|
|
2880
|
+
const hint = opts.resourceId ? `"${opts.resourceId}"` : '"yes"';
|
|
2881
|
+
console.log(chalk11.yellow(`! ${message}`));
|
|
2882
|
+
const answer = await new Promise((resolve) => {
|
|
2883
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
2884
|
+
rl.question(` Type ${hint} to confirm: `, (ans) => {
|
|
2885
|
+
rl.close();
|
|
2886
|
+
resolve(ans);
|
|
2887
|
+
});
|
|
2888
|
+
});
|
|
2889
|
+
if (answer.trim() !== expected) {
|
|
2890
|
+
console.log(chalk11.dim("Aborted."));
|
|
2891
|
+
process.exit(1);
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
|
|
2895
|
+
// src/commands/team/index.ts
|
|
2896
|
+
var ROLES = ["OWNER", "ADMIN", "MEMBER"];
|
|
2897
|
+
var INTERVALS = ["MONTHLY", "YEARLY"];
|
|
2898
|
+
function getOutputFormat2(cmd) {
|
|
2899
|
+
const config = loadConfig();
|
|
2900
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
2901
|
+
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
2902
|
+
}
|
|
2903
|
+
function parseRole(value) {
|
|
2904
|
+
const role = value.trim().toUpperCase();
|
|
2905
|
+
if (!ROLES.includes(role)) {
|
|
2906
|
+
throw new Error(`Invalid role "${value}". Expected one of: ${ROLES.join(", ")}.`);
|
|
2907
|
+
}
|
|
2908
|
+
return role;
|
|
2909
|
+
}
|
|
2910
|
+
function parseInterval(value) {
|
|
2911
|
+
const interval = value.trim().toUpperCase();
|
|
2912
|
+
if (!INTERVALS.includes(interval)) {
|
|
2913
|
+
throw new Error(`Invalid billing interval "${value}". Expected one of: ${INTERVALS.join(", ")}.`);
|
|
2914
|
+
}
|
|
2915
|
+
return interval;
|
|
2916
|
+
}
|
|
2917
|
+
function parseCount(value, label) {
|
|
2918
|
+
const count = Number(value);
|
|
2919
|
+
if (!Number.isInteger(count) || count < 0) {
|
|
2920
|
+
throw new Error(`Invalid ${label} "${value}". Expected a non-negative whole number.`);
|
|
2921
|
+
}
|
|
2922
|
+
return count;
|
|
2923
|
+
}
|
|
2924
|
+
function formatMoney(cents, currency) {
|
|
2925
|
+
const sign = cents < 0 ? "-" : "";
|
|
2926
|
+
const abs = Math.abs(cents);
|
|
2927
|
+
return `${sign}${(abs / 100).toFixed(2)} ${currency.toUpperCase()}`;
|
|
2928
|
+
}
|
|
2929
|
+
function printInvoicePreview(preview, outputFormat) {
|
|
2930
|
+
if (outputFormat === "json") {
|
|
2931
|
+
format(preview, { format: outputFormat });
|
|
2932
|
+
return;
|
|
2933
|
+
}
|
|
2934
|
+
format(
|
|
2935
|
+
preview.lineItems.map((item) => ({
|
|
2936
|
+
description: item.description,
|
|
2937
|
+
amount: formatMoney(item.amountCents, preview.currency)
|
|
2938
|
+
})),
|
|
2939
|
+
{ format: outputFormat, columns: ["description", "amount"] }
|
|
2940
|
+
);
|
|
2941
|
+
console.log(`Total: ${formatMoney(preview.totalCents, preview.currency)}`);
|
|
2942
|
+
if (preview.nextBillingDate) {
|
|
2943
|
+
const next = preview.nextBillingAmountCents;
|
|
2944
|
+
console.log(
|
|
2945
|
+
`Next bill: ${preview.nextBillingDate}` + (next !== null && next !== void 0 ? ` for ${formatMoney(next, preview.currency)}` : "")
|
|
2946
|
+
);
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
function registerTeamCommands(program) {
|
|
2950
|
+
const team = program.command("team").description("Manage teams: membership, invitations, seats, billing, and ownership");
|
|
2951
|
+
team.command("list", { isDefault: true }).description("List the teams you belong to").action(async (_options, cmd) => {
|
|
2952
|
+
try {
|
|
2953
|
+
const api = createApiClient();
|
|
2954
|
+
const teams = await api.admin.listMyTeams();
|
|
2955
|
+
format(teams, {
|
|
2956
|
+
format: getOutputFormat2(cmd),
|
|
2957
|
+
columns: ["id", "name", "planId", "seatCount", "packCount", "renewal"],
|
|
2958
|
+
dateColumns: ["createdAt", "dunningStartedAt"]
|
|
2959
|
+
});
|
|
2960
|
+
} catch (error) {
|
|
2961
|
+
handleError(error);
|
|
2962
|
+
}
|
|
2963
|
+
});
|
|
2964
|
+
team.command("get").description("Show a team").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
|
|
2965
|
+
try {
|
|
2966
|
+
const api = createApiClient();
|
|
2967
|
+
format(await api.admin.getTeam(teamId), {
|
|
2968
|
+
format: getOutputFormat2(cmd),
|
|
2969
|
+
dateColumns: ["createdAt", "dunningStartedAt"]
|
|
2970
|
+
});
|
|
2971
|
+
} catch (error) {
|
|
2972
|
+
handleError(error);
|
|
2973
|
+
}
|
|
2974
|
+
});
|
|
2975
|
+
team.command("use").description("Set your active team (new projects are created under it)").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
|
|
2976
|
+
try {
|
|
2977
|
+
const api = createApiClient();
|
|
2978
|
+
await api.admin.setActiveTeam(teamId);
|
|
2979
|
+
formatMessage(`Active team set to "${teamId}".`, { format: getOutputFormat2(cmd) });
|
|
2980
|
+
} catch (error) {
|
|
2981
|
+
handleError(error);
|
|
2982
|
+
}
|
|
2983
|
+
});
|
|
2984
|
+
team.command("usage").description("Show credit usage for a team, broken down by member").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
|
|
2985
|
+
try {
|
|
2986
|
+
const outputFormat = getOutputFormat2(cmd);
|
|
2987
|
+
const api = createApiClient();
|
|
2988
|
+
const usage = await api.admin.getTeamUsage(teamId);
|
|
2989
|
+
if (outputFormat === "json") {
|
|
2990
|
+
format(usage, { format: outputFormat });
|
|
2991
|
+
return;
|
|
2992
|
+
}
|
|
2993
|
+
console.log(
|
|
2994
|
+
`${usage.year}-${String(usage.month).padStart(2, "0")} ${usage.totalCredits} credits used of ${usage.baselineCredits} included`
|
|
2995
|
+
);
|
|
2996
|
+
format(usage.members, {
|
|
2997
|
+
format: outputFormat,
|
|
2998
|
+
columns: ["userId", "name", "email", "credits"]
|
|
2999
|
+
});
|
|
3000
|
+
} catch (error) {
|
|
3001
|
+
handleError(error);
|
|
3002
|
+
}
|
|
3003
|
+
});
|
|
3004
|
+
team.command("create").description("Start checkout for a new team and print the URL to complete it in a browser").requiredOption("--name <name>", "Team name").requiredOption("--plan <planId>", "Plan ID").requiredOption("--seats <count>", "Number of seats").option("--interval <interval>", "Billing interval (MONTHLY, YEARLY)", "MONTHLY").option("--packs <count>", "Number of credit extension packs").option("--currency <currency>", "Billing currency (e.g. EUR, USD)").action(async (options, cmd) => {
|
|
3005
|
+
try {
|
|
3006
|
+
const api = createApiClient();
|
|
3007
|
+
const session = await api.admin.startTeamCheckout({
|
|
3008
|
+
name: options.name,
|
|
3009
|
+
planId: options.plan,
|
|
3010
|
+
billingInterval: parseInterval(options.interval),
|
|
3011
|
+
seatCount: parseCount(options.seats, "seat count"),
|
|
3012
|
+
...options.packs !== void 0 ? { packCount: parseCount(options.packs, "pack count") } : {},
|
|
3013
|
+
...options.currency !== void 0 ? { currency: options.currency.toUpperCase() } : {}
|
|
3014
|
+
});
|
|
3015
|
+
const outputFormat = getOutputFormat2(cmd);
|
|
3016
|
+
if (outputFormat === "json") {
|
|
3017
|
+
format(session, { format: outputFormat });
|
|
3018
|
+
return;
|
|
3019
|
+
}
|
|
3020
|
+
console.log("Open this URL to complete checkout:");
|
|
3021
|
+
console.log(chalk12.cyan(session.url));
|
|
3022
|
+
} catch (error) {
|
|
3023
|
+
handleError(error);
|
|
3024
|
+
}
|
|
3025
|
+
});
|
|
3026
|
+
team.command("portal").description("Open the billing portal for a team and print the URL").argument("<teamId>", "Team ID").option("--return-url <url>", "Where the portal returns to when done", "https://diafunc.com/team").action(async (teamId, options, cmd) => {
|
|
3027
|
+
try {
|
|
3028
|
+
const api = createApiClient();
|
|
3029
|
+
const session = await api.admin.createTeamPortalSession(teamId, options.returnUrl);
|
|
3030
|
+
const outputFormat = getOutputFormat2(cmd);
|
|
3031
|
+
if (outputFormat === "json") {
|
|
3032
|
+
format(session, { format: outputFormat });
|
|
3033
|
+
return;
|
|
3034
|
+
}
|
|
3035
|
+
console.log("Open this URL to manage billing:");
|
|
3036
|
+
console.log(chalk12.cyan(session.url));
|
|
3037
|
+
} catch (error) {
|
|
3038
|
+
handleError(error);
|
|
3039
|
+
}
|
|
3040
|
+
});
|
|
3041
|
+
team.command("cancel").description("Cancel a team's subscription at the end of the current period").argument("<teamId>", "Team ID").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, options, cmd) => {
|
|
3042
|
+
try {
|
|
3043
|
+
await confirmDestructive(
|
|
3044
|
+
`This will cancel team "${teamId}" at the end of the current billing period.`,
|
|
3045
|
+
{ yes: options.yes, resourceId: teamId }
|
|
3046
|
+
);
|
|
3047
|
+
const api = createApiClient();
|
|
3048
|
+
const response = await api.admin.cancelTeam(teamId);
|
|
3049
|
+
formatMessage(
|
|
3050
|
+
`Team "${teamId}" cancelled. Access ends ${response.endsAt ?? "at the end of the period"}.`,
|
|
3051
|
+
{ format: getOutputFormat2(cmd) }
|
|
3052
|
+
);
|
|
3053
|
+
} catch (error) {
|
|
3054
|
+
handleError(error);
|
|
3055
|
+
}
|
|
3056
|
+
});
|
|
3057
|
+
team.command("leave").description("Leave a team you are a member of").argument("<teamId>", "Team ID").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, options, cmd) => {
|
|
3058
|
+
try {
|
|
3059
|
+
await confirmDestructive(`This will remove you from team "${teamId}".`, {
|
|
3060
|
+
yes: options.yes,
|
|
3061
|
+
resourceId: teamId
|
|
3062
|
+
});
|
|
3063
|
+
const api = createApiClient();
|
|
3064
|
+
await api.admin.leaveTeam(teamId);
|
|
3065
|
+
formatMessage(`Left team "${teamId}".`, { format: getOutputFormat2(cmd) });
|
|
3066
|
+
} catch (error) {
|
|
3067
|
+
handleError(error);
|
|
3068
|
+
}
|
|
3069
|
+
});
|
|
3070
|
+
registerMemberCommands(team);
|
|
3071
|
+
registerInvitationCommands(team);
|
|
3072
|
+
registerSeatCommands(team);
|
|
3073
|
+
registerPackCommands(team);
|
|
3074
|
+
registerOwnershipCommands(team);
|
|
3075
|
+
}
|
|
3076
|
+
function registerMemberCommands(team) {
|
|
3077
|
+
const members = team.command("members").description("Manage team members");
|
|
3078
|
+
members.command("list", { isDefault: true }).description("List team members").argument("<teamId>", "Team ID").option("--all", "Include members who have been removed from the team").action(async (teamId, options, cmd) => {
|
|
3079
|
+
try {
|
|
3080
|
+
const api = createApiClient();
|
|
3081
|
+
const all = await api.admin.listTeamMembers(teamId);
|
|
3082
|
+
const shown = options.all ? all : all.filter((m) => !m.removedAt);
|
|
3083
|
+
format(shown, {
|
|
3084
|
+
format: getOutputFormat2(cmd),
|
|
3085
|
+
columns: options.all ? ["userId", "name", "email", "role", "joinedAt", "removedAt"] : ["userId", "name", "email", "role", "joinedAt"],
|
|
3086
|
+
dateColumns: ["joinedAt", "invitedAt", "removedAt"]
|
|
3087
|
+
});
|
|
3088
|
+
} catch (error) {
|
|
3089
|
+
handleError(error);
|
|
3090
|
+
}
|
|
3091
|
+
});
|
|
3092
|
+
members.command("invite").description("Invite someone to the team by email").argument("<teamId>", "Team ID").argument("<email>", "Email address to invite").option("--role <role>", "Team role (OWNER, ADMIN, MEMBER)", "MEMBER").action(async (teamId, email, options, cmd) => {
|
|
3093
|
+
try {
|
|
3094
|
+
const role = parseRole(options.role);
|
|
3095
|
+
const api = createApiClient();
|
|
3096
|
+
await api.admin.inviteTeamMember(teamId, email, role);
|
|
3097
|
+
formatMessage(`Invited ${email} to team "${teamId}" as ${role}.`, {
|
|
3098
|
+
format: getOutputFormat2(cmd)
|
|
3099
|
+
});
|
|
3100
|
+
} catch (error) {
|
|
3101
|
+
handleError(error);
|
|
3102
|
+
}
|
|
3103
|
+
});
|
|
3104
|
+
members.command("remove").description("Remove a member from the team").argument("<teamId>", "Team ID").argument("<userId>", "User ID to remove").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, userId, options, cmd) => {
|
|
3105
|
+
try {
|
|
3106
|
+
await confirmDestructive(`This will remove ${userId} from team "${teamId}".`, {
|
|
3107
|
+
yes: options.yes,
|
|
3108
|
+
resourceId: userId
|
|
3109
|
+
});
|
|
3110
|
+
const api = createApiClient();
|
|
3111
|
+
await api.admin.removeTeamMember(teamId, userId);
|
|
3112
|
+
formatMessage(`Removed ${userId} from team "${teamId}".`, {
|
|
3113
|
+
format: getOutputFormat2(cmd)
|
|
3114
|
+
});
|
|
3115
|
+
} catch (error) {
|
|
3116
|
+
handleError(error);
|
|
3117
|
+
}
|
|
3118
|
+
});
|
|
3119
|
+
}
|
|
3120
|
+
function registerInvitationCommands(team) {
|
|
3121
|
+
const invitations = team.command("invitations").description("Manage pending team invitations");
|
|
3122
|
+
invitations.command("list", { isDefault: true }).description("List pending invitations").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
|
|
3123
|
+
try {
|
|
3124
|
+
const api = createApiClient();
|
|
3125
|
+
format(await api.admin.listTeamInvitations(teamId), {
|
|
3126
|
+
format: getOutputFormat2(cmd),
|
|
3127
|
+
columns: ["invitationId", "email", "role", "invitedBy", "expiresAt"],
|
|
3128
|
+
dateColumns: ["createdAt", "expiresAt"]
|
|
3129
|
+
});
|
|
3130
|
+
} catch (error) {
|
|
3131
|
+
handleError(error);
|
|
3132
|
+
}
|
|
3133
|
+
});
|
|
3134
|
+
invitations.command("revoke").description("Revoke a pending invitation").argument("<teamId>", "Team ID").argument("<invitationId>", "Invitation ID").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, invitationId, options, cmd) => {
|
|
3135
|
+
try {
|
|
3136
|
+
await confirmDestructive(`This will revoke invitation "${invitationId}".`, {
|
|
3137
|
+
yes: options.yes,
|
|
3138
|
+
resourceId: invitationId
|
|
3139
|
+
});
|
|
3140
|
+
const api = createApiClient();
|
|
3141
|
+
await api.admin.revokeTeamInvitation(teamId, invitationId);
|
|
3142
|
+
formatMessage(`Revoked invitation "${invitationId}".`, {
|
|
3143
|
+
format: getOutputFormat2(cmd)
|
|
3144
|
+
});
|
|
3145
|
+
} catch (error) {
|
|
3146
|
+
handleError(error);
|
|
3147
|
+
}
|
|
3148
|
+
});
|
|
3149
|
+
invitations.command("resend").description("Resend a pending invitation email").argument("<teamId>", "Team ID").argument("<invitationId>", "Invitation ID").action(async (teamId, invitationId, _options, cmd) => {
|
|
3150
|
+
try {
|
|
3151
|
+
const api = createApiClient();
|
|
3152
|
+
await api.admin.resendTeamInvitation(teamId, invitationId);
|
|
3153
|
+
formatMessage(`Resent invitation "${invitationId}".`, {
|
|
3154
|
+
format: getOutputFormat2(cmd)
|
|
3155
|
+
});
|
|
3156
|
+
} catch (error) {
|
|
3157
|
+
handleError(error);
|
|
3158
|
+
}
|
|
3159
|
+
});
|
|
3160
|
+
invitations.command("accept").description("Accept a team invitation you received by email").argument("<token>", "Invitation token from the email link").action(async (token, _options, cmd) => {
|
|
3161
|
+
try {
|
|
3162
|
+
const api = createApiClient();
|
|
3163
|
+
const member = await api.admin.acceptTeamInvitation(token);
|
|
3164
|
+
formatMessage(`Joined the team as ${member.role}.`, {
|
|
3165
|
+
format: getOutputFormat2(cmd)
|
|
3166
|
+
});
|
|
3167
|
+
} catch (error) {
|
|
3168
|
+
handleError(error);
|
|
3169
|
+
}
|
|
3170
|
+
});
|
|
3171
|
+
}
|
|
3172
|
+
function registerSeatCommands(team) {
|
|
3173
|
+
const seats = team.command("seats").description("Change a team's seat count");
|
|
3174
|
+
seats.command("preview").description("Preview the invoice for a seat-count change without applying it").argument("<teamId>", "Team ID").argument("<count>", "New seat count").action(async (teamId, count, _options, cmd) => {
|
|
3175
|
+
try {
|
|
3176
|
+
const api = createApiClient();
|
|
3177
|
+
printInvoicePreview(
|
|
3178
|
+
await api.admin.previewTeamSeatCount(teamId, parseCount(count, "seat count")),
|
|
3179
|
+
getOutputFormat2(cmd)
|
|
3180
|
+
);
|
|
3181
|
+
} catch (error) {
|
|
3182
|
+
handleError(error);
|
|
3183
|
+
}
|
|
3184
|
+
});
|
|
3185
|
+
seats.command("set").description("Change the seat count and bill the difference").argument("<teamId>", "Team ID").argument("<count>", "New seat count").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, count, options, cmd) => {
|
|
3186
|
+
try {
|
|
3187
|
+
const seatCount = parseCount(count, "seat count");
|
|
3188
|
+
await confirmDestructive(
|
|
3189
|
+
`This will change the seat count of team "${teamId}" to ${seatCount} and adjust billing.`,
|
|
3190
|
+
{ yes: options.yes, resourceId: teamId }
|
|
3191
|
+
);
|
|
3192
|
+
const api = createApiClient();
|
|
3193
|
+
const change = await api.admin.updateTeamSeatCount(teamId, seatCount);
|
|
3194
|
+
formatMessage(`Seats changed from ${change.oldSeatCount} to ${change.newSeatCount}.`, {
|
|
3195
|
+
format: getOutputFormat2(cmd)
|
|
3196
|
+
});
|
|
3197
|
+
} catch (error) {
|
|
3198
|
+
handleError(error);
|
|
3199
|
+
}
|
|
3200
|
+
});
|
|
3201
|
+
}
|
|
3202
|
+
function registerPackCommands(team) {
|
|
3203
|
+
const packs = team.command("packs").description("Change a team's credit extension packs");
|
|
3204
|
+
packs.command("preview").description("Preview the invoice for a pack-count change without applying it").argument("<teamId>", "Team ID").argument("<count>", "New pack count").action(async (teamId, count, _options, cmd) => {
|
|
3205
|
+
try {
|
|
3206
|
+
const api = createApiClient();
|
|
3207
|
+
printInvoicePreview(
|
|
3208
|
+
await api.admin.previewTeamPackCount(teamId, parseCount(count, "pack count")),
|
|
3209
|
+
getOutputFormat2(cmd)
|
|
3210
|
+
);
|
|
3211
|
+
} catch (error) {
|
|
3212
|
+
handleError(error);
|
|
3213
|
+
}
|
|
3214
|
+
});
|
|
3215
|
+
packs.command("set").description("Change the pack count and bill the difference").argument("<teamId>", "Team ID").argument("<count>", "New pack count").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, count, options, cmd) => {
|
|
3216
|
+
try {
|
|
3217
|
+
const packCount = parseCount(count, "pack count");
|
|
3218
|
+
await confirmDestructive(
|
|
3219
|
+
`This will change the extension packs of team "${teamId}" to ${packCount} and adjust billing.`,
|
|
3220
|
+
{ yes: options.yes, resourceId: teamId }
|
|
3221
|
+
);
|
|
3222
|
+
const api = createApiClient();
|
|
3223
|
+
const change = await api.admin.updateTeamPackCount(teamId, packCount);
|
|
3224
|
+
formatMessage(`Packs changed from ${change.oldPackCount} to ${change.newPackCount}.`, {
|
|
3225
|
+
format: getOutputFormat2(cmd)
|
|
3226
|
+
});
|
|
3227
|
+
} catch (error) {
|
|
3228
|
+
handleError(error);
|
|
3229
|
+
}
|
|
3230
|
+
});
|
|
3231
|
+
}
|
|
3232
|
+
function registerOwnershipCommands(team) {
|
|
3233
|
+
const transfer = team.command("transfer").description("Transfer ownership of a team to another member");
|
|
3234
|
+
transfer.command("start").description("Offer ownership to another member").argument("<teamId>", "Team ID").argument("<userId>", "User ID of the new owner").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, userId, options, cmd) => {
|
|
3235
|
+
try {
|
|
3236
|
+
await confirmDestructive(
|
|
3237
|
+
`This will offer ownership of team "${teamId}" to ${userId}.`,
|
|
3238
|
+
{ yes: options.yes, resourceId: teamId }
|
|
3239
|
+
);
|
|
3240
|
+
const api = createApiClient();
|
|
3241
|
+
format(await api.admin.initiateOwnershipTransfer(teamId, userId), {
|
|
3242
|
+
format: getOutputFormat2(cmd)
|
|
3243
|
+
});
|
|
3244
|
+
} catch (error) {
|
|
3245
|
+
handleError(error);
|
|
3246
|
+
}
|
|
3247
|
+
});
|
|
3248
|
+
transfer.command("status", { isDefault: true }).description("Show the pending ownership transfer").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
|
|
3249
|
+
try {
|
|
3250
|
+
const api = createApiClient();
|
|
3251
|
+
const pending = await api.admin.getOwnershipTransfer(teamId);
|
|
3252
|
+
const outputFormat = getOutputFormat2(cmd);
|
|
3253
|
+
if (!pending) {
|
|
3254
|
+
if (outputFormat === "json") {
|
|
3255
|
+
format(null, { format: outputFormat });
|
|
3256
|
+
} else {
|
|
3257
|
+
console.log(`No pending ownership transfer for team "${teamId}".`);
|
|
3258
|
+
}
|
|
3259
|
+
return;
|
|
3260
|
+
}
|
|
3261
|
+
format(pending, { format: outputFormat, dateColumns: ["createdAt"] });
|
|
3262
|
+
} catch (error) {
|
|
3263
|
+
handleError(error);
|
|
3264
|
+
}
|
|
3265
|
+
});
|
|
3266
|
+
transfer.command("accept").description("Accept an ownership transfer offered to you").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
|
|
3267
|
+
try {
|
|
3268
|
+
const api = createApiClient();
|
|
3269
|
+
const response = await api.admin.acceptOwnershipTransfer(teamId);
|
|
3270
|
+
const outputFormat = getOutputFormat2(cmd);
|
|
3271
|
+
if (outputFormat === "json") {
|
|
3272
|
+
format(response, { format: outputFormat });
|
|
3273
|
+
return;
|
|
3274
|
+
}
|
|
3275
|
+
console.log(chalk12.green(`Ownership transfer ${response.status}.`));
|
|
3276
|
+
if (response.checkoutUrl) {
|
|
3277
|
+
console.log("Open this URL to complete the billing handover:");
|
|
3278
|
+
console.log(chalk12.cyan(response.checkoutUrl));
|
|
3279
|
+
}
|
|
3280
|
+
} catch (error) {
|
|
3281
|
+
handleError(error);
|
|
3282
|
+
}
|
|
3283
|
+
});
|
|
3284
|
+
transfer.command("cancel").description("Cancel a pending ownership transfer").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
|
|
3285
|
+
try {
|
|
3286
|
+
const api = createApiClient();
|
|
3287
|
+
await api.admin.cancelOwnershipTransfer(teamId);
|
|
3288
|
+
formatMessage(`Cancelled the ownership transfer for team "${teamId}".`, {
|
|
3289
|
+
format: getOutputFormat2(cmd)
|
|
3290
|
+
});
|
|
2724
3291
|
} catch (error) {
|
|
2725
3292
|
handleError(error);
|
|
2726
3293
|
}
|
|
@@ -2728,32 +3295,9 @@ function registerProjectCommands(program) {
|
|
|
2728
3295
|
}
|
|
2729
3296
|
|
|
2730
3297
|
// src/commands/entity/index.ts
|
|
2731
|
-
import
|
|
3298
|
+
import chalk13 from "chalk";
|
|
2732
3299
|
import * as fs3 from "fs";
|
|
2733
|
-
|
|
2734
|
-
// src/util/confirm.ts
|
|
2735
|
-
import * as readline from "readline";
|
|
2736
|
-
import chalk10 from "chalk";
|
|
2737
|
-
async function confirmDestructive(message, opts = {}) {
|
|
2738
|
-
if (!process.stdin.isTTY || opts.yes) return;
|
|
2739
|
-
const expected = opts.resourceId ?? "yes";
|
|
2740
|
-
const hint = opts.resourceId ? `"${opts.resourceId}"` : '"yes"';
|
|
2741
|
-
console.log(chalk10.yellow(`! ${message}`));
|
|
2742
|
-
const answer = await new Promise((resolve) => {
|
|
2743
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
2744
|
-
rl.question(` Type ${hint} to confirm: `, (ans) => {
|
|
2745
|
-
rl.close();
|
|
2746
|
-
resolve(ans);
|
|
2747
|
-
});
|
|
2748
|
-
});
|
|
2749
|
-
if (answer.trim() !== expected) {
|
|
2750
|
-
console.log(chalk10.dim("Aborted."));
|
|
2751
|
-
process.exit(1);
|
|
2752
|
-
}
|
|
2753
|
-
}
|
|
2754
|
-
|
|
2755
|
-
// src/commands/entity/index.ts
|
|
2756
|
-
function getOutputFormat2(cmd) {
|
|
3300
|
+
function getOutputFormat3(cmd) {
|
|
2757
3301
|
const config = loadConfig();
|
|
2758
3302
|
const globalOpts = cmd.optsWithGlobals();
|
|
2759
3303
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -2766,7 +3310,7 @@ function registerEntityCommands(program) {
|
|
|
2766
3310
|
const entity = program.command("entity").description("Manage entities");
|
|
2767
3311
|
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) => {
|
|
2768
3312
|
try {
|
|
2769
|
-
const outputFormat =
|
|
3313
|
+
const outputFormat = getOutputFormat3(cmd);
|
|
2770
3314
|
const overrides = getOverrides2(cmd);
|
|
2771
3315
|
const ref = parseEntityReference(projectRef + "/" + projectRef, overrides);
|
|
2772
3316
|
const api = createApiClient();
|
|
@@ -2793,7 +3337,7 @@ function registerEntityCommands(program) {
|
|
|
2793
3337
|
});
|
|
2794
3338
|
entity.command("get").description("Get entity metadata").argument("<ref>", "Entity reference").option("--content", "Include content").action(async (ref, options, cmd) => {
|
|
2795
3339
|
try {
|
|
2796
|
-
const outputFormat =
|
|
3340
|
+
const outputFormat = getOutputFormat3(cmd);
|
|
2797
3341
|
const overrides = getOverrides2(cmd);
|
|
2798
3342
|
const resolved = parseEntityReference(ref, overrides);
|
|
2799
3343
|
const api = createApiClient();
|
|
@@ -2829,14 +3373,14 @@ function registerEntityCommands(program) {
|
|
|
2829
3373
|
const resolved = parseEntityReference(ref, overrides);
|
|
2830
3374
|
const api = createApiClient();
|
|
2831
3375
|
await api.storage.deleteEntity(resolved);
|
|
2832
|
-
console.log(
|
|
3376
|
+
console.log(chalk13.green(`Entity "${resolved.entityId}" deleted.`));
|
|
2833
3377
|
} catch (error) {
|
|
2834
3378
|
handleError(error);
|
|
2835
3379
|
}
|
|
2836
3380
|
});
|
|
2837
3381
|
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) => {
|
|
2838
3382
|
try {
|
|
2839
|
-
const outputFormat =
|
|
3383
|
+
const outputFormat = getOutputFormat3(cmd);
|
|
2840
3384
|
const overrides = getOverrides2(cmd);
|
|
2841
3385
|
const resolved = parseEntityReference(ref, overrides);
|
|
2842
3386
|
const api = createApiClient();
|
|
@@ -2870,7 +3414,7 @@ function registerEntityCommands(program) {
|
|
|
2870
3414
|
const resolved = parseEntityReference(ref, overrides);
|
|
2871
3415
|
const api = createApiClient();
|
|
2872
3416
|
await api.storage.revertEntity(resolved, parseInt(version, 10));
|
|
2873
|
-
console.log(
|
|
3417
|
+
console.log(chalk13.green(`Entity "${resolved.entityId}" reverted to version ${version}.`));
|
|
2874
3418
|
} catch (error) {
|
|
2875
3419
|
handleError(error);
|
|
2876
3420
|
}
|
|
@@ -2881,7 +3425,7 @@ function registerEntityCommands(program) {
|
|
|
2881
3425
|
const resolved = parseEntityReference(ref, overrides);
|
|
2882
3426
|
const api = createApiClient();
|
|
2883
3427
|
await api.storage.renameEntity(resolved, newId);
|
|
2884
|
-
console.log(
|
|
3428
|
+
console.log(chalk13.green(`Entity renamed from "${resolved.entityId}" to "${newId}".`));
|
|
2885
3429
|
} catch (error) {
|
|
2886
3430
|
handleError(error);
|
|
2887
3431
|
}
|
|
@@ -2896,7 +3440,7 @@ function registerEntityCommands(program) {
|
|
|
2896
3440
|
if (options.out) {
|
|
2897
3441
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
2898
3442
|
fs3.writeFileSync(options.out, buffer);
|
|
2899
|
-
console.log(
|
|
3443
|
+
console.log(chalk13.green(`Content saved to ${options.out}`));
|
|
2900
3444
|
} else {
|
|
2901
3445
|
const text = await response.text();
|
|
2902
3446
|
process.stdout.write(text);
|
|
@@ -2913,7 +3457,7 @@ function registerEntityCommands(program) {
|
|
|
2913
3457
|
const fileBuffer = fs3.readFileSync(file);
|
|
2914
3458
|
const base64 = fileBuffer.toString("base64");
|
|
2915
3459
|
await api.storage.saveEntityContentBase64(resolved, base64);
|
|
2916
|
-
console.log(
|
|
3460
|
+
console.log(chalk13.green(`Content uploaded from "${file}" to entity "${resolved.entityId}".`));
|
|
2917
3461
|
} catch (error) {
|
|
2918
3462
|
handleError(error);
|
|
2919
3463
|
}
|
|
@@ -2925,7 +3469,7 @@ function registerEntityCommands(program) {
|
|
|
2925
3469
|
const resolved = parseEntityReference(ref, overrides);
|
|
2926
3470
|
const api = createApiClient();
|
|
2927
3471
|
await api.storage.deleteEntityContent(resolved);
|
|
2928
|
-
console.log(
|
|
3472
|
+
console.log(chalk13.green(`Content deleted from entity "${resolved.entityId}".`));
|
|
2929
3473
|
} catch (error) {
|
|
2930
3474
|
handleError(error);
|
|
2931
3475
|
}
|
|
@@ -2938,21 +3482,21 @@ function registerEntityCommands(program) {
|
|
|
2938
3482
|
const request = { rootEntityIds: entityIds, dataFormat: options.data };
|
|
2939
3483
|
if (options.async) {
|
|
2940
3484
|
const bundleId = await api.storage.exportEntitySubset(ref.projectId, ref.projectBranch, request);
|
|
2941
|
-
console.log(
|
|
3485
|
+
console.log(chalk13.green(`Export queued (bundle ID: ${bundleId}).`));
|
|
2942
3486
|
console.log(`Poll progress: diafunc notebook bundles ${project}`);
|
|
2943
3487
|
return;
|
|
2944
3488
|
}
|
|
2945
3489
|
const response = await api.storage.streamEntitySubset(ref.projectId, ref.projectBranch, request);
|
|
2946
3490
|
const outFile = options.out ?? "entities.dfset";
|
|
2947
3491
|
const bytes = await streamResponseToFile(response, outFile);
|
|
2948
|
-
console.log(
|
|
3492
|
+
console.log(chalk13.green(`Bundle written to ${outFile} (${bytes} bytes, ${entityIds.length} entity(ies)).`));
|
|
2949
3493
|
} catch (error) {
|
|
2950
3494
|
handleError(error);
|
|
2951
3495
|
}
|
|
2952
3496
|
});
|
|
2953
3497
|
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), overwrite, or skip", "copy").option("--preview", "Show the bundle inventory without importing").action(async (project, file, options, cmd) => {
|
|
2954
3498
|
try {
|
|
2955
|
-
const outputFormat =
|
|
3499
|
+
const outputFormat = getOutputFormat3(cmd);
|
|
2956
3500
|
const overrides = getOverrides2(cmd);
|
|
2957
3501
|
const ref = parseProjectReference(project, overrides);
|
|
2958
3502
|
const api = createApiClient();
|
|
@@ -2964,8 +3508,8 @@ function registerEntityCommands(program) {
|
|
|
2964
3508
|
}
|
|
2965
3509
|
|
|
2966
3510
|
// src/commands/link/index.ts
|
|
2967
|
-
import
|
|
2968
|
-
function
|
|
3511
|
+
import chalk14 from "chalk";
|
|
3512
|
+
function getOutputFormat4(cmd) {
|
|
2969
3513
|
const config = loadConfig();
|
|
2970
3514
|
const globalOpts = cmd.optsWithGlobals();
|
|
2971
3515
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -2978,7 +3522,7 @@ function registerLinkCommands(program) {
|
|
|
2978
3522
|
const link = program.command("link").description("Manage links between entities");
|
|
2979
3523
|
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) => {
|
|
2980
3524
|
try {
|
|
2981
|
-
const outputFormat =
|
|
3525
|
+
const outputFormat = getOutputFormat4(cmd);
|
|
2982
3526
|
const overrides = getOverrides3(cmd);
|
|
2983
3527
|
const resolved = parseEntityReference(ref, overrides);
|
|
2984
3528
|
const api = createApiClient();
|
|
@@ -3014,7 +3558,7 @@ function registerLinkCommands(program) {
|
|
|
3014
3558
|
target.entityId,
|
|
3015
3559
|
target.entityBranch
|
|
3016
3560
|
);
|
|
3017
|
-
console.log(
|
|
3561
|
+
console.log(chalk14.green(`Link "${linkId}" created: ${source.entityId} \u2192 ${target.entityId}`));
|
|
3018
3562
|
} catch (error) {
|
|
3019
3563
|
handleError(error);
|
|
3020
3564
|
}
|
|
@@ -3035,7 +3579,7 @@ function registerLinkCommands(program) {
|
|
|
3035
3579
|
target.entityId,
|
|
3036
3580
|
target.entityBranch
|
|
3037
3581
|
);
|
|
3038
|
-
console.log(
|
|
3582
|
+
console.log(chalk14.green(`Link "${linkId}" deleted: ${source.entityId} \u2192 ${target.entityId}`));
|
|
3039
3583
|
} else {
|
|
3040
3584
|
await api.storage.deleteLink(
|
|
3041
3585
|
source.projectId,
|
|
@@ -3044,7 +3588,7 @@ function registerLinkCommands(program) {
|
|
|
3044
3588
|
source.entityBranch,
|
|
3045
3589
|
linkId
|
|
3046
3590
|
);
|
|
3047
|
-
console.log(
|
|
3591
|
+
console.log(chalk14.green(`All links with ID "${linkId}" from "${source.entityId}" deleted.`));
|
|
3048
3592
|
}
|
|
3049
3593
|
} catch (error) {
|
|
3050
3594
|
handleError(error);
|
|
@@ -3053,8 +3597,8 @@ function registerLinkCommands(program) {
|
|
|
3053
3597
|
}
|
|
3054
3598
|
|
|
3055
3599
|
// src/commands/event/index.ts
|
|
3056
|
-
import
|
|
3057
|
-
function
|
|
3600
|
+
import chalk15 from "chalk";
|
|
3601
|
+
function getOutputFormat5(cmd) {
|
|
3058
3602
|
const config = loadConfig();
|
|
3059
3603
|
const globalOpts = cmd.optsWithGlobals();
|
|
3060
3604
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -3067,7 +3611,7 @@ function registerEventCommands(program) {
|
|
|
3067
3611
|
const event = program.command("event").description("Manage events");
|
|
3068
3612
|
event.command("list").description("List events for an entity").argument("<ref>", "Entity reference").action(async (ref, _options, cmd) => {
|
|
3069
3613
|
try {
|
|
3070
|
-
const outputFormat =
|
|
3614
|
+
const outputFormat = getOutputFormat5(cmd);
|
|
3071
3615
|
const overrides = getOverrides4(cmd);
|
|
3072
3616
|
const resolved = parseEntityReference(ref, overrides);
|
|
3073
3617
|
const api = createApiClient();
|
|
@@ -3089,7 +3633,7 @@ function registerEventCommands(program) {
|
|
|
3089
3633
|
});
|
|
3090
3634
|
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) => {
|
|
3091
3635
|
try {
|
|
3092
|
-
const outputFormat =
|
|
3636
|
+
const outputFormat = getOutputFormat5(cmd);
|
|
3093
3637
|
const overrides = getOverrides4(cmd);
|
|
3094
3638
|
const resolved = parseEntityReference(ref, overrides);
|
|
3095
3639
|
const api = createApiClient();
|
|
@@ -3115,7 +3659,7 @@ function registerEventCommands(program) {
|
|
|
3115
3659
|
const api = createApiClient();
|
|
3116
3660
|
const arr = Array.isArray(events) ? events : [events];
|
|
3117
3661
|
await api.storage.createEvents(arr);
|
|
3118
|
-
console.log(
|
|
3662
|
+
console.log(chalk15.green(`${arr.length} event(s) created.`));
|
|
3119
3663
|
} catch (error) {
|
|
3120
3664
|
handleError(error);
|
|
3121
3665
|
}
|
|
@@ -3142,7 +3686,7 @@ function registerEventCommands(program) {
|
|
|
3142
3686
|
const resolved = parseEntityReference(ref, overrides);
|
|
3143
3687
|
const api = createApiClient();
|
|
3144
3688
|
await api.storage.deleteEvent(resolved, eventId, occurrenceId);
|
|
3145
|
-
console.log(
|
|
3689
|
+
console.log(chalk15.green(`Event "${eventId}/${occurrenceId}" deleted.`));
|
|
3146
3690
|
} catch (error) {
|
|
3147
3691
|
handleError(error);
|
|
3148
3692
|
}
|
|
@@ -3150,8 +3694,8 @@ function registerEventCommands(program) {
|
|
|
3150
3694
|
}
|
|
3151
3695
|
|
|
3152
3696
|
// src/commands/branch/index.ts
|
|
3153
|
-
import
|
|
3154
|
-
function
|
|
3697
|
+
import chalk16 from "chalk";
|
|
3698
|
+
function getOutputFormat6(cmd) {
|
|
3155
3699
|
const config = loadConfig();
|
|
3156
3700
|
const globalOpts = cmd.optsWithGlobals();
|
|
3157
3701
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -3164,12 +3708,12 @@ function registerBranchCommands(program) {
|
|
|
3164
3708
|
const branch = program.command("branch").description("Manage branches");
|
|
3165
3709
|
branch.command("list").description("List branches for a project").argument("[projectId]", "Project ID (uses default if omitted)").action(async (projectId, _options, cmd) => {
|
|
3166
3710
|
try {
|
|
3167
|
-
const outputFormat =
|
|
3711
|
+
const outputFormat = getOutputFormat6(cmd);
|
|
3168
3712
|
const overrides = getOverrides5(cmd);
|
|
3169
3713
|
const config = loadConfig();
|
|
3170
3714
|
const pid = projectId ?? overrides.project ?? config.defaults.project;
|
|
3171
3715
|
if (!pid) {
|
|
3172
|
-
console.error(
|
|
3716
|
+
console.error(chalk16.red("No project specified. Pass a project ID or set defaults.project."));
|
|
3173
3717
|
process.exit(1);
|
|
3174
3718
|
}
|
|
3175
3719
|
const api = createApiClient();
|
|
@@ -3193,7 +3737,7 @@ function registerBranchCommands(program) {
|
|
|
3193
3737
|
sourceProjectBranch: options.source,
|
|
3194
3738
|
targetProjectBranch: branchName
|
|
3195
3739
|
});
|
|
3196
|
-
console.log(
|
|
3740
|
+
console.log(chalk16.green(`Branch "${branchName}" created in project "${projectId}" from "${options.source}".`));
|
|
3197
3741
|
} catch (error) {
|
|
3198
3742
|
handleError(error);
|
|
3199
3743
|
}
|
|
@@ -3202,7 +3746,7 @@ function registerBranchCommands(program) {
|
|
|
3202
3746
|
try {
|
|
3203
3747
|
const api = createApiClient();
|
|
3204
3748
|
await api.storage.deleteProjectBranch(projectId, branchName);
|
|
3205
|
-
console.log(
|
|
3749
|
+
console.log(chalk16.green(`Branch "${branchName}" deleted from project "${projectId}".`));
|
|
3206
3750
|
} catch (error) {
|
|
3207
3751
|
handleError(error);
|
|
3208
3752
|
}
|
|
@@ -3223,7 +3767,7 @@ function registerBranchCommands(program) {
|
|
|
3223
3767
|
linkId: options.linkId,
|
|
3224
3768
|
deepMerge: options.deep
|
|
3225
3769
|
});
|
|
3226
|
-
console.log(
|
|
3770
|
+
console.log(chalk16.green("Merge completed."));
|
|
3227
3771
|
} catch (error) {
|
|
3228
3772
|
handleError(error);
|
|
3229
3773
|
}
|
|
@@ -3238,7 +3782,7 @@ function registerBranchCommands(program) {
|
|
|
3238
3782
|
forkProjectName: options.name ?? forkProjectId,
|
|
3239
3783
|
forkProjectDescription: options.description
|
|
3240
3784
|
});
|
|
3241
|
-
console.log(
|
|
3785
|
+
console.log(chalk16.green(`Project "${projectId}" forked to "${forkProjectId}".`));
|
|
3242
3786
|
} catch (error) {
|
|
3243
3787
|
handleError(error);
|
|
3244
3788
|
}
|
|
@@ -3246,10 +3790,10 @@ function registerBranchCommands(program) {
|
|
|
3246
3790
|
}
|
|
3247
3791
|
|
|
3248
3792
|
// src/commands/table/index.ts
|
|
3249
|
-
import
|
|
3793
|
+
import chalk17 from "chalk";
|
|
3250
3794
|
import * as fs4 from "fs";
|
|
3251
3795
|
import * as path3 from "path";
|
|
3252
|
-
function
|
|
3796
|
+
function getOutputFormat7(cmd) {
|
|
3253
3797
|
const config = loadConfig();
|
|
3254
3798
|
const globalOpts = cmd.optsWithGlobals();
|
|
3255
3799
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -3275,7 +3819,7 @@ function registerTableCommands(program) {
|
|
|
3275
3819
|
const table = program.command("table").description("Manage tables");
|
|
3276
3820
|
table.command("view").description("View table data").argument("<ref>", "Table entity reference").option("--rows <range>", "Row range (e.g., 0:10)").option("--cols <range>", "Column range (e.g., 0:5)").action(async (ref, options, cmd) => {
|
|
3277
3821
|
try {
|
|
3278
|
-
const outputFormat =
|
|
3822
|
+
const outputFormat = getOutputFormat7(cmd);
|
|
3279
3823
|
const overrides = getOverrides6(cmd);
|
|
3280
3824
|
const resolved = parseEntityReference(ref, overrides);
|
|
3281
3825
|
const api = createApiClient();
|
|
@@ -3299,8 +3843,8 @@ function registerTableCommands(program) {
|
|
|
3299
3843
|
const sortedCols = [...snapshot.columns].sort((a, b) => a.index - b.index);
|
|
3300
3844
|
const colNames = sortedCols.map((c) => c.name || `col${c.index}`);
|
|
3301
3845
|
const cellMap = /* @__PURE__ */ new Map();
|
|
3302
|
-
for (const
|
|
3303
|
-
cellMap.set(`${
|
|
3846
|
+
for (const cell3 of snapshot.cells) {
|
|
3847
|
+
cellMap.set(`${cell3.rowIndex}:${cell3.columnIndex}`, cell3.value ?? "");
|
|
3304
3848
|
}
|
|
3305
3849
|
const sortedRows = [...snapshot.rows].sort((a, b) => a.index - b.index);
|
|
3306
3850
|
const tableData = sortedRows.map((row2) => {
|
|
@@ -3316,7 +3860,7 @@ function registerTableCommands(program) {
|
|
|
3316
3860
|
console.log(colNames.map((c) => row2[c] ?? "").join(" "));
|
|
3317
3861
|
}
|
|
3318
3862
|
} else {
|
|
3319
|
-
console.log(
|
|
3863
|
+
console.log(chalk17.dim(`${snapshot.rows.length} rows \xD7 ${snapshot.columns.length} columns`));
|
|
3320
3864
|
format(tableData, { format: outputFormat, columns: colNames });
|
|
3321
3865
|
}
|
|
3322
3866
|
} catch (error) {
|
|
@@ -3328,7 +3872,7 @@ function registerTableCommands(program) {
|
|
|
3328
3872
|
const overrides = getOverrides6(cmd);
|
|
3329
3873
|
const resolved = parseEntityReference(ref, overrides);
|
|
3330
3874
|
if (!fs4.existsSync(file)) {
|
|
3331
|
-
console.error(
|
|
3875
|
+
console.error(chalk17.red(`File not found: ${file}`));
|
|
3332
3876
|
process.exit(1);
|
|
3333
3877
|
}
|
|
3334
3878
|
const api = createApiClient();
|
|
@@ -3346,22 +3890,22 @@ function registerTableCommands(program) {
|
|
|
3346
3890
|
const imp = await api.storage.getImport(resolved, importId);
|
|
3347
3891
|
if (imp.finished !== null) {
|
|
3348
3892
|
if (imp.succeeded) {
|
|
3349
|
-
console.log(
|
|
3893
|
+
console.log(chalk17.green(`Import completed successfully (${imp.duration}ms).`));
|
|
3350
3894
|
} else {
|
|
3351
|
-
console.error(
|
|
3895
|
+
console.error(chalk17.red(`Import failed: ${imp.error}`));
|
|
3352
3896
|
process.exit(1);
|
|
3353
3897
|
}
|
|
3354
3898
|
return;
|
|
3355
3899
|
}
|
|
3356
3900
|
}
|
|
3357
|
-
console.error(
|
|
3901
|
+
console.error(chalk17.yellow("Import still in progress. Check status later."));
|
|
3358
3902
|
} catch (error) {
|
|
3359
3903
|
handleError(error);
|
|
3360
3904
|
}
|
|
3361
3905
|
});
|
|
3362
3906
|
table.command("import-formats").description("List supported import formats").action(async (_options, cmd) => {
|
|
3363
3907
|
try {
|
|
3364
|
-
const outputFormat =
|
|
3908
|
+
const outputFormat = getOutputFormat7(cmd);
|
|
3365
3909
|
const api = createApiClient();
|
|
3366
3910
|
const response = await api.storage.getSupportedImportFormats();
|
|
3367
3911
|
if (outputFormat === "json") {
|
|
@@ -3390,15 +3934,15 @@ function registerTableCommands(program) {
|
|
|
3390
3934
|
const formats = await api.storage.getSupportedExportFormats();
|
|
3391
3935
|
const format2 = formats.formats.find((f) => f.id.toLowerCase() === fmt.toLowerCase());
|
|
3392
3936
|
if (!format2) {
|
|
3393
|
-
console.error(
|
|
3937
|
+
console.error(chalk17.red(`Unknown format: "${fmt}". Run \`diafunc table export-formats\` to see the catalogue.`));
|
|
3394
3938
|
process.exit(1);
|
|
3395
3939
|
}
|
|
3396
3940
|
if (options.compression && !formats.compressionAlgorithms.includes(options.compression)) {
|
|
3397
|
-
console.error(
|
|
3941
|
+
console.error(chalk17.red(`Unknown compression: "${options.compression}". Use one of ${formats.compressionAlgorithms.join(", ")}.`));
|
|
3398
3942
|
process.exit(1);
|
|
3399
3943
|
}
|
|
3400
3944
|
if (options.archive && !formats.archiveAlgorithms.includes(options.archive)) {
|
|
3401
|
-
console.error(
|
|
3945
|
+
console.error(chalk17.red(`Unknown archive: "${options.archive}". Use one of ${formats.archiveAlgorithms.join(", ")}.`));
|
|
3402
3946
|
process.exit(1);
|
|
3403
3947
|
}
|
|
3404
3948
|
const exportOptions = {
|
|
@@ -3428,10 +3972,10 @@ function registerTableCommands(program) {
|
|
|
3428
3972
|
const outFile = options.out ?? deriveOutFile(resolved.entityId, format2.extension, options.archive, options.compression);
|
|
3429
3973
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
3430
3974
|
fs4.writeFileSync(outFile, buffer);
|
|
3431
|
-
console.log(
|
|
3975
|
+
console.log(chalk17.green(`Table streamed to ${outFile}`));
|
|
3432
3976
|
} else {
|
|
3433
3977
|
const exportId = await api.storage.exportTable(resolved, format2.id, exportOptions);
|
|
3434
|
-
console.log(
|
|
3978
|
+
console.log(chalk17.green(`Export queued (ID: ${exportId}).`));
|
|
3435
3979
|
console.log(`Poll progress: diafunc table exports get ${exportId} --ref ${ref}`);
|
|
3436
3980
|
}
|
|
3437
3981
|
} catch (error) {
|
|
@@ -3440,7 +3984,7 @@ function registerTableCommands(program) {
|
|
|
3440
3984
|
});
|
|
3441
3985
|
table.command("export-formats").description("List supported export formats").action(async (_options, cmd) => {
|
|
3442
3986
|
try {
|
|
3443
|
-
const outputFormat =
|
|
3987
|
+
const outputFormat = getOutputFormat7(cmd);
|
|
3444
3988
|
const api = createApiClient();
|
|
3445
3989
|
const response = await api.storage.getSupportedExportFormats();
|
|
3446
3990
|
if (outputFormat === "json") {
|
|
@@ -3456,8 +4000,8 @@ function registerTableCommands(program) {
|
|
|
3456
4000
|
knownLimitations: f.knownLimitations.join(" / ")
|
|
3457
4001
|
}));
|
|
3458
4002
|
format(rows, { format: outputFormat, columns: ["id", "displayName", "category", "extension", "mimeType", "knownLimitations"] });
|
|
3459
|
-
console.log(
|
|
3460
|
-
console.log(
|
|
4003
|
+
console.log(chalk17.dim(`Compression: ${response.compressionAlgorithms.join(", ")}`));
|
|
4004
|
+
console.log(chalk17.dim(`Archive: ${response.archiveAlgorithms.join(", ")}`));
|
|
3461
4005
|
} catch (error) {
|
|
3462
4006
|
handleError(error);
|
|
3463
4007
|
}
|
|
@@ -3465,7 +4009,7 @@ function registerTableCommands(program) {
|
|
|
3465
4009
|
const exportsCmd = table.command("exports").description("Track and download async table exports");
|
|
3466
4010
|
exportsCmd.command("list").description("List async exports for a table entity").argument("<ref>", "Table entity reference").action(async (ref, _options, cmd) => {
|
|
3467
4011
|
try {
|
|
3468
|
-
const outputFormat =
|
|
4012
|
+
const outputFormat = getOutputFormat7(cmd);
|
|
3469
4013
|
const overrides = getOverrides6(cmd);
|
|
3470
4014
|
const resolved = parseEntityReference(ref, overrides);
|
|
3471
4015
|
const api = createApiClient();
|
|
@@ -3475,7 +4019,7 @@ function registerTableCommands(program) {
|
|
|
3475
4019
|
return;
|
|
3476
4020
|
}
|
|
3477
4021
|
if (exports.length === 0) {
|
|
3478
|
-
console.log(
|
|
4022
|
+
console.log(chalk17.dim("No exports found."));
|
|
3479
4023
|
return;
|
|
3480
4024
|
}
|
|
3481
4025
|
const rows = exports.map((e) => ({
|
|
@@ -3493,14 +4037,14 @@ function registerTableCommands(program) {
|
|
|
3493
4037
|
});
|
|
3494
4038
|
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) => {
|
|
3495
4039
|
try {
|
|
3496
|
-
const outputFormat =
|
|
4040
|
+
const outputFormat = getOutputFormat7(cmd);
|
|
3497
4041
|
const overrides = getOverrides6(cmd);
|
|
3498
4042
|
const resolved = parseEntityReference(options.ref, overrides);
|
|
3499
4043
|
const api = createApiClient();
|
|
3500
4044
|
const exports = await api.storage.listExports(resolved);
|
|
3501
4045
|
const exp = exports.find((e) => e.exportId === exportId);
|
|
3502
4046
|
if (!exp) {
|
|
3503
|
-
console.error(
|
|
4047
|
+
console.error(chalk17.red(`Export ${exportId} not found for ref ${options.ref}.`));
|
|
3504
4048
|
process.exit(1);
|
|
3505
4049
|
}
|
|
3506
4050
|
if (outputFormat === "json") {
|
|
@@ -3509,11 +4053,11 @@ function registerTableCommands(program) {
|
|
|
3509
4053
|
}
|
|
3510
4054
|
if (exp.finished === null) {
|
|
3511
4055
|
const pct = Math.round((exp.progress ?? 0) * 100);
|
|
3512
|
-
console.log(
|
|
4056
|
+
console.log(chalk17.dim(`Export in progress: ${pct}% \u2014 check again later.`));
|
|
3513
4057
|
return;
|
|
3514
4058
|
}
|
|
3515
4059
|
if (!exp.succeeded) {
|
|
3516
|
-
console.error(
|
|
4060
|
+
console.error(chalk17.red(`Export failed: ${exp.error}`));
|
|
3517
4061
|
process.exit(1);
|
|
3518
4062
|
}
|
|
3519
4063
|
const outFile = options.out ?? exp.filename;
|
|
@@ -3521,7 +4065,7 @@ function registerTableCommands(program) {
|
|
|
3521
4065
|
const response = await api.storage.downloadExport(resolved, exportId, exp.filename);
|
|
3522
4066
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
3523
4067
|
fs4.writeFileSync(outFile, buffer);
|
|
3524
|
-
console.log(
|
|
4068
|
+
console.log(chalk17.green(`Export saved to ${outFile}`));
|
|
3525
4069
|
} catch (error) {
|
|
3526
4070
|
handleError(error);
|
|
3527
4071
|
}
|
|
@@ -3533,7 +4077,7 @@ function registerTableCommands(program) {
|
|
|
3533
4077
|
const resolved = parseEntityReference(ref, overrides);
|
|
3534
4078
|
const api = createApiClient();
|
|
3535
4079
|
await api.storage.appendRow(resolved);
|
|
3536
|
-
console.log(
|
|
4080
|
+
console.log(chalk17.green("Row appended."));
|
|
3537
4081
|
} catch (error) {
|
|
3538
4082
|
handleError(error);
|
|
3539
4083
|
}
|
|
@@ -3544,7 +4088,7 @@ function registerTableCommands(program) {
|
|
|
3544
4088
|
const resolved = parseEntityReference(ref, overrides);
|
|
3545
4089
|
const api = createApiClient();
|
|
3546
4090
|
await api.storage.insertRow(resolved, parseInt(index, 10));
|
|
3547
|
-
console.log(
|
|
4091
|
+
console.log(chalk17.green(`Row inserted at index ${index}.`));
|
|
3548
4092
|
} catch (error) {
|
|
3549
4093
|
handleError(error);
|
|
3550
4094
|
}
|
|
@@ -3555,7 +4099,7 @@ function registerTableCommands(program) {
|
|
|
3555
4099
|
const resolved = parseEntityReference(ref, overrides);
|
|
3556
4100
|
const api = createApiClient();
|
|
3557
4101
|
await api.storage.removeRow(resolved, parseInt(index, 10));
|
|
3558
|
-
console.log(
|
|
4102
|
+
console.log(chalk17.green(`Row ${index} removed.`));
|
|
3559
4103
|
} catch (error) {
|
|
3560
4104
|
handleError(error);
|
|
3561
4105
|
}
|
|
@@ -3566,7 +4110,7 @@ function registerTableCommands(program) {
|
|
|
3566
4110
|
const resolved = parseEntityReference(ref, overrides);
|
|
3567
4111
|
const api = createApiClient();
|
|
3568
4112
|
await api.storage.deleteRow(resolved, parseInt(index, 10));
|
|
3569
|
-
console.log(
|
|
4113
|
+
console.log(chalk17.green(`Row ${index} deleted.`));
|
|
3570
4114
|
} catch (error) {
|
|
3571
4115
|
handleError(error);
|
|
3572
4116
|
}
|
|
@@ -3578,7 +4122,7 @@ function registerTableCommands(program) {
|
|
|
3578
4122
|
const resolved = parseEntityReference(ref, overrides);
|
|
3579
4123
|
const api = createApiClient();
|
|
3580
4124
|
await api.storage.appendColumn(resolved);
|
|
3581
|
-
console.log(
|
|
4125
|
+
console.log(chalk17.green("Column appended."));
|
|
3582
4126
|
} catch (error) {
|
|
3583
4127
|
handleError(error);
|
|
3584
4128
|
}
|
|
@@ -3589,7 +4133,7 @@ function registerTableCommands(program) {
|
|
|
3589
4133
|
const resolved = parseEntityReference(ref, overrides);
|
|
3590
4134
|
const api = createApiClient();
|
|
3591
4135
|
await api.storage.insertColumn(resolved, parseInt(index, 10));
|
|
3592
|
-
console.log(
|
|
4136
|
+
console.log(chalk17.green(`Column inserted at index ${index}.`));
|
|
3593
4137
|
} catch (error) {
|
|
3594
4138
|
handleError(error);
|
|
3595
4139
|
}
|
|
@@ -3600,7 +4144,7 @@ function registerTableCommands(program) {
|
|
|
3600
4144
|
const resolved = parseEntityReference(ref, overrides);
|
|
3601
4145
|
const api = createApiClient();
|
|
3602
4146
|
await api.storage.removeColumn(resolved, parseInt(index, 10));
|
|
3603
|
-
console.log(
|
|
4147
|
+
console.log(chalk17.green(`Column ${index} removed.`));
|
|
3604
4148
|
} catch (error) {
|
|
3605
4149
|
handleError(error);
|
|
3606
4150
|
}
|
|
@@ -3611,13 +4155,13 @@ function registerTableCommands(program) {
|
|
|
3611
4155
|
const resolved = parseEntityReference(ref, overrides);
|
|
3612
4156
|
const api = createApiClient();
|
|
3613
4157
|
await api.storage.deleteColumn(resolved, parseInt(index, 10));
|
|
3614
|
-
console.log(
|
|
4158
|
+
console.log(chalk17.green(`Column ${index} deleted.`));
|
|
3615
4159
|
} catch (error) {
|
|
3616
4160
|
handleError(error);
|
|
3617
4161
|
}
|
|
3618
4162
|
});
|
|
3619
|
-
const
|
|
3620
|
-
|
|
4163
|
+
const cell2 = table.command("cell").description("Manage table cells");
|
|
4164
|
+
cell2.command("set").description("Set a cell value").argument("<ref>", "Table entity reference").argument("<row>", "Row index").argument("<col>", "Column index").argument("<value>", "Cell value").action(async (ref, row2, col, value, _options, cmd) => {
|
|
3621
4165
|
try {
|
|
3622
4166
|
const overrides = getOverrides6(cmd);
|
|
3623
4167
|
const resolved = parseEntityReference(ref, overrides);
|
|
@@ -3628,18 +4172,18 @@ function registerTableCommands(program) {
|
|
|
3628
4172
|
value,
|
|
3629
4173
|
type: "text"
|
|
3630
4174
|
}]);
|
|
3631
|
-
console.log(
|
|
4175
|
+
console.log(chalk17.green(`Cell [${row2}, ${col}] set to "${value}".`));
|
|
3632
4176
|
} catch (error) {
|
|
3633
4177
|
handleError(error);
|
|
3634
4178
|
}
|
|
3635
4179
|
});
|
|
3636
|
-
|
|
4180
|
+
cell2.command("delete").description("Delete a cell value").argument("<ref>", "Table entity reference").argument("<row>", "Row index").argument("<col>", "Column index").action(async (ref, row2, col, _options, cmd) => {
|
|
3637
4181
|
try {
|
|
3638
4182
|
const overrides = getOverrides6(cmd);
|
|
3639
4183
|
const resolved = parseEntityReference(ref, overrides);
|
|
3640
4184
|
const api = createApiClient();
|
|
3641
4185
|
await api.storage.removeCell(resolved, parseInt(row2, 10), parseInt(col, 10));
|
|
3642
|
-
console.log(
|
|
4186
|
+
console.log(chalk17.green(`Cell [${row2}, ${col}] deleted.`));
|
|
3643
4187
|
} catch (error) {
|
|
3644
4188
|
handleError(error);
|
|
3645
4189
|
}
|
|
@@ -3651,7 +4195,7 @@ function registerTableCommands(program) {
|
|
|
3651
4195
|
const resolved = parseEntityReference(ref, overrides);
|
|
3652
4196
|
const api = createApiClient();
|
|
3653
4197
|
await api.storage.clearTable(resolved);
|
|
3654
|
-
console.log(
|
|
4198
|
+
console.log(chalk17.green("Table cleared."));
|
|
3655
4199
|
} catch (error) {
|
|
3656
4200
|
handleError(error);
|
|
3657
4201
|
}
|
|
@@ -3659,10 +4203,10 @@ function registerTableCommands(program) {
|
|
|
3659
4203
|
}
|
|
3660
4204
|
|
|
3661
4205
|
// src/commands/notebook/index.ts
|
|
3662
|
-
import
|
|
4206
|
+
import chalk18 from "chalk";
|
|
3663
4207
|
import * as fs5 from "fs";
|
|
3664
4208
|
import * as path4 from "path";
|
|
3665
|
-
function
|
|
4209
|
+
function getOutputFormat8(cmd) {
|
|
3666
4210
|
const config = loadConfig();
|
|
3667
4211
|
const globalOpts = cmd.optsWithGlobals();
|
|
3668
4212
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -3681,7 +4225,7 @@ function registerNotebookCommands(program) {
|
|
|
3681
4225
|
const request = { rootEntityIds: notebookIds, dataFormat: options.data };
|
|
3682
4226
|
if (options.async) {
|
|
3683
4227
|
const bundleId = await api.storage.exportBundle(ref.projectId, ref.projectBranch, request);
|
|
3684
|
-
console.log(
|
|
4228
|
+
console.log(chalk18.green(`Export queued (bundle ID: ${bundleId}).`));
|
|
3685
4229
|
console.log(`Poll progress: diafunc notebook bundles ${project}`);
|
|
3686
4230
|
return;
|
|
3687
4231
|
}
|
|
@@ -3689,14 +4233,14 @@ function registerNotebookCommands(program) {
|
|
|
3689
4233
|
const outFile = options.out ?? "notebooks.dfnb";
|
|
3690
4234
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
3691
4235
|
fs5.writeFileSync(outFile, buffer);
|
|
3692
|
-
console.log(
|
|
4236
|
+
console.log(chalk18.green(`Bundle written to ${outFile} (${buffer.length} bytes, ${notebookIds.length} notebook(s)).`));
|
|
3693
4237
|
} catch (error) {
|
|
3694
4238
|
handleError(error);
|
|
3695
4239
|
}
|
|
3696
4240
|
});
|
|
3697
4241
|
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), overwrite, or skip", "copy").option("--preview", "Show the bundle inventory without importing").action(async (project, file, options, cmd) => {
|
|
3698
4242
|
try {
|
|
3699
|
-
const outputFormat =
|
|
4243
|
+
const outputFormat = getOutputFormat8(cmd);
|
|
3700
4244
|
const overrides = getOverrides7(cmd);
|
|
3701
4245
|
const ref = parseProjectReference(project, overrides);
|
|
3702
4246
|
const api = createApiClient();
|
|
@@ -3710,9 +4254,9 @@ function registerNotebookCommands(program) {
|
|
|
3710
4254
|
format(preview, { format: outputFormat });
|
|
3711
4255
|
return;
|
|
3712
4256
|
}
|
|
3713
|
-
console.log(
|
|
4257
|
+
console.log(chalk18.bold(`${preview.kind} bundle \xB7 ${preview.entityCount} entities`));
|
|
3714
4258
|
if (preview.sourceProjectId) {
|
|
3715
|
-
console.log(
|
|
4259
|
+
console.log(chalk18.dim(`from ${preview.sourceProjectId}/${preview.sourceProjectBranch}` + (preview.createdBy ? ` \xB7 by ${preview.createdBy}` : "")));
|
|
3716
4260
|
}
|
|
3717
4261
|
const counts = /* @__PURE__ */ new Map();
|
|
3718
4262
|
for (const e of preview.entities ?? []) {
|
|
@@ -3722,9 +4266,9 @@ function registerNotebookCommands(program) {
|
|
|
3722
4266
|
console.log(` ${type}: ${count}`);
|
|
3723
4267
|
}
|
|
3724
4268
|
if (preview.lossinessNotes && preview.lossinessNotes.length > 0) {
|
|
3725
|
-
console.log(
|
|
4269
|
+
console.log(chalk18.yellow("Lossiness:"));
|
|
3726
4270
|
for (const note of preview.lossinessNotes) {
|
|
3727
|
-
console.log(
|
|
4271
|
+
console.log(chalk18.yellow(` - ${note}`));
|
|
3728
4272
|
}
|
|
3729
4273
|
}
|
|
3730
4274
|
return;
|
|
@@ -3734,7 +4278,7 @@ function registerNotebookCommands(program) {
|
|
|
3734
4278
|
format(result, { format: outputFormat });
|
|
3735
4279
|
return;
|
|
3736
4280
|
}
|
|
3737
|
-
console.log(
|
|
4281
|
+
console.log(chalk18.green(`Imported ${result.entityCount} entities, ${result.linkCount} links.`));
|
|
3738
4282
|
console.log(`Notebook id(s): ${result.rootEntityIds.join(", ")}`);
|
|
3739
4283
|
} catch (error) {
|
|
3740
4284
|
handleError(error);
|
|
@@ -3742,7 +4286,7 @@ function registerNotebookCommands(program) {
|
|
|
3742
4286
|
});
|
|
3743
4287
|
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) => {
|
|
3744
4288
|
try {
|
|
3745
|
-
const outputFormat =
|
|
4289
|
+
const outputFormat = getOutputFormat8(cmd);
|
|
3746
4290
|
const overrides = getOverrides7(cmd);
|
|
3747
4291
|
const ref = parseProjectReference(project, overrides);
|
|
3748
4292
|
const api = createApiClient();
|
|
@@ -3771,7 +4315,7 @@ function registerNotebookCommands(program) {
|
|
|
3771
4315
|
}
|
|
3772
4316
|
|
|
3773
4317
|
// src/commands/function/index.ts
|
|
3774
|
-
import
|
|
4318
|
+
import chalk19 from "chalk";
|
|
3775
4319
|
import * as fs6 from "fs";
|
|
3776
4320
|
import * as os2 from "os";
|
|
3777
4321
|
import * as path5 from "path";
|
|
@@ -3827,7 +4371,7 @@ function buildFunctionEntity(args) {
|
|
|
3827
4371
|
}
|
|
3828
4372
|
|
|
3829
4373
|
// src/commands/function/index.ts
|
|
3830
|
-
function
|
|
4374
|
+
function getOutputFormat9(cmd) {
|
|
3831
4375
|
const config = loadConfig();
|
|
3832
4376
|
const globalOpts = cmd.optsWithGlobals();
|
|
3833
4377
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -3850,7 +4394,7 @@ function registerFunctionCommands(program) {
|
|
|
3850
4394
|
const fn = program.command("function").description("Execute and manage functions");
|
|
3851
4395
|
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) => {
|
|
3852
4396
|
try {
|
|
3853
|
-
const outputFormat =
|
|
4397
|
+
const outputFormat = getOutputFormat9(cmd);
|
|
3854
4398
|
const overrides = getOverrides8(cmd);
|
|
3855
4399
|
const resolved = parseEntityReference(ref, overrides);
|
|
3856
4400
|
const api = createApiClient();
|
|
@@ -3893,7 +4437,7 @@ function registerFunctionCommands(program) {
|
|
|
3893
4437
|
}, isAsync);
|
|
3894
4438
|
if (isAsync) {
|
|
3895
4439
|
if (outputFormat === "human") {
|
|
3896
|
-
console.log(
|
|
4440
|
+
console.log(chalk19.green("Function launched."));
|
|
3897
4441
|
console.log(` Evaluation ID: ${result.evaluationId}`);
|
|
3898
4442
|
} else {
|
|
3899
4443
|
format({ evaluationId: result.evaluationId }, { format: outputFormat });
|
|
@@ -3901,14 +4445,14 @@ function registerFunctionCommands(program) {
|
|
|
3901
4445
|
} else {
|
|
3902
4446
|
if (outputFormat === "human") {
|
|
3903
4447
|
if (result.successful) {
|
|
3904
|
-
console.log(
|
|
4448
|
+
console.log(chalk19.green("Function completed successfully."));
|
|
3905
4449
|
if (result.result) {
|
|
3906
4450
|
console.log(` Result: ${result.result}`);
|
|
3907
4451
|
}
|
|
3908
4452
|
const duration = result.completed - result.started;
|
|
3909
4453
|
console.log(` Duration: ${duration}ms`);
|
|
3910
4454
|
} else {
|
|
3911
|
-
console.log(
|
|
4455
|
+
console.log(chalk19.red("Function failed."));
|
|
3912
4456
|
console.log(` Error: ${result.error}`);
|
|
3913
4457
|
if (result.lineNumber > 0) {
|
|
3914
4458
|
console.log(` Line: ${result.lineNumber}, Column: ${result.columnNumber}`);
|
|
@@ -3916,7 +4460,7 @@ function registerFunctionCommands(program) {
|
|
|
3916
4460
|
}
|
|
3917
4461
|
if (result.outputs?.length) {
|
|
3918
4462
|
console.log();
|
|
3919
|
-
console.log(
|
|
4463
|
+
console.log(chalk19.bold("Outputs:"));
|
|
3920
4464
|
for (const out of result.outputs) {
|
|
3921
4465
|
console.log(` [${out.type}] ${out.output}`);
|
|
3922
4466
|
}
|
|
@@ -3931,7 +4475,7 @@ function registerFunctionCommands(program) {
|
|
|
3931
4475
|
});
|
|
3932
4476
|
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) => {
|
|
3933
4477
|
try {
|
|
3934
|
-
const outputFormat =
|
|
4478
|
+
const outputFormat = getOutputFormat9(cmd);
|
|
3935
4479
|
const overrides = getOverrides8(cmd);
|
|
3936
4480
|
const resolved = parseEntityReference(ref, overrides);
|
|
3937
4481
|
const api = createApiClient();
|
|
@@ -3965,16 +4509,16 @@ function registerFunctionCommands(program) {
|
|
|
3965
4509
|
});
|
|
3966
4510
|
fn.command("outputs").description("Get outputs for an evaluation").argument("<projectId>", "Project ID").argument("<evaluationId>", "Evaluation ID").action(async (projectId, evaluationId, _options, cmd) => {
|
|
3967
4511
|
try {
|
|
3968
|
-
const outputFormat =
|
|
4512
|
+
const outputFormat = getOutputFormat9(cmd);
|
|
3969
4513
|
const api = createApiClient();
|
|
3970
4514
|
const outputs = await api.evaluation.getOutputs(projectId, evaluationId);
|
|
3971
4515
|
if (outputFormat === "human") {
|
|
3972
4516
|
if (outputs.length === 0) {
|
|
3973
|
-
console.log(
|
|
4517
|
+
console.log(chalk19.dim("No outputs."));
|
|
3974
4518
|
}
|
|
3975
4519
|
for (const out of outputs) {
|
|
3976
4520
|
const time = new Date(out.timestamp).toISOString();
|
|
3977
|
-
console.log(`${
|
|
4521
|
+
console.log(`${chalk19.dim(time)} [${out.type}] ${out.output}`);
|
|
3978
4522
|
}
|
|
3979
4523
|
} else {
|
|
3980
4524
|
format(outputs, { format: outputFormat });
|
|
@@ -3985,7 +4529,7 @@ function registerFunctionCommands(program) {
|
|
|
3985
4529
|
});
|
|
3986
4530
|
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) => {
|
|
3987
4531
|
try {
|
|
3988
|
-
const outputFormat =
|
|
4532
|
+
const outputFormat = getOutputFormat9(cmd);
|
|
3989
4533
|
const overrides = getOverrides8(cmd);
|
|
3990
4534
|
const resolved = parseEntityReference(ref, overrides);
|
|
3991
4535
|
const api = createApiClient();
|
|
@@ -4024,14 +4568,14 @@ function registerFunctionCommands(program) {
|
|
|
4024
4568
|
hour,
|
|
4025
4569
|
evaluationId
|
|
4026
4570
|
);
|
|
4027
|
-
console.log(
|
|
4571
|
+
console.log(chalk19.green(`Evaluation ${evaluationId} stopped.`));
|
|
4028
4572
|
} catch (error) {
|
|
4029
4573
|
handleError(error);
|
|
4030
4574
|
}
|
|
4031
4575
|
});
|
|
4032
4576
|
fn.command("engines").description("List available engines").action(async (_options, cmd) => {
|
|
4033
4577
|
try {
|
|
4034
|
-
const outputFormat =
|
|
4578
|
+
const outputFormat = getOutputFormat9(cmd);
|
|
4035
4579
|
const api = createApiClient();
|
|
4036
4580
|
const engines = await api.evaluation.getEngines();
|
|
4037
4581
|
format(engines, { format: outputFormat });
|
|
@@ -4041,7 +4585,7 @@ function registerFunctionCommands(program) {
|
|
|
4041
4585
|
});
|
|
4042
4586
|
fn.command("last-evaluation").description("Show the most recent evaluation of a function").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
|
|
4043
4587
|
try {
|
|
4044
|
-
const outputFormat =
|
|
4588
|
+
const outputFormat = getOutputFormat9(cmd);
|
|
4045
4589
|
const overrides = getOverrides8(cmd);
|
|
4046
4590
|
const resolved = parseEntityReference(ref, overrides);
|
|
4047
4591
|
const api = createApiClient();
|
|
@@ -4072,7 +4616,7 @@ function registerFunctionCommands(program) {
|
|
|
4072
4616
|
sourceCode
|
|
4073
4617
|
});
|
|
4074
4618
|
await api.storage.saveEntities([entity]);
|
|
4075
|
-
console.log(
|
|
4619
|
+
console.log(chalk19.green(`Function "${resolved.entityId}" created (${options.language}).`));
|
|
4076
4620
|
} catch (error) {
|
|
4077
4621
|
handleError(error);
|
|
4078
4622
|
}
|
|
@@ -4087,7 +4631,7 @@ function registerFunctionCommands(program) {
|
|
|
4087
4631
|
const sourceCode = decodeFunctionSource(entity);
|
|
4088
4632
|
if (options.out) {
|
|
4089
4633
|
fs6.writeFileSync(options.out, sourceCode);
|
|
4090
|
-
console.log(
|
|
4634
|
+
console.log(chalk19.green(`Source written to ${options.out}`));
|
|
4091
4635
|
} else {
|
|
4092
4636
|
process.stdout.write(sourceCode);
|
|
4093
4637
|
if (!sourceCode.endsWith("\n")) process.stdout.write("\n");
|
|
@@ -4111,7 +4655,7 @@ function registerFunctionCommands(program) {
|
|
|
4111
4655
|
process.stdin.on("error", reject);
|
|
4112
4656
|
});
|
|
4113
4657
|
await api.storage.saveEntityContentBase64(resolved, encodeFunctionSource(sourceCode));
|
|
4114
|
-
console.log(
|
|
4658
|
+
console.log(chalk19.green(`Source updated for "${resolved.entityId}".`));
|
|
4115
4659
|
} catch (error) {
|
|
4116
4660
|
handleError(error);
|
|
4117
4661
|
}
|
|
@@ -4136,11 +4680,11 @@ function registerFunctionCommands(program) {
|
|
|
4136
4680
|
const newSource = fs6.readFileSync(tmpFile, "utf-8");
|
|
4137
4681
|
fs6.unlinkSync(tmpFile);
|
|
4138
4682
|
if (newSource === currentSource) {
|
|
4139
|
-
console.log(
|
|
4683
|
+
console.log(chalk19.dim("No changes."));
|
|
4140
4684
|
return;
|
|
4141
4685
|
}
|
|
4142
4686
|
await api.storage.saveEntityContentBase64(resolved, encodeFunctionSource(newSource));
|
|
4143
|
-
console.log(
|
|
4687
|
+
console.log(chalk19.green(`Source updated for "${resolved.entityId}".`));
|
|
4144
4688
|
} catch (error) {
|
|
4145
4689
|
handleError(error);
|
|
4146
4690
|
}
|
|
@@ -4157,8 +4701,8 @@ function extensionFor(language) {
|
|
|
4157
4701
|
}
|
|
4158
4702
|
|
|
4159
4703
|
// src/commands/trigger/index.ts
|
|
4160
|
-
import
|
|
4161
|
-
function
|
|
4704
|
+
import chalk20 from "chalk";
|
|
4705
|
+
function getOutputFormat10(cmd) {
|
|
4162
4706
|
const config = loadConfig();
|
|
4163
4707
|
const globalOpts = cmd.optsWithGlobals();
|
|
4164
4708
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -4171,7 +4715,7 @@ function registerTriggerCommands(program) {
|
|
|
4171
4715
|
const trigger = program.command("trigger").description("Manage function triggers");
|
|
4172
4716
|
trigger.command("list").description("List triggers for a function").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
|
|
4173
4717
|
try {
|
|
4174
|
-
const outputFormat =
|
|
4718
|
+
const outputFormat = getOutputFormat10(cmd);
|
|
4175
4719
|
const overrides = getOverrides9(cmd);
|
|
4176
4720
|
const resolved = parseEntityReference(ref, overrides);
|
|
4177
4721
|
const api = createApiClient();
|
|
@@ -4199,7 +4743,7 @@ function registerTriggerCommands(program) {
|
|
|
4199
4743
|
});
|
|
4200
4744
|
trigger.command("get").description("Get a specific trigger").argument("<ref>", "Function entity reference").argument("<triggerId>", "Trigger ID").action(async (ref, triggerId, _options, cmd) => {
|
|
4201
4745
|
try {
|
|
4202
|
-
const outputFormat =
|
|
4746
|
+
const outputFormat = getOutputFormat10(cmd);
|
|
4203
4747
|
const overrides = getOverrides9(cmd);
|
|
4204
4748
|
const resolved = parseEntityReference(ref, overrides);
|
|
4205
4749
|
const api = createApiClient();
|
|
@@ -4227,7 +4771,7 @@ function registerTriggerCommands(program) {
|
|
|
4227
4771
|
resolved.entityBranch,
|
|
4228
4772
|
triggerId
|
|
4229
4773
|
);
|
|
4230
|
-
console.log(
|
|
4774
|
+
console.log(chalk20.green(`Trigger "${triggerId}" deleted.`));
|
|
4231
4775
|
} catch (error) {
|
|
4232
4776
|
handleError(error);
|
|
4233
4777
|
}
|
|
@@ -4275,7 +4819,7 @@ function registerTriggerCommands(program) {
|
|
|
4275
4819
|
scheduler: null,
|
|
4276
4820
|
heartbeat: null
|
|
4277
4821
|
});
|
|
4278
|
-
console.log(
|
|
4822
|
+
console.log(chalk20.green("Trigger saved."));
|
|
4279
4823
|
} catch (error) {
|
|
4280
4824
|
handleError(error);
|
|
4281
4825
|
}
|
|
@@ -4283,9 +4827,9 @@ function registerTriggerCommands(program) {
|
|
|
4283
4827
|
}
|
|
4284
4828
|
|
|
4285
4829
|
// src/commands/schedule/index.ts
|
|
4286
|
-
import
|
|
4830
|
+
import chalk21 from "chalk";
|
|
4287
4831
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
4288
|
-
function
|
|
4832
|
+
function getOutputFormat11(cmd) {
|
|
4289
4833
|
const config = loadConfig();
|
|
4290
4834
|
const globalOpts = cmd.optsWithGlobals();
|
|
4291
4835
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -4298,7 +4842,7 @@ function registerScheduleCommands(program) {
|
|
|
4298
4842
|
const schedule = program.command("schedule").description("Schedule function execution");
|
|
4299
4843
|
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) => {
|
|
4300
4844
|
try {
|
|
4301
|
-
const outputFormat =
|
|
4845
|
+
const outputFormat = getOutputFormat11(cmd);
|
|
4302
4846
|
const overrides = getOverrides10(cmd);
|
|
4303
4847
|
const resolved = parseEntityReference(ref, overrides);
|
|
4304
4848
|
const api = createApiClient();
|
|
@@ -4335,7 +4879,7 @@ function registerScheduleCommands(program) {
|
|
|
4335
4879
|
removeFunction: false
|
|
4336
4880
|
});
|
|
4337
4881
|
if (outputFormat === "human") {
|
|
4338
|
-
console.log(
|
|
4882
|
+
console.log(chalk21.green("Function scheduled."));
|
|
4339
4883
|
} else {
|
|
4340
4884
|
format(result, { format: outputFormat });
|
|
4341
4885
|
}
|
|
@@ -4360,14 +4904,14 @@ function registerScheduleCommands(program) {
|
|
|
4360
4904
|
hour,
|
|
4361
4905
|
evaluationId
|
|
4362
4906
|
);
|
|
4363
|
-
console.log(
|
|
4907
|
+
console.log(chalk21.green(`Scheduled evaluation ${evaluationId} stopped.`));
|
|
4364
4908
|
} catch (error) {
|
|
4365
4909
|
handleError(error);
|
|
4366
4910
|
}
|
|
4367
4911
|
});
|
|
4368
4912
|
schedule.command("list").description("List persistent triggers (scheduled functions are modeled as triggers)").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
|
|
4369
4913
|
try {
|
|
4370
|
-
const outputFormat =
|
|
4914
|
+
const outputFormat = getOutputFormat11(cmd);
|
|
4371
4915
|
const overrides = getOverrides10(cmd);
|
|
4372
4916
|
const resolved = parseEntityReference(ref, overrides);
|
|
4373
4917
|
const api = createApiClient();
|
|
@@ -4397,10 +4941,10 @@ function registerScheduleCommands(program) {
|
|
|
4397
4941
|
}
|
|
4398
4942
|
|
|
4399
4943
|
// src/commands/chat/index.ts
|
|
4400
|
-
import
|
|
4944
|
+
import chalk22 from "chalk";
|
|
4401
4945
|
import * as fs7 from "fs";
|
|
4402
4946
|
import * as path6 from "path";
|
|
4403
|
-
function
|
|
4947
|
+
function getOutputFormat12(cmd) {
|
|
4404
4948
|
const config = loadConfig();
|
|
4405
4949
|
const globalOpts = cmd.optsWithGlobals();
|
|
4406
4950
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -4438,7 +4982,7 @@ async function streamOneTurn(message, sessionId, projectId, branch) {
|
|
|
4438
4982
|
input = event.inputTokens;
|
|
4439
4983
|
output = event.outputTokens;
|
|
4440
4984
|
} else if (event.type === "error") {
|
|
4441
|
-
console.error(
|
|
4985
|
+
console.error(chalk22.red(`
|
|
4442
4986
|
Error: ${event.content}`));
|
|
4443
4987
|
}
|
|
4444
4988
|
} catch {
|
|
@@ -4449,19 +4993,19 @@ Error: ${event.content}`));
|
|
|
4449
4993
|
}
|
|
4450
4994
|
async function runChatRepl(options) {
|
|
4451
4995
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
4452
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
4996
|
+
const { getUpdateNotice } = await import("./update-check-L55QNPYQ.js");
|
|
4453
4997
|
let sessionId = options.session;
|
|
4454
|
-
console.log(
|
|
4998
|
+
console.log(chalk22.bold("Diafunc chat") + chalk22.dim(" \xB7 /help for commands, /quit to exit"));
|
|
4455
4999
|
if (sessionId) {
|
|
4456
|
-
console.log(
|
|
5000
|
+
console.log(chalk22.dim(`Continuing session ${sessionId}`));
|
|
4457
5001
|
}
|
|
4458
5002
|
const notice = await getUpdateNotice();
|
|
4459
|
-
if (notice) console.log(
|
|
5003
|
+
if (notice) console.log(chalk22.dim(notice));
|
|
4460
5004
|
console.log();
|
|
4461
5005
|
for (; ; ) {
|
|
4462
5006
|
let line;
|
|
4463
5007
|
try {
|
|
4464
|
-
line = await promptInput({ message:
|
|
5008
|
+
line = await promptInput({ message: chalk22.cyan.bold("you >") });
|
|
4465
5009
|
} catch {
|
|
4466
5010
|
console.log();
|
|
4467
5011
|
return;
|
|
@@ -4478,37 +5022,37 @@ async function runChatRepl(options) {
|
|
|
4478
5022
|
return;
|
|
4479
5023
|
case "new":
|
|
4480
5024
|
sessionId = void 0;
|
|
4481
|
-
console.log(
|
|
5025
|
+
console.log(chalk22.dim("Started a new session."));
|
|
4482
5026
|
continue;
|
|
4483
5027
|
case "session":
|
|
4484
5028
|
if (!arg) {
|
|
4485
|
-
console.log(
|
|
5029
|
+
console.log(chalk22.dim(`Current session: ${sessionId ?? "(new)"}`));
|
|
4486
5030
|
} else {
|
|
4487
5031
|
sessionId = arg;
|
|
4488
|
-
console.log(
|
|
5032
|
+
console.log(chalk22.dim(`Switched to session ${sessionId}`));
|
|
4489
5033
|
}
|
|
4490
5034
|
continue;
|
|
4491
5035
|
case "help":
|
|
4492
5036
|
case "h":
|
|
4493
5037
|
case "?":
|
|
4494
|
-
console.log(
|
|
4495
|
-
console.log(
|
|
4496
|
-
console.log(
|
|
5038
|
+
console.log(chalk22.dim(" /new start a new session"));
|
|
5039
|
+
console.log(chalk22.dim(" /session [id] switch to a session (no id = show current)"));
|
|
5040
|
+
console.log(chalk22.dim(" /quit exit the REPL"));
|
|
4497
5041
|
continue;
|
|
4498
5042
|
default:
|
|
4499
|
-
console.log(
|
|
5043
|
+
console.log(chalk22.dim(`Unknown command: /${cmd}. Try /help.`));
|
|
4500
5044
|
continue;
|
|
4501
5045
|
}
|
|
4502
5046
|
}
|
|
4503
|
-
process.stdout.write(
|
|
5047
|
+
process.stdout.write(chalk22.magenta.bold("diafunc > "));
|
|
4504
5048
|
try {
|
|
4505
5049
|
const result = await streamOneTurn(trimmed, sessionId, options.project, options.branch);
|
|
4506
5050
|
sessionId = result.sessionId || sessionId;
|
|
4507
5051
|
console.log();
|
|
4508
|
-
console.log(
|
|
5052
|
+
console.log(chalk22.dim(`[session ${sessionId} \xB7 ${result.input} in / ${result.output} out]`));
|
|
4509
5053
|
console.log();
|
|
4510
5054
|
} catch (error) {
|
|
4511
|
-
console.error(
|
|
5055
|
+
console.error(chalk22.red(`
|
|
4512
5056
|
Request failed: ${error.message}`));
|
|
4513
5057
|
}
|
|
4514
5058
|
}
|
|
@@ -4524,7 +5068,7 @@ function registerChatCommands(program) {
|
|
|
4524
5068
|
});
|
|
4525
5069
|
chat.command("send").description("Send a chat message (blocking)").argument("<message>", "Message to send").option("--project <id>", "Project context").option("--branch <branch>", "Project branch", "main").option("--session <id>", "Session ID to continue").action(async (message, options, cmd) => {
|
|
4526
5070
|
try {
|
|
4527
|
-
const outputFormat =
|
|
5071
|
+
const outputFormat = getOutputFormat12(cmd);
|
|
4528
5072
|
const api = createApiClient();
|
|
4529
5073
|
const response = await api.language.chat({
|
|
4530
5074
|
message,
|
|
@@ -4535,7 +5079,7 @@ function registerChatCommands(program) {
|
|
|
4535
5079
|
if (outputFormat === "human") {
|
|
4536
5080
|
console.log(response.content);
|
|
4537
5081
|
console.log();
|
|
4538
|
-
console.log(
|
|
5082
|
+
console.log(chalk22.dim(`Session: ${response.sessionId} | Tokens: ${response.inputTokens} in, ${response.outputTokens} out`));
|
|
4539
5083
|
} else {
|
|
4540
5084
|
format(response, { format: outputFormat });
|
|
4541
5085
|
}
|
|
@@ -4545,7 +5089,7 @@ function registerChatCommands(program) {
|
|
|
4545
5089
|
});
|
|
4546
5090
|
chat.command("stream").description("Send a chat message (streaming)").argument("<message>", "Message to send").option("--project <id>", "Project context").option("--branch <branch>", "Project branch", "main").option("--session <id>", "Session ID to continue").action(async (message, options, cmd) => {
|
|
4547
5091
|
try {
|
|
4548
|
-
const outputFormat =
|
|
5092
|
+
const outputFormat = getOutputFormat12(cmd);
|
|
4549
5093
|
const api = createApiClient();
|
|
4550
5094
|
const response = await api.language.chatStream({
|
|
4551
5095
|
message,
|
|
@@ -4600,9 +5144,9 @@ function registerChatCommands(program) {
|
|
|
4600
5144
|
sessionId = event.sessionId ?? "";
|
|
4601
5145
|
console.log();
|
|
4602
5146
|
console.log();
|
|
4603
|
-
console.log(
|
|
5147
|
+
console.log(chalk22.dim(`Session: ${sessionId} | Tokens: ${event.inputTokens} in, ${event.outputTokens} out`));
|
|
4604
5148
|
} else if (event.type === "error") {
|
|
4605
|
-
console.error(
|
|
5149
|
+
console.error(chalk22.red(`
|
|
4606
5150
|
Error: ${event.content}`));
|
|
4607
5151
|
}
|
|
4608
5152
|
} catch {
|
|
@@ -4618,7 +5162,7 @@ Error: ${event.content}`));
|
|
|
4618
5162
|
chat.command("upload").description("Upload a file for chat context").argument("<file>", "File to upload").action(async (file) => {
|
|
4619
5163
|
try {
|
|
4620
5164
|
if (!fs7.existsSync(file)) {
|
|
4621
|
-
console.error(
|
|
5165
|
+
console.error(chalk22.red(`File not found: ${file}`));
|
|
4622
5166
|
process.exit(1);
|
|
4623
5167
|
}
|
|
4624
5168
|
const api = createApiClient();
|
|
@@ -4627,7 +5171,7 @@ Error: ${event.content}`));
|
|
|
4627
5171
|
const formData = new FormData();
|
|
4628
5172
|
formData.append("file", blob, path6.basename(file));
|
|
4629
5173
|
const result = await api.language.upload(formData);
|
|
4630
|
-
console.log(
|
|
5174
|
+
console.log(chalk22.green(`File uploaded: ${result}`));
|
|
4631
5175
|
} catch (error) {
|
|
4632
5176
|
handleError(error);
|
|
4633
5177
|
}
|
|
@@ -4635,7 +5179,7 @@ Error: ${event.content}`));
|
|
|
4635
5179
|
const session = chat.command("session").description("Manage chat sessions");
|
|
4636
5180
|
session.command("list").description("List chat sessions").action(async (_options, cmd) => {
|
|
4637
5181
|
try {
|
|
4638
|
-
const outputFormat =
|
|
5182
|
+
const outputFormat = getOutputFormat12(cmd);
|
|
4639
5183
|
const api = createApiClient();
|
|
4640
5184
|
const sessions = await api.language.getSessions();
|
|
4641
5185
|
format(sessions, {
|
|
@@ -4650,22 +5194,22 @@ Error: ${event.content}`));
|
|
|
4650
5194
|
try {
|
|
4651
5195
|
const api = createApiClient();
|
|
4652
5196
|
await api.language.deleteSession(sessionId);
|
|
4653
|
-
console.log(
|
|
5197
|
+
console.log(chalk22.green(`Session "${sessionId}" deleted.`));
|
|
4654
5198
|
} catch (error) {
|
|
4655
5199
|
handleError(error);
|
|
4656
5200
|
}
|
|
4657
5201
|
});
|
|
4658
5202
|
session.command("show").description("Show the message history of a chat session").argument("<sessionId>", "Session ID").action(async (sessionId, _options, cmd) => {
|
|
4659
5203
|
try {
|
|
4660
|
-
const outputFormat =
|
|
5204
|
+
const outputFormat = getOutputFormat12(cmd);
|
|
4661
5205
|
const api = createApiClient();
|
|
4662
5206
|
const detail = await api.language.getSession(sessionId);
|
|
4663
5207
|
if (outputFormat === "human") {
|
|
4664
|
-
console.log(
|
|
5208
|
+
console.log(chalk22.bold(detail.title) + chalk22.dim(` (${detail.sessionId})`));
|
|
4665
5209
|
console.log();
|
|
4666
5210
|
for (const msg of detail.messages) {
|
|
4667
|
-
const role = msg.role === "user" ?
|
|
4668
|
-
console.log(`${role} ${
|
|
5211
|
+
const role = msg.role === "user" ? chalk22.cyan.bold("You") : chalk22.magenta.bold("Diafunc");
|
|
5212
|
+
console.log(`${role} ${chalk22.dim(msg.created)}`);
|
|
4669
5213
|
console.log(msg.content);
|
|
4670
5214
|
console.log();
|
|
4671
5215
|
}
|
|
@@ -4680,14 +5224,14 @@ Error: ${event.content}`));
|
|
|
4680
5224
|
try {
|
|
4681
5225
|
const api = createApiClient();
|
|
4682
5226
|
await api.language.renameSession(sessionId, title);
|
|
4683
|
-
console.log(
|
|
5227
|
+
console.log(chalk22.green(`Session "${sessionId}" renamed to "${title}".`));
|
|
4684
5228
|
} catch (error) {
|
|
4685
5229
|
handleError(error);
|
|
4686
5230
|
}
|
|
4687
5231
|
});
|
|
4688
5232
|
chat.command("usage").description("Show token usage").action(async (_options, cmd) => {
|
|
4689
5233
|
try {
|
|
4690
|
-
const outputFormat =
|
|
5234
|
+
const outputFormat = getOutputFormat12(cmd);
|
|
4691
5235
|
const api = createApiClient();
|
|
4692
5236
|
const usage = await api.language.getUsage();
|
|
4693
5237
|
format(usage, { format: outputFormat });
|
|
@@ -4698,7 +5242,7 @@ Error: ${event.content}`));
|
|
|
4698
5242
|
}
|
|
4699
5243
|
|
|
4700
5244
|
// src/commands/search/index.ts
|
|
4701
|
-
function
|
|
5245
|
+
function getOutputFormat13(cmd) {
|
|
4702
5246
|
const config = loadConfig();
|
|
4703
5247
|
const globalOpts = cmd.optsWithGlobals();
|
|
4704
5248
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -4706,7 +5250,7 @@ function getOutputFormat12(cmd) {
|
|
|
4706
5250
|
function registerSearchCommands(program) {
|
|
4707
5251
|
program.command("search").description("Search entities across projects").argument("<query>", "Search query").option("--project <id>", "Limit search to a project").option("--branch <branch>", "Project branch", "main").action(async (query, options, cmd) => {
|
|
4708
5252
|
try {
|
|
4709
|
-
const outputFormat =
|
|
5253
|
+
const outputFormat = getOutputFormat13(cmd);
|
|
4710
5254
|
const api = createApiClient();
|
|
4711
5255
|
if (options.project) {
|
|
4712
5256
|
const results = await api.storage.searchProject(
|
|
@@ -4736,124 +5280,9 @@ function registerSearchCommands(program) {
|
|
|
4736
5280
|
});
|
|
4737
5281
|
}
|
|
4738
5282
|
|
|
4739
|
-
// src/commands/group/index.ts
|
|
4740
|
-
import chalk21 from "chalk";
|
|
4741
|
-
function getOutputFormat13(cmd) {
|
|
4742
|
-
const config = loadConfig();
|
|
4743
|
-
const globalOpts = cmd.optsWithGlobals();
|
|
4744
|
-
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
4745
|
-
}
|
|
4746
|
-
function registerGroupCommands(program) {
|
|
4747
|
-
const group = program.command("group").description("Manage groups");
|
|
4748
|
-
group.command("list").description("List groups").option("--all", "List all groups (admin)").action(async (options, cmd) => {
|
|
4749
|
-
try {
|
|
4750
|
-
const outputFormat = getOutputFormat13(cmd);
|
|
4751
|
-
const api = createApiClient();
|
|
4752
|
-
const groups = options.all ? await api.admin.getAllGroups() : await api.admin.getGroups();
|
|
4753
|
-
format(groups, { format: outputFormat, columns: ["groupId", "name"] });
|
|
4754
|
-
} catch (error) {
|
|
4755
|
-
handleError(error);
|
|
4756
|
-
}
|
|
4757
|
-
});
|
|
4758
|
-
group.command("get").description("Get group details").argument("<groupId>", "Group ID").action(async (groupId, _options, cmd) => {
|
|
4759
|
-
try {
|
|
4760
|
-
const outputFormat = getOutputFormat13(cmd);
|
|
4761
|
-
const api = createApiClient();
|
|
4762
|
-
const g = await api.admin.getGroup(groupId);
|
|
4763
|
-
format(g, { format: outputFormat });
|
|
4764
|
-
} catch (error) {
|
|
4765
|
-
handleError(error);
|
|
4766
|
-
}
|
|
4767
|
-
});
|
|
4768
|
-
group.command("create").description("Create a new group").argument("<groupId>", "Group ID").option("--name <name>", "Group name").action(async (groupId, options) => {
|
|
4769
|
-
try {
|
|
4770
|
-
const api = createApiClient();
|
|
4771
|
-
await api.admin.createGroup({ groupId, name: options.name ?? groupId });
|
|
4772
|
-
console.log(chalk21.green(`Group "${groupId}" created.`));
|
|
4773
|
-
} catch (error) {
|
|
4774
|
-
handleError(error);
|
|
4775
|
-
}
|
|
4776
|
-
});
|
|
4777
|
-
group.command("update").description("Update a group").argument("<groupId>", "Group ID").requiredOption("--name <name>", "New group name").action(async (groupId, options) => {
|
|
4778
|
-
try {
|
|
4779
|
-
const api = createApiClient();
|
|
4780
|
-
await api.admin.updateGroup({ groupId, name: options.name });
|
|
4781
|
-
console.log(chalk21.green(`Group "${groupId}" updated.`));
|
|
4782
|
-
} catch (error) {
|
|
4783
|
-
handleError(error);
|
|
4784
|
-
}
|
|
4785
|
-
});
|
|
4786
|
-
group.command("delete").description("Delete a group").argument("<groupId>", "Group ID").action(async (groupId) => {
|
|
4787
|
-
try {
|
|
4788
|
-
const api = createApiClient();
|
|
4789
|
-
await api.admin.deleteGroup(groupId);
|
|
4790
|
-
console.log(chalk21.green(`Group "${groupId}" deleted.`));
|
|
4791
|
-
} catch (error) {
|
|
4792
|
-
handleError(error);
|
|
4793
|
-
}
|
|
4794
|
-
});
|
|
4795
|
-
const members = group.command("members").description("Manage group members");
|
|
4796
|
-
members.command("list").description("List group members").argument("<groupId>", "Group ID").action(async (groupId, _options, cmd) => {
|
|
4797
|
-
try {
|
|
4798
|
-
const outputFormat = getOutputFormat13(cmd);
|
|
4799
|
-
const api = createApiClient();
|
|
4800
|
-
const memberList = await api.admin.getGroupMembers(groupId);
|
|
4801
|
-
format(memberList, { format: outputFormat, columns: ["userId", "role", "joined"] });
|
|
4802
|
-
} catch (error) {
|
|
4803
|
-
handleError(error);
|
|
4804
|
-
}
|
|
4805
|
-
});
|
|
4806
|
-
members.command("invite").description("Invite a user to a group").argument("<groupId>", "Group ID").argument("<userId>", "User ID").argument("<role>", "Role").action(async (groupId, userId, role) => {
|
|
4807
|
-
try {
|
|
4808
|
-
const api = createApiClient();
|
|
4809
|
-
await api.admin.inviteGroupMember(groupId, userId, role.toUpperCase());
|
|
4810
|
-
console.log(chalk21.green(`Invited ${userId} to group "${groupId}" as ${role.toUpperCase()}.`));
|
|
4811
|
-
} catch (error) {
|
|
4812
|
-
handleError(error);
|
|
4813
|
-
}
|
|
4814
|
-
});
|
|
4815
|
-
members.command("remove").description("Remove a member from a group").argument("<groupId>", "Group ID").argument("<userId>", "User ID").action(async (groupId, userId) => {
|
|
4816
|
-
try {
|
|
4817
|
-
const api = createApiClient();
|
|
4818
|
-
await api.admin.removeGroupMember(groupId, userId);
|
|
4819
|
-
console.log(chalk21.green(`Removed ${userId} from group "${groupId}".`));
|
|
4820
|
-
} catch (error) {
|
|
4821
|
-
handleError(error);
|
|
4822
|
-
}
|
|
4823
|
-
});
|
|
4824
|
-
const projects = group.command("projects").description("Manage group projects");
|
|
4825
|
-
projects.command("list").description("List group projects").argument("<groupId>", "Group ID").action(async (groupId, _options, cmd) => {
|
|
4826
|
-
try {
|
|
4827
|
-
const outputFormat = getOutputFormat13(cmd);
|
|
4828
|
-
const api = createApiClient();
|
|
4829
|
-
const projectList = await api.admin.getGroupProjects(groupId);
|
|
4830
|
-
format(projectList, { format: outputFormat, columns: ["projectId", "visibility", "language"] });
|
|
4831
|
-
} catch (error) {
|
|
4832
|
-
handleError(error);
|
|
4833
|
-
}
|
|
4834
|
-
});
|
|
4835
|
-
projects.command("add").description("Add a project to a group").argument("<groupId>", "Group ID").argument("<projectId>", "Project ID").action(async (groupId, projectId) => {
|
|
4836
|
-
try {
|
|
4837
|
-
const api = createApiClient();
|
|
4838
|
-
await api.admin.addGroupProject(groupId, projectId);
|
|
4839
|
-
console.log(chalk21.green(`Project "${projectId}" added to group "${groupId}".`));
|
|
4840
|
-
} catch (error) {
|
|
4841
|
-
handleError(error);
|
|
4842
|
-
}
|
|
4843
|
-
});
|
|
4844
|
-
projects.command("remove").description("Remove a project from a group").argument("<groupId>", "Group ID").argument("<projectId>", "Project ID").action(async (groupId, projectId) => {
|
|
4845
|
-
try {
|
|
4846
|
-
const api = createApiClient();
|
|
4847
|
-
await api.admin.removeGroupProject(groupId, projectId);
|
|
4848
|
-
console.log(chalk21.green(`Project "${projectId}" removed from group "${groupId}".`));
|
|
4849
|
-
} catch (error) {
|
|
4850
|
-
handleError(error);
|
|
4851
|
-
}
|
|
4852
|
-
});
|
|
4853
|
-
}
|
|
4854
|
-
|
|
4855
5283
|
// src/commands/admin/index.ts
|
|
4856
|
-
import
|
|
5284
|
+
import { readFile } from "fs/promises";
|
|
5285
|
+
import chalk23 from "chalk";
|
|
4857
5286
|
function getOutputFormat14(cmd) {
|
|
4858
5287
|
const config = loadConfig();
|
|
4859
5288
|
const globalOpts = cmd.optsWithGlobals();
|
|
@@ -4917,7 +5346,7 @@ function registerAdminCommands(program) {
|
|
|
4917
5346
|
try {
|
|
4918
5347
|
const api = createApiClient();
|
|
4919
5348
|
await api.admin.mergeSetting({ [key]: value });
|
|
4920
|
-
console.log(
|
|
5349
|
+
console.log(chalk23.green(`Setting "${key}" updated.`));
|
|
4921
5350
|
} catch (error) {
|
|
4922
5351
|
handleError(error);
|
|
4923
5352
|
}
|
|
@@ -4928,10 +5357,10 @@ function registerAdminCommands(program) {
|
|
|
4928
5357
|
const api = createApiClient();
|
|
4929
5358
|
if (options.longTerm) {
|
|
4930
5359
|
await api.storage.createLongTermFullBackup();
|
|
4931
|
-
console.log(
|
|
5360
|
+
console.log(chalk23.green("Full long-term backup initiated."));
|
|
4932
5361
|
} else {
|
|
4933
5362
|
await api.storage.createShortTermFullBackup();
|
|
4934
|
-
console.log(
|
|
5363
|
+
console.log(chalk23.green("Full short-term backup initiated."));
|
|
4935
5364
|
}
|
|
4936
5365
|
} catch (error) {
|
|
4937
5366
|
handleError(error);
|
|
@@ -4942,10 +5371,10 @@ function registerAdminCommands(program) {
|
|
|
4942
5371
|
const api = createApiClient();
|
|
4943
5372
|
if (options.longTerm) {
|
|
4944
5373
|
await api.storage.createLongTermProjectBackup();
|
|
4945
|
-
console.log(
|
|
5374
|
+
console.log(chalk23.green("Project long-term backup initiated."));
|
|
4946
5375
|
} else {
|
|
4947
5376
|
await api.storage.createShortTermProjectBackup();
|
|
4948
|
-
console.log(
|
|
5377
|
+
console.log(chalk23.green("Project short-term backup initiated."));
|
|
4949
5378
|
}
|
|
4950
5379
|
} catch (error) {
|
|
4951
5380
|
handleError(error);
|
|
@@ -4959,7 +5388,7 @@ function registerAdminCommands(program) {
|
|
|
4959
5388
|
);
|
|
4960
5389
|
const api = createApiClient();
|
|
4961
5390
|
await api.storage.restoreProjectBackup({ projectId, projectBranch, bucketName, objectName });
|
|
4962
|
-
console.log(
|
|
5391
|
+
console.log(chalk23.green(`Restore initiated for ${projectId}/${projectBranch} from ${bucketName}/${objectName}.`));
|
|
4963
5392
|
} catch (error) {
|
|
4964
5393
|
handleError(error);
|
|
4965
5394
|
}
|
|
@@ -4972,7 +5401,7 @@ function registerAdminCommands(program) {
|
|
|
4972
5401
|
);
|
|
4973
5402
|
const api = createApiClient();
|
|
4974
5403
|
await api.storage.restoreFullBackup({ bucketName, objectName });
|
|
4975
|
-
console.log(
|
|
5404
|
+
console.log(chalk23.green(`Full restore initiated from ${bucketName}/${objectName}.`));
|
|
4976
5405
|
} catch (error) {
|
|
4977
5406
|
handleError(error);
|
|
4978
5407
|
}
|
|
@@ -4982,10 +5411,10 @@ function registerAdminCommands(program) {
|
|
|
4982
5411
|
const api = createApiClient();
|
|
4983
5412
|
if (options.project) {
|
|
4984
5413
|
await api.index.rebuildProject(options.project);
|
|
4985
|
-
console.log(
|
|
5414
|
+
console.log(chalk23.green(`Index rebuild initiated for project "${options.project}".`));
|
|
4986
5415
|
} else {
|
|
4987
5416
|
await api.index.rebuildAll();
|
|
4988
|
-
console.log(
|
|
5417
|
+
console.log(chalk23.green("Index rebuild initiated for all projects."));
|
|
4989
5418
|
}
|
|
4990
5419
|
} catch (error) {
|
|
4991
5420
|
handleError(error);
|
|
@@ -5001,10 +5430,33 @@ function registerAdminCommands(program) {
|
|
|
5001
5430
|
handleError(error);
|
|
5002
5431
|
}
|
|
5003
5432
|
});
|
|
5433
|
+
const team = admin.command("team").description("Team administration");
|
|
5434
|
+
const contract = team.command("contract").description("Issue and inspect negotiated team contracts");
|
|
5435
|
+
contract.command("get", { isDefault: true }).description("Show a team's contract").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
|
|
5436
|
+
try {
|
|
5437
|
+
const api = createApiClient();
|
|
5438
|
+
format(await api.admin.getTeamContract(teamId), { format: getOutputFormat14(cmd) });
|
|
5439
|
+
} catch (error) {
|
|
5440
|
+
handleError(error);
|
|
5441
|
+
}
|
|
5442
|
+
});
|
|
5443
|
+
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) => {
|
|
5444
|
+
try {
|
|
5445
|
+
const request = JSON.parse(await readFile(options.file, "utf8"));
|
|
5446
|
+
await confirmDestructive(
|
|
5447
|
+
`This will replace the contract of team "${teamId}" with the terms in ${options.file}.`,
|
|
5448
|
+
{ yes: options.yes, resourceId: teamId }
|
|
5449
|
+
);
|
|
5450
|
+
const api = createApiClient();
|
|
5451
|
+
format(await api.admin.issueTeamContract(teamId, request), { format: getOutputFormat14(cmd) });
|
|
5452
|
+
} catch (error) {
|
|
5453
|
+
handleError(error);
|
|
5454
|
+
}
|
|
5455
|
+
});
|
|
5004
5456
|
}
|
|
5005
5457
|
|
|
5006
5458
|
// src/commands/status/summary.ts
|
|
5007
|
-
import
|
|
5459
|
+
import chalk24 from "chalk";
|
|
5008
5460
|
|
|
5009
5461
|
// src/client/services/status.ts
|
|
5010
5462
|
function createStatusService() {
|
|
@@ -5030,24 +5482,24 @@ function createStatusService() {
|
|
|
5030
5482
|
|
|
5031
5483
|
// src/commands/status/summary.ts
|
|
5032
5484
|
var STATE_COLORS = {
|
|
5033
|
-
UP:
|
|
5034
|
-
DEGRADED:
|
|
5035
|
-
DOWN:
|
|
5036
|
-
UNKNOWN:
|
|
5485
|
+
UP: chalk24.green,
|
|
5486
|
+
DEGRADED: chalk24.yellow,
|
|
5487
|
+
DOWN: chalk24.red,
|
|
5488
|
+
UNKNOWN: chalk24.gray
|
|
5037
5489
|
};
|
|
5038
5490
|
function stateColor(state) {
|
|
5039
|
-
return STATE_COLORS[state] ??
|
|
5491
|
+
return STATE_COLORS[state] ?? chalk24.gray;
|
|
5040
5492
|
}
|
|
5041
5493
|
function stateSymbol(state) {
|
|
5042
5494
|
switch (state) {
|
|
5043
5495
|
case "UP":
|
|
5044
|
-
return
|
|
5496
|
+
return chalk24.green("\u25CF");
|
|
5045
5497
|
case "DEGRADED":
|
|
5046
|
-
return
|
|
5498
|
+
return chalk24.yellow("\u25CF");
|
|
5047
5499
|
case "DOWN":
|
|
5048
|
-
return
|
|
5500
|
+
return chalk24.red("\u25CF");
|
|
5049
5501
|
default:
|
|
5050
|
-
return
|
|
5502
|
+
return chalk24.gray("\u25CB");
|
|
5051
5503
|
}
|
|
5052
5504
|
}
|
|
5053
5505
|
function registerSummaryCommand(parent) {
|
|
@@ -5074,11 +5526,11 @@ function registerSummaryCommand(parent) {
|
|
|
5074
5526
|
}
|
|
5075
5527
|
console.log();
|
|
5076
5528
|
if (summary.openIncidents > 0) {
|
|
5077
|
-
console.log(
|
|
5529
|
+
console.log(chalk24.yellow(` ${summary.openIncidents} active incident(s)`));
|
|
5078
5530
|
} else {
|
|
5079
|
-
console.log(
|
|
5531
|
+
console.log(chalk24.dim(" No active incidents"));
|
|
5080
5532
|
}
|
|
5081
|
-
console.log(
|
|
5533
|
+
console.log(chalk24.dim(`
|
|
5082
5534
|
Platform v${version.platformVersion} \u2022 ${new Date(summary.timestamp).toLocaleString()}`));
|
|
5083
5535
|
console.log();
|
|
5084
5536
|
} catch (error) {
|
|
@@ -5088,17 +5540,17 @@ function registerSummaryCommand(parent) {
|
|
|
5088
5540
|
}
|
|
5089
5541
|
|
|
5090
5542
|
// src/commands/status/component.ts
|
|
5091
|
-
import
|
|
5543
|
+
import chalk25 from "chalk";
|
|
5092
5544
|
function stateSymbol2(state) {
|
|
5093
5545
|
switch (state) {
|
|
5094
5546
|
case "UP":
|
|
5095
|
-
return
|
|
5547
|
+
return chalk25.green("\u25CF");
|
|
5096
5548
|
case "DEGRADED":
|
|
5097
|
-
return
|
|
5549
|
+
return chalk25.yellow("\u25CF");
|
|
5098
5550
|
case "DOWN":
|
|
5099
|
-
return
|
|
5551
|
+
return chalk25.red("\u25CF");
|
|
5100
5552
|
default:
|
|
5101
|
-
return
|
|
5553
|
+
return chalk25.gray("\u25CB");
|
|
5102
5554
|
}
|
|
5103
5555
|
}
|
|
5104
5556
|
function registerComponentCommand(parent) {
|
|
@@ -5111,7 +5563,7 @@ function registerComponentCommand(parent) {
|
|
|
5111
5563
|
const match = components.find((c) => c.id === id || c.id === id + "-service");
|
|
5112
5564
|
if (!match) {
|
|
5113
5565
|
const available = components.map((c) => c.id).join(", ");
|
|
5114
|
-
console.error(
|
|
5566
|
+
console.error(chalk25.red(`Component "${id}" not found. Available: ${available}`));
|
|
5115
5567
|
process.exit(1);
|
|
5116
5568
|
}
|
|
5117
5569
|
if (outputFormat !== "human") {
|
|
@@ -5119,7 +5571,7 @@ function registerComponentCommand(parent) {
|
|
|
5119
5571
|
return;
|
|
5120
5572
|
}
|
|
5121
5573
|
console.log();
|
|
5122
|
-
console.log(` ${stateSymbol2(match.state)} ${
|
|
5574
|
+
console.log(` ${stateSymbol2(match.state)} ${chalk25.bold(match.id)} ${match.version ? chalk25.dim("v" + match.version) : ""}`);
|
|
5123
5575
|
console.log(` State: ${match.state}`);
|
|
5124
5576
|
if (match.lastCheckAt) {
|
|
5125
5577
|
console.log(` Last check: ${new Date(match.lastCheckAt).toLocaleString()}`);
|
|
@@ -5128,7 +5580,7 @@ function registerComponentCommand(parent) {
|
|
|
5128
5580
|
console.log();
|
|
5129
5581
|
console.log(" Checks:");
|
|
5130
5582
|
for (const check of match.checks) {
|
|
5131
|
-
const cat = check.category ?
|
|
5583
|
+
const cat = check.category ? chalk25.dim(` (${check.category})`) : "";
|
|
5132
5584
|
console.log(` ${stateSymbol2(check.state)} ${check.name}${cat}`);
|
|
5133
5585
|
}
|
|
5134
5586
|
}
|
|
@@ -5140,12 +5592,12 @@ function registerComponentCommand(parent) {
|
|
|
5140
5592
|
}
|
|
5141
5593
|
|
|
5142
5594
|
// src/commands/status/incidents.ts
|
|
5143
|
-
import
|
|
5595
|
+
import chalk26 from "chalk";
|
|
5144
5596
|
var SEVERITY_COLORS = {
|
|
5145
|
-
ERROR:
|
|
5146
|
-
WARNING:
|
|
5147
|
-
INFO:
|
|
5148
|
-
MAINTENANCE:
|
|
5597
|
+
ERROR: chalk26.red,
|
|
5598
|
+
WARNING: chalk26.yellow,
|
|
5599
|
+
INFO: chalk26.blue,
|
|
5600
|
+
MAINTENANCE: chalk26.cyan
|
|
5149
5601
|
};
|
|
5150
5602
|
function registerIncidentsCommand(parent) {
|
|
5151
5603
|
parent.command("incidents").description("List recent incidents").option("-w, --window <window>", "Time window (e.g. 24h, 48h)", "24h").action(async (options, cmd) => {
|
|
@@ -5159,22 +5611,22 @@ function registerIncidentsCommand(parent) {
|
|
|
5159
5611
|
return;
|
|
5160
5612
|
}
|
|
5161
5613
|
if (incidents.length === 0) {
|
|
5162
|
-
console.log(
|
|
5614
|
+
console.log(chalk26.dim(`
|
|
5163
5615
|
No incidents in the last ${options.window}.
|
|
5164
5616
|
`));
|
|
5165
5617
|
return;
|
|
5166
5618
|
}
|
|
5167
5619
|
console.log();
|
|
5168
5620
|
for (const incident of incidents) {
|
|
5169
|
-
const color = SEVERITY_COLORS[incident.severity] ??
|
|
5621
|
+
const color = SEVERITY_COLORS[incident.severity] ?? chalk26.gray;
|
|
5170
5622
|
const severity = color(incident.severity.padEnd(8));
|
|
5171
5623
|
const time = incident.startedAt ? new Date(incident.startedAt).toLocaleString() : "";
|
|
5172
|
-
const resolved = incident.resolvedAt ?
|
|
5624
|
+
const resolved = incident.resolvedAt ? chalk26.green(" [resolved]") : chalk26.yellow(" [open]");
|
|
5173
5625
|
console.log(` ${severity} ${incident.summary}${resolved}`);
|
|
5174
|
-
console.log(
|
|
5626
|
+
console.log(chalk26.dim(` ${time}`));
|
|
5175
5627
|
for (const update of incident.updates) {
|
|
5176
5628
|
const updateTime = new Date(update.at).toLocaleTimeString();
|
|
5177
|
-
console.log(
|
|
5629
|
+
console.log(chalk26.dim(` ${updateTime} ${update.status} ${update.message}`));
|
|
5178
5630
|
}
|
|
5179
5631
|
console.log();
|
|
5180
5632
|
}
|
|
@@ -5193,7 +5645,7 @@ function registerStatusCommands(program) {
|
|
|
5193
5645
|
}
|
|
5194
5646
|
|
|
5195
5647
|
// src/commands/analyze/index.ts
|
|
5196
|
-
import
|
|
5648
|
+
import chalk27 from "chalk";
|
|
5197
5649
|
import * as fs8 from "fs";
|
|
5198
5650
|
import * as path7 from "path";
|
|
5199
5651
|
import { spawn as spawn2 } from "child_process";
|
|
@@ -5238,14 +5690,14 @@ function multipartFromFile(file) {
|
|
|
5238
5690
|
}
|
|
5239
5691
|
async function runAnalysis(file, options, cmd) {
|
|
5240
5692
|
if (!fs8.existsSync(file)) {
|
|
5241
|
-
console.error(
|
|
5693
|
+
console.error(chalk27.red(`File not found: ${file}`));
|
|
5242
5694
|
process.exit(1);
|
|
5243
5695
|
}
|
|
5244
5696
|
if (options.preset) {
|
|
5245
5697
|
const api2 = createApiClient();
|
|
5246
5698
|
const opt = await api2.analysis.getPreset(options.preset);
|
|
5247
5699
|
if (!opt.preset) {
|
|
5248
|
-
console.error(
|
|
5700
|
+
console.error(chalk27.red(`Preset not found: ${options.preset}`));
|
|
5249
5701
|
process.exit(1);
|
|
5250
5702
|
}
|
|
5251
5703
|
const p = opt.preset;
|
|
@@ -5273,15 +5725,15 @@ async function runAnalysis(file, options, cmd) {
|
|
|
5273
5725
|
};
|
|
5274
5726
|
process.stdout.write(`Creating analysis "${name}" ...`);
|
|
5275
5727
|
const created = await api.analysis.create(request);
|
|
5276
|
-
console.log(
|
|
5277
|
-
console.log(
|
|
5728
|
+
console.log(chalk27.green(" done"));
|
|
5729
|
+
console.log(chalk27.dim(` analysisId: ${created.analysisId}`));
|
|
5278
5730
|
process.stdout.write(`Uploading ${path7.basename(file)} ...`);
|
|
5279
5731
|
await api.analysis.uploadDataMultipart(created.analysisId, multipartFromFile(file));
|
|
5280
|
-
console.log(
|
|
5732
|
+
console.log(chalk27.green(" done"));
|
|
5281
5733
|
process.stdout.write("Queuing analysis run ...");
|
|
5282
5734
|
const run = await api.analysis.runAnalysis(created.analysisId);
|
|
5283
|
-
console.log(
|
|
5284
|
-
console.log(
|
|
5735
|
+
console.log(chalk27.green(" done"));
|
|
5736
|
+
console.log(chalk27.dim(` runId: ${run.runId}`));
|
|
5285
5737
|
console.log();
|
|
5286
5738
|
await monitorRun(api, created.analysisId, run.runId, parseFloat(hours), cmd);
|
|
5287
5739
|
}
|
|
@@ -5306,7 +5758,7 @@ async function monitorRun(api, analysisId, runId, hoursForProgress, cmd) {
|
|
|
5306
5758
|
if (!seenOutputIds.has(out.outputId)) {
|
|
5307
5759
|
seenOutputIds.add(out.outputId);
|
|
5308
5760
|
if (outputFormat === "human") {
|
|
5309
|
-
console.log(` ${
|
|
5761
|
+
console.log(` ${chalk27.dim("Output:")} ${out.output}`);
|
|
5310
5762
|
} else {
|
|
5311
5763
|
process.stdout.write(
|
|
5312
5764
|
JSON.stringify({ type: "output", outputId: out.outputId, output: out.output }) + "\n"
|
|
@@ -5323,7 +5775,7 @@ async function monitorRun(api, analysisId, runId, hoursForProgress, cmd) {
|
|
|
5323
5775
|
const durationStr = formatDuration(duration);
|
|
5324
5776
|
if (run.state === "COMPLETED") {
|
|
5325
5777
|
if (outputFormat === "human") {
|
|
5326
|
-
console.log(
|
|
5778
|
+
console.log(chalk27.green(`Analysis complete! (${durationStr})`));
|
|
5327
5779
|
try {
|
|
5328
5780
|
const nav = await api.analysis.getNavigation(analysisId);
|
|
5329
5781
|
const endpoint = config.profiles[config.currentProfile]?.endpoint ?? "https://diafunc.com";
|
|
@@ -5335,13 +5787,13 @@ async function monitorRun(api, analysisId, runId, hoursForProgress, cmd) {
|
|
|
5335
5787
|
}
|
|
5336
5788
|
} else if (run.state === "CANCELLED") {
|
|
5337
5789
|
if (outputFormat === "human") {
|
|
5338
|
-
console.log(
|
|
5790
|
+
console.log(chalk27.yellow("Analysis cancelled."));
|
|
5339
5791
|
} else {
|
|
5340
5792
|
format({ status: "cancelled", runId, analysisId }, { format: outputFormat });
|
|
5341
5793
|
}
|
|
5342
5794
|
} else {
|
|
5343
5795
|
if (outputFormat === "human") {
|
|
5344
|
-
console.log(
|
|
5796
|
+
console.log(chalk27.red("Analysis failed."));
|
|
5345
5797
|
if (run.errorMessage) console.log(` Error: ${run.errorMessage}`);
|
|
5346
5798
|
} else {
|
|
5347
5799
|
format({ status: "failed", runId, analysisId, error: run.errorMessage }, { format: outputFormat });
|
|
@@ -5383,7 +5835,7 @@ async function getAnalysisDetails(analysisId, cmd) {
|
|
|
5383
5835
|
const api = createApiClient();
|
|
5384
5836
|
const result = analysisId ? await api.analysis.get(analysisId) : await api.analysis.getLast();
|
|
5385
5837
|
if (!result.analysis) {
|
|
5386
|
-
console.log(
|
|
5838
|
+
console.log(chalk27.dim("No analysis found."));
|
|
5387
5839
|
return;
|
|
5388
5840
|
}
|
|
5389
5841
|
format(result.analysis, { format: outputFormat });
|
|
@@ -5392,18 +5844,18 @@ async function watchAnalysis(analysisId, cmd) {
|
|
|
5392
5844
|
const api = createApiClient();
|
|
5393
5845
|
const result = analysisId ? await api.analysis.get(analysisId) : await api.analysis.getLast();
|
|
5394
5846
|
if (!result.analysis) {
|
|
5395
|
-
console.log(
|
|
5847
|
+
console.log(chalk27.dim("No analysis found."));
|
|
5396
5848
|
return;
|
|
5397
5849
|
}
|
|
5398
5850
|
const recipe = result.analysis;
|
|
5399
5851
|
const runs = await api.analysis.getRunsForAnalysis(recipe.analysisId, 1);
|
|
5400
5852
|
if (runs.length === 0) {
|
|
5401
|
-
console.log(
|
|
5853
|
+
console.log(chalk27.dim("No runs for this analysis."));
|
|
5402
5854
|
return;
|
|
5403
5855
|
}
|
|
5404
5856
|
const latest = runs[0];
|
|
5405
5857
|
if (isTerminalState(latest.state)) {
|
|
5406
|
-
console.log(
|
|
5858
|
+
console.log(chalk27.green(`Latest run already in terminal state: ${latest.state}`));
|
|
5407
5859
|
try {
|
|
5408
5860
|
const nav = await api.analysis.getNavigation(recipe.analysisId);
|
|
5409
5861
|
const config = loadConfig();
|
|
@@ -5419,16 +5871,16 @@ async function watchAnalysis(analysisId, cmd) {
|
|
|
5419
5871
|
async function rerunAnalysis(analysisId) {
|
|
5420
5872
|
const api = createApiClient();
|
|
5421
5873
|
const run = await api.analysis.runAnalysis(analysisId);
|
|
5422
|
-
console.log(
|
|
5423
|
-
console.log(
|
|
5874
|
+
console.log(chalk27.green(`\u2713 Queued new run ${run.runId} for analysis ${analysisId}`));
|
|
5875
|
+
console.log(chalk27.dim(` State: ${run.state}`));
|
|
5424
5876
|
console.log();
|
|
5425
|
-
console.log(
|
|
5877
|
+
console.log(chalk27.dim("Track progress: diafunc analyze watch " + analysisId));
|
|
5426
5878
|
}
|
|
5427
5879
|
async function openAnalysis(analysisId) {
|
|
5428
5880
|
const api = createApiClient();
|
|
5429
5881
|
const result = analysisId ? await api.analysis.get(analysisId) : await api.analysis.getLast();
|
|
5430
5882
|
if (!result.analysis) {
|
|
5431
|
-
console.log(
|
|
5883
|
+
console.log(chalk27.dim("No analysis found."));
|
|
5432
5884
|
return;
|
|
5433
5885
|
}
|
|
5434
5886
|
const config = loadConfig();
|
|
@@ -5439,7 +5891,7 @@ async function openAnalysis(analysisId) {
|
|
|
5439
5891
|
console.log(`Opening ${url} ...`);
|
|
5440
5892
|
openUrl(url);
|
|
5441
5893
|
} catch {
|
|
5442
|
-
console.log(
|
|
5894
|
+
console.log(chalk27.dim("Notebook not yet provisioned \u2014 run the analysis first."));
|
|
5443
5895
|
}
|
|
5444
5896
|
}
|
|
5445
5897
|
async function createRecipe(options, cmd) {
|
|
@@ -5463,14 +5915,14 @@ async function createRecipe(options, cmd) {
|
|
|
5463
5915
|
async function deleteAnalysis(analysisId) {
|
|
5464
5916
|
const api = createApiClient();
|
|
5465
5917
|
await api.analysis.delete(analysisId);
|
|
5466
|
-
console.log(
|
|
5918
|
+
console.log(chalk27.green(`\u2713 Deleted analysis ${analysisId}`));
|
|
5467
5919
|
}
|
|
5468
5920
|
async function patchAndPrint(analysisId, value, handler, successLabel, cmd) {
|
|
5469
5921
|
const outputFormat = getOutputFormat15(cmd);
|
|
5470
5922
|
const api = createApiClient();
|
|
5471
5923
|
const updated = await handler(api, analysisId, value);
|
|
5472
5924
|
if (outputFormat === "human") {
|
|
5473
|
-
console.log(
|
|
5925
|
+
console.log(chalk27.green(`\u2713 ${successLabel} updated for analysis ${analysisId}`));
|
|
5474
5926
|
} else {
|
|
5475
5927
|
format(updated, { format: outputFormat });
|
|
5476
5928
|
}
|
|
@@ -5479,32 +5931,32 @@ async function uploadData(analysisId, file, options) {
|
|
|
5479
5931
|
const api = createApiClient();
|
|
5480
5932
|
if (options.url) {
|
|
5481
5933
|
if (file) {
|
|
5482
|
-
console.error(
|
|
5934
|
+
console.error(chalk27.red("Provide either a file or --url, not both."));
|
|
5483
5935
|
process.exit(1);
|
|
5484
5936
|
}
|
|
5485
5937
|
process.stdout.write(`Uploading from ${options.url} ...`);
|
|
5486
5938
|
await api.analysis.uploadDataUrl(analysisId, { dataUrl: options.url });
|
|
5487
|
-
console.log(
|
|
5939
|
+
console.log(chalk27.green(" done"));
|
|
5488
5940
|
return;
|
|
5489
5941
|
}
|
|
5490
5942
|
if (!file) {
|
|
5491
|
-
console.error(
|
|
5943
|
+
console.error(chalk27.red("Provide a file path or --url <URL>."));
|
|
5492
5944
|
process.exit(1);
|
|
5493
5945
|
}
|
|
5494
5946
|
if (!fs8.existsSync(file)) {
|
|
5495
|
-
console.error(
|
|
5947
|
+
console.error(chalk27.red(`File not found: ${file}`));
|
|
5496
5948
|
process.exit(1);
|
|
5497
5949
|
}
|
|
5498
5950
|
process.stdout.write(`Uploading ${path7.basename(file)} ...`);
|
|
5499
5951
|
await api.analysis.uploadDataMultipart(analysisId, multipartFromFile(file));
|
|
5500
|
-
console.log(
|
|
5952
|
+
console.log(chalk27.green(" done"));
|
|
5501
5953
|
}
|
|
5502
5954
|
async function listColumns(analysisId, cmd) {
|
|
5503
5955
|
const outputFormat = getOutputFormat15(cmd);
|
|
5504
5956
|
const api = createApiClient();
|
|
5505
5957
|
const columns = await api.analysis.getColumns(analysisId);
|
|
5506
5958
|
if (columns.length === 0) {
|
|
5507
|
-
console.log(
|
|
5959
|
+
console.log(chalk27.dim("No columns yet \u2014 upload data first."));
|
|
5508
5960
|
return;
|
|
5509
5961
|
}
|
|
5510
5962
|
format(columns, { format: outputFormat, columns: ["name", "valueType"] });
|
|
@@ -5530,7 +5982,7 @@ async function cancelRun(runId, cmd) {
|
|
|
5530
5982
|
const api = createApiClient();
|
|
5531
5983
|
const run = await api.analysis.cancelRun(runId);
|
|
5532
5984
|
if (outputFormat === "human") {
|
|
5533
|
-
console.log(
|
|
5985
|
+
console.log(chalk27.green(`\u2713 Run ${run.runId} state: ${run.state}`));
|
|
5534
5986
|
} else {
|
|
5535
5987
|
format(run, { format: outputFormat });
|
|
5536
5988
|
}
|
|
@@ -5557,7 +6009,7 @@ async function getPreset(presetId, cmd) {
|
|
|
5557
6009
|
const api = createApiClient();
|
|
5558
6010
|
const opt = await api.analysis.getPreset(presetId);
|
|
5559
6011
|
if (!opt.preset) {
|
|
5560
|
-
console.log(
|
|
6012
|
+
console.log(chalk27.dim("Preset not found."));
|
|
5561
6013
|
return;
|
|
5562
6014
|
}
|
|
5563
6015
|
format(opt.preset, { format: outputFormat });
|
|
@@ -5580,7 +6032,7 @@ async function savePreset(options, cmd) {
|
|
|
5580
6032
|
async function deletePreset(presetId) {
|
|
5581
6033
|
const api = createApiClient();
|
|
5582
6034
|
await api.analysis.deletePreset(presetId);
|
|
5583
|
-
console.log(
|
|
6035
|
+
console.log(chalk27.green(`\u2713 Deleted preset ${presetId}`));
|
|
5584
6036
|
}
|
|
5585
6037
|
async function listTriggers(analysisId, cmd) {
|
|
5586
6038
|
const outputFormat = getOutputFormat15(cmd);
|
|
@@ -5601,7 +6053,7 @@ async function createTrigger(analysisId, kind, schedule, cmd) {
|
|
|
5601
6053
|
const outputFormat = getOutputFormat15(cmd);
|
|
5602
6054
|
const upper = kind.toUpperCase();
|
|
5603
6055
|
if (upper !== "ONCE" && upper !== "CRON") {
|
|
5604
|
-
console.error(
|
|
6056
|
+
console.error(chalk27.red(`Invalid kind "${kind}" \u2014 must be ONCE or CRON.`));
|
|
5605
6057
|
process.exit(1);
|
|
5606
6058
|
}
|
|
5607
6059
|
const api = createApiClient();
|
|
@@ -5614,7 +6066,7 @@ async function createTrigger(analysisId, kind, schedule, cmd) {
|
|
|
5614
6066
|
async function deleteTrigger(triggerId) {
|
|
5615
6067
|
const api = createApiClient();
|
|
5616
6068
|
await api.analysis.deleteTrigger(triggerId);
|
|
5617
|
-
console.log(
|
|
6069
|
+
console.log(chalk27.green(`\u2713 Deleted trigger ${triggerId}`));
|
|
5618
6070
|
}
|
|
5619
6071
|
async function updateTriggerCmd(triggerId, options, cmd) {
|
|
5620
6072
|
const outputFormat = getOutputFormat15(cmd);
|
|
@@ -5622,13 +6074,13 @@ async function updateTriggerCmd(triggerId, options, cmd) {
|
|
|
5622
6074
|
if (options.active !== void 0) {
|
|
5623
6075
|
const lc = options.active.toLowerCase();
|
|
5624
6076
|
if (lc !== "true" && lc !== "false") {
|
|
5625
|
-
console.error(
|
|
6077
|
+
console.error(chalk27.red(`Invalid --active value "${options.active}" \u2014 must be true or false.`));
|
|
5626
6078
|
process.exit(1);
|
|
5627
6079
|
}
|
|
5628
6080
|
activeFlag = lc === "true";
|
|
5629
6081
|
}
|
|
5630
6082
|
if (activeFlag === void 0 && !options.schedule) {
|
|
5631
|
-
console.error(
|
|
6083
|
+
console.error(chalk27.red("Pass at least one of --active or --schedule."));
|
|
5632
6084
|
process.exit(1);
|
|
5633
6085
|
}
|
|
5634
6086
|
const api = createApiClient();
|
|
@@ -5912,7 +6364,7 @@ function registerAnalyzeCommand(program) {
|
|
|
5912
6364
|
}
|
|
5913
6365
|
|
|
5914
6366
|
// src/commands/data-sources/index.ts
|
|
5915
|
-
import
|
|
6367
|
+
import chalk28 from "chalk";
|
|
5916
6368
|
function getOutputFormat16(cmd) {
|
|
5917
6369
|
const config = loadConfig();
|
|
5918
6370
|
const globalOpts = cmd.optsWithGlobals();
|
|
@@ -6006,7 +6458,7 @@ async function listDataSources(projectId, cmd) {
|
|
|
6006
6458
|
const api = createApiClient();
|
|
6007
6459
|
const sources = await api.storage.listDataSources(projectId);
|
|
6008
6460
|
if (outputFormat === "human" && sources.length === 0) {
|
|
6009
|
-
console.log(
|
|
6461
|
+
console.log(chalk28.dim("No data sources found."));
|
|
6010
6462
|
return;
|
|
6011
6463
|
}
|
|
6012
6464
|
format(sources.map(dataSourceTableRow), {
|
|
@@ -6029,11 +6481,11 @@ async function showDashboard(projectId, cmd) {
|
|
|
6029
6481
|
return;
|
|
6030
6482
|
}
|
|
6031
6483
|
const r = dashboard.rollup;
|
|
6032
|
-
let line =
|
|
6484
|
+
let line = chalk28.bold(`DataSources in ${projectId}: `) + `${r.totalSources} total, ${r.scheduledSources} scheduled, ${r.sourcesWithRecentFailure} failing recently`;
|
|
6033
6485
|
if (r.lastActivityAt) line += `, last activity ${r.lastActivityAt}`;
|
|
6034
6486
|
console.log(line);
|
|
6035
6487
|
if (dashboard.sources.length === 0) {
|
|
6036
|
-
console.log(
|
|
6488
|
+
console.log(chalk28.dim("No data sources."));
|
|
6037
6489
|
return;
|
|
6038
6490
|
}
|
|
6039
6491
|
format(dashboard.sources.map(dashboardTableRow), {
|
|
@@ -6056,9 +6508,9 @@ async function createDataSource(options, cmd) {
|
|
|
6056
6508
|
};
|
|
6057
6509
|
const ds = await api.storage.createDataSource(request);
|
|
6058
6510
|
if (outputFormat === "human") {
|
|
6059
|
-
console.log(
|
|
6060
|
-
console.log(
|
|
6061
|
-
if (ds.lastRunError) console.log(
|
|
6511
|
+
console.log(chalk28.green(`\u2713 Created data source ${ds.id}`));
|
|
6512
|
+
console.log(chalk28.dim(` Last run: ${ds.lastRunStatus ?? "\u2014"}`));
|
|
6513
|
+
if (ds.lastRunError) console.log(chalk28.dim(` Error: ${ds.lastRunError}`));
|
|
6062
6514
|
} else {
|
|
6063
6515
|
format(ds, { format: outputFormat });
|
|
6064
6516
|
}
|
|
@@ -6088,7 +6540,7 @@ async function updateDataSource(id, options, cmd) {
|
|
|
6088
6540
|
const api = createApiClient();
|
|
6089
6541
|
const ds = await api.storage.updateDataSource(id, request);
|
|
6090
6542
|
if (outputFormat === "human") {
|
|
6091
|
-
console.log(
|
|
6543
|
+
console.log(chalk28.green(`\u2713 Updated data source ${ds.id}`));
|
|
6092
6544
|
} else {
|
|
6093
6545
|
format(ds, { format: outputFormat });
|
|
6094
6546
|
}
|
|
@@ -6096,15 +6548,15 @@ async function updateDataSource(id, options, cmd) {
|
|
|
6096
6548
|
async function deleteDataSource(id) {
|
|
6097
6549
|
const api = createApiClient();
|
|
6098
6550
|
await api.storage.deleteDataSource(id);
|
|
6099
|
-
console.log(
|
|
6551
|
+
console.log(chalk28.green(`\u2713 Deleted data source ${id}`));
|
|
6100
6552
|
}
|
|
6101
6553
|
async function refreshDataSource(id, cmd) {
|
|
6102
6554
|
const outputFormat = getOutputFormat16(cmd);
|
|
6103
6555
|
const api = createApiClient();
|
|
6104
6556
|
const run = await api.storage.refreshDataSource(id);
|
|
6105
6557
|
if (outputFormat === "human") {
|
|
6106
|
-
console.log(
|
|
6107
|
-
if (run.errorMessage) console.log(
|
|
6558
|
+
console.log(chalk28.green(`\u2713 Refresh queued \u2014 run ${run.runId}, status ${run.status}`));
|
|
6559
|
+
if (run.errorMessage) console.log(chalk28.red(` Error: ${run.errorMessage}`));
|
|
6108
6560
|
} else {
|
|
6109
6561
|
format(run, { format: outputFormat });
|
|
6110
6562
|
}
|
|
@@ -6114,7 +6566,7 @@ async function listRuns2(id, limit, cmd) {
|
|
|
6114
6566
|
const api = createApiClient();
|
|
6115
6567
|
const runs = await api.storage.listDataSourceRuns(id, limit);
|
|
6116
6568
|
if (outputFormat === "human" && runs.length === 0) {
|
|
6117
|
-
console.log(
|
|
6569
|
+
console.log(chalk28.dim("No runs yet."));
|
|
6118
6570
|
return;
|
|
6119
6571
|
}
|
|
6120
6572
|
format(runs.map(runTableRow), {
|
|
@@ -6134,7 +6586,7 @@ async function listConnectorTypes(cmd) {
|
|
|
6134
6586
|
const types = await api.storage.listDataSourceConnectorTypes();
|
|
6135
6587
|
if (outputFormat === "human") {
|
|
6136
6588
|
if (types.length === 0) {
|
|
6137
|
-
console.log(
|
|
6589
|
+
console.log(chalk28.dim("No connector types registered."));
|
|
6138
6590
|
return;
|
|
6139
6591
|
}
|
|
6140
6592
|
for (const t of types) console.log(t);
|
|
@@ -6218,7 +6670,7 @@ function registerDataSourcesCommands(program) {
|
|
|
6218
6670
|
}
|
|
6219
6671
|
|
|
6220
6672
|
// src/commands/table-exporters/index.ts
|
|
6221
|
-
import
|
|
6673
|
+
import chalk29 from "chalk";
|
|
6222
6674
|
function getOutputFormat17(cmd) {
|
|
6223
6675
|
const config = loadConfig();
|
|
6224
6676
|
const globalOpts = cmd.optsWithGlobals();
|
|
@@ -6249,7 +6701,7 @@ function registerTableExportersCommands(program) {
|
|
|
6249
6701
|
format: outputFormat,
|
|
6250
6702
|
columns: ["id", "name", "format", "extension", "mimeType", "priority", "function", "createdBy"]
|
|
6251
6703
|
});
|
|
6252
|
-
console.log(
|
|
6704
|
+
console.log(chalk29.dim(`${list.length} exporter(s)`));
|
|
6253
6705
|
} catch (error) {
|
|
6254
6706
|
handleError(error);
|
|
6255
6707
|
}
|
|
@@ -6261,7 +6713,7 @@ function registerTableExportersCommands(program) {
|
|
|
6261
6713
|
const list = await api.storage.listUserDefinedExporters();
|
|
6262
6714
|
const exporter = list.find((e) => e.id === id);
|
|
6263
6715
|
if (!exporter) {
|
|
6264
|
-
console.error(
|
|
6716
|
+
console.error(chalk29.red(`No exporter with id="${id}".`));
|
|
6265
6717
|
process.exit(1);
|
|
6266
6718
|
}
|
|
6267
6719
|
format(exporter, { format: outputFormat });
|
|
@@ -6290,7 +6742,7 @@ function registerTableExportersCommands(program) {
|
|
|
6290
6742
|
format(created, { format: outputFormat });
|
|
6291
6743
|
return;
|
|
6292
6744
|
}
|
|
6293
|
-
console.log(
|
|
6745
|
+
console.log(chalk29.green(`Registered exporter "${created.name}" (id=${created.id}, format=${created.format})`));
|
|
6294
6746
|
} catch (error) {
|
|
6295
6747
|
handleError(error);
|
|
6296
6748
|
}
|
|
@@ -6299,7 +6751,7 @@ function registerTableExportersCommands(program) {
|
|
|
6299
6751
|
try {
|
|
6300
6752
|
const api = createApiClient();
|
|
6301
6753
|
await api.storage.deleteUserDefinedExporter(id);
|
|
6302
|
-
console.log(
|
|
6754
|
+
console.log(chalk29.green(`Deleted exporter id=${id}`));
|
|
6303
6755
|
} catch (error) {
|
|
6304
6756
|
handleError(error);
|
|
6305
6757
|
}
|
|
@@ -6307,7 +6759,7 @@ function registerTableExportersCommands(program) {
|
|
|
6307
6759
|
}
|
|
6308
6760
|
|
|
6309
6761
|
// src/commands/skeleton/index.ts
|
|
6310
|
-
import
|
|
6762
|
+
import chalk30 from "chalk";
|
|
6311
6763
|
import * as fs9 from "fs";
|
|
6312
6764
|
function getOutputFormat18(cmd) {
|
|
6313
6765
|
const config = loadConfig();
|
|
@@ -6373,11 +6825,11 @@ async function createSkeleton(options, cmd) {
|
|
|
6373
6825
|
const api = createApiClient();
|
|
6374
6826
|
const skeleton = await api.storage.createSkeleton(request);
|
|
6375
6827
|
if (outputFormat === "human") {
|
|
6376
|
-
console.log(
|
|
6377
|
-
console.log(
|
|
6378
|
-
console.log(
|
|
6379
|
-
console.log(
|
|
6380
|
-
console.log(
|
|
6828
|
+
console.log(chalk30.green(`\u2713 Created skeleton ${skeleton.id}`));
|
|
6829
|
+
console.log(chalk30.dim(` name: ${skeleton.name}`));
|
|
6830
|
+
console.log(chalk30.dim(` template: ${skeleton.template}`));
|
|
6831
|
+
console.log(chalk30.dim(` paramCount: ${skeleton.paramCount}`));
|
|
6832
|
+
console.log(chalk30.dim(` weight: ${skeleton.weight}`));
|
|
6381
6833
|
} else {
|
|
6382
6834
|
format(skeleton, { format: outputFormat });
|
|
6383
6835
|
}
|
|
@@ -6388,7 +6840,7 @@ async function listSkeletons(localProject, cmd) {
|
|
|
6388
6840
|
const api = createApiClient();
|
|
6389
6841
|
const skeletons = await api.storage.listSkeletons(projectId);
|
|
6390
6842
|
if (outputFormat === "human" && skeletons.length === 0) {
|
|
6391
|
-
console.log(
|
|
6843
|
+
console.log(chalk30.dim(`No skeletons in project ${projectId}.`));
|
|
6392
6844
|
return;
|
|
6393
6845
|
}
|
|
6394
6846
|
format(skeletons.map(skeletonTableRow), {
|
|
@@ -6415,11 +6867,11 @@ async function updateSkeleton(id, options, cmd) {
|
|
|
6415
6867
|
const api = createApiClient();
|
|
6416
6868
|
const skeleton = await api.storage.updateSkeleton(id, request);
|
|
6417
6869
|
if (outputFormat === "human") {
|
|
6418
|
-
console.log(
|
|
6419
|
-
console.log(
|
|
6420
|
-
console.log(
|
|
6421
|
-
console.log(
|
|
6422
|
-
console.log(
|
|
6870
|
+
console.log(chalk30.green(`\u2713 Updated skeleton ${skeleton.id}`));
|
|
6871
|
+
console.log(chalk30.dim(` name: ${skeleton.name}`));
|
|
6872
|
+
console.log(chalk30.dim(` template: ${skeleton.template}`));
|
|
6873
|
+
console.log(chalk30.dim(` paramCount: ${skeleton.paramCount}`));
|
|
6874
|
+
console.log(chalk30.dim(` weight: ${skeleton.weight}`));
|
|
6423
6875
|
} else {
|
|
6424
6876
|
format(skeleton, { format: outputFormat });
|
|
6425
6877
|
}
|
|
@@ -6427,7 +6879,7 @@ async function updateSkeleton(id, options, cmd) {
|
|
|
6427
6879
|
async function deleteSkeleton(id) {
|
|
6428
6880
|
const api = createApiClient();
|
|
6429
6881
|
await api.storage.deleteSkeleton(id);
|
|
6430
|
-
console.log(
|
|
6882
|
+
console.log(chalk30.green(`\u2713 Deleted skeleton ${id}`));
|
|
6431
6883
|
}
|
|
6432
6884
|
function registerSkeletonCommands(program) {
|
|
6433
6885
|
const skeleton = program.command("skeleton").description("Manage user-provided skeleton templates (project-scoped, capped at 100/project)");
|
|
@@ -6479,7 +6931,7 @@ _diafunc_completions() {
|
|
|
6479
6931
|
cur="\${COMP_WORDS[COMP_CWORD]}"
|
|
6480
6932
|
prev="\${COMP_WORDS[COMP_CWORD-1]}"
|
|
6481
6933
|
|
|
6482
|
-
commands="auth config project entity link event branch table function trigger schedule chat search
|
|
6934
|
+
commands="auth config project team entity link event branch table function trigger schedule chat search admin analyze help"
|
|
6483
6935
|
|
|
6484
6936
|
case "\${COMP_WORDS[1]}" in
|
|
6485
6937
|
auth)
|
|
@@ -6549,11 +7001,13 @@ _diafunc_completions() {
|
|
|
6549
7001
|
COMPREPLY=($(compgen -W "\${subcommands}" -- "\${cur}"))
|
|
6550
7002
|
fi
|
|
6551
7003
|
;;
|
|
6552
|
-
|
|
6553
|
-
subcommands="list get create
|
|
7004
|
+
team)
|
|
7005
|
+
subcommands="list get use usage create portal cancel leave members invitations seats packs transfer"
|
|
6554
7006
|
case "\${COMP_WORDS[2]}" in
|
|
6555
7007
|
members) COMPREPLY=($(compgen -W "list invite remove" -- "\${cur}")) ;;
|
|
6556
|
-
|
|
7008
|
+
invitations) COMPREPLY=($(compgen -W "list revoke resend accept" -- "\${cur}")) ;;
|
|
7009
|
+
seats|packs) COMPREPLY=($(compgen -W "preview set" -- "\${cur}")) ;;
|
|
7010
|
+
transfer) COMPREPLY=($(compgen -W "start status accept cancel" -- "\${cur}")) ;;
|
|
6557
7011
|
*) COMPREPLY=($(compgen -W "\${subcommands}" -- "\${cur}")) ;;
|
|
6558
7012
|
esac
|
|
6559
7013
|
;;
|
|
@@ -6580,6 +7034,7 @@ _diafunc() {
|
|
|
6580
7034
|
'auth:Authentication and credential management'
|
|
6581
7035
|
'config:Manage CLI configuration'
|
|
6582
7036
|
'project:Manage projects'
|
|
7037
|
+
'team:Manage teams'
|
|
6583
7038
|
'entity:Manage entities'
|
|
6584
7039
|
'link:Manage links between entities'
|
|
6585
7040
|
'event:Manage events'
|
|
@@ -6590,7 +7045,6 @@ _diafunc() {
|
|
|
6590
7045
|
'schedule:Schedule function execution'
|
|
6591
7046
|
'chat:AI chat'
|
|
6592
7047
|
'search:Search entities across projects'
|
|
6593
|
-
'group:Manage groups'
|
|
6594
7048
|
'admin:Administration commands'
|
|
6595
7049
|
'analyze:Run an automatic analysis on a data file'
|
|
6596
7050
|
)
|
|
@@ -6614,6 +7068,7 @@ _diafunc() {
|
|
|
6614
7068
|
auth) _diafunc_auth ;;
|
|
6615
7069
|
config) _diafunc_config ;;
|
|
6616
7070
|
project) _diafunc_project ;;
|
|
7071
|
+
team) _diafunc_team ;;
|
|
6617
7072
|
entity) _diafunc_entity ;;
|
|
6618
7073
|
link) _values 'subcommand' list create delete ;;
|
|
6619
7074
|
event) _values 'subcommand' list get delete ;;
|
|
@@ -6623,7 +7078,6 @@ _diafunc() {
|
|
|
6623
7078
|
trigger) _values 'subcommand' list get delete ;;
|
|
6624
7079
|
schedule) _values 'subcommand' call ;;
|
|
6625
7080
|
chat) _diafunc_chat ;;
|
|
6626
|
-
group) _diafunc_group ;;
|
|
6627
7081
|
admin) _diafunc_admin ;;
|
|
6628
7082
|
analyze) _files '*.csv' '*.xlsx' '*.xls' ;;
|
|
6629
7083
|
esac
|
|
@@ -6634,15 +7088,15 @@ _diafunc() {
|
|
|
6634
7088
|
_diafunc_auth() { _values 'subcommand' login logout status token; }
|
|
6635
7089
|
_diafunc_config() { _values 'subcommand' set get list profile; }
|
|
6636
7090
|
_diafunc_project() { _values 'subcommand' list get create delete lock unlock members; }
|
|
7091
|
+
_diafunc_team() { _values 'subcommand' list get use usage create portal cancel leave members invitations seats packs transfer; }
|
|
6637
7092
|
_diafunc_entity() { _values 'subcommand' list get delete history revert rename content; }
|
|
6638
7093
|
_diafunc_table() { _values 'subcommand' view import export row column cell clear; }
|
|
6639
7094
|
_diafunc_chat() { _values 'subcommand' send stream upload session usage; }
|
|
6640
|
-
_diafunc_group() { _values 'subcommand' list get create delete members projects; }
|
|
6641
7095
|
_diafunc_admin() { _values 'subcommand' users subscription settings backup; }
|
|
6642
7096
|
|
|
6643
7097
|
_diafunc "$@"`;
|
|
6644
7098
|
var FISH_COMPLETION = `# Fish completions for diafunc
|
|
6645
|
-
set -l commands auth config project entity link event branch table function trigger schedule chat search
|
|
7099
|
+
set -l commands auth config project team entity link event branch table function trigger schedule chat search admin analyze
|
|
6646
7100
|
|
|
6647
7101
|
# Disable file completions by default
|
|
6648
7102
|
complete -c diafunc -f
|
|
@@ -6651,6 +7105,7 @@ complete -c diafunc -f
|
|
|
6651
7105
|
complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a auth -d "Authentication and credential management"
|
|
6652
7106
|
complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a config -d "Manage CLI configuration"
|
|
6653
7107
|
complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a project -d "Manage projects"
|
|
7108
|
+
complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a team -d "Manage teams"
|
|
6654
7109
|
complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a entity -d "Manage entities"
|
|
6655
7110
|
complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a link -d "Manage links between entities"
|
|
6656
7111
|
complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a event -d "Manage events"
|
|
@@ -6661,7 +7116,6 @@ complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a trigger -d
|
|
|
6661
7116
|
complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a schedule -d "Schedule function execution"
|
|
6662
7117
|
complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a chat -d "AI chat"
|
|
6663
7118
|
complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a search -d "Search entities"
|
|
6664
|
-
complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a group -d "Manage groups"
|
|
6665
7119
|
complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a admin -d "Administration commands"
|
|
6666
7120
|
complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a analyze -d "Run automatic analysis"
|
|
6667
7121
|
|
|
@@ -6698,8 +7152,11 @@ complete -c diafunc -n "__fish_seen_subcommand_from function; and not __fish_see
|
|
|
6698
7152
|
# chat
|
|
6699
7153
|
complete -c diafunc -n "__fish_seen_subcommand_from chat; and not __fish_seen_subcommand_from send stream upload session usage" -a "send stream upload session usage"
|
|
6700
7154
|
|
|
6701
|
-
#
|
|
6702
|
-
complete -c diafunc -n "__fish_seen_subcommand_from
|
|
7155
|
+
# team
|
|
7156
|
+
complete -c diafunc -n "__fish_seen_subcommand_from team; and not __fish_seen_subcommand_from list get use usage create portal cancel leave members invitations seats packs transfer" -a "list get use usage create portal cancel leave members invitations seats packs transfer"
|
|
7157
|
+
complete -c diafunc -n "__fish_seen_subcommand_from invitations; and not __fish_seen_subcommand_from list revoke resend accept" -a "list revoke resend accept"
|
|
7158
|
+
complete -c diafunc -n "__fish_seen_subcommand_from seats packs; and not __fish_seen_subcommand_from preview set" -a "preview set"
|
|
7159
|
+
complete -c diafunc -n "__fish_seen_subcommand_from transfer; and not __fish_seen_subcommand_from start status accept cancel" -a "start status accept cancel"
|
|
6703
7160
|
|
|
6704
7161
|
# admin
|
|
6705
7162
|
complete -c diafunc -n "__fish_seen_subcommand_from admin; and not __fish_seen_subcommand_from users subscription settings backup" -a "users subscription settings backup"
|
|
@@ -6726,7 +7183,7 @@ function registerCompletionCommand(program) {
|
|
|
6726
7183
|
}
|
|
6727
7184
|
|
|
6728
7185
|
// src/commands/whoami/index.ts
|
|
6729
|
-
import
|
|
7186
|
+
import chalk31 from "chalk";
|
|
6730
7187
|
function registerWhoamiCommand(program) {
|
|
6731
7188
|
program.command("whoami").description("Show the currently authenticated user").action(async (_options, cmd) => {
|
|
6732
7189
|
try {
|
|
@@ -6736,8 +7193,8 @@ function registerWhoamiCommand(program) {
|
|
|
6736
7193
|
const api = createApiClient();
|
|
6737
7194
|
const user = await api.admin.getMyUser();
|
|
6738
7195
|
if (outputFormat === "human") {
|
|
6739
|
-
console.log(
|
|
6740
|
-
console.log(
|
|
7196
|
+
console.log(chalk31.bold(user.name) + chalk31.dim(` <${user.email}>`));
|
|
7197
|
+
console.log(chalk31.dim(` Role: ${user.role} \xB7 Remaining credits: ${user.remainingCredits} \xB7 Profile: ${config.currentProfile}`));
|
|
6741
7198
|
} else {
|
|
6742
7199
|
format(user, { format: outputFormat });
|
|
6743
7200
|
}
|
|
@@ -6748,7 +7205,7 @@ function registerWhoamiCommand(program) {
|
|
|
6748
7205
|
}
|
|
6749
7206
|
|
|
6750
7207
|
// src/commands/utilization/index.ts
|
|
6751
|
-
import
|
|
7208
|
+
import chalk32 from "chalk";
|
|
6752
7209
|
function getOutputFormat19(cmd) {
|
|
6753
7210
|
const config = loadConfig();
|
|
6754
7211
|
const globalOpts = cmd.optsWithGlobals();
|
|
@@ -6757,21 +7214,21 @@ function getOutputFormat19(cmd) {
|
|
|
6757
7214
|
function printUtilizationHuman(u, label) {
|
|
6758
7215
|
const when = u.day !== null && u.day !== void 0 ? `${u.year}-${String(u.month).padStart(2, "0")}-${String(u.day).padStart(2, "0")}` : `${u.year}-${String(u.month).padStart(2, "0")}`;
|
|
6759
7216
|
if (label) {
|
|
6760
|
-
console.log(
|
|
7217
|
+
console.log(chalk32.bold(label) + " " + chalk32.dim(when));
|
|
6761
7218
|
} else {
|
|
6762
|
-
console.log(
|
|
7219
|
+
console.log(chalk32.bold(when));
|
|
6763
7220
|
}
|
|
6764
7221
|
if (u.types.length === 0) {
|
|
6765
|
-
console.log(
|
|
7222
|
+
console.log(chalk32.dim(" (no usage)"));
|
|
6766
7223
|
return;
|
|
6767
7224
|
}
|
|
6768
7225
|
for (const t of u.types) {
|
|
6769
7226
|
console.log(
|
|
6770
|
-
` ${t.type.padEnd(24)} ${
|
|
7227
|
+
` ${t.type.padEnd(24)} ${chalk32.cyan(String(t.quantity).padStart(10))} ${chalk32.dim("credits:")} ${t.credits.toFixed(2)}`
|
|
6771
7228
|
);
|
|
6772
7229
|
}
|
|
6773
7230
|
const total = u.totalCredits ?? u.types.reduce((s, t) => s + t.credits, 0);
|
|
6774
|
-
console.log(
|
|
7231
|
+
console.log(chalk32.bold(` Total credits: ${total.toFixed(2)}`));
|
|
6775
7232
|
}
|
|
6776
7233
|
function registerUtilizationCommand(program) {
|
|
6777
7234
|
const util = program.command("utilization").description("Show credit utilization");
|
|
@@ -6796,7 +7253,7 @@ function registerUtilizationCommand(program) {
|
|
|
6796
7253
|
const history = await api.admin.getUtilizationHistory();
|
|
6797
7254
|
if (outputFormat === "human") {
|
|
6798
7255
|
if (history.length === 0) {
|
|
6799
|
-
console.log(
|
|
7256
|
+
console.log(chalk32.dim("No usage recorded."));
|
|
6800
7257
|
return;
|
|
6801
7258
|
}
|
|
6802
7259
|
for (const u of history) {
|
|
@@ -6813,7 +7270,7 @@ function registerUtilizationCommand(program) {
|
|
|
6813
7270
|
}
|
|
6814
7271
|
|
|
6815
7272
|
// src/commands/entity-branch/index.ts
|
|
6816
|
-
import
|
|
7273
|
+
import chalk33 from "chalk";
|
|
6817
7274
|
function getOutputFormat20(cmd) {
|
|
6818
7275
|
const config = loadConfig();
|
|
6819
7276
|
const globalOpts = cmd.optsWithGlobals();
|
|
@@ -6857,7 +7314,7 @@ function registerEntityBranchCommands(program) {
|
|
|
6857
7314
|
sourceEntityBranch: resolved.entityBranch,
|
|
6858
7315
|
targetEntityBranch: targetBranch
|
|
6859
7316
|
});
|
|
6860
|
-
console.log(
|
|
7317
|
+
console.log(chalk33.green(`Entity branch "${targetBranch}" created from "${resolved.entityBranch}".`));
|
|
6861
7318
|
} catch (error) {
|
|
6862
7319
|
handleError(error);
|
|
6863
7320
|
}
|
|
@@ -6902,7 +7359,7 @@ function registerSubscriptionCommand(program) {
|
|
|
6902
7359
|
}
|
|
6903
7360
|
|
|
6904
7361
|
// src/commands/invoice/index.ts
|
|
6905
|
-
import
|
|
7362
|
+
import chalk34 from "chalk";
|
|
6906
7363
|
import * as fs10 from "fs";
|
|
6907
7364
|
function getOutputFormat22(cmd) {
|
|
6908
7365
|
const config = loadConfig();
|
|
@@ -6930,7 +7387,7 @@ function registerInvoiceCommand(program) {
|
|
|
6930
7387
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
6931
7388
|
const outPath = options.out ?? fileName;
|
|
6932
7389
|
fs10.writeFileSync(outPath, buffer);
|
|
6933
|
-
console.log(
|
|
7390
|
+
console.log(chalk34.green(`Invoice saved to ${outPath}`));
|
|
6934
7391
|
} catch (error) {
|
|
6935
7392
|
handleError(error);
|
|
6936
7393
|
}
|
|
@@ -6938,7 +7395,7 @@ function registerInvoiceCommand(program) {
|
|
|
6938
7395
|
}
|
|
6939
7396
|
|
|
6940
7397
|
// src/commands/shell/index.ts
|
|
6941
|
-
import
|
|
7398
|
+
import chalk35 from "chalk";
|
|
6942
7399
|
import * as fs11 from "fs";
|
|
6943
7400
|
import * as os3 from "os";
|
|
6944
7401
|
import * as path8 from "path";
|
|
@@ -7004,21 +7461,21 @@ async function evaluate(api, fnRef, language, sourceCode) {
|
|
|
7004
7461
|
}, false);
|
|
7005
7462
|
if (result.outputs?.length) {
|
|
7006
7463
|
for (const out of result.outputs) {
|
|
7007
|
-
console.log(
|
|
7464
|
+
console.log(chalk35.dim(` [${out.type}]`) + " " + out.output);
|
|
7008
7465
|
}
|
|
7009
7466
|
}
|
|
7010
7467
|
if (result.successful) {
|
|
7011
7468
|
if (result.result) {
|
|
7012
|
-
console.log(
|
|
7469
|
+
console.log(chalk35.green("=> ") + result.result);
|
|
7013
7470
|
} else {
|
|
7014
|
-
console.log(
|
|
7471
|
+
console.log(chalk35.dim("=> (no value)"));
|
|
7015
7472
|
}
|
|
7016
7473
|
const duration = result.completed - result.started;
|
|
7017
|
-
console.log(
|
|
7474
|
+
console.log(chalk35.dim(` [${duration}ms \xB7 ${evaluationId}]`));
|
|
7018
7475
|
} else {
|
|
7019
|
-
console.log(
|
|
7476
|
+
console.log(chalk35.red("error: ") + result.error);
|
|
7020
7477
|
if (result.lineNumber > 0) {
|
|
7021
|
-
console.log(
|
|
7478
|
+
console.log(chalk35.dim(` at line ${result.lineNumber}, col ${result.columnNumber}`));
|
|
7022
7479
|
}
|
|
7023
7480
|
}
|
|
7024
7481
|
}
|
|
@@ -7026,9 +7483,9 @@ function registerShellCommand(program) {
|
|
|
7026
7483
|
program.command("shell").description("Interactive REPL for function code evaluation").option("--function <ref>", "Function entity reference to use as scratch (required)").option("--language <lang>", "Source language", "JavaScript").action(async (options, cmd) => {
|
|
7027
7484
|
try {
|
|
7028
7485
|
if (!options.function) {
|
|
7029
|
-
console.error(
|
|
7030
|
-
console.error(
|
|
7031
|
-
console.error(
|
|
7486
|
+
console.error(chalk35.red("Missing --function <ref>."));
|
|
7487
|
+
console.error(chalk35.dim("Pass an existing or new function entity reference to use as the shell target."));
|
|
7488
|
+
console.error(chalk35.dim("Example: diafunc shell --function my-project/main/scratch/main --language JavaScript"));
|
|
7032
7489
|
process.exit(1);
|
|
7033
7490
|
}
|
|
7034
7491
|
const config = loadConfig();
|
|
@@ -7039,18 +7496,18 @@ function registerShellCommand(program) {
|
|
|
7039
7496
|
});
|
|
7040
7497
|
const api = createApiClient();
|
|
7041
7498
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
7042
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
7043
|
-
console.log(
|
|
7044
|
-
console.log(
|
|
7045
|
-
console.log(
|
|
7499
|
+
const { getUpdateNotice } = await import("./update-check-L55QNPYQ.js");
|
|
7500
|
+
console.log(chalk35.bold("Diafunc shell") + chalk35.dim(` \xB7 function ${fnRef.entityId} \xB7 ${options.language}`));
|
|
7501
|
+
console.log(chalk35.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
|
|
7502
|
+
console.log(chalk35.dim("Commands: /edit (multi-line in $EDITOR), /lang <name>, /file <path>, /help, /quit"));
|
|
7046
7503
|
const notice = await getUpdateNotice();
|
|
7047
|
-
if (notice) console.log(
|
|
7504
|
+
if (notice) console.log(chalk35.dim(notice));
|
|
7048
7505
|
console.log();
|
|
7049
7506
|
let language = options.language;
|
|
7050
7507
|
for (; ; ) {
|
|
7051
7508
|
let line;
|
|
7052
7509
|
try {
|
|
7053
|
-
line = await promptInput({ message:
|
|
7510
|
+
line = await promptInput({ message: chalk35.cyan.bold(`${language} >`) });
|
|
7054
7511
|
} catch {
|
|
7055
7512
|
console.log();
|
|
7056
7513
|
return;
|
|
@@ -7068,54 +7525,54 @@ function registerShellCommand(program) {
|
|
|
7068
7525
|
case "help":
|
|
7069
7526
|
case "h":
|
|
7070
7527
|
case "?":
|
|
7071
|
-
console.log(
|
|
7072
|
-
console.log(
|
|
7073
|
-
console.log(
|
|
7074
|
-
console.log(
|
|
7528
|
+
console.log(chalk35.dim(" /edit open $EDITOR for multi-line code"));
|
|
7529
|
+
console.log(chalk35.dim(" /file <path> evaluate the contents of a file"));
|
|
7530
|
+
console.log(chalk35.dim(" /lang <name> switch language (Java, JavaScript, Kotlin, Python, Scala)"));
|
|
7531
|
+
console.log(chalk35.dim(" /quit exit the shell"));
|
|
7075
7532
|
continue;
|
|
7076
7533
|
case "lang":
|
|
7077
7534
|
if (arg) language = arg;
|
|
7078
|
-
console.log(
|
|
7535
|
+
console.log(chalk35.dim(`Language: ${language}`));
|
|
7079
7536
|
continue;
|
|
7080
7537
|
case "edit": {
|
|
7081
7538
|
const sourceCode = await openInEditor("", extensionFor2(language));
|
|
7082
7539
|
if (!sourceCode.trim()) {
|
|
7083
|
-
console.log(
|
|
7540
|
+
console.log(chalk35.dim("(empty \u2014 not evaluated)"));
|
|
7084
7541
|
continue;
|
|
7085
7542
|
}
|
|
7086
7543
|
try {
|
|
7087
7544
|
await evaluate(api, fnRef, language, sourceCode);
|
|
7088
7545
|
} catch (e) {
|
|
7089
|
-
console.error(
|
|
7546
|
+
console.error(chalk35.red(e.message));
|
|
7090
7547
|
}
|
|
7091
7548
|
continue;
|
|
7092
7549
|
}
|
|
7093
7550
|
case "file": {
|
|
7094
7551
|
if (!arg) {
|
|
7095
|
-
console.log(
|
|
7552
|
+
console.log(chalk35.dim("usage: /file <path>"));
|
|
7096
7553
|
continue;
|
|
7097
7554
|
}
|
|
7098
7555
|
if (!fs11.existsSync(arg)) {
|
|
7099
|
-
console.log(
|
|
7556
|
+
console.log(chalk35.red(`file not found: ${arg}`));
|
|
7100
7557
|
continue;
|
|
7101
7558
|
}
|
|
7102
7559
|
const sourceCode = fs11.readFileSync(arg, "utf-8");
|
|
7103
7560
|
try {
|
|
7104
7561
|
await evaluate(api, fnRef, language, sourceCode);
|
|
7105
7562
|
} catch (e) {
|
|
7106
|
-
console.error(
|
|
7563
|
+
console.error(chalk35.red(e.message));
|
|
7107
7564
|
}
|
|
7108
7565
|
continue;
|
|
7109
7566
|
}
|
|
7110
7567
|
default:
|
|
7111
|
-
console.log(
|
|
7568
|
+
console.log(chalk35.dim(`Unknown command: /${cmd2}. Try /help.`));
|
|
7112
7569
|
continue;
|
|
7113
7570
|
}
|
|
7114
7571
|
}
|
|
7115
7572
|
try {
|
|
7116
7573
|
await evaluate(api, fnRef, language, trimmed);
|
|
7117
7574
|
} catch (e) {
|
|
7118
|
-
console.error(
|
|
7575
|
+
console.error(chalk35.red(e.message));
|
|
7119
7576
|
}
|
|
7120
7577
|
}
|
|
7121
7578
|
} catch (error) {
|
|
@@ -7125,7 +7582,7 @@ function registerShellCommand(program) {
|
|
|
7125
7582
|
}
|
|
7126
7583
|
|
|
7127
7584
|
// src/commands/update/index.ts
|
|
7128
|
-
import
|
|
7585
|
+
import chalk36 from "chalk";
|
|
7129
7586
|
import * as path9 from "path";
|
|
7130
7587
|
import { spawn as spawn4 } from "child_process";
|
|
7131
7588
|
|
|
@@ -7171,14 +7628,14 @@ function registerUpdateCommand(program) {
|
|
|
7171
7628
|
const install = detectInstall();
|
|
7172
7629
|
const latest = await fetchLatestVersion();
|
|
7173
7630
|
if (latest === package_default.version) {
|
|
7174
|
-
console.log(
|
|
7631
|
+
console.log(chalk36.dim(`diafunc is already at the latest version (${package_default.version}).`));
|
|
7175
7632
|
return;
|
|
7176
7633
|
}
|
|
7177
|
-
console.log(
|
|
7634
|
+
console.log(chalk36.dim(`Current: ${package_default.version} \u2192 Available: ${latest}`));
|
|
7178
7635
|
if (install.method === "npm") {
|
|
7179
7636
|
console.log();
|
|
7180
7637
|
console.log("Installed via npm. Upgrade with:");
|
|
7181
|
-
console.log(
|
|
7638
|
+
console.log(chalk36.bold(` npm install -g @diafunc/cli@${latest}`));
|
|
7182
7639
|
return;
|
|
7183
7640
|
}
|
|
7184
7641
|
const installDir = path9.dirname(install.binaryPath);
|
|
@@ -7192,7 +7649,7 @@ function registerUpdateCommand(program) {
|
|
|
7192
7649
|
}
|
|
7193
7650
|
|
|
7194
7651
|
// src/commands/uninstall/index.ts
|
|
7195
|
-
import
|
|
7652
|
+
import chalk37 from "chalk";
|
|
7196
7653
|
import { spawn as spawn5 } from "child_process";
|
|
7197
7654
|
import * as fs13 from "fs";
|
|
7198
7655
|
import * as os4 from "os";
|
|
@@ -7204,11 +7661,11 @@ function registerUninstallCommand(program) {
|
|
|
7204
7661
|
const configDir = path10.join(os4.homedir(), ".diafunc");
|
|
7205
7662
|
if (install.method === "npm") {
|
|
7206
7663
|
console.log("Installed via npm. Remove with:");
|
|
7207
|
-
console.log(
|
|
7664
|
+
console.log(chalk37.bold(" npm uninstall -g @diafunc/cli"));
|
|
7208
7665
|
if (fs13.existsSync(configDir)) {
|
|
7209
7666
|
console.log();
|
|
7210
7667
|
console.log(`Config + credentials live at ${configDir} \u2014 remove manually with:`);
|
|
7211
|
-
console.log(
|
|
7668
|
+
console.log(chalk37.bold(` rm -rf ${configDir}`));
|
|
7212
7669
|
}
|
|
7213
7670
|
return;
|
|
7214
7671
|
}
|
|
@@ -7218,7 +7675,7 @@ function registerUninstallCommand(program) {
|
|
|
7218
7675
|
default: false
|
|
7219
7676
|
});
|
|
7220
7677
|
if (!removeBinary) {
|
|
7221
|
-
console.log(
|
|
7678
|
+
console.log(chalk37.dim("Aborted."));
|
|
7222
7679
|
return;
|
|
7223
7680
|
}
|
|
7224
7681
|
let removeConfig = options.purge ?? false;
|
|
@@ -7230,7 +7687,7 @@ function registerUninstallCommand(program) {
|
|
|
7230
7687
|
}
|
|
7231
7688
|
if (removeConfig && fs13.existsSync(configDir)) {
|
|
7232
7689
|
fs13.rmSync(configDir, { recursive: true, force: true });
|
|
7233
|
-
console.log(
|
|
7690
|
+
console.log(chalk37.dim(`Removed ${configDir}`));
|
|
7234
7691
|
}
|
|
7235
7692
|
if (process.platform === "win32") {
|
|
7236
7693
|
const cmd = `timeout /t 2 /nobreak >nul & del /f /q "${install.binaryPath}"`;
|
|
@@ -7240,13 +7697,13 @@ function registerUninstallCommand(program) {
|
|
|
7240
7697
|
windowsHide: true
|
|
7241
7698
|
});
|
|
7242
7699
|
child.unref();
|
|
7243
|
-
console.log(
|
|
7700
|
+
console.log(chalk37.dim(`Removing ${install.binaryPath} on exit...`));
|
|
7244
7701
|
console.log();
|
|
7245
7702
|
console.log("diafunc uninstalled.");
|
|
7246
7703
|
return;
|
|
7247
7704
|
}
|
|
7248
7705
|
fs13.rmSync(install.binaryPath, { force: true });
|
|
7249
|
-
console.log(
|
|
7706
|
+
console.log(chalk37.dim(`Removed ${install.binaryPath}`));
|
|
7250
7707
|
console.log();
|
|
7251
7708
|
console.log("diafunc uninstalled.");
|
|
7252
7709
|
} catch (error) {
|
|
@@ -7267,6 +7724,7 @@ function createProgram() {
|
|
|
7267
7724
|
registerAuthCommands(program);
|
|
7268
7725
|
registerConfigCommands(program);
|
|
7269
7726
|
registerProjectCommands(program);
|
|
7727
|
+
registerTeamCommands(program);
|
|
7270
7728
|
registerEntityCommands(program);
|
|
7271
7729
|
registerLinkCommands(program);
|
|
7272
7730
|
registerEventCommands(program);
|
|
@@ -7278,7 +7736,6 @@ function createProgram() {
|
|
|
7278
7736
|
registerScheduleCommands(program);
|
|
7279
7737
|
registerChatCommands(program);
|
|
7280
7738
|
registerSearchCommands(program);
|
|
7281
|
-
registerGroupCommands(program);
|
|
7282
7739
|
registerAdminCommands(program);
|
|
7283
7740
|
registerStatusCommands(program);
|
|
7284
7741
|
registerAnalyzeCommand(program);
|
|
@@ -7300,4 +7757,4 @@ function createProgram() {
|
|
|
7300
7757
|
export {
|
|
7301
7758
|
createProgram
|
|
7302
7759
|
};
|
|
7303
|
-
//# sourceMappingURL=chunk-
|
|
7760
|
+
//# sourceMappingURL=chunk-2WJQPO4V.js.map
|