@uipath/resourcecatalog-tool 1.1.0 → 1.195.0

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 (3) hide show
  1. package/dist/index.js +620 -118
  2. package/dist/tool.js +620 -118
  3. package/package.json +28 -34
package/dist/index.js CHANGED
@@ -2761,6 +2761,7 @@ var init_open = __esm(() => {
2761
2761
  });
2762
2762
 
2763
2763
  // ../../filesystem/src/node.ts
2764
+ import { randomUUID } from "node:crypto";
2764
2765
  import { existsSync } from "node:fs";
2765
2766
  import * as fs6 from "node:fs/promises";
2766
2767
  import * as os2 from "node:os";
@@ -2842,6 +2843,90 @@ class NodeFileSystem {
2842
2843
  async mkdir(dirPath) {
2843
2844
  await fs6.mkdir(dirPath, { recursive: true });
2844
2845
  }
2846
+ async acquireLock(lockPath) {
2847
+ const canonicalPath = await this.canonicalizeLockTarget(lockPath);
2848
+ const lockFile = `${canonicalPath}.lock`;
2849
+ const ownerId = randomUUID();
2850
+ const start = Date.now();
2851
+ while (true) {
2852
+ try {
2853
+ await fs6.writeFile(lockFile, ownerId, { flag: "wx" });
2854
+ return this.createLockRelease(lockFile, ownerId);
2855
+ } catch (error) {
2856
+ if (!this.hasErrnoCode(error, "EEXIST")) {
2857
+ throw error;
2858
+ }
2859
+ const stats = await fs6.stat(lockFile).catch(() => null);
2860
+ if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
2861
+ const reclaimed = await fs6.rm(lockFile, { force: true }).then(() => true).catch(() => false);
2862
+ if (reclaimed)
2863
+ continue;
2864
+ }
2865
+ if (Date.now() - start > LOCK_MAX_WAIT_MS) {
2866
+ throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
2867
+ }
2868
+ await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
2869
+ }
2870
+ }
2871
+ }
2872
+ async canonicalizeLockTarget(lockPath) {
2873
+ const absolute = path2.resolve(lockPath);
2874
+ const fullReal = await fs6.realpath(absolute).catch(() => null);
2875
+ if (fullReal)
2876
+ return fullReal;
2877
+ const parent = path2.dirname(absolute);
2878
+ const base = path2.basename(absolute);
2879
+ const canonicalParent = await fs6.realpath(parent).catch(() => parent);
2880
+ return path2.join(canonicalParent, base);
2881
+ }
2882
+ createLockRelease(lockFile, ownerId) {
2883
+ const heartbeatStart = Date.now();
2884
+ let heartbeatTimer;
2885
+ let stopped = false;
2886
+ const stopHeartbeat = () => {
2887
+ stopped = true;
2888
+ if (heartbeatTimer)
2889
+ clearTimeout(heartbeatTimer);
2890
+ };
2891
+ const scheduleNextHeartbeat = () => {
2892
+ if (stopped)
2893
+ return;
2894
+ if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) {
2895
+ stopped = true;
2896
+ return;
2897
+ }
2898
+ heartbeatTimer = setTimeout(() => {
2899
+ runHeartbeat();
2900
+ }, LOCK_HEARTBEAT_MS);
2901
+ heartbeatTimer.unref?.();
2902
+ };
2903
+ const runHeartbeat = async () => {
2904
+ if (stopped)
2905
+ return;
2906
+ const current = await fs6.readFile(lockFile, "utf-8").catch(() => null);
2907
+ if (stopped)
2908
+ return;
2909
+ if (current !== ownerId) {
2910
+ stopped = true;
2911
+ return;
2912
+ }
2913
+ const now = Date.now() / 1000;
2914
+ await fs6.utimes(lockFile, now, now).catch(() => {});
2915
+ scheduleNextHeartbeat();
2916
+ };
2917
+ scheduleNextHeartbeat();
2918
+ let released = false;
2919
+ return async () => {
2920
+ if (released)
2921
+ return;
2922
+ released = true;
2923
+ stopHeartbeat();
2924
+ const current = await fs6.readFile(lockFile, "utf-8").catch(() => null);
2925
+ if (current === ownerId) {
2926
+ await fs6.rm(lockFile, { force: true });
2927
+ }
2928
+ };
2929
+ }
2845
2930
  async rm(filePath) {
2846
2931
  await fs6.rm(filePath, { recursive: true, force: true });
2847
2932
  }
@@ -2887,9 +2972,13 @@ class NodeFileSystem {
2887
2972
  }
2888
2973
  }
2889
2974
  isEnoent(error) {
2890
- return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
2975
+ return this.hasErrnoCode(error, "ENOENT");
2976
+ }
2977
+ hasErrnoCode(error, code) {
2978
+ return typeof error === "object" && error !== null && "code" in error && error.code === code;
2891
2979
  }
2892
2980
  }
2981
+ var LOCK_HEARTBEAT_MS = 5000, LOCK_STALE_MS = 15000, LOCK_MAX_WAIT_MS = 20000, LOCK_MAX_HOLD_MS = 60000, LOCK_RETRY_MIN_MS = 100, LOCK_RETRY_JITTER_MS = 200;
2893
2982
  var init_node = __esm(() => {
2894
2983
  init_open();
2895
2984
  });
@@ -2942,7 +3031,7 @@ function isBrowser() {
2942
3031
 
2943
3032
  // ../../../node_modules/@uipath/coreipc/index.js
2944
3033
  var require_coreipc = __commonJS((exports, module) => {
2945
- var __dirname = "/Users/alexandru.oltean/github/cli/node_modules/@uipath/coreipc";
3034
+ var __dirname = "/home/runner/work/cli/cli/node_modules/@uipath/coreipc";
2946
3035
  /*! For license information please see index.js.LICENSE.txt */
2947
3036
  (function(e, t) {
2948
3037
  typeof exports == "object" && typeof module == "object" ? module.exports = t() : typeof define == "function" && define.amd ? define([], t) : typeof exports == "object" ? exports.ipc = t() : e.ipc = t();
@@ -21134,6 +21223,10 @@ var require_dist = __commonJS((exports) => {
21134
21223
  exports.RobotProxyConstructor = RobotProxyConstructor;
21135
21224
  __exportStar(require_agent(), exports);
21136
21225
  });
21226
+ // ../../auth/src/server.ts
21227
+ var init_server = __esm(() => {
21228
+ init_constants();
21229
+ });
21137
21230
 
21138
21231
  // ../../../node_modules/commander/esm.mjs
21139
21232
  var import__ = __toESM(require_commander(), 1);
@@ -21153,7 +21246,8 @@ var {
21153
21246
  // package.json
21154
21247
  var package_default = {
21155
21248
  name: "@uipath/resourcecatalog-tool",
21156
- version: "1.1.0",
21249
+ license: "MIT",
21250
+ version: "1.195.0",
21157
21251
  description: "CLI plugin for the UiPath Resource Catalog Service.",
21158
21252
  private: false,
21159
21253
  repository: {
@@ -21332,10 +21426,15 @@ async function extractErrorDetails(error, options) {
21332
21426
  }
21333
21427
  if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
21334
21428
  context.errorCode = parsedBody.errorCode;
21429
+ } else if (parsedBody?.code && typeof parsedBody.code === "string") {
21430
+ context.errorCode = parsedBody.code;
21335
21431
  }
21336
21432
  if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
21337
21433
  context.requestId = parsedBody.requestId;
21338
21434
  }
21435
+ if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
21436
+ context.traceId = parsedBody.traceId;
21437
+ }
21339
21438
  if (status === 429) {
21340
21439
  const resp = response;
21341
21440
  const headersObj = resp?.headers;
@@ -21355,7 +21454,35 @@ async function extractErrorDetails(error, options) {
21355
21454
  }
21356
21455
  }
21357
21456
  const hasContext = Object.keys(context).length > 0;
21358
- return { result, message, details, ...hasContext ? { context } : {} };
21457
+ let parsedErrors;
21458
+ if (parsedBody?.errors && typeof parsedBody.errors === "object") {
21459
+ const errors = {};
21460
+ for (const [field, raw] of Object.entries(parsedBody.errors)) {
21461
+ if (Array.isArray(raw)) {
21462
+ const messages = raw.map((entry) => {
21463
+ if (typeof entry === "string")
21464
+ return entry;
21465
+ if (entry && typeof entry === "object" && typeof entry.message === "string") {
21466
+ return entry.message;
21467
+ }
21468
+ return String(entry);
21469
+ }).filter(Boolean);
21470
+ if (messages.length > 0)
21471
+ errors[field] = messages;
21472
+ } else if (typeof raw === "string") {
21473
+ errors[field] = [raw];
21474
+ }
21475
+ }
21476
+ if (Object.keys(errors).length > 0)
21477
+ parsedErrors = errors;
21478
+ }
21479
+ return {
21480
+ result,
21481
+ message,
21482
+ details,
21483
+ ...hasContext ? { context } : {},
21484
+ ...parsedErrors ? { parsedErrors } : {}
21485
+ };
21359
21486
  }
21360
21487
  async function extractErrorMessage(error, options) {
21361
21488
  const { message } = await extractErrorDetails(error, options);
@@ -26487,6 +26614,60 @@ function escapeNonAscii(jsonText) {
26487
26614
  function needsAsciiSafeJson(sink) {
26488
26615
  return process.platform === "win32" && !sink.capabilities.isInteractive;
26489
26616
  }
26617
+ function isPlainRecord(value) {
26618
+ if (value === null || typeof value !== "object")
26619
+ return false;
26620
+ const prototype = Object.getPrototypeOf(value);
26621
+ return prototype === Object.prototype || prototype === null;
26622
+ }
26623
+ function toLowerCamelCaseKey(key) {
26624
+ if (!key)
26625
+ return key;
26626
+ if (/[_\-\s]/.test(key)) {
26627
+ const [firstPart, ...restParts] = key.split(/[_\-\s]+/).filter(Boolean);
26628
+ if (!firstPart)
26629
+ return key;
26630
+ return [
26631
+ toLowerCamelCaseSimpleKey(firstPart),
26632
+ ...restParts.map((part) => {
26633
+ const normalized = toLowerCamelCaseSimpleKey(part);
26634
+ return normalized.charAt(0).toUpperCase() + normalized.slice(1);
26635
+ })
26636
+ ].join("");
26637
+ }
26638
+ return toLowerCamelCaseSimpleKey(key);
26639
+ }
26640
+ function toLowerCamelCaseSimpleKey(key) {
26641
+ if (/^[A-Z0-9]+$/.test(key))
26642
+ return key.toLowerCase();
26643
+ return key.replace(/^[A-Z]+(?=[A-Z][a-z]|\d|$)|^[A-Z]/, (match) => match.toLowerCase());
26644
+ }
26645
+ function toPascalCaseKey(key) {
26646
+ const lowerCamelKey = toLowerCamelCaseKey(key);
26647
+ return lowerCamelKey ? lowerCamelKey.charAt(0).toUpperCase() + lowerCamelKey.slice(1) : lowerCamelKey;
26648
+ }
26649
+ function toPascalCaseData(value) {
26650
+ if (Array.isArray(value))
26651
+ return value.map(toPascalCaseData);
26652
+ if (!isPlainRecord(value))
26653
+ return value;
26654
+ const result = {};
26655
+ for (const [key, nestedValue] of Object.entries(value)) {
26656
+ result[toPascalCaseKey(key)] = toPascalCaseData(nestedValue);
26657
+ }
26658
+ return result;
26659
+ }
26660
+ function normalizeDataKeys(data) {
26661
+ return toPascalCaseData(data);
26662
+ }
26663
+ function normalizeOutputKeys(data) {
26664
+ const result = {};
26665
+ for (const [key, value] of Object.entries(data)) {
26666
+ const pascalKey = toPascalCaseKey(key);
26667
+ result[pascalKey] = pascalKey === "Data" ? value : toPascalCaseData(value);
26668
+ }
26669
+ return result;
26670
+ }
26490
26671
  function printOutput(data, format = "json", logFn, asciiSafe = false) {
26491
26672
  if (!data) {
26492
26673
  logFn("Empty response object. No data to display.");
@@ -26549,7 +26730,7 @@ function wrapText(text, width) {
26549
26730
  function printTable(data, logFn, externalLogValue) {
26550
26731
  if (data.length === 0)
26551
26732
  return;
26552
- const keys = Object.keys(data[0]).filter((key) => key !== "Code" && key !== "Log");
26733
+ const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
26553
26734
  const maxWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
26554
26735
  const header = keys.map((key, i2) => key.padEnd(maxWidths[i2])).join(" | ");
26555
26736
  logFn(header);
@@ -26564,7 +26745,7 @@ function printTable(data, logFn, externalLogValue) {
26564
26745
  }
26565
26746
  }
26566
26747
  function printVerticalTable(data, logFn = console.log, externalLogValue) {
26567
- const keys = Object.keys(data).filter((key) => key !== "Code" && key !== "Log");
26748
+ const keys = Object.keys(data).filter((key) => !["code", "log"].includes(key.toLowerCase()));
26568
26749
  if (keys.length === 0)
26569
26750
  return;
26570
26751
  const maxKeyWidth = Math.max(...keys.map((key) => key.length));
@@ -26580,7 +26761,7 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
26580
26761
  function printResizableTable(data, logFn = console.log, externalLogValue) {
26581
26762
  if (data.length === 0)
26582
26763
  return;
26583
- const keys = Object.keys(data[0]).filter((key) => key !== "Code" && key !== "Log");
26764
+ const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
26584
26765
  if (keys.length === 0)
26585
26766
  return;
26586
26767
  if (!process.stdout.isTTY) {
@@ -26656,8 +26837,26 @@ function printResizableTable(data, logFn = console.log, externalLogValue) {
26656
26837
  function toYaml(data) {
26657
26838
  return dump(data);
26658
26839
  }
26840
+ class FilterEvaluationError extends Error {
26841
+ __brand = "FilterEvaluationError";
26842
+ filter;
26843
+ instructions;
26844
+ result = RESULTS.ValidationError;
26845
+ constructor(filter, cause) {
26846
+ const underlying = cause instanceof Error ? cause.message : String(cause);
26847
+ super(`Filter '${filter}' failed to evaluate: ${underlying}`);
26848
+ this.name = "FilterEvaluationError";
26849
+ this.filter = filter;
26850
+ this.instructions = `The --output-filter expression '${filter}' failed at evaluation time. ` + "Note that --output-filter operates on the 'Data' field of the envelope, not the full object. " + "For example, on a list result use 'length(@)' instead of 'Data | length(@)'.";
26851
+ }
26852
+ }
26659
26853
  function applyFilter(data, filter) {
26660
- const result = search(data, filter);
26854
+ let result;
26855
+ try {
26856
+ result = search(data, filter);
26857
+ } catch (err) {
26858
+ throw new FilterEvaluationError(filter, err);
26859
+ }
26661
26860
  if (result == null)
26662
26861
  return [];
26663
26862
  if (Array.isArray(result)) {
@@ -26674,13 +26873,18 @@ function applyFilter(data, filter) {
26674
26873
  }
26675
26874
  var OutputFormatter;
26676
26875
  ((OutputFormatter) => {
26677
- function success(data) {
26876
+ function success(data, options) {
26678
26877
  data.Log ??= getLogFilePath() || undefined;
26878
+ const normalize = !options?.preserveDataKeys;
26879
+ if (normalize) {
26880
+ data.Data = normalizeDataKeys(data.Data);
26881
+ }
26679
26882
  const filter = getOutputFilter();
26680
26883
  if (filter) {
26681
- data.Data = applyFilter(data.Data, filter);
26884
+ const filtered = applyFilter(data.Data, filter);
26885
+ data.Data = normalize ? normalizeDataKeys(filtered) : filtered;
26682
26886
  }
26683
- logOutput(data, getOutputFormat());
26887
+ logOutput(normalizeOutputKeys(data), getOutputFormat());
26684
26888
  }
26685
26889
  OutputFormatter.success = success;
26686
26890
  function error(data) {
@@ -26690,7 +26894,7 @@ var OutputFormatter;
26690
26894
  result: data.Result,
26691
26895
  message: data.Message
26692
26896
  });
26693
- logOutput(data, getOutputFormat());
26897
+ logOutput(normalizeOutputKeys(data), getOutputFormat());
26694
26898
  }
26695
26899
  OutputFormatter.error = error;
26696
26900
  function emitList(code, items, opts) {
@@ -26711,13 +26915,14 @@ var OutputFormatter;
26711
26915
  function log(data) {
26712
26916
  const format = getOutputFormat();
26713
26917
  const sink = getOutputSink();
26918
+ const normalized = toPascalCaseData(data);
26714
26919
  if (format === "json") {
26715
- const json2 = JSON.stringify(data);
26920
+ const json2 = JSON.stringify(normalized);
26716
26921
  const safe = needsAsciiSafeJson(sink) ? escapeNonAscii(json2) : json2;
26717
26922
  sink.writeErr(`${safe}
26718
26923
  `);
26719
26924
  } else {
26720
- for (const [key, value] of Object.entries(data)) {
26925
+ for (const [key, value] of Object.entries(normalized)) {
26721
26926
  sink.writeErr(`${key}: ${value}
26722
26927
  `);
26723
26928
  }
@@ -26726,12 +26931,16 @@ var OutputFormatter;
26726
26931
  OutputFormatter.log = log;
26727
26932
  function formatToString(data) {
26728
26933
  const filter = getOutputFilter();
26729
- if (filter && "Data" in data && data.Data != null) {
26730
- data.Data = applyFilter(data.Data, filter);
26934
+ if ("Data" in data && data.Data != null) {
26935
+ data.Data = normalizeDataKeys(data.Data);
26936
+ if (filter) {
26937
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
26938
+ }
26731
26939
  }
26940
+ const output = normalizeOutputKeys(data);
26732
26941
  const lines = [];
26733
26942
  const sink = getOutputSink();
26734
- printOutput(data, getOutputFormat(), (msg) => {
26943
+ printOutput(output, getOutputFormat(), (msg) => {
26735
26944
  lines.push(msg);
26736
26945
  }, needsAsciiSafeJson(sink));
26737
26946
  return lines.join(`
@@ -28182,6 +28391,22 @@ function warnDeprecatedTenantOption(tenant) {
28182
28391
  return;
28183
28392
  warnDeprecatedOptionAlias("--tenant", TENANT_SWITCH_COMMAND);
28184
28393
  }
28394
+ // ../../common/src/polling/types.ts
28395
+ var PollOutcome = {
28396
+ Completed: "completed",
28397
+ Timeout: "timeout",
28398
+ Interrupted: "interrupted",
28399
+ Aborted: "aborted",
28400
+ Failed: "failed"
28401
+ };
28402
+
28403
+ // ../../common/src/polling/poll-failure-mapping.ts
28404
+ var REASON_BY_OUTCOME = {
28405
+ [PollOutcome.Timeout]: "poll_timeout",
28406
+ [PollOutcome.Failed]: "poll_failed",
28407
+ [PollOutcome.Interrupted]: "poll_failed",
28408
+ [PollOutcome.Aborted]: "poll_aborted"
28409
+ };
28185
28410
  // ../../common/src/polling/terminal-statuses.ts
28186
28411
  var TERMINAL_STATUSES = new Set([
28187
28412
  "completed",
@@ -28209,6 +28434,105 @@ var ScreenLogger;
28209
28434
  }
28210
28435
  ScreenLogger.progress = progress;
28211
28436
  })(ScreenLogger ||= {});
28437
+ // ../../common/src/sdk-user-agent.ts
28438
+ var USER_AGENT_HEADER = "User-Agent";
28439
+ var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
28440
+ function userAgentPatchKey(userAgent) {
28441
+ return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
28442
+ }
28443
+ function splitUserAgentTokens(value) {
28444
+ return value?.trim().split(/\s+/).filter(Boolean) ?? [];
28445
+ }
28446
+ function appendUserAgentToken(value, userAgent) {
28447
+ const tokens = splitUserAgentTokens(value);
28448
+ const seen = new Set(tokens);
28449
+ for (const token of splitUserAgentTokens(userAgent)) {
28450
+ if (!seen.has(token)) {
28451
+ tokens.push(token);
28452
+ seen.add(token);
28453
+ }
28454
+ }
28455
+ return tokens.join(" ");
28456
+ }
28457
+ function getEffectiveUserAgent(userAgent) {
28458
+ return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
28459
+ }
28460
+ function isHeadersLike(headers) {
28461
+ return typeof headers === "object" && headers !== null && "get" in headers && typeof headers.get === "function" && "set" in headers && typeof headers.set === "function";
28462
+ }
28463
+ function getSdkUserAgentToken(pkg) {
28464
+ const packageName = pkg.name.replace(/^@uipath\//, "");
28465
+ return getEffectiveUserAgent(`${packageName}/${pkg.version}`);
28466
+ }
28467
+ function addSdkUserAgentHeader(headers, userAgent) {
28468
+ const result = { ...headers ?? {} };
28469
+ const effectiveUserAgent = getEffectiveUserAgent(userAgent);
28470
+ const headerName = Object.keys(result).find((key) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
28471
+ if (headerName) {
28472
+ result[headerName] = appendUserAgentToken(result[headerName], effectiveUserAgent);
28473
+ } else {
28474
+ result[USER_AGENT_HEADER] = effectiveUserAgent;
28475
+ }
28476
+ return result;
28477
+ }
28478
+ function withSdkUserAgentHeader(headers, userAgent) {
28479
+ const effectiveUserAgent = getEffectiveUserAgent(userAgent);
28480
+ if (isHeadersLike(headers)) {
28481
+ headers.set(USER_AGENT_HEADER, appendUserAgentToken(headers.get(USER_AGENT_HEADER), effectiveUserAgent));
28482
+ return headers;
28483
+ }
28484
+ if (Array.isArray(headers)) {
28485
+ const result = headers.map((entry) => {
28486
+ const [key, value] = entry;
28487
+ return [key, value];
28488
+ });
28489
+ const headerIndex = result.findIndex(([key]) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
28490
+ if (headerIndex >= 0) {
28491
+ const [key, value] = result[headerIndex];
28492
+ result[headerIndex] = [
28493
+ key,
28494
+ appendUserAgentToken(value, effectiveUserAgent)
28495
+ ];
28496
+ } else {
28497
+ result.push([USER_AGENT_HEADER, effectiveUserAgent]);
28498
+ }
28499
+ return result;
28500
+ }
28501
+ return addSdkUserAgentHeader(typeof headers === "object" && headers !== null ? { ...headers } : {}, effectiveUserAgent);
28502
+ }
28503
+ function withUserAgentInitOverride(initOverrides, userAgent) {
28504
+ return async (requestContext) => {
28505
+ const initWithUserAgent = {
28506
+ ...requestContext.init,
28507
+ headers: withSdkUserAgentHeader(requestContext.init.headers, userAgent)
28508
+ };
28509
+ const override = typeof initOverrides === "function" ? await initOverrides({
28510
+ ...requestContext,
28511
+ init: initWithUserAgent
28512
+ }) : initOverrides;
28513
+ return {
28514
+ ...override ?? {},
28515
+ headers: withSdkUserAgentHeader(override?.headers ?? initWithUserAgent.headers, userAgent)
28516
+ };
28517
+ };
28518
+ }
28519
+ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
28520
+ const prototype = BaseApiClass.prototype;
28521
+ const patchKey = userAgentPatchKey(userAgent);
28522
+ if (prototype[patchKey]) {
28523
+ return;
28524
+ }
28525
+ if (typeof prototype.request !== "function") {
28526
+ throw new Error("Generated BaseAPI request function not found.");
28527
+ }
28528
+ const originalRequest = prototype.request;
28529
+ prototype.request = function requestWithUserAgent(context, initOverrides) {
28530
+ return originalRequest.call(this, context, withUserAgentInitOverride(initOverrides, userAgent));
28531
+ };
28532
+ Object.defineProperty(prototype, patchKey, {
28533
+ value: true
28534
+ });
28535
+ }
28212
28536
  // ../../common/src/tool-provider.ts
28213
28537
  var factorySlot = singleton("PackagerFactoryProvider");
28214
28538
  // ../../common/src/telemetry/pii-redactor.ts
@@ -28391,13 +28715,17 @@ Command.prototype.trackedAction = function(context, fn, properties) {
28391
28715
  const [error] = await catchError(fn(...args));
28392
28716
  if (error) {
28393
28717
  errorMessage = error instanceof Error ? error.message : String(error);
28394
- logger.error(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
28718
+ logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
28719
+ const typed = error;
28720
+ const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
28721
+ const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
28722
+ const finalResult = customResult ?? RESULTS.Failure;
28395
28723
  OutputFormatter.error({
28396
- Result: RESULTS.Failure,
28724
+ Result: finalResult,
28397
28725
  Message: errorMessage,
28398
- Instructions: "An unexpected error occurred. Run with --log-level debug for details."
28726
+ Instructions: customInstructions ?? "An unexpected error occurred. Run with --log-level debug for details."
28399
28727
  });
28400
- context.exit(1);
28728
+ context.exit(EXIT_CODES[finalResult]);
28401
28729
  }
28402
28730
  const durationMs = performance.now() - startTime;
28403
28731
  const success = !error && (process.exitCode === undefined || process.exitCode === 0);
@@ -28659,6 +28987,56 @@ class VoidApiResponse {
28659
28987
  return;
28660
28988
  }
28661
28989
  }
28990
+ // ../resourcecatalog-sdk/package.json
28991
+ var package_default2 = {
28992
+ name: "@uipath/resourcecatalog-sdk",
28993
+ license: "MIT",
28994
+ version: "1.195.0",
28995
+ description: "SDK for the UiPath Resource Catalog Service API.",
28996
+ repository: {
28997
+ type: "git",
28998
+ url: "https://github.com/UiPath/cli.git",
28999
+ directory: "packages/admin/resourcecatalog-sdk"
29000
+ },
29001
+ publishConfig: {
29002
+ registry: "https://npm.pkg.github.com/@uipath"
29003
+ },
29004
+ keywords: [
29005
+ "uipath",
29006
+ "resource-catalog",
29007
+ "sdk"
29008
+ ],
29009
+ type: "module",
29010
+ main: "./dist/index.js",
29011
+ types: "./dist/src/index.d.ts",
29012
+ exports: {
29013
+ ".": {
29014
+ types: "./dist/src/index.d.ts",
29015
+ default: "./dist/index.js"
29016
+ }
29017
+ },
29018
+ files: [
29019
+ "dist"
29020
+ ],
29021
+ private: true,
29022
+ scripts: {
29023
+ build: "bun build ./src/index.ts --outdir dist --format esm --target node && tsc -p tsconfig.build.json --noCheck",
29024
+ generate: "bun run src/scripts/generate-sdk.ts",
29025
+ lint: "biome check ."
29026
+ },
29027
+ devDependencies: {
29028
+ "@openapitools/openapi-generator-cli": "^2.31.1",
29029
+ "@types/node": "^25.5.2",
29030
+ "@uipath/auth": "workspace:*",
29031
+ "@uipath/common": "workspace:*",
29032
+ "@uipath/filesystem": "workspace:*",
29033
+ typescript: "^6.0.2"
29034
+ }
29035
+ };
29036
+
29037
+ // ../resourcecatalog-sdk/src/user-agent.ts
29038
+ var SDK_USER_AGENT = getSdkUserAgentToken(package_default2);
29039
+ installSdkUserAgentHeader(BaseAPI, SDK_USER_AGENT);
28662
29040
 
28663
29041
  // ../resourcecatalog-sdk/generated/src/models/EntitySearchState.ts
28664
29042
  function EntitySearchStateFromJSON(json2) {
@@ -30024,32 +30402,7 @@ class InvalidBaseUrlError extends Error {
30024
30402
  this.name = "InvalidBaseUrlError";
30025
30403
  }
30026
30404
  }
30027
- var DEFAULT_SCOPES = [
30028
- "offline_access",
30029
- "ProcessMining",
30030
- "OrchestratorApiUserAccess",
30031
- "StudioWebBackend",
30032
- "IdentityServerApi",
30033
- "ConnectionService",
30034
- "DataService",
30035
- "DataServiceApiUserAccess",
30036
- "DocumentUnderstanding",
30037
- "EnterpriseContextService",
30038
- "Directory",
30039
- "JamJamApi",
30040
- "LLMGateway",
30041
- "LLMOps",
30042
- "OMS",
30043
- "RCS.FolderAuthorization",
30044
- "RCS.TagsManagement",
30045
- "TestmanagerApiUserAccess",
30046
- "AutomationSolutions",
30047
- "StudioWebTypeCacheService",
30048
- "Docs.GPT.Search",
30049
- "Insights",
30050
- "ReferenceToken",
30051
- "Audit.Read"
30052
- ];
30405
+ var DEFAULT_SCOPES = ["openid", "profile", "offline_access"];
30053
30406
  var normalizeAndValidateBaseUrl = (rawUrl) => {
30054
30407
  let baseUrl = rawUrl;
30055
30408
  if (baseUrl.endsWith("/identity_/")) {
@@ -30099,7 +30452,8 @@ var resolveConfigAsync = async ({
30099
30452
  if (!clientSecret && fileAuth.clientSecret) {
30100
30453
  clientSecret = fileAuth.clientSecret;
30101
30454
  }
30102
- const scopes = customScopes && customScopes.length > 0 ? customScopes : fileAuth.scopes && fileAuth.scopes.length > 0 ? fileAuth.scopes : DEFAULT_SCOPES;
30455
+ const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && Boolean(clientSecret);
30456
+ const scopes = customScopes && customScopes.length > 0 ? customScopes : fileAuth.scopes && fileAuth.scopes.length > 0 ? fileAuth.scopes : isExternalAppAuth ? [] : DEFAULT_SCOPES;
30103
30457
  return {
30104
30458
  clientId,
30105
30459
  clientSecret,
@@ -30599,6 +30953,129 @@ function normalizeTokenRefreshFailure() {
30599
30953
  function normalizeTokenRefreshUnavailableFailure() {
30600
30954
  return "token refresh failed before authentication completed";
30601
30955
  }
30956
+ function errorMessage(error) {
30957
+ return error instanceof Error ? error.message : String(error);
30958
+ }
30959
+ function computeExpirationThreshold(ensureTokenValidityMinutes) {
30960
+ return new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
30961
+ }
30962
+ async function runRefreshLocked(inputs) {
30963
+ const {
30964
+ absolutePath,
30965
+ refreshToken: callerRefreshToken,
30966
+ customAuthority,
30967
+ ensureTokenValidityMinutes,
30968
+ loadEnvFile,
30969
+ saveEnvFile,
30970
+ refreshFn,
30971
+ resolveConfig
30972
+ } = inputs;
30973
+ const expirationThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
30974
+ let fresh;
30975
+ try {
30976
+ fresh = await loadEnvFile({ envPath: absolutePath });
30977
+ } catch (error) {
30978
+ return {
30979
+ kind: "fail",
30980
+ status: {
30981
+ loginStatus: "Refresh Failed",
30982
+ hint: "Could not read the auth file while refreshing. Retry, or run 'uip login' to re-authenticate.",
30983
+ tokenRefresh: {
30984
+ attempted: false,
30985
+ success: false,
30986
+ errorMessage: `auth file read failed: ${errorMessage(error)}`
30987
+ }
30988
+ }
30989
+ };
30990
+ }
30991
+ const freshAccess = fresh.UIPATH_ACCESS_TOKEN;
30992
+ const freshExp = freshAccess ? getTokenExpiration(freshAccess) : undefined;
30993
+ if (freshAccess && freshExp && freshExp > expirationThreshold) {
30994
+ return {
30995
+ kind: "ok",
30996
+ accessToken: freshAccess,
30997
+ refreshToken: fresh.UIPATH_REFRESH_TOKEN ?? callerRefreshToken,
30998
+ expiration: freshExp,
30999
+ tokenRefresh: { attempted: false, success: true }
31000
+ };
31001
+ }
31002
+ const tokenForIdP = fresh.UIPATH_REFRESH_TOKEN ?? callerRefreshToken;
31003
+ let refreshedAccess;
31004
+ let refreshedRefresh;
31005
+ try {
31006
+ const config = await resolveConfig({ customAuthority });
31007
+ const refreshed = await refreshFn({
31008
+ refreshToken: tokenForIdP,
31009
+ tokenEndpoint: config.tokenEndpoint,
31010
+ clientId: config.clientId,
31011
+ expectedAuthority: customAuthority
31012
+ });
31013
+ refreshedAccess = refreshed.accessToken;
31014
+ refreshedRefresh = refreshed.refreshToken;
31015
+ } catch (error) {
31016
+ const isOAuthFailure = isTokenRefreshOAuthFailure(error);
31017
+ const hint = isOAuthFailure ? "Run 'uip login' to re-authenticate — the stored refresh token is invalid or expired." : "Token refresh failed. Check your network connection, then retry or run 'uip login' to re-authenticate.";
31018
+ const message = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
31019
+ return {
31020
+ kind: "fail",
31021
+ status: {
31022
+ loginStatus: "Refresh Failed",
31023
+ hint,
31024
+ tokenRefresh: {
31025
+ attempted: true,
31026
+ success: false,
31027
+ errorMessage: message
31028
+ }
31029
+ }
31030
+ };
31031
+ }
31032
+ const refreshedExp = getTokenExpiration(refreshedAccess);
31033
+ if (!refreshedExp || refreshedExp <= new Date) {
31034
+ return {
31035
+ kind: "fail",
31036
+ status: {
31037
+ loginStatus: "Refresh Failed",
31038
+ hint: "The identity server returned an unusable token. Run 'uip login' to re-authenticate.",
31039
+ tokenRefresh: {
31040
+ attempted: true,
31041
+ success: false,
31042
+ errorMessage: "refreshed token has no valid expiration claim"
31043
+ }
31044
+ }
31045
+ };
31046
+ }
31047
+ try {
31048
+ await saveEnvFile({
31049
+ envPath: absolutePath,
31050
+ data: {
31051
+ UIPATH_ACCESS_TOKEN: refreshedAccess,
31052
+ UIPATH_REFRESH_TOKEN: refreshedRefresh
31053
+ },
31054
+ merge: true
31055
+ });
31056
+ return {
31057
+ kind: "ok",
31058
+ accessToken: refreshedAccess,
31059
+ refreshToken: refreshedRefresh,
31060
+ expiration: refreshedExp,
31061
+ tokenRefresh: { attempted: true, success: true }
31062
+ };
31063
+ } catch (error) {
31064
+ const msg = errorMessage(error);
31065
+ return {
31066
+ kind: "ok",
31067
+ accessToken: refreshedAccess,
31068
+ refreshToken: refreshedRefresh,
31069
+ expiration: refreshedExp,
31070
+ persistenceWarning: `Access token refreshed in memory but could not be written to ${absolutePath}: ${msg}. The next CLI invocation will fail until the file can be updated — run 'uip login' to re-authenticate.`,
31071
+ tokenRefresh: {
31072
+ attempted: true,
31073
+ success: true,
31074
+ errorMessage: `persistence failed: ${msg}`
31075
+ }
31076
+ };
31077
+ }
31078
+ }
30602
31079
  var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
30603
31080
  const {
30604
31081
  resolveEnvFilePath = resolveEnvFilePathAsync,
@@ -30673,73 +31150,103 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
30673
31150
  let refreshToken = credentials.UIPATH_REFRESH_TOKEN;
30674
31151
  let expiration = getTokenExpiration(accessToken);
30675
31152
  let persistenceWarning;
31153
+ let lockReleaseFailed = false;
30676
31154
  let tokenRefresh;
30677
- const expirationThreshold = new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
30678
- if (expiration && expiration <= expirationThreshold && refreshToken) {
30679
- let refreshedAccess;
30680
- let refreshedRefresh;
31155
+ const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
31156
+ const tryGlobalCredsHint = async () => {
31157
+ const fs7 = getFs();
31158
+ const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
31159
+ if (absolutePath === globalPath)
31160
+ return;
31161
+ if (!await fs7.exists(globalPath))
31162
+ return;
30681
31163
  try {
30682
- const config = await resolveConfig({
30683
- customAuthority: credentials.UIPATH_URL
30684
- });
30685
- const refreshed = await refreshTokenFn({
30686
- refreshToken,
30687
- tokenEndpoint: config.tokenEndpoint,
30688
- clientId: config.clientId,
30689
- expectedAuthority: credentials.UIPATH_URL
30690
- });
30691
- refreshedAccess = refreshed.accessToken;
30692
- refreshedRefresh = refreshed.refreshToken;
31164
+ const globalCreds = await loadEnvFile({ envPath: globalPath });
31165
+ if (!globalCreds.UIPATH_ACCESS_TOKEN)
31166
+ return;
31167
+ const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
31168
+ if (globalExp && globalExp <= new Date)
31169
+ return;
31170
+ return `Local credentials file at ${absolutePath} has expired credentials. Valid credentials exist in ${globalPath}. Remove the local file or run 'uip login' to re-authenticate.`;
31171
+ } catch {
31172
+ return;
31173
+ }
31174
+ };
31175
+ if (expiration && expiration <= outerThreshold && refreshToken) {
31176
+ let release;
31177
+ try {
31178
+ release = await getFs().acquireLock(absolutePath);
30693
31179
  } catch (error) {
30694
- const isOAuthFailure = isTokenRefreshOAuthFailure(error);
30695
- const hint = isOAuthFailure ? "Run 'uip login' to re-authenticate — the stored refresh token is invalid or expired." : "Token refresh failed. Check your network connection, then retry or run 'uip login' to re-authenticate.";
30696
- const errorMessage = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
31180
+ const msg = errorMessage(error);
31181
+ const globalHint = await tryGlobalCredsHint();
31182
+ if (globalHint) {
31183
+ return {
31184
+ loginStatus: "Expired",
31185
+ accessToken,
31186
+ refreshToken,
31187
+ baseUrl: credentials.UIPATH_URL,
31188
+ organizationName: credentials.UIPATH_ORGANIZATION_NAME,
31189
+ organizationId: credentials.UIPATH_ORGANIZATION_ID,
31190
+ tenantName: credentials.UIPATH_TENANT_NAME,
31191
+ tenantId: credentials.UIPATH_TENANT_ID,
31192
+ expiration,
31193
+ source: "file" /* File */,
31194
+ hint: globalHint,
31195
+ tokenRefresh: {
31196
+ attempted: false,
31197
+ success: false,
31198
+ errorMessage: `lock acquisition failed: ${msg}`
31199
+ }
31200
+ };
31201
+ }
30697
31202
  return {
30698
31203
  loginStatus: "Refresh Failed",
30699
- hint,
31204
+ hint: "Could not acquire the auth-file lock — too many concurrent `uip` processes, or a permission issue on the auth directory. Retry, or run 'uip login' to re-authenticate.",
30700
31205
  tokenRefresh: {
30701
- attempted: true,
31206
+ attempted: false,
30702
31207
  success: false,
30703
- errorMessage
31208
+ errorMessage: `lock acquisition failed: ${msg}`
30704
31209
  }
30705
31210
  };
30706
31211
  }
30707
- const refreshedExp = getTokenExpiration(refreshedAccess);
30708
- if (!refreshedExp || refreshedExp <= new Date) {
30709
- return {
30710
- loginStatus: "Refresh Failed",
30711
- hint: "The identity server returned an unusable token. Run 'uip login' to re-authenticate.",
30712
- tokenRefresh: {
30713
- attempted: true,
30714
- success: false,
30715
- errorMessage: "refreshed token has no valid expiration claim"
30716
- }
30717
- };
30718
- }
30719
- accessToken = refreshedAccess;
30720
- refreshToken = refreshedRefresh;
30721
- expiration = refreshedExp;
31212
+ let lockedFailure;
30722
31213
  try {
30723
- await saveEnvFile({
30724
- envPath: absolutePath,
30725
- data: {
30726
- UIPATH_ACCESS_TOKEN: accessToken,
30727
- UIPATH_REFRESH_TOKEN: refreshToken
30728
- },
30729
- merge: true
31214
+ const outcome = await runRefreshLocked({
31215
+ absolutePath,
31216
+ refreshToken,
31217
+ customAuthority: credentials.UIPATH_URL,
31218
+ ensureTokenValidityMinutes,
31219
+ loadEnvFile,
31220
+ saveEnvFile,
31221
+ refreshFn: refreshTokenFn,
31222
+ resolveConfig
30730
31223
  });
30731
- tokenRefresh = {
30732
- attempted: true,
30733
- success: true
30734
- };
30735
- } catch (error) {
30736
- const msg = error instanceof Error ? error.message : String(error);
30737
- persistenceWarning = `Access token refreshed in memory but could not be written to ${absolutePath}: ${msg}. The next CLI invocation will fail until the file can be updated — run 'uip login' to re-authenticate.`;
30738
- tokenRefresh = {
30739
- attempted: true,
30740
- success: true,
30741
- errorMessage: `persistence failed: ${msg}`
30742
- };
31224
+ if (outcome.kind === "fail") {
31225
+ lockedFailure = outcome.status;
31226
+ } else {
31227
+ accessToken = outcome.accessToken;
31228
+ refreshToken = outcome.refreshToken;
31229
+ expiration = outcome.expiration;
31230
+ tokenRefresh = outcome.tokenRefresh;
31231
+ if (outcome.persistenceWarning) {
31232
+ persistenceWarning = outcome.persistenceWarning;
31233
+ }
31234
+ }
31235
+ } finally {
31236
+ try {
31237
+ await release();
31238
+ } catch {
31239
+ lockReleaseFailed = true;
31240
+ }
31241
+ }
31242
+ if (lockedFailure) {
31243
+ const globalHint = await tryGlobalCredsHint();
31244
+ const base = globalHint ? {
31245
+ ...lockedFailure,
31246
+ loginStatus: "Expired",
31247
+ hint: globalHint
31248
+ } : lockedFailure;
31249
+ return lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base;
30743
31250
  }
30744
31251
  }
30745
31252
  const result = {
@@ -30754,23 +31261,13 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
30754
31261
  expiration,
30755
31262
  source: "file" /* File */,
30756
31263
  ...persistenceWarning ? { hint: persistenceWarning, persistenceFailed: true } : {},
31264
+ ...lockReleaseFailed ? { lockReleaseFailed: true } : {},
30757
31265
  ...tokenRefresh ? { tokenRefresh } : {}
30758
31266
  };
30759
31267
  if (result.loginStatus === "Expired") {
30760
- const fs7 = getFs();
30761
- const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
30762
- if (absolutePath !== globalPath && await fs7.exists(globalPath)) {
30763
- try {
30764
- const globalCreds = await loadEnvFile({
30765
- envPath: globalPath
30766
- });
30767
- if (globalCreds.UIPATH_ACCESS_TOKEN) {
30768
- const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
30769
- if (!globalExp || globalExp > new Date) {
30770
- result.hint = `Local credentials file at ${absolutePath} has expired credentials. Valid credentials exist in ${globalPath}. Remove the local file or run 'uip login' to re-authenticate.`;
30771
- }
30772
- }
30773
- } catch {}
31268
+ const globalHint = await tryGlobalCredsHint();
31269
+ if (globalHint) {
31270
+ result.hint = globalHint;
30774
31271
  }
30775
31272
  }
30776
31273
  return result;
@@ -30787,6 +31284,10 @@ var getLoginStatusAsync = async (options = {}) => {
30787
31284
  init_src();
30788
31285
  // ../../auth/src/logout.ts
30789
31286
  init_src();
31287
+
31288
+ // ../../auth/src/index.ts
31289
+ init_server();
31290
+
30790
31291
  // ../resourcecatalog-sdk/src/client-factory.ts
30791
31292
  async function resolveConfig(options) {
30792
31293
  const status = await getLoginStatusAsync({
@@ -30807,7 +31308,8 @@ async function resolveConfig(options) {
30807
31308
  return {
30808
31309
  config: new Configuration({
30809
31310
  basePath,
30810
- accessToken: async () => bearerToken
31311
+ accessToken: async () => bearerToken,
31312
+ headers: addSdkUserAgentHeader(undefined, SDK_USER_AGENT)
30811
31313
  }),
30812
31314
  organizationId: status.organizationId,
30813
31315
  tenantName: tenant