@uipath/resourcecatalog-tool 0.1.0 → 1.2.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 +1591 -236
  2. package/dist/tool.js +1594 -236
  3. package/package.json +28 -42
package/dist/tool.js CHANGED
@@ -383,11 +383,11 @@ import path from "node:path";
383
383
  import { fileURLToPath } from "node:url";
384
384
  import childProcess3 from "node:child_process";
385
385
  import fs5, { constants as fsConstants2 } from "node:fs/promises";
386
- function detectArchBinary(binary2) {
387
- if (typeof binary2 === "string" || Array.isArray(binary2)) {
388
- return binary2;
386
+ function detectArchBinary(binary) {
387
+ if (typeof binary === "string" || Array.isArray(binary)) {
388
+ return binary;
389
389
  }
390
- const { [arch]: archBinary } = binary2;
390
+ const { [arch]: archBinary } = binary;
391
391
  if (!archBinary) {
392
392
  throw new Error(`${arch} is not supported`);
393
393
  }
@@ -667,6 +667,7 @@ var init_open = __esm(() => {
667
667
  });
668
668
 
669
669
  // ../../filesystem/src/node.ts
670
+ import { randomUUID } from "node:crypto";
670
671
  import { existsSync } from "node:fs";
671
672
  import * as fs6 from "node:fs/promises";
672
673
  import * as os2 from "node:os";
@@ -748,6 +749,90 @@ class NodeFileSystem {
748
749
  async mkdir(dirPath) {
749
750
  await fs6.mkdir(dirPath, { recursive: true });
750
751
  }
752
+ async acquireLock(lockPath) {
753
+ const canonicalPath = await this.canonicalizeLockTarget(lockPath);
754
+ const lockFile = `${canonicalPath}.lock`;
755
+ const ownerId = randomUUID();
756
+ const start = Date.now();
757
+ while (true) {
758
+ try {
759
+ await fs6.writeFile(lockFile, ownerId, { flag: "wx" });
760
+ return this.createLockRelease(lockFile, ownerId);
761
+ } catch (error) {
762
+ if (!this.hasErrnoCode(error, "EEXIST")) {
763
+ throw error;
764
+ }
765
+ const stats = await fs6.stat(lockFile).catch(() => null);
766
+ if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
767
+ const reclaimed = await fs6.rm(lockFile, { force: true }).then(() => true).catch(() => false);
768
+ if (reclaimed)
769
+ continue;
770
+ }
771
+ if (Date.now() - start > LOCK_MAX_WAIT_MS) {
772
+ throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
773
+ }
774
+ await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
775
+ }
776
+ }
777
+ }
778
+ async canonicalizeLockTarget(lockPath) {
779
+ const absolute = path2.resolve(lockPath);
780
+ const fullReal = await fs6.realpath(absolute).catch(() => null);
781
+ if (fullReal)
782
+ return fullReal;
783
+ const parent = path2.dirname(absolute);
784
+ const base = path2.basename(absolute);
785
+ const canonicalParent = await fs6.realpath(parent).catch(() => parent);
786
+ return path2.join(canonicalParent, base);
787
+ }
788
+ createLockRelease(lockFile, ownerId) {
789
+ const heartbeatStart = Date.now();
790
+ let heartbeatTimer;
791
+ let stopped = false;
792
+ const stopHeartbeat = () => {
793
+ stopped = true;
794
+ if (heartbeatTimer)
795
+ clearTimeout(heartbeatTimer);
796
+ };
797
+ const scheduleNextHeartbeat = () => {
798
+ if (stopped)
799
+ return;
800
+ if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) {
801
+ stopped = true;
802
+ return;
803
+ }
804
+ heartbeatTimer = setTimeout(() => {
805
+ runHeartbeat();
806
+ }, LOCK_HEARTBEAT_MS);
807
+ heartbeatTimer.unref?.();
808
+ };
809
+ const runHeartbeat = async () => {
810
+ if (stopped)
811
+ return;
812
+ const current = await fs6.readFile(lockFile, "utf-8").catch(() => null);
813
+ if (stopped)
814
+ return;
815
+ if (current !== ownerId) {
816
+ stopped = true;
817
+ return;
818
+ }
819
+ const now = Date.now() / 1000;
820
+ await fs6.utimes(lockFile, now, now).catch(() => {});
821
+ scheduleNextHeartbeat();
822
+ };
823
+ scheduleNextHeartbeat();
824
+ let released = false;
825
+ return async () => {
826
+ if (released)
827
+ return;
828
+ released = true;
829
+ stopHeartbeat();
830
+ const current = await fs6.readFile(lockFile, "utf-8").catch(() => null);
831
+ if (current === ownerId) {
832
+ await fs6.rm(lockFile, { force: true });
833
+ }
834
+ };
835
+ }
751
836
  async rm(filePath) {
752
837
  await fs6.rm(filePath, { recursive: true, force: true });
753
838
  }
@@ -793,16 +878,18 @@ class NodeFileSystem {
793
878
  }
794
879
  }
795
880
  isEnoent(error) {
796
- return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
881
+ return this.hasErrnoCode(error, "ENOENT");
882
+ }
883
+ hasErrnoCode(error, code) {
884
+ return typeof error === "object" && error !== null && "code" in error && error.code === code;
797
885
  }
798
886
  }
887
+ 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;
799
888
  var init_node = __esm(() => {
800
889
  init_open();
801
890
  });
802
891
  // ../../filesystem/src/index.ts
803
- var fsInstance, getFileSystem = () => {
804
- return fsInstance;
805
- };
892
+ var fsInstance, getFileSystem = () => fsInstance;
806
893
  var init_src = __esm(() => {
807
894
  init_node();
808
895
  init_node();
@@ -19042,10 +19129,15 @@ var require_dist = __commonJS((exports) => {
19042
19129
  exports.RobotProxyConstructor = RobotProxyConstructor;
19043
19130
  __exportStar(require_agent(), exports);
19044
19131
  });
19132
+ // ../../auth/src/server.ts
19133
+ var init_server = __esm(() => {
19134
+ init_constants();
19135
+ });
19045
19136
  // package.json
19046
19137
  var package_default = {
19047
19138
  name: "@uipath/resourcecatalog-tool",
19048
- version: "0.1.0",
19139
+ license: "MIT",
19140
+ version: "1.2.0",
19049
19141
  description: "CLI plugin for the UiPath Resource Catalog Service.",
19050
19142
  private: false,
19051
19143
  repository: {
@@ -19087,6 +19179,9 @@ var package_default = {
19087
19179
  }
19088
19180
  };
19089
19181
 
19182
+ // ../../common/src/attachment-binding.ts
19183
+ init_src();
19184
+
19090
19185
  // ../../common/src/catch-error.ts
19091
19186
  function isPromiseLike(value) {
19092
19187
  return value !== null && typeof value === "object" && typeof value.then === "function";
@@ -19114,79 +19209,7 @@ function settlePromiseLike(thenable) {
19114
19209
  undefined
19115
19210
  ]);
19116
19211
  }
19117
- // ../../common/src/command-examples.ts
19118
- import { Command } from "commander";
19119
- var examplesByCommand = new WeakMap;
19120
- Command.prototype.examples = function(examples) {
19121
- examplesByCommand.set(this, examples);
19122
- return this;
19123
- };
19124
- // ../../common/src/singleton.ts
19125
- var PREFIX = "@uipath/common/";
19126
- var _g = globalThis;
19127
- function singleton(ctorOrName) {
19128
- const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name;
19129
- const key = Symbol.for(PREFIX + name);
19130
- return {
19131
- get(fallback) {
19132
- return _g[key] ?? fallback;
19133
- },
19134
- set(value) {
19135
- _g[key] = value;
19136
- },
19137
- clear() {
19138
- delete _g[key];
19139
- },
19140
- getOrInit(factory, guard) {
19141
- const existing = _g[key];
19142
- if (existing != null && typeof existing === "object") {
19143
- if (!guard || guard(existing)) {
19144
- return existing;
19145
- }
19146
- }
19147
- const instance = factory();
19148
- _g[key] = instance;
19149
- return instance;
19150
- }
19151
- };
19152
- }
19153
19212
 
19154
- // ../../common/src/output-context.ts
19155
- function createStorage() {
19156
- const [error, mod] = catchError(() => __require("node:async_hooks"));
19157
- if (error || typeof mod?.AsyncLocalStorage !== "function") {
19158
- return {
19159
- getStore: () => {
19160
- return;
19161
- },
19162
- run: (_store, fn) => fn()
19163
- };
19164
- }
19165
- return new mod.AsyncLocalStorage;
19166
- }
19167
- var storageSingleton = singleton("OutputStorage");
19168
- var sinkSlot = singleton("OutputSink");
19169
- var outputStorage = storageSingleton.getOrInit(createStorage, (v) => ("getStore" in v));
19170
- var CONSOLE_FALLBACK = {
19171
- writeOut: (str) => process.stdout.write(str),
19172
- writeErr: (str) => process.stderr.write(str),
19173
- writeLog: (str) => process.stdout.write(str),
19174
- capabilities: {
19175
- isInteractive: false,
19176
- supportsColor: false,
19177
- outputWidth: 80
19178
- }
19179
- };
19180
- function getOutputSink() {
19181
- return outputStorage.getStore() ?? sinkSlot.get() ?? CONSOLE_FALLBACK;
19182
- }
19183
- // ../../common/src/completer.ts
19184
- var COMPLETER_SYMBOL = Symbol.for("@uipath/common/completer");
19185
- // ../../common/src/console-guard.ts
19186
- var guardInstalledSlot = singleton("ConsoleGuardInstalled");
19187
- var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
19188
- // ../../common/src/constants.ts
19189
- var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
19190
19213
  // ../../common/src/error-handler.ts
19191
19214
  var DEFAULT_401 = "Unauthorized (401). Run `uip login` to authenticate.";
19192
19215
  var DEFAULT_403 = "Forbidden (403). Ensure the account has the required permissions.";
@@ -19293,10 +19316,15 @@ async function extractErrorDetails(error, options) {
19293
19316
  }
19294
19317
  if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
19295
19318
  context.errorCode = parsedBody.errorCode;
19319
+ } else if (parsedBody?.code && typeof parsedBody.code === "string") {
19320
+ context.errorCode = parsedBody.code;
19296
19321
  }
19297
19322
  if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
19298
19323
  context.requestId = parsedBody.requestId;
19299
19324
  }
19325
+ if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
19326
+ context.traceId = parsedBody.traceId;
19327
+ }
19300
19328
  if (status === 429) {
19301
19329
  const resp = response;
19302
19330
  const headersObj = resp?.headers;
@@ -19316,12 +19344,114 @@ async function extractErrorDetails(error, options) {
19316
19344
  }
19317
19345
  }
19318
19346
  const hasContext = Object.keys(context).length > 0;
19319
- return { result, message, details, ...hasContext ? { context } : {} };
19347
+ let parsedErrors;
19348
+ if (parsedBody?.errors && typeof parsedBody.errors === "object") {
19349
+ const errors = {};
19350
+ for (const [field, raw] of Object.entries(parsedBody.errors)) {
19351
+ if (Array.isArray(raw)) {
19352
+ const messages = raw.map((entry) => {
19353
+ if (typeof entry === "string")
19354
+ return entry;
19355
+ if (entry && typeof entry === "object" && typeof entry.message === "string") {
19356
+ return entry.message;
19357
+ }
19358
+ return String(entry);
19359
+ }).filter(Boolean);
19360
+ if (messages.length > 0)
19361
+ errors[field] = messages;
19362
+ } else if (typeof raw === "string") {
19363
+ errors[field] = [raw];
19364
+ }
19365
+ }
19366
+ if (Object.keys(errors).length > 0)
19367
+ parsedErrors = errors;
19368
+ }
19369
+ return {
19370
+ result,
19371
+ message,
19372
+ details,
19373
+ ...hasContext ? { context } : {},
19374
+ ...parsedErrors ? { parsedErrors } : {}
19375
+ };
19320
19376
  }
19321
19377
  async function extractErrorMessage(error, options) {
19322
19378
  const { message } = await extractErrorDetails(error, options);
19323
19379
  return message;
19324
19380
  }
19381
+ // ../../common/src/command-examples.ts
19382
+ import { Command } from "commander";
19383
+ var examplesByCommand = new WeakMap;
19384
+ Command.prototype.examples = function(examples) {
19385
+ examplesByCommand.set(this, examples);
19386
+ return this;
19387
+ };
19388
+ // ../../common/src/singleton.ts
19389
+ var PREFIX = "@uipath/common/";
19390
+ var _g = globalThis;
19391
+ function singleton(ctorOrName) {
19392
+ const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name;
19393
+ const key = Symbol.for(PREFIX + name);
19394
+ return {
19395
+ get(fallback) {
19396
+ return _g[key] ?? fallback;
19397
+ },
19398
+ set(value) {
19399
+ _g[key] = value;
19400
+ },
19401
+ clear() {
19402
+ delete _g[key];
19403
+ },
19404
+ getOrInit(factory, guard) {
19405
+ const existing = _g[key];
19406
+ if (existing != null && typeof existing === "object") {
19407
+ if (!guard || guard(existing)) {
19408
+ return existing;
19409
+ }
19410
+ }
19411
+ const instance = factory();
19412
+ _g[key] = instance;
19413
+ return instance;
19414
+ }
19415
+ };
19416
+ }
19417
+
19418
+ // ../../common/src/output-context.ts
19419
+ function createStorage() {
19420
+ const [error, mod] = catchError(() => __require("node:async_hooks"));
19421
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
19422
+ return {
19423
+ getStore: () => {
19424
+ return;
19425
+ },
19426
+ run: (_store, fn) => fn()
19427
+ };
19428
+ }
19429
+ return new mod.AsyncLocalStorage;
19430
+ }
19431
+ var storageSingleton = singleton("OutputStorage");
19432
+ var sinkSlot = singleton("OutputSink");
19433
+ var outputStorage = storageSingleton.getOrInit(createStorage, (v) => ("getStore" in v));
19434
+ var CONSOLE_FALLBACK = {
19435
+ writeOut: (str) => process.stdout.write(str),
19436
+ writeErr: (str) => process.stderr.write(str),
19437
+ writeLog: (str) => process.stdout.write(str),
19438
+ capabilities: {
19439
+ isInteractive: false,
19440
+ supportsColor: false,
19441
+ outputWidth: 80
19442
+ }
19443
+ };
19444
+ function getOutputSink() {
19445
+ return outputStorage.getStore() ?? sinkSlot.get() ?? CONSOLE_FALLBACK;
19446
+ }
19447
+ // ../../common/src/completer.ts
19448
+ var COMPLETER_SYMBOL = Symbol.for("@uipath/common/completer");
19449
+ // ../../common/src/console-guard.ts
19450
+ var guardInstalledSlot = singleton("ConsoleGuardInstalled");
19451
+ var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
19452
+ // ../../common/src/constants.ts
19453
+ var DEFAULT_PAGE_SIZE = 50;
19454
+ var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
19325
19455
  // ../../../node_modules/@jmespath-community/jmespath/dist/index.mjs
19326
19456
  var isObject = (obj) => {
19327
19457
  return obj !== null && Object.prototype.toString.call(obj) === "[object Object]";
@@ -24366,15 +24496,80 @@ class SuccessOutput {
24366
24496
  }
24367
24497
  }
24368
24498
  }
24369
- function printOutput(data, format = "json", logFn) {
24499
+ function escapeNonAscii(jsonText) {
24500
+ return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
24501
+ const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
24502
+ return `\\u${hex}`;
24503
+ });
24504
+ }
24505
+ function needsAsciiSafeJson(sink) {
24506
+ return process.platform === "win32" && !sink.capabilities.isInteractive;
24507
+ }
24508
+ function isPlainRecord(value) {
24509
+ if (value === null || typeof value !== "object")
24510
+ return false;
24511
+ const prototype = Object.getPrototypeOf(value);
24512
+ return prototype === Object.prototype || prototype === null;
24513
+ }
24514
+ function toLowerCamelCaseKey(key) {
24515
+ if (!key)
24516
+ return key;
24517
+ if (/[_\-\s]/.test(key)) {
24518
+ const [firstPart, ...restParts] = key.split(/[_\-\s]+/).filter(Boolean);
24519
+ if (!firstPart)
24520
+ return key;
24521
+ return [
24522
+ toLowerCamelCaseSimpleKey(firstPart),
24523
+ ...restParts.map((part) => {
24524
+ const normalized = toLowerCamelCaseSimpleKey(part);
24525
+ return normalized.charAt(0).toUpperCase() + normalized.slice(1);
24526
+ })
24527
+ ].join("");
24528
+ }
24529
+ return toLowerCamelCaseSimpleKey(key);
24530
+ }
24531
+ function toLowerCamelCaseSimpleKey(key) {
24532
+ if (/^[A-Z0-9]+$/.test(key))
24533
+ return key.toLowerCase();
24534
+ return key.replace(/^[A-Z]+(?=[A-Z][a-z]|\d|$)|^[A-Z]/, (match) => match.toLowerCase());
24535
+ }
24536
+ function toPascalCaseKey(key) {
24537
+ const lowerCamelKey = toLowerCamelCaseKey(key);
24538
+ return lowerCamelKey ? lowerCamelKey.charAt(0).toUpperCase() + lowerCamelKey.slice(1) : lowerCamelKey;
24539
+ }
24540
+ function toPascalCaseData(value) {
24541
+ if (Array.isArray(value))
24542
+ return value.map(toPascalCaseData);
24543
+ if (!isPlainRecord(value))
24544
+ return value;
24545
+ const result = {};
24546
+ for (const [key, nestedValue] of Object.entries(value)) {
24547
+ result[toPascalCaseKey(key)] = toPascalCaseData(nestedValue);
24548
+ }
24549
+ return result;
24550
+ }
24551
+ function normalizeDataKeys(data) {
24552
+ return toPascalCaseData(data);
24553
+ }
24554
+ function normalizeOutputKeys(data) {
24555
+ const result = {};
24556
+ for (const [key, value] of Object.entries(data)) {
24557
+ const pascalKey = toPascalCaseKey(key);
24558
+ result[pascalKey] = pascalKey === "Data" ? value : toPascalCaseData(value);
24559
+ }
24560
+ return result;
24561
+ }
24562
+ function printOutput(data, format = "json", logFn, asciiSafe = false) {
24370
24563
  if (!data) {
24371
24564
  logFn("Empty response object. No data to display.");
24372
24565
  return;
24373
24566
  }
24374
24567
  switch (format) {
24375
- case "json":
24376
- logFn(JSON.stringify(data, null, 2));
24568
+ case "json": {
24569
+ const json2 = JSON.stringify(data, null, 2);
24570
+ logFn(asciiSafe ? escapeNonAscii(json2) : json2);
24377
24571
  break;
24572
+ }
24378
24573
  case "yaml":
24379
24574
  logFn(toYaml(data));
24380
24575
  break;
@@ -24409,7 +24604,7 @@ function printOutput(data, format = "json", logFn) {
24409
24604
  function logOutput(data, format = "json") {
24410
24605
  const sink = getOutputSink();
24411
24606
  printOutput(data, format, (msg) => sink.writeOut(`${msg}
24412
- `));
24607
+ `), needsAsciiSafeJson(sink));
24413
24608
  }
24414
24609
  function cellToString(val) {
24415
24610
  return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
@@ -24426,7 +24621,7 @@ function wrapText(text, width) {
24426
24621
  function printTable(data, logFn, externalLogValue) {
24427
24622
  if (data.length === 0)
24428
24623
  return;
24429
- const keys = Object.keys(data[0]).filter((key) => key !== "Code" && key !== "Log");
24624
+ const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
24430
24625
  const maxWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
24431
24626
  const header = keys.map((key, i2) => key.padEnd(maxWidths[i2])).join(" | ");
24432
24627
  logFn(header);
@@ -24441,7 +24636,7 @@ function printTable(data, logFn, externalLogValue) {
24441
24636
  }
24442
24637
  }
24443
24638
  function printVerticalTable(data, logFn = console.log, externalLogValue) {
24444
- const keys = Object.keys(data).filter((key) => key !== "Code" && key !== "Log");
24639
+ const keys = Object.keys(data).filter((key) => !["code", "log"].includes(key.toLowerCase()));
24445
24640
  if (keys.length === 0)
24446
24641
  return;
24447
24642
  const maxKeyWidth = Math.max(...keys.map((key) => key.length));
@@ -24457,7 +24652,7 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
24457
24652
  function printResizableTable(data, logFn = console.log, externalLogValue) {
24458
24653
  if (data.length === 0)
24459
24654
  return;
24460
- const keys = Object.keys(data[0]).filter((key) => key !== "Code" && key !== "Log");
24655
+ const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
24461
24656
  if (keys.length === 0)
24462
24657
  return;
24463
24658
  if (!process.stdout.isTTY) {
@@ -24533,8 +24728,26 @@ function printResizableTable(data, logFn = console.log, externalLogValue) {
24533
24728
  function toYaml(data) {
24534
24729
  return dump(data);
24535
24730
  }
24731
+ class FilterEvaluationError extends Error {
24732
+ __brand = "FilterEvaluationError";
24733
+ filter;
24734
+ instructions;
24735
+ result = RESULTS.ValidationError;
24736
+ constructor(filter, cause) {
24737
+ const underlying = cause instanceof Error ? cause.message : String(cause);
24738
+ super(`Filter '${filter}' failed to evaluate: ${underlying}`);
24739
+ this.name = "FilterEvaluationError";
24740
+ this.filter = filter;
24741
+ 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(@)'.";
24742
+ }
24743
+ }
24536
24744
  function applyFilter(data, filter) {
24537
- const result = search(data, filter);
24745
+ let result;
24746
+ try {
24747
+ result = search(data, filter);
24748
+ } catch (err) {
24749
+ throw new FilterEvaluationError(filter, err);
24750
+ }
24538
24751
  if (result == null)
24539
24752
  return [];
24540
24753
  if (Array.isArray(result)) {
@@ -24551,13 +24764,18 @@ function applyFilter(data, filter) {
24551
24764
  }
24552
24765
  var OutputFormatter;
24553
24766
  ((OutputFormatter) => {
24554
- function success(data) {
24767
+ function success(data, options) {
24555
24768
  data.Log ??= getLogFilePath() || undefined;
24769
+ const normalize = !options?.preserveDataKeys;
24770
+ if (normalize) {
24771
+ data.Data = normalizeDataKeys(data.Data);
24772
+ }
24556
24773
  const filter = getOutputFilter();
24557
24774
  if (filter) {
24558
- data.Data = applyFilter(data.Data, filter);
24775
+ const filtered = applyFilter(data.Data, filter);
24776
+ data.Data = normalize ? normalizeDataKeys(filtered) : filtered;
24559
24777
  }
24560
- logOutput(data, getOutputFormat());
24778
+ logOutput(normalizeOutputKeys(data), getOutputFormat());
24561
24779
  }
24562
24780
  OutputFormatter.success = success;
24563
24781
  function error(data) {
@@ -24567,7 +24785,7 @@ var OutputFormatter;
24567
24785
  result: data.Result,
24568
24786
  message: data.Message
24569
24787
  });
24570
- logOutput(data, getOutputFormat());
24788
+ logOutput(normalizeOutputKeys(data), getOutputFormat());
24571
24789
  }
24572
24790
  OutputFormatter.error = error;
24573
24791
  function emitList(code, items, opts) {
@@ -24588,11 +24806,14 @@ var OutputFormatter;
24588
24806
  function log(data) {
24589
24807
  const format = getOutputFormat();
24590
24808
  const sink = getOutputSink();
24809
+ const normalized = toPascalCaseData(data);
24591
24810
  if (format === "json") {
24592
- sink.writeErr(`${JSON.stringify(data)}
24811
+ const json2 = JSON.stringify(normalized);
24812
+ const safe = needsAsciiSafeJson(sink) ? escapeNonAscii(json2) : json2;
24813
+ sink.writeErr(`${safe}
24593
24814
  `);
24594
24815
  } else {
24595
- for (const [key, value] of Object.entries(data)) {
24816
+ for (const [key, value] of Object.entries(normalized)) {
24596
24817
  sink.writeErr(`${key}: ${value}
24597
24818
  `);
24598
24819
  }
@@ -24601,13 +24822,18 @@ var OutputFormatter;
24601
24822
  OutputFormatter.log = log;
24602
24823
  function formatToString(data) {
24603
24824
  const filter = getOutputFilter();
24604
- if (filter && "Data" in data && data.Data != null) {
24605
- data.Data = applyFilter(data.Data, filter);
24825
+ if ("Data" in data && data.Data != null) {
24826
+ data.Data = normalizeDataKeys(data.Data);
24827
+ if (filter) {
24828
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
24829
+ }
24606
24830
  }
24831
+ const output = normalizeOutputKeys(data);
24607
24832
  const lines = [];
24608
- printOutput(data, getOutputFormat(), (msg) => {
24833
+ const sink = getOutputSink();
24834
+ printOutput(output, getOutputFormat(), (msg) => {
24609
24835
  lines.push(msg);
24610
- });
24836
+ }, needsAsciiSafeJson(sink));
24611
24837
  return lines.join(`
24612
24838
  `);
24613
24839
  }
@@ -26016,8 +26242,65 @@ JSONPath.prototype.safeVm = {
26016
26242
  Script: SafeScript
26017
26243
  };
26018
26244
  JSONPath.prototype.vm = vm;
26245
+ // ../../common/src/option-aliases.ts
26246
+ import { Option } from "commander";
26247
+ function resolveDeprecatedOptionAlias({
26248
+ preferredValue,
26249
+ deprecatedValue,
26250
+ preferredFlag,
26251
+ deprecatedFlag
26252
+ }) {
26253
+ const hasPreferred = preferredValue !== undefined;
26254
+ const hasDeprecated = deprecatedValue !== undefined;
26255
+ if (hasPreferred && hasDeprecated) {
26256
+ return {
26257
+ value: undefined,
26258
+ usedDeprecated: true,
26259
+ error: {
26260
+ message: `${deprecatedFlag} and ${preferredFlag} are aliases. Use only ${preferredFlag}.`,
26261
+ instructions: `Replace ${deprecatedFlag} with ${preferredFlag}.`
26262
+ }
26263
+ };
26264
+ }
26265
+ return {
26266
+ value: hasPreferred ? preferredValue : deprecatedValue,
26267
+ usedDeprecated: hasDeprecated
26268
+ };
26269
+ }
26270
+ function warnDeprecatedOptionAlias(deprecatedFlag, preferredFlag) {
26271
+ getOutputSink().writeErr(`[WARN] ${deprecatedFlag} is deprecated. Use ${preferredFlag} instead.
26272
+ `);
26273
+ }
26274
+ var TENANT_SWITCH_COMMAND = "uip login tenant set <tenant>";
26275
+ function createHiddenDeprecatedTenantOption(flags = "-t, --tenant <tenant-name>") {
26276
+ return new Option(flags, `Tenant name. Deprecated; use ${TENANT_SWITCH_COMMAND} to switch active tenants.`).hideHelp().argParser((tenant) => {
26277
+ warnDeprecatedTenantOption(tenant);
26278
+ return tenant;
26279
+ });
26280
+ }
26281
+ function warnDeprecatedTenantOption(tenant) {
26282
+ if (tenant === undefined)
26283
+ return;
26284
+ warnDeprecatedOptionAlias("--tenant", TENANT_SWITCH_COMMAND);
26285
+ }
26019
26286
  // ../../common/src/option-validators.ts
26020
26287
  import { InvalidArgumentError } from "commander";
26288
+ // ../../common/src/polling/types.ts
26289
+ var PollOutcome = {
26290
+ Completed: "completed",
26291
+ Timeout: "timeout",
26292
+ Interrupted: "interrupted",
26293
+ Aborted: "aborted",
26294
+ Failed: "failed"
26295
+ };
26296
+
26297
+ // ../../common/src/polling/poll-failure-mapping.ts
26298
+ var REASON_BY_OUTCOME = {
26299
+ [PollOutcome.Timeout]: "poll_timeout",
26300
+ [PollOutcome.Failed]: "poll_failed",
26301
+ [PollOutcome.Interrupted]: "poll_failed",
26302
+ [PollOutcome.Aborted]: "poll_aborted"
26303
+ };
26021
26304
  // ../../common/src/polling/terminal-statuses.ts
26022
26305
  var TERMINAL_STATUSES = new Set([
26023
26306
  "completed",
@@ -26045,6 +26328,105 @@ var ScreenLogger;
26045
26328
  }
26046
26329
  ScreenLogger.progress = progress;
26047
26330
  })(ScreenLogger ||= {});
26331
+ // ../../common/src/sdk-user-agent.ts
26332
+ var USER_AGENT_HEADER = "User-Agent";
26333
+ var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
26334
+ function userAgentPatchKey(userAgent) {
26335
+ return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
26336
+ }
26337
+ function splitUserAgentTokens(value) {
26338
+ return value?.trim().split(/\s+/).filter(Boolean) ?? [];
26339
+ }
26340
+ function appendUserAgentToken(value, userAgent) {
26341
+ const tokens = splitUserAgentTokens(value);
26342
+ const seen = new Set(tokens);
26343
+ for (const token of splitUserAgentTokens(userAgent)) {
26344
+ if (!seen.has(token)) {
26345
+ tokens.push(token);
26346
+ seen.add(token);
26347
+ }
26348
+ }
26349
+ return tokens.join(" ");
26350
+ }
26351
+ function getEffectiveUserAgent(userAgent) {
26352
+ return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
26353
+ }
26354
+ function isHeadersLike(headers) {
26355
+ return typeof headers === "object" && headers !== null && "get" in headers && typeof headers.get === "function" && "set" in headers && typeof headers.set === "function";
26356
+ }
26357
+ function getSdkUserAgentToken(pkg) {
26358
+ const packageName = pkg.name.replace(/^@uipath\//, "");
26359
+ return getEffectiveUserAgent(`${packageName}/${pkg.version}`);
26360
+ }
26361
+ function addSdkUserAgentHeader(headers, userAgent) {
26362
+ const result = { ...headers ?? {} };
26363
+ const effectiveUserAgent = getEffectiveUserAgent(userAgent);
26364
+ const headerName = Object.keys(result).find((key) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
26365
+ if (headerName) {
26366
+ result[headerName] = appendUserAgentToken(result[headerName], effectiveUserAgent);
26367
+ } else {
26368
+ result[USER_AGENT_HEADER] = effectiveUserAgent;
26369
+ }
26370
+ return result;
26371
+ }
26372
+ function withSdkUserAgentHeader(headers, userAgent) {
26373
+ const effectiveUserAgent = getEffectiveUserAgent(userAgent);
26374
+ if (isHeadersLike(headers)) {
26375
+ headers.set(USER_AGENT_HEADER, appendUserAgentToken(headers.get(USER_AGENT_HEADER), effectiveUserAgent));
26376
+ return headers;
26377
+ }
26378
+ if (Array.isArray(headers)) {
26379
+ const result = headers.map((entry) => {
26380
+ const [key, value] = entry;
26381
+ return [key, value];
26382
+ });
26383
+ const headerIndex = result.findIndex(([key]) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
26384
+ if (headerIndex >= 0) {
26385
+ const [key, value] = result[headerIndex];
26386
+ result[headerIndex] = [
26387
+ key,
26388
+ appendUserAgentToken(value, effectiveUserAgent)
26389
+ ];
26390
+ } else {
26391
+ result.push([USER_AGENT_HEADER, effectiveUserAgent]);
26392
+ }
26393
+ return result;
26394
+ }
26395
+ return addSdkUserAgentHeader(typeof headers === "object" && headers !== null ? { ...headers } : {}, effectiveUserAgent);
26396
+ }
26397
+ function withUserAgentInitOverride(initOverrides, userAgent) {
26398
+ return async (requestContext) => {
26399
+ const initWithUserAgent = {
26400
+ ...requestContext.init,
26401
+ headers: withSdkUserAgentHeader(requestContext.init.headers, userAgent)
26402
+ };
26403
+ const override = typeof initOverrides === "function" ? await initOverrides({
26404
+ ...requestContext,
26405
+ init: initWithUserAgent
26406
+ }) : initOverrides;
26407
+ return {
26408
+ ...override ?? {},
26409
+ headers: withSdkUserAgentHeader(override?.headers ?? initWithUserAgent.headers, userAgent)
26410
+ };
26411
+ };
26412
+ }
26413
+ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
26414
+ const prototype = BaseApiClass.prototype;
26415
+ const patchKey = userAgentPatchKey(userAgent);
26416
+ if (prototype[patchKey]) {
26417
+ return;
26418
+ }
26419
+ if (typeof prototype.request !== "function") {
26420
+ throw new Error("Generated BaseAPI request function not found.");
26421
+ }
26422
+ const originalRequest = prototype.request;
26423
+ prototype.request = function requestWithUserAgent(context, initOverrides) {
26424
+ return originalRequest.call(this, context, withUserAgentInitOverride(initOverrides, userAgent));
26425
+ };
26426
+ Object.defineProperty(prototype, patchKey, {
26427
+ value: true
26428
+ });
26429
+ }
26048
26430
  // ../../common/src/tool-provider.ts
26049
26431
  var factorySlot = singleton("PackagerFactoryProvider");
26050
26432
  // ../../common/src/trackedAction.ts
@@ -26230,13 +26612,17 @@ Command2.prototype.trackedAction = function(context, fn, properties) {
26230
26612
  const [error] = await catchError(fn(...args));
26231
26613
  if (error) {
26232
26614
  errorMessage = error instanceof Error ? error.message : String(error);
26233
- logger.error(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
26615
+ logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
26616
+ const typed = error;
26617
+ const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
26618
+ const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
26619
+ const finalResult = customResult ?? RESULTS.Failure;
26234
26620
  OutputFormatter.error({
26235
- Result: RESULTS.Failure,
26621
+ Result: finalResult,
26236
26622
  Message: errorMessage,
26237
- Instructions: "An unexpected error occurred. Run with --log-level debug for details."
26623
+ Instructions: customInstructions ?? "An unexpected error occurred. Run with --log-level debug for details."
26238
26624
  });
26239
- context.exit(1);
26625
+ context.exit(EXIT_CODES[finalResult]);
26240
26626
  }
26241
26627
  const durationMs = performance.now() - startTime;
26242
26628
  const success = !error && (process.exitCode === undefined || process.exitCode === 0);
@@ -26498,8 +26884,66 @@ class VoidApiResponse {
26498
26884
  return;
26499
26885
  }
26500
26886
  }
26501
-
26502
- // ../resourcecatalog-sdk/generated/src/models/TagType.ts
26887
+ // ../resourcecatalog-sdk/package.json
26888
+ var package_default2 = {
26889
+ name: "@uipath/resourcecatalog-sdk",
26890
+ license: "MIT",
26891
+ version: "1.2.0",
26892
+ description: "SDK for the UiPath Resource Catalog Service API.",
26893
+ repository: {
26894
+ type: "git",
26895
+ url: "https://github.com/UiPath/cli.git",
26896
+ directory: "packages/admin/resourcecatalog-sdk"
26897
+ },
26898
+ publishConfig: {
26899
+ registry: "https://npm.pkg.github.com/@uipath"
26900
+ },
26901
+ keywords: [
26902
+ "uipath",
26903
+ "resource-catalog",
26904
+ "sdk"
26905
+ ],
26906
+ type: "module",
26907
+ main: "./dist/index.js",
26908
+ types: "./dist/src/index.d.ts",
26909
+ exports: {
26910
+ ".": {
26911
+ types: "./dist/src/index.d.ts",
26912
+ default: "./dist/index.js"
26913
+ }
26914
+ },
26915
+ files: [
26916
+ "dist"
26917
+ ],
26918
+ private: true,
26919
+ scripts: {
26920
+ build: "bun build ./src/index.ts --outdir dist --format esm --target node && tsc -p tsconfig.build.json --noCheck",
26921
+ generate: "bun run src/scripts/generate-sdk.ts",
26922
+ lint: "biome check ."
26923
+ },
26924
+ devDependencies: {
26925
+ "@openapitools/openapi-generator-cli": "^2.31.1",
26926
+ "@types/node": "^25.5.2",
26927
+ "@uipath/auth": "workspace:*",
26928
+ "@uipath/common": "workspace:*",
26929
+ "@uipath/filesystem": "workspace:*",
26930
+ typescript: "^6.0.2"
26931
+ }
26932
+ };
26933
+
26934
+ // ../resourcecatalog-sdk/src/user-agent.ts
26935
+ var SDK_USER_AGENT = getSdkUserAgentToken(package_default2);
26936
+ installSdkUserAgentHeader(BaseAPI, SDK_USER_AGENT);
26937
+
26938
+ // ../resourcecatalog-sdk/generated/src/models/EntitySearchState.ts
26939
+ function EntitySearchStateFromJSON(json2) {
26940
+ return EntitySearchStateFromJSONTyped(json2, false);
26941
+ }
26942
+ function EntitySearchStateFromJSONTyped(json2, ignoreDiscriminator) {
26943
+ return json2;
26944
+ }
26945
+
26946
+ // ../resourcecatalog-sdk/generated/src/models/TagType.ts
26503
26947
  var TagType = {
26504
26948
  Label: "Label",
26505
26949
  KeyValue: "KeyValue"
@@ -26514,6 +26958,168 @@ function TagTypeToJSON(value) {
26514
26958
  return value;
26515
26959
  }
26516
26960
 
26961
+ // ../resourcecatalog-sdk/generated/src/models/TagModel.ts
26962
+ function TagModelFromJSON(json2) {
26963
+ return TagModelFromJSONTyped(json2, false);
26964
+ }
26965
+ function TagModelFromJSONTyped(json2, ignoreDiscriminator) {
26966
+ if (json2 == null) {
26967
+ return json2;
26968
+ }
26969
+ return {
26970
+ key: json2["key"] == null ? undefined : json2["key"],
26971
+ displayName: json2["displayName"] == null ? undefined : json2["displayName"],
26972
+ name: json2["name"] == null ? undefined : json2["name"],
26973
+ displayValue: json2["displayValue"] == null ? undefined : json2["displayValue"],
26974
+ value: json2["value"] == null ? undefined : json2["value"],
26975
+ type: json2["type"] == null ? undefined : TagTypeFromJSON(json2["type"]),
26976
+ accountKey: json2["accountKey"] == null ? undefined : json2["accountKey"],
26977
+ tenantKey: json2["tenantKey"] == null ? undefined : json2["tenantKey"],
26978
+ userKey: json2["userKey"] == null ? undefined : json2["userKey"]
26979
+ };
26980
+ }
26981
+
26982
+ // ../resourcecatalog-sdk/generated/src/models/EntityScope.ts
26983
+ function EntityScopeFromJSON(json2) {
26984
+ return EntityScopeFromJSONTyped(json2, false);
26985
+ }
26986
+ function EntityScopeFromJSONTyped(json2, ignoreDiscriminator) {
26987
+ return json2;
26988
+ }
26989
+
26990
+ // ../resourcecatalog-sdk/generated/src/models/FolderType.ts
26991
+ function FolderTypeFromJSON(json2) {
26992
+ return FolderTypeFromJSONTyped(json2, false);
26993
+ }
26994
+ function FolderTypeFromJSONTyped(json2, ignoreDiscriminator) {
26995
+ return json2;
26996
+ }
26997
+
26998
+ // ../resourcecatalog-sdk/generated/src/models/FolderModel.ts
26999
+ function FolderModelFromJSON(json2) {
27000
+ return FolderModelFromJSONTyped(json2, false);
27001
+ }
27002
+ function FolderModelFromJSONTyped(json2, ignoreDiscriminator) {
27003
+ if (json2 == null) {
27004
+ return json2;
27005
+ }
27006
+ return {
27007
+ id: json2["id"] == null ? undefined : json2["id"],
27008
+ key: json2["key"] == null ? undefined : json2["key"],
27009
+ displayName: json2["displayName"] == null ? undefined : json2["displayName"],
27010
+ code: json2["code"] == null ? undefined : json2["code"],
27011
+ fullyQualifiedName: json2["fullyQualifiedName"] == null ? undefined : json2["fullyQualifiedName"],
27012
+ timestamp: json2["timestamp"] == null ? undefined : new Date(json2["timestamp"]),
27013
+ tenantKey: json2["tenantKey"] == null ? undefined : json2["tenantKey"],
27014
+ accountKey: json2["accountKey"] == null ? undefined : json2["accountKey"],
27015
+ userKey: json2["userKey"] == null ? undefined : json2["userKey"],
27016
+ type: json2["type"] == null ? undefined : FolderTypeFromJSON(json2["type"]),
27017
+ path: json2["path"] == null ? undefined : json2["path"],
27018
+ permissions: json2["permissions"] == null ? undefined : json2["permissions"]
27019
+ };
27020
+ }
27021
+
27022
+ // ../resourcecatalog-sdk/generated/src/models/EntityModel.ts
27023
+ function EntityModelFromJSON(json2) {
27024
+ return EntityModelFromJSONTyped(json2, false);
27025
+ }
27026
+ function EntityModelFromJSONTyped(json2, ignoreDiscriminator) {
27027
+ if (json2 == null) {
27028
+ return json2;
27029
+ }
27030
+ return {
27031
+ entityKey: json2["entityKey"] == null ? undefined : json2["entityKey"],
27032
+ name: json2["name"] == null ? undefined : json2["name"],
27033
+ description: json2["description"] == null ? undefined : json2["description"],
27034
+ entityType: json2["entityType"] == null ? undefined : json2["entityType"],
27035
+ tags: json2["tags"] == null ? undefined : json2["tags"].map(TagModelFromJSON),
27036
+ folders: json2["folders"] == null ? undefined : json2["folders"].map(FolderModelFromJSON),
27037
+ linkedFoldersCount: json2["linkedFoldersCount"] == null ? undefined : json2["linkedFoldersCount"],
27038
+ source: json2["source"] == null ? undefined : json2["source"],
27039
+ scope: json2["scope"] == null ? undefined : EntityScopeFromJSON(json2["scope"]),
27040
+ searchState: json2["searchState"] == null ? undefined : EntitySearchStateFromJSON(json2["searchState"]),
27041
+ timestamp: json2["timestamp"] == null ? undefined : new Date(json2["timestamp"]),
27042
+ folderKey: json2["folderKey"] == null ? undefined : json2["folderKey"],
27043
+ folderKeys: json2["folderKeys"] == null ? undefined : json2["folderKeys"],
27044
+ tenantKey: json2["tenantKey"] == null ? undefined : json2["tenantKey"],
27045
+ accountKey: json2["accountKey"] == null ? undefined : json2["accountKey"],
27046
+ userKey: json2["userKey"] == null ? undefined : json2["userKey"],
27047
+ dependencies: json2["dependencies"] == null ? undefined : json2["dependencies"],
27048
+ customData: json2["customData"] == null ? undefined : json2["customData"],
27049
+ entitySubType: json2["entitySubType"] == null ? undefined : json2["entitySubType"]
27050
+ };
27051
+ }
27052
+
27053
+ // ../resourcecatalog-sdk/generated/src/models/EntityModelPaginationResult.ts
27054
+ function EntityModelPaginationResultFromJSON(json2) {
27055
+ return EntityModelPaginationResultFromJSONTyped(json2, false);
27056
+ }
27057
+ function EntityModelPaginationResultFromJSONTyped(json2, ignoreDiscriminator) {
27058
+ if (json2 == null) {
27059
+ return json2;
27060
+ }
27061
+ return {
27062
+ count: json2["count"] == null ? undefined : json2["count"],
27063
+ value: json2["value"] == null ? undefined : json2["value"].map(EntityModelFromJSON)
27064
+ };
27065
+ }
27066
+
27067
+ // ../resourcecatalog-sdk/generated/src/models/FolderDto.ts
27068
+ function FolderDtoFromJSON(json2) {
27069
+ return FolderDtoFromJSONTyped(json2, false);
27070
+ }
27071
+ function FolderDtoFromJSONTyped(json2, ignoreDiscriminator) {
27072
+ if (json2 == null) {
27073
+ return json2;
27074
+ }
27075
+ return {
27076
+ key: json2["key"] == null ? undefined : json2["key"],
27077
+ fullyQualifiedName: json2["fullyQualifiedName"] == null ? undefined : json2["fullyQualifiedName"],
27078
+ isPersonal: json2["isPersonal"] == null ? undefined : json2["isPersonal"],
27079
+ folderType: json2["folderType"] == null ? undefined : FolderTypeFromJSON(json2["folderType"])
27080
+ };
27081
+ }
27082
+
27083
+ // ../resourcecatalog-sdk/generated/src/models/FolderEntityModel.ts
27084
+ function FolderEntityModelFromJSON(json2) {
27085
+ return FolderEntityModelFromJSONTyped(json2, false);
27086
+ }
27087
+ function FolderEntityModelFromJSONTyped(json2, ignoreDiscriminator) {
27088
+ if (json2 == null) {
27089
+ return json2;
27090
+ }
27091
+ return {
27092
+ folderKey: json2["folderKey"] == null ? undefined : json2["folderKey"],
27093
+ folderName: json2["folderName"] == null ? undefined : json2["folderName"],
27094
+ folderCode: json2["folderCode"] == null ? undefined : json2["folderCode"],
27095
+ fullyQualifiedName: json2["fullyQualifiedName"] == null ? undefined : json2["fullyQualifiedName"],
27096
+ folderType: json2["folderType"] == null ? undefined : FolderTypeFromJSON(json2["folderType"]),
27097
+ folderPath: json2["folderPath"] == null ? undefined : json2["folderPath"],
27098
+ entityKey: json2["entityKey"] == null ? undefined : json2["entityKey"],
27099
+ entityName: json2["entityName"] == null ? undefined : json2["entityName"],
27100
+ entityDescription: json2["entityDescription"] == null ? undefined : json2["entityDescription"],
27101
+ entityType: json2["entityType"] == null ? undefined : json2["entityType"],
27102
+ entitySubType: json2["entitySubType"] == null ? undefined : json2["entitySubType"],
27103
+ entitySource: json2["entitySource"] == null ? undefined : json2["entitySource"]
27104
+ };
27105
+ }
27106
+
27107
+ // ../resourcecatalog-sdk/generated/src/models/FolderEntityModelCursorPaginationResult.ts
27108
+ function FolderEntityModelCursorPaginationResultFromJSON(json2) {
27109
+ return FolderEntityModelCursorPaginationResultFromJSONTyped(json2, false);
27110
+ }
27111
+ function FolderEntityModelCursorPaginationResultFromJSONTyped(json2, ignoreDiscriminator) {
27112
+ if (json2 == null) {
27113
+ return json2;
27114
+ }
27115
+ return {
27116
+ items: json2["items"] == null ? undefined : json2["items"].map(FolderEntityModelFromJSON),
27117
+ totalCount: json2["totalCount"] == null ? undefined : json2["totalCount"],
27118
+ nextPage: json2["nextPage"] == null ? undefined : json2["nextPage"],
27119
+ previousPage: json2["previousPage"] == null ? undefined : json2["previousPage"]
27120
+ };
27121
+ }
27122
+
26517
27123
  // ../resourcecatalog-sdk/generated/src/models/TagReferencesModel.ts
26518
27124
  function TagReferencesModelFromJSON(json2) {
26519
27125
  return TagReferencesModelFromJSONTyped(json2, false);
@@ -26635,27 +27241,464 @@ function TagValueModelPaginationResultFromJSONTyped(json2, ignoreDiscriminator)
26635
27241
  if (json2 == null) {
26636
27242
  return json2;
26637
27243
  }
26638
- return {
26639
- count: json2["count"] == null ? undefined : json2["count"],
26640
- value: json2["value"] == null ? undefined : json2["value"].map(TagValueModelFromJSON)
26641
- };
26642
- }
26643
-
26644
- // ../resourcecatalog-sdk/generated/src/models/ValueModel.ts
26645
- function ValueModelToJSON(json2) {
26646
- return ValueModelToJSONTyped(json2, false);
26647
- }
26648
- function ValueModelToJSONTyped(value, ignoreDiscriminator = false) {
26649
- if (value == null) {
26650
- return value;
27244
+ return {
27245
+ count: json2["count"] == null ? undefined : json2["count"],
27246
+ value: json2["value"] == null ? undefined : json2["value"].map(TagValueModelFromJSON)
27247
+ };
27248
+ }
27249
+
27250
+ // ../resourcecatalog-sdk/generated/src/models/ValueModel.ts
27251
+ function ValueModelToJSON(json2) {
27252
+ return ValueModelToJSONTyped(json2, false);
27253
+ }
27254
+ function ValueModelToJSONTyped(value, ignoreDiscriminator = false) {
27255
+ if (value == null) {
27256
+ return value;
27257
+ }
27258
+ return {
27259
+ labelKey: value["labelKey"],
27260
+ values: value["values"],
27261
+ accountKey: value["accountKey"],
27262
+ tenantKey: value["tenantKey"],
27263
+ userKey: value["userKey"]
27264
+ };
27265
+ }
27266
+
27267
+ // ../resourcecatalog-sdk/generated/src/apis/EntitiesApi.ts
27268
+ class EntitiesApi extends BaseAPI {
27269
+ async entitiesGetRaw(requestParameters, initOverrides) {
27270
+ if (requestParameters["xUiPathInternalAccountId"] == null) {
27271
+ throw new RequiredError("xUiPathInternalAccountId", 'Required parameter "xUiPathInternalAccountId" was null or undefined when calling entitiesGet().');
27272
+ }
27273
+ const queryParameters = {};
27274
+ if (requestParameters["skip"] != null) {
27275
+ queryParameters["skip"] = requestParameters["skip"];
27276
+ }
27277
+ if (requestParameters["take"] != null) {
27278
+ queryParameters["take"] = requestParameters["take"];
27279
+ }
27280
+ if (requestParameters["entityTypes"] != null) {
27281
+ queryParameters["entityTypes"] = requestParameters["entityTypes"];
27282
+ }
27283
+ if (requestParameters["entitySubType"] != null) {
27284
+ queryParameters["entitySubType"] = requestParameters["entitySubType"];
27285
+ }
27286
+ if (requestParameters["apiVersion"] != null) {
27287
+ queryParameters["api-version"] = requestParameters["apiVersion"];
27288
+ }
27289
+ const headerParameters = {};
27290
+ if (requestParameters["xVersion"] != null) {
27291
+ headerParameters["X-Version"] = String(requestParameters["xVersion"]);
27292
+ }
27293
+ if (requestParameters["xUiPathInternalAccountId"] != null) {
27294
+ headerParameters["X-UiPath-Internal-AccountId"] = String(requestParameters["xUiPathInternalAccountId"]);
27295
+ }
27296
+ if (requestParameters["xUiPathInternalTenantId"] != null) {
27297
+ headerParameters["X-UiPath-Internal-TenantId"] = String(requestParameters["xUiPathInternalTenantId"]);
27298
+ }
27299
+ if (requestParameters["xUIPATHOrganizationUnitId"] != null) {
27300
+ headerParameters["X-UIPATH-OrganizationUnitId"] = String(requestParameters["xUIPATHOrganizationUnitId"]);
27301
+ }
27302
+ if (requestParameters["xUIPATHFolderPath"] != null) {
27303
+ headerParameters["X-UIPATH-FolderPath"] = String(requestParameters["xUIPATHFolderPath"]);
27304
+ }
27305
+ if (requestParameters["xUIPATHFolderPathEncoded"] != null) {
27306
+ headerParameters["X-UIPATH-FolderPath-Encoded"] = String(requestParameters["xUIPATHFolderPathEncoded"]);
27307
+ }
27308
+ if (requestParameters["xUIPATHFolderKey"] != null) {
27309
+ headerParameters["X-UIPATH-FolderKey"] = String(requestParameters["xUIPATHFolderKey"]);
27310
+ }
27311
+ if (this.configuration && this.configuration.accessToken) {
27312
+ const token = this.configuration.accessToken;
27313
+ const tokenString = await token("Bearer", []);
27314
+ if (tokenString) {
27315
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
27316
+ }
27317
+ }
27318
+ let urlPath = `/Entities`;
27319
+ const response = await this.request({
27320
+ path: urlPath,
27321
+ method: "GET",
27322
+ headers: headerParameters,
27323
+ query: queryParameters
27324
+ }, initOverrides);
27325
+ return new JSONApiResponse(response, (jsonValue) => EntityModelPaginationResultFromJSON(jsonValue));
27326
+ }
27327
+ async entitiesGet(requestParameters, initOverrides) {
27328
+ const response = await this.entitiesGetRaw(requestParameters, initOverrides);
27329
+ return await response.value();
27330
+ }
27331
+ async entitiesGetByEntityTypeRaw(requestParameters, initOverrides) {
27332
+ if (requestParameters["entityType"] == null) {
27333
+ throw new RequiredError("entityType", 'Required parameter "entityType" was null or undefined when calling entitiesGetByEntityType().');
27334
+ }
27335
+ if (requestParameters["xUiPathInternalAccountId"] == null) {
27336
+ throw new RequiredError("xUiPathInternalAccountId", 'Required parameter "xUiPathInternalAccountId" was null or undefined when calling entitiesGetByEntityType().');
27337
+ }
27338
+ const queryParameters = {};
27339
+ if (requestParameters["name"] != null) {
27340
+ queryParameters["name"] = requestParameters["name"];
27341
+ }
27342
+ if (requestParameters["skip"] != null) {
27343
+ queryParameters["skip"] = requestParameters["skip"];
27344
+ }
27345
+ if (requestParameters["take"] != null) {
27346
+ queryParameters["take"] = requestParameters["take"];
27347
+ }
27348
+ if (requestParameters["entitySubType"] != null) {
27349
+ queryParameters["entitySubType"] = requestParameters["entitySubType"];
27350
+ }
27351
+ if (requestParameters["apiVersion"] != null) {
27352
+ queryParameters["api-version"] = requestParameters["apiVersion"];
27353
+ }
27354
+ const headerParameters = {};
27355
+ if (requestParameters["xVersion"] != null) {
27356
+ headerParameters["X-Version"] = String(requestParameters["xVersion"]);
27357
+ }
27358
+ if (requestParameters["xUiPathInternalAccountId"] != null) {
27359
+ headerParameters["X-UiPath-Internal-AccountId"] = String(requestParameters["xUiPathInternalAccountId"]);
27360
+ }
27361
+ if (requestParameters["xUiPathInternalTenantId"] != null) {
27362
+ headerParameters["X-UiPath-Internal-TenantId"] = String(requestParameters["xUiPathInternalTenantId"]);
27363
+ }
27364
+ if (requestParameters["xUIPATHOrganizationUnitId"] != null) {
27365
+ headerParameters["X-UIPATH-OrganizationUnitId"] = String(requestParameters["xUIPATHOrganizationUnitId"]);
27366
+ }
27367
+ if (requestParameters["xUIPATHFolderPath"] != null) {
27368
+ headerParameters["X-UIPATH-FolderPath"] = String(requestParameters["xUIPATHFolderPath"]);
27369
+ }
27370
+ if (requestParameters["xUIPATHFolderPathEncoded"] != null) {
27371
+ headerParameters["X-UIPATH-FolderPath-Encoded"] = String(requestParameters["xUIPATHFolderPathEncoded"]);
27372
+ }
27373
+ if (requestParameters["xUIPATHFolderKey"] != null) {
27374
+ headerParameters["X-UIPATH-FolderKey"] = String(requestParameters["xUIPATHFolderKey"]);
27375
+ }
27376
+ if (this.configuration && this.configuration.accessToken) {
27377
+ const token = this.configuration.accessToken;
27378
+ const tokenString = await token("Bearer", []);
27379
+ if (tokenString) {
27380
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
27381
+ }
27382
+ }
27383
+ let urlPath = `/Entities/{entityType}`;
27384
+ urlPath = urlPath.replace(`{${"entityType"}}`, encodeURIComponent(String(requestParameters["entityType"])));
27385
+ const response = await this.request({
27386
+ path: urlPath,
27387
+ method: "GET",
27388
+ headers: headerParameters,
27389
+ query: queryParameters
27390
+ }, initOverrides);
27391
+ return new JSONApiResponse(response, (jsonValue) => EntityModelPaginationResultFromJSON(jsonValue));
27392
+ }
27393
+ async entitiesGetByEntityType(requestParameters, initOverrides) {
27394
+ const response = await this.entitiesGetByEntityTypeRaw(requestParameters, initOverrides);
27395
+ return await response.value();
27396
+ }
27397
+ async entitiesGetDependenciesRaw(requestParameters, initOverrides) {
27398
+ if (requestParameters["entityKey"] == null) {
27399
+ throw new RequiredError("entityKey", 'Required parameter "entityKey" was null or undefined when calling entitiesGetDependencies().');
27400
+ }
27401
+ if (requestParameters["xUiPathInternalAccountId"] == null) {
27402
+ throw new RequiredError("xUiPathInternalAccountId", 'Required parameter "xUiPathInternalAccountId" was null or undefined when calling entitiesGetDependencies().');
27403
+ }
27404
+ const queryParameters = {};
27405
+ if (requestParameters["apiVersion"] != null) {
27406
+ queryParameters["api-version"] = requestParameters["apiVersion"];
27407
+ }
27408
+ const headerParameters = {};
27409
+ if (requestParameters["xVersion"] != null) {
27410
+ headerParameters["X-Version"] = String(requestParameters["xVersion"]);
27411
+ }
27412
+ if (requestParameters["xUiPathInternalAccountId"] != null) {
27413
+ headerParameters["X-UiPath-Internal-AccountId"] = String(requestParameters["xUiPathInternalAccountId"]);
27414
+ }
27415
+ if (requestParameters["xUiPathInternalTenantId"] != null) {
27416
+ headerParameters["X-UiPath-Internal-TenantId"] = String(requestParameters["xUiPathInternalTenantId"]);
27417
+ }
27418
+ if (this.configuration && this.configuration.accessToken) {
27419
+ const token = this.configuration.accessToken;
27420
+ const tokenString = await token("Bearer", []);
27421
+ if (tokenString) {
27422
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
27423
+ }
27424
+ }
27425
+ let urlPath = `/Entities/{entityKey}/Dependencies`;
27426
+ urlPath = urlPath.replace(`{${"entityKey"}}`, encodeURIComponent(String(requestParameters["entityKey"])));
27427
+ const response = await this.request({
27428
+ path: urlPath,
27429
+ method: "GET",
27430
+ headers: headerParameters,
27431
+ query: queryParameters
27432
+ }, initOverrides);
27433
+ return new JSONApiResponse(response, (jsonValue) => jsonValue.map(EntityModelFromJSON));
27434
+ }
27435
+ async entitiesGetDependencies(requestParameters, initOverrides) {
27436
+ const response = await this.entitiesGetDependenciesRaw(requestParameters, initOverrides);
27437
+ return await response.value();
27438
+ }
27439
+ async entitiesGetEntitiesByKeysRaw(requestParameters, initOverrides) {
27440
+ if (requestParameters["xUiPathInternalAccountId"] == null) {
27441
+ throw new RequiredError("xUiPathInternalAccountId", 'Required parameter "xUiPathInternalAccountId" was null or undefined when calling entitiesGetEntitiesByKeys().');
27442
+ }
27443
+ const queryParameters = {};
27444
+ if (requestParameters["apiVersion"] != null) {
27445
+ queryParameters["api-version"] = requestParameters["apiVersion"];
27446
+ }
27447
+ const headerParameters = {};
27448
+ headerParameters["Content-Type"] = "application/json";
27449
+ if (requestParameters["xVersion"] != null) {
27450
+ headerParameters["X-Version"] = String(requestParameters["xVersion"]);
27451
+ }
27452
+ if (requestParameters["xUiPathInternalAccountId"] != null) {
27453
+ headerParameters["X-UiPath-Internal-AccountId"] = String(requestParameters["xUiPathInternalAccountId"]);
27454
+ }
27455
+ if (requestParameters["xUiPathInternalTenantId"] != null) {
27456
+ headerParameters["X-UiPath-Internal-TenantId"] = String(requestParameters["xUiPathInternalTenantId"]);
27457
+ }
27458
+ if (this.configuration && this.configuration.accessToken) {
27459
+ const token = this.configuration.accessToken;
27460
+ const tokenString = await token("Bearer", []);
27461
+ if (tokenString) {
27462
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
27463
+ }
27464
+ }
27465
+ let urlPath = `/Entities/GetEntitiesByKeys`;
27466
+ const response = await this.request({
27467
+ path: urlPath,
27468
+ method: "POST",
27469
+ headers: headerParameters,
27470
+ query: queryParameters,
27471
+ body: requestParameters["requestBody"]
27472
+ }, initOverrides);
27473
+ return new JSONApiResponse(response, (jsonValue) => jsonValue.map(EntityModelFromJSON));
27474
+ }
27475
+ async entitiesGetEntitiesByKeys(requestParameters, initOverrides) {
27476
+ const response = await this.entitiesGetEntitiesByKeysRaw(requestParameters, initOverrides);
27477
+ return await response.value();
27478
+ }
27479
+ async entitiesGetFoldersRaw(requestParameters, initOverrides) {
27480
+ if (requestParameters["entityType"] == null) {
27481
+ throw new RequiredError("entityType", 'Required parameter "entityType" was null or undefined when calling entitiesGetFolders().');
27482
+ }
27483
+ if (requestParameters["xUiPathInternalAccountId"] == null) {
27484
+ throw new RequiredError("xUiPathInternalAccountId", 'Required parameter "xUiPathInternalAccountId" was null or undefined when calling entitiesGetFolders().');
27485
+ }
27486
+ const queryParameters = {};
27487
+ if (requestParameters["permissions"] != null) {
27488
+ queryParameters["permissions"] = requestParameters["permissions"];
27489
+ }
27490
+ if (requestParameters["folderTypes"] != null) {
27491
+ queryParameters["folderTypes"] = requestParameters["folderTypes"];
27492
+ }
27493
+ if (requestParameters["apiVersion"] != null) {
27494
+ queryParameters["api-version"] = requestParameters["apiVersion"];
27495
+ }
27496
+ const headerParameters = {};
27497
+ if (requestParameters["xVersion"] != null) {
27498
+ headerParameters["X-Version"] = String(requestParameters["xVersion"]);
27499
+ }
27500
+ if (requestParameters["xUiPathInternalAccountId"] != null) {
27501
+ headerParameters["X-UiPath-Internal-AccountId"] = String(requestParameters["xUiPathInternalAccountId"]);
27502
+ }
27503
+ if (requestParameters["xUiPathInternalTenantId"] != null) {
27504
+ headerParameters["X-UiPath-Internal-TenantId"] = String(requestParameters["xUiPathInternalTenantId"]);
27505
+ }
27506
+ if (this.configuration && this.configuration.accessToken) {
27507
+ const token = this.configuration.accessToken;
27508
+ const tokenString = await token("Bearer", []);
27509
+ if (tokenString) {
27510
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
27511
+ }
27512
+ }
27513
+ let urlPath = `/Entities/{entityType}/Folders`;
27514
+ urlPath = urlPath.replace(`{${"entityType"}}`, encodeURIComponent(String(requestParameters["entityType"])));
27515
+ const response = await this.request({
27516
+ path: urlPath,
27517
+ method: "GET",
27518
+ headers: headerParameters,
27519
+ query: queryParameters
27520
+ }, initOverrides);
27521
+ return new JSONApiResponse(response, (jsonValue) => jsonValue.map(FolderDtoFromJSON));
27522
+ }
27523
+ async entitiesGetFolders(requestParameters, initOverrides) {
27524
+ const response = await this.entitiesGetFoldersRaw(requestParameters, initOverrides);
27525
+ return await response.value();
27526
+ }
27527
+ async entitiesGetPermissionsRaw(requestParameters, initOverrides) {
27528
+ if (requestParameters["entityType"] == null) {
27529
+ throw new RequiredError("entityType", 'Required parameter "entityType" was null or undefined when calling entitiesGetPermissions().');
27530
+ }
27531
+ if (requestParameters["xUiPathInternalAccountId"] == null) {
27532
+ throw new RequiredError("xUiPathInternalAccountId", 'Required parameter "xUiPathInternalAccountId" was null or undefined when calling entitiesGetPermissions().');
27533
+ }
27534
+ const queryParameters = {};
27535
+ if (requestParameters["apiVersion"] != null) {
27536
+ queryParameters["api-version"] = requestParameters["apiVersion"];
27537
+ }
27538
+ const headerParameters = {};
27539
+ if (requestParameters["xVersion"] != null) {
27540
+ headerParameters["X-Version"] = String(requestParameters["xVersion"]);
27541
+ }
27542
+ if (requestParameters["xUiPathInternalAccountId"] != null) {
27543
+ headerParameters["X-UiPath-Internal-AccountId"] = String(requestParameters["xUiPathInternalAccountId"]);
27544
+ }
27545
+ if (requestParameters["xUiPathInternalTenantId"] != null) {
27546
+ headerParameters["X-UiPath-Internal-TenantId"] = String(requestParameters["xUiPathInternalTenantId"]);
27547
+ }
27548
+ if (requestParameters["xUIPATHOrganizationUnitId"] != null) {
27549
+ headerParameters["X-UIPATH-OrganizationUnitId"] = String(requestParameters["xUIPATHOrganizationUnitId"]);
27550
+ }
27551
+ if (requestParameters["xUIPATHFolderPath"] != null) {
27552
+ headerParameters["X-UIPATH-FolderPath"] = String(requestParameters["xUIPATHFolderPath"]);
27553
+ }
27554
+ if (requestParameters["xUIPATHFolderPathEncoded"] != null) {
27555
+ headerParameters["X-UIPATH-FolderPath-Encoded"] = String(requestParameters["xUIPATHFolderPathEncoded"]);
27556
+ }
27557
+ if (requestParameters["xUIPATHFolderKey"] != null) {
27558
+ headerParameters["X-UIPATH-FolderKey"] = String(requestParameters["xUIPATHFolderKey"]);
27559
+ }
27560
+ if (this.configuration && this.configuration.accessToken) {
27561
+ const token = this.configuration.accessToken;
27562
+ const tokenString = await token("Bearer", []);
27563
+ if (tokenString) {
27564
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
27565
+ }
27566
+ }
27567
+ let urlPath = `/Entities/{entityType}/Permissions`;
27568
+ urlPath = urlPath.replace(`{${"entityType"}}`, encodeURIComponent(String(requestParameters["entityType"])));
27569
+ const response = await this.request({
27570
+ path: urlPath,
27571
+ method: "GET",
27572
+ headers: headerParameters,
27573
+ query: queryParameters
27574
+ }, initOverrides);
27575
+ return new JSONApiResponse(response);
27576
+ }
27577
+ async entitiesGetPermissions(requestParameters, initOverrides) {
27578
+ const response = await this.entitiesGetPermissionsRaw(requestParameters, initOverrides);
27579
+ return await response.value();
27580
+ }
27581
+ async entitiesSearchRaw(requestParameters, initOverrides) {
27582
+ if (requestParameters["xUiPathInternalAccountId"] == null) {
27583
+ throw new RequiredError("xUiPathInternalAccountId", 'Required parameter "xUiPathInternalAccountId" was null or undefined when calling entitiesSearch().');
27584
+ }
27585
+ const queryParameters = {};
27586
+ if (requestParameters["name"] != null) {
27587
+ queryParameters["name"] = requestParameters["name"];
27588
+ }
27589
+ if (requestParameters["skip"] != null) {
27590
+ queryParameters["skip"] = requestParameters["skip"];
27591
+ }
27592
+ if (requestParameters["take"] != null) {
27593
+ queryParameters["take"] = requestParameters["take"];
27594
+ }
27595
+ if (requestParameters["entityTypes"] != null) {
27596
+ queryParameters["entityTypes"] = requestParameters["entityTypes"];
27597
+ }
27598
+ if (requestParameters["entitySubType"] != null) {
27599
+ queryParameters["entitySubType"] = requestParameters["entitySubType"];
27600
+ }
27601
+ if (requestParameters["apiVersion"] != null) {
27602
+ queryParameters["api-version"] = requestParameters["apiVersion"];
27603
+ }
27604
+ const headerParameters = {};
27605
+ if (requestParameters["xVersion"] != null) {
27606
+ headerParameters["X-Version"] = String(requestParameters["xVersion"]);
27607
+ }
27608
+ if (requestParameters["xUiPathInternalAccountId"] != null) {
27609
+ headerParameters["X-UiPath-Internal-AccountId"] = String(requestParameters["xUiPathInternalAccountId"]);
27610
+ }
27611
+ if (requestParameters["xUiPathInternalTenantId"] != null) {
27612
+ headerParameters["X-UiPath-Internal-TenantId"] = String(requestParameters["xUiPathInternalTenantId"]);
27613
+ }
27614
+ if (requestParameters["xUIPATHOrganizationUnitId"] != null) {
27615
+ headerParameters["X-UIPATH-OrganizationUnitId"] = String(requestParameters["xUIPATHOrganizationUnitId"]);
27616
+ }
27617
+ if (requestParameters["xUIPATHFolderPath"] != null) {
27618
+ headerParameters["X-UIPATH-FolderPath"] = String(requestParameters["xUIPATHFolderPath"]);
27619
+ }
27620
+ if (requestParameters["xUIPATHFolderPathEncoded"] != null) {
27621
+ headerParameters["X-UIPATH-FolderPath-Encoded"] = String(requestParameters["xUIPATHFolderPathEncoded"]);
27622
+ }
27623
+ if (requestParameters["xUIPATHFolderKey"] != null) {
27624
+ headerParameters["X-UIPATH-FolderKey"] = String(requestParameters["xUIPATHFolderKey"]);
27625
+ }
27626
+ if (this.configuration && this.configuration.accessToken) {
27627
+ const token = this.configuration.accessToken;
27628
+ const tokenString = await token("Bearer", []);
27629
+ if (tokenString) {
27630
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
27631
+ }
27632
+ }
27633
+ let urlPath = `/Entities/Search`;
27634
+ const response = await this.request({
27635
+ path: urlPath,
27636
+ method: "GET",
27637
+ headers: headerParameters,
27638
+ query: queryParameters
27639
+ }, initOverrides);
27640
+ return new JSONApiResponse(response, (jsonValue) => EntityModelPaginationResultFromJSON(jsonValue));
27641
+ }
27642
+ async entitiesSearch(requestParameters, initOverrides) {
27643
+ const response = await this.entitiesSearchRaw(requestParameters, initOverrides);
27644
+ return await response.value();
27645
+ }
27646
+ async entitiesSearchFolderEntitiesRaw(requestParameters, initOverrides) {
27647
+ if (requestParameters["xUiPathInternalAccountId"] == null) {
27648
+ throw new RequiredError("xUiPathInternalAccountId", 'Required parameter "xUiPathInternalAccountId" was null or undefined when calling entitiesSearchFolderEntities().');
27649
+ }
27650
+ const queryParameters = {};
27651
+ if (requestParameters["name"] != null) {
27652
+ queryParameters["name"] = requestParameters["name"];
27653
+ }
27654
+ if (requestParameters["pageCursor"] != null) {
27655
+ queryParameters["pageCursor"] = requestParameters["pageCursor"];
27656
+ }
27657
+ if (requestParameters["pageSize"] != null) {
27658
+ queryParameters["pageSize"] = requestParameters["pageSize"];
27659
+ }
27660
+ if (requestParameters["entityTypes"] != null) {
27661
+ queryParameters["entityTypes"] = requestParameters["entityTypes"];
27662
+ }
27663
+ if (requestParameters["entitySubTypes"] != null) {
27664
+ queryParameters["entitySubTypes"] = requestParameters["entitySubTypes"];
27665
+ }
27666
+ if (requestParameters["folderTypes"] != null) {
27667
+ queryParameters["folderTypes"] = requestParameters["folderTypes"];
27668
+ }
27669
+ if (requestParameters["apiVersion"] != null) {
27670
+ queryParameters["api-version"] = requestParameters["apiVersion"];
27671
+ }
27672
+ const headerParameters = {};
27673
+ if (requestParameters["xVersion"] != null) {
27674
+ headerParameters["X-Version"] = String(requestParameters["xVersion"]);
27675
+ }
27676
+ if (requestParameters["xUiPathInternalAccountId"] != null) {
27677
+ headerParameters["X-UiPath-Internal-AccountId"] = String(requestParameters["xUiPathInternalAccountId"]);
27678
+ }
27679
+ if (requestParameters["xUiPathInternalTenantId"] != null) {
27680
+ headerParameters["X-UiPath-Internal-TenantId"] = String(requestParameters["xUiPathInternalTenantId"]);
27681
+ }
27682
+ if (this.configuration && this.configuration.accessToken) {
27683
+ const token = this.configuration.accessToken;
27684
+ const tokenString = await token("Bearer", []);
27685
+ if (tokenString) {
27686
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
27687
+ }
27688
+ }
27689
+ let urlPath = `/Entities/SearchFolderEntities`;
27690
+ const response = await this.request({
27691
+ path: urlPath,
27692
+ method: "GET",
27693
+ headers: headerParameters,
27694
+ query: queryParameters
27695
+ }, initOverrides);
27696
+ return new JSONApiResponse(response, (jsonValue) => FolderEntityModelCursorPaginationResultFromJSON(jsonValue));
27697
+ }
27698
+ async entitiesSearchFolderEntities(requestParameters, initOverrides) {
27699
+ const response = await this.entitiesSearchFolderEntitiesRaw(requestParameters, initOverrides);
27700
+ return await response.value();
26651
27701
  }
26652
- return {
26653
- labelKey: value["labelKey"],
26654
- values: value["values"],
26655
- accountKey: value["accountKey"],
26656
- tenantKey: value["tenantKey"],
26657
- userKey: value["userKey"]
26658
- };
26659
27702
  }
26660
27703
 
26661
27704
  // ../resourcecatalog-sdk/generated/src/apis/TagsApi.ts
@@ -27256,30 +28299,7 @@ class InvalidBaseUrlError extends Error {
27256
28299
  this.name = "InvalidBaseUrlError";
27257
28300
  }
27258
28301
  }
27259
- var DEFAULT_SCOPES = [
27260
- "offline_access",
27261
- "ProcessMining",
27262
- "OrchestratorApiUserAccess",
27263
- "StudioWebBackend",
27264
- "IdentityServerApi",
27265
- "ConnectionService",
27266
- "DataService",
27267
- "DataServiceApiUserAccess",
27268
- "DocumentUnderstanding",
27269
- "EnterpriseContextService",
27270
- "Directory",
27271
- "JamJamApi",
27272
- "LLMGateway",
27273
- "LLMOps",
27274
- "OMS",
27275
- "RCS.FolderAuthorization",
27276
- "RCS.TagsManagement",
27277
- "TestmanagerApiUserAccess",
27278
- "AutomationSolutions",
27279
- "StudioWebTypeCacheService",
27280
- "Docs.GPT.Search",
27281
- "Insights"
27282
- ];
28302
+ var DEFAULT_SCOPES = ["openid", "profile", "offline_access"];
27283
28303
  var normalizeAndValidateBaseUrl = (rawUrl) => {
27284
28304
  let baseUrl = rawUrl;
27285
28305
  if (baseUrl.endsWith("/identity_/")) {
@@ -27329,7 +28349,8 @@ var resolveConfigAsync = async ({
27329
28349
  if (!clientSecret && fileAuth.clientSecret) {
27330
28350
  clientSecret = fileAuth.clientSecret;
27331
28351
  }
27332
- const scopes = customScopes && customScopes.length > 0 ? customScopes : fileAuth.scopes && fileAuth.scopes.length > 0 ? fileAuth.scopes : DEFAULT_SCOPES;
28352
+ const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && Boolean(clientSecret);
28353
+ const scopes = customScopes && customScopes.length > 0 ? customScopes : fileAuth.scopes && fileAuth.scopes.length > 0 ? fileAuth.scopes : isExternalAppAuth ? [] : DEFAULT_SCOPES;
27333
28354
  return {
27334
28355
  clientId,
27335
28356
  clientSecret,
@@ -27417,6 +28438,7 @@ var getTokenExpiration = (accessToken) => {
27417
28438
 
27418
28439
  // ../../auth/src/envAuth.ts
27419
28440
  var ENV_AUTH_ENABLE_VAR = "UIPATH_CLI_ENABLE_ENV_AUTH";
28441
+ var ENFORCE_ROBOT_AUTH_VAR = "UIPATH_CLI_ENFORCE_ROBOT_AUTH";
27420
28442
  var ENV_AUTH_VARS = {
27421
28443
  token: "UIPATH_CLI_AUTH_TOKEN",
27422
28444
  organizationName: "UIPATH_CLI_ORGANIZATION_NAME",
@@ -27432,6 +28454,7 @@ class EnvAuthConfigError extends Error {
27432
28454
  }
27433
28455
  }
27434
28456
  var isEnvAuthEnabled = () => process.env[ENV_AUTH_ENABLE_VAR] === "true";
28457
+ var isRobotAuthEnforced = () => process.env[ENFORCE_ROBOT_AUTH_VAR] === "true";
27435
28458
  var requireEnv = (name) => {
27436
28459
  const value = process.env[name];
27437
28460
  if (!value) {
@@ -27473,7 +28496,9 @@ var readAuthFromEnv = () => {
27473
28496
  expiration
27474
28497
  };
27475
28498
  };
28499
+
27476
28500
  // ../../auth/src/robotClientFallback.ts
28501
+ init_src();
27477
28502
  var DEFAULT_TIMEOUT_MS = 1000;
27478
28503
  var CLOSE_TIMEOUT_MS = 500;
27479
28504
  var NOTICE_SENTINEL = Symbol.for("@uipath/auth/robotFallbackNoticePrinted");
@@ -27485,6 +28510,35 @@ var printNoticeOnce = () => {
27485
28510
  catchError2(() => process.stderr.write(`Using UiPath Robot credentials. Run 'uip login' for a dedicated session.
27486
28511
  `));
27487
28512
  };
28513
+ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
28514
+ var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
28515
+ var PIPE_NAME_MAX_LENGTH = 103;
28516
+ var getRobotIpcPipeNames = async () => {
28517
+ const fs7 = getFileSystem();
28518
+ const username = fs7.env.getenv("USER") ?? fs7.env.getenv("USERNAME");
28519
+ if (!username) {
28520
+ throw new Error("Unable to determine current username");
28521
+ }
28522
+ const tempPath = fs7.env.getenv("TMPDIR") ?? "/tmp/";
28523
+ return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs7.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
28524
+ };
28525
+ var defaultIsRobotIpcAvailable = async () => {
28526
+ if (process.platform === "win32") {
28527
+ return true;
28528
+ }
28529
+ const [pipeNamesError, pipeNames] = await catchError2(getRobotIpcPipeNames());
28530
+ if (pipeNamesError || !pipeNames) {
28531
+ return false;
28532
+ }
28533
+ const fs7 = getFileSystem();
28534
+ for (const pipeName of pipeNames) {
28535
+ const [existsError, exists] = await catchError2(fs7.exists(pipeName));
28536
+ if (!existsError && exists === true) {
28537
+ return true;
28538
+ }
28539
+ }
28540
+ return false;
28541
+ };
27488
28542
  var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
27489
28543
  const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
27490
28544
  promise.then((value) => {
@@ -27516,14 +28570,20 @@ var defaultLoadModule = async () => {
27516
28570
  var tryRobotClientFallback = async (options = {}) => {
27517
28571
  if (isBrowser())
27518
28572
  return;
27519
- if (process.env.CI || process.env.GITHUB_ACTIONS) {
27520
- return;
27521
- }
27522
- if (process.env.UIPATH_URL) {
27523
- return;
28573
+ if (!options.force) {
28574
+ if (process.env.CI || process.env.GITHUB_ACTIONS) {
28575
+ return;
28576
+ }
28577
+ if (process.env.UIPATH_URL) {
28578
+ return;
28579
+ }
27524
28580
  }
27525
28581
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
28582
+ const isRobotIpcAvailable = options.isRobotIpcAvailable ?? defaultIsRobotIpcAvailable;
27526
28583
  const loadModule = options.loadModule ?? defaultLoadModule;
28584
+ if (!await isRobotIpcAvailable()) {
28585
+ return;
28586
+ }
27527
28587
  const mod2 = await loadModule();
27528
28588
  if (!mod2)
27529
28589
  return;
@@ -27790,11 +28850,130 @@ function normalizeTokenRefreshFailure() {
27790
28850
  function normalizeTokenRefreshUnavailableFailure() {
27791
28851
  return "token refresh failed before authentication completed";
27792
28852
  }
27793
- var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
27794
- if (isEnvAuthEnabled()) {
27795
- return readAuthFromEnv();
28853
+ function errorMessage(error) {
28854
+ return error instanceof Error ? error.message : String(error);
28855
+ }
28856
+ function computeExpirationThreshold(ensureTokenValidityMinutes) {
28857
+ return new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
28858
+ }
28859
+ async function runRefreshLocked(inputs) {
28860
+ const {
28861
+ absolutePath,
28862
+ refreshToken: callerRefreshToken,
28863
+ customAuthority,
28864
+ ensureTokenValidityMinutes,
28865
+ loadEnvFile,
28866
+ saveEnvFile,
28867
+ refreshFn,
28868
+ resolveConfig
28869
+ } = inputs;
28870
+ const expirationThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
28871
+ let fresh;
28872
+ try {
28873
+ fresh = await loadEnvFile({ envPath: absolutePath });
28874
+ } catch (error) {
28875
+ return {
28876
+ kind: "fail",
28877
+ status: {
28878
+ loginStatus: "Refresh Failed",
28879
+ hint: "Could not read the auth file while refreshing. Retry, or run 'uip login' to re-authenticate.",
28880
+ tokenRefresh: {
28881
+ attempted: false,
28882
+ success: false,
28883
+ errorMessage: `auth file read failed: ${errorMessage(error)}`
28884
+ }
28885
+ }
28886
+ };
27796
28887
  }
27797
- const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
28888
+ const freshAccess = fresh.UIPATH_ACCESS_TOKEN;
28889
+ const freshExp = freshAccess ? getTokenExpiration(freshAccess) : undefined;
28890
+ if (freshAccess && freshExp && freshExp > expirationThreshold) {
28891
+ return {
28892
+ kind: "ok",
28893
+ accessToken: freshAccess,
28894
+ refreshToken: fresh.UIPATH_REFRESH_TOKEN ?? callerRefreshToken,
28895
+ expiration: freshExp,
28896
+ tokenRefresh: { attempted: false, success: true }
28897
+ };
28898
+ }
28899
+ const tokenForIdP = fresh.UIPATH_REFRESH_TOKEN ?? callerRefreshToken;
28900
+ let refreshedAccess;
28901
+ let refreshedRefresh;
28902
+ try {
28903
+ const config = await resolveConfig({ customAuthority });
28904
+ const refreshed = await refreshFn({
28905
+ refreshToken: tokenForIdP,
28906
+ tokenEndpoint: config.tokenEndpoint,
28907
+ clientId: config.clientId,
28908
+ expectedAuthority: customAuthority
28909
+ });
28910
+ refreshedAccess = refreshed.accessToken;
28911
+ refreshedRefresh = refreshed.refreshToken;
28912
+ } catch (error) {
28913
+ const isOAuthFailure = isTokenRefreshOAuthFailure(error);
28914
+ 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.";
28915
+ const message = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
28916
+ return {
28917
+ kind: "fail",
28918
+ status: {
28919
+ loginStatus: "Refresh Failed",
28920
+ hint,
28921
+ tokenRefresh: {
28922
+ attempted: true,
28923
+ success: false,
28924
+ errorMessage: message
28925
+ }
28926
+ }
28927
+ };
28928
+ }
28929
+ const refreshedExp = getTokenExpiration(refreshedAccess);
28930
+ if (!refreshedExp || refreshedExp <= new Date) {
28931
+ return {
28932
+ kind: "fail",
28933
+ status: {
28934
+ loginStatus: "Refresh Failed",
28935
+ hint: "The identity server returned an unusable token. Run 'uip login' to re-authenticate.",
28936
+ tokenRefresh: {
28937
+ attempted: true,
28938
+ success: false,
28939
+ errorMessage: "refreshed token has no valid expiration claim"
28940
+ }
28941
+ }
28942
+ };
28943
+ }
28944
+ try {
28945
+ await saveEnvFile({
28946
+ envPath: absolutePath,
28947
+ data: {
28948
+ UIPATH_ACCESS_TOKEN: refreshedAccess,
28949
+ UIPATH_REFRESH_TOKEN: refreshedRefresh
28950
+ },
28951
+ merge: true
28952
+ });
28953
+ return {
28954
+ kind: "ok",
28955
+ accessToken: refreshedAccess,
28956
+ refreshToken: refreshedRefresh,
28957
+ expiration: refreshedExp,
28958
+ tokenRefresh: { attempted: true, success: true }
28959
+ };
28960
+ } catch (error) {
28961
+ const msg = errorMessage(error);
28962
+ return {
28963
+ kind: "ok",
28964
+ accessToken: refreshedAccess,
28965
+ refreshToken: refreshedRefresh,
28966
+ expiration: refreshedExp,
28967
+ 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.`,
28968
+ tokenRefresh: {
28969
+ attempted: true,
28970
+ success: true,
28971
+ errorMessage: `persistence failed: ${msg}`
28972
+ }
28973
+ };
28974
+ }
28975
+ }
28976
+ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
27798
28977
  const {
27799
28978
  resolveEnvFilePath = resolveEnvFilePathAsync,
27800
28979
  loadEnvFile = loadEnvFileAsync,
@@ -27804,6 +28983,34 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
27804
28983
  resolveConfig = resolveConfigAsync,
27805
28984
  robotFallback = tryRobotClientFallback
27806
28985
  } = deps;
28986
+ if (isRobotAuthEnforced()) {
28987
+ if (isEnvAuthEnabled()) {
28988
+ throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
28989
+ }
28990
+ const robotCreds = await robotFallback({ force: true });
28991
+ if (!robotCreds) {
28992
+ return {
28993
+ loginStatus: "Not logged in",
28994
+ hint: `${ENFORCE_ROBOT_AUTH_VAR}=true but the UiPath Robot ` + `session is unavailable. Start and sign in to the Assistant, ` + `or unset ${ENFORCE_ROBOT_AUTH_VAR} to fall back to file or ` + `env-var authentication.`
28995
+ };
28996
+ }
28997
+ const expiration2 = getTokenExpiration(robotCreds.accessToken);
28998
+ return {
28999
+ loginStatus: "Logged in",
29000
+ accessToken: robotCreds.accessToken,
29001
+ baseUrl: robotCreds.baseUrl,
29002
+ organizationName: robotCreds.organizationName,
29003
+ organizationId: robotCreds.organizationId,
29004
+ tenantName: robotCreds.tenantName,
29005
+ tenantId: robotCreds.tenantId,
29006
+ expiration: expiration2,
29007
+ source: "robot" /* Robot */
29008
+ };
29009
+ }
29010
+ if (isEnvAuthEnabled()) {
29011
+ return readAuthFromEnv();
29012
+ }
29013
+ const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
27807
29014
  const { absolutePath } = await resolveEnvFilePath(envFilePath);
27808
29015
  if (absolutePath === undefined) {
27809
29016
  const robotCreds = await robotFallback();
@@ -27840,73 +29047,103 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
27840
29047
  let refreshToken = credentials.UIPATH_REFRESH_TOKEN;
27841
29048
  let expiration = getTokenExpiration(accessToken);
27842
29049
  let persistenceWarning;
29050
+ let lockReleaseFailed = false;
27843
29051
  let tokenRefresh;
27844
- const expirationThreshold = new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
27845
- if (expiration && expiration <= expirationThreshold && refreshToken) {
27846
- let refreshedAccess;
27847
- let refreshedRefresh;
29052
+ const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
29053
+ const tryGlobalCredsHint = async () => {
29054
+ const fs7 = getFs();
29055
+ const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
29056
+ if (absolutePath === globalPath)
29057
+ return;
29058
+ if (!await fs7.exists(globalPath))
29059
+ return;
27848
29060
  try {
27849
- const config = await resolveConfig({
27850
- customAuthority: credentials.UIPATH_URL
27851
- });
27852
- const refreshed = await refreshTokenFn({
27853
- refreshToken,
27854
- tokenEndpoint: config.tokenEndpoint,
27855
- clientId: config.clientId,
27856
- expectedAuthority: credentials.UIPATH_URL
27857
- });
27858
- refreshedAccess = refreshed.accessToken;
27859
- refreshedRefresh = refreshed.refreshToken;
27860
- } catch (error) {
27861
- const isOAuthFailure = isTokenRefreshOAuthFailure(error);
27862
- 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.";
27863
- const errorMessage = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
27864
- return {
27865
- loginStatus: "Refresh Failed",
27866
- hint,
27867
- tokenRefresh: {
27868
- attempted: true,
27869
- success: false,
27870
- errorMessage
27871
- }
27872
- };
29061
+ const globalCreds = await loadEnvFile({ envPath: globalPath });
29062
+ if (!globalCreds.UIPATH_ACCESS_TOKEN)
29063
+ return;
29064
+ const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
29065
+ if (globalExp && globalExp <= new Date)
29066
+ return;
29067
+ 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.`;
29068
+ } catch {
29069
+ return;
27873
29070
  }
27874
- const refreshedExp = getTokenExpiration(refreshedAccess);
27875
- if (!refreshedExp || refreshedExp <= new Date) {
29071
+ };
29072
+ if (expiration && expiration <= outerThreshold && refreshToken) {
29073
+ let release;
29074
+ try {
29075
+ release = await getFs().acquireLock(absolutePath);
29076
+ } catch (error) {
29077
+ const msg = errorMessage(error);
29078
+ const globalHint = await tryGlobalCredsHint();
29079
+ if (globalHint) {
29080
+ return {
29081
+ loginStatus: "Expired",
29082
+ accessToken,
29083
+ refreshToken,
29084
+ baseUrl: credentials.UIPATH_URL,
29085
+ organizationName: credentials.UIPATH_ORGANIZATION_NAME,
29086
+ organizationId: credentials.UIPATH_ORGANIZATION_ID,
29087
+ tenantName: credentials.UIPATH_TENANT_NAME,
29088
+ tenantId: credentials.UIPATH_TENANT_ID,
29089
+ expiration,
29090
+ source: "file" /* File */,
29091
+ hint: globalHint,
29092
+ tokenRefresh: {
29093
+ attempted: false,
29094
+ success: false,
29095
+ errorMessage: `lock acquisition failed: ${msg}`
29096
+ }
29097
+ };
29098
+ }
27876
29099
  return {
27877
29100
  loginStatus: "Refresh Failed",
27878
- hint: "The identity server returned an unusable token. Run 'uip login' to re-authenticate.",
29101
+ 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.",
27879
29102
  tokenRefresh: {
27880
- attempted: true,
29103
+ attempted: false,
27881
29104
  success: false,
27882
- errorMessage: "refreshed token has no valid expiration claim"
29105
+ errorMessage: `lock acquisition failed: ${msg}`
27883
29106
  }
27884
29107
  };
27885
29108
  }
27886
- accessToken = refreshedAccess;
27887
- refreshToken = refreshedRefresh;
27888
- expiration = refreshedExp;
29109
+ let lockedFailure;
27889
29110
  try {
27890
- await saveEnvFile({
27891
- envPath: absolutePath,
27892
- data: {
27893
- UIPATH_ACCESS_TOKEN: accessToken,
27894
- UIPATH_REFRESH_TOKEN: refreshToken
27895
- },
27896
- merge: true
29111
+ const outcome = await runRefreshLocked({
29112
+ absolutePath,
29113
+ refreshToken,
29114
+ customAuthority: credentials.UIPATH_URL,
29115
+ ensureTokenValidityMinutes,
29116
+ loadEnvFile,
29117
+ saveEnvFile,
29118
+ refreshFn: refreshTokenFn,
29119
+ resolveConfig
27897
29120
  });
27898
- tokenRefresh = {
27899
- attempted: true,
27900
- success: true
27901
- };
27902
- } catch (error) {
27903
- const msg = error instanceof Error ? error.message : String(error);
27904
- 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.`;
27905
- tokenRefresh = {
27906
- attempted: true,
27907
- success: true,
27908
- errorMessage: `persistence failed: ${msg}`
27909
- };
29121
+ if (outcome.kind === "fail") {
29122
+ lockedFailure = outcome.status;
29123
+ } else {
29124
+ accessToken = outcome.accessToken;
29125
+ refreshToken = outcome.refreshToken;
29126
+ expiration = outcome.expiration;
29127
+ tokenRefresh = outcome.tokenRefresh;
29128
+ if (outcome.persistenceWarning) {
29129
+ persistenceWarning = outcome.persistenceWarning;
29130
+ }
29131
+ }
29132
+ } finally {
29133
+ try {
29134
+ await release();
29135
+ } catch {
29136
+ lockReleaseFailed = true;
29137
+ }
29138
+ }
29139
+ if (lockedFailure) {
29140
+ const globalHint = await tryGlobalCredsHint();
29141
+ const base = globalHint ? {
29142
+ ...lockedFailure,
29143
+ loginStatus: "Expired",
29144
+ hint: globalHint
29145
+ } : lockedFailure;
29146
+ return lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base;
27910
29147
  }
27911
29148
  }
27912
29149
  const result = {
@@ -27921,23 +29158,13 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
27921
29158
  expiration,
27922
29159
  source: "file" /* File */,
27923
29160
  ...persistenceWarning ? { hint: persistenceWarning, persistenceFailed: true } : {},
29161
+ ...lockReleaseFailed ? { lockReleaseFailed: true } : {},
27924
29162
  ...tokenRefresh ? { tokenRefresh } : {}
27925
29163
  };
27926
29164
  if (result.loginStatus === "Expired") {
27927
- const fs7 = getFs();
27928
- const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
27929
- if (absolutePath !== globalPath && await fs7.exists(globalPath)) {
27930
- try {
27931
- const globalCreds = await loadEnvFile({
27932
- envPath: globalPath
27933
- });
27934
- if (globalCreds.UIPATH_ACCESS_TOKEN) {
27935
- const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
27936
- if (!globalExp || globalExp > new Date) {
27937
- 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.`;
27938
- }
27939
- }
27940
- } catch {}
29165
+ const globalHint = await tryGlobalCredsHint();
29166
+ if (globalHint) {
29167
+ result.hint = globalHint;
27941
29168
  }
27942
29169
  }
27943
29170
  return result;
@@ -27954,6 +29181,10 @@ var getLoginStatusAsync = async (options = {}) => {
27954
29181
  init_src();
27955
29182
  // ../../auth/src/logout.ts
27956
29183
  init_src();
29184
+
29185
+ // ../../auth/src/index.ts
29186
+ init_server();
29187
+
27957
29188
  // ../resourcecatalog-sdk/src/client-factory.ts
27958
29189
  async function resolveConfig(options) {
27959
29190
  const status = await getLoginStatusAsync({
@@ -27967,14 +29198,15 @@ async function resolveConfig(options) {
27967
29198
  }
27968
29199
  const tenant = options?.tenantName ?? status.tenantName;
27969
29200
  if (!tenant) {
27970
- throw new Error("Tenant not available. Pass --tenant <name> or log in with a tenant context.");
29201
+ throw new Error("Tenant not available. Run 'uip login' to select a tenant, or use 'uip login tenant set <tenant>' to switch tenants.");
27971
29202
  }
27972
29203
  const basePath = `${status.baseUrl}/${status.organizationId}/${tenant}/resourcecatalog_`;
27973
29204
  const bearerToken = options?.s2sToken ?? status.accessToken;
27974
29205
  return {
27975
29206
  config: new Configuration({
27976
29207
  basePath,
27977
- accessToken: async () => bearerToken
29208
+ accessToken: async () => bearerToken,
29209
+ headers: addSdkUserAgentHeader(undefined, SDK_USER_AGENT)
27978
29210
  }),
27979
29211
  organizationId: status.organizationId,
27980
29212
  tenantName: tenant
@@ -27988,8 +29220,114 @@ async function createApiClient(ApiClass, options) {
27988
29220
  tenantName
27989
29221
  };
27990
29222
  }
29223
+ // src/commands/search.ts
29224
+ import { Option as Option2 } from "commander";
29225
+ var LOGIN_INSTRUCTIONS = "Ensure you are logged in with 'uip login' and have access to the Resource Catalog service.";
29226
+ var SEARCH_EXAMPLES = [
29227
+ {
29228
+ Description: "Search RCS Process entities by entitySubType (matches the Orchestrator UI Add-Tool picker)",
29229
+ Command: "uip admin rcs search --entity-type Process --entity-sub-type ProcessOrchestration --limit 8",
29230
+ Output: {
29231
+ Code: "RcsSearch",
29232
+ Data: {
29233
+ items: [
29234
+ {
29235
+ entityKey: "entity-guid",
29236
+ name: "Sample Orchestrator",
29237
+ entityType: "Process",
29238
+ entitySubType: "ProcessOrchestration"
29239
+ }
29240
+ ],
29241
+ count: 1
29242
+ }
29243
+ }
29244
+ },
29245
+ {
29246
+ Description: "Search across one folder by key",
29247
+ Command: "uip admin rcs search --entity-type Process --folder-key 11111111-1111-1111-1111-111111111111",
29248
+ Output: {
29249
+ Code: "RcsSearch",
29250
+ Data: { items: [], count: 0 }
29251
+ }
29252
+ }
29253
+ ];
29254
+ var registerSearchCommands = (rcs) => {
29255
+ rcs.command("search").description([
29256
+ "Search Resource Catalog entities (RCS GET /Entities/Search).",
29257
+ "",
29258
+ "Filters: --entity-type, --entity-sub-type (each repeatable),",
29259
+ "--name (substring on entity name), --folder-key/--folder-path",
29260
+ "(sent as X-UIPATH-FolderKey/X-UIPATH-FolderPath headers).",
29261
+ "",
29262
+ "Returns the standard paging envelope {items, total, count, next}."
29263
+ ].join(`
29264
+ `)).addOption(createHiddenDeprecatedTenantOption("--tenant <name>")).option("--entity-type <value>", "RCS entityTypes filter entry. Repeat to pass multiple values (e.g. --entity-type Process).", (value, previous = []) => [...previous, value]).option("--entity-sub-type <value>", "RCS entitySubType filter entry. Repeat to pass multiple values (e.g. --entity-sub-type ProcessOrchestration).", (value, previous = []) => [...previous, value]).option("--name <text>", "Substring filter on entity name (RCS `name` query param).").option("--folder-key <guid>", "Folder GUID to scope the call (sets X-UIPATH-FolderKey).").option("--folder-path <path>", "Folder path to scope the call (sets X-UIPATH-FolderPath).").option("--limit <n>", `Page size. Maps to RCS take. Defaults to ${DEFAULT_PAGE_SIZE}.`, (v) => Number.parseInt(v, 10)).option("--offset <n>", "Row offset. Maps to RCS skip. Defaults to 0.", (v) => Number.parseInt(v, 10)).addOption(new Option2("--skip <n>").hideHelp().argParser((v) => Number.parseInt(v, 10))).option("--login-validity <minutes>", "Override the interactive-login token lifetime for this call. Rarely needed.", (v) => Number.parseInt(v, 10)).examples(SEARCH_EXAMPLES).trackedAction(processContext, async (options) => {
29265
+ const offset = resolveDeprecatedOptionAlias({
29266
+ preferredValue: options.offset,
29267
+ deprecatedValue: options.skip,
29268
+ preferredFlag: "--offset",
29269
+ deprecatedFlag: "--skip"
29270
+ });
29271
+ if (offset.error) {
29272
+ OutputFormatter.error({
29273
+ Result: RESULTS.Failure,
29274
+ Message: offset.error.message,
29275
+ Instructions: offset.error.instructions
29276
+ });
29277
+ processContext.exit(1);
29278
+ return;
29279
+ }
29280
+ if (offset.usedDeprecated) {
29281
+ warnDeprecatedOptionAlias("--skip", "--offset");
29282
+ }
29283
+ const resolvedOffset = offset.value ?? 0;
29284
+ const resolvedLimit = options.limit ?? DEFAULT_PAGE_SIZE;
29285
+ const [error, result] = await catchError((async () => {
29286
+ const { api, organizationId } = await createApiClient(EntitiesApi, {
29287
+ loginValidity: options.loginValidity,
29288
+ tenantName: options.tenant
29289
+ });
29290
+ return await api.entitiesSearch({
29291
+ xUiPathInternalAccountId: organizationId,
29292
+ name: options.name,
29293
+ skip: resolvedOffset,
29294
+ take: resolvedLimit,
29295
+ entityTypes: options.entityType,
29296
+ entitySubType: options.entitySubType,
29297
+ xUIPATHFolderKey: options.folderKey,
29298
+ xUIPATHFolderPath: options.folderPath
29299
+ });
29300
+ })());
29301
+ if (error) {
29302
+ OutputFormatter.error({
29303
+ Result: RESULTS.Failure,
29304
+ Message: await extractErrorMessage(error),
29305
+ Instructions: LOGIN_INSTRUCTIONS
29306
+ });
29307
+ processContext.exit(1);
29308
+ return;
29309
+ }
29310
+ const items = result?.value ?? [];
29311
+ const total = result?.count;
29312
+ const count = items.length;
29313
+ const nextSkip = resolvedOffset + count;
29314
+ const next = typeof total === "number" && nextSkip < total ? { skip: nextSkip, take: resolvedLimit } : undefined;
29315
+ OutputFormatter.success({
29316
+ Result: RESULTS.Success,
29317
+ Code: "RcsSearch",
29318
+ Data: {
29319
+ items,
29320
+ total,
29321
+ count,
29322
+ ...next ? { next } : {}
29323
+ }
29324
+ });
29325
+ });
29326
+ };
29327
+
27991
29328
  // src/commands/tag.ts
27992
- var LOGIN_INSTRUCTIONS = "Ensure you are logged in with 'uip login' and have access to the Resource Catalog service. If you see 'Invalid scope(s)', re-run 'uip login' to pick up the RCS.Tags scope.";
29329
+ import { Option as Option3 } from "commander";
29330
+ var LOGIN_INSTRUCTIONS2 = "Ensure you are logged in with 'uip login' and have access to the Resource Catalog service. If you see 'Invalid scope(s)', re-run 'uip login' to pick up the RCS.Tags scope.";
27993
29331
  var LIST_EXAMPLES = [
27994
29332
  {
27995
29333
  Description: "List all Label tags for the current tenant",
@@ -28031,11 +29369,29 @@ var registerTagCommands = (rcs) => {
28031
29369
  "List tags for a tenant in the current organization.",
28032
29370
  "",
28033
29371
  "By default returns TagType.Label tags for the tenant in your login context.",
28034
- "Pass --tenant <name> to target a different tenant in the same organization",
29372
+ "Use 'uip login tenant set <tenant>' to target a different tenant in the same organization",
28035
29373
  "(your account must have RCS access to that tenant). Use --type KeyValue",
28036
29374
  "for key/value tags, or --starts-with to filter by name prefix."
28037
29375
  ].join(`
28038
- `)).option("--tenant <name>", "Target tenant name. Defaults to the tenant in your login context.").option("--type <type>", "Tag type to list: 'Label' (default) or 'KeyValue'. Case-sensitive.", "Label").option("--starts-with <prefix>", "Return only tags whose normalized name starts with this prefix (case-insensitive).").option("--limit <n>", "Page size — how many tags to return in one call. Defaults to 100.", (v) => Number.parseInt(v, 10), 100).option("--skip <n>", "Row offset into the result set. Defaults to 0.", (v) => Number.parseInt(v, 10), 0).option("--login-validity <minutes>", "Override the interactive-login token lifetime for this call. Rarely needed.", (v) => Number.parseInt(v, 10)).examples(LIST_EXAMPLES).trackedAction(processContext, async (options) => {
29376
+ `)).addOption(createHiddenDeprecatedTenantOption("--tenant <name>")).option("--type <type>", "Tag type to list: 'Label' (default) or 'KeyValue'. Case-sensitive.", "Label").option("--starts-with <prefix>", "Return only tags whose normalized name starts with this prefix (case-insensitive).").option("--limit <n>", "Page size — how many tags to return in one call. Defaults to 100.", (v) => Number.parseInt(v, 10), 100).option("--offset <n>", "Row offset into the result set. Defaults to 0.", (v) => Number.parseInt(v, 10)).addOption(new Option3("--skip <n>").hideHelp().argParser((v) => Number.parseInt(v, 10))).option("--login-validity <minutes>", "Override the interactive-login token lifetime for this call. Rarely needed.", (v) => Number.parseInt(v, 10)).examples(LIST_EXAMPLES).trackedAction(processContext, async (options) => {
29377
+ const offset = resolveDeprecatedOptionAlias({
29378
+ preferredValue: options.offset,
29379
+ deprecatedValue: options.skip,
29380
+ preferredFlag: "--offset",
29381
+ deprecatedFlag: "--skip"
29382
+ });
29383
+ if (offset.error) {
29384
+ OutputFormatter.error({
29385
+ Result: RESULTS.Failure,
29386
+ Message: offset.error.message,
29387
+ Instructions: offset.error.instructions
29388
+ });
29389
+ processContext.exit(1);
29390
+ return;
29391
+ }
29392
+ if (offset.usedDeprecated) {
29393
+ warnDeprecatedOptionAlias("--skip", "--offset");
29394
+ }
28039
29395
  const [error, result] = await catchError((async () => {
28040
29396
  if (options.type !== TagType.Label && options.type !== TagType.KeyValue) {
28041
29397
  throw new Error(`Invalid --type '${options.type}'. Use 'Label' or 'KeyValue'.`);
@@ -28049,14 +29405,14 @@ var registerTagCommands = (rcs) => {
28049
29405
  type: options.type,
28050
29406
  startsWith: options.startsWith,
28051
29407
  take: options.limit,
28052
- skip: options.skip
29408
+ skip: offset.value ?? 0
28053
29409
  });
28054
29410
  })());
28055
29411
  if (error) {
28056
29412
  OutputFormatter.error({
28057
29413
  Result: RESULTS.Failure,
28058
29414
  Message: await extractErrorMessage(error),
28059
- Instructions: LOGIN_INSTRUCTIONS
29415
+ Instructions: LOGIN_INSTRUCTIONS2
28060
29416
  });
28061
29417
  processContext.exit(1);
28062
29418
  return;
@@ -28075,9 +29431,11 @@ var registerRcsCommand = (program) => {
28075
29431
  "Manage UiPath Resource Catalog Service resources.",
28076
29432
  "",
28077
29433
  "Subcommand groups:",
29434
+ " search — search tenant- or folder-scoped RCS entities.",
28078
29435
  " tag — list tenant-scoped tags."
28079
29436
  ].join(`
28080
29437
  `));
29438
+ registerSearchCommands(rcs);
28081
29439
  registerTagCommands(rcs);
28082
29440
  };
28083
29441