@amaster.ai/runtime-cli 1.1.13-beta.0 → 1.1.14-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/dist/cli.cjs +398 -220
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +398 -220
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +398 -220
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +398 -220
- package/dist/index.js.map +1 -1
- package/dist/skill/SKILL.md +29 -0
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { existsSync, rmSync, mkdirSync,
|
|
2
|
+
import { readFileSync, existsSync, rmSync, mkdirSync, writeFileSync, realpathSync } from 'fs';
|
|
3
3
|
import { join, resolve, basename } from 'path';
|
|
4
4
|
import { homedir } from 'os';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
import { Command, Option } from 'commander';
|
|
7
|
-
import
|
|
7
|
+
import chalk4 from 'chalk';
|
|
8
8
|
import { createClient } from '@amaster.ai/client';
|
|
9
9
|
import ora from 'ora';
|
|
10
10
|
import { File } from 'buffer';
|
|
@@ -327,9 +327,9 @@ async function login(appCode, options) {
|
|
|
327
327
|
const appConfig = getAppConfig(appCode);
|
|
328
328
|
if (!appConfig) {
|
|
329
329
|
spinner.fail(`App not configured: ${appCode}`);
|
|
330
|
-
console.error(
|
|
330
|
+
console.error(chalk4.red(`
|
|
331
331
|
\u274C App not found: ${appCode}`));
|
|
332
|
-
console.log(
|
|
332
|
+
console.log(chalk4.yellow(`Initialize it first: amaster init --app-code ${appCode} --url <url>`));
|
|
333
333
|
process.exit(1);
|
|
334
334
|
}
|
|
335
335
|
let username = options.username;
|
|
@@ -378,7 +378,7 @@ async function login(appCode, options) {
|
|
|
378
378
|
const result = await client.auth.login(loginParams);
|
|
379
379
|
if (result.error) {
|
|
380
380
|
spinner.fail("Login failed");
|
|
381
|
-
console.error(
|
|
381
|
+
console.error(chalk4.red(result.error.message));
|
|
382
382
|
process.exit(1);
|
|
383
383
|
}
|
|
384
384
|
const loginData = result.data;
|
|
@@ -412,16 +412,16 @@ async function login(appCode, options) {
|
|
|
412
412
|
format: options.format,
|
|
413
413
|
pretty: () => {
|
|
414
414
|
console.log(
|
|
415
|
-
|
|
415
|
+
chalk4.green(
|
|
416
416
|
`
|
|
417
417
|
Welcome, ${loginData.user?.displayName || loginData.user?.email || loginData.user?.username || email}!`
|
|
418
418
|
)
|
|
419
419
|
);
|
|
420
|
-
console.log(
|
|
421
|
-
console.log(
|
|
420
|
+
console.log(chalk4.gray(`App: ${appCode}`));
|
|
421
|
+
console.log(chalk4.gray(`URL: ${appConfig.baseURL}`));
|
|
422
422
|
if (expiresAt) {
|
|
423
423
|
const expires = new Date(expiresAt);
|
|
424
|
-
console.log(
|
|
424
|
+
console.log(chalk4.gray(`Session expires: ${expires.toLocaleString()}`));
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
}
|
|
@@ -457,7 +457,7 @@ async function logout(appCode, options = {}) {
|
|
|
457
457
|
{
|
|
458
458
|
format: options.format,
|
|
459
459
|
pretty: () => {
|
|
460
|
-
console.log(
|
|
460
|
+
console.log(chalk4.green(`Logged out from ${appCode}`));
|
|
461
461
|
}
|
|
462
462
|
}
|
|
463
463
|
);
|
|
@@ -473,7 +473,7 @@ async function getMe(getClient, options = {}) {
|
|
|
473
473
|
const result = await client.auth.getMe();
|
|
474
474
|
if (result.error) {
|
|
475
475
|
spinner.fail("Failed to fetch user info");
|
|
476
|
-
console.error(
|
|
476
|
+
console.error(chalk4.red(result.error.message));
|
|
477
477
|
process.exit(1);
|
|
478
478
|
}
|
|
479
479
|
spinner.succeed("User info retrieved");
|
|
@@ -481,11 +481,11 @@ async function getMe(getClient, options = {}) {
|
|
|
481
481
|
renderOutput(user, {
|
|
482
482
|
format: options.format,
|
|
483
483
|
pretty: () => {
|
|
484
|
-
console.log(
|
|
485
|
-
console.log(` ${
|
|
486
|
-
console.log(` ${
|
|
487
|
-
console.log(` ${
|
|
488
|
-
console.log(` ${
|
|
484
|
+
console.log(chalk4.blue("\n\u{1F464} User Profile\n"));
|
|
485
|
+
console.log(` ${chalk4.bold("UID:")} ${user?.uid}`);
|
|
486
|
+
console.log(` ${chalk4.bold("Email:")} ${user?.email}`);
|
|
487
|
+
console.log(` ${chalk4.bold("Name:")} ${user?.displayName || user?.username || "N/A"}`);
|
|
488
|
+
console.log(` ${chalk4.bold("Status:")} ${user?.isActive ? "Active" : "Inactive"}`);
|
|
489
489
|
}
|
|
490
490
|
});
|
|
491
491
|
} catch (error) {
|
|
@@ -615,7 +615,7 @@ function exitWithCommandError(spinner, failureMessage, error) {
|
|
|
615
615
|
spinner.fail(failureMessage);
|
|
616
616
|
const details = error instanceof Error ? error.message : String(error);
|
|
617
617
|
if (details) {
|
|
618
|
-
console.error(
|
|
618
|
+
console.error(chalk4.red(details));
|
|
619
619
|
}
|
|
620
620
|
process.exit(1);
|
|
621
621
|
}
|
|
@@ -680,7 +680,7 @@ async function listEntities(client, options) {
|
|
|
680
680
|
});
|
|
681
681
|
if (result.error) {
|
|
682
682
|
spinner.fail("Failed to fetch entities");
|
|
683
|
-
console.error(
|
|
683
|
+
console.error(chalk4.red(result.error.message));
|
|
684
684
|
process.exit(1);
|
|
685
685
|
}
|
|
686
686
|
spinner.stop();
|
|
@@ -700,12 +700,12 @@ async function listEntities(client, options) {
|
|
|
700
700
|
renderOutput(result.data, {
|
|
701
701
|
format: options.format,
|
|
702
702
|
pretty: () => {
|
|
703
|
-
console.log(
|
|
703
|
+
console.log(chalk4.blue(`
|
|
704
704
|
\u{1F4E6} ${options.entity} in ${options.namespace}`));
|
|
705
|
-
console.log(
|
|
705
|
+
console.log(chalk4.gray(`\u5171 ${total} \u6761\u8BB0\u5F55:
|
|
706
706
|
`));
|
|
707
707
|
if (items.length === 0) {
|
|
708
|
-
console.log(
|
|
708
|
+
console.log(chalk4.gray(" \u6682\u65E0\u6570\u636E"));
|
|
709
709
|
return;
|
|
710
710
|
}
|
|
711
711
|
const firstItem = items[0];
|
|
@@ -725,7 +725,7 @@ async function listEntities(client, options) {
|
|
|
725
725
|
});
|
|
726
726
|
const headerLine = keys.map((key) => {
|
|
727
727
|
const width = widths[key] ?? 0;
|
|
728
|
-
return
|
|
728
|
+
return chalk4.bold(key.slice(0, width).padEnd(width));
|
|
729
729
|
}).join("\u2502");
|
|
730
730
|
console.log(" " + headerLine);
|
|
731
731
|
console.log(" " + keys.map((key) => "\u2500".repeat(widths[key] ?? 0)).join("\u253C"));
|
|
@@ -741,7 +741,7 @@ async function listEntities(client, options) {
|
|
|
741
741
|
}
|
|
742
742
|
console.log();
|
|
743
743
|
if (items.length < total) {
|
|
744
|
-
console.log(
|
|
744
|
+
console.log(chalk4.gray(` ... \u8FD8\u6709 ${total - items.length} \u6761\u8BB0\u5F55`));
|
|
745
745
|
}
|
|
746
746
|
}
|
|
747
747
|
});
|
|
@@ -756,14 +756,14 @@ async function getEntity(client, options) {
|
|
|
756
756
|
const result = await entityClient.get(options.namespace, options.entity, options.id);
|
|
757
757
|
if (result.error) {
|
|
758
758
|
spinner.fail("Failed to fetch entity");
|
|
759
|
-
console.error(
|
|
759
|
+
console.error(chalk4.red(result.error.message));
|
|
760
760
|
process.exit(1);
|
|
761
761
|
}
|
|
762
762
|
spinner.succeed("Entity retrieved");
|
|
763
763
|
renderOutput(result.data, {
|
|
764
764
|
format: options.format,
|
|
765
765
|
pretty: () => {
|
|
766
|
-
console.log(
|
|
766
|
+
console.log(chalk4.blue(`
|
|
767
767
|
\u{1F4C4} ${options.entity}
|
|
768
768
|
`));
|
|
769
769
|
console.log(JSON.stringify(result.data, null, 2));
|
|
@@ -781,14 +781,14 @@ async function createEntity(client, options) {
|
|
|
781
781
|
const result = await entityClient.create(options.namespace, options.entity, data);
|
|
782
782
|
if (result.error) {
|
|
783
783
|
spinner.fail("Failed to create entity");
|
|
784
|
-
console.error(
|
|
784
|
+
console.error(chalk4.red(result.error.message));
|
|
785
785
|
process.exit(1);
|
|
786
786
|
}
|
|
787
787
|
spinner.succeed("Entity created");
|
|
788
788
|
renderOutput(result.data, {
|
|
789
789
|
format: options.format,
|
|
790
790
|
pretty: () => {
|
|
791
|
-
console.log(
|
|
791
|
+
console.log(chalk4.green("\nCreated entity:"));
|
|
792
792
|
console.log(JSON.stringify(result.data, null, 2));
|
|
793
793
|
}
|
|
794
794
|
});
|
|
@@ -804,14 +804,14 @@ async function updateEntity(client, options) {
|
|
|
804
804
|
const result = await entityClient.update(options.namespace, options.entity, options.id, data);
|
|
805
805
|
if (result.error) {
|
|
806
806
|
spinner.fail("Failed to update entity");
|
|
807
|
-
console.error(
|
|
807
|
+
console.error(chalk4.red(result.error.message));
|
|
808
808
|
process.exit(1);
|
|
809
809
|
}
|
|
810
810
|
spinner.succeed("Entity updated");
|
|
811
811
|
renderOutput(result.data, {
|
|
812
812
|
format: options.format,
|
|
813
813
|
pretty: () => {
|
|
814
|
-
console.log(
|
|
814
|
+
console.log(chalk4.green("\nUpdated entity:"));
|
|
815
815
|
console.log(JSON.stringify(result.data, null, 2));
|
|
816
816
|
}
|
|
817
817
|
});
|
|
@@ -826,7 +826,7 @@ async function deleteEntity(client, options) {
|
|
|
826
826
|
const result = await entityClient.delete(options.namespace, options.entity, options.id);
|
|
827
827
|
if (result.error) {
|
|
828
828
|
spinner.fail("Failed to delete entity");
|
|
829
|
-
console.error(
|
|
829
|
+
console.error(chalk4.red(result.error.message));
|
|
830
830
|
process.exit(1);
|
|
831
831
|
}
|
|
832
832
|
spinner.succeed("Entity deleted");
|
|
@@ -840,7 +840,7 @@ async function deleteEntity(client, options) {
|
|
|
840
840
|
{
|
|
841
841
|
format: options.format,
|
|
842
842
|
pretty: () => {
|
|
843
|
-
console.log(
|
|
843
|
+
console.log(chalk4.green(`
|
|
844
844
|
Deleted ${options.entity} with ID: ${options.id}`));
|
|
845
845
|
}
|
|
846
846
|
}
|
|
@@ -857,14 +857,14 @@ async function listEntityOptions(client, options) {
|
|
|
857
857
|
const result = await entityClient.options(options.namespace, options.entity, fields);
|
|
858
858
|
if (result.error) {
|
|
859
859
|
spinner.fail("Failed to fetch entity options");
|
|
860
|
-
console.error(
|
|
860
|
+
console.error(chalk4.red(result.error.message));
|
|
861
861
|
process.exit(1);
|
|
862
862
|
}
|
|
863
863
|
spinner.succeed(`Found ${result.data?.length || 0} options`);
|
|
864
864
|
renderOutput(result.data || [], {
|
|
865
865
|
format: options.format,
|
|
866
866
|
pretty: () => {
|
|
867
|
-
console.log(
|
|
867
|
+
console.log(chalk4.blue(`
|
|
868
868
|
\u{1F9FE} ${options.entity} options
|
|
869
869
|
`));
|
|
870
870
|
console.log(JSON.stringify(result.data || [], null, 2));
|
|
@@ -887,14 +887,14 @@ async function bulkUpdateEntities(client, options) {
|
|
|
887
887
|
const result = await entityClient.bulkUpdate(options.namespace, options.entity, items);
|
|
888
888
|
if (result.error) {
|
|
889
889
|
spinner.fail("Failed to bulk update entities");
|
|
890
|
-
console.error(
|
|
890
|
+
console.error(chalk4.red(result.error.message));
|
|
891
891
|
process.exit(1);
|
|
892
892
|
}
|
|
893
893
|
spinner.succeed(`Updated ${items.length} entities`);
|
|
894
894
|
renderOutput(result.data, {
|
|
895
895
|
format: options.format,
|
|
896
896
|
pretty: () => {
|
|
897
|
-
console.log(
|
|
897
|
+
console.log(chalk4.green(`
|
|
898
898
|
Bulk updated ${items.length} ${options.entity} records:`));
|
|
899
899
|
console.log(JSON.stringify(result.data, null, 2));
|
|
900
900
|
}
|
|
@@ -911,7 +911,7 @@ async function bulkDeleteEntities(client, options) {
|
|
|
911
911
|
const result = await entityClient.bulkDelete(options.namespace, options.entity, ids);
|
|
912
912
|
if (result.error) {
|
|
913
913
|
spinner.fail("Failed to bulk delete entities");
|
|
914
|
-
console.error(
|
|
914
|
+
console.error(chalk4.red(result.error.message));
|
|
915
915
|
process.exit(1);
|
|
916
916
|
}
|
|
917
917
|
spinner.succeed(`Deleted ${ids.length} entities`);
|
|
@@ -926,7 +926,7 @@ async function bulkDeleteEntities(client, options) {
|
|
|
926
926
|
{
|
|
927
927
|
format: options.format,
|
|
928
928
|
pretty: () => {
|
|
929
|
-
console.log(
|
|
929
|
+
console.log(chalk4.green(`
|
|
930
930
|
Deleted ${ids.length} ${options.entity} records.`));
|
|
931
931
|
}
|
|
932
932
|
}
|
|
@@ -935,10 +935,165 @@ Deleted ${ids.length} ${options.entity} records.`));
|
|
|
935
935
|
exitWithCommandError(spinner, "Failed to bulk delete entities", error);
|
|
936
936
|
}
|
|
937
937
|
}
|
|
938
|
+
function resolveInputSource2(input) {
|
|
939
|
+
if (!input.startsWith("@")) {
|
|
940
|
+
return input;
|
|
941
|
+
}
|
|
942
|
+
const filePath = input.slice(1);
|
|
943
|
+
if (!filePath) {
|
|
944
|
+
throw new Error("File path is required after '@'.");
|
|
945
|
+
}
|
|
946
|
+
return readFileSync(filePath, "utf8");
|
|
947
|
+
}
|
|
948
|
+
function exitWithCommandError2(spinner, failureMessage, error) {
|
|
949
|
+
spinner.fail(failureMessage);
|
|
950
|
+
const details = error instanceof Error ? error.message : String(error);
|
|
951
|
+
if (details) {
|
|
952
|
+
console.error(chalk4.red(details));
|
|
953
|
+
}
|
|
954
|
+
process.exit(1);
|
|
955
|
+
}
|
|
956
|
+
function parseTableNamesInput(input) {
|
|
957
|
+
if (!input) {
|
|
958
|
+
return void 0;
|
|
959
|
+
}
|
|
960
|
+
const source = resolveInputSource2(input).trim();
|
|
961
|
+
if (!source) {
|
|
962
|
+
return void 0;
|
|
963
|
+
}
|
|
964
|
+
if (source.startsWith("[")) {
|
|
965
|
+
let parsed;
|
|
966
|
+
try {
|
|
967
|
+
parsed = JSON.parse(source);
|
|
968
|
+
} catch (error) {
|
|
969
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
970
|
+
throw new Error(`Invalid table list: ${reason}`);
|
|
971
|
+
}
|
|
972
|
+
if (!Array.isArray(parsed)) {
|
|
973
|
+
throw new Error("Table list must be a JSON array.");
|
|
974
|
+
}
|
|
975
|
+
return parsed.map((value, index) => {
|
|
976
|
+
if (typeof value !== "string") {
|
|
977
|
+
throw new Error(`Table name at index ${index} must be a string.`);
|
|
978
|
+
}
|
|
979
|
+
return value;
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
const values = source.split(/[,\n]/).map((entry) => entry.trim()).filter(Boolean);
|
|
983
|
+
return values.length > 0 ? values : void 0;
|
|
984
|
+
}
|
|
985
|
+
async function listDatasources(client, options = {}) {
|
|
986
|
+
const spinner = createSpinner("Fetching datasources...", options.format);
|
|
987
|
+
try {
|
|
988
|
+
const result = await client.http.request({
|
|
989
|
+
url: "/api/entity/source/list_with_models",
|
|
990
|
+
method: "GET"
|
|
991
|
+
});
|
|
992
|
+
if (result.error) {
|
|
993
|
+
spinner.fail("Failed to fetch datasources");
|
|
994
|
+
console.error(chalk4.red(result.error.message));
|
|
995
|
+
process.exit(1);
|
|
996
|
+
}
|
|
997
|
+
const datasources = result.data || [];
|
|
998
|
+
spinner.succeed(`Found ${datasources.length} datasource${datasources.length === 1 ? "" : "s"}`);
|
|
999
|
+
renderOutput(datasources, {
|
|
1000
|
+
format: options.format,
|
|
1001
|
+
tableRows: datasources.map((source) => ({
|
|
1002
|
+
sourceId: source.sourceId,
|
|
1003
|
+
name: source.name,
|
|
1004
|
+
systemBuilt: source.systemBuilt,
|
|
1005
|
+
synchronizeMode: source.synchronizeMode,
|
|
1006
|
+
modelCount: source.models?.length || 0
|
|
1007
|
+
})),
|
|
1008
|
+
csvRows: datasources.map((source) => ({
|
|
1009
|
+
sourceId: source.sourceId,
|
|
1010
|
+
name: source.name,
|
|
1011
|
+
systemBuilt: source.systemBuilt,
|
|
1012
|
+
synchronizeMode: source.synchronizeMode,
|
|
1013
|
+
modelCount: source.models?.length || 0
|
|
1014
|
+
})),
|
|
1015
|
+
ndjsonItems: datasources,
|
|
1016
|
+
pretty: () => {
|
|
1017
|
+
console.log(chalk4.blue("\nData Sources\n"));
|
|
1018
|
+
if (datasources.length === 0) {
|
|
1019
|
+
console.log(chalk4.gray("No datasources found."));
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
for (const source of datasources) {
|
|
1023
|
+
console.log(`${chalk4.green("\u2022")} ${chalk4.bold(source.name)} ${chalk4.gray(`(${source.sourceId})`)}`);
|
|
1024
|
+
console.log(` ${chalk4.gray("System Built:")} ${source.systemBuilt}`);
|
|
1025
|
+
console.log(` ${chalk4.gray("Sync Mode:")} ${source.synchronizeMode}`);
|
|
1026
|
+
if (!source.models || source.models.length === 0) {
|
|
1027
|
+
console.log(` ${chalk4.gray("Models:")} none`);
|
|
1028
|
+
continue;
|
|
1029
|
+
}
|
|
1030
|
+
console.log(` ${chalk4.gray("Models:")}`);
|
|
1031
|
+
for (const model of source.models) {
|
|
1032
|
+
const suffix = model.description ? ` ${chalk4.gray(`- ${model.description}`)}` : "";
|
|
1033
|
+
console.log(` - ${chalk4.bold(model.tableName)} ${chalk4.gray(`(${model.modelId})`)}${suffix}`);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
});
|
|
1038
|
+
} catch (error) {
|
|
1039
|
+
exitWithCommandError2(spinner, "Failed to fetch datasources", error);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
async function getTableSchema(client, options) {
|
|
1043
|
+
const spinner = createSpinner(`Fetching table schema for ${options.sourceId}...`, options.format);
|
|
1044
|
+
try {
|
|
1045
|
+
const tableNames = parseTableNamesInput(options.tables);
|
|
1046
|
+
const search = new URLSearchParams();
|
|
1047
|
+
if (tableNames && tableNames.length > 0) {
|
|
1048
|
+
search.set("tableNames", tableNames.join(","));
|
|
1049
|
+
}
|
|
1050
|
+
const query = search.toString();
|
|
1051
|
+
const url = `/api/entity/source/${encodeURIComponent(options.sourceId)}/create_table_statements${query ? `?${query}` : ""}`;
|
|
1052
|
+
const result = await client.http.request({
|
|
1053
|
+
url,
|
|
1054
|
+
method: "GET"
|
|
1055
|
+
});
|
|
1056
|
+
if (result.error) {
|
|
1057
|
+
spinner.fail("Failed to fetch table schema");
|
|
1058
|
+
console.error(chalk4.red(result.error.message));
|
|
1059
|
+
process.exit(1);
|
|
1060
|
+
}
|
|
1061
|
+
const tables = result.data || [];
|
|
1062
|
+
spinner.succeed(`Fetched schema for ${tables.length} table${tables.length === 1 ? "" : "s"}`);
|
|
1063
|
+
renderOutput(tables, {
|
|
1064
|
+
format: options.format,
|
|
1065
|
+
tableRows: tables.map((table) => ({
|
|
1066
|
+
tableName: table.tableName,
|
|
1067
|
+
createTableSql: table.createTableSql
|
|
1068
|
+
})),
|
|
1069
|
+
csvRows: tables.map((table) => ({
|
|
1070
|
+
tableName: table.tableName,
|
|
1071
|
+
createTableSql: table.createTableSql
|
|
1072
|
+
})),
|
|
1073
|
+
ndjsonItems: tables,
|
|
1074
|
+
pretty: () => {
|
|
1075
|
+
console.log(chalk4.blue(`
|
|
1076
|
+
Table Schemas: ${options.sourceId}
|
|
1077
|
+
`));
|
|
1078
|
+
if (tables.length === 0) {
|
|
1079
|
+
console.log(chalk4.gray("No tables found."));
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
for (const table of tables) {
|
|
1083
|
+
console.log(chalk4.green(table.tableName));
|
|
1084
|
+
console.log(table.createTableSql);
|
|
1085
|
+
console.log();
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
});
|
|
1089
|
+
} catch (error) {
|
|
1090
|
+
exitWithCommandError2(spinner, "Failed to fetch table schema", error);
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
938
1093
|
function isPlainObject3(value) {
|
|
939
1094
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
940
1095
|
}
|
|
941
|
-
function
|
|
1096
|
+
function resolveInputSource3(input) {
|
|
942
1097
|
if (!input.startsWith("@")) {
|
|
943
1098
|
return input;
|
|
944
1099
|
}
|
|
@@ -949,7 +1104,7 @@ function resolveInputSource2(input) {
|
|
|
949
1104
|
return readFileSync(filePath, "utf8");
|
|
950
1105
|
}
|
|
951
1106
|
function parseJsonInput2(input, label) {
|
|
952
|
-
const source =
|
|
1107
|
+
const source = resolveInputSource3(input).trim();
|
|
953
1108
|
if (!source) {
|
|
954
1109
|
throw new Error(`${label} is required.`);
|
|
955
1110
|
}
|
|
@@ -990,11 +1145,11 @@ function loadOptionalJsonObjectInput2(input, label) {
|
|
|
990
1145
|
}
|
|
991
1146
|
return value;
|
|
992
1147
|
}
|
|
993
|
-
function
|
|
1148
|
+
function exitWithCommandError3(spinner, failureMessage, error) {
|
|
994
1149
|
spinner.fail(failureMessage);
|
|
995
1150
|
const details = error instanceof Error ? error.message : String(error);
|
|
996
1151
|
if (details) {
|
|
997
|
-
console.error(
|
|
1152
|
+
console.error(chalk4.red(details));
|
|
998
1153
|
}
|
|
999
1154
|
process.exit(1);
|
|
1000
1155
|
}
|
|
@@ -1003,7 +1158,7 @@ function extractClientErrorMessage(error) {
|
|
|
1003
1158
|
}
|
|
1004
1159
|
function exitWithClientError(spinner, failureMessage, error, diagnosticMessage) {
|
|
1005
1160
|
spinner.fail(failureMessage);
|
|
1006
|
-
console.error(
|
|
1161
|
+
console.error(chalk4.red(diagnosticMessage || extractClientErrorMessage(error)));
|
|
1007
1162
|
process.exit(1);
|
|
1008
1163
|
}
|
|
1009
1164
|
function inspectStartEventFormConfiguration(bpmnXml) {
|
|
@@ -1184,7 +1339,7 @@ async function listProcesses(client, options = {}) {
|
|
|
1184
1339
|
const result = await bpmClient.getProcessDefinitions(params);
|
|
1185
1340
|
if (result.error) {
|
|
1186
1341
|
spinner.fail("Failed to fetch processes");
|
|
1187
|
-
console.error(
|
|
1342
|
+
console.error(chalk4.red(result.error.message));
|
|
1188
1343
|
process.exit(1);
|
|
1189
1344
|
}
|
|
1190
1345
|
spinner.succeed(`Found ${result.data?.length || 0} process definitions`);
|
|
@@ -1192,19 +1347,19 @@ async function listProcesses(client, options = {}) {
|
|
|
1192
1347
|
renderOutput(processes, {
|
|
1193
1348
|
format: options.format,
|
|
1194
1349
|
pretty: () => {
|
|
1195
|
-
console.log(
|
|
1350
|
+
console.log(chalk4.blue("\n\u{1F4CA} Process Definitions\n"));
|
|
1196
1351
|
for (const proc of processes) {
|
|
1197
|
-
console.log(` ${
|
|
1198
|
-
console.log(` ${
|
|
1199
|
-
console.log(` ${
|
|
1200
|
-
console.log(` ${
|
|
1201
|
-
console.log(` ${
|
|
1352
|
+
console.log(` ${chalk4.green("\u2022")} ${chalk4.bold(proc.key)}`);
|
|
1353
|
+
console.log(` ${chalk4.gray("ID:")} ${proc.id || "N/A"}`);
|
|
1354
|
+
console.log(` ${chalk4.gray("Name:")} ${proc.name || "N/A"}`);
|
|
1355
|
+
console.log(` ${chalk4.gray("Version:")} ${proc.version || "N/A"}`);
|
|
1356
|
+
console.log(` ${chalk4.gray("Suspended:")} ${proc.suspended ? "Yes" : "No"}`);
|
|
1202
1357
|
console.log();
|
|
1203
1358
|
}
|
|
1204
1359
|
}
|
|
1205
1360
|
});
|
|
1206
1361
|
} catch (error) {
|
|
1207
|
-
|
|
1362
|
+
exitWithCommandError3(spinner, "Failed to fetch processes", error);
|
|
1208
1363
|
}
|
|
1209
1364
|
}
|
|
1210
1365
|
async function getProcessXml(client, options) {
|
|
@@ -1214,21 +1369,21 @@ async function getProcessXml(client, options) {
|
|
|
1214
1369
|
const result = await bpmClient.getProcessXml(options.key);
|
|
1215
1370
|
if (result.error) {
|
|
1216
1371
|
spinner.fail("Failed to fetch process XML");
|
|
1217
|
-
console.error(
|
|
1372
|
+
console.error(chalk4.red(result.error.message));
|
|
1218
1373
|
process.exit(1);
|
|
1219
1374
|
}
|
|
1220
1375
|
spinner.succeed("Process XML retrieved");
|
|
1221
1376
|
renderOutput(result.data, {
|
|
1222
1377
|
format: options.format,
|
|
1223
1378
|
pretty: () => {
|
|
1224
|
-
console.log(
|
|
1379
|
+
console.log(chalk4.blue(`
|
|
1225
1380
|
\u{1F4C4} BPMN XML: ${options.key}
|
|
1226
1381
|
`));
|
|
1227
1382
|
console.log(result.data?.bpmn20Xml || "");
|
|
1228
1383
|
}
|
|
1229
1384
|
});
|
|
1230
1385
|
} catch (error) {
|
|
1231
|
-
|
|
1386
|
+
exitWithCommandError3(spinner, "Failed to fetch process XML", error);
|
|
1232
1387
|
}
|
|
1233
1388
|
}
|
|
1234
1389
|
async function startProcess(client, options) {
|
|
@@ -1239,22 +1394,22 @@ async function startProcess(client, options) {
|
|
|
1239
1394
|
const result = await bpmClient.startProcess(options.key, variables);
|
|
1240
1395
|
if (result.error) {
|
|
1241
1396
|
spinner.fail("Failed to start process");
|
|
1242
|
-
console.error(
|
|
1397
|
+
console.error(chalk4.red(result.error.message));
|
|
1243
1398
|
process.exit(1);
|
|
1244
1399
|
}
|
|
1245
1400
|
spinner.succeed("Process started");
|
|
1246
1401
|
renderOutput(result.data, {
|
|
1247
1402
|
format: options.format,
|
|
1248
1403
|
pretty: () => {
|
|
1249
|
-
console.log(
|
|
1250
|
-
console.log(` ${
|
|
1251
|
-
console.log(` ${
|
|
1252
|
-
console.log(` ${
|
|
1253
|
-
console.log(` ${
|
|
1404
|
+
console.log(chalk4.green("\nProcess Instance:"));
|
|
1405
|
+
console.log(` ${chalk4.bold("ID:")} ${result.data?.id}`);
|
|
1406
|
+
console.log(` ${chalk4.bold("Definition ID:")} ${result.data?.definitionId}`);
|
|
1407
|
+
console.log(` ${chalk4.bold("Business Key:")} ${result.data?.businessKey || "N/A"}`);
|
|
1408
|
+
console.log(` ${chalk4.bold("Status:")} ${result.data?.suspended ? "Suspended" : "Active"}`);
|
|
1254
1409
|
}
|
|
1255
1410
|
});
|
|
1256
1411
|
} catch (error) {
|
|
1257
|
-
|
|
1412
|
+
exitWithCommandError3(spinner, "Failed to start process", error);
|
|
1258
1413
|
}
|
|
1259
1414
|
}
|
|
1260
1415
|
async function listProcessInstances(client, options = {}) {
|
|
@@ -1265,7 +1420,7 @@ async function listProcessInstances(client, options = {}) {
|
|
|
1265
1420
|
const result = await bpmClient.getProcessInstances(params);
|
|
1266
1421
|
if (result.error) {
|
|
1267
1422
|
spinner.fail("Failed to fetch process instances");
|
|
1268
|
-
console.error(
|
|
1423
|
+
console.error(chalk4.red(result.error.message));
|
|
1269
1424
|
process.exit(1);
|
|
1270
1425
|
}
|
|
1271
1426
|
spinner.succeed(`Found ${result.data?.length || 0} process instances`);
|
|
@@ -1273,20 +1428,20 @@ async function listProcessInstances(client, options = {}) {
|
|
|
1273
1428
|
renderOutput(instances, {
|
|
1274
1429
|
format: options.format,
|
|
1275
1430
|
pretty: () => {
|
|
1276
|
-
console.log(
|
|
1431
|
+
console.log(chalk4.blue("\n\u{1F504} Process Instances\n"));
|
|
1277
1432
|
for (const instance of instances) {
|
|
1278
|
-
console.log(` ${
|
|
1279
|
-
console.log(` ${
|
|
1280
|
-
console.log(` ${
|
|
1433
|
+
console.log(` ${chalk4.green("\u2022")} ${chalk4.bold(instance.id)}`);
|
|
1434
|
+
console.log(` ${chalk4.gray("Definition:")} ${instance.definitionId || "N/A"}`);
|
|
1435
|
+
console.log(` ${chalk4.gray("Business Key:")} ${instance.businessKey || "N/A"}`);
|
|
1281
1436
|
console.log(
|
|
1282
|
-
` ${
|
|
1437
|
+
` ${chalk4.gray("Status:")} ${instance.ended ? "Ended" : instance.suspended ? "Suspended" : "Active"}`
|
|
1283
1438
|
);
|
|
1284
1439
|
console.log();
|
|
1285
1440
|
}
|
|
1286
1441
|
}
|
|
1287
1442
|
});
|
|
1288
1443
|
} catch (error) {
|
|
1289
|
-
|
|
1444
|
+
exitWithCommandError3(spinner, "Failed to fetch process instances", error);
|
|
1290
1445
|
}
|
|
1291
1446
|
}
|
|
1292
1447
|
async function getProcessInstance(client, options) {
|
|
@@ -1296,19 +1451,19 @@ async function getProcessInstance(client, options) {
|
|
|
1296
1451
|
const result = await bpmClient.getProcessInstance(options.id);
|
|
1297
1452
|
if (result.error) {
|
|
1298
1453
|
spinner.fail("Failed to fetch process instance");
|
|
1299
|
-
console.error(
|
|
1454
|
+
console.error(chalk4.red(result.error.message));
|
|
1300
1455
|
process.exit(1);
|
|
1301
1456
|
}
|
|
1302
1457
|
spinner.succeed("Process instance retrieved");
|
|
1303
1458
|
renderOutput(result.data, {
|
|
1304
1459
|
format: options.format,
|
|
1305
1460
|
pretty: () => {
|
|
1306
|
-
console.log(
|
|
1461
|
+
console.log(chalk4.blue("\n\u{1F4CA} Process Instance\n"));
|
|
1307
1462
|
console.log(JSON.stringify(result.data, null, 2));
|
|
1308
1463
|
}
|
|
1309
1464
|
});
|
|
1310
1465
|
} catch (error) {
|
|
1311
|
-
|
|
1466
|
+
exitWithCommandError3(spinner, "Failed to fetch process instance", error);
|
|
1312
1467
|
}
|
|
1313
1468
|
}
|
|
1314
1469
|
async function getActivityInstanceTree(client, options) {
|
|
@@ -1318,19 +1473,19 @@ async function getActivityInstanceTree(client, options) {
|
|
|
1318
1473
|
const result = await bpmClient.getActivityInstanceTree(options.id);
|
|
1319
1474
|
if (result.error) {
|
|
1320
1475
|
spinner.fail("Failed to fetch activity instance tree");
|
|
1321
|
-
console.error(
|
|
1476
|
+
console.error(chalk4.red(result.error.message));
|
|
1322
1477
|
process.exit(1);
|
|
1323
1478
|
}
|
|
1324
1479
|
spinner.succeed("Activity instance tree retrieved");
|
|
1325
1480
|
renderOutput(result.data, {
|
|
1326
1481
|
format: options.format,
|
|
1327
1482
|
pretty: () => {
|
|
1328
|
-
console.log(
|
|
1483
|
+
console.log(chalk4.blue("\n\u{1F333} Activity Instance Tree\n"));
|
|
1329
1484
|
console.log(JSON.stringify(result.data, null, 2));
|
|
1330
1485
|
}
|
|
1331
1486
|
});
|
|
1332
1487
|
} catch (error) {
|
|
1333
|
-
|
|
1488
|
+
exitWithCommandError3(spinner, "Failed to fetch activity instance tree", error);
|
|
1334
1489
|
}
|
|
1335
1490
|
}
|
|
1336
1491
|
async function getActiveActivities(client, options) {
|
|
@@ -1340,7 +1495,7 @@ async function getActiveActivities(client, options) {
|
|
|
1340
1495
|
const result = await bpmClient.getActiveActivities(options.id);
|
|
1341
1496
|
if (result.error) {
|
|
1342
1497
|
spinner.fail("Failed to fetch active activities");
|
|
1343
|
-
console.error(
|
|
1498
|
+
console.error(chalk4.red(result.error.message));
|
|
1344
1499
|
process.exit(1);
|
|
1345
1500
|
}
|
|
1346
1501
|
const activities = Array.isArray(result.data) ? result.data : [];
|
|
@@ -1348,12 +1503,12 @@ async function getActiveActivities(client, options) {
|
|
|
1348
1503
|
renderOutput(result.data, {
|
|
1349
1504
|
format: options.format,
|
|
1350
1505
|
pretty: () => {
|
|
1351
|
-
console.log(
|
|
1506
|
+
console.log(chalk4.blue("\n\u26A1 Active Activities\n"));
|
|
1352
1507
|
console.log(JSON.stringify(result.data, null, 2));
|
|
1353
1508
|
}
|
|
1354
1509
|
});
|
|
1355
1510
|
} catch (error) {
|
|
1356
|
-
|
|
1511
|
+
exitWithCommandError3(spinner, "Failed to fetch active activities", error);
|
|
1357
1512
|
}
|
|
1358
1513
|
}
|
|
1359
1514
|
async function getRuntimeVariables(client, options) {
|
|
@@ -1363,19 +1518,19 @@ async function getRuntimeVariables(client, options) {
|
|
|
1363
1518
|
const result = await bpmClient.getRuntimeVariables(options.id);
|
|
1364
1519
|
if (result.error) {
|
|
1365
1520
|
spinner.fail("Failed to fetch runtime variables");
|
|
1366
|
-
console.error(
|
|
1521
|
+
console.error(chalk4.red(result.error.message));
|
|
1367
1522
|
process.exit(1);
|
|
1368
1523
|
}
|
|
1369
1524
|
spinner.succeed("Runtime variables retrieved");
|
|
1370
1525
|
renderOutput(result.data, {
|
|
1371
1526
|
format: options.format,
|
|
1372
1527
|
pretty: () => {
|
|
1373
|
-
console.log(
|
|
1528
|
+
console.log(chalk4.blue("\n\u{1F9EE} Runtime Variables\n"));
|
|
1374
1529
|
console.log(JSON.stringify(result.data, null, 2));
|
|
1375
1530
|
}
|
|
1376
1531
|
});
|
|
1377
1532
|
} catch (error) {
|
|
1378
|
-
|
|
1533
|
+
exitWithCommandError3(spinner, "Failed to fetch runtime variables", error);
|
|
1379
1534
|
}
|
|
1380
1535
|
}
|
|
1381
1536
|
async function getProcessVariables(client, options) {
|
|
@@ -1388,19 +1543,19 @@ async function getProcessVariables(client, options) {
|
|
|
1388
1543
|
});
|
|
1389
1544
|
if (result.error) {
|
|
1390
1545
|
spinner.fail("Failed to fetch process variables");
|
|
1391
|
-
console.error(
|
|
1546
|
+
console.error(chalk4.red(result.error.message));
|
|
1392
1547
|
process.exit(1);
|
|
1393
1548
|
}
|
|
1394
1549
|
spinner.succeed(`Found ${result.data?.length || 0} variables`);
|
|
1395
1550
|
renderOutput(result.data || [], {
|
|
1396
1551
|
format: options.format,
|
|
1397
1552
|
pretty: () => {
|
|
1398
|
-
console.log(
|
|
1553
|
+
console.log(chalk4.blue("\n\u{1F9FE} Process Variables\n"));
|
|
1399
1554
|
console.log(JSON.stringify(result.data || [], null, 2));
|
|
1400
1555
|
}
|
|
1401
1556
|
});
|
|
1402
1557
|
} catch (error) {
|
|
1403
|
-
|
|
1558
|
+
exitWithCommandError3(spinner, "Failed to fetch process variables", error);
|
|
1404
1559
|
}
|
|
1405
1560
|
}
|
|
1406
1561
|
async function deleteProcessInstance(client, options) {
|
|
@@ -1412,7 +1567,7 @@ async function deleteProcessInstance(client, options) {
|
|
|
1412
1567
|
});
|
|
1413
1568
|
if (result.error) {
|
|
1414
1569
|
spinner.fail("Failed to delete process instance");
|
|
1415
|
-
console.error(
|
|
1570
|
+
console.error(chalk4.red(result.error.message));
|
|
1416
1571
|
process.exit(1);
|
|
1417
1572
|
}
|
|
1418
1573
|
spinner.succeed("Process instance deleted");
|
|
@@ -1425,12 +1580,12 @@ async function deleteProcessInstance(client, options) {
|
|
|
1425
1580
|
{
|
|
1426
1581
|
format: options.format,
|
|
1427
1582
|
pretty: () => {
|
|
1428
|
-
console.log(
|
|
1583
|
+
console.log(chalk4.green(`Deleted process instance: ${options.id}`));
|
|
1429
1584
|
}
|
|
1430
1585
|
}
|
|
1431
1586
|
);
|
|
1432
1587
|
} catch (error) {
|
|
1433
|
-
|
|
1588
|
+
exitWithCommandError3(spinner, "Failed to delete process instance", error);
|
|
1434
1589
|
}
|
|
1435
1590
|
}
|
|
1436
1591
|
async function suspendProcessInstance(client, options) {
|
|
@@ -1440,7 +1595,7 @@ async function suspendProcessInstance(client, options) {
|
|
|
1440
1595
|
const result = await bpmClient.suspendProcessInstance(options.id);
|
|
1441
1596
|
if (result.error) {
|
|
1442
1597
|
spinner.fail("Failed to suspend process instance");
|
|
1443
|
-
console.error(
|
|
1598
|
+
console.error(chalk4.red(result.error.message));
|
|
1444
1599
|
process.exit(1);
|
|
1445
1600
|
}
|
|
1446
1601
|
spinner.succeed("Process instance suspended");
|
|
@@ -1452,12 +1607,12 @@ async function suspendProcessInstance(client, options) {
|
|
|
1452
1607
|
{
|
|
1453
1608
|
format: options.format,
|
|
1454
1609
|
pretty: () => {
|
|
1455
|
-
console.log(
|
|
1610
|
+
console.log(chalk4.green(`Suspended process instance: ${options.id}`));
|
|
1456
1611
|
}
|
|
1457
1612
|
}
|
|
1458
1613
|
);
|
|
1459
1614
|
} catch (error) {
|
|
1460
|
-
|
|
1615
|
+
exitWithCommandError3(spinner, "Failed to suspend process instance", error);
|
|
1461
1616
|
}
|
|
1462
1617
|
}
|
|
1463
1618
|
async function activateProcessInstance(client, options) {
|
|
@@ -1467,7 +1622,7 @@ async function activateProcessInstance(client, options) {
|
|
|
1467
1622
|
const result = await bpmClient.activateProcessInstance(options.id);
|
|
1468
1623
|
if (result.error) {
|
|
1469
1624
|
spinner.fail("Failed to activate process instance");
|
|
1470
|
-
console.error(
|
|
1625
|
+
console.error(chalk4.red(result.error.message));
|
|
1471
1626
|
process.exit(1);
|
|
1472
1627
|
}
|
|
1473
1628
|
spinner.succeed("Process instance activated");
|
|
@@ -1479,12 +1634,12 @@ async function activateProcessInstance(client, options) {
|
|
|
1479
1634
|
{
|
|
1480
1635
|
format: options.format,
|
|
1481
1636
|
pretty: () => {
|
|
1482
|
-
console.log(
|
|
1637
|
+
console.log(chalk4.green(`Activated process instance: ${options.id}`));
|
|
1483
1638
|
}
|
|
1484
1639
|
}
|
|
1485
1640
|
);
|
|
1486
1641
|
} catch (error) {
|
|
1487
|
-
|
|
1642
|
+
exitWithCommandError3(spinner, "Failed to activate process instance", error);
|
|
1488
1643
|
}
|
|
1489
1644
|
}
|
|
1490
1645
|
async function modifyProcessInstance(client, options) {
|
|
@@ -1499,7 +1654,7 @@ async function modifyProcessInstance(client, options) {
|
|
|
1499
1654
|
const result = await bpmClient.modifyProcessInstance(options.id, modification);
|
|
1500
1655
|
if (result.error) {
|
|
1501
1656
|
spinner.fail("Failed to modify process instance");
|
|
1502
|
-
console.error(
|
|
1657
|
+
console.error(chalk4.red(result.error.message));
|
|
1503
1658
|
process.exit(1);
|
|
1504
1659
|
}
|
|
1505
1660
|
spinner.succeed("Process instance modified");
|
|
@@ -1512,12 +1667,12 @@ async function modifyProcessInstance(client, options) {
|
|
|
1512
1667
|
{
|
|
1513
1668
|
format: options.format,
|
|
1514
1669
|
pretty: () => {
|
|
1515
|
-
console.log(
|
|
1670
|
+
console.log(chalk4.green(`Modified process instance: ${options.id}`));
|
|
1516
1671
|
}
|
|
1517
1672
|
}
|
|
1518
1673
|
);
|
|
1519
1674
|
} catch (error) {
|
|
1520
|
-
|
|
1675
|
+
exitWithCommandError3(spinner, "Failed to modify process instance", error);
|
|
1521
1676
|
}
|
|
1522
1677
|
}
|
|
1523
1678
|
async function listTasks(client, options) {
|
|
@@ -1528,7 +1683,7 @@ async function listTasks(client, options) {
|
|
|
1528
1683
|
const result = await bpmClient.getTasks(params);
|
|
1529
1684
|
if (result.error) {
|
|
1530
1685
|
spinner.fail("Failed to fetch tasks");
|
|
1531
|
-
console.error(
|
|
1686
|
+
console.error(chalk4.red(result.error.message));
|
|
1532
1687
|
process.exit(1);
|
|
1533
1688
|
}
|
|
1534
1689
|
spinner.succeed(`Found ${result.data?.length || 0} tasks`);
|
|
@@ -1536,19 +1691,19 @@ async function listTasks(client, options) {
|
|
|
1536
1691
|
renderOutput(tasks, {
|
|
1537
1692
|
format: options.format,
|
|
1538
1693
|
pretty: () => {
|
|
1539
|
-
console.log(
|
|
1694
|
+
console.log(chalk4.blue("\n\u{1F4DD} Tasks\n"));
|
|
1540
1695
|
for (const task of tasks) {
|
|
1541
|
-
console.log(` ${
|
|
1542
|
-
console.log(` ${
|
|
1543
|
-
console.log(` ${
|
|
1544
|
-
console.log(` ${
|
|
1545
|
-
console.log(` ${
|
|
1696
|
+
console.log(` ${chalk4.green("\u2022")} ${chalk4.bold(task.name || task.id)}`);
|
|
1697
|
+
console.log(` ${chalk4.gray("ID:")} ${task.id}`);
|
|
1698
|
+
console.log(` ${chalk4.gray("Assignee:")} ${task.assignee || "Unassigned"}`);
|
|
1699
|
+
console.log(` ${chalk4.gray("Process Instance:")} ${task.processInstanceId || "N/A"}`);
|
|
1700
|
+
console.log(` ${chalk4.gray("Created:")} ${task.created || "N/A"}`);
|
|
1546
1701
|
console.log();
|
|
1547
1702
|
}
|
|
1548
1703
|
}
|
|
1549
1704
|
});
|
|
1550
1705
|
} catch (error) {
|
|
1551
|
-
|
|
1706
|
+
exitWithCommandError3(spinner, "Failed to fetch tasks", error);
|
|
1552
1707
|
}
|
|
1553
1708
|
}
|
|
1554
1709
|
async function getTask(client, options) {
|
|
@@ -1558,19 +1713,19 @@ async function getTask(client, options) {
|
|
|
1558
1713
|
const result = await bpmClient.getTask(options.id);
|
|
1559
1714
|
if (result.error) {
|
|
1560
1715
|
spinner.fail("Failed to fetch task");
|
|
1561
|
-
console.error(
|
|
1716
|
+
console.error(chalk4.red(result.error.message));
|
|
1562
1717
|
process.exit(1);
|
|
1563
1718
|
}
|
|
1564
1719
|
spinner.succeed("Task retrieved");
|
|
1565
1720
|
renderOutput(result.data, {
|
|
1566
1721
|
format: options.format,
|
|
1567
1722
|
pretty: () => {
|
|
1568
|
-
console.log(
|
|
1723
|
+
console.log(chalk4.blue("\n\u{1F4DD} Task\n"));
|
|
1569
1724
|
console.log(JSON.stringify(result.data, null, 2));
|
|
1570
1725
|
}
|
|
1571
1726
|
});
|
|
1572
1727
|
} catch (error) {
|
|
1573
|
-
|
|
1728
|
+
exitWithCommandError3(spinner, "Failed to fetch task", error);
|
|
1574
1729
|
}
|
|
1575
1730
|
}
|
|
1576
1731
|
async function getTaskCount(client, options) {
|
|
@@ -1581,18 +1736,18 @@ async function getTaskCount(client, options) {
|
|
|
1581
1736
|
const result = await bpmClient.getTaskCount(params);
|
|
1582
1737
|
if (result.error) {
|
|
1583
1738
|
spinner.fail("Failed to fetch task count");
|
|
1584
|
-
console.error(
|
|
1739
|
+
console.error(chalk4.red(result.error.message));
|
|
1585
1740
|
process.exit(1);
|
|
1586
1741
|
}
|
|
1587
1742
|
spinner.succeed("Task count retrieved");
|
|
1588
1743
|
renderOutput(result.data, {
|
|
1589
1744
|
format: options.format,
|
|
1590
1745
|
pretty: () => {
|
|
1591
|
-
console.log(
|
|
1746
|
+
console.log(chalk4.green(`Task count: ${result.data?.count ?? 0}`));
|
|
1592
1747
|
}
|
|
1593
1748
|
});
|
|
1594
1749
|
} catch (error) {
|
|
1595
|
-
|
|
1750
|
+
exitWithCommandError3(spinner, "Failed to fetch task count", error);
|
|
1596
1751
|
}
|
|
1597
1752
|
}
|
|
1598
1753
|
async function completeTask(client, options) {
|
|
@@ -1603,7 +1758,7 @@ async function completeTask(client, options) {
|
|
|
1603
1758
|
const result = await bpmClient.completeTask(options.id, variables);
|
|
1604
1759
|
if (result.error) {
|
|
1605
1760
|
spinner.fail("Failed to complete task");
|
|
1606
|
-
console.error(
|
|
1761
|
+
console.error(chalk4.red(result.error.message));
|
|
1607
1762
|
process.exit(1);
|
|
1608
1763
|
}
|
|
1609
1764
|
spinner.succeed("Task completed");
|
|
@@ -1615,12 +1770,12 @@ async function completeTask(client, options) {
|
|
|
1615
1770
|
{
|
|
1616
1771
|
format: options.format,
|
|
1617
1772
|
pretty: () => {
|
|
1618
|
-
console.log(
|
|
1773
|
+
console.log(chalk4.green(`Completed task: ${options.id}`));
|
|
1619
1774
|
}
|
|
1620
1775
|
}
|
|
1621
1776
|
);
|
|
1622
1777
|
} catch (error) {
|
|
1623
|
-
|
|
1778
|
+
exitWithCommandError3(spinner, "Failed to complete task", error);
|
|
1624
1779
|
}
|
|
1625
1780
|
}
|
|
1626
1781
|
async function delegateTask(client, options) {
|
|
@@ -1630,7 +1785,7 @@ async function delegateTask(client, options) {
|
|
|
1630
1785
|
const result = await bpmClient.delegateTask(options.id, options.userId);
|
|
1631
1786
|
if (result.error) {
|
|
1632
1787
|
spinner.fail("Failed to delegate task");
|
|
1633
|
-
console.error(
|
|
1788
|
+
console.error(chalk4.red(result.error.message));
|
|
1634
1789
|
process.exit(1);
|
|
1635
1790
|
}
|
|
1636
1791
|
spinner.succeed("Task delegated");
|
|
@@ -1643,12 +1798,12 @@ async function delegateTask(client, options) {
|
|
|
1643
1798
|
{
|
|
1644
1799
|
format: options.format,
|
|
1645
1800
|
pretty: () => {
|
|
1646
|
-
console.log(
|
|
1801
|
+
console.log(chalk4.green(`Delegated task ${options.id} to ${options.userId}`));
|
|
1647
1802
|
}
|
|
1648
1803
|
}
|
|
1649
1804
|
);
|
|
1650
1805
|
} catch (error) {
|
|
1651
|
-
|
|
1806
|
+
exitWithCommandError3(spinner, "Failed to delegate task", error);
|
|
1652
1807
|
}
|
|
1653
1808
|
}
|
|
1654
1809
|
async function getTaskForm(client, options) {
|
|
@@ -1658,19 +1813,19 @@ async function getTaskForm(client, options) {
|
|
|
1658
1813
|
const result = await bpmClient.getTaskForm(options.id);
|
|
1659
1814
|
if (result.error) {
|
|
1660
1815
|
spinner.fail("Failed to fetch task form");
|
|
1661
|
-
console.error(
|
|
1816
|
+
console.error(chalk4.red(result.error.message));
|
|
1662
1817
|
process.exit(1);
|
|
1663
1818
|
}
|
|
1664
1819
|
spinner.succeed("Task form retrieved");
|
|
1665
1820
|
renderOutput(result.data, {
|
|
1666
1821
|
format: options.format,
|
|
1667
1822
|
pretty: () => {
|
|
1668
|
-
console.log(
|
|
1823
|
+
console.log(chalk4.blue("\n\u{1F9E9} Task Form\n"));
|
|
1669
1824
|
console.log(JSON.stringify(result.data, null, 2));
|
|
1670
1825
|
}
|
|
1671
1826
|
});
|
|
1672
1827
|
} catch (error) {
|
|
1673
|
-
|
|
1828
|
+
exitWithCommandError3(spinner, "Failed to fetch task form", error);
|
|
1674
1829
|
}
|
|
1675
1830
|
}
|
|
1676
1831
|
async function getTaskFormSchema(client, options) {
|
|
@@ -1693,12 +1848,12 @@ async function getTaskFormSchema(client, options) {
|
|
|
1693
1848
|
renderOutput(result.data, {
|
|
1694
1849
|
format: options.format,
|
|
1695
1850
|
pretty: () => {
|
|
1696
|
-
console.log(
|
|
1851
|
+
console.log(chalk4.blue("\n\u{1F9E9} Task Form Schema\n"));
|
|
1697
1852
|
console.log(JSON.stringify(result.data, null, 2));
|
|
1698
1853
|
}
|
|
1699
1854
|
});
|
|
1700
1855
|
} catch (error) {
|
|
1701
|
-
|
|
1856
|
+
exitWithCommandError3(spinner, "Failed to fetch task form schema", error);
|
|
1702
1857
|
}
|
|
1703
1858
|
}
|
|
1704
1859
|
async function getTaskFormVariables(client, options) {
|
|
@@ -1708,19 +1863,19 @@ async function getTaskFormVariables(client, options) {
|
|
|
1708
1863
|
const result = await bpmClient.getTaskFormVariables(options.id);
|
|
1709
1864
|
if (result.error) {
|
|
1710
1865
|
spinner.fail("Failed to fetch task form variables");
|
|
1711
|
-
console.error(
|
|
1866
|
+
console.error(chalk4.red(result.error.message));
|
|
1712
1867
|
process.exit(1);
|
|
1713
1868
|
}
|
|
1714
1869
|
spinner.succeed("Task form variables retrieved");
|
|
1715
1870
|
renderOutput(result.data, {
|
|
1716
1871
|
format: options.format,
|
|
1717
1872
|
pretty: () => {
|
|
1718
|
-
console.log(
|
|
1873
|
+
console.log(chalk4.blue("\n\u{1F9EE} Task Form Variables\n"));
|
|
1719
1874
|
console.log(JSON.stringify(result.data, null, 2));
|
|
1720
1875
|
}
|
|
1721
1876
|
});
|
|
1722
1877
|
} catch (error) {
|
|
1723
|
-
|
|
1878
|
+
exitWithCommandError3(spinner, "Failed to fetch task form variables", error);
|
|
1724
1879
|
}
|
|
1725
1880
|
}
|
|
1726
1881
|
async function getTaskRenderedForm(client, options) {
|
|
@@ -1730,19 +1885,19 @@ async function getTaskRenderedForm(client, options) {
|
|
|
1730
1885
|
const result = await bpmClient.getTaskRenderedForm(options.id);
|
|
1731
1886
|
if (result.error) {
|
|
1732
1887
|
spinner.fail("Failed to fetch rendered task form");
|
|
1733
|
-
console.error(
|
|
1888
|
+
console.error(chalk4.red(result.error.message));
|
|
1734
1889
|
process.exit(1);
|
|
1735
1890
|
}
|
|
1736
1891
|
spinner.succeed("Rendered task form retrieved");
|
|
1737
1892
|
renderOutput(result.data, {
|
|
1738
1893
|
format: options.format,
|
|
1739
1894
|
pretty: () => {
|
|
1740
|
-
console.log(
|
|
1895
|
+
console.log(chalk4.blue("\n\u{1F9FE} Rendered Task Form\n"));
|
|
1741
1896
|
console.log(result.data || "");
|
|
1742
1897
|
}
|
|
1743
1898
|
});
|
|
1744
1899
|
} catch (error) {
|
|
1745
|
-
|
|
1900
|
+
exitWithCommandError3(spinner, "Failed to fetch rendered task form", error);
|
|
1746
1901
|
}
|
|
1747
1902
|
}
|
|
1748
1903
|
async function getTaskDeployedForm(client, options) {
|
|
@@ -1752,19 +1907,19 @@ async function getTaskDeployedForm(client, options) {
|
|
|
1752
1907
|
const result = await bpmClient.getTaskDeployedForm(options.id);
|
|
1753
1908
|
if (result.error) {
|
|
1754
1909
|
spinner.fail("Failed to fetch deployed task form");
|
|
1755
|
-
console.error(
|
|
1910
|
+
console.error(chalk4.red(result.error.message));
|
|
1756
1911
|
process.exit(1);
|
|
1757
1912
|
}
|
|
1758
1913
|
spinner.succeed("Deployed task form retrieved");
|
|
1759
1914
|
renderOutput(result.data, {
|
|
1760
1915
|
format: options.format,
|
|
1761
1916
|
pretty: () => {
|
|
1762
|
-
console.log(
|
|
1917
|
+
console.log(chalk4.blue("\n\u{1F9FE} Deployed Task Form\n"));
|
|
1763
1918
|
console.log(JSON.stringify(result.data, null, 2));
|
|
1764
1919
|
}
|
|
1765
1920
|
});
|
|
1766
1921
|
} catch (error) {
|
|
1767
|
-
|
|
1922
|
+
exitWithCommandError3(spinner, "Failed to fetch deployed task form", error);
|
|
1768
1923
|
}
|
|
1769
1924
|
}
|
|
1770
1925
|
async function getStartFormInfo(client, options) {
|
|
@@ -1784,12 +1939,12 @@ async function getStartFormInfo(client, options) {
|
|
|
1784
1939
|
renderOutput(result.data, {
|
|
1785
1940
|
format: options.format,
|
|
1786
1941
|
pretty: () => {
|
|
1787
|
-
console.log(
|
|
1942
|
+
console.log(chalk4.blue("\n\u{1F680} Start Form Info\n"));
|
|
1788
1943
|
console.log(JSON.stringify(result.data, null, 2));
|
|
1789
1944
|
}
|
|
1790
1945
|
});
|
|
1791
1946
|
} catch (error) {
|
|
1792
|
-
|
|
1947
|
+
exitWithCommandError3(spinner, "Failed to fetch start form info", error);
|
|
1793
1948
|
}
|
|
1794
1949
|
}
|
|
1795
1950
|
async function getStartFormVariables(client, options) {
|
|
@@ -1809,12 +1964,12 @@ async function getStartFormVariables(client, options) {
|
|
|
1809
1964
|
renderOutput(result.data, {
|
|
1810
1965
|
format: options.format,
|
|
1811
1966
|
pretty: () => {
|
|
1812
|
-
console.log(
|
|
1967
|
+
console.log(chalk4.blue("\n\u{1F680} Start Form Variables\n"));
|
|
1813
1968
|
console.log(JSON.stringify(result.data, null, 2));
|
|
1814
1969
|
}
|
|
1815
1970
|
});
|
|
1816
1971
|
} catch (error) {
|
|
1817
|
-
|
|
1972
|
+
exitWithCommandError3(spinner, "Failed to fetch start form variables", error);
|
|
1818
1973
|
}
|
|
1819
1974
|
}
|
|
1820
1975
|
async function getDeployedStartForm(client, options) {
|
|
@@ -1834,12 +1989,12 @@ async function getDeployedStartForm(client, options) {
|
|
|
1834
1989
|
renderOutput(result.data, {
|
|
1835
1990
|
format: options.format,
|
|
1836
1991
|
pretty: () => {
|
|
1837
|
-
console.log(
|
|
1992
|
+
console.log(chalk4.blue("\n\u{1F680} Deployed Start Form\n"));
|
|
1838
1993
|
console.log(JSON.stringify(result.data, null, 2));
|
|
1839
1994
|
}
|
|
1840
1995
|
});
|
|
1841
1996
|
} catch (error) {
|
|
1842
|
-
|
|
1997
|
+
exitWithCommandError3(spinner, "Failed to fetch deployed start form", error);
|
|
1843
1998
|
}
|
|
1844
1999
|
}
|
|
1845
2000
|
async function listHistoryTasks(client, options = {}) {
|
|
@@ -1850,7 +2005,7 @@ async function listHistoryTasks(client, options = {}) {
|
|
|
1850
2005
|
const result = await bpmClient.getHistoryTasks(params);
|
|
1851
2006
|
if (result.error) {
|
|
1852
2007
|
spinner.fail("Failed to fetch history tasks");
|
|
1853
|
-
console.error(
|
|
2008
|
+
console.error(chalk4.red(result.error.message));
|
|
1854
2009
|
process.exit(1);
|
|
1855
2010
|
}
|
|
1856
2011
|
const tasks = result.data || [];
|
|
@@ -1858,12 +2013,12 @@ async function listHistoryTasks(client, options = {}) {
|
|
|
1858
2013
|
renderOutput(tasks, {
|
|
1859
2014
|
format: options.format,
|
|
1860
2015
|
pretty: () => {
|
|
1861
|
-
console.log(
|
|
2016
|
+
console.log(chalk4.blue("\n\u{1F4DA} History Tasks\n"));
|
|
1862
2017
|
console.log(JSON.stringify(tasks, null, 2));
|
|
1863
2018
|
}
|
|
1864
2019
|
});
|
|
1865
2020
|
} catch (error) {
|
|
1866
|
-
|
|
2021
|
+
exitWithCommandError3(spinner, "Failed to fetch history tasks", error);
|
|
1867
2022
|
}
|
|
1868
2023
|
}
|
|
1869
2024
|
async function getHistoryTaskCount(client, options = {}) {
|
|
@@ -1874,18 +2029,18 @@ async function getHistoryTaskCount(client, options = {}) {
|
|
|
1874
2029
|
const result = await bpmClient.getHistoryTaskCount(params);
|
|
1875
2030
|
if (result.error) {
|
|
1876
2031
|
spinner.fail("Failed to fetch history task count");
|
|
1877
|
-
console.error(
|
|
2032
|
+
console.error(chalk4.red(result.error.message));
|
|
1878
2033
|
process.exit(1);
|
|
1879
2034
|
}
|
|
1880
2035
|
spinner.succeed("History task count retrieved");
|
|
1881
2036
|
renderOutput(result.data, {
|
|
1882
2037
|
format: options.format,
|
|
1883
2038
|
pretty: () => {
|
|
1884
|
-
console.log(
|
|
2039
|
+
console.log(chalk4.green(`History task count: ${result.data?.count ?? 0}`));
|
|
1885
2040
|
}
|
|
1886
2041
|
});
|
|
1887
2042
|
} catch (error) {
|
|
1888
|
-
|
|
2043
|
+
exitWithCommandError3(spinner, "Failed to fetch history task count", error);
|
|
1889
2044
|
}
|
|
1890
2045
|
}
|
|
1891
2046
|
async function listHistoryProcessInstances(client, options = {}) {
|
|
@@ -1896,7 +2051,7 @@ async function listHistoryProcessInstances(client, options = {}) {
|
|
|
1896
2051
|
const result = await bpmClient.getHistoryProcessInstances(params);
|
|
1897
2052
|
if (result.error) {
|
|
1898
2053
|
spinner.fail("Failed to fetch history process instances");
|
|
1899
|
-
console.error(
|
|
2054
|
+
console.error(chalk4.red(result.error.message));
|
|
1900
2055
|
process.exit(1);
|
|
1901
2056
|
}
|
|
1902
2057
|
const instances = result.data || [];
|
|
@@ -1904,12 +2059,12 @@ async function listHistoryProcessInstances(client, options = {}) {
|
|
|
1904
2059
|
renderOutput(instances, {
|
|
1905
2060
|
format: options.format,
|
|
1906
2061
|
pretty: () => {
|
|
1907
|
-
console.log(
|
|
2062
|
+
console.log(chalk4.blue("\n\u{1F4DA} History Process Instances\n"));
|
|
1908
2063
|
console.log(JSON.stringify(instances, null, 2));
|
|
1909
2064
|
}
|
|
1910
2065
|
});
|
|
1911
2066
|
} catch (error) {
|
|
1912
|
-
|
|
2067
|
+
exitWithCommandError3(spinner, "Failed to fetch history process instances", error);
|
|
1913
2068
|
}
|
|
1914
2069
|
}
|
|
1915
2070
|
async function getHistoryProcessInstanceCount(client, options = {}) {
|
|
@@ -1920,18 +2075,18 @@ async function getHistoryProcessInstanceCount(client, options = {}) {
|
|
|
1920
2075
|
const result = await bpmClient.getHistoryProcessInstanceCount(params);
|
|
1921
2076
|
if (result.error) {
|
|
1922
2077
|
spinner.fail("Failed to fetch history process instance count");
|
|
1923
|
-
console.error(
|
|
2078
|
+
console.error(chalk4.red(result.error.message));
|
|
1924
2079
|
process.exit(1);
|
|
1925
2080
|
}
|
|
1926
2081
|
spinner.succeed("History process instance count retrieved");
|
|
1927
2082
|
renderOutput(result.data, {
|
|
1928
2083
|
format: options.format,
|
|
1929
2084
|
pretty: () => {
|
|
1930
|
-
console.log(
|
|
2085
|
+
console.log(chalk4.green(`History process instance count: ${result.data?.count ?? 0}`));
|
|
1931
2086
|
}
|
|
1932
2087
|
});
|
|
1933
2088
|
} catch (error) {
|
|
1934
|
-
|
|
2089
|
+
exitWithCommandError3(spinner, "Failed to fetch history process instance count", error);
|
|
1935
2090
|
}
|
|
1936
2091
|
}
|
|
1937
2092
|
async function getHistoryProcessInstance(client, options) {
|
|
@@ -1941,19 +2096,19 @@ async function getHistoryProcessInstance(client, options) {
|
|
|
1941
2096
|
const result = await bpmClient.getHistoryProcessInstance(options.id);
|
|
1942
2097
|
if (result.error) {
|
|
1943
2098
|
spinner.fail("Failed to fetch history process instance");
|
|
1944
|
-
console.error(
|
|
2099
|
+
console.error(chalk4.red(result.error.message));
|
|
1945
2100
|
process.exit(1);
|
|
1946
2101
|
}
|
|
1947
2102
|
spinner.succeed("History process instance retrieved");
|
|
1948
2103
|
renderOutput(result.data, {
|
|
1949
2104
|
format: options.format,
|
|
1950
2105
|
pretty: () => {
|
|
1951
|
-
console.log(
|
|
2106
|
+
console.log(chalk4.blue("\n\u{1F4DA} History Process Instance\n"));
|
|
1952
2107
|
console.log(JSON.stringify(result.data, null, 2));
|
|
1953
2108
|
}
|
|
1954
2109
|
});
|
|
1955
2110
|
} catch (error) {
|
|
1956
|
-
|
|
2111
|
+
exitWithCommandError3(spinner, "Failed to fetch history process instance", error);
|
|
1957
2112
|
}
|
|
1958
2113
|
}
|
|
1959
2114
|
async function listHistoryActivityInstances(client, options = {}) {
|
|
@@ -1964,7 +2119,7 @@ async function listHistoryActivityInstances(client, options = {}) {
|
|
|
1964
2119
|
const result = await bpmClient.getHistoryActivityInstances(params);
|
|
1965
2120
|
if (result.error) {
|
|
1966
2121
|
spinner.fail("Failed to fetch history activity instances");
|
|
1967
|
-
console.error(
|
|
2122
|
+
console.error(chalk4.red(result.error.message));
|
|
1968
2123
|
process.exit(1);
|
|
1969
2124
|
}
|
|
1970
2125
|
const activities = result.data || [];
|
|
@@ -1972,12 +2127,12 @@ async function listHistoryActivityInstances(client, options = {}) {
|
|
|
1972
2127
|
renderOutput(activities, {
|
|
1973
2128
|
format: options.format,
|
|
1974
2129
|
pretty: () => {
|
|
1975
|
-
console.log(
|
|
2130
|
+
console.log(chalk4.blue("\n\u{1F4DA} History Activity Instances\n"));
|
|
1976
2131
|
console.log(JSON.stringify(activities, null, 2));
|
|
1977
2132
|
}
|
|
1978
2133
|
});
|
|
1979
2134
|
} catch (error) {
|
|
1980
|
-
|
|
2135
|
+
exitWithCommandError3(spinner, "Failed to fetch history activity instances", error);
|
|
1981
2136
|
}
|
|
1982
2137
|
}
|
|
1983
2138
|
async function listHistoryVariableInstances(client, options = {}) {
|
|
@@ -1988,7 +2143,7 @@ async function listHistoryVariableInstances(client, options = {}) {
|
|
|
1988
2143
|
const result = await bpmClient.getHistoryVariableInstances(params);
|
|
1989
2144
|
if (result.error) {
|
|
1990
2145
|
spinner.fail("Failed to fetch history variable instances");
|
|
1991
|
-
console.error(
|
|
2146
|
+
console.error(chalk4.red(result.error.message));
|
|
1992
2147
|
process.exit(1);
|
|
1993
2148
|
}
|
|
1994
2149
|
const variables = result.data || [];
|
|
@@ -1996,12 +2151,12 @@ async function listHistoryVariableInstances(client, options = {}) {
|
|
|
1996
2151
|
renderOutput(variables, {
|
|
1997
2152
|
format: options.format,
|
|
1998
2153
|
pretty: () => {
|
|
1999
|
-
console.log(
|
|
2154
|
+
console.log(chalk4.blue("\n\u{1F4DA} History Variable Instances\n"));
|
|
2000
2155
|
console.log(JSON.stringify(variables, null, 2));
|
|
2001
2156
|
}
|
|
2002
2157
|
});
|
|
2003
2158
|
} catch (error) {
|
|
2004
|
-
|
|
2159
|
+
exitWithCommandError3(spinner, "Failed to fetch history variable instances", error);
|
|
2005
2160
|
}
|
|
2006
2161
|
}
|
|
2007
2162
|
async function listUserOperationLogs(client, options = {}) {
|
|
@@ -2012,7 +2167,7 @@ async function listUserOperationLogs(client, options = {}) {
|
|
|
2012
2167
|
const result = await bpmClient.getUserOperationLogs(params);
|
|
2013
2168
|
if (result.error) {
|
|
2014
2169
|
spinner.fail("Failed to fetch user operation logs");
|
|
2015
|
-
console.error(
|
|
2170
|
+
console.error(chalk4.red(result.error.message));
|
|
2016
2171
|
process.exit(1);
|
|
2017
2172
|
}
|
|
2018
2173
|
const logs = result.data || [];
|
|
@@ -2020,12 +2175,12 @@ async function listUserOperationLogs(client, options = {}) {
|
|
|
2020
2175
|
renderOutput(logs, {
|
|
2021
2176
|
format: options.format,
|
|
2022
2177
|
pretty: () => {
|
|
2023
|
-
console.log(
|
|
2178
|
+
console.log(chalk4.blue("\n\u{1F4DA} User Operation Logs\n"));
|
|
2024
2179
|
console.log(JSON.stringify(logs, null, 2));
|
|
2025
2180
|
}
|
|
2026
2181
|
});
|
|
2027
2182
|
} catch (error) {
|
|
2028
|
-
|
|
2183
|
+
exitWithCommandError3(spinner, "Failed to fetch user operation logs", error);
|
|
2029
2184
|
}
|
|
2030
2185
|
}
|
|
2031
2186
|
async function deleteHistoryProcessInstance(client, options) {
|
|
@@ -2035,7 +2190,7 @@ async function deleteHistoryProcessInstance(client, options) {
|
|
|
2035
2190
|
const result = await bpmClient.deleteHistoryProcessInstance(options.id);
|
|
2036
2191
|
if (result.error) {
|
|
2037
2192
|
spinner.fail("Failed to delete history process instance");
|
|
2038
|
-
console.error(
|
|
2193
|
+
console.error(chalk4.red(result.error.message));
|
|
2039
2194
|
process.exit(1);
|
|
2040
2195
|
}
|
|
2041
2196
|
spinner.succeed("History process instance deleted");
|
|
@@ -2047,12 +2202,12 @@ async function deleteHistoryProcessInstance(client, options) {
|
|
|
2047
2202
|
{
|
|
2048
2203
|
format: options.format,
|
|
2049
2204
|
pretty: () => {
|
|
2050
|
-
console.log(
|
|
2205
|
+
console.log(chalk4.green(`Deleted history process instance: ${options.id}`));
|
|
2051
2206
|
}
|
|
2052
2207
|
}
|
|
2053
2208
|
);
|
|
2054
2209
|
} catch (error) {
|
|
2055
|
-
|
|
2210
|
+
exitWithCommandError3(spinner, "Failed to delete history process instance", error);
|
|
2056
2211
|
}
|
|
2057
2212
|
}
|
|
2058
2213
|
async function listRoles(client, options = {}) {
|
|
@@ -2062,7 +2217,7 @@ async function listRoles(client, options = {}) {
|
|
|
2062
2217
|
const result = await bpmClient.getRoles();
|
|
2063
2218
|
if (result.error) {
|
|
2064
2219
|
spinner.fail("Failed to fetch roles");
|
|
2065
|
-
console.error(
|
|
2220
|
+
console.error(chalk4.red(result.error.message));
|
|
2066
2221
|
process.exit(1);
|
|
2067
2222
|
}
|
|
2068
2223
|
const roles = result.data || [];
|
|
@@ -2070,12 +2225,12 @@ async function listRoles(client, options = {}) {
|
|
|
2070
2225
|
renderOutput(roles, {
|
|
2071
2226
|
format: options.format,
|
|
2072
2227
|
pretty: () => {
|
|
2073
|
-
console.log(
|
|
2228
|
+
console.log(chalk4.blue("\n\u{1F465} Roles\n"));
|
|
2074
2229
|
console.log(JSON.stringify(roles, null, 2));
|
|
2075
2230
|
}
|
|
2076
2231
|
});
|
|
2077
2232
|
} catch (error) {
|
|
2078
|
-
|
|
2233
|
+
exitWithCommandError3(spinner, "Failed to fetch roles", error);
|
|
2079
2234
|
}
|
|
2080
2235
|
}
|
|
2081
2236
|
async function getUserRoles(client, options) {
|
|
@@ -2085,7 +2240,7 @@ async function getUserRoles(client, options) {
|
|
|
2085
2240
|
const result = await bpmClient.getUserRoles(options.userId);
|
|
2086
2241
|
if (result.error) {
|
|
2087
2242
|
spinner.fail("Failed to fetch user roles");
|
|
2088
|
-
console.error(
|
|
2243
|
+
console.error(chalk4.red(result.error.message));
|
|
2089
2244
|
process.exit(1);
|
|
2090
2245
|
}
|
|
2091
2246
|
const roles = result.data || [];
|
|
@@ -2093,17 +2248,17 @@ async function getUserRoles(client, options) {
|
|
|
2093
2248
|
renderOutput(roles, {
|
|
2094
2249
|
format: options.format,
|
|
2095
2250
|
pretty: () => {
|
|
2096
|
-
console.log(
|
|
2251
|
+
console.log(chalk4.blue(`
|
|
2097
2252
|
\u{1F464} User Roles: ${options.userId}
|
|
2098
2253
|
`));
|
|
2099
2254
|
console.log(JSON.stringify(roles, null, 2));
|
|
2100
2255
|
}
|
|
2101
2256
|
});
|
|
2102
2257
|
} catch (error) {
|
|
2103
|
-
|
|
2258
|
+
exitWithCommandError3(spinner, "Failed to fetch user roles", error);
|
|
2104
2259
|
}
|
|
2105
2260
|
}
|
|
2106
|
-
function
|
|
2261
|
+
function resolveInputSource4(input) {
|
|
2107
2262
|
if (!input.startsWith("@")) {
|
|
2108
2263
|
return input;
|
|
2109
2264
|
}
|
|
@@ -2114,7 +2269,7 @@ function resolveInputSource3(input) {
|
|
|
2114
2269
|
return readFileSync(filePath, "utf8");
|
|
2115
2270
|
}
|
|
2116
2271
|
function parseJsonInput3(input, label) {
|
|
2117
|
-
const source =
|
|
2272
|
+
const source = resolveInputSource4(input).trim();
|
|
2118
2273
|
if (!source) {
|
|
2119
2274
|
throw new Error(`${label} is required.`);
|
|
2120
2275
|
}
|
|
@@ -2148,11 +2303,11 @@ function loadOptionalJsonArrayInput(input, label) {
|
|
|
2148
2303
|
}
|
|
2149
2304
|
return value;
|
|
2150
2305
|
}
|
|
2151
|
-
function
|
|
2306
|
+
function exitWithCommandError4(spinner, failureMessage, error) {
|
|
2152
2307
|
spinner.fail(failureMessage);
|
|
2153
2308
|
const details = error instanceof Error ? error.message : String(error);
|
|
2154
2309
|
if (details) {
|
|
2155
|
-
console.error(
|
|
2310
|
+
console.error(chalk4.red(details));
|
|
2156
2311
|
}
|
|
2157
2312
|
process.exit(1);
|
|
2158
2313
|
}
|
|
@@ -2187,26 +2342,26 @@ async function runWorkflow(client, options) {
|
|
|
2187
2342
|
const result = await workflowClient.run(options.name, request);
|
|
2188
2343
|
if (result.error) {
|
|
2189
2344
|
spinner.fail("Failed to run workflow");
|
|
2190
|
-
console.error(
|
|
2345
|
+
console.error(chalk4.red(result.error.message));
|
|
2191
2346
|
process.exit(1);
|
|
2192
2347
|
}
|
|
2193
2348
|
spinner.succeed("Workflow completed");
|
|
2194
2349
|
renderOutput(result.data, {
|
|
2195
2350
|
format: options.format,
|
|
2196
2351
|
pretty: () => {
|
|
2197
|
-
console.log(
|
|
2352
|
+
console.log(chalk4.blue("\n\u26A1 Workflow Run\n"));
|
|
2198
2353
|
console.log(JSON.stringify(result.data, null, 2));
|
|
2199
2354
|
}
|
|
2200
2355
|
});
|
|
2201
2356
|
} catch (error) {
|
|
2202
|
-
|
|
2357
|
+
exitWithCommandError4(spinner, "Failed to run workflow", error);
|
|
2203
2358
|
}
|
|
2204
2359
|
}
|
|
2205
|
-
function
|
|
2360
|
+
function exitWithCommandError5(spinner, failureMessage, error) {
|
|
2206
2361
|
spinner.fail(failureMessage);
|
|
2207
2362
|
const details = error instanceof Error ? error.message : String(error);
|
|
2208
2363
|
if (details) {
|
|
2209
|
-
console.error(
|
|
2364
|
+
console.error(chalk4.red(details));
|
|
2210
2365
|
}
|
|
2211
2366
|
process.exit(1);
|
|
2212
2367
|
}
|
|
@@ -2245,20 +2400,20 @@ async function uploadFile(client, options) {
|
|
|
2245
2400
|
const result = await s3Client.upload(file);
|
|
2246
2401
|
if (result.error) {
|
|
2247
2402
|
spinner.fail("Upload failed");
|
|
2248
|
-
console.error(
|
|
2403
|
+
console.error(chalk4.red(result.error.message));
|
|
2249
2404
|
process.exit(1);
|
|
2250
2405
|
}
|
|
2251
2406
|
spinner.succeed("Upload complete");
|
|
2252
2407
|
renderOutput(result.data, {
|
|
2253
2408
|
format: options.format,
|
|
2254
2409
|
pretty: () => {
|
|
2255
|
-
console.log(
|
|
2256
|
-
console.log(` ${
|
|
2257
|
-
console.log(` ${
|
|
2410
|
+
console.log(chalk4.green("\nFile uploaded:"));
|
|
2411
|
+
console.log(` ${chalk4.bold("Key:")} ${result.data?.key}`);
|
|
2412
|
+
console.log(` ${chalk4.bold("URL:")} ${result.data?.url || "N/A"}`);
|
|
2258
2413
|
}
|
|
2259
2414
|
});
|
|
2260
2415
|
} catch (error) {
|
|
2261
|
-
|
|
2416
|
+
exitWithCommandError5(spinner, "Upload failed", error);
|
|
2262
2417
|
}
|
|
2263
2418
|
}
|
|
2264
2419
|
async function downloadFile(client, options) {
|
|
@@ -2268,12 +2423,12 @@ async function downloadFile(client, options) {
|
|
|
2268
2423
|
const result = await s3Client.download(options.key);
|
|
2269
2424
|
if (result.error) {
|
|
2270
2425
|
spinner.fail("Download failed");
|
|
2271
|
-
console.error(
|
|
2426
|
+
console.error(chalk4.red(result.error.message));
|
|
2272
2427
|
process.exit(1);
|
|
2273
2428
|
}
|
|
2274
2429
|
if (!result.data) {
|
|
2275
2430
|
spinner.fail("Download failed");
|
|
2276
|
-
console.error(
|
|
2431
|
+
console.error(chalk4.red("Empty file response."));
|
|
2277
2432
|
process.exit(1);
|
|
2278
2433
|
}
|
|
2279
2434
|
const outputPath = resolve(options.output);
|
|
@@ -2289,13 +2444,13 @@ async function downloadFile(client, options) {
|
|
|
2289
2444
|
{
|
|
2290
2445
|
format: options.format,
|
|
2291
2446
|
pretty: () => {
|
|
2292
|
-
console.log(
|
|
2447
|
+
console.log(chalk4.green(`
|
|
2293
2448
|
File saved to: ${outputPath}`));
|
|
2294
2449
|
}
|
|
2295
2450
|
}
|
|
2296
2451
|
);
|
|
2297
2452
|
} catch (error) {
|
|
2298
|
-
|
|
2453
|
+
exitWithCommandError5(spinner, "Download failed", error);
|
|
2299
2454
|
}
|
|
2300
2455
|
}
|
|
2301
2456
|
async function getFileMetadata(client, options) {
|
|
@@ -2305,21 +2460,21 @@ async function getFileMetadata(client, options) {
|
|
|
2305
2460
|
const result = await s3Client.getMetadata(options.key);
|
|
2306
2461
|
if (result.error) {
|
|
2307
2462
|
spinner.fail("Failed to fetch metadata");
|
|
2308
|
-
console.error(
|
|
2463
|
+
console.error(chalk4.red(result.error.message));
|
|
2309
2464
|
process.exit(1);
|
|
2310
2465
|
}
|
|
2311
2466
|
spinner.succeed("Metadata retrieved");
|
|
2312
2467
|
renderOutput(result.data, {
|
|
2313
2468
|
format: options.format,
|
|
2314
2469
|
pretty: () => {
|
|
2315
|
-
console.log(
|
|
2470
|
+
console.log(chalk4.blue(`
|
|
2316
2471
|
\u{1F4C4} Metadata for ${options.key}
|
|
2317
2472
|
`));
|
|
2318
2473
|
console.log(JSON.stringify(result.data, null, 2));
|
|
2319
2474
|
}
|
|
2320
2475
|
});
|
|
2321
2476
|
} catch (error) {
|
|
2322
|
-
|
|
2477
|
+
exitWithCommandError5(spinner, "Failed to fetch metadata", error);
|
|
2323
2478
|
}
|
|
2324
2479
|
}
|
|
2325
2480
|
|
|
@@ -2360,8 +2515,8 @@ async function initOpenClaw(options) {
|
|
|
2360
2515
|
const existingConfig = getAppConfig(options.appCode);
|
|
2361
2516
|
if (existingConfig && !options.force) {
|
|
2362
2517
|
spinner.fail(`App already exists: ${options.appCode}`);
|
|
2363
|
-
console.log(
|
|
2364
|
-
console.log(
|
|
2518
|
+
console.log(chalk4.yellow(`Use --force to reinitialize`));
|
|
2519
|
+
console.log(chalk4.gray(`Current URL: ${existingConfig.baseURL}`));
|
|
2365
2520
|
process.exit(1);
|
|
2366
2521
|
}
|
|
2367
2522
|
addApp(options.appCode, {
|
|
@@ -2372,8 +2527,8 @@ async function initOpenClaw(options) {
|
|
|
2372
2527
|
if (!openClawDetected) {
|
|
2373
2528
|
spinner.succeed(`App initialized: ${options.appCode}`);
|
|
2374
2529
|
if (pretty) {
|
|
2375
|
-
console.log(
|
|
2376
|
-
console.log(
|
|
2530
|
+
console.log(chalk4.yellow("\n\u26A0\uFE0F OpenClaw not detected, skipping skill download"));
|
|
2531
|
+
console.log(chalk4.gray(" Install OpenClaw: npm install -g openclaw"));
|
|
2377
2532
|
} else {
|
|
2378
2533
|
renderOutput(
|
|
2379
2534
|
{
|
|
@@ -2391,9 +2546,9 @@ async function initOpenClaw(options) {
|
|
|
2391
2546
|
}
|
|
2392
2547
|
spinner.succeed(`App initialized: ${options.appCode}`);
|
|
2393
2548
|
if (pretty) {
|
|
2394
|
-
console.log(
|
|
2395
|
-
console.log(` App Code: ${
|
|
2396
|
-
console.log(` Base URL: ${
|
|
2549
|
+
console.log(chalk4.blue("\n\u{1F4CB} Configuration:\n"));
|
|
2550
|
+
console.log(` App Code: ${chalk4.green(options.appCode)}`);
|
|
2551
|
+
console.log(` Base URL: ${chalk4.gray(options.baseURL)}`);
|
|
2397
2552
|
console.log();
|
|
2398
2553
|
}
|
|
2399
2554
|
spinner.start("Downloading skills...");
|
|
@@ -2465,16 +2620,16 @@ async function initOpenClaw(options) {
|
|
|
2465
2620
|
};
|
|
2466
2621
|
if (pretty) {
|
|
2467
2622
|
console.log();
|
|
2468
|
-
console.log(
|
|
2623
|
+
console.log(chalk4.green("\u2705 Initialization complete!"));
|
|
2469
2624
|
console.log();
|
|
2470
2625
|
console.log(`Next step: Login to your app`);
|
|
2471
|
-
console.log(
|
|
2626
|
+
console.log(chalk4.gray(` amaster login --app ${options.appCode}`));
|
|
2472
2627
|
console.log();
|
|
2473
2628
|
if (apps.length > 1) {
|
|
2474
|
-
console.log(
|
|
2629
|
+
console.log(chalk4.blue("Configured apps:"));
|
|
2475
2630
|
for (const app of apps) {
|
|
2476
2631
|
const config = getAppConfig(app);
|
|
2477
|
-
console.log(` ${
|
|
2632
|
+
console.log(` ${chalk4.gray("\u2022")} ${app} - ${config?.baseURL}`);
|
|
2478
2633
|
}
|
|
2479
2634
|
console.log();
|
|
2480
2635
|
}
|
|
@@ -2575,6 +2730,14 @@ async function downloadMcpConfig(ossEndpoint, appCode) {
|
|
|
2575
2730
|
}
|
|
2576
2731
|
|
|
2577
2732
|
// src/cli.ts
|
|
2733
|
+
function resolveCliVersion() {
|
|
2734
|
+
try {
|
|
2735
|
+
const packageJsonUrl = new URL("../package.json", import.meta.url);
|
|
2736
|
+
return JSON.parse(readFileSync(packageJsonUrl, "utf-8")).version || "0.0.0";
|
|
2737
|
+
} catch {
|
|
2738
|
+
return "0.0.0";
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2578
2741
|
function resolveAppCode(optionsApp) {
|
|
2579
2742
|
if (optionsApp) {
|
|
2580
2743
|
return optionsApp;
|
|
@@ -2583,22 +2746,22 @@ function resolveAppCode(optionsApp) {
|
|
|
2583
2746
|
if (defaultApp) {
|
|
2584
2747
|
return defaultApp;
|
|
2585
2748
|
}
|
|
2586
|
-
console.error(
|
|
2587
|
-
console.log(
|
|
2588
|
-
console.log(
|
|
2589
|
-
console.log(
|
|
2749
|
+
console.error(chalk4.red("\u274C No app specified."));
|
|
2750
|
+
console.log(chalk4.yellow("Use one of:"));
|
|
2751
|
+
console.log(chalk4.gray(" 1. Add --app <app-code> to the command"));
|
|
2752
|
+
console.log(chalk4.gray(" 2. Set a default app: amaster use <app-code>"));
|
|
2590
2753
|
process.exit(1);
|
|
2591
2754
|
}
|
|
2592
2755
|
function createAmasterClient(appCode) {
|
|
2593
2756
|
const appConfig = getAppConfig(appCode);
|
|
2594
2757
|
if (!appConfig) {
|
|
2595
|
-
console.error(
|
|
2596
|
-
console.log(
|
|
2758
|
+
console.error(chalk4.red(`\u274C App not configured: ${appCode}`));
|
|
2759
|
+
console.log(chalk4.yellow(`Initialize it first: amaster init --app-code ${appCode} --url <url>`));
|
|
2597
2760
|
process.exit(1);
|
|
2598
2761
|
}
|
|
2599
2762
|
const token = getAccessToken(appCode);
|
|
2600
2763
|
if (token && shouldRefreshToken(appCode)) {
|
|
2601
|
-
console.error(
|
|
2764
|
+
console.error(chalk4.yellow("\u26A0\uFE0F Session expiring soon. Please login again."));
|
|
2602
2765
|
}
|
|
2603
2766
|
const client = createClient({
|
|
2604
2767
|
baseURL: appConfig.baseURL,
|
|
@@ -2609,12 +2772,12 @@ function createAmasterClient(appCode) {
|
|
|
2609
2772
|
} : {},
|
|
2610
2773
|
onUnauthorized: () => {
|
|
2611
2774
|
if (token) {
|
|
2612
|
-
console.error(
|
|
2613
|
-
console.error(
|
|
2775
|
+
console.error(chalk4.red("\n\u274C Session expired. Please login again."));
|
|
2776
|
+
console.error(chalk4.yellow(`Run: amaster login --app ${appCode}`));
|
|
2614
2777
|
} else {
|
|
2615
|
-
console.error(
|
|
2778
|
+
console.error(chalk4.red(`
|
|
2616
2779
|
\u274C Authentication required for app: ${appCode}`));
|
|
2617
|
-
console.error(
|
|
2780
|
+
console.error(chalk4.yellow(`Run: amaster login --app ${appCode}`));
|
|
2618
2781
|
}
|
|
2619
2782
|
process.exit(1);
|
|
2620
2783
|
}
|
|
@@ -2625,7 +2788,7 @@ function createAmasterClient(appCode) {
|
|
|
2625
2788
|
return client;
|
|
2626
2789
|
}
|
|
2627
2790
|
var program = new Command();
|
|
2628
|
-
program.name("amaster").description("CLI for Amaster SDK - Multi-app support for OpenClaw").version(
|
|
2791
|
+
program.name("amaster").description("CLI for Amaster SDK - Multi-app support for OpenClaw").version(resolveCliVersion());
|
|
2629
2792
|
program.command("apps").description("List all configured apps").addOption(createFormatOption()).action((options) => {
|
|
2630
2793
|
const apps = listApps();
|
|
2631
2794
|
const current = getCurrentApp();
|
|
@@ -2641,17 +2804,17 @@ program.command("apps").description("List all configured apps").addOption(create
|
|
|
2641
2804
|
renderOutput(appSummaries, {
|
|
2642
2805
|
format: options.format,
|
|
2643
2806
|
pretty: () => {
|
|
2644
|
-
console.log(
|
|
2807
|
+
console.log(chalk4.blue("\n\u{1F4F1} Configured Apps\n"));
|
|
2645
2808
|
if (appSummaries.length === 0) {
|
|
2646
|
-
console.log(
|
|
2647
|
-
console.log(
|
|
2809
|
+
console.log(chalk4.gray(" No apps configured"));
|
|
2810
|
+
console.log(chalk4.gray(" Run: amaster init --app-code <code> --url <url>"));
|
|
2648
2811
|
} else {
|
|
2649
2812
|
for (const app of appSummaries) {
|
|
2650
|
-
const prefix = app.current ?
|
|
2651
|
-
console.log(`${prefix}${
|
|
2652
|
-
console.log(` ${
|
|
2813
|
+
const prefix = app.current ? chalk4.green("\u2192 ") : " ";
|
|
2814
|
+
console.log(`${prefix}${chalk4.bold(app.appCode)}${app.current ? chalk4.green(" (current)") : ""}`);
|
|
2815
|
+
console.log(` ${chalk4.gray(app.baseURL || "No URL")}`);
|
|
2653
2816
|
console.log(
|
|
2654
|
-
` ${app.authenticated ?
|
|
2817
|
+
` ${app.authenticated ? chalk4.green("\u25CF Authenticated") : chalk4.yellow("\u25CB Not authenticated")}`
|
|
2655
2818
|
);
|
|
2656
2819
|
console.log();
|
|
2657
2820
|
}
|
|
@@ -2670,12 +2833,12 @@ program.command("use <app-code>").description("Set the default app for subsequen
|
|
|
2670
2833
|
{
|
|
2671
2834
|
format: options.format,
|
|
2672
2835
|
pretty: () => {
|
|
2673
|
-
console.log(
|
|
2836
|
+
console.log(chalk4.green(`\u2705 Now using app: ${appCode}`));
|
|
2674
2837
|
}
|
|
2675
2838
|
}
|
|
2676
2839
|
);
|
|
2677
2840
|
} else {
|
|
2678
|
-
console.error(
|
|
2841
|
+
console.error(chalk4.red(`\u274C App not found: ${appCode}`));
|
|
2679
2842
|
process.exit(1);
|
|
2680
2843
|
}
|
|
2681
2844
|
});
|
|
@@ -2792,6 +2955,21 @@ entityCmd.command("bulk-delete <namespace> <entity>").description("Bulk delete e
|
|
|
2792
2955
|
format: options.format
|
|
2793
2956
|
});
|
|
2794
2957
|
});
|
|
2958
|
+
var modelCmd = program.command("model").description("Discover runtime datasources and table schemas");
|
|
2959
|
+
modelCmd.command("datasources").description("List runtime datasources with their models").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (options) => {
|
|
2960
|
+
const appCode = resolveAppCode(options.app);
|
|
2961
|
+
await listDatasources(createAmasterClient(appCode), {
|
|
2962
|
+
format: options.format
|
|
2963
|
+
});
|
|
2964
|
+
});
|
|
2965
|
+
modelCmd.command("table-schema <source-id>").description("Get CREATE TABLE statements for one datasource").option("--app <app-code>", "App code (uses default if not specified)").option("--tables <tables>", "Comma-separated table names, JSON array, or @file").addOption(createFormatOption()).action(async (sourceId, options) => {
|
|
2966
|
+
const appCode = resolveAppCode(options.app);
|
|
2967
|
+
await getTableSchema(createAmasterClient(appCode), {
|
|
2968
|
+
sourceId,
|
|
2969
|
+
tables: options.tables,
|
|
2970
|
+
format: options.format
|
|
2971
|
+
});
|
|
2972
|
+
});
|
|
2795
2973
|
var bpmCmd = program.command("bpm").description("Manage BPM processes and tasks");
|
|
2796
2974
|
bpmCmd.command("processes").description("List process definitions").option("--app <app-code>", "App code (uses default if not specified)").option("--key <key>", "Filter by process definition key").option("--name <name>", "Filter by process definition name").option("--latest-version", "Only return latest version").option("--active", "Only return active process definitions").option("--suspended", "Only return suspended process definitions").option("--sort-by <field>", "Sort field").addOption(new Option("--sort-order <order>", "Sort order").choices(["asc", "desc"])).option("-q, --query <json>", "Additional ProcessDefinitionQueryParams as JSON or @file").addOption(createFormatOption()).action(async (options) => {
|
|
2797
2975
|
const appCode = resolveAppCode(options.app);
|