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