@uipath/case-tool 1.206.0-preview.303 → 1.207.0-preview.305
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 +7 -90
- package/dist/THIRD-PARTY-NOTICES.md +162 -7
- package/dist/{authoring-wt5ngnjb.js → authoring-qqev46bh.js} +233 -63
- package/dist/{bindings-v2-x100hvcy.js → bindings-v2-wjgg92tj.js} +4 -4
- package/dist/{browser-strategy-627rrg7z.js → browser-strategy-qc6htsnf.js} +1 -1
- package/dist/{business-rule-export-pggs7x01.js → business-rule-export-0pbc3ysq.js} +2 -2
- package/dist/{carry-forward-gxsadrqb.js → carry-forward-tj5yrqf6.js} +6 -6
- package/dist/{case-api-a6v5beat.js → case-api-bfwmvkb8.js} +24 -28
- package/dist/{case-bindings-service-9zemt0r2.js → case-bindings-service-5r7c70kz.js} +5 -5
- package/dist/case-catalog-h4fjn6q3.js +304 -0
- package/dist/{case-debug-solution-projects-c300019s.js → case-debug-solution-projects-5tr4pwbs.js} +2 -2
- package/dist/{case-debug-studio-web-service-b6xe8es1.js → case-debug-studio-web-service-7smzvq4c.js} +10 -9
- package/dist/{case-described-io-service-8dw21x2y.js → case-described-io-service-ddsvkz8w.js} +5 -5
- package/dist/{case-event-trigger-bindings-pmad4dev.js → case-event-trigger-bindings-8nd78j4e.js} +5 -5
- package/dist/{case-format-service-xjvnx3jd.js → case-format-service-4mzszgfb.js} +2 -2
- package/dist/case-pack-service-bp7sh20v.js +297 -0
- package/dist/{case-splice-service-8deak994.js → case-splice-service-tpp2syvn.js} +7 -7
- package/dist/{case-validate-service-p324kcry.js → case-validate-service-fxvq4qx7.js} +146 -38
- package/dist/{connector-enrichment-service-9wnew5a0.js → connector-enrichment-service-x0w721wj.js} +26 -25
- package/dist/{connector-library-1yw5r47w.js → connector-library-844myxz2.js} +20 -6
- package/dist/{connector-lookup-service-v8r2htmg.js → connector-lookup-service-51pca3bf.js} +8 -8
- package/dist/{connector-task-shape-bgywpbqc.js → connector-task-shape-s2zny4gf.js} +3 -3
- package/dist/{de-AI7ML6JM-km47f8k4.js → de-B6IFKV43-9sk50xx0.js} +164 -2
- package/dist/{de-2BEKRUMY-x4dx0nn9.js → de-HF4GJ4EK-xrrajtht.js} +1277 -10
- package/dist/{debug-service-tm92ws5e.js → debug-service-hf2wb4tw.js} +9 -4
- package/dist/{en-LAVDF7IQ-yzy20n6d.js → en-5JIPZTS5-c68n8taw.js} +4 -2
- package/dist/{en-X6T4SP2Y-xm47mf18.js → en-ETY46SDS-far9tmsf.js} +66 -2
- package/dist/{enrichment-service-hzsn1aqp.js → enrichment-service-7f4sdff5.js} +17 -17
- package/dist/{es-SPNKTD5Y-vw5cbgv5.js → es-AQW6PFIU-q2mz247f.js} +164 -2
- package/dist/{es-7ZTQTGKN-11sj0yjx.js → es-IYP2OLUY-98xsbyd5.js} +1271 -10
- package/dist/{es-MX-IHGRIEWH-g63p0gb4.js → es-MX-D2MN3U37-0y5q0nbe.js} +1276 -10
- package/dist/{es-MX-7KJZPEQN-1fq0a9jr.js → es-MX-KWITVBWE-w49gknha.js} +164 -2
- package/dist/{fr-7ZDL4MVO-pd27vwh6.js → fr-NISALSPL-vzfmygd7.js} +1277 -10
- package/dist/{fr-AXJGUT53-hdg3pmd4.js → fr-RNWK2TMC-dpyzj366.js} +164 -2
- package/dist/{index-n1ndwwsz.js → index-2j5tfjwv.js} +129 -76
- package/dist/{index-kc1h1yf6.js → index-ezxmyhan.js} +4 -4
- package/dist/{index-j2gw61z0.js → index-gb75pv5a.js} +111 -65
- package/dist/index-prn518fr.js +36 -0
- package/dist/{index-nj3axvya.js → index-rk82650j.js} +7 -5
- package/dist/{index-pg9wmyrf.js → index-t6fnts8a.js} +2 -2
- package/dist/index-wkmh1h6w.js +26 -0
- package/dist/{index-21kns9qg.js → index-y7v9rkq9.js} +1 -1
- package/dist/index.js +13 -11
- package/dist/init-entry-points-52kvvbg9.js +15 -0
- package/dist/input-reader-zr71xcm9.js +13 -0
- package/dist/integration-service-fetcher-bpbz1gcx.js +68 -0
- package/dist/{ja-C7GZV6YP-hvtbngr5.js → ja-DH4I3GEF-ywyhhppa.js} +164 -2
- package/dist/{ja-LGAM5HKR-sgrtjqjh.js → ja-HTS2Q4YG-4ahnq47y.js} +1277 -10
- package/dist/{known-types-gak9by1w.js → known-types-a5d0evdm.js} +2 -2
- package/dist/{ko-7B4SUZB7-c8wr20sc.js → ko-3JFGTMNY-qnf1bnef.js} +1271 -10
- package/dist/{ko-Q24HSSL4-5vn55pte.js → ko-R5BCWVO7-whzgmh6q.js} +164 -2
- package/dist/library-option-pbvkt66g.js +13 -0
- package/dist/{localSolutionDiscovery-9pj8mzye.js → localSolutionDiscovery-5sqz9dkr.js} +5 -5
- package/dist/manifest-rhee8kem.js +32 -0
- package/dist/{node-strategy-2mqzg36t.js → node-strategy-aaf2qe6c.js} +2 -2
- package/dist/{node-sync-service-7n5960qy.js → node-sync-service-q1a37d6n.js} +21 -15
- package/dist/{out-target-gtg3we44.js → out-target-02x6x6nk.js} +5 -5
- package/dist/{packager-tool-h2ar8xf8.js → packager-tool-00ck60cc.js} +25 -24
- package/dist/{packager-tool-rfdkx9c9.js → packager-tool-00qmds4s.js} +254 -69
- package/dist/{packager-tool-388vyja1.js → packager-tool-0gmnk7sb.js} +2 -2
- package/dist/{packager-tool-fcektt1g.js → packager-tool-0nbcqyvp.js} +10 -9
- package/dist/{packager-tool-anvg0etj.js → packager-tool-178xtejt.js} +191 -154
- package/dist/{packager-tool-j69tzg52.js → packager-tool-1dsedy7x.js} +59 -34
- package/dist/packager-tool-1yew22sn.js +9 -0
- package/dist/{packager-tool-1hpd2gmh.js → packager-tool-225b9qhq.js} +1 -1
- package/dist/{packager-tool-z4phaas7.js → packager-tool-2x40ye7a.js} +21 -7
- package/dist/{packager-tool-p0rdmmvk.js → packager-tool-2xemp3b1.js} +2 -2
- package/dist/packager-tool-34ttsx9q.js +18 -0
- package/dist/{packager-tool-3zy717ga.js → packager-tool-36vkdb3h.js} +2 -2
- package/dist/{packager-tool-7hcpmn4g.js → packager-tool-380ac64s.js} +61 -11
- package/dist/{packager-tool-cqkbf2fg.js → packager-tool-3hzsw5r7.js} +906 -41
- package/dist/packager-tool-3k5j706w.js +73 -0
- package/dist/{packager-tool-scy94jyb.js → packager-tool-4seehsme.js} +2 -72
- package/dist/{packager-tool-es77jvky.js → packager-tool-4w7nzx18.js} +360 -44
- package/dist/{packager-tool-4avchhz8.js → packager-tool-57970zfm.js} +12 -7
- package/dist/{packager-tool-bjt8b2nz.js → packager-tool-5s476jdt.js} +13 -13
- package/dist/{packager-tool-0xj79bbd.js → packager-tool-8kcwawyg.js} +13 -4
- package/dist/{packager-tool-wy3a65rx.js → packager-tool-bw4fsdq4.js} +27 -13
- package/dist/{packager-tool-dn9d4ywm.js → packager-tool-c0pavv0s.js} +66 -10
- package/dist/packager-tool-c9h0rwgv.js +31 -0
- package/dist/{packager-tool-t8qx6hvn.js → packager-tool-dv2vtyg0.js} +4 -4
- package/dist/{packager-tool-3r23qsca.js → packager-tool-ef43cy32.js} +213 -231
- package/dist/{packager-tool-m4kp6a7j.js → packager-tool-ej14cxen.js} +22 -22
- package/dist/{packager-tool-5w0gjcck.js → packager-tool-engs9gvj.js} +1 -1
- package/dist/{packager-tool-stdwmgvd.js → packager-tool-exrjwmew.js} +202 -83
- package/dist/{task-type-declaration-yhczvj05.js → packager-tool-f9n5mk1c.js} +8 -12
- package/dist/{packager-tool-b2q8m9pq.js → packager-tool-fspmvh6g.js} +5 -4
- package/dist/packager-tool-geh2qybm.js +179 -0
- package/dist/{packager-tool-17b466mr.js → packager-tool-hrd44w8g.js} +7561 -6408
- package/dist/{packager-tool-snesn0bt.js → packager-tool-j1etnthk.js} +19 -14
- package/dist/{packager-tool-k871wgpe.js → packager-tool-j53d4vv1.js} +18 -4
- package/dist/{packager-tool-6ewsbrnb.js → packager-tool-j8mnpsv8.js} +329 -149
- package/dist/{packager-tool-7x1tmb8a.js → packager-tool-jydreskq.js} +1 -1
- package/dist/{packager-tool-r5pha7xq.js → packager-tool-k08k9g2y.js} +9 -9
- package/dist/{packager-tool-bg3tdpva.js → packager-tool-kh9gs4d5.js} +4 -2
- package/dist/{packager-tool-8467kcz9.js → packager-tool-m7s4n455.js} +120 -13
- package/dist/{packager-tool-q26hncjr.js → packager-tool-n3r5apbb.js} +4 -2
- package/dist/packager-tool-n6h4bz4d.js +22 -0
- package/dist/{packager-tool-ad8v11jd.js → packager-tool-p4c1g2sj.js} +1032 -819
- package/dist/{packager-tool-z070caqq.js → packager-tool-p64w2wrt.js} +30 -8
- package/dist/{packager-tool-xd1wbvay.js → packager-tool-pq61r2f1.js} +1 -1
- package/dist/{packager-tool-65vr263d.js → packager-tool-qzyb1eac.js} +1 -1
- package/dist/{packager-tool-5dptce1y.js → packager-tool-rzxnm9yj.js} +2 -2
- package/dist/{init-entry-points-5xzn81bb.js → packager-tool-t6xwkhht.js} +12 -10
- package/dist/packager-tool-vmfd007q.js +27 -0
- package/dist/packager-tool-wvf6b31h.js +50 -0
- package/dist/{packager-tool-cdvrca04.js → packager-tool-x9z4krtr.js} +1036 -259
- package/dist/{packager-tool-z1fw9a8v.js → packager-tool-y69796fy.js} +19 -11
- package/dist/{packager-tool-jkwpw95j.js → packager-tool-z13dp55w.js} +3393 -3092
- package/dist/{packager-tool-9m7jbv7t.js → packager-tool-zbfwp75m.js} +4 -4
- package/dist/{packager-tool-pq9xv4vq.js → packager-tool-zte9svtn.js} +11 -4
- package/dist/packager-tool.js +2 -2
- package/dist/{prepare-uip-ad7mfs8t.js → prepare-uip-2hcb65bn.js} +39 -6
- package/dist/{project-artifacts-pfcn65cg.js → project-artifacts-77yctm8b.js} +1 -1
- package/dist/{pt-BR-BIUJXIPU-2sqzhr8y.js → pt-BR-6TBBEDQS-y3f2vg5d.js} +164 -2
- package/dist/{pt-BR-PHLFHMXZ-n6de4s7z.js → pt-BR-7H7BP5DT-z2e5aaj1.js} +1276 -10
- package/dist/{pt-N7ZTJT4W-d6c67xcn.js → pt-QWGSZKMD-m50nrkx8.js} +1271 -10
- package/dist/{pt-MHX6JGAX-xfgvdqwg.js → pt-ZSQC5RZ3-8kp3g1z5.js} +164 -2
- package/dist/{resolved-check-dz8eqrf6.js → resolved-check-kwgy875v.js} +1 -1
- package/dist/{resourcesSyncService-y5r4k43w.js → resourcesSyncService-gegbd8b8.js} +49 -26
- package/dist/{ro-FLNXVYJI-ytrwabg2.js → ro-B7G474JK-9k2jjk88.js} +1271 -10
- package/dist/{ro-3RKJNGJZ-xqj14e3d.js → ro-P33AQ6ZL-s92z1mgg.js} +164 -2
- package/dist/{rule-type-declaration-ze0saj5r.js → rule-type-declaration-a0fk7fe7.js} +12 -11
- package/dist/{sdd-convert-service-m8e615a1.js → sdd-convert-service-2ag3xjpj.js} +120 -621
- package/dist/{sdd-lookup-fwj6x364.js → sdd-lookup-wgm5ctnd.js} +2 -2
- package/dist/{sdd-resolve-service-dvg387wx.js → sdd-resolve-service-epygyb0n.js} +34 -6
- package/dist/{sdd-resolve-siblings-xsm2ktkq.js → sdd-resolve-siblings-qz7gwws5.js} +4 -4
- package/dist/solution-auth-yb1twb9d.js +11 -0
- package/dist/{solution-discovery-gfdqhgt2.js → solution-discovery-t0nkzpm3.js} +4 -4
- package/dist/{strict-case-rules-045kbjvv.js → strict-case-rules-x1sytx3e.js} +91 -46
- package/dist/{strict-entry-points-wd85a81g.js → strict-entry-points-anxeg692.js} +6 -6
- package/dist/strict-sdd-audit-z1bg2zr0.js +28 -0
- package/dist/taggable-variables-gc58xb0s.js +6094 -0
- package/dist/task-type-declaration-b0ejzhc6.js +15 -0
- package/dist/tool.js +13 -11
- package/dist/{tr-7AIZZWZ6-pdzp9n0p.js → tr-FX7WCKK2-x3rx9fjt.js} +1271 -10
- package/dist/{tr-PQLUUHPC-qsb7btxn.js → tr-XD73CQAA-tb2nrpyp.js} +164 -2
- package/dist/{trigger-enrichment-service-dzkht78s.js → trigger-enrichment-service-bsj58ppa.js} +33 -32
- package/dist/{trigger-entry-point-id-4j9rk3kp.js → trigger-entry-point-id-hre2ewts.js} +1 -1
- package/dist/{zh-CN-OHNTHZRI-b0hjkfqn.js → zh-CN-GWP3B2EM-c07fm17a.js} +164 -2
- package/dist/{zh-CN-CN2ARPFS-e0p2qrxf.js → zh-CN-NCMB6YM5-drw9bnxg.js} +1271 -10
- package/dist/{zh-TW-E4D3Y6ZR-tn3bmzz5.js → zh-TW-2DLUOA7C-9khqnr4r.js} +164 -2
- package/dist/{zh-TW-7RUFEVFK-qd7myw31.js → zh-TW-UNIEJPLE-4vxzbphe.js} +1272 -11
- package/package.json +2 -2
- package/dist/case-pack-service-adhg30nq.js +0 -167
- package/dist/index-garh9kcd.js +0 -35
- package/dist/input-reader-pjt4a914.js +0 -10
- package/dist/packager-tool-v11fx4dk.js +0 -25
- package/dist/solution-auth-a1p22hq1.js +0 -11
- package/dist/strict-sdd-audit-6es2j6fs.js +0 -26
|
@@ -1,31 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
2
|
catchError2,
|
|
3
|
-
extractErrorMessage,
|
|
4
3
|
RESULTS,
|
|
5
|
-
|
|
4
|
+
extractErrorMessage,
|
|
5
|
+
instructionsFor,
|
|
6
|
+
classifiedFailure,
|
|
7
|
+
Option,
|
|
6
8
|
logger,
|
|
7
9
|
EXIT_CODES,
|
|
8
10
|
Pagination,
|
|
9
11
|
OutputFormatter,
|
|
10
12
|
processContext,
|
|
11
13
|
DEFAULT_PAGE_SIZE,
|
|
12
|
-
isGuid,
|
|
13
14
|
parseLimit,
|
|
14
15
|
parseOffset,
|
|
15
16
|
parseBoundedInt
|
|
16
|
-
} from "./packager-tool-
|
|
17
|
+
} from "./packager-tool-j8mnpsv8.js";
|
|
18
|
+
import {
|
|
19
|
+
normalizeTimestamps
|
|
20
|
+
} from "./packager-tool-wvf6b31h.js";
|
|
17
21
|
import {
|
|
18
22
|
getAuthContext2
|
|
19
|
-
} from "./packager-tool-
|
|
23
|
+
} from "./packager-tool-c0pavv0s.js";
|
|
20
24
|
import {
|
|
21
25
|
DEBUG_MODE_MAP2,
|
|
22
26
|
SIMULATION_MODE_MAP2
|
|
23
|
-
} from "./packager-tool-
|
|
27
|
+
} from "./packager-tool-4w7nzx18.js";
|
|
24
28
|
import {
|
|
25
29
|
resolveJsonInput
|
|
26
|
-
} from "./packager-tool-
|
|
30
|
+
} from "./packager-tool-rzxnm9yj.js";
|
|
31
|
+
import {
|
|
32
|
+
isGuid
|
|
33
|
+
} from "./packager-tool-1yew22sn.js";
|
|
27
34
|
|
|
28
35
|
// ../maestro-sdk/src/client.ts
|
|
36
|
+
var PIMS_PROBLEM_TYPE = /^PIMS-\d+$/;
|
|
29
37
|
function parseBackendErrorBody(body) {
|
|
30
38
|
if (!body)
|
|
31
39
|
return {};
|
|
@@ -37,6 +45,8 @@ function parseBackendErrorBody(body) {
|
|
|
37
45
|
result.message = parsed.message;
|
|
38
46
|
if (typeof parsed.errorCode === "number" || typeof parsed.errorCode === "string") {
|
|
39
47
|
result.errorCode = String(parsed.errorCode);
|
|
48
|
+
} else if (typeof parsed.type === "string" && PIMS_PROBLEM_TYPE.test(parsed.type)) {
|
|
49
|
+
result.errorCode = parsed.type;
|
|
40
50
|
}
|
|
41
51
|
if (typeof parsed.traceId === "string")
|
|
42
52
|
result.traceId = parsed.traceId;
|
|
@@ -116,7 +126,7 @@ async function pimsGet(config, path, options) {
|
|
|
116
126
|
const [parseErr, parsed] = catchError2(() => JSON.parse(text));
|
|
117
127
|
if (parseErr)
|
|
118
128
|
throw new Error(`Failed to parse API response body: ${parseErr.message}`);
|
|
119
|
-
return parsed;
|
|
129
|
+
return normalizeTimestamps(parsed);
|
|
120
130
|
}
|
|
121
131
|
async function pimsRequest(config, method, path, body, options) {
|
|
122
132
|
const url = buildPimsUrl(config, path);
|
|
@@ -144,7 +154,7 @@ async function pimsRequest(config, method, path, body, options) {
|
|
|
144
154
|
if (parseErr) {
|
|
145
155
|
throw new Error(`Failed to parse API response body: ${parseErr.message}`);
|
|
146
156
|
}
|
|
147
|
-
return parsed;
|
|
157
|
+
return normalizeTimestamps(parsed);
|
|
148
158
|
}
|
|
149
159
|
async function pimsPost(config, path, body, options) {
|
|
150
160
|
return pimsRequest(config, "POST", path, body, options);
|
|
@@ -190,6 +200,33 @@ function buildQueryString(params) {
|
|
|
190
200
|
return `?${new URLSearchParams(entries).toString()}`;
|
|
191
201
|
}
|
|
192
202
|
|
|
203
|
+
// ../maestro-sdk/src/variables-patch.ts
|
|
204
|
+
var PATCH_SHAPE_EXAMPLE = '{"globals":[{"op":"replace","path":"/flag","value":true}],"elements":[]}';
|
|
205
|
+
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
206
|
+
var readKey = (value, name) => {
|
|
207
|
+
const key = Object.keys(value).reverse().find((k) => k.toLowerCase() === name);
|
|
208
|
+
return key === undefined ? undefined : value[key];
|
|
209
|
+
};
|
|
210
|
+
function isVariablesPatch(data) {
|
|
211
|
+
if (!isPlainObject(data))
|
|
212
|
+
return false;
|
|
213
|
+
const globals = readKey(data, "globals");
|
|
214
|
+
const elements = readKey(data, "elements");
|
|
215
|
+
if (globals == null && elements == null)
|
|
216
|
+
return false;
|
|
217
|
+
if (globals != null && !Array.isArray(globals))
|
|
218
|
+
return false;
|
|
219
|
+
return elements == null || Array.isArray(elements);
|
|
220
|
+
}
|
|
221
|
+
function failBadVariablesPatch() {
|
|
222
|
+
OutputFormatter.error({
|
|
223
|
+
Result: RESULTS.ValidationError,
|
|
224
|
+
Message: "Invalid variables payload",
|
|
225
|
+
Instructions: `--inputs must be an object whose "globals" is a JSON Patch array and/or whose "elements" is an array of {"elementId":"<id>","inputs":[JSON Patch ops]}. The server ignores or rejects any other shape. Example: ${PATCH_SHAPE_EXAMPLE}`
|
|
226
|
+
});
|
|
227
|
+
processContext.exit(EXIT_CODES.ValidationError);
|
|
228
|
+
}
|
|
229
|
+
|
|
193
230
|
// ../maestro-sdk/src/shared-commands/examples.ts
|
|
194
231
|
var INSTANCE = "f4a1c2b3-0000-4000-8000-000000000001";
|
|
195
232
|
var FOLDER = "b2c3d4e5-0000-4000-8000-000000000002";
|
|
@@ -294,8 +331,8 @@ var EXAMPLES = {
|
|
|
294
331
|
}
|
|
295
332
|
}),
|
|
296
333
|
"instances variables-set": (prefix) => ({
|
|
297
|
-
Description: "
|
|
298
|
-
Command: `${prefix} instances variables-set ${INSTANCE} --folder-key ${FOLDER} --inputs
|
|
334
|
+
Description: "Replace a global variable on a running instance with a JSON Patch",
|
|
335
|
+
Command: `${prefix} instances variables-set ${INSTANCE} --folder-key ${FOLDER} --inputs '{"globals":[{"op":"replace","path":"/flag","value":true}],"elements":[]}'`,
|
|
299
336
|
Output: {
|
|
300
337
|
Code: "InstanceVariablesSet",
|
|
301
338
|
Data: {}
|
|
@@ -449,49 +486,58 @@ var EXAMPLES = {
|
|
|
449
486
|
Data: {}
|
|
450
487
|
}
|
|
451
488
|
}),
|
|
452
|
-
"process variable-tags
|
|
453
|
-
Description: "
|
|
454
|
-
Command: `${prefix} process variable-tags
|
|
489
|
+
"process variable-tags list": (prefix) => ({
|
|
490
|
+
Description: "List the variables you can tag for instance search, and which are tagged",
|
|
491
|
+
Command: `${prefix} process variable-tags list ${PROCESS} --folder-key ${FOLDER}`,
|
|
455
492
|
Output: {
|
|
456
|
-
Code: "
|
|
457
|
-
Data:
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
493
|
+
Code: "ProcessVariableTagsList",
|
|
494
|
+
Data: [
|
|
495
|
+
{
|
|
496
|
+
Element: "Review claim",
|
|
497
|
+
Variable: "claimAmount",
|
|
498
|
+
Id: `${ELEMENT}.claimAmount`,
|
|
499
|
+
Tagged: true,
|
|
500
|
+
Label: "Claim amount",
|
|
501
|
+
Stale: false,
|
|
502
|
+
Note: ""
|
|
503
|
+
}
|
|
504
|
+
]
|
|
462
505
|
}
|
|
463
506
|
}),
|
|
464
|
-
"process variable-tags
|
|
465
|
-
Description: "
|
|
466
|
-
Command: `${prefix} process variable-tags
|
|
507
|
+
"process variable-tags create": (prefix) => ({
|
|
508
|
+
Description: "Tag a variable so instances can be filtered by it",
|
|
509
|
+
Command: `${prefix} process variable-tags create ${PROCESS} --folder-key ${FOLDER} --variables claimAmount="Claim amount"`,
|
|
467
510
|
Output: {
|
|
468
|
-
Code: "
|
|
469
|
-
Data:
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
Elements: {
|
|
479
|
-
[ELEMENT]: {
|
|
480
|
-
Outputs: [
|
|
481
|
-
{
|
|
482
|
-
Name: "claimAmount",
|
|
483
|
-
Tags: ["Searchable"],
|
|
484
|
-
ExtractPath: "claimAmount",
|
|
485
|
-
Label: "Claim amount",
|
|
486
|
-
ExtractedValueType: "number"
|
|
487
|
-
}
|
|
488
|
-
]
|
|
489
|
-
}
|
|
490
|
-
},
|
|
491
|
-
SourcePackageVersion: "1.0.3",
|
|
492
|
-
LastUpdateTimeUtc: "2026-10-12T15:00:00Z"
|
|
511
|
+
Code: "ProcessVariableTagsCreated",
|
|
512
|
+
Data: [
|
|
513
|
+
{
|
|
514
|
+
Element: "Review claim",
|
|
515
|
+
Variable: "claimAmount",
|
|
516
|
+
Id: `${ELEMENT}.claimAmount`,
|
|
517
|
+
Tagged: true,
|
|
518
|
+
Label: "Claim amount",
|
|
519
|
+
Stale: false,
|
|
520
|
+
Note: ""
|
|
493
521
|
}
|
|
494
|
-
|
|
522
|
+
]
|
|
523
|
+
}
|
|
524
|
+
}),
|
|
525
|
+
"process variable-tags delete": (prefix) => ({
|
|
526
|
+
Description: "Stop tagging a variable",
|
|
527
|
+
Command: `${prefix} process variable-tags delete ${PROCESS} --folder-key ${FOLDER} --variables claimAmount`,
|
|
528
|
+
Output: {
|
|
529
|
+
Code: "ProcessVariableTagsDeleted",
|
|
530
|
+
Data: [
|
|
531
|
+
{
|
|
532
|
+
Element: "Review claim",
|
|
533
|
+
Variable: "claimAmount",
|
|
534
|
+
Id: `${ELEMENT}.claimAmount`,
|
|
535
|
+
Tagged: false,
|
|
536
|
+
Label: "",
|
|
537
|
+
Stale: false,
|
|
538
|
+
Note: ""
|
|
539
|
+
}
|
|
540
|
+
]
|
|
495
541
|
}
|
|
496
542
|
}),
|
|
497
543
|
"processes list": (prefix) => ({
|
|
@@ -643,8 +689,8 @@ var EXAMPLES = {
|
|
|
643
689
|
}
|
|
644
690
|
}),
|
|
645
691
|
"debug-instances variables-set": (prefix) => ({
|
|
646
|
-
Description: "
|
|
647
|
-
Command: `${prefix} debug-instances variables-set ${INSTANCE} --inputs
|
|
692
|
+
Description: "Replace a global variable on a paused debug run with a JSON Patch",
|
|
693
|
+
Command: `${prefix} debug-instances variables-set ${INSTANCE} --inputs '{"globals":[{"op":"replace","path":"/flag","value":true}],"elements":[]}'`,
|
|
648
694
|
Output: {
|
|
649
695
|
Code: "DebugInstanceVariablesSet",
|
|
650
696
|
Data: {}
|
|
@@ -694,6 +740,7 @@ var VALID_DEBUG_MODES = Object.keys(DEBUG_MODE_MAP2);
|
|
|
694
740
|
var VALID_SIMULATION_MODES = Object.keys(SIMULATION_MODE_MAP2);
|
|
695
741
|
|
|
696
742
|
// ../maestro-sdk/src/with-pims-call.ts
|
|
743
|
+
var PIMS_VARIABLES_TOO_LARGE = "PIMS-100079";
|
|
697
744
|
var NETWORK_ERROR_CODES = new Set([
|
|
698
745
|
"ECONNREFUSED",
|
|
699
746
|
"ECONNRESET",
|
|
@@ -757,10 +804,16 @@ function pimsFailureInstructions(error) {
|
|
|
757
804
|
} else if (error.parsedRequestId) {
|
|
758
805
|
lines.push(`Request ID: ${error.parsedRequestId}`);
|
|
759
806
|
}
|
|
760
|
-
lines.push(
|
|
807
|
+
lines.push(pimsRemediation(error));
|
|
761
808
|
return lines.join(`
|
|
762
809
|
`);
|
|
763
810
|
}
|
|
811
|
+
function pimsRemediation(error) {
|
|
812
|
+
if (error.parsedErrorCode === PIMS_VARIABLES_TOO_LARGE) {
|
|
813
|
+
return "Remediation: the instance's variables are over the size PIMS can return, so retrying will not help and the folder and identifiers are not the cause. Reduce the size of the largest variables the process stores. To read this instance's variables, contact UiPath support with the trace/request ID.";
|
|
814
|
+
}
|
|
815
|
+
return "Remediation: verify the folder scope and identifiers, then retry. If the error persists, contact UiPath support with the status, resource, and trace/request ID.";
|
|
816
|
+
}
|
|
764
817
|
function compactPimsErrorBody(body) {
|
|
765
818
|
const text = body.split(/\s+/).filter(Boolean).join(" ");
|
|
766
819
|
return text.length <= 700 ? text : `${text.slice(0, 699)}...`;
|
|
@@ -852,17 +905,31 @@ async function withPimsCall(fn, errorMessage, hint) {
|
|
|
852
905
|
return result;
|
|
853
906
|
}
|
|
854
907
|
|
|
908
|
+
// ../maestro-sdk/src/folder-scope.ts
|
|
909
|
+
var inFolder = (row, folderKey) => row.folderKey?.toLowerCase() === folderKey.toLowerCase();
|
|
910
|
+
var filterByFolder = (rows, folderKey) => folderKey === undefined ? rows : rows.filter((row) => inFolder(row, folderKey));
|
|
911
|
+
|
|
912
|
+
// ../maestro-sdk/src/row-window.ts
|
|
913
|
+
var windowRows = (rows, offset, limit) => rows.slice(offset, limit === undefined ? undefined : offset + limit);
|
|
914
|
+
|
|
855
915
|
// ../maestro-sdk/src/shared-commands/incidents.ts
|
|
916
|
+
var UNSUPPORTED_FILTER_MESSAGE = "--status and --severity are not supported: the server ignores them and the incident summary rows carry neither field.";
|
|
856
917
|
var registerSharedIncidentCommands = (program, config) => {
|
|
857
|
-
const { toolLabel } = config;
|
|
918
|
+
const { toolLabel, processType } = config;
|
|
858
919
|
const incident = program.command("incidents").alias("incident").description(`Manage ${toolLabel} incidents`);
|
|
859
|
-
incident.command("summary").description(`Get ${toolLabel} incident summaries across processes`).option("--folder-key <key>", "
|
|
920
|
+
incident.command("summary").description(`Get ${toolLabel} incident summaries across processes. The CLI ` + "applies --folder-key, --offset and --limit to the full list.").option("--folder-key <key>", "Keep only incidents of this folder (applied by the CLI)").option("-l, --limit <number>", "Number of items to return (1-10000)", parseLimit).option("--offset <number>", "Number of items to skip (0-1000000)", parseOffset, 0).option("--process-key <process-key>", "Filter by process key").addOption(new Option("--status <status>").hideHelp()).addOption(new Option("--severity <severity>").hideHelp()).trackedAction(processContext, async (options) => {
|
|
921
|
+
if (options.status !== undefined || options.severity !== undefined) {
|
|
922
|
+
OutputFormatter.error({
|
|
923
|
+
Result: RESULTS.ValidationError,
|
|
924
|
+
Message: UNSUPPORTED_FILTER_MESSAGE,
|
|
925
|
+
Instructions: "Drop the option. Use --process-key and --folder-key to narrow the list."
|
|
926
|
+
});
|
|
927
|
+
processContext.exit(EXIT_CODES.ValidationError);
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
860
930
|
const query = buildQueryString({
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
incidentSeverity: options.severity,
|
|
864
|
-
$top: options.limit,
|
|
865
|
-
$skip: options.offset !== 0 ? options.offset : undefined
|
|
931
|
+
processType,
|
|
932
|
+
processKey: options.processKey
|
|
866
933
|
});
|
|
867
934
|
const reqOptions = { folderKey: options.folderKey };
|
|
868
935
|
const result = await withPimsCall((config) => pimsGet(config, `/incidents/summary${query}`, reqOptions), "Error listing incidents");
|
|
@@ -871,7 +938,7 @@ var registerSharedIncidentCommands = (program, config) => {
|
|
|
871
938
|
OutputFormatter.success({
|
|
872
939
|
Result: RESULTS.Success,
|
|
873
940
|
Code: "IncidentSummary",
|
|
874
|
-
Data: result
|
|
941
|
+
Data: windowRows(filterByFolder(result, options.folderKey), options.offset, options.limit)
|
|
875
942
|
});
|
|
876
943
|
});
|
|
877
944
|
incident.command("get").description(`Get a single ${toolLabel} incident by ID`).argument("<incident-id>", "Incident ID").requiredOption("-f, --folder-key <key>", "Folder key").trackedAction(processContext, async (incidentId, options) => {
|
|
@@ -929,7 +996,135 @@ function resolveInstanceStatuses(raw) {
|
|
|
929
996
|
return { statuses, invalid };
|
|
930
997
|
}
|
|
931
998
|
|
|
999
|
+
// ../maestro-sdk/src/shared-commands/debug-folder.ts
|
|
1000
|
+
var FOLDER_ID_INSTRUCTIONS = "Provide --folder-id as a positive integer (the Orchestrator folder Id, e.g. 12345).";
|
|
1001
|
+
var FOLDER_TARGETING_INSTRUCTIONS = "Pass at most one of --folder-id, --folder-key, or --folder-path. Use 'uip or folders list' to discover values.";
|
|
1002
|
+
var FOLDER_RESOLUTION_INSTRUCTIONS = "Provide a valid --folder-key (UUID) or --folder-path. Use 'uip or folders list' to confirm the key or path.";
|
|
1003
|
+
var FOLDER_RESOLUTION_NETWORK_INSTRUCTIONS = "The folder lookup itself failed (network / Orchestrator API). Re-authenticate with 'uip login', verify connectivity, and retry.";
|
|
1004
|
+
var VALIDATION_EXIT_CODE = 3;
|
|
1005
|
+
var FAILURE_EXIT_CODE = 1;
|
|
1006
|
+
var responseStatus = (err) => err.response?.status;
|
|
1007
|
+
var NOT_FOUND_STATUS = 404;
|
|
1008
|
+
var isFolderInputError = (err) => {
|
|
1009
|
+
if (responseStatus(err) === NOT_FOUND_STATUS)
|
|
1010
|
+
return true;
|
|
1011
|
+
if ("response" in err)
|
|
1012
|
+
return false;
|
|
1013
|
+
if (err.name === "FetchError")
|
|
1014
|
+
return false;
|
|
1015
|
+
return true;
|
|
1016
|
+
};
|
|
1017
|
+
var parsePositiveInteger = (value) => {
|
|
1018
|
+
const parsed = Number(value);
|
|
1019
|
+
return Number.isInteger(parsed) && parsed > 0 ? parsed : undefined;
|
|
1020
|
+
};
|
|
1021
|
+
var folderMessage = (options, err) => {
|
|
1022
|
+
if (err === undefined) {
|
|
1023
|
+
return "Folder targeting requested but no folder resolved.";
|
|
1024
|
+
}
|
|
1025
|
+
if (responseStatus(err) === NOT_FOUND_STATUS) {
|
|
1026
|
+
return `Could not resolve folder: no folder with key '${options.folderKey}'.`;
|
|
1027
|
+
}
|
|
1028
|
+
return `Could not resolve folder: ${err.message}`;
|
|
1029
|
+
};
|
|
1030
|
+
var resolveDebugFolder = async (options) => {
|
|
1031
|
+
const flags = [
|
|
1032
|
+
options.folderId !== undefined ? "--folder-id" : undefined,
|
|
1033
|
+
options.folderKey !== undefined ? "--folder-key" : undefined,
|
|
1034
|
+
options.folderPath !== undefined ? "--folder-path" : undefined
|
|
1035
|
+
].filter((flag) => flag !== undefined);
|
|
1036
|
+
if (flags.length > 1) {
|
|
1037
|
+
OutputFormatter.error({
|
|
1038
|
+
Result: RESULTS.ValidationError,
|
|
1039
|
+
Message: `Cannot combine ${flags.join(", ")}.`,
|
|
1040
|
+
Instructions: FOLDER_TARGETING_INSTRUCTIONS
|
|
1041
|
+
});
|
|
1042
|
+
processContext.exit(VALIDATION_EXIT_CODE);
|
|
1043
|
+
return { kind: "failed" };
|
|
1044
|
+
}
|
|
1045
|
+
if (options.folderId !== undefined) {
|
|
1046
|
+
const folderId = parsePositiveInteger(options.folderId);
|
|
1047
|
+
if (folderId === undefined) {
|
|
1048
|
+
OutputFormatter.error({
|
|
1049
|
+
Result: RESULTS.ValidationError,
|
|
1050
|
+
Message: "--folder-id must be a positive integer.",
|
|
1051
|
+
Instructions: FOLDER_ID_INSTRUCTIONS
|
|
1052
|
+
});
|
|
1053
|
+
processContext.exit(VALIDATION_EXIT_CODE);
|
|
1054
|
+
return { kind: "failed" };
|
|
1055
|
+
}
|
|
1056
|
+
return { kind: "resolved", folderId };
|
|
1057
|
+
}
|
|
1058
|
+
if (options.folderKey === undefined && options.folderPath === undefined) {
|
|
1059
|
+
return { kind: "resolved", folderId: undefined };
|
|
1060
|
+
}
|
|
1061
|
+
const { resolveFolder } = await import("./index-wkmh1h6w.js");
|
|
1062
|
+
const [folderError, folder] = await catchError2(resolveFolder({ folderKey: options.folderKey, folderPath: options.folderPath }, { loginValidity: options.loginValidity }));
|
|
1063
|
+
if (folderError) {
|
|
1064
|
+
const classified = await classifiedFailure(folderMessage(options, folderError), folderError);
|
|
1065
|
+
if (classified.Result === RESULTS.AuthenticationError) {
|
|
1066
|
+
OutputFormatter.error({
|
|
1067
|
+
...classified,
|
|
1068
|
+
Instructions: instructionsFor("backend", folderError)
|
|
1069
|
+
});
|
|
1070
|
+
processContext.exit(EXIT_CODES[RESULTS.AuthenticationError]);
|
|
1071
|
+
return { kind: "failed" };
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
if (folderError || !folder) {
|
|
1075
|
+
const inputProblem = !folderError || isFolderInputError(folderError);
|
|
1076
|
+
OutputFormatter.error({
|
|
1077
|
+
Result: inputProblem ? RESULTS.ValidationError : RESULTS.Failure,
|
|
1078
|
+
Message: folderMessage(options, folderError),
|
|
1079
|
+
Instructions: inputProblem ? FOLDER_RESOLUTION_INSTRUCTIONS : FOLDER_RESOLUTION_NETWORK_INSTRUCTIONS
|
|
1080
|
+
});
|
|
1081
|
+
processContext.exit(inputProblem ? VALIDATION_EXIT_CODE : FAILURE_EXIT_CODE);
|
|
1082
|
+
return { kind: "failed" };
|
|
1083
|
+
}
|
|
1084
|
+
logger.info(`Resolved folder '${folder.path}' to ID ${folder.id} (key ${folder.key}).`);
|
|
1085
|
+
return { kind: "resolved", folderId: folder.id, folderKey: folder.key };
|
|
1086
|
+
};
|
|
1087
|
+
|
|
1088
|
+
// ../maestro-sdk/src/shared-commands/folder-key.ts
|
|
1089
|
+
var FOLDER_PATH_FLAG = "--folder-path <path>";
|
|
1090
|
+
var FOLDER_PATH_HELP = "Folder path (e.g. 'Shared/Sub'), resolved to its key. Alternative to --folder-key";
|
|
1091
|
+
var failFolder = (message, instructions) => {
|
|
1092
|
+
OutputFormatter.error({
|
|
1093
|
+
Result: RESULTS.ValidationError,
|
|
1094
|
+
Message: message,
|
|
1095
|
+
Instructions: instructions
|
|
1096
|
+
});
|
|
1097
|
+
processContext.exit(EXIT_CODES.ValidationError);
|
|
1098
|
+
return false;
|
|
1099
|
+
};
|
|
1100
|
+
var resolveFolderKey = async (options, requirement = 0 /* Required */) => {
|
|
1101
|
+
const { folderKey, folderPath } = options;
|
|
1102
|
+
if (folderKey !== undefined && folderPath !== undefined) {
|
|
1103
|
+
return failFolder("Cannot combine --folder-key and --folder-path.", "Pass one of them.");
|
|
1104
|
+
}
|
|
1105
|
+
if (folderPath === undefined) {
|
|
1106
|
+
if (folderKey !== undefined)
|
|
1107
|
+
return true;
|
|
1108
|
+
if (requirement === 1 /* Optional */)
|
|
1109
|
+
return true;
|
|
1110
|
+
return failFolder("Missing folder: pass -f, --folder-key <key> or --folder-path <path>.", "Use 'uip or folders list' to find a folder's key or path.");
|
|
1111
|
+
}
|
|
1112
|
+
const outcome = await resolveDebugFolder({ folderPath });
|
|
1113
|
+
if (outcome.kind === "failed")
|
|
1114
|
+
return false;
|
|
1115
|
+
options.folderKey = outcome.folderKey;
|
|
1116
|
+
return true;
|
|
1117
|
+
};
|
|
1118
|
+
|
|
932
1119
|
// ../maestro-sdk/src/shared-commands/instances.ts
|
|
1120
|
+
var VARIABLE_VALUE_FIELDS = [
|
|
1121
|
+
"Globals",
|
|
1122
|
+
"GlobalDefinitions",
|
|
1123
|
+
"Inputs",
|
|
1124
|
+
"InputDefinitions",
|
|
1125
|
+
"Outputs",
|
|
1126
|
+
"Value"
|
|
1127
|
+
];
|
|
933
1128
|
var collectStatus = (raw, prev) => [...prev, raw];
|
|
934
1129
|
var MAX_INSTANCE_PAGE_SIZE = 500;
|
|
935
1130
|
var parseInstanceLimit = (raw) => parseBoundedInt(raw, "--limit", { min: 1, max: MAX_INSTANCE_PAGE_SIZE });
|
|
@@ -949,6 +1144,58 @@ function extractInstanceCursor(result) {
|
|
|
949
1144
|
hasMore: result.hasMoreResults ?? nextPage !== undefined
|
|
950
1145
|
};
|
|
951
1146
|
}
|
|
1147
|
+
var MAX_FOLDER_SCAN_PAGES = 20;
|
|
1148
|
+
async function listInstancePage(options, statuses, processType) {
|
|
1149
|
+
const { folderKey } = options;
|
|
1150
|
+
const fetchPage = (pageSize, nextPage) => {
|
|
1151
|
+
const query = buildQueryString({
|
|
1152
|
+
processKey: options.processKey,
|
|
1153
|
+
packageId: options.packageId,
|
|
1154
|
+
errorCode: options.errorCode,
|
|
1155
|
+
statuses: statuses?.join(","),
|
|
1156
|
+
startedTimeUtcStart: options.fromDate,
|
|
1157
|
+
startedTimeUtcEnd: options.toDate,
|
|
1158
|
+
processType,
|
|
1159
|
+
pageSize,
|
|
1160
|
+
nextPage
|
|
1161
|
+
});
|
|
1162
|
+
return withPimsCall((config) => pimsGet(config, `/instances${query}`, { folderKey }), "Error listing instances");
|
|
1163
|
+
};
|
|
1164
|
+
const instanceList = [];
|
|
1165
|
+
let nextPage = options.nextPage;
|
|
1166
|
+
let cursor = {};
|
|
1167
|
+
for (let scanned = 0;scanned < MAX_FOLDER_SCAN_PAGES; scanned++) {
|
|
1168
|
+
let result = await fetchPage(options.limit, nextPage);
|
|
1169
|
+
if (!result)
|
|
1170
|
+
return;
|
|
1171
|
+
let rows = extractProcessInstances(result);
|
|
1172
|
+
if (folderKey === undefined) {
|
|
1173
|
+
instanceList.push(...rows);
|
|
1174
|
+
return { instanceList, cursor: extractInstanceCursor(result) };
|
|
1175
|
+
}
|
|
1176
|
+
let matches = rows.filter((row) => inFolder(row, folderKey));
|
|
1177
|
+
const missing = options.limit - instanceList.length;
|
|
1178
|
+
if (matches.length > missing) {
|
|
1179
|
+
const keptEnd = rows.indexOf(matches[missing - 1]) + 1;
|
|
1180
|
+
if (keptEnd < rows.length) {
|
|
1181
|
+
result = await fetchPage(keptEnd, nextPage);
|
|
1182
|
+
if (!result)
|
|
1183
|
+
return;
|
|
1184
|
+
rows = extractProcessInstances(result);
|
|
1185
|
+
matches = rows.filter((row) => inFolder(row, folderKey));
|
|
1186
|
+
}
|
|
1187
|
+
matches = matches.slice(0, missing);
|
|
1188
|
+
}
|
|
1189
|
+
instanceList.push(...matches);
|
|
1190
|
+
cursor = extractInstanceCursor(result);
|
|
1191
|
+
nextPage = cursor.nextPage;
|
|
1192
|
+
if (!cursor.hasMore || !nextPage)
|
|
1193
|
+
break;
|
|
1194
|
+
if (instanceList.length >= options.limit)
|
|
1195
|
+
break;
|
|
1196
|
+
}
|
|
1197
|
+
return { instanceList, cursor };
|
|
1198
|
+
}
|
|
952
1199
|
var failListFilter = (message, instructions) => {
|
|
953
1200
|
OutputFormatter.error({
|
|
954
1201
|
Result: RESULTS.ValidationError,
|
|
@@ -977,33 +1224,21 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
977
1224
|
assetType,
|
|
978
1225
|
processType,
|
|
979
1226
|
includeElementExecutions = true,
|
|
980
|
-
|
|
981
|
-
listFolderKeyRequired = folderKeyRequired
|
|
1227
|
+
variablesHelpNote
|
|
982
1228
|
} = config;
|
|
983
|
-
const withFolderKey = (cmd
|
|
1229
|
+
const withFolderKey = (cmd) => cmd.option("-f, --folder-key <key>", "Folder key (GUID) of the instance, from FolderKey in 'instances list'. Required unless --folder-path is given").option(FOLDER_PATH_FLAG, FOLDER_PATH_HELP);
|
|
984
1230
|
const instances = program.command("instances").alias("instance").description(`Manage ${toolLabel} process instances`);
|
|
985
|
-
const listCmd = instances.command("list").description(`List ${toolLabel} process instances. Filters are applied by the ` + "server: --status narrows by run status, --process-key by " + "process key (GUID), --package-id by package identifier, and " + "--from-date/--to-date by start time. Results page by cursor " + "— read Pagination.NextPage and pass it back via --next-page.");
|
|
986
|
-
|
|
1231
|
+
const listCmd = instances.command("list").description(`List ${toolLabel} process instances. Filters are applied by the ` + "server: --status narrows by run status, --process-key by " + "process key (GUID), --package-id by package identifier, and " + "--from-date/--to-date by start time. Results page by cursor " + "— read Pagination.NextPage and pass it back via --next-page. " + "--folder-key and --folder-path are applied by the CLI, so a page can hold fewer " + "rows than --limit: keep paging while Pagination.HasMore is true.");
|
|
1232
|
+
listCmd.option("-f, --folder-key <key>", "Only list instances in this folder (GUID). Optional here; every other instance command requires a folder").option(FOLDER_PATH_FLAG, FOLDER_PATH_HELP).option("-l, --limit <number>", `Number of items to return (1-${MAX_INSTANCE_PAGE_SIZE})`, parseInstanceLimit, DEFAULT_PAGE_SIZE).option("--offset <number>", "Not supported by the instances API — use --next-page instead").option("--next-page <cursor>", "Cursor from a previous response's Pagination.NextPage").option("--process-key <process-key>", "Filter by process key (GUID). For the dotted package " + "identifier use --package-id.").option("--package-id <id>", "Filter by package ID").option("--error-code <code>", "Filter by error code").option("--status <status>", "Filter by instance status (repeatable; OR-semantics). " + `Values: ${INSTANCE_STATUS_LIST}.`, collectStatus, []).option("--from-date <iso-8601>", "Only include instances started at or after this ISO-8601 " + "timestamp (e.g. 2026-01-01T00:00:00Z).").option("--to-date <iso-8601>", "Only include instances started at or before this ISO-8601 " + "timestamp (e.g. 2026-02-01T00:00:00Z).").trackedAction(processContext, async (options) => {
|
|
1233
|
+
if (!await resolveFolderKey(options, 1 /* Optional */))
|
|
1234
|
+
return;
|
|
987
1235
|
const filters = resolveListFilters(options);
|
|
988
1236
|
if (!filters)
|
|
989
1237
|
return;
|
|
990
|
-
const
|
|
991
|
-
|
|
992
|
-
packageId: options.packageId,
|
|
993
|
-
errorCode: options.errorCode,
|
|
994
|
-
statuses: filters.statuses?.join(","),
|
|
995
|
-
startedTimeUtcStart: options.fromDate,
|
|
996
|
-
startedTimeUtcEnd: options.toDate,
|
|
997
|
-
processType,
|
|
998
|
-
pageSize: options.limit,
|
|
999
|
-
nextPage: options.nextPage
|
|
1000
|
-
});
|
|
1001
|
-
const reqOptions = { folderKey: options.folderKey };
|
|
1002
|
-
const result = await withPimsCall((config) => pimsGet(config, `/instances${query}`, reqOptions), "Error listing instances");
|
|
1003
|
-
if (!result)
|
|
1238
|
+
const page = await listInstancePage(options, filters.statuses, processType);
|
|
1239
|
+
if (!page)
|
|
1004
1240
|
return;
|
|
1005
|
-
const instanceList =
|
|
1006
|
-
const cursor = extractInstanceCursor(result);
|
|
1241
|
+
const { instanceList, cursor } = page;
|
|
1007
1242
|
OutputFormatter.success({
|
|
1008
1243
|
Result: RESULTS.Success,
|
|
1009
1244
|
Code: "InstanceList",
|
|
@@ -1018,6 +1253,8 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1018
1253
|
});
|
|
1019
1254
|
const getCmd = instances.command("get").description(`Get a ${toolLabel} process instance by ID`).argument("<instance-id>", "Process instance ID");
|
|
1020
1255
|
withFolderKey(getCmd).trackedAction(processContext, async (instanceId, options) => {
|
|
1256
|
+
if (!await resolveFolderKey(options))
|
|
1257
|
+
return;
|
|
1021
1258
|
const result = await withPimsCall((config) => pimsGet(config, `/instances/${instanceId}`, { folderKey: options.folderKey }), "Error getting instance", { resource: "instance", id: instanceId });
|
|
1022
1259
|
if (!result)
|
|
1023
1260
|
return;
|
|
@@ -1029,6 +1266,8 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1029
1266
|
});
|
|
1030
1267
|
const pauseCmd = instances.command("pause").description(`Pause a running ${toolLabel} process instance`).argument("<instance-id>", "Process instance ID");
|
|
1031
1268
|
withFolderKey(pauseCmd).option("--comment <text>", "Optional comment for the operation").trackedAction(processContext, async (instanceId, options) => {
|
|
1269
|
+
if (!await resolveFolderKey(options))
|
|
1270
|
+
return;
|
|
1032
1271
|
const body = { comment: options.comment || "" };
|
|
1033
1272
|
const reqOptions = { folderKey: options.folderKey };
|
|
1034
1273
|
const result = await withPimsCall((config) => pimsPost(config, `/instances/${instanceId}/pause`, body, reqOptions), "Error pausing instance");
|
|
@@ -1042,6 +1281,8 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1042
1281
|
});
|
|
1043
1282
|
const resumeCmd = instances.command("resume").description(`Resume a paused ${toolLabel} process instance`).argument("<instance-id>", "Process instance ID");
|
|
1044
1283
|
withFolderKey(resumeCmd).option("--comment <text>", "Optional comment for the operation").trackedAction(processContext, async (instanceId, options) => {
|
|
1284
|
+
if (!await resolveFolderKey(options))
|
|
1285
|
+
return;
|
|
1045
1286
|
const body = { comment: options.comment || "" };
|
|
1046
1287
|
const reqOptions = { folderKey: options.folderKey };
|
|
1047
1288
|
const result = await withPimsCall((config) => pimsPost(config, `/instances/${instanceId}/resume`, body, reqOptions), "Error resuming instance");
|
|
@@ -1055,6 +1296,8 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1055
1296
|
});
|
|
1056
1297
|
const cancelCmd = instances.command("cancel").description(`Cancel a ${toolLabel} process instance`).argument("<instance-id>", "Process instance ID");
|
|
1057
1298
|
withFolderKey(cancelCmd).option("--comment <text>", "Optional comment for the operation").trackedAction(processContext, async (instanceId, options) => {
|
|
1299
|
+
if (!await resolveFolderKey(options))
|
|
1300
|
+
return;
|
|
1058
1301
|
const body = { comment: options.comment || "" };
|
|
1059
1302
|
const reqOptions = { folderKey: options.folderKey };
|
|
1060
1303
|
const result = await withPimsCall((config) => pimsPost(config, `/instances/${instanceId}/cancel`, body, reqOptions), "Error canceling instance");
|
|
@@ -1066,8 +1309,10 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1066
1309
|
Data: result
|
|
1067
1310
|
});
|
|
1068
1311
|
});
|
|
1069
|
-
const variablesCmd = instances.command("variables").description(`Get variables for a ${toolLabel} process instance`).argument("<instance-id>", "Process instance ID");
|
|
1312
|
+
const variablesCmd = instances.command("variables").description(`Get variables for a ${toolLabel} process instance${variablesHelpNote ? `. ${variablesHelpNote}` : ""}`).argument("<instance-id>", "Process instance ID");
|
|
1070
1313
|
withFolderKey(variablesCmd).option("--parent-element-id <id>", "Filter variables by parent element ID").trackedAction(processContext, async (instanceId, options) => {
|
|
1314
|
+
if (!await resolveFolderKey(options))
|
|
1315
|
+
return;
|
|
1071
1316
|
const query = buildQueryString({
|
|
1072
1317
|
parentElementId: options.parentElementId
|
|
1073
1318
|
});
|
|
@@ -1079,10 +1324,12 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1079
1324
|
Result: RESULTS.Success,
|
|
1080
1325
|
Code: "InstanceVariables",
|
|
1081
1326
|
Data: result
|
|
1082
|
-
});
|
|
1327
|
+
}, { preserveDataKeys: VARIABLE_VALUE_FIELDS });
|
|
1083
1328
|
});
|
|
1084
1329
|
const incidentsCmd = instances.command("incidents").description(`Get incidents for a ${toolLabel} process instance`).argument("<instance-id>", "Process instance ID");
|
|
1085
1330
|
withFolderKey(incidentsCmd).trackedAction(processContext, async (instanceId, options) => {
|
|
1331
|
+
if (!await resolveFolderKey(options))
|
|
1332
|
+
return;
|
|
1086
1333
|
const result = await withPimsCall((config) => pimsGet(config, `/instances/${instanceId}/incidents`, { folderKey: options.folderKey }), "Error getting incidents");
|
|
1087
1334
|
if (!result)
|
|
1088
1335
|
return;
|
|
@@ -1094,6 +1341,8 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1094
1341
|
});
|
|
1095
1342
|
const assetCmd = instances.command("asset").description(`Get the ${toolLabel} definition for a process instance`).argument("<instance-id>", "Process instance ID");
|
|
1096
1343
|
withFolderKey(assetCmd).trackedAction(processContext, async (instanceId, options) => {
|
|
1344
|
+
if (!await resolveFolderKey(options))
|
|
1345
|
+
return;
|
|
1097
1346
|
const result = await withPimsCall((config) => pimsGet(config, `/instances/${instanceId}/asset?type=${assetType}`, { folderKey: options.folderKey }), "Error getting asset");
|
|
1098
1347
|
if (!result)
|
|
1099
1348
|
return;
|
|
@@ -1105,6 +1354,8 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1105
1354
|
});
|
|
1106
1355
|
const retryCmd = instances.command("retry").description(`Retry a faulted ${toolLabel} process instance`).argument("<instance-id>", "Process instance ID");
|
|
1107
1356
|
withFolderKey(retryCmd).option("--comment <text>", "Optional comment for the operation").trackedAction(processContext, async (instanceId, options) => {
|
|
1357
|
+
if (!await resolveFolderKey(options))
|
|
1358
|
+
return;
|
|
1108
1359
|
const body = { comment: options.comment || "" };
|
|
1109
1360
|
const reqOptions = { folderKey: options.folderKey };
|
|
1110
1361
|
const result = await withPimsCall((config) => pimsPost(config, `/instances/${instanceId}/retry`, body, reqOptions), "Error retrying instance");
|
|
@@ -1118,6 +1369,8 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1118
1369
|
});
|
|
1119
1370
|
const migrateCmd = instances.command("migrate").description(`Migrate a ${toolLabel} process instance to a different package version`).argument("<instance-id>", "Process instance ID").argument("<new-version>", "Target package version");
|
|
1120
1371
|
withFolderKey(migrateCmd).option("--comment <text>", "Optional comment for the operation").trackedAction(processContext, async (instanceId, newVersion, options) => {
|
|
1372
|
+
if (!await resolveFolderKey(options))
|
|
1373
|
+
return;
|
|
1121
1374
|
const body = {
|
|
1122
1375
|
newVersion,
|
|
1123
1376
|
comment: options.comment || ""
|
|
@@ -1134,6 +1387,8 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1134
1387
|
});
|
|
1135
1388
|
const gotoCmd = instances.command("goto").description("Move execution cursor from one element to another").argument("<instance-id>", "Process instance ID").argument("<transitions>", `JSON array of transitions, e.g. '[{"sourceElementId":"A","targetElementId":"B"}]'`);
|
|
1136
1389
|
withFolderKey(gotoCmd).trackedAction(processContext, async (instanceId, transitionsJson, options) => {
|
|
1390
|
+
if (!await resolveFolderKey(options))
|
|
1391
|
+
return;
|
|
1137
1392
|
const [parseError, transitions] = catchError2(() => JSON.parse(transitionsJson));
|
|
1138
1393
|
const isValidShape = !parseError && Array.isArray(transitions) && transitions.every((t) => t?.sourceElementId != null && t?.targetElementId != null);
|
|
1139
1394
|
if (!isValidShape) {
|
|
@@ -1158,6 +1413,8 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1158
1413
|
});
|
|
1159
1414
|
const cursorsCmd = instances.command("cursors").description(`Get current execution cursor positions for a ${toolLabel} process instance`).argument("<instance-id>", "Process instance ID");
|
|
1160
1415
|
withFolderKey(cursorsCmd).trackedAction(processContext, async (instanceId, options) => {
|
|
1416
|
+
if (!await resolveFolderKey(options))
|
|
1417
|
+
return;
|
|
1161
1418
|
const result = await withPimsCall((config) => pimsGet(config, `/instances/${instanceId}/goto/cursors`, { folderKey: options.folderKey }), "Error getting cursors");
|
|
1162
1419
|
if (!result)
|
|
1163
1420
|
return;
|
|
@@ -1168,7 +1425,9 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1168
1425
|
});
|
|
1169
1426
|
});
|
|
1170
1427
|
const messageCmd = instances.command("messages").alias("message").description(`Manage ${toolLabel} instance messages`);
|
|
1171
|
-
messageCmd.command("send").description(`Send a message to ${toolLabel} workflow subscriptions`).
|
|
1428
|
+
messageCmd.command("send").description(`Send a message to ${toolLabel} workflow subscriptions`).option("-f, --folder-key <key>", "Folder key (GUID). Required unless --folder-path is given").option(FOLDER_PATH_FLAG, FOLDER_PATH_HELP).option("--inputs <value>", "Message payload as JSON string, @file path, or piped via stdin").trackedAction(processContext, async (options) => {
|
|
1429
|
+
if (!await resolveFolderKey(options))
|
|
1430
|
+
return;
|
|
1172
1431
|
const [readError, body] = await catchError2(resolveJsonInput({
|
|
1173
1432
|
inline: options.inputs,
|
|
1174
1433
|
allowStdin: true
|
|
@@ -1204,6 +1463,8 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1204
1463
|
if (includeElementExecutions) {
|
|
1205
1464
|
const elementExeCmd = instances.command("element-executions").description(`Get element executions for a ${toolLabel} process instance`).argument("<instance-id>", "Process instance ID");
|
|
1206
1465
|
withFolderKey(elementExeCmd).trackedAction(processContext, async (instanceId, options) => {
|
|
1466
|
+
if (!await resolveFolderKey(options))
|
|
1467
|
+
return;
|
|
1207
1468
|
const result = await withPimsCall((config) => pimsGet(config, `/instances/${instanceId}/element-executions`, { folderKey: options.folderKey }), "Error getting element executions");
|
|
1208
1469
|
if (!result)
|
|
1209
1470
|
return;
|
|
@@ -1216,6 +1477,8 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1216
1477
|
}
|
|
1217
1478
|
const variablesSetCmd = instances.command("variables-set").description(`Update variables for a ${toolLabel} process instance`).argument("<instance-id>", "Process instance ID");
|
|
1218
1479
|
withFolderKey(variablesSetCmd).option("--inputs <value>", "Patch variables payload as JSON string, @file path, or piped via stdin").trackedAction(processContext, async (instanceId, options) => {
|
|
1480
|
+
if (!await resolveFolderKey(options))
|
|
1481
|
+
return;
|
|
1219
1482
|
const [readError, data] = await catchError2(resolveJsonInput({
|
|
1220
1483
|
inline: options.inputs,
|
|
1221
1484
|
allowStdin: true
|
|
@@ -1238,6 +1501,10 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1238
1501
|
processContext.exit(1);
|
|
1239
1502
|
return;
|
|
1240
1503
|
}
|
|
1504
|
+
if (!isVariablesPatch(data)) {
|
|
1505
|
+
failBadVariablesPatch();
|
|
1506
|
+
return;
|
|
1507
|
+
}
|
|
1241
1508
|
const body = data;
|
|
1242
1509
|
const reqOptions = { folderKey: options.folderKey };
|
|
1243
1510
|
const result = await withPimsCall((config) => pimsPatch(config, `/instances/${instanceId}/variables`, body, reqOptions), "Error updating variables");
|
|
@@ -1251,6 +1518,8 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1251
1518
|
});
|
|
1252
1519
|
const variablesAllCmd = instances.command("variables-all").description(`Get all variables (including subprocesses) for a ${toolLabel} process instance`).argument("<instance-id>", "Process instance ID");
|
|
1253
1520
|
withFolderKey(variablesAllCmd).trackedAction(processContext, async (instanceId, options) => {
|
|
1521
|
+
if (!await resolveFolderKey(options))
|
|
1522
|
+
return;
|
|
1254
1523
|
const result = await withPimsCall((config) => pimsGet(config, `/instances/${instanceId}/variables-all`, { folderKey: options.folderKey }), "Error getting all variables");
|
|
1255
1524
|
if (!result)
|
|
1256
1525
|
return;
|
|
@@ -1258,10 +1527,12 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1258
1527
|
Result: RESULTS.Success,
|
|
1259
1528
|
Code: "InstanceVariablesAll",
|
|
1260
1529
|
Data: result
|
|
1261
|
-
});
|
|
1530
|
+
}, { preserveDataKeys: VARIABLE_VALUE_FIELDS });
|
|
1262
1531
|
});
|
|
1263
1532
|
const globalVarsCmd = instances.command("global-variables").description(`Get global variables for a ${toolLabel} process instance`).argument("<instance-id>", "Process instance ID");
|
|
1264
1533
|
withFolderKey(globalVarsCmd).trackedAction(processContext, async (instanceId, options) => {
|
|
1534
|
+
if (!await resolveFolderKey(options))
|
|
1535
|
+
return;
|
|
1265
1536
|
const result = await withPimsCall((config) => pimsGet(config, `/instances/${instanceId}/global-variables`, { folderKey: options.folderKey }), "Error getting global variables");
|
|
1266
1537
|
if (!result)
|
|
1267
1538
|
return;
|
|
@@ -1269,11 +1540,13 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1269
1540
|
Result: RESULTS.Success,
|
|
1270
1541
|
Code: "InstanceGlobalVariables",
|
|
1271
1542
|
Data: result
|
|
1272
|
-
});
|
|
1543
|
+
}, { preserveDataKeys: VARIABLE_VALUE_FIELDS });
|
|
1273
1544
|
});
|
|
1274
1545
|
const element = instances.command("elements").alias("element").description(`Manage elements within a ${toolLabel} process instance`);
|
|
1275
1546
|
const elementCancelCmd = element.command("cancel").description(`Cancel a specific element in a ${toolLabel} process instance`).argument("<instance-id>", "Process instance ID").argument("<element-id>", "Element ID");
|
|
1276
1547
|
withFolderKey(elementCancelCmd).option("--comment <text>", "Optional comment for the operation").trackedAction(processContext, async (instanceId, elementId, options) => {
|
|
1548
|
+
if (!await resolveFolderKey(options))
|
|
1549
|
+
return;
|
|
1277
1550
|
const body = { comment: options.comment || "" };
|
|
1278
1551
|
const reqOptions = { folderKey: options.folderKey };
|
|
1279
1552
|
const result = await withPimsCall((config) => pimsPost(config, `/instances/${instanceId}/element/${elementId}/cancel`, body, reqOptions), "Error canceling element");
|
|
@@ -1287,6 +1560,8 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1287
1560
|
});
|
|
1288
1561
|
const elementRetryCmd = element.command("retry").description(`Retry a faulted element in a ${toolLabel} process instance`).argument("<instance-id>", "Process instance ID").argument("<element-id>", "Element ID");
|
|
1289
1562
|
withFolderKey(elementRetryCmd).option("--comment <text>", "Optional comment for the operation").trackedAction(processContext, async (instanceId, elementId, options) => {
|
|
1563
|
+
if (!await resolveFolderKey(options))
|
|
1564
|
+
return;
|
|
1290
1565
|
const body = { comment: options.comment || "" };
|
|
1291
1566
|
const reqOptions = { folderKey: options.folderKey };
|
|
1292
1567
|
const result = await withPimsCall((config) => pimsPost(config, `/instances/${instanceId}/element/${elementId}/retry`, body, reqOptions), "Error retrying element");
|
|
@@ -1301,160 +1576,673 @@ var registerSharedInstanceCommands = (program, config) => {
|
|
|
1301
1576
|
attachSharedExamples(instances);
|
|
1302
1577
|
};
|
|
1303
1578
|
|
|
1304
|
-
// ../maestro-sdk/src/shared-commands/
|
|
1579
|
+
// ../maestro-sdk/src/shared-commands/variable-tags-release.ts
|
|
1580
|
+
async function lookupRelease(processKey, folderKey) {
|
|
1581
|
+
const {
|
|
1582
|
+
createOrchestratorConfig,
|
|
1583
|
+
quoteODataStringLiteral,
|
|
1584
|
+
ReleaseNotFoundError,
|
|
1585
|
+
ReleasesApi
|
|
1586
|
+
} = await import("./index-wkmh1h6w.js");
|
|
1587
|
+
const config = await createOrchestratorConfig({ folderKey });
|
|
1588
|
+
const [listError, result] = await catchError2(new ReleasesApi(config).releasesListReleases({
|
|
1589
|
+
$filter: `Key eq ${quoteODataStringLiteral(processKey)}`,
|
|
1590
|
+
$top: 1
|
|
1591
|
+
}));
|
|
1592
|
+
if (listError) {
|
|
1593
|
+
throw new Error(`Failed to look up process '${processKey}': ${await extractErrorMessage(listError)}`, { cause: listError });
|
|
1594
|
+
}
|
|
1595
|
+
const release = result.value?.[0];
|
|
1596
|
+
if (!release) {
|
|
1597
|
+
throw new ReleaseNotFoundError(`Process '${processKey}' not found in folder '${folderKey}'.`, true);
|
|
1598
|
+
}
|
|
1599
|
+
return {
|
|
1600
|
+
processVersion: release.processVersion ?? undefined,
|
|
1601
|
+
processType: release.processType
|
|
1602
|
+
};
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
// ../maestro-sdk/src/shared-commands/variable-tags-payload.ts
|
|
1305
1606
|
var SEARCHABLE_TAG = "Searchable";
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1607
|
+
function splitVariableIdentity(id) {
|
|
1608
|
+
const [elementId, name, ...rest] = id.split(".");
|
|
1609
|
+
if (!elementId || !name) {
|
|
1610
|
+
throw new Error(`Variable identity "${id}" must be "<elementId>.<name>" with an optional ".<extractPath>".`);
|
|
1611
|
+
}
|
|
1612
|
+
return { elementId, name, extractPath: rest.join(".") };
|
|
1613
|
+
}
|
|
1614
|
+
function buildVariableTagsElements(selection) {
|
|
1615
|
+
const elements = Object.create(null);
|
|
1616
|
+
const seen = new Set;
|
|
1617
|
+
for (const variable of selection) {
|
|
1618
|
+
if (seen.has(variable.id))
|
|
1619
|
+
continue;
|
|
1620
|
+
seen.add(variable.id);
|
|
1621
|
+
const { elementId, name, extractPath } = splitVariableIdentity(variable.id);
|
|
1622
|
+
const row = {
|
|
1623
|
+
tags: [SEARCHABLE_TAG],
|
|
1624
|
+
name,
|
|
1625
|
+
label: variable.label,
|
|
1626
|
+
extractedValueType: variable.extractedValueType,
|
|
1627
|
+
extractPath
|
|
1628
|
+
};
|
|
1629
|
+
elements[elementId] ??= { outputs: [] };
|
|
1630
|
+
elements[elementId].outputs.push(row);
|
|
1631
|
+
}
|
|
1632
|
+
return elements;
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
// ../maestro-sdk/src/shared-commands/variable-tags-selection.ts
|
|
1636
|
+
class SelectionError extends Error {
|
|
1637
|
+
instructions;
|
|
1638
|
+
errorCode;
|
|
1639
|
+
retry = "RetryWillNotFix";
|
|
1640
|
+
constructor(message, instructions, errorCode = "invalid_argument") {
|
|
1641
|
+
super(message);
|
|
1642
|
+
this.instructions = instructions;
|
|
1643
|
+
this.errorCode = errorCode;
|
|
1644
|
+
this.name = "SelectionError";
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
var describeEntry = (entry) => entry.elementLabel && entry.elementLabel !== entry.id.split(".")[0] ? `${entry.id} (element "${entry.elementLabel}")` : entry.id;
|
|
1648
|
+
function rankMatch(token, id) {
|
|
1649
|
+
if (id === token)
|
|
1650
|
+
return 3;
|
|
1651
|
+
const segments = id.split(".");
|
|
1652
|
+
if (segments.slice(1).join(".") === token)
|
|
1653
|
+
return 2;
|
|
1654
|
+
return id.endsWith(`.${token}`) ? 1 : 0;
|
|
1655
|
+
}
|
|
1656
|
+
function bestMatches(token, catalog) {
|
|
1657
|
+
let best = 0;
|
|
1658
|
+
for (const one of [...catalog.variables, ...catalog.containers]) {
|
|
1659
|
+
best = Math.max(best, rankMatch(token, one.id));
|
|
1660
|
+
}
|
|
1661
|
+
if (best === 0)
|
|
1662
|
+
return { variables: [], objects: [] };
|
|
1663
|
+
const variables = catalog.variables.filter((one) => rankMatch(token, one.id) === best);
|
|
1664
|
+
const variableIds = new Set(variables.map((one) => one.id));
|
|
1665
|
+
const objects = catalog.containers.filter((one) => rankMatch(token, one.id) === best && !variableIds.has(one.id));
|
|
1666
|
+
return { variables, objects };
|
|
1667
|
+
}
|
|
1668
|
+
var list = (ids) => ids.map((entry) => ` ${describeEntry(entry)}`).join(`
|
|
1669
|
+
`);
|
|
1670
|
+
var SUGGESTION_LIMIT = 5;
|
|
1671
|
+
function resolveVariableToken(token, catalog, options) {
|
|
1672
|
+
const { listCommand, mode, prefer } = options;
|
|
1673
|
+
const best = bestMatches(token, catalog);
|
|
1674
|
+
const { objects } = best;
|
|
1675
|
+
const preferred = best.variables.filter((one) => prefer?.has(one.id));
|
|
1676
|
+
const matches = best.variables.length > 1 && objects.length === 0 && preferred.length === 1 ? preferred : best.variables;
|
|
1677
|
+
if (matches.length + objects.length > 1) {
|
|
1678
|
+
const everyMatch = [
|
|
1679
|
+
...matches,
|
|
1680
|
+
...objects.map((one) => ({
|
|
1681
|
+
id: `${one.id} (object)`,
|
|
1682
|
+
elementLabel: ""
|
|
1683
|
+
}))
|
|
1684
|
+
];
|
|
1685
|
+
throw new SelectionError(`"${token}" matches more than one variable:
|
|
1686
|
+
${list(everyMatch)}`, `Use the full id from the list above, or run '${listCommand}'.`);
|
|
1687
|
+
}
|
|
1688
|
+
if (matches.length === 1) {
|
|
1689
|
+
const [entry] = matches;
|
|
1690
|
+
if (!entry.taggable) {
|
|
1691
|
+
throw mode === "delete" ? new SelectionError(`"${entry.id}" is not tagged.`, `Run '${listCommand}' to see which variables are tagged.`, "not_found") : new SelectionError(`"${entry.id}" cannot be tagged: ${entry.reason ?? "not supported"}.`, `Run '${listCommand}' to see the variables you can tag.`);
|
|
1346
1692
|
}
|
|
1693
|
+
return entry;
|
|
1694
|
+
}
|
|
1695
|
+
const [container] = objects;
|
|
1696
|
+
if (container) {
|
|
1697
|
+
const fields = container.leafIds.map((id) => catalog.variables.find((entry) => entry.id === id)).filter((entry) => entry !== undefined);
|
|
1698
|
+
throw new SelectionError(fields.length > 0 ? `"${token}" is an object, not a field:
|
|
1699
|
+
${list(fields)}` : `"${token}" is an object with no fields to tag.`, fields.length > 0 ? "Name one of its fields, with the full id from the list above." : `Run '${listCommand}' to see the variables you can tag.`);
|
|
1347
1700
|
}
|
|
1348
|
-
const
|
|
1349
|
-
const
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1701
|
+
const needle = token.toLowerCase();
|
|
1702
|
+
const similar = catalog.variables.filter((entry) => entry.id.toLowerCase().includes(needle)).slice(0, SUGGESTION_LIMIT);
|
|
1703
|
+
throw new SelectionError(`No variable matches "${token}".${similar.length > 0 ? `
|
|
1704
|
+
Did you mean:
|
|
1705
|
+
${list(similar)}` : ""}`, `Run '${listCommand}' to see the variables you can tag.`, "not_found");
|
|
1706
|
+
}
|
|
1707
|
+
function computeDefaultLabels(selection) {
|
|
1708
|
+
const byTitle = new Map;
|
|
1709
|
+
for (const entry of selection) {
|
|
1710
|
+
byTitle.set(entry.defaultLabel, [
|
|
1711
|
+
...byTitle.get(entry.defaultLabel) ?? [],
|
|
1712
|
+
entry
|
|
1713
|
+
]);
|
|
1714
|
+
}
|
|
1715
|
+
const labels = new Map;
|
|
1716
|
+
for (const [title, group] of byTitle) {
|
|
1717
|
+
if (group.length === 1) {
|
|
1718
|
+
labels.set(group[0].id, title);
|
|
1719
|
+
continue;
|
|
1720
|
+
}
|
|
1721
|
+
const seen = new Map;
|
|
1722
|
+
for (const entry of group) {
|
|
1723
|
+
const base = entry.source ? `${entry.source} ${title}` : title;
|
|
1724
|
+
const count = (seen.get(base) ?? 0) + 1;
|
|
1725
|
+
seen.set(base, count);
|
|
1726
|
+
labels.set(entry.id, count > 1 ? `${base} (${count})` : base);
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
return labels;
|
|
1730
|
+
}
|
|
1731
|
+
var savedRowId = (elementId, row) => [elementId, row.name, ...row.extractPath ? [row.extractPath] : []].join(".");
|
|
1732
|
+
function readSavedRows(elements) {
|
|
1733
|
+
return Object.entries(elements ?? {}).flatMap(([elementId, element]) => (element.outputs ?? []).map((row) => ({
|
|
1734
|
+
id: savedRowId(elementId, row),
|
|
1735
|
+
elementId,
|
|
1736
|
+
row
|
|
1737
|
+
})));
|
|
1738
|
+
}
|
|
1739
|
+
var comparable = (row) => ({
|
|
1740
|
+
tags: [...row.tags ?? []].sort((a, b) => a.localeCompare(b)),
|
|
1741
|
+
label: row.label,
|
|
1742
|
+
type: row.extractedValueType
|
|
1743
|
+
});
|
|
1744
|
+
function canonical(elements) {
|
|
1745
|
+
return JSON.stringify(readSavedRows(elements).map(({ id, row }) => [id, comparable(row)]).sort((a, b) => a[0].localeCompare(b[0])));
|
|
1746
|
+
}
|
|
1747
|
+
function describeRewrite(before, after) {
|
|
1748
|
+
const was = comparable(before);
|
|
1749
|
+
const now = comparable(after);
|
|
1750
|
+
const parts = [
|
|
1751
|
+
...was.type === now.type ? [] : [`type ${was.type} -> ${now.type}`],
|
|
1752
|
+
...was.tags.join() === now.tags.join() ? [] : [`tags [${was.tags.join(", ")}] -> [${now.tags.join(", ")}]`]
|
|
1753
|
+
];
|
|
1754
|
+
return parts.length > 0 ? parts.join(", ") : undefined;
|
|
1755
|
+
}
|
|
1756
|
+
function buildElements(selection, stale) {
|
|
1757
|
+
const elements = buildVariableTagsElements(selection.map(({ entry, label }) => ({
|
|
1758
|
+
id: entry.id,
|
|
1759
|
+
label,
|
|
1760
|
+
extractedValueType: entry.extractedValueType
|
|
1761
|
+
})));
|
|
1762
|
+
for (const { elementId, row } of stale) {
|
|
1763
|
+
elements[elementId] ??= { outputs: [] };
|
|
1764
|
+
elements[elementId].outputs.push(structuredClone(row));
|
|
1765
|
+
}
|
|
1766
|
+
return elements;
|
|
1767
|
+
}
|
|
1768
|
+
var finish = (current, elements, next, stale) => {
|
|
1769
|
+
const before = new Map(current.map((one) => [one.id, one.row]));
|
|
1770
|
+
const nextIds = new Set([
|
|
1771
|
+
...next.map((one) => one.id),
|
|
1772
|
+
...stale.map((one) => one.id)
|
|
1773
|
+
]);
|
|
1774
|
+
const currentElements = Object.create(null);
|
|
1775
|
+
for (const { elementId, row } of current) {
|
|
1776
|
+
currentElements[elementId] ??= { outputs: [] };
|
|
1777
|
+
currentElements[elementId].outputs.push(row);
|
|
1778
|
+
}
|
|
1779
|
+
const rewritten = readSavedRows(elements).flatMap(({ id, row }) => {
|
|
1780
|
+
const was = before.get(id);
|
|
1781
|
+
const change = was && describeRewrite(was, row);
|
|
1782
|
+
return change ? [{ id, change }] : [];
|
|
1355
1783
|
});
|
|
1784
|
+
return {
|
|
1785
|
+
elements,
|
|
1786
|
+
changed: canonical(elements) !== canonical(currentElements),
|
|
1787
|
+
added: next.filter((one) => !before.has(one.id)).map((one) => one.id),
|
|
1788
|
+
removed: current.filter((one) => !nextIds.has(one.id)).map((one) => one.id),
|
|
1789
|
+
relabeled: next.filter((one) => before.has(one.id) && before.get(one.id)?.label !== one.label).map((one) => one.id),
|
|
1790
|
+
rewritten,
|
|
1791
|
+
collapsed: before.size < current.length
|
|
1792
|
+
};
|
|
1356
1793
|
};
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
const
|
|
1360
|
-
|
|
1361
|
-
|
|
1794
|
+
function splitSaved(variables, saved) {
|
|
1795
|
+
const taggable = new Set(variables.filter((one) => one.taggable).map((one) => one.id));
|
|
1796
|
+
const live = new Map;
|
|
1797
|
+
const stale = [];
|
|
1798
|
+
const seen = new Set;
|
|
1799
|
+
for (const one of saved) {
|
|
1800
|
+
if (seen.has(one.id))
|
|
1801
|
+
continue;
|
|
1802
|
+
seen.add(one.id);
|
|
1803
|
+
if (taggable.has(one.id))
|
|
1804
|
+
live.set(one.id, one);
|
|
1805
|
+
else
|
|
1806
|
+
stale.push(one);
|
|
1362
1807
|
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1808
|
+
return { live, stale };
|
|
1809
|
+
}
|
|
1810
|
+
function checkRequests(requests) {
|
|
1811
|
+
const explicit = new Map;
|
|
1812
|
+
for (const { id, label } of requests) {
|
|
1813
|
+
if (label === undefined)
|
|
1814
|
+
continue;
|
|
1815
|
+
const trimmed = label.trim();
|
|
1816
|
+
if (trimmed === "") {
|
|
1817
|
+
throw new SelectionError(`The label for "${id}" is empty.`, "Give a label after '=', or leave the '=' out to use the default label.");
|
|
1818
|
+
}
|
|
1819
|
+
const earlier = explicit.get(id);
|
|
1820
|
+
if (earlier !== undefined && earlier !== trimmed) {
|
|
1821
|
+
throw new SelectionError(`"${id}" was given two different labels ("${earlier}" and "${trimmed}").`, "Give each variable one label.");
|
|
1822
|
+
}
|
|
1823
|
+
explicit.set(id, trimmed);
|
|
1365
1824
|
}
|
|
1366
|
-
|
|
1367
|
-
|
|
1825
|
+
return explicit;
|
|
1826
|
+
}
|
|
1827
|
+
function planAdd(input) {
|
|
1828
|
+
const { variables, saved, requests } = input;
|
|
1829
|
+
const { live, stale } = splitSaved(variables, saved);
|
|
1830
|
+
const wanted = new Set(requests === "all" ? variables.filter((one) => one.taggable).map((one) => one.id) : requests.map((one) => one.id));
|
|
1831
|
+
const explicit = checkRequests(requests === "all" ? [] : requests);
|
|
1832
|
+
const selected = variables.filter((one) => one.taggable && (live.has(one.id) || wanted.has(one.id)));
|
|
1833
|
+
const defaults = computeDefaultLabels(selected);
|
|
1834
|
+
const labelled = selected.map((entry) => ({
|
|
1835
|
+
entry,
|
|
1836
|
+
label: explicit.get(entry.id) ?? live.get(entry.id)?.row.label ?? defaults.get(entry.id) ?? entry.name
|
|
1837
|
+
}));
|
|
1838
|
+
const owners = new Map;
|
|
1839
|
+
const everyLabel = [
|
|
1840
|
+
...labelled.map(({ entry, label }) => ({ id: entry.id, label })),
|
|
1841
|
+
...stale.map((one) => ({ id: one.id, label: one.row.label }))
|
|
1842
|
+
];
|
|
1843
|
+
for (const { id, label } of everyLabel) {
|
|
1844
|
+
const trimmed = label.trim();
|
|
1845
|
+
if (trimmed === "") {
|
|
1846
|
+
throw new SelectionError(`The saved label of "${id}" is empty.`, `Give it a label, as '<variable>=<label>'.`);
|
|
1847
|
+
}
|
|
1848
|
+
const owner = owners.get(trimmed);
|
|
1849
|
+
if (owner !== undefined && owner !== id) {
|
|
1850
|
+
throw new SelectionError(`The label "${trimmed}" would be used by both "${owner}" and "${id}"; labels must be unique.`, "Give one of them another label, as '<variable>=<label>'.");
|
|
1851
|
+
}
|
|
1852
|
+
owners.set(trimmed, id);
|
|
1368
1853
|
}
|
|
1369
|
-
const
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1854
|
+
const elements = buildElements(labelled.map(({ entry, label }) => ({ entry, label: label.trim() })), stale);
|
|
1855
|
+
return finish(saved, elements, labelled.map(({ entry, label }) => ({
|
|
1856
|
+
id: entry.id,
|
|
1857
|
+
label: label.trim()
|
|
1858
|
+
})), stale);
|
|
1859
|
+
}
|
|
1860
|
+
function planRemove(input) {
|
|
1861
|
+
const { variables, saved, ids } = input;
|
|
1862
|
+
const drop = ids === "all" ? undefined : new Set(ids);
|
|
1863
|
+
const { live, stale } = splitSaved(variables, saved);
|
|
1864
|
+
const keptStale = drop ? stale.filter((one) => !drop.has(one.id)) : [];
|
|
1865
|
+
const kept = variables.filter((one) => one.taggable && live.has(one.id) && (drop === undefined ? false : !drop.has(one.id))).map((entry) => ({
|
|
1866
|
+
entry,
|
|
1867
|
+
label: live.get(entry.id)?.row.label ?? entry.name
|
|
1868
|
+
}));
|
|
1869
|
+
return finish(saved, buildElements(kept, keptStale), kept.map(({ entry, label }) => ({ id: entry.id, label })), keptStale);
|
|
1870
|
+
}
|
|
1871
|
+
function removableCatalog(catalog, saved) {
|
|
1872
|
+
const savedIds = new Set(saved.map((one) => one.id));
|
|
1873
|
+
const known = new Set(catalog.variables.map((one) => one.id));
|
|
1874
|
+
const added = new Set;
|
|
1875
|
+
const savedOnly = [];
|
|
1876
|
+
for (const one of saved) {
|
|
1877
|
+
if (known.has(one.id) || added.has(one.id))
|
|
1878
|
+
continue;
|
|
1879
|
+
added.add(one.id);
|
|
1880
|
+
savedOnly.push({
|
|
1881
|
+
id: one.id,
|
|
1882
|
+
name: one.row.name,
|
|
1883
|
+
elementId: one.elementId,
|
|
1884
|
+
extractPath: one.row.extractPath,
|
|
1885
|
+
extractedValueType: "String",
|
|
1886
|
+
defaultLabel: one.row.label,
|
|
1887
|
+
elementLabel: one.elementId,
|
|
1888
|
+
source: one.elementId,
|
|
1889
|
+
taggable: true
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
1892
|
+
return {
|
|
1893
|
+
containers: catalog.containers,
|
|
1894
|
+
variables: [
|
|
1895
|
+
...catalog.variables.map((entry) => ({
|
|
1896
|
+
...entry,
|
|
1897
|
+
taggable: entry.taggable || savedIds.has(entry.id)
|
|
1898
|
+
})),
|
|
1899
|
+
...savedOnly
|
|
1900
|
+
]
|
|
1901
|
+
};
|
|
1902
|
+
}
|
|
1903
|
+
function buildListRows(variables, saved) {
|
|
1904
|
+
const savedById = new Map(saved.map((one) => [one.id, one]));
|
|
1905
|
+
const rows = groupByElement(variables).map((entry) => {
|
|
1906
|
+
const row = savedById.get(entry.id);
|
|
1907
|
+
return {
|
|
1908
|
+
Element: entry.elementLabel,
|
|
1909
|
+
Variable: entry.extractPath ? `${entry.name}.${entry.extractPath}` : entry.name,
|
|
1910
|
+
Id: entry.id,
|
|
1911
|
+
Tagged: row !== undefined,
|
|
1912
|
+
Label: row?.row.label ?? "",
|
|
1913
|
+
Stale: row !== undefined && !entry.taggable,
|
|
1914
|
+
Note: entry.taggable ? entry.note ?? "" : entry.reason ?? "not taggable"
|
|
1915
|
+
};
|
|
1916
|
+
});
|
|
1917
|
+
const known = new Set(variables.map((one) => one.id));
|
|
1918
|
+
const arrays = variables.filter((one) => one.array);
|
|
1919
|
+
for (const one of saved) {
|
|
1920
|
+
if (known.has(one.id))
|
|
1921
|
+
continue;
|
|
1922
|
+
known.add(one.id);
|
|
1923
|
+
const underArray = arrays.some((array) => one.id.startsWith(`${array.id}.`));
|
|
1924
|
+
rows.push({
|
|
1925
|
+
Element: one.elementId,
|
|
1926
|
+
Variable: one.row.extractPath ? `${one.row.name}.${one.row.extractPath}` : one.row.name,
|
|
1927
|
+
Id: one.id,
|
|
1928
|
+
Tagged: true,
|
|
1929
|
+
Label: one.row.label,
|
|
1930
|
+
Stale: !underArray,
|
|
1931
|
+
Note: underArray ? "saved in the Maestro UI on an array field; the CLI cannot edit it yet" : "saved, but this version no longer declares it"
|
|
1932
|
+
});
|
|
1374
1933
|
}
|
|
1375
|
-
|
|
1376
|
-
|
|
1934
|
+
return rows;
|
|
1935
|
+
}
|
|
1936
|
+
function groupByElement(variables) {
|
|
1937
|
+
const groups = new Map;
|
|
1938
|
+
for (const entry of variables) {
|
|
1939
|
+
const group = groups.get(entry.elementLabel);
|
|
1940
|
+
if (group)
|
|
1941
|
+
group.push(entry);
|
|
1942
|
+
else
|
|
1943
|
+
groups.set(entry.elementLabel, [entry]);
|
|
1377
1944
|
}
|
|
1378
|
-
|
|
1379
|
-
|
|
1945
|
+
return [...groups.values()].flat();
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
// ../maestro-sdk/src/shared-commands/variable-tags-commands.ts
|
|
1949
|
+
var PROCESS_TYPES = {
|
|
1950
|
+
ProcessOrchestration: {
|
|
1951
|
+
label: "Maestro BPMN",
|
|
1952
|
+
tool: () => "uip maestro bpmn"
|
|
1953
|
+
},
|
|
1954
|
+
Flow: {
|
|
1955
|
+
label: "Flow",
|
|
1956
|
+
tool: (mount) => mount === "maestro" /* Maestro */ ? "uip maestro flow" : "uip flow"
|
|
1957
|
+
},
|
|
1958
|
+
CaseManagement: {
|
|
1959
|
+
label: "Case Management",
|
|
1960
|
+
tool: (mount) => mount === "maestro" /* Maestro */ ? "uip maestro case" : "uip case"
|
|
1380
1961
|
}
|
|
1381
|
-
return null;
|
|
1382
1962
|
};
|
|
1383
|
-
var
|
|
1384
|
-
|
|
1385
|
-
|
|
1963
|
+
var isMaestroProcessType = (type) => Object.hasOwn(PROCESS_TYPES, type);
|
|
1964
|
+
function mountedPrefix(group) {
|
|
1965
|
+
const names = [];
|
|
1966
|
+
for (let at = group;at?.parent; at = at.parent) {
|
|
1967
|
+
names.unshift(at.name());
|
|
1968
|
+
}
|
|
1969
|
+
const tool = names.slice(0, -2);
|
|
1970
|
+
return tool.length > 0 ? ["uip", ...tool].join(" ") : undefined;
|
|
1971
|
+
}
|
|
1972
|
+
var FLOW_NOTE = "Filtering instances by these values in the Maestro UI needs Flow variable filtering to be enabled on the tenant.";
|
|
1973
|
+
async function fail(nextStep, error) {
|
|
1974
|
+
if (error instanceof SelectionError) {
|
|
1975
|
+
if (error.errorCode === "invalid_argument") {
|
|
1976
|
+
failInvalid(error.message, error.instructions);
|
|
1977
|
+
return;
|
|
1978
|
+
}
|
|
1979
|
+
failNotFound(error.message, error.instructions);
|
|
1980
|
+
return;
|
|
1981
|
+
}
|
|
1982
|
+
const failure = await classifiedFailure(nextStep, error);
|
|
1983
|
+
OutputFormatter.error({
|
|
1984
|
+
...failure,
|
|
1985
|
+
Message: failure.Instructions,
|
|
1986
|
+
Instructions: nextStep
|
|
1987
|
+
});
|
|
1988
|
+
processContext.exit(1);
|
|
1989
|
+
}
|
|
1990
|
+
function failInvalid(message, instructions) {
|
|
1991
|
+
OutputFormatter.error({
|
|
1992
|
+
Result: RESULTS.ValidationError,
|
|
1993
|
+
ErrorCode: "invalid_argument",
|
|
1994
|
+
Message: message,
|
|
1995
|
+
Instructions: instructions,
|
|
1996
|
+
Retry: "RetryWillNotFix"
|
|
1997
|
+
});
|
|
1998
|
+
processContext.exit(EXIT_CODES.ValidationError);
|
|
1999
|
+
}
|
|
2000
|
+
function failNotFound(message, instructions) {
|
|
2001
|
+
OutputFormatter.error({
|
|
2002
|
+
Result: RESULTS.Failure,
|
|
2003
|
+
ErrorCode: "not_found",
|
|
2004
|
+
Message: message,
|
|
2005
|
+
Instructions: instructions,
|
|
2006
|
+
Retry: "RetryWillNotFix"
|
|
2007
|
+
});
|
|
2008
|
+
processContext.exit(1);
|
|
2009
|
+
}
|
|
2010
|
+
var settingsPath = (processKey) => `/processes/${encodeURIComponent(processKey)}/settings`;
|
|
2011
|
+
var shellWord = (value) => /^[\w.-]+$/.test(value) ? value : `"${value.replace(/(["\\$`])/g, "\\$1")}"`;
|
|
2012
|
+
function wrongToolFailure(config, mount, processKey, folderKey, processType) {
|
|
2013
|
+
if (!processType || processType === "Undefined" || processType === config.expectedProcessType) {
|
|
2014
|
+
return;
|
|
2015
|
+
}
|
|
2016
|
+
const expected = PROCESS_TYPES[config.expectedProcessType];
|
|
2017
|
+
const key = `${shellWord(processKey)} -f ${shellWord(folderKey)}`;
|
|
2018
|
+
if (isMaestroProcessType(processType)) {
|
|
2019
|
+
const owner = PROCESS_TYPES[processType];
|
|
2020
|
+
return {
|
|
2021
|
+
message: `Process '${processKey}' is a ${owner.label} process, not a ${expected.label} process.`,
|
|
2022
|
+
instructions: `Use '${owner.tool(mount)} process variable-tags list ${key}' instead.`
|
|
2023
|
+
};
|
|
2024
|
+
}
|
|
2025
|
+
const lists = Object.values(PROCESS_TYPES).map((one) => `'${one.tool(mount)} process list -f ${shellWord(folderKey)}'`);
|
|
1386
2026
|
return {
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
all: options.all,
|
|
1390
|
-
addTags: options.searchable ? SEARCHABLE_TAG : undefined,
|
|
1391
|
-
removeTags: options.searchable ? undefined : SEARCHABLE_TAG
|
|
2027
|
+
message: `Process '${processKey}' has process type '${processType}'; only Maestro BPMN, Flow and Case Management processes have variables to tag.`,
|
|
2028
|
+
instructions: `Pick a process of one of those types: ${lists.slice(0, -1).join(", ")} or ${lists.at(-1)}.`
|
|
1392
2029
|
};
|
|
1393
|
-
}
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
processContext.exit(1);
|
|
2030
|
+
}
|
|
2031
|
+
async function deriveCatalog(assetType, definition) {
|
|
2032
|
+
if (assetType === "bpmn") {
|
|
2033
|
+
if (typeof definition !== "string")
|
|
2034
|
+
return;
|
|
2035
|
+
const { deriveTaggableVariables } = await import("./taggable-variables-gc58xb0s.js");
|
|
2036
|
+
return deriveTaggableVariables(definition);
|
|
2037
|
+
}
|
|
2038
|
+
if (typeof definition !== "string" && typeof definition !== "object") {
|
|
1403
2039
|
return;
|
|
1404
2040
|
}
|
|
1405
|
-
if (
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
2041
|
+
if (definition === null)
|
|
2042
|
+
return;
|
|
2043
|
+
const { deriveCaseTaggableVariables } = await import("./case-catalog-h4fjn6q3.js");
|
|
2044
|
+
return deriveCaseTaggableVariables(definition);
|
|
2045
|
+
}
|
|
2046
|
+
async function loadProcess(config, mount, prefix, processKey, options) {
|
|
2047
|
+
const { folderKey } = options;
|
|
2048
|
+
const reqOptions = { folderKey };
|
|
2049
|
+
const listCommand = `${prefix} process variable-tags list ${shellWord(processKey)} -f ${shellWord(folderKey)}`;
|
|
2050
|
+
const [releaseError, release] = await catchError2(lookupRelease(processKey, folderKey));
|
|
2051
|
+
if (releaseError) {
|
|
2052
|
+
await fail(`Check both keys with '${prefix} process list -f ${shellWord(folderKey)}'.`, releaseError);
|
|
1412
2053
|
return;
|
|
1413
2054
|
}
|
|
1414
|
-
const
|
|
1415
|
-
|
|
1416
|
-
|
|
2055
|
+
const wrongTool = wrongToolFailure(config, mount, processKey, folderKey, release.processType);
|
|
2056
|
+
if (wrongTool) {
|
|
2057
|
+
failInvalid(wrongTool.message, wrongTool.instructions);
|
|
1417
2058
|
return;
|
|
1418
|
-
|
|
1419
|
-
const
|
|
1420
|
-
if (!
|
|
2059
|
+
}
|
|
2060
|
+
const version = options.processVersion ?? release.processVersion;
|
|
2061
|
+
if (!version) {
|
|
2062
|
+
failNotFound(`Process '${processKey}' has no version on record.`, "Pass --process-version <version>.");
|
|
1421
2063
|
return;
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
});
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
const
|
|
1430
|
-
|
|
1431
|
-
|
|
2064
|
+
}
|
|
2065
|
+
const settings = await withPimsCall((pims) => pimsGet(pims, settingsPath(processKey), reqOptions), `Could not read the settings of process '${processKey}'`, { resource: "process", id: processKey });
|
|
2066
|
+
if (!settings)
|
|
2067
|
+
return;
|
|
2068
|
+
const definition = await withPimsCall((pims) => pimsGet(pims, `/processes/${encodeURIComponent(processKey)}/asset?type=${config.assetType}&processVersion=${encodeURIComponent(version)}`, reqOptions), `Could not read version ${version} of process '${processKey}'`, { resource: "process version", id: version });
|
|
2069
|
+
if (definition === undefined)
|
|
2070
|
+
return;
|
|
2071
|
+
const [parseError, catalog] = await catchError2(deriveCatalog(config.assetType, definition));
|
|
2072
|
+
if (parseError) {
|
|
2073
|
+
await fail(`Check the version with --process-version, or run '${listCommand}' on another one.`, parseError);
|
|
2074
|
+
return;
|
|
2075
|
+
}
|
|
2076
|
+
if (!catalog) {
|
|
2077
|
+
failNotFound(`Version ${version} of process '${processKey}' did not return a ${config.assetType === "bpmn" ? "BPMN" : "case"} document.`, "Pass --process-version with a version that exists.");
|
|
1432
2078
|
return;
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
2079
|
+
}
|
|
2080
|
+
return {
|
|
2081
|
+
processKey,
|
|
2082
|
+
folderKey,
|
|
2083
|
+
settings,
|
|
2084
|
+
catalog,
|
|
2085
|
+
saved: readSavedRows(settings.variableTags?.elements)
|
|
1437
2086
|
};
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
2087
|
+
}
|
|
2088
|
+
function parseVariableArgument(raw) {
|
|
2089
|
+
const at = raw.indexOf("=");
|
|
2090
|
+
return at < 0 ? { token: raw.trim() } : { token: raw.slice(0, at).trim(), label: raw.slice(at + 1) };
|
|
2091
|
+
}
|
|
2092
|
+
async function applyPlan(config, loaded, plan, options, codes) {
|
|
2093
|
+
const rows = buildListRows(loaded.catalog.variables, readSavedRows(plan.elements)).filter((row) => row.Tagged);
|
|
2094
|
+
const changes = [
|
|
2095
|
+
...plan.added.map((id) => `added ${id}`),
|
|
2096
|
+
...plan.relabeled.map((id) => `relabeled ${id}`),
|
|
2097
|
+
...plan.removed.map((id) => `removed ${id}`),
|
|
2098
|
+
...plan.rewritten.map(({ id, change }) => `rewrote ${id} (${change})`),
|
|
2099
|
+
...plan.collapsed ? ["collapsed a row saved twice"] : []
|
|
2100
|
+
].join(", ") || "rewrote the saved selection";
|
|
2101
|
+
const flowNote = config.expectedProcessType === "Flow" ? ` ${FLOW_NOTE}` : "";
|
|
2102
|
+
if (!plan.changed) {
|
|
2103
|
+
OutputFormatter.success({
|
|
2104
|
+
Result: RESULTS.Success,
|
|
2105
|
+
Code: codes.done,
|
|
2106
|
+
Data: rows,
|
|
2107
|
+
Instructions: "Nothing to change; the saved selection already matches."
|
|
1444
2108
|
});
|
|
1445
|
-
processContext.exit(1);
|
|
1446
2109
|
return;
|
|
1447
2110
|
}
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
2111
|
+
if (options.dryRun) {
|
|
2112
|
+
OutputFormatter.success({
|
|
2113
|
+
Result: RESULTS.Success,
|
|
2114
|
+
Code: "ProcessVariableTagsDryRun",
|
|
2115
|
+
Data: rows,
|
|
2116
|
+
Instructions: `Dry run, nothing saved. Would have ${changes}. Run again without --dry-run to apply.`
|
|
2117
|
+
});
|
|
2118
|
+
return;
|
|
2119
|
+
}
|
|
2120
|
+
const body = {
|
|
2121
|
+
...loaded.settings,
|
|
2122
|
+
variableTags: {
|
|
2123
|
+
elements: plan.elements,
|
|
2124
|
+
lastUpdateTimeUtc: new Date().toISOString(),
|
|
2125
|
+
sourcePackageVersion: loaded.processKey.toLowerCase()
|
|
2126
|
+
}
|
|
2127
|
+
};
|
|
2128
|
+
const saved = await withPimsCall((pims) => pimsPut(pims, settingsPath(loaded.processKey), body, { folderKey: loaded.folderKey }), `Error ${codes.verb} variable tags`);
|
|
2129
|
+
if (!saved)
|
|
1451
2130
|
return;
|
|
1452
2131
|
OutputFormatter.success({
|
|
1453
2132
|
Result: RESULTS.Success,
|
|
1454
|
-
Code:
|
|
1455
|
-
Data:
|
|
2133
|
+
Code: codes.done,
|
|
2134
|
+
Data: rows,
|
|
2135
|
+
Instructions: `Saved: ${changes}.${flowNote}`
|
|
2136
|
+
});
|
|
2137
|
+
}
|
|
2138
|
+
function checkTargets(listCommand, variables, options, verb) {
|
|
2139
|
+
if (variables.length > 0 && options.all) {
|
|
2140
|
+
failInvalid("Both --variables and --all were given.", "Pass --variables, or --all, not both.");
|
|
2141
|
+
return false;
|
|
2142
|
+
}
|
|
2143
|
+
if (variables.length === 0 && !options.all) {
|
|
2144
|
+
failInvalid("No variable given.", `Pass --variables with one or more variables to ${verb}, or --all. Run '${listCommand}' to see them.`);
|
|
2145
|
+
return false;
|
|
2146
|
+
}
|
|
2147
|
+
return true;
|
|
2148
|
+
}
|
|
2149
|
+
var PROCESS_ARGUMENT = "Process key (GUID)";
|
|
2150
|
+
var FOLDER_KEY_OPTION = "Folder key (GUID)";
|
|
2151
|
+
var VERSION_OPTION = "Process version whose variables are offered (default: the version new instances run)";
|
|
2152
|
+
var registerVariableTagsCommands = (variableTagsCmd, config) => {
|
|
2153
|
+
const { toolLabel } = config;
|
|
2154
|
+
const prefixNow = () => mountedPrefix(variableTagsCmd) ?? config.commandPrefix;
|
|
2155
|
+
const mountNow = () => mountedPrefix(variableTagsCmd)?.startsWith("uip maestro") ? "maestro" /* Maestro */ : "tool" /* Tool */;
|
|
2156
|
+
const flowDescription = config.expectedProcessType === "Flow" ? " Flow instances can only be filtered by these values where the tenant has Flow variable filtering enabled." : "";
|
|
2157
|
+
const listCommandFor = (processKey, folderKey) => `${prefixNow()} process variable-tags list ${shellWord(processKey)} -f ${shellWord(folderKey)}`;
|
|
2158
|
+
const scope = (command) => command.requiredOption("-f, --folder-key <key>", FOLDER_KEY_OPTION).option("--process-version <version>", VERSION_OPTION);
|
|
2159
|
+
const removed = (name, replacement) => variableTagsCmd.command(name, { hidden: true }).allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, async () => {
|
|
2160
|
+
failInvalid(`'variable-tags ${name}' was removed.`, replacement(prefixNow()));
|
|
2161
|
+
});
|
|
2162
|
+
const KEYS = "<process-key> -f <folder-key>";
|
|
2163
|
+
removed("get", (prefix) => `Use '${prefix} process variable-tags list ${KEYS}' to see which variables are tagged.`);
|
|
2164
|
+
removed("set", (prefix) => `Use '${prefix} process variable-tags create ${KEYS} --variables <variable>' to tag a variable, or 'delete' to untag one; 'list' shows the variables.`);
|
|
2165
|
+
scope(variableTagsCmd.command("list").description(`List the variables a ${toolLabel} process lets you tag for instance filtering, and which are tagged.${flowDescription}`).argument("<process-key>", PROCESS_ARGUMENT)).trackedAction(processContext, async (processKey, options) => {
|
|
2166
|
+
const loaded = await loadProcess(config, mountNow(), prefixNow(), processKey, options);
|
|
2167
|
+
if (!loaded)
|
|
2168
|
+
return;
|
|
2169
|
+
const empty = loaded.catalog.variables.length === 0 && loaded.saved.length === 0;
|
|
2170
|
+
OutputFormatter.success({
|
|
2171
|
+
Result: RESULTS.Success,
|
|
2172
|
+
Code: "ProcessVariableTagsList",
|
|
2173
|
+
Data: buildListRows(loaded.catalog.variables, loaded.saved),
|
|
2174
|
+
...empty && {
|
|
2175
|
+
Instructions: "This version of the process declares no variables that can be tagged."
|
|
2176
|
+
}
|
|
2177
|
+
});
|
|
2178
|
+
});
|
|
2179
|
+
scope(variableTagsCmd.command("create").description(`Tag variables so ${toolLabel} process instances can be filtered by them. Name a variable as <name>, <element>.<name> or <element>.<name>.<field>, or by the id 'list' shows; append =<label> to set its label.${flowDescription}`).argument("<process-key>", PROCESS_ARGUMENT).option("--variables <variable...>", "Variables to tag, as <variable>[=<label>]").option("--all", "Tag every variable that can be tagged").option("--dry-run", "Show the result without saving it")).trackedAction(processContext, async (processKey, options) => {
|
|
2180
|
+
const listCommand = listCommandFor(processKey, options.folderKey);
|
|
2181
|
+
const variables = options.variables ?? [];
|
|
2182
|
+
if (!checkTargets(listCommand, variables, options, "tag"))
|
|
2183
|
+
return;
|
|
2184
|
+
const loaded = await loadProcess(config, mountNow(), prefixNow(), processKey, options);
|
|
2185
|
+
if (!loaded)
|
|
2186
|
+
return;
|
|
2187
|
+
const [planError, plan] = catchError2(() => {
|
|
2188
|
+
const requests = variables.map((raw) => {
|
|
2189
|
+
const { token, label } = parseVariableArgument(raw);
|
|
2190
|
+
const entry = resolveVariableToken(token, loaded.catalog, {
|
|
2191
|
+
listCommand,
|
|
2192
|
+
mode: "create"
|
|
2193
|
+
});
|
|
2194
|
+
return { id: entry.id, label };
|
|
2195
|
+
});
|
|
2196
|
+
return planAdd({
|
|
2197
|
+
variables: loaded.catalog.variables,
|
|
2198
|
+
saved: loaded.saved,
|
|
2199
|
+
requests: options.all ? "all" : requests
|
|
2200
|
+
});
|
|
2201
|
+
});
|
|
2202
|
+
if (planError) {
|
|
2203
|
+
await fail(`Run '${listCommand}' to see the variables you can tag.`, planError);
|
|
2204
|
+
return;
|
|
2205
|
+
}
|
|
2206
|
+
await applyPlan(config, loaded, plan, options, {
|
|
2207
|
+
done: "ProcessVariableTagsCreated",
|
|
2208
|
+
verb: "creating"
|
|
2209
|
+
});
|
|
2210
|
+
});
|
|
2211
|
+
scope(variableTagsCmd.command("delete").description(`Stop tagging variables. Name a variable as <name>, <element>.<name> or <element>.<name>.<field>, or by the id 'list' shows; a saved variable the process no longer declares can be untagged too.${flowDescription}`).argument("<process-key>", PROCESS_ARGUMENT).option("--variables <variable...>", "Variables to untag").option("--all", "Untag every variable, including ones the process no longer declares").option("--yes", "Confirm --all").option("--dry-run", "Show the result without saving it")).trackedAction(processContext, async (processKey, options) => {
|
|
2212
|
+
const listCommand = listCommandFor(processKey, options.folderKey);
|
|
2213
|
+
const variables = options.variables ?? [];
|
|
2214
|
+
if (!checkTargets(listCommand, variables, options, "untag")) {
|
|
2215
|
+
return;
|
|
2216
|
+
}
|
|
2217
|
+
if (options.all && !options.yes && !options.dryRun) {
|
|
2218
|
+
failInvalid("--all untags every variable and needs confirmation.", "Add --yes to confirm, or --dry-run to preview it.");
|
|
2219
|
+
return;
|
|
2220
|
+
}
|
|
2221
|
+
const loaded = await loadProcess(config, mountNow(), prefixNow(), processKey, options);
|
|
2222
|
+
if (!loaded)
|
|
2223
|
+
return;
|
|
2224
|
+
const [planError, plan] = catchError2(() => {
|
|
2225
|
+
const savedIds = new Set(loaded.saved.map((one) => one.id));
|
|
2226
|
+
const resolvable = removableCatalog(loaded.catalog, loaded.saved);
|
|
2227
|
+
const ids = variables.map((raw) => resolveVariableToken(parseVariableArgument(raw).token, resolvable, { listCommand, mode: "delete", prefer: savedIds }).id);
|
|
2228
|
+
return planRemove({
|
|
2229
|
+
variables: loaded.catalog.variables,
|
|
2230
|
+
saved: loaded.saved,
|
|
2231
|
+
ids: options.all ? "all" : ids
|
|
2232
|
+
});
|
|
2233
|
+
});
|
|
2234
|
+
if (planError) {
|
|
2235
|
+
await fail(`Run '${listCommand}' to see which variables are tagged.`, planError);
|
|
2236
|
+
return;
|
|
2237
|
+
}
|
|
2238
|
+
await applyPlan(config, loaded, plan, options, {
|
|
2239
|
+
done: "ProcessVariableTagsDeleted",
|
|
2240
|
+
verb: "deleting"
|
|
2241
|
+
});
|
|
1456
2242
|
});
|
|
1457
2243
|
};
|
|
2244
|
+
|
|
2245
|
+
// ../maestro-sdk/src/shared-commands/process.ts
|
|
1458
2246
|
var registerSharedProcessCommands = (processCmd, config) => {
|
|
1459
2247
|
const { toolLabel } = config;
|
|
1460
2248
|
const settingsCmd = processCmd.command("settings").description(`Manage ${toolLabel} process settings`);
|
|
@@ -1467,7 +2255,7 @@ var registerSharedProcessCommands = (processCmd, config) => {
|
|
|
1467
2255
|
Result: RESULTS.Success,
|
|
1468
2256
|
Code: "ProcessSettingsGet",
|
|
1469
2257
|
Data: result
|
|
1470
|
-
});
|
|
2258
|
+
}, { preserveDataKeys: ["elements"] });
|
|
1471
2259
|
});
|
|
1472
2260
|
settingsCmd.command("set").description(`Update settings for a ${toolLabel} process`).argument("<process-key>", "Process definition key").requiredOption("-f, --folder-key <key>", "Folder key (GUID)").option("--inputs <value>", "Settings payload as JSON string, @file path, or piped via stdin").trackedAction(processContext, async (processKey, options) => {
|
|
1473
2261
|
const [fileError, body] = await catchError2(resolveJsonInput({
|
|
@@ -1500,52 +2288,19 @@ var registerSharedProcessCommands = (processCmd, config) => {
|
|
|
1500
2288
|
Result: RESULTS.Success,
|
|
1501
2289
|
Code: "ProcessSettingsSet",
|
|
1502
2290
|
Data: result
|
|
1503
|
-
});
|
|
2291
|
+
}, { preserveDataKeys: ["elements"] });
|
|
1504
2292
|
});
|
|
1505
2293
|
const variableTagsCmd = processCmd.command("variable-tags").description(`Manage ${toolLabel} process variable tags`);
|
|
1506
|
-
variableTagsCmd
|
|
1507
|
-
const reqOptions = { folderKey: options.folderKey };
|
|
1508
|
-
const result = await withPimsCall((config) => pimsGet(config, `/processes/${encodeURIComponent(processKey)}/settings`, reqOptions), "Error getting variable tags", { resource: "process", id: processKey });
|
|
1509
|
-
if (!result)
|
|
1510
|
-
return;
|
|
1511
|
-
OutputFormatter.success({
|
|
1512
|
-
Result: RESULTS.Success,
|
|
1513
|
-
Code: "ProcessVariableTagsGet",
|
|
1514
|
-
Data: result.variableTags ?? {}
|
|
1515
|
-
});
|
|
1516
|
-
});
|
|
1517
|
-
variableTagsCmd.command("set").description(`Update variable tags for a ${toolLabel} process`).argument("<process-key>", "Process definition key").requiredOption("-f, --folder-key <key>", "Folder key (GUID)").option("--variable <name>", "Name of a variable (output) to tag. Repeatable — pass it multiple times to tag several variables in one call.", collectValue, []).option("--element-id <id>", "Element that owns the variable (disambiguates when the same name appears in multiple elements). Only valid with a single --variable.").option("--all", "Apply the change to every taggable variable").option("--searchable <boolean>", "Mark the variable searchable for instance filtering ('true' or 'false')", parseBooleanFlag).option("--tags <list>", "Advanced: comma-separated tags to set, replacing the variable's current tags (empty value clears them)").option("--add-tags <list>", "Comma-separated tags to add to the variable's current tags").option("--remove-tags <list>", "Comma-separated tags to remove from the variable's current tags").option("--inputs <value>", "Full variable tags payload as JSON string, @file path, or piped via stdin").trackedAction(processContext, async (processKey, options) => {
|
|
1518
|
-
const friendlyRequested = options.variable.length > 0 || options.elementId !== undefined || options.all === true || options.searchable !== undefined || options.tags !== undefined || options.addTags !== undefined || options.removeTags !== undefined;
|
|
1519
|
-
if (options.inputs !== undefined && friendlyRequested) {
|
|
1520
|
-
OutputFormatter.error({
|
|
1521
|
-
Result: RESULTS.Failure,
|
|
1522
|
-
Message: "Error updating variable tags",
|
|
1523
|
-
Instructions: "Provide either --inputs (full JSON payload) or the --searchable/--variable/--all flags, not both."
|
|
1524
|
-
});
|
|
1525
|
-
processContext.exit(1);
|
|
1526
|
-
return;
|
|
1527
|
-
}
|
|
1528
|
-
if (friendlyRequested) {
|
|
1529
|
-
const validationError = validateFriendlyTagFlags(options);
|
|
1530
|
-
if (validationError) {
|
|
1531
|
-
OutputFormatter.error({
|
|
1532
|
-
Result: RESULTS.Failure,
|
|
1533
|
-
Message: "Error updating variable tags",
|
|
1534
|
-
Instructions: validationError
|
|
1535
|
-
});
|
|
1536
|
-
processContext.exit(1);
|
|
1537
|
-
return;
|
|
1538
|
-
}
|
|
1539
|
-
await setVariableTagsFromFlags(processKey, options);
|
|
1540
|
-
return;
|
|
1541
|
-
}
|
|
1542
|
-
await setVariableTagsFromPayload(processKey, options);
|
|
1543
|
-
});
|
|
2294
|
+
registerVariableTagsCommands(variableTagsCmd, config);
|
|
1544
2295
|
attachSharedExamples(settingsCmd);
|
|
1545
2296
|
attachSharedExamples(variableTagsCmd);
|
|
1546
2297
|
};
|
|
1547
2298
|
|
|
1548
2299
|
// ../maestro-sdk/src/shared-commands/processes.ts
|
|
2300
|
+
var hasStatus = (row, status) => {
|
|
2301
|
+
const key = `${status.charAt(0).toLowerCase()}${status.slice(1)}Count`;
|
|
2302
|
+
return Number(row[key]) > 0;
|
|
2303
|
+
};
|
|
1549
2304
|
async function findProcessSummary(config, processKey, folderKey, processType) {
|
|
1550
2305
|
const page = await pimsGet(config, `/processes/summary${buildQueryString({ processType, processKey })}`, { folderKey });
|
|
1551
2306
|
const summaries = Array.isArray(page?.processes) ? page.processes : [];
|
|
@@ -1555,21 +2310,31 @@ var registerSharedProcessesCommands = (program, config) => {
|
|
|
1555
2310
|
const { toolLabel, processType } = config;
|
|
1556
2311
|
const incidentsQuery = buildQueryString({ processType });
|
|
1557
2312
|
const processes = program.command("processes").description(`Manage ${toolLabel} process summaries`);
|
|
1558
|
-
processes.command("list").description(`List
|
|
1559
|
-
const
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
2313
|
+
processes.command("list").description(`List ${toolLabel} process summaries. The CLI applies --folder-key, ` + "--status (keeps processes with at least one instance in that " + "status), --offset and --limit to the full list.").option("--folder-key <key>", "Keep only processes of this folder (applied by the CLI)").option("-l, --limit <number>", "Number of items to return (1-10000)", parseLimit).option("--offset <number>", "Number of items to skip (0-1000000)", parseOffset, 0).option("--status <status>", `Keep processes with an instance in this status: ${INSTANCE_STATUS_LIST} (applied by the CLI)`).trackedAction(processContext, async (options) => {
|
|
2314
|
+
const { statuses, invalid } = resolveInstanceStatuses(options.status === undefined ? [] : [options.status]);
|
|
2315
|
+
if (invalid.length > 0) {
|
|
2316
|
+
OutputFormatter.error({
|
|
2317
|
+
Result: RESULTS.ValidationError,
|
|
2318
|
+
Message: `Invalid --status value: ${invalid.join(", ")}`,
|
|
2319
|
+
Instructions: `Valid values: ${INSTANCE_STATUS_LIST}.`
|
|
2320
|
+
});
|
|
2321
|
+
processContext.exit(EXIT_CODES.ValidationError);
|
|
2322
|
+
return;
|
|
2323
|
+
}
|
|
2324
|
+
const query = buildQueryString({ processType });
|
|
1565
2325
|
const reqOptions = { folderKey: options.folderKey };
|
|
1566
2326
|
const result = await withPimsCall((config) => pimsGet(config, `/processes/summary${query}`, reqOptions), "Error listing processes");
|
|
1567
2327
|
if (!result)
|
|
1568
2328
|
return;
|
|
2329
|
+
const scoped = filterByFolder(result.processes ?? [], options.folderKey);
|
|
2330
|
+
const matching = statuses.length === 0 ? scoped : scoped.filter((row) => hasStatus(row, statuses[0]));
|
|
1569
2331
|
OutputFormatter.success({
|
|
1570
2332
|
Result: RESULTS.Success,
|
|
1571
2333
|
Code: "ProcessList",
|
|
1572
|
-
Data:
|
|
2334
|
+
Data: {
|
|
2335
|
+
...result,
|
|
2336
|
+
processes: windowRows(matching, options.offset, options.limit)
|
|
2337
|
+
}
|
|
1573
2338
|
});
|
|
1574
2339
|
});
|
|
1575
2340
|
processes.command("incidents").description(`Get incidents for a specific ${toolLabel} process`).argument("<process-key>", "Process definition key").requiredOption("--folder-key <key>", "Folder key").trackedAction(processContext, async (processKey, options) => {
|
|
@@ -1586,6 +2351,9 @@ var registerSharedProcessesCommands = (program, config) => {
|
|
|
1586
2351
|
processes.command("diagnose").description(`Correlate ${toolLabel} process summary, incidents, and error codes`).argument("<process-key>", "Process definition key").requiredOption("--folder-key <key>", "Folder key").trackedAction(processContext, async (processKey, options) => {
|
|
1587
2352
|
const result = await withPimsCall(async (config) => {
|
|
1588
2353
|
const summary = await findProcessSummary(config, processKey, options.folderKey, processType);
|
|
2354
|
+
if (summary?.folderKey && !inFolder(summary, options.folderKey)) {
|
|
2355
|
+
return { wrongFolder: summary.folderKey };
|
|
2356
|
+
}
|
|
1589
2357
|
const incidents = await pimsGet(config, `/incidents/process/${encodeURIComponent(processKey)}${incidentsQuery}`, { folderKey: options.folderKey });
|
|
1590
2358
|
const errorCodes = await pimsGet(config, `/incidents/process/${encodeURIComponent(processKey)}/error-codes`, { folderKey: options.folderKey });
|
|
1591
2359
|
return {
|
|
@@ -1596,6 +2364,15 @@ var registerSharedProcessesCommands = (program, config) => {
|
|
|
1596
2364
|
}, "Error diagnosing process");
|
|
1597
2365
|
if (!result)
|
|
1598
2366
|
return;
|
|
2367
|
+
if ("wrongFolder" in result) {
|
|
2368
|
+
OutputFormatter.error({
|
|
2369
|
+
Result: RESULTS.ValidationError,
|
|
2370
|
+
Message: `Process ${processKey} is in folder ${result.wrongFolder}, not ${options.folderKey}.`,
|
|
2371
|
+
Instructions: `Rerun with --folder-key ${result.wrongFolder}.`
|
|
2372
|
+
});
|
|
2373
|
+
processContext.exit(EXIT_CODES.ValidationError);
|
|
2374
|
+
return;
|
|
2375
|
+
}
|
|
1599
2376
|
OutputFormatter.success({
|
|
1600
2377
|
Result: RESULTS.Success,
|
|
1601
2378
|
Code: "ProcessDiagnostics",
|
|
@@ -1628,4 +2405,4 @@ var registerSharedProcessesCommands = (program, config) => {
|
|
|
1628
2405
|
|
|
1629
2406
|
export { registerSharedIncidentCommands, registerSharedInstanceCommands, registerSharedProcessCommands, registerSharedProcessesCommands };
|
|
1630
2407
|
|
|
1631
|
-
//# debugId=
|
|
2408
|
+
//# debugId=D481306A0F15A90064756E2164756E21
|