@uipath/case-tool 1.201.0-preview.133 → 1.202.0-preview.134

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.
Files changed (96) hide show
  1. package/dist/{authoring-aaaqwck3.js → authoring-jj4zkqer.js} +74 -48
  2. package/dist/{browser-strategy-rkcvc6tn.js → browser-strategy-6atc7v8s.js} +3 -3
  3. package/dist/case-api-2nfc0ynz.js +381 -0
  4. package/dist/case-debug-studio-web-service-e31g6mrp.js +335 -0
  5. package/dist/{case-pack-service-rvyqh3x3.js → case-pack-service-ye4shs12.js} +11 -18
  6. package/dist/case-validate-service-mayc7mw1.js +2114 -0
  7. package/dist/connector-enrichment-service-83pqstp8.js +60 -0
  8. package/dist/connector-lookup-service-59kkbbwm.js +22 -0
  9. package/dist/connector-task-spec-c54daswf.js +1250 -0
  10. package/dist/{de-5KVP66U6-t37qr521.js → de-5KVP66U6-1bnf4zt5.js} +54 -54
  11. package/dist/{de-5HU6GFWV-zheyw6d2.js → de-7XQXX2DK-tqdy5n2b.js} +857 -845
  12. package/dist/debug-service-77n8tv17.js +57 -0
  13. package/dist/{en-MABQK6C4-nkzq2j8t.js → en-5ZGC5VQ3-h581y30k.js} +897 -897
  14. package/dist/{en-4KXU7N7B-24v330b5.js → en-X3S6IZ5J-nhkg6pwn.js} +55 -61
  15. package/dist/enrichment-service-27j145k3.js +421 -0
  16. package/dist/{es-MX-POESXYP2-9538722k.js → es-MX-U2VN3SZW-anynsmd8.js} +857 -845
  17. package/dist/{es-MX-XAVLOQW3-47a405kf.js → es-MX-XAVLOQW3-q00km2y7.js} +54 -54
  18. package/dist/{es-VFPNVMP5-6sftsdxe.js → es-VFPNVMP5-bx2c337j.js} +54 -54
  19. package/dist/{es-LUTYN7U7-ye5zn4sn.js → es-ZGCPPOME-8gazspjj.js} +857 -845
  20. package/dist/{fr-E5MDO4EG-f3x1jeqw.js → fr-E5MDO4EG-c3mkty2t.js} +54 -54
  21. package/dist/{fr-LJIK56LW-xf3xf2kh.js → fr-T3G5GZCT-y3f7xb1q.js} +857 -845
  22. package/dist/index-67s20rhx.js +630 -0
  23. package/dist/{index-hsadteg4.js → index-h8cph72k.js} +4 -4
  24. package/dist/index-k4xz16db.js +63712 -0
  25. package/dist/{index-p50kx6jv.js → index-k5tbd184.js} +276 -276
  26. package/dist/index-kwxe1vep.js +143 -0
  27. package/dist/{index-cncq089f.js → index-mhe5065f.js} +163 -80
  28. package/dist/{index-9f8q2ege.js → index-p3vk57z7.js} +27 -27
  29. package/dist/index.js +16 -17
  30. package/dist/{index.umd.min-drpc57vn.js → index.umd.min-fqefd9kn.js} +3 -3
  31. package/dist/input-reader-vprf0kv6.js +11 -0
  32. package/dist/{ja-FGEGLBJ3-w9byjhze.js → ja-BI5K3JDZ-77zat4z2.js} +857 -845
  33. package/dist/{ja-DPO5PPLO-fmbg7zt2.js → ja-DPO5PPLO-mysfmznx.js} +54 -54
  34. package/dist/{js-yaml-cggj6w7q.js → js-yaml-87tvr6f6.js} +16 -16
  35. package/dist/known-types-qryebm95.js +15 -0
  36. package/dist/{ko-ITOPNIYI-aqy82jk8.js → ko-ITOPNIYI-hmxd2asd.js} +54 -54
  37. package/dist/{ko-TUAK3G3A-s25w0ckg.js → ko-JOBF5V7N-4bv0mjje.js} +857 -845
  38. package/dist/{node-strategy-8gzp67xs.js → node-strategy-0267x5e5.js} +130 -14
  39. package/dist/node-sync-service-15hccr1y.js +38 -0
  40. package/dist/{packager-tool-9qecd4wb.js → packager-tool-0gctz400.js} +5 -2
  41. package/dist/packager-tool-0mj06yen.js +65 -0
  42. package/dist/{packager-tool-1cb0d5e0.js → packager-tool-0v3s8r01.js} +2 -2
  43. package/dist/packager-tool-134mvmcm.js +3040 -0
  44. package/dist/packager-tool-13kkvf2n.js +356 -0
  45. package/dist/packager-tool-1j44c5z3.js +1217 -0
  46. package/dist/packager-tool-1jsabv93.js +6717 -0
  47. package/dist/packager-tool-1v6h5met.js +852 -0
  48. package/dist/{packager-tool-wckvcay0.js → packager-tool-1yh8g550.js} +9 -7
  49. package/dist/packager-tool-37ww3cn0.js +80 -0
  50. package/dist/packager-tool-3mdhyhk6.js +4892 -0
  51. package/dist/packager-tool-50hjsghv.js +1125 -0
  52. package/dist/{packager-tool-3wygxefb.js → packager-tool-58q3tvh7.js} +10 -10
  53. package/dist/packager-tool-5ww9gbj3.js +6865 -0
  54. package/dist/{packager-tool-w3h8xrnv.js → packager-tool-66s6vs1k.js} +71 -3
  55. package/dist/{packager-tool-zqa5k9f7.js → packager-tool-a190917w.js} +990 -2287
  56. package/dist/{packager-tool-p9j43p8h.js → packager-tool-a42jnpy5.js} +3 -9
  57. package/dist/packager-tool-ay3zvfcv.js +54 -0
  58. package/dist/{packager-tool-jysvpt8p.js → packager-tool-c23zrhj8.js} +2 -2
  59. package/dist/packager-tool-dqs5qy9s.js +2327 -0
  60. package/dist/{packager-tool-wvqz81mx.js → packager-tool-gtzs471w.js} +3 -2
  61. package/dist/{packager-tool-we1phz71.js → packager-tool-hxw1a9ac.js} +31 -3
  62. package/dist/{packager-tool-8t401j6x.js → packager-tool-jhdf8gt1.js} +5054 -17851
  63. package/dist/packager-tool-ncedqc8m.js +77 -0
  64. package/dist/packager-tool-p7jgrm5r.js +15 -0
  65. package/dist/packager-tool-q24fc6jm.js +546 -0
  66. package/dist/packager-tool-r84ng21s.js +57 -0
  67. package/dist/packager-tool-sv0d6wb6.js +173 -0
  68. package/dist/packager-tool-ty1t2byf.js +27 -0
  69. package/dist/packager-tool-vepqrsse.js +23 -0
  70. package/dist/{packager-tool-5arsyj36.js → packager-tool-yc4kw997.js} +4 -2
  71. package/dist/{packager-tool-zx48pq4v.js → packager-tool-ygwa3sc0.js} +1997 -1174
  72. package/dist/packager-tool.js +91 -5
  73. package/dist/project-artifacts-9e7bs1vq.js +14 -0
  74. package/dist/{pt-BR-7XGDXRDJ-espnkgrj.js → pt-BR-7DYX2YPT-fqxqzqtf.js} +857 -845
  75. package/dist/{pt-BR-BXURWX4W-xzyndmrx.js → pt-BR-BXURWX4W-bwfcwhk1.js} +54 -54
  76. package/dist/{pt-TMVOOITK-myha14p9.js → pt-HTXGGX6Y-97t21dty.js} +857 -845
  77. package/dist/{pt-YI4VE4YQ-521681zf.js → pt-YI4VE4YQ-wdkn2dcf.js} +54 -54
  78. package/dist/resourcesSyncService-jnze5zjq.js +683 -0
  79. package/dist/{ro-2VALF3S5-cdz5afkr.js → ro-KTNQ3MNU-y08n1x5g.js} +857 -845
  80. package/dist/{ro-RKXZUG7Z-pdztdafr.js → ro-RKXZUG7Z-nndrrsq7.js} +54 -54
  81. package/dist/{ru-GSCT4ARZ-qj8dm4dp.js → ru-GSCT4ARZ-1sa9wbr8.js} +1 -1
  82. package/dist/ru-WBLQ5B2U-8r3c7v6d.js +10 -0
  83. package/dist/strict-case-rules-303vjvas.js +377 -0
  84. package/dist/strict-sdd-audit-qdmc9e1y.js +1024 -0
  85. package/dist/tool.js +17 -18
  86. package/dist/{tr-AA6O2WSR-bj9n80k8.js → tr-AA6O2WSR-86ba4bdf.js} +54 -54
  87. package/dist/{tr-RIFCEXFH-hgkb4g8y.js → tr-XHSSPNK7-cmqyc4wd.js} +857 -845
  88. package/dist/trigger-enrichment-service-46b8k7ex.js +340 -0
  89. package/dist/{zh-CN-IP3FMXWM-1cfarhcp.js → zh-CN-2EHQT23P-mr63c4xz.js} +857 -845
  90. package/dist/{zh-CN-R2KLHXQV-x6gnk2n0.js → zh-CN-R2KLHXQV-agqr45ds.js} +54 -54
  91. package/dist/{zh-TW-AGIDXIPF-n6r6w7vy.js → zh-TW-MGZCE5BT-c4ekmrz9.js} +857 -845
  92. package/dist/{zh-TW-RJGCQANM-tt8j5wv2.js → zh-TW-RJGCQANM-w0x3qc1p.js} +54 -54
  93. package/package.json +2 -2
  94. package/dist/index-8bsngk9y.js +0 -247140
  95. package/dist/packager-tool-qtwqp3q5.js +0 -13607
  96. package/dist/ru-WBLQ5B2U-8xd4gpv2.js +0 -10
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  resolveMaestroRegistry
3
- } from "./packager-tool-we1phz71.js";
3
+ } from "./packager-tool-hxw1a9ac.js";
4
4
  import {
5
5
  OutputFormatter,
6
6
  RESULTS,
7
7
  getOutputFormat,
8
8
  getOutputFormatExplicit,
9
9
  processContext
10
- } from "./packager-tool-zx48pq4v.js";
10
+ } from "./packager-tool-ygwa3sc0.js";
11
11
  import {
12
12
  getFileSystem
13
- } from "./packager-tool-1cb0d5e0.js";
14
- import"./packager-tool-wckvcay0.js";
13
+ } from "./packager-tool-0v3s8r01.js";
14
+ import"./packager-tool-1yh8g550.js";
15
15
 
16
16
  // ../builder-sdk/src/argv.ts
17
17
  function addValue(argv, flag, value) {
@@ -23,7 +23,10 @@ function addValue(argv, flag, value) {
23
23
  // ../builder-sdk/src/delegate.ts
24
24
  import { spawn } from "node:child_process";
25
25
  import { createRequire } from "node:module";
26
- var MINIMUM_FLOW_SDK_VERSION = "1.1.0";
26
+ var FLOW_SDK_PACKAGES = [
27
+ { name: "@uipath/maestro-builder-sdk", minimumVersion: "4.0.0" },
28
+ { name: "@uipath/flow-sdk", minimumVersion: "1.1.0" }
29
+ ];
27
30
  function commandLabel(family, verb) {
28
31
  return `uip maestro ${family} ${verb}`;
29
32
  }
@@ -77,53 +80,66 @@ async function runChild(cliPath, args, cwd, label) {
77
80
  });
78
81
  });
79
82
  }
83
+ function upgradeInstructions() {
84
+ const [current, legacy] = FLOW_SDK_PACKAGES;
85
+ return `npm install --save-dev ${current.name}` + ` (the previous name ${legacy.name} also works and needs an .npmrc` + ` routing @uipath to https://npm.pkg.github.com/).`;
86
+ }
80
87
  async function resolveFlowSdk(workspace, label) {
81
88
  const fs = getFileSystem();
82
- let packagePath;
83
- try {
84
- packagePath = createRequire(import.meta.url).resolve("@uipath/flow-sdk/package.json", { paths: [workspace] });
85
- } catch {
86
- return {
87
- ok: false,
88
- message: `${label}: @uipath/flow-sdk is not installed in this workspace.`,
89
- instructions: "Add it to this project's dependencies: npm install --save-dev @uipath/flow-sdk (requires an .npmrc routing @uipath to https://npm.pkg.github.com/)."
90
- };
91
- }
92
- const packageText = await fs.readFile(packagePath, "utf-8");
93
- if (packageText === null) {
94
- return {
95
- ok: false,
96
- message: `${label}: could not read ${packagePath}.`,
97
- instructions: "Reinstall @uipath/flow-sdk, then retry."
98
- };
99
- }
100
- let version = "";
101
- let bin = {};
102
- try {
103
- const parsed = JSON.parse(packageText);
104
- version = typeof parsed.version === "string" ? parsed.version : "";
105
- if (parsed.bin && typeof parsed.bin === "object") {
106
- for (const [name, target] of Object.entries(parsed.bin)) {
107
- if (typeof target === "string")
108
- bin[name] = target;
89
+ const require2 = createRequire(import.meta.url);
90
+ let firstFailure;
91
+ for (const candidate of FLOW_SDK_PACKAGES) {
92
+ let packagePath;
93
+ try {
94
+ packagePath = require2.resolve(`${candidate.name}/package.json`, {
95
+ paths: [workspace]
96
+ });
97
+ } catch {
98
+ continue;
99
+ }
100
+ const packageText = await fs.readFile(packagePath, "utf-8");
101
+ if (packageText === null) {
102
+ firstFailure ??= {
103
+ ok: false,
104
+ message: `${label}: could not read ${packagePath}.`,
105
+ instructions: `Reinstall ${candidate.name}, then retry.`
106
+ };
107
+ continue;
108
+ }
109
+ let version = "";
110
+ let bin = {};
111
+ try {
112
+ const parsed = JSON.parse(packageText);
113
+ version = typeof parsed.version === "string" ? parsed.version : "";
114
+ if (parsed.bin && typeof parsed.bin === "object") {
115
+ for (const [name, target] of Object.entries(parsed.bin)) {
116
+ if (typeof target === "string")
117
+ bin[name] = target;
118
+ }
109
119
  }
120
+ } catch {
121
+ version = "";
122
+ bin = {};
123
+ }
124
+ if (!versionMeetsFloor(version, candidate.minimumVersion)) {
125
+ firstFailure ??= {
126
+ ok: false,
127
+ message: `${label}: found ${candidate.name} ${version || "with no valid version"}; need >= ${candidate.minimumVersion}.`,
128
+ instructions: upgradeInstructions()
129
+ };
130
+ continue;
110
131
  }
111
- } catch {
112
- version = "";
113
- bin = {};
114
- }
115
- if (!versionMeetsFloor(version, MINIMUM_FLOW_SDK_VERSION)) {
116
132
  return {
117
- ok: false,
118
- message: `${label}: found @uipath/flow-sdk ${version || "with no valid version"}; need >= ${MINIMUM_FLOW_SDK_VERSION}.`,
119
- instructions: "Run: npm install --save-dev @uipath/flow-sdk@latest."
133
+ ok: true,
134
+ packageDir: fs.path.dirname(packagePath),
135
+ version,
136
+ bin
120
137
  };
121
138
  }
122
- return {
123
- ok: true,
124
- packageDir: fs.path.dirname(packagePath),
125
- version,
126
- bin
139
+ return firstFailure ?? {
140
+ ok: false,
141
+ message: `${label}: ${FLOW_SDK_PACKAGES[0].name} is not installed in this workspace.`,
142
+ instructions: upgradeInstructions()
127
143
  };
128
144
  }
129
145
  async function delegateToFlowSdk({
@@ -162,6 +178,8 @@ function sdkCliExample(description, command, message) {
162
178
  async function resolveLibraryOption(explicit) {
163
179
  if (explicit !== undefined)
164
180
  return explicit;
181
+ if (getFileSystem().env.getenv("FLOW_SDK_LIBRARY_JSON"))
182
+ return;
165
183
  const registry = await resolveMaestroRegistry();
166
184
  return registry?.libraryJson;
167
185
  }
@@ -175,7 +193,7 @@ var CHECK_EXAMPLES = {
175
193
  var registerCheckCommand = (program, family) => {
176
194
  const command = program.previewCommand("check <input>").description("Run the authoring-time SDK analyzer on source or an artifact.").option("--source", "Check authored TypeScript").option("--compiled", "Check the compiled artifact");
177
195
  if (family === "flow") {
178
- command.option("--library <dir>", "Connector library directory (defaults to the pulled registry; source checks also honor $FLOW_SDK_LIBRARY_JSON)").option("--json", "Print compiled-check diagnostics as JSON").option("--uip", "Resolve missing schemas with the UiPath CLI").option("--max-errors <count>", "Stop after this many compiled-check errors").option("--script-determinism", "Check script blocks for non-deterministic calls").option("--quiet", "Suppress warnings and information");
196
+ command.option("--library <dir>", "Connector library directory (defaults to $FLOW_SDK_LIBRARY_JSON, else the pulled library)").option("--json", "Print compiled-check diagnostics as JSON").option("--uip", "Resolve missing schemas with the UiPath CLI").option("--max-errors <count>", "Stop after this many compiled-check errors").option("--script-determinism", "Check script blocks for non-deterministic calls").option("--quiet", "Suppress warnings and information");
179
197
  }
180
198
  const example = CHECK_EXAMPLES[family];
181
199
  command.examples(sdkCliExample(`Check a ${family} source file before compiling it`, `uip maestro ${family} check ${example.input} --source`, example.message)).trackedAction(processContext, async (input, options) => {
@@ -263,15 +281,23 @@ var DECOMPILE_EXAMPLES = {
263
281
  var registerDecompileCommand = (program, family) => {
264
282
  const command = program.previewCommand("decompile <input>").description(`Convert a ${family === "flow" ? ".flow" : "caseplan.json"} artifact to authored TypeScript.`).option("-o, --output <file>", `Output ${family === "flow" ? ".flow.ts" : ".case.ts"} path`).option("--import <specifier>", "SDK import specifier in generated source");
265
283
  if (family === "flow") {
266
- command.option("--strict", "Fail on unsupported constructs").option("--no-pipeline", "Do not emit a brownfield pipeline helper");
284
+ command.option("--strict", "Fail on unsupported constructs");
285
+ } else {
286
+ command.option("--library <dir>", "Connector library directory (defaults to the pulled registry)").option("--best-effort", "Emit a marked repair scaffold for unsupported constructs");
267
287
  }
288
+ command.option("--no-pipeline", "Do not emit a brownfield pipeline helper");
268
289
  const example = DECOMPILE_EXAMPLES[family];
269
290
  command.examples(sdkCliExample(`Convert a ${family} artifact back to authored TypeScript`, `uip maestro ${family} decompile ${example.input} --output ${example.output}`, example.message)).trackedAction(processContext, async (input, options) => {
270
291
  const argv = [input];
271
292
  addValue(argv, "-o", options.output);
272
293
  addValue(argv, "--import", options.import);
294
+ if (family === "case") {
295
+ addValue(argv, "--library", await resolveLibraryOption(options.library));
296
+ }
273
297
  if (options.strict)
274
298
  argv.push("--strict");
299
+ if (options.bestEffort)
300
+ argv.push("--best-effort");
275
301
  if (options.pipeline === false)
276
302
  argv.push("--no-pipeline");
277
303
  const code = await delegateToFlowSdk({
@@ -293,4 +319,4 @@ export {
293
319
  registerCaseAuthoringCommands
294
320
  };
295
321
 
296
- //# debugId=847E8056C2AECFF464756E2164756E21
322
+ //# debugId=1A1E49FDDB5AEC9264756E2164756E21
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  getGlobalThis
3
- } from "./packager-tool-9qecd4wb.js";
3
+ } from "./packager-tool-0gctz400.js";
4
4
  import {
5
5
  AUTH_CANCELLED_ERROR_CODE
6
- } from "./packager-tool-5arsyj36.js";
7
- import"./packager-tool-wckvcay0.js";
6
+ } from "./packager-tool-yc4kw997.js";
7
+ import"./packager-tool-1yh8g550.js";
8
8
 
9
9
  // ../auth/src/strategies/browser-strategy.ts
10
10
  class BrowserAuthStrategy {
@@ -0,0 +1,381 @@
1
+ import {
2
+ JobsApi,
3
+ ReleasesApi,
4
+ createOrchestratorConfig,
5
+ resolveFolder
6
+ } from "./packager-tool-a190917w.js";
7
+ import {
8
+ parseJsonInputOrFile
9
+ } from "./packager-tool-ay3zvfcv.js";
10
+ import"./packager-tool-vepqrsse.js";
11
+ import"./packager-tool-dqs5qy9s.js";
12
+ import"./packager-tool-qa9gftnj.js";
13
+ import {
14
+ OutputFormatter,
15
+ catchError
16
+ } from "./packager-tool-ygwa3sc0.js";
17
+ import"./packager-tool-0v3s8r01.js";
18
+ import"./packager-tool-0gctz400.js";
19
+ import"./packager-tool-yc4kw997.js";
20
+ import"./packager-tool-1yh8g550.js";
21
+
22
+ // src/services/http-client.ts
23
+ function buildCommonHeaders(config, options) {
24
+ const headers = {
25
+ Authorization: `Bearer ${config.authToken}`,
26
+ Accept: "application/json"
27
+ };
28
+ if (options?.includeContentType !== false) {
29
+ headers["Content-Type"] = "application/json";
30
+ }
31
+ if (config.organizationUnitId) {
32
+ headers["X-UIPATH-OrganizationUnitId"] = config.organizationUnitId.toString();
33
+ }
34
+ if (config.folderKey) {
35
+ headers["x-uipath-folderkey"] = config.folderKey;
36
+ }
37
+ return headers;
38
+ }
39
+ function buildOrchestratorHeaders(config) {
40
+ return buildCommonHeaders(config);
41
+ }
42
+ function buildOrchestratorUrl(config, path) {
43
+ return `${config.baseUrl}/${config.organizationId}/${config.tenantName}/orchestrator_${path}`;
44
+ }
45
+ async function orchestratorGet(config, path) {
46
+ const url = buildOrchestratorUrl(config, path);
47
+ const headers = buildOrchestratorHeaders(config);
48
+ if (typeof process !== "undefined" && process.env?.DEBUG) {
49
+ OutputFormatter.log({ Message: `DEBUG GET: ${url}` });
50
+ }
51
+ const response = await fetch(url, {
52
+ method: "GET",
53
+ headers
54
+ });
55
+ if (!response.ok) {
56
+ const errorText = await response.text();
57
+ throw new Error(`API request failed: ${response.status} ${response.statusText} - ${errorText}`);
58
+ }
59
+ return response.json();
60
+ }
61
+
62
+ // src/services/case-api.ts
63
+ async function listCaseProcesses(config, filter) {
64
+ const organizationUnitId = await resolveOrganizationUnitId(config);
65
+ const sdkConfig = await createOrchestratorConfig({
66
+ folderId: organizationUnitId?.toString(),
67
+ tenant: config.tenantName
68
+ });
69
+ const releasesApi = new ReleasesApi(sdkConfig);
70
+ const filters = ["ProcessType eq 'CaseManagement'"];
71
+ if (config.folderKey) {
72
+ const guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
73
+ if (!guidRegex.test(config.folderKey)) {
74
+ throw new Error(`Invalid folder key format: "${config.folderKey}". Expected GUID ex. 01234567-0123-0123-0123-0123456789ab`);
75
+ }
76
+ filters.push(`FolderKey eq '${config.folderKey}'`);
77
+ }
78
+ if (filter) {
79
+ filters.push(filter);
80
+ }
81
+ const filterQuery = filters.length > 0 ? filters.join(" and ") : undefined;
82
+ const response = await releasesApi.releasesGet({
83
+ $filter: filterQuery
84
+ });
85
+ return response.value || [];
86
+ }
87
+ async function getCaseEntryPoints(config) {
88
+ const organizationUnitId = await resolveOrganizationUnitId(config);
89
+ const apiConfig = {
90
+ baseUrl: config.baseUrl,
91
+ organizationId: config.organizationId,
92
+ tenantName: config.tenantName,
93
+ authToken: config.authToken,
94
+ organizationUnitId
95
+ };
96
+ const feedIdParam = config.feedId ? `?feedId=${encodeURIComponent(config.feedId)}` : "";
97
+ if (!/^[a-zA-Z0-9._-]+$/.test(config.processKey)) {
98
+ throw new Error(`Invalid process key format: "${config.processKey}"`);
99
+ }
100
+ const path = `/odata/Processes/UiPath.Server.Configuration.OData.GetPackageEntryPointsV2(key='${config.processKey}')${feedIdParam}`;
101
+ const response = await orchestratorGet(apiConfig, path);
102
+ return response.value;
103
+ }
104
+ async function startCaseJob(config) {
105
+ const organizationUnitId = await resolveOrganizationUnitId(config);
106
+ const sdkConfig = await createOrchestratorConfig({
107
+ folderId: organizationUnitId?.toString(),
108
+ tenant: config.tenantName
109
+ });
110
+ const jobsApi = new JobsApi(sdkConfig);
111
+ const inputArguments = config.inputs ? JSON.stringify(config.inputs) : "{}";
112
+ const startInfo = {
113
+ releaseKey: config.releaseKey,
114
+ inputArguments,
115
+ runAsMe: true
116
+ };
117
+ if (config.robotIds && config.robotIds.length > 0) {
118
+ startInfo.robotIds = config.robotIds;
119
+ }
120
+ const response = await jobsApi.jobsStartJobs({
121
+ body: { startInfo }
122
+ });
123
+ if (!response.value || response.value.length === 0) {
124
+ throw new Error("Failed to start job: No job returned from API");
125
+ }
126
+ return response.value[0];
127
+ }
128
+ async function getCaseTraces(config, traceId) {
129
+ if (!config.tenantId) {
130
+ throw new Error("Tenant ID is required for Traces API. Please ensure you're logged in properly.");
131
+ }
132
+ const serviceName = config.tracesServiceName || "llmopstenant_";
133
+ const url = `${config.baseUrl}/${config.organizationId}/${config.tenantId}/${serviceName}/api/Traces/spans/?traceId=${traceId}`;
134
+ const headers = {
135
+ Authorization: `Bearer ${config.authToken}`,
136
+ "Content-Type": "application/json",
137
+ Accept: "application/json"
138
+ };
139
+ if (config.organizationUnitId) {
140
+ headers["X-UIPATH-OrganizationUnitId"] = config.organizationUnitId.toString();
141
+ }
142
+ if (process.env.DEBUG) {
143
+ OutputFormatter.log({ Message: `DEBUG GET TRACES: ${url}` });
144
+ }
145
+ const response = await fetch(url, {
146
+ method: "GET",
147
+ headers
148
+ });
149
+ if (process.env.DEBUG) {
150
+ OutputFormatter.log({
151
+ Message: `DEBUG TRACES RESPONSE: ${response.status} ${response.statusText}`
152
+ });
153
+ }
154
+ if (!response.ok) {
155
+ const errorText = await response.text();
156
+ if (process.env.DEBUG) {
157
+ OutputFormatter.log({
158
+ Message: `DEBUG TRACES ERROR BODY: ${errorText.substring(0, 200)}`
159
+ });
160
+ }
161
+ throw new Error(`Traces API failed: ${response.status} ${response.statusText} - ${errorText}`);
162
+ }
163
+ const data = await response.json();
164
+ if (process.env.DEBUG) {
165
+ OutputFormatter.log({
166
+ Message: `DEBUG TRACES DATA: ${JSON.stringify(data).substring(0, 200)}`
167
+ });
168
+ }
169
+ return data;
170
+ }
171
+ function spanToTraceEvent(span) {
172
+ let attributes = {};
173
+ const [parseError, parsed] = catchError(() => JSON.parse(span.Attributes));
174
+ if (!parseError) {
175
+ attributes = parsed;
176
+ }
177
+ const duration = span.EndTime ? new Date(span.EndTime).getTime() - new Date(span.StartTime).getTime() : undefined;
178
+ return {
179
+ timestamp: span.StartTime,
180
+ spanId: span.Id,
181
+ parentId: span.ParentId,
182
+ name: span.Name,
183
+ type: span.SpanType,
184
+ status: attributes.status || "Unknown",
185
+ duration,
186
+ attributes
187
+ };
188
+ }
189
+ async function startCaseProjectJob(config) {
190
+ if (!config.releaseKey) {
191
+ throw new Error("Release key is required. Use 'case process list' to find it.");
192
+ }
193
+ return startCaseJob(config);
194
+ }
195
+ async function streamJobTraces(config, jobKey, options = {}) {
196
+ const startTime = Date.now();
197
+ const pollInterval = options.pollInterval || 2000;
198
+ const maxPolls = options.maxPolls || 300;
199
+ const traceId = jobKey;
200
+ let pollCount = 0;
201
+ const seenSpanIds = new Set;
202
+ let tracesFound = false;
203
+ const [outerError, outerResult] = await catchError((async () => {
204
+ while (pollCount < maxPolls) {
205
+ const [tracesError, fetchedSpans] = await catchError(getCaseTraces(config, traceId));
206
+ let spans = [];
207
+ if (tracesError) {
208
+ if (tracesError instanceof Error && (tracesError.message.includes("404") || tracesError.message.includes("400"))) {
209
+ if (!tracesFound && pollCount % 5 === 0) {
210
+ OutputFormatter.log({
211
+ Message: `⏳ Waiting for traces... (${(pollCount * pollInterval / 1000).toFixed(1)}s)`
212
+ });
213
+ }
214
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
215
+ pollCount++;
216
+ continue;
217
+ }
218
+ throw tracesError;
219
+ } else {
220
+ spans = fetchedSpans;
221
+ if (!tracesFound && spans.length > 0) {
222
+ tracesFound = true;
223
+ OutputFormatter.log({
224
+ Message: "✓ Execution started, streaming traces..."
225
+ });
226
+ }
227
+ }
228
+ for (const span of spans) {
229
+ if (!seenSpanIds.has(span.Id)) {
230
+ seenSpanIds.add(span.Id);
231
+ const traceEvent = spanToTraceEvent(span);
232
+ options.onTrace?.(traceEvent);
233
+ }
234
+ }
235
+ const processRunSpan = spans.find((s) => s.SpanType === "ProcessRun");
236
+ if (processRunSpan) {
237
+ const [parseError, attributes] = catchError(() => JSON.parse(processRunSpan.Attributes));
238
+ if (parseError || !attributes) {
239
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
240
+ pollCount++;
241
+ continue;
242
+ }
243
+ const status = String(attributes.status ?? "");
244
+ const terminalStates = [
245
+ "Completed",
246
+ "Faulted",
247
+ "Cancelled"
248
+ ];
249
+ if (terminalStates.includes(status)) {
250
+ const success = status === "Completed";
251
+ const result = {
252
+ success,
253
+ jobKey,
254
+ traceId,
255
+ finalState: status,
256
+ duration: Date.now() - startTime
257
+ };
258
+ options.onComplete?.(result);
259
+ return result;
260
+ }
261
+ }
262
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
263
+ pollCount++;
264
+ }
265
+ throw new Error(`Polling timed out after ${(maxPolls * pollInterval / 1000).toFixed(1)}s`);
266
+ })());
267
+ if (outerError) {
268
+ const err = outerError instanceof Error ? outerError : new Error("Unknown error");
269
+ options.onError?.(err);
270
+ return {
271
+ success: false,
272
+ jobKey,
273
+ traceId,
274
+ error: err.message,
275
+ duration: Date.now() - startTime,
276
+ finalState: "Failed"
277
+ };
278
+ }
279
+ return outerResult;
280
+ }
281
+ async function getJobStatusDetailed(config, jobKey) {
282
+ const organizationUnitId = await resolveOrganizationUnitId(config);
283
+ const sdkConfig = await createOrchestratorConfig({
284
+ folderId: organizationUnitId?.toString(),
285
+ tenant: config.tenantName
286
+ });
287
+ const jobsApi = new JobsApi(sdkConfig);
288
+ if (!/^[0-9a-fA-F-]+$/.test(jobKey)) {
289
+ throw new Error(`Invalid job key format: "${jobKey}"`);
290
+ }
291
+ const response = await jobsApi.jobsGet({
292
+ $filter: `Key eq '${jobKey}'`,
293
+ $expand: "Robot,Release,Machine",
294
+ $top: 1
295
+ });
296
+ if (!response.value || response.value.length === 0) {
297
+ throw new Error(`Job not found: ${jobKey}`);
298
+ }
299
+ return response.value[0];
300
+ }
301
+ async function resolveOrganizationUnitId(config) {
302
+ if (config.organizationUnitId !== undefined) {
303
+ return config.organizationUnitId;
304
+ }
305
+ if (!config.folderKey) {
306
+ return;
307
+ }
308
+ const folder = await resolveFolder({ folderKey: config.folderKey }, { tenant: config.tenantName });
309
+ if (folder?.id === undefined || folder.id === null) {
310
+ throw new Error(`Folder with key '${config.folderKey}' could not be resolved to an organization unit ID.`);
311
+ }
312
+ config.organizationUnitId = folder.id;
313
+ return folder.id;
314
+ }
315
+ async function validateCaseInputs(config, inputs) {
316
+ const [error, validationResult] = await catchError((async () => {
317
+ const entryPoints = await getCaseEntryPoints(config);
318
+ if (entryPoints.length === 0) {
319
+ return {
320
+ valid: false,
321
+ errors: ["No entry points found for this process"]
322
+ };
323
+ }
324
+ const entryPoint = entryPoints[0];
325
+ const inputSchema = JSON.parse(entryPoint.InputArguments);
326
+ if (inputSchema.type !== "object") {
327
+ return { valid: true };
328
+ }
329
+ const errors = [];
330
+ const requiredProps = inputSchema.required || [];
331
+ for (const prop of requiredProps) {
332
+ if (!(prop in inputs)) {
333
+ errors.push(`Missing required property: ${prop}`);
334
+ }
335
+ }
336
+ if (inputSchema.properties) {
337
+ for (const [key, value] of Object.entries(inputs)) {
338
+ if (inputSchema.properties[key]?.type) {
339
+ const expectedType = inputSchema.properties[key].type;
340
+ const actualType = typeof value;
341
+ if (expectedType === "string" && actualType !== "string") {
342
+ errors.push(`Property '${key}' should be string, got ${actualType}`);
343
+ } else if (expectedType === "number" && actualType !== "number") {
344
+ errors.push(`Property '${key}' should be number, got ${actualType}`);
345
+ } else if (expectedType === "boolean" && actualType !== "boolean") {
346
+ errors.push(`Property '${key}' should be boolean, got ${actualType}`);
347
+ }
348
+ }
349
+ }
350
+ }
351
+ return {
352
+ valid: errors.length === 0,
353
+ errors: errors.length > 0 ? errors : undefined
354
+ };
355
+ })());
356
+ if (error) {
357
+ return {
358
+ valid: false,
359
+ errors: [
360
+ `Failed to validate inputs: ${error instanceof Error ? error.message : String(error)}`
361
+ ]
362
+ };
363
+ }
364
+ return validationResult;
365
+ }
366
+ async function parseCaseInputs(inputSource) {
367
+ return await parseJsonInputOrFile(inputSource);
368
+ }
369
+ export {
370
+ getCaseEntryPoints,
371
+ getJobStatusDetailed,
372
+ listCaseProcesses,
373
+ parseCaseInputs,
374
+ resolveOrganizationUnitId,
375
+ spanToTraceEvent,
376
+ startCaseProjectJob,
377
+ streamJobTraces,
378
+ validateCaseInputs
379
+ };
380
+
381
+ //# debugId=9AD4F87B84A79AEF64756E2164756E21