@uipath/test-manager-tool 1.206.0-preview.301 → 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.
@@ -1,30 +1,22 @@
1
1
  import {
2
2
  getFileSystem,
3
3
  catchError,
4
- isCliErrorCode,
5
- isRetryHint,
6
- isHtmlDocument,
7
- extractErrorDetails2,
8
- instructionsFor,
9
4
  RESULTS,
5
+ instructionsFor,
10
6
  InvalidArgumentError,
11
7
  Option,
12
- LogLevel,
13
8
  logger,
14
- configureLogger,
15
9
  EXIT_CODES,
16
10
  Pagination,
17
11
  SuccessOutput,
18
12
  OutputFormatter,
19
13
  processContext,
20
- resolveDeprecatedOptionAlias,
21
- warnDeprecatedOptionAlias,
22
14
  createHiddenDeprecatedTenantOption,
23
15
  PollOutcome,
24
16
  mapPollFailure,
25
17
  pollUntil,
26
18
  getAuthContext
27
- } from "./tool-0650qfw3.js";
19
+ } from "./tool-4xdq18pz.js";
28
20
  import {
29
21
  Configuration2,
30
22
  UiPathTestManagementHubProjectMigrationAbstractionsEnumsMigrationJobType2,
@@ -32,389 +24,52 @@ import {
32
24
  ProjectMigrationAttachmentApi2,
33
25
  ProjectMigrationJobApi2,
34
26
  ProjectsApi2
35
- } from "./tool-1nkyed5m.js";
27
+ } from "./tool-hm0kg56c.js";
28
+ import {
29
+ PROJECT_CONFIG_FORBIDDEN_MESSAGE,
30
+ TM_FORBIDDEN_MESSAGE,
31
+ resolvePaginationOptions,
32
+ toPascalCaseKeys,
33
+ sameGuid,
34
+ resolveWaitTiming,
35
+ extractErrorDetails,
36
+ emitTmFailure,
37
+ emitInvalidArgument
38
+ } from "./tool-bvkzq6jr.js";
36
39
 
37
- // src/utils/shared.ts
38
- var ENCODING_MARKERS = [
39
- "\uFEFF",
40
- "￾",
41
- "+/v8",
42
- "+/v9",
43
- "+/v+",
44
- "+/v/"
45
- ];
46
- function stripEncodingMarkers(content) {
47
- for (const marker of ENCODING_MARKERS) {
48
- if (content.startsWith(marker)) {
49
- return content.slice(marker.length);
50
- }
51
- }
52
- return content;
53
- }
54
- var ROBOT_LOG_LEVELS = [
55
- "Trace",
56
- "Info",
57
- "Warn",
58
- "Error",
59
- "Fatal"
60
- ];
61
- var TERMINAL_STATUSES = new Set(["finished", "cancelled"]);
62
- function msToDuration(ms) {
63
- const totalSec = Math.floor(ms / 1000);
64
- const h = Math.floor(totalSec / 3600);
65
- const m = Math.floor(totalSec % 3600 / 60);
66
- const s = totalSec % 60;
67
- return [h, m, s].map((v) => String(v).padStart(2, "0")).join(":");
68
- }
69
- function calcPassRate(passed, failed) {
70
- const executed = passed + failed;
71
- return executed > 0 ? Math.round(passed / executed * 1000) / 10 : 0;
72
- }
73
- var DEFAULT_TEST_CASE_VERSION = "1.0.0";
74
- var PROJECT_CONFIG_FORBIDDEN_MESSAGE = "Forbidden (403). Exporting project configuration is a Test Cloud only feature, and this tenant is not a Test Cloud tenant. This is a licence limit, not a permissions problem.";
75
- var SCHEMA_FORBIDDEN_MESSAGE = "Forbidden (403). Reading migration schemas needs the TM.Users or TM.Users.Read scope, which the other migration commands do not. Check the scopes on the token or external app you logged in with.";
76
- var PROJECT_CONFIG_IMPORT_FORBIDDEN_MESSAGE = "Forbidden (403). Importing project configuration is a Test Cloud only feature, and this tenant is not a Test Cloud tenant. This is a licence limit, not a permissions problem.";
77
- var TM_FORBIDDEN_MESSAGE = "Forbidden (403). The account lacks the Test Manager permission for this operation, or the token carries no Test Manager (TM.*) scope. Run `uip login status --detailed` to see the token's scopes; an external application needs the TM scopes granted on the app itself.";
78
- var TM_LICENSED_USER_FORBIDDEN_MESSAGE = "Forbidden (403). This operation requires a Test Manager license. Contact your tenant admin to assign a license, or use a read-only command.";
79
- var TM_TEST_CLOUD_FORBIDDEN_MESSAGE = "Forbidden (403). Group-by needs a Test Cloud licence for this account and the StructuredViewsGroupBy feature on the tenant, and the token must carry the TM.TestCases scope. On a tenant not yet on the current Test Manager build, an external application (client-credentials) token cannot call group-by at all; use a user login (`uip login`). Run `uip login status --detailed` to see the token's scopes, or ask your tenant admin about the licence.";
80
- var TM_NOT_AVAILABLE_MESSAGE = "Test Manager is not enabled for this tenant.";
81
- var TM_NOT_AVAILABLE_INSTRUCTIONS = "Enable Test Manager for this tenant, or rerun the command against a tenant where Test Manager is already provisioned.";
82
- var TAGGED_UPLOAD_NOT_SUPPORTED_INSTRUCTIONS = "Test Manager refused the tagged upload with featureDisabled: --source and --attachment-type go to the tagged-upload endpoint, which needs a Test Manager feature the connected environment does not turn on. Drop --source and --attachment-type to attach the file untagged, or run the command against an environment where tagged uploads are turned on.";
83
- function makeEnumParser(map) {
84
- const allowed = Object.keys(map).join(", ");
85
- return (raw) => {
86
- if (!Object.hasOwn(map, raw)) {
87
- throw new InvalidArgumentError(`Invalid value "${raw}". Must be one of: ${allowed}.`);
88
- }
89
- return map[raw];
90
- };
91
- }
92
- var CUSTOMFIELD_OBJECT_TYPE_MAP = {
93
- Requirement: "requirement",
94
- TestCase: "testCase",
95
- TestSet: "testSet"
96
- };
97
- var parseCustomFieldObjectType = makeEnumParser(CUSTOMFIELD_OBJECT_TYPE_MAP);
98
- var CUSTOMFIELD_DATA_TYPE_MAP = {
99
- Text: "text",
100
- Label: "label"
101
- };
102
- var parseCustomFieldDataType = makeEnumParser(CUSTOMFIELD_DATA_TYPE_MAP);
103
- function validateIdentity(spec) {
104
- if (spec.naturalKey.length === 0) {
105
- throw new Error("validateIdentity: naturalKey must contain at least one field.");
106
- }
107
- const hasPrimary = Array.isArray(spec.primary.value) ? spec.primary.value.length > 0 : spec.primary.value !== undefined && spec.primary.value !== "";
108
- const naturalFlags = spec.naturalKey.map((f) => f.flag).join(" + ");
109
- const supplied = spec.naturalKey.filter((f) => f.value !== undefined && f.value !== "");
110
- const hasFullNatural = supplied.length === spec.naturalKey.length;
111
- const hasAnyNatural = supplied.length > 0;
112
- const hasPartialNatural = hasAnyNatural && !hasFullNatural;
113
- if (!hasPrimary && !hasAnyNatural) {
114
- return {
115
- Result: "ValidationError",
116
- Message: `Provide ${spec.primary.flag}, or ${naturalFlags}.`,
117
- Instructions: `Pass ${spec.primary.flag}, or ${naturalFlags} to identify by natural key.`
118
- };
119
- }
120
- if (hasPrimary && hasAnyNatural) {
121
- return {
122
- Result: "ValidationError",
123
- Message: `${spec.primary.flag} and ${naturalFlags} are mutually exclusive identities.`,
124
- Instructions: `Pass either ${spec.primary.flag}, or ${naturalFlags} — not both.`
125
- };
126
- }
127
- if (hasPartialNatural) {
128
- return {
129
- Result: "ValidationError",
130
- Message: `${naturalFlags} must all be supplied together.`,
131
- Instructions: `Pass all of ${naturalFlags} to identify by natural key.`
132
- };
133
- }
134
- return null;
135
- }
136
- async function findExactByNamePaged(fetchPage, match, options = {}) {
137
- const pageSize = options.pageSize ?? 200;
138
- const maxPages = options.maxPages ?? 20;
139
- for (let pageIndex = 0;pageIndex < maxPages; pageIndex++) {
140
- const page = await fetchPage(pageSize, pageIndex * pageSize);
141
- const items = page.data ?? [];
142
- const found = items.find(match);
143
- if (found)
144
- return found;
145
- if (items.length < pageSize)
146
- return null;
147
- }
148
- return null;
149
- }
150
- function splitKeys(raw) {
151
- return raw.flatMap((k) => k.split(",")).map((k) => k.trim()).filter((k) => k.length > 0);
152
- }
153
- function parseTop(raw, flagName = "--top") {
154
- const parsed = Number(raw);
155
- if (raw.trim() === "" || Number.isNaN(parsed) || !Number.isInteger(parsed) || parsed < 0) {
156
- throw new Error(`Invalid value for ${flagName}: "${raw}" must be a non-negative integer.`);
157
- }
158
- return parsed;
159
- }
160
- function parseSkip(raw, flagName = "--skip") {
161
- const parsed = Number(raw);
162
- if (raw.trim() === "" || Number.isNaN(parsed) || !Number.isInteger(parsed) || parsed < 0) {
163
- throw new Error(`Invalid value for ${flagName}: "${raw}" must be a non-negative integer.`);
164
- }
165
- return parsed;
166
- }
167
- function resolvePaginationOptions(options, defaults = {
168
- limit: "50",
169
- offset: "0"
170
- }) {
171
- const limit = resolveDeprecatedOptionAlias({
172
- preferredValue: options.limit,
173
- deprecatedValue: options.top,
174
- preferredFlag: "--limit",
175
- deprecatedFlag: "--top"
176
- });
177
- if (limit.error) {
178
- return { top: 0, skip: 0, error: limit.error };
179
- }
180
- const offset = resolveDeprecatedOptionAlias({
181
- preferredValue: options.offset,
182
- deprecatedValue: options.skip,
183
- preferredFlag: "--offset",
184
- deprecatedFlag: "--skip"
185
- });
186
- if (offset.error) {
187
- return { top: 0, skip: 0, error: offset.error };
188
- }
189
- if (limit.usedDeprecated) {
190
- warnDeprecatedOptionAlias("--top", "--limit");
191
- }
192
- if (offset.usedDeprecated) {
193
- warnDeprecatedOptionAlias("--skip", "--offset");
194
- }
195
- const limitFlag = limit.usedDeprecated ? "--top" : "--limit";
196
- const offsetFlag = offset.usedDeprecated ? "--skip" : "--offset";
197
- try {
198
- return {
199
- top: parseTop(limit.value ?? defaults.limit, limitFlag),
200
- skip: parseSkip(offset.value ?? defaults.offset, offsetFlag)
201
- };
202
- } catch (err) {
203
- return {
204
- top: 0,
205
- skip: 0,
206
- error: {
207
- message: err instanceof Error ? err.message : String(err),
208
- instructions: "Pass a non-negative integer, e.g. --limit 50 --offset 0."
209
- }
210
- };
211
- }
212
- }
213
- function toPascalCase(key) {
214
- if (!key)
215
- return key;
216
- return key.charAt(0).toUpperCase() + key.slice(1);
217
- }
218
- function toPascalCaseKeys(value) {
219
- if (value === null || value === undefined)
220
- return value;
221
- if (Array.isArray(value))
222
- return value.map(toPascalCaseKeys);
223
- if (typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
224
- const result = {};
225
- for (const [k, v] of Object.entries(value)) {
226
- result[toPascalCase(k)] = toPascalCaseKeys(v);
227
- }
228
- return result;
229
- }
230
- return value;
231
- }
232
- function hasText(value) {
233
- return value !== null && value !== undefined && value.trim() !== "";
234
- }
235
- function sameGuid(a, b) {
236
- return typeof a === "string" && typeof b === "string" && a.toLowerCase() === b.toLowerCase();
237
- }
238
- var TIMER_MAX_MS = 2147483647;
239
- function resolveWaitTiming(options) {
240
- const timeoutRaw = options.timeout ?? "";
241
- const intervalRaw = options.pollInterval ?? "";
242
- for (const [flag, raw] of [
243
- ["--timeout", timeoutRaw],
244
- ["--poll-interval", intervalRaw]
245
- ]) {
246
- if (raw.trim().length === 0) {
247
- OutputFormatter.error({
248
- Result: RESULTS.Failure,
249
- Message: `${flag} was empty.`,
250
- Instructions: `Pass a number of seconds, e.g. ${flag} ${flag === "--timeout" ? "1800" : "10"}.`,
251
- ErrorCode: "invalid_argument",
252
- Retry: "RetryWillNotFix"
253
- });
254
- processContext.exit(1);
255
- return null;
256
- }
257
- }
258
- const timeoutS = Number(timeoutRaw);
259
- if (!Number.isFinite(timeoutS) || timeoutS < 0) {
260
- OutputFormatter.error({
261
- Result: RESULTS.Failure,
262
- Message: `Invalid --timeout value: '${String(options.timeout)}'. Must be a non-negative number.`,
263
- Instructions: "Pass seconds, e.g. --timeout 1800",
264
- ErrorCode: "invalid_argument",
265
- Retry: "RetryWillNotFix"
266
- });
267
- processContext.exit(1);
268
- return null;
269
- }
270
- const intervalS = Number(intervalRaw);
271
- if (!Number.isFinite(intervalS) || intervalS <= 0) {
272
- OutputFormatter.error({
273
- Result: RESULTS.Failure,
274
- Message: `Invalid --poll-interval value: '${String(options.pollInterval)}'. Must be a positive number.`,
275
- Instructions: "Pass seconds, e.g. --poll-interval 10",
276
- ErrorCode: "invalid_argument",
277
- Retry: "RetryWillNotFix"
278
- });
279
- processContext.exit(1);
280
- return null;
281
- }
282
- const timeoutMs = timeoutS * 1000;
283
- const intervalMs = intervalS * 1000;
284
- if (intervalMs > TIMER_MAX_MS) {
285
- OutputFormatter.error({
286
- Result: RESULTS.Failure,
287
- Message: `--poll-interval value '${intervalS}' is larger than the longest delay a timer can hold (${Math.floor(TIMER_MAX_MS / 1000)} seconds).`,
288
- Instructions: "Pass a smaller number of seconds, e.g. --poll-interval 10.",
289
- ErrorCode: "invalid_argument",
290
- Retry: "RetryWillNotFix"
291
- });
292
- processContext.exit(1);
293
- return null;
294
- }
295
- for (const [flag, seconds, ms] of [
296
- ["--timeout", timeoutS, timeoutMs],
297
- ["--poll-interval", intervalS, intervalMs]
298
- ]) {
299
- if (!Number.isFinite(ms)) {
300
- OutputFormatter.error({
301
- Result: RESULTS.Failure,
302
- Message: `${flag} value '${seconds}' is too large to use as a duration.`,
303
- Instructions: flag === "--timeout" ? "Pass a smaller number of seconds, e.g. --timeout 14400, or --timeout 0 for no ceiling." : "Pass a smaller number of seconds, e.g. --poll-interval 10.",
304
- ErrorCode: "invalid_argument",
305
- Retry: "RetryWillNotFix"
306
- });
307
- processContext.exit(1);
308
- return null;
309
- }
310
- }
311
- return { intervalMs, timeoutMs };
312
- }
40
+ // src/utils/request-timeout.ts
41
+ var TM_REQUEST_TIMEOUT_MS = 60000;
313
42
 
314
- // src/utils/error-handler.ts
315
- var TM_NOT_AVAILABLE_PATTERNS = [/testmanager not found in organization/i];
316
- var FEATURE_DISABLED_PATTERN = /\bfeatureDisabled\b/i;
317
- var TM_PORTAL_ROUTE_PATTERN = /\/portal_\//i;
318
- var TM_PORTAL_SHELL_PATTERNS = [
319
- /portalShellLoaded/i,
320
- /window\.PortalShell\.initialize/i
321
- ];
322
- function hasKnownPortalShellMarkers(body) {
323
- return TM_PORTAL_SHELL_PATTERNS.every((pattern) => pattern.test(body));
324
- }
325
- function isPortalShellDocument(body) {
326
- return TM_PORTAL_ROUTE_PATTERN.test(body) && hasKnownPortalShellMarkers(body);
327
- }
328
- function shouldWarnAboutPortalShellDrift(result) {
329
- return result.context?.httpStatus === 200 && isHtmlDocument(result.details) && TM_PORTAL_ROUTE_PATTERN.test(result.details) && !hasKnownPortalShellMarkers(result.details);
330
- }
331
- function isTmNotAvailableError(result) {
332
- if (TM_NOT_AVAILABLE_PATTERNS.some((pattern) => pattern.test(result.details))) {
333
- return true;
334
- }
335
- return result.context?.httpStatus === 200 && isHtmlDocument(result.details) && isPortalShellDocument(result.details);
336
- }
337
- function isFeatureDisabledError(result) {
338
- return result.context?.httpStatus === 403 && FEATURE_DISABLED_PATTERN.test(`${result.context?.errorCode ?? ""} ${result.details}`);
339
- }
340
- async function extractErrorDetails(error, options) {
341
- const result = await extractErrorDetails2(error, {
342
- ...options,
343
- forbiddenMessage: options?.forbiddenMessage ?? TM_FORBIDDEN_MESSAGE
344
- });
345
- if (isTmNotAvailableError(result)) {
346
- return {
347
- ...result,
348
- message: TM_NOT_AVAILABLE_MESSAGE,
349
- details: TM_NOT_AVAILABLE_INSTRUCTIONS
350
- };
351
- }
352
- if (shouldWarnAboutPortalShellDrift(result)) {
353
- logger.warn("Test Manager returned portal HTML with the expected route but without known shell markers. The Test Manager availability detector may need updating.");
354
- }
355
- return result;
356
- }
357
- async function emitTmFailure(error, options) {
358
- const { instructionsSuffix, ...extractOptions } = options ?? {};
359
- const classified = await extractErrorDetails(error, {
360
- ...extractOptions,
361
- forbiddenMessage: extractOptions.forbiddenMessage ?? TM_FORBIDDEN_MESSAGE
362
- });
363
- emitTmFailureDetails(classified, instructionsSuffix);
364
- }
365
- function emitTmFailureDetails(classified, instructionsSuffix) {
366
- const { result, message, details, errorCode, retry } = classified;
367
- const suffix = typeof instructionsSuffix === "function" ? instructionsSuffix(errorCode) : instructionsSuffix;
368
- OutputFormatter.error({
369
- Result: result,
370
- ErrorCode: errorCode,
371
- Message: message,
372
- Instructions: suffix ? `${details} ${suffix}`.trim() : details,
373
- Retry: retry
374
- });
375
- }
376
- async function refuseUnexpectedContentType(response, accept, expected, what) {
377
- const contentType = response.raw.headers.get("content-type") ?? "";
378
- if (contentType.trim() === "" || accept.test(contentType))
379
- return false;
380
- const responseError = Object.assign(new Error(`${what} returned content-type "${contentType || "<empty>"}"; expected ${expected}.`), { response: response.raw.clone() });
381
- await emitTmFailure(responseError);
382
- return true;
383
- }
384
- function emitInvalidArgument(message, instructions) {
385
- OutputFormatter.error({
386
- Result: RESULTS.ValidationError,
387
- ErrorCode: "invalid_argument",
388
- Message: message,
389
- Instructions: instructions,
390
- Retry: "RetryWillNotFix"
391
- });
392
- }
393
- function emitAttachmentNotFound(attachmentId, objectType) {
394
- OutputFormatter.error({
395
- Result: RESULTS.Failure,
396
- ErrorCode: "not_found",
397
- Message: `Attachment '${attachmentId}' was not found for object type '${objectType}'.`,
398
- Instructions: "Run 'uip tm attachment list' on the parent object to find its attachment ids, and check --object-type matches the object the file is attached to.",
399
- Retry: "RetryWillNotFix"
400
- });
401
- }
402
- function instructiveError(message, instructions, errorCode, retry = "RetryWillNotFix") {
403
- const error = new Error(message);
404
- error.instructions = instructions;
405
- error.errorCode = errorCode;
406
- error.retry = retry;
407
- return error;
408
- }
409
- function readInstructions(error) {
410
- const candidate = error;
411
- return typeof candidate?.instructions === "string" ? candidate.instructions : undefined;
412
- }
413
- function readClassification(error) {
414
- const candidate = error;
415
- return {
416
- errorCode: isCliErrorCode(candidate?.errorCode) ? candidate.errorCode : undefined,
417
- retry: isRetryHint(candidate?.retry) ? candidate.retry : undefined
43
+ class TmRequestTimeoutError extends Error {
44
+ code = "ETIMEDOUT";
45
+ constructor(method, url, timeoutMs) {
46
+ super(`Test Manager did not answer ${method} ${new URL(url).pathname} within ${Math.round(timeoutMs / 1000)} s. ` + "The request may still have been applied; check before repeating a change.");
47
+ this.name = "TmRequestTimeoutError";
48
+ }
49
+ }
50
+ function isUpload(body) {
51
+ return typeof FormData !== "undefined" && body instanceof FormData || typeof Blob !== "undefined" && body instanceof Blob;
52
+ }
53
+ function createTimeoutFetch(timeoutMs = TM_REQUEST_TIMEOUT_MS) {
54
+ return async (input, init = {}) => {
55
+ if (isUpload(init.body))
56
+ return globalThis.fetch(input, init);
57
+ const request = input instanceof Request ? input : undefined;
58
+ const url = request?.url ?? (input instanceof URL ? input.href : String(input));
59
+ const method = init.method ?? request?.method ?? "GET";
60
+ const controller = new AbortController;
61
+ const timer = setTimeout(() => controller.abort(new TmRequestTimeoutError(method, url, timeoutMs)), timeoutMs);
62
+ const callerSignal = init.signal ?? request?.signal;
63
+ const signal = callerSignal ? AbortSignal.any([callerSignal, controller.signal]) : controller.signal;
64
+ try {
65
+ return await globalThis.fetch(input, { ...init, signal });
66
+ } catch (err) {
67
+ if (controller.signal.aborted)
68
+ throw controller.signal.reason;
69
+ throw err;
70
+ } finally {
71
+ clearTimeout(timer);
72
+ }
418
73
  };
419
74
  }
420
75
 
@@ -529,11 +184,6 @@ async function getProjectLookupResult(projectKey, rawResponse) {
529
184
  }
530
185
  };
531
186
  }
532
- function configureLoggerFromOptions(logLevel) {
533
- const key = (logLevel ?? "Information").toUpperCase();
534
- const lvl = LogLevel[key] ?? 1 /* INFO */;
535
- configureLogger({ level: lvl });
536
- }
537
187
  async function resolveAuth(options) {
538
188
  const authCtx = await getAuthContext({
539
189
  tenant: options.tenant,
@@ -546,20 +196,21 @@ async function resolveAuth(options) {
546
196
  const tmBaseUrl = `${authCtx.baseUrl}/${encodeURIComponent(organizationId)}/${encodeURIComponent(tenantName)}/testmanager_`;
547
197
  const tmConfig = new Configuration2({
548
198
  basePath: tmBaseUrl,
549
- accessToken: authCtx.accessToken
199
+ accessToken: authCtx.accessToken,
200
+ fetchApi: createTimeoutFetch()
550
201
  });
551
202
  return {
552
203
  accessToken: authCtx.accessToken,
553
204
  baseUrl: authCtx.baseUrl,
554
205
  organizationId,
555
206
  organizationName: authCtx.organizationName,
207
+ tenantId: authCtx.tenantId,
556
208
  tenantName,
557
209
  tmBaseUrl,
558
210
  tmConfig
559
211
  };
560
212
  }
561
213
  async function initializeContext(options) {
562
- configureLoggerFromOptions(options.logLevel);
563
214
  return resolveAuth(options);
564
215
  }
565
216
  function selectProject(options) {
@@ -608,7 +259,6 @@ function selectProject(options) {
608
259
  return { kind: "key", projectKey: derivedKey };
609
260
  }
610
261
  async function initializeContextWithProject(options) {
611
- configureLoggerFromOptions(options.logLevel);
612
262
  const selection = selectProject(options);
613
263
  if (selection === null) {
614
264
  return null;
@@ -627,14 +277,7 @@ async function initializeContextWithProject(options) {
627
277
  projectPrefix: projectKey
628
278
  }));
629
279
  if (projectError) {
630
- const { message, details } = await extractErrorDetails(projectError, {
631
- forbiddenMessage: TM_FORBIDDEN_MESSAGE
632
- });
633
- OutputFormatter.error({
634
- Result: RESULTS.Failure,
635
- Message: message,
636
- Instructions: details
637
- });
280
+ await emitTmFailure(projectError);
638
281
  processContext.exit(1);
639
282
  return null;
640
283
  }
@@ -880,6 +523,20 @@ function withRefreshingToken(base) {
880
523
  });
881
524
  }
882
525
 
526
+ // src/utils/enum-option.ts
527
+ function enumOption(flags, description, values) {
528
+ const option = new Option(flags, description).choices(values);
529
+ return option.argParser((value, previous) => {
530
+ const match = values.find((v) => v.toLowerCase() === value.toLowerCase());
531
+ if (match === undefined) {
532
+ throw new InvalidArgumentError(`Allowed choices are ${values.join(", ")}.`);
533
+ }
534
+ if (!option.variadic)
535
+ return match;
536
+ return Array.isArray(previous) && previous !== option.defaultValue ? [...previous, match] : [match];
537
+ });
538
+ }
539
+
883
540
  // src/utils/filter-values.ts
884
541
  function flagName(flag) {
885
542
  return flag.startsWith("--") ? flag : `--${flag.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`;
@@ -1461,7 +1118,7 @@ async function readProjectJob(ctx, jobId) {
1461
1118
  return job;
1462
1119
  }
1463
1120
  var registerProjectExportCommand = (parent) => {
1464
- parent.command("export").description("Export a project to a .tmh package. The service runs this as a background job with no push notification, so this returns the job id to poll yourself unless --wait is given, in which case it polls until the job finishes and writes the file.").addOption(projectKeyOption()).addOption(projectIdOption()).option("--output-file <path>", "Where to write the .tmh package. Required with --wait.").option("--overwrite", "Replace --output-file if it already exists. Without it, an existing file is refused before the export starts").addOption(new Option("--include <content...>", `Content to add to the package, space-separated. ${describeContentDefaults(EXPORT_CONTENT)}`).choices(EXPORT_CONTENT_CHOICES)).addOption(new Option("--exclude <content...>", `Content to leave out of the package, space-separated. ${describeContentDefaults(EXPORT_CONTENT)}`).choices(EXPORT_CONTENT_CHOICES)).option("--wait", "Poll until the export finishes and download the package to --output-file").option("--timeout <seconds>", "Maximum seconds to wait (0 = no timeout). Requires --wait.", String(DEFAULT_EXPORT_TIMEOUT_MS / 1000)).option("--poll-interval <seconds>", "Seconds between status checks. Requires --wait.", String(DEFAULT_MIGRATION_INTERVAL_MS / 1000)).addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--log-level <level>", "Log verbosity: debug, info, warn, error", "Information").examples(MIGRATION_EXPORT_EXAMPLES).trackedAction(processContext, async (options) => {
1121
+ parent.command("export").description("Export a project to a .tmh package. The service runs this as a background job with no push notification, so this returns the job id to poll yourself unless --wait is given, in which case it polls until the job finishes and writes the file.").addOption(projectKeyOption()).addOption(projectIdOption()).option("--output-file <path>", "Where to write the .tmh package. Required with --wait.").option("--overwrite", "Replace --output-file if it already exists. Without it, an existing file is refused before the export starts").addOption(new Option("--include <content...>", `Content to add to the package, space-separated. ${describeContentDefaults(EXPORT_CONTENT)}`).choices(EXPORT_CONTENT_CHOICES)).addOption(new Option("--exclude <content...>", `Content to leave out of the package, space-separated. ${describeContentDefaults(EXPORT_CONTENT)}`).choices(EXPORT_CONTENT_CHOICES)).option("--wait", "Poll until the export finishes and download the package to --output-file").option("--timeout <seconds>", "Maximum seconds to wait (0 = no timeout). Requires --wait.", String(DEFAULT_EXPORT_TIMEOUT_MS / 1000)).option("--poll-interval <seconds>", "Seconds between status checks. Requires --wait.", String(DEFAULT_MIGRATION_INTERVAL_MS / 1000)).addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).examples(MIGRATION_EXPORT_EXAMPLES).trackedAction(processContext, async (options) => {
1465
1122
  const selection = {
1466
1123
  include: options.include,
1467
1124
  exclude: options.exclude
@@ -1538,7 +1195,7 @@ async function finishWaitedExport(tmConfig, projectId, jobId, timing, options) {
1538
1195
  }
1539
1196
  var registerMigrationCommand = (program) => {
1540
1197
  const migrationCmd = program.command("migration").description("Inspect and download the migration jobs behind `project export`");
1541
- migrationCmd.command("get").description("Get a migration job by id.").addOption(projectKeyOption()).addOption(projectIdOption()).requiredOption("--job-id <uuid>", "Migration job UUID").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--log-level <level>", "Log verbosity: debug, info, warn, error", "Information").examples(MIGRATION_JOB_GET_EXAMPLES).trackedAction(processContext, async (options) => {
1198
+ migrationCmd.command("get").description("Get a migration job by id.").addOption(projectKeyOption()).addOption(projectIdOption()).requiredOption("--job-id <uuid>", "Migration job UUID").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).examples(MIGRATION_JOB_GET_EXAMPLES).trackedAction(processContext, async (options) => {
1542
1199
  const jobId = String(options.jobId ?? "").trim();
1543
1200
  if (jobId === "") {
1544
1201
  emitInvalidArgument("--job-id cannot be blank.", "Pass the id of a migration job, e.g. --job-id a1b2c3d4-0000-0000-0000-000000000001.");
@@ -1552,7 +1209,7 @@ var registerMigrationCommand = (program) => {
1552
1209
  return;
1553
1210
  OutputFormatter.success(new SuccessOutput("MigrationJobGet", toMigrationJobOutput(job)));
1554
1211
  });
1555
- migrationCmd.command("download").description("Download the .tmh from an export job that already finished, without exporting again.").addOption(projectKeyOption()).addOption(projectIdOption()).requiredOption("--job-id <uuid>", "Export job UUID").requiredOption("--output-file <path>", "Where to write the package").option("--overwrite", "Replace --output-file if it already exists. Without it, an existing file is refused and nothing is written").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--log-level <level>", "Log verbosity: debug, info, warn, error", "Information").examples(MIGRATION_JOB_DOWNLOAD_EXAMPLES).trackedAction(processContext, async (options) => {
1212
+ migrationCmd.command("download").description("Download the .tmh from an export job that already finished, without exporting again.").addOption(projectKeyOption()).addOption(projectIdOption()).requiredOption("--job-id <uuid>", "Export job UUID").requiredOption("--output-file <path>", "Where to write the package").option("--overwrite", "Replace --output-file if it already exists. Without it, an existing file is refused and nothing is written").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).examples(MIGRATION_JOB_DOWNLOAD_EXAMPLES).trackedAction(processContext, async (options) => {
1556
1213
  const jobId = String(options.jobId ?? "").trim();
1557
1214
  if (jobId === "") {
1558
1215
  emitInvalidArgument("--job-id cannot be blank.", "Pass the job id an export returned, e.g. --job-id a1b2c3d4-0000-0000-0000-000000000001.");
@@ -1597,7 +1254,7 @@ var registerMigrationCommand = (program) => {
1597
1254
  Bytes: bytes
1598
1255
  }));
1599
1256
  });
1600
- migrationCmd.command("list").description("Find a migration job when you no longer have its id, newest first. Pass --project-key or --project-id to narrow it to one project: the service lists across the whole tenant, including projects you have no role on.").addOption(new Option("--status <status>", `Filter by job status (${Object.values(UiPathTestManagementHubProjectMigrationAbstractionsEnumsMigrationJobStatus2).join(", ")})`).choices(Object.values(UiPathTestManagementHubProjectMigrationAbstractionsEnumsMigrationJobStatus2))).addOption(new Option("--type <type>", `Filter by job type (${Object.values(UiPathTestManagementHubProjectMigrationAbstractionsEnumsMigrationJobType2).join(", ")})`).choices(Object.values(UiPathTestManagementHubProjectMigrationAbstractionsEnumsMigrationJobType2))).addOption(projectKeyOption("Only jobs for this project — a filter, not a scope")).addOption(projectIdOption()).option("--package-name <name>", "Filter by package name").option("--filter <text>", "Substring match on package name. --package-name matches the whole name").option("--sort-by <expression>", "Sort as '<property> asc|desc', e.g. 'updated asc'", DEFAULT_JOB_SORT).option("--limit <number>", "Maximum jobs to return", "50").option("--offset <number>", "Jobs to skip", "0").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--log-level <level>", "Log verbosity: debug, info, warn, error", "Information").examples(MIGRATION_JOB_LIST_EXAMPLES).trackedAction(processContext, async (options) => {
1257
+ migrationCmd.command("list").description("Find a migration job when you no longer have its id, newest first. Pass --project-key or --project-id to narrow it to one project: the service lists across the whole tenant, including projects you have no role on.").addOption(enumOption("--status <status>", `Filter by job status (${Object.values(UiPathTestManagementHubProjectMigrationAbstractionsEnumsMigrationJobStatus2).join(", ")})`, Object.values(UiPathTestManagementHubProjectMigrationAbstractionsEnumsMigrationJobStatus2))).addOption(enumOption("--type <type>", `Filter by job type (${Object.values(UiPathTestManagementHubProjectMigrationAbstractionsEnumsMigrationJobType2).join(", ")})`, Object.values(UiPathTestManagementHubProjectMigrationAbstractionsEnumsMigrationJobType2))).addOption(projectKeyOption("Only jobs for this project — a filter, not a scope")).addOption(projectIdOption()).option("--package-name <name>", "Filter by package name").option("--filter <text>", "Substring match on package name. --package-name matches the whole name").option("--sort-by <expression>", "Sort as '<property> asc|desc', e.g. 'updated asc'", DEFAULT_JOB_SORT).option("--limit <number>", "Maximum jobs to return", "50").option("--offset <number>", "Jobs to skip", "0").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).examples(MIGRATION_JOB_LIST_EXAMPLES).trackedAction(processContext, async (options) => {
1601
1258
  if (blankFilterGiven(options, ["packageName", "filter", "sortBy"]))
1602
1259
  return;
1603
1260
  const paging = resolvePaginationOptions(options);
@@ -1669,6 +1326,6 @@ var registerMigrationCommand = (program) => {
1669
1326
  return migrationCmd;
1670
1327
  };
1671
1328
 
1672
- export { stripEncodingMarkers, ROBOT_LOG_LEVELS, TERMINAL_STATUSES, msToDuration, calcPassRate, DEFAULT_TEST_CASE_VERSION, SCHEMA_FORBIDDEN_MESSAGE, PROJECT_CONFIG_IMPORT_FORBIDDEN_MESSAGE, TM_FORBIDDEN_MESSAGE, TM_LICENSED_USER_FORBIDDEN_MESSAGE, TM_TEST_CLOUD_FORBIDDEN_MESSAGE, TM_NOT_AVAILABLE_MESSAGE, TM_NOT_AVAILABLE_INSTRUCTIONS, TAGGED_UPLOAD_NOT_SUPPORTED_INSTRUCTIONS, parseCustomFieldObjectType, parseCustomFieldDataType, validateIdentity, findExactByNamePaged, splitKeys, resolvePaginationOptions, hasText, sameGuid, resolveWaitTiming, toOutput, toIsoDate, isPortalShellDocument, isFeatureDisabledError, extractErrorDetails, emitTmFailure, emitTmFailureDetails, refuseUnexpectedContentType, emitInvalidArgument, emitAttachmentNotFound, instructiveError, readInstructions, readClassification, tmWebUrl, initializeContext, initializeContextWithProject, resolveContextWithProject, ensureProjectKey, projectKeyOption, projectIdOption, blankValueMessage, blankFilterGiven, IMPORT_CONTENT, IMPORT_CONTENT_CHOICES, toImportJobRequest, toChunkUploadRequest, toJobUpdateRequest, toMigrationJobOutput, toSchemaVersionRows, DEFAULT_IMPORT_TIMEOUT_MS, DEFAULT_MIGRATION_INTERVAL_MS, CHUNK_UPLOAD_ATTEMPTS, CHUNK_RETRY_BACKOFF_MS, CHUNK_SIZE_BYTES, MAX_PACKAGE_NAME_LENGTH, MAX_IMPORT_PACKAGE_BYTES, CHUNK_NOT_SENT_CODES, checkOutputTarget, resolveOutputPath, withRefreshingToken, describeContentDefaults, checkContentSelection, waitForMigrationJob, recheckJobHint, writeZipResponse, registerProjectExportCommand, registerMigrationCommand };
1329
+ export { toOutput, toIsoDate, tmWebUrl, initializeContext, initializeContextWithProject, resolveContextWithProject, ensureProjectKey, enumOption, projectKeyOption, projectIdOption, blankValueMessage, blankFilterGiven, IMPORT_CONTENT, IMPORT_CONTENT_CHOICES, toImportJobRequest, toChunkUploadRequest, toJobUpdateRequest, toMigrationJobOutput, toSchemaVersionRows, DEFAULT_IMPORT_TIMEOUT_MS, DEFAULT_MIGRATION_INTERVAL_MS, CHUNK_UPLOAD_ATTEMPTS, CHUNK_RETRY_BACKOFF_MS, CHUNK_SIZE_BYTES, MAX_PACKAGE_NAME_LENGTH, MAX_IMPORT_PACKAGE_BYTES, CHUNK_NOT_SENT_CODES, checkOutputTarget, resolveOutputPath, withRefreshingToken, describeContentDefaults, checkContentSelection, waitForMigrationJob, recheckJobHint, writeZipResponse, registerProjectExportCommand, registerMigrationCommand };
1673
1330
 
1674
- //# debugId=6868C82965129C4264756E2164756E21
1331
+ //# debugId=45341E7131C483BB64756E2164756E21
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  UiPathTestManagementHubCommonEnumsObjectType2
3
- } from "./tool-1nkyed5m.js";
3
+ } from "./tool-hm0kg56c.js";
4
4
 
5
5
  // src/mappers/input/attachment.input.ts
6
6
  function toGetAttachmentsByObjectIdRequest2(id, projectId, objectType) {
package/dist/tool.js CHANGED
@@ -1,16 +1,19 @@
1
1
  import {
2
2
  metadata2,
3
3
  registerCommands2
4
- } from "./tool-bep6n7t3.js";
5
- import"./tool-fz859vt8.js";
6
- import"./tool-vgc9gpy6.js";
7
- import"./tool-967s3mts.js";
8
- import"./tool-0650qfw3.js";
9
- import"./tool-1nkyed5m.js";
10
- import"./tool-6mpkbszw.js";
4
+ } from "./tool-fspr1btk.js";
5
+ import"./tool-w2tgc8pr.js";
6
+ import"./tool-y8kmsg4w.js";
7
+ import"./tool-b24ehgnz.js";
8
+ import"./tool-begvxz7a.js";
9
+ import"./tool-bvkzq6jr.js";
10
+ import"./tool-246df0cd.js";
11
+ import"./tool-4xdq18pz.js";
12
+ import"./tool-hm0kg56c.js";
13
+ import"./tool-f4ytsjzn.js";
11
14
  export {
12
15
  metadata2 as metadata,
13
16
  registerCommands2 as registerCommands
14
17
  };
15
18
 
16
- //# debugId=6A0047DB14A5D92D64756E2164756E21
19
+ //# debugId=AC0F61B59142B50164756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/test-manager-tool",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.206.0-preview.301",
5
+ "version": "1.207.0-preview.305",
6
6
  "description": "Manage test cases, test sets, executions, and results.",
7
7
  "private": false,
8
8
  "repository": {
@@ -27,5 +27,5 @@
27
27
  "files": [
28
28
  "dist"
29
29
  ],
30
- "gitHead": "078afc3ef7ebf4c38353ee0059e321acf16a350d"
30
+ "gitHead": "1600aa89255c37c1b8bc68d9882c3395c1d5bff4"
31
31
  }