@amaster.ai/runtime-cli 1.1.9 → 1.1.11
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 +272 -18
- package/dist/cli.cjs +1708 -232
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1708 -232
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1708 -232
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1708 -232
- package/dist/index.js.map +1 -1
- package/dist/skill/SKILL.md +161 -87
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -4,15 +4,16 @@ var fs = require('fs');
|
|
|
4
4
|
var path = require('path');
|
|
5
5
|
var os = require('os');
|
|
6
6
|
var commander = require('commander');
|
|
7
|
-
var
|
|
7
|
+
var chalk3 = require('chalk');
|
|
8
8
|
var client = require('@amaster.ai/client');
|
|
9
9
|
var ora = require('ora');
|
|
10
|
+
var buffer = require('buffer');
|
|
10
11
|
var yaml = require('yaml');
|
|
11
12
|
|
|
12
13
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
13
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
|
|
15
|
-
var
|
|
16
|
+
var chalk3__default = /*#__PURE__*/_interopDefault(chalk3);
|
|
16
17
|
var ora__default = /*#__PURE__*/_interopDefault(ora);
|
|
17
18
|
var yaml__default = /*#__PURE__*/_interopDefault(yaml);
|
|
18
19
|
|
|
@@ -336,9 +337,9 @@ async function login(appCode, options) {
|
|
|
336
337
|
const appConfig = getAppConfig(appCode);
|
|
337
338
|
if (!appConfig) {
|
|
338
339
|
spinner.fail(`App not configured: ${appCode}`);
|
|
339
|
-
console.error(
|
|
340
|
+
console.error(chalk3__default.default.red(`
|
|
340
341
|
\u274C App not found: ${appCode}`));
|
|
341
|
-
console.log(
|
|
342
|
+
console.log(chalk3__default.default.yellow(`Initialize it first: amaster init --app-code ${appCode} --url <url>`));
|
|
342
343
|
process.exit(1);
|
|
343
344
|
}
|
|
344
345
|
let username = options.username;
|
|
@@ -387,7 +388,7 @@ async function login(appCode, options) {
|
|
|
387
388
|
const result = await client$1.auth.login(loginParams);
|
|
388
389
|
if (result.error) {
|
|
389
390
|
spinner.fail("Login failed");
|
|
390
|
-
console.error(
|
|
391
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
391
392
|
process.exit(1);
|
|
392
393
|
}
|
|
393
394
|
const loginData = result.data;
|
|
@@ -421,16 +422,16 @@ async function login(appCode, options) {
|
|
|
421
422
|
format: options.format,
|
|
422
423
|
pretty: () => {
|
|
423
424
|
console.log(
|
|
424
|
-
|
|
425
|
+
chalk3__default.default.green(
|
|
425
426
|
`
|
|
426
427
|
Welcome, ${loginData.user?.displayName || loginData.user?.email || loginData.user?.username || email}!`
|
|
427
428
|
)
|
|
428
429
|
);
|
|
429
|
-
console.log(
|
|
430
|
-
console.log(
|
|
430
|
+
console.log(chalk3__default.default.gray(`App: ${appCode}`));
|
|
431
|
+
console.log(chalk3__default.default.gray(`URL: ${appConfig.baseURL}`));
|
|
431
432
|
if (expiresAt) {
|
|
432
433
|
const expires = new Date(expiresAt);
|
|
433
|
-
console.log(
|
|
434
|
+
console.log(chalk3__default.default.gray(`Session expires: ${expires.toLocaleString()}`));
|
|
434
435
|
}
|
|
435
436
|
}
|
|
436
437
|
}
|
|
@@ -466,7 +467,7 @@ async function logout(appCode, options = {}) {
|
|
|
466
467
|
{
|
|
467
468
|
format: options.format,
|
|
468
469
|
pretty: () => {
|
|
469
|
-
console.log(
|
|
470
|
+
console.log(chalk3__default.default.green(`Logged out from ${appCode}`));
|
|
470
471
|
}
|
|
471
472
|
}
|
|
472
473
|
);
|
|
@@ -482,7 +483,7 @@ async function getMe(getClient, options = {}) {
|
|
|
482
483
|
const result = await client.auth.getMe();
|
|
483
484
|
if (result.error) {
|
|
484
485
|
spinner.fail("Failed to fetch user info");
|
|
485
|
-
console.error(
|
|
486
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
486
487
|
process.exit(1);
|
|
487
488
|
}
|
|
488
489
|
spinner.succeed("User info retrieved");
|
|
@@ -490,11 +491,11 @@ async function getMe(getClient, options = {}) {
|
|
|
490
491
|
renderOutput(user, {
|
|
491
492
|
format: options.format,
|
|
492
493
|
pretty: () => {
|
|
493
|
-
console.log(
|
|
494
|
-
console.log(` ${
|
|
495
|
-
console.log(` ${
|
|
496
|
-
console.log(` ${
|
|
497
|
-
console.log(` ${
|
|
494
|
+
console.log(chalk3__default.default.blue("\n\u{1F464} User Profile\n"));
|
|
495
|
+
console.log(` ${chalk3__default.default.bold("UID:")} ${user?.uid}`);
|
|
496
|
+
console.log(` ${chalk3__default.default.bold("Email:")} ${user?.email}`);
|
|
497
|
+
console.log(` ${chalk3__default.default.bold("Name:")} ${user?.displayName || user?.username || "N/A"}`);
|
|
498
|
+
console.log(` ${chalk3__default.default.bold("Status:")} ${user?.isActive ? "Active" : "Inactive"}`);
|
|
498
499
|
}
|
|
499
500
|
});
|
|
500
501
|
} catch (error) {
|
|
@@ -624,7 +625,7 @@ function exitWithCommandError(spinner, failureMessage, error) {
|
|
|
624
625
|
spinner.fail(failureMessage);
|
|
625
626
|
const details = error instanceof Error ? error.message : String(error);
|
|
626
627
|
if (details) {
|
|
627
|
-
console.error(
|
|
628
|
+
console.error(chalk3__default.default.red(details));
|
|
628
629
|
}
|
|
629
630
|
process.exit(1);
|
|
630
631
|
}
|
|
@@ -676,14 +677,20 @@ async function listEntities(client, options) {
|
|
|
676
677
|
try {
|
|
677
678
|
const entityClient = client.entity;
|
|
678
679
|
const query = buildListQueryParams(options);
|
|
680
|
+
const paginationParams = {};
|
|
681
|
+
if (options.page !== void 0) {
|
|
682
|
+
paginationParams.page = options.page;
|
|
683
|
+
}
|
|
684
|
+
if (options.pageSize !== void 0) {
|
|
685
|
+
paginationParams.perPage = options.pageSize;
|
|
686
|
+
}
|
|
679
687
|
const result = await entityClient.list(options.namespace, options.entity, {
|
|
680
688
|
...query,
|
|
681
|
-
|
|
682
|
-
perPage: options.pageSize || 10
|
|
689
|
+
...paginationParams
|
|
683
690
|
});
|
|
684
691
|
if (result.error) {
|
|
685
692
|
spinner.fail("Failed to fetch entities");
|
|
686
|
-
console.error(
|
|
693
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
687
694
|
process.exit(1);
|
|
688
695
|
}
|
|
689
696
|
spinner.stop();
|
|
@@ -703,12 +710,12 @@ async function listEntities(client, options) {
|
|
|
703
710
|
renderOutput(result.data, {
|
|
704
711
|
format: options.format,
|
|
705
712
|
pretty: () => {
|
|
706
|
-
console.log(
|
|
713
|
+
console.log(chalk3__default.default.blue(`
|
|
707
714
|
\u{1F4E6} ${options.entity} in ${options.namespace}`));
|
|
708
|
-
console.log(
|
|
715
|
+
console.log(chalk3__default.default.gray(`\u5171 ${total} \u6761\u8BB0\u5F55:
|
|
709
716
|
`));
|
|
710
717
|
if (items.length === 0) {
|
|
711
|
-
console.log(
|
|
718
|
+
console.log(chalk3__default.default.gray(" \u6682\u65E0\u6570\u636E"));
|
|
712
719
|
return;
|
|
713
720
|
}
|
|
714
721
|
const firstItem = items[0];
|
|
@@ -728,7 +735,7 @@ async function listEntities(client, options) {
|
|
|
728
735
|
});
|
|
729
736
|
const headerLine = keys.map((key) => {
|
|
730
737
|
const width = widths[key] ?? 0;
|
|
731
|
-
return
|
|
738
|
+
return chalk3__default.default.bold(key.slice(0, width).padEnd(width));
|
|
732
739
|
}).join("\u2502");
|
|
733
740
|
console.log(" " + headerLine);
|
|
734
741
|
console.log(" " + keys.map((key) => "\u2500".repeat(widths[key] ?? 0)).join("\u253C"));
|
|
@@ -744,7 +751,7 @@ async function listEntities(client, options) {
|
|
|
744
751
|
}
|
|
745
752
|
console.log();
|
|
746
753
|
if (items.length < total) {
|
|
747
|
-
console.log(
|
|
754
|
+
console.log(chalk3__default.default.gray(` ... \u8FD8\u6709 ${total - items.length} \u6761\u8BB0\u5F55`));
|
|
748
755
|
}
|
|
749
756
|
}
|
|
750
757
|
});
|
|
@@ -759,14 +766,14 @@ async function getEntity(client, options) {
|
|
|
759
766
|
const result = await entityClient.get(options.namespace, options.entity, options.id);
|
|
760
767
|
if (result.error) {
|
|
761
768
|
spinner.fail("Failed to fetch entity");
|
|
762
|
-
console.error(
|
|
769
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
763
770
|
process.exit(1);
|
|
764
771
|
}
|
|
765
772
|
spinner.succeed("Entity retrieved");
|
|
766
773
|
renderOutput(result.data, {
|
|
767
774
|
format: options.format,
|
|
768
775
|
pretty: () => {
|
|
769
|
-
console.log(
|
|
776
|
+
console.log(chalk3__default.default.blue(`
|
|
770
777
|
\u{1F4C4} ${options.entity}
|
|
771
778
|
`));
|
|
772
779
|
console.log(JSON.stringify(result.data, null, 2));
|
|
@@ -784,14 +791,14 @@ async function createEntity(client, options) {
|
|
|
784
791
|
const result = await entityClient.create(options.namespace, options.entity, data);
|
|
785
792
|
if (result.error) {
|
|
786
793
|
spinner.fail("Failed to create entity");
|
|
787
|
-
console.error(
|
|
794
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
788
795
|
process.exit(1);
|
|
789
796
|
}
|
|
790
797
|
spinner.succeed("Entity created");
|
|
791
798
|
renderOutput(result.data, {
|
|
792
799
|
format: options.format,
|
|
793
800
|
pretty: () => {
|
|
794
|
-
console.log(
|
|
801
|
+
console.log(chalk3__default.default.green("\nCreated entity:"));
|
|
795
802
|
console.log(JSON.stringify(result.data, null, 2));
|
|
796
803
|
}
|
|
797
804
|
});
|
|
@@ -807,14 +814,14 @@ async function updateEntity(client, options) {
|
|
|
807
814
|
const result = await entityClient.update(options.namespace, options.entity, options.id, data);
|
|
808
815
|
if (result.error) {
|
|
809
816
|
spinner.fail("Failed to update entity");
|
|
810
|
-
console.error(
|
|
817
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
811
818
|
process.exit(1);
|
|
812
819
|
}
|
|
813
820
|
spinner.succeed("Entity updated");
|
|
814
821
|
renderOutput(result.data, {
|
|
815
822
|
format: options.format,
|
|
816
823
|
pretty: () => {
|
|
817
|
-
console.log(
|
|
824
|
+
console.log(chalk3__default.default.green("\nUpdated entity:"));
|
|
818
825
|
console.log(JSON.stringify(result.data, null, 2));
|
|
819
826
|
}
|
|
820
827
|
});
|
|
@@ -829,7 +836,7 @@ async function deleteEntity(client, options) {
|
|
|
829
836
|
const result = await entityClient.delete(options.namespace, options.entity, options.id);
|
|
830
837
|
if (result.error) {
|
|
831
838
|
spinner.fail("Failed to delete entity");
|
|
832
|
-
console.error(
|
|
839
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
833
840
|
process.exit(1);
|
|
834
841
|
}
|
|
835
842
|
spinner.succeed("Entity deleted");
|
|
@@ -843,7 +850,7 @@ async function deleteEntity(client, options) {
|
|
|
843
850
|
{
|
|
844
851
|
format: options.format,
|
|
845
852
|
pretty: () => {
|
|
846
|
-
console.log(
|
|
853
|
+
console.log(chalk3__default.default.green(`
|
|
847
854
|
Deleted ${options.entity} with ID: ${options.id}`));
|
|
848
855
|
}
|
|
849
856
|
}
|
|
@@ -860,14 +867,14 @@ async function listEntityOptions(client, options) {
|
|
|
860
867
|
const result = await entityClient.options(options.namespace, options.entity, fields);
|
|
861
868
|
if (result.error) {
|
|
862
869
|
spinner.fail("Failed to fetch entity options");
|
|
863
|
-
console.error(
|
|
870
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
864
871
|
process.exit(1);
|
|
865
872
|
}
|
|
866
873
|
spinner.succeed(`Found ${result.data?.length || 0} options`);
|
|
867
874
|
renderOutput(result.data || [], {
|
|
868
875
|
format: options.format,
|
|
869
876
|
pretty: () => {
|
|
870
|
-
console.log(
|
|
877
|
+
console.log(chalk3__default.default.blue(`
|
|
871
878
|
\u{1F9FE} ${options.entity} options
|
|
872
879
|
`));
|
|
873
880
|
console.log(JSON.stringify(result.data || [], null, 2));
|
|
@@ -890,14 +897,14 @@ async function bulkUpdateEntities(client, options) {
|
|
|
890
897
|
const result = await entityClient.bulkUpdate(options.namespace, options.entity, items);
|
|
891
898
|
if (result.error) {
|
|
892
899
|
spinner.fail("Failed to bulk update entities");
|
|
893
|
-
console.error(
|
|
900
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
894
901
|
process.exit(1);
|
|
895
902
|
}
|
|
896
903
|
spinner.succeed(`Updated ${items.length} entities`);
|
|
897
904
|
renderOutput(result.data, {
|
|
898
905
|
format: options.format,
|
|
899
906
|
pretty: () => {
|
|
900
|
-
console.log(
|
|
907
|
+
console.log(chalk3__default.default.green(`
|
|
901
908
|
Bulk updated ${items.length} ${options.entity} records:`));
|
|
902
909
|
console.log(JSON.stringify(result.data, null, 2));
|
|
903
910
|
}
|
|
@@ -914,7 +921,7 @@ async function bulkDeleteEntities(client, options) {
|
|
|
914
921
|
const result = await entityClient.bulkDelete(options.namespace, options.entity, ids);
|
|
915
922
|
if (result.error) {
|
|
916
923
|
spinner.fail("Failed to bulk delete entities");
|
|
917
|
-
console.error(
|
|
924
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
918
925
|
process.exit(1);
|
|
919
926
|
}
|
|
920
927
|
spinner.succeed(`Deleted ${ids.length} entities`);
|
|
@@ -929,7 +936,7 @@ async function bulkDeleteEntities(client, options) {
|
|
|
929
936
|
{
|
|
930
937
|
format: options.format,
|
|
931
938
|
pretty: () => {
|
|
932
|
-
console.log(
|
|
939
|
+
console.log(chalk3__default.default.green(`
|
|
933
940
|
Deleted ${ids.length} ${options.entity} records.`));
|
|
934
941
|
}
|
|
935
942
|
}
|
|
@@ -938,14 +945,256 @@ Deleted ${ids.length} ${options.entity} records.`));
|
|
|
938
945
|
exitWithCommandError(spinner, "Failed to bulk delete entities", error);
|
|
939
946
|
}
|
|
940
947
|
}
|
|
948
|
+
function isPlainObject3(value) {
|
|
949
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
950
|
+
}
|
|
951
|
+
function resolveInputSource2(input) {
|
|
952
|
+
if (!input.startsWith("@")) {
|
|
953
|
+
return input;
|
|
954
|
+
}
|
|
955
|
+
const filePath = input.slice(1);
|
|
956
|
+
if (!filePath) {
|
|
957
|
+
throw new Error("File path is required after '@'.");
|
|
958
|
+
}
|
|
959
|
+
return fs.readFileSync(filePath, "utf8");
|
|
960
|
+
}
|
|
961
|
+
function parseJsonInput2(input, label) {
|
|
962
|
+
const source = resolveInputSource2(input).trim();
|
|
963
|
+
if (!source) {
|
|
964
|
+
throw new Error(`${label} is required.`);
|
|
965
|
+
}
|
|
966
|
+
try {
|
|
967
|
+
return JSON.parse(source);
|
|
968
|
+
} catch (error) {
|
|
969
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
970
|
+
throw new Error(`Invalid ${label}: ${reason}`);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
async function promptForJson2(message, defaultValue) {
|
|
974
|
+
const { default: inquirer } = await import('inquirer');
|
|
975
|
+
const { jsonData } = await inquirer.prompt([
|
|
976
|
+
{
|
|
977
|
+
type: "editor",
|
|
978
|
+
name: "jsonData",
|
|
979
|
+
message,
|
|
980
|
+
default: defaultValue
|
|
981
|
+
}
|
|
982
|
+
]);
|
|
983
|
+
return jsonData;
|
|
984
|
+
}
|
|
985
|
+
async function loadJsonObjectInput2(input, label, promptMessage) {
|
|
986
|
+
const source = input ?? await promptForJson2(promptMessage, "{}");
|
|
987
|
+
const value = parseJsonInput2(source, label);
|
|
988
|
+
if (!isPlainObject3(value)) {
|
|
989
|
+
throw new Error(`${label} must be a JSON object.`);
|
|
990
|
+
}
|
|
991
|
+
return value;
|
|
992
|
+
}
|
|
993
|
+
function loadOptionalJsonObjectInput2(input, label) {
|
|
994
|
+
if (!input) {
|
|
995
|
+
return {};
|
|
996
|
+
}
|
|
997
|
+
const value = parseJsonInput2(input, label);
|
|
998
|
+
if (!isPlainObject3(value)) {
|
|
999
|
+
throw new Error(`${label} must be a JSON object.`);
|
|
1000
|
+
}
|
|
1001
|
+
return value;
|
|
1002
|
+
}
|
|
1003
|
+
function exitWithCommandError2(spinner, failureMessage, error) {
|
|
1004
|
+
spinner.fail(failureMessage);
|
|
1005
|
+
const details = error instanceof Error ? error.message : String(error);
|
|
1006
|
+
if (details) {
|
|
1007
|
+
console.error(chalk3__default.default.red(details));
|
|
1008
|
+
}
|
|
1009
|
+
process.exit(1);
|
|
1010
|
+
}
|
|
1011
|
+
function extractClientErrorMessage(error) {
|
|
1012
|
+
return error?.message || "Unknown BPM client error.";
|
|
1013
|
+
}
|
|
1014
|
+
function exitWithClientError(spinner, failureMessage, error, diagnosticMessage) {
|
|
1015
|
+
spinner.fail(failureMessage);
|
|
1016
|
+
console.error(chalk3__default.default.red(diagnosticMessage || extractClientErrorMessage(error)));
|
|
1017
|
+
process.exit(1);
|
|
1018
|
+
}
|
|
1019
|
+
function inspectStartEventFormConfiguration(bpmnXml) {
|
|
1020
|
+
const startEventMatches = bpmnXml.match(/<[^>]*startEvent\b[\s\S]*?(?:<\/[^>]*startEvent>|\/>)/g) || [];
|
|
1021
|
+
return {
|
|
1022
|
+
startEventCount: startEventMatches.length,
|
|
1023
|
+
hasFormKey: startEventMatches.some((eventXml) => /\bformKey\s*=/.test(eventXml)),
|
|
1024
|
+
hasCamundaFormRef: startEventMatches.some((eventXml) => /\bcamunda:formRef\s*=/.test(eventXml)),
|
|
1025
|
+
hasCamundaFormData: startEventMatches.some((eventXml) => /<camunda:formData\b/.test(eventXml))
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
async function diagnoseTaskFormSchemaError(bpmClient, taskId, originalMessage) {
|
|
1029
|
+
try {
|
|
1030
|
+
const taskFormResult = await bpmClient.getTaskForm(taskId);
|
|
1031
|
+
if (taskFormResult?.error || !taskFormResult?.data) {
|
|
1032
|
+
return null;
|
|
1033
|
+
}
|
|
1034
|
+
const key = typeof taskFormResult.data.key === "string" && taskFormResult.data.key.length > 0 ? taskFormResult.data.key : null;
|
|
1035
|
+
const camundaFormRef = taskFormResult.data.camundaFormRef;
|
|
1036
|
+
if (!camundaFormRef && key?.includes("/rendered-form")) {
|
|
1037
|
+
return [
|
|
1038
|
+
`Task '${taskId}' uses an embedded/generated Camunda form (${key}) rather than a schema-backed form.`,
|
|
1039
|
+
"`bpm task-form-schema` is expected to return 404 in this case.",
|
|
1040
|
+
"Use `bpm task-form`, `bpm task-rendered-form`, or `bpm task-form-variables` instead."
|
|
1041
|
+
].join(" ");
|
|
1042
|
+
}
|
|
1043
|
+
if (!camundaFormRef && !key) {
|
|
1044
|
+
return [
|
|
1045
|
+
`Task '${taskId}' does not expose schema-backed form metadata.`,
|
|
1046
|
+
"Use `bpm task-form` or `bpm task-form-variables` instead."
|
|
1047
|
+
].join(" ");
|
|
1048
|
+
}
|
|
1049
|
+
if (camundaFormRef) {
|
|
1050
|
+
return [
|
|
1051
|
+
`Task '${taskId}' appears to reference a Camunda form via camundaFormRef, but the backend returned 404 for /form-schema.`,
|
|
1052
|
+
`Original error: ${originalMessage}`
|
|
1053
|
+
].join(" ");
|
|
1054
|
+
}
|
|
1055
|
+
} catch {
|
|
1056
|
+
}
|
|
1057
|
+
return null;
|
|
1058
|
+
}
|
|
1059
|
+
async function diagnoseStartFormError(bpmClient, processKey, originalMessage) {
|
|
1060
|
+
let tenantId = null;
|
|
1061
|
+
let startFormConfig = null;
|
|
1062
|
+
try {
|
|
1063
|
+
const definitionsResult = await bpmClient.getProcessDefinitions({ key: processKey, latestVersion: true });
|
|
1064
|
+
if (!definitionsResult?.error && Array.isArray(definitionsResult?.data) && definitionsResult.data.length > 0) {
|
|
1065
|
+
const latestDefinition = definitionsResult.data[0];
|
|
1066
|
+
tenantId = latestDefinition?.tenantId || null;
|
|
1067
|
+
}
|
|
1068
|
+
} catch {
|
|
1069
|
+
}
|
|
1070
|
+
try {
|
|
1071
|
+
const xmlResult = await bpmClient.getProcessXml(processKey);
|
|
1072
|
+
if (!xmlResult?.error && typeof xmlResult?.data?.bpmn20Xml === "string") {
|
|
1073
|
+
startFormConfig = inspectStartEventFormConfiguration(xmlResult.data.bpmn20Xml);
|
|
1074
|
+
}
|
|
1075
|
+
} catch {
|
|
1076
|
+
}
|
|
1077
|
+
if (startFormConfig && !startFormConfig.hasFormKey && !startFormConfig.hasCamundaFormRef && !startFormConfig.hasCamundaFormData) {
|
|
1078
|
+
const tenantHint = tenantId && /no tenant-id/i.test(originalMessage) ? ` The process definition is tenant-scoped ('${tenantId}'), and this endpoint also appears to resolve by key without tenant context.` : "";
|
|
1079
|
+
return [
|
|
1080
|
+
`Process '${processKey}' exists, but its start event does not define formKey, camunda:formRef, or camunda:formData.`,
|
|
1081
|
+
"`bpm start-form*` endpoints are expected to fail for this model.",
|
|
1082
|
+
`Use \`bpm xml ${processKey}\` to inspect the BPMN or configure a start form first.${tenantHint}`
|
|
1083
|
+
].join(" ");
|
|
1084
|
+
}
|
|
1085
|
+
if (tenantId && /no tenant-id/i.test(originalMessage)) {
|
|
1086
|
+
return [
|
|
1087
|
+
`Process '${processKey}' exists under tenant '${tenantId}', but the backend start-form endpoint resolved the process definition by key without tenant-id.`,
|
|
1088
|
+
"Current CLI/SDK sends only processKey for this endpoint.",
|
|
1089
|
+
"This is likely a backend multi-tenant lookup limitation rather than a wrong CLI parameter."
|
|
1090
|
+
].join(" ");
|
|
1091
|
+
}
|
|
1092
|
+
if (/formKey/i.test(originalMessage) && /camunda:formRef/i.test(originalMessage)) {
|
|
1093
|
+
return [
|
|
1094
|
+
`Process '${processKey}' does not expose a deployed start form because neither formKey nor camunda:formRef is configured on the start event.`,
|
|
1095
|
+
"If you need a start form, add formKey or camunda:formRef in the BPMN model."
|
|
1096
|
+
].join(" ");
|
|
1097
|
+
}
|
|
1098
|
+
return null;
|
|
1099
|
+
}
|
|
1100
|
+
function buildProcessDefinitionQueryParams(options) {
|
|
1101
|
+
const params = loadOptionalJsonObjectInput2(options.query, "process query params");
|
|
1102
|
+
if (options.key) params.key = options.key;
|
|
1103
|
+
if (options.name) params.name = options.name;
|
|
1104
|
+
if (options.latestVersion !== void 0) params.latestVersion = options.latestVersion;
|
|
1105
|
+
if (options.active !== void 0) params.active = options.active;
|
|
1106
|
+
if (options.suspended !== void 0) params.suspended = options.suspended;
|
|
1107
|
+
if (options.sortBy) params.sortBy = options.sortBy;
|
|
1108
|
+
if (options.sortOrder) params.sortOrder = options.sortOrder;
|
|
1109
|
+
return params;
|
|
1110
|
+
}
|
|
1111
|
+
function buildTaskQueryParams(options) {
|
|
1112
|
+
const params = loadOptionalJsonObjectInput2(options.query, "task query params");
|
|
1113
|
+
if (options.processInstanceId) params.processInstanceId = options.processInstanceId;
|
|
1114
|
+
if (options.assignee) params.assignee = options.assignee;
|
|
1115
|
+
if (options.candidateUser) params.candidateUser = options.candidateUser;
|
|
1116
|
+
if (options.candidateGroup) params.candidateGroup = options.candidateGroup;
|
|
1117
|
+
if (options.name) params.name = options.name;
|
|
1118
|
+
if (options.nameLike) params.nameLike = options.nameLike;
|
|
1119
|
+
if (options.taskDefinitionKey) params.taskDefinitionKey = options.taskDefinitionKey;
|
|
1120
|
+
if (options.firstResult !== void 0) params.firstResult = options.firstResult;
|
|
1121
|
+
if (options.maxResults !== void 0) params.maxResults = options.maxResults;
|
|
1122
|
+
if (options.sortBy) params.sortBy = options.sortBy;
|
|
1123
|
+
if (options.sortOrder) params.sortOrder = options.sortOrder;
|
|
1124
|
+
return params;
|
|
1125
|
+
}
|
|
1126
|
+
function buildProcessInstanceQueryParams(options) {
|
|
1127
|
+
const params = loadOptionalJsonObjectInput2(options.query, "process instance query params");
|
|
1128
|
+
if (options.processDefinitionKey) params.processDefinitionKey = options.processDefinitionKey;
|
|
1129
|
+
if (options.active !== void 0) params.active = options.active;
|
|
1130
|
+
if (options.firstResult !== void 0) params.firstResult = options.firstResult;
|
|
1131
|
+
if (options.maxResults !== void 0) params.maxResults = options.maxResults;
|
|
1132
|
+
return params;
|
|
1133
|
+
}
|
|
1134
|
+
function buildHistoryTaskQueryParams(options) {
|
|
1135
|
+
const params = loadOptionalJsonObjectInput2(options.query, "history task query params");
|
|
1136
|
+
if (options.taskAssignee) params.taskAssignee = options.taskAssignee;
|
|
1137
|
+
if (options.processInstanceId) params.processInstanceId = options.processInstanceId;
|
|
1138
|
+
if (options.finished !== void 0) params.finished = options.finished;
|
|
1139
|
+
if (options.unfinished !== void 0) params.unfinished = options.unfinished;
|
|
1140
|
+
if (options.scope) params.scope = options.scope;
|
|
1141
|
+
if (options.firstResult !== void 0) params.firstResult = options.firstResult;
|
|
1142
|
+
if (options.maxResults !== void 0) params.maxResults = options.maxResults;
|
|
1143
|
+
if (options.sortBy) params.sortBy = options.sortBy;
|
|
1144
|
+
if (options.sortOrder) params.sortOrder = options.sortOrder;
|
|
1145
|
+
return params;
|
|
1146
|
+
}
|
|
1147
|
+
function buildHistoryProcessInstanceQueryParams(options) {
|
|
1148
|
+
const params = loadOptionalJsonObjectInput2(options.query, "history process instance query params");
|
|
1149
|
+
if (options.startedBy) params.startedBy = options.startedBy;
|
|
1150
|
+
if (options.finished !== void 0) params.finished = options.finished;
|
|
1151
|
+
if (options.unfinished !== void 0) params.unfinished = options.unfinished;
|
|
1152
|
+
if (options.processDefinitionKey) params.processDefinitionKey = options.processDefinitionKey;
|
|
1153
|
+
if (options.scope) params.scope = options.scope;
|
|
1154
|
+
if (options.sortBy) params.sortBy = options.sortBy;
|
|
1155
|
+
if (options.sortOrder) params.sortOrder = options.sortOrder;
|
|
1156
|
+
if (options.firstResult !== void 0) params.firstResult = options.firstResult;
|
|
1157
|
+
if (options.maxResults !== void 0) params.maxResults = options.maxResults;
|
|
1158
|
+
return params;
|
|
1159
|
+
}
|
|
1160
|
+
function buildHistoryActivityQueryParams(options) {
|
|
1161
|
+
const params = loadOptionalJsonObjectInput2(options.query, "history activity query params");
|
|
1162
|
+
if (options.processInstanceId) params.processInstanceId = options.processInstanceId;
|
|
1163
|
+
if (options.activityId) params.activityId = options.activityId;
|
|
1164
|
+
if (options.activityType) params.activityType = options.activityType;
|
|
1165
|
+
if (options.finished !== void 0) params.finished = options.finished;
|
|
1166
|
+
if (options.sortBy) params.sortBy = options.sortBy;
|
|
1167
|
+
if (options.sortOrder) params.sortOrder = options.sortOrder;
|
|
1168
|
+
return params;
|
|
1169
|
+
}
|
|
1170
|
+
function buildHistoryVariableQueryParams(options) {
|
|
1171
|
+
const params = loadOptionalJsonObjectInput2(options.query, "history variable query params");
|
|
1172
|
+
if (options.processInstanceId) params.processInstanceId = options.processInstanceId;
|
|
1173
|
+
if (options.variableName) params.variableName = options.variableName;
|
|
1174
|
+
if (options.deserializeValues !== void 0) params.deserializeValues = options.deserializeValues;
|
|
1175
|
+
return params;
|
|
1176
|
+
}
|
|
1177
|
+
function buildUserOperationLogQueryParams(options) {
|
|
1178
|
+
const params = loadOptionalJsonObjectInput2(options.query, "user operation log query params");
|
|
1179
|
+
if (options.processInstanceId) params.processInstanceId = options.processInstanceId;
|
|
1180
|
+
if (options.taskId) params.taskId = options.taskId;
|
|
1181
|
+
if (options.userId) params.userId = options.userId;
|
|
1182
|
+
if (options.operationType) params.operationType = options.operationType;
|
|
1183
|
+
if (options.sortBy) params.sortBy = options.sortBy;
|
|
1184
|
+
if (options.sortOrder) params.sortOrder = options.sortOrder;
|
|
1185
|
+
if (options.firstResult !== void 0) params.firstResult = options.firstResult;
|
|
1186
|
+
if (options.maxResults !== void 0) params.maxResults = options.maxResults;
|
|
1187
|
+
return params;
|
|
1188
|
+
}
|
|
941
1189
|
async function listProcesses(client, options = {}) {
|
|
942
1190
|
const spinner = createSpinner("Fetching process definitions...", options.format);
|
|
943
1191
|
try {
|
|
944
1192
|
const bpmClient = client.bpm;
|
|
945
|
-
const
|
|
1193
|
+
const params = buildProcessDefinitionQueryParams(options);
|
|
1194
|
+
const result = await bpmClient.getProcessDefinitions(params);
|
|
946
1195
|
if (result.error) {
|
|
947
1196
|
spinner.fail("Failed to fetch processes");
|
|
948
|
-
console.error(
|
|
1197
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
949
1198
|
process.exit(1);
|
|
950
1199
|
}
|
|
951
1200
|
spinner.succeed(`Found ${result.data?.length || 0} process definitions`);
|
|
@@ -953,169 +1202,1045 @@ async function listProcesses(client, options = {}) {
|
|
|
953
1202
|
renderOutput(processes, {
|
|
954
1203
|
format: options.format,
|
|
955
1204
|
pretty: () => {
|
|
956
|
-
console.log(
|
|
1205
|
+
console.log(chalk3__default.default.blue("\n\u{1F4CA} Process Definitions\n"));
|
|
957
1206
|
for (const proc of processes) {
|
|
958
|
-
console.log(` ${
|
|
959
|
-
console.log(` ${
|
|
960
|
-
console.log(` ${
|
|
1207
|
+
console.log(` ${chalk3__default.default.green("\u2022")} ${chalk3__default.default.bold(proc.key)}`);
|
|
1208
|
+
console.log(` ${chalk3__default.default.gray("ID:")} ${proc.id || "N/A"}`);
|
|
1209
|
+
console.log(` ${chalk3__default.default.gray("Name:")} ${proc.name || "N/A"}`);
|
|
1210
|
+
console.log(` ${chalk3__default.default.gray("Version:")} ${proc.version || "N/A"}`);
|
|
1211
|
+
console.log(` ${chalk3__default.default.gray("Suspended:")} ${proc.suspended ? "Yes" : "No"}`);
|
|
961
1212
|
console.log();
|
|
962
1213
|
}
|
|
963
1214
|
}
|
|
964
1215
|
});
|
|
965
1216
|
} catch (error) {
|
|
966
|
-
spinner
|
|
967
|
-
|
|
1217
|
+
exitWithCommandError2(spinner, "Failed to fetch processes", error);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
async function getProcessXml(client, options) {
|
|
1221
|
+
const spinner = createSpinner(`Fetching BPMN XML for ${options.key}...`, options.format);
|
|
1222
|
+
try {
|
|
1223
|
+
const bpmClient = client.bpm;
|
|
1224
|
+
const result = await bpmClient.getProcessXml(options.key);
|
|
1225
|
+
if (result.error) {
|
|
1226
|
+
spinner.fail("Failed to fetch process XML");
|
|
1227
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1228
|
+
process.exit(1);
|
|
1229
|
+
}
|
|
1230
|
+
spinner.succeed("Process XML retrieved");
|
|
1231
|
+
renderOutput(result.data, {
|
|
1232
|
+
format: options.format,
|
|
1233
|
+
pretty: () => {
|
|
1234
|
+
console.log(chalk3__default.default.blue(`
|
|
1235
|
+
\u{1F4C4} BPMN XML: ${options.key}
|
|
1236
|
+
`));
|
|
1237
|
+
console.log(result.data?.bpmn20Xml || "");
|
|
1238
|
+
}
|
|
1239
|
+
});
|
|
1240
|
+
} catch (error) {
|
|
1241
|
+
exitWithCommandError2(spinner, "Failed to fetch process XML", error);
|
|
968
1242
|
}
|
|
969
1243
|
}
|
|
970
1244
|
async function startProcess(client, options) {
|
|
971
1245
|
const spinner = createSpinner(`Starting process: ${options.key}...`, options.format);
|
|
972
1246
|
try {
|
|
973
1247
|
const bpmClient = client.bpm;
|
|
974
|
-
const variables = options.variables
|
|
975
|
-
const result = await bpmClient.startProcess(
|
|
976
|
-
processKey: options.key,
|
|
977
|
-
variables
|
|
978
|
-
});
|
|
1248
|
+
const variables = loadOptionalJsonObjectInput2(options.variables, "process variables");
|
|
1249
|
+
const result = await bpmClient.startProcess(options.key, variables);
|
|
979
1250
|
if (result.error) {
|
|
980
1251
|
spinner.fail("Failed to start process");
|
|
981
|
-
console.error(
|
|
1252
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
982
1253
|
process.exit(1);
|
|
983
1254
|
}
|
|
984
1255
|
spinner.succeed("Process started");
|
|
985
1256
|
renderOutput(result.data, {
|
|
986
1257
|
format: options.format,
|
|
987
1258
|
pretty: () => {
|
|
988
|
-
console.log(
|
|
989
|
-
console.log(` ${
|
|
990
|
-
console.log(` ${
|
|
991
|
-
console.log(` ${
|
|
992
|
-
console.log(` ${
|
|
1259
|
+
console.log(chalk3__default.default.green("\nProcess Instance:"));
|
|
1260
|
+
console.log(` ${chalk3__default.default.bold("ID:")} ${result.data?.id}`);
|
|
1261
|
+
console.log(` ${chalk3__default.default.bold("Definition ID:")} ${result.data?.definitionId}`);
|
|
1262
|
+
console.log(` ${chalk3__default.default.bold("Business Key:")} ${result.data?.businessKey || "N/A"}`);
|
|
1263
|
+
console.log(` ${chalk3__default.default.bold("Status:")} ${result.data?.suspended ? "Suspended" : "Active"}`);
|
|
993
1264
|
}
|
|
994
1265
|
});
|
|
995
1266
|
} catch (error) {
|
|
996
|
-
spinner
|
|
997
|
-
throw error;
|
|
1267
|
+
exitWithCommandError2(spinner, "Failed to start process", error);
|
|
998
1268
|
}
|
|
999
1269
|
}
|
|
1000
|
-
async function
|
|
1001
|
-
const spinner = createSpinner("Fetching
|
|
1270
|
+
async function listProcessInstances(client, options = {}) {
|
|
1271
|
+
const spinner = createSpinner("Fetching process instances...", options.format);
|
|
1002
1272
|
try {
|
|
1003
1273
|
const bpmClient = client.bpm;
|
|
1004
|
-
const params =
|
|
1005
|
-
|
|
1006
|
-
params.assignee = options.assignee;
|
|
1007
|
-
}
|
|
1008
|
-
const result = await bpmClient.getMyTasks(params);
|
|
1274
|
+
const params = buildProcessInstanceQueryParams(options);
|
|
1275
|
+
const result = await bpmClient.getProcessInstances(params);
|
|
1009
1276
|
if (result.error) {
|
|
1010
|
-
spinner.fail("Failed to fetch
|
|
1011
|
-
console.error(
|
|
1277
|
+
spinner.fail("Failed to fetch process instances");
|
|
1278
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1012
1279
|
process.exit(1);
|
|
1013
1280
|
}
|
|
1014
|
-
spinner.succeed(`Found ${result.data?.length || 0}
|
|
1015
|
-
const
|
|
1016
|
-
renderOutput(
|
|
1281
|
+
spinner.succeed(`Found ${result.data?.length || 0} process instances`);
|
|
1282
|
+
const instances = result.data || [];
|
|
1283
|
+
renderOutput(instances, {
|
|
1017
1284
|
format: options.format,
|
|
1018
1285
|
pretty: () => {
|
|
1019
|
-
console.log(
|
|
1020
|
-
for (const
|
|
1021
|
-
console.log(` ${
|
|
1022
|
-
console.log(` ${
|
|
1023
|
-
console.log(` ${
|
|
1024
|
-
console.log(
|
|
1286
|
+
console.log(chalk3__default.default.blue("\n\u{1F504} Process Instances\n"));
|
|
1287
|
+
for (const instance of instances) {
|
|
1288
|
+
console.log(` ${chalk3__default.default.green("\u2022")} ${chalk3__default.default.bold(instance.id)}`);
|
|
1289
|
+
console.log(` ${chalk3__default.default.gray("Definition:")} ${instance.definitionId || "N/A"}`);
|
|
1290
|
+
console.log(` ${chalk3__default.default.gray("Business Key:")} ${instance.businessKey || "N/A"}`);
|
|
1291
|
+
console.log(
|
|
1292
|
+
` ${chalk3__default.default.gray("Status:")} ${instance.ended ? "Ended" : instance.suspended ? "Suspended" : "Active"}`
|
|
1293
|
+
);
|
|
1025
1294
|
console.log();
|
|
1026
1295
|
}
|
|
1027
1296
|
}
|
|
1028
1297
|
});
|
|
1029
1298
|
} catch (error) {
|
|
1030
|
-
spinner
|
|
1031
|
-
throw error;
|
|
1299
|
+
exitWithCommandError2(spinner, "Failed to fetch process instances", error);
|
|
1032
1300
|
}
|
|
1033
1301
|
}
|
|
1034
|
-
async function
|
|
1035
|
-
const spinner = createSpinner(
|
|
1302
|
+
async function getProcessInstance(client, options) {
|
|
1303
|
+
const spinner = createSpinner("Fetching process instance...", options.format);
|
|
1036
1304
|
try {
|
|
1037
1305
|
const bpmClient = client.bpm;
|
|
1038
|
-
const
|
|
1039
|
-
const result = await bpmClient.completeTask(options.id, { variables });
|
|
1306
|
+
const result = await bpmClient.getProcessInstance(options.id);
|
|
1040
1307
|
if (result.error) {
|
|
1041
|
-
spinner.fail("Failed to
|
|
1042
|
-
console.error(
|
|
1308
|
+
spinner.fail("Failed to fetch process instance");
|
|
1309
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1043
1310
|
process.exit(1);
|
|
1044
1311
|
}
|
|
1045
|
-
spinner.succeed("
|
|
1312
|
+
spinner.succeed("Process instance retrieved");
|
|
1313
|
+
renderOutput(result.data, {
|
|
1314
|
+
format: options.format,
|
|
1315
|
+
pretty: () => {
|
|
1316
|
+
console.log(chalk3__default.default.blue("\n\u{1F4CA} Process Instance\n"));
|
|
1317
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
1318
|
+
}
|
|
1319
|
+
});
|
|
1320
|
+
} catch (error) {
|
|
1321
|
+
exitWithCommandError2(spinner, "Failed to fetch process instance", error);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
async function getActivityInstanceTree(client, options) {
|
|
1325
|
+
const spinner = createSpinner("Fetching activity instance tree...", options.format);
|
|
1326
|
+
try {
|
|
1327
|
+
const bpmClient = client.bpm;
|
|
1328
|
+
const result = await bpmClient.getActivityInstanceTree(options.id);
|
|
1329
|
+
if (result.error) {
|
|
1330
|
+
spinner.fail("Failed to fetch activity instance tree");
|
|
1331
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1332
|
+
process.exit(1);
|
|
1333
|
+
}
|
|
1334
|
+
spinner.succeed("Activity instance tree retrieved");
|
|
1335
|
+
renderOutput(result.data, {
|
|
1336
|
+
format: options.format,
|
|
1337
|
+
pretty: () => {
|
|
1338
|
+
console.log(chalk3__default.default.blue("\n\u{1F333} Activity Instance Tree\n"));
|
|
1339
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
1340
|
+
}
|
|
1341
|
+
});
|
|
1342
|
+
} catch (error) {
|
|
1343
|
+
exitWithCommandError2(spinner, "Failed to fetch activity instance tree", error);
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
async function getActiveActivities(client, options) {
|
|
1347
|
+
const spinner = createSpinner("Fetching active activities...", options.format);
|
|
1348
|
+
try {
|
|
1349
|
+
const bpmClient = client.bpm;
|
|
1350
|
+
const result = await bpmClient.getActiveActivities(options.id);
|
|
1351
|
+
if (result.error) {
|
|
1352
|
+
spinner.fail("Failed to fetch active activities");
|
|
1353
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1354
|
+
process.exit(1);
|
|
1355
|
+
}
|
|
1356
|
+
const activities = Array.isArray(result.data) ? result.data : [];
|
|
1357
|
+
spinner.succeed(`Found ${activities.length} active activities`);
|
|
1358
|
+
renderOutput(result.data, {
|
|
1359
|
+
format: options.format,
|
|
1360
|
+
pretty: () => {
|
|
1361
|
+
console.log(chalk3__default.default.blue("\n\u26A1 Active Activities\n"));
|
|
1362
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
1363
|
+
}
|
|
1364
|
+
});
|
|
1365
|
+
} catch (error) {
|
|
1366
|
+
exitWithCommandError2(spinner, "Failed to fetch active activities", error);
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
async function getRuntimeVariables(client, options) {
|
|
1370
|
+
const spinner = createSpinner("Fetching runtime variables...", options.format);
|
|
1371
|
+
try {
|
|
1372
|
+
const bpmClient = client.bpm;
|
|
1373
|
+
const result = await bpmClient.getRuntimeVariables(options.id);
|
|
1374
|
+
if (result.error) {
|
|
1375
|
+
spinner.fail("Failed to fetch runtime variables");
|
|
1376
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1377
|
+
process.exit(1);
|
|
1378
|
+
}
|
|
1379
|
+
spinner.succeed("Runtime variables retrieved");
|
|
1380
|
+
renderOutput(result.data, {
|
|
1381
|
+
format: options.format,
|
|
1382
|
+
pretty: () => {
|
|
1383
|
+
console.log(chalk3__default.default.blue("\n\u{1F9EE} Runtime Variables\n"));
|
|
1384
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
1385
|
+
}
|
|
1386
|
+
});
|
|
1387
|
+
} catch (error) {
|
|
1388
|
+
exitWithCommandError2(spinner, "Failed to fetch runtime variables", error);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
async function getProcessVariables(client, options) {
|
|
1392
|
+
const spinner = createSpinner("Fetching process variables...", options.format);
|
|
1393
|
+
try {
|
|
1394
|
+
const bpmClient = client.bpm;
|
|
1395
|
+
const result = await bpmClient.getProcessVariables({
|
|
1396
|
+
processInstanceId: options.id,
|
|
1397
|
+
variableName: options.name
|
|
1398
|
+
});
|
|
1399
|
+
if (result.error) {
|
|
1400
|
+
spinner.fail("Failed to fetch process variables");
|
|
1401
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1402
|
+
process.exit(1);
|
|
1403
|
+
}
|
|
1404
|
+
spinner.succeed(`Found ${result.data?.length || 0} variables`);
|
|
1405
|
+
renderOutput(result.data || [], {
|
|
1406
|
+
format: options.format,
|
|
1407
|
+
pretty: () => {
|
|
1408
|
+
console.log(chalk3__default.default.blue("\n\u{1F9FE} Process Variables\n"));
|
|
1409
|
+
console.log(JSON.stringify(result.data || [], null, 2));
|
|
1410
|
+
}
|
|
1411
|
+
});
|
|
1412
|
+
} catch (error) {
|
|
1413
|
+
exitWithCommandError2(spinner, "Failed to fetch process variables", error);
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
async function deleteProcessInstance(client, options) {
|
|
1417
|
+
const spinner = createSpinner(`Deleting process instance: ${options.id}...`, options.format);
|
|
1418
|
+
try {
|
|
1419
|
+
const bpmClient = client.bpm;
|
|
1420
|
+
const result = await bpmClient.deleteProcessInstance(options.id, {
|
|
1421
|
+
skipCustomListeners: options.skipCustomListeners
|
|
1422
|
+
});
|
|
1423
|
+
if (result.error) {
|
|
1424
|
+
spinner.fail("Failed to delete process instance");
|
|
1425
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1426
|
+
process.exit(1);
|
|
1427
|
+
}
|
|
1428
|
+
spinner.succeed("Process instance deleted");
|
|
1046
1429
|
renderOutput(
|
|
1047
1430
|
{
|
|
1048
1431
|
id: options.id,
|
|
1049
|
-
|
|
1432
|
+
deleted: true,
|
|
1433
|
+
skipCustomListeners: !!options.skipCustomListeners
|
|
1050
1434
|
},
|
|
1051
1435
|
{
|
|
1052
1436
|
format: options.format,
|
|
1053
1437
|
pretty: () => {
|
|
1054
|
-
console.log(
|
|
1438
|
+
console.log(chalk3__default.default.green(`Deleted process instance: ${options.id}`));
|
|
1055
1439
|
}
|
|
1056
1440
|
}
|
|
1057
1441
|
);
|
|
1058
1442
|
} catch (error) {
|
|
1059
|
-
spinner
|
|
1060
|
-
|
|
1443
|
+
exitWithCommandError2(spinner, "Failed to delete process instance", error);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
async function suspendProcessInstance(client, options) {
|
|
1447
|
+
const spinner = createSpinner(`Suspending process instance: ${options.id}...`, options.format);
|
|
1448
|
+
try {
|
|
1449
|
+
const bpmClient = client.bpm;
|
|
1450
|
+
const result = await bpmClient.suspendProcessInstance(options.id);
|
|
1451
|
+
if (result.error) {
|
|
1452
|
+
spinner.fail("Failed to suspend process instance");
|
|
1453
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1454
|
+
process.exit(1);
|
|
1455
|
+
}
|
|
1456
|
+
spinner.succeed("Process instance suspended");
|
|
1457
|
+
renderOutput(
|
|
1458
|
+
{
|
|
1459
|
+
id: options.id,
|
|
1460
|
+
suspended: true
|
|
1461
|
+
},
|
|
1462
|
+
{
|
|
1463
|
+
format: options.format,
|
|
1464
|
+
pretty: () => {
|
|
1465
|
+
console.log(chalk3__default.default.green(`Suspended process instance: ${options.id}`));
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
);
|
|
1469
|
+
} catch (error) {
|
|
1470
|
+
exitWithCommandError2(spinner, "Failed to suspend process instance", error);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
async function activateProcessInstance(client, options) {
|
|
1474
|
+
const spinner = createSpinner(`Activating process instance: ${options.id}...`, options.format);
|
|
1475
|
+
try {
|
|
1476
|
+
const bpmClient = client.bpm;
|
|
1477
|
+
const result = await bpmClient.activateProcessInstance(options.id);
|
|
1478
|
+
if (result.error) {
|
|
1479
|
+
spinner.fail("Failed to activate process instance");
|
|
1480
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1481
|
+
process.exit(1);
|
|
1482
|
+
}
|
|
1483
|
+
spinner.succeed("Process instance activated");
|
|
1484
|
+
renderOutput(
|
|
1485
|
+
{
|
|
1486
|
+
id: options.id,
|
|
1487
|
+
activated: true
|
|
1488
|
+
},
|
|
1489
|
+
{
|
|
1490
|
+
format: options.format,
|
|
1491
|
+
pretty: () => {
|
|
1492
|
+
console.log(chalk3__default.default.green(`Activated process instance: ${options.id}`));
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
);
|
|
1496
|
+
} catch (error) {
|
|
1497
|
+
exitWithCommandError2(spinner, "Failed to activate process instance", error);
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
async function modifyProcessInstance(client, options) {
|
|
1501
|
+
const spinner = createSpinner(`Modifying process instance: ${options.id}...`, options.format);
|
|
1502
|
+
try {
|
|
1503
|
+
const bpmClient = client.bpm;
|
|
1504
|
+
const modification = await loadJsonObjectInput2(
|
|
1505
|
+
options.modification,
|
|
1506
|
+
"process modification",
|
|
1507
|
+
"Enter process modification JSON:"
|
|
1508
|
+
);
|
|
1509
|
+
const result = await bpmClient.modifyProcessInstance(options.id, modification);
|
|
1510
|
+
if (result.error) {
|
|
1511
|
+
spinner.fail("Failed to modify process instance");
|
|
1512
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1513
|
+
process.exit(1);
|
|
1514
|
+
}
|
|
1515
|
+
spinner.succeed("Process instance modified");
|
|
1516
|
+
renderOutput(
|
|
1517
|
+
{
|
|
1518
|
+
id: options.id,
|
|
1519
|
+
modified: true,
|
|
1520
|
+
modification
|
|
1521
|
+
},
|
|
1522
|
+
{
|
|
1523
|
+
format: options.format,
|
|
1524
|
+
pretty: () => {
|
|
1525
|
+
console.log(chalk3__default.default.green(`Modified process instance: ${options.id}`));
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
);
|
|
1529
|
+
} catch (error) {
|
|
1530
|
+
exitWithCommandError2(spinner, "Failed to modify process instance", error);
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
async function listTasks(client, options) {
|
|
1534
|
+
const spinner = createSpinner("Fetching tasks...", options.format);
|
|
1535
|
+
try {
|
|
1536
|
+
const bpmClient = client.bpm;
|
|
1537
|
+
const params = buildTaskQueryParams(options);
|
|
1538
|
+
const result = await bpmClient.getTasks(params);
|
|
1539
|
+
if (result.error) {
|
|
1540
|
+
spinner.fail("Failed to fetch tasks");
|
|
1541
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1542
|
+
process.exit(1);
|
|
1543
|
+
}
|
|
1544
|
+
spinner.succeed(`Found ${result.data?.length || 0} tasks`);
|
|
1545
|
+
const tasks = result.data || [];
|
|
1546
|
+
renderOutput(tasks, {
|
|
1547
|
+
format: options.format,
|
|
1548
|
+
pretty: () => {
|
|
1549
|
+
console.log(chalk3__default.default.blue("\n\u{1F4DD} Tasks\n"));
|
|
1550
|
+
for (const task of tasks) {
|
|
1551
|
+
console.log(` ${chalk3__default.default.green("\u2022")} ${chalk3__default.default.bold(task.name || task.id)}`);
|
|
1552
|
+
console.log(` ${chalk3__default.default.gray("ID:")} ${task.id}`);
|
|
1553
|
+
console.log(` ${chalk3__default.default.gray("Assignee:")} ${task.assignee || "Unassigned"}`);
|
|
1554
|
+
console.log(` ${chalk3__default.default.gray("Process Instance:")} ${task.processInstanceId || "N/A"}`);
|
|
1555
|
+
console.log(` ${chalk3__default.default.gray("Created:")} ${task.created || "N/A"}`);
|
|
1556
|
+
console.log();
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
});
|
|
1560
|
+
} catch (error) {
|
|
1561
|
+
exitWithCommandError2(spinner, "Failed to fetch tasks", error);
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
async function getTask(client, options) {
|
|
1565
|
+
const spinner = createSpinner(`Fetching task: ${options.id}...`, options.format);
|
|
1566
|
+
try {
|
|
1567
|
+
const bpmClient = client.bpm;
|
|
1568
|
+
const result = await bpmClient.getTask(options.id);
|
|
1569
|
+
if (result.error) {
|
|
1570
|
+
spinner.fail("Failed to fetch task");
|
|
1571
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1572
|
+
process.exit(1);
|
|
1573
|
+
}
|
|
1574
|
+
spinner.succeed("Task retrieved");
|
|
1575
|
+
renderOutput(result.data, {
|
|
1576
|
+
format: options.format,
|
|
1577
|
+
pretty: () => {
|
|
1578
|
+
console.log(chalk3__default.default.blue("\n\u{1F4DD} Task\n"));
|
|
1579
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
1580
|
+
}
|
|
1581
|
+
});
|
|
1582
|
+
} catch (error) {
|
|
1583
|
+
exitWithCommandError2(spinner, "Failed to fetch task", error);
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
async function getTaskCount(client, options) {
|
|
1587
|
+
const spinner = createSpinner("Fetching task count...", options.format);
|
|
1588
|
+
try {
|
|
1589
|
+
const bpmClient = client.bpm;
|
|
1590
|
+
const params = buildTaskQueryParams(options);
|
|
1591
|
+
const result = await bpmClient.getTaskCount(params);
|
|
1592
|
+
if (result.error) {
|
|
1593
|
+
spinner.fail("Failed to fetch task count");
|
|
1594
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1595
|
+
process.exit(1);
|
|
1596
|
+
}
|
|
1597
|
+
spinner.succeed("Task count retrieved");
|
|
1598
|
+
renderOutput(result.data, {
|
|
1599
|
+
format: options.format,
|
|
1600
|
+
pretty: () => {
|
|
1601
|
+
console.log(chalk3__default.default.green(`Task count: ${result.data?.count ?? 0}`));
|
|
1602
|
+
}
|
|
1603
|
+
});
|
|
1604
|
+
} catch (error) {
|
|
1605
|
+
exitWithCommandError2(spinner, "Failed to fetch task count", error);
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
async function completeTask(client, options) {
|
|
1609
|
+
const spinner = createSpinner(`Completing task: ${options.id}...`, options.format);
|
|
1610
|
+
try {
|
|
1611
|
+
const bpmClient = client.bpm;
|
|
1612
|
+
const variables = loadOptionalJsonObjectInput2(options.variables, "task variables");
|
|
1613
|
+
const result = await bpmClient.completeTask(options.id, variables);
|
|
1614
|
+
if (result.error) {
|
|
1615
|
+
spinner.fail("Failed to complete task");
|
|
1616
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1617
|
+
process.exit(1);
|
|
1618
|
+
}
|
|
1619
|
+
spinner.succeed("Task completed");
|
|
1620
|
+
renderOutput(
|
|
1621
|
+
{
|
|
1622
|
+
id: options.id,
|
|
1623
|
+
completed: true
|
|
1624
|
+
},
|
|
1625
|
+
{
|
|
1626
|
+
format: options.format,
|
|
1627
|
+
pretty: () => {
|
|
1628
|
+
console.log(chalk3__default.default.green(`Completed task: ${options.id}`));
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
);
|
|
1632
|
+
} catch (error) {
|
|
1633
|
+
exitWithCommandError2(spinner, "Failed to complete task", error);
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
async function delegateTask(client, options) {
|
|
1637
|
+
const spinner = createSpinner(`Delegating task: ${options.id}...`, options.format);
|
|
1638
|
+
try {
|
|
1639
|
+
const bpmClient = client.bpm;
|
|
1640
|
+
const result = await bpmClient.delegateTask(options.id, options.userId);
|
|
1641
|
+
if (result.error) {
|
|
1642
|
+
spinner.fail("Failed to delegate task");
|
|
1643
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1644
|
+
process.exit(1);
|
|
1645
|
+
}
|
|
1646
|
+
spinner.succeed("Task delegated");
|
|
1647
|
+
renderOutput(
|
|
1648
|
+
{
|
|
1649
|
+
id: options.id,
|
|
1650
|
+
userId: options.userId,
|
|
1651
|
+
delegated: true
|
|
1652
|
+
},
|
|
1653
|
+
{
|
|
1654
|
+
format: options.format,
|
|
1655
|
+
pretty: () => {
|
|
1656
|
+
console.log(chalk3__default.default.green(`Delegated task ${options.id} to ${options.userId}`));
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
);
|
|
1660
|
+
} catch (error) {
|
|
1661
|
+
exitWithCommandError2(spinner, "Failed to delegate task", error);
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
async function getTaskForm(client, options) {
|
|
1665
|
+
const spinner = createSpinner("Fetching task form...", options.format);
|
|
1666
|
+
try {
|
|
1667
|
+
const bpmClient = client.bpm;
|
|
1668
|
+
const result = await bpmClient.getTaskForm(options.id);
|
|
1669
|
+
if (result.error) {
|
|
1670
|
+
spinner.fail("Failed to fetch task form");
|
|
1671
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1672
|
+
process.exit(1);
|
|
1673
|
+
}
|
|
1674
|
+
spinner.succeed("Task form retrieved");
|
|
1675
|
+
renderOutput(result.data, {
|
|
1676
|
+
format: options.format,
|
|
1677
|
+
pretty: () => {
|
|
1678
|
+
console.log(chalk3__default.default.blue("\n\u{1F9E9} Task Form\n"));
|
|
1679
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
1680
|
+
}
|
|
1681
|
+
});
|
|
1682
|
+
} catch (error) {
|
|
1683
|
+
exitWithCommandError2(spinner, "Failed to fetch task form", error);
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
async function getTaskFormSchema(client, options) {
|
|
1687
|
+
const spinner = createSpinner("Fetching task form schema...", options.format);
|
|
1688
|
+
try {
|
|
1689
|
+
const bpmClient = client.bpm;
|
|
1690
|
+
const result = await bpmClient.getTaskFormSchema(
|
|
1691
|
+
options.id,
|
|
1692
|
+
options.redirect ? { redirect: options.redirect } : void 0
|
|
1693
|
+
);
|
|
1694
|
+
if (result.error) {
|
|
1695
|
+
const diagnostic = await diagnoseTaskFormSchemaError(
|
|
1696
|
+
bpmClient,
|
|
1697
|
+
options.id,
|
|
1698
|
+
extractClientErrorMessage(result.error)
|
|
1699
|
+
);
|
|
1700
|
+
exitWithClientError(spinner, "Failed to fetch task form schema", result.error, diagnostic);
|
|
1701
|
+
}
|
|
1702
|
+
spinner.succeed("Task form schema retrieved");
|
|
1703
|
+
renderOutput(result.data, {
|
|
1704
|
+
format: options.format,
|
|
1705
|
+
pretty: () => {
|
|
1706
|
+
console.log(chalk3__default.default.blue("\n\u{1F9E9} Task Form Schema\n"));
|
|
1707
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
1708
|
+
}
|
|
1709
|
+
});
|
|
1710
|
+
} catch (error) {
|
|
1711
|
+
exitWithCommandError2(spinner, "Failed to fetch task form schema", error);
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
async function getTaskFormVariables(client, options) {
|
|
1715
|
+
const spinner = createSpinner("Fetching task form variables...", options.format);
|
|
1716
|
+
try {
|
|
1717
|
+
const bpmClient = client.bpm;
|
|
1718
|
+
const result = await bpmClient.getTaskFormVariables(options.id);
|
|
1719
|
+
if (result.error) {
|
|
1720
|
+
spinner.fail("Failed to fetch task form variables");
|
|
1721
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1722
|
+
process.exit(1);
|
|
1723
|
+
}
|
|
1724
|
+
spinner.succeed("Task form variables retrieved");
|
|
1725
|
+
renderOutput(result.data, {
|
|
1726
|
+
format: options.format,
|
|
1727
|
+
pretty: () => {
|
|
1728
|
+
console.log(chalk3__default.default.blue("\n\u{1F9EE} Task Form Variables\n"));
|
|
1729
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
1730
|
+
}
|
|
1731
|
+
});
|
|
1732
|
+
} catch (error) {
|
|
1733
|
+
exitWithCommandError2(spinner, "Failed to fetch task form variables", error);
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
async function getTaskRenderedForm(client, options) {
|
|
1737
|
+
const spinner = createSpinner("Fetching rendered task form...", options.format);
|
|
1738
|
+
try {
|
|
1739
|
+
const bpmClient = client.bpm;
|
|
1740
|
+
const result = await bpmClient.getTaskRenderedForm(options.id);
|
|
1741
|
+
if (result.error) {
|
|
1742
|
+
spinner.fail("Failed to fetch rendered task form");
|
|
1743
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1744
|
+
process.exit(1);
|
|
1745
|
+
}
|
|
1746
|
+
spinner.succeed("Rendered task form retrieved");
|
|
1747
|
+
renderOutput(result.data, {
|
|
1748
|
+
format: options.format,
|
|
1749
|
+
pretty: () => {
|
|
1750
|
+
console.log(chalk3__default.default.blue("\n\u{1F9FE} Rendered Task Form\n"));
|
|
1751
|
+
console.log(result.data || "");
|
|
1752
|
+
}
|
|
1753
|
+
});
|
|
1754
|
+
} catch (error) {
|
|
1755
|
+
exitWithCommandError2(spinner, "Failed to fetch rendered task form", error);
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
async function getTaskDeployedForm(client, options) {
|
|
1759
|
+
const spinner = createSpinner("Fetching deployed task form...", options.format);
|
|
1760
|
+
try {
|
|
1761
|
+
const bpmClient = client.bpm;
|
|
1762
|
+
const result = await bpmClient.getTaskDeployedForm(options.id);
|
|
1763
|
+
if (result.error) {
|
|
1764
|
+
spinner.fail("Failed to fetch deployed task form");
|
|
1765
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1766
|
+
process.exit(1);
|
|
1767
|
+
}
|
|
1768
|
+
spinner.succeed("Deployed task form retrieved");
|
|
1769
|
+
renderOutput(result.data, {
|
|
1770
|
+
format: options.format,
|
|
1771
|
+
pretty: () => {
|
|
1772
|
+
console.log(chalk3__default.default.blue("\n\u{1F9FE} Deployed Task Form\n"));
|
|
1773
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
1774
|
+
}
|
|
1775
|
+
});
|
|
1776
|
+
} catch (error) {
|
|
1777
|
+
exitWithCommandError2(spinner, "Failed to fetch deployed task form", error);
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
async function getStartFormInfo(client, options) {
|
|
1781
|
+
const spinner = createSpinner("Fetching start form info...", options.format);
|
|
1782
|
+
try {
|
|
1783
|
+
const bpmClient = client.bpm;
|
|
1784
|
+
const result = await bpmClient.getStartFormInfo(options.key);
|
|
1785
|
+
if (result.error) {
|
|
1786
|
+
const diagnostic = await diagnoseStartFormError(
|
|
1787
|
+
bpmClient,
|
|
1788
|
+
options.key,
|
|
1789
|
+
extractClientErrorMessage(result.error)
|
|
1790
|
+
);
|
|
1791
|
+
exitWithClientError(spinner, "Failed to fetch start form info", result.error, diagnostic);
|
|
1792
|
+
}
|
|
1793
|
+
spinner.succeed("Start form info retrieved");
|
|
1794
|
+
renderOutput(result.data, {
|
|
1795
|
+
format: options.format,
|
|
1796
|
+
pretty: () => {
|
|
1797
|
+
console.log(chalk3__default.default.blue("\n\u{1F680} Start Form Info\n"));
|
|
1798
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
1799
|
+
}
|
|
1800
|
+
});
|
|
1801
|
+
} catch (error) {
|
|
1802
|
+
exitWithCommandError2(spinner, "Failed to fetch start form info", error);
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
async function getStartFormVariables(client, options) {
|
|
1806
|
+
const spinner = createSpinner("Fetching start form variables...", options.format);
|
|
1807
|
+
try {
|
|
1808
|
+
const bpmClient = client.bpm;
|
|
1809
|
+
const result = await bpmClient.getStartFormVariables(options.key);
|
|
1810
|
+
if (result.error) {
|
|
1811
|
+
const diagnostic = await diagnoseStartFormError(
|
|
1812
|
+
bpmClient,
|
|
1813
|
+
options.key,
|
|
1814
|
+
extractClientErrorMessage(result.error)
|
|
1815
|
+
);
|
|
1816
|
+
exitWithClientError(spinner, "Failed to fetch start form variables", result.error, diagnostic);
|
|
1817
|
+
}
|
|
1818
|
+
spinner.succeed("Start form variables retrieved");
|
|
1819
|
+
renderOutput(result.data, {
|
|
1820
|
+
format: options.format,
|
|
1821
|
+
pretty: () => {
|
|
1822
|
+
console.log(chalk3__default.default.blue("\n\u{1F680} Start Form Variables\n"));
|
|
1823
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
1824
|
+
}
|
|
1825
|
+
});
|
|
1826
|
+
} catch (error) {
|
|
1827
|
+
exitWithCommandError2(spinner, "Failed to fetch start form variables", error);
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
async function getDeployedStartForm(client, options) {
|
|
1831
|
+
const spinner = createSpinner("Fetching deployed start form...", options.format);
|
|
1832
|
+
try {
|
|
1833
|
+
const bpmClient = client.bpm;
|
|
1834
|
+
const result = await bpmClient.getDeployedStartForm(options.key);
|
|
1835
|
+
if (result.error) {
|
|
1836
|
+
const diagnostic = await diagnoseStartFormError(
|
|
1837
|
+
bpmClient,
|
|
1838
|
+
options.key,
|
|
1839
|
+
extractClientErrorMessage(result.error)
|
|
1840
|
+
);
|
|
1841
|
+
exitWithClientError(spinner, "Failed to fetch deployed start form", result.error, diagnostic);
|
|
1842
|
+
}
|
|
1843
|
+
spinner.succeed("Deployed start form retrieved");
|
|
1844
|
+
renderOutput(result.data, {
|
|
1845
|
+
format: options.format,
|
|
1846
|
+
pretty: () => {
|
|
1847
|
+
console.log(chalk3__default.default.blue("\n\u{1F680} Deployed Start Form\n"));
|
|
1848
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
1849
|
+
}
|
|
1850
|
+
});
|
|
1851
|
+
} catch (error) {
|
|
1852
|
+
exitWithCommandError2(spinner, "Failed to fetch deployed start form", error);
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
async function listHistoryTasks(client, options = {}) {
|
|
1856
|
+
const spinner = createSpinner("Fetching history tasks...", options.format);
|
|
1857
|
+
try {
|
|
1858
|
+
const bpmClient = client.bpm;
|
|
1859
|
+
const params = buildHistoryTaskQueryParams(options);
|
|
1860
|
+
const result = await bpmClient.getHistoryTasks(params);
|
|
1861
|
+
if (result.error) {
|
|
1862
|
+
spinner.fail("Failed to fetch history tasks");
|
|
1863
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1864
|
+
process.exit(1);
|
|
1865
|
+
}
|
|
1866
|
+
const tasks = result.data || [];
|
|
1867
|
+
spinner.succeed(`Found ${tasks.length} history tasks`);
|
|
1868
|
+
renderOutput(tasks, {
|
|
1869
|
+
format: options.format,
|
|
1870
|
+
pretty: () => {
|
|
1871
|
+
console.log(chalk3__default.default.blue("\n\u{1F4DA} History Tasks\n"));
|
|
1872
|
+
console.log(JSON.stringify(tasks, null, 2));
|
|
1873
|
+
}
|
|
1874
|
+
});
|
|
1875
|
+
} catch (error) {
|
|
1876
|
+
exitWithCommandError2(spinner, "Failed to fetch history tasks", error);
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
async function getHistoryTaskCount(client, options = {}) {
|
|
1880
|
+
const spinner = createSpinner("Fetching history task count...", options.format);
|
|
1881
|
+
try {
|
|
1882
|
+
const bpmClient = client.bpm;
|
|
1883
|
+
const params = buildHistoryTaskQueryParams(options);
|
|
1884
|
+
const result = await bpmClient.getHistoryTaskCount(params);
|
|
1885
|
+
if (result.error) {
|
|
1886
|
+
spinner.fail("Failed to fetch history task count");
|
|
1887
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1888
|
+
process.exit(1);
|
|
1889
|
+
}
|
|
1890
|
+
spinner.succeed("History task count retrieved");
|
|
1891
|
+
renderOutput(result.data, {
|
|
1892
|
+
format: options.format,
|
|
1893
|
+
pretty: () => {
|
|
1894
|
+
console.log(chalk3__default.default.green(`History task count: ${result.data?.count ?? 0}`));
|
|
1895
|
+
}
|
|
1896
|
+
});
|
|
1897
|
+
} catch (error) {
|
|
1898
|
+
exitWithCommandError2(spinner, "Failed to fetch history task count", error);
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
async function listHistoryProcessInstances(client, options = {}) {
|
|
1902
|
+
const spinner = createSpinner("Fetching history process instances...", options.format);
|
|
1903
|
+
try {
|
|
1904
|
+
const bpmClient = client.bpm;
|
|
1905
|
+
const params = buildHistoryProcessInstanceQueryParams(options);
|
|
1906
|
+
const result = await bpmClient.getHistoryProcessInstances(params);
|
|
1907
|
+
if (result.error) {
|
|
1908
|
+
spinner.fail("Failed to fetch history process instances");
|
|
1909
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1910
|
+
process.exit(1);
|
|
1911
|
+
}
|
|
1912
|
+
const instances = result.data || [];
|
|
1913
|
+
spinner.succeed(`Found ${instances.length} history process instances`);
|
|
1914
|
+
renderOutput(instances, {
|
|
1915
|
+
format: options.format,
|
|
1916
|
+
pretty: () => {
|
|
1917
|
+
console.log(chalk3__default.default.blue("\n\u{1F4DA} History Process Instances\n"));
|
|
1918
|
+
console.log(JSON.stringify(instances, null, 2));
|
|
1919
|
+
}
|
|
1920
|
+
});
|
|
1921
|
+
} catch (error) {
|
|
1922
|
+
exitWithCommandError2(spinner, "Failed to fetch history process instances", error);
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
async function getHistoryProcessInstanceCount(client, options = {}) {
|
|
1926
|
+
const spinner = createSpinner("Fetching history process instance count...", options.format);
|
|
1927
|
+
try {
|
|
1928
|
+
const bpmClient = client.bpm;
|
|
1929
|
+
const params = buildHistoryProcessInstanceQueryParams(options);
|
|
1930
|
+
const result = await bpmClient.getHistoryProcessInstanceCount(params);
|
|
1931
|
+
if (result.error) {
|
|
1932
|
+
spinner.fail("Failed to fetch history process instance count");
|
|
1933
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1934
|
+
process.exit(1);
|
|
1935
|
+
}
|
|
1936
|
+
spinner.succeed("History process instance count retrieved");
|
|
1937
|
+
renderOutput(result.data, {
|
|
1938
|
+
format: options.format,
|
|
1939
|
+
pretty: () => {
|
|
1940
|
+
console.log(chalk3__default.default.green(`History process instance count: ${result.data?.count ?? 0}`));
|
|
1941
|
+
}
|
|
1942
|
+
});
|
|
1943
|
+
} catch (error) {
|
|
1944
|
+
exitWithCommandError2(spinner, "Failed to fetch history process instance count", error);
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
async function getHistoryProcessInstance(client, options) {
|
|
1948
|
+
const spinner = createSpinner("Fetching history process instance...", options.format);
|
|
1949
|
+
try {
|
|
1950
|
+
const bpmClient = client.bpm;
|
|
1951
|
+
const result = await bpmClient.getHistoryProcessInstance(options.id);
|
|
1952
|
+
if (result.error) {
|
|
1953
|
+
spinner.fail("Failed to fetch history process instance");
|
|
1954
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1955
|
+
process.exit(1);
|
|
1956
|
+
}
|
|
1957
|
+
spinner.succeed("History process instance retrieved");
|
|
1958
|
+
renderOutput(result.data, {
|
|
1959
|
+
format: options.format,
|
|
1960
|
+
pretty: () => {
|
|
1961
|
+
console.log(chalk3__default.default.blue("\n\u{1F4DA} History Process Instance\n"));
|
|
1962
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
1963
|
+
}
|
|
1964
|
+
});
|
|
1965
|
+
} catch (error) {
|
|
1966
|
+
exitWithCommandError2(spinner, "Failed to fetch history process instance", error);
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
async function listHistoryActivityInstances(client, options = {}) {
|
|
1970
|
+
const spinner = createSpinner("Fetching history activity instances...", options.format);
|
|
1971
|
+
try {
|
|
1972
|
+
const bpmClient = client.bpm;
|
|
1973
|
+
const params = buildHistoryActivityQueryParams(options);
|
|
1974
|
+
const result = await bpmClient.getHistoryActivityInstances(params);
|
|
1975
|
+
if (result.error) {
|
|
1976
|
+
spinner.fail("Failed to fetch history activity instances");
|
|
1977
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1978
|
+
process.exit(1);
|
|
1979
|
+
}
|
|
1980
|
+
const activities = result.data || [];
|
|
1981
|
+
spinner.succeed(`Found ${activities.length} history activity instances`);
|
|
1982
|
+
renderOutput(activities, {
|
|
1983
|
+
format: options.format,
|
|
1984
|
+
pretty: () => {
|
|
1985
|
+
console.log(chalk3__default.default.blue("\n\u{1F4DA} History Activity Instances\n"));
|
|
1986
|
+
console.log(JSON.stringify(activities, null, 2));
|
|
1987
|
+
}
|
|
1988
|
+
});
|
|
1989
|
+
} catch (error) {
|
|
1990
|
+
exitWithCommandError2(spinner, "Failed to fetch history activity instances", error);
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
async function listHistoryVariableInstances(client, options = {}) {
|
|
1994
|
+
const spinner = createSpinner("Fetching history variable instances...", options.format);
|
|
1995
|
+
try {
|
|
1996
|
+
const bpmClient = client.bpm;
|
|
1997
|
+
const params = buildHistoryVariableQueryParams(options);
|
|
1998
|
+
const result = await bpmClient.getHistoryVariableInstances(params);
|
|
1999
|
+
if (result.error) {
|
|
2000
|
+
spinner.fail("Failed to fetch history variable instances");
|
|
2001
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
2002
|
+
process.exit(1);
|
|
2003
|
+
}
|
|
2004
|
+
const variables = result.data || [];
|
|
2005
|
+
spinner.succeed(`Found ${variables.length} history variable instances`);
|
|
2006
|
+
renderOutput(variables, {
|
|
2007
|
+
format: options.format,
|
|
2008
|
+
pretty: () => {
|
|
2009
|
+
console.log(chalk3__default.default.blue("\n\u{1F4DA} History Variable Instances\n"));
|
|
2010
|
+
console.log(JSON.stringify(variables, null, 2));
|
|
2011
|
+
}
|
|
2012
|
+
});
|
|
2013
|
+
} catch (error) {
|
|
2014
|
+
exitWithCommandError2(spinner, "Failed to fetch history variable instances", error);
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
async function listUserOperationLogs(client, options = {}) {
|
|
2018
|
+
const spinner = createSpinner("Fetching user operation logs...", options.format);
|
|
2019
|
+
try {
|
|
2020
|
+
const bpmClient = client.bpm;
|
|
2021
|
+
const params = buildUserOperationLogQueryParams(options);
|
|
2022
|
+
const result = await bpmClient.getUserOperationLogs(params);
|
|
2023
|
+
if (result.error) {
|
|
2024
|
+
spinner.fail("Failed to fetch user operation logs");
|
|
2025
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
2026
|
+
process.exit(1);
|
|
2027
|
+
}
|
|
2028
|
+
const logs = result.data || [];
|
|
2029
|
+
spinner.succeed(`Found ${logs.length} user operation logs`);
|
|
2030
|
+
renderOutput(logs, {
|
|
2031
|
+
format: options.format,
|
|
2032
|
+
pretty: () => {
|
|
2033
|
+
console.log(chalk3__default.default.blue("\n\u{1F4DA} User Operation Logs\n"));
|
|
2034
|
+
console.log(JSON.stringify(logs, null, 2));
|
|
2035
|
+
}
|
|
2036
|
+
});
|
|
2037
|
+
} catch (error) {
|
|
2038
|
+
exitWithCommandError2(spinner, "Failed to fetch user operation logs", error);
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
async function deleteHistoryProcessInstance(client, options) {
|
|
2042
|
+
const spinner = createSpinner(`Deleting history process instance: ${options.id}...`, options.format);
|
|
2043
|
+
try {
|
|
2044
|
+
const bpmClient = client.bpm;
|
|
2045
|
+
const result = await bpmClient.deleteHistoryProcessInstance(options.id);
|
|
2046
|
+
if (result.error) {
|
|
2047
|
+
spinner.fail("Failed to delete history process instance");
|
|
2048
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
2049
|
+
process.exit(1);
|
|
2050
|
+
}
|
|
2051
|
+
spinner.succeed("History process instance deleted");
|
|
2052
|
+
renderOutput(
|
|
2053
|
+
{
|
|
2054
|
+
id: options.id,
|
|
2055
|
+
deleted: true
|
|
2056
|
+
},
|
|
2057
|
+
{
|
|
2058
|
+
format: options.format,
|
|
2059
|
+
pretty: () => {
|
|
2060
|
+
console.log(chalk3__default.default.green(`Deleted history process instance: ${options.id}`));
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
);
|
|
2064
|
+
} catch (error) {
|
|
2065
|
+
exitWithCommandError2(spinner, "Failed to delete history process instance", error);
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
async function listRoles(client, options = {}) {
|
|
2069
|
+
const spinner = createSpinner("Fetching roles...", options.format);
|
|
2070
|
+
try {
|
|
2071
|
+
const bpmClient = client.bpm;
|
|
2072
|
+
const result = await bpmClient.getRoles();
|
|
2073
|
+
if (result.error) {
|
|
2074
|
+
spinner.fail("Failed to fetch roles");
|
|
2075
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
2076
|
+
process.exit(1);
|
|
2077
|
+
}
|
|
2078
|
+
const roles = result.data || [];
|
|
2079
|
+
spinner.succeed(`Found ${roles.length} roles`);
|
|
2080
|
+
renderOutput(roles, {
|
|
2081
|
+
format: options.format,
|
|
2082
|
+
pretty: () => {
|
|
2083
|
+
console.log(chalk3__default.default.blue("\n\u{1F465} Roles\n"));
|
|
2084
|
+
console.log(JSON.stringify(roles, null, 2));
|
|
2085
|
+
}
|
|
2086
|
+
});
|
|
2087
|
+
} catch (error) {
|
|
2088
|
+
exitWithCommandError2(spinner, "Failed to fetch roles", error);
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
async function getUserRoles(client, options) {
|
|
2092
|
+
const spinner = createSpinner(`Fetching roles for user: ${options.userId}...`, options.format);
|
|
2093
|
+
try {
|
|
2094
|
+
const bpmClient = client.bpm;
|
|
2095
|
+
const result = await bpmClient.getUserRoles(options.userId);
|
|
2096
|
+
if (result.error) {
|
|
2097
|
+
spinner.fail("Failed to fetch user roles");
|
|
2098
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
2099
|
+
process.exit(1);
|
|
2100
|
+
}
|
|
2101
|
+
const roles = result.data || [];
|
|
2102
|
+
spinner.succeed(`Found ${roles.length} roles for user ${options.userId}`);
|
|
2103
|
+
renderOutput(roles, {
|
|
2104
|
+
format: options.format,
|
|
2105
|
+
pretty: () => {
|
|
2106
|
+
console.log(chalk3__default.default.blue(`
|
|
2107
|
+
\u{1F464} User Roles: ${options.userId}
|
|
2108
|
+
`));
|
|
2109
|
+
console.log(JSON.stringify(roles, null, 2));
|
|
2110
|
+
}
|
|
2111
|
+
});
|
|
2112
|
+
} catch (error) {
|
|
2113
|
+
exitWithCommandError2(spinner, "Failed to fetch user roles", error);
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
function resolveInputSource3(input) {
|
|
2117
|
+
if (!input.startsWith("@")) {
|
|
2118
|
+
return input;
|
|
2119
|
+
}
|
|
2120
|
+
const filePath = input.slice(1);
|
|
2121
|
+
if (!filePath) {
|
|
2122
|
+
throw new Error("File path is required after '@'.");
|
|
2123
|
+
}
|
|
2124
|
+
return fs.readFileSync(filePath, "utf8");
|
|
2125
|
+
}
|
|
2126
|
+
function parseJsonInput3(input, label) {
|
|
2127
|
+
const source = resolveInputSource3(input).trim();
|
|
2128
|
+
if (!source) {
|
|
2129
|
+
throw new Error(`${label} is required.`);
|
|
2130
|
+
}
|
|
2131
|
+
try {
|
|
2132
|
+
return JSON.parse(source);
|
|
2133
|
+
} catch (error) {
|
|
2134
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
2135
|
+
throw new Error(`Invalid ${label}: ${reason}`);
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
function isPlainObject4(value) {
|
|
2139
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2140
|
+
}
|
|
2141
|
+
function loadOptionalJsonObjectInput3(input, label) {
|
|
2142
|
+
if (!input) {
|
|
2143
|
+
return {};
|
|
2144
|
+
}
|
|
2145
|
+
const value = parseJsonInput3(input, label);
|
|
2146
|
+
if (!isPlainObject4(value)) {
|
|
2147
|
+
throw new Error(`${label} must be a JSON object.`);
|
|
2148
|
+
}
|
|
2149
|
+
return value;
|
|
2150
|
+
}
|
|
2151
|
+
function loadOptionalJsonArrayInput(input, label) {
|
|
2152
|
+
if (!input) {
|
|
2153
|
+
return void 0;
|
|
2154
|
+
}
|
|
2155
|
+
const value = parseJsonInput3(input, label);
|
|
2156
|
+
if (!Array.isArray(value)) {
|
|
2157
|
+
throw new Error(`${label} must be a JSON array.`);
|
|
1061
2158
|
}
|
|
2159
|
+
return value;
|
|
1062
2160
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
2161
|
+
function exitWithCommandError3(spinner, failureMessage, error) {
|
|
2162
|
+
spinner.fail(failureMessage);
|
|
2163
|
+
const details = error instanceof Error ? error.message : String(error);
|
|
2164
|
+
if (details) {
|
|
2165
|
+
console.error(chalk3__default.default.red(details));
|
|
2166
|
+
}
|
|
2167
|
+
process.exit(1);
|
|
2168
|
+
}
|
|
2169
|
+
function buildWorkflowRunRequest(options) {
|
|
2170
|
+
const request = loadOptionalJsonObjectInput3(options.request, "workflow request");
|
|
2171
|
+
if (options.input) {
|
|
2172
|
+
const inputs = parseJsonInput3(options.input, "workflow input");
|
|
2173
|
+
if (!isPlainObject4(inputs)) {
|
|
2174
|
+
throw new Error("workflow input must be a JSON object.");
|
|
1072
2175
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
console.log(` ${chalk7__default.default.gray("Status:")} ${workflow.status || "N/A"}`);
|
|
1084
|
-
console.log();
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
});
|
|
1088
|
-
} catch (error) {
|
|
1089
|
-
spinner.fail("Failed to fetch workflows");
|
|
1090
|
-
throw error;
|
|
2176
|
+
request.inputs = inputs;
|
|
2177
|
+
}
|
|
2178
|
+
if (options.responseMode) {
|
|
2179
|
+
request.response_mode = options.responseMode;
|
|
2180
|
+
}
|
|
2181
|
+
if (options.user) {
|
|
2182
|
+
request.user = options.user;
|
|
2183
|
+
}
|
|
2184
|
+
if (options.files) {
|
|
2185
|
+
request.files = loadOptionalJsonArrayInput(options.files, "workflow files");
|
|
1091
2186
|
}
|
|
2187
|
+
if (options.traceId) {
|
|
2188
|
+
request.trace_id = options.traceId;
|
|
2189
|
+
}
|
|
2190
|
+
return request;
|
|
1092
2191
|
}
|
|
1093
|
-
async function
|
|
1094
|
-
const spinner = createSpinner(`
|
|
2192
|
+
async function runWorkflow(client, options) {
|
|
2193
|
+
const spinner = createSpinner(`Running workflow: ${options.name}...`, options.format);
|
|
1095
2194
|
try {
|
|
1096
2195
|
const workflowClient = client.workflow;
|
|
1097
|
-
const
|
|
1098
|
-
const result = await workflowClient.
|
|
1099
|
-
input,
|
|
1100
|
-
version: options.version
|
|
1101
|
-
});
|
|
2196
|
+
const request = buildWorkflowRunRequest(options);
|
|
2197
|
+
const result = await workflowClient.run(options.name, request);
|
|
1102
2198
|
if (result.error) {
|
|
1103
|
-
spinner.fail("Failed to
|
|
1104
|
-
console.error(
|
|
2199
|
+
spinner.fail("Failed to run workflow");
|
|
2200
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1105
2201
|
process.exit(1);
|
|
1106
2202
|
}
|
|
1107
|
-
spinner.succeed("Workflow
|
|
2203
|
+
spinner.succeed("Workflow completed");
|
|
1108
2204
|
renderOutput(result.data, {
|
|
1109
2205
|
format: options.format,
|
|
1110
2206
|
pretty: () => {
|
|
1111
|
-
console.log(
|
|
2207
|
+
console.log(chalk3__default.default.blue("\n\u26A1 Workflow Run\n"));
|
|
1112
2208
|
console.log(JSON.stringify(result.data, null, 2));
|
|
1113
2209
|
}
|
|
1114
2210
|
});
|
|
1115
2211
|
} catch (error) {
|
|
1116
|
-
spinner
|
|
1117
|
-
|
|
2212
|
+
exitWithCommandError3(spinner, "Failed to run workflow", error);
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
function exitWithCommandError4(spinner, failureMessage, error) {
|
|
2216
|
+
spinner.fail(failureMessage);
|
|
2217
|
+
const details = error instanceof Error ? error.message : String(error);
|
|
2218
|
+
if (details) {
|
|
2219
|
+
console.error(chalk3__default.default.red(details));
|
|
2220
|
+
}
|
|
2221
|
+
process.exit(1);
|
|
2222
|
+
}
|
|
2223
|
+
async function toBuffer(data) {
|
|
2224
|
+
if (data instanceof Blob) {
|
|
2225
|
+
return Buffer.from(await data.arrayBuffer());
|
|
2226
|
+
}
|
|
2227
|
+
if (Buffer.isBuffer(data)) {
|
|
2228
|
+
return data;
|
|
2229
|
+
}
|
|
2230
|
+
if (data instanceof Uint8Array) {
|
|
2231
|
+
return Buffer.from(data);
|
|
2232
|
+
}
|
|
2233
|
+
if (data instanceof ArrayBuffer) {
|
|
2234
|
+
return Buffer.from(data);
|
|
2235
|
+
}
|
|
2236
|
+
if (typeof data === "string") {
|
|
2237
|
+
return Buffer.from(data);
|
|
1118
2238
|
}
|
|
2239
|
+
if (typeof data === "object" && data !== null && "arrayBuffer" in data && typeof data.arrayBuffer === "function") {
|
|
2240
|
+
const arrayBuffer = await data.arrayBuffer();
|
|
2241
|
+
return Buffer.from(arrayBuffer);
|
|
2242
|
+
}
|
|
2243
|
+
throw new Error(`Unsupported download response type: ${Object.prototype.toString.call(data)}`);
|
|
1119
2244
|
}
|
|
1120
2245
|
async function uploadFile(client, options) {
|
|
1121
2246
|
const spinner = createSpinner("Uploading file...", options.format);
|
|
@@ -1126,74 +2251,87 @@ async function uploadFile(client, options) {
|
|
|
1126
2251
|
spinner.fail(`File not found: ${options.file}`);
|
|
1127
2252
|
process.exit(1);
|
|
1128
2253
|
}
|
|
1129
|
-
const
|
|
1130
|
-
|
|
1131
|
-
bucket: options.bucket,
|
|
1132
|
-
isPublic: options.public
|
|
1133
|
-
});
|
|
2254
|
+
const file = new buffer.File([fs.readFileSync(filePath)], path.basename(filePath));
|
|
2255
|
+
const result = await s3Client.upload(file);
|
|
1134
2256
|
if (result.error) {
|
|
1135
2257
|
spinner.fail("Upload failed");
|
|
1136
|
-
console.error(
|
|
2258
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1137
2259
|
process.exit(1);
|
|
1138
2260
|
}
|
|
1139
2261
|
spinner.succeed("Upload complete");
|
|
1140
2262
|
renderOutput(result.data, {
|
|
1141
2263
|
format: options.format,
|
|
1142
2264
|
pretty: () => {
|
|
1143
|
-
console.log(
|
|
1144
|
-
console.log(` ${
|
|
1145
|
-
console.log(` ${
|
|
1146
|
-
console.log(` ${chalk7__default.default.bold("Bucket:")} ${result.data?.bucket || options.bucket || "default"}`);
|
|
2265
|
+
console.log(chalk3__default.default.green("\nFile uploaded:"));
|
|
2266
|
+
console.log(` ${chalk3__default.default.bold("Key:")} ${result.data?.key}`);
|
|
2267
|
+
console.log(` ${chalk3__default.default.bold("URL:")} ${result.data?.url || "N/A"}`);
|
|
1147
2268
|
}
|
|
1148
2269
|
});
|
|
1149
2270
|
} catch (error) {
|
|
1150
|
-
spinner
|
|
1151
|
-
throw error;
|
|
2271
|
+
exitWithCommandError4(spinner, "Upload failed", error);
|
|
1152
2272
|
}
|
|
1153
2273
|
}
|
|
1154
|
-
async function
|
|
1155
|
-
const spinner = createSpinner("
|
|
2274
|
+
async function downloadFile(client, options) {
|
|
2275
|
+
const spinner = createSpinner("Downloading file...", options.format);
|
|
1156
2276
|
try {
|
|
1157
2277
|
const s3Client = client.s3;
|
|
1158
|
-
const result = await s3Client.
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
}
|
|
2278
|
+
const result = await s3Client.download(options.key);
|
|
2279
|
+
if (result.error) {
|
|
2280
|
+
spinner.fail("Download failed");
|
|
2281
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
2282
|
+
process.exit(1);
|
|
2283
|
+
}
|
|
2284
|
+
if (!result.data) {
|
|
2285
|
+
spinner.fail("Download failed");
|
|
2286
|
+
console.error(chalk3__default.default.red("Empty file response."));
|
|
2287
|
+
process.exit(1);
|
|
2288
|
+
}
|
|
2289
|
+
const outputPath = path.resolve(options.output);
|
|
2290
|
+
const buffer = await toBuffer(result.data);
|
|
2291
|
+
fs.writeFileSync(outputPath, buffer);
|
|
2292
|
+
spinner.succeed("Download complete");
|
|
2293
|
+
renderOutput(
|
|
2294
|
+
{
|
|
2295
|
+
key: options.key,
|
|
2296
|
+
output: outputPath,
|
|
2297
|
+
downloaded: true
|
|
2298
|
+
},
|
|
2299
|
+
{
|
|
2300
|
+
format: options.format,
|
|
2301
|
+
pretty: () => {
|
|
2302
|
+
console.log(chalk3__default.default.green(`
|
|
2303
|
+
File saved to: ${outputPath}`));
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
);
|
|
2307
|
+
} catch (error) {
|
|
2308
|
+
exitWithCommandError4(spinner, "Download failed", error);
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
async function getFileMetadata(client, options) {
|
|
2312
|
+
const spinner = createSpinner("Fetching file metadata...", options.format);
|
|
2313
|
+
try {
|
|
2314
|
+
const s3Client = client.s3;
|
|
2315
|
+
const result = await s3Client.getMetadata(options.key);
|
|
1164
2316
|
if (result.error) {
|
|
1165
|
-
spinner.fail("Failed to fetch
|
|
1166
|
-
console.error(
|
|
2317
|
+
spinner.fail("Failed to fetch metadata");
|
|
2318
|
+
console.error(chalk3__default.default.red(result.error.message));
|
|
1167
2319
|
process.exit(1);
|
|
1168
2320
|
}
|
|
1169
|
-
spinner.succeed(
|
|
1170
|
-
const files = result.data?.list || [];
|
|
2321
|
+
spinner.succeed("Metadata retrieved");
|
|
1171
2322
|
renderOutput(result.data, {
|
|
1172
2323
|
format: options.format,
|
|
1173
2324
|
pretty: () => {
|
|
1174
|
-
console.log(
|
|
1175
|
-
\u{
|
|
2325
|
+
console.log(chalk3__default.default.blue(`
|
|
2326
|
+
\u{1F4C4} Metadata for ${options.key}
|
|
1176
2327
|
`));
|
|
1177
|
-
|
|
1178
|
-
console.log(` ${chalk7__default.default.green("\u2022")} ${chalk7__default.default.bold(file.key)}`);
|
|
1179
|
-
console.log(` ${chalk7__default.default.gray("Size:")} ${formatBytes(file.size || 0)}`);
|
|
1180
|
-
console.log(` ${chalk7__default.default.gray("Modified:")} ${file.lastModified || "N/A"}`);
|
|
1181
|
-
console.log();
|
|
1182
|
-
}
|
|
2328
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
1183
2329
|
}
|
|
1184
2330
|
});
|
|
1185
2331
|
} catch (error) {
|
|
1186
|
-
spinner
|
|
1187
|
-
throw error;
|
|
2332
|
+
exitWithCommandError4(spinner, "Failed to fetch metadata", error);
|
|
1188
2333
|
}
|
|
1189
2334
|
}
|
|
1190
|
-
function formatBytes(bytes) {
|
|
1191
|
-
if (bytes === 0) return "0 B";
|
|
1192
|
-
const k = 1024;
|
|
1193
|
-
const sizes = ["B", "KB", "MB", "GB", "TB"];
|
|
1194
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
1195
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
|
|
1196
|
-
}
|
|
1197
2335
|
|
|
1198
2336
|
// src/commands/openclaw.ts
|
|
1199
2337
|
init_config();
|
|
@@ -1232,8 +2370,8 @@ async function initOpenClaw(options) {
|
|
|
1232
2370
|
const existingConfig = getAppConfig(options.appCode);
|
|
1233
2371
|
if (existingConfig && !options.force) {
|
|
1234
2372
|
spinner.fail(`App already exists: ${options.appCode}`);
|
|
1235
|
-
console.log(
|
|
1236
|
-
console.log(
|
|
2373
|
+
console.log(chalk3__default.default.yellow(`Use --force to reinitialize`));
|
|
2374
|
+
console.log(chalk3__default.default.gray(`Current URL: ${existingConfig.baseURL}`));
|
|
1237
2375
|
process.exit(1);
|
|
1238
2376
|
}
|
|
1239
2377
|
addApp(options.appCode, {
|
|
@@ -1244,8 +2382,8 @@ async function initOpenClaw(options) {
|
|
|
1244
2382
|
if (!openClawDetected) {
|
|
1245
2383
|
spinner.succeed(`App initialized: ${options.appCode}`);
|
|
1246
2384
|
if (pretty) {
|
|
1247
|
-
console.log(
|
|
1248
|
-
console.log(
|
|
2385
|
+
console.log(chalk3__default.default.yellow("\n\u26A0\uFE0F OpenClaw not detected, skipping skill download"));
|
|
2386
|
+
console.log(chalk3__default.default.gray(" Install OpenClaw: npm install -g openclaw"));
|
|
1249
2387
|
} else {
|
|
1250
2388
|
renderOutput(
|
|
1251
2389
|
{
|
|
@@ -1263,9 +2401,9 @@ async function initOpenClaw(options) {
|
|
|
1263
2401
|
}
|
|
1264
2402
|
spinner.succeed(`App initialized: ${options.appCode}`);
|
|
1265
2403
|
if (pretty) {
|
|
1266
|
-
console.log(
|
|
1267
|
-
console.log(` App Code: ${
|
|
1268
|
-
console.log(` Base URL: ${
|
|
2404
|
+
console.log(chalk3__default.default.blue("\n\u{1F4CB} Configuration:\n"));
|
|
2405
|
+
console.log(` App Code: ${chalk3__default.default.green(options.appCode)}`);
|
|
2406
|
+
console.log(` Base URL: ${chalk3__default.default.gray(options.baseURL)}`);
|
|
1269
2407
|
console.log();
|
|
1270
2408
|
}
|
|
1271
2409
|
spinner.start("Downloading skills...");
|
|
@@ -1337,16 +2475,16 @@ async function initOpenClaw(options) {
|
|
|
1337
2475
|
};
|
|
1338
2476
|
if (pretty) {
|
|
1339
2477
|
console.log();
|
|
1340
|
-
console.log(
|
|
2478
|
+
console.log(chalk3__default.default.green("\u2705 Initialization complete!"));
|
|
1341
2479
|
console.log();
|
|
1342
2480
|
console.log(`Next step: Login to your app`);
|
|
1343
|
-
console.log(
|
|
2481
|
+
console.log(chalk3__default.default.gray(` amaster login --app ${options.appCode}`));
|
|
1344
2482
|
console.log();
|
|
1345
2483
|
if (apps.length > 1) {
|
|
1346
|
-
console.log(
|
|
2484
|
+
console.log(chalk3__default.default.blue("Configured apps:"));
|
|
1347
2485
|
for (const app of apps) {
|
|
1348
2486
|
const config = getAppConfig(app);
|
|
1349
|
-
console.log(` ${
|
|
2487
|
+
console.log(` ${chalk3__default.default.gray("\u2022")} ${app} - ${config?.baseURL}`);
|
|
1350
2488
|
}
|
|
1351
2489
|
console.log();
|
|
1352
2490
|
}
|
|
@@ -1455,40 +2593,45 @@ function resolveAppCode(optionsApp) {
|
|
|
1455
2593
|
if (defaultApp) {
|
|
1456
2594
|
return defaultApp;
|
|
1457
2595
|
}
|
|
1458
|
-
console.error(
|
|
1459
|
-
console.log(
|
|
1460
|
-
console.log(
|
|
1461
|
-
console.log(
|
|
2596
|
+
console.error(chalk3__default.default.red("\u274C No app specified."));
|
|
2597
|
+
console.log(chalk3__default.default.yellow("Use one of:"));
|
|
2598
|
+
console.log(chalk3__default.default.gray(" 1. Add --app <app-code> to the command"));
|
|
2599
|
+
console.log(chalk3__default.default.gray(" 2. Set a default app: amaster use <app-code>"));
|
|
1462
2600
|
process.exit(1);
|
|
1463
2601
|
}
|
|
1464
2602
|
function createAmasterClient(appCode) {
|
|
1465
2603
|
const appConfig = getAppConfig(appCode);
|
|
1466
2604
|
if (!appConfig) {
|
|
1467
|
-
console.error(
|
|
1468
|
-
console.log(
|
|
2605
|
+
console.error(chalk3__default.default.red(`\u274C App not configured: ${appCode}`));
|
|
2606
|
+
console.log(chalk3__default.default.yellow(`Initialize it first: amaster init --app-code ${appCode} --url <url>`));
|
|
1469
2607
|
process.exit(1);
|
|
1470
2608
|
}
|
|
1471
2609
|
const token = getAccessToken(appCode);
|
|
1472
|
-
if (
|
|
1473
|
-
console.error(
|
|
1474
|
-
console.log(chalk7__default.default.yellow(`Login first: amaster login --app ${appCode}`));
|
|
1475
|
-
process.exit(1);
|
|
1476
|
-
}
|
|
1477
|
-
if (shouldRefreshToken(appCode)) {
|
|
1478
|
-
console.error(chalk7__default.default.yellow("\u26A0\uFE0F Session expiring soon. Please login again."));
|
|
2610
|
+
if (token && shouldRefreshToken(appCode)) {
|
|
2611
|
+
console.error(chalk3__default.default.yellow("\u26A0\uFE0F Session expiring soon. Please login again."));
|
|
1479
2612
|
}
|
|
1480
2613
|
const client$1 = client.createClient({
|
|
1481
2614
|
baseURL: appConfig.baseURL,
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
2615
|
+
...token ? {
|
|
2616
|
+
headers: {
|
|
2617
|
+
Authorization: `Bearer ${token}`
|
|
2618
|
+
}
|
|
2619
|
+
} : {},
|
|
1485
2620
|
onUnauthorized: () => {
|
|
1486
|
-
|
|
1487
|
-
|
|
2621
|
+
if (token) {
|
|
2622
|
+
console.error(chalk3__default.default.red("\n\u274C Session expired. Please login again."));
|
|
2623
|
+
console.error(chalk3__default.default.yellow(`Run: amaster login --app ${appCode}`));
|
|
2624
|
+
} else {
|
|
2625
|
+
console.error(chalk3__default.default.red(`
|
|
2626
|
+
\u274C Authentication required for app: ${appCode}`));
|
|
2627
|
+
console.error(chalk3__default.default.yellow(`Run: amaster login --app ${appCode}`));
|
|
2628
|
+
}
|
|
1488
2629
|
process.exit(1);
|
|
1489
2630
|
}
|
|
1490
2631
|
});
|
|
1491
|
-
|
|
2632
|
+
if (token) {
|
|
2633
|
+
client$1.setAccessToken(token);
|
|
2634
|
+
}
|
|
1492
2635
|
return client$1;
|
|
1493
2636
|
}
|
|
1494
2637
|
var program = new commander.Command();
|
|
@@ -1508,17 +2651,17 @@ program.command("apps").description("List all configured apps").addOption(create
|
|
|
1508
2651
|
renderOutput(appSummaries, {
|
|
1509
2652
|
format: options.format,
|
|
1510
2653
|
pretty: () => {
|
|
1511
|
-
console.log(
|
|
2654
|
+
console.log(chalk3__default.default.blue("\n\u{1F4F1} Configured Apps\n"));
|
|
1512
2655
|
if (appSummaries.length === 0) {
|
|
1513
|
-
console.log(
|
|
1514
|
-
console.log(
|
|
2656
|
+
console.log(chalk3__default.default.gray(" No apps configured"));
|
|
2657
|
+
console.log(chalk3__default.default.gray(" Run: amaster init --app-code <code> --url <url>"));
|
|
1515
2658
|
} else {
|
|
1516
2659
|
for (const app of appSummaries) {
|
|
1517
|
-
const prefix = app.current ?
|
|
1518
|
-
console.log(`${prefix}${
|
|
1519
|
-
console.log(` ${
|
|
2660
|
+
const prefix = app.current ? chalk3__default.default.green("\u2192 ") : " ";
|
|
2661
|
+
console.log(`${prefix}${chalk3__default.default.bold(app.appCode)}${app.current ? chalk3__default.default.green(" (current)") : ""}`);
|
|
2662
|
+
console.log(` ${chalk3__default.default.gray(app.baseURL || "No URL")}`);
|
|
1520
2663
|
console.log(
|
|
1521
|
-
` ${app.authenticated ?
|
|
2664
|
+
` ${app.authenticated ? chalk3__default.default.green("\u25CF Authenticated") : chalk3__default.default.yellow("\u25CB Not authenticated")}`
|
|
1522
2665
|
);
|
|
1523
2666
|
console.log();
|
|
1524
2667
|
}
|
|
@@ -1537,12 +2680,12 @@ program.command("use <app-code>").description("Set the default app for subsequen
|
|
|
1537
2680
|
{
|
|
1538
2681
|
format: options.format,
|
|
1539
2682
|
pretty: () => {
|
|
1540
|
-
console.log(
|
|
2683
|
+
console.log(chalk3__default.default.green(`\u2705 Now using app: ${appCode}`));
|
|
1541
2684
|
}
|
|
1542
2685
|
}
|
|
1543
2686
|
);
|
|
1544
2687
|
} else {
|
|
1545
|
-
console.error(
|
|
2688
|
+
console.error(chalk3__default.default.red(`\u274C App not found: ${appCode}`));
|
|
1546
2689
|
process.exit(1);
|
|
1547
2690
|
}
|
|
1548
2691
|
});
|
|
@@ -1574,13 +2717,13 @@ program.command("whoami").description("Show current user information").option("-
|
|
|
1574
2717
|
await getMe(() => createAmasterClient(appCode), { format: options.format });
|
|
1575
2718
|
});
|
|
1576
2719
|
var entityCmd = program.command("entity").description("Manage entities");
|
|
1577
|
-
entityCmd.command("list <namespace> <entity>").description("List entities").option("--app <app-code>", "App code (uses default if not specified)").option("--page <page>", "Page number"
|
|
2720
|
+
entityCmd.command("list <namespace> <entity>").description("List entities").option("--app <app-code>", "App code (uses default if not specified)").option("--page <page>", "Page number").option("--page-size <size>", "Page size").option("-f, --fields <fields>", "Comma-separated fields to return").option("-r, --relations <relations>", "Comma-separated relations to load").option("-k, --keyword <keyword>", "Keyword to search").option("--keyword-fields <fields>", "Comma-separated fields for keyword search").option("--order-by <field>", "Field to sort by").addOption(new commander.Option("--order-dir <dir>", "Sort direction").choices(["asc", "desc"])).option("--orders <orders>", "Multi-order expression, e.g. created_at:desc,name:asc").option("--filter <json>", "Advanced __filter JSON or @file").option("--limit <limit>", "Limit number of records").option("--offset <offset>", "Offset number of records").option("-q, --query <json>", "Additional EntityQueryParams as JSON or @file").addOption(createFormatOption()).action(async (namespace, entityName, options) => {
|
|
1578
2721
|
const appCode = resolveAppCode(options.app);
|
|
1579
2722
|
await listEntities(createAmasterClient(appCode), {
|
|
1580
2723
|
namespace,
|
|
1581
2724
|
entity: entityName,
|
|
1582
|
-
page: parseInt(options.page),
|
|
1583
|
-
pageSize: parseInt(options.pageSize),
|
|
2725
|
+
page: options.page ? parseInt(options.page) : void 0,
|
|
2726
|
+
pageSize: options.pageSize ? parseInt(options.pageSize) : void 0,
|
|
1584
2727
|
fields: options.fields,
|
|
1585
2728
|
relations: options.relations,
|
|
1586
2729
|
keyword: options.keyword,
|
|
@@ -1660,11 +2803,28 @@ entityCmd.command("bulk-delete <namespace> <entity>").description("Bulk delete e
|
|
|
1660
2803
|
});
|
|
1661
2804
|
});
|
|
1662
2805
|
var bpmCmd = program.command("bpm").description("Manage BPM processes and tasks");
|
|
1663
|
-
bpmCmd.command("processes").description("List process definitions").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (options) => {
|
|
2806
|
+
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 commander.Option("--sort-order <order>", "Sort order").choices(["asc", "desc"])).option("-q, --query <json>", "Additional ProcessDefinitionQueryParams as JSON or @file").addOption(createFormatOption()).action(async (options) => {
|
|
2807
|
+
const appCode = resolveAppCode(options.app);
|
|
2808
|
+
await listProcesses(createAmasterClient(appCode), {
|
|
2809
|
+
key: options.key,
|
|
2810
|
+
name: options.name,
|
|
2811
|
+
latestVersion: options.latestVersion,
|
|
2812
|
+
active: options.active,
|
|
2813
|
+
suspended: options.suspended,
|
|
2814
|
+
sortBy: options.sortBy,
|
|
2815
|
+
sortOrder: options.sortOrder,
|
|
2816
|
+
query: options.query,
|
|
2817
|
+
format: options.format
|
|
2818
|
+
});
|
|
2819
|
+
});
|
|
2820
|
+
bpmCmd.command("xml <key>").description("Get BPMN XML for a process definition key").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (key, options) => {
|
|
1664
2821
|
const appCode = resolveAppCode(options.app);
|
|
1665
|
-
await
|
|
2822
|
+
await getProcessXml(createAmasterClient(appCode), {
|
|
2823
|
+
key,
|
|
2824
|
+
format: options.format
|
|
2825
|
+
});
|
|
1666
2826
|
});
|
|
1667
|
-
bpmCmd.command("start <key>").description("Start a process instance").option("--app <app-code>", "App code (uses default if not specified)").option("-v, --variables <json>", "Process variables as JSON").addOption(createFormatOption()).action(async (key, options) => {
|
|
2827
|
+
bpmCmd.command("start <key>").description("Start a process instance").option("--app <app-code>", "App code (uses default if not specified)").option("-v, --variables <json>", "Process variables as JSON or @file").addOption(createFormatOption()).action(async (key, options) => {
|
|
1668
2828
|
const appCode = resolveAppCode(options.app);
|
|
1669
2829
|
await startProcess(createAmasterClient(appCode), {
|
|
1670
2830
|
key,
|
|
@@ -1672,14 +2832,127 @@ bpmCmd.command("start <key>").description("Start a process instance").option("--
|
|
|
1672
2832
|
format: options.format
|
|
1673
2833
|
});
|
|
1674
2834
|
});
|
|
1675
|
-
bpmCmd.command("
|
|
2835
|
+
bpmCmd.command("instances").description("List process instances").option("--app <app-code>", "App code (uses default if not specified)").option("--process-definition-key <key>", "Filter by process definition key").option("--active", "Only return active instances").option("--first-result <n>", "Pagination offset").option("--max-results <n>", "Maximum number of results").option("-q, --query <json>", "Additional ProcessInstanceQueryParams as JSON or @file").addOption(createFormatOption()).action(async (options) => {
|
|
2836
|
+
const appCode = resolveAppCode(options.app);
|
|
2837
|
+
await listProcessInstances(createAmasterClient(appCode), {
|
|
2838
|
+
processDefinitionKey: options.processDefinitionKey,
|
|
2839
|
+
active: options.active,
|
|
2840
|
+
firstResult: options.firstResult ? parseInt(options.firstResult) : void 0,
|
|
2841
|
+
maxResults: options.maxResults ? parseInt(options.maxResults) : void 0,
|
|
2842
|
+
query: options.query,
|
|
2843
|
+
format: options.format
|
|
2844
|
+
});
|
|
2845
|
+
});
|
|
2846
|
+
bpmCmd.command("instance <id>").description("Get a process instance by ID").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (id, options) => {
|
|
2847
|
+
const appCode = resolveAppCode(options.app);
|
|
2848
|
+
await getProcessInstance(createAmasterClient(appCode), {
|
|
2849
|
+
id,
|
|
2850
|
+
format: options.format
|
|
2851
|
+
});
|
|
2852
|
+
});
|
|
2853
|
+
bpmCmd.command("instance-tree <id>").description("Get the activity instance tree for a process instance").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (id, options) => {
|
|
2854
|
+
const appCode = resolveAppCode(options.app);
|
|
2855
|
+
await getActivityInstanceTree(createAmasterClient(appCode), {
|
|
2856
|
+
id,
|
|
2857
|
+
format: options.format
|
|
2858
|
+
});
|
|
2859
|
+
});
|
|
2860
|
+
bpmCmd.command("active-activities <id>").description("Get active activities for a process instance").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (id, options) => {
|
|
2861
|
+
const appCode = resolveAppCode(options.app);
|
|
2862
|
+
await getActiveActivities(createAmasterClient(appCode), {
|
|
2863
|
+
id,
|
|
2864
|
+
format: options.format
|
|
2865
|
+
});
|
|
2866
|
+
});
|
|
2867
|
+
bpmCmd.command("runtime-variables <id>").description("Get runtime variables for a process instance").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (id, options) => {
|
|
2868
|
+
const appCode = resolveAppCode(options.app);
|
|
2869
|
+
await getRuntimeVariables(createAmasterClient(appCode), {
|
|
2870
|
+
id,
|
|
2871
|
+
format: options.format
|
|
2872
|
+
});
|
|
2873
|
+
});
|
|
2874
|
+
bpmCmd.command("variables <id>").description("Get historic variables for a process instance").option("--app <app-code>", "App code (uses default if not specified)").option("--name <name>", "Filter by variable name").addOption(createFormatOption()).action(async (id, options) => {
|
|
2875
|
+
const appCode = resolveAppCode(options.app);
|
|
2876
|
+
await getProcessVariables(createAmasterClient(appCode), {
|
|
2877
|
+
id,
|
|
2878
|
+
name: options.name,
|
|
2879
|
+
format: options.format
|
|
2880
|
+
});
|
|
2881
|
+
});
|
|
2882
|
+
bpmCmd.command("delete-instance <id>").description("Delete a process instance").option("--app <app-code>", "App code (uses default if not specified)").option("--skip-custom-listeners", "Skip custom listeners during deletion").addOption(createFormatOption()).action(async (id, options) => {
|
|
2883
|
+
const appCode = resolveAppCode(options.app);
|
|
2884
|
+
await deleteProcessInstance(createAmasterClient(appCode), {
|
|
2885
|
+
id,
|
|
2886
|
+
skipCustomListeners: options.skipCustomListeners,
|
|
2887
|
+
format: options.format
|
|
2888
|
+
});
|
|
2889
|
+
});
|
|
2890
|
+
bpmCmd.command("suspend-instance <id>").description("Suspend a process instance").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (id, options) => {
|
|
2891
|
+
const appCode = resolveAppCode(options.app);
|
|
2892
|
+
await suspendProcessInstance(createAmasterClient(appCode), {
|
|
2893
|
+
id,
|
|
2894
|
+
format: options.format
|
|
2895
|
+
});
|
|
2896
|
+
});
|
|
2897
|
+
bpmCmd.command("activate-instance <id>").description("Activate a suspended process instance").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (id, options) => {
|
|
2898
|
+
const appCode = resolveAppCode(options.app);
|
|
2899
|
+
await activateProcessInstance(createAmasterClient(appCode), {
|
|
2900
|
+
id,
|
|
2901
|
+
format: options.format
|
|
2902
|
+
});
|
|
2903
|
+
});
|
|
2904
|
+
bpmCmd.command("modify-instance <id>").description("Modify a process instance").option("--app <app-code>", "App code (uses default if not specified)").option("-m, --modification <json>", "ProcessInstanceModification JSON or @file").addOption(createFormatOption()).action(async (id, options) => {
|
|
2905
|
+
const appCode = resolveAppCode(options.app);
|
|
2906
|
+
await modifyProcessInstance(createAmasterClient(appCode), {
|
|
2907
|
+
id,
|
|
2908
|
+
modification: options.modification,
|
|
2909
|
+
format: options.format
|
|
2910
|
+
});
|
|
2911
|
+
});
|
|
2912
|
+
bpmCmd.command("tasks").description("List tasks").option("--app <app-code>", "App code (uses default if not specified)").option("-a, --assignee <assignee>", "Filter by assignee").option("--process-instance-id <id>", "Filter by process instance ID").option("--candidate-user <user>", "Filter by candidate user").option("--candidate-group <group>", "Filter by candidate group").option("--name <name>", "Filter by exact task name").option("--name-like <name>", "Filter by fuzzy task name").option("--task-definition-key <key>", "Filter by task definition key").option("--first-result <n>", "Pagination offset").option("--max-results <n>", "Maximum number of results").option("--sort-by <field>", "Sort field").addOption(new commander.Option("--sort-order <order>", "Sort order").choices(["asc", "desc"])).option("-q, --query <json>", "Additional TaskQueryParams as JSON or @file").addOption(createFormatOption()).action(async (options) => {
|
|
1676
2913
|
const appCode = resolveAppCode(options.app);
|
|
1677
2914
|
await listTasks(createAmasterClient(appCode), {
|
|
2915
|
+
processInstanceId: options.processInstanceId,
|
|
2916
|
+
assignee: options.assignee,
|
|
2917
|
+
candidateUser: options.candidateUser,
|
|
2918
|
+
candidateGroup: options.candidateGroup,
|
|
2919
|
+
name: options.name,
|
|
2920
|
+
nameLike: options.nameLike,
|
|
2921
|
+
taskDefinitionKey: options.taskDefinitionKey,
|
|
2922
|
+
firstResult: options.firstResult ? parseInt(options.firstResult) : void 0,
|
|
2923
|
+
maxResults: options.maxResults ? parseInt(options.maxResults) : void 0,
|
|
2924
|
+
sortBy: options.sortBy,
|
|
2925
|
+
sortOrder: options.sortOrder,
|
|
2926
|
+
query: options.query,
|
|
2927
|
+
format: options.format
|
|
2928
|
+
});
|
|
2929
|
+
});
|
|
2930
|
+
bpmCmd.command("task <id>").description("Get a task by ID").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (id, options) => {
|
|
2931
|
+
const appCode = resolveAppCode(options.app);
|
|
2932
|
+
await getTask(createAmasterClient(appCode), {
|
|
2933
|
+
id,
|
|
2934
|
+
format: options.format
|
|
2935
|
+
});
|
|
2936
|
+
});
|
|
2937
|
+
bpmCmd.command("task-count").description("Get task count").option("--app <app-code>", "App code (uses default if not specified)").option("-a, --assignee <assignee>", "Filter by assignee").option("--process-instance-id <id>", "Filter by process instance ID").option("--candidate-user <user>", "Filter by candidate user").option("--candidate-group <group>", "Filter by candidate group").option("--name <name>", "Filter by exact task name").option("--name-like <name>", "Filter by fuzzy task name").option("--task-definition-key <key>", "Filter by task definition key").option("--first-result <n>", "Pagination offset").option("--max-results <n>", "Maximum number of results").option("--sort-by <field>", "Sort field").addOption(new commander.Option("--sort-order <order>", "Sort order").choices(["asc", "desc"])).option("-q, --query <json>", "Additional TaskQueryParams as JSON or @file").addOption(createFormatOption()).action(async (options) => {
|
|
2938
|
+
const appCode = resolveAppCode(options.app);
|
|
2939
|
+
await getTaskCount(createAmasterClient(appCode), {
|
|
2940
|
+
processInstanceId: options.processInstanceId,
|
|
1678
2941
|
assignee: options.assignee,
|
|
2942
|
+
candidateUser: options.candidateUser,
|
|
2943
|
+
candidateGroup: options.candidateGroup,
|
|
2944
|
+
name: options.name,
|
|
2945
|
+
nameLike: options.nameLike,
|
|
2946
|
+
taskDefinitionKey: options.taskDefinitionKey,
|
|
2947
|
+
firstResult: options.firstResult ? parseInt(options.firstResult) : void 0,
|
|
2948
|
+
maxResults: options.maxResults ? parseInt(options.maxResults) : void 0,
|
|
2949
|
+
sortBy: options.sortBy,
|
|
2950
|
+
sortOrder: options.sortOrder,
|
|
2951
|
+
query: options.query,
|
|
1679
2952
|
format: options.format
|
|
1680
2953
|
});
|
|
1681
2954
|
});
|
|
1682
|
-
bpmCmd.command("complete <id>").description("Complete a task").option("--app <app-code>", "App code (uses default if not specified)").option("-v, --variables <json>", "Task variables as JSON").addOption(createFormatOption()).action(async (id, options) => {
|
|
2955
|
+
bpmCmd.command("complete <id>").description("Complete a task").option("--app <app-code>", "App code (uses default if not specified)").option("-v, --variables <json>", "Task variables as JSON or @file").addOption(createFormatOption()).action(async (id, options) => {
|
|
1683
2956
|
const appCode = resolveAppCode(options.app);
|
|
1684
2957
|
await completeTask(createAmasterClient(appCode), {
|
|
1685
2958
|
id,
|
|
@@ -1687,33 +2960,236 @@ bpmCmd.command("complete <id>").description("Complete a task").option("--app <ap
|
|
|
1687
2960
|
format: options.format
|
|
1688
2961
|
});
|
|
1689
2962
|
});
|
|
1690
|
-
|
|
1691
|
-
|
|
2963
|
+
bpmCmd.command("delegate <id>").description("Delegate a task to another user").option("--app <app-code>", "App code (uses default if not specified)").requiredOption("--user-id <userId>", "Delegate target user ID").addOption(createFormatOption()).action(async (id, options) => {
|
|
2964
|
+
const appCode = resolveAppCode(options.app);
|
|
2965
|
+
await delegateTask(createAmasterClient(appCode), {
|
|
2966
|
+
id,
|
|
2967
|
+
userId: options.userId,
|
|
2968
|
+
format: options.format
|
|
2969
|
+
});
|
|
2970
|
+
});
|
|
2971
|
+
bpmCmd.command("task-form <id>").description("Get task form metadata").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (id, options) => {
|
|
1692
2972
|
const appCode = resolveAppCode(options.app);
|
|
1693
|
-
await
|
|
2973
|
+
await getTaskForm(createAmasterClient(appCode), {
|
|
2974
|
+
id,
|
|
2975
|
+
format: options.format
|
|
2976
|
+
});
|
|
1694
2977
|
});
|
|
1695
|
-
|
|
2978
|
+
bpmCmd.command("task-form-schema <id>").description("Get task form schema").option("--app <app-code>", "App code (uses default if not specified)").option("--redirect <url>", "Optional redirect URL").addOption(createFormatOption()).action(async (id, options) => {
|
|
1696
2979
|
const appCode = resolveAppCode(options.app);
|
|
1697
|
-
await
|
|
2980
|
+
await getTaskFormSchema(createAmasterClient(appCode), {
|
|
1698
2981
|
id,
|
|
1699
|
-
|
|
2982
|
+
redirect: options.redirect,
|
|
1700
2983
|
format: options.format
|
|
1701
2984
|
});
|
|
1702
2985
|
});
|
|
1703
|
-
|
|
1704
|
-
|
|
2986
|
+
bpmCmd.command("task-form-variables <id>").description("Get task form variables").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (id, options) => {
|
|
2987
|
+
const appCode = resolveAppCode(options.app);
|
|
2988
|
+
await getTaskFormVariables(createAmasterClient(appCode), {
|
|
2989
|
+
id,
|
|
2990
|
+
format: options.format
|
|
2991
|
+
});
|
|
2992
|
+
});
|
|
2993
|
+
bpmCmd.command("task-rendered-form <id>").description("Get rendered task form HTML").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (id, options) => {
|
|
2994
|
+
const appCode = resolveAppCode(options.app);
|
|
2995
|
+
await getTaskRenderedForm(createAmasterClient(appCode), {
|
|
2996
|
+
id,
|
|
2997
|
+
format: options.format
|
|
2998
|
+
});
|
|
2999
|
+
});
|
|
3000
|
+
bpmCmd.command("task-deployed-form <id>").description("Get deployed task form definition").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (id, options) => {
|
|
3001
|
+
const appCode = resolveAppCode(options.app);
|
|
3002
|
+
await getTaskDeployedForm(createAmasterClient(appCode), {
|
|
3003
|
+
id,
|
|
3004
|
+
format: options.format
|
|
3005
|
+
});
|
|
3006
|
+
});
|
|
3007
|
+
bpmCmd.command("start-form <key>").description("Get start form info for a process definition key").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (key, options) => {
|
|
3008
|
+
const appCode = resolveAppCode(options.app);
|
|
3009
|
+
await getStartFormInfo(createAmasterClient(appCode), {
|
|
3010
|
+
key,
|
|
3011
|
+
format: options.format
|
|
3012
|
+
});
|
|
3013
|
+
});
|
|
3014
|
+
bpmCmd.command("start-form-variables <key>").description("Get start form variables for a process definition key").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (key, options) => {
|
|
3015
|
+
const appCode = resolveAppCode(options.app);
|
|
3016
|
+
await getStartFormVariables(createAmasterClient(appCode), {
|
|
3017
|
+
key,
|
|
3018
|
+
format: options.format
|
|
3019
|
+
});
|
|
3020
|
+
});
|
|
3021
|
+
bpmCmd.command("history-tasks").description("List history tasks").option("--app <app-code>", "App code (uses default if not specified)").option("--task-assignee <assignee>", "Filter by historical task assignee").option("--process-instance-id <id>", "Filter by process instance ID").option("--finished", "Only return finished history tasks").option("--unfinished", "Only return unfinished history tasks").addOption(new commander.Option("--scope <scope>", "History task scope").choices(["handled"])).option("--first-result <n>", "Pagination offset").option("--max-results <n>", "Maximum number of results").option("--sort-by <field>", "Sort field").addOption(new commander.Option("--sort-order <order>", "Sort order").choices(["asc", "desc"])).option("-q, --query <json>", "Additional HistoryTaskQueryParams as JSON or @file").addOption(createFormatOption()).action(async (options) => {
|
|
3022
|
+
const appCode = resolveAppCode(options.app);
|
|
3023
|
+
await listHistoryTasks(createAmasterClient(appCode), {
|
|
3024
|
+
taskAssignee: options.taskAssignee,
|
|
3025
|
+
processInstanceId: options.processInstanceId,
|
|
3026
|
+
finished: options.finished,
|
|
3027
|
+
unfinished: options.unfinished,
|
|
3028
|
+
scope: options.scope,
|
|
3029
|
+
firstResult: options.firstResult ? parseInt(options.firstResult) : void 0,
|
|
3030
|
+
maxResults: options.maxResults ? parseInt(options.maxResults) : void 0,
|
|
3031
|
+
sortBy: options.sortBy,
|
|
3032
|
+
sortOrder: options.sortOrder,
|
|
3033
|
+
query: options.query,
|
|
3034
|
+
format: options.format
|
|
3035
|
+
});
|
|
3036
|
+
});
|
|
3037
|
+
bpmCmd.command("history-task-count").description("Get history task count").option("--app <app-code>", "App code (uses default if not specified)").option("--task-assignee <assignee>", "Filter by historical task assignee").option("--process-instance-id <id>", "Filter by process instance ID").option("--finished", "Only count finished history tasks").option("--unfinished", "Only count unfinished history tasks").addOption(new commander.Option("--scope <scope>", "History task scope").choices(["handled"])).option("--first-result <n>", "Pagination offset").option("--max-results <n>", "Maximum number of results").option("--sort-by <field>", "Sort field").addOption(new commander.Option("--sort-order <order>", "Sort order").choices(["asc", "desc"])).option("-q, --query <json>", "Additional HistoryTaskQueryParams as JSON or @file").addOption(createFormatOption()).action(async (options) => {
|
|
3038
|
+
const appCode = resolveAppCode(options.app);
|
|
3039
|
+
await getHistoryTaskCount(createAmasterClient(appCode), {
|
|
3040
|
+
taskAssignee: options.taskAssignee,
|
|
3041
|
+
processInstanceId: options.processInstanceId,
|
|
3042
|
+
finished: options.finished,
|
|
3043
|
+
unfinished: options.unfinished,
|
|
3044
|
+
scope: options.scope,
|
|
3045
|
+
firstResult: options.firstResult ? parseInt(options.firstResult) : void 0,
|
|
3046
|
+
maxResults: options.maxResults ? parseInt(options.maxResults) : void 0,
|
|
3047
|
+
sortBy: options.sortBy,
|
|
3048
|
+
sortOrder: options.sortOrder,
|
|
3049
|
+
query: options.query,
|
|
3050
|
+
format: options.format
|
|
3051
|
+
});
|
|
3052
|
+
});
|
|
3053
|
+
bpmCmd.command("history-instances").description("List history process instances").option("--app <app-code>", "App code (uses default if not specified)").option("--started-by <userId>", "Filter by starter user ID").option("--process-definition-key <key>", "Filter by process definition key").option("--finished", "Only return finished history instances").option("--unfinished", "Only return unfinished history instances").addOption(new commander.Option("--scope <scope>", "History process scope").choices(["initiated"])).option("--sort-by <field>", "Sort field").addOption(new commander.Option("--sort-order <order>", "Sort order").choices(["asc", "desc"])).option("--first-result <n>", "Pagination offset").option("--max-results <n>", "Maximum number of results").option("-q, --query <json>", "Additional HistoryProcessInstanceQueryParams as JSON or @file").addOption(createFormatOption()).action(async (options) => {
|
|
3054
|
+
const appCode = resolveAppCode(options.app);
|
|
3055
|
+
await listHistoryProcessInstances(createAmasterClient(appCode), {
|
|
3056
|
+
startedBy: options.startedBy,
|
|
3057
|
+
processDefinitionKey: options.processDefinitionKey,
|
|
3058
|
+
finished: options.finished,
|
|
3059
|
+
unfinished: options.unfinished,
|
|
3060
|
+
scope: options.scope,
|
|
3061
|
+
sortBy: options.sortBy,
|
|
3062
|
+
sortOrder: options.sortOrder,
|
|
3063
|
+
firstResult: options.firstResult ? parseInt(options.firstResult) : void 0,
|
|
3064
|
+
maxResults: options.maxResults ? parseInt(options.maxResults) : void 0,
|
|
3065
|
+
query: options.query,
|
|
3066
|
+
format: options.format
|
|
3067
|
+
});
|
|
3068
|
+
});
|
|
3069
|
+
bpmCmd.command("history-instance-count").description("Get history process instance count").option("--app <app-code>", "App code (uses default if not specified)").option("--started-by <userId>", "Filter by starter user ID").option("--process-definition-key <key>", "Filter by process definition key").option("--finished", "Only count finished history instances").option("--unfinished", "Only count unfinished history instances").addOption(new commander.Option("--scope <scope>", "History process scope").choices(["initiated"])).option("--sort-by <field>", "Sort field").addOption(new commander.Option("--sort-order <order>", "Sort order").choices(["asc", "desc"])).option("--first-result <n>", "Pagination offset").option("--max-results <n>", "Maximum number of results").option("-q, --query <json>", "Additional HistoryProcessInstanceQueryParams as JSON or @file").addOption(createFormatOption()).action(async (options) => {
|
|
3070
|
+
const appCode = resolveAppCode(options.app);
|
|
3071
|
+
await getHistoryProcessInstanceCount(createAmasterClient(appCode), {
|
|
3072
|
+
startedBy: options.startedBy,
|
|
3073
|
+
processDefinitionKey: options.processDefinitionKey,
|
|
3074
|
+
finished: options.finished,
|
|
3075
|
+
unfinished: options.unfinished,
|
|
3076
|
+
scope: options.scope,
|
|
3077
|
+
sortBy: options.sortBy,
|
|
3078
|
+
sortOrder: options.sortOrder,
|
|
3079
|
+
firstResult: options.firstResult ? parseInt(options.firstResult) : void 0,
|
|
3080
|
+
maxResults: options.maxResults ? parseInt(options.maxResults) : void 0,
|
|
3081
|
+
query: options.query,
|
|
3082
|
+
format: options.format
|
|
3083
|
+
});
|
|
3084
|
+
});
|
|
3085
|
+
bpmCmd.command("history-instance <id>").description("Get a history process instance by ID").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (id, options) => {
|
|
3086
|
+
const appCode = resolveAppCode(options.app);
|
|
3087
|
+
await getHistoryProcessInstance(createAmasterClient(appCode), {
|
|
3088
|
+
id,
|
|
3089
|
+
format: options.format
|
|
3090
|
+
});
|
|
3091
|
+
});
|
|
3092
|
+
bpmCmd.command("history-activities").description("List history activity instances").option("--app <app-code>", "App code (uses default if not specified)").option("--process-instance-id <id>", "Filter by process instance ID").option("--activity-id <activityId>", "Filter by BPMN activity ID").option("--activity-type <activityType>", "Filter by activity type").option("--finished", "Only return finished history activity instances").option("--sort-by <field>", "Sort field").addOption(new commander.Option("--sort-order <order>", "Sort order").choices(["asc", "desc"])).option("-q, --query <json>", "Additional HistoryActivityQueryParams as JSON or @file").addOption(createFormatOption()).action(async (options) => {
|
|
3093
|
+
const appCode = resolveAppCode(options.app);
|
|
3094
|
+
await listHistoryActivityInstances(createAmasterClient(appCode), {
|
|
3095
|
+
processInstanceId: options.processInstanceId,
|
|
3096
|
+
activityId: options.activityId,
|
|
3097
|
+
activityType: options.activityType,
|
|
3098
|
+
finished: options.finished,
|
|
3099
|
+
sortBy: options.sortBy,
|
|
3100
|
+
sortOrder: options.sortOrder,
|
|
3101
|
+
query: options.query,
|
|
3102
|
+
format: options.format
|
|
3103
|
+
});
|
|
3104
|
+
});
|
|
3105
|
+
bpmCmd.command("history-variables").description("List history variable instances").option("--app <app-code>", "App code (uses default if not specified)").option("--process-instance-id <id>", "Filter by process instance ID").option("--variable-name <name>", "Filter by variable name").option("--deserialize-values", "Deserialize complex variable values").option("-q, --query <json>", "Additional HistoryVariableQueryParams as JSON or @file").addOption(createFormatOption()).action(async (options) => {
|
|
3106
|
+
const appCode = resolveAppCode(options.app);
|
|
3107
|
+
await listHistoryVariableInstances(createAmasterClient(appCode), {
|
|
3108
|
+
processInstanceId: options.processInstanceId,
|
|
3109
|
+
variableName: options.variableName,
|
|
3110
|
+
deserializeValues: options.deserializeValues,
|
|
3111
|
+
query: options.query,
|
|
3112
|
+
format: options.format
|
|
3113
|
+
});
|
|
3114
|
+
});
|
|
3115
|
+
bpmCmd.command("user-operations").description("List user operation logs").option("--app <app-code>", "App code (uses default if not specified)").option("--process-instance-id <id>", "Filter by process instance ID").option("--task-id <id>", "Filter by task ID").option("--user-id <userId>", "Filter by user ID").option("--operation-type <type>", "Filter by operation type").option("--sort-by <field>", "Sort field").addOption(new commander.Option("--sort-order <order>", "Sort order").choices(["asc", "desc"])).option("--first-result <n>", "Pagination offset").option("--max-results <n>", "Maximum number of results").option("-q, --query <json>", "Additional UserOperationLogQueryParams as JSON or @file").addOption(createFormatOption()).action(async (options) => {
|
|
3116
|
+
const appCode = resolveAppCode(options.app);
|
|
3117
|
+
await listUserOperationLogs(createAmasterClient(appCode), {
|
|
3118
|
+
processInstanceId: options.processInstanceId,
|
|
3119
|
+
taskId: options.taskId,
|
|
3120
|
+
userId: options.userId,
|
|
3121
|
+
operationType: options.operationType,
|
|
3122
|
+
sortBy: options.sortBy,
|
|
3123
|
+
sortOrder: options.sortOrder,
|
|
3124
|
+
firstResult: options.firstResult ? parseInt(options.firstResult) : void 0,
|
|
3125
|
+
maxResults: options.maxResults ? parseInt(options.maxResults) : void 0,
|
|
3126
|
+
query: options.query,
|
|
3127
|
+
format: options.format
|
|
3128
|
+
});
|
|
3129
|
+
});
|
|
3130
|
+
bpmCmd.command("delete-history-instance <id>").description("Delete a history process instance").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (id, options) => {
|
|
3131
|
+
const appCode = resolveAppCode(options.app);
|
|
3132
|
+
await deleteHistoryProcessInstance(createAmasterClient(appCode), {
|
|
3133
|
+
id,
|
|
3134
|
+
format: options.format
|
|
3135
|
+
});
|
|
3136
|
+
});
|
|
3137
|
+
bpmCmd.command("roles").description("List runtime roles").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (options) => {
|
|
3138
|
+
const appCode = resolveAppCode(options.app);
|
|
3139
|
+
await listRoles(createAmasterClient(appCode), {
|
|
3140
|
+
format: options.format
|
|
3141
|
+
});
|
|
3142
|
+
});
|
|
3143
|
+
bpmCmd.command("user-roles <userId>").description("List roles assigned to a user").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (userId, options) => {
|
|
3144
|
+
const appCode = resolveAppCode(options.app);
|
|
3145
|
+
await getUserRoles(createAmasterClient(appCode), {
|
|
3146
|
+
userId,
|
|
3147
|
+
format: options.format
|
|
3148
|
+
});
|
|
3149
|
+
});
|
|
3150
|
+
bpmCmd.command("start-form-deployed <key>").description("Get deployed start form definition for a process definition key").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (key, options) => {
|
|
3151
|
+
const appCode = resolveAppCode(options.app);
|
|
3152
|
+
await getDeployedStartForm(createAmasterClient(appCode), {
|
|
3153
|
+
key,
|
|
3154
|
+
format: options.format
|
|
3155
|
+
});
|
|
3156
|
+
});
|
|
3157
|
+
var workflowCmd = program.command("workflow").description("Run workflows");
|
|
3158
|
+
workflowCmd.command("run <name>").alias("execute").description("Run a workflow").option("--app <app-code>", "App code (uses default if not specified)").option("-i, --input <json>", "Workflow inputs object as JSON or @file").option("-r, --request <json>", "Full WorkflowRunRequest as JSON or @file").addOption(
|
|
3159
|
+
new commander.Option("--response-mode <mode>", "Workflow response mode").choices(["blocking", "streaming"])
|
|
3160
|
+
).option("--user <user>", "Workflow user identifier").option("--files <json>", "Workflow files array as JSON or @file").option("--trace-id <traceId>", "Workflow trace ID").addOption(createFormatOption()).action(async (name, options) => {
|
|
1705
3161
|
const appCode = resolveAppCode(options.app);
|
|
1706
|
-
await
|
|
1707
|
-
|
|
3162
|
+
await runWorkflow(createAmasterClient(appCode), {
|
|
3163
|
+
name,
|
|
3164
|
+
input: options.input,
|
|
3165
|
+
request: options.request,
|
|
3166
|
+
responseMode: options.responseMode,
|
|
3167
|
+
user: options.user,
|
|
3168
|
+
files: options.files,
|
|
3169
|
+
traceId: options.traceId,
|
|
1708
3170
|
format: options.format
|
|
1709
3171
|
});
|
|
1710
3172
|
});
|
|
1711
|
-
s3Cmd.command("
|
|
3173
|
+
var s3Cmd = program.command("s3").description("Manage S3 files");
|
|
3174
|
+
s3Cmd.command("upload <file>").description("Upload a file").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (file, options) => {
|
|
1712
3175
|
const appCode = resolveAppCode(options.app);
|
|
1713
3176
|
await uploadFile(createAmasterClient(appCode), {
|
|
1714
3177
|
file,
|
|
1715
|
-
|
|
1716
|
-
|
|
3178
|
+
format: options.format
|
|
3179
|
+
});
|
|
3180
|
+
});
|
|
3181
|
+
s3Cmd.command("download <key> <output>").description("Download a file to a local path").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (key, output, options) => {
|
|
3182
|
+
const appCode = resolveAppCode(options.app);
|
|
3183
|
+
await downloadFile(createAmasterClient(appCode), {
|
|
3184
|
+
key,
|
|
3185
|
+
output,
|
|
3186
|
+
format: options.format
|
|
3187
|
+
});
|
|
3188
|
+
});
|
|
3189
|
+
s3Cmd.command("metadata <key>").description("Get file metadata").option("--app <app-code>", "App code (uses default if not specified)").addOption(createFormatOption()).action(async (key, options) => {
|
|
3190
|
+
const appCode = resolveAppCode(options.app);
|
|
3191
|
+
await getFileMetadata(createAmasterClient(appCode), {
|
|
3192
|
+
key,
|
|
1717
3193
|
format: options.format
|
|
1718
3194
|
});
|
|
1719
3195
|
});
|