@uipath/tasks-tool 1.1.0 → 1.195.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tool.js CHANGED
@@ -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,9 +878,13 @@ 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
  });
@@ -2941,7 +3030,7 @@ function isBrowser() {
2941
3030
 
2942
3031
  // ../../node_modules/@uipath/coreipc/index.js
2943
3032
  var require_coreipc = __commonJS((exports, module) => {
2944
- var __dirname = "/Users/alexandru.oltean/github/cli/node_modules/@uipath/coreipc";
3033
+ var __dirname = "/home/runner/work/cli/cli/node_modules/@uipath/coreipc";
2945
3034
  /*! For license information please see index.js.LICENSE.txt */
2946
3035
  (function(e, t) {
2947
3036
  typeof exports == "object" && typeof module == "object" ? module.exports = t() : typeof define == "function" && define.amd ? define([], t) : typeof exports == "object" ? exports.ipc = t() : e.ipc = t();
@@ -21133,6 +21222,10 @@ var require_dist = __commonJS((exports) => {
21133
21222
  exports.RobotProxyConstructor = RobotProxyConstructor;
21134
21223
  __exportStar(require_agent(), exports);
21135
21224
  });
21225
+ // ../auth/src/server.ts
21226
+ var init_server = __esm(() => {
21227
+ init_constants();
21228
+ });
21136
21229
 
21137
21230
  // ../../node_modules/@opentelemetry/api/build/src/version.js
21138
21231
  var require_version = __commonJS((exports) => {
@@ -22614,7 +22707,7 @@ var require_src = __commonJS((exports) => {
22614
22707
  };
22615
22708
  });
22616
22709
 
22617
- // ../../node_modules/@opentelemetry/api-logs/build/src/types/LogRecord.js
22710
+ // ../../node_modules/@opentelemetry/sdk-logs/node_modules/@opentelemetry/api-logs/build/src/types/LogRecord.js
22618
22711
  var require_LogRecord = __commonJS((exports) => {
22619
22712
  Object.defineProperty(exports, "__esModule", { value: true });
22620
22713
  exports.SeverityNumber = undefined;
@@ -22648,7 +22741,7 @@ var require_LogRecord = __commonJS((exports) => {
22648
22741
  })(SeverityNumber = exports.SeverityNumber || (exports.SeverityNumber = {}));
22649
22742
  });
22650
22743
 
22651
- // ../../node_modules/@opentelemetry/api-logs/build/src/NoopLogger.js
22744
+ // ../../node_modules/@opentelemetry/sdk-logs/node_modules/@opentelemetry/api-logs/build/src/NoopLogger.js
22652
22745
  var require_NoopLogger = __commonJS((exports) => {
22653
22746
  Object.defineProperty(exports, "__esModule", { value: true });
22654
22747
  exports.NOOP_LOGGER = exports.NoopLogger = undefined;
@@ -22660,7 +22753,7 @@ var require_NoopLogger = __commonJS((exports) => {
22660
22753
  exports.NOOP_LOGGER = new NoopLogger;
22661
22754
  });
22662
22755
 
22663
- // ../../node_modules/@opentelemetry/api-logs/build/src/NoopLoggerProvider.js
22756
+ // ../../node_modules/@opentelemetry/sdk-logs/node_modules/@opentelemetry/api-logs/build/src/NoopLoggerProvider.js
22664
22757
  var require_NoopLoggerProvider = __commonJS((exports) => {
22665
22758
  Object.defineProperty(exports, "__esModule", { value: true });
22666
22759
  exports.NOOP_LOGGER_PROVIDER = exports.NoopLoggerProvider = undefined;
@@ -22675,7 +22768,7 @@ var require_NoopLoggerProvider = __commonJS((exports) => {
22675
22768
  exports.NOOP_LOGGER_PROVIDER = new NoopLoggerProvider;
22676
22769
  });
22677
22770
 
22678
- // ../../node_modules/@opentelemetry/api-logs/build/src/ProxyLogger.js
22771
+ // ../../node_modules/@opentelemetry/sdk-logs/node_modules/@opentelemetry/api-logs/build/src/ProxyLogger.js
22679
22772
  var require_ProxyLogger = __commonJS((exports) => {
22680
22773
  Object.defineProperty(exports, "__esModule", { value: true });
22681
22774
  exports.ProxyLogger = undefined;
@@ -22706,7 +22799,7 @@ var require_ProxyLogger = __commonJS((exports) => {
22706
22799
  exports.ProxyLogger = ProxyLogger;
22707
22800
  });
22708
22801
 
22709
- // ../../node_modules/@opentelemetry/api-logs/build/src/ProxyLoggerProvider.js
22802
+ // ../../node_modules/@opentelemetry/sdk-logs/node_modules/@opentelemetry/api-logs/build/src/ProxyLoggerProvider.js
22710
22803
  var require_ProxyLoggerProvider = __commonJS((exports) => {
22711
22804
  Object.defineProperty(exports, "__esModule", { value: true });
22712
22805
  exports.ProxyLoggerProvider = undefined;
@@ -22733,14 +22826,14 @@ var require_ProxyLoggerProvider = __commonJS((exports) => {
22733
22826
  exports.ProxyLoggerProvider = ProxyLoggerProvider;
22734
22827
  });
22735
22828
 
22736
- // ../../node_modules/@opentelemetry/api-logs/build/src/platform/node/globalThis.js
22829
+ // ../../node_modules/@opentelemetry/sdk-logs/node_modules/@opentelemetry/api-logs/build/src/platform/node/globalThis.js
22737
22830
  var require_globalThis = __commonJS((exports) => {
22738
22831
  Object.defineProperty(exports, "__esModule", { value: true });
22739
22832
  exports._globalThis = undefined;
22740
22833
  exports._globalThis = typeof globalThis === "object" ? globalThis : global;
22741
22834
  });
22742
22835
 
22743
- // ../../node_modules/@opentelemetry/api-logs/build/src/platform/node/index.js
22836
+ // ../../node_modules/@opentelemetry/sdk-logs/node_modules/@opentelemetry/api-logs/build/src/platform/node/index.js
22744
22837
  var require_node = __commonJS((exports) => {
22745
22838
  Object.defineProperty(exports, "__esModule", { value: true });
22746
22839
  exports._globalThis = undefined;
@@ -22750,7 +22843,7 @@ var require_node = __commonJS((exports) => {
22750
22843
  } });
22751
22844
  });
22752
22845
 
22753
- // ../../node_modules/@opentelemetry/api-logs/build/src/platform/index.js
22846
+ // ../../node_modules/@opentelemetry/sdk-logs/node_modules/@opentelemetry/api-logs/build/src/platform/index.js
22754
22847
  var require_platform = __commonJS((exports) => {
22755
22848
  Object.defineProperty(exports, "__esModule", { value: true });
22756
22849
  exports._globalThis = undefined;
@@ -22760,7 +22853,7 @@ var require_platform = __commonJS((exports) => {
22760
22853
  } });
22761
22854
  });
22762
22855
 
22763
- // ../../node_modules/@opentelemetry/api-logs/build/src/internal/global-utils.js
22856
+ // ../../node_modules/@opentelemetry/sdk-logs/node_modules/@opentelemetry/api-logs/build/src/internal/global-utils.js
22764
22857
  var require_global_utils2 = __commonJS((exports) => {
22765
22858
  Object.defineProperty(exports, "__esModule", { value: true });
22766
22859
  exports.API_BACKWARDS_COMPATIBILITY_VERSION = exports.makeGetter = exports._global = exports.GLOBAL_LOGS_API_KEY = undefined;
@@ -22774,7 +22867,7 @@ var require_global_utils2 = __commonJS((exports) => {
22774
22867
  exports.API_BACKWARDS_COMPATIBILITY_VERSION = 1;
22775
22868
  });
22776
22869
 
22777
- // ../../node_modules/@opentelemetry/api-logs/build/src/api/logs.js
22870
+ // ../../node_modules/@opentelemetry/sdk-logs/node_modules/@opentelemetry/api-logs/build/src/api/logs.js
22778
22871
  var require_logs = __commonJS((exports) => {
22779
22872
  Object.defineProperty(exports, "__esModule", { value: true });
22780
22873
  exports.LogsAPI = undefined;
@@ -22815,7 +22908,7 @@ var require_logs = __commonJS((exports) => {
22815
22908
  exports.LogsAPI = LogsAPI;
22816
22909
  });
22817
22910
 
22818
- // ../../node_modules/@opentelemetry/api-logs/build/src/index.js
22911
+ // ../../node_modules/@opentelemetry/sdk-logs/node_modules/@opentelemetry/api-logs/build/src/index.js
22819
22912
  var require_src2 = __commonJS((exports) => {
22820
22913
  Object.defineProperty(exports, "__esModule", { value: true });
22821
22914
  exports.logs = exports.ProxyLoggerProvider = exports.ProxyLogger = exports.NoopLoggerProvider = exports.NOOP_LOGGER_PROVIDER = exports.NoopLogger = exports.NOOP_LOGGER = exports.SeverityNumber = undefined;
@@ -27069,7 +27162,8 @@ var require_src6 = __commonJS((exports) => {
27069
27162
  // package.json
27070
27163
  var package_default = {
27071
27164
  name: "@uipath/tasks-tool",
27072
- version: "1.1.0",
27165
+ license: "MIT",
27166
+ version: "1.195.0",
27073
27167
  description: "Manage Action Center tasks.",
27074
27168
  type: "module",
27075
27169
  main: "./dist/tool.js",
@@ -27090,7 +27184,7 @@ var package_default = {
27090
27184
  "@types/node": "^25.5.2",
27091
27185
  "@uipath/auth": "workspace:*",
27092
27186
  "@uipath/common": "workspace:*",
27093
- "@uipath/uipath-typescript": "^1.3.7",
27187
+ "@uipath/uipath-typescript": "^1.3.11",
27094
27188
  commander: "^14.0.3",
27095
27189
  typescript: "^6.0.2"
27096
27190
  }
@@ -27233,10 +27327,15 @@ async function extractErrorDetails(error, options) {
27233
27327
  }
27234
27328
  if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
27235
27329
  context.errorCode = parsedBody.errorCode;
27330
+ } else if (parsedBody?.code && typeof parsedBody.code === "string") {
27331
+ context.errorCode = parsedBody.code;
27236
27332
  }
27237
27333
  if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
27238
27334
  context.requestId = parsedBody.requestId;
27239
27335
  }
27336
+ if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
27337
+ context.traceId = parsedBody.traceId;
27338
+ }
27240
27339
  if (status === 429) {
27241
27340
  const resp = response;
27242
27341
  const headersObj = resp?.headers;
@@ -27256,7 +27355,35 @@ async function extractErrorDetails(error, options) {
27256
27355
  }
27257
27356
  }
27258
27357
  const hasContext = Object.keys(context).length > 0;
27259
- return { result, message, details, ...hasContext ? { context } : {} };
27358
+ let parsedErrors;
27359
+ if (parsedBody?.errors && typeof parsedBody.errors === "object") {
27360
+ const errors = {};
27361
+ for (const [field, raw] of Object.entries(parsedBody.errors)) {
27362
+ if (Array.isArray(raw)) {
27363
+ const messages = raw.map((entry) => {
27364
+ if (typeof entry === "string")
27365
+ return entry;
27366
+ if (entry && typeof entry === "object" && typeof entry.message === "string") {
27367
+ return entry.message;
27368
+ }
27369
+ return String(entry);
27370
+ }).filter(Boolean);
27371
+ if (messages.length > 0)
27372
+ errors[field] = messages;
27373
+ } else if (typeof raw === "string") {
27374
+ errors[field] = [raw];
27375
+ }
27376
+ }
27377
+ if (Object.keys(errors).length > 0)
27378
+ parsedErrors = errors;
27379
+ }
27380
+ return {
27381
+ result,
27382
+ message,
27383
+ details,
27384
+ ...hasContext ? { context } : {},
27385
+ ...parsedErrors ? { parsedErrors } : {}
27386
+ };
27260
27387
  }
27261
27388
  async function extractErrorMessage(error, options) {
27262
27389
  const { message } = await extractErrorDetails(error, options);
@@ -32417,6 +32544,60 @@ function escapeNonAscii(jsonText) {
32417
32544
  function needsAsciiSafeJson(sink) {
32418
32545
  return process.platform === "win32" && !sink.capabilities.isInteractive;
32419
32546
  }
32547
+ function isPlainRecord(value) {
32548
+ if (value === null || typeof value !== "object")
32549
+ return false;
32550
+ const prototype = Object.getPrototypeOf(value);
32551
+ return prototype === Object.prototype || prototype === null;
32552
+ }
32553
+ function toLowerCamelCaseKey(key) {
32554
+ if (!key)
32555
+ return key;
32556
+ if (/[_\-\s]/.test(key)) {
32557
+ const [firstPart, ...restParts] = key.split(/[_\-\s]+/).filter(Boolean);
32558
+ if (!firstPart)
32559
+ return key;
32560
+ return [
32561
+ toLowerCamelCaseSimpleKey(firstPart),
32562
+ ...restParts.map((part) => {
32563
+ const normalized = toLowerCamelCaseSimpleKey(part);
32564
+ return normalized.charAt(0).toUpperCase() + normalized.slice(1);
32565
+ })
32566
+ ].join("");
32567
+ }
32568
+ return toLowerCamelCaseSimpleKey(key);
32569
+ }
32570
+ function toLowerCamelCaseSimpleKey(key) {
32571
+ if (/^[A-Z0-9]+$/.test(key))
32572
+ return key.toLowerCase();
32573
+ return key.replace(/^[A-Z]+(?=[A-Z][a-z]|\d|$)|^[A-Z]/, (match) => match.toLowerCase());
32574
+ }
32575
+ function toPascalCaseKey(key) {
32576
+ const lowerCamelKey = toLowerCamelCaseKey(key);
32577
+ return lowerCamelKey ? lowerCamelKey.charAt(0).toUpperCase() + lowerCamelKey.slice(1) : lowerCamelKey;
32578
+ }
32579
+ function toPascalCaseData(value) {
32580
+ if (Array.isArray(value))
32581
+ return value.map(toPascalCaseData);
32582
+ if (!isPlainRecord(value))
32583
+ return value;
32584
+ const result = {};
32585
+ for (const [key, nestedValue] of Object.entries(value)) {
32586
+ result[toPascalCaseKey(key)] = toPascalCaseData(nestedValue);
32587
+ }
32588
+ return result;
32589
+ }
32590
+ function normalizeDataKeys(data) {
32591
+ return toPascalCaseData(data);
32592
+ }
32593
+ function normalizeOutputKeys(data) {
32594
+ const result = {};
32595
+ for (const [key, value] of Object.entries(data)) {
32596
+ const pascalKey = toPascalCaseKey(key);
32597
+ result[pascalKey] = pascalKey === "Data" ? value : toPascalCaseData(value);
32598
+ }
32599
+ return result;
32600
+ }
32420
32601
  function printOutput(data, format = "json", logFn, asciiSafe = false) {
32421
32602
  if (!data) {
32422
32603
  logFn("Empty response object. No data to display.");
@@ -32479,7 +32660,7 @@ function wrapText(text, width) {
32479
32660
  function printTable(data, logFn, externalLogValue) {
32480
32661
  if (data.length === 0)
32481
32662
  return;
32482
- const keys = Object.keys(data[0]).filter((key) => key !== "Code" && key !== "Log");
32663
+ const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
32483
32664
  const maxWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
32484
32665
  const header = keys.map((key, i2) => key.padEnd(maxWidths[i2])).join(" | ");
32485
32666
  logFn(header);
@@ -32494,7 +32675,7 @@ function printTable(data, logFn, externalLogValue) {
32494
32675
  }
32495
32676
  }
32496
32677
  function printVerticalTable(data, logFn = console.log, externalLogValue) {
32497
- const keys = Object.keys(data).filter((key) => key !== "Code" && key !== "Log");
32678
+ const keys = Object.keys(data).filter((key) => !["code", "log"].includes(key.toLowerCase()));
32498
32679
  if (keys.length === 0)
32499
32680
  return;
32500
32681
  const maxKeyWidth = Math.max(...keys.map((key) => key.length));
@@ -32510,7 +32691,7 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
32510
32691
  function printResizableTable(data, logFn = console.log, externalLogValue) {
32511
32692
  if (data.length === 0)
32512
32693
  return;
32513
- const keys = Object.keys(data[0]).filter((key) => key !== "Code" && key !== "Log");
32694
+ const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
32514
32695
  if (keys.length === 0)
32515
32696
  return;
32516
32697
  if (!process.stdout.isTTY) {
@@ -32586,8 +32767,26 @@ function printResizableTable(data, logFn = console.log, externalLogValue) {
32586
32767
  function toYaml(data) {
32587
32768
  return dump(data);
32588
32769
  }
32770
+ class FilterEvaluationError extends Error {
32771
+ __brand = "FilterEvaluationError";
32772
+ filter;
32773
+ instructions;
32774
+ result = RESULTS.ValidationError;
32775
+ constructor(filter, cause) {
32776
+ const underlying = cause instanceof Error ? cause.message : String(cause);
32777
+ super(`Filter '${filter}' failed to evaluate: ${underlying}`);
32778
+ this.name = "FilterEvaluationError";
32779
+ this.filter = filter;
32780
+ 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(@)'.";
32781
+ }
32782
+ }
32589
32783
  function applyFilter(data, filter) {
32590
- const result = search(data, filter);
32784
+ let result;
32785
+ try {
32786
+ result = search(data, filter);
32787
+ } catch (err) {
32788
+ throw new FilterEvaluationError(filter, err);
32789
+ }
32591
32790
  if (result == null)
32592
32791
  return [];
32593
32792
  if (Array.isArray(result)) {
@@ -32604,13 +32803,18 @@ function applyFilter(data, filter) {
32604
32803
  }
32605
32804
  var OutputFormatter;
32606
32805
  ((OutputFormatter) => {
32607
- function success(data) {
32806
+ function success(data, options) {
32608
32807
  data.Log ??= getLogFilePath() || undefined;
32808
+ const normalize = !options?.preserveDataKeys;
32809
+ if (normalize) {
32810
+ data.Data = normalizeDataKeys(data.Data);
32811
+ }
32609
32812
  const filter = getOutputFilter();
32610
32813
  if (filter) {
32611
- data.Data = applyFilter(data.Data, filter);
32814
+ const filtered = applyFilter(data.Data, filter);
32815
+ data.Data = normalize ? normalizeDataKeys(filtered) : filtered;
32612
32816
  }
32613
- logOutput(data, getOutputFormat());
32817
+ logOutput(normalizeOutputKeys(data), getOutputFormat());
32614
32818
  }
32615
32819
  OutputFormatter.success = success;
32616
32820
  function error(data) {
@@ -32620,7 +32824,7 @@ var OutputFormatter;
32620
32824
  result: data.Result,
32621
32825
  message: data.Message
32622
32826
  });
32623
- logOutput(data, getOutputFormat());
32827
+ logOutput(normalizeOutputKeys(data), getOutputFormat());
32624
32828
  }
32625
32829
  OutputFormatter.error = error;
32626
32830
  function emitList(code, items, opts) {
@@ -32641,13 +32845,14 @@ var OutputFormatter;
32641
32845
  function log(data) {
32642
32846
  const format = getOutputFormat();
32643
32847
  const sink = getOutputSink();
32848
+ const normalized = toPascalCaseData(data);
32644
32849
  if (format === "json") {
32645
- const json2 = JSON.stringify(data);
32850
+ const json2 = JSON.stringify(normalized);
32646
32851
  const safe = needsAsciiSafeJson(sink) ? escapeNonAscii(json2) : json2;
32647
32852
  sink.writeErr(`${safe}
32648
32853
  `);
32649
32854
  } else {
32650
- for (const [key, value] of Object.entries(data)) {
32855
+ for (const [key, value] of Object.entries(normalized)) {
32651
32856
  sink.writeErr(`${key}: ${value}
32652
32857
  `);
32653
32858
  }
@@ -32656,12 +32861,16 @@ var OutputFormatter;
32656
32861
  OutputFormatter.log = log;
32657
32862
  function formatToString(data) {
32658
32863
  const filter = getOutputFilter();
32659
- if (filter && "Data" in data && data.Data != null) {
32660
- data.Data = applyFilter(data.Data, filter);
32864
+ if ("Data" in data && data.Data != null) {
32865
+ data.Data = normalizeDataKeys(data.Data);
32866
+ if (filter) {
32867
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
32868
+ }
32661
32869
  }
32870
+ const output = normalizeOutputKeys(data);
32662
32871
  const lines = [];
32663
32872
  const sink = getOutputSink();
32664
- printOutput(data, getOutputFormat(), (msg) => {
32873
+ printOutput(output, getOutputFormat(), (msg) => {
32665
32874
  lines.push(msg);
32666
32875
  }, needsAsciiSafeJson(sink));
32667
32876
  return lines.join(`
@@ -34089,6 +34298,22 @@ function warnDeprecatedTenantOption(tenant) {
34089
34298
  return;
34090
34299
  warnDeprecatedOptionAlias("--tenant", TENANT_SWITCH_COMMAND);
34091
34300
  }
34301
+ // ../common/src/polling/types.ts
34302
+ var PollOutcome = {
34303
+ Completed: "completed",
34304
+ Timeout: "timeout",
34305
+ Interrupted: "interrupted",
34306
+ Aborted: "aborted",
34307
+ Failed: "failed"
34308
+ };
34309
+
34310
+ // ../common/src/polling/poll-failure-mapping.ts
34311
+ var REASON_BY_OUTCOME = {
34312
+ [PollOutcome.Timeout]: "poll_timeout",
34313
+ [PollOutcome.Failed]: "poll_failed",
34314
+ [PollOutcome.Interrupted]: "poll_failed",
34315
+ [PollOutcome.Aborted]: "poll_aborted"
34316
+ };
34092
34317
  // ../common/src/polling/terminal-statuses.ts
34093
34318
  var TERMINAL_STATUSES = new Set([
34094
34319
  "completed",
@@ -34116,6 +34341,8 @@ var ScreenLogger;
34116
34341
  }
34117
34342
  ScreenLogger.progress = progress;
34118
34343
  })(ScreenLogger ||= {});
34344
+ // ../common/src/sdk-user-agent.ts
34345
+ var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
34119
34346
  // ../common/src/tool-provider.ts
34120
34347
  var factorySlot = singleton("PackagerFactoryProvider");
34121
34348
  // ../common/src/telemetry/pii-redactor.ts
@@ -34298,13 +34525,17 @@ Command.prototype.trackedAction = function(context, fn, properties) {
34298
34525
  const [error] = await catchError(fn(...args));
34299
34526
  if (error) {
34300
34527
  errorMessage = error instanceof Error ? error.message : String(error);
34301
- logger.error(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
34528
+ logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
34529
+ const typed = error;
34530
+ const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
34531
+ const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
34532
+ const finalResult = customResult ?? RESULTS.Failure;
34302
34533
  OutputFormatter.error({
34303
- Result: RESULTS.Failure,
34534
+ Result: finalResult,
34304
34535
  Message: errorMessage,
34305
- Instructions: "An unexpected error occurred. Run with --log-level debug for details."
34536
+ Instructions: customInstructions ?? "An unexpected error occurred. Run with --log-level debug for details."
34306
34537
  });
34307
- context.exit(1);
34538
+ context.exit(EXIT_CODES[finalResult]);
34308
34539
  }
34309
34540
  const durationMs = performance.now() - startTime;
34310
34541
  const success = !error && (process.exitCode === undefined || process.exitCode === 0);
@@ -34341,32 +34572,7 @@ class InvalidBaseUrlError extends Error {
34341
34572
  this.name = "InvalidBaseUrlError";
34342
34573
  }
34343
34574
  }
34344
- var DEFAULT_SCOPES = [
34345
- "offline_access",
34346
- "ProcessMining",
34347
- "OrchestratorApiUserAccess",
34348
- "StudioWebBackend",
34349
- "IdentityServerApi",
34350
- "ConnectionService",
34351
- "DataService",
34352
- "DataServiceApiUserAccess",
34353
- "DocumentUnderstanding",
34354
- "EnterpriseContextService",
34355
- "Directory",
34356
- "JamJamApi",
34357
- "LLMGateway",
34358
- "LLMOps",
34359
- "OMS",
34360
- "RCS.FolderAuthorization",
34361
- "RCS.TagsManagement",
34362
- "TestmanagerApiUserAccess",
34363
- "AutomationSolutions",
34364
- "StudioWebTypeCacheService",
34365
- "Docs.GPT.Search",
34366
- "Insights",
34367
- "ReferenceToken",
34368
- "Audit.Read"
34369
- ];
34575
+ var DEFAULT_SCOPES = ["openid", "profile", "offline_access"];
34370
34576
  var normalizeAndValidateBaseUrl = (rawUrl) => {
34371
34577
  let baseUrl = rawUrl;
34372
34578
  if (baseUrl.endsWith("/identity_/")) {
@@ -34416,7 +34622,8 @@ var resolveConfigAsync = async ({
34416
34622
  if (!clientSecret && fileAuth.clientSecret) {
34417
34623
  clientSecret = fileAuth.clientSecret;
34418
34624
  }
34419
- const scopes = customScopes && customScopes.length > 0 ? customScopes : fileAuth.scopes && fileAuth.scopes.length > 0 ? fileAuth.scopes : DEFAULT_SCOPES;
34625
+ const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && Boolean(clientSecret);
34626
+ const scopes = customScopes && customScopes.length > 0 ? customScopes : fileAuth.scopes && fileAuth.scopes.length > 0 ? fileAuth.scopes : isExternalAppAuth ? [] : DEFAULT_SCOPES;
34420
34627
  return {
34421
34628
  clientId,
34422
34629
  clientSecret,
@@ -34916,6 +35123,129 @@ function normalizeTokenRefreshFailure() {
34916
35123
  function normalizeTokenRefreshUnavailableFailure() {
34917
35124
  return "token refresh failed before authentication completed";
34918
35125
  }
35126
+ function errorMessage(error) {
35127
+ return error instanceof Error ? error.message : String(error);
35128
+ }
35129
+ function computeExpirationThreshold(ensureTokenValidityMinutes) {
35130
+ return new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
35131
+ }
35132
+ async function runRefreshLocked(inputs) {
35133
+ const {
35134
+ absolutePath,
35135
+ refreshToken: callerRefreshToken,
35136
+ customAuthority,
35137
+ ensureTokenValidityMinutes,
35138
+ loadEnvFile,
35139
+ saveEnvFile,
35140
+ refreshFn,
35141
+ resolveConfig
35142
+ } = inputs;
35143
+ const expirationThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
35144
+ let fresh;
35145
+ try {
35146
+ fresh = await loadEnvFile({ envPath: absolutePath });
35147
+ } catch (error) {
35148
+ return {
35149
+ kind: "fail",
35150
+ status: {
35151
+ loginStatus: "Refresh Failed",
35152
+ hint: "Could not read the auth file while refreshing. Retry, or run 'uip login' to re-authenticate.",
35153
+ tokenRefresh: {
35154
+ attempted: false,
35155
+ success: false,
35156
+ errorMessage: `auth file read failed: ${errorMessage(error)}`
35157
+ }
35158
+ }
35159
+ };
35160
+ }
35161
+ const freshAccess = fresh.UIPATH_ACCESS_TOKEN;
35162
+ const freshExp = freshAccess ? getTokenExpiration(freshAccess) : undefined;
35163
+ if (freshAccess && freshExp && freshExp > expirationThreshold) {
35164
+ return {
35165
+ kind: "ok",
35166
+ accessToken: freshAccess,
35167
+ refreshToken: fresh.UIPATH_REFRESH_TOKEN ?? callerRefreshToken,
35168
+ expiration: freshExp,
35169
+ tokenRefresh: { attempted: false, success: true }
35170
+ };
35171
+ }
35172
+ const tokenForIdP = fresh.UIPATH_REFRESH_TOKEN ?? callerRefreshToken;
35173
+ let refreshedAccess;
35174
+ let refreshedRefresh;
35175
+ try {
35176
+ const config = await resolveConfig({ customAuthority });
35177
+ const refreshed = await refreshFn({
35178
+ refreshToken: tokenForIdP,
35179
+ tokenEndpoint: config.tokenEndpoint,
35180
+ clientId: config.clientId,
35181
+ expectedAuthority: customAuthority
35182
+ });
35183
+ refreshedAccess = refreshed.accessToken;
35184
+ refreshedRefresh = refreshed.refreshToken;
35185
+ } catch (error) {
35186
+ const isOAuthFailure = isTokenRefreshOAuthFailure(error);
35187
+ 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.";
35188
+ const message = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
35189
+ return {
35190
+ kind: "fail",
35191
+ status: {
35192
+ loginStatus: "Refresh Failed",
35193
+ hint,
35194
+ tokenRefresh: {
35195
+ attempted: true,
35196
+ success: false,
35197
+ errorMessage: message
35198
+ }
35199
+ }
35200
+ };
35201
+ }
35202
+ const refreshedExp = getTokenExpiration(refreshedAccess);
35203
+ if (!refreshedExp || refreshedExp <= new Date) {
35204
+ return {
35205
+ kind: "fail",
35206
+ status: {
35207
+ loginStatus: "Refresh Failed",
35208
+ hint: "The identity server returned an unusable token. Run 'uip login' to re-authenticate.",
35209
+ tokenRefresh: {
35210
+ attempted: true,
35211
+ success: false,
35212
+ errorMessage: "refreshed token has no valid expiration claim"
35213
+ }
35214
+ }
35215
+ };
35216
+ }
35217
+ try {
35218
+ await saveEnvFile({
35219
+ envPath: absolutePath,
35220
+ data: {
35221
+ UIPATH_ACCESS_TOKEN: refreshedAccess,
35222
+ UIPATH_REFRESH_TOKEN: refreshedRefresh
35223
+ },
35224
+ merge: true
35225
+ });
35226
+ return {
35227
+ kind: "ok",
35228
+ accessToken: refreshedAccess,
35229
+ refreshToken: refreshedRefresh,
35230
+ expiration: refreshedExp,
35231
+ tokenRefresh: { attempted: true, success: true }
35232
+ };
35233
+ } catch (error) {
35234
+ const msg = errorMessage(error);
35235
+ return {
35236
+ kind: "ok",
35237
+ accessToken: refreshedAccess,
35238
+ refreshToken: refreshedRefresh,
35239
+ expiration: refreshedExp,
35240
+ 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.`,
35241
+ tokenRefresh: {
35242
+ attempted: true,
35243
+ success: true,
35244
+ errorMessage: `persistence failed: ${msg}`
35245
+ }
35246
+ };
35247
+ }
35248
+ }
34919
35249
  var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
34920
35250
  const {
34921
35251
  resolveEnvFilePath = resolveEnvFilePathAsync,
@@ -34990,73 +35320,103 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
34990
35320
  let refreshToken = credentials.UIPATH_REFRESH_TOKEN;
34991
35321
  let expiration = getTokenExpiration(accessToken);
34992
35322
  let persistenceWarning;
35323
+ let lockReleaseFailed = false;
34993
35324
  let tokenRefresh;
34994
- const expirationThreshold = new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
34995
- if (expiration && expiration <= expirationThreshold && refreshToken) {
34996
- let refreshedAccess;
34997
- let refreshedRefresh;
35325
+ const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
35326
+ const tryGlobalCredsHint = async () => {
35327
+ const fs7 = getFs();
35328
+ const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
35329
+ if (absolutePath === globalPath)
35330
+ return;
35331
+ if (!await fs7.exists(globalPath))
35332
+ return;
34998
35333
  try {
34999
- const config = await resolveConfig({
35000
- customAuthority: credentials.UIPATH_URL
35001
- });
35002
- const refreshed = await refreshTokenFn({
35003
- refreshToken,
35004
- tokenEndpoint: config.tokenEndpoint,
35005
- clientId: config.clientId,
35006
- expectedAuthority: credentials.UIPATH_URL
35007
- });
35008
- refreshedAccess = refreshed.accessToken;
35009
- refreshedRefresh = refreshed.refreshToken;
35010
- } catch (error) {
35011
- const isOAuthFailure = isTokenRefreshOAuthFailure(error);
35012
- 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.";
35013
- const errorMessage = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
35014
- return {
35015
- loginStatus: "Refresh Failed",
35016
- hint,
35017
- tokenRefresh: {
35018
- attempted: true,
35019
- success: false,
35020
- errorMessage
35021
- }
35022
- };
35334
+ const globalCreds = await loadEnvFile({ envPath: globalPath });
35335
+ if (!globalCreds.UIPATH_ACCESS_TOKEN)
35336
+ return;
35337
+ const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
35338
+ if (globalExp && globalExp <= new Date)
35339
+ return;
35340
+ 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.`;
35341
+ } catch {
35342
+ return;
35023
35343
  }
35024
- const refreshedExp = getTokenExpiration(refreshedAccess);
35025
- if (!refreshedExp || refreshedExp <= new Date) {
35344
+ };
35345
+ if (expiration && expiration <= outerThreshold && refreshToken) {
35346
+ let release;
35347
+ try {
35348
+ release = await getFs().acquireLock(absolutePath);
35349
+ } catch (error) {
35350
+ const msg = errorMessage(error);
35351
+ const globalHint = await tryGlobalCredsHint();
35352
+ if (globalHint) {
35353
+ return {
35354
+ loginStatus: "Expired",
35355
+ accessToken,
35356
+ refreshToken,
35357
+ baseUrl: credentials.UIPATH_URL,
35358
+ organizationName: credentials.UIPATH_ORGANIZATION_NAME,
35359
+ organizationId: credentials.UIPATH_ORGANIZATION_ID,
35360
+ tenantName: credentials.UIPATH_TENANT_NAME,
35361
+ tenantId: credentials.UIPATH_TENANT_ID,
35362
+ expiration,
35363
+ source: "file" /* File */,
35364
+ hint: globalHint,
35365
+ tokenRefresh: {
35366
+ attempted: false,
35367
+ success: false,
35368
+ errorMessage: `lock acquisition failed: ${msg}`
35369
+ }
35370
+ };
35371
+ }
35026
35372
  return {
35027
35373
  loginStatus: "Refresh Failed",
35028
- hint: "The identity server returned an unusable token. Run 'uip login' to re-authenticate.",
35374
+ 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.",
35029
35375
  tokenRefresh: {
35030
- attempted: true,
35376
+ attempted: false,
35031
35377
  success: false,
35032
- errorMessage: "refreshed token has no valid expiration claim"
35378
+ errorMessage: `lock acquisition failed: ${msg}`
35033
35379
  }
35034
35380
  };
35035
35381
  }
35036
- accessToken = refreshedAccess;
35037
- refreshToken = refreshedRefresh;
35038
- expiration = refreshedExp;
35382
+ let lockedFailure;
35039
35383
  try {
35040
- await saveEnvFile({
35041
- envPath: absolutePath,
35042
- data: {
35043
- UIPATH_ACCESS_TOKEN: accessToken,
35044
- UIPATH_REFRESH_TOKEN: refreshToken
35045
- },
35046
- merge: true
35384
+ const outcome = await runRefreshLocked({
35385
+ absolutePath,
35386
+ refreshToken,
35387
+ customAuthority: credentials.UIPATH_URL,
35388
+ ensureTokenValidityMinutes,
35389
+ loadEnvFile,
35390
+ saveEnvFile,
35391
+ refreshFn: refreshTokenFn,
35392
+ resolveConfig
35047
35393
  });
35048
- tokenRefresh = {
35049
- attempted: true,
35050
- success: true
35051
- };
35052
- } catch (error) {
35053
- const msg = error instanceof Error ? error.message : String(error);
35054
- 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.`;
35055
- tokenRefresh = {
35056
- attempted: true,
35057
- success: true,
35058
- errorMessage: `persistence failed: ${msg}`
35059
- };
35394
+ if (outcome.kind === "fail") {
35395
+ lockedFailure = outcome.status;
35396
+ } else {
35397
+ accessToken = outcome.accessToken;
35398
+ refreshToken = outcome.refreshToken;
35399
+ expiration = outcome.expiration;
35400
+ tokenRefresh = outcome.tokenRefresh;
35401
+ if (outcome.persistenceWarning) {
35402
+ persistenceWarning = outcome.persistenceWarning;
35403
+ }
35404
+ }
35405
+ } finally {
35406
+ try {
35407
+ await release();
35408
+ } catch {
35409
+ lockReleaseFailed = true;
35410
+ }
35411
+ }
35412
+ if (lockedFailure) {
35413
+ const globalHint = await tryGlobalCredsHint();
35414
+ const base = globalHint ? {
35415
+ ...lockedFailure,
35416
+ loginStatus: "Expired",
35417
+ hint: globalHint
35418
+ } : lockedFailure;
35419
+ return lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base;
35060
35420
  }
35061
35421
  }
35062
35422
  const result = {
@@ -35071,23 +35431,13 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
35071
35431
  expiration,
35072
35432
  source: "file" /* File */,
35073
35433
  ...persistenceWarning ? { hint: persistenceWarning, persistenceFailed: true } : {},
35434
+ ...lockReleaseFailed ? { lockReleaseFailed: true } : {},
35074
35435
  ...tokenRefresh ? { tokenRefresh } : {}
35075
35436
  };
35076
35437
  if (result.loginStatus === "Expired") {
35077
- const fs7 = getFs();
35078
- const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
35079
- if (absolutePath !== globalPath && await fs7.exists(globalPath)) {
35080
- try {
35081
- const globalCreds = await loadEnvFile({
35082
- envPath: globalPath
35083
- });
35084
- if (globalCreds.UIPATH_ACCESS_TOKEN) {
35085
- const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
35086
- if (!globalExp || globalExp > new Date) {
35087
- 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.`;
35088
- }
35089
- }
35090
- } catch {}
35438
+ const globalHint = await tryGlobalCredsHint();
35439
+ if (globalHint) {
35440
+ result.hint = globalHint;
35091
35441
  }
35092
35442
  }
35093
35443
  return result;
@@ -35104,8 +35454,246 @@ var getLoginStatusAsync = async (options = {}) => {
35104
35454
  init_src();
35105
35455
  // ../auth/src/logout.ts
35106
35456
  init_src();
35107
- // ../../node_modules/@uipath/uipath-typescript/dist/index.mjs
35457
+
35458
+ // ../auth/src/index.ts
35459
+ init_server();
35460
+
35461
+ // ../../node_modules/@uipath/core-telemetry/dist/index.mjs
35108
35462
  var import_sdk_logs = __toESM(require_src6(), 1);
35463
+ var CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
35464
+ var VERSION = "Version";
35465
+ var SERVICE = "Service";
35466
+ var CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
35467
+ var CLOUD_TENANT_NAME = "CloudTenantName";
35468
+ var CLOUD_URL = "CloudUrl";
35469
+ var CLOUD_CLIENT_ID = "CloudClientId";
35470
+ var CLOUD_REDIRECT_URI = "CloudRedirectUri";
35471
+ var APP_NAME = "ApplicationName";
35472
+ var UNKNOWN = "";
35473
+ var INSTRUMENTATION_KEY_RE = /InstrumentationKey=([^;]+)/;
35474
+ var INGESTION_ENDPOINT_RE = /IngestionEndpoint=([^;]+)/;
35475
+
35476
+ class ApplicationInsightsEventExporter {
35477
+ constructor(connectionString, tags) {
35478
+ this.connectionString = connectionString;
35479
+ this.tags = tags;
35480
+ }
35481
+ export(logs, resultCallback) {
35482
+ try {
35483
+ for (const log of logs) {
35484
+ this.sendAsCustomEvent(log);
35485
+ }
35486
+ resultCallback({ code: 0 });
35487
+ } catch (error) {
35488
+ const err = error instanceof Error ? error : new Error(String(error));
35489
+ console.debug("Failed to export logs to Application Insights:", err);
35490
+ resultCallback({ code: 1, error: err });
35491
+ }
35492
+ }
35493
+ shutdown() {
35494
+ return Promise.resolve();
35495
+ }
35496
+ sendAsCustomEvent(logRecord) {
35497
+ const eventName = String(logRecord.body);
35498
+ const payload = {
35499
+ name: "Microsoft.ApplicationInsights.Event",
35500
+ time: new Date().toISOString(),
35501
+ iKey: this.extractInstrumentationKey(),
35502
+ data: {
35503
+ baseType: "EventData",
35504
+ baseData: {
35505
+ ver: 2,
35506
+ name: eventName,
35507
+ properties: this.convertAttributesToProperties(logRecord.attributes)
35508
+ }
35509
+ },
35510
+ tags: {
35511
+ "ai.cloud.role": this.tags.cloudRoleName,
35512
+ "ai.cloud.roleInstance": this.tags.cloudRoleInstance
35513
+ }
35514
+ };
35515
+ this.sendToApplicationInsights(payload);
35516
+ }
35517
+ extractInstrumentationKey() {
35518
+ const match = INSTRUMENTATION_KEY_RE.exec(this.connectionString);
35519
+ return match ? match[1] : "";
35520
+ }
35521
+ convertAttributesToProperties(attributes) {
35522
+ const properties = {};
35523
+ for (const [key, value] of Object.entries(attributes ?? {})) {
35524
+ properties[key] = String(value);
35525
+ }
35526
+ return properties;
35527
+ }
35528
+ async sendToApplicationInsights(payload) {
35529
+ try {
35530
+ const ingestionEndpoint = this.extractIngestionEndpoint();
35531
+ if (!ingestionEndpoint) {
35532
+ console.debug("No ingestion endpoint found in connection string");
35533
+ return;
35534
+ }
35535
+ const url = `${ingestionEndpoint}/v2/track`;
35536
+ const response = await fetch(url, {
35537
+ method: "POST",
35538
+ headers: { "Content-Type": "application/json" },
35539
+ body: JSON.stringify(payload)
35540
+ });
35541
+ if (!response.ok) {
35542
+ console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
35543
+ }
35544
+ } catch (error) {
35545
+ console.debug("Error sending event telemetry to Application Insights:", error);
35546
+ }
35547
+ }
35548
+ extractIngestionEndpoint() {
35549
+ const match = INGESTION_ENDPOINT_RE.exec(this.connectionString);
35550
+ return match ? match[1] : "";
35551
+ }
35552
+ }
35553
+
35554
+ class TelemetryClient {
35555
+ constructor() {
35556
+ this.isInitialized = false;
35557
+ }
35558
+ initialize(options) {
35559
+ if (this.isInitialized) {
35560
+ console.debug("Telemetry client has already been initialized");
35561
+ return;
35562
+ }
35563
+ this.isInitialized = true;
35564
+ this.options = options;
35565
+ this.telemetryContext = options.context;
35566
+ try {
35567
+ if (!this.isValidConnectionString(CONNECTION_STRING)) {
35568
+ return;
35569
+ }
35570
+ this.setupTelemetryProvider(CONNECTION_STRING);
35571
+ } catch (error) {
35572
+ console.debug("Failed to initialize telemetry:", error);
35573
+ }
35574
+ }
35575
+ track(eventName, name, extraAttributes = {}) {
35576
+ try {
35577
+ if (!this.logger) {
35578
+ return;
35579
+ }
35580
+ const finalDisplayName = name ?? eventName;
35581
+ const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
35582
+ this.logger.emit({
35583
+ body: finalDisplayName,
35584
+ attributes,
35585
+ timestamp: Date.now()
35586
+ });
35587
+ } catch (error) {
35588
+ console.debug("Failed to track telemetry event:", error);
35589
+ }
35590
+ }
35591
+ getDefaultEventName() {
35592
+ return this.options?.defaultEventName;
35593
+ }
35594
+ setupTelemetryProvider(connectionString) {
35595
+ const opts = this.options;
35596
+ const exporter = new ApplicationInsightsEventExporter(connectionString, {
35597
+ cloudRoleName: opts.cloudRoleName,
35598
+ cloudRoleInstance: opts.sdkVersion
35599
+ });
35600
+ const processor = new import_sdk_logs.BatchLogRecordProcessor(exporter);
35601
+ this.logProvider = new import_sdk_logs.LoggerProvider({
35602
+ processors: [processor]
35603
+ });
35604
+ this.logger = this.logProvider.getLogger(opts.loggerName);
35605
+ }
35606
+ isValidConnectionString(connectionString) {
35607
+ return Boolean(connectionString) && !connectionString.startsWith("$");
35608
+ }
35609
+ getEnrichedAttributes(extraAttributes, eventName) {
35610
+ const opts = this.options;
35611
+ return {
35612
+ [APP_NAME]: opts?.serviceName ?? UNKNOWN,
35613
+ [VERSION]: opts?.sdkVersion ?? UNKNOWN,
35614
+ [SERVICE]: eventName,
35615
+ [CLOUD_URL]: this.createCloudUrl(),
35616
+ [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName ?? UNKNOWN,
35617
+ [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName ?? UNKNOWN,
35618
+ [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri ?? UNKNOWN,
35619
+ [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId ?? UNKNOWN,
35620
+ ...extraAttributes
35621
+ };
35622
+ }
35623
+ createCloudUrl() {
35624
+ const baseUrl = this.telemetryContext?.baseUrl;
35625
+ const orgId = this.telemetryContext?.orgName;
35626
+ const tenantId = this.telemetryContext?.tenantName;
35627
+ if (!baseUrl || !orgId || !tenantId) {
35628
+ return UNKNOWN;
35629
+ }
35630
+ return `${baseUrl}/${orgId}/${tenantId}`;
35631
+ }
35632
+ }
35633
+ var REGISTRY_KEY = Symbol.for("@uipath/core-telemetry/clients");
35634
+ function getGlobalRegistry() {
35635
+ const holder = globalThis;
35636
+ let registry2 = holder[REGISTRY_KEY];
35637
+ if (!registry2) {
35638
+ registry2 = {};
35639
+ holder[REGISTRY_KEY] = registry2;
35640
+ }
35641
+ return registry2;
35642
+ }
35643
+ function getOrCreateClient(name) {
35644
+ const registry2 = getGlobalRegistry();
35645
+ if (!registry2[name]) {
35646
+ registry2[name] = new TelemetryClient;
35647
+ }
35648
+ return registry2[name];
35649
+ }
35650
+ function createTrackedFunction(originalFunction, { client, nameOrOptions, fallbackName, opts }) {
35651
+ const wrapped = function(...args) {
35652
+ let shouldTrack = true;
35653
+ if (opts.condition !== undefined) {
35654
+ shouldTrack = typeof opts.condition === "function" ? opts.condition.apply(this, args) : opts.condition;
35655
+ }
35656
+ if (shouldTrack) {
35657
+ const serviceMethod = typeof nameOrOptions === "string" ? nameOrOptions : fallbackName;
35658
+ client.track(serviceMethod, client.getDefaultEventName(), opts.attributes);
35659
+ }
35660
+ return originalFunction.apply(this, args);
35661
+ };
35662
+ return wrapped;
35663
+ }
35664
+ function createTrack(client) {
35665
+ function trackFactory(nameOrOptions, options) {
35666
+ const opts = typeof nameOrOptions === "object" ? nameOrOptions : options ?? {};
35667
+ function decoratorImpl(target, propertyKey, descriptor) {
35668
+ if (descriptor && typeof descriptor.value === "function") {
35669
+ const original = descriptor.value;
35670
+ descriptor.value = createTrackedFunction(original, {
35671
+ client,
35672
+ nameOrOptions,
35673
+ fallbackName: typeof propertyKey === "string" ? propertyKey : "unknown_method",
35674
+ opts
35675
+ });
35676
+ return descriptor;
35677
+ }
35678
+ const fn = target;
35679
+ return createTrackedFunction(fn, {
35680
+ client,
35681
+ nameOrOptions,
35682
+ fallbackName: fn.name || "unknown_function",
35683
+ opts
35684
+ });
35685
+ }
35686
+ return decoratorImpl;
35687
+ }
35688
+ return trackFactory;
35689
+ }
35690
+ function createTrackEvent(client) {
35691
+ return function trackEvent(eventName, name, attributes) {
35692
+ client.track(eventName, name, attributes);
35693
+ };
35694
+ }
35695
+
35696
+ // ../../node_modules/@uipath/uipath-typescript/dist/index.mjs
35109
35697
  function __decorate(decorators, target, key, desc) {
35110
35698
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
35111
35699
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -38988,6 +39576,7 @@ var ORCHESTRATOR_BASE = "orchestrator_";
38988
39576
  var PIMS_BASE = "pims_";
38989
39577
  var DATAFABRIC_BASE = "datafabric_";
38990
39578
  var IDENTITY_BASE = "identity_";
39579
+ var INSIGHTS_RTM_BASE = "insightsrtm_";
38991
39580
  var TASK_ENDPOINTS = {
38992
39581
  CREATE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CreateTask`,
38993
39582
  GET_TASK_USERS: (folderId) => `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTaskUsers(organizationUnitId=${folderId})`,
@@ -39010,7 +39599,9 @@ var BUCKET_ENDPOINTS = {
39010
39599
  GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})`,
39011
39600
  GET_FILE_META_DATA: (id) => `${ORCHESTRATOR_BASE}/api/Buckets/${id}/ListFiles`,
39012
39601
  GET_READ_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetReadUri`,
39013
- GET_WRITE_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetWriteUri`
39602
+ GET_WRITE_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetWriteUri`,
39603
+ DELETE_FILE: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.DeleteFile`,
39604
+ GET_FILES: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetFiles`
39014
39605
  };
39015
39606
  var PROCESS_ENDPOINTS = {
39016
39607
  GET_ALL: `${ORCHESTRATOR_BASE}/odata/Releases`,
@@ -39061,6 +39652,15 @@ var MAESTRO_ENDPOINTS = {
39061
39652
  GET_CASE_JSON: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/case-json`,
39062
39653
  GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/element-executions/case-instances/${instanceId}`,
39063
39654
  REOPEN: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/reopen`
39655
+ },
39656
+ INSIGHTS: {
39657
+ SLA_SUMMARY: `${INSIGHTS_RTM_BASE}/caseManagement/slaSummary`,
39658
+ STAGES_SUMMARY: `${INSIGHTS_RTM_BASE}/caseManagement/stages`,
39659
+ TOP_PROCESSES_BY_RUN_COUNT: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByRunCount`,
39660
+ TOP_PROCESSES_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcesseswithFailure`,
39661
+ TOP_ELEMENTS_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopElementswithFailure`,
39662
+ INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
39663
+ TOP_PROCESSES_BY_DURATION: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByDuration`
39064
39664
  }
39065
39665
  };
39066
39666
  var DATA_FABRIC_TENANT_FOLDER_ID = "00000000-0000-0000-0000-000000000000";
@@ -39087,7 +39687,13 @@ var DATA_FABRIC_ENDPOINTS = {
39087
39687
  },
39088
39688
  CHOICESETS: {
39089
39689
  GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
39090
- GET_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/query_expansion`
39690
+ GET_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/query_expansion`,
39691
+ CREATE: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
39692
+ UPDATE: (choiceSetId) => `${DATAFABRIC_BASE}/api/Entity/${choiceSetId}/metadata`,
39693
+ DELETE: (choiceSetId) => `${DATAFABRIC_BASE}/api/Entity/${choiceSetId}/delete`,
39694
+ INSERT_BY_NAME: (choiceSetName) => `${DATAFABRIC_BASE}/api/EntityService/${choiceSetName}/choiceset/insert`,
39695
+ UPDATE_BY_NAME: (choiceSetName, valueId) => `${DATAFABRIC_BASE}/api/EntityService/${choiceSetName}/choiceset/${valueId}/update`,
39696
+ DELETE_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/choiceset/delete`
39091
39697
  }
39092
39698
  };
39093
39699
  var IDENTITY_ENDPOINTS = {
@@ -39684,218 +40290,33 @@ function isCompleteConfig(config2) {
39684
40290
  function normalizeBaseUrl(url) {
39685
40291
  return url.endsWith("/") ? url.slice(0, -1) : url;
39686
40292
  }
39687
- var CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
39688
- var SDK_VERSION = "1.3.7";
39689
- var VERSION = "Version";
39690
- var SERVICE = "Service";
39691
- var CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
39692
- var CLOUD_TENANT_NAME = "CloudTenantName";
39693
- var CLOUD_URL = "CloudUrl";
39694
- var CLOUD_CLIENT_ID = "CloudClientId";
39695
- var CLOUD_REDIRECT_URI = "CloudRedirectUri";
39696
- var APP_NAME = "ApplicationName";
40293
+ var SDK_VERSION = "1.3.11";
39697
40294
  var CLOUD_ROLE_NAME = "uipath-ts-sdk";
39698
40295
  var SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
39699
40296
  var SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
39700
40297
  var SDK_RUN_EVENT = "Sdk.Run";
39701
- var UNKNOWN$1 = "";
39702
-
39703
- class ApplicationInsightsEventExporter {
39704
- constructor(connectionString) {
39705
- this.connectionString = connectionString;
39706
- }
39707
- export(logs, resultCallback) {
39708
- try {
39709
- logs.forEach((logRecord) => {
39710
- this.sendAsCustomEvent(logRecord);
39711
- });
39712
- resultCallback({ code: 0 });
39713
- } catch (error) {
39714
- console.debug("Failed to export logs to Application Insights:", error);
39715
- resultCallback({ code: 2, error });
39716
- }
39717
- }
39718
- shutdown() {
39719
- return Promise.resolve();
39720
- }
39721
- sendAsCustomEvent(logRecord) {
39722
- const eventName = logRecord.body || SDK_RUN_EVENT;
39723
- const payload = {
39724
- name: "Microsoft.ApplicationInsights.Event",
39725
- time: new Date().toISOString(),
39726
- iKey: this.extractInstrumentationKey(),
39727
- data: {
39728
- baseType: "EventData",
39729
- baseData: {
39730
- ver: 2,
39731
- name: eventName,
39732
- properties: this.convertAttributesToProperties(logRecord.attributes || {})
39733
- }
39734
- },
39735
- tags: {
39736
- "ai.cloud.role": CLOUD_ROLE_NAME,
39737
- "ai.cloud.roleInstance": SDK_VERSION
39738
- }
39739
- };
39740
- this.sendToApplicationInsights(payload);
39741
- }
39742
- extractInstrumentationKey() {
39743
- const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
39744
- return match ? match[1] : "";
39745
- }
39746
- convertAttributesToProperties(attributes) {
39747
- const properties = {};
39748
- Object.entries(attributes || {}).forEach(([key, value]) => {
39749
- properties[key] = String(value);
40298
+ var sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
40299
+ var track = createTrack(sdkClient);
40300
+ var trackEvent = createTrackEvent(sdkClient);
40301
+ var telemetryClient = {
40302
+ initialize(context) {
40303
+ sdkClient.initialize({
40304
+ sdkVersion: SDK_VERSION,
40305
+ serviceName: SDK_SERVICE_NAME,
40306
+ cloudRoleName: CLOUD_ROLE_NAME,
40307
+ loggerName: SDK_LOGGER_NAME,
40308
+ defaultEventName: SDK_RUN_EVENT,
40309
+ context
39750
40310
  });
39751
- return properties;
39752
40311
  }
39753
- async sendToApplicationInsights(payload) {
39754
- try {
39755
- const ingestionEndpoint = this.extractIngestionEndpoint();
39756
- if (!ingestionEndpoint) {
39757
- console.debug("No ingestion endpoint found in connection string");
39758
- return;
39759
- }
39760
- const url = `${ingestionEndpoint}/v2/track`;
39761
- const response = await fetch(url, {
39762
- method: "POST",
39763
- headers: {
39764
- "Content-Type": "application/json"
39765
- },
39766
- body: JSON.stringify(payload)
39767
- });
39768
- if (!response.ok) {
39769
- console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
39770
- }
39771
- } catch (error) {
39772
- console.debug("Error sending event telemetry to Application Insights:", error);
39773
- }
39774
- }
39775
- extractIngestionEndpoint() {
39776
- const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
39777
- return match ? match[1] : "";
39778
- }
39779
- }
39780
-
39781
- class TelemetryClient {
39782
- constructor() {
39783
- this.isInitialized = false;
39784
- }
39785
- static getInstance() {
39786
- if (!TelemetryClient.instance) {
39787
- TelemetryClient.instance = new TelemetryClient;
39788
- }
39789
- return TelemetryClient.instance;
39790
- }
39791
- initialize(config2) {
39792
- if (this.isInitialized) {
39793
- return;
39794
- }
39795
- this.isInitialized = true;
39796
- if (config2) {
39797
- this.telemetryContext = config2;
39798
- }
39799
- try {
39800
- const connectionString = this.getConnectionString();
39801
- if (!connectionString) {
39802
- return;
39803
- }
39804
- this.setupTelemetryProvider(connectionString);
39805
- } catch (error) {
39806
- console.debug("Failed to initialize OpenTelemetry:", error);
39807
- }
39808
- }
39809
- getConnectionString() {
39810
- const connectionString = CONNECTION_STRING;
39811
- return connectionString;
39812
- }
39813
- setupTelemetryProvider(connectionString) {
39814
- const exporter = new ApplicationInsightsEventExporter(connectionString);
39815
- const processor = new import_sdk_logs.BatchLogRecordProcessor(exporter);
39816
- this.logProvider = new import_sdk_logs.LoggerProvider({
39817
- processors: [processor]
39818
- });
39819
- this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
39820
- }
39821
- track(eventName, name, extraAttributes = {}) {
39822
- try {
39823
- if (!this.logger) {
39824
- return;
39825
- }
39826
- const finalDisplayName = name || eventName;
39827
- const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
39828
- this.logger.emit({
39829
- body: finalDisplayName,
39830
- attributes,
39831
- timestamp: Date.now()
39832
- });
39833
- } catch (error) {
39834
- console.debug("Failed to track telemetry event:", error);
39835
- }
39836
- }
39837
- getEnrichedAttributes(extraAttributes, eventName) {
39838
- const attributes = {
39839
- [APP_NAME]: SDK_SERVICE_NAME,
39840
- [VERSION]: SDK_VERSION,
39841
- [SERVICE]: eventName,
39842
- [CLOUD_URL]: this.createCloudUrl(),
39843
- [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN$1,
39844
- [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN$1,
39845
- [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN$1,
39846
- [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN$1,
39847
- ...extraAttributes
39848
- };
39849
- return attributes;
39850
- }
39851
- createCloudUrl() {
39852
- const baseUrl = this.telemetryContext?.baseUrl;
39853
- const orgId = this.telemetryContext?.orgName;
39854
- const tenantId = this.telemetryContext?.tenantName;
39855
- if (!baseUrl || !orgId || !tenantId) {
39856
- return UNKNOWN$1;
39857
- }
39858
- return `${baseUrl}/${orgId}/${tenantId}`;
39859
- }
39860
- }
39861
- var telemetryClient = TelemetryClient.getInstance();
39862
- function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
39863
- return function(...args) {
39864
- let shouldTrack = true;
39865
- if (opts.condition !== undefined) {
39866
- if (typeof opts.condition === "function") {
39867
- shouldTrack = opts.condition.apply(this, args);
39868
- } else {
39869
- shouldTrack = opts.condition;
39870
- }
39871
- }
39872
- if (shouldTrack) {
39873
- const serviceMethod = typeof nameOrOptions === "string" ? nameOrOptions : fallbackName;
39874
- telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
39875
- }
39876
- return originalFunction.apply(this, args);
39877
- };
39878
- }
39879
- function track(nameOrOptions, options) {
39880
- return function decorator(_target, propertyKey, descriptor) {
39881
- const opts = typeof nameOrOptions === "object" ? nameOrOptions : options || {};
39882
- if (descriptor && typeof descriptor.value === "function") {
39883
- descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || "unknown_method", opts);
39884
- return descriptor;
39885
- }
39886
- return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || "unknown_function", opts);
39887
- };
39888
- }
39889
- function trackEvent(eventName, name, attributes) {
39890
- telemetryClient.track(eventName, name, attributes);
39891
- }
39892
- var REGISTRY_KEY = Symbol.for("@uipath/sdk-internals-registry");
40312
+ };
40313
+ var REGISTRY_KEY2 = Symbol.for("@uipath/sdk-internals-registry");
39893
40314
  var getGlobalStore = () => {
39894
40315
  const globalObj = globalThis;
39895
- if (!globalObj[REGISTRY_KEY]) {
39896
- globalObj[REGISTRY_KEY] = new WeakMap;
40316
+ if (!globalObj[REGISTRY_KEY2]) {
40317
+ globalObj[REGISTRY_KEY2] = new WeakMap;
39897
40318
  }
39898
- return globalObj[REGISTRY_KEY];
40319
+ return globalObj[REGISTRY_KEY2];
39899
40320
  };
39900
40321
 
39901
40322
  class SDKInternalsRegistry {
@@ -39995,8 +40416,8 @@ var UiPath$1 = class UiPath {
39995
40416
  __classPrivateFieldSet(this, _UiPath_initialized, true, "f");
39996
40417
  }
39997
40418
  } catch (error) {
39998
- const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
39999
- throw new Error(`Failed to initialize UiPath SDK: ${errorMessage}`);
40419
+ const errorMessage2 = error instanceof Error ? error.message : "An unknown error occurred";
40420
+ throw new Error(`Failed to initialize UiPath SDK: ${errorMessage2}`);
40000
40421
  }
40001
40422
  }
40002
40423
  setMultiLogin() {
@@ -40025,8 +40446,8 @@ var UiPath$1 = class UiPath {
40025
40446
  }
40026
40447
  return false;
40027
40448
  } catch (error) {
40028
- const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
40029
- throw new Error(`Failed to complete OAuth: ${errorMessage}`);
40449
+ const errorMessage2 = error instanceof Error ? error.message : "An unknown error occurred";
40450
+ throw new Error(`Failed to complete OAuth: ${errorMessage2}`);
40030
40451
  }
40031
40452
  }
40032
40453
  isAuthenticated() {
@@ -40347,7 +40768,17 @@ class ApiClient {
40347
40768
  if (!text) {
40348
40769
  return;
40349
40770
  }
40350
- return JSON.parse(text);
40771
+ try {
40772
+ return JSON.parse(text);
40773
+ } catch (error) {
40774
+ if (error instanceof SyntaxError) {
40775
+ throw new ServerError({
40776
+ message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
40777
+ statusCode: response.status
40778
+ });
40779
+ }
40780
+ throw error;
40781
+ }
40351
40782
  } catch (error) {
40352
40783
  if (error.type && error.type.includes("Error")) {
40353
40784
  throw error;
@@ -40376,6 +40807,22 @@ var PaginationType;
40376
40807
  PaginationType2["OFFSET"] = "offset";
40377
40808
  PaginationType2["TOKEN"] = "token";
40378
40809
  })(PaginationType || (PaginationType = {}));
40810
+ function resolveNestedField(data, fieldPath) {
40811
+ if (!data) {
40812
+ return;
40813
+ }
40814
+ if (fieldPath in data) {
40815
+ return data[fieldPath];
40816
+ }
40817
+ if (!fieldPath.includes(".")) {
40818
+ return;
40819
+ }
40820
+ let value = data;
40821
+ for (const part of fieldPath.split(".")) {
40822
+ value = value?.[part];
40823
+ }
40824
+ return value;
40825
+ }
40379
40826
  function filterUndefined(obj) {
40380
40827
  const result = {};
40381
40828
  for (const [key, value] of Object.entries(obj)) {
@@ -40490,7 +40937,7 @@ function createHeaders(headersObj) {
40490
40937
  return headers;
40491
40938
  }
40492
40939
  var ODATA_PREFIX = "$";
40493
- var UNKNOWN = "Unknown";
40940
+ var UNKNOWN2 = "Unknown";
40494
40941
  var NO_INSTANCE = "no-instance";
40495
40942
  var HTTP_METHODS = {
40496
40943
  GET: "GET",
@@ -40512,6 +40959,15 @@ var BUCKET_PAGINATION = {
40512
40959
  ITEMS_FIELD: "items",
40513
40960
  CONTINUATION_TOKEN_FIELD: "continuationToken"
40514
40961
  };
40962
+ var SLA_SUMMARY_PAGINATION = {
40963
+ ITEMS_FIELD: "data",
40964
+ TOTAL_COUNT_FIELD: "pagination.totalCount"
40965
+ };
40966
+ var SLA_SUMMARY_OFFSET_PARAMS = {
40967
+ PAGE_SIZE_PARAM: "PageSize",
40968
+ OFFSET_PARAM: "PageNumber",
40969
+ COUNT_PARAM: undefined
40970
+ };
40515
40971
  var PROCESS_INSTANCE_PAGINATION = {
40516
40972
  ITEMS_FIELD: "instances",
40517
40973
  CONTINUATION_TOKEN_FIELD: "nextPage"
@@ -40534,6 +40990,10 @@ var PROCESS_INSTANCE_TOKEN_PARAMS = {
40534
40990
  PAGE_SIZE_PARAM: "pageSize",
40535
40991
  TOKEN_PARAM: "nextPage"
40536
40992
  };
40993
+ function toISOUtc(value) {
40994
+ const date2 = new Date(value + " UTC");
40995
+ return isNaN(date2.getTime()) ? value : date2.toISOString();
40996
+ }
40537
40997
  function transformData(data, fieldMapping) {
40538
40998
  if (Array.isArray(data)) {
40539
40999
  return data.map((item) => transformData(item, fieldMapping));
@@ -40734,9 +41194,9 @@ class PaginationHelpers {
40734
41194
  }
40735
41195
  }
40736
41196
  static async getAllPaginated(params) {
40737
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
41197
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
40738
41198
  const endpoint = getEndpoint(folderId);
40739
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
41199
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
40740
41200
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
40741
41201
  headers,
40742
41202
  params: additionalParams,
@@ -40757,11 +41217,11 @@ class PaginationHelpers {
40757
41217
  };
40758
41218
  }
40759
41219
  static async getAllNonPaginated(params) {
40760
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
41220
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
40761
41221
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
40762
41222
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
40763
41223
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
40764
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
41224
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
40765
41225
  let response;
40766
41226
  if (method === HTTP_METHODS.POST) {
40767
41227
  response = await serviceAccess.post(endpoint, additionalParams, { headers });
@@ -40772,7 +41232,8 @@ class PaginationHelpers {
40772
41232
  });
40773
41233
  }
40774
41234
  const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
40775
- const totalCount = Array.isArray(response.data) ? undefined : response.data?.[totalCountField];
41235
+ const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
41236
+ const totalCount = typeof rawTotalCount === "number" ? rawTotalCount : undefined;
40776
41237
  const parsedItems = typeof rawItems === "string" ? JSON.parse(rawItems) : rawItems || [];
40777
41238
  const items = transformFn ? parsedItems.map(transformFn) : parsedItems;
40778
41239
  return {
@@ -40802,6 +41263,7 @@ class PaginationHelpers {
40802
41263
  serviceAccess: config2.serviceAccess,
40803
41264
  getEndpoint: config2.getEndpoint,
40804
41265
  folderId,
41266
+ headers: config2.headers,
40805
41267
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
40806
41268
  additionalParams: prefixedOptions,
40807
41269
  transformFn: config2.transformFn,
@@ -40818,6 +41280,7 @@ class PaginationHelpers {
40818
41280
  getAllEndpoint: config2.getEndpoint(),
40819
41281
  getByFolderEndpoint: byFolderEndpoint,
40820
41282
  folderId,
41283
+ headers: config2.headers,
40821
41284
  additionalParams: prefixedOptions,
40822
41285
  transformFn: config2.transformFn,
40823
41286
  method: config2.method,
@@ -40927,9 +41390,14 @@ class BaseService {
40927
41390
  const pageSizeParam = paginationParams?.pageSizeParam || ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM;
40928
41391
  const offsetParam = paginationParams?.offsetParam || ODATA_OFFSET_PARAMS.OFFSET_PARAM;
40929
41392
  const countParam = paginationParams?.countParam || ODATA_OFFSET_PARAMS.COUNT_PARAM;
41393
+ const convertToSkip = paginationParams?.convertToSkip ?? true;
40930
41394
  requestParams[pageSizeParam] = limitedPageSize;
40931
- if (params.pageNumber && params.pageNumber > 1) {
40932
- requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
41395
+ if (convertToSkip) {
41396
+ if (params.pageNumber && params.pageNumber > 1) {
41397
+ requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
41398
+ }
41399
+ } else {
41400
+ requestParams[offsetParam] = params.pageNumber || 1;
40933
41401
  }
40934
41402
  {
40935
41403
  requestParams[countParam] = true;
@@ -40953,7 +41421,8 @@ class BaseService {
40953
41421
  const totalCountField = fields.totalCountField || "totalRecordCount";
40954
41422
  const continuationTokenField = fields.continuationTokenField || "continuationToken";
40955
41423
  const items = Array.isArray(response.data) ? response.data : response.data[itemsField] || [];
40956
- const totalCount = Array.isArray(response.data) ? undefined : response.data[totalCountField];
41424
+ const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
41425
+ const totalCount = typeof rawTotalCount === "number" ? rawTotalCount : undefined;
40957
41426
  const continuationToken = response.data[continuationTokenField];
40958
41427
  const hasMore = this.determineHasMorePages(paginationType, {
40959
41428
  totalCount,
@@ -41439,10 +41908,6 @@ class EntityService extends BaseService {
41439
41908
  return this.insertRecordsById(id, data, options);
41440
41909
  }
41441
41910
  async create(name, fields, options) {
41442
- this.validateName(name, "entity");
41443
- for (const field of fields) {
41444
- this.validateName(field.fieldName, "field");
41445
- }
41446
41911
  const opts = options ?? {};
41447
41912
  const payload = {
41448
41913
  ...opts.description !== undefined && { description: opts.description },
@@ -41514,6 +41979,7 @@ class EntityService extends BaseService {
41514
41979
  ...update.isUnique !== undefined && { isUnique: update.isUnique },
41515
41980
  ...update.isRbacEnabled !== undefined && { isRbacEnabled: update.isRbacEnabled },
41516
41981
  ...update.isEncrypted !== undefined && { isEncrypted: update.isEncrypted },
41982
+ ...update.isHiddenField !== undefined && { isHiddenField: update.isHiddenField },
41517
41983
  ...update.defaultValue !== undefined && { defaultValue: update.defaultValue },
41518
41984
  ...hasConstraintUpdate && f.sqlType && { sqlType: { ...f.sqlType, ...constraintUpdate } }
41519
41985
  };
@@ -41521,9 +41987,6 @@ class EntityService extends BaseService {
41521
41987
  }
41522
41988
  const newFields = [];
41523
41989
  if (options.addFields?.length) {
41524
- for (const field of options.addFields) {
41525
- this.validateName(field.fieldName, "field");
41526
- }
41527
41990
  newFields.push(...options.addFields.map((f) => this.buildSchemaFieldPayload(f)));
41528
41991
  }
41529
41992
  await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, {
@@ -41594,9 +42057,15 @@ class EntityService extends BaseService {
41594
42057
  });
41595
42058
  }
41596
42059
  buildSchemaFieldPayload(field) {
41597
- this.validateName(field.fieldName, "field");
41598
42060
  const fieldType = field.type ?? EntityFieldDataType.STRING;
41599
42061
  this.validateFieldConstraints(fieldType, field, field.fieldName);
42062
+ const isRelationship = fieldType === EntityFieldDataType.RELATIONSHIP;
42063
+ const isFile = fieldType === EntityFieldDataType.FILE;
42064
+ if ((isRelationship || isFile) && (!field.referenceEntityId || !field.referenceFieldId)) {
42065
+ throw new ValidationError({
42066
+ message: `Field '${field.fieldName}' of type ${fieldType} requires both referenceEntityId and referenceFieldId (UUIDs of the target entity and field).`
42067
+ });
42068
+ }
41600
42069
  const mapping = EntitySchemaFieldTypeMap[fieldType];
41601
42070
  return {
41602
42071
  name: field.fieldName,
@@ -41611,10 +42080,13 @@ class EntityService extends BaseService {
41611
42080
  isUnique: field.isUnique ?? false,
41612
42081
  isRbacEnabled: field.isRbacEnabled ?? false,
41613
42082
  isEncrypted: field.isEncrypted ?? false,
42083
+ isHiddenField: field.isHiddenField ?? false,
41614
42084
  ...field.defaultValue !== undefined && { defaultValue: field.defaultValue },
41615
42085
  ...field.choiceSetId !== undefined && { choiceSetId: field.choiceSetId },
41616
- ...field.referenceEntityName !== undefined && { referenceEntityName: field.referenceEntityName },
41617
- ...field.referenceFieldName !== undefined && { referenceFieldName: field.referenceFieldName }
42086
+ ...(isRelationship || isFile) && { isForeignKey: true },
42087
+ ...isRelationship && { referenceType: ReferenceType.ManyToOne },
42088
+ ...field.referenceEntityId !== undefined && { referenceEntity: { id: field.referenceEntityId } },
42089
+ ...field.referenceFieldId !== undefined && { referenceField: { id: field.referenceFieldId } }
41618
42090
  };
41619
42091
  }
41620
42092
  resolveFieldDataType(f) {
@@ -41693,28 +42165,7 @@ class EntityService extends BaseService {
41693
42165
  return {};
41694
42166
  }
41695
42167
  }
41696
- validateName(name, context) {
41697
- if (name.length < 3 || name.length > 100 || !/^[a-zA-Z]\w*$/.test(name)) {
41698
- const suggestion = name.replace(/\W/g, "").replace(/^[0-9_]+/, "");
41699
- const defaultName = `My${context.charAt(0).toUpperCase() + context.slice(1)}`;
41700
- throw new ValidationError({
41701
- message: `Invalid ${context} name '${name}'. Must start with a letter, contain only letters, numbers, and underscores, 3–100 characters (e.g., "${suggestion || defaultName}").`
41702
- });
41703
- }
41704
- if (context === "field" && EntityService.RESERVED_FIELD_NAMES.has(name)) {
41705
- throw new ValidationError({
41706
- message: `Field name '${name}' is reserved. Reserved names: ${[...EntityService.RESERVED_FIELD_NAMES].join(", ")}.`
41707
- });
41708
- }
41709
- }
41710
42168
  }
41711
- EntityService.RESERVED_FIELD_NAMES = new Set([
41712
- "Id",
41713
- "CreatedBy",
41714
- "CreateTime",
41715
- "UpdatedBy",
41716
- "UpdateTime"
41717
- ]);
41718
42169
  __decorate([
41719
42170
  track("Entities.GetById")
41720
42171
  ], EntityService.prototype, "getById", null);
@@ -41798,6 +42249,62 @@ class ChoiceSetService extends BaseService {
41798
42249
  }
41799
42250
  }, options);
41800
42251
  }
42252
+ async create(name, options) {
42253
+ const opts = options ?? {};
42254
+ const payload = {
42255
+ ...opts.description !== undefined && { description: opts.description },
42256
+ ...opts.displayName !== undefined && { displayName: opts.displayName },
42257
+ entityDefinition: {
42258
+ name,
42259
+ fields: [],
42260
+ folderId: opts.folderKey ?? DATA_FABRIC_TENANT_FOLDER_ID
42261
+ }
42262
+ };
42263
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.CREATE, payload);
42264
+ return response.data;
42265
+ }
42266
+ async updateById(choiceSetId, options) {
42267
+ if (options.displayName === undefined && options.description === undefined) {
42268
+ throw new ValidationError({
42269
+ message: "updateById requires at least one of displayName or description."
42270
+ });
42271
+ }
42272
+ await this.patch(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE(choiceSetId), {
42273
+ ...options.displayName !== undefined && { displayName: options.displayName },
42274
+ ...options.description !== undefined && { description: options.description }
42275
+ });
42276
+ }
42277
+ async deleteById(choiceSetId) {
42278
+ await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE(choiceSetId), {});
42279
+ }
42280
+ async insertValueById(choiceSetId, name, options) {
42281
+ const choiceSetName = await this.resolveChoiceSetName(choiceSetId);
42282
+ const payload = {
42283
+ Name: name,
42284
+ ...options?.displayName !== undefined && { DisplayName: options.displayName }
42285
+ };
42286
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.INSERT_BY_NAME(choiceSetName), payload);
42287
+ const camelCased = pascalToCamelCaseKeys(response.data);
42288
+ return transformData(camelCased, EntityMap);
42289
+ }
42290
+ async updateValueById(choiceSetId, valueId, displayName) {
42291
+ const choiceSetName = await this.resolveChoiceSetName(choiceSetId);
42292
+ const payload = { DisplayName: displayName };
42293
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE_BY_NAME(choiceSetName, valueId), payload);
42294
+ const camelCased = pascalToCamelCaseKeys(response.data);
42295
+ return transformData(camelCased, EntityMap);
42296
+ }
42297
+ async deleteValuesById(choiceSetId, valueIds) {
42298
+ await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE_BY_ID(choiceSetId), valueIds);
42299
+ }
42300
+ async resolveChoiceSetName(choiceSetId) {
42301
+ const all = await this.getAll();
42302
+ const match = all.find((cs) => cs.id === choiceSetId);
42303
+ if (!match) {
42304
+ throw new NotFoundError({ message: `Choice set with id '${choiceSetId}' not found.` });
42305
+ }
42306
+ return match.name;
42307
+ }
41801
42308
  }
41802
42309
  __decorate([
41803
42310
  track("Choicesets.GetAll")
@@ -41805,6 +42312,24 @@ __decorate([
41805
42312
  __decorate([
41806
42313
  track("Choicesets.GetById")
41807
42314
  ], ChoiceSetService.prototype, "getById", null);
42315
+ __decorate([
42316
+ track("Choicesets.Create")
42317
+ ], ChoiceSetService.prototype, "create", null);
42318
+ __decorate([
42319
+ track("Choicesets.UpdateById")
42320
+ ], ChoiceSetService.prototype, "updateById", null);
42321
+ __decorate([
42322
+ track("Choicesets.DeleteById")
42323
+ ], ChoiceSetService.prototype, "deleteById", null);
42324
+ __decorate([
42325
+ track("Choicesets.InsertValueById")
42326
+ ], ChoiceSetService.prototype, "insertValueById", null);
42327
+ __decorate([
42328
+ track("Choicesets.UpdateValueById")
42329
+ ], ChoiceSetService.prototype, "updateValueById", null);
42330
+ __decorate([
42331
+ track("Choicesets.DeleteValuesById")
42332
+ ], ChoiceSetService.prototype, "deleteValuesById", null);
41808
42333
  function createProcessMethods(processData, service) {
41809
42334
  return {
41810
42335
  async getIncidents() {
@@ -41820,6 +42345,30 @@ function createProcessWithMethods(processData, service) {
41820
42345
  const methods = createProcessMethods(processData, service);
41821
42346
  return Object.assign({}, processData, methods);
41822
42347
  }
42348
+ function buildInsightsTopBody(startTime, endTime, isCaseManagement, options) {
42349
+ return {
42350
+ commonParams: {
42351
+ startTime: startTime.getTime(),
42352
+ endTime: endTime.getTime(),
42353
+ isCaseManagement,
42354
+ ...options?.packageId ? { packageId: options.packageId } : {},
42355
+ ...options?.processKey ? { processKey: options.processKey } : {},
42356
+ ...options?.version ? { version: options.version } : {}
42357
+ }
42358
+ };
42359
+ }
42360
+ async function fetchInstanceStatusTimeline(postFn, startTime, endTime, isCaseManagement, options) {
42361
+ const response = await postFn(MAESTRO_ENDPOINTS.INSIGHTS.INSTANCE_STATUS_BY_DATE, {
42362
+ commonParams: {
42363
+ startTime: startTime.getTime(),
42364
+ endTime: endTime.getTime(),
42365
+ isCaseManagement
42366
+ },
42367
+ timeSliceUnit: options?.groupBy,
42368
+ timezoneOffset: new Date().getTimezoneOffset() * -1
42369
+ });
42370
+ return response.data ?? [];
42371
+ }
41823
42372
  var ProcessIncidentMap = {
41824
42373
  errorTimeUtc: "errorTime"
41825
42374
  };
@@ -41895,8 +42444,8 @@ class BpmnHelpers {
41895
42444
  const transformed = transformData(incident, ProcessIncidentMap);
41896
42445
  return {
41897
42446
  ...transformed,
41898
- incidentElementActivityType: element?.type || UNKNOWN,
41899
- incidentElementActivityName: element?.name || UNKNOWN
42447
+ incidentElementActivityType: element?.type || UNKNOWN2,
42448
+ incidentElementActivityName: element?.name || UNKNOWN2
41900
42449
  };
41901
42450
  }
41902
42451
  }
@@ -41978,6 +42527,29 @@ var DebugMode;
41978
42527
  DebugMode2["StepByStep"] = "StepByStep";
41979
42528
  DebugMode2["SingleStep"] = "SingleStep";
41980
42529
  })(DebugMode || (DebugMode = {}));
42530
+ var SlaSummaryStatus;
42531
+ (function(SlaSummaryStatus2) {
42532
+ SlaSummaryStatus2["ON_TRACK"] = "On Track";
42533
+ SlaSummaryStatus2["AT_RISK"] = "At Risk";
42534
+ SlaSummaryStatus2["OVERDUE"] = "Overdue";
42535
+ SlaSummaryStatus2["COMPLETED"] = "Completed";
42536
+ SlaSummaryStatus2["UNKNOWN"] = "Unknown";
42537
+ })(SlaSummaryStatus || (SlaSummaryStatus = {}));
42538
+ var InstanceStatus;
42539
+ (function(InstanceStatus2) {
42540
+ InstanceStatus2["UNKNOWN"] = "";
42541
+ InstanceStatus2["CANCELLED"] = "Cancelled";
42542
+ InstanceStatus2["CANCELING"] = "Canceling";
42543
+ InstanceStatus2["COMPLETED"] = "Completed";
42544
+ InstanceStatus2["FAULTED"] = "Faulted";
42545
+ InstanceStatus2["PAUSED"] = "Paused";
42546
+ InstanceStatus2["PAUSING"] = "Pausing";
42547
+ InstanceStatus2["PENDING"] = "Pending";
42548
+ InstanceStatus2["RESUMING"] = "Resuming";
42549
+ InstanceStatus2["RETRYING"] = "Retrying";
42550
+ InstanceStatus2["RUNNING"] = "Running";
42551
+ InstanceStatus2["UPGRADING"] = "Upgrading";
42552
+ })(InstanceStatus || (InstanceStatus = {}));
41981
42553
  var StageTaskType;
41982
42554
  (function(StageTaskType2) {
41983
42555
  StageTaskType2["EXTERNAL_AGENT"] = "external-agent";
@@ -42000,6 +42572,7 @@ var EscalationTriggerType;
42000
42572
  (function(EscalationTriggerType2) {
42001
42573
  EscalationTriggerType2["SLA_BREACHED"] = "sla-breached";
42002
42574
  EscalationTriggerType2["AT_RISK"] = "at-risk";
42575
+ EscalationTriggerType2["NONE"] = "None";
42003
42576
  })(EscalationTriggerType || (EscalationTriggerType = {}));
42004
42577
  var SLADurationUnit;
42005
42578
  (function(SLADurationUnit2) {
@@ -42056,6 +42629,16 @@ function createCaseInstanceMethods(instanceData, service) {
42056
42629
  if (!instanceData.instanceId)
42057
42630
  throw new Error("Case instance ID is undefined");
42058
42631
  return service.getActionTasks(instanceData.instanceId, options);
42632
+ },
42633
+ async getSlaSummary(options) {
42634
+ if (!instanceData.instanceId)
42635
+ throw new Error("Case instance ID is undefined");
42636
+ return service.getSlaSummary({ ...options, caseInstanceId: instanceData.instanceId });
42637
+ },
42638
+ async getStagesSlaSummary() {
42639
+ if (!instanceData.instanceId)
42640
+ throw new Error("Case instance ID is undefined");
42641
+ return service.getStagesSlaSummary({ caseInstanceId: instanceData.instanceId });
42059
42642
  }
42060
42643
  };
42061
42644
  }
@@ -42063,6 +42646,18 @@ function createCaseInstanceWithMethods(instanceData, service) {
42063
42646
  const methods = createCaseInstanceMethods(instanceData, service);
42064
42647
  return Object.assign({}, instanceData, methods);
42065
42648
  }
42649
+ var TimeInterval;
42650
+ (function(TimeInterval2) {
42651
+ TimeInterval2["Hour"] = "HOUR";
42652
+ TimeInterval2["Day"] = "DAY";
42653
+ TimeInterval2["Week"] = "WEEK";
42654
+ })(TimeInterval || (TimeInterval = {}));
42655
+ var InstanceFinalStatus;
42656
+ (function(InstanceFinalStatus2) {
42657
+ InstanceFinalStatus2["Completed"] = "Completed";
42658
+ InstanceFinalStatus2["Faulted"] = "Faulted";
42659
+ InstanceFinalStatus2["Cancelled"] = "Cancelled";
42660
+ })(InstanceFinalStatus || (InstanceFinalStatus = {}));
42066
42661
  var ProcessInstanceMap = {
42067
42662
  startedTimeUtc: "startedTime",
42068
42663
  completedTimeUtc: "completedTime",
@@ -42278,6 +42873,35 @@ class MaestroProcessesService extends BaseService {
42278
42873
  });
42279
42874
  return BpmnHelpers.enrichIncidentsWithBpmnData(rawResponse.data || [], folderKey, this.processInstancesService);
42280
42875
  }
42876
+ async getTopRunCount(startTime, endTime, options) {
42877
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_RUN_COUNT, buildInsightsTopBody(startTime, endTime, false, options));
42878
+ return (data ?? []).map((process10) => ({ ...process10, name: process10.packageId }));
42879
+ }
42880
+ async getTopElementFailedCount(startTime, endTime, options) {
42881
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_ELEMENTS_WITH_FAILURE, buildInsightsTopBody(startTime, endTime, false, options));
42882
+ return (data ?? []).map((item) => ({
42883
+ elementName: item.elementName,
42884
+ elementType: item.elementType,
42885
+ processKey: item.processKey,
42886
+ failedCount: item.count
42887
+ }));
42888
+ }
42889
+ async getInstanceStatusTimeline(startTime, endTime, options) {
42890
+ return fetchInstanceStatusTimeline(this.post.bind(this), startTime, endTime, false, options);
42891
+ }
42892
+ async getTopFaultedCount(startTime, endTime, options) {
42893
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_WITH_FAILURE, buildInsightsTopBody(startTime, endTime, false, options));
42894
+ return (data ?? []).map((item) => ({
42895
+ packageId: item.packageId,
42896
+ processKey: item.processKey,
42897
+ faultedCount: item.runCount,
42898
+ name: item.packageId
42899
+ }));
42900
+ }
42901
+ async getTopExecutionDuration(startTime, endTime, options) {
42902
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_DURATION, buildInsightsTopBody(startTime, endTime, false, options));
42903
+ return (data ?? []).map((process10) => ({ ...process10, name: process10.packageId }));
42904
+ }
42281
42905
  }
42282
42906
  __decorate([
42283
42907
  track("MaestroProcesses.GetAll")
@@ -42285,6 +42909,21 @@ __decorate([
42285
42909
  __decorate([
42286
42910
  track("MaestroProcesses.GetIncidents")
42287
42911
  ], MaestroProcessesService.prototype, "getIncidents", null);
42912
+ __decorate([
42913
+ track("MaestroProcesses.GetTopRunCount")
42914
+ ], MaestroProcessesService.prototype, "getTopRunCount", null);
42915
+ __decorate([
42916
+ track("MaestroProcesses.GetTopElementFailedCount")
42917
+ ], MaestroProcessesService.prototype, "getTopElementFailedCount", null);
42918
+ __decorate([
42919
+ track("MaestroProcesses.GetInstanceStatusTimeline")
42920
+ ], MaestroProcessesService.prototype, "getInstanceStatusTimeline", null);
42921
+ __decorate([
42922
+ track("MaestroProcesses.GetTopFaultedCount")
42923
+ ], MaestroProcessesService.prototype, "getTopFaultedCount", null);
42924
+ __decorate([
42925
+ track("MaestroProcesses.GetTopExecutionDuration")
42926
+ ], MaestroProcessesService.prototype, "getTopExecutionDuration", null);
42288
42927
 
42289
42928
  class ProcessIncidentsService extends BaseService {
42290
42929
  async getAll() {
@@ -42313,6 +42952,35 @@ class CasesService extends BaseService {
42313
42952
  name: this.extractCaseName(caseItem.packageId)
42314
42953
  }));
42315
42954
  }
42955
+ async getTopRunCount(startTime, endTime, options) {
42956
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_RUN_COUNT, buildInsightsTopBody(startTime, endTime, true, options));
42957
+ return (data ?? []).map((process10) => ({ ...process10, name: this.extractCaseName(process10.packageId) }));
42958
+ }
42959
+ async getTopElementFailedCount(startTime, endTime, options) {
42960
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_ELEMENTS_WITH_FAILURE, buildInsightsTopBody(startTime, endTime, true, options));
42961
+ return (data ?? []).map((item) => ({
42962
+ elementName: item.elementName,
42963
+ elementType: item.elementType,
42964
+ processKey: item.processKey,
42965
+ failedCount: item.count
42966
+ }));
42967
+ }
42968
+ async getInstanceStatusTimeline(startTime, endTime, options) {
42969
+ return fetchInstanceStatusTimeline(this.post.bind(this), startTime, endTime, true, options);
42970
+ }
42971
+ async getTopFaultedCount(startTime, endTime, options) {
42972
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_WITH_FAILURE, buildInsightsTopBody(startTime, endTime, true, options));
42973
+ return (data ?? []).map((item) => ({
42974
+ packageId: item.packageId,
42975
+ processKey: item.processKey,
42976
+ faultedCount: item.runCount,
42977
+ name: this.extractCaseName(item.packageId)
42978
+ }));
42979
+ }
42980
+ async getTopExecutionDuration(startTime, endTime, options) {
42981
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_DURATION, buildInsightsTopBody(startTime, endTime, true, options));
42982
+ return (data ?? []).map((process10) => ({ ...process10, name: this.extractCaseName(process10.packageId) }));
42983
+ }
42316
42984
  extractCaseName(packageId) {
42317
42985
  const caseManagementIndex = packageId.indexOf("CaseManagement.");
42318
42986
  if (caseManagementIndex !== -1) {
@@ -42325,6 +42993,21 @@ class CasesService extends BaseService {
42325
42993
  __decorate([
42326
42994
  track("Cases.GetAll")
42327
42995
  ], CasesService.prototype, "getAll", null);
42996
+ __decorate([
42997
+ track("Cases.GetTopRunCount")
42998
+ ], CasesService.prototype, "getTopRunCount", null);
42999
+ __decorate([
43000
+ track("Cases.GetTopElementFailedCount")
43001
+ ], CasesService.prototype, "getTopElementFailedCount", null);
43002
+ __decorate([
43003
+ track("Cases.GetInstanceStatusTimeline")
43004
+ ], CasesService.prototype, "getInstanceStatusTimeline", null);
43005
+ __decorate([
43006
+ track("Cases.GetTopFaultedCount")
43007
+ ], CasesService.prototype, "getTopFaultedCount", null);
43008
+ __decorate([
43009
+ track("Cases.GetTopExecutionDuration")
43010
+ ], CasesService.prototype, "getTopExecutionDuration", null);
42328
43011
  var CaseInstanceMap = {
42329
43012
  startedTimeUtc: "startedTime",
42330
43013
  completedTimeUtc: "completedTime",
@@ -42826,6 +43509,41 @@ class CaseInstancesService extends BaseService {
42826
43509
  };
42827
43510
  return await this.taskService.getAll(enhancedOptions);
42828
43511
  }
43512
+ async getSlaSummary(options) {
43513
+ const apiOptions = options ? {
43514
+ ...options,
43515
+ startTimeUtc: options.startTimeUtc?.toISOString(),
43516
+ endTimeUtc: options.endTimeUtc?.toISOString()
43517
+ } : undefined;
43518
+ return PaginationHelpers.getAll({
43519
+ serviceAccess: this.createPaginationServiceAccess(),
43520
+ getEndpoint: () => MAESTRO_ENDPOINTS.INSIGHTS.SLA_SUMMARY,
43521
+ method: HTTP_METHODS.POST,
43522
+ excludeFromPrefix: ["caseInstanceId", "startTimeUtc", "endTimeUtc"],
43523
+ transformFn: (item) => ({
43524
+ ...item,
43525
+ slaDueTime: toISOUtc(item.slaDueTime),
43526
+ lastModifiedTime: toISOUtc(item.lastModifiedTime)
43527
+ }),
43528
+ pagination: {
43529
+ paginationType: PaginationType.OFFSET,
43530
+ itemsField: SLA_SUMMARY_PAGINATION.ITEMS_FIELD,
43531
+ totalCountField: SLA_SUMMARY_PAGINATION.TOTAL_COUNT_FIELD,
43532
+ paginationParams: {
43533
+ pageSizeParam: SLA_SUMMARY_OFFSET_PARAMS.PAGE_SIZE_PARAM,
43534
+ offsetParam: SLA_SUMMARY_OFFSET_PARAMS.OFFSET_PARAM,
43535
+ countParam: SLA_SUMMARY_OFFSET_PARAMS.COUNT_PARAM,
43536
+ convertToSkip: false
43537
+ }
43538
+ }
43539
+ }, apiOptions);
43540
+ }
43541
+ async getStagesSlaSummary(options) {
43542
+ const response = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.STAGES_SUMMARY, {
43543
+ caseInstanceId: options?.caseInstanceId
43544
+ });
43545
+ return response.data ?? [];
43546
+ }
42829
43547
  }
42830
43548
  __decorate([
42831
43549
  track("CaseInstances.GetAll")
@@ -42854,6 +43572,12 @@ __decorate([
42854
43572
  __decorate([
42855
43573
  track("CaseInstances.GetActionTasks")
42856
43574
  ], CaseInstancesService.prototype, "getActionTasks", null);
43575
+ __decorate([
43576
+ track("CaseInstances.GetSlaSummary")
43577
+ ], CaseInstancesService.prototype, "getSlaSummary", null);
43578
+ __decorate([
43579
+ track("CaseInstances.GetStagesSlaSummary")
43580
+ ], CaseInstancesService.prototype, "getStagesSlaSummary", null);
42857
43581
  function validateName(resourceType, name) {
42858
43582
  if (!name) {
42859
43583
  throw new ValidationError({
@@ -43050,6 +43774,9 @@ class BucketService extends FolderScopedService {
43050
43774
  });
43051
43775
  return pascalToCamelCaseKeys(response.data);
43052
43776
  }
43777
+ async getByName(name, options = {}) {
43778
+ return this.getByNameLookup("Bucket", BUCKET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => pascalToCamelCaseKeys(raw));
43779
+ }
43053
43780
  async getAll(options) {
43054
43781
  const transformBucketResponse = (bucket) => pascalToCamelCaseKeys(bucket);
43055
43782
  return PaginationHelpers.getAll({
@@ -43167,6 +43894,56 @@ class BucketService extends FolderScopedService {
43167
43894
  }
43168
43895
  return transformedData;
43169
43896
  }
43897
+ async getFiles(bucketId, options) {
43898
+ if (!bucketId) {
43899
+ throw new ValidationError({ message: "bucketId is required for getFiles" });
43900
+ }
43901
+ const { folderId, folderKey, folderPath, ...restOptions } = options ?? {};
43902
+ const headers = resolveFolderHeaders({
43903
+ folderId,
43904
+ folderKey,
43905
+ folderPath,
43906
+ resourceType: "Buckets.getFiles",
43907
+ fallbackFolderKey: this.config.folderKey
43908
+ });
43909
+ const transformBucketFile = (file) => transformData(pascalToCamelCaseKeys(file), BucketMap);
43910
+ return PaginationHelpers.getAll({
43911
+ serviceAccess: this.createPaginationServiceAccess(),
43912
+ getEndpoint: () => BUCKET_ENDPOINTS.GET_FILES(bucketId),
43913
+ transformFn: transformBucketFile,
43914
+ pagination: {
43915
+ paginationType: PaginationType.OFFSET,
43916
+ itemsField: ODATA_PAGINATION.ITEMS_FIELD,
43917
+ totalCountField: ODATA_PAGINATION.TOTAL_COUNT_FIELD,
43918
+ paginationParams: {
43919
+ pageSizeParam: ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM,
43920
+ offsetParam: ODATA_OFFSET_PARAMS.OFFSET_PARAM,
43921
+ countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM
43922
+ }
43923
+ },
43924
+ excludeFromPrefix: ["directory", "recursive", "fileNameRegex"],
43925
+ headers
43926
+ }, { ...restOptions, directory: "/", recursive: true });
43927
+ }
43928
+ async deleteFile(bucketId, path3, options) {
43929
+ if (!bucketId) {
43930
+ throw new ValidationError({ message: "bucketId is required for deleteFile" });
43931
+ }
43932
+ if (!path3) {
43933
+ throw new ValidationError({ message: "path is required for deleteFile" });
43934
+ }
43935
+ const headers = resolveFolderHeaders({
43936
+ folderId: options?.folderId,
43937
+ folderKey: options?.folderKey,
43938
+ folderPath: options?.folderPath,
43939
+ resourceType: "Buckets.deleteFile",
43940
+ fallbackFolderKey: this.config.folderKey
43941
+ });
43942
+ await this.delete(BUCKET_ENDPOINTS.DELETE_FILE(bucketId), {
43943
+ params: { path: path3 },
43944
+ headers
43945
+ });
43946
+ }
43170
43947
  async _getWriteUri(options) {
43171
43948
  const { bucketId, folderId, path: path3, expiryInMinutes, ...restOptions } = options;
43172
43949
  const queryOptions = {
@@ -43179,6 +43956,9 @@ class BucketService extends FolderScopedService {
43179
43956
  __decorate([
43180
43957
  track("Buckets.GetById")
43181
43958
  ], BucketService.prototype, "getById", null);
43959
+ __decorate([
43960
+ track("Buckets.GetByName")
43961
+ ], BucketService.prototype, "getByName", null);
43182
43962
  __decorate([
43183
43963
  track("Buckets.GetAll")
43184
43964
  ], BucketService.prototype, "getAll", null);
@@ -43191,6 +43971,12 @@ __decorate([
43191
43971
  __decorate([
43192
43972
  track("Buckets.GetReadUri")
43193
43973
  ], BucketService.prototype, "getReadUri", null);
43974
+ __decorate([
43975
+ track("Buckets.GetFiles")
43976
+ ], BucketService.prototype, "getFiles", null);
43977
+ __decorate([
43978
+ track("Buckets.DeleteFile")
43979
+ ], BucketService.prototype, "deleteFile", null);
43194
43980
  var BucketOptions;
43195
43981
  (function(BucketOptions2) {
43196
43982
  BucketOptions2["None"] = "None";
@@ -43650,14 +44436,34 @@ class ProcessService extends FolderScopedService {
43650
44436
  }
43651
44437
  }, options);
43652
44438
  }
43653
- async start(request, folderId, options = {}) {
43654
- const headers = createHeaders({ [FOLDER_ID]: folderId });
44439
+ async start(request, optionsOrFolderId, legacyOptions) {
44440
+ let folderId;
44441
+ let folderKey;
44442
+ let folderPath;
44443
+ let queryOptions;
44444
+ if (typeof optionsOrFolderId === "number") {
44445
+ folderId = optionsOrFolderId;
44446
+ queryOptions = legacyOptions ?? {};
44447
+ } else {
44448
+ const { folderId: fid, folderKey: fkey, folderPath: fpath, ...rest } = optionsOrFolderId ?? {};
44449
+ folderId = fid;
44450
+ folderKey = fkey;
44451
+ folderPath = fpath;
44452
+ queryOptions = rest;
44453
+ }
44454
+ const headers = resolveFolderHeaders({
44455
+ folderId,
44456
+ folderKey,
44457
+ folderPath,
44458
+ resourceType: "processes.start",
44459
+ fallbackFolderKey: this.config.folderKey
44460
+ });
43655
44461
  const apiRequest = transformRequest(request, ProcessMap);
43656
44462
  const requestBody = {
43657
44463
  startInfo: apiRequest
43658
44464
  };
43659
- const keysToPrefix = Object.keys(options);
43660
- const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
44465
+ const keysToPrefix = Object.keys(queryOptions);
44466
+ const apiOptions = addPrefixToKeys(queryOptions, ODATA_PREFIX, keysToPrefix);
43661
44467
  const response = await this.post(PROCESS_ENDPOINTS.START_PROCESS, requestBody, {
43662
44468
  params: apiOptions,
43663
44469
  headers
@@ -43947,8 +44753,8 @@ var WordGroupType;
43947
44753
  })(WordGroupType || (WordGroupType = {}));
43948
44754
  var ModelKind;
43949
44755
  (function(ModelKind2) {
43950
- ModelKind2["Classifier"] = "Classifier";
43951
44756
  ModelKind2["Extractor"] = "Extractor";
44757
+ ModelKind2["Classifier"] = "Classifier";
43952
44758
  })(ModelKind || (ModelKind = {}));
43953
44759
  var ModelType;
43954
44760
  (function(ModelType2) {
@@ -43956,6 +44762,12 @@ var ModelType;
43956
44762
  ModelType2["Modern"] = "Modern";
43957
44763
  ModelType2["Predefined"] = "Predefined";
43958
44764
  })(ModelType || (ModelType = {}));
44765
+ var ErrorSeverity;
44766
+ (function(ErrorSeverity2) {
44767
+ ErrorSeverity2["Info"] = "Info";
44768
+ ErrorSeverity2["Warning"] = "Warning";
44769
+ ErrorSeverity2["Error"] = "Error";
44770
+ })(ErrorSeverity || (ErrorSeverity = {}));
43959
44771
  var ClassifierDocumentTypeType;
43960
44772
  (function(ClassifierDocumentTypeType2) {
43961
44773
  ClassifierDocumentTypeType2["FormsAi"] = "FormsAi";
@@ -43979,6 +44791,13 @@ var GptFieldType;
43979
44791
  GptFieldType2["Number"] = "Number";
43980
44792
  GptFieldType2["Text"] = "Text";
43981
44793
  })(GptFieldType || (GptFieldType = {}));
44794
+ var JobStatus;
44795
+ (function(JobStatus2) {
44796
+ JobStatus2["Succeeded"] = "Succeeded";
44797
+ JobStatus2["Failed"] = "Failed";
44798
+ JobStatus2["Running"] = "Running";
44799
+ JobStatus2["NotStarted"] = "NotStarted";
44800
+ })(JobStatus || (JobStatus = {}));
43982
44801
  var ValidationDisplayMode;
43983
44802
  (function(ValidationDisplayMode2) {
43984
44803
  ValidationDisplayMode2["Classic"] = "Classic";