@uipath/eval-tool 1.203.0-preview.203 → 1.204.0-preview.206
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD-PARTY-NOTICES.md +323 -0
- package/dist/{index-nzr4mx5p.js → index-sby22td6.js} +22 -2
- package/dist/index-ynehe0js.js +39451 -0
- package/dist/index.js +9 -8
- package/dist/{jmespath-ab6tdc42.js → jmespath-231m3hyn.js} +1 -1
- package/dist/{js-yaml-a2bk27p6.js → js-yaml-88tdqrtd.js} +3 -1
- package/dist/{tool-epsr41wx.js → tool-1de529jm.js} +3 -12
- package/dist/{tool-r9mtm8ew.js → tool-80vkb32z.js} +76 -31
- package/dist/{tool-9wbdx38t.js → tool-jpgd82xt.js} +1809 -1343
- package/dist/tool.js +8 -7
- package/package.json +2 -10
- package/dist/index-0ccvrrm4.js +0 -692
- package/dist/index-24qchvk6.js +0 -686
- package/dist/index-5n3avrgd.js +0 -686
- package/dist/index-79k4yaq0.js +0 -692
- package/dist/tool-4dvyv6d3.js +0 -1593
- package/dist/tool-hmrrz4ws.js +0 -1593
- package/dist/tool-pa6awsya.js +0 -7379
- package/dist/tool-qgxwdxzs.js +0 -7407
- package/dist/tool-s9nrxyrx.js +0 -7407
- package/dist/tool-wpdw8g6y.js +0 -1593
- package/dist/tool-y87tv8gm.js +0 -1593
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
__toESM,
|
|
3
2
|
__commonJS,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "./tool-
|
|
3
|
+
__require,
|
|
4
|
+
__toESM
|
|
5
|
+
} from "./tool-1de529jm.js";
|
|
7
6
|
|
|
8
7
|
// ../../node_modules/commander/lib/error.js
|
|
9
8
|
var require_error = __commonJS(function(exports) {
|
|
@@ -125,7 +124,7 @@ var require_help = __commonJS(function(exports) {
|
|
|
125
124
|
this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
|
|
126
125
|
}
|
|
127
126
|
visibleCommands(cmd) {
|
|
128
|
-
const visibleCommands = cmd.commands.filter((
|
|
127
|
+
const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
|
|
129
128
|
const helpCommand = cmd._getHelpCommand();
|
|
130
129
|
if (helpCommand && !helpCommand._hidden) {
|
|
131
130
|
visibleCommands.push(helpCommand);
|
|
@@ -605,8 +604,8 @@ var require_option = __commonJS(function(exports) {
|
|
|
605
604
|
}
|
|
606
605
|
}
|
|
607
606
|
function camelcase(str) {
|
|
608
|
-
return str.split("-").reduce((
|
|
609
|
-
return
|
|
607
|
+
return str.split("-").reduce((str2, word) => {
|
|
608
|
+
return str2 + word[0].toUpperCase() + word.slice(1);
|
|
610
609
|
});
|
|
611
610
|
}
|
|
612
611
|
function splitOptionFlags(flags) {
|
|
@@ -1177,44 +1176,44 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1177
1176
|
});
|
|
1178
1177
|
return source;
|
|
1179
1178
|
}
|
|
1180
|
-
_prepareUserArgs(
|
|
1181
|
-
if (
|
|
1179
|
+
_prepareUserArgs(argv, parseOptions) {
|
|
1180
|
+
if (argv !== undefined && !Array.isArray(argv)) {
|
|
1182
1181
|
throw new Error("first parameter to parse must be array or undefined");
|
|
1183
1182
|
}
|
|
1184
1183
|
parseOptions = parseOptions || {};
|
|
1185
|
-
if (
|
|
1184
|
+
if (argv === undefined && parseOptions.from === undefined) {
|
|
1186
1185
|
if (process2.versions?.electron) {
|
|
1187
1186
|
parseOptions.from = "electron";
|
|
1188
1187
|
}
|
|
1189
|
-
const
|
|
1190
|
-
if (
|
|
1188
|
+
const execArgv = process2.execArgv ?? [];
|
|
1189
|
+
if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
|
|
1191
1190
|
parseOptions.from = "eval";
|
|
1192
1191
|
}
|
|
1193
1192
|
}
|
|
1194
|
-
if (
|
|
1195
|
-
|
|
1193
|
+
if (argv === undefined) {
|
|
1194
|
+
argv = process2.argv;
|
|
1196
1195
|
}
|
|
1197
|
-
this.rawArgs =
|
|
1196
|
+
this.rawArgs = argv.slice();
|
|
1198
1197
|
let userArgs;
|
|
1199
1198
|
switch (parseOptions.from) {
|
|
1200
1199
|
case undefined:
|
|
1201
1200
|
case "node":
|
|
1202
|
-
this._scriptPath =
|
|
1203
|
-
userArgs =
|
|
1201
|
+
this._scriptPath = argv[1];
|
|
1202
|
+
userArgs = argv.slice(2);
|
|
1204
1203
|
break;
|
|
1205
1204
|
case "electron":
|
|
1206
1205
|
if (process2.defaultApp) {
|
|
1207
|
-
this._scriptPath =
|
|
1208
|
-
userArgs =
|
|
1206
|
+
this._scriptPath = argv[1];
|
|
1207
|
+
userArgs = argv.slice(2);
|
|
1209
1208
|
} else {
|
|
1210
|
-
userArgs =
|
|
1209
|
+
userArgs = argv.slice(1);
|
|
1211
1210
|
}
|
|
1212
1211
|
break;
|
|
1213
1212
|
case "user":
|
|
1214
|
-
userArgs =
|
|
1213
|
+
userArgs = argv.slice(0);
|
|
1215
1214
|
break;
|
|
1216
1215
|
case "eval":
|
|
1217
|
-
userArgs =
|
|
1216
|
+
userArgs = argv.slice(1);
|
|
1218
1217
|
break;
|
|
1219
1218
|
default:
|
|
1220
1219
|
throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
|
|
@@ -1737,18 +1736,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1737
1736
|
this.error(message, { code: "commander.missingMandatoryOptionValue" });
|
|
1738
1737
|
}
|
|
1739
1738
|
_conflictingOption(option, conflictingOption) {
|
|
1740
|
-
const findBestOptionFromValue = (
|
|
1741
|
-
const optionKey =
|
|
1739
|
+
const findBestOptionFromValue = (option2) => {
|
|
1740
|
+
const optionKey = option2.attributeName();
|
|
1742
1741
|
const optionValue = this.getOptionValue(optionKey);
|
|
1743
1742
|
const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
|
|
1744
1743
|
const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
|
|
1745
1744
|
if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) {
|
|
1746
1745
|
return negativeOption;
|
|
1747
1746
|
}
|
|
1748
|
-
return positiveOption ||
|
|
1747
|
+
return positiveOption || option2;
|
|
1749
1748
|
};
|
|
1750
|
-
const getErrorMessage = (
|
|
1751
|
-
const bestOption = findBestOptionFromValue(
|
|
1749
|
+
const getErrorMessage = (option2) => {
|
|
1750
|
+
const bestOption = findBestOptionFromValue(option2);
|
|
1752
1751
|
const optionKey = bestOption.attributeName();
|
|
1753
1752
|
const source = this.getOptionValueSource(optionKey);
|
|
1754
1753
|
if (source === "env") {
|
|
@@ -1902,10 +1901,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1902
1901
|
this._name = path.basename(filename, path.extname(filename));
|
|
1903
1902
|
return this;
|
|
1904
1903
|
}
|
|
1905
|
-
executableDir(
|
|
1906
|
-
if (
|
|
1904
|
+
executableDir(path2) {
|
|
1905
|
+
if (path2 === undefined)
|
|
1907
1906
|
return this._executableDir;
|
|
1908
|
-
this._executableDir =
|
|
1907
|
+
this._executableDir = path2;
|
|
1909
1908
|
return this;
|
|
1910
1909
|
}
|
|
1911
1910
|
helpInformation(contextOptions) {
|
|
@@ -2002,11 +2001,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2002
2001
|
}
|
|
2003
2002
|
help(contextOptions) {
|
|
2004
2003
|
this.outputHelp(contextOptions);
|
|
2005
|
-
let
|
|
2006
|
-
if (
|
|
2007
|
-
|
|
2004
|
+
let exitCode = Number(process2.exitCode ?? 0);
|
|
2005
|
+
if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
|
|
2006
|
+
exitCode = 1;
|
|
2008
2007
|
}
|
|
2009
|
-
this._exit(
|
|
2008
|
+
this._exit(exitCode, "commander.help", "(outputHelp)");
|
|
2010
2009
|
}
|
|
2011
2010
|
addHelpText(position, text) {
|
|
2012
2011
|
const allowedValues = ["beforeAll", "before", "after", "afterAll"];
|
|
@@ -2079,63 +2078,206 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2079
2078
|
});
|
|
2080
2079
|
|
|
2081
2080
|
// ../../node_modules/commander/index.js
|
|
2082
|
-
var
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
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
|
|
2081
|
+
var require_commander = __commonJS(function(exports) {
|
|
2082
|
+
var { Argument } = require_argument();
|
|
2083
|
+
var { Command } = require_command();
|
|
2084
|
+
var { CommanderError, InvalidArgumentError } = require_error();
|
|
2085
|
+
var { Help } = require_help();
|
|
2086
|
+
var { Option } = require_option();
|
|
2087
|
+
exports.program = new Command;
|
|
2088
|
+
exports.createCommand = (name) => new Command(name);
|
|
2089
|
+
exports.createOption = (flags, description) => new Option(flags, description);
|
|
2090
|
+
exports.createArgument = (name, description) => new Argument(name, description);
|
|
2091
|
+
exports.Command = Command;
|
|
2092
|
+
exports.Option = Option;
|
|
2093
|
+
exports.Argument = Argument;
|
|
2094
|
+
exports.Help = Help;
|
|
2095
|
+
exports.CommanderError = CommanderError;
|
|
2096
|
+
exports.InvalidArgumentError = InvalidArgumentError;
|
|
2097
|
+
exports.InvalidOptionArgumentError = InvalidArgumentError;
|
|
2107
2098
|
});
|
|
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;
|
|
2124
2099
|
|
|
2125
2100
|
// ../../node_modules/commander/esm.mjs
|
|
2101
|
+
var import__ = __toESM(require_commander(), 1);
|
|
2126
2102
|
var {
|
|
2127
2103
|
program,
|
|
2128
2104
|
createCommand,
|
|
2129
2105
|
createArgument,
|
|
2130
2106
|
createOption,
|
|
2131
|
-
CommanderError
|
|
2132
|
-
InvalidArgumentError
|
|
2107
|
+
CommanderError,
|
|
2108
|
+
InvalidArgumentError,
|
|
2133
2109
|
InvalidOptionArgumentError,
|
|
2134
2110
|
Command,
|
|
2135
|
-
Argument
|
|
2136
|
-
Option
|
|
2137
|
-
Help
|
|
2138
|
-
} =
|
|
2111
|
+
Argument,
|
|
2112
|
+
Option,
|
|
2113
|
+
Help
|
|
2114
|
+
} = import__.default;
|
|
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
|
+
}
|
|
2139
2281
|
|
|
2140
2282
|
// ../common/src/singleton.ts
|
|
2141
2283
|
var PREFIX = "@uipath/common/";
|
|
@@ -2167,1219 +2309,1260 @@ function singleton(ctorOrName) {
|
|
|
2167
2309
|
};
|
|
2168
2310
|
}
|
|
2169
2311
|
|
|
2170
|
-
// ../common/src/telemetry/
|
|
2171
|
-
var
|
|
2172
|
-
function
|
|
2173
|
-
|
|
2312
|
+
// ../common/src/telemetry/supplied-values.ts
|
|
2313
|
+
var suppliedValuesSlot = singleton("TelemetrySuppliedArgumentValues");
|
|
2314
|
+
function activeEntries() {
|
|
2315
|
+
const existing = suppliedValuesSlot.get();
|
|
2316
|
+
return Array.isArray(existing) ? existing : [];
|
|
2174
2317
|
}
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
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;
|
|
2181
2336
|
}
|
|
2182
|
-
function
|
|
2183
|
-
|
|
2337
|
+
function releaseSuppliedArgumentValues(entry) {
|
|
2338
|
+
suppliedValuesSlot.set(activeEntries().filter((held) => held !== entry));
|
|
2184
2339
|
}
|
|
2185
|
-
function
|
|
2186
|
-
const
|
|
2187
|
-
const
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
tokens.push(token);
|
|
2191
|
-
seen.add(token);
|
|
2340
|
+
function getSuppliedArgumentValues() {
|
|
2341
|
+
const all = new Set;
|
|
2342
|
+
for (const entry of activeEntries()) {
|
|
2343
|
+
for (const value of entry.values) {
|
|
2344
|
+
all.add(value);
|
|
2192
2345
|
}
|
|
2193
2346
|
}
|
|
2194
|
-
return
|
|
2195
|
-
}
|
|
2196
|
-
function getEffectiveUserAgent(userAgent) {
|
|
2197
|
-
return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
|
|
2198
|
-
}
|
|
2199
|
-
function getHeaderName(headers, headerName) {
|
|
2200
|
-
return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase());
|
|
2201
|
-
}
|
|
2202
|
-
function getSdkUserAgentToken(pkg) {
|
|
2203
|
-
const packageName = pkg.name.replace(/^@uipath\//, "");
|
|
2204
|
-
return getEffectiveUserAgent(`${packageName}/${pkg.version}`);
|
|
2205
|
-
}
|
|
2206
|
-
function addSdkUserAgentHeader(headers, userAgent) {
|
|
2207
|
-
const result = { ...headers ?? {} };
|
|
2208
|
-
const headerName = getHeaderName(result, USER_AGENT_HEADER);
|
|
2209
|
-
result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent));
|
|
2210
|
-
return result;
|
|
2347
|
+
return [...all].sort((a, b) => b.length - a.length);
|
|
2211
2348
|
}
|
|
2212
|
-
|
|
2213
|
-
|
|
2349
|
+
|
|
2350
|
+
// ../common/src/telemetry/pii-redactor.ts
|
|
2351
|
+
var REDACTED = "[REDACTED]";
|
|
2352
|
+
var MAX_VALUE_LENGTH = 280;
|
|
2353
|
+
var MAX_STACK_LENGTH = 4096;
|
|
2354
|
+
var MAX_SCAN_LENGTH = MAX_STACK_LENGTH;
|
|
2355
|
+
function truncate(value, maxLength) {
|
|
2356
|
+
return value.length > maxLength ? `${value.slice(0, maxLength)}…` : value;
|
|
2214
2357
|
}
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2358
|
+
var SENSITIVE_NAME_TOKENS = new Set([
|
|
2359
|
+
"token",
|
|
2360
|
+
"tokens",
|
|
2361
|
+
"secret",
|
|
2362
|
+
"secrets",
|
|
2363
|
+
"password",
|
|
2364
|
+
"passwords",
|
|
2365
|
+
"pwd",
|
|
2366
|
+
"credential",
|
|
2367
|
+
"credentials",
|
|
2368
|
+
"auth",
|
|
2369
|
+
"authentication",
|
|
2370
|
+
"authorization",
|
|
2371
|
+
"authority",
|
|
2372
|
+
"cert",
|
|
2373
|
+
"certificate",
|
|
2374
|
+
"certificates"
|
|
2375
|
+
]);
|
|
2376
|
+
var SENSITIVE_KEY_PREFIXES = new Set([
|
|
2377
|
+
"api",
|
|
2378
|
+
"access",
|
|
2379
|
+
"client",
|
|
2380
|
+
"private",
|
|
2381
|
+
"public",
|
|
2382
|
+
"signing",
|
|
2383
|
+
"encryption",
|
|
2384
|
+
"session",
|
|
2385
|
+
"master",
|
|
2386
|
+
"shared",
|
|
2387
|
+
"root",
|
|
2388
|
+
"ssh",
|
|
2389
|
+
"rsa",
|
|
2390
|
+
"aes",
|
|
2391
|
+
"hmac",
|
|
2392
|
+
"oauth"
|
|
2393
|
+
]);
|
|
2394
|
+
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;
|
|
2395
|
+
var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
2396
|
+
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
2397
|
+
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
2398
|
+
var PADDED_BASE64_PATTERN = /(?<![A-Za-z0-9+/])[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
|
|
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"
|
|
2436
|
+
]);
|
|
2437
|
+
var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
|
|
2438
|
+
var QUOTED_LITERAL_MAX_SPAN = 200;
|
|
2439
|
+
var QUOTED_LITERAL_PATTERN = new RegExp([
|
|
2440
|
+
`(?<![A-Za-z0-9])'(?:[^\\
|
|
2441
|
+
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?'(?![A-Za-z0-9])`,
|
|
2442
|
+
`(?<![A-Za-z0-9])"(?:[^\\
|
|
2443
|
+
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
|
|
2444
|
+
].join("|"), "g");
|
|
2445
|
+
var JSON_BODY_PATTERN = /[{[][^{}[\]:,]*[:,][^{}[\]]*[\]}]/g;
|
|
2446
|
+
var COLLAPSED_BODY = "{…}";
|
|
2447
|
+
var COLLAPSED_BODY_MARKER = "\x01body\x01";
|
|
2448
|
+
var MAX_BODY_NESTING = 8;
|
|
2449
|
+
function collapseJsonBodies(text) {
|
|
2450
|
+
let out = text;
|
|
2451
|
+
for (let pass = 0;pass < MAX_BODY_NESTING; pass++) {
|
|
2452
|
+
const next = out.replace(JSON_BODY_PATTERN, COLLAPSED_BODY_MARKER);
|
|
2453
|
+
if (next === out) {
|
|
2454
|
+
break;
|
|
2455
|
+
}
|
|
2456
|
+
out = next;
|
|
2457
|
+
}
|
|
2458
|
+
return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
|
|
2230
2459
|
}
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2460
|
+
var TRAILING_PROSE_PUNCT = `.,;:!?)]}>'"`;
|
|
2461
|
+
function peelTrailingPunctuation(match) {
|
|
2462
|
+
let end = match.length;
|
|
2463
|
+
while (end > 0 && TRAILING_PROSE_PUNCT.includes(match[end - 1])) {
|
|
2464
|
+
end -= 1;
|
|
2235
2465
|
}
|
|
2236
|
-
|
|
2237
|
-
|
|
2466
|
+
return [match.slice(0, end), match.slice(end)];
|
|
2467
|
+
}
|
|
2468
|
+
function redactUrl(raw) {
|
|
2469
|
+
try {
|
|
2470
|
+
const url = new URL(raw);
|
|
2471
|
+
return `${url.protocol}//${url.host}`;
|
|
2472
|
+
} catch {
|
|
2473
|
+
return `url#${pseudonymize(raw)}`;
|
|
2238
2474
|
}
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2475
|
+
}
|
|
2476
|
+
function redactValueDetectors(value, maxLength = MAX_VALUE_LENGTH) {
|
|
2477
|
+
let out = truncate(value, MAX_SCAN_LENGTH);
|
|
2478
|
+
out = out.replace(JWT_PATTERN, () => REDACTED);
|
|
2479
|
+
out = out.replace(URL_PATTERN, (match) => {
|
|
2480
|
+
const [core, trailing] = peelTrailingPunctuation(match);
|
|
2481
|
+
return `${redactUrl(core)}${trailing}`;
|
|
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}`;
|
|
2245
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;
|
|
2496
|
+
}
|
|
2497
|
+
return `host#${pseudonymize(host)}:${match.slice(split + 1)}`;
|
|
2498
|
+
});
|
|
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);
|
|
2246
2503
|
}
|
|
2247
|
-
function
|
|
2248
|
-
|
|
2504
|
+
function redactSpanName(name) {
|
|
2505
|
+
return redactValueDetectors(truncate(name, MAX_SCAN_LENGTH).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`));
|
|
2506
|
+
}
|
|
2507
|
+
var HTTP_DEPENDENCY_NAME = /^([A-Z]+) (\/.*)$/s;
|
|
2508
|
+
function redactHttpDependencyName(name) {
|
|
2509
|
+
const parts = HTTP_DEPENDENCY_NAME.exec(name);
|
|
2510
|
+
if (!parts) {
|
|
2511
|
+
return redactMessage(name);
|
|
2512
|
+
}
|
|
2513
|
+
return `${parts[1]} ${redactMessage(parts[2])}`;
|
|
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);
|
|
2519
|
+
}
|
|
2520
|
+
return redactValueDetectors(out);
|
|
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);
|
|
2549
|
+
}
|
|
2550
|
+
return `${redactMessage(bounded.slice(0, firstBreak))}
|
|
2551
|
+
${redactValueDetectors(bounded.slice(firstBreak + 1), MAX_STACK_LENGTH)}`;
|
|
2552
|
+
}
|
|
2553
|
+
function nameTokens(name) {
|
|
2554
|
+
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);
|
|
2555
|
+
}
|
|
2556
|
+
function isSensitiveName(name) {
|
|
2557
|
+
const tokens = nameTokens(name);
|
|
2558
|
+
for (let i = 0;i < tokens.length; i++) {
|
|
2559
|
+
const token = tokens[i];
|
|
2560
|
+
if (SENSITIVE_NAME_TOKENS.has(token)) {
|
|
2561
|
+
return true;
|
|
2562
|
+
}
|
|
2563
|
+
if (token === "key" || token === "keys") {
|
|
2564
|
+
const prev = tokens[i - 1];
|
|
2565
|
+
if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
|
|
2566
|
+
return true;
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
return false;
|
|
2571
|
+
}
|
|
2572
|
+
function redactProperty(name, value) {
|
|
2573
|
+
if (value === undefined || value === null) {
|
|
2574
|
+
return;
|
|
2575
|
+
}
|
|
2576
|
+
if (isSensitiveName(name)) {
|
|
2577
|
+
return REDACTED;
|
|
2578
|
+
}
|
|
2579
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
2580
|
+
return value;
|
|
2581
|
+
}
|
|
2582
|
+
if (typeof value !== "string") {
|
|
2583
|
+
return "[OBJECT]";
|
|
2584
|
+
}
|
|
2585
|
+
return isFreeFormValue(name, value) ? redactMessage(value) : redactValueDetectors(value);
|
|
2586
|
+
}
|
|
2587
|
+
function redactProperties(properties) {
|
|
2588
|
+
const out = {};
|
|
2589
|
+
for (const [name, value] of Object.entries(properties)) {
|
|
2590
|
+
const redacted = redactProperty(name, value);
|
|
2591
|
+
if (redacted !== undefined) {
|
|
2592
|
+
out[name] = redacted;
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
return out;
|
|
2596
|
+
}
|
|
2597
|
+
|
|
2598
|
+
// ../common/src/catch-error.ts
|
|
2599
|
+
var MAX_SERIALIZED_LENGTH = 500;
|
|
2600
|
+
var TRUNCATION_SUFFIX = "…(truncated)";
|
|
2601
|
+
var REDACTED2 = "[REDACTED]";
|
|
2602
|
+
function cap(text) {
|
|
2603
|
+
return text.length > MAX_SERIALIZED_LENGTH ? `${text.slice(0, MAX_SERIALIZED_LENGTH)}${TRUNCATION_SUFFIX}` : text;
|
|
2604
|
+
}
|
|
2605
|
+
function omitSensitive(key, value) {
|
|
2606
|
+
return key.length > 0 && isSensitiveName(key) ? REDACTED2 : value;
|
|
2607
|
+
}
|
|
2608
|
+
function describeThrownValue(value) {
|
|
2609
|
+
if (typeof value !== "object" || value === null) {
|
|
2610
|
+
return String(value);
|
|
2611
|
+
}
|
|
2612
|
+
let message;
|
|
2613
|
+
try {
|
|
2614
|
+
message = value.message;
|
|
2615
|
+
} catch {
|
|
2616
|
+
message = undefined;
|
|
2617
|
+
}
|
|
2618
|
+
if (typeof message === "string" && message.length > 0) {
|
|
2619
|
+
return cap(message);
|
|
2620
|
+
}
|
|
2621
|
+
try {
|
|
2622
|
+
const json = JSON.stringify(value, omitSensitive);
|
|
2623
|
+
if (json !== undefined) {
|
|
2624
|
+
return cap(json);
|
|
2625
|
+
}
|
|
2626
|
+
} catch {}
|
|
2627
|
+
return String(value);
|
|
2628
|
+
}
|
|
2629
|
+
function toError(error) {
|
|
2630
|
+
return error instanceof Error ? error : new Error(describeThrownValue(error), { cause: error });
|
|
2631
|
+
}
|
|
2632
|
+
function isPromiseLike(value) {
|
|
2633
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
2634
|
+
}
|
|
2635
|
+
function catchError(fnOrPromise) {
|
|
2636
|
+
if (isPromiseLike(fnOrPromise)) {
|
|
2637
|
+
return settlePromiseLike(fnOrPromise);
|
|
2638
|
+
}
|
|
2639
|
+
try {
|
|
2640
|
+
const result = fnOrPromise();
|
|
2641
|
+
if (isPromiseLike(result)) {
|
|
2642
|
+
return settlePromiseLike(result);
|
|
2643
|
+
}
|
|
2644
|
+
return [undefined, result];
|
|
2645
|
+
} catch (error) {
|
|
2646
|
+
return [toError(error), undefined];
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
function settlePromiseLike(thenable) {
|
|
2650
|
+
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
|
|
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);
|
|
2670
|
+
}
|
|
2671
|
+
return;
|
|
2672
|
+
}
|
|
2673
|
+
function parseHttpStatusFromMessage(message) {
|
|
2674
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
2675
|
+
if (!match)
|
|
2676
|
+
return;
|
|
2677
|
+
const status = Number(match[1]);
|
|
2678
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
2249
2679
|
}
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
import * as path from "node:path";
|
|
2257
|
-
var LOCK_HEARTBEAT_MS = 5000;
|
|
2258
|
-
var LOCK_STALE_MS = 15000;
|
|
2259
|
-
var LOCK_MAX_WAIT_MS = 20000;
|
|
2260
|
-
var LOCK_MAX_HOLD_MS = 60000;
|
|
2261
|
-
var LOCK_RETRY_MIN_MS = 100;
|
|
2262
|
-
var LOCK_RETRY_JITTER_MS = 200;
|
|
2263
|
-
|
|
2264
|
-
class NodeFileSystem {
|
|
2265
|
-
path = {
|
|
2266
|
-
join: path.join,
|
|
2267
|
-
resolve: path.resolve,
|
|
2268
|
-
relative: path.relative,
|
|
2269
|
-
dirname: path.dirname,
|
|
2270
|
-
isAbsolute: path.isAbsolute,
|
|
2271
|
-
basename: path.basename
|
|
2272
|
-
};
|
|
2273
|
-
env = {
|
|
2274
|
-
cwd: process.cwd,
|
|
2275
|
-
homedir: os.homedir,
|
|
2276
|
-
tmpdir: os.tmpdir,
|
|
2277
|
-
getenv: (key) => process.env[key]
|
|
2278
|
-
};
|
|
2279
|
-
utils = {
|
|
2280
|
-
open: async (url) => {
|
|
2281
|
-
const { default: open } = await import("./index-nzr4mx5p.js");
|
|
2282
|
-
await open(url);
|
|
2680
|
+
function findHttpStatusInGraph(error) {
|
|
2681
|
+
for (const node of walkErrorGraph(error)) {
|
|
2682
|
+
const response = node.response;
|
|
2683
|
+
const explicit = typeof node.status === "number" ? node.status : response?.status;
|
|
2684
|
+
if (typeof explicit === "number" && explicit >= 400 && explicit <= 599) {
|
|
2685
|
+
return explicit;
|
|
2283
2686
|
}
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
return await fs.readFile(path2, "utf-8");
|
|
2687
|
+
if (typeof node.message === "string") {
|
|
2688
|
+
const parsed = parseHttpStatusFromMessage(node.message);
|
|
2689
|
+
if (parsed !== undefined && parsed >= 400) {
|
|
2690
|
+
return parsed;
|
|
2289
2691
|
}
|
|
2290
|
-
return await fs.readFile(path2);
|
|
2291
|
-
} catch (error) {
|
|
2292
|
-
if (this.isEnoent(error))
|
|
2293
|
-
return null;
|
|
2294
|
-
throw error;
|
|
2295
2692
|
}
|
|
2296
2693
|
}
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2694
|
+
return;
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
// ../common/src/local-permission-codes.ts
|
|
2698
|
+
var LOCAL_PERMISSION_ERROR_CODES = new Set([
|
|
2699
|
+
"EACCES",
|
|
2700
|
+
"EPERM",
|
|
2701
|
+
"EROFS"
|
|
2702
|
+
]);
|
|
2703
|
+
|
|
2704
|
+
// ../common/src/error-handler.ts
|
|
2705
|
+
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.";
|
|
2706
|
+
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.";
|
|
2707
|
+
var DEFAULT_405 = "Method Not Allowed (405). The endpoint may not exist or the base URL may be incorrect.";
|
|
2708
|
+
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.";
|
|
2709
|
+
var HTML_RESPONSE_MESSAGE = "Received HTML instead of the expected JSON response.";
|
|
2710
|
+
var NETWORK_ERROR_CODES = new Set([
|
|
2711
|
+
"ECONNREFUSED",
|
|
2712
|
+
"ECONNRESET",
|
|
2713
|
+
"ENOTFOUND",
|
|
2714
|
+
"EAI_AGAIN",
|
|
2715
|
+
"ETIMEDOUT",
|
|
2716
|
+
"EPIPE",
|
|
2717
|
+
"EHOSTUNREACH",
|
|
2718
|
+
"ENETUNREACH",
|
|
2719
|
+
"EAI_FAIL"
|
|
2720
|
+
]);
|
|
2721
|
+
var TLS_ERROR_CODES = new Set([
|
|
2722
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
2723
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
2724
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
2725
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
2726
|
+
"UNABLE_TO_GET_ISSUER_CERT",
|
|
2727
|
+
"CERT_HAS_EXPIRED",
|
|
2728
|
+
"CERT_UNTRUSTED",
|
|
2729
|
+
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
2730
|
+
]);
|
|
2731
|
+
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.";
|
|
2732
|
+
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.";
|
|
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.";
|
|
2310
2738
|
}
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
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;
|
|
2748
|
+
}
|
|
2749
|
+
function describeConnectivityError(error) {
|
|
2750
|
+
for (const cur of walkErrorGraph(error)) {
|
|
2751
|
+
const code = typeof cur.code === "string" ? cur.code : undefined;
|
|
2752
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
2753
|
+
if (code && TLS_ERROR_CODES.has(code)) {
|
|
2754
|
+
return {
|
|
2755
|
+
code,
|
|
2756
|
+
kind: "tls",
|
|
2757
|
+
message: message ?? code,
|
|
2758
|
+
instructions: TLS_INSTRUCTIONS
|
|
2759
|
+
};
|
|
2318
2760
|
}
|
|
2319
|
-
|
|
2320
|
-
async stat(filePath) {
|
|
2321
|
-
try {
|
|
2322
|
-
const stats = await fs.stat(filePath);
|
|
2761
|
+
if (code && NETWORK_ERROR_CODES.has(code)) {
|
|
2323
2762
|
return {
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2763
|
+
code,
|
|
2764
|
+
kind: "network",
|
|
2765
|
+
message: message ?? code,
|
|
2766
|
+
instructions: NETWORK_INSTRUCTIONS
|
|
2328
2767
|
};
|
|
2329
|
-
} catch (error) {
|
|
2330
|
-
if (this.isEnoent(error))
|
|
2331
|
-
return null;
|
|
2332
|
-
throw error;
|
|
2333
2768
|
}
|
|
2334
2769
|
}
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
const
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
} catch (error) {
|
|
2351
|
-
if (!this.hasErrnoCode(error, "EEXIST")) {
|
|
2352
|
-
throw error;
|
|
2353
|
-
}
|
|
2354
|
-
const stats = await fs.stat(lockFile).catch(() => null);
|
|
2355
|
-
if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
|
|
2356
|
-
const reclaimed = await fs.rm(lockFile, { force: true }).then(() => true).catch(() => false);
|
|
2357
|
-
if (reclaimed)
|
|
2358
|
-
continue;
|
|
2359
|
-
}
|
|
2360
|
-
if (Date.now() - start > LOCK_MAX_WAIT_MS) {
|
|
2361
|
-
throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
|
|
2362
|
-
}
|
|
2363
|
-
await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
|
|
2364
|
-
}
|
|
2365
|
-
}
|
|
2770
|
+
return;
|
|
2771
|
+
}
|
|
2772
|
+
function describePermissionError(error) {
|
|
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
|
+
};
|
|
2366
2785
|
}
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
const parent = path.dirname(absolute);
|
|
2373
|
-
const base = path.basename(absolute);
|
|
2374
|
-
const canonicalParent = await fs.realpath(parent).catch(() => parent);
|
|
2375
|
-
return path.join(canonicalParent, base);
|
|
2786
|
+
return;
|
|
2787
|
+
}
|
|
2788
|
+
function matchLocalPermissionCode(code, message) {
|
|
2789
|
+
if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
|
|
2790
|
+
return code;
|
|
2376
2791
|
}
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
const now = Date.now() / 1000;
|
|
2409
|
-
await fs.utimes(lockFile, now, now).catch(() => {});
|
|
2410
|
-
scheduleNextHeartbeat();
|
|
2411
|
-
};
|
|
2412
|
-
scheduleNextHeartbeat();
|
|
2413
|
-
let released = false;
|
|
2414
|
-
return async () => {
|
|
2415
|
-
if (released)
|
|
2416
|
-
return;
|
|
2417
|
-
released = true;
|
|
2418
|
-
stopHeartbeat();
|
|
2419
|
-
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
2420
|
-
if (current === ownerId) {
|
|
2421
|
-
await fs.rm(lockFile, { force: true });
|
|
2422
|
-
}
|
|
2792
|
+
const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
|
|
2793
|
+
return match ? match[1] : undefined;
|
|
2794
|
+
}
|
|
2795
|
+
function localPermissionPath(path, message) {
|
|
2796
|
+
if (typeof path === "string")
|
|
2797
|
+
return path;
|
|
2798
|
+
return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
|
|
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";
|
|
2814
|
+
}
|
|
2815
|
+
function classifyError(status, error) {
|
|
2816
|
+
if (status === 400 || status === 409 || status === 422) {
|
|
2817
|
+
return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
|
|
2818
|
+
}
|
|
2819
|
+
if (status === 401) {
|
|
2820
|
+
return {
|
|
2821
|
+
errorCode: "authentication_required",
|
|
2822
|
+
retry: "RetryWillNotFix"
|
|
2423
2823
|
};
|
|
2424
2824
|
}
|
|
2425
|
-
|
|
2426
|
-
|
|
2825
|
+
if (status === 403) {
|
|
2826
|
+
return { errorCode: "permission_denied", retry: "RetryWillNotFix" };
|
|
2427
2827
|
}
|
|
2428
|
-
|
|
2429
|
-
|
|
2828
|
+
if (status === 404) {
|
|
2829
|
+
return { errorCode: "not_found", retry: "RetryWillNotFix" };
|
|
2430
2830
|
}
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
return await fs.realpath(filePath);
|
|
2434
|
-
} catch (error) {
|
|
2435
|
-
if (this.isEnoent(error))
|
|
2436
|
-
return filePath;
|
|
2437
|
-
throw error;
|
|
2438
|
-
}
|
|
2831
|
+
if (status === 405) {
|
|
2832
|
+
return { errorCode: "method_not_allowed", retry: "RetryWillNotFix" };
|
|
2439
2833
|
}
|
|
2440
|
-
|
|
2441
|
-
return
|
|
2834
|
+
if (status === 413) {
|
|
2835
|
+
return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
|
|
2442
2836
|
}
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
if (!sourceStats) {
|
|
2446
|
-
throw new Error(`Source directory does not exist: ${sourcePath}`);
|
|
2447
|
-
}
|
|
2448
|
-
if (!sourceStats.isDirectory()) {
|
|
2449
|
-
throw new Error(`Source path is not a directory: ${sourcePath}`);
|
|
2450
|
-
}
|
|
2451
|
-
await this.mkdir(destPath);
|
|
2452
|
-
const entries = await this.readdir(sourcePath);
|
|
2453
|
-
for (const entry of entries) {
|
|
2454
|
-
const srcEntry = path.join(sourcePath, entry);
|
|
2455
|
-
const destEntry = path.join(destPath, entry);
|
|
2456
|
-
const entryStats = await this.stat(srcEntry);
|
|
2457
|
-
if (!entryStats)
|
|
2458
|
-
continue;
|
|
2459
|
-
if (entryStats.isDirectory()) {
|
|
2460
|
-
await this.copyDirectory(srcEntry, destEntry);
|
|
2461
|
-
} else if (entryStats.isFile()) {
|
|
2462
|
-
const content = await this.readFile(srcEntry);
|
|
2463
|
-
if (content !== null) {
|
|
2464
|
-
await this.writeFile(destEntry, content);
|
|
2465
|
-
}
|
|
2466
|
-
}
|
|
2467
|
-
}
|
|
2837
|
+
if (status === 408) {
|
|
2838
|
+
return { errorCode: "timeout", retry: "RetryLater" };
|
|
2468
2839
|
}
|
|
2469
|
-
|
|
2470
|
-
return
|
|
2840
|
+
if (status === 429) {
|
|
2841
|
+
return { errorCode: "rate_limited", retry: "RetryLater" };
|
|
2471
2842
|
}
|
|
2472
|
-
|
|
2473
|
-
return
|
|
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
|
+
};
|
|
2474
2858
|
}
|
|
2859
|
+
return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
|
|
2475
2860
|
}
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
// ../common/src/telemetry/pseudonymize.ts
|
|
2482
|
-
var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
|
|
2483
|
-
var PSEUDONYM_HEX_LENGTH = 32;
|
|
2484
|
-
var SHA256_K = new Uint32Array([
|
|
2485
|
-
1116352408,
|
|
2486
|
-
1899447441,
|
|
2487
|
-
3049323471,
|
|
2488
|
-
3921009573,
|
|
2489
|
-
961987163,
|
|
2490
|
-
1508970993,
|
|
2491
|
-
2453635748,
|
|
2492
|
-
2870763221,
|
|
2493
|
-
3624381080,
|
|
2494
|
-
310598401,
|
|
2495
|
-
607225278,
|
|
2496
|
-
1426881987,
|
|
2497
|
-
1925078388,
|
|
2498
|
-
2162078206,
|
|
2499
|
-
2614888103,
|
|
2500
|
-
3248222580,
|
|
2501
|
-
3835390401,
|
|
2502
|
-
4022224774,
|
|
2503
|
-
264347078,
|
|
2504
|
-
604807628,
|
|
2505
|
-
770255983,
|
|
2506
|
-
1249150122,
|
|
2507
|
-
1555081692,
|
|
2508
|
-
1996064986,
|
|
2509
|
-
2554220882,
|
|
2510
|
-
2821834349,
|
|
2511
|
-
2952996808,
|
|
2512
|
-
3210313671,
|
|
2513
|
-
3336571891,
|
|
2514
|
-
3584528711,
|
|
2515
|
-
113926993,
|
|
2516
|
-
338241895,
|
|
2517
|
-
666307205,
|
|
2518
|
-
773529912,
|
|
2519
|
-
1294757372,
|
|
2520
|
-
1396182291,
|
|
2521
|
-
1695183700,
|
|
2522
|
-
1986661051,
|
|
2523
|
-
2177026350,
|
|
2524
|
-
2456956037,
|
|
2525
|
-
2730485921,
|
|
2526
|
-
2820302411,
|
|
2527
|
-
3259730800,
|
|
2528
|
-
3345764771,
|
|
2529
|
-
3516065817,
|
|
2530
|
-
3600352804,
|
|
2531
|
-
4094571909,
|
|
2532
|
-
275423344,
|
|
2533
|
-
430227734,
|
|
2534
|
-
506948616,
|
|
2535
|
-
659060556,
|
|
2536
|
-
883997877,
|
|
2537
|
-
958139571,
|
|
2538
|
-
1322822218,
|
|
2539
|
-
1537002063,
|
|
2540
|
-
1747873779,
|
|
2541
|
-
1955562222,
|
|
2542
|
-
2024104815,
|
|
2543
|
-
2227730452,
|
|
2544
|
-
2361852424,
|
|
2545
|
-
2428436474,
|
|
2546
|
-
2756734187,
|
|
2547
|
-
3204031479,
|
|
2548
|
-
3329325298
|
|
2549
|
-
]);
|
|
2550
|
-
var SHA256_INITIAL_STATE = new Uint32Array([
|
|
2551
|
-
1779033703,
|
|
2552
|
-
3144134277,
|
|
2553
|
-
1013904242,
|
|
2554
|
-
2773480762,
|
|
2555
|
-
1359893119,
|
|
2556
|
-
2600822924,
|
|
2557
|
-
528734635,
|
|
2558
|
-
1541459225
|
|
2559
|
-
]);
|
|
2560
|
-
function rotr(value, bits) {
|
|
2561
|
-
return (value >>> bits | value << 32 - bits) >>> 0;
|
|
2861
|
+
function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
|
|
2862
|
+
if (extractedMessage) {
|
|
2863
|
+
return `HTTP ${status}: ${extractedMessage}`;
|
|
2864
|
+
}
|
|
2865
|
+
return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
|
|
2562
2866
|
}
|
|
2563
|
-
function
|
|
2564
|
-
const
|
|
2565
|
-
const
|
|
2566
|
-
const
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
const
|
|
2570
|
-
const
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
const
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
d = c;
|
|
2606
|
-
c = b;
|
|
2607
|
-
b = a;
|
|
2608
|
-
a = temp1 + temp2 >>> 0;
|
|
2867
|
+
async function extractErrorDetails(error, options) {
|
|
2868
|
+
const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
|
|
2869
|
+
const response = err.response;
|
|
2870
|
+
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
2871
|
+
const explicitStatus = err.status ?? response?.status;
|
|
2872
|
+
const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
|
|
2873
|
+
const status = explicitStatus ?? inferredStatus;
|
|
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;
|
|
2908
|
+
}
|
|
2609
2909
|
}
|
|
2610
|
-
state[0] = state[0] + a >>> 0;
|
|
2611
|
-
state[1] = state[1] + b >>> 0;
|
|
2612
|
-
state[2] = state[2] + c >>> 0;
|
|
2613
|
-
state[3] = state[3] + d >>> 0;
|
|
2614
|
-
state[4] = state[4] + e >>> 0;
|
|
2615
|
-
state[5] = state[5] + f >>> 0;
|
|
2616
|
-
state[6] = state[6] + g >>> 0;
|
|
2617
|
-
state[7] = state[7] + h >>> 0;
|
|
2618
|
-
}
|
|
2619
|
-
let hex = "";
|
|
2620
|
-
for (const word of state) {
|
|
2621
|
-
hex += word.toString(16).padStart(8, "0");
|
|
2622
2910
|
}
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2911
|
+
let message;
|
|
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;
|
|
2631
2936
|
}
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
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;
|
|
2636
2948
|
}
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
return cachedSha256Hex(input);
|
|
2642
|
-
}
|
|
2643
|
-
function pseudonymize(input) {
|
|
2644
|
-
return digest(`${PSEUDONYM_DOMAIN}${input}`).slice(0, PSEUDONYM_HEX_LENGTH);
|
|
2645
|
-
}
|
|
2646
|
-
|
|
2647
|
-
// ../common/src/telemetry/supplied-values.ts
|
|
2648
|
-
var suppliedValuesSlot = singleton("TelemetrySuppliedArgumentValues");
|
|
2649
|
-
function activeEntries() {
|
|
2650
|
-
const existing = suppliedValuesSlot.get();
|
|
2651
|
-
return Array.isArray(existing) ? existing : [];
|
|
2652
|
-
}
|
|
2653
|
-
var MIN_SCRUBBABLE_LENGTH = 4;
|
|
2654
|
-
function recordSuppliedArgumentValues(values) {
|
|
2655
|
-
const flat = [];
|
|
2656
|
-
const push = (value) => {
|
|
2657
|
-
if (Array.isArray(value)) {
|
|
2658
|
-
for (const item of value) {
|
|
2659
|
-
push(item);
|
|
2660
|
-
}
|
|
2661
|
-
return;
|
|
2949
|
+
if (status === undefined) {
|
|
2950
|
+
const connectivity = describeConnectivityError(error);
|
|
2951
|
+
if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
|
|
2952
|
+
message = `${message}: ${connectivity.message}`;
|
|
2662
2953
|
}
|
|
2663
|
-
|
|
2664
|
-
|
|
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}`;
|
|
2665
2959
|
}
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
suppliedValuesSlot.set([...activeEntries(), entry]);
|
|
2670
|
-
return entry;
|
|
2671
|
-
}
|
|
2672
|
-
function releaseSuppliedArgumentValues(entry) {
|
|
2673
|
-
suppliedValuesSlot.set(activeEntries().filter((held) => held !== entry));
|
|
2674
|
-
}
|
|
2675
|
-
function getSuppliedArgumentValues() {
|
|
2676
|
-
const all = new Set;
|
|
2677
|
-
for (const entry of activeEntries()) {
|
|
2678
|
-
for (const value of entry.values) {
|
|
2679
|
-
all.add(value);
|
|
2960
|
+
if (!message.includes(permission.instructions)) {
|
|
2961
|
+
const punctuated = message.endsWith(".") ? message : `${message}.`;
|
|
2962
|
+
message = `${punctuated} ${permission.instructions}`;
|
|
2680
2963
|
}
|
|
2681
2964
|
}
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
"pwd",
|
|
2701
|
-
"credential",
|
|
2702
|
-
"credentials",
|
|
2703
|
-
"auth",
|
|
2704
|
-
"authentication",
|
|
2705
|
-
"authorization",
|
|
2706
|
-
"authority",
|
|
2707
|
-
"cert",
|
|
2708
|
-
"certificate",
|
|
2709
|
-
"certificates"
|
|
2710
|
-
]);
|
|
2711
|
-
var SENSITIVE_KEY_PREFIXES = new Set([
|
|
2712
|
-
"api",
|
|
2713
|
-
"access",
|
|
2714
|
-
"client",
|
|
2715
|
-
"private",
|
|
2716
|
-
"public",
|
|
2717
|
-
"signing",
|
|
2718
|
-
"encryption",
|
|
2719
|
-
"session",
|
|
2720
|
-
"master",
|
|
2721
|
-
"shared",
|
|
2722
|
-
"root",
|
|
2723
|
-
"ssh",
|
|
2724
|
-
"rsa",
|
|
2725
|
-
"aes",
|
|
2726
|
-
"hmac",
|
|
2727
|
-
"oauth"
|
|
2728
|
-
]);
|
|
2729
|
-
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;
|
|
2730
|
-
var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
2731
|
-
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
2732
|
-
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
2733
|
-
var PADDED_BASE64_PATTERN = /(?<![A-Za-z0-9+/])[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
|
|
2734
|
-
var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
|
|
2735
|
-
var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
|
|
2736
|
-
var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
|
|
2737
|
-
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;
|
|
2738
|
-
var SOURCE_FILE_EXTENSIONS = new Set([
|
|
2739
|
-
"ts",
|
|
2740
|
-
"tsx",
|
|
2741
|
-
"js",
|
|
2742
|
-
"jsx",
|
|
2743
|
-
"mjs",
|
|
2744
|
-
"cjs",
|
|
2745
|
-
"cts",
|
|
2746
|
-
"mts",
|
|
2747
|
-
"py",
|
|
2748
|
-
"cs",
|
|
2749
|
-
"java",
|
|
2750
|
-
"go",
|
|
2751
|
-
"rs",
|
|
2752
|
-
"rb",
|
|
2753
|
-
"php",
|
|
2754
|
-
"sh",
|
|
2755
|
-
"ps1",
|
|
2756
|
-
"json",
|
|
2757
|
-
"jsonc",
|
|
2758
|
-
"yaml",
|
|
2759
|
-
"yml",
|
|
2760
|
-
"xml",
|
|
2761
|
-
"xaml",
|
|
2762
|
-
"md",
|
|
2763
|
-
"txt",
|
|
2764
|
-
"log",
|
|
2765
|
-
"css",
|
|
2766
|
-
"html",
|
|
2767
|
-
"htm",
|
|
2768
|
-
"csproj",
|
|
2769
|
-
"nuspec",
|
|
2770
|
-
"sql"
|
|
2771
|
-
]);
|
|
2772
|
-
var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
|
|
2773
|
-
var QUOTED_LITERAL_MAX_SPAN = 200;
|
|
2774
|
-
var QUOTED_LITERAL_PATTERN = new RegExp([
|
|
2775
|
-
`(?<![A-Za-z0-9])'(?:[^\\
|
|
2776
|
-
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?'(?![A-Za-z0-9])`,
|
|
2777
|
-
`(?<![A-Za-z0-9])"(?:[^\\
|
|
2778
|
-
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
|
|
2779
|
-
].join("|"), "g");
|
|
2780
|
-
var JSON_BODY_PATTERN = /[{[][^{}[\]:,]*[:,][^{}[\]]*[\]}]/g;
|
|
2781
|
-
var COLLAPSED_BODY = "{…}";
|
|
2782
|
-
var COLLAPSED_BODY_MARKER = "\x01body\x01";
|
|
2783
|
-
var MAX_BODY_NESTING = 8;
|
|
2784
|
-
function collapseJsonBodies(text) {
|
|
2785
|
-
let out = text;
|
|
2786
|
-
for (let pass = 0;pass < MAX_BODY_NESTING; pass++) {
|
|
2787
|
-
const next = out.replace(JSON_BODY_PATTERN, COLLAPSED_BODY_MARKER);
|
|
2788
|
-
if (next === out) {
|
|
2789
|
-
break;
|
|
2965
|
+
let details = rawMessage;
|
|
2966
|
+
if (rawBody) {
|
|
2967
|
+
if (parsedBody) {
|
|
2968
|
+
const extra = {};
|
|
2969
|
+
if (parsedBody.errorCode)
|
|
2970
|
+
extra.errorCode = parsedBody.errorCode;
|
|
2971
|
+
if (parsedBody.detail)
|
|
2972
|
+
extra.detail = parsedBody.detail;
|
|
2973
|
+
if (parsedBody.details)
|
|
2974
|
+
extra.details = parsedBody.details;
|
|
2975
|
+
if (parsedBody.errors != null)
|
|
2976
|
+
extra.errors = parsedBody.errors;
|
|
2977
|
+
if (parsedBody.data && typeof parsedBody.data === "object" && Object.keys(parsedBody.data).length > 0) {
|
|
2978
|
+
extra.data = parsedBody.data;
|
|
2979
|
+
}
|
|
2980
|
+
details = Object.keys(extra).length > 0 ? JSON.stringify(extra) : rawBody;
|
|
2981
|
+
} else {
|
|
2982
|
+
details = rawBody;
|
|
2790
2983
|
}
|
|
2791
|
-
|
|
2984
|
+
} else if (typeof err.message === "string") {
|
|
2985
|
+
details = err.message;
|
|
2986
|
+
} else {
|
|
2987
|
+
details = describeThrownValue(error);
|
|
2792
2988
|
}
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
function peelTrailingPunctuation(match) {
|
|
2797
|
-
let end = match.length;
|
|
2798
|
-
while (end > 0 && TRAILING_PROSE_PUNCT.includes(match[end - 1])) {
|
|
2799
|
-
end -= 1;
|
|
2989
|
+
const context = {};
|
|
2990
|
+
if (classificationStatus) {
|
|
2991
|
+
context.httpStatus = classificationStatus;
|
|
2800
2992
|
}
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
const url = new URL(raw);
|
|
2806
|
-
return `${url.protocol}//${url.host}`;
|
|
2807
|
-
} catch {
|
|
2808
|
-
return `url#${pseudonymize(raw)}`;
|
|
2993
|
+
if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
|
|
2994
|
+
context.errorCode = parsedBody.errorCode;
|
|
2995
|
+
} else if (parsedBody?.code && typeof parsedBody.code === "string") {
|
|
2996
|
+
context.errorCode = parsedBody.code;
|
|
2809
2997
|
}
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
let out = truncate(value, MAX_SCAN_LENGTH);
|
|
2813
|
-
out = out.replace(JWT_PATTERN, () => REDACTED);
|
|
2814
|
-
out = out.replace(URL_PATTERN, (match) => {
|
|
2815
|
-
const [core, trailing] = peelTrailingPunctuation(match);
|
|
2816
|
-
return `${redactUrl(core)}${trailing}`;
|
|
2817
|
-
});
|
|
2818
|
-
out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
|
|
2819
|
-
out = out.replace(UNC_PATH_PATTERN, (_match, before, path) => {
|
|
2820
|
-
const [core, trailing] = peelTrailingPunctuation(path);
|
|
2821
|
-
return `${before}unc#${pseudonymize(core)}${trailing}`;
|
|
2822
|
-
});
|
|
2823
|
-
out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
|
|
2824
|
-
out = out.replace(UUID_PATTERN, (match) => `uuid#${pseudonymize(match)}`);
|
|
2825
|
-
out = out.replace(HOST_PORT_PATTERN, (match) => {
|
|
2826
|
-
const split = match.lastIndexOf(":");
|
|
2827
|
-
const host = match.slice(0, split);
|
|
2828
|
-
const extension = host.slice(host.lastIndexOf(".") + 1).toLowerCase();
|
|
2829
|
-
if (SOURCE_FILE_EXTENSIONS.has(extension)) {
|
|
2830
|
-
return match;
|
|
2831
|
-
}
|
|
2832
|
-
return `host#${pseudonymize(host)}:${match.slice(split + 1)}`;
|
|
2833
|
-
});
|
|
2834
|
-
out = out.replace(PADDED_BASE64_PATTERN, () => REDACTED);
|
|
2835
|
-
out = out.replace(BASE64_WITH_PLUS_PATTERN, (match) => match.includes("+") ? REDACTED : match);
|
|
2836
|
-
out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
|
|
2837
|
-
return truncate(out, maxLength);
|
|
2838
|
-
}
|
|
2839
|
-
function redactSpanName(name) {
|
|
2840
|
-
return redactValueDetectors(truncate(name, MAX_SCAN_LENGTH).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`));
|
|
2841
|
-
}
|
|
2842
|
-
var HTTP_DEPENDENCY_NAME = /^([A-Z]+) (\/.*)$/s;
|
|
2843
|
-
function redactHttpDependencyName(name) {
|
|
2844
|
-
const parts = HTTP_DEPENDENCY_NAME.exec(name);
|
|
2845
|
-
if (!parts) {
|
|
2846
|
-
return redactMessage(name);
|
|
2998
|
+
if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
|
|
2999
|
+
context.requestId = parsedBody.requestId;
|
|
2847
3000
|
}
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
function redactMessage(value) {
|
|
2851
|
-
let out = collapseJsonBodies(truncate(value, MAX_SCAN_LENGTH)).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`);
|
|
2852
|
-
for (const supplied of getSuppliedArgumentValues()) {
|
|
2853
|
-
out = out.split(supplied).join(REDACTED);
|
|
3001
|
+
if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
|
|
3002
|
+
context.traceId = parsedBody.traceId;
|
|
2854
3003
|
}
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
var MESSAGE_NAMES = new Set([
|
|
2858
|
-
"message",
|
|
2859
|
-
"errormessage",
|
|
2860
|
-
"errmessage",
|
|
2861
|
-
"error_message",
|
|
2862
|
-
"msg",
|
|
2863
|
-
"detail",
|
|
2864
|
-
"details",
|
|
2865
|
-
"reason",
|
|
2866
|
-
"instructions",
|
|
2867
|
-
"warning"
|
|
2868
|
-
]);
|
|
2869
|
-
function isFreeFormValue(name, value) {
|
|
2870
|
-
return MESSAGE_NAMES.has(name.toLowerCase()) || /['"{[]/.test(value);
|
|
2871
|
-
}
|
|
2872
|
-
function redactError(error) {
|
|
2873
|
-
const safe = new Error(redactMessage(error.message ?? ""));
|
|
2874
|
-
safe.name = error.name;
|
|
2875
|
-
safe.stack = typeof error.stack === "string" ? redactStack(error.stack) : undefined;
|
|
2876
|
-
return safe;
|
|
2877
|
-
}
|
|
2878
|
-
function redactStack(stack) {
|
|
2879
|
-
const bounded = truncate(stack, MAX_STACK_LENGTH);
|
|
2880
|
-
const firstBreak = bounded.indexOf(`
|
|
2881
|
-
`);
|
|
2882
|
-
if (firstBreak === -1) {
|
|
2883
|
-
return redactMessage(bounded);
|
|
3004
|
+
if (permission?.path !== undefined) {
|
|
3005
|
+
context.path = permission.path;
|
|
2884
3006
|
}
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
function isSensitiveName(name) {
|
|
2892
|
-
const tokens = nameTokens(name);
|
|
2893
|
-
for (let i = 0;i < tokens.length; i++) {
|
|
2894
|
-
const token = tokens[i];
|
|
2895
|
-
if (SENSITIVE_NAME_TOKENS.has(token)) {
|
|
2896
|
-
return true;
|
|
3007
|
+
if (status === 429) {
|
|
3008
|
+
const resp = response;
|
|
3009
|
+
const headersObj = resp?.headers;
|
|
3010
|
+
let retryAfterValue;
|
|
3011
|
+
if (headersObj && typeof headersObj === "object" && typeof headersObj.get === "function") {
|
|
3012
|
+
retryAfterValue = headersObj.get("retry-after") ?? undefined;
|
|
2897
3013
|
}
|
|
2898
|
-
if (
|
|
2899
|
-
const
|
|
2900
|
-
|
|
2901
|
-
|
|
3014
|
+
if (!retryAfterValue && headersObj && typeof headersObj === "object") {
|
|
3015
|
+
const headers = headersObj;
|
|
3016
|
+
retryAfterValue = headers["retry-after"] ?? headers["Retry-After"];
|
|
3017
|
+
}
|
|
3018
|
+
if (retryAfterValue) {
|
|
3019
|
+
const seconds = Number(retryAfterValue);
|
|
3020
|
+
if (!Number.isNaN(seconds)) {
|
|
3021
|
+
context.retryAfter = seconds;
|
|
3022
|
+
retry = retryHintForRetryAfter(seconds);
|
|
2902
3023
|
}
|
|
2903
3024
|
}
|
|
2904
3025
|
}
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
3026
|
+
const hasContext = Object.keys(context).length > 0;
|
|
3027
|
+
let parsedErrors;
|
|
3028
|
+
if (parsedBody?.errors && typeof parsedBody.errors === "object") {
|
|
3029
|
+
const errors = {};
|
|
3030
|
+
for (const [field, raw] of Object.entries(parsedBody.errors)) {
|
|
3031
|
+
if (Array.isArray(raw)) {
|
|
3032
|
+
const messages = raw.map((entry) => {
|
|
3033
|
+
if (typeof entry === "string")
|
|
3034
|
+
return entry;
|
|
3035
|
+
if (entry && typeof entry === "object" && typeof entry.message === "string") {
|
|
3036
|
+
return entry.message;
|
|
3037
|
+
}
|
|
3038
|
+
return String(entry);
|
|
3039
|
+
}).filter(Boolean);
|
|
3040
|
+
if (messages.length > 0)
|
|
3041
|
+
errors[field] = messages;
|
|
3042
|
+
} else if (typeof raw === "string") {
|
|
3043
|
+
errors[field] = [raw];
|
|
3044
|
+
}
|
|
3045
|
+
}
|
|
3046
|
+
if (Object.keys(errors).length > 0)
|
|
3047
|
+
parsedErrors = errors;
|
|
2916
3048
|
}
|
|
2917
|
-
|
|
2918
|
-
|
|
3049
|
+
return {
|
|
3050
|
+
result,
|
|
3051
|
+
errorCode: classification.errorCode,
|
|
3052
|
+
message,
|
|
3053
|
+
retry,
|
|
3054
|
+
details,
|
|
3055
|
+
...hasContext ? { context } : {},
|
|
3056
|
+
...parsedErrors ? { parsedErrors } : {}
|
|
3057
|
+
};
|
|
3058
|
+
}
|
|
3059
|
+
async function extractErrorMessage(error, options) {
|
|
3060
|
+
const { message } = await extractErrorDetails(error, options);
|
|
3061
|
+
return message;
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3064
|
+
// ../common/src/mime-types.ts
|
|
3065
|
+
var OCTET_STREAM = "application/octet-stream";
|
|
3066
|
+
var MIME_TYPES_BY_EXTENSION = Object.freeze({
|
|
3067
|
+
pdf: "application/pdf",
|
|
3068
|
+
png: "image/png",
|
|
3069
|
+
jpg: "image/jpeg",
|
|
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;
|
|
2919
3103
|
}
|
|
2920
|
-
|
|
3104
|
+
const extension = fileName.slice(dot + 1).toLowerCase();
|
|
3105
|
+
return Object.hasOwn(MIME_TYPES_BY_EXTENSION, extension) ? MIME_TYPES_BY_EXTENSION[extension] : OCTET_STREAM;
|
|
2921
3106
|
}
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
3107
|
+
|
|
3108
|
+
// ../common/src/telemetry/global-telemetry-properties.ts
|
|
3109
|
+
var telemetryPropsSlot = singleton("TelemetryDefaultProps");
|
|
3110
|
+
function getGlobalTelemetryProperties() {
|
|
3111
|
+
return telemetryPropsSlot.get();
|
|
3112
|
+
}
|
|
3113
|
+
|
|
3114
|
+
// ../common/src/telemetry/telemetry-dimensions.ts
|
|
3115
|
+
var BaseDimensions = {
|
|
3116
|
+
ApplicationName: "ApplicationName",
|
|
3117
|
+
ProductVersion: "ProductVersion",
|
|
3118
|
+
InstallationId: "InstallationId",
|
|
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
|
+
};
|
|
3169
|
+
var AuthDimensions = {
|
|
3170
|
+
AuthenticationMethod: "AuthenticationMethod",
|
|
3171
|
+
Success: "Success",
|
|
3172
|
+
Reason: "Reason"
|
|
3173
|
+
};
|
|
3174
|
+
var SkillsDimensions = {
|
|
3175
|
+
SchemaVersion: "SchemaVersion",
|
|
3176
|
+
AgentType: "AgentType",
|
|
3177
|
+
SkillsVersion: "SkillsVersion",
|
|
3178
|
+
UipSubcommand: "UipSubcommand",
|
|
3179
|
+
FileExtension: "FileExtension",
|
|
3180
|
+
SubagentModel: "SubagentModel",
|
|
3181
|
+
SubagentType: "SubagentType",
|
|
3182
|
+
PermissionMode: "PermissionMode",
|
|
3183
|
+
EffortLevel: "EffortLevel",
|
|
3184
|
+
SessionSource: "SessionSource",
|
|
3185
|
+
Outcome: "Outcome",
|
|
3186
|
+
DurationMs: "DurationMs",
|
|
3187
|
+
Source: "Source"
|
|
3188
|
+
};
|
|
3189
|
+
var PackagerDimensions = {
|
|
3190
|
+
ProjectId: "ProjectId",
|
|
3191
|
+
ProjectType: "ProjectType",
|
|
3192
|
+
SolutionId: "SolutionId"
|
|
3193
|
+
};
|
|
3194
|
+
var ScopeDimensions = {
|
|
3195
|
+
FolderId: "FolderId"
|
|
3196
|
+
};
|
|
3197
|
+
var ID_DIMENSIONS = new Set([
|
|
3198
|
+
BaseDimensions.CloudUserId,
|
|
3199
|
+
BaseDimensions.CloudTenantId,
|
|
3200
|
+
BaseDimensions.CloudOrganizationId,
|
|
3201
|
+
BaseDimensions.InstallationId,
|
|
3202
|
+
ShipDimensions.ArtifactCorrelationKey,
|
|
3203
|
+
ShipDimensions.PackageVersionKey,
|
|
3204
|
+
ShipDimensions.DeploymentKey,
|
|
3205
|
+
ShipDimensions.SolutionId,
|
|
3206
|
+
ShipDimensions.FolderKey,
|
|
3207
|
+
ShipDimensions.FeedId,
|
|
3208
|
+
PackagerDimensions.ProjectId
|
|
3209
|
+
]);
|
|
3210
|
+
var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
|
|
3211
|
+
var RESERVED_DIMENSION_NAMES = new Set([
|
|
3212
|
+
...Object.values(BaseDimensions),
|
|
3213
|
+
...Object.values(CommandDimensions),
|
|
3214
|
+
...Object.values(ShipDimensions),
|
|
3215
|
+
...Object.values(ErrorDimensions),
|
|
3216
|
+
...Object.values(AuthDimensions),
|
|
3217
|
+
...Object.values(SkillsDimensions),
|
|
3218
|
+
...Object.values(PackagerDimensions),
|
|
3219
|
+
...Object.values(ScopeDimensions)
|
|
3220
|
+
]);
|
|
3221
|
+
var CURATED_DIMENSIONS = new Set([
|
|
3222
|
+
BaseDimensions.ApplicationName,
|
|
3223
|
+
BaseDimensions.ProductVersion,
|
|
3224
|
+
BaseDimensions.InstallationId,
|
|
3225
|
+
BaseDimensions.CloudUserId,
|
|
3226
|
+
BaseDimensions.CloudTenantId,
|
|
3227
|
+
BaseDimensions.CloudOrganizationId,
|
|
3228
|
+
BaseDimensions.IsInternalUser,
|
|
3229
|
+
BaseDimensions.Environment,
|
|
3230
|
+
BaseDimensions.BaseUrl,
|
|
3231
|
+
BaseDimensions.Region,
|
|
3232
|
+
BaseDimensions.Agent,
|
|
3233
|
+
BaseDimensions.AgentVersion,
|
|
3234
|
+
BaseDimensions.ToolVersion,
|
|
3235
|
+
BaseDimensions.ExecutionContext,
|
|
3236
|
+
BaseDimensions.CiProvider,
|
|
3237
|
+
BaseDimensions.SessionIdSource,
|
|
3238
|
+
BaseDimensions.SessionId,
|
|
3239
|
+
...Object.values(CommandDimensions),
|
|
3240
|
+
...Object.values(ShipDimensions)
|
|
3241
|
+
]);
|
|
3242
|
+
function lowercaseIdDimensionValues(properties) {
|
|
3243
|
+
let changed = false;
|
|
3244
|
+
const result = {
|
|
3245
|
+
...properties
|
|
3246
|
+
};
|
|
3247
|
+
for (const key of Object.keys(result)) {
|
|
3248
|
+
const value = result[key];
|
|
3249
|
+
if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
|
|
3250
|
+
continue;
|
|
3251
|
+
}
|
|
3252
|
+
const lowered = value.toLowerCase();
|
|
3253
|
+
if (lowered !== value) {
|
|
3254
|
+
result[key] = lowered;
|
|
3255
|
+
changed = true;
|
|
2928
3256
|
}
|
|
2929
3257
|
}
|
|
2930
|
-
return
|
|
3258
|
+
return changed ? result : properties;
|
|
2931
3259
|
}
|
|
2932
3260
|
|
|
2933
|
-
// ../common/src/
|
|
2934
|
-
var
|
|
2935
|
-
var
|
|
2936
|
-
var
|
|
2937
|
-
function
|
|
2938
|
-
return
|
|
3261
|
+
// ../common/src/sdk-user-agent.ts
|
|
3262
|
+
var USER_AGENT_HEADER = "User-Agent";
|
|
3263
|
+
var AGENT_PROPERTY = BaseDimensions.Agent;
|
|
3264
|
+
var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
|
|
3265
|
+
function userAgentPatchKey(userAgent) {
|
|
3266
|
+
return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
|
|
2939
3267
|
}
|
|
2940
|
-
function
|
|
2941
|
-
return
|
|
3268
|
+
function splitUserAgentTokens(value) {
|
|
3269
|
+
return value?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
2942
3270
|
}
|
|
2943
|
-
function
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
} catch {
|
|
2951
|
-
message = undefined;
|
|
2952
|
-
}
|
|
2953
|
-
if (typeof message === "string" && message.length > 0) {
|
|
2954
|
-
return cap(message);
|
|
2955
|
-
}
|
|
2956
|
-
try {
|
|
2957
|
-
const json = JSON.stringify(value, omitSensitive);
|
|
2958
|
-
if (json !== undefined) {
|
|
2959
|
-
return cap(json);
|
|
3271
|
+
function appendUserAgentToken(value, userAgent) {
|
|
3272
|
+
const tokens = splitUserAgentTokens(value);
|
|
3273
|
+
const seen = new Set(tokens);
|
|
3274
|
+
for (const token of splitUserAgentTokens(userAgent)) {
|
|
3275
|
+
if (!seen.has(token)) {
|
|
3276
|
+
tokens.push(token);
|
|
3277
|
+
seen.add(token);
|
|
2960
3278
|
}
|
|
2961
|
-
}
|
|
2962
|
-
return
|
|
2963
|
-
}
|
|
2964
|
-
function toError(error) {
|
|
2965
|
-
return error instanceof Error ? error : new Error(describeThrownValue(error), { cause: error });
|
|
3279
|
+
}
|
|
3280
|
+
return tokens.join(" ");
|
|
2966
3281
|
}
|
|
2967
|
-
function
|
|
2968
|
-
return
|
|
3282
|
+
function getEffectiveUserAgent(userAgent) {
|
|
3283
|
+
return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
|
|
2969
3284
|
}
|
|
2970
|
-
function
|
|
2971
|
-
|
|
2972
|
-
return settlePromiseLike(fnOrPromise);
|
|
2973
|
-
}
|
|
2974
|
-
try {
|
|
2975
|
-
const result = fnOrPromise();
|
|
2976
|
-
if (isPromiseLike(result)) {
|
|
2977
|
-
return settlePromiseLike(result);
|
|
2978
|
-
}
|
|
2979
|
-
return [undefined, result];
|
|
2980
|
-
} catch (error) {
|
|
2981
|
-
return [toError(error), undefined];
|
|
2982
|
-
}
|
|
3285
|
+
function getHeaderName(headers, headerName) {
|
|
3286
|
+
return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase());
|
|
2983
3287
|
}
|
|
2984
|
-
function
|
|
2985
|
-
|
|
3288
|
+
function getSdkUserAgentToken(pkg) {
|
|
3289
|
+
const packageName = pkg.name.replace(/^@uipath\//, "");
|
|
3290
|
+
return getEffectiveUserAgent(`${packageName}/${pkg.version}`);
|
|
2986
3291
|
}
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
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.";
|
|
2993
|
-
var HTML_RESPONSE_MESSAGE = "Received HTML instead of the expected JSON response.";
|
|
2994
|
-
var NETWORK_ERROR_CODES = new Set([
|
|
2995
|
-
"ECONNREFUSED",
|
|
2996
|
-
"ECONNRESET",
|
|
2997
|
-
"ENOTFOUND",
|
|
2998
|
-
"EAI_AGAIN",
|
|
2999
|
-
"ETIMEDOUT",
|
|
3000
|
-
"EPIPE",
|
|
3001
|
-
"EHOSTUNREACH",
|
|
3002
|
-
"ENETUNREACH",
|
|
3003
|
-
"EAI_FAIL"
|
|
3004
|
-
]);
|
|
3005
|
-
var TLS_ERROR_CODES = new Set([
|
|
3006
|
-
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
3007
|
-
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
3008
|
-
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
3009
|
-
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
3010
|
-
"UNABLE_TO_GET_ISSUER_CERT",
|
|
3011
|
-
"CERT_HAS_EXPIRED",
|
|
3012
|
-
"CERT_UNTRUSTED",
|
|
3013
|
-
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
3014
|
-
]);
|
|
3015
|
-
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.";
|
|
3016
|
-
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.";
|
|
3017
|
-
var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
|
|
3018
|
-
var LOCAL_PERMISSION_MESSAGE_PATTERN = /\b(EACCES|EPERM|EROFS)\b/;
|
|
3019
|
-
function localPermissionInstructions(code, path) {
|
|
3020
|
-
const target = path !== undefined ? `'${path}'` : "a local file or resource";
|
|
3021
|
-
if (code === "EROFS") {
|
|
3022
|
-
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.";
|
|
3023
|
-
}
|
|
3024
|
-
const remedy = process.platform === "win32" ? "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.";
|
|
3025
|
-
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}`;
|
|
3292
|
+
function addSdkUserAgentHeader(headers, userAgent) {
|
|
3293
|
+
const result = { ...headers ?? {} };
|
|
3294
|
+
const headerName = getHeaderName(result, USER_AGENT_HEADER);
|
|
3295
|
+
result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent));
|
|
3296
|
+
return result;
|
|
3026
3297
|
}
|
|
3027
|
-
function
|
|
3028
|
-
|
|
3029
|
-
const code = typeof cur.code === "string" ? cur.code : undefined;
|
|
3030
|
-
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
3031
|
-
if (code && TLS_ERROR_CODES.has(code)) {
|
|
3032
|
-
return {
|
|
3033
|
-
code,
|
|
3034
|
-
kind: "tls",
|
|
3035
|
-
message: message ?? code,
|
|
3036
|
-
instructions: TLS_INSTRUCTIONS
|
|
3037
|
-
};
|
|
3038
|
-
}
|
|
3039
|
-
if (code && NETWORK_ERROR_CODES.has(code)) {
|
|
3040
|
-
return {
|
|
3041
|
-
code,
|
|
3042
|
-
kind: "network",
|
|
3043
|
-
message: message ?? code,
|
|
3044
|
-
instructions: NETWORK_INSTRUCTIONS
|
|
3045
|
-
};
|
|
3046
|
-
}
|
|
3047
|
-
}
|
|
3048
|
-
return;
|
|
3298
|
+
function asHeaderRecord(headers) {
|
|
3299
|
+
return typeof headers === "object" && headers !== null ? { ...headers } : {};
|
|
3049
3300
|
}
|
|
3050
|
-
function
|
|
3051
|
-
|
|
3052
|
-
const
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
const
|
|
3301
|
+
function withForwardedHeadersInitOverride(initOverrides, forward) {
|
|
3302
|
+
return async (requestContext) => {
|
|
3303
|
+
const initWithHeaders = {
|
|
3304
|
+
...requestContext.init,
|
|
3305
|
+
headers: forward(asHeaderRecord(requestContext.init.headers))
|
|
3306
|
+
};
|
|
3307
|
+
const override = typeof initOverrides === "function" ? await initOverrides({
|
|
3308
|
+
...requestContext,
|
|
3309
|
+
init: initWithHeaders
|
|
3310
|
+
}) : initOverrides;
|
|
3057
3311
|
return {
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
...path !== undefined ? { path } : {},
|
|
3061
|
-
instructions: localPermissionInstructions(code, path)
|
|
3312
|
+
...override ?? {},
|
|
3313
|
+
headers: forward(asHeaderRecord(override?.headers ?? initWithHeaders.headers))
|
|
3062
3314
|
};
|
|
3063
|
-
}
|
|
3064
|
-
return;
|
|
3315
|
+
};
|
|
3065
3316
|
}
|
|
3066
|
-
function
|
|
3067
|
-
|
|
3068
|
-
|
|
3317
|
+
function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
|
|
3318
|
+
const prototype = BaseApiClass.prototype;
|
|
3319
|
+
if (prototype[patchKey]) {
|
|
3320
|
+
return;
|
|
3069
3321
|
}
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
}
|
|
3073
|
-
function localPermissionPath(path, message) {
|
|
3074
|
-
if (typeof path === "string")
|
|
3075
|
-
return path;
|
|
3076
|
-
return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
|
|
3077
|
-
}
|
|
3078
|
-
function* walkErrorGraph(error) {
|
|
3079
|
-
const queue = [error];
|
|
3080
|
-
const seen = new Set;
|
|
3081
|
-
for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
|
|
3082
|
-
const current = queue.shift();
|
|
3083
|
-
if (current === null || typeof current !== "object")
|
|
3084
|
-
continue;
|
|
3085
|
-
if (seen.has(current))
|
|
3086
|
-
continue;
|
|
3087
|
-
seen.add(current);
|
|
3088
|
-
const cur = current;
|
|
3089
|
-
yield cur;
|
|
3090
|
-
if (cur.cause !== undefined)
|
|
3091
|
-
queue.push(cur.cause);
|
|
3092
|
-
if (Array.isArray(cur.errors))
|
|
3093
|
-
queue.push(...cur.errors);
|
|
3322
|
+
if (typeof prototype.request !== "function") {
|
|
3323
|
+
throw new Error("Generated BaseAPI request function not found.");
|
|
3094
3324
|
}
|
|
3095
|
-
|
|
3325
|
+
const originalRequest = prototype.request;
|
|
3326
|
+
prototype.request = function requestWithForwardedHeaders(context, initOverrides) {
|
|
3327
|
+
return originalRequest.call(this, context, withForwardedHeadersInitOverride(initOverrides, forward));
|
|
3328
|
+
};
|
|
3329
|
+
Object.defineProperty(prototype, patchKey, {
|
|
3330
|
+
value: true
|
|
3331
|
+
});
|
|
3096
3332
|
}
|
|
3097
|
-
function
|
|
3098
|
-
|
|
3099
|
-
if (!match)
|
|
3100
|
-
return;
|
|
3101
|
-
const status = Number(match[1]);
|
|
3102
|
-
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
3333
|
+
function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
3334
|
+
installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
|
|
3103
3335
|
}
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3336
|
+
|
|
3337
|
+
// ../filesystem/src/node.ts
|
|
3338
|
+
import { randomUUID } from "node:crypto";
|
|
3339
|
+
import { existsSync } from "node:fs";
|
|
3340
|
+
import * as fs from "node:fs/promises";
|
|
3341
|
+
import * as os from "node:os";
|
|
3342
|
+
import * as path from "node:path";
|
|
3343
|
+
var LOCK_HEARTBEAT_MS = 5000;
|
|
3344
|
+
var LOCK_STALE_MS = 15000;
|
|
3345
|
+
var LOCK_MAX_WAIT_MS = 20000;
|
|
3346
|
+
var LOCK_MAX_HOLD_MS = 60000;
|
|
3347
|
+
var LOCK_RETRY_MIN_MS = 100;
|
|
3348
|
+
var LOCK_RETRY_JITTER_MS = 200;
|
|
3349
|
+
|
|
3350
|
+
class NodeFileSystem {
|
|
3351
|
+
path = {
|
|
3352
|
+
join: path.join,
|
|
3353
|
+
resolve: path.resolve,
|
|
3354
|
+
relative: path.relative,
|
|
3355
|
+
dirname: path.dirname,
|
|
3356
|
+
isAbsolute: path.isAbsolute,
|
|
3357
|
+
basename: path.basename
|
|
3358
|
+
};
|
|
3359
|
+
env = {
|
|
3360
|
+
cwd: process.cwd,
|
|
3361
|
+
homedir: os.homedir,
|
|
3362
|
+
tmpdir: os.tmpdir,
|
|
3363
|
+
getenv: (key) => process.env[key]
|
|
3364
|
+
};
|
|
3365
|
+
utils = {
|
|
3366
|
+
open: async (url) => {
|
|
3367
|
+
const { default: open } = await import("./index-sby22td6.js");
|
|
3368
|
+
await open(url);
|
|
3110
3369
|
}
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3370
|
+
};
|
|
3371
|
+
async readFile(path2, options) {
|
|
3372
|
+
try {
|
|
3373
|
+
if (options) {
|
|
3374
|
+
return await fs.readFile(path2, "utf-8");
|
|
3115
3375
|
}
|
|
3376
|
+
return await fs.readFile(path2);
|
|
3377
|
+
} catch (error) {
|
|
3378
|
+
if (this.isEnoent(error))
|
|
3379
|
+
return null;
|
|
3380
|
+
throw error;
|
|
3116
3381
|
}
|
|
3117
3382
|
}
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
}
|
|
3123
|
-
|
|
3124
|
-
if (seconds <= 1) {
|
|
3125
|
-
return "RetryAfter1Second";
|
|
3126
|
-
}
|
|
3127
|
-
if (seconds <= 10) {
|
|
3128
|
-
return "RetryAfter10Seconds";
|
|
3129
|
-
}
|
|
3130
|
-
if (seconds <= 30) {
|
|
3131
|
-
return "RetryAfter30Seconds";
|
|
3132
|
-
}
|
|
3133
|
-
return "RetryAfter60Seconds";
|
|
3134
|
-
}
|
|
3135
|
-
function classifyError(status, error) {
|
|
3136
|
-
if (status === 400 || status === 409 || status === 422) {
|
|
3137
|
-
return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
|
|
3138
|
-
}
|
|
3139
|
-
if (status === 401) {
|
|
3140
|
-
return {
|
|
3141
|
-
errorCode: "authentication_required",
|
|
3142
|
-
retry: "RetryWillNotFix"
|
|
3143
|
-
};
|
|
3144
|
-
}
|
|
3145
|
-
if (status === 403) {
|
|
3146
|
-
return { errorCode: "permission_denied", retry: "RetryWillNotFix" };
|
|
3147
|
-
}
|
|
3148
|
-
if (status === 404) {
|
|
3149
|
-
return { errorCode: "not_found", retry: "RetryWillNotFix" };
|
|
3150
|
-
}
|
|
3151
|
-
if (status === 405) {
|
|
3152
|
-
return { errorCode: "method_not_allowed", retry: "RetryWillNotFix" };
|
|
3153
|
-
}
|
|
3154
|
-
if (status === 413) {
|
|
3155
|
-
return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
|
|
3156
|
-
}
|
|
3157
|
-
if (status === 408) {
|
|
3158
|
-
return { errorCode: "timeout", retry: "RetryLater" };
|
|
3383
|
+
async writeFile(filePath, data) {
|
|
3384
|
+
const dir = path.dirname(filePath);
|
|
3385
|
+
if (dir) {
|
|
3386
|
+
await fs.mkdir(dir, { recursive: true });
|
|
3387
|
+
}
|
|
3388
|
+
await fs.writeFile(filePath, data);
|
|
3159
3389
|
}
|
|
3160
|
-
|
|
3161
|
-
|
|
3390
|
+
async appendFile(filePath, data) {
|
|
3391
|
+
const dir = path.dirname(filePath);
|
|
3392
|
+
if (dir) {
|
|
3393
|
+
await fs.mkdir(dir, { recursive: true });
|
|
3394
|
+
}
|
|
3395
|
+
await fs.appendFile(filePath, data);
|
|
3162
3396
|
}
|
|
3163
|
-
|
|
3164
|
-
|
|
3397
|
+
async readdir(dirPath) {
|
|
3398
|
+
try {
|
|
3399
|
+
return await fs.readdir(dirPath);
|
|
3400
|
+
} catch (error) {
|
|
3401
|
+
if (this.isEnoent(error))
|
|
3402
|
+
return [];
|
|
3403
|
+
throw error;
|
|
3404
|
+
}
|
|
3165
3405
|
}
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3406
|
+
async stat(filePath) {
|
|
3407
|
+
try {
|
|
3408
|
+
const stats = await fs.stat(filePath);
|
|
3409
|
+
return {
|
|
3410
|
+
isFile: () => stats.isFile(),
|
|
3411
|
+
isDirectory: () => stats.isDirectory(),
|
|
3412
|
+
size: stats.size,
|
|
3413
|
+
mtimeMs: stats.mtimeMs
|
|
3414
|
+
};
|
|
3415
|
+
} catch (error) {
|
|
3416
|
+
if (this.isEnoent(error))
|
|
3417
|
+
return null;
|
|
3418
|
+
throw error;
|
|
3419
|
+
}
|
|
3171
3420
|
}
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
return {
|
|
3175
|
-
errorCode: "network_error",
|
|
3176
|
-
retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
|
|
3177
|
-
};
|
|
3421
|
+
async exists(filePath) {
|
|
3422
|
+
return existsSync(filePath);
|
|
3178
3423
|
}
|
|
3179
|
-
|
|
3180
|
-
}
|
|
3181
|
-
function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
|
|
3182
|
-
if (extractedMessage) {
|
|
3183
|
-
return `HTTP ${status}: ${extractedMessage}`;
|
|
3424
|
+
async mkdir(dirPath) {
|
|
3425
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
3184
3426
|
}
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
let parsedBody;
|
|
3198
|
-
const textFn = response?.text?.bind(response);
|
|
3199
|
-
if (textFn) {
|
|
3200
|
-
const [bodyError, body] = await catchError((async () => textFn())());
|
|
3201
|
-
if (!bodyError && body) {
|
|
3202
|
-
rawBody = body;
|
|
3203
|
-
const [parseError, parsed] = catchError(() => JSON.parse(body));
|
|
3204
|
-
if (!parseError && parsed && typeof parsed === "object") {
|
|
3205
|
-
parsedBody = parsed;
|
|
3206
|
-
if (parsedBody.errors && typeof parsedBody.errors === "object") {
|
|
3207
|
-
for (const field of Object.values(parsedBody.errors)) {
|
|
3208
|
-
if (Array.isArray(field) && field.length > 0) {
|
|
3209
|
-
const first = field[0];
|
|
3210
|
-
if (first && typeof first.message === "string") {
|
|
3211
|
-
extractedMessage = first.message;
|
|
3212
|
-
break;
|
|
3213
|
-
}
|
|
3214
|
-
}
|
|
3215
|
-
}
|
|
3216
|
-
}
|
|
3217
|
-
if (!extractedMessage) {
|
|
3218
|
-
extractedMessage = typeof parsedBody.message === "string" ? parsedBody.message : typeof parsedBody.errorMessage === "string" ? parsedBody.errorMessage : typeof parsedBody.title === "string" ? parsedBody.title : undefined;
|
|
3427
|
+
async acquireLock(lockPath) {
|
|
3428
|
+
const canonicalPath = await this.canonicalizeLockTarget(lockPath);
|
|
3429
|
+
const lockFile = `${canonicalPath}.lock`;
|
|
3430
|
+
const ownerId = randomUUID();
|
|
3431
|
+
const start = Date.now();
|
|
3432
|
+
while (true) {
|
|
3433
|
+
try {
|
|
3434
|
+
await fs.writeFile(lockFile, ownerId, { flag: "wx" });
|
|
3435
|
+
return this.createLockRelease(lockFile, ownerId);
|
|
3436
|
+
} catch (error) {
|
|
3437
|
+
if (!this.hasErrnoCode(error, "EEXIST")) {
|
|
3438
|
+
throw error;
|
|
3219
3439
|
}
|
|
3220
|
-
|
|
3221
|
-
|
|
3440
|
+
const stats = await fs.stat(lockFile).catch(() => null);
|
|
3441
|
+
if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
|
|
3442
|
+
const reclaimed = await fs.rm(lockFile, { force: true }).then(() => true).catch(() => false);
|
|
3443
|
+
if (reclaimed)
|
|
3444
|
+
continue;
|
|
3222
3445
|
}
|
|
3223
|
-
if (
|
|
3224
|
-
|
|
3446
|
+
if (Date.now() - start > LOCK_MAX_WAIT_MS) {
|
|
3447
|
+
throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
|
|
3225
3448
|
}
|
|
3226
|
-
|
|
3227
|
-
extractedMessage = isHtmlDocument(body) ? HTML_RESPONSE_MESSAGE : body;
|
|
3449
|
+
await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
|
|
3228
3450
|
}
|
|
3229
3451
|
}
|
|
3230
3452
|
}
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
message = options?.forbiddenMessage ?? DEFAULT_403;
|
|
3241
|
-
result = "AuthenticationError";
|
|
3242
|
-
} else if (status === 405) {
|
|
3243
|
-
message = DEFAULT_405;
|
|
3244
|
-
} else if (status === 413) {
|
|
3245
|
-
message = DEFAULT_413;
|
|
3246
|
-
} else if (status === 400 || status === 422) {
|
|
3247
|
-
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
3248
|
-
result = "ValidationError";
|
|
3249
|
-
} else if (status === 429) {
|
|
3250
|
-
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
3251
|
-
} else if (extractedMessage) {
|
|
3252
|
-
if (isSuccessfulResponse && rawMessage !== "Unknown error") {
|
|
3253
|
-
message = rawMessage;
|
|
3254
|
-
} else {
|
|
3255
|
-
message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
|
|
3256
|
-
}
|
|
3257
|
-
} else if (status) {
|
|
3258
|
-
if (inferredStatus !== undefined) {
|
|
3259
|
-
message = rawMessage;
|
|
3260
|
-
} else if (rawMessage === "Unknown error" && response) {
|
|
3261
|
-
const statusText = response.statusText;
|
|
3262
|
-
message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
|
|
3263
|
-
} else {
|
|
3264
|
-
message = `HTTP ${status}: ${rawMessage}`;
|
|
3265
|
-
}
|
|
3266
|
-
} else {
|
|
3267
|
-
message = rawMessage;
|
|
3268
|
-
}
|
|
3269
|
-
if (status === undefined) {
|
|
3270
|
-
const connectivity = describeConnectivityError(error);
|
|
3271
|
-
if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
|
|
3272
|
-
message = `${message}: ${connectivity.message}`;
|
|
3273
|
-
}
|
|
3274
|
-
}
|
|
3275
|
-
const permission = status === undefined ? describePermissionError(error) : undefined;
|
|
3276
|
-
if (permission) {
|
|
3277
|
-
if (permission.message !== message && !message.includes(permission.message)) {
|
|
3278
|
-
message = `${message}: ${permission.message}`;
|
|
3279
|
-
}
|
|
3280
|
-
if (!message.includes(permission.instructions)) {
|
|
3281
|
-
const punctuated = message.endsWith(".") ? message : `${message}.`;
|
|
3282
|
-
message = `${punctuated} ${permission.instructions}`;
|
|
3283
|
-
}
|
|
3453
|
+
async canonicalizeLockTarget(lockPath) {
|
|
3454
|
+
const absolute = path.resolve(lockPath);
|
|
3455
|
+
const fullReal = await fs.realpath(absolute).catch(() => null);
|
|
3456
|
+
if (fullReal)
|
|
3457
|
+
return fullReal;
|
|
3458
|
+
const parent = path.dirname(absolute);
|
|
3459
|
+
const base = path.basename(absolute);
|
|
3460
|
+
const canonicalParent = await fs.realpath(parent).catch(() => parent);
|
|
3461
|
+
return path.join(canonicalParent, base);
|
|
3284
3462
|
}
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
if (
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
if (
|
|
3296
|
-
|
|
3297
|
-
if (
|
|
3298
|
-
|
|
3463
|
+
createLockRelease(lockFile, ownerId) {
|
|
3464
|
+
const heartbeatStart = Date.now();
|
|
3465
|
+
let heartbeatTimer;
|
|
3466
|
+
let stopped = false;
|
|
3467
|
+
const stopHeartbeat = () => {
|
|
3468
|
+
stopped = true;
|
|
3469
|
+
if (heartbeatTimer)
|
|
3470
|
+
clearTimeout(heartbeatTimer);
|
|
3471
|
+
};
|
|
3472
|
+
const scheduleNextHeartbeat = () => {
|
|
3473
|
+
if (stopped)
|
|
3474
|
+
return;
|
|
3475
|
+
if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) {
|
|
3476
|
+
stopped = true;
|
|
3477
|
+
return;
|
|
3299
3478
|
}
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3479
|
+
heartbeatTimer = setTimeout(() => {
|
|
3480
|
+
runHeartbeat();
|
|
3481
|
+
}, LOCK_HEARTBEAT_MS);
|
|
3482
|
+
heartbeatTimer.unref?.();
|
|
3483
|
+
};
|
|
3484
|
+
const runHeartbeat = async () => {
|
|
3485
|
+
if (stopped)
|
|
3486
|
+
return;
|
|
3487
|
+
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
3488
|
+
if (stopped)
|
|
3489
|
+
return;
|
|
3490
|
+
if (current !== ownerId) {
|
|
3491
|
+
stopped = true;
|
|
3492
|
+
return;
|
|
3493
|
+
}
|
|
3494
|
+
const now = Date.now() / 1000;
|
|
3495
|
+
await fs.utimes(lockFile, now, now).catch(() => {});
|
|
3496
|
+
scheduleNextHeartbeat();
|
|
3497
|
+
};
|
|
3498
|
+
scheduleNextHeartbeat();
|
|
3499
|
+
let released = false;
|
|
3500
|
+
return async () => {
|
|
3501
|
+
if (released)
|
|
3502
|
+
return;
|
|
3503
|
+
released = true;
|
|
3504
|
+
stopHeartbeat();
|
|
3505
|
+
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
3506
|
+
if (current === ownerId) {
|
|
3507
|
+
await fs.rm(lockFile, { force: true });
|
|
3508
|
+
}
|
|
3509
|
+
};
|
|
3312
3510
|
}
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
} else if (parsedBody?.code && typeof parsedBody.code === "string") {
|
|
3316
|
-
context.errorCode = parsedBody.code;
|
|
3511
|
+
async rm(filePath) {
|
|
3512
|
+
await fs.rm(filePath, { recursive: true, force: true });
|
|
3317
3513
|
}
|
|
3318
|
-
|
|
3319
|
-
|
|
3514
|
+
async rename(oldPath, newPath) {
|
|
3515
|
+
await fs.rename(oldPath, newPath);
|
|
3320
3516
|
}
|
|
3321
|
-
|
|
3322
|
-
|
|
3517
|
+
async realpath(filePath) {
|
|
3518
|
+
try {
|
|
3519
|
+
return await fs.realpath(filePath);
|
|
3520
|
+
} catch (error) {
|
|
3521
|
+
if (this.isEnoent(error))
|
|
3522
|
+
return filePath;
|
|
3523
|
+
throw error;
|
|
3524
|
+
}
|
|
3323
3525
|
}
|
|
3324
|
-
|
|
3325
|
-
|
|
3526
|
+
async getTempDir() {
|
|
3527
|
+
return await fs.mkdtemp(path.join(os.tmpdir(), "uipath-fs-"));
|
|
3326
3528
|
}
|
|
3327
|
-
|
|
3328
|
-
const
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
if (headersObj && typeof headersObj === "object" && typeof headersObj.get === "function") {
|
|
3332
|
-
retryAfterValue = headersObj.get("retry-after") ?? undefined;
|
|
3529
|
+
async copyDirectory(sourcePath, destPath) {
|
|
3530
|
+
const sourceStats = await this.stat(sourcePath);
|
|
3531
|
+
if (!sourceStats) {
|
|
3532
|
+
throw new Error(`Source directory does not exist: ${sourcePath}`);
|
|
3333
3533
|
}
|
|
3334
|
-
if (!
|
|
3335
|
-
|
|
3336
|
-
retryAfterValue = headers["retry-after"] ?? headers["Retry-After"];
|
|
3534
|
+
if (!sourceStats.isDirectory()) {
|
|
3535
|
+
throw new Error(`Source path is not a directory: ${sourcePath}`);
|
|
3337
3536
|
}
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3537
|
+
await this.mkdir(destPath);
|
|
3538
|
+
const entries = await this.readdir(sourcePath);
|
|
3539
|
+
for (const entry of entries) {
|
|
3540
|
+
const srcEntry = path.join(sourcePath, entry);
|
|
3541
|
+
const destEntry = path.join(destPath, entry);
|
|
3542
|
+
const entryStats = await this.stat(srcEntry);
|
|
3543
|
+
if (!entryStats)
|
|
3544
|
+
continue;
|
|
3545
|
+
if (entryStats.isDirectory()) {
|
|
3546
|
+
await this.copyDirectory(srcEntry, destEntry);
|
|
3547
|
+
} else if (entryStats.isFile()) {
|
|
3548
|
+
const content = await this.readFile(srcEntry);
|
|
3549
|
+
if (content !== null) {
|
|
3550
|
+
await this.writeFile(destEntry, content);
|
|
3551
|
+
}
|
|
3343
3552
|
}
|
|
3344
3553
|
}
|
|
3345
3554
|
}
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
if (Array.isArray(raw)) {
|
|
3352
|
-
const messages = raw.map((entry) => {
|
|
3353
|
-
if (typeof entry === "string")
|
|
3354
|
-
return entry;
|
|
3355
|
-
if (entry && typeof entry === "object" && typeof entry.message === "string") {
|
|
3356
|
-
return entry.message;
|
|
3357
|
-
}
|
|
3358
|
-
return String(entry);
|
|
3359
|
-
}).filter(Boolean);
|
|
3360
|
-
if (messages.length > 0)
|
|
3361
|
-
errors[field] = messages;
|
|
3362
|
-
} else if (typeof raw === "string") {
|
|
3363
|
-
errors[field] = [raw];
|
|
3364
|
-
}
|
|
3365
|
-
}
|
|
3366
|
-
if (Object.keys(errors).length > 0)
|
|
3367
|
-
parsedErrors = errors;
|
|
3555
|
+
isEnoent(error) {
|
|
3556
|
+
return this.hasErrnoCode(error, "ENOENT");
|
|
3557
|
+
}
|
|
3558
|
+
hasErrnoCode(error, code) {
|
|
3559
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
3368
3560
|
}
|
|
3369
|
-
return {
|
|
3370
|
-
result,
|
|
3371
|
-
errorCode: classification.errorCode,
|
|
3372
|
-
message,
|
|
3373
|
-
retry,
|
|
3374
|
-
details,
|
|
3375
|
-
...hasContext ? { context } : {},
|
|
3376
|
-
...parsedErrors ? { parsedErrors } : {}
|
|
3377
|
-
};
|
|
3378
|
-
}
|
|
3379
|
-
async function extractErrorMessage(error, options) {
|
|
3380
|
-
const { message } = await extractErrorDetails(error, options);
|
|
3381
|
-
return message;
|
|
3382
3561
|
}
|
|
3562
|
+
|
|
3563
|
+
// ../filesystem/src/index.ts
|
|
3564
|
+
var fsInstance = new NodeFileSystem;
|
|
3565
|
+
var getFileSystem = () => fsInstance;
|
|
3383
3566
|
// ../common/src/exit-code.ts
|
|
3384
3567
|
function setExitCode(code) {
|
|
3385
3568
|
process.exitCode = code;
|
|
@@ -3418,8 +3601,8 @@ function getOutputSink() {
|
|
|
3418
3601
|
|
|
3419
3602
|
// ../common/src/logger.ts
|
|
3420
3603
|
var logFilePathSlot = singleton("logFilePath");
|
|
3421
|
-
function setGlobalLogFilePath(
|
|
3422
|
-
logFilePathSlot.set(
|
|
3604
|
+
function setGlobalLogFilePath(path2) {
|
|
3605
|
+
logFilePathSlot.set(path2);
|
|
3423
3606
|
}
|
|
3424
3607
|
function getGlobalLogFilePath() {
|
|
3425
3608
|
return logFilePathSlot.get("");
|
|
@@ -3487,14 +3670,14 @@ class SimpleLogger {
|
|
|
3487
3670
|
return this.fileLoggingEnabled || !!getGlobalLogFilePath();
|
|
3488
3671
|
}
|
|
3489
3672
|
writeToFile(formatted) {
|
|
3490
|
-
const
|
|
3491
|
-
if (!
|
|
3673
|
+
const path2 = this.logFilePath || getGlobalLogFilePath();
|
|
3674
|
+
if (!path2)
|
|
3492
3675
|
return;
|
|
3493
3676
|
const timestamp = new Date().toISOString();
|
|
3494
3677
|
this.pendingWrites = Promise.all([
|
|
3495
3678
|
this.pendingWrites,
|
|
3496
3679
|
this.pendingInit
|
|
3497
|
-
]).then(() => getFileSystem().appendFile(
|
|
3680
|
+
]).then(() => getFileSystem().appendFile(path2, `${timestamp} ${formatted}`).catch(() => {}));
|
|
3498
3681
|
}
|
|
3499
3682
|
write(formatted) {
|
|
3500
3683
|
if (this.isFileLoggingActive()) {
|
|
@@ -3544,17 +3727,17 @@ class SimpleLogger {
|
|
|
3544
3727
|
setGlobalLogFilePath("");
|
|
3545
3728
|
}
|
|
3546
3729
|
}
|
|
3547
|
-
setLogFile(
|
|
3548
|
-
this.logFilePath =
|
|
3549
|
-
setGlobalLogFilePath(
|
|
3550
|
-
if (!
|
|
3730
|
+
setLogFile(path2) {
|
|
3731
|
+
this.logFilePath = path2;
|
|
3732
|
+
setGlobalLogFilePath(path2);
|
|
3733
|
+
if (!path2)
|
|
3551
3734
|
return;
|
|
3552
3735
|
this.fileLoggingEnabled = true;
|
|
3553
|
-
const
|
|
3736
|
+
const fs2 = getFileSystem();
|
|
3554
3737
|
this.pendingInit = (async () => {
|
|
3555
3738
|
const [error] = await catchError((async () => {
|
|
3556
|
-
await
|
|
3557
|
-
await
|
|
3739
|
+
await fs2.mkdir(fs2.path.dirname(path2));
|
|
3740
|
+
await fs2.writeFile(path2, "");
|
|
3558
3741
|
})());
|
|
3559
3742
|
if (error)
|
|
3560
3743
|
this.fileLoggingEnabled = false;
|
|
@@ -3608,12 +3791,12 @@ var jmespathSlot = singleton("JmespathCodec");
|
|
|
3608
3791
|
async function loadOutputCodecsAsync(needed) {
|
|
3609
3792
|
const loads = [];
|
|
3610
3793
|
if (needed.yaml && yamlSlot.get() === undefined) {
|
|
3611
|
-
loads.push(import("./js-yaml-
|
|
3794
|
+
loads.push(import("./js-yaml-88tdqrtd.js").then((mod) => {
|
|
3612
3795
|
yamlSlot.set(mod);
|
|
3613
3796
|
}));
|
|
3614
3797
|
}
|
|
3615
3798
|
if (needed.filter && jmespathSlot.get() === undefined) {
|
|
3616
|
-
loads.push(import("./jmespath-
|
|
3799
|
+
loads.push(import("./jmespath-231m3hyn.js").then((m)=>__toESM(m.default,1)).then((mod) => {
|
|
3617
3800
|
jmespathSlot.set(mod);
|
|
3618
3801
|
}));
|
|
3619
3802
|
}
|
|
@@ -3644,6 +3827,9 @@ var AUTH_ERROR_CODES = new Set([
|
|
|
3644
3827
|
"authentication_required",
|
|
3645
3828
|
"permission_denied"
|
|
3646
3829
|
]);
|
|
3830
|
+
var LOCAL_PERMISSION_CLI_ERROR_CODES = new Set([
|
|
3831
|
+
"local_permission_denied"
|
|
3832
|
+
]);
|
|
3647
3833
|
var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
|
|
3648
3834
|
var NETWORK_HTTP_ERROR_CODES = new Set([
|
|
3649
3835
|
"network_error",
|
|
@@ -3784,6 +3970,9 @@ function classifyFromErrorCode(errorCode) {
|
|
|
3784
3970
|
if (AUTH_ERROR_CODES.has(errorCode)) {
|
|
3785
3971
|
return "auth";
|
|
3786
3972
|
}
|
|
3973
|
+
if (LOCAL_PERMISSION_CLI_ERROR_CODES.has(errorCode)) {
|
|
3974
|
+
return "local_permission";
|
|
3975
|
+
}
|
|
3787
3976
|
if (VALIDATION_ERROR_CODES.has(errorCode)) {
|
|
3788
3977
|
return "validation";
|
|
3789
3978
|
}
|
|
@@ -3795,6 +3984,15 @@ function classifyFromErrorCode(errorCode) {
|
|
|
3795
3984
|
}
|
|
3796
3985
|
return;
|
|
3797
3986
|
}
|
|
3987
|
+
function hasLocalPermissionCode(error) {
|
|
3988
|
+
for (const node of walkErrorGraph(error)) {
|
|
3989
|
+
const code = node.code;
|
|
3990
|
+
if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
|
|
3991
|
+
return true;
|
|
3992
|
+
}
|
|
3993
|
+
}
|
|
3994
|
+
return false;
|
|
3995
|
+
}
|
|
3798
3996
|
function classifyFromError(error) {
|
|
3799
3997
|
const code = findCodeInCauseChain(error);
|
|
3800
3998
|
if (code) {
|
|
@@ -3811,6 +4009,9 @@ function classifyFromError(error) {
|
|
|
3811
4009
|
return "missing_dependency";
|
|
3812
4010
|
}
|
|
3813
4011
|
}
|
|
4012
|
+
if (hasLocalPermissionCode(error)) {
|
|
4013
|
+
return "local_permission";
|
|
4014
|
+
}
|
|
3814
4015
|
const message = stringField(error, "message");
|
|
3815
4016
|
if (message?.includes("fetch failed") === true) {
|
|
3816
4017
|
return "network_http";
|
|
@@ -3826,7 +4027,7 @@ function classifyError2(input) {
|
|
|
3826
4027
|
if (recorded?.errorClass) {
|
|
3827
4028
|
return recorded.errorClass;
|
|
3828
4029
|
}
|
|
3829
|
-
const status = recorded?.context?.httpStatus;
|
|
4030
|
+
const status = recorded?.context?.httpStatus ?? findHttpStatusInGraph(input.error);
|
|
3830
4031
|
if (status !== undefined) {
|
|
3831
4032
|
return classifyHttpStatus(status);
|
|
3832
4033
|
}
|
|
@@ -3849,17 +4050,18 @@ function buildCommandTerminalTelemetryProperties(input) {
|
|
|
3849
4050
|
const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError2(input);
|
|
3850
4051
|
const terminalSignal = terminalSignalFor(input, outcome);
|
|
3851
4052
|
return {
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
...errorClass ? {
|
|
3855
|
-
...terminalSignal ? {
|
|
4053
|
+
[CommandDimensions.ExitCode]: input.exitCode,
|
|
4054
|
+
[CommandDimensions.TerminalOutcome]: outcome,
|
|
4055
|
+
...errorClass ? { [CommandDimensions.ErrorClass]: errorClass } : {},
|
|
4056
|
+
...terminalSignal ? { [CommandDimensions.TerminalSignal]: terminalSignal } : {}
|
|
3856
4057
|
};
|
|
3857
4058
|
}
|
|
3858
4059
|
|
|
3859
4060
|
// ../common/src/telemetry/telemetry-events.ts
|
|
3860
4061
|
var CommonTelemetryEvents = {
|
|
3861
|
-
|
|
3862
|
-
|
|
4062
|
+
Start: "Application.Start",
|
|
4063
|
+
Error: "Application.Error",
|
|
4064
|
+
ShipSucceeded: "Cli.ShipSucceeded"
|
|
3863
4065
|
};
|
|
3864
4066
|
|
|
3865
4067
|
// ../common/src/registry.ts
|
|
@@ -4067,8 +4269,8 @@ function detectExecutionContext(options = {}) {
|
|
|
4067
4269
|
function getExecutionContextTelemetryProperties() {
|
|
4068
4270
|
const detected = detectExecutionContext();
|
|
4069
4271
|
return {
|
|
4070
|
-
|
|
4071
|
-
...detected.ciProvider ? {
|
|
4272
|
+
[BaseDimensions.ExecutionContext]: detected.executionContext,
|
|
4273
|
+
...detected.ciProvider ? { [BaseDimensions.CiProvider]: detected.ciProvider } : {}
|
|
4072
4274
|
};
|
|
4073
4275
|
}
|
|
4074
4276
|
// ../common/src/telemetry/node-context-storage.ts
|
|
@@ -4111,7 +4313,7 @@ function getInboundTraceContext() {
|
|
|
4111
4313
|
var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
|
|
4112
4314
|
var SESSION_ID_MAX_LENGTH = 64;
|
|
4113
4315
|
var RANDOM_SESSION_ID_LENGTH = 32;
|
|
4114
|
-
var TELEMETRY_SESSION_SOURCE_PROPERTY = "
|
|
4316
|
+
var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
|
|
4115
4317
|
var CONTROL_CHARACTERS = /\p{Cc}/gu;
|
|
4116
4318
|
var INHERITED_SESSION_SOURCES = [
|
|
4117
4319
|
{ envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
|
|
@@ -4163,6 +4365,9 @@ function resolveTelemetrySession() {
|
|
|
4163
4365
|
telemetrySessionSlot.set(resolved);
|
|
4164
4366
|
return resolved;
|
|
4165
4367
|
}
|
|
4368
|
+
function getTelemetrySessionId() {
|
|
4369
|
+
return resolveTelemetrySession().id;
|
|
4370
|
+
}
|
|
4166
4371
|
function getTelemetrySessionSource() {
|
|
4167
4372
|
return resolveTelemetrySession().source;
|
|
4168
4373
|
}
|
|
@@ -4237,7 +4442,10 @@ class TelemetryService {
|
|
|
4237
4442
|
} catch (error) {
|
|
4238
4443
|
const durationMs = clock.elapsedMs();
|
|
4239
4444
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
4240
|
-
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, {
|
|
4445
|
+
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, {
|
|
4446
|
+
...properties,
|
|
4447
|
+
[CommandDimensions.ErrorMessage]: err.message
|
|
4448
|
+
}, context));
|
|
4241
4449
|
throw error;
|
|
4242
4450
|
}
|
|
4243
4451
|
}
|
|
@@ -4308,7 +4516,10 @@ class TelemetryService {
|
|
|
4308
4516
|
const durationMs = clock.elapsedMs();
|
|
4309
4517
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
4310
4518
|
await this.telemetryProvider.trackDependency({
|
|
4311
|
-
...this.spanFor(name, durationMs, false, {
|
|
4519
|
+
...this.spanFor(name, durationMs, false, {
|
|
4520
|
+
...properties,
|
|
4521
|
+
[CommandDimensions.ErrorMessage]: err.message
|
|
4522
|
+
}, childContext),
|
|
4312
4523
|
type
|
|
4313
4524
|
});
|
|
4314
4525
|
throw error;
|
|
@@ -4343,9 +4554,10 @@ class TelemetryService {
|
|
|
4343
4554
|
...globalProperties,
|
|
4344
4555
|
...this.defaultProperties,
|
|
4345
4556
|
...redactProperties(properties ?? {}),
|
|
4346
|
-
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
|
|
4557
|
+
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
|
|
4558
|
+
[BaseDimensions.SessionId]: this.telemetryProvider.getSessionId?.() ?? getTelemetrySessionId()
|
|
4347
4559
|
};
|
|
4348
|
-
return enriched;
|
|
4560
|
+
return lowercaseIdDimensionValues(enriched);
|
|
4349
4561
|
}
|
|
4350
4562
|
generateId() {
|
|
4351
4563
|
const bytes = new Uint8Array(8);
|
|
@@ -5139,7 +5351,165 @@ class FilterImplicitLimitError extends Error {
|
|
|
5139
5351
|
this.instructions = "Pass --limit <n> to choose how many records the filter applies to. " + "To filter over all records, pass the command's maximum accepted --limit (see the option's description in --help).";
|
|
5140
5352
|
}
|
|
5141
5353
|
}
|
|
5142
|
-
function
|
|
5354
|
+
function countRecords(data) {
|
|
5355
|
+
if (Array.isArray(data))
|
|
5356
|
+
return data.length;
|
|
5357
|
+
return data == null ? 0 : 1;
|
|
5358
|
+
}
|
|
5359
|
+
function availableFields(data) {
|
|
5360
|
+
const records = Array.isArray(data) ? data : [data];
|
|
5361
|
+
const keys = new Set;
|
|
5362
|
+
for (const record of records) {
|
|
5363
|
+
if (record && typeof record === "object" && !Array.isArray(record)) {
|
|
5364
|
+
for (const key of Object.keys(record))
|
|
5365
|
+
keys.add(key);
|
|
5366
|
+
}
|
|
5367
|
+
}
|
|
5368
|
+
return [...keys];
|
|
5369
|
+
}
|
|
5370
|
+
function decodeQuotedIdentifier(whole, inner) {
|
|
5371
|
+
const [error, decoded] = catchError(() => JSON.parse(whole));
|
|
5372
|
+
if (!error && typeof decoded === "string")
|
|
5373
|
+
return decoded;
|
|
5374
|
+
return inner.replace(/\\(.)/g, "$1");
|
|
5375
|
+
}
|
|
5376
|
+
function referencedFields(filter) {
|
|
5377
|
+
const top = new Set;
|
|
5378
|
+
const nested = new Set;
|
|
5379
|
+
const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
|
|
5380
|
+
const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
|
|
5381
|
+
const quoted = [];
|
|
5382
|
+
const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
|
|
5383
|
+
const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
|
|
5384
|
+
if (!isAlias) {
|
|
5385
|
+
quoted.push({
|
|
5386
|
+
name: decodeQuotedIdentifier(whole, name),
|
|
5387
|
+
index,
|
|
5388
|
+
tail: isPathTail(withoutValueLiterals, index)
|
|
5389
|
+
});
|
|
5390
|
+
}
|
|
5391
|
+
return `"${" ".repeat(whole.length - 2)}"`;
|
|
5392
|
+
});
|
|
5393
|
+
const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
|
|
5394
|
+
const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
|
|
5395
|
+
const place = (name, index, tail) => {
|
|
5396
|
+
if (tail || index >= rootEnd)
|
|
5397
|
+
nested.add(name);
|
|
5398
|
+
else
|
|
5399
|
+
top.add(name);
|
|
5400
|
+
};
|
|
5401
|
+
for (const entry of quoted)
|
|
5402
|
+
place(entry.name, entry.index, entry.tail);
|
|
5403
|
+
const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
|
|
5404
|
+
const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
|
|
5405
|
+
for (const match of identifiers) {
|
|
5406
|
+
const [, name, trailing] = match;
|
|
5407
|
+
if (trailing || reserved.has(name))
|
|
5408
|
+
continue;
|
|
5409
|
+
place(name, match.index, isPathTail(withoutLiterals, match.index));
|
|
5410
|
+
}
|
|
5411
|
+
return {
|
|
5412
|
+
top: [...top],
|
|
5413
|
+
nested: [...nested].filter((name) => !top.has(name)),
|
|
5414
|
+
hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
|
|
5415
|
+
};
|
|
5416
|
+
}
|
|
5417
|
+
function appearsBelowTopLevel(data, name) {
|
|
5418
|
+
let budget = 2000;
|
|
5419
|
+
const visit = (value, depth) => {
|
|
5420
|
+
if (budget-- <= 0 || depth > 4)
|
|
5421
|
+
return false;
|
|
5422
|
+
if (value === null || typeof value !== "object")
|
|
5423
|
+
return false;
|
|
5424
|
+
if (Array.isArray(value))
|
|
5425
|
+
return value.some((entry) => visit(entry, depth));
|
|
5426
|
+
const record = value;
|
|
5427
|
+
if (depth > 0 && Object.hasOwn(record, name))
|
|
5428
|
+
return true;
|
|
5429
|
+
return Object.values(record).some((entry) => visit(entry, depth + 1));
|
|
5430
|
+
};
|
|
5431
|
+
return visit(data, 0);
|
|
5432
|
+
}
|
|
5433
|
+
function alwaysNullKeys(records) {
|
|
5434
|
+
const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
|
|
5435
|
+
if (objects.length === 0 || objects.length !== records.length)
|
|
5436
|
+
return [];
|
|
5437
|
+
const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
|
|
5438
|
+
if (keys.length === 0)
|
|
5439
|
+
return [];
|
|
5440
|
+
const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
|
|
5441
|
+
return nullKeys.length === keys.length ? nullKeys : [];
|
|
5442
|
+
}
|
|
5443
|
+
function carriesOnlyNulls(value) {
|
|
5444
|
+
if (value === null)
|
|
5445
|
+
return true;
|
|
5446
|
+
if (Array.isArray(value)) {
|
|
5447
|
+
return value.length > 0 && value.every(carriesOnlyNulls);
|
|
5448
|
+
}
|
|
5449
|
+
if (typeof value === "object" && value !== undefined) {
|
|
5450
|
+
const values = Object.values(value);
|
|
5451
|
+
return values.length > 0 && values.every(carriesOnlyNulls);
|
|
5452
|
+
}
|
|
5453
|
+
return false;
|
|
5454
|
+
}
|
|
5455
|
+
function nameList(names, cap2 = 12) {
|
|
5456
|
+
const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
|
|
5457
|
+
const rest = names.length - shown.length;
|
|
5458
|
+
return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
|
|
5459
|
+
}
|
|
5460
|
+
function buildFilterWarning(filter, data, outcome) {
|
|
5461
|
+
const present = availableFields(data);
|
|
5462
|
+
const refs = referencedFields(filter);
|
|
5463
|
+
const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
|
|
5464
|
+
const unchecked = refs.nested.filter((name) => !present.includes(name));
|
|
5465
|
+
const count = countRecords(data);
|
|
5466
|
+
const scope = `${count} record(s)`;
|
|
5467
|
+
const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
|
|
5468
|
+
const soundness = unchecked.length > 0 ? `${nameList(unchecked)} ${unchecked.length === 1 ? "reads" : "read"} below the top level, so ${unchecked.length === 1 ? "it was" : "they were"} not checked against the record keys` : refs.top.length > 0 ? "every field it names exists" : "";
|
|
5469
|
+
const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
|
|
5470
|
+
let detail;
|
|
5471
|
+
let lede;
|
|
5472
|
+
if (outcome.kind === "null-elements") {
|
|
5473
|
+
lede = "returned only null values";
|
|
5474
|
+
const projected = `all ${outcome.count} of the elements it projected are null`;
|
|
5475
|
+
if (unknown.length > 0) {
|
|
5476
|
+
detail = `${projected}, because ${isNotAField(unknown)}`;
|
|
5477
|
+
} else if (unchecked.length > 0) {
|
|
5478
|
+
detail = withSoundness(projected);
|
|
5479
|
+
} else {
|
|
5480
|
+
detail = `${projected}, and every field it names exists — a multi-select list ` + `(\`[A, B]\`) reads each entry against \`Data\` itself, so on a list ` + `result use \`[].[A, B]\` or \`[].{a: A, b: B}\` to read the records`;
|
|
5481
|
+
}
|
|
5482
|
+
} else if (outcome.kind === "null-rows") {
|
|
5483
|
+
lede = "returned only null values";
|
|
5484
|
+
const projected = `every value it projected is null on all ${outcome.count} row(s)`;
|
|
5485
|
+
detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
|
|
5486
|
+
} else if (outcome.kind === "null-values") {
|
|
5487
|
+
lede = "returned only null values";
|
|
5488
|
+
const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
|
|
5489
|
+
const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
|
|
5490
|
+
if (sameSet) {
|
|
5491
|
+
detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
|
|
5492
|
+
} else if (unknown.length > 0) {
|
|
5493
|
+
detail = `${projected}, because ${isNotAField(unknown)}`;
|
|
5494
|
+
} else {
|
|
5495
|
+
detail = withSoundness(`${projected} on all ${scope}`);
|
|
5496
|
+
}
|
|
5497
|
+
} else {
|
|
5498
|
+
lede = "returned nothing";
|
|
5499
|
+
if (unknown.length > 0) {
|
|
5500
|
+
detail = isNotAField(unknown);
|
|
5501
|
+
} else {
|
|
5502
|
+
const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
|
|
5503
|
+
detail = withSoundness(`${selection} — it read ${scope}`);
|
|
5504
|
+
}
|
|
5505
|
+
}
|
|
5506
|
+
const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
|
|
5507
|
+
return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
|
|
5508
|
+
}
|
|
5509
|
+
function appendWarning(existing, note) {
|
|
5510
|
+
return existing ? `${existing} ${note}` : note;
|
|
5511
|
+
}
|
|
5512
|
+
function applyFilter(data, filter, onWarning) {
|
|
5143
5513
|
const codec = requireJmespath();
|
|
5144
5514
|
let result;
|
|
5145
5515
|
try {
|
|
@@ -5147,9 +5517,34 @@ function applyFilter(data, filter) {
|
|
|
5147
5517
|
} catch (err) {
|
|
5148
5518
|
throw new FilterEvaluationError(filter, err);
|
|
5149
5519
|
}
|
|
5150
|
-
|
|
5520
|
+
const inputCount = countRecords(data);
|
|
5521
|
+
const warn = (outcome) => {
|
|
5522
|
+
if (inputCount === 0)
|
|
5523
|
+
return;
|
|
5524
|
+
const note = buildFilterWarning(filter, data, outcome);
|
|
5525
|
+
getOutputSink().writeErr(`[WARN] ${note}
|
|
5526
|
+
`);
|
|
5527
|
+
onWarning?.(note);
|
|
5528
|
+
};
|
|
5529
|
+
const warnIfAllNull = (records) => {
|
|
5530
|
+
const keys = alwaysNullKeys(records);
|
|
5531
|
+
if (keys.length > 0)
|
|
5532
|
+
warn({ kind: "null-values", keys });
|
|
5533
|
+
};
|
|
5534
|
+
if (result == null) {
|
|
5535
|
+
warn({ kind: "empty" });
|
|
5151
5536
|
return [];
|
|
5537
|
+
}
|
|
5152
5538
|
if (Array.isArray(result)) {
|
|
5539
|
+
if (result.length === 0) {
|
|
5540
|
+
warn({ kind: "empty" });
|
|
5541
|
+
} else if (result.every((entry) => entry === null)) {
|
|
5542
|
+
warn({ kind: "null-elements", count: result.length });
|
|
5543
|
+
} else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
|
|
5544
|
+
warn({ kind: "null-rows", count: result.length });
|
|
5545
|
+
} else {
|
|
5546
|
+
warnIfAllNull(result);
|
|
5547
|
+
}
|
|
5153
5548
|
if (result.length > 0 && typeof result[0] !== "object") {
|
|
5154
5549
|
const fieldMatch = filter.match(/\.(\w+)$/);
|
|
5155
5550
|
const key = fieldMatch ? fieldMatch[1] : "Value";
|
|
@@ -5157,8 +5552,10 @@ function applyFilter(data, filter) {
|
|
|
5157
5552
|
}
|
|
5158
5553
|
return result;
|
|
5159
5554
|
}
|
|
5160
|
-
if (typeof result === "object")
|
|
5555
|
+
if (typeof result === "object") {
|
|
5556
|
+
warnIfAllNull([result]);
|
|
5161
5557
|
return result;
|
|
5558
|
+
}
|
|
5162
5559
|
return { Value: result };
|
|
5163
5560
|
}
|
|
5164
5561
|
function filterFailureData(envelope) {
|
|
@@ -5166,12 +5563,18 @@ function filterFailureData(envelope) {
|
|
|
5166
5563
|
const data = envelope.Data;
|
|
5167
5564
|
if (!filter || data == null)
|
|
5168
5565
|
return;
|
|
5169
|
-
|
|
5566
|
+
let note;
|
|
5567
|
+
const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
|
|
5568
|
+
note = n;
|
|
5569
|
+
}));
|
|
5170
5570
|
if (filterError) {
|
|
5171
|
-
envelope.Warning = `--output-filter was not applied, so Data is shown in full: ${filterError.message}
|
|
5571
|
+
envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
|
|
5172
5572
|
return;
|
|
5173
5573
|
}
|
|
5174
5574
|
envelope.Data = filtered;
|
|
5575
|
+
if (note) {
|
|
5576
|
+
envelope.Warning = appendWarning(envelope.Warning, note);
|
|
5577
|
+
}
|
|
5175
5578
|
}
|
|
5176
5579
|
function defaultErrorCodeForResult(result) {
|
|
5177
5580
|
switch (result) {
|
|
@@ -5216,7 +5619,7 @@ function defaultErrorCodeForHttpStatus(status) {
|
|
|
5216
5619
|
return "server_error";
|
|
5217
5620
|
return;
|
|
5218
5621
|
}
|
|
5219
|
-
var LOCAL_PERMISSION_TEXT_PATTERN =
|
|
5622
|
+
var LOCAL_PERMISSION_TEXT_PATTERN = new RegExp(`(?:\\b|\\()(?:${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})(?::\\s|\\))`);
|
|
5220
5623
|
function defaultErrorCodeForFailure(data) {
|
|
5221
5624
|
if (data.Result === RESULTS.Failure) {
|
|
5222
5625
|
const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
|
|
@@ -5255,8 +5658,14 @@ var OutputFormatter;
|
|
|
5255
5658
|
}
|
|
5256
5659
|
const filter = getOutputFilter();
|
|
5257
5660
|
if (filter) {
|
|
5258
|
-
|
|
5661
|
+
let note;
|
|
5662
|
+
const filtered = applyFilter(data.Data, filter, (n) => {
|
|
5663
|
+
note = n;
|
|
5664
|
+
});
|
|
5259
5665
|
data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
|
|
5666
|
+
if (note) {
|
|
5667
|
+
data.Warning = appendWarning(data.Warning, note);
|
|
5668
|
+
}
|
|
5260
5669
|
}
|
|
5261
5670
|
logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
|
|
5262
5671
|
}
|
|
@@ -5287,10 +5696,10 @@ var OutputFormatter;
|
|
|
5287
5696
|
filterFailureData(envelope);
|
|
5288
5697
|
if (!suppressTelemetry) {
|
|
5289
5698
|
telemetry.trackEvent(CommonTelemetryEvents.Error, {
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5699
|
+
[ErrorDimensions.Result]: data.Result,
|
|
5700
|
+
[ErrorDimensions.ErrorCode]: data.ErrorCode,
|
|
5701
|
+
[ErrorDimensions.Retry]: data.Retry,
|
|
5702
|
+
[ErrorDimensions.ErrorMessage]: data.Message
|
|
5294
5703
|
});
|
|
5295
5704
|
}
|
|
5296
5705
|
logOutput(normalizeOutputKeys(envelope), getOutputFormat());
|
|
@@ -5333,13 +5742,20 @@ var OutputFormatter;
|
|
|
5333
5742
|
OutputFormatter.log = log;
|
|
5334
5743
|
function formatToString(data) {
|
|
5335
5744
|
const filter = getOutputFilter();
|
|
5745
|
+
const envelope = data;
|
|
5336
5746
|
if ("Data" in data && data.Data != null) {
|
|
5337
5747
|
data.Data = normalizeDataKeys(data.Data);
|
|
5338
5748
|
if (filter) {
|
|
5339
|
-
|
|
5749
|
+
let note;
|
|
5750
|
+
data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
|
|
5751
|
+
note = n;
|
|
5752
|
+
}));
|
|
5753
|
+
if (note) {
|
|
5754
|
+
envelope.Warning = appendWarning(envelope.Warning, note);
|
|
5755
|
+
}
|
|
5340
5756
|
}
|
|
5341
5757
|
}
|
|
5342
|
-
const output = normalizeOutputKeys(
|
|
5758
|
+
const output = normalizeOutputKeys(envelope);
|
|
5343
5759
|
const lines = [];
|
|
5344
5760
|
const sink = getOutputSink();
|
|
5345
5761
|
printOutput(output, getOutputFormat(), (msg) => {
|
|
@@ -5373,7 +5789,7 @@ var LEGACY_SKILL_NAMESPACE = "uipath:";
|
|
|
5373
5789
|
var MAX_SKILL_NAME_LENGTH = 80;
|
|
5374
5790
|
var SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
|
|
5375
5791
|
function productMode(productArea, mode) {
|
|
5376
|
-
return {
|
|
5792
|
+
return { ProductArea: productArea, Mode: mode };
|
|
5377
5793
|
}
|
|
5378
5794
|
function attributionRecord(groups) {
|
|
5379
5795
|
const record = {};
|
|
@@ -5431,6 +5847,7 @@ var COMMAND_ATTRIBUTION = commandAttribution([
|
|
|
5431
5847
|
["rpa", "build", ["uip.rpa-legacy"]],
|
|
5432
5848
|
["conversational", "operate", ["uip.conversational"]],
|
|
5433
5849
|
["agents", "build", ["uip.codedagent", "uip.agent"]],
|
|
5850
|
+
["coding-agents", "build", ["uip.coder"]],
|
|
5434
5851
|
["agenthub", "build", ["uip.agenthub"]],
|
|
5435
5852
|
["coded-apps", "build", ["uip.codedapp"]],
|
|
5436
5853
|
["functions", "build", ["uip.function", "uip.functions"]],
|
|
@@ -5516,15 +5933,15 @@ function normalizeSkillName(value) {
|
|
|
5516
5933
|
function buildCommandTelemetryAttribution(commandPath, skillSource) {
|
|
5517
5934
|
const skillName = normalizeSkillName(skillSource);
|
|
5518
5935
|
return {
|
|
5519
|
-
...skillName ? {
|
|
5936
|
+
...skillName ? { SkillName: skillName } : {},
|
|
5520
5937
|
...getCommandProductModeAttribution(commandPath)
|
|
5521
5938
|
};
|
|
5522
5939
|
}
|
|
5523
5940
|
var AGENT_SESSION_ENV = {
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5941
|
+
[BaseDimensions.AgentModel]: "UIPATH_AGENT_MODEL",
|
|
5942
|
+
[SkillsDimensions.PermissionMode]: "UIPATH_PERMISSION_MODE",
|
|
5943
|
+
[SkillsDimensions.EffortLevel]: "UIPATH_EFFORT_LEVEL",
|
|
5944
|
+
[SkillsDimensions.SkillsVersion]: "UIPATH_SKILLS_VERSION"
|
|
5528
5945
|
};
|
|
5529
5946
|
var MAX_TELEMETRY_TOKEN_LENGTH = 120;
|
|
5530
5947
|
function sanitizeTelemetryToken(value) {
|
|
@@ -5542,26 +5959,38 @@ function buildAgentSessionTelemetry(env) {
|
|
|
5542
5959
|
}
|
|
5543
5960
|
|
|
5544
5961
|
// ../common/src/telemetry/command-name.ts
|
|
5545
|
-
var
|
|
5962
|
+
var TELEMETRY_NAME_ROOT = "Cli";
|
|
5963
|
+
var CLI_COMMAND_ROOT = "uip";
|
|
5964
|
+
var TELEMETRY_NAME_BARE_ACTION = "Invoke";
|
|
5546
5965
|
function commandTelemetryName(parts) {
|
|
5966
|
+
const action = vetCommandTokens(parts).map(pascalizeToken).join("");
|
|
5967
|
+
return `${TELEMETRY_NAME_ROOT}.${action || TELEMETRY_NAME_BARE_ACTION}`;
|
|
5968
|
+
}
|
|
5969
|
+
function commandInvocationPath(parts) {
|
|
5970
|
+
return [CLI_COMMAND_ROOT, ...vetCommandTokens(parts)].join(" ");
|
|
5971
|
+
}
|
|
5972
|
+
function vetCommandTokens(parts) {
|
|
5547
5973
|
const tokens = [];
|
|
5548
5974
|
for (const part of parts) {
|
|
5549
|
-
const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !==
|
|
5975
|
+
const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== CLI_COMMAND_ROOT);
|
|
5550
5976
|
if (pieces.every(isCommandToken)) {
|
|
5551
5977
|
tokens.push(...pieces);
|
|
5552
5978
|
continue;
|
|
5553
5979
|
}
|
|
5554
5980
|
tokens.push(UNKNOWN_TOKEN);
|
|
5555
5981
|
}
|
|
5556
|
-
return
|
|
5982
|
+
return tokens;
|
|
5557
5983
|
}
|
|
5558
|
-
|
|
5984
|
+
function pascalizeToken(token) {
|
|
5985
|
+
return token.split("-").filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
5986
|
+
}
|
|
5987
|
+
var COMMAND_TOKEN_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
5559
5988
|
var MAX_COMMAND_TOKEN_LENGTH = 32;
|
|
5560
5989
|
var GUID_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
5561
5990
|
function isCommandToken(token) {
|
|
5562
|
-
return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token)
|
|
5991
|
+
return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token);
|
|
5563
5992
|
}
|
|
5564
|
-
var UNKNOWN_TOKEN = "
|
|
5993
|
+
var UNKNOWN_TOKEN = "unknown";
|
|
5565
5994
|
|
|
5566
5995
|
// ../common/src/telemetry/invocation-request.ts
|
|
5567
5996
|
var requestContextSlot = singleton("TelemetryInvocationRequestContext");
|
|
@@ -5666,7 +6095,7 @@ function withheldArgumentValues(cmd) {
|
|
|
5666
6095
|
});
|
|
5667
6096
|
return values;
|
|
5668
6097
|
}
|
|
5669
|
-
function
|
|
6098
|
+
function deriveCommandParts(cmd) {
|
|
5670
6099
|
const parts = [];
|
|
5671
6100
|
let current = cmd;
|
|
5672
6101
|
while (current) {
|
|
@@ -5679,14 +6108,13 @@ function deriveCommandPath(cmd) {
|
|
|
5679
6108
|
if (parts.length > 1) {
|
|
5680
6109
|
parts.shift();
|
|
5681
6110
|
}
|
|
5682
|
-
return
|
|
6111
|
+
return parts;
|
|
5683
6112
|
}
|
|
5684
6113
|
function isErrorContext(value) {
|
|
5685
6114
|
return value !== null && typeof value === "object";
|
|
5686
6115
|
}
|
|
5687
6116
|
function commandHelpHint(commandPath) {
|
|
5688
|
-
|
|
5689
|
-
return `An unexpected error occurred. Run '${command} --help' to verify command syntax, or run with --log-level debug for details.`;
|
|
6117
|
+
return `An unexpected error occurred. Run '${commandPath} --help' to verify command syntax, or run with --log-level debug for details.`;
|
|
5690
6118
|
}
|
|
5691
6119
|
function isPromptCancellation(error) {
|
|
5692
6120
|
return error instanceof Error && error.name === "ExitPromptError";
|
|
@@ -5711,7 +6139,9 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
5711
6139
|
yaml: getOutputFormat() === "yaml",
|
|
5712
6140
|
filter: getOutputFilter() !== undefined
|
|
5713
6141
|
});
|
|
5714
|
-
const
|
|
6142
|
+
const commandParts = deriveCommandParts(command);
|
|
6143
|
+
const telemetryName = commandTelemetryName(commandParts);
|
|
6144
|
+
const commandPath = commandInvocationPath(commandParts);
|
|
5715
6145
|
const props = typeof properties === "function" ? properties(...args) : properties;
|
|
5716
6146
|
markCommandStart();
|
|
5717
6147
|
const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
|
|
@@ -5746,7 +6176,7 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
5746
6176
|
Result: finalResult,
|
|
5747
6177
|
...customErrorCode ? { ErrorCode: customErrorCode } : {},
|
|
5748
6178
|
Message: errorMessage,
|
|
5749
|
-
Instructions: customInstructions ?? commandHelpHint(
|
|
6179
|
+
Instructions: customInstructions ?? commandHelpHint(commandPath),
|
|
5750
6180
|
...customRetry ? { Retry: customRetry } : {},
|
|
5751
6181
|
...customContext ? { Context: customContext } : {}
|
|
5752
6182
|
});
|
|
@@ -5763,8 +6193,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
5763
6193
|
recordedFailure,
|
|
5764
6194
|
pollSignal: context.pollSignal
|
|
5765
6195
|
});
|
|
5766
|
-
if (terminalTelemetry.
|
|
5767
|
-
telemetry.trackException(error instanceof Error ? error : new Error(String(error)), {
|
|
6196
|
+
if (terminalTelemetry[CommandDimensions.ErrorClass] === "internal" && error) {
|
|
6197
|
+
telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { [CommandDimensions.CommandName]: commandPath }, getInvocationRequestContext());
|
|
5768
6198
|
}
|
|
5769
6199
|
const commandParams = extractCommandParams(command);
|
|
5770
6200
|
if (props) {
|
|
@@ -5775,11 +6205,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
5775
6205
|
const baseProperties = redactProperties({
|
|
5776
6206
|
...commandParams,
|
|
5777
6207
|
...props,
|
|
5778
|
-
...buildCommandTelemetryAttribution(
|
|
6208
|
+
...buildCommandTelemetryAttribution(commandPath, process.env.UIPATH_SKILL),
|
|
5779
6209
|
...buildAgentSessionTelemetry(process.env),
|
|
5780
|
-
|
|
6210
|
+
[CommandDimensions.CommandName]: commandPath,
|
|
6211
|
+
[CommandDimensions.IsCommand]: "true",
|
|
5781
6212
|
...terminalTelemetry,
|
|
5782
|
-
...errorMessage ? { errorMessage } : {}
|
|
6213
|
+
...errorMessage ? { [CommandDimensions.ErrorMessage]: errorMessage } : {}
|
|
5783
6214
|
});
|
|
5784
6215
|
emitInvocationRequest(telemetryName, success, baseProperties);
|
|
5785
6216
|
} finally {
|
|
@@ -5992,6 +6423,75 @@ var RESERVED_KEYWORDS_LOWER = new Set([
|
|
|
5992
6423
|
"writeonly",
|
|
5993
6424
|
"xor"
|
|
5994
6425
|
]);
|
|
6426
|
+
// ../common/src/error-instructions.ts
|
|
6427
|
+
function extractHttpStatus(err) {
|
|
6428
|
+
if (!err || typeof err !== "object")
|
|
6429
|
+
return;
|
|
6430
|
+
const e = err;
|
|
6431
|
+
const structured = e.response?.status ?? e.status ?? e.statusCode;
|
|
6432
|
+
if (structured !== undefined)
|
|
6433
|
+
return structured;
|
|
6434
|
+
return typeof e.message === "string" ? parseHttpStatusFromMessage(e.message) : undefined;
|
|
6435
|
+
}
|
|
6436
|
+
var GENERIC = "Check authentication and parameters";
|
|
6437
|
+
function instructionsFor(ctx, err) {
|
|
6438
|
+
switch (ctx) {
|
|
6439
|
+
case "auth":
|
|
6440
|
+
return "Run 'uip login' to authenticate. To inspect the current session, run 'uip whoami'.";
|
|
6441
|
+
case "identity":
|
|
6442
|
+
return "Select an active tenant with 'uip login tenant set <tenant>' and ensure your login includes an organization";
|
|
6443
|
+
case "input-parse":
|
|
6444
|
+
return "Ensure --inputs is valid JSON or pipe JSON via stdin";
|
|
6445
|
+
case "input-validate":
|
|
6446
|
+
return "Fix the flagged input fields to match the process's input schema";
|
|
6447
|
+
case "flag-format":
|
|
6448
|
+
return "Check the flag value format — see --help for the expected shape";
|
|
6449
|
+
case "permissions":
|
|
6450
|
+
return "Confirm your user has the required permissions in this folder/tenant, or re-authenticate with 'uip login' if your session has lapsed";
|
|
6451
|
+
case "backend": {
|
|
6452
|
+
const status = extractHttpStatus(err);
|
|
6453
|
+
if (status === 401) {
|
|
6454
|
+
return "Re-authenticate with 'uip login' — your session is invalid or expired";
|
|
6455
|
+
}
|
|
6456
|
+
if (status === 403) {
|
|
6457
|
+
return "Confirm your user has access to the resource, and the required permissions in this folder or tenant";
|
|
6458
|
+
}
|
|
6459
|
+
if (status === 404) {
|
|
6460
|
+
return "Verify the resource exists in the current folder/tenant";
|
|
6461
|
+
}
|
|
6462
|
+
if (status === 400 || status === 422) {
|
|
6463
|
+
return "Request was rejected — check flag values and inputs";
|
|
6464
|
+
}
|
|
6465
|
+
if (status === 405) {
|
|
6466
|
+
return "Check the command name and the base URL in use — the endpoint may not exist";
|
|
6467
|
+
}
|
|
6468
|
+
if (status === 408) {
|
|
6469
|
+
return "The request timed out — retry; if it persists, narrow the request (e.g. --limit on list commands)";
|
|
6470
|
+
}
|
|
6471
|
+
if (status === 409) {
|
|
6472
|
+
return "The resource already exists, or changed since it was read — list it to see the current state";
|
|
6473
|
+
}
|
|
6474
|
+
if (status === 413) {
|
|
6475
|
+
return "The upload is over the size limit — exclude unused dependencies or drop large files, then retry";
|
|
6476
|
+
}
|
|
6477
|
+
if (status === 429) {
|
|
6478
|
+
return "Rate limit reached — wait and retry; when the service suggests a delay, Retry and Context.retryAfter carry it";
|
|
6479
|
+
}
|
|
6480
|
+
if (status !== undefined && status >= 500 && status < 600) {
|
|
6481
|
+
return "The service returned a server error — retry; if it persists, check service status";
|
|
6482
|
+
}
|
|
6483
|
+
const permission = describePermissionError(err);
|
|
6484
|
+
if (permission) {
|
|
6485
|
+
return permission.instructions;
|
|
6486
|
+
}
|
|
6487
|
+
const connectivity = describeConnectivityError(err);
|
|
6488
|
+
if (connectivity) {
|
|
6489
|
+
return connectivity.instructions;
|
|
6490
|
+
}
|
|
6491
|
+
return GENERIC;
|
|
6492
|
+
}
|
|
6493
|
+
}
|
|
6494
|
+
}
|
|
5995
6495
|
// ../common/src/host-global-options.ts
|
|
5996
6496
|
var HOST_GLOBAL_OPTIONS_WITH_VALUE = [
|
|
5997
6497
|
"--output",
|
|
@@ -6010,40 +6510,6 @@ var BOOLEAN_FLAGS = new Set(HOST_GLOBAL_FLAGS);
|
|
|
6010
6510
|
// ../common/src/interactivity-context.ts
|
|
6011
6511
|
var modeSlot = singleton("InteractivityMode");
|
|
6012
6512
|
var interactiveFlagSlot = singleton("InteractiveFlag");
|
|
6013
|
-
// ../common/src/mime-types.ts
|
|
6014
|
-
var MIME_TYPES_BY_EXTENSION = Object.freeze({
|
|
6015
|
-
pdf: "application/pdf",
|
|
6016
|
-
png: "image/png",
|
|
6017
|
-
jpg: "image/jpeg",
|
|
6018
|
-
jpeg: "image/jpeg",
|
|
6019
|
-
gif: "image/gif",
|
|
6020
|
-
webp: "image/webp",
|
|
6021
|
-
bmp: "image/bmp",
|
|
6022
|
-
tif: "image/tiff",
|
|
6023
|
-
tiff: "image/tiff",
|
|
6024
|
-
svg: "image/svg+xml",
|
|
6025
|
-
txt: "text/plain",
|
|
6026
|
-
log: "text/plain",
|
|
6027
|
-
md: "text/markdown",
|
|
6028
|
-
csv: "text/csv",
|
|
6029
|
-
tsv: "text/tab-separated-values",
|
|
6030
|
-
json: "application/json",
|
|
6031
|
-
xml: "application/xml",
|
|
6032
|
-
html: "text/html",
|
|
6033
|
-
htm: "text/html",
|
|
6034
|
-
yaml: "application/yaml",
|
|
6035
|
-
yml: "application/yaml",
|
|
6036
|
-
doc: "application/msword",
|
|
6037
|
-
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
6038
|
-
xls: "application/vnd.ms-excel",
|
|
6039
|
-
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
6040
|
-
ppt: "application/vnd.ms-powerpoint",
|
|
6041
|
-
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
6042
|
-
zip: "application/zip",
|
|
6043
|
-
mp3: "audio/mpeg",
|
|
6044
|
-
wav: "audio/wav",
|
|
6045
|
-
mp4: "video/mp4"
|
|
6046
|
-
});
|
|
6047
6513
|
// ../common/src/polling/types.ts
|
|
6048
6514
|
var PollOutcome = {
|
|
6049
6515
|
Completed: "completed",
|
|
@@ -6152,9 +6618,9 @@ function getProfileStorage() {
|
|
|
6152
6618
|
if (isAuthProfileStorage(existing)) {
|
|
6153
6619
|
return existing;
|
|
6154
6620
|
}
|
|
6155
|
-
const
|
|
6156
|
-
globalSlot[AUTH_PROFILE_STORAGE_KEY] =
|
|
6157
|
-
return
|
|
6621
|
+
const storage2 = createProfileStorage();
|
|
6622
|
+
globalSlot[AUTH_PROFILE_STORAGE_KEY] = storage2;
|
|
6623
|
+
return storage2;
|
|
6158
6624
|
}
|
|
6159
6625
|
var profileStorage = getProfileStorage();
|
|
6160
6626
|
|
|
@@ -6185,8 +6651,8 @@ function resolveAuthProfileFilePath(profile) {
|
|
|
6185
6651
|
if (normalized === undefined) {
|
|
6186
6652
|
throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
|
|
6187
6653
|
}
|
|
6188
|
-
const
|
|
6189
|
-
return
|
|
6654
|
+
const fs2 = getFileSystem();
|
|
6655
|
+
return fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
|
|
6190
6656
|
}
|
|
6191
6657
|
function getActiveAuthProfileFilePath() {
|
|
6192
6658
|
const profile = getActiveAuthProfile();
|
|
@@ -6484,11 +6950,11 @@ var readAuthFromEnv = () => {
|
|
|
6484
6950
|
if (!rawUrl) {
|
|
6485
6951
|
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}).`);
|
|
6486
6952
|
}
|
|
6487
|
-
const
|
|
6953
|
+
const baseUrl2 = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
|
|
6488
6954
|
return {
|
|
6489
6955
|
loginStatus: "Logged in",
|
|
6490
6956
|
accessToken,
|
|
6491
|
-
baseUrl,
|
|
6957
|
+
baseUrl: baseUrl2,
|
|
6492
6958
|
organizationName,
|
|
6493
6959
|
organizationId,
|
|
6494
6960
|
tenantName,
|
|
@@ -6529,8 +6995,8 @@ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
|
|
|
6529
6995
|
async function refreshTokenFingerprint(refreshToken) {
|
|
6530
6996
|
const bytes = new TextEncoder().encode(refreshToken);
|
|
6531
6997
|
if (globalThis.crypto?.subtle) {
|
|
6532
|
-
const
|
|
6533
|
-
return Array.from(new Uint8Array(
|
|
6998
|
+
const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
6999
|
+
return Array.from(new Uint8Array(digest2), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
|
|
6534
7000
|
}
|
|
6535
7001
|
const { createHash } = await import("node:crypto");
|
|
6536
7002
|
return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
@@ -6539,9 +7005,9 @@ function breakerPathFor(authPath) {
|
|
|
6539
7005
|
return `${authPath}${BREAKER_SUFFIX}`;
|
|
6540
7006
|
}
|
|
6541
7007
|
async function loadRefreshBreaker(authPath) {
|
|
6542
|
-
const
|
|
7008
|
+
const fs2 = getFileSystem();
|
|
6543
7009
|
try {
|
|
6544
|
-
const content = await
|
|
7010
|
+
const content = await fs2.readFile(breakerPathFor(authPath), "utf-8");
|
|
6545
7011
|
if (!content)
|
|
6546
7012
|
return {};
|
|
6547
7013
|
const parsed = JSON.parse(content);
|
|
@@ -6552,20 +7018,20 @@ async function loadRefreshBreaker(authPath) {
|
|
|
6552
7018
|
}
|
|
6553
7019
|
async function saveRefreshBreaker(authPath, state) {
|
|
6554
7020
|
try {
|
|
6555
|
-
const
|
|
6556
|
-
const
|
|
6557
|
-
await
|
|
6558
|
-
const tempPath = `${
|
|
6559
|
-
await
|
|
6560
|
-
await
|
|
7021
|
+
const fs2 = getFileSystem();
|
|
7022
|
+
const path2 = breakerPathFor(authPath);
|
|
7023
|
+
await fs2.mkdir(fs2.path.dirname(path2));
|
|
7024
|
+
const tempPath = `${path2}.tmp`;
|
|
7025
|
+
await fs2.writeFile(tempPath, JSON.stringify(state));
|
|
7026
|
+
await fs2.rename(tempPath, path2);
|
|
6561
7027
|
} catch {}
|
|
6562
7028
|
}
|
|
6563
7029
|
async function clearRefreshBreaker(authPath) {
|
|
6564
|
-
const
|
|
6565
|
-
const
|
|
7030
|
+
const fs2 = getFileSystem();
|
|
7031
|
+
const path2 = breakerPathFor(authPath);
|
|
6566
7032
|
try {
|
|
6567
|
-
if (await
|
|
6568
|
-
await
|
|
7033
|
+
if (await fs2.exists(path2)) {
|
|
7034
|
+
await fs2.rm(path2);
|
|
6569
7035
|
}
|
|
6570
7036
|
} catch {}
|
|
6571
7037
|
}
|
|
@@ -6586,13 +7052,13 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
|
6586
7052
|
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
6587
7053
|
var PIPE_NAME_MAX_LENGTH = 103;
|
|
6588
7054
|
var getRobotIpcPipeNames = async () => {
|
|
6589
|
-
const
|
|
6590
|
-
const username =
|
|
7055
|
+
const fs2 = getFileSystem();
|
|
7056
|
+
const username = fs2.env.getenv("USER") ?? fs2.env.getenv("USERNAME");
|
|
6591
7057
|
if (!username) {
|
|
6592
7058
|
throw new Error("Unable to determine current username");
|
|
6593
7059
|
}
|
|
6594
|
-
const tempPath =
|
|
6595
|
-
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) =>
|
|
7060
|
+
const tempPath = fs2.env.getenv("TMPDIR") ?? "/tmp/";
|
|
7061
|
+
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs2.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
|
|
6596
7062
|
};
|
|
6597
7063
|
var defaultIsRobotIpcAvailable = async () => {
|
|
6598
7064
|
if (process.platform === "win32") {
|
|
@@ -6602,20 +7068,20 @@ var defaultIsRobotIpcAvailable = async () => {
|
|
|
6602
7068
|
if (pipeNamesError || !pipeNames) {
|
|
6603
7069
|
return false;
|
|
6604
7070
|
}
|
|
6605
|
-
const
|
|
7071
|
+
const fs2 = getFileSystem();
|
|
6606
7072
|
for (const pipeName of pipeNames) {
|
|
6607
|
-
const [existsError, exists] = await catchError2(
|
|
7073
|
+
const [existsError, exists] = await catchError2(fs2.exists(pipeName));
|
|
6608
7074
|
if (!existsError && exists === true) {
|
|
6609
7075
|
return true;
|
|
6610
7076
|
}
|
|
6611
7077
|
}
|
|
6612
7078
|
return false;
|
|
6613
7079
|
};
|
|
6614
|
-
var withTimeout = (promise, timeoutMs) => new Promise((
|
|
7080
|
+
var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
|
|
6615
7081
|
const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
6616
7082
|
promise.then((value) => {
|
|
6617
7083
|
clearTimeout(timer);
|
|
6618
|
-
|
|
7084
|
+
resolve2(value);
|
|
6619
7085
|
}, (error) => {
|
|
6620
7086
|
clearTimeout(timer);
|
|
6621
7087
|
reject(error);
|
|
@@ -6788,9 +7254,9 @@ var errorCode = (err) => {
|
|
|
6788
7254
|
}
|
|
6789
7255
|
return "EUNKNOWN";
|
|
6790
7256
|
};
|
|
6791
|
-
var probeAsync = async (
|
|
7257
|
+
var probeAsync = async (fs2, candidate) => {
|
|
6792
7258
|
try {
|
|
6793
|
-
const stats = await
|
|
7259
|
+
const stats = await fs2.stat(candidate);
|
|
6794
7260
|
if (stats === null) {
|
|
6795
7261
|
return { exists: false };
|
|
6796
7262
|
}
|
|
@@ -6817,36 +7283,36 @@ var probeAsync = async (fs, candidate) => {
|
|
|
6817
7283
|
}
|
|
6818
7284
|
};
|
|
6819
7285
|
var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
|
|
6820
|
-
const
|
|
6821
|
-
if (
|
|
6822
|
-
const
|
|
6823
|
-
return
|
|
7286
|
+
const fs2 = getFileSystem();
|
|
7287
|
+
if (fs2.path.isAbsolute(envFilePath)) {
|
|
7288
|
+
const probe2 = await probeAsync(fs2, envFilePath);
|
|
7289
|
+
return probe2.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
|
|
6824
7290
|
exists: false,
|
|
6825
7291
|
absolutePath: envFilePath,
|
|
6826
7292
|
source: "absolute",
|
|
6827
|
-
...
|
|
7293
|
+
...probe2.unusable ? { unusable: probe2.unusable } : {}
|
|
6828
7294
|
};
|
|
6829
7295
|
}
|
|
6830
|
-
const cwd = opts?.cwd ??
|
|
7296
|
+
const cwd = opts?.cwd ?? fs2.env.cwd();
|
|
6831
7297
|
let searchDir = cwd;
|
|
6832
7298
|
while (true) {
|
|
6833
|
-
const candidate =
|
|
6834
|
-
const
|
|
6835
|
-
if (
|
|
7299
|
+
const candidate = fs2.path.join(searchDir, envFilePath);
|
|
7300
|
+
const probe2 = await probeAsync(fs2, candidate);
|
|
7301
|
+
if (probe2.exists) {
|
|
6836
7302
|
return {
|
|
6837
7303
|
exists: true,
|
|
6838
7304
|
absolutePath: candidate,
|
|
6839
7305
|
source: searchDir === cwd ? "cwd" : "ancestor"
|
|
6840
7306
|
};
|
|
6841
7307
|
}
|
|
6842
|
-
const parentDir =
|
|
7308
|
+
const parentDir = fs2.path.dirname(searchDir);
|
|
6843
7309
|
if (parentDir === searchDir) {
|
|
6844
7310
|
break;
|
|
6845
7311
|
}
|
|
6846
7312
|
searchDir = parentDir;
|
|
6847
7313
|
}
|
|
6848
|
-
const homePath =
|
|
6849
|
-
const probe = await probeAsync(
|
|
7314
|
+
const homePath = fs2.path.join(fs2.env.homedir(), envFilePath);
|
|
7315
|
+
const probe = await probeAsync(fs2, homePath);
|
|
6850
7316
|
if (probe.exists) {
|
|
6851
7317
|
return { exists: true, absolutePath: homePath, source: "home" };
|
|
6852
7318
|
}
|
|
@@ -6889,12 +7355,12 @@ var parseEnvContent = (content) => {
|
|
|
6889
7355
|
return env;
|
|
6890
7356
|
};
|
|
6891
7357
|
var loadEnvFileAsync = async ({ envPath }) => {
|
|
6892
|
-
const
|
|
6893
|
-
const absolutePath =
|
|
6894
|
-
if (!await
|
|
7358
|
+
const fs2 = getFileSystem();
|
|
7359
|
+
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
|
|
7360
|
+
if (!await fs2.exists(absolutePath)) {
|
|
6895
7361
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
6896
7362
|
}
|
|
6897
|
-
const content = await
|
|
7363
|
+
const content = await fs2.readFile(absolutePath, "utf-8");
|
|
6898
7364
|
if (content === null) {
|
|
6899
7365
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
6900
7366
|
}
|
|
@@ -6905,10 +7371,10 @@ var saveEnvFileAsync = async ({
|
|
|
6905
7371
|
data,
|
|
6906
7372
|
merge = true
|
|
6907
7373
|
}) => {
|
|
6908
|
-
const
|
|
6909
|
-
const absolutePath =
|
|
7374
|
+
const fs2 = getFileSystem();
|
|
7375
|
+
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.homedir(), envPath);
|
|
6910
7376
|
let existingData = {};
|
|
6911
|
-
if (merge && await
|
|
7377
|
+
if (merge && await fs2.exists(absolutePath)) {
|
|
6912
7378
|
try {
|
|
6913
7379
|
existingData = await loadEnvFileAsync({ envPath: absolutePath });
|
|
6914
7380
|
} catch {}
|
|
@@ -6926,11 +7392,11 @@ var saveEnvFileAsync = async ({
|
|
|
6926
7392
|
const content = `${lines.join(`
|
|
6927
7393
|
`)}
|
|
6928
7394
|
`;
|
|
6929
|
-
const dir =
|
|
6930
|
-
await
|
|
7395
|
+
const dir = fs2.path.dirname(absolutePath);
|
|
7396
|
+
await fs2.mkdir(dir);
|
|
6931
7397
|
const tempPath = `${absolutePath}.tmp`;
|
|
6932
|
-
await
|
|
6933
|
-
await
|
|
7398
|
+
await fs2.writeFile(tempPath, content);
|
|
7399
|
+
await fs2.rename(tempPath, absolutePath);
|
|
6934
7400
|
};
|
|
6935
7401
|
|
|
6936
7402
|
// ../auth/src/loginStatus.ts
|
|
@@ -7044,11 +7510,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
|
|
|
7044
7510
|
return { credentials };
|
|
7045
7511
|
}
|
|
7046
7512
|
async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
|
|
7047
|
-
const
|
|
7048
|
-
const globalPath =
|
|
7513
|
+
const fs2 = getFs();
|
|
7514
|
+
const globalPath = fs2.path.join(fs2.env.homedir(), envFilePath);
|
|
7049
7515
|
if (absolutePath === globalPath)
|
|
7050
7516
|
return;
|
|
7051
|
-
if (!await
|
|
7517
|
+
if (!await fs2.exists(globalPath))
|
|
7052
7518
|
return;
|
|
7053
7519
|
try {
|
|
7054
7520
|
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
@@ -7457,6 +7923,6 @@ var TENANT_SELECTION_CODES = new Set([
|
|
|
7457
7923
|
TENANT_SELECTION_REQUIRED_CODE,
|
|
7458
7924
|
INVALID_TENANT_CODE
|
|
7459
7925
|
]);
|
|
7460
|
-
export { catchError, extractErrorMessage, RESULTS, Pagination, OutputFormatter, Command, processContext, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, getAuthContext };
|
|
7926
|
+
export { catchError, carriedInstructions, extractErrorDetails, extractErrorMessage, RESULTS, Pagination, OutputFormatter, Command, processContext, instructionsFor, mimeTypeForFileName, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, getAuthContext };
|
|
7461
7927
|
|
|
7462
|
-
//# debugId=
|
|
7928
|
+
//# debugId=DC3201D6735AF35364756E2164756E21
|