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