@uipath/rpa-tool 0.9.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +139 -76
  2. package/dist/tool.js +1755 -14765
  3. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -4407,6 +4407,66 @@ Command2.prototype.examples = function(examples) {
4407
4407
  examplesByCommand.set(this, examples);
4408
4408
  return this;
4409
4409
  };
4410
+ var PREFIX = "@uipath/common/";
4411
+ var _g = globalThis;
4412
+ function singleton(ctorOrName) {
4413
+ const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name;
4414
+ const key = Symbol.for(PREFIX + name);
4415
+ return {
4416
+ get(fallback) {
4417
+ return _g[key] ?? fallback;
4418
+ },
4419
+ set(value) {
4420
+ _g[key] = value;
4421
+ },
4422
+ clear() {
4423
+ delete _g[key];
4424
+ },
4425
+ getOrInit(factory, guard) {
4426
+ const existing = _g[key];
4427
+ if (existing != null && typeof existing === "object") {
4428
+ if (!guard || guard(existing)) {
4429
+ return existing;
4430
+ }
4431
+ }
4432
+ const instance = factory();
4433
+ _g[key] = instance;
4434
+ return instance;
4435
+ }
4436
+ };
4437
+ }
4438
+ function createStorage() {
4439
+ const [error, mod] = catchError(() => __require2("node:async_hooks"));
4440
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
4441
+ return {
4442
+ getStore: () => {
4443
+ return;
4444
+ },
4445
+ run: (_store, fn) => fn()
4446
+ };
4447
+ }
4448
+ return new mod.AsyncLocalStorage;
4449
+ }
4450
+ var storageSingleton = singleton("OutputStorage");
4451
+ var sinkSlot = singleton("OutputSink");
4452
+ var outputStorage = storageSingleton.getOrInit(createStorage, (v) => ("getStore" in v));
4453
+ var CONSOLE_FALLBACK = {
4454
+ writeOut: (str) => process.stdout.write(str),
4455
+ writeErr: (str) => process.stderr.write(str),
4456
+ writeLog: (str) => process.stdout.write(str),
4457
+ capabilities: {
4458
+ isInteractive: false,
4459
+ supportsColor: false,
4460
+ outputWidth: 80
4461
+ }
4462
+ };
4463
+ function getOutputSink() {
4464
+ return outputStorage.getStore() ?? sinkSlot.get() ?? CONSOLE_FALLBACK;
4465
+ }
4466
+ var COMPLETER_SYMBOL = Symbol.for("@uipath/common/completer");
4467
+ var guardInstalledSlot = singleton("ConsoleGuardInstalled");
4468
+ var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
4469
+ var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
4410
4470
  var isObject = (obj) => {
4411
4471
  return obj !== null && Object.prototype.toString.call(obj) === "[object Object]";
4412
4472
  };
@@ -9636,6 +9696,15 @@ class NodeFileSystem {
9636
9696
  async rename(oldPath, newPath) {
9637
9697
  await fs6.rename(oldPath, newPath);
9638
9698
  }
9699
+ async realpath(filePath) {
9700
+ try {
9701
+ return await fs6.realpath(filePath);
9702
+ } catch (error) {
9703
+ if (this.isEnoent(error))
9704
+ return filePath;
9705
+ throw error;
9706
+ }
9707
+ }
9639
9708
  async getTempDir() {
9640
9709
  return await fs6.mkdtemp(path2.join(os2.tmpdir(), "uipath-fs-"));
9641
9710
  }
@@ -9673,62 +9742,6 @@ var fsInstance = new NodeFileSystem;
9673
9742
  var getFileSystem = () => {
9674
9743
  return fsInstance;
9675
9744
  };
9676
- var PREFIX = "@uipath/common/";
9677
- var _g = globalThis;
9678
- function singleton(ctorOrName) {
9679
- const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name;
9680
- const key = Symbol.for(PREFIX + name);
9681
- return {
9682
- get(fallback) {
9683
- return _g[key] ?? fallback;
9684
- },
9685
- set(value) {
9686
- _g[key] = value;
9687
- },
9688
- clear() {
9689
- delete _g[key];
9690
- },
9691
- getOrInit(factory, guard) {
9692
- const existing = _g[key];
9693
- if (existing != null && typeof existing === "object") {
9694
- if (!guard || guard(existing)) {
9695
- return existing;
9696
- }
9697
- }
9698
- const instance = factory();
9699
- _g[key] = instance;
9700
- return instance;
9701
- }
9702
- };
9703
- }
9704
- function createStorage() {
9705
- const [error, mod2] = catchError(() => __require2("node:async_hooks"));
9706
- if (error || typeof mod2?.AsyncLocalStorage !== "function") {
9707
- return {
9708
- getStore: () => {
9709
- return;
9710
- },
9711
- run: (_store, fn) => fn()
9712
- };
9713
- }
9714
- return new mod2.AsyncLocalStorage;
9715
- }
9716
- var storageSingleton = singleton("OutputStorage");
9717
- var sinkSlot = singleton("OutputSink");
9718
- var outputStorage = storageSingleton.getOrInit(createStorage, (v) => ("getStore" in v));
9719
- var CONSOLE_FALLBACK = {
9720
- writeOut: (str2) => process.stdout.write(str2),
9721
- writeErr: (str2) => process.stderr.write(str2),
9722
- writeLog: (str2) => process.stdout.write(str2),
9723
- capabilities: {
9724
- isInteractive: false,
9725
- supportsColor: false,
9726
- outputWidth: 80
9727
- }
9728
- };
9729
- function getOutputSink() {
9730
- return outputStorage.getStore() ?? sinkSlot.get() ?? CONSOLE_FALLBACK;
9731
- }
9732
9745
  var logFilePathSlot = singleton("logFilePath");
9733
9746
  function setGlobalLogFilePath(path3) {
9734
9747
  logFilePathSlot.set(path3);
@@ -9928,8 +9941,8 @@ function getLogFilePath() {
9928
9941
  var formatSlot = singleton("OutputFormat");
9929
9942
  var formatExplicitSlot = singleton("OutputFormatExplicit");
9930
9943
  var filterSlot = singleton("OutputFilter");
9931
- function setOutputFormat(format) {
9932
- formatSlot.set(format);
9944
+ function setOutputFormat(format2) {
9945
+ formatSlot.set(format2);
9933
9946
  }
9934
9947
  function getOutputFormat() {
9935
9948
  return formatSlot.get("json");
@@ -10113,6 +10126,64 @@ function toOperationUrn(name) {
10113
10126
  const sanitized = encodeURIComponent(name).replace(/%2F/g, "/");
10114
10127
  return `urn:uip:${sanitized}`;
10115
10128
  }
10129
+ function isRecord(value) {
10130
+ return value !== null && typeof value === "object";
10131
+ }
10132
+ function formatFlushJsonError(error) {
10133
+ if (error instanceof Error)
10134
+ return error.message;
10135
+ if (typeof error === "string")
10136
+ return error;
10137
+ if (!isRecord(error))
10138
+ return String(error);
10139
+ const parts = [];
10140
+ if (error.index !== undefined) {
10141
+ parts.push(`index ${String(error.index)}`);
10142
+ }
10143
+ if (error.statusCode !== undefined) {
10144
+ parts.push(`status ${String(error.statusCode)}`);
10145
+ }
10146
+ if (error.message !== undefined) {
10147
+ parts.push(String(error.message));
10148
+ }
10149
+ return parts.length > 0 ? parts.join(": ") : JSON.stringify(error);
10150
+ }
10151
+ function stripAppInsightsDumpStack(response) {
10152
+ return response.replace(/stack:\s*(['"`])[\s\S]*?\1\s*,?\s*/g, "").replace(/^\[object Error\]\s*/, "").trim();
10153
+ }
10154
+ function extractAppInsightsDumpMessage(response) {
10155
+ if (!response.startsWith("[object Error]"))
10156
+ return;
10157
+ const messageMatch = response.match(/\bmessage:\s*(['"`])([\s\S]*?)\1/);
10158
+ if (messageMatch?.[2])
10159
+ return messageMatch[2];
10160
+ const normalizedDiagnostic = stripAppInsightsDumpStack(response);
10161
+ if (normalizedDiagnostic && normalizedDiagnostic !== "{}") {
10162
+ return normalizedDiagnostic;
10163
+ }
10164
+ const stackLineMatch = response.match(/Error:\s*[^\\\n\r']+/);
10165
+ return stackLineMatch?.[0] ?? response;
10166
+ }
10167
+ function normalizeFlushCallbackError(response) {
10168
+ if (response === undefined || response === null)
10169
+ return;
10170
+ if (response instanceof Error)
10171
+ return response.message;
10172
+ const text = String(response).trim();
10173
+ if (!text)
10174
+ return;
10175
+ if (text.toLowerCase().includes("no data to send"))
10176
+ return;
10177
+ const [parseError, parsed] = catchError(() => JSON.parse(text));
10178
+ if (!parseError) {
10179
+ const errors = isRecord(parsed) ? parsed.errors : undefined;
10180
+ if (Array.isArray(errors) && errors.length > 0) {
10181
+ return errors.map(formatFlushJsonError).join("; ");
10182
+ }
10183
+ return;
10184
+ }
10185
+ return extractAppInsightsDumpMessage(text) ?? text;
10186
+ }
10116
10187
  async function loadApplicationInsights() {
10117
10188
  const savedDebug = process.env.DEBUG;
10118
10189
  delete process.env.DEBUG;
@@ -10237,16 +10308,12 @@ class NodeAppInsightsTelemetryProvider {
10237
10308
  const [error] = await catchError(new Promise((resolve2, reject) => {
10238
10309
  client.flush({
10239
10310
  callback: (response) => {
10240
- if (!response) {
10311
+ const errorMessage = normalizeFlushCallbackError(response);
10312
+ if (errorMessage === undefined) {
10241
10313
  resolve2();
10242
10314
  return;
10243
10315
  }
10244
- const [parseError, parsed] = catchError(() => JSON.parse(response));
10245
- if (parseError || parsed?.errors && parsed.errors.length > 0) {
10246
- reject(new Error(response));
10247
- } else {
10248
- resolve2();
10249
- }
10316
+ reject(new Error(errorMessage));
10250
10317
  }
10251
10318
  });
10252
10319
  }));
@@ -10400,11 +10467,11 @@ var EXIT_CODES = {
10400
10467
  ValidationError: 3,
10401
10468
  TimeoutError: 4
10402
10469
  };
10403
-
10404
10470
  class SuccessOutput {
10405
10471
  Result = RESULTS.Success;
10406
10472
  Code;
10407
10473
  Data;
10474
+ Pagination;
10408
10475
  Instructions;
10409
10476
  Log;
10410
10477
  constructor(code, data) {
@@ -10416,12 +10483,12 @@ class SuccessOutput {
10416
10483
  }
10417
10484
  }
10418
10485
  }
10419
- function printOutput(data, format = "json", logFn) {
10486
+ function printOutput(data, format2 = "json", logFn) {
10420
10487
  if (!data) {
10421
10488
  logFn("Empty response object. No data to display.");
10422
10489
  return;
10423
10490
  }
10424
- switch (format) {
10491
+ switch (format2) {
10425
10492
  case "json":
10426
10493
  logFn(JSON.stringify(data, null, 2));
10427
10494
  break;
@@ -10456,9 +10523,9 @@ function printOutput(data, format = "json", logFn) {
10456
10523
  }
10457
10524
  }
10458
10525
  }
10459
- function logOutput(data, format = "json") {
10526
+ function logOutput(data, format2 = "json") {
10460
10527
  const sink = getOutputSink();
10461
- printOutput(data, format, (msg) => sink.writeOut(`${msg}
10528
+ printOutput(data, format2, (msg) => sink.writeOut(`${msg}
10462
10529
  `));
10463
10530
  }
10464
10531
  function cellToString(val) {
@@ -10636,9 +10703,9 @@ var OutputFormatter;
10636
10703
  }
10637
10704
  OutputFormatter2.emitList = emitList;
10638
10705
  function log(data) {
10639
- const format = getOutputFormat();
10706
+ const format2 = getOutputFormat();
10640
10707
  const sink = getOutputSink();
10641
- if (format === "json") {
10708
+ if (format2 === "json") {
10642
10709
  sink.writeErr(`${JSON.stringify(data)}
10643
10710
  `);
10644
10711
  } else {
@@ -10663,10 +10730,6 @@ var OutputFormatter;
10663
10730
  }
10664
10731
  OutputFormatter2.formatToString = formatToString;
10665
10732
  })(OutputFormatter ||= {});
10666
- var COMPLETER_SYMBOL = Symbol.for("@uipath/common/completer");
10667
- var guardInstalledSlot = singleton("ConsoleGuardInstalled");
10668
- var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
10669
- var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
10670
10733
  class Hooks {
10671
10734
  add(name, callback, first) {
10672
10735
  if (typeof arguments[0] != "string") {