@uipath/integrationservice-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 +938 -430
- package/package.json +28 -36
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
|
|
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 = "/
|
|
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,10 +21222,15 @@ 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
|
// package.json
|
|
21137
21230
|
var package_default = {
|
|
21138
21231
|
name: "@uipath/integrationservice-tool",
|
|
21139
|
-
|
|
21232
|
+
license: "MIT",
|
|
21233
|
+
version: "1.195.0",
|
|
21140
21234
|
description: "Manage Integration Service connectors, connections, and triggers.",
|
|
21141
21235
|
private: false,
|
|
21142
21236
|
repository: {
|
|
@@ -21317,10 +21411,15 @@ async function extractErrorDetails(error, options) {
|
|
|
21317
21411
|
}
|
|
21318
21412
|
if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
|
|
21319
21413
|
context.errorCode = parsedBody.errorCode;
|
|
21414
|
+
} else if (parsedBody?.code && typeof parsedBody.code === "string") {
|
|
21415
|
+
context.errorCode = parsedBody.code;
|
|
21320
21416
|
}
|
|
21321
21417
|
if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
|
|
21322
21418
|
context.requestId = parsedBody.requestId;
|
|
21323
21419
|
}
|
|
21420
|
+
if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
|
|
21421
|
+
context.traceId = parsedBody.traceId;
|
|
21422
|
+
}
|
|
21324
21423
|
if (status === 429) {
|
|
21325
21424
|
const resp = response;
|
|
21326
21425
|
const headersObj = resp?.headers;
|
|
@@ -21340,7 +21439,35 @@ async function extractErrorDetails(error, options) {
|
|
|
21340
21439
|
}
|
|
21341
21440
|
}
|
|
21342
21441
|
const hasContext = Object.keys(context).length > 0;
|
|
21343
|
-
|
|
21442
|
+
let parsedErrors;
|
|
21443
|
+
if (parsedBody?.errors && typeof parsedBody.errors === "object") {
|
|
21444
|
+
const errors = {};
|
|
21445
|
+
for (const [field, raw] of Object.entries(parsedBody.errors)) {
|
|
21446
|
+
if (Array.isArray(raw)) {
|
|
21447
|
+
const messages = raw.map((entry) => {
|
|
21448
|
+
if (typeof entry === "string")
|
|
21449
|
+
return entry;
|
|
21450
|
+
if (entry && typeof entry === "object" && typeof entry.message === "string") {
|
|
21451
|
+
return entry.message;
|
|
21452
|
+
}
|
|
21453
|
+
return String(entry);
|
|
21454
|
+
}).filter(Boolean);
|
|
21455
|
+
if (messages.length > 0)
|
|
21456
|
+
errors[field] = messages;
|
|
21457
|
+
} else if (typeof raw === "string") {
|
|
21458
|
+
errors[field] = [raw];
|
|
21459
|
+
}
|
|
21460
|
+
}
|
|
21461
|
+
if (Object.keys(errors).length > 0)
|
|
21462
|
+
parsedErrors = errors;
|
|
21463
|
+
}
|
|
21464
|
+
return {
|
|
21465
|
+
result,
|
|
21466
|
+
message,
|
|
21467
|
+
details,
|
|
21468
|
+
...hasContext ? { context } : {},
|
|
21469
|
+
...parsedErrors ? { parsedErrors } : {}
|
|
21470
|
+
};
|
|
21344
21471
|
}
|
|
21345
21472
|
async function extractErrorMessage(error, options) {
|
|
21346
21473
|
const { message } = await extractErrorDetails(error, options);
|
|
@@ -26488,6 +26615,60 @@ function escapeNonAscii(jsonText) {
|
|
|
26488
26615
|
function needsAsciiSafeJson(sink) {
|
|
26489
26616
|
return process.platform === "win32" && !sink.capabilities.isInteractive;
|
|
26490
26617
|
}
|
|
26618
|
+
function isPlainRecord(value) {
|
|
26619
|
+
if (value === null || typeof value !== "object")
|
|
26620
|
+
return false;
|
|
26621
|
+
const prototype = Object.getPrototypeOf(value);
|
|
26622
|
+
return prototype === Object.prototype || prototype === null;
|
|
26623
|
+
}
|
|
26624
|
+
function toLowerCamelCaseKey(key) {
|
|
26625
|
+
if (!key)
|
|
26626
|
+
return key;
|
|
26627
|
+
if (/[_\-\s]/.test(key)) {
|
|
26628
|
+
const [firstPart, ...restParts] = key.split(/[_\-\s]+/).filter(Boolean);
|
|
26629
|
+
if (!firstPart)
|
|
26630
|
+
return key;
|
|
26631
|
+
return [
|
|
26632
|
+
toLowerCamelCaseSimpleKey(firstPart),
|
|
26633
|
+
...restParts.map((part) => {
|
|
26634
|
+
const normalized = toLowerCamelCaseSimpleKey(part);
|
|
26635
|
+
return normalized.charAt(0).toUpperCase() + normalized.slice(1);
|
|
26636
|
+
})
|
|
26637
|
+
].join("");
|
|
26638
|
+
}
|
|
26639
|
+
return toLowerCamelCaseSimpleKey(key);
|
|
26640
|
+
}
|
|
26641
|
+
function toLowerCamelCaseSimpleKey(key) {
|
|
26642
|
+
if (/^[A-Z0-9]+$/.test(key))
|
|
26643
|
+
return key.toLowerCase();
|
|
26644
|
+
return key.replace(/^[A-Z]+(?=[A-Z][a-z]|\d|$)|^[A-Z]/, (match) => match.toLowerCase());
|
|
26645
|
+
}
|
|
26646
|
+
function toPascalCaseKey(key) {
|
|
26647
|
+
const lowerCamelKey = toLowerCamelCaseKey(key);
|
|
26648
|
+
return lowerCamelKey ? lowerCamelKey.charAt(0).toUpperCase() + lowerCamelKey.slice(1) : lowerCamelKey;
|
|
26649
|
+
}
|
|
26650
|
+
function toPascalCaseData(value) {
|
|
26651
|
+
if (Array.isArray(value))
|
|
26652
|
+
return value.map(toPascalCaseData);
|
|
26653
|
+
if (!isPlainRecord(value))
|
|
26654
|
+
return value;
|
|
26655
|
+
const result = {};
|
|
26656
|
+
for (const [key, nestedValue] of Object.entries(value)) {
|
|
26657
|
+
result[toPascalCaseKey(key)] = toPascalCaseData(nestedValue);
|
|
26658
|
+
}
|
|
26659
|
+
return result;
|
|
26660
|
+
}
|
|
26661
|
+
function normalizeDataKeys(data) {
|
|
26662
|
+
return toPascalCaseData(data);
|
|
26663
|
+
}
|
|
26664
|
+
function normalizeOutputKeys(data) {
|
|
26665
|
+
const result = {};
|
|
26666
|
+
for (const [key, value] of Object.entries(data)) {
|
|
26667
|
+
const pascalKey = toPascalCaseKey(key);
|
|
26668
|
+
result[pascalKey] = pascalKey === "Data" ? value : toPascalCaseData(value);
|
|
26669
|
+
}
|
|
26670
|
+
return result;
|
|
26671
|
+
}
|
|
26491
26672
|
function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
26492
26673
|
if (!data) {
|
|
26493
26674
|
logFn("Empty response object. No data to display.");
|
|
@@ -26550,7 +26731,7 @@ function wrapText(text, width) {
|
|
|
26550
26731
|
function printTable(data, logFn, externalLogValue) {
|
|
26551
26732
|
if (data.length === 0)
|
|
26552
26733
|
return;
|
|
26553
|
-
const keys = Object.keys(data[0]).filter((key) =>
|
|
26734
|
+
const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
26554
26735
|
const maxWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
|
|
26555
26736
|
const header = keys.map((key, i2) => key.padEnd(maxWidths[i2])).join(" | ");
|
|
26556
26737
|
logFn(header);
|
|
@@ -26565,7 +26746,7 @@ function printTable(data, logFn, externalLogValue) {
|
|
|
26565
26746
|
}
|
|
26566
26747
|
}
|
|
26567
26748
|
function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
26568
|
-
const keys = Object.keys(data).filter((key) =>
|
|
26749
|
+
const keys = Object.keys(data).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
26569
26750
|
if (keys.length === 0)
|
|
26570
26751
|
return;
|
|
26571
26752
|
const maxKeyWidth = Math.max(...keys.map((key) => key.length));
|
|
@@ -26581,7 +26762,7 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
|
26581
26762
|
function printResizableTable(data, logFn = console.log, externalLogValue) {
|
|
26582
26763
|
if (data.length === 0)
|
|
26583
26764
|
return;
|
|
26584
|
-
const keys = Object.keys(data[0]).filter((key) =>
|
|
26765
|
+
const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
26585
26766
|
if (keys.length === 0)
|
|
26586
26767
|
return;
|
|
26587
26768
|
if (!process.stdout.isTTY) {
|
|
@@ -26657,8 +26838,26 @@ function printResizableTable(data, logFn = console.log, externalLogValue) {
|
|
|
26657
26838
|
function toYaml(data) {
|
|
26658
26839
|
return dump(data);
|
|
26659
26840
|
}
|
|
26841
|
+
class FilterEvaluationError extends Error {
|
|
26842
|
+
__brand = "FilterEvaluationError";
|
|
26843
|
+
filter;
|
|
26844
|
+
instructions;
|
|
26845
|
+
result = RESULTS.ValidationError;
|
|
26846
|
+
constructor(filter, cause) {
|
|
26847
|
+
const underlying = cause instanceof Error ? cause.message : String(cause);
|
|
26848
|
+
super(`Filter '${filter}' failed to evaluate: ${underlying}`);
|
|
26849
|
+
this.name = "FilterEvaluationError";
|
|
26850
|
+
this.filter = filter;
|
|
26851
|
+
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(@)'.";
|
|
26852
|
+
}
|
|
26853
|
+
}
|
|
26660
26854
|
function applyFilter(data, filter) {
|
|
26661
|
-
|
|
26855
|
+
let result;
|
|
26856
|
+
try {
|
|
26857
|
+
result = search(data, filter);
|
|
26858
|
+
} catch (err) {
|
|
26859
|
+
throw new FilterEvaluationError(filter, err);
|
|
26860
|
+
}
|
|
26662
26861
|
if (result == null)
|
|
26663
26862
|
return [];
|
|
26664
26863
|
if (Array.isArray(result)) {
|
|
@@ -26675,13 +26874,18 @@ function applyFilter(data, filter) {
|
|
|
26675
26874
|
}
|
|
26676
26875
|
var OutputFormatter;
|
|
26677
26876
|
((OutputFormatter) => {
|
|
26678
|
-
function success(data) {
|
|
26877
|
+
function success(data, options) {
|
|
26679
26878
|
data.Log ??= getLogFilePath() || undefined;
|
|
26879
|
+
const normalize = !options?.preserveDataKeys;
|
|
26880
|
+
if (normalize) {
|
|
26881
|
+
data.Data = normalizeDataKeys(data.Data);
|
|
26882
|
+
}
|
|
26680
26883
|
const filter = getOutputFilter();
|
|
26681
26884
|
if (filter) {
|
|
26682
|
-
|
|
26885
|
+
const filtered = applyFilter(data.Data, filter);
|
|
26886
|
+
data.Data = normalize ? normalizeDataKeys(filtered) : filtered;
|
|
26683
26887
|
}
|
|
26684
|
-
logOutput(data, getOutputFormat());
|
|
26888
|
+
logOutput(normalizeOutputKeys(data), getOutputFormat());
|
|
26685
26889
|
}
|
|
26686
26890
|
OutputFormatter.success = success;
|
|
26687
26891
|
function error(data) {
|
|
@@ -26691,7 +26895,7 @@ var OutputFormatter;
|
|
|
26691
26895
|
result: data.Result,
|
|
26692
26896
|
message: data.Message
|
|
26693
26897
|
});
|
|
26694
|
-
logOutput(data, getOutputFormat());
|
|
26898
|
+
logOutput(normalizeOutputKeys(data), getOutputFormat());
|
|
26695
26899
|
}
|
|
26696
26900
|
OutputFormatter.error = error;
|
|
26697
26901
|
function emitList(code, items, opts) {
|
|
@@ -26712,13 +26916,14 @@ var OutputFormatter;
|
|
|
26712
26916
|
function log(data) {
|
|
26713
26917
|
const format = getOutputFormat();
|
|
26714
26918
|
const sink = getOutputSink();
|
|
26919
|
+
const normalized = toPascalCaseData(data);
|
|
26715
26920
|
if (format === "json") {
|
|
26716
|
-
const json2 = JSON.stringify(
|
|
26921
|
+
const json2 = JSON.stringify(normalized);
|
|
26717
26922
|
const safe = needsAsciiSafeJson(sink) ? escapeNonAscii(json2) : json2;
|
|
26718
26923
|
sink.writeErr(`${safe}
|
|
26719
26924
|
`);
|
|
26720
26925
|
} else {
|
|
26721
|
-
for (const [key, value] of Object.entries(
|
|
26926
|
+
for (const [key, value] of Object.entries(normalized)) {
|
|
26722
26927
|
sink.writeErr(`${key}: ${value}
|
|
26723
26928
|
`);
|
|
26724
26929
|
}
|
|
@@ -26727,12 +26932,16 @@ var OutputFormatter;
|
|
|
26727
26932
|
OutputFormatter.log = log;
|
|
26728
26933
|
function formatToString(data) {
|
|
26729
26934
|
const filter = getOutputFilter();
|
|
26730
|
-
if (
|
|
26731
|
-
data.Data =
|
|
26935
|
+
if ("Data" in data && data.Data != null) {
|
|
26936
|
+
data.Data = normalizeDataKeys(data.Data);
|
|
26937
|
+
if (filter) {
|
|
26938
|
+
data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
|
|
26939
|
+
}
|
|
26732
26940
|
}
|
|
26941
|
+
const output = normalizeOutputKeys(data);
|
|
26733
26942
|
const lines = [];
|
|
26734
26943
|
const sink = getOutputSink();
|
|
26735
|
-
printOutput(
|
|
26944
|
+
printOutput(output, getOutputFormat(), (msg) => {
|
|
26736
26945
|
lines.push(msg);
|
|
26737
26946
|
}, needsAsciiSafeJson(sink));
|
|
26738
26947
|
return lines.join(`
|
|
@@ -28235,6 +28444,13 @@ var BACKOFF_DEFAULTS = {
|
|
|
28235
28444
|
};
|
|
28236
28445
|
var MIN_INTERVAL_MS = 100;
|
|
28237
28446
|
|
|
28447
|
+
// ../common/src/polling/poll-failure-mapping.ts
|
|
28448
|
+
var REASON_BY_OUTCOME = {
|
|
28449
|
+
[PollOutcome.Timeout]: "poll_timeout",
|
|
28450
|
+
[PollOutcome.Failed]: "poll_failed",
|
|
28451
|
+
[PollOutcome.Interrupted]: "poll_failed",
|
|
28452
|
+
[PollOutcome.Aborted]: "poll_aborted"
|
|
28453
|
+
};
|
|
28238
28454
|
// ../common/src/polling/poll-until.ts
|
|
28239
28455
|
function resolveIntervalFn(options) {
|
|
28240
28456
|
if (typeof options.intervalMs === "function") {
|
|
@@ -28642,6 +28858,105 @@ var ScreenLogger;
|
|
|
28642
28858
|
}
|
|
28643
28859
|
ScreenLogger.progress = progress;
|
|
28644
28860
|
})(ScreenLogger ||= {});
|
|
28861
|
+
// ../common/src/sdk-user-agent.ts
|
|
28862
|
+
var USER_AGENT_HEADER = "User-Agent";
|
|
28863
|
+
var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
|
|
28864
|
+
function userAgentPatchKey(userAgent) {
|
|
28865
|
+
return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
|
|
28866
|
+
}
|
|
28867
|
+
function splitUserAgentTokens(value) {
|
|
28868
|
+
return value?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
28869
|
+
}
|
|
28870
|
+
function appendUserAgentToken(value, userAgent) {
|
|
28871
|
+
const tokens = splitUserAgentTokens(value);
|
|
28872
|
+
const seen = new Set(tokens);
|
|
28873
|
+
for (const token of splitUserAgentTokens(userAgent)) {
|
|
28874
|
+
if (!seen.has(token)) {
|
|
28875
|
+
tokens.push(token);
|
|
28876
|
+
seen.add(token);
|
|
28877
|
+
}
|
|
28878
|
+
}
|
|
28879
|
+
return tokens.join(" ");
|
|
28880
|
+
}
|
|
28881
|
+
function getEffectiveUserAgent(userAgent) {
|
|
28882
|
+
return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
|
|
28883
|
+
}
|
|
28884
|
+
function isHeadersLike(headers) {
|
|
28885
|
+
return typeof headers === "object" && headers !== null && "get" in headers && typeof headers.get === "function" && "set" in headers && typeof headers.set === "function";
|
|
28886
|
+
}
|
|
28887
|
+
function getSdkUserAgentToken(pkg) {
|
|
28888
|
+
const packageName = pkg.name.replace(/^@uipath\//, "");
|
|
28889
|
+
return getEffectiveUserAgent(`${packageName}/${pkg.version}`);
|
|
28890
|
+
}
|
|
28891
|
+
function addSdkUserAgentHeader(headers, userAgent) {
|
|
28892
|
+
const result = { ...headers ?? {} };
|
|
28893
|
+
const effectiveUserAgent = getEffectiveUserAgent(userAgent);
|
|
28894
|
+
const headerName = Object.keys(result).find((key) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
|
|
28895
|
+
if (headerName) {
|
|
28896
|
+
result[headerName] = appendUserAgentToken(result[headerName], effectiveUserAgent);
|
|
28897
|
+
} else {
|
|
28898
|
+
result[USER_AGENT_HEADER] = effectiveUserAgent;
|
|
28899
|
+
}
|
|
28900
|
+
return result;
|
|
28901
|
+
}
|
|
28902
|
+
function withSdkUserAgentHeader(headers, userAgent) {
|
|
28903
|
+
const effectiveUserAgent = getEffectiveUserAgent(userAgent);
|
|
28904
|
+
if (isHeadersLike(headers)) {
|
|
28905
|
+
headers.set(USER_AGENT_HEADER, appendUserAgentToken(headers.get(USER_AGENT_HEADER), effectiveUserAgent));
|
|
28906
|
+
return headers;
|
|
28907
|
+
}
|
|
28908
|
+
if (Array.isArray(headers)) {
|
|
28909
|
+
const result = headers.map((entry) => {
|
|
28910
|
+
const [key, value] = entry;
|
|
28911
|
+
return [key, value];
|
|
28912
|
+
});
|
|
28913
|
+
const headerIndex = result.findIndex(([key]) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
|
|
28914
|
+
if (headerIndex >= 0) {
|
|
28915
|
+
const [key, value] = result[headerIndex];
|
|
28916
|
+
result[headerIndex] = [
|
|
28917
|
+
key,
|
|
28918
|
+
appendUserAgentToken(value, effectiveUserAgent)
|
|
28919
|
+
];
|
|
28920
|
+
} else {
|
|
28921
|
+
result.push([USER_AGENT_HEADER, effectiveUserAgent]);
|
|
28922
|
+
}
|
|
28923
|
+
return result;
|
|
28924
|
+
}
|
|
28925
|
+
return addSdkUserAgentHeader(typeof headers === "object" && headers !== null ? { ...headers } : {}, effectiveUserAgent);
|
|
28926
|
+
}
|
|
28927
|
+
function withUserAgentInitOverride(initOverrides, userAgent) {
|
|
28928
|
+
return async (requestContext) => {
|
|
28929
|
+
const initWithUserAgent = {
|
|
28930
|
+
...requestContext.init,
|
|
28931
|
+
headers: withSdkUserAgentHeader(requestContext.init.headers, userAgent)
|
|
28932
|
+
};
|
|
28933
|
+
const override = typeof initOverrides === "function" ? await initOverrides({
|
|
28934
|
+
...requestContext,
|
|
28935
|
+
init: initWithUserAgent
|
|
28936
|
+
}) : initOverrides;
|
|
28937
|
+
return {
|
|
28938
|
+
...override ?? {},
|
|
28939
|
+
headers: withSdkUserAgentHeader(override?.headers ?? initWithUserAgent.headers, userAgent)
|
|
28940
|
+
};
|
|
28941
|
+
};
|
|
28942
|
+
}
|
|
28943
|
+
function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
28944
|
+
const prototype = BaseApiClass.prototype;
|
|
28945
|
+
const patchKey = userAgentPatchKey(userAgent);
|
|
28946
|
+
if (prototype[patchKey]) {
|
|
28947
|
+
return;
|
|
28948
|
+
}
|
|
28949
|
+
if (typeof prototype.request !== "function") {
|
|
28950
|
+
throw new Error("Generated BaseAPI request function not found.");
|
|
28951
|
+
}
|
|
28952
|
+
const originalRequest = prototype.request;
|
|
28953
|
+
prototype.request = function requestWithUserAgent(context, initOverrides) {
|
|
28954
|
+
return originalRequest.call(this, context, withUserAgentInitOverride(initOverrides, userAgent));
|
|
28955
|
+
};
|
|
28956
|
+
Object.defineProperty(prototype, patchKey, {
|
|
28957
|
+
value: true
|
|
28958
|
+
});
|
|
28959
|
+
}
|
|
28645
28960
|
// ../common/src/tool-provider.ts
|
|
28646
28961
|
var factorySlot = singleton("PackagerFactoryProvider");
|
|
28647
28962
|
// ../common/src/telemetry/pii-redactor.ts
|
|
@@ -28824,13 +29139,17 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
28824
29139
|
const [error] = await catchError(fn(...args));
|
|
28825
29140
|
if (error) {
|
|
28826
29141
|
errorMessage = error instanceof Error ? error.message : String(error);
|
|
28827
|
-
logger.
|
|
29142
|
+
logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
|
|
29143
|
+
const typed = error;
|
|
29144
|
+
const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
|
|
29145
|
+
const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
|
|
29146
|
+
const finalResult = customResult ?? RESULTS.Failure;
|
|
28828
29147
|
OutputFormatter.error({
|
|
28829
|
-
Result:
|
|
29148
|
+
Result: finalResult,
|
|
28830
29149
|
Message: errorMessage,
|
|
28831
|
-
Instructions: "An unexpected error occurred. Run with --log-level debug for details."
|
|
29150
|
+
Instructions: customInstructions ?? "An unexpected error occurred. Run with --log-level debug for details."
|
|
28832
29151
|
});
|
|
28833
|
-
context.exit(
|
|
29152
|
+
context.exit(EXIT_CODES[finalResult]);
|
|
28834
29153
|
}
|
|
28835
29154
|
const durationMs = performance.now() - startTime;
|
|
28836
29155
|
const success = !error && (process.exitCode === undefined || process.exitCode === 0);
|
|
@@ -29099,6 +29418,327 @@ class VoidApiResponse {
|
|
|
29099
29418
|
return;
|
|
29100
29419
|
}
|
|
29101
29420
|
}
|
|
29421
|
+
|
|
29422
|
+
// ../integrationservice-sdk/generated/elements/src/runtime.ts
|
|
29423
|
+
var BASE_PATH2 = "http://localhost:8086/v3/element".replace(/\/+$/, "");
|
|
29424
|
+
|
|
29425
|
+
class Configuration2 {
|
|
29426
|
+
configuration;
|
|
29427
|
+
constructor(configuration = {}) {
|
|
29428
|
+
this.configuration = configuration;
|
|
29429
|
+
}
|
|
29430
|
+
set config(configuration) {
|
|
29431
|
+
this.configuration = configuration;
|
|
29432
|
+
}
|
|
29433
|
+
get basePath() {
|
|
29434
|
+
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH2;
|
|
29435
|
+
}
|
|
29436
|
+
get fetchApi() {
|
|
29437
|
+
return this.configuration.fetchApi;
|
|
29438
|
+
}
|
|
29439
|
+
get middleware() {
|
|
29440
|
+
return this.configuration.middleware || [];
|
|
29441
|
+
}
|
|
29442
|
+
get queryParamsStringify() {
|
|
29443
|
+
return this.configuration.queryParamsStringify || querystring2;
|
|
29444
|
+
}
|
|
29445
|
+
get username() {
|
|
29446
|
+
return this.configuration.username;
|
|
29447
|
+
}
|
|
29448
|
+
get password() {
|
|
29449
|
+
return this.configuration.password;
|
|
29450
|
+
}
|
|
29451
|
+
get apiKey() {
|
|
29452
|
+
const apiKey = this.configuration.apiKey;
|
|
29453
|
+
if (apiKey) {
|
|
29454
|
+
return typeof apiKey === "function" ? apiKey : () => apiKey;
|
|
29455
|
+
}
|
|
29456
|
+
return;
|
|
29457
|
+
}
|
|
29458
|
+
get accessToken() {
|
|
29459
|
+
const accessToken = this.configuration.accessToken;
|
|
29460
|
+
if (accessToken) {
|
|
29461
|
+
return typeof accessToken === "function" ? accessToken : async () => accessToken;
|
|
29462
|
+
}
|
|
29463
|
+
return;
|
|
29464
|
+
}
|
|
29465
|
+
get headers() {
|
|
29466
|
+
return this.configuration.headers;
|
|
29467
|
+
}
|
|
29468
|
+
get credentials() {
|
|
29469
|
+
return this.configuration.credentials;
|
|
29470
|
+
}
|
|
29471
|
+
}
|
|
29472
|
+
var DefaultConfig2 = new Configuration2;
|
|
29473
|
+
|
|
29474
|
+
class BaseAPI2 {
|
|
29475
|
+
configuration;
|
|
29476
|
+
static jsonRegex = new RegExp("^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$", "i");
|
|
29477
|
+
middleware;
|
|
29478
|
+
constructor(configuration = DefaultConfig2) {
|
|
29479
|
+
this.configuration = configuration;
|
|
29480
|
+
this.middleware = configuration.middleware;
|
|
29481
|
+
}
|
|
29482
|
+
withMiddleware(...middlewares) {
|
|
29483
|
+
const next = this.clone();
|
|
29484
|
+
next.middleware = next.middleware.concat(...middlewares);
|
|
29485
|
+
return next;
|
|
29486
|
+
}
|
|
29487
|
+
withPreMiddleware(...preMiddlewares) {
|
|
29488
|
+
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
|
29489
|
+
return this.withMiddleware(...middlewares);
|
|
29490
|
+
}
|
|
29491
|
+
withPostMiddleware(...postMiddlewares) {
|
|
29492
|
+
const middlewares = postMiddlewares.map((post) => ({ post }));
|
|
29493
|
+
return this.withMiddleware(...middlewares);
|
|
29494
|
+
}
|
|
29495
|
+
isJsonMime(mime) {
|
|
29496
|
+
if (!mime) {
|
|
29497
|
+
return false;
|
|
29498
|
+
}
|
|
29499
|
+
return BaseAPI2.jsonRegex.test(mime);
|
|
29500
|
+
}
|
|
29501
|
+
async request(context, initOverrides) {
|
|
29502
|
+
const { url, init } = await this.createFetchParams(context, initOverrides);
|
|
29503
|
+
const response = await this.fetchApi(url, init);
|
|
29504
|
+
if (response && (response.status >= 200 && response.status < 300)) {
|
|
29505
|
+
return response;
|
|
29506
|
+
}
|
|
29507
|
+
throw new ResponseError2(response, "Response returned an error code");
|
|
29508
|
+
}
|
|
29509
|
+
async createFetchParams(context, initOverrides) {
|
|
29510
|
+
let url = this.configuration.basePath + context.path;
|
|
29511
|
+
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
|
|
29512
|
+
url += "?" + this.configuration.queryParamsStringify(context.query);
|
|
29513
|
+
}
|
|
29514
|
+
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
|
29515
|
+
Object.keys(headers).forEach((key) => headers[key] === undefined ? delete headers[key] : {});
|
|
29516
|
+
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : async () => initOverrides;
|
|
29517
|
+
const initParams = {
|
|
29518
|
+
method: context.method,
|
|
29519
|
+
headers,
|
|
29520
|
+
body: context.body,
|
|
29521
|
+
credentials: this.configuration.credentials
|
|
29522
|
+
};
|
|
29523
|
+
const overriddenInit = {
|
|
29524
|
+
...initParams,
|
|
29525
|
+
...await initOverrideFn({
|
|
29526
|
+
init: initParams,
|
|
29527
|
+
context
|
|
29528
|
+
})
|
|
29529
|
+
};
|
|
29530
|
+
let body;
|
|
29531
|
+
if (isFormData2(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob2(overriddenInit.body)) {
|
|
29532
|
+
body = overriddenInit.body;
|
|
29533
|
+
} else if (this.isJsonMime(headers["Content-Type"])) {
|
|
29534
|
+
body = JSON.stringify(overriddenInit.body);
|
|
29535
|
+
} else {
|
|
29536
|
+
body = overriddenInit.body;
|
|
29537
|
+
}
|
|
29538
|
+
const init = {
|
|
29539
|
+
...overriddenInit,
|
|
29540
|
+
body
|
|
29541
|
+
};
|
|
29542
|
+
return { url, init };
|
|
29543
|
+
}
|
|
29544
|
+
fetchApi = async (url, init) => {
|
|
29545
|
+
let fetchParams = { url, init };
|
|
29546
|
+
for (const middleware of this.middleware) {
|
|
29547
|
+
if (middleware.pre) {
|
|
29548
|
+
fetchParams = await middleware.pre({
|
|
29549
|
+
fetch: this.fetchApi,
|
|
29550
|
+
...fetchParams
|
|
29551
|
+
}) || fetchParams;
|
|
29552
|
+
}
|
|
29553
|
+
}
|
|
29554
|
+
let response = undefined;
|
|
29555
|
+
try {
|
|
29556
|
+
response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
|
|
29557
|
+
} catch (e) {
|
|
29558
|
+
for (const middleware of this.middleware) {
|
|
29559
|
+
if (middleware.onError) {
|
|
29560
|
+
response = await middleware.onError({
|
|
29561
|
+
fetch: this.fetchApi,
|
|
29562
|
+
url: fetchParams.url,
|
|
29563
|
+
init: fetchParams.init,
|
|
29564
|
+
error: e,
|
|
29565
|
+
response: response ? response.clone() : undefined
|
|
29566
|
+
}) || response;
|
|
29567
|
+
}
|
|
29568
|
+
}
|
|
29569
|
+
if (response === undefined) {
|
|
29570
|
+
if (e instanceof Error) {
|
|
29571
|
+
throw new FetchError2(e, "The request failed and the interceptors did not return an alternative response");
|
|
29572
|
+
} else {
|
|
29573
|
+
throw e;
|
|
29574
|
+
}
|
|
29575
|
+
}
|
|
29576
|
+
}
|
|
29577
|
+
for (const middleware of this.middleware) {
|
|
29578
|
+
if (middleware.post) {
|
|
29579
|
+
response = await middleware.post({
|
|
29580
|
+
fetch: this.fetchApi,
|
|
29581
|
+
url: fetchParams.url,
|
|
29582
|
+
init: fetchParams.init,
|
|
29583
|
+
response: response.clone()
|
|
29584
|
+
}) || response;
|
|
29585
|
+
}
|
|
29586
|
+
}
|
|
29587
|
+
return response;
|
|
29588
|
+
};
|
|
29589
|
+
clone() {
|
|
29590
|
+
const constructor = this.constructor;
|
|
29591
|
+
const next = new constructor(this.configuration);
|
|
29592
|
+
next.middleware = this.middleware.slice();
|
|
29593
|
+
return next;
|
|
29594
|
+
}
|
|
29595
|
+
}
|
|
29596
|
+
function isBlob2(value) {
|
|
29597
|
+
return typeof Blob !== "undefined" && value instanceof Blob;
|
|
29598
|
+
}
|
|
29599
|
+
function isFormData2(value) {
|
|
29600
|
+
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
29601
|
+
}
|
|
29602
|
+
|
|
29603
|
+
class ResponseError2 extends Error {
|
|
29604
|
+
response;
|
|
29605
|
+
name = "ResponseError";
|
|
29606
|
+
constructor(response, msg) {
|
|
29607
|
+
super(msg);
|
|
29608
|
+
this.response = response;
|
|
29609
|
+
}
|
|
29610
|
+
}
|
|
29611
|
+
|
|
29612
|
+
class FetchError2 extends Error {
|
|
29613
|
+
cause;
|
|
29614
|
+
name = "FetchError";
|
|
29615
|
+
constructor(cause, msg) {
|
|
29616
|
+
super(msg);
|
|
29617
|
+
this.cause = cause;
|
|
29618
|
+
}
|
|
29619
|
+
}
|
|
29620
|
+
|
|
29621
|
+
class RequiredError2 extends Error {
|
|
29622
|
+
field;
|
|
29623
|
+
name = "RequiredError";
|
|
29624
|
+
constructor(field, msg) {
|
|
29625
|
+
super(msg);
|
|
29626
|
+
this.field = field;
|
|
29627
|
+
}
|
|
29628
|
+
}
|
|
29629
|
+
function querystring2(params, prefix = "") {
|
|
29630
|
+
return Object.keys(params).map((key) => querystringSingleKey2(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
|
|
29631
|
+
}
|
|
29632
|
+
function querystringSingleKey2(key, value, keyPrefix = "") {
|
|
29633
|
+
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
|
|
29634
|
+
if (value instanceof Array) {
|
|
29635
|
+
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
|
|
29636
|
+
return `${encodeURIComponent(fullKey)}=${multiValue}`;
|
|
29637
|
+
}
|
|
29638
|
+
if (value instanceof Set) {
|
|
29639
|
+
const valueAsArray = Array.from(value);
|
|
29640
|
+
return querystringSingleKey2(key, valueAsArray, keyPrefix);
|
|
29641
|
+
}
|
|
29642
|
+
if (value instanceof Date) {
|
|
29643
|
+
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
|
|
29644
|
+
}
|
|
29645
|
+
if (value instanceof Object) {
|
|
29646
|
+
return querystring2(value, fullKey);
|
|
29647
|
+
}
|
|
29648
|
+
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
|
|
29649
|
+
}
|
|
29650
|
+
class JSONApiResponse2 {
|
|
29651
|
+
raw;
|
|
29652
|
+
transformer;
|
|
29653
|
+
constructor(raw, transformer = (jsonValue) => jsonValue) {
|
|
29654
|
+
this.raw = raw;
|
|
29655
|
+
this.transformer = transformer;
|
|
29656
|
+
}
|
|
29657
|
+
async value() {
|
|
29658
|
+
return this.transformer(await this.raw.json());
|
|
29659
|
+
}
|
|
29660
|
+
}
|
|
29661
|
+
|
|
29662
|
+
class VoidApiResponse2 {
|
|
29663
|
+
raw;
|
|
29664
|
+
constructor(raw) {
|
|
29665
|
+
this.raw = raw;
|
|
29666
|
+
}
|
|
29667
|
+
async value() {
|
|
29668
|
+
return;
|
|
29669
|
+
}
|
|
29670
|
+
}
|
|
29671
|
+
|
|
29672
|
+
class BlobApiResponse {
|
|
29673
|
+
raw;
|
|
29674
|
+
constructor(raw) {
|
|
29675
|
+
this.raw = raw;
|
|
29676
|
+
}
|
|
29677
|
+
async value() {
|
|
29678
|
+
return await this.raw.blob();
|
|
29679
|
+
}
|
|
29680
|
+
}
|
|
29681
|
+
|
|
29682
|
+
class TextApiResponse {
|
|
29683
|
+
raw;
|
|
29684
|
+
constructor(raw) {
|
|
29685
|
+
this.raw = raw;
|
|
29686
|
+
}
|
|
29687
|
+
async value() {
|
|
29688
|
+
return await this.raw.text();
|
|
29689
|
+
}
|
|
29690
|
+
}
|
|
29691
|
+
// ../integrationservice-sdk/package.json
|
|
29692
|
+
var package_default2 = {
|
|
29693
|
+
name: "@uipath/integrationservice-sdk",
|
|
29694
|
+
license: "MIT",
|
|
29695
|
+
version: "1.2.0",
|
|
29696
|
+
repository: {
|
|
29697
|
+
type: "git",
|
|
29698
|
+
url: "https://github.com/UiPath/cli.git",
|
|
29699
|
+
directory: "packages/integrationservice-sdk"
|
|
29700
|
+
},
|
|
29701
|
+
publishConfig: {
|
|
29702
|
+
registry: "https://npm.pkg.github.com/@uipath"
|
|
29703
|
+
},
|
|
29704
|
+
keywords: [
|
|
29705
|
+
"uipath",
|
|
29706
|
+
"integrationservice",
|
|
29707
|
+
"sdk"
|
|
29708
|
+
],
|
|
29709
|
+
type: "module",
|
|
29710
|
+
main: "./dist/index.js",
|
|
29711
|
+
types: "./dist/src/index.d.ts",
|
|
29712
|
+
exports: {
|
|
29713
|
+
".": {
|
|
29714
|
+
types: "./dist/src/index.d.ts",
|
|
29715
|
+
default: "./dist/index.js"
|
|
29716
|
+
}
|
|
29717
|
+
},
|
|
29718
|
+
files: [
|
|
29719
|
+
"dist"
|
|
29720
|
+
],
|
|
29721
|
+
scripts: {
|
|
29722
|
+
build: "bun build ./src/index.ts --outdir dist --format esm --target node && tsc -p tsconfig.build.json --noCheck",
|
|
29723
|
+
generate: "bun run src/scripts/generate-sdk.ts",
|
|
29724
|
+
lint: "biome check .",
|
|
29725
|
+
test: "vitest run",
|
|
29726
|
+
"test:coverage": "vitest run --coverage"
|
|
29727
|
+
},
|
|
29728
|
+
devDependencies: {
|
|
29729
|
+
"@uipath/auth": "workspace:*",
|
|
29730
|
+
"@uipath/common": "workspace:*",
|
|
29731
|
+
"@openapitools/openapi-generator-cli": "^2.31.1",
|
|
29732
|
+
"@types/node": "^25.5.2",
|
|
29733
|
+
typescript: "^6.0.2",
|
|
29734
|
+
uuid: "^14.0.0"
|
|
29735
|
+
}
|
|
29736
|
+
};
|
|
29737
|
+
|
|
29738
|
+
// ../integrationservice-sdk/src/user-agent.ts
|
|
29739
|
+
var SDK_USER_AGENT = getSdkUserAgentToken(package_default2);
|
|
29740
|
+
installSdkUserAgentHeader(BaseAPI, SDK_USER_AGENT);
|
|
29741
|
+
installSdkUserAgentHeader(BaseAPI2, SDK_USER_AGENT);
|
|
29102
29742
|
// ../integrationservice-sdk/generated/connections/src/models/AccessTokenResponse.ts
|
|
29103
29743
|
function AccessTokenResponseFromJSON(json2) {
|
|
29104
29744
|
return AccessTokenResponseFromJSONTyped(json2, false);
|
|
@@ -30859,276 +31499,6 @@ class SessionsApi extends BaseAPI {
|
|
|
30859
31499
|
return await response.value();
|
|
30860
31500
|
}
|
|
30861
31501
|
}
|
|
30862
|
-
// ../integrationservice-sdk/generated/elements/src/runtime.ts
|
|
30863
|
-
var BASE_PATH2 = "http://localhost:8086/v3/element".replace(/\/+$/, "");
|
|
30864
|
-
|
|
30865
|
-
class Configuration2 {
|
|
30866
|
-
configuration;
|
|
30867
|
-
constructor(configuration = {}) {
|
|
30868
|
-
this.configuration = configuration;
|
|
30869
|
-
}
|
|
30870
|
-
set config(configuration) {
|
|
30871
|
-
this.configuration = configuration;
|
|
30872
|
-
}
|
|
30873
|
-
get basePath() {
|
|
30874
|
-
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH2;
|
|
30875
|
-
}
|
|
30876
|
-
get fetchApi() {
|
|
30877
|
-
return this.configuration.fetchApi;
|
|
30878
|
-
}
|
|
30879
|
-
get middleware() {
|
|
30880
|
-
return this.configuration.middleware || [];
|
|
30881
|
-
}
|
|
30882
|
-
get queryParamsStringify() {
|
|
30883
|
-
return this.configuration.queryParamsStringify || querystring2;
|
|
30884
|
-
}
|
|
30885
|
-
get username() {
|
|
30886
|
-
return this.configuration.username;
|
|
30887
|
-
}
|
|
30888
|
-
get password() {
|
|
30889
|
-
return this.configuration.password;
|
|
30890
|
-
}
|
|
30891
|
-
get apiKey() {
|
|
30892
|
-
const apiKey = this.configuration.apiKey;
|
|
30893
|
-
if (apiKey) {
|
|
30894
|
-
return typeof apiKey === "function" ? apiKey : () => apiKey;
|
|
30895
|
-
}
|
|
30896
|
-
return;
|
|
30897
|
-
}
|
|
30898
|
-
get accessToken() {
|
|
30899
|
-
const accessToken = this.configuration.accessToken;
|
|
30900
|
-
if (accessToken) {
|
|
30901
|
-
return typeof accessToken === "function" ? accessToken : async () => accessToken;
|
|
30902
|
-
}
|
|
30903
|
-
return;
|
|
30904
|
-
}
|
|
30905
|
-
get headers() {
|
|
30906
|
-
return this.configuration.headers;
|
|
30907
|
-
}
|
|
30908
|
-
get credentials() {
|
|
30909
|
-
return this.configuration.credentials;
|
|
30910
|
-
}
|
|
30911
|
-
}
|
|
30912
|
-
var DefaultConfig2 = new Configuration2;
|
|
30913
|
-
|
|
30914
|
-
class BaseAPI2 {
|
|
30915
|
-
configuration;
|
|
30916
|
-
static jsonRegex = new RegExp("^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$", "i");
|
|
30917
|
-
middleware;
|
|
30918
|
-
constructor(configuration = DefaultConfig2) {
|
|
30919
|
-
this.configuration = configuration;
|
|
30920
|
-
this.middleware = configuration.middleware;
|
|
30921
|
-
}
|
|
30922
|
-
withMiddleware(...middlewares) {
|
|
30923
|
-
const next = this.clone();
|
|
30924
|
-
next.middleware = next.middleware.concat(...middlewares);
|
|
30925
|
-
return next;
|
|
30926
|
-
}
|
|
30927
|
-
withPreMiddleware(...preMiddlewares) {
|
|
30928
|
-
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
|
30929
|
-
return this.withMiddleware(...middlewares);
|
|
30930
|
-
}
|
|
30931
|
-
withPostMiddleware(...postMiddlewares) {
|
|
30932
|
-
const middlewares = postMiddlewares.map((post) => ({ post }));
|
|
30933
|
-
return this.withMiddleware(...middlewares);
|
|
30934
|
-
}
|
|
30935
|
-
isJsonMime(mime) {
|
|
30936
|
-
if (!mime) {
|
|
30937
|
-
return false;
|
|
30938
|
-
}
|
|
30939
|
-
return BaseAPI2.jsonRegex.test(mime);
|
|
30940
|
-
}
|
|
30941
|
-
async request(context, initOverrides) {
|
|
30942
|
-
const { url, init } = await this.createFetchParams(context, initOverrides);
|
|
30943
|
-
const response = await this.fetchApi(url, init);
|
|
30944
|
-
if (response && (response.status >= 200 && response.status < 300)) {
|
|
30945
|
-
return response;
|
|
30946
|
-
}
|
|
30947
|
-
throw new ResponseError2(response, "Response returned an error code");
|
|
30948
|
-
}
|
|
30949
|
-
async createFetchParams(context, initOverrides) {
|
|
30950
|
-
let url = this.configuration.basePath + context.path;
|
|
30951
|
-
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
|
|
30952
|
-
url += "?" + this.configuration.queryParamsStringify(context.query);
|
|
30953
|
-
}
|
|
30954
|
-
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
|
30955
|
-
Object.keys(headers).forEach((key) => headers[key] === undefined ? delete headers[key] : {});
|
|
30956
|
-
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : async () => initOverrides;
|
|
30957
|
-
const initParams = {
|
|
30958
|
-
method: context.method,
|
|
30959
|
-
headers,
|
|
30960
|
-
body: context.body,
|
|
30961
|
-
credentials: this.configuration.credentials
|
|
30962
|
-
};
|
|
30963
|
-
const overriddenInit = {
|
|
30964
|
-
...initParams,
|
|
30965
|
-
...await initOverrideFn({
|
|
30966
|
-
init: initParams,
|
|
30967
|
-
context
|
|
30968
|
-
})
|
|
30969
|
-
};
|
|
30970
|
-
let body;
|
|
30971
|
-
if (isFormData2(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob2(overriddenInit.body)) {
|
|
30972
|
-
body = overriddenInit.body;
|
|
30973
|
-
} else if (this.isJsonMime(headers["Content-Type"])) {
|
|
30974
|
-
body = JSON.stringify(overriddenInit.body);
|
|
30975
|
-
} else {
|
|
30976
|
-
body = overriddenInit.body;
|
|
30977
|
-
}
|
|
30978
|
-
const init = {
|
|
30979
|
-
...overriddenInit,
|
|
30980
|
-
body
|
|
30981
|
-
};
|
|
30982
|
-
return { url, init };
|
|
30983
|
-
}
|
|
30984
|
-
fetchApi = async (url, init) => {
|
|
30985
|
-
let fetchParams = { url, init };
|
|
30986
|
-
for (const middleware of this.middleware) {
|
|
30987
|
-
if (middleware.pre) {
|
|
30988
|
-
fetchParams = await middleware.pre({
|
|
30989
|
-
fetch: this.fetchApi,
|
|
30990
|
-
...fetchParams
|
|
30991
|
-
}) || fetchParams;
|
|
30992
|
-
}
|
|
30993
|
-
}
|
|
30994
|
-
let response = undefined;
|
|
30995
|
-
try {
|
|
30996
|
-
response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
|
|
30997
|
-
} catch (e) {
|
|
30998
|
-
for (const middleware of this.middleware) {
|
|
30999
|
-
if (middleware.onError) {
|
|
31000
|
-
response = await middleware.onError({
|
|
31001
|
-
fetch: this.fetchApi,
|
|
31002
|
-
url: fetchParams.url,
|
|
31003
|
-
init: fetchParams.init,
|
|
31004
|
-
error: e,
|
|
31005
|
-
response: response ? response.clone() : undefined
|
|
31006
|
-
}) || response;
|
|
31007
|
-
}
|
|
31008
|
-
}
|
|
31009
|
-
if (response === undefined) {
|
|
31010
|
-
if (e instanceof Error) {
|
|
31011
|
-
throw new FetchError2(e, "The request failed and the interceptors did not return an alternative response");
|
|
31012
|
-
} else {
|
|
31013
|
-
throw e;
|
|
31014
|
-
}
|
|
31015
|
-
}
|
|
31016
|
-
}
|
|
31017
|
-
for (const middleware of this.middleware) {
|
|
31018
|
-
if (middleware.post) {
|
|
31019
|
-
response = await middleware.post({
|
|
31020
|
-
fetch: this.fetchApi,
|
|
31021
|
-
url: fetchParams.url,
|
|
31022
|
-
init: fetchParams.init,
|
|
31023
|
-
response: response.clone()
|
|
31024
|
-
}) || response;
|
|
31025
|
-
}
|
|
31026
|
-
}
|
|
31027
|
-
return response;
|
|
31028
|
-
};
|
|
31029
|
-
clone() {
|
|
31030
|
-
const constructor = this.constructor;
|
|
31031
|
-
const next = new constructor(this.configuration);
|
|
31032
|
-
next.middleware = this.middleware.slice();
|
|
31033
|
-
return next;
|
|
31034
|
-
}
|
|
31035
|
-
}
|
|
31036
|
-
function isBlob2(value) {
|
|
31037
|
-
return typeof Blob !== "undefined" && value instanceof Blob;
|
|
31038
|
-
}
|
|
31039
|
-
function isFormData2(value) {
|
|
31040
|
-
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
31041
|
-
}
|
|
31042
|
-
|
|
31043
|
-
class ResponseError2 extends Error {
|
|
31044
|
-
response;
|
|
31045
|
-
name = "ResponseError";
|
|
31046
|
-
constructor(response, msg) {
|
|
31047
|
-
super(msg);
|
|
31048
|
-
this.response = response;
|
|
31049
|
-
}
|
|
31050
|
-
}
|
|
31051
|
-
|
|
31052
|
-
class FetchError2 extends Error {
|
|
31053
|
-
cause;
|
|
31054
|
-
name = "FetchError";
|
|
31055
|
-
constructor(cause, msg) {
|
|
31056
|
-
super(msg);
|
|
31057
|
-
this.cause = cause;
|
|
31058
|
-
}
|
|
31059
|
-
}
|
|
31060
|
-
|
|
31061
|
-
class RequiredError2 extends Error {
|
|
31062
|
-
field;
|
|
31063
|
-
name = "RequiredError";
|
|
31064
|
-
constructor(field, msg) {
|
|
31065
|
-
super(msg);
|
|
31066
|
-
this.field = field;
|
|
31067
|
-
}
|
|
31068
|
-
}
|
|
31069
|
-
function querystring2(params, prefix = "") {
|
|
31070
|
-
return Object.keys(params).map((key) => querystringSingleKey2(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
|
|
31071
|
-
}
|
|
31072
|
-
function querystringSingleKey2(key, value, keyPrefix = "") {
|
|
31073
|
-
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
|
|
31074
|
-
if (value instanceof Array) {
|
|
31075
|
-
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
|
|
31076
|
-
return `${encodeURIComponent(fullKey)}=${multiValue}`;
|
|
31077
|
-
}
|
|
31078
|
-
if (value instanceof Set) {
|
|
31079
|
-
const valueAsArray = Array.from(value);
|
|
31080
|
-
return querystringSingleKey2(key, valueAsArray, keyPrefix);
|
|
31081
|
-
}
|
|
31082
|
-
if (value instanceof Date) {
|
|
31083
|
-
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
|
|
31084
|
-
}
|
|
31085
|
-
if (value instanceof Object) {
|
|
31086
|
-
return querystring2(value, fullKey);
|
|
31087
|
-
}
|
|
31088
|
-
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
|
|
31089
|
-
}
|
|
31090
|
-
class JSONApiResponse2 {
|
|
31091
|
-
raw;
|
|
31092
|
-
transformer;
|
|
31093
|
-
constructor(raw, transformer = (jsonValue) => jsonValue) {
|
|
31094
|
-
this.raw = raw;
|
|
31095
|
-
this.transformer = transformer;
|
|
31096
|
-
}
|
|
31097
|
-
async value() {
|
|
31098
|
-
return this.transformer(await this.raw.json());
|
|
31099
|
-
}
|
|
31100
|
-
}
|
|
31101
|
-
|
|
31102
|
-
class VoidApiResponse2 {
|
|
31103
|
-
raw;
|
|
31104
|
-
constructor(raw) {
|
|
31105
|
-
this.raw = raw;
|
|
31106
|
-
}
|
|
31107
|
-
async value() {
|
|
31108
|
-
return;
|
|
31109
|
-
}
|
|
31110
|
-
}
|
|
31111
|
-
|
|
31112
|
-
class BlobApiResponse {
|
|
31113
|
-
raw;
|
|
31114
|
-
constructor(raw) {
|
|
31115
|
-
this.raw = raw;
|
|
31116
|
-
}
|
|
31117
|
-
async value() {
|
|
31118
|
-
return await this.raw.blob();
|
|
31119
|
-
}
|
|
31120
|
-
}
|
|
31121
|
-
|
|
31122
|
-
class TextApiResponse {
|
|
31123
|
-
raw;
|
|
31124
|
-
constructor(raw) {
|
|
31125
|
-
this.raw = raw;
|
|
31126
|
-
}
|
|
31127
|
-
async value() {
|
|
31128
|
-
return await this.raw.text();
|
|
31129
|
-
}
|
|
31130
|
-
}
|
|
31131
|
-
|
|
31132
31502
|
// ../integrationservice-sdk/generated/elements/src/models/UnknownFieldSet.ts
|
|
31133
31503
|
function UnknownFieldSetFromJSON(json2) {
|
|
31134
31504
|
return UnknownFieldSetFromJSONTyped(json2, false);
|
|
@@ -35084,32 +35454,7 @@ class InvalidBaseUrlError extends Error {
|
|
|
35084
35454
|
this.name = "InvalidBaseUrlError";
|
|
35085
35455
|
}
|
|
35086
35456
|
}
|
|
35087
|
-
var DEFAULT_SCOPES = [
|
|
35088
|
-
"offline_access",
|
|
35089
|
-
"ProcessMining",
|
|
35090
|
-
"OrchestratorApiUserAccess",
|
|
35091
|
-
"StudioWebBackend",
|
|
35092
|
-
"IdentityServerApi",
|
|
35093
|
-
"ConnectionService",
|
|
35094
|
-
"DataService",
|
|
35095
|
-
"DataServiceApiUserAccess",
|
|
35096
|
-
"DocumentUnderstanding",
|
|
35097
|
-
"EnterpriseContextService",
|
|
35098
|
-
"Directory",
|
|
35099
|
-
"JamJamApi",
|
|
35100
|
-
"LLMGateway",
|
|
35101
|
-
"LLMOps",
|
|
35102
|
-
"OMS",
|
|
35103
|
-
"RCS.FolderAuthorization",
|
|
35104
|
-
"RCS.TagsManagement",
|
|
35105
|
-
"TestmanagerApiUserAccess",
|
|
35106
|
-
"AutomationSolutions",
|
|
35107
|
-
"StudioWebTypeCacheService",
|
|
35108
|
-
"Docs.GPT.Search",
|
|
35109
|
-
"Insights",
|
|
35110
|
-
"ReferenceToken",
|
|
35111
|
-
"Audit.Read"
|
|
35112
|
-
];
|
|
35457
|
+
var DEFAULT_SCOPES = ["openid", "profile", "offline_access"];
|
|
35113
35458
|
var normalizeAndValidateBaseUrl = (rawUrl) => {
|
|
35114
35459
|
let baseUrl = rawUrl;
|
|
35115
35460
|
if (baseUrl.endsWith("/identity_/")) {
|
|
@@ -35159,7 +35504,8 @@ var resolveConfigAsync = async ({
|
|
|
35159
35504
|
if (!clientSecret && fileAuth.clientSecret) {
|
|
35160
35505
|
clientSecret = fileAuth.clientSecret;
|
|
35161
35506
|
}
|
|
35162
|
-
const
|
|
35507
|
+
const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && Boolean(clientSecret);
|
|
35508
|
+
const scopes = customScopes && customScopes.length > 0 ? customScopes : fileAuth.scopes && fileAuth.scopes.length > 0 ? fileAuth.scopes : isExternalAppAuth ? [] : DEFAULT_SCOPES;
|
|
35163
35509
|
return {
|
|
35164
35510
|
clientId,
|
|
35165
35511
|
clientSecret,
|
|
@@ -35659,6 +36005,129 @@ function normalizeTokenRefreshFailure() {
|
|
|
35659
36005
|
function normalizeTokenRefreshUnavailableFailure() {
|
|
35660
36006
|
return "token refresh failed before authentication completed";
|
|
35661
36007
|
}
|
|
36008
|
+
function errorMessage(error) {
|
|
36009
|
+
return error instanceof Error ? error.message : String(error);
|
|
36010
|
+
}
|
|
36011
|
+
function computeExpirationThreshold(ensureTokenValidityMinutes) {
|
|
36012
|
+
return new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
|
|
36013
|
+
}
|
|
36014
|
+
async function runRefreshLocked(inputs) {
|
|
36015
|
+
const {
|
|
36016
|
+
absolutePath,
|
|
36017
|
+
refreshToken: callerRefreshToken,
|
|
36018
|
+
customAuthority,
|
|
36019
|
+
ensureTokenValidityMinutes,
|
|
36020
|
+
loadEnvFile,
|
|
36021
|
+
saveEnvFile,
|
|
36022
|
+
refreshFn,
|
|
36023
|
+
resolveConfig: resolveConfig2
|
|
36024
|
+
} = inputs;
|
|
36025
|
+
const expirationThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
36026
|
+
let fresh;
|
|
36027
|
+
try {
|
|
36028
|
+
fresh = await loadEnvFile({ envPath: absolutePath });
|
|
36029
|
+
} catch (error) {
|
|
36030
|
+
return {
|
|
36031
|
+
kind: "fail",
|
|
36032
|
+
status: {
|
|
36033
|
+
loginStatus: "Refresh Failed",
|
|
36034
|
+
hint: "Could not read the auth file while refreshing. Retry, or run 'uip login' to re-authenticate.",
|
|
36035
|
+
tokenRefresh: {
|
|
36036
|
+
attempted: false,
|
|
36037
|
+
success: false,
|
|
36038
|
+
errorMessage: `auth file read failed: ${errorMessage(error)}`
|
|
36039
|
+
}
|
|
36040
|
+
}
|
|
36041
|
+
};
|
|
36042
|
+
}
|
|
36043
|
+
const freshAccess = fresh.UIPATH_ACCESS_TOKEN;
|
|
36044
|
+
const freshExp = freshAccess ? getTokenExpiration(freshAccess) : undefined;
|
|
36045
|
+
if (freshAccess && freshExp && freshExp > expirationThreshold) {
|
|
36046
|
+
return {
|
|
36047
|
+
kind: "ok",
|
|
36048
|
+
accessToken: freshAccess,
|
|
36049
|
+
refreshToken: fresh.UIPATH_REFRESH_TOKEN ?? callerRefreshToken,
|
|
36050
|
+
expiration: freshExp,
|
|
36051
|
+
tokenRefresh: { attempted: false, success: true }
|
|
36052
|
+
};
|
|
36053
|
+
}
|
|
36054
|
+
const tokenForIdP = fresh.UIPATH_REFRESH_TOKEN ?? callerRefreshToken;
|
|
36055
|
+
let refreshedAccess;
|
|
36056
|
+
let refreshedRefresh;
|
|
36057
|
+
try {
|
|
36058
|
+
const config = await resolveConfig2({ customAuthority });
|
|
36059
|
+
const refreshed = await refreshFn({
|
|
36060
|
+
refreshToken: tokenForIdP,
|
|
36061
|
+
tokenEndpoint: config.tokenEndpoint,
|
|
36062
|
+
clientId: config.clientId,
|
|
36063
|
+
expectedAuthority: customAuthority
|
|
36064
|
+
});
|
|
36065
|
+
refreshedAccess = refreshed.accessToken;
|
|
36066
|
+
refreshedRefresh = refreshed.refreshToken;
|
|
36067
|
+
} catch (error) {
|
|
36068
|
+
const isOAuthFailure = isTokenRefreshOAuthFailure(error);
|
|
36069
|
+
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.";
|
|
36070
|
+
const message = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
|
|
36071
|
+
return {
|
|
36072
|
+
kind: "fail",
|
|
36073
|
+
status: {
|
|
36074
|
+
loginStatus: "Refresh Failed",
|
|
36075
|
+
hint,
|
|
36076
|
+
tokenRefresh: {
|
|
36077
|
+
attempted: true,
|
|
36078
|
+
success: false,
|
|
36079
|
+
errorMessage: message
|
|
36080
|
+
}
|
|
36081
|
+
}
|
|
36082
|
+
};
|
|
36083
|
+
}
|
|
36084
|
+
const refreshedExp = getTokenExpiration(refreshedAccess);
|
|
36085
|
+
if (!refreshedExp || refreshedExp <= new Date) {
|
|
36086
|
+
return {
|
|
36087
|
+
kind: "fail",
|
|
36088
|
+
status: {
|
|
36089
|
+
loginStatus: "Refresh Failed",
|
|
36090
|
+
hint: "The identity server returned an unusable token. Run 'uip login' to re-authenticate.",
|
|
36091
|
+
tokenRefresh: {
|
|
36092
|
+
attempted: true,
|
|
36093
|
+
success: false,
|
|
36094
|
+
errorMessage: "refreshed token has no valid expiration claim"
|
|
36095
|
+
}
|
|
36096
|
+
}
|
|
36097
|
+
};
|
|
36098
|
+
}
|
|
36099
|
+
try {
|
|
36100
|
+
await saveEnvFile({
|
|
36101
|
+
envPath: absolutePath,
|
|
36102
|
+
data: {
|
|
36103
|
+
UIPATH_ACCESS_TOKEN: refreshedAccess,
|
|
36104
|
+
UIPATH_REFRESH_TOKEN: refreshedRefresh
|
|
36105
|
+
},
|
|
36106
|
+
merge: true
|
|
36107
|
+
});
|
|
36108
|
+
return {
|
|
36109
|
+
kind: "ok",
|
|
36110
|
+
accessToken: refreshedAccess,
|
|
36111
|
+
refreshToken: refreshedRefresh,
|
|
36112
|
+
expiration: refreshedExp,
|
|
36113
|
+
tokenRefresh: { attempted: true, success: true }
|
|
36114
|
+
};
|
|
36115
|
+
} catch (error) {
|
|
36116
|
+
const msg = errorMessage(error);
|
|
36117
|
+
return {
|
|
36118
|
+
kind: "ok",
|
|
36119
|
+
accessToken: refreshedAccess,
|
|
36120
|
+
refreshToken: refreshedRefresh,
|
|
36121
|
+
expiration: refreshedExp,
|
|
36122
|
+
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.`,
|
|
36123
|
+
tokenRefresh: {
|
|
36124
|
+
attempted: true,
|
|
36125
|
+
success: true,
|
|
36126
|
+
errorMessage: `persistence failed: ${msg}`
|
|
36127
|
+
}
|
|
36128
|
+
};
|
|
36129
|
+
}
|
|
36130
|
+
}
|
|
35662
36131
|
var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
35663
36132
|
const {
|
|
35664
36133
|
resolveEnvFilePath = resolveEnvFilePathAsync,
|
|
@@ -35733,73 +36202,103 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
|
35733
36202
|
let refreshToken = credentials.UIPATH_REFRESH_TOKEN;
|
|
35734
36203
|
let expiration = getTokenExpiration(accessToken);
|
|
35735
36204
|
let persistenceWarning;
|
|
36205
|
+
let lockReleaseFailed = false;
|
|
35736
36206
|
let tokenRefresh;
|
|
35737
|
-
const
|
|
35738
|
-
|
|
35739
|
-
|
|
35740
|
-
|
|
36207
|
+
const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
36208
|
+
const tryGlobalCredsHint = async () => {
|
|
36209
|
+
const fs7 = getFs();
|
|
36210
|
+
const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
|
|
36211
|
+
if (absolutePath === globalPath)
|
|
36212
|
+
return;
|
|
36213
|
+
if (!await fs7.exists(globalPath))
|
|
36214
|
+
return;
|
|
35741
36215
|
try {
|
|
35742
|
-
const
|
|
35743
|
-
|
|
35744
|
-
|
|
35745
|
-
const
|
|
35746
|
-
|
|
35747
|
-
|
|
35748
|
-
|
|
35749
|
-
|
|
35750
|
-
|
|
35751
|
-
refreshedAccess = refreshed.accessToken;
|
|
35752
|
-
refreshedRefresh = refreshed.refreshToken;
|
|
35753
|
-
} catch (error) {
|
|
35754
|
-
const isOAuthFailure = isTokenRefreshOAuthFailure(error);
|
|
35755
|
-
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.";
|
|
35756
|
-
const errorMessage = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
|
|
35757
|
-
return {
|
|
35758
|
-
loginStatus: "Refresh Failed",
|
|
35759
|
-
hint,
|
|
35760
|
-
tokenRefresh: {
|
|
35761
|
-
attempted: true,
|
|
35762
|
-
success: false,
|
|
35763
|
-
errorMessage
|
|
35764
|
-
}
|
|
35765
|
-
};
|
|
36216
|
+
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
36217
|
+
if (!globalCreds.UIPATH_ACCESS_TOKEN)
|
|
36218
|
+
return;
|
|
36219
|
+
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
36220
|
+
if (globalExp && globalExp <= new Date)
|
|
36221
|
+
return;
|
|
36222
|
+
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.`;
|
|
36223
|
+
} catch {
|
|
36224
|
+
return;
|
|
35766
36225
|
}
|
|
35767
|
-
|
|
35768
|
-
|
|
36226
|
+
};
|
|
36227
|
+
if (expiration && expiration <= outerThreshold && refreshToken) {
|
|
36228
|
+
let release;
|
|
36229
|
+
try {
|
|
36230
|
+
release = await getFs().acquireLock(absolutePath);
|
|
36231
|
+
} catch (error) {
|
|
36232
|
+
const msg = errorMessage(error);
|
|
36233
|
+
const globalHint = await tryGlobalCredsHint();
|
|
36234
|
+
if (globalHint) {
|
|
36235
|
+
return {
|
|
36236
|
+
loginStatus: "Expired",
|
|
36237
|
+
accessToken,
|
|
36238
|
+
refreshToken,
|
|
36239
|
+
baseUrl: credentials.UIPATH_URL,
|
|
36240
|
+
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
36241
|
+
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
36242
|
+
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
36243
|
+
tenantId: credentials.UIPATH_TENANT_ID,
|
|
36244
|
+
expiration,
|
|
36245
|
+
source: "file" /* File */,
|
|
36246
|
+
hint: globalHint,
|
|
36247
|
+
tokenRefresh: {
|
|
36248
|
+
attempted: false,
|
|
36249
|
+
success: false,
|
|
36250
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
36251
|
+
}
|
|
36252
|
+
};
|
|
36253
|
+
}
|
|
35769
36254
|
return {
|
|
35770
36255
|
loginStatus: "Refresh Failed",
|
|
35771
|
-
hint: "
|
|
36256
|
+
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.",
|
|
35772
36257
|
tokenRefresh: {
|
|
35773
|
-
attempted:
|
|
36258
|
+
attempted: false,
|
|
35774
36259
|
success: false,
|
|
35775
|
-
errorMessage:
|
|
36260
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
35776
36261
|
}
|
|
35777
36262
|
};
|
|
35778
36263
|
}
|
|
35779
|
-
|
|
35780
|
-
refreshToken = refreshedRefresh;
|
|
35781
|
-
expiration = refreshedExp;
|
|
36264
|
+
let lockedFailure;
|
|
35782
36265
|
try {
|
|
35783
|
-
await
|
|
35784
|
-
|
|
35785
|
-
|
|
35786
|
-
|
|
35787
|
-
|
|
35788
|
-
|
|
35789
|
-
|
|
36266
|
+
const outcome = await runRefreshLocked({
|
|
36267
|
+
absolutePath,
|
|
36268
|
+
refreshToken,
|
|
36269
|
+
customAuthority: credentials.UIPATH_URL,
|
|
36270
|
+
ensureTokenValidityMinutes,
|
|
36271
|
+
loadEnvFile,
|
|
36272
|
+
saveEnvFile,
|
|
36273
|
+
refreshFn: refreshTokenFn,
|
|
36274
|
+
resolveConfig: resolveConfig2
|
|
35790
36275
|
});
|
|
35791
|
-
|
|
35792
|
-
|
|
35793
|
-
|
|
35794
|
-
|
|
35795
|
-
|
|
35796
|
-
|
|
35797
|
-
|
|
35798
|
-
|
|
35799
|
-
|
|
35800
|
-
|
|
35801
|
-
|
|
35802
|
-
|
|
36276
|
+
if (outcome.kind === "fail") {
|
|
36277
|
+
lockedFailure = outcome.status;
|
|
36278
|
+
} else {
|
|
36279
|
+
accessToken = outcome.accessToken;
|
|
36280
|
+
refreshToken = outcome.refreshToken;
|
|
36281
|
+
expiration = outcome.expiration;
|
|
36282
|
+
tokenRefresh = outcome.tokenRefresh;
|
|
36283
|
+
if (outcome.persistenceWarning) {
|
|
36284
|
+
persistenceWarning = outcome.persistenceWarning;
|
|
36285
|
+
}
|
|
36286
|
+
}
|
|
36287
|
+
} finally {
|
|
36288
|
+
try {
|
|
36289
|
+
await release();
|
|
36290
|
+
} catch {
|
|
36291
|
+
lockReleaseFailed = true;
|
|
36292
|
+
}
|
|
36293
|
+
}
|
|
36294
|
+
if (lockedFailure) {
|
|
36295
|
+
const globalHint = await tryGlobalCredsHint();
|
|
36296
|
+
const base = globalHint ? {
|
|
36297
|
+
...lockedFailure,
|
|
36298
|
+
loginStatus: "Expired",
|
|
36299
|
+
hint: globalHint
|
|
36300
|
+
} : lockedFailure;
|
|
36301
|
+
return lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base;
|
|
35803
36302
|
}
|
|
35804
36303
|
}
|
|
35805
36304
|
const result = {
|
|
@@ -35814,23 +36313,13 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
|
35814
36313
|
expiration,
|
|
35815
36314
|
source: "file" /* File */,
|
|
35816
36315
|
...persistenceWarning ? { hint: persistenceWarning, persistenceFailed: true } : {},
|
|
36316
|
+
...lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
35817
36317
|
...tokenRefresh ? { tokenRefresh } : {}
|
|
35818
36318
|
};
|
|
35819
36319
|
if (result.loginStatus === "Expired") {
|
|
35820
|
-
const
|
|
35821
|
-
|
|
35822
|
-
|
|
35823
|
-
try {
|
|
35824
|
-
const globalCreds = await loadEnvFile({
|
|
35825
|
-
envPath: globalPath
|
|
35826
|
-
});
|
|
35827
|
-
if (globalCreds.UIPATH_ACCESS_TOKEN) {
|
|
35828
|
-
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
35829
|
-
if (!globalExp || globalExp > new Date) {
|
|
35830
|
-
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.`;
|
|
35831
|
-
}
|
|
35832
|
-
}
|
|
35833
|
-
} catch {}
|
|
36320
|
+
const globalHint = await tryGlobalCredsHint();
|
|
36321
|
+
if (globalHint) {
|
|
36322
|
+
result.hint = globalHint;
|
|
35834
36323
|
}
|
|
35835
36324
|
}
|
|
35836
36325
|
return result;
|
|
@@ -35897,6 +36386,10 @@ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId)
|
|
|
35897
36386
|
};
|
|
35898
36387
|
// ../auth/src/logout.ts
|
|
35899
36388
|
init_src();
|
|
36389
|
+
|
|
36390
|
+
// ../auth/src/index.ts
|
|
36391
|
+
init_server();
|
|
36392
|
+
|
|
35900
36393
|
// ../integrationservice-sdk/src/client-factory.ts
|
|
35901
36394
|
var API_DOMAIN_MAP = new Map([
|
|
35902
36395
|
[ConnectorsApi, "connections"],
|
|
@@ -35925,7 +36418,9 @@ async function createConnectionsConfig(options) {
|
|
|
35925
36418
|
return new Configuration({
|
|
35926
36419
|
basePath: `${baseUrl}/${organizationId}/${tenantName}/connections_`,
|
|
35927
36420
|
accessToken: async () => accessToken,
|
|
35928
|
-
headers: {
|
|
36421
|
+
headers: addSdkUserAgentHeader({
|
|
36422
|
+
"x-uipath-source": "UiPath.CodingAgent"
|
|
36423
|
+
}, SDK_USER_AGENT)
|
|
35929
36424
|
});
|
|
35930
36425
|
}
|
|
35931
36426
|
async function createElementsConfig(options) {
|
|
@@ -35933,7 +36428,9 @@ async function createElementsConfig(options) {
|
|
|
35933
36428
|
return new Configuration2({
|
|
35934
36429
|
basePath: `${baseUrl}/${organizationId}/${tenantName}/elements_/v3/element`,
|
|
35935
36430
|
accessToken: async () => accessToken,
|
|
35936
|
-
headers: {
|
|
36431
|
+
headers: addSdkUserAgentHeader({
|
|
36432
|
+
"x-uipath-source": "UiPath.CodingAgent"
|
|
36433
|
+
}, SDK_USER_AGENT)
|
|
35937
36434
|
});
|
|
35938
36435
|
}
|
|
35939
36436
|
async function createApiClient(ApiClass, options) {
|
|
@@ -35954,11 +36451,11 @@ async function executeOperation(options, connectionId, objectName, httpMethod =
|
|
|
35954
36451
|
}
|
|
35955
36452
|
const requestOptions = {
|
|
35956
36453
|
method: httpMethod,
|
|
35957
|
-
headers: {
|
|
36454
|
+
headers: addSdkUserAgentHeader({
|
|
35958
36455
|
Authorization: `Bearer ${accessToken}`,
|
|
35959
36456
|
"Content-Type": "application/json",
|
|
35960
36457
|
"x-uipath-source": "UiPath.CodingAgent"
|
|
35961
|
-
}
|
|
36458
|
+
}, SDK_USER_AGENT)
|
|
35962
36459
|
};
|
|
35963
36460
|
if (body && ["POST", "PUT", "PATCH"].includes(httpMethod)) {
|
|
35964
36461
|
requestOptions.body = JSON.stringify(body);
|
|
@@ -35986,11 +36483,11 @@ async function executeOperation(options, connectionId, objectName, httpMethod =
|
|
|
35986
36483
|
async function runInstanceDesignAction(options, connectionOrInstanceId, method, relativeUrl, body) {
|
|
35987
36484
|
const { baseUrl, accessToken, organizationId, tenantName } = await getValidatedAuthContext(options);
|
|
35988
36485
|
const url = `${baseUrl}/${organizationId}/${tenantName}/elements_/v3/element/instances/${encodeURIComponent(connectionOrInstanceId)}${relativeUrl}`;
|
|
35989
|
-
const headers = {
|
|
36486
|
+
const headers = addSdkUserAgentHeader({
|
|
35990
36487
|
Authorization: `Bearer ${accessToken}`,
|
|
35991
36488
|
Accept: "application/json",
|
|
35992
36489
|
"x-uipath-source": "UiPath.CodingAgent"
|
|
35993
|
-
};
|
|
36490
|
+
}, SDK_USER_AGENT);
|
|
35994
36491
|
const init = { method, headers };
|
|
35995
36492
|
if (body && Object.keys(body).length > 0) {
|
|
35996
36493
|
headers["Content-Type"] = "application/json";
|
|
@@ -36019,11 +36516,11 @@ async function getWebhookConfig(options, connectionId, elementInstanceId, connec
|
|
|
36019
36516
|
});
|
|
36020
36517
|
const url = `${baseUrl}/${organizationId}/${tenantName}/elements_/v1/webhooks/subscribers/${encodeURIComponent(connectionId)}/webhook/config?${params.toString()}`;
|
|
36021
36518
|
const response = await fetch(url, {
|
|
36022
|
-
headers: {
|
|
36519
|
+
headers: addSdkUserAgentHeader({
|
|
36023
36520
|
Authorization: `Bearer ${accessToken}`,
|
|
36024
36521
|
Accept: "application/json",
|
|
36025
36522
|
"x-uipath-source": "UiPath.CodingAgent"
|
|
36026
|
-
}
|
|
36523
|
+
}, SDK_USER_AGENT)
|
|
36027
36524
|
});
|
|
36028
36525
|
if (!response.ok) {
|
|
36029
36526
|
const errorText = await response.text();
|
|
@@ -36036,12 +36533,12 @@ async function getHttpRequestPreview(options, connectionId) {
|
|
|
36036
36533
|
const url = `${baseUrl}/${organizationId}/${tenantName}/elements_/v3/element/instances/${encodeURIComponent(connectionId)}/http-request-preview`;
|
|
36037
36534
|
const response = await fetch(url, {
|
|
36038
36535
|
method: "POST",
|
|
36039
|
-
headers: {
|
|
36536
|
+
headers: addSdkUserAgentHeader({
|
|
36040
36537
|
Authorization: `Bearer ${accessToken}`,
|
|
36041
36538
|
"Content-Type": "application/json",
|
|
36042
36539
|
Accept: "application/json",
|
|
36043
36540
|
"x-uipath-source": "UiPath.CodingAgent"
|
|
36044
|
-
},
|
|
36541
|
+
}, SDK_USER_AGENT),
|
|
36045
36542
|
body: "{}"
|
|
36046
36543
|
});
|
|
36047
36544
|
if (!response.ok) {
|
|
@@ -37026,9 +37523,42 @@ function writePendingAuthorization(connectorKey, connectionId, response) {
|
|
|
37026
37523
|
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
37027
37524
|
var LIST_CONNECTIONS_AUTH_INSTRUCTIONS = "Run 'uip login' to authenticate, then use 'uip login tenant set <tenant>' if you need to switch tenants.";
|
|
37028
37525
|
var LIST_CONNECTIONS_API_INSTRUCTIONS = "Verify the connector key and folder key, then retry. Use 'uip is connections list --help' for accepted options.";
|
|
37526
|
+
var INVALID_CONNECTOR_KEY_INSTRUCTIONS = "Verify the connector key. Run 'uip is connectors list' to see available connectors.";
|
|
37527
|
+
var PERSONAL_WORKSPACE_UNAVAILABLE_INSTRUCTIONS = "Personal workspace is not configured on this tenant. Run 'uip is connections list --folder <folder-key>' against a shared folder, or contact your administrator.";
|
|
37528
|
+
var CNS_CONNECTOR_KEY_INVALID = "CNS1001";
|
|
37529
|
+
var CNS_NOT_FOUND = "CNS1049";
|
|
37029
37530
|
var EXPORT_CONNECTIONS_API_INSTRUCTIONS = "Verify the tenant and retry. Use 'uip is connections export --help' for accepted options.";
|
|
37030
37531
|
var CONNECTIONS_CONFIG_ERROR_INSTRUCTIONS = "Run 'uip login' and retry. Use 'uip login tenant set <tenant>' to switch tenants, or set UIPATH_TENANT_NAME for environment authentication.";
|
|
37031
37532
|
var CONNECTIONS_UPDATE_POLLING_INTERVAL_ERROR_INSTRUCTIONS = "Verify the connection ID with 'uip is connections list --refresh', confirm --polling-interval is supported for the connection, and retry.";
|
|
37533
|
+
async function emitListConnectionsFailure(fetchError) {
|
|
37534
|
+
const { message, details, context } = await extractErrorDetails(fetchError);
|
|
37535
|
+
if (context?.errorCode === CNS_CONNECTOR_KEY_INVALID) {
|
|
37536
|
+
OutputFormatter.error({
|
|
37537
|
+
Result: RESULTS.Failure,
|
|
37538
|
+
Code: "InvalidConnectorKey",
|
|
37539
|
+
Message: message,
|
|
37540
|
+
Instructions: INVALID_CONNECTOR_KEY_INSTRUCTIONS
|
|
37541
|
+
});
|
|
37542
|
+
processContext.exit(1);
|
|
37543
|
+
return;
|
|
37544
|
+
}
|
|
37545
|
+
if (context?.errorCode === CNS_NOT_FOUND && /personal workspace/i.test(message)) {
|
|
37546
|
+
OutputFormatter.error({
|
|
37547
|
+
Result: RESULTS.Failure,
|
|
37548
|
+
Code: "PersonalWorkspaceNotAvailable",
|
|
37549
|
+
Message: "Personal workspace not available on this environment.",
|
|
37550
|
+
Instructions: PERSONAL_WORKSPACE_UNAVAILABLE_INSTRUCTIONS
|
|
37551
|
+
});
|
|
37552
|
+
processContext.exit(1);
|
|
37553
|
+
return;
|
|
37554
|
+
}
|
|
37555
|
+
OutputFormatter.error({
|
|
37556
|
+
Result: RESULTS.Failure,
|
|
37557
|
+
Message: message,
|
|
37558
|
+
Instructions: appendListConnectionsHint(details, LIST_CONNECTIONS_API_INSTRUCTIONS)
|
|
37559
|
+
});
|
|
37560
|
+
processContext.exit(1);
|
|
37561
|
+
}
|
|
37032
37562
|
function appendListConnectionsHint(details, hint) {
|
|
37033
37563
|
const normalizedDetails = details?.trim();
|
|
37034
37564
|
if (!normalizedDetails || normalizedDetails === hint) {
|
|
@@ -37260,44 +37790,22 @@ var registerConnectionsCommand = (program2) => {
|
|
|
37260
37790
|
...options.allFolders ? { allFolders: true } : {}
|
|
37261
37791
|
}, folderOverride(folderKey)));
|
|
37262
37792
|
if (fetchError) {
|
|
37263
|
-
|
|
37264
|
-
|
|
37265
|
-
|
|
37266
|
-
|
|
37267
|
-
|
|
37268
|
-
|
|
37269
|
-
Message: message,
|
|
37270
|
-
Instructions: appendListConnectionsHint(details, LIST_CONNECTIONS_API_INSTRUCTIONS)
|
|
37271
|
-
});
|
|
37272
|
-
processContext.exit(1);
|
|
37273
|
-
return;
|
|
37274
|
-
}
|
|
37275
|
-
} else {
|
|
37276
|
-
data = fetched;
|
|
37277
|
-
if (data && data.length > 0) {
|
|
37278
|
-
await writeConnections(connectorKey, data, folderKey, options.tenant, options.allFolders);
|
|
37279
|
-
}
|
|
37793
|
+
await emitListConnectionsFailure(fetchError);
|
|
37794
|
+
return;
|
|
37795
|
+
}
|
|
37796
|
+
data = fetched;
|
|
37797
|
+
if (data && data.length > 0) {
|
|
37798
|
+
await writeConnections(connectorKey, data, folderKey, options.tenant, options.allFolders);
|
|
37280
37799
|
}
|
|
37281
37800
|
}
|
|
37282
37801
|
} else {
|
|
37283
37802
|
const api = new ConnectionsApi(config);
|
|
37284
37803
|
const [fetchError, fetched] = await catchError(api.apiV1ConnectionsGet(options.allFolders ? { allFolders: true } : {}, folderOverride(folderKey)));
|
|
37285
37804
|
if (fetchError) {
|
|
37286
|
-
|
|
37287
|
-
|
|
37288
|
-
data = [];
|
|
37289
|
-
} else {
|
|
37290
|
-
OutputFormatter.error({
|
|
37291
|
-
Result: RESULTS.Failure,
|
|
37292
|
-
Message: message,
|
|
37293
|
-
Instructions: appendListConnectionsHint(details, LIST_CONNECTIONS_API_INSTRUCTIONS)
|
|
37294
|
-
});
|
|
37295
|
-
processContext.exit(1);
|
|
37296
|
-
return;
|
|
37297
|
-
}
|
|
37298
|
-
} else {
|
|
37299
|
-
data = fetched;
|
|
37805
|
+
await emitListConnectionsFailure(fetchError);
|
|
37806
|
+
return;
|
|
37300
37807
|
}
|
|
37808
|
+
data = fetched;
|
|
37301
37809
|
}
|
|
37302
37810
|
if (options.connectionId && data) {
|
|
37303
37811
|
data = data.filter((c) => c.id === options.connectionId);
|
|
@@ -39137,14 +39645,14 @@ async function handleExecuteAction(connectorKey, objectName, httpMethod, normali
|
|
|
39137
39645
|
Result: RESULTS.Success,
|
|
39138
39646
|
Code: "ExecuteOperation",
|
|
39139
39647
|
Data: data
|
|
39140
|
-
});
|
|
39648
|
+
}, { preserveDataKeys: true });
|
|
39141
39649
|
} else {
|
|
39142
39650
|
const body = result.body != null && typeof result.body === "object" ? result.body : { Value: result.body };
|
|
39143
39651
|
OutputFormatter.success({
|
|
39144
39652
|
Result: RESULTS.Success,
|
|
39145
39653
|
Code: "ExecuteOperation",
|
|
39146
39654
|
Data: body
|
|
39147
|
-
});
|
|
39655
|
+
}, { preserveDataKeys: true });
|
|
39148
39656
|
}
|
|
39149
39657
|
}
|
|
39150
39658
|
var registerResourcesCommand = (program2) => {
|