@uipath/eval-tool 1.205.0-preview.281 → 1.206.0-preview.282
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/README.md +42 -0
- package/dist/index-4vph9vqn.js +478 -0
- package/dist/{index-sby22td6.js → index-nzr4mx5p.js} +2 -22
- package/dist/index.js +8 -9
- package/dist/{jmespath-231m3hyn.js → jmespath-ab6tdc42.js} +1 -1
- package/dist/{js-yaml-88tdqrtd.js → js-yaml-a2bk27p6.js} +1 -3
- package/dist/{tool-1de529jm.js → tool-epsr41wx.js} +12 -3
- package/dist/{tool-5wkfd0fa.js → tool-hjrw81t7.js} +14 -16
- package/dist/{tool-ja7k1eac.js → tool-r2w4fazn.js} +2226 -1734
- package/dist/tool.js +7 -8
- package/package.json +2 -2
- package/dist/index-wm83gmqp.js +0 -23665
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
__toESM,
|
|
2
3
|
__commonJS,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "./tool-
|
|
4
|
+
__exportCjs,
|
|
5
|
+
__require
|
|
6
|
+
} from "./tool-epsr41wx.js";
|
|
6
7
|
|
|
7
8
|
// ../../node_modules/commander/lib/error.js
|
|
8
9
|
var require_error = __commonJS(function(exports) {
|
|
@@ -124,7 +125,7 @@ var require_help = __commonJS(function(exports) {
|
|
|
124
125
|
this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
|
|
125
126
|
}
|
|
126
127
|
visibleCommands(cmd) {
|
|
127
|
-
const visibleCommands = cmd.commands.filter((
|
|
128
|
+
const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden);
|
|
128
129
|
const helpCommand = cmd._getHelpCommand();
|
|
129
130
|
if (helpCommand && !helpCommand._hidden) {
|
|
130
131
|
visibleCommands.push(helpCommand);
|
|
@@ -604,8 +605,8 @@ var require_option = __commonJS(function(exports) {
|
|
|
604
605
|
}
|
|
605
606
|
}
|
|
606
607
|
function camelcase(str) {
|
|
607
|
-
return str.split("-").reduce((
|
|
608
|
-
return
|
|
608
|
+
return str.split("-").reduce((str, word) => {
|
|
609
|
+
return str + word[0].toUpperCase() + word.slice(1);
|
|
609
610
|
});
|
|
610
611
|
}
|
|
611
612
|
function splitOptionFlags(flags) {
|
|
@@ -1176,44 +1177,44 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1176
1177
|
});
|
|
1177
1178
|
return source;
|
|
1178
1179
|
}
|
|
1179
|
-
_prepareUserArgs(
|
|
1180
|
-
if (
|
|
1180
|
+
_prepareUserArgs(argv2, parseOptions) {
|
|
1181
|
+
if (argv2 !== undefined && !Array.isArray(argv2)) {
|
|
1181
1182
|
throw new Error("first parameter to parse must be array or undefined");
|
|
1182
1183
|
}
|
|
1183
1184
|
parseOptions = parseOptions || {};
|
|
1184
|
-
if (
|
|
1185
|
+
if (argv2 === undefined && parseOptions.from === undefined) {
|
|
1185
1186
|
if (process2.versions?.electron) {
|
|
1186
1187
|
parseOptions.from = "electron";
|
|
1187
1188
|
}
|
|
1188
|
-
const
|
|
1189
|
-
if (
|
|
1189
|
+
const execArgv2 = process2.execArgv ?? [];
|
|
1190
|
+
if (execArgv2.includes("-e") || execArgv2.includes("--eval") || execArgv2.includes("-p") || execArgv2.includes("--print")) {
|
|
1190
1191
|
parseOptions.from = "eval";
|
|
1191
1192
|
}
|
|
1192
1193
|
}
|
|
1193
|
-
if (
|
|
1194
|
-
|
|
1194
|
+
if (argv2 === undefined) {
|
|
1195
|
+
argv2 = process2.argv;
|
|
1195
1196
|
}
|
|
1196
|
-
this.rawArgs =
|
|
1197
|
+
this.rawArgs = argv2.slice();
|
|
1197
1198
|
let userArgs;
|
|
1198
1199
|
switch (parseOptions.from) {
|
|
1199
1200
|
case undefined:
|
|
1200
1201
|
case "node":
|
|
1201
|
-
this._scriptPath =
|
|
1202
|
-
userArgs =
|
|
1202
|
+
this._scriptPath = argv2[1];
|
|
1203
|
+
userArgs = argv2.slice(2);
|
|
1203
1204
|
break;
|
|
1204
1205
|
case "electron":
|
|
1205
1206
|
if (process2.defaultApp) {
|
|
1206
|
-
this._scriptPath =
|
|
1207
|
-
userArgs =
|
|
1207
|
+
this._scriptPath = argv2[1];
|
|
1208
|
+
userArgs = argv2.slice(2);
|
|
1208
1209
|
} else {
|
|
1209
|
-
userArgs =
|
|
1210
|
+
userArgs = argv2.slice(1);
|
|
1210
1211
|
}
|
|
1211
1212
|
break;
|
|
1212
1213
|
case "user":
|
|
1213
|
-
userArgs =
|
|
1214
|
+
userArgs = argv2.slice(0);
|
|
1214
1215
|
break;
|
|
1215
1216
|
case "eval":
|
|
1216
|
-
userArgs =
|
|
1217
|
+
userArgs = argv2.slice(1);
|
|
1217
1218
|
break;
|
|
1218
1219
|
default:
|
|
1219
1220
|
throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
|
|
@@ -1736,18 +1737,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1736
1737
|
this.error(message, { code: "commander.missingMandatoryOptionValue" });
|
|
1737
1738
|
}
|
|
1738
1739
|
_conflictingOption(option, conflictingOption) {
|
|
1739
|
-
const findBestOptionFromValue = (
|
|
1740
|
-
const optionKey =
|
|
1740
|
+
const findBestOptionFromValue = (option) => {
|
|
1741
|
+
const optionKey = option.attributeName();
|
|
1741
1742
|
const optionValue = this.getOptionValue(optionKey);
|
|
1742
1743
|
const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
|
|
1743
1744
|
const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
|
|
1744
1745
|
if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) {
|
|
1745
1746
|
return negativeOption;
|
|
1746
1747
|
}
|
|
1747
|
-
return positiveOption ||
|
|
1748
|
+
return positiveOption || option;
|
|
1748
1749
|
};
|
|
1749
|
-
const getErrorMessage = (
|
|
1750
|
-
const bestOption = findBestOptionFromValue(
|
|
1750
|
+
const getErrorMessage = (option) => {
|
|
1751
|
+
const bestOption = findBestOptionFromValue(option);
|
|
1751
1752
|
const optionKey = bestOption.attributeName();
|
|
1752
1753
|
const source = this.getOptionValueSource(optionKey);
|
|
1753
1754
|
if (source === "env") {
|
|
@@ -1901,10 +1902,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1901
1902
|
this._name = path.basename(filename, path.extname(filename));
|
|
1902
1903
|
return this;
|
|
1903
1904
|
}
|
|
1904
|
-
executableDir(
|
|
1905
|
-
if (
|
|
1905
|
+
executableDir(path) {
|
|
1906
|
+
if (path === undefined)
|
|
1906
1907
|
return this._executableDir;
|
|
1907
|
-
this._executableDir =
|
|
1908
|
+
this._executableDir = path;
|
|
1908
1909
|
return this;
|
|
1909
1910
|
}
|
|
1910
1911
|
helpInformation(contextOptions) {
|
|
@@ -2001,11 +2002,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2001
2002
|
}
|
|
2002
2003
|
help(contextOptions) {
|
|
2003
2004
|
this.outputHelp(contextOptions);
|
|
2004
|
-
let
|
|
2005
|
-
if (
|
|
2006
|
-
|
|
2005
|
+
let exitCode2 = Number(process2.exitCode ?? 0);
|
|
2006
|
+
if (exitCode2 === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
|
|
2007
|
+
exitCode2 = 1;
|
|
2007
2008
|
}
|
|
2008
|
-
this._exit(
|
|
2009
|
+
this._exit(exitCode2, "commander.help", "(outputHelp)");
|
|
2009
2010
|
}
|
|
2010
2011
|
addHelpText(position, text) {
|
|
2011
2012
|
const allowedValues = ["beforeAll", "before", "after", "afterAll"];
|
|
@@ -2078,206 +2079,63 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2078
2079
|
});
|
|
2079
2080
|
|
|
2080
2081
|
// ../../node_modules/commander/index.js
|
|
2081
|
-
var
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2082
|
+
var exports_commander = {};
|
|
2083
|
+
__exportCjs(exports_commander, {
|
|
2084
|
+
program: () => $program,
|
|
2085
|
+
createCommand: () => $createCommand,
|
|
2086
|
+
createOption: () => $createOption,
|
|
2087
|
+
createArgument: () => $createArgument,
|
|
2088
|
+
Command: () => $Command,
|
|
2089
|
+
Option: () => $Option,
|
|
2090
|
+
Argument: () => $Argument,
|
|
2091
|
+
Help: () => $Help,
|
|
2092
|
+
CommanderError: () => $CommanderError,
|
|
2093
|
+
InvalidArgumentError: () => $InvalidArgumentError,
|
|
2094
|
+
InvalidOptionArgumentError: () => $InvalidOptionArgumentError
|
|
2095
|
+
}, {
|
|
2096
|
+
program: (value) => $program = value,
|
|
2097
|
+
createCommand: (value) => $createCommand = value,
|
|
2098
|
+
createOption: (value) => $createOption = value,
|
|
2099
|
+
createArgument: (value) => $createArgument = value,
|
|
2100
|
+
Command: (value) => $Command = value,
|
|
2101
|
+
Option: (value) => $Option = value,
|
|
2102
|
+
Argument: (value) => $Argument = value,
|
|
2103
|
+
Help: (value) => $Help = value,
|
|
2104
|
+
CommanderError: (value) => $CommanderError = value,
|
|
2105
|
+
InvalidArgumentError: (value) => $InvalidArgumentError = value,
|
|
2106
|
+
InvalidOptionArgumentError: (value) => $InvalidOptionArgumentError = value
|
|
2098
2107
|
});
|
|
2108
|
+
var { Argument } = require_argument();
|
|
2109
|
+
var { Command: Command2 } = require_command();
|
|
2110
|
+
var { CommanderError, InvalidArgumentError } = require_error();
|
|
2111
|
+
var { Help } = require_help();
|
|
2112
|
+
var { Option } = require_option();
|
|
2113
|
+
var $program = new Command2;
|
|
2114
|
+
var $createCommand = (name) => new Command2(name);
|
|
2115
|
+
var $createOption = (flags, description) => new Option(flags, description);
|
|
2116
|
+
var $createArgument = (name, description) => new Argument(name, description);
|
|
2117
|
+
var $Command = Command2;
|
|
2118
|
+
var $Option = Option;
|
|
2119
|
+
var $Argument = Argument;
|
|
2120
|
+
var $Help = Help;
|
|
2121
|
+
var $CommanderError = CommanderError;
|
|
2122
|
+
var $InvalidArgumentError = InvalidArgumentError;
|
|
2123
|
+
var $InvalidOptionArgumentError = InvalidArgumentError;
|
|
2099
2124
|
|
|
2100
2125
|
// ../../node_modules/commander/esm.mjs
|
|
2101
|
-
var import__ = __toESM(require_commander(), 1);
|
|
2102
2126
|
var {
|
|
2103
2127
|
program,
|
|
2104
2128
|
createCommand,
|
|
2105
2129
|
createArgument,
|
|
2106
2130
|
createOption,
|
|
2107
|
-
CommanderError,
|
|
2108
|
-
InvalidArgumentError,
|
|
2131
|
+
CommanderError: CommanderError2,
|
|
2132
|
+
InvalidArgumentError: InvalidArgumentError2,
|
|
2109
2133
|
InvalidOptionArgumentError,
|
|
2110
2134
|
Command,
|
|
2111
|
-
Argument,
|
|
2112
|
-
Option,
|
|
2113
|
-
Help
|
|
2114
|
-
} =
|
|
2115
|
-
|
|
2116
|
-
// ../common/src/telemetry/pseudonymize.ts
|
|
2117
|
-
var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
|
|
2118
|
-
var PSEUDONYM_HEX_LENGTH = 32;
|
|
2119
|
-
var SHA256_K = new Uint32Array([
|
|
2120
|
-
1116352408,
|
|
2121
|
-
1899447441,
|
|
2122
|
-
3049323471,
|
|
2123
|
-
3921009573,
|
|
2124
|
-
961987163,
|
|
2125
|
-
1508970993,
|
|
2126
|
-
2453635748,
|
|
2127
|
-
2870763221,
|
|
2128
|
-
3624381080,
|
|
2129
|
-
310598401,
|
|
2130
|
-
607225278,
|
|
2131
|
-
1426881987,
|
|
2132
|
-
1925078388,
|
|
2133
|
-
2162078206,
|
|
2134
|
-
2614888103,
|
|
2135
|
-
3248222580,
|
|
2136
|
-
3835390401,
|
|
2137
|
-
4022224774,
|
|
2138
|
-
264347078,
|
|
2139
|
-
604807628,
|
|
2140
|
-
770255983,
|
|
2141
|
-
1249150122,
|
|
2142
|
-
1555081692,
|
|
2143
|
-
1996064986,
|
|
2144
|
-
2554220882,
|
|
2145
|
-
2821834349,
|
|
2146
|
-
2952996808,
|
|
2147
|
-
3210313671,
|
|
2148
|
-
3336571891,
|
|
2149
|
-
3584528711,
|
|
2150
|
-
113926993,
|
|
2151
|
-
338241895,
|
|
2152
|
-
666307205,
|
|
2153
|
-
773529912,
|
|
2154
|
-
1294757372,
|
|
2155
|
-
1396182291,
|
|
2156
|
-
1695183700,
|
|
2157
|
-
1986661051,
|
|
2158
|
-
2177026350,
|
|
2159
|
-
2456956037,
|
|
2160
|
-
2730485921,
|
|
2161
|
-
2820302411,
|
|
2162
|
-
3259730800,
|
|
2163
|
-
3345764771,
|
|
2164
|
-
3516065817,
|
|
2165
|
-
3600352804,
|
|
2166
|
-
4094571909,
|
|
2167
|
-
275423344,
|
|
2168
|
-
430227734,
|
|
2169
|
-
506948616,
|
|
2170
|
-
659060556,
|
|
2171
|
-
883997877,
|
|
2172
|
-
958139571,
|
|
2173
|
-
1322822218,
|
|
2174
|
-
1537002063,
|
|
2175
|
-
1747873779,
|
|
2176
|
-
1955562222,
|
|
2177
|
-
2024104815,
|
|
2178
|
-
2227730452,
|
|
2179
|
-
2361852424,
|
|
2180
|
-
2428436474,
|
|
2181
|
-
2756734187,
|
|
2182
|
-
3204031479,
|
|
2183
|
-
3329325298
|
|
2184
|
-
]);
|
|
2185
|
-
var SHA256_INITIAL_STATE = new Uint32Array([
|
|
2186
|
-
1779033703,
|
|
2187
|
-
3144134277,
|
|
2188
|
-
1013904242,
|
|
2189
|
-
2773480762,
|
|
2190
|
-
1359893119,
|
|
2191
|
-
2600822924,
|
|
2192
|
-
528734635,
|
|
2193
|
-
1541459225
|
|
2194
|
-
]);
|
|
2195
|
-
function rotr(value, bits) {
|
|
2196
|
-
return (value >>> bits | value << 32 - bits) >>> 0;
|
|
2197
|
-
}
|
|
2198
|
-
function sha256Hex(input) {
|
|
2199
|
-
const bytes = new TextEncoder().encode(input);
|
|
2200
|
-
const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
|
|
2201
|
-
const buffer = new Uint8Array(paddedLength);
|
|
2202
|
-
buffer.set(bytes);
|
|
2203
|
-
buffer[bytes.length] = 128;
|
|
2204
|
-
const view = new DataView(buffer.buffer);
|
|
2205
|
-
const bitLength = bytes.length * 8;
|
|
2206
|
-
view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296));
|
|
2207
|
-
view.setUint32(paddedLength - 4, bitLength >>> 0);
|
|
2208
|
-
const state = SHA256_INITIAL_STATE.slice();
|
|
2209
|
-
const schedule = new Uint32Array(64);
|
|
2210
|
-
for (let offset = 0;offset < paddedLength; offset += 64) {
|
|
2211
|
-
for (let i = 0;i < 16; i++) {
|
|
2212
|
-
schedule[i] = view.getUint32(offset + i * 4);
|
|
2213
|
-
}
|
|
2214
|
-
for (let i = 16;i < 64; i++) {
|
|
2215
|
-
const x = schedule[i - 15];
|
|
2216
|
-
const y = schedule[i - 2];
|
|
2217
|
-
const s0 = (rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3) >>> 0;
|
|
2218
|
-
const s1 = (rotr(y, 17) ^ rotr(y, 19) ^ y >>> 10) >>> 0;
|
|
2219
|
-
schedule[i] = schedule[i - 16] + s0 + schedule[i - 7] + s1 >>> 0;
|
|
2220
|
-
}
|
|
2221
|
-
let a = state[0];
|
|
2222
|
-
let b = state[1];
|
|
2223
|
-
let c = state[2];
|
|
2224
|
-
let d = state[3];
|
|
2225
|
-
let e = state[4];
|
|
2226
|
-
let f = state[5];
|
|
2227
|
-
let g = state[6];
|
|
2228
|
-
let h = state[7];
|
|
2229
|
-
for (let i = 0;i < 64; i++) {
|
|
2230
|
-
const s1 = (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) >>> 0;
|
|
2231
|
-
const ch = (e & f ^ ~e & g) >>> 0;
|
|
2232
|
-
const temp1 = h + s1 + ch + SHA256_K[i] + schedule[i] >>> 0;
|
|
2233
|
-
const s0 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) >>> 0;
|
|
2234
|
-
const maj = (a & b ^ a & c ^ b & c) >>> 0;
|
|
2235
|
-
const temp2 = s0 + maj >>> 0;
|
|
2236
|
-
h = g;
|
|
2237
|
-
g = f;
|
|
2238
|
-
f = e;
|
|
2239
|
-
e = d + temp1 >>> 0;
|
|
2240
|
-
d = c;
|
|
2241
|
-
c = b;
|
|
2242
|
-
b = a;
|
|
2243
|
-
a = temp1 + temp2 >>> 0;
|
|
2244
|
-
}
|
|
2245
|
-
state[0] = state[0] + a >>> 0;
|
|
2246
|
-
state[1] = state[1] + b >>> 0;
|
|
2247
|
-
state[2] = state[2] + c >>> 0;
|
|
2248
|
-
state[3] = state[3] + d >>> 0;
|
|
2249
|
-
state[4] = state[4] + e >>> 0;
|
|
2250
|
-
state[5] = state[5] + f >>> 0;
|
|
2251
|
-
state[6] = state[6] + g >>> 0;
|
|
2252
|
-
state[7] = state[7] + h >>> 0;
|
|
2253
|
-
}
|
|
2254
|
-
let hex = "";
|
|
2255
|
-
for (const word of state) {
|
|
2256
|
-
hex += word.toString(16).padStart(8, "0");
|
|
2257
|
-
}
|
|
2258
|
-
return hex;
|
|
2259
|
-
}
|
|
2260
|
-
function resolveSha256Hex() {
|
|
2261
|
-
try {
|
|
2262
|
-
const nodeCrypto = __require("node:crypto");
|
|
2263
|
-
const createHash = nodeCrypto?.createHash;
|
|
2264
|
-
if (typeof createHash !== "function") {
|
|
2265
|
-
return sha256Hex;
|
|
2266
|
-
}
|
|
2267
|
-
const native = (input) => createHash("sha256").update(input, "utf8").digest("hex");
|
|
2268
|
-
return native("abc") === sha256Hex("abc") ? native : sha256Hex;
|
|
2269
|
-
} catch {
|
|
2270
|
-
return sha256Hex;
|
|
2271
|
-
}
|
|
2272
|
-
}
|
|
2273
|
-
var cachedSha256Hex;
|
|
2274
|
-
function digest(input) {
|
|
2275
|
-
cachedSha256Hex ??= resolveSha256Hex();
|
|
2276
|
-
return cachedSha256Hex(input);
|
|
2277
|
-
}
|
|
2278
|
-
function pseudonymize(input) {
|
|
2279
|
-
return digest(`${PSEUDONYM_DOMAIN}${input}`).slice(0, PSEUDONYM_HEX_LENGTH);
|
|
2280
|
-
}
|
|
2135
|
+
Argument: Argument2,
|
|
2136
|
+
Option: Option2,
|
|
2137
|
+
Help: Help2
|
|
2138
|
+
} = exports_commander;
|
|
2281
2139
|
|
|
2282
2140
|
// ../common/src/singleton.ts
|
|
2283
2141
|
var PREFIX = "@uipath/common/";
|
|
@@ -2309,1276 +2167,1701 @@ function singleton(ctorOrName) {
|
|
|
2309
2167
|
};
|
|
2310
2168
|
}
|
|
2311
2169
|
|
|
2312
|
-
// ../common/src/telemetry/
|
|
2313
|
-
var
|
|
2314
|
-
function
|
|
2315
|
-
|
|
2316
|
-
return Array.isArray(existing) ? existing : [];
|
|
2317
|
-
}
|
|
2318
|
-
var MIN_SCRUBBABLE_LENGTH = 4;
|
|
2319
|
-
function recordSuppliedArgumentValues(values) {
|
|
2320
|
-
const flat = [];
|
|
2321
|
-
const push = (value) => {
|
|
2322
|
-
if (Array.isArray(value)) {
|
|
2323
|
-
for (const item of value) {
|
|
2324
|
-
push(item);
|
|
2325
|
-
}
|
|
2326
|
-
return;
|
|
2327
|
-
}
|
|
2328
|
-
if (typeof value === "string" && value.length >= MIN_SCRUBBABLE_LENGTH) {
|
|
2329
|
-
flat.push(value);
|
|
2330
|
-
}
|
|
2331
|
-
};
|
|
2332
|
-
push(values);
|
|
2333
|
-
const entry = { values: flat };
|
|
2334
|
-
suppliedValuesSlot.set([...activeEntries(), entry]);
|
|
2335
|
-
return entry;
|
|
2170
|
+
// ../common/src/telemetry/global-telemetry-properties.ts
|
|
2171
|
+
var telemetryPropsSlot = singleton("TelemetryDefaultProps");
|
|
2172
|
+
function getGlobalTelemetryProperties() {
|
|
2173
|
+
return telemetryPropsSlot.get();
|
|
2336
2174
|
}
|
|
2337
|
-
|
|
2338
|
-
|
|
2175
|
+
|
|
2176
|
+
// ../common/src/telemetry/telemetry-config.ts
|
|
2177
|
+
function isTelemetryDisabled() {
|
|
2178
|
+
const value = process.env.UIPATH_TELEMETRY_DISABLED;
|
|
2179
|
+
return value === "1" || value === "true";
|
|
2339
2180
|
}
|
|
2340
|
-
function
|
|
2341
|
-
|
|
2342
|
-
for (const entry of activeEntries()) {
|
|
2343
|
-
for (const value of entry.values) {
|
|
2344
|
-
all.add(value);
|
|
2345
|
-
}
|
|
2346
|
-
}
|
|
2347
|
-
return [...all].sort((a, b) => b.length - a.length);
|
|
2181
|
+
function isProjectTelemetryDisabled() {
|
|
2182
|
+
return isTelemetryDisabled() || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "1" || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "true";
|
|
2348
2183
|
}
|
|
2349
2184
|
|
|
2350
|
-
// ../common/src/telemetry/
|
|
2351
|
-
var
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
"
|
|
2360
|
-
"
|
|
2361
|
-
"
|
|
2362
|
-
"
|
|
2363
|
-
"
|
|
2364
|
-
"
|
|
2365
|
-
"
|
|
2366
|
-
"
|
|
2367
|
-
"
|
|
2368
|
-
"
|
|
2369
|
-
"
|
|
2370
|
-
"
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
"
|
|
2374
|
-
"
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
"
|
|
2378
|
-
"
|
|
2379
|
-
"
|
|
2380
|
-
"
|
|
2381
|
-
"
|
|
2382
|
-
"
|
|
2383
|
-
"
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
"
|
|
2387
|
-
"
|
|
2388
|
-
"
|
|
2389
|
-
"
|
|
2390
|
-
"
|
|
2391
|
-
"
|
|
2392
|
-
"
|
|
2393
|
-
|
|
2394
|
-
var
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
|
|
2400
|
-
var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
|
|
2401
|
-
var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
|
|
2402
|
-
var HOST_PORT_PATTERN = /(?<![/@.\w-])(?!\d+\.\d+\.\d+\.\d+:)[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)+:\d{1,5}\b/g;
|
|
2403
|
-
var SOURCE_FILE_EXTENSIONS = new Set([
|
|
2404
|
-
"ts",
|
|
2405
|
-
"tsx",
|
|
2406
|
-
"js",
|
|
2407
|
-
"jsx",
|
|
2408
|
-
"mjs",
|
|
2409
|
-
"cjs",
|
|
2410
|
-
"cts",
|
|
2411
|
-
"mts",
|
|
2412
|
-
"py",
|
|
2413
|
-
"cs",
|
|
2414
|
-
"java",
|
|
2415
|
-
"go",
|
|
2416
|
-
"rs",
|
|
2417
|
-
"rb",
|
|
2418
|
-
"php",
|
|
2419
|
-
"sh",
|
|
2420
|
-
"ps1",
|
|
2421
|
-
"json",
|
|
2422
|
-
"jsonc",
|
|
2423
|
-
"yaml",
|
|
2424
|
-
"yml",
|
|
2425
|
-
"xml",
|
|
2426
|
-
"xaml",
|
|
2427
|
-
"md",
|
|
2428
|
-
"txt",
|
|
2429
|
-
"log",
|
|
2430
|
-
"css",
|
|
2431
|
-
"html",
|
|
2432
|
-
"htm",
|
|
2433
|
-
"csproj",
|
|
2434
|
-
"nuspec",
|
|
2435
|
-
"sql"
|
|
2185
|
+
// ../common/src/telemetry/telemetry-dimensions.ts
|
|
2186
|
+
var BaseDimensions = {
|
|
2187
|
+
ApplicationName: "ApplicationName",
|
|
2188
|
+
ProductVersion: "ProductVersion",
|
|
2189
|
+
InstallationId: "InstallationId",
|
|
2190
|
+
CloudUserId: "CloudUserId",
|
|
2191
|
+
CloudTenantId: "CloudTenantId",
|
|
2192
|
+
CloudOrganizationId: "CloudOrganizationId",
|
|
2193
|
+
IsInternalUser: "IsInternalUser",
|
|
2194
|
+
Environment: "Environment",
|
|
2195
|
+
BaseUrl: "BaseUrl",
|
|
2196
|
+
Region: "Region",
|
|
2197
|
+
Agent: "Agent",
|
|
2198
|
+
AgentVersion: "AgentVersion",
|
|
2199
|
+
AgentModel: "AgentModel",
|
|
2200
|
+
ToolName: "ToolName",
|
|
2201
|
+
ToolVersion: "ToolVersion",
|
|
2202
|
+
ExecutionContext: "ExecutionContext",
|
|
2203
|
+
CiProvider: "CiProvider",
|
|
2204
|
+
SessionIdSource: "SessionIdSource",
|
|
2205
|
+
SessionId: "SessionId"
|
|
2206
|
+
};
|
|
2207
|
+
var CommandDimensions = {
|
|
2208
|
+
IsCommand: "IsCommand",
|
|
2209
|
+
IsReexec: "IsReexec",
|
|
2210
|
+
CommandName: "CommandName",
|
|
2211
|
+
ExitCode: "ExitCode",
|
|
2212
|
+
TerminalOutcome: "TerminalOutcome",
|
|
2213
|
+
ErrorClass: "ErrorClass",
|
|
2214
|
+
TerminalSignal: "TerminalSignal",
|
|
2215
|
+
ErrorMessage: "ErrorMessage",
|
|
2216
|
+
SkillName: "SkillName",
|
|
2217
|
+
ProductArea: "ProductArea",
|
|
2218
|
+
Mode: "Mode"
|
|
2219
|
+
};
|
|
2220
|
+
var ProjectDimensions = {
|
|
2221
|
+
ProjectKey: "ProjectKey",
|
|
2222
|
+
ProjectType: "ProjectType",
|
|
2223
|
+
ProjectIdentityStatus: "ProjectIdentityStatus",
|
|
2224
|
+
SolutionKey: "SolutionKey",
|
|
2225
|
+
SolutionProjectKey: "SolutionProjectKey",
|
|
2226
|
+
SolutionIdentityStatus: "SolutionIdentityStatus",
|
|
2227
|
+
PreviousSolutionKey: "PreviousSolutionKey"
|
|
2228
|
+
};
|
|
2229
|
+
var GUID_KEY_DIMENSIONS = new Set([
|
|
2230
|
+
ProjectDimensions.ProjectKey,
|
|
2231
|
+
ProjectDimensions.SolutionKey,
|
|
2232
|
+
ProjectDimensions.SolutionProjectKey,
|
|
2233
|
+
ProjectDimensions.PreviousSolutionKey
|
|
2436
2234
|
]);
|
|
2437
|
-
var
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2235
|
+
var ShipDimensions = {
|
|
2236
|
+
ShipKind: "ShipKind",
|
|
2237
|
+
Target: "Target",
|
|
2238
|
+
ProjectType: "ProjectType",
|
|
2239
|
+
ProjectTypes: "ProjectTypes",
|
|
2240
|
+
ArtifactCorrelationKey: "ArtifactCorrelationKey",
|
|
2241
|
+
PackageName: "PackageName",
|
|
2242
|
+
PackageVersion: "PackageVersion",
|
|
2243
|
+
PackageVersionKey: "PackageVersionKey",
|
|
2244
|
+
DeploymentKey: "DeploymentKey",
|
|
2245
|
+
SolutionId: "SolutionId",
|
|
2246
|
+
FolderKey: "FolderKey",
|
|
2247
|
+
FeedId: "FeedId"
|
|
2248
|
+
};
|
|
2249
|
+
var ErrorDimensions = {
|
|
2250
|
+
Result: "Result",
|
|
2251
|
+
ErrorCode: "ErrorCode",
|
|
2252
|
+
Retry: "Retry",
|
|
2253
|
+
ErrorMessage: "ErrorMessage",
|
|
2254
|
+
HttpStatus: "HttpStatus",
|
|
2255
|
+
UpstreamErrorCode: "UpstreamErrorCode"
|
|
2256
|
+
};
|
|
2257
|
+
var AuthDimensions = {
|
|
2258
|
+
AuthenticationMethod: "AuthenticationMethod",
|
|
2259
|
+
Success: "Success",
|
|
2260
|
+
Reason: "Reason"
|
|
2261
|
+
};
|
|
2262
|
+
var SkillsDimensions = {
|
|
2263
|
+
SchemaVersion: "SchemaVersion",
|
|
2264
|
+
AgentType: "AgentType",
|
|
2265
|
+
SkillsVersion: "SkillsVersion",
|
|
2266
|
+
UipSubcommand: "UipSubcommand",
|
|
2267
|
+
FileExtension: "FileExtension",
|
|
2268
|
+
SubagentModel: "SubagentModel",
|
|
2269
|
+
SubagentType: "SubagentType",
|
|
2270
|
+
PermissionMode: "PermissionMode",
|
|
2271
|
+
EffortLevel: "EffortLevel",
|
|
2272
|
+
SessionSource: "SessionSource",
|
|
2273
|
+
Outcome: "Outcome",
|
|
2274
|
+
DurationMs: "DurationMs",
|
|
2275
|
+
Source: "Source"
|
|
2276
|
+
};
|
|
2277
|
+
var PackagerDimensions = {
|
|
2278
|
+
ProjectId: "ProjectId",
|
|
2279
|
+
ProjectType: "ProjectType",
|
|
2280
|
+
SolutionId: "SolutionId"
|
|
2281
|
+
};
|
|
2282
|
+
var ScopeDimensions = {
|
|
2283
|
+
FolderId: "FolderId"
|
|
2284
|
+
};
|
|
2285
|
+
var ID_DIMENSIONS = new Set([
|
|
2286
|
+
BaseDimensions.CloudUserId,
|
|
2287
|
+
BaseDimensions.CloudTenantId,
|
|
2288
|
+
BaseDimensions.CloudOrganizationId,
|
|
2289
|
+
BaseDimensions.InstallationId,
|
|
2290
|
+
ShipDimensions.ArtifactCorrelationKey,
|
|
2291
|
+
ShipDimensions.PackageVersionKey,
|
|
2292
|
+
ShipDimensions.DeploymentKey,
|
|
2293
|
+
ShipDimensions.SolutionId,
|
|
2294
|
+
ShipDimensions.FolderKey,
|
|
2295
|
+
ShipDimensions.FeedId,
|
|
2296
|
+
PackagerDimensions.ProjectId
|
|
2297
|
+
]);
|
|
2298
|
+
var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
|
|
2299
|
+
var RESERVED_DIMENSION_NAMES = new Set([
|
|
2300
|
+
...Object.values(BaseDimensions),
|
|
2301
|
+
...Object.values(CommandDimensions),
|
|
2302
|
+
...Object.values(ShipDimensions),
|
|
2303
|
+
...Object.values(ProjectDimensions),
|
|
2304
|
+
...Object.values(ErrorDimensions),
|
|
2305
|
+
...Object.values(AuthDimensions),
|
|
2306
|
+
...Object.values(SkillsDimensions),
|
|
2307
|
+
...Object.values(PackagerDimensions),
|
|
2308
|
+
...Object.values(ScopeDimensions)
|
|
2309
|
+
]);
|
|
2310
|
+
var CURATED_DIMENSIONS = new Set([
|
|
2311
|
+
BaseDimensions.ApplicationName,
|
|
2312
|
+
BaseDimensions.ProductVersion,
|
|
2313
|
+
BaseDimensions.InstallationId,
|
|
2314
|
+
BaseDimensions.CloudUserId,
|
|
2315
|
+
BaseDimensions.CloudTenantId,
|
|
2316
|
+
BaseDimensions.CloudOrganizationId,
|
|
2317
|
+
BaseDimensions.IsInternalUser,
|
|
2318
|
+
BaseDimensions.Environment,
|
|
2319
|
+
BaseDimensions.BaseUrl,
|
|
2320
|
+
BaseDimensions.Region,
|
|
2321
|
+
BaseDimensions.Agent,
|
|
2322
|
+
BaseDimensions.AgentVersion,
|
|
2323
|
+
BaseDimensions.ToolVersion,
|
|
2324
|
+
BaseDimensions.ExecutionContext,
|
|
2325
|
+
BaseDimensions.CiProvider,
|
|
2326
|
+
BaseDimensions.SessionIdSource,
|
|
2327
|
+
BaseDimensions.SessionId,
|
|
2328
|
+
...Object.values(CommandDimensions),
|
|
2329
|
+
...Object.values(ShipDimensions),
|
|
2330
|
+
...Object.values(ProjectDimensions)
|
|
2331
|
+
]);
|
|
2332
|
+
function lowercaseIdDimensionValues(properties) {
|
|
2333
|
+
let changed = false;
|
|
2334
|
+
const result = {
|
|
2335
|
+
...properties
|
|
2336
|
+
};
|
|
2337
|
+
for (const key of Object.keys(result)) {
|
|
2338
|
+
const value = result[key];
|
|
2339
|
+
if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
|
|
2340
|
+
continue;
|
|
2341
|
+
}
|
|
2342
|
+
const lowered = value.toLowerCase();
|
|
2343
|
+
if (lowered !== value) {
|
|
2344
|
+
result[key] = lowered;
|
|
2345
|
+
changed = true;
|
|
2455
2346
|
}
|
|
2456
|
-
out = next;
|
|
2457
2347
|
}
|
|
2458
|
-
return
|
|
2348
|
+
return changed ? result : properties;
|
|
2459
2349
|
}
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
return
|
|
2350
|
+
|
|
2351
|
+
// ../common/src/sdk-user-agent.ts
|
|
2352
|
+
var USER_AGENT_HEADER = "User-Agent";
|
|
2353
|
+
var AGENT_PROPERTY = BaseDimensions.Agent;
|
|
2354
|
+
var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
|
|
2355
|
+
function userAgentPatchKey(userAgent) {
|
|
2356
|
+
return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
|
|
2467
2357
|
}
|
|
2468
|
-
function
|
|
2469
|
-
|
|
2470
|
-
const url = new URL(raw);
|
|
2471
|
-
return `${url.protocol}//${url.host}`;
|
|
2472
|
-
} catch {
|
|
2473
|
-
return `url#${pseudonymize(raw)}`;
|
|
2474
|
-
}
|
|
2358
|
+
function splitUserAgentTokens(value) {
|
|
2359
|
+
return value?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
2475
2360
|
}
|
|
2476
|
-
function
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
|
|
2484
|
-
out = out.replace(UNC_PATH_PATTERN, (_match, before, path) => {
|
|
2485
|
-
const [core, trailing] = peelTrailingPunctuation(path);
|
|
2486
|
-
return `${before}unc#${pseudonymize(core)}${trailing}`;
|
|
2487
|
-
});
|
|
2488
|
-
out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
|
|
2489
|
-
out = out.replace(UUID_PATTERN, (match) => `uuid#${pseudonymize(match)}`);
|
|
2490
|
-
out = out.replace(HOST_PORT_PATTERN, (match) => {
|
|
2491
|
-
const split = match.lastIndexOf(":");
|
|
2492
|
-
const host = match.slice(0, split);
|
|
2493
|
-
const extension = host.slice(host.lastIndexOf(".") + 1).toLowerCase();
|
|
2494
|
-
if (SOURCE_FILE_EXTENSIONS.has(extension)) {
|
|
2495
|
-
return match;
|
|
2361
|
+
function appendUserAgentToken(value, userAgent) {
|
|
2362
|
+
const tokens = splitUserAgentTokens(value);
|
|
2363
|
+
const seen = new Set(tokens);
|
|
2364
|
+
for (const token of splitUserAgentTokens(userAgent)) {
|
|
2365
|
+
if (!seen.has(token)) {
|
|
2366
|
+
tokens.push(token);
|
|
2367
|
+
seen.add(token);
|
|
2496
2368
|
}
|
|
2497
|
-
|
|
2369
|
+
}
|
|
2370
|
+
return tokens.join(" ");
|
|
2371
|
+
}
|
|
2372
|
+
function getEffectiveUserAgent(userAgent) {
|
|
2373
|
+
return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
|
|
2374
|
+
}
|
|
2375
|
+
function getHeaderName(headers, headerName) {
|
|
2376
|
+
return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase());
|
|
2377
|
+
}
|
|
2378
|
+
function getSdkUserAgentToken(pkg) {
|
|
2379
|
+
const packageName = pkg.name.replace(/^@uipath\//, "");
|
|
2380
|
+
return getEffectiveUserAgent(`${packageName}/${pkg.version}`);
|
|
2381
|
+
}
|
|
2382
|
+
function addSdkUserAgentHeader(headers, userAgent) {
|
|
2383
|
+
const result = { ...headers ?? {} };
|
|
2384
|
+
const headerName = getHeaderName(result, USER_AGENT_HEADER);
|
|
2385
|
+
result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent));
|
|
2386
|
+
return result;
|
|
2387
|
+
}
|
|
2388
|
+
function asHeaderRecord(headers) {
|
|
2389
|
+
return typeof headers === "object" && headers !== null ? { ...headers } : {};
|
|
2390
|
+
}
|
|
2391
|
+
function withForwardedHeadersInitOverride(initOverrides, forward) {
|
|
2392
|
+
return async (requestContext) => {
|
|
2393
|
+
const initWithHeaders = {
|
|
2394
|
+
...requestContext.init,
|
|
2395
|
+
headers: forward(asHeaderRecord(requestContext.init.headers))
|
|
2396
|
+
};
|
|
2397
|
+
const override = typeof initOverrides === "function" ? await initOverrides({
|
|
2398
|
+
...requestContext,
|
|
2399
|
+
init: initWithHeaders
|
|
2400
|
+
}) : initOverrides;
|
|
2401
|
+
return {
|
|
2402
|
+
...override ?? {},
|
|
2403
|
+
headers: forward(asHeaderRecord(override?.headers ?? initWithHeaders.headers))
|
|
2404
|
+
};
|
|
2405
|
+
};
|
|
2406
|
+
}
|
|
2407
|
+
function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
|
|
2408
|
+
const prototype = BaseApiClass.prototype;
|
|
2409
|
+
if (prototype[patchKey]) {
|
|
2410
|
+
return;
|
|
2411
|
+
}
|
|
2412
|
+
if (typeof prototype.request !== "function") {
|
|
2413
|
+
throw new Error("Generated BaseAPI request function not found.");
|
|
2414
|
+
}
|
|
2415
|
+
const originalRequest = prototype.request;
|
|
2416
|
+
prototype.request = function requestWithForwardedHeaders(context, initOverrides) {
|
|
2417
|
+
return originalRequest.call(this, context, withForwardedHeadersInitOverride(initOverrides, forward));
|
|
2418
|
+
};
|
|
2419
|
+
Object.defineProperty(prototype, patchKey, {
|
|
2420
|
+
value: true
|
|
2498
2421
|
});
|
|
2499
|
-
out = out.replace(PADDED_BASE64_PATTERN, () => REDACTED);
|
|
2500
|
-
out = out.replace(BASE64_WITH_PLUS_PATTERN, (match) => match.includes("+") ? REDACTED : match);
|
|
2501
|
-
out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
|
|
2502
|
-
return truncate(out, maxLength);
|
|
2503
2422
|
}
|
|
2504
|
-
function
|
|
2505
|
-
|
|
2423
|
+
function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
2424
|
+
installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
|
|
2506
2425
|
}
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2426
|
+
|
|
2427
|
+
// ../filesystem/src/node.ts
|
|
2428
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2429
|
+
import { existsSync } from "node:fs";
|
|
2430
|
+
import * as fs from "node:fs/promises";
|
|
2431
|
+
import * as os from "node:os";
|
|
2432
|
+
import * as path from "node:path";
|
|
2433
|
+
var LOCK_HEARTBEAT_MS = 5000;
|
|
2434
|
+
var LOCK_STALE_MS = 15000;
|
|
2435
|
+
var LOCK_MAX_WAIT_MS = 20000;
|
|
2436
|
+
var LOCK_MAX_HOLD_MS = 60000;
|
|
2437
|
+
var LOCK_RETRY_MIN_MS = 100;
|
|
2438
|
+
var LOCK_RETRY_JITTER_MS = 200;
|
|
2439
|
+
var HASH_CHUNK_BYTES = 256 * 1024;
|
|
2440
|
+
var hashBuffers = [];
|
|
2441
|
+
var HASH_BUFFERS_KEPT = 64;
|
|
2442
|
+
|
|
2443
|
+
class NodeFileSystem {
|
|
2444
|
+
path = {
|
|
2445
|
+
join: path.join,
|
|
2446
|
+
resolve: path.resolve,
|
|
2447
|
+
relative: path.relative,
|
|
2448
|
+
dirname: path.dirname,
|
|
2449
|
+
isAbsolute: path.isAbsolute,
|
|
2450
|
+
basename: path.basename
|
|
2451
|
+
};
|
|
2452
|
+
env = {
|
|
2453
|
+
cwd: process.cwd,
|
|
2454
|
+
homedir: os.homedir,
|
|
2455
|
+
tmpdir: os.tmpdir,
|
|
2456
|
+
getenv: (key) => process.env[key]
|
|
2457
|
+
};
|
|
2458
|
+
utils = {
|
|
2459
|
+
open: async (url) => {
|
|
2460
|
+
const { default: open } = await import("./index-nzr4mx5p.js");
|
|
2461
|
+
await open(url);
|
|
2462
|
+
}
|
|
2463
|
+
};
|
|
2464
|
+
async readFile(path2, options) {
|
|
2465
|
+
try {
|
|
2466
|
+
if (options) {
|
|
2467
|
+
return await fs.readFile(path2, "utf-8");
|
|
2468
|
+
}
|
|
2469
|
+
return await fs.readFile(path2);
|
|
2470
|
+
} catch (error) {
|
|
2471
|
+
if (this.isEnoent(error))
|
|
2472
|
+
return null;
|
|
2473
|
+
throw error;
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
async writeFile(filePath, data) {
|
|
2477
|
+
const dir = path.dirname(filePath);
|
|
2478
|
+
if (dir) {
|
|
2479
|
+
await fs.mkdir(dir, { recursive: true });
|
|
2480
|
+
}
|
|
2481
|
+
await fs.writeFile(filePath, data);
|
|
2482
|
+
}
|
|
2483
|
+
async appendFile(filePath, data) {
|
|
2484
|
+
const dir = path.dirname(filePath);
|
|
2485
|
+
if (dir) {
|
|
2486
|
+
await fs.mkdir(dir, { recursive: true });
|
|
2487
|
+
}
|
|
2488
|
+
await fs.appendFile(filePath, data);
|
|
2489
|
+
}
|
|
2490
|
+
async readdir(dirPath) {
|
|
2491
|
+
try {
|
|
2492
|
+
return await fs.readdir(dirPath);
|
|
2493
|
+
} catch (error) {
|
|
2494
|
+
if (this.isEnoent(error))
|
|
2495
|
+
return [];
|
|
2496
|
+
throw error;
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
async readdirEntries(dirPath) {
|
|
2500
|
+
try {
|
|
2501
|
+
return await fs.readdir(dirPath, { withFileTypes: true });
|
|
2502
|
+
} catch (error) {
|
|
2503
|
+
if (this.isEnoent(error))
|
|
2504
|
+
return [];
|
|
2505
|
+
throw error;
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
async stat(filePath) {
|
|
2509
|
+
try {
|
|
2510
|
+
const stats = await fs.stat(filePath);
|
|
2511
|
+
return {
|
|
2512
|
+
isFile: () => stats.isFile(),
|
|
2513
|
+
isDirectory: () => stats.isDirectory(),
|
|
2514
|
+
size: stats.size,
|
|
2515
|
+
mtimeMs: stats.mtimeMs,
|
|
2516
|
+
ctimeMs: stats.ctimeMs
|
|
2517
|
+
};
|
|
2518
|
+
} catch (error) {
|
|
2519
|
+
if (this.isEnoent(error))
|
|
2520
|
+
return null;
|
|
2521
|
+
throw error;
|
|
2522
|
+
}
|
|
2512
2523
|
}
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
function redactMessage(value) {
|
|
2516
|
-
let out = collapseJsonBodies(truncate(value, MAX_SCAN_LENGTH)).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`);
|
|
2517
|
-
for (const supplied of getSuppliedArgumentValues()) {
|
|
2518
|
-
out = out.split(supplied).join(REDACTED);
|
|
2524
|
+
async exists(filePath) {
|
|
2525
|
+
return existsSync(filePath);
|
|
2519
2526
|
}
|
|
2520
|
-
|
|
2521
|
-
}
|
|
2522
|
-
var MESSAGE_NAMES = new Set([
|
|
2523
|
-
"message",
|
|
2524
|
-
"errormessage",
|
|
2525
|
-
"errmessage",
|
|
2526
|
-
"error_message",
|
|
2527
|
-
"msg",
|
|
2528
|
-
"detail",
|
|
2529
|
-
"details",
|
|
2530
|
-
"reason",
|
|
2531
|
-
"instructions",
|
|
2532
|
-
"warning"
|
|
2533
|
-
]);
|
|
2534
|
-
function isFreeFormValue(name, value) {
|
|
2535
|
-
return MESSAGE_NAMES.has(name.toLowerCase()) || /['"{[]/.test(value);
|
|
2536
|
-
}
|
|
2537
|
-
function redactError(error) {
|
|
2538
|
-
const safe = new Error(redactMessage(error.message ?? ""));
|
|
2539
|
-
safe.name = error.name;
|
|
2540
|
-
safe.stack = typeof error.stack === "string" ? redactStack(error.stack) : undefined;
|
|
2541
|
-
return safe;
|
|
2542
|
-
}
|
|
2543
|
-
function redactStack(stack) {
|
|
2544
|
-
const bounded = truncate(stack, MAX_STACK_LENGTH);
|
|
2545
|
-
const firstBreak = bounded.indexOf(`
|
|
2546
|
-
`);
|
|
2547
|
-
if (firstBreak === -1) {
|
|
2548
|
-
return redactMessage(bounded);
|
|
2527
|
+
async mkdir(dirPath) {
|
|
2528
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
2549
2529
|
}
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
}
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2530
|
+
async acquireLock(lockPath) {
|
|
2531
|
+
const canonicalPath = await this.canonicalizeLockTarget(lockPath);
|
|
2532
|
+
const lockFile = `${canonicalPath}.lock`;
|
|
2533
|
+
const ownerId = randomUUID();
|
|
2534
|
+
const start = Date.now();
|
|
2535
|
+
while (true) {
|
|
2536
|
+
try {
|
|
2537
|
+
await fs.writeFile(lockFile, ownerId, { flag: "wx" });
|
|
2538
|
+
return this.createLockRelease(lockFile, ownerId);
|
|
2539
|
+
} catch (error) {
|
|
2540
|
+
if (!this.hasErrnoCode(error, "EEXIST")) {
|
|
2541
|
+
throw error;
|
|
2542
|
+
}
|
|
2543
|
+
const stats = await fs.stat(lockFile).catch(() => null);
|
|
2544
|
+
if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
|
|
2545
|
+
const reclaimed = await fs.rm(lockFile, { force: true }).then(() => true).catch(() => false);
|
|
2546
|
+
if (reclaimed)
|
|
2547
|
+
continue;
|
|
2548
|
+
}
|
|
2549
|
+
if (Date.now() - start > LOCK_MAX_WAIT_MS) {
|
|
2550
|
+
throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
|
|
2551
|
+
}
|
|
2552
|
+
await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
|
|
2567
2553
|
}
|
|
2568
2554
|
}
|
|
2569
2555
|
}
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2556
|
+
async canonicalizeLockTarget(lockPath) {
|
|
2557
|
+
const absolute = path.resolve(lockPath);
|
|
2558
|
+
const fullReal = await fs.realpath(absolute).catch(() => null);
|
|
2559
|
+
if (fullReal)
|
|
2560
|
+
return fullReal;
|
|
2561
|
+
const parent = path.dirname(absolute);
|
|
2562
|
+
const base = path.basename(absolute);
|
|
2563
|
+
const canonicalParent = await fs.realpath(parent).catch(() => parent);
|
|
2564
|
+
return path.join(canonicalParent, base);
|
|
2575
2565
|
}
|
|
2576
|
-
|
|
2577
|
-
|
|
2566
|
+
createLockRelease(lockFile, ownerId) {
|
|
2567
|
+
const heartbeatStart = Date.now();
|
|
2568
|
+
let heartbeatTimer;
|
|
2569
|
+
let stopped = false;
|
|
2570
|
+
const stopHeartbeat = () => {
|
|
2571
|
+
stopped = true;
|
|
2572
|
+
if (heartbeatTimer)
|
|
2573
|
+
clearTimeout(heartbeatTimer);
|
|
2574
|
+
};
|
|
2575
|
+
const scheduleNextHeartbeat = () => {
|
|
2576
|
+
if (stopped)
|
|
2577
|
+
return;
|
|
2578
|
+
if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) {
|
|
2579
|
+
stopped = true;
|
|
2580
|
+
return;
|
|
2581
|
+
}
|
|
2582
|
+
heartbeatTimer = setTimeout(() => {
|
|
2583
|
+
runHeartbeat();
|
|
2584
|
+
}, LOCK_HEARTBEAT_MS);
|
|
2585
|
+
heartbeatTimer.unref?.();
|
|
2586
|
+
};
|
|
2587
|
+
const runHeartbeat = async () => {
|
|
2588
|
+
if (stopped)
|
|
2589
|
+
return;
|
|
2590
|
+
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
2591
|
+
if (stopped)
|
|
2592
|
+
return;
|
|
2593
|
+
if (current !== ownerId) {
|
|
2594
|
+
stopped = true;
|
|
2595
|
+
return;
|
|
2596
|
+
}
|
|
2597
|
+
const now = Date.now() / 1000;
|
|
2598
|
+
await fs.utimes(lockFile, now, now).catch(() => {});
|
|
2599
|
+
scheduleNextHeartbeat();
|
|
2600
|
+
};
|
|
2601
|
+
scheduleNextHeartbeat();
|
|
2602
|
+
let released = false;
|
|
2603
|
+
return async () => {
|
|
2604
|
+
if (released)
|
|
2605
|
+
return;
|
|
2606
|
+
released = true;
|
|
2607
|
+
stopHeartbeat();
|
|
2608
|
+
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
2609
|
+
if (current === ownerId) {
|
|
2610
|
+
await fs.rm(lockFile, { force: true });
|
|
2611
|
+
}
|
|
2612
|
+
};
|
|
2578
2613
|
}
|
|
2579
|
-
|
|
2580
|
-
|
|
2614
|
+
async rm(filePath) {
|
|
2615
|
+
await fs.rm(filePath, { recursive: true, force: true });
|
|
2581
2616
|
}
|
|
2582
|
-
|
|
2583
|
-
|
|
2617
|
+
async rename(oldPath, newPath) {
|
|
2618
|
+
await fs.rename(oldPath, newPath);
|
|
2584
2619
|
}
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2620
|
+
async isSymbolicLink(filePath) {
|
|
2621
|
+
try {
|
|
2622
|
+
return (await fs.lstat(filePath)).isSymbolicLink();
|
|
2623
|
+
} catch (error) {
|
|
2624
|
+
if (this.isEnoent(error) || this.hasErrnoCode(error, "ENOTDIR")) {
|
|
2625
|
+
return false;
|
|
2626
|
+
}
|
|
2627
|
+
throw error;
|
|
2593
2628
|
}
|
|
2594
2629
|
}
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2630
|
+
async hashFile(filePath) {
|
|
2631
|
+
let handle;
|
|
2632
|
+
try {
|
|
2633
|
+
handle = await fs.open(filePath, "r");
|
|
2634
|
+
} catch (error) {
|
|
2635
|
+
if (this.isEnoent(error))
|
|
2636
|
+
return null;
|
|
2637
|
+
throw error;
|
|
2638
|
+
}
|
|
2639
|
+
const buffer = hashBuffers.pop() ?? Buffer.allocUnsafe(HASH_CHUNK_BYTES);
|
|
2640
|
+
try {
|
|
2641
|
+
const opened = await handle.stat();
|
|
2642
|
+
const stats = {
|
|
2643
|
+
isFile: () => opened.isFile(),
|
|
2644
|
+
isDirectory: () => opened.isDirectory(),
|
|
2645
|
+
size: opened.size,
|
|
2646
|
+
mtimeMs: opened.mtimeMs,
|
|
2647
|
+
ctimeMs: opened.ctimeMs
|
|
2648
|
+
};
|
|
2649
|
+
const hash = createHash("sha256");
|
|
2650
|
+
let size = 0;
|
|
2651
|
+
for (;; ) {
|
|
2652
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.byteLength, null);
|
|
2653
|
+
if (bytesRead === 0)
|
|
2654
|
+
break;
|
|
2655
|
+
hash.update(buffer.subarray(0, bytesRead));
|
|
2656
|
+
size += bytesRead;
|
|
2657
|
+
}
|
|
2658
|
+
return { sha256: hash.digest("hex"), size, stats };
|
|
2659
|
+
} finally {
|
|
2660
|
+
if (hashBuffers.length < HASH_BUFFERS_KEPT) {
|
|
2661
|
+
hashBuffers.push(buffer);
|
|
2662
|
+
}
|
|
2663
|
+
await handle.close();
|
|
2664
|
+
}
|
|
2611
2665
|
}
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2666
|
+
async realpath(filePath) {
|
|
2667
|
+
try {
|
|
2668
|
+
return await fs.realpath(filePath);
|
|
2669
|
+
} catch (error) {
|
|
2670
|
+
if (this.isEnoent(error))
|
|
2671
|
+
return filePath;
|
|
2672
|
+
throw error;
|
|
2673
|
+
}
|
|
2617
2674
|
}
|
|
2618
|
-
|
|
2619
|
-
return
|
|
2675
|
+
async getTempDir() {
|
|
2676
|
+
return await fs.mkdtemp(path.join(os.tmpdir(), "uipath-fs-"));
|
|
2620
2677
|
}
|
|
2621
|
-
|
|
2622
|
-
const
|
|
2623
|
-
if (
|
|
2624
|
-
|
|
2678
|
+
async copyDirectory(sourcePath, destPath) {
|
|
2679
|
+
const sourceStats = await this.stat(sourcePath);
|
|
2680
|
+
if (!sourceStats) {
|
|
2681
|
+
throw new Error(`Source directory does not exist: ${sourcePath}`);
|
|
2625
2682
|
}
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
}
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2683
|
+
if (!sourceStats.isDirectory()) {
|
|
2684
|
+
throw new Error(`Source path is not a directory: ${sourcePath}`);
|
|
2685
|
+
}
|
|
2686
|
+
await this.mkdir(destPath);
|
|
2687
|
+
const entries = await this.readdir(sourcePath);
|
|
2688
|
+
for (const entry of entries) {
|
|
2689
|
+
const srcEntry = path.join(sourcePath, entry);
|
|
2690
|
+
const destEntry = path.join(destPath, entry);
|
|
2691
|
+
const entryStats = await this.stat(srcEntry);
|
|
2692
|
+
if (!entryStats)
|
|
2693
|
+
continue;
|
|
2694
|
+
if (entryStats.isDirectory()) {
|
|
2695
|
+
await this.copyDirectory(srcEntry, destEntry);
|
|
2696
|
+
} else if (entryStats.isFile()) {
|
|
2697
|
+
const content = await this.readFile(srcEntry);
|
|
2698
|
+
if (content !== null) {
|
|
2699
|
+
await this.writeFile(destEntry, content);
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2643
2702
|
}
|
|
2644
|
-
return [undefined, result];
|
|
2645
|
-
} catch (error) {
|
|
2646
|
-
return [toError(error), undefined];
|
|
2647
2703
|
}
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
// ../common/src/error-graph.ts
|
|
2654
|
-
function* walkErrorGraph(error) {
|
|
2655
|
-
const queue = [error];
|
|
2656
|
-
const seen = new Set;
|
|
2657
|
-
for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
|
|
2658
|
-
const current = queue.shift();
|
|
2659
|
-
if (current === null || typeof current !== "object")
|
|
2660
|
-
continue;
|
|
2661
|
-
if (seen.has(current))
|
|
2662
|
-
continue;
|
|
2663
|
-
seen.add(current);
|
|
2664
|
-
const cur = current;
|
|
2665
|
-
yield cur;
|
|
2666
|
-
if (cur.cause !== undefined)
|
|
2667
|
-
queue.push(cur.cause);
|
|
2668
|
-
if (Array.isArray(cur.errors))
|
|
2669
|
-
queue.push(...cur.errors);
|
|
2704
|
+
isEnoent(error) {
|
|
2705
|
+
return this.hasErrnoCode(error, "ENOENT");
|
|
2706
|
+
}
|
|
2707
|
+
hasErrnoCode(error, code) {
|
|
2708
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
2670
2709
|
}
|
|
2671
|
-
return;
|
|
2672
2710
|
}
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2711
|
+
|
|
2712
|
+
// ../filesystem/src/index.ts
|
|
2713
|
+
var fsInstance = new NodeFileSystem;
|
|
2714
|
+
var getFileSystem = () => fsInstance;
|
|
2715
|
+
|
|
2716
|
+
// ../common/src/telemetry/project-identity.ts
|
|
2717
|
+
function projectKey(id) {
|
|
2718
|
+
if (typeof id !== "string")
|
|
2676
2719
|
return;
|
|
2677
|
-
const
|
|
2678
|
-
return
|
|
2720
|
+
const key = id.trim().toLowerCase().replaceAll("-", "");
|
|
2721
|
+
return /^[0-9a-f]{32}$/.test(key) ? key : undefined;
|
|
2679
2722
|
}
|
|
2680
|
-
function
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2723
|
+
function projectIdentityProperties(identity) {
|
|
2724
|
+
const key = identity.id ? projectKey(identity.id) : undefined;
|
|
2725
|
+
return {
|
|
2726
|
+
[ProjectDimensions.ProjectIdentityStatus]: identity.status === "resolved" && !key ? "invalid" : identity.status,
|
|
2727
|
+
[ProjectDimensions.ProjectType]: identity.projectType,
|
|
2728
|
+
...identity.status === "resolved" && key ? {
|
|
2729
|
+
[ProjectDimensions.ProjectKey]: key
|
|
2730
|
+
} : {}
|
|
2731
|
+
};
|
|
2732
|
+
}
|
|
2733
|
+
var PROJECT_IDENTITY_LOOKUP_BUDGET_MS = 1000;
|
|
2734
|
+
async function withinProjectIdentityBudget(work, onTimeout) {
|
|
2735
|
+
work.catch(() => {
|
|
2736
|
+
return;
|
|
2737
|
+
});
|
|
2738
|
+
let timer;
|
|
2739
|
+
const expired = new Promise((resolve) => {
|
|
2740
|
+
timer = setTimeout(() => {
|
|
2741
|
+
onTimeout?.();
|
|
2742
|
+
resolve(undefined);
|
|
2743
|
+
}, PROJECT_IDENTITY_LOOKUP_BUDGET_MS);
|
|
2744
|
+
});
|
|
2745
|
+
try {
|
|
2746
|
+
return await Promise.race([work, expired]);
|
|
2747
|
+
} finally {
|
|
2748
|
+
clearTimeout(timer);
|
|
2693
2749
|
}
|
|
2694
|
-
return;
|
|
2695
2750
|
}
|
|
2696
2751
|
|
|
2697
|
-
// ../common/src/
|
|
2698
|
-
var
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2752
|
+
// ../common/src/telemetry/pseudonymize.ts
|
|
2753
|
+
var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
|
|
2754
|
+
var PSEUDONYM_HEX_LENGTH = 32;
|
|
2755
|
+
var SHA256_K = new Uint32Array([
|
|
2756
|
+
1116352408,
|
|
2757
|
+
1899447441,
|
|
2758
|
+
3049323471,
|
|
2759
|
+
3921009573,
|
|
2760
|
+
961987163,
|
|
2761
|
+
1508970993,
|
|
2762
|
+
2453635748,
|
|
2763
|
+
2870763221,
|
|
2764
|
+
3624381080,
|
|
2765
|
+
310598401,
|
|
2766
|
+
607225278,
|
|
2767
|
+
1426881987,
|
|
2768
|
+
1925078388,
|
|
2769
|
+
2162078206,
|
|
2770
|
+
2614888103,
|
|
2771
|
+
3248222580,
|
|
2772
|
+
3835390401,
|
|
2773
|
+
4022224774,
|
|
2774
|
+
264347078,
|
|
2775
|
+
604807628,
|
|
2776
|
+
770255983,
|
|
2777
|
+
1249150122,
|
|
2778
|
+
1555081692,
|
|
2779
|
+
1996064986,
|
|
2780
|
+
2554220882,
|
|
2781
|
+
2821834349,
|
|
2782
|
+
2952996808,
|
|
2783
|
+
3210313671,
|
|
2784
|
+
3336571891,
|
|
2785
|
+
3584528711,
|
|
2786
|
+
113926993,
|
|
2787
|
+
338241895,
|
|
2788
|
+
666307205,
|
|
2789
|
+
773529912,
|
|
2790
|
+
1294757372,
|
|
2791
|
+
1396182291,
|
|
2792
|
+
1695183700,
|
|
2793
|
+
1986661051,
|
|
2794
|
+
2177026350,
|
|
2795
|
+
2456956037,
|
|
2796
|
+
2730485921,
|
|
2797
|
+
2820302411,
|
|
2798
|
+
3259730800,
|
|
2799
|
+
3345764771,
|
|
2800
|
+
3516065817,
|
|
2801
|
+
3600352804,
|
|
2802
|
+
4094571909,
|
|
2803
|
+
275423344,
|
|
2804
|
+
430227734,
|
|
2805
|
+
506948616,
|
|
2806
|
+
659060556,
|
|
2807
|
+
883997877,
|
|
2808
|
+
958139571,
|
|
2809
|
+
1322822218,
|
|
2810
|
+
1537002063,
|
|
2811
|
+
1747873779,
|
|
2812
|
+
1955562222,
|
|
2813
|
+
2024104815,
|
|
2814
|
+
2227730452,
|
|
2815
|
+
2361852424,
|
|
2816
|
+
2428436474,
|
|
2817
|
+
2756734187,
|
|
2818
|
+
3204031479,
|
|
2819
|
+
3329325298
|
|
2720
2820
|
]);
|
|
2721
|
-
var
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2821
|
+
var SHA256_INITIAL_STATE = new Uint32Array([
|
|
2822
|
+
1779033703,
|
|
2823
|
+
3144134277,
|
|
2824
|
+
1013904242,
|
|
2825
|
+
2773480762,
|
|
2826
|
+
1359893119,
|
|
2827
|
+
2600822924,
|
|
2828
|
+
528734635,
|
|
2829
|
+
1541459225
|
|
2730
2830
|
]);
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
var LOCAL_PERMISSION_MESSAGE_PATTERN = new RegExp(`\\b(${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})\\b`);
|
|
2734
|
-
function localPermissionInstructions(code, path) {
|
|
2735
|
-
const target = path !== undefined ? `'${path}'` : "a local file or resource";
|
|
2736
|
-
if (code === "EROFS") {
|
|
2737
|
-
return `The filesystem containing ${target} is read-only (EROFS), so the ` + "CLI could not write to it. This is a local environment problem, " + "not a UiPath service error — retrying will not help. Use a " + "writable location, or give this environment write access to the " + "path.";
|
|
2738
|
-
}
|
|
2739
|
-
const onWindows = typeof process !== "undefined" && process.platform === "win32";
|
|
2740
|
-
const remedy = onWindows ? "Re-run from an elevated terminal, close any program holding " + "the file open, or grant your user access to the path." : "Grant this user (or the sandbox the command runs in) access " + "to the path, or run the command outside the sandbox.";
|
|
2741
|
-
return `The operating system denied access to ${target} (${code}). This is ` + "a local permission problem, not a UiPath service error — retrying " + `without a permission change will not help. ${remedy}`;
|
|
2742
|
-
}
|
|
2743
|
-
function carriedInstructions(error) {
|
|
2744
|
-
if (!error || typeof error !== "object")
|
|
2745
|
-
return;
|
|
2746
|
-
const e = error;
|
|
2747
|
-
return typeof e.instructions === "string" ? e.instructions : undefined;
|
|
2831
|
+
function rotr(value, bits) {
|
|
2832
|
+
return (value >>> bits | value << 32 - bits) >>> 0;
|
|
2748
2833
|
}
|
|
2749
|
-
function
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2834
|
+
function sha256Hex(input) {
|
|
2835
|
+
const bytes = new TextEncoder().encode(input);
|
|
2836
|
+
const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
|
|
2837
|
+
const buffer = new Uint8Array(paddedLength);
|
|
2838
|
+
buffer.set(bytes);
|
|
2839
|
+
buffer[bytes.length] = 128;
|
|
2840
|
+
const view = new DataView(buffer.buffer);
|
|
2841
|
+
const bitLength = bytes.length * 8;
|
|
2842
|
+
view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296));
|
|
2843
|
+
view.setUint32(paddedLength - 4, bitLength >>> 0);
|
|
2844
|
+
const state = SHA256_INITIAL_STATE.slice();
|
|
2845
|
+
const schedule = new Uint32Array(64);
|
|
2846
|
+
for (let offset = 0;offset < paddedLength; offset += 64) {
|
|
2847
|
+
for (let i = 0;i < 16; i++) {
|
|
2848
|
+
schedule[i] = view.getUint32(offset + i * 4);
|
|
2760
2849
|
}
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2850
|
+
for (let i = 16;i < 64; i++) {
|
|
2851
|
+
const x = schedule[i - 15];
|
|
2852
|
+
const y = schedule[i - 2];
|
|
2853
|
+
const s0 = (rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3) >>> 0;
|
|
2854
|
+
const s1 = (rotr(y, 17) ^ rotr(y, 19) ^ y >>> 10) >>> 0;
|
|
2855
|
+
schedule[i] = schedule[i - 16] + s0 + schedule[i - 7] + s1 >>> 0;
|
|
2856
|
+
}
|
|
2857
|
+
let a = state[0];
|
|
2858
|
+
let b = state[1];
|
|
2859
|
+
let c = state[2];
|
|
2860
|
+
let d = state[3];
|
|
2861
|
+
let e = state[4];
|
|
2862
|
+
let f = state[5];
|
|
2863
|
+
let g = state[6];
|
|
2864
|
+
let h = state[7];
|
|
2865
|
+
for (let i = 0;i < 64; i++) {
|
|
2866
|
+
const s1 = (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) >>> 0;
|
|
2867
|
+
const ch = (e & f ^ ~e & g) >>> 0;
|
|
2868
|
+
const temp1 = h + s1 + ch + SHA256_K[i] + schedule[i] >>> 0;
|
|
2869
|
+
const s0 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) >>> 0;
|
|
2870
|
+
const maj = (a & b ^ a & c ^ b & c) >>> 0;
|
|
2871
|
+
const temp2 = s0 + maj >>> 0;
|
|
2872
|
+
h = g;
|
|
2873
|
+
g = f;
|
|
2874
|
+
f = e;
|
|
2875
|
+
e = d + temp1 >>> 0;
|
|
2876
|
+
d = c;
|
|
2877
|
+
c = b;
|
|
2878
|
+
b = a;
|
|
2879
|
+
a = temp1 + temp2 >>> 0;
|
|
2768
2880
|
}
|
|
2881
|
+
state[0] = state[0] + a >>> 0;
|
|
2882
|
+
state[1] = state[1] + b >>> 0;
|
|
2883
|
+
state[2] = state[2] + c >>> 0;
|
|
2884
|
+
state[3] = state[3] + d >>> 0;
|
|
2885
|
+
state[4] = state[4] + e >>> 0;
|
|
2886
|
+
state[5] = state[5] + f >>> 0;
|
|
2887
|
+
state[6] = state[6] + g >>> 0;
|
|
2888
|
+
state[7] = state[7] + h >>> 0;
|
|
2769
2889
|
}
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
for (const cur of walkErrorGraph(error)) {
|
|
2774
|
-
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
2775
|
-
const code = matchLocalPermissionCode(cur.code, message);
|
|
2776
|
-
if (!code)
|
|
2777
|
-
continue;
|
|
2778
|
-
const path = localPermissionPath(cur.path, message);
|
|
2779
|
-
return {
|
|
2780
|
-
code,
|
|
2781
|
-
message: message ?? code,
|
|
2782
|
-
...path !== undefined ? { path } : {},
|
|
2783
|
-
instructions: localPermissionInstructions(code, path)
|
|
2784
|
-
};
|
|
2890
|
+
let hex = "";
|
|
2891
|
+
for (const word of state) {
|
|
2892
|
+
hex += word.toString(16).padStart(8, "0");
|
|
2785
2893
|
}
|
|
2786
|
-
return;
|
|
2894
|
+
return hex;
|
|
2787
2895
|
}
|
|
2788
|
-
function
|
|
2789
|
-
|
|
2790
|
-
|
|
2896
|
+
function resolveSha256Hex() {
|
|
2897
|
+
try {
|
|
2898
|
+
const nodeCrypto = __require("node:crypto");
|
|
2899
|
+
const createHash = nodeCrypto?.createHash;
|
|
2900
|
+
if (typeof createHash !== "function") {
|
|
2901
|
+
return sha256Hex;
|
|
2902
|
+
}
|
|
2903
|
+
const native = (input) => createHash("sha256").update(input, "utf8").digest("hex");
|
|
2904
|
+
return native("abc") === sha256Hex("abc") ? native : sha256Hex;
|
|
2905
|
+
} catch {
|
|
2906
|
+
return sha256Hex;
|
|
2791
2907
|
}
|
|
2792
|
-
const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
|
|
2793
|
-
return match ? match[1] : undefined;
|
|
2794
2908
|
}
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
return
|
|
2799
|
-
}
|
|
2800
|
-
function isHtmlDocument(body) {
|
|
2801
|
-
return /^\s*(<!doctype html|<html\b)/i.test(body);
|
|
2802
|
-
}
|
|
2803
|
-
function retryHintForRetryAfter(seconds) {
|
|
2804
|
-
if (seconds <= 1) {
|
|
2805
|
-
return "RetryAfter1Second";
|
|
2806
|
-
}
|
|
2807
|
-
if (seconds <= 10) {
|
|
2808
|
-
return "RetryAfter10Seconds";
|
|
2809
|
-
}
|
|
2810
|
-
if (seconds <= 30) {
|
|
2811
|
-
return "RetryAfter30Seconds";
|
|
2812
|
-
}
|
|
2813
|
-
return "RetryAfter60Seconds";
|
|
2909
|
+
var cachedSha256Hex;
|
|
2910
|
+
function digest(input) {
|
|
2911
|
+
cachedSha256Hex ??= resolveSha256Hex();
|
|
2912
|
+
return cachedSha256Hex(input);
|
|
2814
2913
|
}
|
|
2815
|
-
function
|
|
2816
|
-
|
|
2817
|
-
return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
|
|
2818
|
-
}
|
|
2819
|
-
if (status === 401) {
|
|
2820
|
-
return {
|
|
2821
|
-
errorCode: "authentication_required",
|
|
2822
|
-
retry: "RetryWillNotFix"
|
|
2823
|
-
};
|
|
2824
|
-
}
|
|
2825
|
-
if (status === 403) {
|
|
2826
|
-
return { errorCode: "permission_denied", retry: "RetryWillNotFix" };
|
|
2827
|
-
}
|
|
2828
|
-
if (status === 404) {
|
|
2829
|
-
return { errorCode: "not_found", retry: "RetryWillNotFix" };
|
|
2830
|
-
}
|
|
2831
|
-
if (status === 405) {
|
|
2832
|
-
return { errorCode: "method_not_allowed", retry: "RetryWillNotFix" };
|
|
2833
|
-
}
|
|
2834
|
-
if (status === 413) {
|
|
2835
|
-
return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
|
|
2836
|
-
}
|
|
2837
|
-
if (status === 408) {
|
|
2838
|
-
return { errorCode: "timeout", retry: "RetryLater" };
|
|
2839
|
-
}
|
|
2840
|
-
if (status === 429) {
|
|
2841
|
-
return { errorCode: "rate_limited", retry: "RetryLater" };
|
|
2842
|
-
}
|
|
2843
|
-
if (status !== undefined && status >= 500 && status < 600) {
|
|
2844
|
-
return { errorCode: "server_error", retry: "RetryLater" };
|
|
2845
|
-
}
|
|
2846
|
-
if (status === undefined && describePermissionError(error)) {
|
|
2847
|
-
return {
|
|
2848
|
-
errorCode: "local_permission_denied",
|
|
2849
|
-
retry: "RetryWillNotFix"
|
|
2850
|
-
};
|
|
2851
|
-
}
|
|
2852
|
-
const connectivity = describeConnectivityError(error);
|
|
2853
|
-
if (connectivity) {
|
|
2854
|
-
return {
|
|
2855
|
-
errorCode: "network_error",
|
|
2856
|
-
retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
|
|
2857
|
-
};
|
|
2858
|
-
}
|
|
2859
|
-
return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
|
|
2914
|
+
function pseudonymize(input) {
|
|
2915
|
+
return digest(`${PSEUDONYM_DOMAIN}${input}`).slice(0, PSEUDONYM_HEX_LENGTH);
|
|
2860
2916
|
}
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2917
|
+
|
|
2918
|
+
// ../common/src/telemetry/supplied-values.ts
|
|
2919
|
+
var suppliedValuesSlot = singleton("TelemetrySuppliedArgumentValues");
|
|
2920
|
+
function activeEntries() {
|
|
2921
|
+
const existing = suppliedValuesSlot.get();
|
|
2922
|
+
return Array.isArray(existing) ? existing : [];
|
|
2866
2923
|
}
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
const
|
|
2870
|
-
const
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
|
|
2875
|
-
let rawBody;
|
|
2876
|
-
let extractedMessage;
|
|
2877
|
-
let parsedBody;
|
|
2878
|
-
const textFn = response?.text?.bind(response);
|
|
2879
|
-
if (textFn) {
|
|
2880
|
-
const [bodyError, body] = await catchError((async () => textFn())());
|
|
2881
|
-
if (!bodyError && body) {
|
|
2882
|
-
rawBody = body;
|
|
2883
|
-
const [parseError, parsed] = catchError(() => JSON.parse(body));
|
|
2884
|
-
if (!parseError && parsed && typeof parsed === "object") {
|
|
2885
|
-
parsedBody = parsed;
|
|
2886
|
-
if (parsedBody.errors && typeof parsedBody.errors === "object") {
|
|
2887
|
-
for (const field of Object.values(parsedBody.errors)) {
|
|
2888
|
-
if (Array.isArray(field) && field.length > 0) {
|
|
2889
|
-
const first = field[0];
|
|
2890
|
-
if (first && typeof first.message === "string") {
|
|
2891
|
-
extractedMessage = first.message;
|
|
2892
|
-
break;
|
|
2893
|
-
}
|
|
2894
|
-
}
|
|
2895
|
-
}
|
|
2896
|
-
}
|
|
2897
|
-
if (!extractedMessage) {
|
|
2898
|
-
extractedMessage = typeof parsedBody.message === "string" ? parsedBody.message : typeof parsedBody.errorMessage === "string" ? parsedBody.errorMessage : typeof parsedBody.title === "string" ? parsedBody.title : undefined;
|
|
2899
|
-
}
|
|
2900
|
-
if (!extractedMessage) {
|
|
2901
|
-
extractedMessage = body;
|
|
2902
|
-
}
|
|
2903
|
-
if (extractedMessage && typeof parsedBody.detail === "string" && parsedBody.detail.length > 0 && !extractedMessage.includes(parsedBody.detail)) {
|
|
2904
|
-
extractedMessage = `${extractedMessage}: ${parsedBody.detail}`;
|
|
2905
|
-
}
|
|
2906
|
-
} else {
|
|
2907
|
-
extractedMessage = isHtmlDocument(body) ? HTML_RESPONSE_MESSAGE : body;
|
|
2924
|
+
var MIN_SCRUBBABLE_LENGTH = 4;
|
|
2925
|
+
function recordSuppliedArgumentValues(values) {
|
|
2926
|
+
const flat = [];
|
|
2927
|
+
const push = (value) => {
|
|
2928
|
+
if (Array.isArray(value)) {
|
|
2929
|
+
for (const item of value) {
|
|
2930
|
+
push(item);
|
|
2908
2931
|
}
|
|
2932
|
+
return;
|
|
2909
2933
|
}
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
let result = "Failure";
|
|
2913
|
-
const classificationStatus = status ?? findHttpStatusInGraph(error);
|
|
2914
|
-
const classification = classifyError(classificationStatus, error);
|
|
2915
|
-
let retry = classification.retry;
|
|
2916
|
-
if (status === 401) {
|
|
2917
|
-
message = DEFAULT_401;
|
|
2918
|
-
result = "AuthenticationError";
|
|
2919
|
-
} else if (status === 403) {
|
|
2920
|
-
message = options?.forbiddenMessage ?? DEFAULT_403;
|
|
2921
|
-
result = "AuthenticationError";
|
|
2922
|
-
} else if (status === 405) {
|
|
2923
|
-
message = DEFAULT_405;
|
|
2924
|
-
} else if (status === 413) {
|
|
2925
|
-
message = DEFAULT_413;
|
|
2926
|
-
} else if (status === 400 || status === 422) {
|
|
2927
|
-
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
2928
|
-
result = "ValidationError";
|
|
2929
|
-
} else if (status === 429) {
|
|
2930
|
-
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
2931
|
-
} else if (extractedMessage) {
|
|
2932
|
-
if (isSuccessfulResponse && rawMessage !== "Unknown error") {
|
|
2933
|
-
message = rawMessage;
|
|
2934
|
-
} else {
|
|
2935
|
-
message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
|
|
2936
|
-
}
|
|
2937
|
-
} else if (status) {
|
|
2938
|
-
if (inferredStatus !== undefined) {
|
|
2939
|
-
message = rawMessage;
|
|
2940
|
-
} else if (rawMessage === "Unknown error" && response) {
|
|
2941
|
-
const statusText = response.statusText;
|
|
2942
|
-
message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
|
|
2943
|
-
} else {
|
|
2944
|
-
message = `HTTP ${status}: ${rawMessage}`;
|
|
2945
|
-
}
|
|
2946
|
-
} else {
|
|
2947
|
-
message = rawMessage;
|
|
2948
|
-
}
|
|
2949
|
-
if (status === undefined) {
|
|
2950
|
-
const connectivity = describeConnectivityError(error);
|
|
2951
|
-
if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
|
|
2952
|
-
message = `${message}: ${connectivity.message}`;
|
|
2953
|
-
}
|
|
2954
|
-
}
|
|
2955
|
-
const permission = status === undefined ? describePermissionError(error) : undefined;
|
|
2956
|
-
if (permission) {
|
|
2957
|
-
if (permission.message !== message && !message.includes(permission.message)) {
|
|
2958
|
-
message = `${message}: ${permission.message}`;
|
|
2959
|
-
}
|
|
2960
|
-
if (!message.includes(permission.instructions)) {
|
|
2961
|
-
const punctuated = message.endsWith(".") ? message : `${message}.`;
|
|
2962
|
-
message = `${punctuated} ${permission.instructions}`;
|
|
2934
|
+
if (typeof value === "string" && value.length >= MIN_SCRUBBABLE_LENGTH) {
|
|
2935
|
+
flat.push(value);
|
|
2963
2936
|
}
|
|
2964
|
-
}
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
extra.data = parsedBody.data;
|
|
2979
|
-
}
|
|
2980
|
-
details = Object.keys(extra).length > 0 ? JSON.stringify(extra) : rawBody;
|
|
2981
|
-
} else {
|
|
2982
|
-
details = rawBody;
|
|
2937
|
+
};
|
|
2938
|
+
push(values);
|
|
2939
|
+
const entry = { values: flat };
|
|
2940
|
+
suppliedValuesSlot.set([...activeEntries(), entry]);
|
|
2941
|
+
return entry;
|
|
2942
|
+
}
|
|
2943
|
+
function releaseSuppliedArgumentValues(entry) {
|
|
2944
|
+
suppliedValuesSlot.set(activeEntries().filter((held) => held !== entry));
|
|
2945
|
+
}
|
|
2946
|
+
function getSuppliedArgumentValues() {
|
|
2947
|
+
const all = new Set;
|
|
2948
|
+
for (const entry of activeEntries()) {
|
|
2949
|
+
for (const value of entry.values) {
|
|
2950
|
+
all.add(value);
|
|
2983
2951
|
}
|
|
2984
|
-
} else if (typeof err.message === "string") {
|
|
2985
|
-
details = err.message;
|
|
2986
|
-
} else {
|
|
2987
|
-
details = describeThrownValue(error);
|
|
2988
2952
|
}
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2953
|
+
return [...all].sort((a, b) => b.length - a.length);
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
// ../common/src/telemetry/pii-redactor.ts
|
|
2957
|
+
var REDACTED = "[REDACTED]";
|
|
2958
|
+
var MAX_VALUE_LENGTH = 280;
|
|
2959
|
+
var MAX_STACK_LENGTH = 4096;
|
|
2960
|
+
var MAX_SCAN_LENGTH = MAX_STACK_LENGTH;
|
|
2961
|
+
function truncate(value, maxLength) {
|
|
2962
|
+
return value.length > maxLength ? `${value.slice(0, maxLength)}…` : value;
|
|
2963
|
+
}
|
|
2964
|
+
var SENSITIVE_NAME_TOKENS = new Set([
|
|
2965
|
+
"token",
|
|
2966
|
+
"tokens",
|
|
2967
|
+
"secret",
|
|
2968
|
+
"secrets",
|
|
2969
|
+
"password",
|
|
2970
|
+
"passwords",
|
|
2971
|
+
"pwd",
|
|
2972
|
+
"credential",
|
|
2973
|
+
"credentials",
|
|
2974
|
+
"auth",
|
|
2975
|
+
"authentication",
|
|
2976
|
+
"authorization",
|
|
2977
|
+
"authority",
|
|
2978
|
+
"cert",
|
|
2979
|
+
"certificate",
|
|
2980
|
+
"certificates"
|
|
2981
|
+
]);
|
|
2982
|
+
var SENSITIVE_KEY_PREFIXES = new Set([
|
|
2983
|
+
"api",
|
|
2984
|
+
"access",
|
|
2985
|
+
"client",
|
|
2986
|
+
"private",
|
|
2987
|
+
"public",
|
|
2988
|
+
"signing",
|
|
2989
|
+
"encryption",
|
|
2990
|
+
"session",
|
|
2991
|
+
"master",
|
|
2992
|
+
"shared",
|
|
2993
|
+
"root",
|
|
2994
|
+
"ssh",
|
|
2995
|
+
"rsa",
|
|
2996
|
+
"aes",
|
|
2997
|
+
"hmac",
|
|
2998
|
+
"oauth"
|
|
2999
|
+
]);
|
|
3000
|
+
var UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi;
|
|
3001
|
+
var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
3002
|
+
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
3003
|
+
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
3004
|
+
var PADDED_BASE64_PATTERN = /(?<![A-Za-z0-9+/])[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
|
|
3005
|
+
var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
|
|
3006
|
+
var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
|
|
3007
|
+
var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
|
|
3008
|
+
var HOST_PORT_PATTERN = /(?<![/@.\w-])(?!\d+\.\d+\.\d+\.\d+:)[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)+:\d{1,5}\b/g;
|
|
3009
|
+
var SOURCE_FILE_EXTENSIONS = new Set([
|
|
3010
|
+
"ts",
|
|
3011
|
+
"tsx",
|
|
3012
|
+
"js",
|
|
3013
|
+
"jsx",
|
|
3014
|
+
"mjs",
|
|
3015
|
+
"cjs",
|
|
3016
|
+
"cts",
|
|
3017
|
+
"mts",
|
|
3018
|
+
"py",
|
|
3019
|
+
"cs",
|
|
3020
|
+
"java",
|
|
3021
|
+
"go",
|
|
3022
|
+
"rs",
|
|
3023
|
+
"rb",
|
|
3024
|
+
"php",
|
|
3025
|
+
"sh",
|
|
3026
|
+
"ps1",
|
|
3027
|
+
"json",
|
|
3028
|
+
"jsonc",
|
|
3029
|
+
"yaml",
|
|
3030
|
+
"yml",
|
|
3031
|
+
"xml",
|
|
3032
|
+
"xaml",
|
|
3033
|
+
"md",
|
|
3034
|
+
"txt",
|
|
3035
|
+
"log",
|
|
3036
|
+
"css",
|
|
3037
|
+
"html",
|
|
3038
|
+
"htm",
|
|
3039
|
+
"csproj",
|
|
3040
|
+
"nuspec",
|
|
3041
|
+
"sql"
|
|
3042
|
+
]);
|
|
3043
|
+
var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
|
|
3044
|
+
var QUOTED_LITERAL_MAX_SPAN = 200;
|
|
3045
|
+
var QUOTED_LITERAL_PATTERN = new RegExp([
|
|
3046
|
+
`(?<![A-Za-z0-9])'(?:[^\\
|
|
3047
|
+
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?'(?![A-Za-z0-9])`,
|
|
3048
|
+
`(?<![A-Za-z0-9])"(?:[^\\
|
|
3049
|
+
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
|
|
3050
|
+
].join("|"), "g");
|
|
3051
|
+
var JSON_BODY_PATTERN = /[{[][^{}[\]:,]*[:,][^{}[\]]*[\]}]/g;
|
|
3052
|
+
var COLLAPSED_BODY = "{…}";
|
|
3053
|
+
var COLLAPSED_BODY_MARKER = "\x01body\x01";
|
|
3054
|
+
var MAX_BODY_NESTING = 8;
|
|
3055
|
+
function collapseJsonBodies(text) {
|
|
3056
|
+
let out = text;
|
|
3057
|
+
for (let pass = 0;pass < MAX_BODY_NESTING; pass++) {
|
|
3058
|
+
const next = out.replace(JSON_BODY_PATTERN, COLLAPSED_BODY_MARKER);
|
|
3059
|
+
if (next === out) {
|
|
3060
|
+
break;
|
|
3061
|
+
}
|
|
3062
|
+
out = next;
|
|
2992
3063
|
}
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
3064
|
+
return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
|
|
3065
|
+
}
|
|
3066
|
+
var TRAILING_PROSE_PUNCT = `.,;:!?)]}>'"`;
|
|
3067
|
+
function peelTrailingPunctuation(match) {
|
|
3068
|
+
let end = match.length;
|
|
3069
|
+
while (end > 0 && TRAILING_PROSE_PUNCT.includes(match[end - 1])) {
|
|
3070
|
+
end -= 1;
|
|
2997
3071
|
}
|
|
2998
|
-
|
|
2999
|
-
|
|
3072
|
+
return [match.slice(0, end), match.slice(end)];
|
|
3073
|
+
}
|
|
3074
|
+
function redactUrl(raw) {
|
|
3075
|
+
try {
|
|
3076
|
+
const url = new URL(raw);
|
|
3077
|
+
return `${url.protocol}//${url.host}`;
|
|
3078
|
+
} catch {
|
|
3079
|
+
return `url#${pseudonymize(raw)}`;
|
|
3000
3080
|
}
|
|
3001
|
-
|
|
3002
|
-
|
|
3081
|
+
}
|
|
3082
|
+
function redactValueDetectors(value, maxLength = MAX_VALUE_LENGTH) {
|
|
3083
|
+
let out = truncate(value, MAX_SCAN_LENGTH);
|
|
3084
|
+
out = out.replace(JWT_PATTERN, () => REDACTED);
|
|
3085
|
+
out = out.replace(URL_PATTERN, (match) => {
|
|
3086
|
+
const [core, trailing] = peelTrailingPunctuation(match);
|
|
3087
|
+
return `${redactUrl(core)}${trailing}`;
|
|
3088
|
+
});
|
|
3089
|
+
out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
|
|
3090
|
+
out = out.replace(UNC_PATH_PATTERN, (_match, before, path) => {
|
|
3091
|
+
const [core, trailing] = peelTrailingPunctuation(path);
|
|
3092
|
+
return `${before}unc#${pseudonymize(core)}${trailing}`;
|
|
3093
|
+
});
|
|
3094
|
+
out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
|
|
3095
|
+
out = out.replace(UUID_PATTERN, (match) => `uuid#${pseudonymize(match)}`);
|
|
3096
|
+
out = out.replace(HOST_PORT_PATTERN, (match) => {
|
|
3097
|
+
const split = match.lastIndexOf(":");
|
|
3098
|
+
const host = match.slice(0, split);
|
|
3099
|
+
const extension = host.slice(host.lastIndexOf(".") + 1).toLowerCase();
|
|
3100
|
+
if (SOURCE_FILE_EXTENSIONS.has(extension)) {
|
|
3101
|
+
return match;
|
|
3102
|
+
}
|
|
3103
|
+
return `host#${pseudonymize(host)}:${match.slice(split + 1)}`;
|
|
3104
|
+
});
|
|
3105
|
+
out = out.replace(PADDED_BASE64_PATTERN, () => REDACTED);
|
|
3106
|
+
out = out.replace(BASE64_WITH_PLUS_PATTERN, (match) => match.includes("+") ? REDACTED : match);
|
|
3107
|
+
out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
|
|
3108
|
+
return truncate(out, maxLength);
|
|
3109
|
+
}
|
|
3110
|
+
function redactSpanName(name) {
|
|
3111
|
+
return redactValueDetectors(truncate(name, MAX_SCAN_LENGTH).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`));
|
|
3112
|
+
}
|
|
3113
|
+
var HTTP_DEPENDENCY_NAME = /^([A-Z]+) (\/.*)$/s;
|
|
3114
|
+
function redactHttpDependencyName(name) {
|
|
3115
|
+
const parts = HTTP_DEPENDENCY_NAME.exec(name);
|
|
3116
|
+
if (!parts) {
|
|
3117
|
+
return redactMessage(name);
|
|
3003
3118
|
}
|
|
3004
|
-
|
|
3005
|
-
|
|
3119
|
+
return `${parts[1]} ${redactMessage(parts[2])}`;
|
|
3120
|
+
}
|
|
3121
|
+
function redactMessage(value) {
|
|
3122
|
+
let out = collapseJsonBodies(truncate(value, MAX_SCAN_LENGTH)).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`);
|
|
3123
|
+
for (const supplied of getSuppliedArgumentValues()) {
|
|
3124
|
+
out = out.split(supplied).join(REDACTED);
|
|
3006
3125
|
}
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3126
|
+
return redactValueDetectors(out);
|
|
3127
|
+
}
|
|
3128
|
+
var MESSAGE_NAMES = new Set([
|
|
3129
|
+
"message",
|
|
3130
|
+
"errormessage",
|
|
3131
|
+
"errmessage",
|
|
3132
|
+
"error_message",
|
|
3133
|
+
"msg",
|
|
3134
|
+
"detail",
|
|
3135
|
+
"details",
|
|
3136
|
+
"reason",
|
|
3137
|
+
"instructions",
|
|
3138
|
+
"warning"
|
|
3139
|
+
]);
|
|
3140
|
+
function isFreeFormValue(name, value) {
|
|
3141
|
+
return MESSAGE_NAMES.has(name.toLowerCase()) || /['"{[]/.test(value);
|
|
3142
|
+
}
|
|
3143
|
+
function redactError(error) {
|
|
3144
|
+
const safe = new Error(redactMessage(error.message ?? ""));
|
|
3145
|
+
safe.name = error.name;
|
|
3146
|
+
safe.stack = typeof error.stack === "string" ? redactStack(error.stack) : undefined;
|
|
3147
|
+
return safe;
|
|
3148
|
+
}
|
|
3149
|
+
function redactStack(stack) {
|
|
3150
|
+
const bounded = truncate(stack, MAX_STACK_LENGTH);
|
|
3151
|
+
const firstBreak = bounded.indexOf(`
|
|
3152
|
+
`);
|
|
3153
|
+
if (firstBreak === -1) {
|
|
3154
|
+
return redactMessage(bounded);
|
|
3025
3155
|
}
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
errors[field] = [raw];
|
|
3156
|
+
return `${redactMessage(bounded.slice(0, firstBreak))}
|
|
3157
|
+
${redactValueDetectors(bounded.slice(firstBreak + 1), MAX_STACK_LENGTH)}`;
|
|
3158
|
+
}
|
|
3159
|
+
function nameTokens(name) {
|
|
3160
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(/[\s._-]+/).map((t) => t.toLowerCase()).filter(Boolean);
|
|
3161
|
+
}
|
|
3162
|
+
function isSensitiveName(name) {
|
|
3163
|
+
const tokens = nameTokens(name);
|
|
3164
|
+
for (let i = 0;i < tokens.length; i++) {
|
|
3165
|
+
const token = tokens[i];
|
|
3166
|
+
if (SENSITIVE_NAME_TOKENS.has(token)) {
|
|
3167
|
+
return true;
|
|
3168
|
+
}
|
|
3169
|
+
if (token === "key" || token === "keys") {
|
|
3170
|
+
const prev = tokens[i - 1];
|
|
3171
|
+
if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
|
|
3172
|
+
return true;
|
|
3044
3173
|
}
|
|
3045
3174
|
}
|
|
3046
|
-
if (Object.keys(errors).length > 0)
|
|
3047
|
-
parsedErrors = errors;
|
|
3048
3175
|
}
|
|
3049
|
-
return
|
|
3050
|
-
result,
|
|
3051
|
-
errorCode: classification.errorCode,
|
|
3052
|
-
message,
|
|
3053
|
-
retry,
|
|
3054
|
-
details,
|
|
3055
|
-
...hasContext ? { context } : {},
|
|
3056
|
-
...parsedErrors ? { parsedErrors } : {}
|
|
3057
|
-
};
|
|
3176
|
+
return false;
|
|
3058
3177
|
}
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3178
|
+
function redactProperty(name, value) {
|
|
3179
|
+
if (value === undefined || value === null) {
|
|
3180
|
+
return;
|
|
3181
|
+
}
|
|
3182
|
+
if (isSensitiveName(name)) {
|
|
3183
|
+
return REDACTED;
|
|
3184
|
+
}
|
|
3185
|
+
if (GUID_KEY_DIMENSIONS.has(name))
|
|
3186
|
+
return projectKey(value);
|
|
3187
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
3188
|
+
return value;
|
|
3189
|
+
}
|
|
3190
|
+
if (typeof value !== "string") {
|
|
3191
|
+
return "[OBJECT]";
|
|
3192
|
+
}
|
|
3193
|
+
return isFreeFormValue(name, value) ? redactMessage(value) : redactValueDetectors(value);
|
|
3062
3194
|
}
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
jpeg: "image/jpeg",
|
|
3071
|
-
gif: "image/gif",
|
|
3072
|
-
webp: "image/webp",
|
|
3073
|
-
bmp: "image/bmp",
|
|
3074
|
-
tif: "image/tiff",
|
|
3075
|
-
tiff: "image/tiff",
|
|
3076
|
-
svg: "image/svg+xml",
|
|
3077
|
-
txt: "text/plain",
|
|
3078
|
-
log: "text/plain",
|
|
3079
|
-
md: "text/markdown",
|
|
3080
|
-
csv: "text/csv",
|
|
3081
|
-
tsv: "text/tab-separated-values",
|
|
3082
|
-
json: "application/json",
|
|
3083
|
-
xml: "application/xml",
|
|
3084
|
-
html: "text/html",
|
|
3085
|
-
htm: "text/html",
|
|
3086
|
-
yaml: "application/yaml",
|
|
3087
|
-
yml: "application/yaml",
|
|
3088
|
-
doc: "application/msword",
|
|
3089
|
-
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
3090
|
-
xls: "application/vnd.ms-excel",
|
|
3091
|
-
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
3092
|
-
ppt: "application/vnd.ms-powerpoint",
|
|
3093
|
-
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
3094
|
-
zip: "application/zip",
|
|
3095
|
-
mp3: "audio/mpeg",
|
|
3096
|
-
wav: "audio/wav",
|
|
3097
|
-
mp4: "video/mp4"
|
|
3098
|
-
});
|
|
3099
|
-
function mimeTypeForFileName(fileName) {
|
|
3100
|
-
const dot = fileName.lastIndexOf(".");
|
|
3101
|
-
if (dot < 0 || dot === fileName.length - 1) {
|
|
3102
|
-
return OCTET_STREAM;
|
|
3195
|
+
function redactProperties(properties) {
|
|
3196
|
+
const out = {};
|
|
3197
|
+
for (const [name, value] of Object.entries(properties)) {
|
|
3198
|
+
const redacted = redactProperty(name, value);
|
|
3199
|
+
if (redacted !== undefined) {
|
|
3200
|
+
out[name] = redacted;
|
|
3201
|
+
}
|
|
3103
3202
|
}
|
|
3104
|
-
|
|
3105
|
-
return Object.hasOwn(MIME_TYPES_BY_EXTENSION, extension) ? MIME_TYPES_BY_EXTENSION[extension] : OCTET_STREAM;
|
|
3203
|
+
return out;
|
|
3106
3204
|
}
|
|
3107
3205
|
|
|
3108
|
-
// ../common/src/
|
|
3109
|
-
var
|
|
3110
|
-
|
|
3111
|
-
|
|
3206
|
+
// ../common/src/catch-error.ts
|
|
3207
|
+
var MAX_SERIALIZED_LENGTH = 500;
|
|
3208
|
+
var TRUNCATION_SUFFIX = "…(truncated)";
|
|
3209
|
+
var REDACTED2 = "[REDACTED]";
|
|
3210
|
+
function cap(text) {
|
|
3211
|
+
return text.length > MAX_SERIALIZED_LENGTH ? `${text.slice(0, MAX_SERIALIZED_LENGTH)}${TRUNCATION_SUFFIX}` : text;
|
|
3112
3212
|
}
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
CloudUserId: "CloudUserId",
|
|
3120
|
-
CloudTenantId: "CloudTenantId",
|
|
3121
|
-
CloudOrganizationId: "CloudOrganizationId",
|
|
3122
|
-
IsInternalUser: "IsInternalUser",
|
|
3123
|
-
Environment: "Environment",
|
|
3124
|
-
BaseUrl: "BaseUrl",
|
|
3125
|
-
Region: "Region",
|
|
3126
|
-
Agent: "Agent",
|
|
3127
|
-
AgentVersion: "AgentVersion",
|
|
3128
|
-
AgentModel: "AgentModel",
|
|
3129
|
-
ToolName: "ToolName",
|
|
3130
|
-
ToolVersion: "ToolVersion",
|
|
3131
|
-
ExecutionContext: "ExecutionContext",
|
|
3132
|
-
CiProvider: "CiProvider",
|
|
3133
|
-
SessionIdSource: "SessionIdSource",
|
|
3134
|
-
SessionId: "SessionId"
|
|
3135
|
-
};
|
|
3136
|
-
var CommandDimensions = {
|
|
3137
|
-
IsCommand: "IsCommand",
|
|
3138
|
-
IsReexec: "IsReexec",
|
|
3139
|
-
CommandName: "CommandName",
|
|
3140
|
-
ExitCode: "ExitCode",
|
|
3141
|
-
TerminalOutcome: "TerminalOutcome",
|
|
3142
|
-
ErrorClass: "ErrorClass",
|
|
3143
|
-
TerminalSignal: "TerminalSignal",
|
|
3144
|
-
ErrorMessage: "ErrorMessage",
|
|
3145
|
-
SkillName: "SkillName",
|
|
3146
|
-
ProductArea: "ProductArea",
|
|
3147
|
-
Mode: "Mode"
|
|
3148
|
-
};
|
|
3149
|
-
var ShipDimensions = {
|
|
3150
|
-
ShipKind: "ShipKind",
|
|
3151
|
-
Target: "Target",
|
|
3152
|
-
ProjectType: "ProjectType",
|
|
3153
|
-
ProjectTypes: "ProjectTypes",
|
|
3154
|
-
ArtifactCorrelationKey: "ArtifactCorrelationKey",
|
|
3155
|
-
PackageName: "PackageName",
|
|
3156
|
-
PackageVersion: "PackageVersion",
|
|
3157
|
-
PackageVersionKey: "PackageVersionKey",
|
|
3158
|
-
DeploymentKey: "DeploymentKey",
|
|
3159
|
-
SolutionId: "SolutionId",
|
|
3160
|
-
FolderKey: "FolderKey",
|
|
3161
|
-
FeedId: "FeedId"
|
|
3162
|
-
};
|
|
3163
|
-
var ErrorDimensions = {
|
|
3164
|
-
Result: "Result",
|
|
3165
|
-
ErrorCode: "ErrorCode",
|
|
3166
|
-
Retry: "Retry",
|
|
3167
|
-
ErrorMessage: "ErrorMessage",
|
|
3168
|
-
HttpStatus: "HttpStatus",
|
|
3169
|
-
UpstreamErrorCode: "UpstreamErrorCode"
|
|
3170
|
-
};
|
|
3171
|
-
var AuthDimensions = {
|
|
3172
|
-
AuthenticationMethod: "AuthenticationMethod",
|
|
3173
|
-
Success: "Success",
|
|
3174
|
-
Reason: "Reason"
|
|
3175
|
-
};
|
|
3176
|
-
var SkillsDimensions = {
|
|
3177
|
-
SchemaVersion: "SchemaVersion",
|
|
3178
|
-
AgentType: "AgentType",
|
|
3179
|
-
SkillsVersion: "SkillsVersion",
|
|
3180
|
-
UipSubcommand: "UipSubcommand",
|
|
3181
|
-
FileExtension: "FileExtension",
|
|
3182
|
-
SubagentModel: "SubagentModel",
|
|
3183
|
-
SubagentType: "SubagentType",
|
|
3184
|
-
PermissionMode: "PermissionMode",
|
|
3185
|
-
EffortLevel: "EffortLevel",
|
|
3186
|
-
SessionSource: "SessionSource",
|
|
3187
|
-
Outcome: "Outcome",
|
|
3188
|
-
DurationMs: "DurationMs",
|
|
3189
|
-
Source: "Source"
|
|
3190
|
-
};
|
|
3191
|
-
var PackagerDimensions = {
|
|
3192
|
-
ProjectId: "ProjectId",
|
|
3193
|
-
ProjectType: "ProjectType",
|
|
3194
|
-
SolutionId: "SolutionId"
|
|
3195
|
-
};
|
|
3196
|
-
var ScopeDimensions = {
|
|
3197
|
-
FolderId: "FolderId"
|
|
3198
|
-
};
|
|
3199
|
-
var ID_DIMENSIONS = new Set([
|
|
3200
|
-
BaseDimensions.CloudUserId,
|
|
3201
|
-
BaseDimensions.CloudTenantId,
|
|
3202
|
-
BaseDimensions.CloudOrganizationId,
|
|
3203
|
-
BaseDimensions.InstallationId,
|
|
3204
|
-
ShipDimensions.ArtifactCorrelationKey,
|
|
3205
|
-
ShipDimensions.PackageVersionKey,
|
|
3206
|
-
ShipDimensions.DeploymentKey,
|
|
3207
|
-
ShipDimensions.SolutionId,
|
|
3208
|
-
ShipDimensions.FolderKey,
|
|
3209
|
-
ShipDimensions.FeedId,
|
|
3210
|
-
PackagerDimensions.ProjectId
|
|
3211
|
-
]);
|
|
3212
|
-
var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
|
|
3213
|
-
var RESERVED_DIMENSION_NAMES = new Set([
|
|
3214
|
-
...Object.values(BaseDimensions),
|
|
3215
|
-
...Object.values(CommandDimensions),
|
|
3216
|
-
...Object.values(ShipDimensions),
|
|
3217
|
-
...Object.values(ErrorDimensions),
|
|
3218
|
-
...Object.values(AuthDimensions),
|
|
3219
|
-
...Object.values(SkillsDimensions),
|
|
3220
|
-
...Object.values(PackagerDimensions),
|
|
3221
|
-
...Object.values(ScopeDimensions)
|
|
3222
|
-
]);
|
|
3223
|
-
var CURATED_DIMENSIONS = new Set([
|
|
3224
|
-
BaseDimensions.ApplicationName,
|
|
3225
|
-
BaseDimensions.ProductVersion,
|
|
3226
|
-
BaseDimensions.InstallationId,
|
|
3227
|
-
BaseDimensions.CloudUserId,
|
|
3228
|
-
BaseDimensions.CloudTenantId,
|
|
3229
|
-
BaseDimensions.CloudOrganizationId,
|
|
3230
|
-
BaseDimensions.IsInternalUser,
|
|
3231
|
-
BaseDimensions.Environment,
|
|
3232
|
-
BaseDimensions.BaseUrl,
|
|
3233
|
-
BaseDimensions.Region,
|
|
3234
|
-
BaseDimensions.Agent,
|
|
3235
|
-
BaseDimensions.AgentVersion,
|
|
3236
|
-
BaseDimensions.ToolVersion,
|
|
3237
|
-
BaseDimensions.ExecutionContext,
|
|
3238
|
-
BaseDimensions.CiProvider,
|
|
3239
|
-
BaseDimensions.SessionIdSource,
|
|
3240
|
-
BaseDimensions.SessionId,
|
|
3241
|
-
...Object.values(CommandDimensions),
|
|
3242
|
-
...Object.values(ShipDimensions)
|
|
3243
|
-
]);
|
|
3244
|
-
function lowercaseIdDimensionValues(properties) {
|
|
3245
|
-
let changed = false;
|
|
3246
|
-
const result = {
|
|
3247
|
-
...properties
|
|
3248
|
-
};
|
|
3249
|
-
for (const key of Object.keys(result)) {
|
|
3250
|
-
const value = result[key];
|
|
3251
|
-
if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
|
|
3252
|
-
continue;
|
|
3253
|
-
}
|
|
3254
|
-
const lowered = value.toLowerCase();
|
|
3255
|
-
if (lowered !== value) {
|
|
3256
|
-
result[key] = lowered;
|
|
3257
|
-
changed = true;
|
|
3258
|
-
}
|
|
3213
|
+
function omitSensitive(key, value) {
|
|
3214
|
+
return key.length > 0 && isSensitiveName(key) ? REDACTED2 : value;
|
|
3215
|
+
}
|
|
3216
|
+
function describeThrownValue(value) {
|
|
3217
|
+
if (typeof value !== "object" || value === null) {
|
|
3218
|
+
return String(value);
|
|
3259
3219
|
}
|
|
3260
|
-
|
|
3220
|
+
let message;
|
|
3221
|
+
try {
|
|
3222
|
+
message = value.message;
|
|
3223
|
+
} catch {
|
|
3224
|
+
message = undefined;
|
|
3225
|
+
}
|
|
3226
|
+
if (typeof message === "string" && message.length > 0) {
|
|
3227
|
+
return cap(message);
|
|
3228
|
+
}
|
|
3229
|
+
try {
|
|
3230
|
+
const json = JSON.stringify(value, omitSensitive);
|
|
3231
|
+
if (json !== undefined) {
|
|
3232
|
+
return cap(json);
|
|
3233
|
+
}
|
|
3234
|
+
} catch {}
|
|
3235
|
+
return String(value);
|
|
3261
3236
|
}
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
var USER_AGENT_HEADER = "User-Agent";
|
|
3265
|
-
var AGENT_PROPERTY = BaseDimensions.Agent;
|
|
3266
|
-
var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
|
|
3267
|
-
function userAgentPatchKey(userAgent) {
|
|
3268
|
-
return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
|
|
3237
|
+
function toError(error) {
|
|
3238
|
+
return error instanceof Error ? error : new Error(describeThrownValue(error), { cause: error });
|
|
3269
3239
|
}
|
|
3270
|
-
function
|
|
3271
|
-
return value
|
|
3240
|
+
function isPromiseLike(value) {
|
|
3241
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
3272
3242
|
}
|
|
3273
|
-
function
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3243
|
+
function catchError(fnOrPromise) {
|
|
3244
|
+
if (isPromiseLike(fnOrPromise)) {
|
|
3245
|
+
return settlePromiseLike(fnOrPromise);
|
|
3246
|
+
}
|
|
3247
|
+
try {
|
|
3248
|
+
const result = fnOrPromise();
|
|
3249
|
+
if (isPromiseLike(result)) {
|
|
3250
|
+
return settlePromiseLike(result);
|
|
3280
3251
|
}
|
|
3252
|
+
return [undefined, result];
|
|
3253
|
+
} catch (error) {
|
|
3254
|
+
return [toError(error), undefined];
|
|
3281
3255
|
}
|
|
3282
|
-
return tokens.join(" ");
|
|
3283
|
-
}
|
|
3284
|
-
function getEffectiveUserAgent(userAgent) {
|
|
3285
|
-
return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
|
|
3286
3256
|
}
|
|
3287
|
-
function
|
|
3288
|
-
return
|
|
3289
|
-
}
|
|
3290
|
-
function getSdkUserAgentToken(pkg) {
|
|
3291
|
-
const packageName = pkg.name.replace(/^@uipath\//, "");
|
|
3292
|
-
return getEffectiveUserAgent(`${packageName}/${pkg.version}`);
|
|
3257
|
+
function settlePromiseLike(thenable) {
|
|
3258
|
+
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
|
|
3293
3259
|
}
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3260
|
+
|
|
3261
|
+
// ../common/src/error-codes.ts
|
|
3262
|
+
var CLI_ERROR_CODES = [
|
|
3263
|
+
"invalid_argument",
|
|
3264
|
+
"authentication_required",
|
|
3265
|
+
"permission_denied",
|
|
3266
|
+
"local_permission_denied",
|
|
3267
|
+
"not_found",
|
|
3268
|
+
"rate_limited",
|
|
3269
|
+
"network_error",
|
|
3270
|
+
"timeout",
|
|
3271
|
+
"server_error",
|
|
3272
|
+
"method_not_allowed",
|
|
3273
|
+
"not_supported",
|
|
3274
|
+
"configuration_error",
|
|
3275
|
+
"execution_failed",
|
|
3276
|
+
"unknown_error"
|
|
3277
|
+
];
|
|
3278
|
+
var RETRY_HINTS = [
|
|
3279
|
+
"RetryWillNotFix",
|
|
3280
|
+
"RetryLater",
|
|
3281
|
+
"RetryAfter1Second",
|
|
3282
|
+
"RetryAfter10Seconds",
|
|
3283
|
+
"RetryAfter30Seconds",
|
|
3284
|
+
"RetryAfter60Seconds"
|
|
3285
|
+
];
|
|
3286
|
+
var CLI_ERROR_CODE_VALUES = new Set(CLI_ERROR_CODES);
|
|
3287
|
+
var RETRY_HINT_VALUES = new Set(RETRY_HINTS);
|
|
3288
|
+
function isCliErrorCode(value) {
|
|
3289
|
+
return typeof value === "string" && CLI_ERROR_CODE_VALUES.has(value);
|
|
3299
3290
|
}
|
|
3300
|
-
function
|
|
3301
|
-
return typeof
|
|
3291
|
+
function isRetryHint(value) {
|
|
3292
|
+
return typeof value === "string" && RETRY_HINT_VALUES.has(value);
|
|
3302
3293
|
}
|
|
3303
|
-
function
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
};
|
|
3309
|
-
const override = typeof initOverrides === "function" ? await initOverrides({
|
|
3310
|
-
...requestContext,
|
|
3311
|
-
init: initWithHeaders
|
|
3312
|
-
}) : initOverrides;
|
|
3313
|
-
return {
|
|
3314
|
-
...override ?? {},
|
|
3315
|
-
headers: forward(asHeaderRecord(override?.headers ?? initWithHeaders.headers))
|
|
3316
|
-
};
|
|
3317
|
-
};
|
|
3294
|
+
function carriedErrorCode(error) {
|
|
3295
|
+
if (!error || typeof error !== "object")
|
|
3296
|
+
return;
|
|
3297
|
+
const code = error.errorCode;
|
|
3298
|
+
return isCliErrorCode(code) ? code : undefined;
|
|
3318
3299
|
}
|
|
3319
|
-
function
|
|
3320
|
-
|
|
3321
|
-
if (prototype[patchKey]) {
|
|
3300
|
+
function carriedRetry(error) {
|
|
3301
|
+
if (!error || typeof error !== "object")
|
|
3322
3302
|
return;
|
|
3303
|
+
const retry = error.retry;
|
|
3304
|
+
return isRetryHint(retry) ? retry : undefined;
|
|
3305
|
+
}
|
|
3306
|
+
function defaultRetryForErrorCode(errorCode) {
|
|
3307
|
+
switch (errorCode) {
|
|
3308
|
+
case "network_error":
|
|
3309
|
+
case "rate_limited":
|
|
3310
|
+
case "server_error":
|
|
3311
|
+
case "timeout":
|
|
3312
|
+
return "RetryLater";
|
|
3313
|
+
default:
|
|
3314
|
+
return "RetryWillNotFix";
|
|
3323
3315
|
}
|
|
3324
|
-
|
|
3325
|
-
|
|
3316
|
+
}
|
|
3317
|
+
|
|
3318
|
+
// ../common/src/error-graph.ts
|
|
3319
|
+
function* walkErrorGraph(error) {
|
|
3320
|
+
const queue = [error];
|
|
3321
|
+
const seen = new Set;
|
|
3322
|
+
for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
|
|
3323
|
+
const current = queue.shift();
|
|
3324
|
+
if (current === null || typeof current !== "object")
|
|
3325
|
+
continue;
|
|
3326
|
+
if (seen.has(current))
|
|
3327
|
+
continue;
|
|
3328
|
+
seen.add(current);
|
|
3329
|
+
const cur = current;
|
|
3330
|
+
yield cur;
|
|
3331
|
+
if (cur.cause !== undefined)
|
|
3332
|
+
queue.push(cur.cause);
|
|
3333
|
+
if (Array.isArray(cur.errors))
|
|
3334
|
+
queue.push(...cur.errors);
|
|
3326
3335
|
}
|
|
3327
|
-
|
|
3328
|
-
prototype.request = function requestWithForwardedHeaders(context, initOverrides) {
|
|
3329
|
-
return originalRequest.call(this, context, withForwardedHeadersInitOverride(initOverrides, forward));
|
|
3330
|
-
};
|
|
3331
|
-
Object.defineProperty(prototype, patchKey, {
|
|
3332
|
-
value: true
|
|
3333
|
-
});
|
|
3336
|
+
return;
|
|
3334
3337
|
}
|
|
3335
|
-
function
|
|
3336
|
-
|
|
3338
|
+
function parseHttpStatusFromMessage(message) {
|
|
3339
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
3340
|
+
if (!match)
|
|
3341
|
+
return;
|
|
3342
|
+
const status = Number(match[1]);
|
|
3343
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
3337
3344
|
}
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
import * as path from "node:path";
|
|
3345
|
-
var LOCK_HEARTBEAT_MS = 5000;
|
|
3346
|
-
var LOCK_STALE_MS = 15000;
|
|
3347
|
-
var LOCK_MAX_WAIT_MS = 20000;
|
|
3348
|
-
var LOCK_MAX_HOLD_MS = 60000;
|
|
3349
|
-
var LOCK_RETRY_MIN_MS = 100;
|
|
3350
|
-
var LOCK_RETRY_JITTER_MS = 200;
|
|
3351
|
-
|
|
3352
|
-
class NodeFileSystem {
|
|
3353
|
-
path = {
|
|
3354
|
-
join: path.join,
|
|
3355
|
-
resolve: path.resolve,
|
|
3356
|
-
relative: path.relative,
|
|
3357
|
-
dirname: path.dirname,
|
|
3358
|
-
isAbsolute: path.isAbsolute,
|
|
3359
|
-
basename: path.basename
|
|
3360
|
-
};
|
|
3361
|
-
env = {
|
|
3362
|
-
cwd: process.cwd,
|
|
3363
|
-
homedir: os.homedir,
|
|
3364
|
-
tmpdir: os.tmpdir,
|
|
3365
|
-
getenv: (key) => process.env[key]
|
|
3366
|
-
};
|
|
3367
|
-
utils = {
|
|
3368
|
-
open: async (url) => {
|
|
3369
|
-
const { default: open } = await import("./index-sby22td6.js");
|
|
3370
|
-
await open(url);
|
|
3345
|
+
function findHttpStatusInGraph(error) {
|
|
3346
|
+
for (const node of walkErrorGraph(error)) {
|
|
3347
|
+
const response = node.response;
|
|
3348
|
+
const explicit = typeof node.status === "number" ? node.status : response?.status;
|
|
3349
|
+
if (typeof explicit === "number" && explicit >= 400 && explicit <= 599) {
|
|
3350
|
+
return explicit;
|
|
3371
3351
|
}
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
return await fs.readFile(path2, "utf-8");
|
|
3352
|
+
if (typeof node.message === "string") {
|
|
3353
|
+
const parsed = parseHttpStatusFromMessage(node.message);
|
|
3354
|
+
if (parsed !== undefined && parsed >= 400) {
|
|
3355
|
+
return parsed;
|
|
3377
3356
|
}
|
|
3378
|
-
return await fs.readFile(path2);
|
|
3379
|
-
} catch (error) {
|
|
3380
|
-
if (this.isEnoent(error))
|
|
3381
|
-
return null;
|
|
3382
|
-
throw error;
|
|
3383
3357
|
}
|
|
3384
3358
|
}
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3359
|
+
return;
|
|
3360
|
+
}
|
|
3361
|
+
|
|
3362
|
+
// ../common/src/http-status.ts
|
|
3363
|
+
function classifyHttpStatus(status) {
|
|
3364
|
+
if (status === undefined)
|
|
3365
|
+
return;
|
|
3366
|
+
if (status === 400 || status === 409 || status === 413 || status === 422) {
|
|
3367
|
+
return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
|
|
3391
3368
|
}
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
}
|
|
3397
|
-
|
|
3369
|
+
if (status === 401) {
|
|
3370
|
+
return {
|
|
3371
|
+
errorCode: "authentication_required",
|
|
3372
|
+
retry: "RetryWillNotFix"
|
|
3373
|
+
};
|
|
3374
|
+
}
|
|
3375
|
+
if (status === 403) {
|
|
3376
|
+
return { errorCode: "permission_denied", retry: "RetryWillNotFix" };
|
|
3377
|
+
}
|
|
3378
|
+
if (status === 404) {
|
|
3379
|
+
return { errorCode: "not_found", retry: "RetryWillNotFix" };
|
|
3380
|
+
}
|
|
3381
|
+
if (status === 405) {
|
|
3382
|
+
return { errorCode: "method_not_allowed", retry: "RetryWillNotFix" };
|
|
3383
|
+
}
|
|
3384
|
+
if (status === 408) {
|
|
3385
|
+
return { errorCode: "timeout", retry: "RetryLater" };
|
|
3386
|
+
}
|
|
3387
|
+
if (status === 429) {
|
|
3388
|
+
return { errorCode: "rate_limited", retry: "RetryLater" };
|
|
3389
|
+
}
|
|
3390
|
+
if (status >= 500 && status < 600) {
|
|
3391
|
+
return { errorCode: "server_error", retry: "RetryLater" };
|
|
3392
|
+
}
|
|
3393
|
+
return;
|
|
3394
|
+
}
|
|
3395
|
+
|
|
3396
|
+
// ../common/src/local-permission-codes.ts
|
|
3397
|
+
var LOCAL_PERMISSION_ERROR_CODES = new Set([
|
|
3398
|
+
"EACCES",
|
|
3399
|
+
"EPERM",
|
|
3400
|
+
"EROFS"
|
|
3401
|
+
]);
|
|
3402
|
+
|
|
3403
|
+
// ../common/src/error-handler.ts
|
|
3404
|
+
var DEFAULT_401 = "Unauthorized (401). The session is missing or expired, or its token carries no scope for this API. Run `uip login status --detailed` to see the session and its scopes.";
|
|
3405
|
+
var DEFAULT_403 = "Forbidden (403). The account lacks permission for this operation, or the token carries no scope for this API. Run `uip login status --detailed` to see the token's scopes.";
|
|
3406
|
+
var DEFAULT_405 = "Method Not Allowed (405). The endpoint may not exist or the base URL may be incorrect.";
|
|
3407
|
+
var DEFAULT_413 = "Payload too large (413). The upload exceeded the server or CDN size limit. Reduce the package size — for example, exclude unused dependencies or remove large files from the project — and try again.";
|
|
3408
|
+
var CLOUDFLARE_BLOCK_403 = "Forbidden (403) by Cloudflare, in front of the service: the answer is a Cloudflare HTML page, not the service's JSON, so the service did not see the request and did not check the account's roles or the token's scopes. Cloudflare blocks a request when its content matches a firewall rule (text that looks like SQL or script code, for example) or when it comes from a network the firewall does not allow.";
|
|
3409
|
+
var CLOUDFLARE_BLOCK_403_INSTRUCTIONS = "If the request carries text that looks like code, change that text and try again. Otherwise send the time of the request and the Cloudflare Ray ID, when the message gives one, to the owner of the service or UiPath support.";
|
|
3410
|
+
var HTML_RESPONSE_MESSAGE = "Received HTML instead of the expected JSON response.";
|
|
3411
|
+
var NETWORK_ERROR_CODES = new Set([
|
|
3412
|
+
"ECONNREFUSED",
|
|
3413
|
+
"ECONNRESET",
|
|
3414
|
+
"ENOTFOUND",
|
|
3415
|
+
"EAI_AGAIN",
|
|
3416
|
+
"ETIMEDOUT",
|
|
3417
|
+
"EPIPE",
|
|
3418
|
+
"EHOSTUNREACH",
|
|
3419
|
+
"ENETUNREACH",
|
|
3420
|
+
"EAI_FAIL"
|
|
3421
|
+
]);
|
|
3422
|
+
var TLS_ERROR_CODES = new Set([
|
|
3423
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
3424
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
3425
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
3426
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
3427
|
+
"UNABLE_TO_GET_ISSUER_CERT",
|
|
3428
|
+
"CERT_HAS_EXPIRED",
|
|
3429
|
+
"CERT_UNTRUSTED",
|
|
3430
|
+
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
3431
|
+
]);
|
|
3432
|
+
var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
|
|
3433
|
+
var NETWORK_INSTRUCTIONS = "Could not reach the UiPath service. Check your network connection and " + "VPN, confirm any HTTP_PROXY/HTTPS_PROXY/NO_PROXY settings are correct, " + "then retry.";
|
|
3434
|
+
var LOCAL_PERMISSION_MESSAGE_PATTERN = new RegExp(`\\b(${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})\\b`);
|
|
3435
|
+
function localPermissionInstructions(code, path) {
|
|
3436
|
+
const target = path !== undefined ? `'${path}'` : "a local file or resource";
|
|
3437
|
+
if (code === "EROFS") {
|
|
3438
|
+
return `The filesystem containing ${target} is read-only (EROFS), so the ` + "CLI could not write to it. This is a local environment problem, " + "not a UiPath service error — retrying will not help. Use a " + "writable location, or give this environment write access to the " + "path.";
|
|
3398
3439
|
}
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3440
|
+
const onWindows = typeof process !== "undefined" && process.platform === "win32";
|
|
3441
|
+
const remedy = onWindows ? "Re-run from an elevated terminal, close any program holding " + "the file open, or grant your user access to the path." : "Grant this user (or the sandbox the command runs in) access " + "to the path, or run the command outside the sandbox.";
|
|
3442
|
+
return `The operating system denied access to ${target} (${code}). This is ` + "a local permission problem, not a UiPath service error — retrying " + `without a permission change will not help. ${remedy}`;
|
|
3443
|
+
}
|
|
3444
|
+
function carriedInstructions(error) {
|
|
3445
|
+
if (!error || typeof error !== "object")
|
|
3446
|
+
return;
|
|
3447
|
+
const e = error;
|
|
3448
|
+
return typeof e.instructions === "string" ? e.instructions : undefined;
|
|
3449
|
+
}
|
|
3450
|
+
function describeConnectivityError(error) {
|
|
3451
|
+
for (const cur of walkErrorGraph(error)) {
|
|
3452
|
+
const code = typeof cur.code === "string" ? cur.code : undefined;
|
|
3453
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
3454
|
+
if (code && TLS_ERROR_CODES.has(code)) {
|
|
3455
|
+
return {
|
|
3456
|
+
code,
|
|
3457
|
+
kind: "tls",
|
|
3458
|
+
message: message ?? code,
|
|
3459
|
+
instructions: TLS_INSTRUCTIONS
|
|
3460
|
+
};
|
|
3406
3461
|
}
|
|
3407
|
-
|
|
3408
|
-
async stat(filePath) {
|
|
3409
|
-
try {
|
|
3410
|
-
const stats = await fs.stat(filePath);
|
|
3462
|
+
if (code && NETWORK_ERROR_CODES.has(code)) {
|
|
3411
3463
|
return {
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3464
|
+
code,
|
|
3465
|
+
kind: "network",
|
|
3466
|
+
message: message ?? code,
|
|
3467
|
+
instructions: NETWORK_INSTRUCTIONS
|
|
3416
3468
|
};
|
|
3417
|
-
} catch (error) {
|
|
3418
|
-
if (this.isEnoent(error))
|
|
3419
|
-
return null;
|
|
3420
|
-
throw error;
|
|
3421
3469
|
}
|
|
3422
3470
|
}
|
|
3423
|
-
|
|
3424
|
-
|
|
3471
|
+
return;
|
|
3472
|
+
}
|
|
3473
|
+
function describePermissionError(error) {
|
|
3474
|
+
for (const cur of walkErrorGraph(error)) {
|
|
3475
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
3476
|
+
const code = matchLocalPermissionCode(cur.code, message);
|
|
3477
|
+
if (!code)
|
|
3478
|
+
continue;
|
|
3479
|
+
const path = localPermissionPath(cur.path, message);
|
|
3480
|
+
return {
|
|
3481
|
+
code,
|
|
3482
|
+
message: message ?? code,
|
|
3483
|
+
...path !== undefined ? { path } : {},
|
|
3484
|
+
instructions: localPermissionInstructions(code, path)
|
|
3485
|
+
};
|
|
3425
3486
|
}
|
|
3426
|
-
|
|
3427
|
-
|
|
3487
|
+
return;
|
|
3488
|
+
}
|
|
3489
|
+
function matchLocalPermissionCode(code, message) {
|
|
3490
|
+
if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
|
|
3491
|
+
return code;
|
|
3428
3492
|
}
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
if (reclaimed)
|
|
3446
|
-
continue;
|
|
3447
|
-
}
|
|
3448
|
-
if (Date.now() - start > LOCK_MAX_WAIT_MS) {
|
|
3449
|
-
throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
|
|
3450
|
-
}
|
|
3451
|
-
await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
|
|
3452
|
-
}
|
|
3453
|
-
}
|
|
3493
|
+
const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
|
|
3494
|
+
return match ? match[1] : undefined;
|
|
3495
|
+
}
|
|
3496
|
+
function localPermissionPath(path, message) {
|
|
3497
|
+
if (typeof path === "string")
|
|
3498
|
+
return path;
|
|
3499
|
+
return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
|
|
3500
|
+
}
|
|
3501
|
+
function readHeader(response, name) {
|
|
3502
|
+
const headers = response?.headers;
|
|
3503
|
+
if (!headers || typeof headers !== "object")
|
|
3504
|
+
return;
|
|
3505
|
+
if (typeof headers.get === "function") {
|
|
3506
|
+
const value = headers.get(name);
|
|
3507
|
+
if (value)
|
|
3508
|
+
return value;
|
|
3454
3509
|
}
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3510
|
+
const plain = headers;
|
|
3511
|
+
const key = Object.keys(plain).find((k) => k.toLowerCase() === name.toLowerCase());
|
|
3512
|
+
const value = key === undefined ? undefined : plain[key];
|
|
3513
|
+
return typeof value === "string" && value !== "" ? value : undefined;
|
|
3514
|
+
}
|
|
3515
|
+
function isHtmlDocument(body) {
|
|
3516
|
+
return /^\s*(<!doctype html|<html\b)/i.test(body);
|
|
3517
|
+
}
|
|
3518
|
+
function retryHintForRetryAfter(seconds) {
|
|
3519
|
+
if (seconds <= 1) {
|
|
3520
|
+
return "RetryAfter1Second";
|
|
3464
3521
|
}
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
heartbeatTimer = setTimeout(() => {
|
|
3482
|
-
runHeartbeat();
|
|
3483
|
-
}, LOCK_HEARTBEAT_MS);
|
|
3484
|
-
heartbeatTimer.unref?.();
|
|
3485
|
-
};
|
|
3486
|
-
const runHeartbeat = async () => {
|
|
3487
|
-
if (stopped)
|
|
3488
|
-
return;
|
|
3489
|
-
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
3490
|
-
if (stopped)
|
|
3491
|
-
return;
|
|
3492
|
-
if (current !== ownerId) {
|
|
3493
|
-
stopped = true;
|
|
3494
|
-
return;
|
|
3495
|
-
}
|
|
3496
|
-
const now = Date.now() / 1000;
|
|
3497
|
-
await fs.utimes(lockFile, now, now).catch(() => {});
|
|
3498
|
-
scheduleNextHeartbeat();
|
|
3522
|
+
if (seconds <= 10) {
|
|
3523
|
+
return "RetryAfter10Seconds";
|
|
3524
|
+
}
|
|
3525
|
+
if (seconds <= 30) {
|
|
3526
|
+
return "RetryAfter30Seconds";
|
|
3527
|
+
}
|
|
3528
|
+
return "RetryAfter60Seconds";
|
|
3529
|
+
}
|
|
3530
|
+
function classifyError(status, error) {
|
|
3531
|
+
const byStatus = classifyHttpStatus(status);
|
|
3532
|
+
if (byStatus)
|
|
3533
|
+
return byStatus;
|
|
3534
|
+
if (status === undefined && describePermissionError(error)) {
|
|
3535
|
+
return {
|
|
3536
|
+
errorCode: "local_permission_denied",
|
|
3537
|
+
retry: "RetryWillNotFix"
|
|
3499
3538
|
};
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
stopHeartbeat();
|
|
3507
|
-
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
3508
|
-
if (current === ownerId) {
|
|
3509
|
-
await fs.rm(lockFile, { force: true });
|
|
3510
|
-
}
|
|
3539
|
+
}
|
|
3540
|
+
const connectivity = describeConnectivityError(error);
|
|
3541
|
+
if (connectivity) {
|
|
3542
|
+
return {
|
|
3543
|
+
errorCode: "network_error",
|
|
3544
|
+
retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
|
|
3511
3545
|
};
|
|
3512
3546
|
}
|
|
3513
|
-
|
|
3514
|
-
|
|
3547
|
+
return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
|
|
3548
|
+
}
|
|
3549
|
+
function withCarriedClass(inferred, error) {
|
|
3550
|
+
const errorCode = carriedErrorCode(error);
|
|
3551
|
+
const retry = carriedRetry(error);
|
|
3552
|
+
if (errorCode === undefined || errorCode === inferred.errorCode) {
|
|
3553
|
+
return {
|
|
3554
|
+
errorCode: inferred.errorCode,
|
|
3555
|
+
retry: retry ?? inferred.retry
|
|
3556
|
+
};
|
|
3515
3557
|
}
|
|
3516
|
-
|
|
3517
|
-
|
|
3558
|
+
return { errorCode, retry: retry ?? defaultRetryForErrorCode(errorCode) };
|
|
3559
|
+
}
|
|
3560
|
+
function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
|
|
3561
|
+
if (extractedMessage) {
|
|
3562
|
+
return `HTTP ${status}: ${extractedMessage}`;
|
|
3518
3563
|
}
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3564
|
+
return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
|
|
3565
|
+
}
|
|
3566
|
+
async function extractErrorDetails(error, options) {
|
|
3567
|
+
const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
|
|
3568
|
+
const response = err.response;
|
|
3569
|
+
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
3570
|
+
const explicitStatus = err.status ?? response?.status;
|
|
3571
|
+
const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
|
|
3572
|
+
const status = explicitStatus ?? inferredStatus;
|
|
3573
|
+
const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
|
|
3574
|
+
let rawBody;
|
|
3575
|
+
let extractedMessage;
|
|
3576
|
+
let parsedBody;
|
|
3577
|
+
const textFn = response?.text?.bind(response);
|
|
3578
|
+
if (textFn) {
|
|
3579
|
+
const [bodyError, body] = await catchError((async () => textFn())());
|
|
3580
|
+
if (!bodyError && body) {
|
|
3581
|
+
rawBody = body;
|
|
3582
|
+
const [parseError, parsed] = catchError(() => JSON.parse(body));
|
|
3583
|
+
if (!parseError && parsed && typeof parsed === "object") {
|
|
3584
|
+
parsedBody = parsed;
|
|
3585
|
+
if (parsedBody.errors && typeof parsedBody.errors === "object") {
|
|
3586
|
+
for (const field of Object.values(parsedBody.errors)) {
|
|
3587
|
+
if (Array.isArray(field) && field.length > 0) {
|
|
3588
|
+
const first = field[0];
|
|
3589
|
+
if (first && typeof first.message === "string") {
|
|
3590
|
+
extractedMessage = first.message;
|
|
3591
|
+
break;
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
}
|
|
3595
|
+
}
|
|
3596
|
+
if (!extractedMessage) {
|
|
3597
|
+
extractedMessage = typeof parsedBody.message === "string" ? parsedBody.message : typeof parsedBody.errorMessage === "string" ? parsedBody.errorMessage : typeof parsedBody.title === "string" ? parsedBody.title : undefined;
|
|
3598
|
+
}
|
|
3599
|
+
if (!extractedMessage) {
|
|
3600
|
+
extractedMessage = body;
|
|
3601
|
+
}
|
|
3602
|
+
if (extractedMessage && typeof parsedBody.detail === "string" && parsedBody.detail.length > 0 && !extractedMessage.includes(parsedBody.detail)) {
|
|
3603
|
+
extractedMessage = `${extractedMessage}: ${parsedBody.detail}`;
|
|
3604
|
+
}
|
|
3605
|
+
} else {
|
|
3606
|
+
extractedMessage = isHtmlDocument(body) ? HTML_RESPONSE_MESSAGE : body;
|
|
3525
3607
|
}
|
|
3526
|
-
throw error;
|
|
3527
3608
|
}
|
|
3528
3609
|
}
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3610
|
+
let message;
|
|
3611
|
+
let result = "Failure";
|
|
3612
|
+
const classificationStatus = status ?? findHttpStatusInGraph(error);
|
|
3613
|
+
const classification = classifyError(classificationStatus, error);
|
|
3614
|
+
let retry = classification.retry;
|
|
3615
|
+
const htmlForbidden = status === 403 && rawBody !== undefined && isHtmlDocument(rawBody);
|
|
3616
|
+
const rayId = htmlForbidden ? readHeader(response, "cf-ray") : undefined;
|
|
3617
|
+
const cloudflareBlock = htmlForbidden && (rayId !== undefined || /\bcloudflare\b/i.test(readHeader(response, "server") ?? ""));
|
|
3618
|
+
if (status === 401) {
|
|
3619
|
+
message = DEFAULT_401;
|
|
3620
|
+
result = "AuthenticationError";
|
|
3621
|
+
} else if (cloudflareBlock) {
|
|
3622
|
+
message = rayId ? `${CLOUDFLARE_BLOCK_403} Cloudflare Ray ID: ${rayId}.` : CLOUDFLARE_BLOCK_403;
|
|
3623
|
+
} else if (status === 403) {
|
|
3624
|
+
message = options?.forbiddenMessage ?? DEFAULT_403;
|
|
3625
|
+
result = "AuthenticationError";
|
|
3626
|
+
} else if (status === 405) {
|
|
3627
|
+
message = DEFAULT_405;
|
|
3628
|
+
} else if (status === 413) {
|
|
3629
|
+
message = DEFAULT_413;
|
|
3630
|
+
} else if (status === 400 || status === 422) {
|
|
3631
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
3632
|
+
result = "ValidationError";
|
|
3633
|
+
} else if (status === 429) {
|
|
3634
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
3635
|
+
} else if (extractedMessage) {
|
|
3636
|
+
if (isSuccessfulResponse && rawMessage !== "Unknown error") {
|
|
3637
|
+
message = rawMessage;
|
|
3638
|
+
} else {
|
|
3639
|
+
message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
|
|
3640
|
+
}
|
|
3641
|
+
} else if (status) {
|
|
3642
|
+
if (inferredStatus !== undefined) {
|
|
3643
|
+
message = rawMessage;
|
|
3644
|
+
} else if (rawMessage === "Unknown error" && response) {
|
|
3645
|
+
const statusText = response.statusText;
|
|
3646
|
+
message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
|
|
3647
|
+
} else {
|
|
3648
|
+
message = `HTTP ${status}: ${rawMessage}`;
|
|
3536
3649
|
}
|
|
3650
|
+
} else {
|
|
3651
|
+
message = rawMessage;
|
|
3537
3652
|
}
|
|
3538
|
-
|
|
3539
|
-
|
|
3653
|
+
if (status === undefined) {
|
|
3654
|
+
const connectivity = describeConnectivityError(error);
|
|
3655
|
+
if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
|
|
3656
|
+
message = `${message}: ${connectivity.message}`;
|
|
3657
|
+
}
|
|
3540
3658
|
}
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
if (!
|
|
3544
|
-
|
|
3659
|
+
const permission = status === undefined ? describePermissionError(error) : undefined;
|
|
3660
|
+
if (permission) {
|
|
3661
|
+
if (permission.message !== message && !message.includes(permission.message)) {
|
|
3662
|
+
message = `${message}: ${permission.message}`;
|
|
3545
3663
|
}
|
|
3546
|
-
if (!
|
|
3547
|
-
|
|
3664
|
+
if (!message.includes(permission.instructions)) {
|
|
3665
|
+
const punctuated = message.endsWith(".") ? message : `${message}.`;
|
|
3666
|
+
message = `${punctuated} ${permission.instructions}`;
|
|
3548
3667
|
}
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3668
|
+
}
|
|
3669
|
+
let details = rawMessage;
|
|
3670
|
+
if (htmlForbidden) {
|
|
3671
|
+
details = cloudflareBlock ? CLOUDFLARE_BLOCK_403_INSTRUCTIONS : HTML_RESPONSE_MESSAGE;
|
|
3672
|
+
} else if (rawBody) {
|
|
3673
|
+
if (parsedBody) {
|
|
3674
|
+
const extra = {};
|
|
3675
|
+
if (parsedBody.errorCode)
|
|
3676
|
+
extra.errorCode = parsedBody.errorCode;
|
|
3677
|
+
if (parsedBody.detail)
|
|
3678
|
+
extra.detail = parsedBody.detail;
|
|
3679
|
+
if (parsedBody.details)
|
|
3680
|
+
extra.details = parsedBody.details;
|
|
3681
|
+
if (parsedBody.errors != null)
|
|
3682
|
+
extra.errors = parsedBody.errors;
|
|
3683
|
+
if (parsedBody.data && typeof parsedBody.data === "object" && Object.keys(parsedBody.data).length > 0) {
|
|
3684
|
+
extra.data = parsedBody.data;
|
|
3564
3685
|
}
|
|
3686
|
+
details = Object.keys(extra).length > 0 ? JSON.stringify(extra) : rawBody;
|
|
3687
|
+
} else {
|
|
3688
|
+
details = rawBody;
|
|
3565
3689
|
}
|
|
3690
|
+
} else if (typeof err.message === "string") {
|
|
3691
|
+
details = err.message;
|
|
3692
|
+
} else {
|
|
3693
|
+
details = describeThrownValue(error);
|
|
3566
3694
|
}
|
|
3567
|
-
|
|
3568
|
-
|
|
3695
|
+
const context = {};
|
|
3696
|
+
if (classificationStatus) {
|
|
3697
|
+
context.httpStatus = classificationStatus;
|
|
3569
3698
|
}
|
|
3570
|
-
|
|
3571
|
-
|
|
3699
|
+
if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
|
|
3700
|
+
context.errorCode = parsedBody.errorCode;
|
|
3701
|
+
} else if (parsedBody?.code && typeof parsedBody.code === "string") {
|
|
3702
|
+
context.errorCode = parsedBody.code;
|
|
3703
|
+
}
|
|
3704
|
+
if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
|
|
3705
|
+
context.requestId = parsedBody.requestId;
|
|
3706
|
+
} else if (cloudflareBlock && rayId) {
|
|
3707
|
+
context.requestId = rayId;
|
|
3708
|
+
}
|
|
3709
|
+
if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
|
|
3710
|
+
context.traceId = parsedBody.traceId;
|
|
3711
|
+
}
|
|
3712
|
+
if (permission?.path !== undefined) {
|
|
3713
|
+
context.path = permission.path;
|
|
3714
|
+
}
|
|
3715
|
+
if (status === 429) {
|
|
3716
|
+
const retryAfterValue = readHeader(response, "retry-after");
|
|
3717
|
+
if (retryAfterValue) {
|
|
3718
|
+
const seconds = Number(retryAfterValue);
|
|
3719
|
+
if (!Number.isNaN(seconds)) {
|
|
3720
|
+
context.retryAfter = seconds;
|
|
3721
|
+
retry = retryHintForRetryAfter(seconds);
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3724
|
+
}
|
|
3725
|
+
const hasContext = Object.keys(context).length > 0;
|
|
3726
|
+
let parsedErrors;
|
|
3727
|
+
if (parsedBody?.errors && typeof parsedBody.errors === "object") {
|
|
3728
|
+
const errors = {};
|
|
3729
|
+
for (const [field, raw] of Object.entries(parsedBody.errors)) {
|
|
3730
|
+
if (Array.isArray(raw)) {
|
|
3731
|
+
const messages = raw.map((entry) => {
|
|
3732
|
+
if (typeof entry === "string")
|
|
3733
|
+
return entry;
|
|
3734
|
+
if (entry && typeof entry === "object" && typeof entry.message === "string") {
|
|
3735
|
+
return entry.message;
|
|
3736
|
+
}
|
|
3737
|
+
return String(entry);
|
|
3738
|
+
}).filter(Boolean);
|
|
3739
|
+
if (messages.length > 0)
|
|
3740
|
+
errors[field] = messages;
|
|
3741
|
+
} else if (typeof raw === "string") {
|
|
3742
|
+
errors[field] = [raw];
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
3745
|
+
if (Object.keys(errors).length > 0)
|
|
3746
|
+
parsedErrors = errors;
|
|
3572
3747
|
}
|
|
3748
|
+
return {
|
|
3749
|
+
result,
|
|
3750
|
+
...withCarriedClass({ errorCode: classification.errorCode, retry }, error),
|
|
3751
|
+
message,
|
|
3752
|
+
details,
|
|
3753
|
+
...hasContext ? { context } : {},
|
|
3754
|
+
...parsedErrors ? { parsedErrors } : {}
|
|
3755
|
+
};
|
|
3573
3756
|
}
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
// ../common/src/
|
|
3579
|
-
function
|
|
3580
|
-
|
|
3757
|
+
async function extractErrorMessage(error, options) {
|
|
3758
|
+
const { message } = await extractErrorDetails(error, options);
|
|
3759
|
+
return message;
|
|
3760
|
+
}
|
|
3761
|
+
// ../common/src/error-instructions.ts
|
|
3762
|
+
function extractHttpStatus(err) {
|
|
3763
|
+
if (!err || typeof err !== "object")
|
|
3764
|
+
return;
|
|
3765
|
+
const e = err;
|
|
3766
|
+
const structured = e.response?.status ?? e.status ?? e.statusCode;
|
|
3767
|
+
if (structured !== undefined)
|
|
3768
|
+
return structured;
|
|
3769
|
+
return typeof e.message === "string" ? parseHttpStatusFromMessage(e.message) : undefined;
|
|
3770
|
+
}
|
|
3771
|
+
var GENERIC = "Check authentication and parameters";
|
|
3772
|
+
function hasIdentityInstructionContext(err) {
|
|
3773
|
+
return err !== null && typeof err === "object" && "instructionContext" in err && err.instructionContext === "identity";
|
|
3774
|
+
}
|
|
3775
|
+
function instructionsFor(ctx, err) {
|
|
3776
|
+
if (ctx === "auth" && hasIdentityInstructionContext(err)) {
|
|
3777
|
+
return instructionsFor("identity");
|
|
3778
|
+
}
|
|
3779
|
+
switch (ctx) {
|
|
3780
|
+
case "auth":
|
|
3781
|
+
return "Run 'uip login' to authenticate. To inspect the current session, run 'uip whoami'.";
|
|
3782
|
+
case "auth-configuration":
|
|
3783
|
+
return "Fix the authentication settings named in Message, then retry.";
|
|
3784
|
+
case "identity":
|
|
3785
|
+
return "Select an active tenant with 'uip login tenant set <tenant>' and ensure your login includes an organization";
|
|
3786
|
+
case "input-parse":
|
|
3787
|
+
return "Ensure --inputs is valid JSON or pipe JSON via stdin";
|
|
3788
|
+
case "input-validate":
|
|
3789
|
+
return "Fix the flagged input fields to match the process's input schema";
|
|
3790
|
+
case "flag-format":
|
|
3791
|
+
return "Check the flag value format — see --help for the expected shape";
|
|
3792
|
+
case "permissions":
|
|
3793
|
+
return "Confirm your user has the required permissions in this folder/tenant, or re-authenticate with 'uip login' if your session has lapsed";
|
|
3794
|
+
case "backend": {
|
|
3795
|
+
const status = extractHttpStatus(err);
|
|
3796
|
+
if (status === 401) {
|
|
3797
|
+
return "Re-authenticate with 'uip login' — your session is invalid or expired";
|
|
3798
|
+
}
|
|
3799
|
+
if (status === 403) {
|
|
3800
|
+
return "Confirm your user has access to the resource, and the required permissions in this folder or tenant";
|
|
3801
|
+
}
|
|
3802
|
+
if (status === 404) {
|
|
3803
|
+
return "Verify the resource exists in the current folder/tenant";
|
|
3804
|
+
}
|
|
3805
|
+
if (status === 400 || status === 422) {
|
|
3806
|
+
return "Request was rejected — check flag values and inputs";
|
|
3807
|
+
}
|
|
3808
|
+
if (status === 405) {
|
|
3809
|
+
return "Check the command name and the base URL in use — the endpoint may not exist";
|
|
3810
|
+
}
|
|
3811
|
+
if (status === 408) {
|
|
3812
|
+
return "The request timed out — retry; if it persists, narrow the request (e.g. --limit on list commands)";
|
|
3813
|
+
}
|
|
3814
|
+
if (status === 409) {
|
|
3815
|
+
return "The resource already exists, or changed since it was read — list it to see the current state";
|
|
3816
|
+
}
|
|
3817
|
+
if (status === 413) {
|
|
3818
|
+
return "The upload is over the size limit — exclude unused dependencies or drop large files, then retry";
|
|
3819
|
+
}
|
|
3820
|
+
if (status === 429) {
|
|
3821
|
+
return "Rate limit reached — wait and retry; when the service suggests a delay, Retry and Context.retryAfter carry it";
|
|
3822
|
+
}
|
|
3823
|
+
if (status !== undefined && status >= 500 && status < 600) {
|
|
3824
|
+
return "The service returned a server error — retry; if it persists, check service status";
|
|
3825
|
+
}
|
|
3826
|
+
const permission = describePermissionError(err);
|
|
3827
|
+
if (permission) {
|
|
3828
|
+
return permission.instructions;
|
|
3829
|
+
}
|
|
3830
|
+
const connectivity = describeConnectivityError(err);
|
|
3831
|
+
if (connectivity) {
|
|
3832
|
+
return connectivity.instructions;
|
|
3833
|
+
}
|
|
3834
|
+
return GENERIC;
|
|
3835
|
+
}
|
|
3836
|
+
}
|
|
3837
|
+
}
|
|
3838
|
+
|
|
3839
|
+
// ../common/src/result-types.ts
|
|
3840
|
+
var RESULTS = {
|
|
3841
|
+
Success: "Success",
|
|
3842
|
+
Failure: "Failure",
|
|
3843
|
+
ConfigError: "ConfigError",
|
|
3844
|
+
AuthenticationError: "AuthenticationError",
|
|
3845
|
+
ValidationError: "ValidationError",
|
|
3846
|
+
TimeoutError: "TimeoutError"
|
|
3847
|
+
};
|
|
3848
|
+
// ../common/src/command-examples.ts
|
|
3849
|
+
var examplesByCommand = new WeakMap;
|
|
3850
|
+
Command.prototype.examples = function(examples) {
|
|
3851
|
+
examplesByCommand.set(this, examples);
|
|
3852
|
+
return this;
|
|
3853
|
+
};
|
|
3854
|
+
// ../common/src/preview.ts
|
|
3855
|
+
var previewSlot = singleton("PreviewBuild");
|
|
3856
|
+
function isPreviewBuild() {
|
|
3857
|
+
return previewSlot.get(false) ?? false;
|
|
3581
3858
|
}
|
|
3859
|
+
Command.prototype.previewCommand = function(nameAndArgs, opts) {
|
|
3860
|
+
if (isPreviewBuild()) {
|
|
3861
|
+
return this.command(nameAndArgs, opts);
|
|
3862
|
+
}
|
|
3863
|
+
return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
|
|
3864
|
+
};
|
|
3582
3865
|
|
|
3583
3866
|
// ../common/src/output-context.ts
|
|
3584
3867
|
function createStorage() {
|
|
@@ -3613,8 +3896,8 @@ function getOutputSink() {
|
|
|
3613
3896
|
|
|
3614
3897
|
// ../common/src/logger.ts
|
|
3615
3898
|
var logFilePathSlot = singleton("logFilePath");
|
|
3616
|
-
function setGlobalLogFilePath(
|
|
3617
|
-
logFilePathSlot.set(
|
|
3899
|
+
function setGlobalLogFilePath(path) {
|
|
3900
|
+
logFilePathSlot.set(path);
|
|
3618
3901
|
}
|
|
3619
3902
|
function getGlobalLogFilePath() {
|
|
3620
3903
|
return logFilePathSlot.get("");
|
|
@@ -3682,14 +3965,14 @@ class SimpleLogger {
|
|
|
3682
3965
|
return this.fileLoggingEnabled || !!getGlobalLogFilePath();
|
|
3683
3966
|
}
|
|
3684
3967
|
writeToFile(formatted) {
|
|
3685
|
-
const
|
|
3686
|
-
if (!
|
|
3968
|
+
const path = this.logFilePath || getGlobalLogFilePath();
|
|
3969
|
+
if (!path)
|
|
3687
3970
|
return;
|
|
3688
3971
|
const timestamp = new Date().toISOString();
|
|
3689
3972
|
this.pendingWrites = Promise.all([
|
|
3690
3973
|
this.pendingWrites,
|
|
3691
3974
|
this.pendingInit
|
|
3692
|
-
]).then(() => getFileSystem().appendFile(
|
|
3975
|
+
]).then(() => getFileSystem().appendFile(path, `${timestamp} ${formatted}`).catch(() => {}));
|
|
3693
3976
|
}
|
|
3694
3977
|
write(formatted) {
|
|
3695
3978
|
if (this.isFileLoggingActive()) {
|
|
@@ -3739,17 +4022,17 @@ class SimpleLogger {
|
|
|
3739
4022
|
setGlobalLogFilePath("");
|
|
3740
4023
|
}
|
|
3741
4024
|
}
|
|
3742
|
-
setLogFile(
|
|
3743
|
-
this.logFilePath =
|
|
3744
|
-
setGlobalLogFilePath(
|
|
3745
|
-
if (!
|
|
4025
|
+
setLogFile(path) {
|
|
4026
|
+
this.logFilePath = path;
|
|
4027
|
+
setGlobalLogFilePath(path);
|
|
4028
|
+
if (!path)
|
|
3746
4029
|
return;
|
|
3747
4030
|
this.fileLoggingEnabled = true;
|
|
3748
|
-
const
|
|
4031
|
+
const fs = getFileSystem();
|
|
3749
4032
|
this.pendingInit = (async () => {
|
|
3750
4033
|
const [error] = await catchError((async () => {
|
|
3751
|
-
await
|
|
3752
|
-
await
|
|
4034
|
+
await fs.mkdir(fs.path.dirname(path));
|
|
4035
|
+
await fs.writeFile(path, "");
|
|
3753
4036
|
})());
|
|
3754
4037
|
if (error)
|
|
3755
4038
|
this.fileLoggingEnabled = false;
|
|
@@ -3797,18 +4080,111 @@ function getLogFilePath() {
|
|
|
3797
4080
|
return logger.getLogFilePath();
|
|
3798
4081
|
}
|
|
3799
4082
|
|
|
4083
|
+
// ../common/src/timings.ts
|
|
4084
|
+
var TIMINGS_ENV_VAR = "UIP_TIMINGS";
|
|
4085
|
+
function createStorage2() {
|
|
4086
|
+
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
4087
|
+
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
4088
|
+
return {
|
|
4089
|
+
getStore: () => {
|
|
4090
|
+
return;
|
|
4091
|
+
},
|
|
4092
|
+
run: (_store, fn) => fn()
|
|
4093
|
+
};
|
|
4094
|
+
}
|
|
4095
|
+
return new mod.AsyncLocalStorage;
|
|
4096
|
+
}
|
|
4097
|
+
var storageSlot = singleton("TimingStorage");
|
|
4098
|
+
var stateSlot = singleton("Timings");
|
|
4099
|
+
var rootStartedSlot = singleton("TimingsRootStarted");
|
|
4100
|
+
var longLivedHostSlot = singleton("TimingsLongLivedHost");
|
|
4101
|
+
var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
|
|
4102
|
+
function newState(baseline) {
|
|
4103
|
+
return { baseline, httpMs: 0, httpCalls: 0 };
|
|
4104
|
+
}
|
|
4105
|
+
function getState() {
|
|
4106
|
+
const scoped = storage.getStore();
|
|
4107
|
+
if (scoped) {
|
|
4108
|
+
return scoped;
|
|
4109
|
+
}
|
|
4110
|
+
const pinned = livePinnedState();
|
|
4111
|
+
if (pinned !== undefined) {
|
|
4112
|
+
return pinned;
|
|
4113
|
+
}
|
|
4114
|
+
return newState(processStartIsInvocationStart() ? 0 : performance.now());
|
|
4115
|
+
}
|
|
4116
|
+
function livePinnedState() {
|
|
4117
|
+
const pinned = stateSlot.get();
|
|
4118
|
+
return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
|
|
4119
|
+
}
|
|
4120
|
+
function processStartIsInvocationStart() {
|
|
4121
|
+
return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
|
|
4122
|
+
}
|
|
4123
|
+
function timingsEnabled() {
|
|
4124
|
+
if (typeof process === "undefined") {
|
|
4125
|
+
return false;
|
|
4126
|
+
}
|
|
4127
|
+
const value = process.env?.[TIMINGS_ENV_VAR];
|
|
4128
|
+
if (value === undefined) {
|
|
4129
|
+
return false;
|
|
4130
|
+
}
|
|
4131
|
+
const normalized = value.trim().toLowerCase();
|
|
4132
|
+
return normalized === "1" || normalized === "true";
|
|
4133
|
+
}
|
|
4134
|
+
function recordExitCode(exitCode) {
|
|
4135
|
+
if (!timingsEnabled()) {
|
|
4136
|
+
return;
|
|
4137
|
+
}
|
|
4138
|
+
getState().exitCode = exitCode;
|
|
4139
|
+
}
|
|
4140
|
+
function invocationStartedAt() {
|
|
4141
|
+
return new Date(performance.timeOrigin + getState().baseline);
|
|
4142
|
+
}
|
|
4143
|
+
function invocationElapsedMs() {
|
|
4144
|
+
return performance.now() - getState().baseline;
|
|
4145
|
+
}
|
|
4146
|
+
function markCommandStart() {
|
|
4147
|
+
if (!timingsEnabled()) {
|
|
4148
|
+
return;
|
|
4149
|
+
}
|
|
4150
|
+
getState().commandStart = performance.now();
|
|
4151
|
+
}
|
|
4152
|
+
function recordCommandDuration(durationMs) {
|
|
4153
|
+
if (!timingsEnabled()) {
|
|
4154
|
+
return;
|
|
4155
|
+
}
|
|
4156
|
+
getState().commandMs = durationMs;
|
|
4157
|
+
}
|
|
4158
|
+
|
|
4159
|
+
// ../common/src/exit-code.ts
|
|
4160
|
+
function setExitCode(code) {
|
|
4161
|
+
process.exitCode = code;
|
|
4162
|
+
recordExitCode(code);
|
|
4163
|
+
}
|
|
4164
|
+
var GENERIC_FAILURE_EXIT_CODE = 1;
|
|
4165
|
+
function recordCommandExit(code) {
|
|
4166
|
+
if (code === GENERIC_FAILURE_EXIT_CODE && getExitCode() !== 0) {
|
|
4167
|
+
return;
|
|
4168
|
+
}
|
|
4169
|
+
setExitCode(code);
|
|
4170
|
+
}
|
|
4171
|
+
function getExitCode() {
|
|
4172
|
+
const code = process.exitCode;
|
|
4173
|
+
return typeof code === "number" ? code : 0;
|
|
4174
|
+
}
|
|
4175
|
+
|
|
3800
4176
|
// ../common/src/output-codecs.ts
|
|
3801
4177
|
var yamlSlot = singleton("YamlCodec");
|
|
3802
4178
|
var jmespathSlot = singleton("JmespathCodec");
|
|
3803
4179
|
async function loadOutputCodecsAsync(needed) {
|
|
3804
4180
|
const loads = [];
|
|
3805
4181
|
if (needed.yaml && yamlSlot.get() === undefined) {
|
|
3806
|
-
loads.push(import("./js-yaml-
|
|
4182
|
+
loads.push(import("./js-yaml-a2bk27p6.js").then((mod) => {
|
|
3807
4183
|
yamlSlot.set(mod);
|
|
3808
4184
|
}));
|
|
3809
4185
|
}
|
|
3810
4186
|
if (needed.filter && jmespathSlot.get() === undefined) {
|
|
3811
|
-
loads.push(import("./jmespath-
|
|
4187
|
+
loads.push(import("./jmespath-ab6tdc42.js").then((m)=>__toESM(m.default,1)).then((mod) => {
|
|
3812
4188
|
jmespathSlot.set(mod);
|
|
3813
4189
|
}));
|
|
3814
4190
|
}
|
|
@@ -3951,17 +4327,8 @@ function terminalSignalFor(input, outcome) {
|
|
|
3951
4327
|
}
|
|
3952
4328
|
return outcome === "cancelled" ? "SIGINT" : undefined;
|
|
3953
4329
|
}
|
|
3954
|
-
function
|
|
3955
|
-
|
|
3956
|
-
return "auth";
|
|
3957
|
-
}
|
|
3958
|
-
if (status === 400 || status === 409 || status === 422) {
|
|
3959
|
-
return "validation";
|
|
3960
|
-
}
|
|
3961
|
-
if (status === 408) {
|
|
3962
|
-
return "timeout";
|
|
3963
|
-
}
|
|
3964
|
-
return "network_http";
|
|
4330
|
+
function classifyFailingHttpStatus(status) {
|
|
4331
|
+
return classifyFromErrorCode(classifyHttpStatus(status)?.errorCode) ?? "network_http";
|
|
3965
4332
|
}
|
|
3966
4333
|
function classifyFromResult(result) {
|
|
3967
4334
|
switch (result) {
|
|
@@ -4041,7 +4408,7 @@ function classifyError2(input) {
|
|
|
4041
4408
|
}
|
|
4042
4409
|
const status = recorded?.context?.httpStatus ?? findHttpStatusInGraph(input.error);
|
|
4043
4410
|
if (status !== undefined) {
|
|
4044
|
-
return
|
|
4411
|
+
return classifyFailingHttpStatus(status);
|
|
4045
4412
|
}
|
|
4046
4413
|
return classifyFromResult(recorded?.result) ?? classifyFromErrorCode(recorded?.errorCode) ?? classifyFromError(input.error) ?? "unknown";
|
|
4047
4414
|
}
|
|
@@ -4073,6 +4440,7 @@ function buildCommandTerminalTelemetryProperties(input) {
|
|
|
4073
4440
|
var CommonTelemetryEvents = {
|
|
4074
4441
|
Start: "Application.Start",
|
|
4075
4442
|
Error: "Application.Error",
|
|
4443
|
+
ProjectActivity: "Cli.ProjectActivity",
|
|
4076
4444
|
ShipSucceeded: "Cli.ShipSucceeded"
|
|
4077
4445
|
};
|
|
4078
4446
|
|
|
@@ -4584,81 +4952,6 @@ class TelemetryService {
|
|
|
4584
4952
|
return hex;
|
|
4585
4953
|
}
|
|
4586
4954
|
}
|
|
4587
|
-
// ../common/src/timings.ts
|
|
4588
|
-
var TIMINGS_ENV_VAR = "UIP_TIMINGS";
|
|
4589
|
-
function createStorage2() {
|
|
4590
|
-
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
4591
|
-
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
4592
|
-
return {
|
|
4593
|
-
getStore: () => {
|
|
4594
|
-
return;
|
|
4595
|
-
},
|
|
4596
|
-
run: (_store, fn) => fn()
|
|
4597
|
-
};
|
|
4598
|
-
}
|
|
4599
|
-
return new mod.AsyncLocalStorage;
|
|
4600
|
-
}
|
|
4601
|
-
var storageSlot = singleton("TimingStorage");
|
|
4602
|
-
var stateSlot = singleton("Timings");
|
|
4603
|
-
var rootStartedSlot = singleton("TimingsRootStarted");
|
|
4604
|
-
var longLivedHostSlot = singleton("TimingsLongLivedHost");
|
|
4605
|
-
var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
|
|
4606
|
-
function newState(baseline) {
|
|
4607
|
-
return { baseline, httpMs: 0, httpCalls: 0 };
|
|
4608
|
-
}
|
|
4609
|
-
function getState() {
|
|
4610
|
-
const scoped = storage.getStore();
|
|
4611
|
-
if (scoped) {
|
|
4612
|
-
return scoped;
|
|
4613
|
-
}
|
|
4614
|
-
const pinned = livePinnedState();
|
|
4615
|
-
if (pinned !== undefined) {
|
|
4616
|
-
return pinned;
|
|
4617
|
-
}
|
|
4618
|
-
return newState(processStartIsInvocationStart() ? 0 : performance.now());
|
|
4619
|
-
}
|
|
4620
|
-
function livePinnedState() {
|
|
4621
|
-
const pinned = stateSlot.get();
|
|
4622
|
-
return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
|
|
4623
|
-
}
|
|
4624
|
-
function processStartIsInvocationStart() {
|
|
4625
|
-
return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
|
|
4626
|
-
}
|
|
4627
|
-
function timingsEnabled() {
|
|
4628
|
-
if (typeof process === "undefined") {
|
|
4629
|
-
return false;
|
|
4630
|
-
}
|
|
4631
|
-
const value = process.env?.[TIMINGS_ENV_VAR];
|
|
4632
|
-
if (value === undefined) {
|
|
4633
|
-
return false;
|
|
4634
|
-
}
|
|
4635
|
-
const normalized = value.trim().toLowerCase();
|
|
4636
|
-
return normalized === "1" || normalized === "true";
|
|
4637
|
-
}
|
|
4638
|
-
function recordExitCode(exitCode) {
|
|
4639
|
-
if (!timingsEnabled()) {
|
|
4640
|
-
return;
|
|
4641
|
-
}
|
|
4642
|
-
getState().exitCode = exitCode;
|
|
4643
|
-
}
|
|
4644
|
-
function invocationStartedAt() {
|
|
4645
|
-
return new Date(performance.timeOrigin + getState().baseline);
|
|
4646
|
-
}
|
|
4647
|
-
function invocationElapsedMs() {
|
|
4648
|
-
return performance.now() - getState().baseline;
|
|
4649
|
-
}
|
|
4650
|
-
function markCommandStart() {
|
|
4651
|
-
if (!timingsEnabled()) {
|
|
4652
|
-
return;
|
|
4653
|
-
}
|
|
4654
|
-
getState().commandStart = performance.now();
|
|
4655
|
-
}
|
|
4656
|
-
function recordCommandDuration(durationMs) {
|
|
4657
|
-
if (!timingsEnabled()) {
|
|
4658
|
-
return;
|
|
4659
|
-
}
|
|
4660
|
-
getState().commandMs = durationMs;
|
|
4661
|
-
}
|
|
4662
4955
|
// ../common/src/telemetry/proxy-http-agent.ts
|
|
4663
4956
|
var slot = singleton("ProxyAuthHttpsAgent");
|
|
4664
4957
|
|
|
@@ -4690,66 +4983,25 @@ function getTelemetryInstance() {
|
|
|
4690
4983
|
if (!_localTelemetryInstance) {
|
|
4691
4984
|
_localTelemetryInstance = new TelemetryService(new LoggerTelemetryProvider, new NodeContextStorage);
|
|
4692
4985
|
setGlobalTelemetryInstance(_localTelemetryInstance);
|
|
4693
|
-
}
|
|
4694
|
-
return _localTelemetryInstance;
|
|
4695
|
-
}
|
|
4696
|
-
var telemetry = new Proxy({}, {
|
|
4697
|
-
get(_, prop) {
|
|
4698
|
-
const instance = getTelemetryInstance();
|
|
4699
|
-
const value = instance[prop];
|
|
4700
|
-
return typeof value === "function" ? value.bind(instance) : value;
|
|
4701
|
-
}
|
|
4702
|
-
});
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
dim: "\x1B[2m"
|
|
4708
|
-
};
|
|
4709
|
-
var ANSI_RESET = "\x1B[0m";
|
|
4710
|
-
function styleLine(line, style) {
|
|
4711
|
-
return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
|
|
4712
|
-
}
|
|
4713
|
-
var CLI_ERROR_CODES = [
|
|
4714
|
-
"invalid_argument",
|
|
4715
|
-
"authentication_required",
|
|
4716
|
-
"permission_denied",
|
|
4717
|
-
"local_permission_denied",
|
|
4718
|
-
"not_found",
|
|
4719
|
-
"rate_limited",
|
|
4720
|
-
"network_error",
|
|
4721
|
-
"timeout",
|
|
4722
|
-
"server_error",
|
|
4723
|
-
"method_not_allowed",
|
|
4724
|
-
"not_supported",
|
|
4725
|
-
"configuration_error",
|
|
4726
|
-
"execution_failed",
|
|
4727
|
-
"unknown_error"
|
|
4728
|
-
];
|
|
4729
|
-
var RETRY_HINTS = [
|
|
4730
|
-
"RetryWillNotFix",
|
|
4731
|
-
"RetryLater",
|
|
4732
|
-
"RetryAfter1Second",
|
|
4733
|
-
"RetryAfter10Seconds",
|
|
4734
|
-
"RetryAfter30Seconds",
|
|
4735
|
-
"RetryAfter60Seconds"
|
|
4736
|
-
];
|
|
4737
|
-
var CLI_ERROR_CODE_VALUES = new Set(CLI_ERROR_CODES);
|
|
4738
|
-
var RETRY_HINT_VALUES = new Set(RETRY_HINTS);
|
|
4739
|
-
function isCliErrorCode(value) {
|
|
4740
|
-
return typeof value === "string" && CLI_ERROR_CODE_VALUES.has(value);
|
|
4741
|
-
}
|
|
4742
|
-
function isRetryHint(value) {
|
|
4743
|
-
return typeof value === "string" && RETRY_HINT_VALUES.has(value);
|
|
4744
|
-
}
|
|
4745
|
-
var RESULTS = {
|
|
4746
|
-
Success: "Success",
|
|
4747
|
-
Failure: "Failure",
|
|
4748
|
-
ConfigError: "ConfigError",
|
|
4749
|
-
AuthenticationError: "AuthenticationError",
|
|
4750
|
-
ValidationError: "ValidationError",
|
|
4751
|
-
TimeoutError: "TimeoutError"
|
|
4986
|
+
}
|
|
4987
|
+
return _localTelemetryInstance;
|
|
4988
|
+
}
|
|
4989
|
+
var telemetry = new Proxy({}, {
|
|
4990
|
+
get(_, prop) {
|
|
4991
|
+
const instance = getTelemetryInstance();
|
|
4992
|
+
const value = instance[prop];
|
|
4993
|
+
return typeof value === "function" ? value.bind(instance) : value;
|
|
4994
|
+
}
|
|
4995
|
+
});
|
|
4996
|
+
// ../common/src/formatter.ts
|
|
4997
|
+
var ANSI_STYLES = {
|
|
4998
|
+
red: "\x1B[31m",
|
|
4999
|
+
dim: "\x1B[2m"
|
|
4752
5000
|
};
|
|
5001
|
+
var ANSI_RESET = "\x1B[0m";
|
|
5002
|
+
function styleLine(line, style) {
|
|
5003
|
+
return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
|
|
5004
|
+
}
|
|
4753
5005
|
var EXIT_CODES = {
|
|
4754
5006
|
Success: 0,
|
|
4755
5007
|
Failure: 1,
|
|
@@ -4758,6 +5010,9 @@ var EXIT_CODES = {
|
|
|
4758
5010
|
ValidationError: 3,
|
|
4759
5011
|
TimeoutError: 4
|
|
4760
5012
|
};
|
|
5013
|
+
function exitCodeForResult(result) {
|
|
5014
|
+
return EXIT_CODES[result] ?? EXIT_CODES.Failure;
|
|
5015
|
+
}
|
|
4761
5016
|
|
|
4762
5017
|
class Pagination {
|
|
4763
5018
|
Returned;
|
|
@@ -5466,8 +5721,8 @@ function carriesOnlyNulls(value) {
|
|
|
5466
5721
|
}
|
|
5467
5722
|
return false;
|
|
5468
5723
|
}
|
|
5469
|
-
function nameList(names,
|
|
5470
|
-
const shown = names.slice(0,
|
|
5724
|
+
function nameList(names, cap = 12) {
|
|
5725
|
+
const shown = names.slice(0, cap).map((n) => `\`${n}\``);
|
|
5471
5726
|
const rest = names.length - shown.length;
|
|
5472
5727
|
return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
|
|
5473
5728
|
}
|
|
@@ -5604,40 +5859,11 @@ function defaultErrorCodeForResult(result) {
|
|
|
5604
5859
|
return "unknown_error";
|
|
5605
5860
|
}
|
|
5606
5861
|
}
|
|
5607
|
-
function parseHttpStatusFromMessage2(message) {
|
|
5608
|
-
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
5609
|
-
if (!match)
|
|
5610
|
-
return;
|
|
5611
|
-
const status = Number(match[1]);
|
|
5612
|
-
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
5613
|
-
}
|
|
5614
|
-
function defaultErrorCodeForHttpStatus(status) {
|
|
5615
|
-
if (status === undefined)
|
|
5616
|
-
return;
|
|
5617
|
-
if (status === 400 || status === 409 || status === 422) {
|
|
5618
|
-
return "invalid_argument";
|
|
5619
|
-
}
|
|
5620
|
-
if (status === 401)
|
|
5621
|
-
return "authentication_required";
|
|
5622
|
-
if (status === 403)
|
|
5623
|
-
return "permission_denied";
|
|
5624
|
-
if (status === 404)
|
|
5625
|
-
return "not_found";
|
|
5626
|
-
if (status === 405)
|
|
5627
|
-
return "method_not_allowed";
|
|
5628
|
-
if (status === 408)
|
|
5629
|
-
return "timeout";
|
|
5630
|
-
if (status === 429)
|
|
5631
|
-
return "rate_limited";
|
|
5632
|
-
if (status >= 500 && status < 600)
|
|
5633
|
-
return "server_error";
|
|
5634
|
-
return;
|
|
5635
|
-
}
|
|
5636
5862
|
var LOCAL_PERMISSION_TEXT_PATTERN = new RegExp(`(?:\\b|\\()(?:${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})(?::\\s|\\))`);
|
|
5637
5863
|
function defaultErrorCodeForFailure(data) {
|
|
5638
5864
|
if (data.Result === RESULTS.Failure) {
|
|
5639
|
-
const status = data.Context?.httpStatus ??
|
|
5640
|
-
const errorCode =
|
|
5865
|
+
const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage(data.Message);
|
|
5866
|
+
const errorCode = classifyHttpStatus(status)?.errorCode;
|
|
5641
5867
|
if (errorCode)
|
|
5642
5868
|
return errorCode;
|
|
5643
5869
|
if (status === undefined && (LOCAL_PERMISSION_TEXT_PATTERN.test(data.Message) || LOCAL_PERMISSION_TEXT_PATTERN.test(data.Instructions))) {
|
|
@@ -5646,17 +5872,6 @@ function defaultErrorCodeForFailure(data) {
|
|
|
5646
5872
|
}
|
|
5647
5873
|
return defaultErrorCodeForResult(data.Result);
|
|
5648
5874
|
}
|
|
5649
|
-
function defaultRetryForErrorCode(errorCode) {
|
|
5650
|
-
switch (errorCode) {
|
|
5651
|
-
case "network_error":
|
|
5652
|
-
case "rate_limited":
|
|
5653
|
-
case "server_error":
|
|
5654
|
-
case "timeout":
|
|
5655
|
-
return "RetryLater";
|
|
5656
|
-
default:
|
|
5657
|
-
return "RetryWillNotFix";
|
|
5658
|
-
}
|
|
5659
|
-
}
|
|
5660
5875
|
var OutputFormatter;
|
|
5661
5876
|
((OutputFormatter) => {
|
|
5662
5877
|
function success(data, options) {
|
|
@@ -5688,7 +5903,7 @@ var OutputFormatter;
|
|
|
5688
5903
|
data.Log ??= getLogFilePath() || undefined;
|
|
5689
5904
|
data.ErrorCode ??= defaultErrorCodeForFailure(data);
|
|
5690
5905
|
data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
|
|
5691
|
-
const exitCode =
|
|
5906
|
+
const exitCode = exitCodeForResult(data.Result);
|
|
5692
5907
|
setExitCode(exitCode);
|
|
5693
5908
|
recordCommandFailureTelemetry({
|
|
5694
5909
|
result: data.Result,
|
|
@@ -5782,23 +5997,228 @@ var OutputFormatter;
|
|
|
5782
5997
|
}
|
|
5783
5998
|
OutputFormatter.formatToString = formatToString;
|
|
5784
5999
|
})(OutputFormatter ||= {});
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
6000
|
+
|
|
6001
|
+
// ../common/src/pass-through-tail.ts
|
|
6002
|
+
function maybeOption(arg) {
|
|
6003
|
+
return arg.length > 1 && arg[0] === "-";
|
|
6004
|
+
}
|
|
6005
|
+
function tokenizeTail(cmd, tail) {
|
|
6006
|
+
const find = (flag) => cmd.options.find((option) => option.long === flag || option.short === flag);
|
|
6007
|
+
const digitShort = cmd.options.some((option) => option.short !== undefined && /^-\d$/.test(option.short));
|
|
6008
|
+
const negativeNumber = (arg) => !digitShort && /^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg);
|
|
6009
|
+
const tokens = [];
|
|
6010
|
+
let firstUnknown = -1;
|
|
6011
|
+
let sentinel = -1;
|
|
6012
|
+
let variadic;
|
|
6013
|
+
let group;
|
|
6014
|
+
let groupIndex = 0;
|
|
6015
|
+
let i = 0;
|
|
6016
|
+
while (i < tail.length || group !== undefined) {
|
|
6017
|
+
const index = group === undefined ? i : groupIndex;
|
|
6018
|
+
const arg = group ?? tail[i++];
|
|
6019
|
+
group = undefined;
|
|
6020
|
+
if (arg === "--") {
|
|
6021
|
+
sentinel = index;
|
|
6022
|
+
tokens.push({ kind: "sentinel", index });
|
|
6023
|
+
for (let j = i;j < tail.length; j++) {
|
|
6024
|
+
tokens.push({
|
|
6025
|
+
kind: "operand",
|
|
6026
|
+
index: j,
|
|
6027
|
+
text: tail[j],
|
|
6028
|
+
literal: true
|
|
6029
|
+
});
|
|
6030
|
+
}
|
|
6031
|
+
break;
|
|
6032
|
+
}
|
|
6033
|
+
if (variadic && (!maybeOption(arg) || negativeNumber(arg))) {
|
|
6034
|
+
tokens.push({
|
|
6035
|
+
kind: "option",
|
|
6036
|
+
index,
|
|
6037
|
+
text: arg,
|
|
6038
|
+
option: variadic,
|
|
6039
|
+
value: arg
|
|
6040
|
+
});
|
|
6041
|
+
continue;
|
|
6042
|
+
}
|
|
6043
|
+
variadic = undefined;
|
|
6044
|
+
if (maybeOption(arg)) {
|
|
6045
|
+
const option = find(arg);
|
|
6046
|
+
if (option) {
|
|
6047
|
+
let value;
|
|
6048
|
+
if (option.required) {
|
|
6049
|
+
value = tail[i];
|
|
6050
|
+
if (value !== undefined)
|
|
6051
|
+
i++;
|
|
6052
|
+
} else if (option.optional) {
|
|
6053
|
+
const next = tail[i];
|
|
6054
|
+
if (next !== undefined && (!maybeOption(next) || negativeNumber(next))) {
|
|
6055
|
+
value = next;
|
|
6056
|
+
i++;
|
|
6057
|
+
}
|
|
6058
|
+
}
|
|
6059
|
+
tokens.push({
|
|
6060
|
+
kind: "option",
|
|
6061
|
+
index,
|
|
6062
|
+
text: arg,
|
|
6063
|
+
option,
|
|
6064
|
+
...value === undefined ? {} : { value }
|
|
6065
|
+
});
|
|
6066
|
+
variadic = option.variadic ? option : undefined;
|
|
6067
|
+
continue;
|
|
6068
|
+
}
|
|
6069
|
+
}
|
|
6070
|
+
if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
|
|
6071
|
+
const option = find(`-${arg[1]}`);
|
|
6072
|
+
if (option) {
|
|
6073
|
+
if (option.required || option.optional) {
|
|
6074
|
+
tokens.push({
|
|
6075
|
+
kind: "option",
|
|
6076
|
+
index,
|
|
6077
|
+
text: arg,
|
|
6078
|
+
option,
|
|
6079
|
+
value: arg.slice(2)
|
|
6080
|
+
});
|
|
6081
|
+
} else {
|
|
6082
|
+
tokens.push({ kind: "option", index, text: arg, option });
|
|
6083
|
+
group = `-${arg.slice(2)}`;
|
|
6084
|
+
groupIndex = index;
|
|
6085
|
+
}
|
|
6086
|
+
continue;
|
|
6087
|
+
}
|
|
6088
|
+
}
|
|
6089
|
+
if (/^--[^=]+=/.test(arg)) {
|
|
6090
|
+
const equals = arg.indexOf("=");
|
|
6091
|
+
const option = find(arg.slice(0, equals));
|
|
6092
|
+
if (option && (option.required || option.optional)) {
|
|
6093
|
+
tokens.push({
|
|
6094
|
+
kind: "option",
|
|
6095
|
+
index,
|
|
6096
|
+
text: arg,
|
|
6097
|
+
option,
|
|
6098
|
+
value: arg.slice(equals + 1)
|
|
6099
|
+
});
|
|
6100
|
+
continue;
|
|
6101
|
+
}
|
|
6102
|
+
}
|
|
6103
|
+
if (maybeOption(arg) && !negativeNumber(arg)) {
|
|
6104
|
+
const equals = arg.startsWith("--") ? arg.indexOf("=") : -1;
|
|
6105
|
+
if (firstUnknown === -1)
|
|
6106
|
+
firstUnknown = index;
|
|
6107
|
+
tokens.push({
|
|
6108
|
+
kind: "unknown",
|
|
6109
|
+
index,
|
|
6110
|
+
text: arg,
|
|
6111
|
+
flag: equals > 0 ? arg.slice(0, equals) : arg,
|
|
6112
|
+
...equals > 0 ? { inlineValue: arg.slice(equals + 1) } : {}
|
|
6113
|
+
});
|
|
6114
|
+
continue;
|
|
6115
|
+
}
|
|
6116
|
+
tokens.push({ kind: "operand", index, text: arg, literal: false });
|
|
6117
|
+
}
|
|
6118
|
+
return { tokens, firstUnknown, sentinel };
|
|
5795
6119
|
}
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
6120
|
+
|
|
6121
|
+
// ../common/src/project-telemetry.ts
|
|
6122
|
+
var RESOLVER = Symbol.for("@uipath/common/projectTelemetryResolver");
|
|
6123
|
+
var CAPTURE = Symbol.for("@uipath/common/projectTelemetryCapture");
|
|
6124
|
+
var CONTEXT_RESOLVER = Symbol.for("@uipath/common/projectContextTelemetryResolver");
|
|
6125
|
+
var RULES = Symbol.for("@uipath/common/projectTargetRules");
|
|
6126
|
+
function logSkipped(what, error) {
|
|
6127
|
+
logger.debug(`[project-telemetry] ${what} skipped: ${error instanceof Error ? error.message : String(error)}`);
|
|
6128
|
+
}
|
|
6129
|
+
function bounded(work, what) {
|
|
6130
|
+
return withinProjectIdentityBudget(work, () => logSkipped(what, `no answer within ${PROJECT_IDENTITY_LOOKUP_BUDGET_MS} ms`));
|
|
6131
|
+
}
|
|
6132
|
+
async function identityWithContext(command, identity) {
|
|
6133
|
+
const props = projectIdentityProperties(identity);
|
|
6134
|
+
if (!identity.projectDirectory || isProjectTelemetryDisabled())
|
|
6135
|
+
return props;
|
|
6136
|
+
for (let node = command;node; node = node.parent ?? undefined) {
|
|
6137
|
+
const resolver = node[CONTEXT_RESOLVER];
|
|
6138
|
+
if (typeof resolver !== "function")
|
|
6139
|
+
continue;
|
|
6140
|
+
try {
|
|
6141
|
+
return {
|
|
6142
|
+
...await resolver(identity.projectDirectory),
|
|
6143
|
+
...props
|
|
6144
|
+
};
|
|
6145
|
+
} catch (error) {
|
|
6146
|
+
logSkipped("solution context lookup", error);
|
|
6147
|
+
return props;
|
|
6148
|
+
}
|
|
5799
6149
|
}
|
|
5800
|
-
return
|
|
5801
|
-
}
|
|
6150
|
+
return props;
|
|
6151
|
+
}
|
|
6152
|
+
function getProjectTelemetryResolver(command) {
|
|
6153
|
+
for (let node = command;node; node = node.parent) {
|
|
6154
|
+
const resolver = node[RESOLVER];
|
|
6155
|
+
if (typeof resolver === "function")
|
|
6156
|
+
return resolver;
|
|
6157
|
+
}
|
|
6158
|
+
return;
|
|
6159
|
+
}
|
|
6160
|
+
function attachProjectTelemetryCapture(command, capture) {
|
|
6161
|
+
command[CAPTURE] = capture;
|
|
6162
|
+
}
|
|
6163
|
+
class ProjectTelemetrySession {
|
|
6164
|
+
resolver;
|
|
6165
|
+
command;
|
|
6166
|
+
target;
|
|
6167
|
+
props = {};
|
|
6168
|
+
explicit = false;
|
|
6169
|
+
input;
|
|
6170
|
+
constructor(resolver, command) {
|
|
6171
|
+
this.resolver = resolver;
|
|
6172
|
+
this.command = command;
|
|
6173
|
+
}
|
|
6174
|
+
async setTarget(path) {
|
|
6175
|
+
this.target = path;
|
|
6176
|
+
if (this.input) {
|
|
6177
|
+
await this.resolve({
|
|
6178
|
+
...this.input,
|
|
6179
|
+
phase: "after",
|
|
6180
|
+
success: true
|
|
6181
|
+
});
|
|
6182
|
+
this.explicit = true;
|
|
6183
|
+
}
|
|
6184
|
+
}
|
|
6185
|
+
async setIdentity(identity) {
|
|
6186
|
+
try {
|
|
6187
|
+
const props = await bounded(identityWithContext(this.command, identity), "project identity capture");
|
|
6188
|
+
if (props !== undefined)
|
|
6189
|
+
this.setProperties(props);
|
|
6190
|
+
} catch (error) {
|
|
6191
|
+
logSkipped("project identity capture", error);
|
|
6192
|
+
}
|
|
6193
|
+
}
|
|
6194
|
+
setProperties(properties) {
|
|
6195
|
+
try {
|
|
6196
|
+
this.props = { ...properties };
|
|
6197
|
+
this.explicit = true;
|
|
6198
|
+
} catch (error) {
|
|
6199
|
+
logSkipped("project identity properties", error);
|
|
6200
|
+
}
|
|
6201
|
+
}
|
|
6202
|
+
properties() {
|
|
6203
|
+
return { ...this.props };
|
|
6204
|
+
}
|
|
6205
|
+
async resolve(input) {
|
|
6206
|
+
this.input = input;
|
|
6207
|
+
if (this.explicit)
|
|
6208
|
+
return;
|
|
6209
|
+
try {
|
|
6210
|
+
const props = await bounded(this.resolver({
|
|
6211
|
+
...input,
|
|
6212
|
+
target: this.target
|
|
6213
|
+
}), `project identity (${input.phase})`);
|
|
6214
|
+
if (props !== undefined) {
|
|
6215
|
+
this.props = props;
|
|
6216
|
+
}
|
|
6217
|
+
} catch (error) {
|
|
6218
|
+
logSkipped(`project identity (${input.phase})`, error);
|
|
6219
|
+
}
|
|
6220
|
+
}
|
|
6221
|
+
}
|
|
5802
6222
|
|
|
5803
6223
|
// ../common/src/telemetry/command-attribution.ts
|
|
5804
6224
|
var LEGACY_SKILL_NAMESPACE = "uipath:";
|
|
@@ -6044,8 +6464,7 @@ var pollSignalSlot = singleton("PollSignal");
|
|
|
6044
6464
|
var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
|
|
6045
6465
|
var processContext = {
|
|
6046
6466
|
exit: (code) => {
|
|
6047
|
-
|
|
6048
|
-
setExitCode(code);
|
|
6467
|
+
recordCommandExit(code);
|
|
6049
6468
|
},
|
|
6050
6469
|
get pollSignal() {
|
|
6051
6470
|
return pollSignalSlot.get();
|
|
@@ -6070,6 +6489,8 @@ function recordableArgValue(value, choices) {
|
|
|
6070
6489
|
function extractCommandParams(cmd) {
|
|
6071
6490
|
const params = {};
|
|
6072
6491
|
forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
|
|
6492
|
+
if (name === undefined)
|
|
6493
|
+
return;
|
|
6073
6494
|
const recordable = recordableArgValue(value, choices);
|
|
6074
6495
|
params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
|
|
6075
6496
|
});
|
|
@@ -6085,7 +6506,8 @@ function isDefaultedPositional(cmd, index) {
|
|
|
6085
6506
|
function forEachSuppliedArgument(cmd, visit) {
|
|
6086
6507
|
const registered = cmd.registeredArguments ?? [];
|
|
6087
6508
|
const processed = cmd.processedArgs ?? [];
|
|
6088
|
-
|
|
6509
|
+
const bound = boundPositionalCount(cmd);
|
|
6510
|
+
for (let i = 0;i < bound; i++) {
|
|
6089
6511
|
const name = registered[i].name();
|
|
6090
6512
|
if (name && processed[i] !== undefined) {
|
|
6091
6513
|
visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
|
|
@@ -6100,6 +6522,71 @@ function forEachSuppliedArgument(cmd, visit) {
|
|
|
6100
6522
|
visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
|
|
6101
6523
|
}
|
|
6102
6524
|
}
|
|
6525
|
+
forEachPassThroughToken(cmd, bound, (name, value) => {
|
|
6526
|
+
visit(name, value, name === undefined ? undefined : choicesByAttribute.get(name), false);
|
|
6527
|
+
});
|
|
6528
|
+
}
|
|
6529
|
+
function boundPositionalCount(cmd) {
|
|
6530
|
+
const registered = cmd.registeredArguments ?? [];
|
|
6531
|
+
if (registered.some((argument) => argument.variadic)) {
|
|
6532
|
+
return registered.length;
|
|
6533
|
+
}
|
|
6534
|
+
if ((cmd.args ?? []).length <= registered.length) {
|
|
6535
|
+
return registered.length;
|
|
6536
|
+
}
|
|
6537
|
+
const firstFlag = tokenizeTail(cmd, (cmd.args ?? []).slice(1)).tokens.find((token) => token.kind !== "operand")?.index ?? -1;
|
|
6538
|
+
return firstFlag === -1 ? registered.length : Math.min(registered.length, firstFlag + 1);
|
|
6539
|
+
}
|
|
6540
|
+
function forEachPassThroughToken(cmd, bound, visit) {
|
|
6541
|
+
const registered = cmd.registeredArguments ?? [];
|
|
6542
|
+
const fillsPositionals = !registered.some((argument) => argument.variadic);
|
|
6543
|
+
const { tokens, firstUnknown } = tokenizeTail(cmd, (cmd.args ?? []).slice(bound));
|
|
6544
|
+
const repeated = new Map;
|
|
6545
|
+
let nextPositional = bound;
|
|
6546
|
+
for (const token of tokens) {
|
|
6547
|
+
const pastUnknown = firstUnknown !== -1 && token.index > firstUnknown;
|
|
6548
|
+
if (token.kind === "sentinel")
|
|
6549
|
+
continue;
|
|
6550
|
+
if (token.kind === "operand") {
|
|
6551
|
+
const claimable = !pastUnknown && fillsPositionals && nextPositional < registered.length;
|
|
6552
|
+
const name = claimable ? registered[nextPositional++].name() : undefined;
|
|
6553
|
+
visit(name || undefined, token.text);
|
|
6554
|
+
continue;
|
|
6555
|
+
}
|
|
6556
|
+
if (token.kind === "unknown") {
|
|
6557
|
+
const bare = token.flag.replace(/^-+/, "");
|
|
6558
|
+
const key = bare.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
6559
|
+
const keyable = token.flag.startsWith("--") || token.flag.length === 2;
|
|
6560
|
+
if (!pastUnknown && keyable && /^[a-z][a-z0-9-]*$/i.test(bare) && key) {
|
|
6561
|
+
visit(key, token.inlineValue ?? true);
|
|
6562
|
+
} else {
|
|
6563
|
+
visit(undefined, token.text);
|
|
6564
|
+
if (token.inlineValue !== undefined) {
|
|
6565
|
+
visit(undefined, token.inlineValue);
|
|
6566
|
+
} else if (!token.flag.startsWith("--") && token.flag.length > 2) {
|
|
6567
|
+
visit(undefined, token.flag.slice(2));
|
|
6568
|
+
}
|
|
6569
|
+
}
|
|
6570
|
+
continue;
|
|
6571
|
+
}
|
|
6572
|
+
if (pastUnknown) {
|
|
6573
|
+
visit(undefined, token.text);
|
|
6574
|
+
if (token.value !== undefined)
|
|
6575
|
+
visit(undefined, token.value);
|
|
6576
|
+
continue;
|
|
6577
|
+
}
|
|
6578
|
+
const option = token.option;
|
|
6579
|
+
const name = option.attributeName();
|
|
6580
|
+
const value = option.negate ? false : option.required || option.optional ? token.value ?? true : true;
|
|
6581
|
+
const previous = repeated.get(name);
|
|
6582
|
+
if (previous) {
|
|
6583
|
+
previous.push(value);
|
|
6584
|
+
visit(name, previous);
|
|
6585
|
+
} else {
|
|
6586
|
+
repeated.set(name, [value]);
|
|
6587
|
+
visit(name, value);
|
|
6588
|
+
}
|
|
6589
|
+
}
|
|
6103
6590
|
}
|
|
6104
6591
|
function withheldArgumentValues(cmd) {
|
|
6105
6592
|
const values = [];
|
|
@@ -6161,6 +6648,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
6161
6648
|
const telemetryName = commandTelemetryName(commandParts);
|
|
6162
6649
|
const commandPath = commandInvocationPath(commandParts);
|
|
6163
6650
|
const props = typeof properties === "function" ? properties(...args) : properties;
|
|
6651
|
+
const projectResolver = getProjectTelemetryResolver(command);
|
|
6652
|
+
const projectSession = projectResolver && !isProjectTelemetryDisabled() ? new ProjectTelemetrySession(projectResolver, command) : undefined;
|
|
6164
6653
|
markCommandStart();
|
|
6165
6654
|
const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
|
|
6166
6655
|
try {
|
|
@@ -6173,6 +6662,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
6173
6662
|
if (violation) {
|
|
6174
6663
|
return Promise.reject(violation);
|
|
6175
6664
|
}
|
|
6665
|
+
if (projectSession) {
|
|
6666
|
+
return projectSession.resolve({ command, args, phase: "before" }).then(() => {
|
|
6667
|
+
attachProjectTelemetryCapture(command, projectSession);
|
|
6668
|
+
return fn(...args);
|
|
6669
|
+
});
|
|
6670
|
+
}
|
|
6176
6671
|
return fn(...args);
|
|
6177
6672
|
}));
|
|
6178
6673
|
if (error) {
|
|
@@ -6181,22 +6676,26 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
6181
6676
|
const typed = error;
|
|
6182
6677
|
const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
|
|
6183
6678
|
const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
|
|
6184
|
-
const
|
|
6679
|
+
const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
|
|
6680
|
+
const classified = cancellationExitCode === undefined ? await extractErrorDetails(error) : undefined;
|
|
6681
|
+
const finalResult = customResult ?? classified?.result ?? RESULTS.Failure;
|
|
6185
6682
|
const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
|
|
6186
6683
|
const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
|
|
6187
6684
|
const typedRetry = typed.retry ?? typed.Retry;
|
|
6188
6685
|
const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
|
|
6189
6686
|
const typedContext = typed.context ?? typed.Context;
|
|
6190
6687
|
const customContext = isErrorContext(typedContext) ? typedContext : undefined;
|
|
6191
|
-
const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
|
|
6192
6688
|
fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
|
|
6689
|
+
const errorCode = customErrorCode ?? classified?.errorCode;
|
|
6690
|
+
const retry = customRetry ?? classified?.retry;
|
|
6691
|
+
const errorContext = customContext ?? classified?.context;
|
|
6193
6692
|
OutputFormatter.error({
|
|
6194
6693
|
Result: finalResult,
|
|
6195
|
-
...
|
|
6694
|
+
...errorCode ? { ErrorCode: errorCode } : {},
|
|
6196
6695
|
Message: errorMessage,
|
|
6197
6696
|
Instructions: customInstructions ?? commandHelpHint(commandPath),
|
|
6198
|
-
...
|
|
6199
|
-
...
|
|
6697
|
+
...retry ? { Retry: retry } : {},
|
|
6698
|
+
...errorContext ? { Context: errorContext } : {}
|
|
6200
6699
|
});
|
|
6201
6700
|
context.exit(fallbackExitCode);
|
|
6202
6701
|
}
|
|
@@ -6205,6 +6704,14 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
6205
6704
|
const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
|
|
6206
6705
|
const recordedFailure = takeRecordedCommandFailureTelemetry();
|
|
6207
6706
|
const success = !error && exitCode === 0;
|
|
6707
|
+
if (projectSession) {
|
|
6708
|
+
await projectSession.resolve({
|
|
6709
|
+
command,
|
|
6710
|
+
args,
|
|
6711
|
+
phase: "after",
|
|
6712
|
+
success
|
|
6713
|
+
});
|
|
6714
|
+
}
|
|
6208
6715
|
const terminalTelemetry = buildCommandTerminalTelemetryProperties({
|
|
6209
6716
|
error,
|
|
6210
6717
|
exitCode,
|
|
@@ -6222,6 +6729,7 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
6222
6729
|
}
|
|
6223
6730
|
const baseProperties = redactProperties({
|
|
6224
6731
|
...commandParams,
|
|
6732
|
+
...projectSession?.properties(),
|
|
6225
6733
|
...props,
|
|
6226
6734
|
...buildCommandTelemetryAttribution(commandPath, process.env.UIPATH_SKILL),
|
|
6227
6735
|
...buildAgentSessionTelemetry(process.env),
|
|
@@ -6232,6 +6740,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
6232
6740
|
});
|
|
6233
6741
|
emitInvocationRequest(telemetryName, success, baseProperties);
|
|
6234
6742
|
} finally {
|
|
6743
|
+
if (projectSession)
|
|
6744
|
+
attachProjectTelemetryCapture(command, undefined);
|
|
6235
6745
|
releaseSuppliedArgumentValues(supplied);
|
|
6236
6746
|
}
|
|
6237
6747
|
});
|
|
@@ -6441,75 +6951,6 @@ var RESERVED_KEYWORDS_LOWER = new Set([
|
|
|
6441
6951
|
"writeonly",
|
|
6442
6952
|
"xor"
|
|
6443
6953
|
]);
|
|
6444
|
-
// ../common/src/error-instructions.ts
|
|
6445
|
-
function extractHttpStatus(err) {
|
|
6446
|
-
if (!err || typeof err !== "object")
|
|
6447
|
-
return;
|
|
6448
|
-
const e = err;
|
|
6449
|
-
const structured = e.response?.status ?? e.status ?? e.statusCode;
|
|
6450
|
-
if (structured !== undefined)
|
|
6451
|
-
return structured;
|
|
6452
|
-
return typeof e.message === "string" ? parseHttpStatusFromMessage(e.message) : undefined;
|
|
6453
|
-
}
|
|
6454
|
-
var GENERIC = "Check authentication and parameters";
|
|
6455
|
-
function instructionsFor(ctx, err) {
|
|
6456
|
-
switch (ctx) {
|
|
6457
|
-
case "auth":
|
|
6458
|
-
return "Run 'uip login' to authenticate. To inspect the current session, run 'uip whoami'.";
|
|
6459
|
-
case "identity":
|
|
6460
|
-
return "Select an active tenant with 'uip login tenant set <tenant>' and ensure your login includes an organization";
|
|
6461
|
-
case "input-parse":
|
|
6462
|
-
return "Ensure --inputs is valid JSON or pipe JSON via stdin";
|
|
6463
|
-
case "input-validate":
|
|
6464
|
-
return "Fix the flagged input fields to match the process's input schema";
|
|
6465
|
-
case "flag-format":
|
|
6466
|
-
return "Check the flag value format — see --help for the expected shape";
|
|
6467
|
-
case "permissions":
|
|
6468
|
-
return "Confirm your user has the required permissions in this folder/tenant, or re-authenticate with 'uip login' if your session has lapsed";
|
|
6469
|
-
case "backend": {
|
|
6470
|
-
const status = extractHttpStatus(err);
|
|
6471
|
-
if (status === 401) {
|
|
6472
|
-
return "Re-authenticate with 'uip login' — your session is invalid or expired";
|
|
6473
|
-
}
|
|
6474
|
-
if (status === 403) {
|
|
6475
|
-
return "Confirm your user has access to the resource, and the required permissions in this folder or tenant";
|
|
6476
|
-
}
|
|
6477
|
-
if (status === 404) {
|
|
6478
|
-
return "Verify the resource exists in the current folder/tenant";
|
|
6479
|
-
}
|
|
6480
|
-
if (status === 400 || status === 422) {
|
|
6481
|
-
return "Request was rejected — check flag values and inputs";
|
|
6482
|
-
}
|
|
6483
|
-
if (status === 405) {
|
|
6484
|
-
return "Check the command name and the base URL in use — the endpoint may not exist";
|
|
6485
|
-
}
|
|
6486
|
-
if (status === 408) {
|
|
6487
|
-
return "The request timed out — retry; if it persists, narrow the request (e.g. --limit on list commands)";
|
|
6488
|
-
}
|
|
6489
|
-
if (status === 409) {
|
|
6490
|
-
return "The resource already exists, or changed since it was read — list it to see the current state";
|
|
6491
|
-
}
|
|
6492
|
-
if (status === 413) {
|
|
6493
|
-
return "The upload is over the size limit — exclude unused dependencies or drop large files, then retry";
|
|
6494
|
-
}
|
|
6495
|
-
if (status === 429) {
|
|
6496
|
-
return "Rate limit reached — wait and retry; when the service suggests a delay, Retry and Context.retryAfter carry it";
|
|
6497
|
-
}
|
|
6498
|
-
if (status !== undefined && status >= 500 && status < 600) {
|
|
6499
|
-
return "The service returned a server error — retry; if it persists, check service status";
|
|
6500
|
-
}
|
|
6501
|
-
const permission = describePermissionError(err);
|
|
6502
|
-
if (permission) {
|
|
6503
|
-
return permission.instructions;
|
|
6504
|
-
}
|
|
6505
|
-
const connectivity = describeConnectivityError(err);
|
|
6506
|
-
if (connectivity) {
|
|
6507
|
-
return connectivity.instructions;
|
|
6508
|
-
}
|
|
6509
|
-
return GENERIC;
|
|
6510
|
-
}
|
|
6511
|
-
}
|
|
6512
|
-
}
|
|
6513
6954
|
// ../common/src/host-global-options.ts
|
|
6514
6955
|
var HOST_GLOBAL_OPTIONS_WITH_VALUE = [
|
|
6515
6956
|
"--output",
|
|
@@ -6528,6 +6969,40 @@ var BOOLEAN_FLAGS = new Set(HOST_GLOBAL_FLAGS);
|
|
|
6528
6969
|
// ../common/src/interactivity-context.ts
|
|
6529
6970
|
var modeSlot = singleton("InteractivityMode");
|
|
6530
6971
|
var interactiveFlagSlot = singleton("InteractiveFlag");
|
|
6972
|
+
// ../common/src/mime-types.ts
|
|
6973
|
+
var MIME_TYPES_BY_EXTENSION = Object.freeze({
|
|
6974
|
+
pdf: "application/pdf",
|
|
6975
|
+
png: "image/png",
|
|
6976
|
+
jpg: "image/jpeg",
|
|
6977
|
+
jpeg: "image/jpeg",
|
|
6978
|
+
gif: "image/gif",
|
|
6979
|
+
webp: "image/webp",
|
|
6980
|
+
bmp: "image/bmp",
|
|
6981
|
+
tif: "image/tiff",
|
|
6982
|
+
tiff: "image/tiff",
|
|
6983
|
+
svg: "image/svg+xml",
|
|
6984
|
+
txt: "text/plain",
|
|
6985
|
+
log: "text/plain",
|
|
6986
|
+
md: "text/markdown",
|
|
6987
|
+
csv: "text/csv",
|
|
6988
|
+
tsv: "text/tab-separated-values",
|
|
6989
|
+
json: "application/json",
|
|
6990
|
+
xml: "application/xml",
|
|
6991
|
+
html: "text/html",
|
|
6992
|
+
htm: "text/html",
|
|
6993
|
+
yaml: "application/yaml",
|
|
6994
|
+
yml: "application/yaml",
|
|
6995
|
+
doc: "application/msword",
|
|
6996
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
6997
|
+
xls: "application/vnd.ms-excel",
|
|
6998
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
6999
|
+
ppt: "application/vnd.ms-powerpoint",
|
|
7000
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
7001
|
+
zip: "application/zip",
|
|
7002
|
+
mp3: "audio/mpeg",
|
|
7003
|
+
wav: "audio/wav",
|
|
7004
|
+
mp4: "video/mp4"
|
|
7005
|
+
});
|
|
6531
7006
|
// ../common/src/polling/types.ts
|
|
6532
7007
|
var PollOutcome = {
|
|
6533
7008
|
Completed: "completed",
|
|
@@ -6795,9 +7270,9 @@ function getProfileStorage() {
|
|
|
6795
7270
|
if (isAuthProfileStorage(existing)) {
|
|
6796
7271
|
return existing;
|
|
6797
7272
|
}
|
|
6798
|
-
const
|
|
6799
|
-
globalSlot[AUTH_PROFILE_STORAGE_KEY] =
|
|
6800
|
-
return
|
|
7273
|
+
const storage = createProfileStorage();
|
|
7274
|
+
globalSlot[AUTH_PROFILE_STORAGE_KEY] = storage;
|
|
7275
|
+
return storage;
|
|
6801
7276
|
}
|
|
6802
7277
|
var profileStorage = getProfileStorage();
|
|
6803
7278
|
|
|
@@ -6828,8 +7303,8 @@ function resolveAuthProfileFilePath(profile) {
|
|
|
6828
7303
|
if (normalized === undefined) {
|
|
6829
7304
|
throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
|
|
6830
7305
|
}
|
|
6831
|
-
const
|
|
6832
|
-
return
|
|
7306
|
+
const fs = getFileSystem();
|
|
7307
|
+
return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
|
|
6833
7308
|
}
|
|
6834
7309
|
function getActiveAuthProfileFilePath() {
|
|
6835
7310
|
const profile = getActiveAuthProfile();
|
|
@@ -6936,6 +7411,8 @@ var ENV_AUTH_VARS = {
|
|
|
6936
7411
|
};
|
|
6937
7412
|
|
|
6938
7413
|
class EnvAuthConfigError extends Error {
|
|
7414
|
+
errorCode = "configuration_error";
|
|
7415
|
+
retry = "RetryWillNotFix";
|
|
6939
7416
|
constructor(message) {
|
|
6940
7417
|
super(message);
|
|
6941
7418
|
this.name = "EnvAuthConfigError";
|
|
@@ -6974,11 +7451,11 @@ var readAuthFromEnv = () => {
|
|
|
6974
7451
|
if (!rawUrl) {
|
|
6975
7452
|
throw new EnvAuthConfigError(`${ENV_AUTH_VARS.token} is not a JWT (treating it as an opaque token, ` + `e.g. a Personal Access Token). Set ${OPAQUE_TOKEN_BASE_URL_VAR} to the ` + `UiPath base URL if this is a PAT, or fix the token if it was meant to ` + `be a JWT (parse error: ${parseErrorMessage}).`);
|
|
6976
7453
|
}
|
|
6977
|
-
const
|
|
7454
|
+
const baseUrl = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
|
|
6978
7455
|
return {
|
|
6979
7456
|
loginStatus: "Logged in",
|
|
6980
7457
|
accessToken,
|
|
6981
|
-
baseUrl
|
|
7458
|
+
baseUrl,
|
|
6982
7459
|
organizationName,
|
|
6983
7460
|
organizationId,
|
|
6984
7461
|
tenantName,
|
|
@@ -7019,8 +7496,8 @@ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
|
|
|
7019
7496
|
async function refreshTokenFingerprint(refreshToken) {
|
|
7020
7497
|
const bytes = new TextEncoder().encode(refreshToken);
|
|
7021
7498
|
if (globalThis.crypto?.subtle) {
|
|
7022
|
-
const
|
|
7023
|
-
return Array.from(new Uint8Array(
|
|
7499
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
7500
|
+
return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
|
|
7024
7501
|
}
|
|
7025
7502
|
const { createHash } = await import("node:crypto");
|
|
7026
7503
|
return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
@@ -7029,9 +7506,9 @@ function breakerPathFor(authPath) {
|
|
|
7029
7506
|
return `${authPath}${BREAKER_SUFFIX}`;
|
|
7030
7507
|
}
|
|
7031
7508
|
async function loadRefreshBreaker(authPath) {
|
|
7032
|
-
const
|
|
7509
|
+
const fs = getFileSystem();
|
|
7033
7510
|
try {
|
|
7034
|
-
const content = await
|
|
7511
|
+
const content = await fs.readFile(breakerPathFor(authPath), "utf-8");
|
|
7035
7512
|
if (!content)
|
|
7036
7513
|
return {};
|
|
7037
7514
|
const parsed = JSON.parse(content);
|
|
@@ -7042,20 +7519,20 @@ async function loadRefreshBreaker(authPath) {
|
|
|
7042
7519
|
}
|
|
7043
7520
|
async function saveRefreshBreaker(authPath, state) {
|
|
7044
7521
|
try {
|
|
7045
|
-
const
|
|
7046
|
-
const
|
|
7047
|
-
await
|
|
7048
|
-
const tempPath = `${
|
|
7049
|
-
await
|
|
7050
|
-
await
|
|
7522
|
+
const fs = getFileSystem();
|
|
7523
|
+
const path = breakerPathFor(authPath);
|
|
7524
|
+
await fs.mkdir(fs.path.dirname(path));
|
|
7525
|
+
const tempPath = `${path}.tmp`;
|
|
7526
|
+
await fs.writeFile(tempPath, JSON.stringify(state));
|
|
7527
|
+
await fs.rename(tempPath, path);
|
|
7051
7528
|
} catch {}
|
|
7052
7529
|
}
|
|
7053
7530
|
async function clearRefreshBreaker(authPath) {
|
|
7054
|
-
const
|
|
7055
|
-
const
|
|
7531
|
+
const fs = getFileSystem();
|
|
7532
|
+
const path = breakerPathFor(authPath);
|
|
7056
7533
|
try {
|
|
7057
|
-
if (await
|
|
7058
|
-
await
|
|
7534
|
+
if (await fs.exists(path)) {
|
|
7535
|
+
await fs.rm(path);
|
|
7059
7536
|
}
|
|
7060
7537
|
} catch {}
|
|
7061
7538
|
}
|
|
@@ -7076,13 +7553,13 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
|
7076
7553
|
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
7077
7554
|
var PIPE_NAME_MAX_LENGTH = 103;
|
|
7078
7555
|
var getRobotIpcPipeNames = async () => {
|
|
7079
|
-
const
|
|
7080
|
-
const username =
|
|
7556
|
+
const fs = getFileSystem();
|
|
7557
|
+
const username = fs.env.getenv("USER") ?? fs.env.getenv("USERNAME");
|
|
7081
7558
|
if (!username) {
|
|
7082
7559
|
throw new Error("Unable to determine current username");
|
|
7083
7560
|
}
|
|
7084
|
-
const tempPath =
|
|
7085
|
-
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) =>
|
|
7561
|
+
const tempPath = fs.env.getenv("TMPDIR") ?? "/tmp/";
|
|
7562
|
+
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
|
|
7086
7563
|
};
|
|
7087
7564
|
var defaultIsRobotIpcAvailable = async () => {
|
|
7088
7565
|
if (process.platform === "win32") {
|
|
@@ -7092,20 +7569,20 @@ var defaultIsRobotIpcAvailable = async () => {
|
|
|
7092
7569
|
if (pipeNamesError || !pipeNames) {
|
|
7093
7570
|
return false;
|
|
7094
7571
|
}
|
|
7095
|
-
const
|
|
7572
|
+
const fs = getFileSystem();
|
|
7096
7573
|
for (const pipeName of pipeNames) {
|
|
7097
|
-
const [existsError, exists] = await catchError2(
|
|
7574
|
+
const [existsError, exists] = await catchError2(fs.exists(pipeName));
|
|
7098
7575
|
if (!existsError && exists === true) {
|
|
7099
7576
|
return true;
|
|
7100
7577
|
}
|
|
7101
7578
|
}
|
|
7102
7579
|
return false;
|
|
7103
7580
|
};
|
|
7104
|
-
var withTimeout = (promise, timeoutMs) => new Promise((
|
|
7581
|
+
var withTimeout = (promise, timeoutMs) => new Promise((resolve, reject) => {
|
|
7105
7582
|
const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
7106
7583
|
promise.then((value) => {
|
|
7107
7584
|
clearTimeout(timer);
|
|
7108
|
-
|
|
7585
|
+
resolve(value);
|
|
7109
7586
|
}, (error) => {
|
|
7110
7587
|
clearTimeout(timer);
|
|
7111
7588
|
reject(error);
|
|
@@ -7278,9 +7755,12 @@ var refreshAccessToken = async ({
|
|
|
7278
7755
|
body: tokenParams
|
|
7279
7756
|
});
|
|
7280
7757
|
const tokenData = await tokenResponse.json();
|
|
7281
|
-
if (
|
|
7758
|
+
if (tokenResponse.status === 400 || tokenResponse.status === 401) {
|
|
7282
7759
|
throw new TokenRefreshOAuthError;
|
|
7283
7760
|
}
|
|
7761
|
+
if (!tokenResponse.ok) {
|
|
7762
|
+
throw new Error(`Token refresh failed: HTTP ${tokenResponse.status}`);
|
|
7763
|
+
}
|
|
7284
7764
|
const newAccessToken = tokenData.access_token;
|
|
7285
7765
|
const newRefreshToken = tokenData.refresh_token;
|
|
7286
7766
|
if (typeof newAccessToken !== "string" || typeof newRefreshToken !== "string") {
|
|
@@ -7312,9 +7792,9 @@ var errorCode = (err) => {
|
|
|
7312
7792
|
}
|
|
7313
7793
|
return "EUNKNOWN";
|
|
7314
7794
|
};
|
|
7315
|
-
var probeAsync = async (
|
|
7795
|
+
var probeAsync = async (fs, candidate) => {
|
|
7316
7796
|
try {
|
|
7317
|
-
const stats = await
|
|
7797
|
+
const stats = await fs.stat(candidate);
|
|
7318
7798
|
if (stats === null) {
|
|
7319
7799
|
return { exists: false };
|
|
7320
7800
|
}
|
|
@@ -7341,36 +7821,36 @@ var probeAsync = async (fs2, candidate) => {
|
|
|
7341
7821
|
}
|
|
7342
7822
|
};
|
|
7343
7823
|
var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
|
|
7344
|
-
const
|
|
7345
|
-
if (
|
|
7346
|
-
const
|
|
7347
|
-
return
|
|
7824
|
+
const fs = getFileSystem();
|
|
7825
|
+
if (fs.path.isAbsolute(envFilePath)) {
|
|
7826
|
+
const probe = await probeAsync(fs, envFilePath);
|
|
7827
|
+
return probe.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
|
|
7348
7828
|
exists: false,
|
|
7349
7829
|
absolutePath: envFilePath,
|
|
7350
7830
|
source: "absolute",
|
|
7351
|
-
...
|
|
7831
|
+
...probe.unusable ? { unusable: probe.unusable } : {}
|
|
7352
7832
|
};
|
|
7353
7833
|
}
|
|
7354
|
-
const cwd = opts?.cwd ??
|
|
7834
|
+
const cwd = opts?.cwd ?? fs.env.cwd();
|
|
7355
7835
|
let searchDir = cwd;
|
|
7356
7836
|
while (true) {
|
|
7357
|
-
const candidate =
|
|
7358
|
-
const
|
|
7359
|
-
if (
|
|
7837
|
+
const candidate = fs.path.join(searchDir, envFilePath);
|
|
7838
|
+
const probe = await probeAsync(fs, candidate);
|
|
7839
|
+
if (probe.exists) {
|
|
7360
7840
|
return {
|
|
7361
7841
|
exists: true,
|
|
7362
7842
|
absolutePath: candidate,
|
|
7363
7843
|
source: searchDir === cwd ? "cwd" : "ancestor"
|
|
7364
7844
|
};
|
|
7365
7845
|
}
|
|
7366
|
-
const parentDir =
|
|
7846
|
+
const parentDir = fs.path.dirname(searchDir);
|
|
7367
7847
|
if (parentDir === searchDir) {
|
|
7368
7848
|
break;
|
|
7369
7849
|
}
|
|
7370
7850
|
searchDir = parentDir;
|
|
7371
7851
|
}
|
|
7372
|
-
const homePath =
|
|
7373
|
-
const probe = await probeAsync(
|
|
7852
|
+
const homePath = fs.path.join(fs.env.homedir(), envFilePath);
|
|
7853
|
+
const probe = await probeAsync(fs, homePath);
|
|
7374
7854
|
if (probe.exists) {
|
|
7375
7855
|
return { exists: true, absolutePath: homePath, source: "home" };
|
|
7376
7856
|
}
|
|
@@ -7413,12 +7893,12 @@ var parseEnvContent = (content) => {
|
|
|
7413
7893
|
return env;
|
|
7414
7894
|
};
|
|
7415
7895
|
var loadEnvFileAsync = async ({ envPath }) => {
|
|
7416
|
-
const
|
|
7417
|
-
const absolutePath =
|
|
7418
|
-
if (!await
|
|
7896
|
+
const fs = getFileSystem();
|
|
7897
|
+
const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.cwd(), envPath);
|
|
7898
|
+
if (!await fs.exists(absolutePath)) {
|
|
7419
7899
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
7420
7900
|
}
|
|
7421
|
-
const content = await
|
|
7901
|
+
const content = await fs.readFile(absolutePath, "utf-8");
|
|
7422
7902
|
if (content === null) {
|
|
7423
7903
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
7424
7904
|
}
|
|
@@ -7429,10 +7909,10 @@ var saveEnvFileAsync = async ({
|
|
|
7429
7909
|
data,
|
|
7430
7910
|
merge = true
|
|
7431
7911
|
}) => {
|
|
7432
|
-
const
|
|
7433
|
-
const absolutePath =
|
|
7912
|
+
const fs = getFileSystem();
|
|
7913
|
+
const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.homedir(), envPath);
|
|
7434
7914
|
let existingData = {};
|
|
7435
|
-
if (merge && await
|
|
7915
|
+
if (merge && await fs.exists(absolutePath)) {
|
|
7436
7916
|
try {
|
|
7437
7917
|
existingData = await loadEnvFileAsync({ envPath: absolutePath });
|
|
7438
7918
|
} catch {}
|
|
@@ -7450,11 +7930,11 @@ var saveEnvFileAsync = async ({
|
|
|
7450
7930
|
const content = `${lines.join(`
|
|
7451
7931
|
`)}
|
|
7452
7932
|
`;
|
|
7453
|
-
const dir =
|
|
7454
|
-
await
|
|
7933
|
+
const dir = fs.path.dirname(absolutePath);
|
|
7934
|
+
await fs.mkdir(dir);
|
|
7455
7935
|
const tempPath = `${absolutePath}.tmp`;
|
|
7456
|
-
await
|
|
7457
|
-
await
|
|
7936
|
+
await fs.writeFile(tempPath, content);
|
|
7937
|
+
await fs.rename(tempPath, absolutePath);
|
|
7458
7938
|
};
|
|
7459
7939
|
|
|
7460
7940
|
// ../auth/src/loginStatus.ts
|
|
@@ -7578,11 +8058,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
|
|
|
7578
8058
|
return { credentials };
|
|
7579
8059
|
}
|
|
7580
8060
|
async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
|
|
7581
|
-
const
|
|
7582
|
-
const globalPath =
|
|
8061
|
+
const fs = getFs();
|
|
8062
|
+
const globalPath = fs.path.join(fs.env.homedir(), envFilePath);
|
|
7583
8063
|
if (absolutePath === globalPath)
|
|
7584
8064
|
return;
|
|
7585
|
-
if (!await
|
|
8065
|
+
if (!await fs.exists(globalPath))
|
|
7586
8066
|
return;
|
|
7587
8067
|
try {
|
|
7588
8068
|
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
@@ -7999,26 +8479,38 @@ function errorMessage(error) {
|
|
|
7999
8479
|
}
|
|
8000
8480
|
|
|
8001
8481
|
// ../auth/src/authContext.ts
|
|
8482
|
+
class AuthContextUnavailableError extends Error {
|
|
8483
|
+
instructionContext;
|
|
8484
|
+
sessionHint;
|
|
8485
|
+
errorCode = "authentication_required";
|
|
8486
|
+
retry = "RetryWillNotFix";
|
|
8487
|
+
constructor(message, instructionContext = "auth", sessionHint) {
|
|
8488
|
+
super(message);
|
|
8489
|
+
this.instructionContext = instructionContext;
|
|
8490
|
+
this.sessionHint = sessionHint;
|
|
8491
|
+
this.name = "AuthContextUnavailableError";
|
|
8492
|
+
}
|
|
8493
|
+
}
|
|
8002
8494
|
var getAuthContext = async (options = {}) => {
|
|
8003
8495
|
const status = await getLoginStatusAsync({
|
|
8004
8496
|
ensureTokenValidityMinutes: options.ensureTokenValidityMinutes,
|
|
8005
8497
|
envFilePath: options.envFilePath
|
|
8006
8498
|
});
|
|
8007
8499
|
if (status.loginStatus !== "Logged in" || !status.baseUrl || !status.accessToken) {
|
|
8008
|
-
throw new
|
|
8500
|
+
throw new AuthContextUnavailableError(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.", "auth", status.hint);
|
|
8009
8501
|
}
|
|
8010
|
-
const tenantName = options.tenant
|
|
8502
|
+
const tenantName = options.tenant || status.tenantName;
|
|
8011
8503
|
if (options.requireOrganizationId && !status.organizationId) {
|
|
8012
|
-
throw new
|
|
8504
|
+
throw new AuthContextUnavailableError("Organization ID not available. Ensure you are logged in with an organization context.", "identity");
|
|
8013
8505
|
}
|
|
8014
8506
|
if (options.requireOrganizationName && !status.organizationName) {
|
|
8015
|
-
throw new
|
|
8507
|
+
throw new AuthContextUnavailableError("Organization name not available. Ensure you are logged in with an organization context.", "identity");
|
|
8016
8508
|
}
|
|
8017
8509
|
if (options.requireTenantId && !status.tenantId) {
|
|
8018
|
-
throw new
|
|
8510
|
+
throw new AuthContextUnavailableError(`Tenant ID not available. Ensure UIPATH_TENANT_ID is set.${status.hint ? ` ${status.hint}` : ""}`, "identity", status.hint);
|
|
8019
8511
|
}
|
|
8020
|
-
if (options.requireTenantName && tenantName
|
|
8021
|
-
throw new
|
|
8512
|
+
if (options.requireTenantName && !tenantName) {
|
|
8513
|
+
throw new AuthContextUnavailableError("Tenant not provided and UIPATH_TENANT_NAME not set. Run 'uip login' to select a tenant, or use 'uip login tenant set <tenant>' to switch tenants.", "identity");
|
|
8022
8514
|
}
|
|
8023
8515
|
return {
|
|
8024
8516
|
baseUrl: status.baseUrl,
|
|
@@ -8037,6 +8529,6 @@ var TENANT_SELECTION_CODES = new Set([
|
|
|
8037
8529
|
TENANT_SELECTION_REQUIRED_CODE,
|
|
8038
8530
|
INVALID_TENANT_CODE
|
|
8039
8531
|
]);
|
|
8040
|
-
export { catchError, carriedInstructions, extractErrorDetails, extractErrorMessage,
|
|
8532
|
+
export { catchError, carriedInstructions, extractErrorDetails, extractErrorMessage, instructionsFor, RESULTS, Command, Pagination, OutputFormatter, processContext, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, resolveSessionIdentity, getAuthContext };
|
|
8041
8533
|
|
|
8042
|
-
//# debugId=
|
|
8534
|
+
//# debugId=0E2905B9952C06F364756E2164756E21
|