@uipath/tasks-tool 1.201.0 → 1.202.0-preview.136
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/{folder-picker-interactive-2kj361mt.js → folder-picker-interactive-1j0ncph1.js} +6 -9
- package/dist/{folder-resolver-htdmzdhy.js → folder-resolver-6pbmf1am.js} +6 -9
- package/dist/{getMachineId-bsd-wfkxpxjv.js → getMachineId-bsd-67w37xtj.js} +5 -5
- package/dist/{getMachineId-darwin-9asn4zy6.js → getMachineId-darwin-4g3xfpfp.js} +5 -5
- package/dist/{getMachineId-linux-62t6m027.js → getMachineId-linux-a4p6fb9w.js} +4 -4
- package/dist/{getMachineId-unsupported-dfrzeqc3.js → getMachineId-unsupported-77w362eh.js} +4 -4
- package/dist/{getMachineId-win-zgvrp5q3.js → getMachineId-win-9cfxg9c8.js} +5 -5
- package/dist/{index-2fj08e7n.js → index-gpd94m28.js} +27 -27
- package/dist/{index-w03qc9m8.js → index-sby22td6.js} +4 -4
- package/dist/index.js +5 -8
- package/dist/{js-yaml-4ypbq2tt.js → js-yaml-88tdqrtd.js} +27 -19
- package/dist/{tool-0n9mj887.js → tool-1b723ek8.js} +3 -3
- package/dist/{tool-0v6na3yp.js → tool-1de529jm.js} +9 -7
- package/dist/{tool-h1k9mjs9.js → tool-2czkpqb0.js} +3 -3
- package/dist/{tool-r6rhp5ep.js → tool-bndhpxxj.js} +46 -46
- package/dist/{tool-mw0gkfep.js → tool-p1m6mq0e.js} +104 -119
- package/dist/{tool-rsk1xt86.js → tool-wfqnt43t.js} +1600 -504
- package/dist/tool.js +7 -10
- package/package.json +2 -2
- package/src/commands/catalogs.ts +25 -21
- package/src/commands/tasks.spec.ts +96 -66
- package/tests/catalogs.e2e.test.ts +25 -0
- package/dist/browser-strategy-yccf8mtd.js +0 -99
- package/dist/node-strategy-12qfy0nv.js +0 -348
- package/dist/tool-5arsyj36.js +0 -11
- package/dist/tool-7eva0peq.js +0 -265
- package/dist/tool-9qecd4wb.js +0 -14
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isBrowser
|
|
3
|
-
} from "./tool-9qecd4wb.js";
|
|
4
|
-
import {
|
|
5
|
-
catchError,
|
|
6
|
-
getFileSystem
|
|
7
|
-
} from "./tool-7eva0peq.js";
|
|
8
|
-
import {
|
|
9
|
-
AUTH_FILENAME,
|
|
10
|
-
DEFAULT_BASE_URL,
|
|
11
|
-
UIPATH_HOME_DIR
|
|
12
|
-
} from "./tool-5arsyj36.js";
|
|
13
1
|
import {
|
|
14
2
|
__commonJS,
|
|
15
3
|
__require,
|
|
16
4
|
__toESM
|
|
17
|
-
} from "./tool-
|
|
5
|
+
} from "./tool-1de529jm.js";
|
|
18
6
|
|
|
19
7
|
// ../../node_modules/commander/lib/error.js
|
|
20
|
-
var require_error = __commonJS((exports)
|
|
8
|
+
var require_error = __commonJS(function(exports) {
|
|
21
9
|
class CommanderError extends Error {
|
|
22
10
|
constructor(exitCode, code, message) {
|
|
23
11
|
super(message);
|
|
@@ -41,7 +29,7 @@ var require_error = __commonJS((exports) => {
|
|
|
41
29
|
});
|
|
42
30
|
|
|
43
31
|
// ../../node_modules/commander/lib/argument.js
|
|
44
|
-
var require_argument = __commonJS((exports)
|
|
32
|
+
var require_argument = __commonJS(function(exports) {
|
|
45
33
|
var { InvalidArgumentError } = require_error();
|
|
46
34
|
|
|
47
35
|
class Argument {
|
|
@@ -121,7 +109,7 @@ var require_argument = __commonJS((exports) => {
|
|
|
121
109
|
});
|
|
122
110
|
|
|
123
111
|
// ../../node_modules/commander/lib/help.js
|
|
124
|
-
var require_help = __commonJS((exports)
|
|
112
|
+
var require_help = __commonJS(function(exports) {
|
|
125
113
|
var { humanReadableArgName } = require_argument();
|
|
126
114
|
|
|
127
115
|
class Help {
|
|
@@ -478,7 +466,7 @@ ${itemIndentStr}`);
|
|
|
478
466
|
});
|
|
479
467
|
|
|
480
468
|
// ../../node_modules/commander/lib/option.js
|
|
481
|
-
var require_option = __commonJS((exports)
|
|
469
|
+
var require_option = __commonJS(function(exports) {
|
|
482
470
|
var { InvalidArgumentError } = require_error();
|
|
483
471
|
|
|
484
472
|
class Option {
|
|
@@ -662,7 +650,7 @@ var require_option = __commonJS((exports) => {
|
|
|
662
650
|
});
|
|
663
651
|
|
|
664
652
|
// ../../node_modules/commander/lib/suggestSimilar.js
|
|
665
|
-
var require_suggestSimilar = __commonJS((exports)
|
|
653
|
+
var require_suggestSimilar = __commonJS(function(exports) {
|
|
666
654
|
var maxDistance = 3;
|
|
667
655
|
function editDistance(a, b) {
|
|
668
656
|
if (Math.abs(a.length - b.length) > maxDistance)
|
|
@@ -735,11 +723,11 @@ var require_suggestSimilar = __commonJS((exports) => {
|
|
|
735
723
|
});
|
|
736
724
|
|
|
737
725
|
// ../../node_modules/commander/lib/command.js
|
|
738
|
-
var require_command = __commonJS((exports)
|
|
726
|
+
var require_command = __commonJS(function(exports) {
|
|
739
727
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
740
728
|
var childProcess = __require("node:child_process");
|
|
741
|
-
var
|
|
742
|
-
var
|
|
729
|
+
var path2 = __require("node:path");
|
|
730
|
+
var fs2 = __require("node:fs");
|
|
743
731
|
var process2 = __require("node:process");
|
|
744
732
|
var { Argument, humanReadableArgName } = require_argument();
|
|
745
733
|
var { CommanderError } = require_error();
|
|
@@ -1274,7 +1262,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1274
1262
|
this.processedArgs = [];
|
|
1275
1263
|
}
|
|
1276
1264
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
1277
|
-
if (
|
|
1265
|
+
if (fs2.existsSync(executableFile))
|
|
1278
1266
|
return;
|
|
1279
1267
|
const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
|
|
1280
1268
|
const executableMissing = `'${executableFile}' does not exist
|
|
@@ -1288,12 +1276,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1288
1276
|
let launchWithNode = false;
|
|
1289
1277
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1290
1278
|
function findFile(baseDir, baseName) {
|
|
1291
|
-
const localBin =
|
|
1292
|
-
if (
|
|
1279
|
+
const localBin = path2.resolve(baseDir, baseName);
|
|
1280
|
+
if (fs2.existsSync(localBin))
|
|
1293
1281
|
return localBin;
|
|
1294
|
-
if (sourceExt.includes(
|
|
1282
|
+
if (sourceExt.includes(path2.extname(baseName)))
|
|
1295
1283
|
return;
|
|
1296
|
-
const foundExt = sourceExt.find((ext) =>
|
|
1284
|
+
const foundExt = sourceExt.find((ext) => fs2.existsSync(`${localBin}${ext}`));
|
|
1297
1285
|
if (foundExt)
|
|
1298
1286
|
return `${localBin}${foundExt}`;
|
|
1299
1287
|
return;
|
|
@@ -1305,23 +1293,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1305
1293
|
if (this._scriptPath) {
|
|
1306
1294
|
let resolvedScriptPath;
|
|
1307
1295
|
try {
|
|
1308
|
-
resolvedScriptPath =
|
|
1296
|
+
resolvedScriptPath = fs2.realpathSync(this._scriptPath);
|
|
1309
1297
|
} catch {
|
|
1310
1298
|
resolvedScriptPath = this._scriptPath;
|
|
1311
1299
|
}
|
|
1312
|
-
executableDir =
|
|
1300
|
+
executableDir = path2.resolve(path2.dirname(resolvedScriptPath), executableDir);
|
|
1313
1301
|
}
|
|
1314
1302
|
if (executableDir) {
|
|
1315
1303
|
let localFile = findFile(executableDir, executableFile);
|
|
1316
1304
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
1317
|
-
const legacyName =
|
|
1305
|
+
const legacyName = path2.basename(this._scriptPath, path2.extname(this._scriptPath));
|
|
1318
1306
|
if (legacyName !== this._name) {
|
|
1319
1307
|
localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
|
|
1320
1308
|
}
|
|
1321
1309
|
}
|
|
1322
1310
|
executableFile = localFile || executableFile;
|
|
1323
1311
|
}
|
|
1324
|
-
launchWithNode = sourceExt.includes(
|
|
1312
|
+
launchWithNode = sourceExt.includes(path2.extname(executableFile));
|
|
1325
1313
|
let proc;
|
|
1326
1314
|
if (process2.platform !== "win32") {
|
|
1327
1315
|
if (launchWithNode) {
|
|
@@ -1910,13 +1898,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1910
1898
|
cmd.helpGroup(this._defaultCommandGroup);
|
|
1911
1899
|
}
|
|
1912
1900
|
nameFromFilename(filename) {
|
|
1913
|
-
this._name =
|
|
1901
|
+
this._name = path2.basename(filename, path2.extname(filename));
|
|
1914
1902
|
return this;
|
|
1915
1903
|
}
|
|
1916
|
-
executableDir(
|
|
1917
|
-
if (
|
|
1904
|
+
executableDir(path3) {
|
|
1905
|
+
if (path3 === undefined)
|
|
1918
1906
|
return this._executableDir;
|
|
1919
|
-
this._executableDir =
|
|
1907
|
+
this._executableDir = path3;
|
|
1920
1908
|
return this;
|
|
1921
1909
|
}
|
|
1922
1910
|
helpInformation(contextOptions) {
|
|
@@ -2090,7 +2078,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2090
2078
|
});
|
|
2091
2079
|
|
|
2092
2080
|
// ../../node_modules/commander/index.js
|
|
2093
|
-
var require_commander = __commonJS((exports)
|
|
2081
|
+
var require_commander = __commonJS(function(exports) {
|
|
2094
2082
|
var { Argument } = require_argument();
|
|
2095
2083
|
var { Command } = require_command();
|
|
2096
2084
|
var { CommanderError, InvalidArgumentError } = require_error();
|
|
@@ -2109,11 +2097,523 @@ var require_commander = __commonJS((exports) => {
|
|
|
2109
2097
|
exports.InvalidOptionArgumentError = InvalidArgumentError;
|
|
2110
2098
|
});
|
|
2111
2099
|
|
|
2100
|
+
// ../common/src/telemetry/pseudonymize.ts
|
|
2101
|
+
var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
|
|
2102
|
+
var PSEUDONYM_HEX_LENGTH = 32;
|
|
2103
|
+
var SHA256_K = new Uint32Array([
|
|
2104
|
+
1116352408,
|
|
2105
|
+
1899447441,
|
|
2106
|
+
3049323471,
|
|
2107
|
+
3921009573,
|
|
2108
|
+
961987163,
|
|
2109
|
+
1508970993,
|
|
2110
|
+
2453635748,
|
|
2111
|
+
2870763221,
|
|
2112
|
+
3624381080,
|
|
2113
|
+
310598401,
|
|
2114
|
+
607225278,
|
|
2115
|
+
1426881987,
|
|
2116
|
+
1925078388,
|
|
2117
|
+
2162078206,
|
|
2118
|
+
2614888103,
|
|
2119
|
+
3248222580,
|
|
2120
|
+
3835390401,
|
|
2121
|
+
4022224774,
|
|
2122
|
+
264347078,
|
|
2123
|
+
604807628,
|
|
2124
|
+
770255983,
|
|
2125
|
+
1249150122,
|
|
2126
|
+
1555081692,
|
|
2127
|
+
1996064986,
|
|
2128
|
+
2554220882,
|
|
2129
|
+
2821834349,
|
|
2130
|
+
2952996808,
|
|
2131
|
+
3210313671,
|
|
2132
|
+
3336571891,
|
|
2133
|
+
3584528711,
|
|
2134
|
+
113926993,
|
|
2135
|
+
338241895,
|
|
2136
|
+
666307205,
|
|
2137
|
+
773529912,
|
|
2138
|
+
1294757372,
|
|
2139
|
+
1396182291,
|
|
2140
|
+
1695183700,
|
|
2141
|
+
1986661051,
|
|
2142
|
+
2177026350,
|
|
2143
|
+
2456956037,
|
|
2144
|
+
2730485921,
|
|
2145
|
+
2820302411,
|
|
2146
|
+
3259730800,
|
|
2147
|
+
3345764771,
|
|
2148
|
+
3516065817,
|
|
2149
|
+
3600352804,
|
|
2150
|
+
4094571909,
|
|
2151
|
+
275423344,
|
|
2152
|
+
430227734,
|
|
2153
|
+
506948616,
|
|
2154
|
+
659060556,
|
|
2155
|
+
883997877,
|
|
2156
|
+
958139571,
|
|
2157
|
+
1322822218,
|
|
2158
|
+
1537002063,
|
|
2159
|
+
1747873779,
|
|
2160
|
+
1955562222,
|
|
2161
|
+
2024104815,
|
|
2162
|
+
2227730452,
|
|
2163
|
+
2361852424,
|
|
2164
|
+
2428436474,
|
|
2165
|
+
2756734187,
|
|
2166
|
+
3204031479,
|
|
2167
|
+
3329325298
|
|
2168
|
+
]);
|
|
2169
|
+
var SHA256_INITIAL_STATE = new Uint32Array([
|
|
2170
|
+
1779033703,
|
|
2171
|
+
3144134277,
|
|
2172
|
+
1013904242,
|
|
2173
|
+
2773480762,
|
|
2174
|
+
1359893119,
|
|
2175
|
+
2600822924,
|
|
2176
|
+
528734635,
|
|
2177
|
+
1541459225
|
|
2178
|
+
]);
|
|
2179
|
+
function rotr(value, bits) {
|
|
2180
|
+
return (value >>> bits | value << 32 - bits) >>> 0;
|
|
2181
|
+
}
|
|
2182
|
+
function sha256Hex(input) {
|
|
2183
|
+
const bytes = new TextEncoder().encode(input);
|
|
2184
|
+
const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
|
|
2185
|
+
const buffer = new Uint8Array(paddedLength);
|
|
2186
|
+
buffer.set(bytes);
|
|
2187
|
+
buffer[bytes.length] = 128;
|
|
2188
|
+
const view = new DataView(buffer.buffer);
|
|
2189
|
+
const bitLength = bytes.length * 8;
|
|
2190
|
+
view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296));
|
|
2191
|
+
view.setUint32(paddedLength - 4, bitLength >>> 0);
|
|
2192
|
+
const state = SHA256_INITIAL_STATE.slice();
|
|
2193
|
+
const schedule = new Uint32Array(64);
|
|
2194
|
+
for (let offset = 0;offset < paddedLength; offset += 64) {
|
|
2195
|
+
for (let i = 0;i < 16; i++) {
|
|
2196
|
+
schedule[i] = view.getUint32(offset + i * 4);
|
|
2197
|
+
}
|
|
2198
|
+
for (let i = 16;i < 64; i++) {
|
|
2199
|
+
const x = schedule[i - 15];
|
|
2200
|
+
const y = schedule[i - 2];
|
|
2201
|
+
const s0 = (rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3) >>> 0;
|
|
2202
|
+
const s1 = (rotr(y, 17) ^ rotr(y, 19) ^ y >>> 10) >>> 0;
|
|
2203
|
+
schedule[i] = schedule[i - 16] + s0 + schedule[i - 7] + s1 >>> 0;
|
|
2204
|
+
}
|
|
2205
|
+
let a = state[0];
|
|
2206
|
+
let b = state[1];
|
|
2207
|
+
let c = state[2];
|
|
2208
|
+
let d = state[3];
|
|
2209
|
+
let e = state[4];
|
|
2210
|
+
let f = state[5];
|
|
2211
|
+
let g = state[6];
|
|
2212
|
+
let h = state[7];
|
|
2213
|
+
for (let i = 0;i < 64; i++) {
|
|
2214
|
+
const s1 = (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) >>> 0;
|
|
2215
|
+
const ch = (e & f ^ ~e & g) >>> 0;
|
|
2216
|
+
const temp1 = h + s1 + ch + SHA256_K[i] + schedule[i] >>> 0;
|
|
2217
|
+
const s0 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) >>> 0;
|
|
2218
|
+
const maj = (a & b ^ a & c ^ b & c) >>> 0;
|
|
2219
|
+
const temp2 = s0 + maj >>> 0;
|
|
2220
|
+
h = g;
|
|
2221
|
+
g = f;
|
|
2222
|
+
f = e;
|
|
2223
|
+
e = d + temp1 >>> 0;
|
|
2224
|
+
d = c;
|
|
2225
|
+
c = b;
|
|
2226
|
+
b = a;
|
|
2227
|
+
a = temp1 + temp2 >>> 0;
|
|
2228
|
+
}
|
|
2229
|
+
state[0] = state[0] + a >>> 0;
|
|
2230
|
+
state[1] = state[1] + b >>> 0;
|
|
2231
|
+
state[2] = state[2] + c >>> 0;
|
|
2232
|
+
state[3] = state[3] + d >>> 0;
|
|
2233
|
+
state[4] = state[4] + e >>> 0;
|
|
2234
|
+
state[5] = state[5] + f >>> 0;
|
|
2235
|
+
state[6] = state[6] + g >>> 0;
|
|
2236
|
+
state[7] = state[7] + h >>> 0;
|
|
2237
|
+
}
|
|
2238
|
+
let hex = "";
|
|
2239
|
+
for (const word of state) {
|
|
2240
|
+
hex += word.toString(16).padStart(8, "0");
|
|
2241
|
+
}
|
|
2242
|
+
return hex;
|
|
2243
|
+
}
|
|
2244
|
+
function resolveSha256Hex() {
|
|
2245
|
+
try {
|
|
2246
|
+
const nodeCrypto = __require("node:crypto");
|
|
2247
|
+
const createHash = nodeCrypto?.createHash;
|
|
2248
|
+
if (typeof createHash !== "function") {
|
|
2249
|
+
return sha256Hex;
|
|
2250
|
+
}
|
|
2251
|
+
const native = (input) => createHash("sha256").update(input, "utf8").digest("hex");
|
|
2252
|
+
return native("abc") === sha256Hex("abc") ? native : sha256Hex;
|
|
2253
|
+
} catch {
|
|
2254
|
+
return sha256Hex;
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
var cachedSha256Hex;
|
|
2258
|
+
function digest(input) {
|
|
2259
|
+
cachedSha256Hex ??= resolveSha256Hex();
|
|
2260
|
+
return cachedSha256Hex(input);
|
|
2261
|
+
}
|
|
2262
|
+
function pseudonymize(input) {
|
|
2263
|
+
return digest(`${PSEUDONYM_DOMAIN}${input}`).slice(0, PSEUDONYM_HEX_LENGTH);
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
// ../common/src/singleton.ts
|
|
2267
|
+
var PREFIX = "@uipath/common/";
|
|
2268
|
+
var _g = globalThis;
|
|
2269
|
+
function singleton(ctorOrName) {
|
|
2270
|
+
const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name;
|
|
2271
|
+
const key = Symbol.for(PREFIX + name);
|
|
2272
|
+
return {
|
|
2273
|
+
get(fallback) {
|
|
2274
|
+
return _g[key] ?? fallback;
|
|
2275
|
+
},
|
|
2276
|
+
set(value) {
|
|
2277
|
+
_g[key] = value;
|
|
2278
|
+
},
|
|
2279
|
+
clear() {
|
|
2280
|
+
delete _g[key];
|
|
2281
|
+
},
|
|
2282
|
+
getOrInit(factory, guard) {
|
|
2283
|
+
const existing = _g[key];
|
|
2284
|
+
if (existing != null && typeof existing === "object") {
|
|
2285
|
+
if (!guard || guard(existing)) {
|
|
2286
|
+
return existing;
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
const instance = factory();
|
|
2290
|
+
_g[key] = instance;
|
|
2291
|
+
return instance;
|
|
2292
|
+
}
|
|
2293
|
+
};
|
|
2294
|
+
}
|
|
2295
|
+
|
|
2296
|
+
// ../common/src/telemetry/supplied-values.ts
|
|
2297
|
+
var suppliedValuesSlot = singleton("TelemetrySuppliedArgumentValues");
|
|
2298
|
+
function activeEntries() {
|
|
2299
|
+
const existing = suppliedValuesSlot.get();
|
|
2300
|
+
return Array.isArray(existing) ? existing : [];
|
|
2301
|
+
}
|
|
2302
|
+
var MIN_SCRUBBABLE_LENGTH = 4;
|
|
2303
|
+
function recordSuppliedArgumentValues(values) {
|
|
2304
|
+
const flat = [];
|
|
2305
|
+
const push = (value) => {
|
|
2306
|
+
if (Array.isArray(value)) {
|
|
2307
|
+
for (const item of value) {
|
|
2308
|
+
push(item);
|
|
2309
|
+
}
|
|
2310
|
+
return;
|
|
2311
|
+
}
|
|
2312
|
+
if (typeof value === "string" && value.length >= MIN_SCRUBBABLE_LENGTH) {
|
|
2313
|
+
flat.push(value);
|
|
2314
|
+
}
|
|
2315
|
+
};
|
|
2316
|
+
push(values);
|
|
2317
|
+
const entry = { values: flat };
|
|
2318
|
+
suppliedValuesSlot.set([...activeEntries(), entry]);
|
|
2319
|
+
return entry;
|
|
2320
|
+
}
|
|
2321
|
+
function releaseSuppliedArgumentValues(entry) {
|
|
2322
|
+
suppliedValuesSlot.set(activeEntries().filter((held) => held !== entry));
|
|
2323
|
+
}
|
|
2324
|
+
function getSuppliedArgumentValues() {
|
|
2325
|
+
const all = new Set;
|
|
2326
|
+
for (const entry of activeEntries()) {
|
|
2327
|
+
for (const value of entry.values) {
|
|
2328
|
+
all.add(value);
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
return [...all].sort((a, b) => b.length - a.length);
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
// ../common/src/telemetry/pii-redactor.ts
|
|
2335
|
+
var REDACTED = "[REDACTED]";
|
|
2336
|
+
var MAX_VALUE_LENGTH = 280;
|
|
2337
|
+
var MAX_STACK_LENGTH = 4096;
|
|
2338
|
+
var MAX_SCAN_LENGTH = MAX_STACK_LENGTH;
|
|
2339
|
+
function truncate(value, maxLength) {
|
|
2340
|
+
return value.length > maxLength ? `${value.slice(0, maxLength)}…` : value;
|
|
2341
|
+
}
|
|
2342
|
+
var SENSITIVE_NAME_TOKENS = new Set([
|
|
2343
|
+
"token",
|
|
2344
|
+
"tokens",
|
|
2345
|
+
"secret",
|
|
2346
|
+
"secrets",
|
|
2347
|
+
"password",
|
|
2348
|
+
"passwords",
|
|
2349
|
+
"pwd",
|
|
2350
|
+
"credential",
|
|
2351
|
+
"credentials",
|
|
2352
|
+
"auth",
|
|
2353
|
+
"authentication",
|
|
2354
|
+
"authorization",
|
|
2355
|
+
"authority",
|
|
2356
|
+
"cert",
|
|
2357
|
+
"certificate",
|
|
2358
|
+
"certificates"
|
|
2359
|
+
]);
|
|
2360
|
+
var SENSITIVE_KEY_PREFIXES = new Set([
|
|
2361
|
+
"api",
|
|
2362
|
+
"access",
|
|
2363
|
+
"client",
|
|
2364
|
+
"private",
|
|
2365
|
+
"public",
|
|
2366
|
+
"signing",
|
|
2367
|
+
"encryption",
|
|
2368
|
+
"session",
|
|
2369
|
+
"master",
|
|
2370
|
+
"shared",
|
|
2371
|
+
"root",
|
|
2372
|
+
"ssh",
|
|
2373
|
+
"rsa",
|
|
2374
|
+
"aes",
|
|
2375
|
+
"hmac",
|
|
2376
|
+
"oauth"
|
|
2377
|
+
]);
|
|
2378
|
+
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;
|
|
2379
|
+
var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
2380
|
+
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
2381
|
+
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
2382
|
+
var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
|
|
2383
|
+
var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
|
|
2384
|
+
var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
|
|
2385
|
+
var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
|
|
2386
|
+
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;
|
|
2387
|
+
var SOURCE_FILE_EXTENSIONS = new Set([
|
|
2388
|
+
"ts",
|
|
2389
|
+
"tsx",
|
|
2390
|
+
"js",
|
|
2391
|
+
"jsx",
|
|
2392
|
+
"mjs",
|
|
2393
|
+
"cjs",
|
|
2394
|
+
"cts",
|
|
2395
|
+
"mts",
|
|
2396
|
+
"py",
|
|
2397
|
+
"cs",
|
|
2398
|
+
"java",
|
|
2399
|
+
"go",
|
|
2400
|
+
"rs",
|
|
2401
|
+
"rb",
|
|
2402
|
+
"php",
|
|
2403
|
+
"sh",
|
|
2404
|
+
"ps1",
|
|
2405
|
+
"json",
|
|
2406
|
+
"jsonc",
|
|
2407
|
+
"yaml",
|
|
2408
|
+
"yml",
|
|
2409
|
+
"xml",
|
|
2410
|
+
"xaml",
|
|
2411
|
+
"md",
|
|
2412
|
+
"txt",
|
|
2413
|
+
"log",
|
|
2414
|
+
"css",
|
|
2415
|
+
"html",
|
|
2416
|
+
"htm",
|
|
2417
|
+
"csproj",
|
|
2418
|
+
"nuspec",
|
|
2419
|
+
"sql"
|
|
2420
|
+
]);
|
|
2421
|
+
var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
|
|
2422
|
+
var QUOTED_LITERAL_MAX_SPAN = 200;
|
|
2423
|
+
var QUOTED_LITERAL_PATTERN = new RegExp([
|
|
2424
|
+
`(?<![A-Za-z0-9])'(?:[^\\
|
|
2425
|
+
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?'(?![A-Za-z0-9])`,
|
|
2426
|
+
`(?<![A-Za-z0-9])"(?:[^\\
|
|
2427
|
+
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
|
|
2428
|
+
].join("|"), "g");
|
|
2429
|
+
var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
|
|
2430
|
+
var COLLAPSED_BODY = "{…}";
|
|
2431
|
+
var COLLAPSED_BODY_MARKER = "\x01body\x01";
|
|
2432
|
+
var MAX_BODY_NESTING = 8;
|
|
2433
|
+
function collapseJsonBodies(text) {
|
|
2434
|
+
let out = text;
|
|
2435
|
+
for (let pass = 0;pass < MAX_BODY_NESTING; pass++) {
|
|
2436
|
+
const next = out.replace(JSON_BODY_PATTERN, COLLAPSED_BODY_MARKER);
|
|
2437
|
+
if (next === out) {
|
|
2438
|
+
break;
|
|
2439
|
+
}
|
|
2440
|
+
out = next;
|
|
2441
|
+
}
|
|
2442
|
+
return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
|
|
2443
|
+
}
|
|
2444
|
+
var TRAILING_PROSE_PUNCT = /[.,;:!?)\]}>'"]+$/;
|
|
2445
|
+
function peelTrailingPunctuation(match) {
|
|
2446
|
+
const trailing = match.match(TRAILING_PROSE_PUNCT)?.[0] ?? "";
|
|
2447
|
+
return trailing ? [match.slice(0, -trailing.length), trailing] : [match, ""];
|
|
2448
|
+
}
|
|
2449
|
+
function redactUrl(raw) {
|
|
2450
|
+
try {
|
|
2451
|
+
const url = new URL(raw);
|
|
2452
|
+
return `${url.protocol}//${url.host}`;
|
|
2453
|
+
} catch {
|
|
2454
|
+
return `url#${pseudonymize(raw)}`;
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
function redactValueDetectors(value, maxLength = MAX_VALUE_LENGTH) {
|
|
2458
|
+
let out = truncate(value, MAX_SCAN_LENGTH);
|
|
2459
|
+
out = out.replace(JWT_PATTERN, () => REDACTED);
|
|
2460
|
+
out = out.replace(URL_PATTERN, (match) => {
|
|
2461
|
+
const [core, trailing] = peelTrailingPunctuation(match);
|
|
2462
|
+
return `${redactUrl(core)}${trailing}`;
|
|
2463
|
+
});
|
|
2464
|
+
out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
|
|
2465
|
+
out = out.replace(UNC_PATH_PATTERN, (_match, before, path) => {
|
|
2466
|
+
const [core, trailing] = peelTrailingPunctuation(path);
|
|
2467
|
+
return `${before}unc#${pseudonymize(core)}${trailing}`;
|
|
2468
|
+
});
|
|
2469
|
+
out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
|
|
2470
|
+
out = out.replace(UUID_PATTERN, (match) => `uuid#${pseudonymize(match)}`);
|
|
2471
|
+
out = out.replace(HOST_PORT_PATTERN, (match) => {
|
|
2472
|
+
const split = match.lastIndexOf(":");
|
|
2473
|
+
const host = match.slice(0, split);
|
|
2474
|
+
const extension = host.slice(host.lastIndexOf(".") + 1).toLowerCase();
|
|
2475
|
+
if (SOURCE_FILE_EXTENSIONS.has(extension)) {
|
|
2476
|
+
return match;
|
|
2477
|
+
}
|
|
2478
|
+
return `host#${pseudonymize(host)}:${match.slice(split + 1)}`;
|
|
2479
|
+
});
|
|
2480
|
+
out = out.replace(PADDED_BASE64_PATTERN, () => REDACTED);
|
|
2481
|
+
out = out.replace(BASE64_WITH_PLUS_PATTERN, (match) => match.includes("+") ? REDACTED : match);
|
|
2482
|
+
out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
|
|
2483
|
+
return truncate(out, maxLength);
|
|
2484
|
+
}
|
|
2485
|
+
function redactSpanName(name) {
|
|
2486
|
+
return redactValueDetectors(truncate(name, MAX_SCAN_LENGTH).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`));
|
|
2487
|
+
}
|
|
2488
|
+
var HTTP_DEPENDENCY_NAME = /^([A-Z]+) (\/.*)$/s;
|
|
2489
|
+
function redactHttpDependencyName(name) {
|
|
2490
|
+
const parts = HTTP_DEPENDENCY_NAME.exec(name);
|
|
2491
|
+
if (!parts) {
|
|
2492
|
+
return redactMessage(name);
|
|
2493
|
+
}
|
|
2494
|
+
return `${parts[1]} ${redactMessage(parts[2])}`;
|
|
2495
|
+
}
|
|
2496
|
+
function redactMessage(value) {
|
|
2497
|
+
let out = collapseJsonBodies(truncate(value, MAX_SCAN_LENGTH)).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`);
|
|
2498
|
+
for (const supplied of getSuppliedArgumentValues()) {
|
|
2499
|
+
out = out.split(supplied).join(REDACTED);
|
|
2500
|
+
}
|
|
2501
|
+
return redactValueDetectors(out);
|
|
2502
|
+
}
|
|
2503
|
+
var MESSAGE_NAMES = new Set([
|
|
2504
|
+
"message",
|
|
2505
|
+
"errormessage",
|
|
2506
|
+
"errmessage",
|
|
2507
|
+
"error_message",
|
|
2508
|
+
"msg",
|
|
2509
|
+
"detail",
|
|
2510
|
+
"details",
|
|
2511
|
+
"reason",
|
|
2512
|
+
"instructions",
|
|
2513
|
+
"warning"
|
|
2514
|
+
]);
|
|
2515
|
+
function isFreeFormValue(name, value) {
|
|
2516
|
+
return MESSAGE_NAMES.has(name.toLowerCase()) || /['"{[]/.test(value);
|
|
2517
|
+
}
|
|
2518
|
+
function redactError(error) {
|
|
2519
|
+
const safe = new Error(redactMessage(error.message ?? ""));
|
|
2520
|
+
safe.name = error.name;
|
|
2521
|
+
safe.stack = typeof error.stack === "string" ? redactStack(error.stack) : undefined;
|
|
2522
|
+
return safe;
|
|
2523
|
+
}
|
|
2524
|
+
function redactStack(stack) {
|
|
2525
|
+
const bounded = truncate(stack, MAX_STACK_LENGTH);
|
|
2526
|
+
const firstBreak = bounded.indexOf(`
|
|
2527
|
+
`);
|
|
2528
|
+
if (firstBreak === -1) {
|
|
2529
|
+
return redactMessage(bounded);
|
|
2530
|
+
}
|
|
2531
|
+
return `${redactMessage(bounded.slice(0, firstBreak))}
|
|
2532
|
+
${redactValueDetectors(bounded.slice(firstBreak + 1), MAX_STACK_LENGTH)}`;
|
|
2533
|
+
}
|
|
2534
|
+
function nameTokens(name) {
|
|
2535
|
+
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);
|
|
2536
|
+
}
|
|
2537
|
+
function isSensitiveName(name) {
|
|
2538
|
+
const tokens = nameTokens(name);
|
|
2539
|
+
for (let i = 0;i < tokens.length; i++) {
|
|
2540
|
+
const token = tokens[i];
|
|
2541
|
+
if (SENSITIVE_NAME_TOKENS.has(token)) {
|
|
2542
|
+
return true;
|
|
2543
|
+
}
|
|
2544
|
+
if (token === "key" || token === "keys") {
|
|
2545
|
+
const prev = tokens[i - 1];
|
|
2546
|
+
if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
|
|
2547
|
+
return true;
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
return false;
|
|
2552
|
+
}
|
|
2553
|
+
function redactProperty(name, value) {
|
|
2554
|
+
if (value === undefined || value === null) {
|
|
2555
|
+
return;
|
|
2556
|
+
}
|
|
2557
|
+
if (isSensitiveName(name)) {
|
|
2558
|
+
return REDACTED;
|
|
2559
|
+
}
|
|
2560
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
2561
|
+
return value;
|
|
2562
|
+
}
|
|
2563
|
+
if (typeof value !== "string") {
|
|
2564
|
+
return "[OBJECT]";
|
|
2565
|
+
}
|
|
2566
|
+
return isFreeFormValue(name, value) ? redactMessage(value) : redactValueDetectors(value);
|
|
2567
|
+
}
|
|
2568
|
+
function redactProperties(properties) {
|
|
2569
|
+
const out = {};
|
|
2570
|
+
for (const [name, value] of Object.entries(properties)) {
|
|
2571
|
+
const redacted = redactProperty(name, value);
|
|
2572
|
+
if (redacted !== undefined) {
|
|
2573
|
+
out[name] = redacted;
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
return out;
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2112
2579
|
// ../common/src/catch-error.ts
|
|
2580
|
+
var MAX_SERIALIZED_LENGTH = 500;
|
|
2581
|
+
var TRUNCATION_SUFFIX = "…(truncated)";
|
|
2582
|
+
var REDACTED2 = "[REDACTED]";
|
|
2583
|
+
function cap(text) {
|
|
2584
|
+
return text.length > MAX_SERIALIZED_LENGTH ? `${text.slice(0, MAX_SERIALIZED_LENGTH)}${TRUNCATION_SUFFIX}` : text;
|
|
2585
|
+
}
|
|
2586
|
+
function omitSensitive(key, value) {
|
|
2587
|
+
return key.length > 0 && isSensitiveName(key) ? REDACTED2 : value;
|
|
2588
|
+
}
|
|
2589
|
+
function describeThrownValue(value) {
|
|
2590
|
+
if (typeof value !== "object" || value === null) {
|
|
2591
|
+
return String(value);
|
|
2592
|
+
}
|
|
2593
|
+
let message;
|
|
2594
|
+
try {
|
|
2595
|
+
message = value.message;
|
|
2596
|
+
} catch {
|
|
2597
|
+
message = undefined;
|
|
2598
|
+
}
|
|
2599
|
+
if (typeof message === "string" && message.length > 0) {
|
|
2600
|
+
return cap(message);
|
|
2601
|
+
}
|
|
2602
|
+
try {
|
|
2603
|
+
const json = JSON.stringify(value, omitSensitive);
|
|
2604
|
+
if (json !== undefined) {
|
|
2605
|
+
return cap(json);
|
|
2606
|
+
}
|
|
2607
|
+
} catch {}
|
|
2608
|
+
return String(value);
|
|
2609
|
+
}
|
|
2610
|
+
function toError(error) {
|
|
2611
|
+
return error instanceof Error ? error : new Error(describeThrownValue(error), { cause: error });
|
|
2612
|
+
}
|
|
2113
2613
|
function isPromiseLike(value) {
|
|
2114
2614
|
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
2115
2615
|
}
|
|
2116
|
-
function
|
|
2616
|
+
function catchError(fnOrPromise) {
|
|
2117
2617
|
if (isPromiseLike(fnOrPromise)) {
|
|
2118
2618
|
return settlePromiseLike(fnOrPromise);
|
|
2119
2619
|
}
|
|
@@ -2124,17 +2624,11 @@ function catchError2(fnOrPromise) {
|
|
|
2124
2624
|
}
|
|
2125
2625
|
return [undefined, result];
|
|
2126
2626
|
} catch (error) {
|
|
2127
|
-
return [
|
|
2128
|
-
error instanceof Error ? error : new Error(String(error)),
|
|
2129
|
-
undefined
|
|
2130
|
-
];
|
|
2627
|
+
return [toError(error), undefined];
|
|
2131
2628
|
}
|
|
2132
2629
|
}
|
|
2133
2630
|
function settlePromiseLike(thenable) {
|
|
2134
|
-
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
|
|
2135
|
-
error instanceof Error ? error : new Error(String(error)),
|
|
2136
|
-
undefined
|
|
2137
|
-
]);
|
|
2631
|
+
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
|
|
2138
2632
|
}
|
|
2139
2633
|
|
|
2140
2634
|
// ../common/src/error-handler.ts
|
|
@@ -2333,10 +2827,10 @@ async function extractErrorDetails(error, options) {
|
|
|
2333
2827
|
let parsedBody;
|
|
2334
2828
|
const textFn = response?.text?.bind(response);
|
|
2335
2829
|
if (textFn) {
|
|
2336
|
-
const [bodyError, body] = await
|
|
2830
|
+
const [bodyError, body] = await catchError((async () => textFn())());
|
|
2337
2831
|
if (!bodyError && body) {
|
|
2338
2832
|
rawBody = body;
|
|
2339
|
-
const [parseError, parsed] =
|
|
2833
|
+
const [parseError, parsed] = catchError(() => JSON.parse(body));
|
|
2340
2834
|
if (!parseError && parsed && typeof parsed === "object") {
|
|
2341
2835
|
parsedBody = parsed;
|
|
2342
2836
|
if (parsedBody.errors && typeof parsedBody.errors === "object") {
|
|
@@ -2439,7 +2933,7 @@ async function extractErrorDetails(error, options) {
|
|
|
2439
2933
|
} else if (typeof err.message === "string") {
|
|
2440
2934
|
details = err.message;
|
|
2441
2935
|
} else {
|
|
2442
|
-
details =
|
|
2936
|
+
details = describeThrownValue(error);
|
|
2443
2937
|
}
|
|
2444
2938
|
const context = {};
|
|
2445
2939
|
if (status) {
|
|
@@ -2527,67 +3021,256 @@ function extractErrorMessageSync(error) {
|
|
|
2527
3021
|
return error.message;
|
|
2528
3022
|
}
|
|
2529
3023
|
}
|
|
2530
|
-
return
|
|
3024
|
+
return describeThrownValue(error);
|
|
2531
3025
|
}
|
|
2532
3026
|
|
|
2533
|
-
//
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
createCommand,
|
|
2538
|
-
createArgument,
|
|
2539
|
-
createOption,
|
|
2540
|
-
CommanderError,
|
|
2541
|
-
InvalidArgumentError,
|
|
2542
|
-
InvalidOptionArgumentError,
|
|
2543
|
-
Command,
|
|
2544
|
-
Argument,
|
|
2545
|
-
Option,
|
|
2546
|
-
Help
|
|
2547
|
-
} = import__.default;
|
|
3027
|
+
// ../common/src/exit-code.ts
|
|
3028
|
+
function setExitCode(code) {
|
|
3029
|
+
process.exitCode = code;
|
|
3030
|
+
}
|
|
2548
3031
|
|
|
2549
|
-
// ../
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
3032
|
+
// ../filesystem/src/node.ts
|
|
3033
|
+
import { randomUUID } from "node:crypto";
|
|
3034
|
+
import { existsSync } from "node:fs";
|
|
3035
|
+
import * as fs from "node:fs/promises";
|
|
3036
|
+
import * as os from "node:os";
|
|
3037
|
+
import * as path from "node:path";
|
|
3038
|
+
var LOCK_HEARTBEAT_MS = 5000;
|
|
3039
|
+
var LOCK_STALE_MS = 15000;
|
|
3040
|
+
var LOCK_MAX_WAIT_MS = 20000;
|
|
3041
|
+
var LOCK_MAX_HOLD_MS = 60000;
|
|
3042
|
+
var LOCK_RETRY_MIN_MS = 100;
|
|
3043
|
+
var LOCK_RETRY_JITTER_MS = 200;
|
|
3044
|
+
|
|
3045
|
+
class NodeFileSystem {
|
|
3046
|
+
path = {
|
|
3047
|
+
join: path.join,
|
|
3048
|
+
resolve: path.resolve,
|
|
3049
|
+
relative: path.relative,
|
|
3050
|
+
dirname: path.dirname,
|
|
3051
|
+
isAbsolute: path.isAbsolute,
|
|
3052
|
+
basename: path.basename
|
|
3053
|
+
};
|
|
3054
|
+
env = {
|
|
3055
|
+
cwd: process.cwd,
|
|
3056
|
+
homedir: os.homedir,
|
|
3057
|
+
tmpdir: os.tmpdir,
|
|
3058
|
+
getenv: (key) => process.env[key]
|
|
3059
|
+
};
|
|
3060
|
+
utils = {
|
|
3061
|
+
open: async (url) => {
|
|
3062
|
+
const { default: open } = await import("./index-sby22td6.js");
|
|
3063
|
+
await open(url);
|
|
2575
3064
|
}
|
|
2576
3065
|
};
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
return;
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
3066
|
+
async readFile(path2, options) {
|
|
3067
|
+
try {
|
|
3068
|
+
if (options) {
|
|
3069
|
+
return await fs.readFile(path2, "utf-8");
|
|
3070
|
+
}
|
|
3071
|
+
return await fs.readFile(path2);
|
|
3072
|
+
} catch (error) {
|
|
3073
|
+
if (this.isEnoent(error))
|
|
3074
|
+
return null;
|
|
3075
|
+
throw error;
|
|
3076
|
+
}
|
|
3077
|
+
}
|
|
3078
|
+
async writeFile(filePath, data) {
|
|
3079
|
+
const dir = path.dirname(filePath);
|
|
3080
|
+
if (dir) {
|
|
3081
|
+
await fs.mkdir(dir, { recursive: true });
|
|
3082
|
+
}
|
|
3083
|
+
await fs.writeFile(filePath, data);
|
|
3084
|
+
}
|
|
3085
|
+
async appendFile(filePath, data) {
|
|
3086
|
+
const dir = path.dirname(filePath);
|
|
3087
|
+
if (dir) {
|
|
3088
|
+
await fs.mkdir(dir, { recursive: true });
|
|
3089
|
+
}
|
|
3090
|
+
await fs.appendFile(filePath, data);
|
|
3091
|
+
}
|
|
3092
|
+
async readdir(dirPath) {
|
|
3093
|
+
try {
|
|
3094
|
+
return await fs.readdir(dirPath);
|
|
3095
|
+
} catch (error) {
|
|
3096
|
+
if (this.isEnoent(error))
|
|
3097
|
+
return [];
|
|
3098
|
+
throw error;
|
|
3099
|
+
}
|
|
3100
|
+
}
|
|
3101
|
+
async stat(filePath) {
|
|
3102
|
+
try {
|
|
3103
|
+
const stats = await fs.stat(filePath);
|
|
3104
|
+
return {
|
|
3105
|
+
isFile: () => stats.isFile(),
|
|
3106
|
+
isDirectory: () => stats.isDirectory(),
|
|
3107
|
+
size: stats.size,
|
|
3108
|
+
mtimeMs: stats.mtimeMs
|
|
3109
|
+
};
|
|
3110
|
+
} catch (error) {
|
|
3111
|
+
if (this.isEnoent(error))
|
|
3112
|
+
return null;
|
|
3113
|
+
throw error;
|
|
3114
|
+
}
|
|
3115
|
+
}
|
|
3116
|
+
async exists(filePath) {
|
|
3117
|
+
return existsSync(filePath);
|
|
3118
|
+
}
|
|
3119
|
+
async mkdir(dirPath) {
|
|
3120
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
3121
|
+
}
|
|
3122
|
+
async acquireLock(lockPath) {
|
|
3123
|
+
const canonicalPath = await this.canonicalizeLockTarget(lockPath);
|
|
3124
|
+
const lockFile = `${canonicalPath}.lock`;
|
|
3125
|
+
const ownerId = randomUUID();
|
|
3126
|
+
const start = Date.now();
|
|
3127
|
+
while (true) {
|
|
3128
|
+
try {
|
|
3129
|
+
await fs.writeFile(lockFile, ownerId, { flag: "wx" });
|
|
3130
|
+
return this.createLockRelease(lockFile, ownerId);
|
|
3131
|
+
} catch (error) {
|
|
3132
|
+
if (!this.hasErrnoCode(error, "EEXIST")) {
|
|
3133
|
+
throw error;
|
|
3134
|
+
}
|
|
3135
|
+
const stats = await fs.stat(lockFile).catch(() => null);
|
|
3136
|
+
if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
|
|
3137
|
+
const reclaimed = await fs.rm(lockFile, { force: true }).then(() => true).catch(() => false);
|
|
3138
|
+
if (reclaimed)
|
|
3139
|
+
continue;
|
|
3140
|
+
}
|
|
3141
|
+
if (Date.now() - start > LOCK_MAX_WAIT_MS) {
|
|
3142
|
+
throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
|
|
3143
|
+
}
|
|
3144
|
+
await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
|
|
3145
|
+
}
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
3148
|
+
async canonicalizeLockTarget(lockPath) {
|
|
3149
|
+
const absolute = path.resolve(lockPath);
|
|
3150
|
+
const fullReal = await fs.realpath(absolute).catch(() => null);
|
|
3151
|
+
if (fullReal)
|
|
3152
|
+
return fullReal;
|
|
3153
|
+
const parent = path.dirname(absolute);
|
|
3154
|
+
const base = path.basename(absolute);
|
|
3155
|
+
const canonicalParent = await fs.realpath(parent).catch(() => parent);
|
|
3156
|
+
return path.join(canonicalParent, base);
|
|
3157
|
+
}
|
|
3158
|
+
createLockRelease(lockFile, ownerId) {
|
|
3159
|
+
const heartbeatStart = Date.now();
|
|
3160
|
+
let heartbeatTimer;
|
|
3161
|
+
let stopped = false;
|
|
3162
|
+
const stopHeartbeat = () => {
|
|
3163
|
+
stopped = true;
|
|
3164
|
+
if (heartbeatTimer)
|
|
3165
|
+
clearTimeout(heartbeatTimer);
|
|
3166
|
+
};
|
|
3167
|
+
const scheduleNextHeartbeat = () => {
|
|
3168
|
+
if (stopped)
|
|
3169
|
+
return;
|
|
3170
|
+
if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) {
|
|
3171
|
+
stopped = true;
|
|
3172
|
+
return;
|
|
3173
|
+
}
|
|
3174
|
+
heartbeatTimer = setTimeout(() => {
|
|
3175
|
+
runHeartbeat();
|
|
3176
|
+
}, LOCK_HEARTBEAT_MS);
|
|
3177
|
+
heartbeatTimer.unref?.();
|
|
3178
|
+
};
|
|
3179
|
+
const runHeartbeat = async () => {
|
|
3180
|
+
if (stopped)
|
|
3181
|
+
return;
|
|
3182
|
+
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
3183
|
+
if (stopped)
|
|
3184
|
+
return;
|
|
3185
|
+
if (current !== ownerId) {
|
|
3186
|
+
stopped = true;
|
|
3187
|
+
return;
|
|
3188
|
+
}
|
|
3189
|
+
const now = Date.now() / 1000;
|
|
3190
|
+
await fs.utimes(lockFile, now, now).catch(() => {});
|
|
3191
|
+
scheduleNextHeartbeat();
|
|
3192
|
+
};
|
|
3193
|
+
scheduleNextHeartbeat();
|
|
3194
|
+
let released = false;
|
|
3195
|
+
return async () => {
|
|
3196
|
+
if (released)
|
|
3197
|
+
return;
|
|
3198
|
+
released = true;
|
|
3199
|
+
stopHeartbeat();
|
|
3200
|
+
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
3201
|
+
if (current === ownerId) {
|
|
3202
|
+
await fs.rm(lockFile, { force: true });
|
|
3203
|
+
}
|
|
3204
|
+
};
|
|
3205
|
+
}
|
|
3206
|
+
async rm(filePath) {
|
|
3207
|
+
await fs.rm(filePath, { recursive: true, force: true });
|
|
3208
|
+
}
|
|
3209
|
+
async rename(oldPath, newPath) {
|
|
3210
|
+
await fs.rename(oldPath, newPath);
|
|
3211
|
+
}
|
|
3212
|
+
async realpath(filePath) {
|
|
3213
|
+
try {
|
|
3214
|
+
return await fs.realpath(filePath);
|
|
3215
|
+
} catch (error) {
|
|
3216
|
+
if (this.isEnoent(error))
|
|
3217
|
+
return filePath;
|
|
3218
|
+
throw error;
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
async getTempDir() {
|
|
3222
|
+
return await fs.mkdtemp(path.join(os.tmpdir(), "uipath-fs-"));
|
|
3223
|
+
}
|
|
3224
|
+
async copyDirectory(sourcePath, destPath) {
|
|
3225
|
+
const sourceStats = await this.stat(sourcePath);
|
|
3226
|
+
if (!sourceStats) {
|
|
3227
|
+
throw new Error(`Source directory does not exist: ${sourcePath}`);
|
|
3228
|
+
}
|
|
3229
|
+
if (!sourceStats.isDirectory()) {
|
|
3230
|
+
throw new Error(`Source path is not a directory: ${sourcePath}`);
|
|
3231
|
+
}
|
|
3232
|
+
await this.mkdir(destPath);
|
|
3233
|
+
const entries = await this.readdir(sourcePath);
|
|
3234
|
+
for (const entry of entries) {
|
|
3235
|
+
const srcEntry = path.join(sourcePath, entry);
|
|
3236
|
+
const destEntry = path.join(destPath, entry);
|
|
3237
|
+
const entryStats = await this.stat(srcEntry);
|
|
3238
|
+
if (!entryStats)
|
|
3239
|
+
continue;
|
|
3240
|
+
if (entryStats.isDirectory()) {
|
|
3241
|
+
await this.copyDirectory(srcEntry, destEntry);
|
|
3242
|
+
} else if (entryStats.isFile()) {
|
|
3243
|
+
const content = await this.readFile(srcEntry);
|
|
3244
|
+
if (content !== null) {
|
|
3245
|
+
await this.writeFile(destEntry, content);
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
}
|
|
3250
|
+
isEnoent(error) {
|
|
3251
|
+
return this.hasErrnoCode(error, "ENOENT");
|
|
3252
|
+
}
|
|
3253
|
+
hasErrnoCode(error, code) {
|
|
3254
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
|
|
3258
|
+
// ../filesystem/src/index.ts
|
|
3259
|
+
var fsInstance = new NodeFileSystem;
|
|
3260
|
+
var getFileSystem = () => fsInstance;
|
|
3261
|
+
|
|
3262
|
+
// ../common/src/output-context.ts
|
|
3263
|
+
function createStorage() {
|
|
3264
|
+
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
3265
|
+
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
3266
|
+
return {
|
|
3267
|
+
getStore: () => {
|
|
3268
|
+
return;
|
|
3269
|
+
},
|
|
3270
|
+
run: (_store, fn) => fn()
|
|
3271
|
+
};
|
|
3272
|
+
}
|
|
3273
|
+
return new mod.AsyncLocalStorage;
|
|
2591
3274
|
}
|
|
2592
3275
|
var storageSingleton = singleton("OutputStorage");
|
|
2593
3276
|
var sinkSlot = singleton("OutputSink");
|
|
@@ -2609,8 +3292,8 @@ function getOutputSink() {
|
|
|
2609
3292
|
|
|
2610
3293
|
// ../common/src/logger.ts
|
|
2611
3294
|
var logFilePathSlot = singleton("logFilePath");
|
|
2612
|
-
function setGlobalLogFilePath(
|
|
2613
|
-
logFilePathSlot.set(
|
|
3295
|
+
function setGlobalLogFilePath(path2) {
|
|
3296
|
+
logFilePathSlot.set(path2);
|
|
2614
3297
|
}
|
|
2615
3298
|
function getGlobalLogFilePath() {
|
|
2616
3299
|
return logFilePathSlot.get("");
|
|
@@ -2647,7 +3330,7 @@ class SimpleLogger {
|
|
|
2647
3330
|
}
|
|
2648
3331
|
return DEFAULT_LOG_LEVEL;
|
|
2649
3332
|
}
|
|
2650
|
-
const [localStorageError, hasDebug] =
|
|
3333
|
+
const [localStorageError, hasDebug] = catchError(() => typeof localStorage !== "undefined" && !!localStorage.getItem("debug"));
|
|
2651
3334
|
if (!localStorageError && hasDebug) {
|
|
2652
3335
|
return 0 /* DEBUG */;
|
|
2653
3336
|
}
|
|
@@ -2678,54 +3361,49 @@ class SimpleLogger {
|
|
|
2678
3361
|
return this.fileLoggingEnabled || !!getGlobalLogFilePath();
|
|
2679
3362
|
}
|
|
2680
3363
|
writeToFile(formatted) {
|
|
2681
|
-
const
|
|
2682
|
-
if (!
|
|
3364
|
+
const path2 = this.logFilePath || getGlobalLogFilePath();
|
|
3365
|
+
if (!path2)
|
|
2683
3366
|
return;
|
|
2684
3367
|
const timestamp = new Date().toISOString();
|
|
2685
3368
|
this.pendingWrites = Promise.all([
|
|
2686
3369
|
this.pendingWrites,
|
|
2687
3370
|
this.pendingInit
|
|
2688
|
-
]).then(() => getFileSystem().appendFile(
|
|
3371
|
+
]).then(() => getFileSystem().appendFile(path2, `${timestamp} ${formatted}`).catch(() => {}));
|
|
2689
3372
|
}
|
|
2690
|
-
|
|
2691
|
-
if (this.level > 0 /* DEBUG */)
|
|
2692
|
-
return;
|
|
2693
|
-
const formatted = this.format(`[DEBUG] ${message}`, args);
|
|
3373
|
+
write(formatted) {
|
|
2694
3374
|
if (this.isFileLoggingActive()) {
|
|
2695
3375
|
this.writeToFile(formatted);
|
|
2696
3376
|
} else {
|
|
2697
3377
|
getOutputSink().writeErr(formatted);
|
|
2698
3378
|
}
|
|
2699
3379
|
}
|
|
3380
|
+
debug(message, ...args) {
|
|
3381
|
+
if (this.level > 0 /* DEBUG */)
|
|
3382
|
+
return;
|
|
3383
|
+
const formatted = this.format(`[DEBUG] ${message}`, args);
|
|
3384
|
+
this.write(formatted);
|
|
3385
|
+
}
|
|
2700
3386
|
info(message, ...args) {
|
|
2701
3387
|
if (this.level > 1 /* INFO */)
|
|
2702
3388
|
return;
|
|
2703
3389
|
const formatted = this.format(message, args);
|
|
2704
|
-
|
|
2705
|
-
this.writeToFile(formatted);
|
|
2706
|
-
} else {
|
|
2707
|
-
getOutputSink().writeErr(formatted);
|
|
2708
|
-
}
|
|
3390
|
+
this.write(formatted);
|
|
2709
3391
|
}
|
|
2710
3392
|
warn(message, ...args) {
|
|
2711
3393
|
if (this.level > 2 /* WARN */)
|
|
2712
3394
|
return;
|
|
2713
3395
|
const formatted = this.format(`[WARN] ${message}`, args);
|
|
2714
|
-
|
|
2715
|
-
this.writeToFile(formatted);
|
|
2716
|
-
} else {
|
|
2717
|
-
getOutputSink().writeErr(formatted);
|
|
2718
|
-
}
|
|
3396
|
+
this.write(formatted);
|
|
2719
3397
|
}
|
|
2720
3398
|
error(message, ...args) {
|
|
2721
3399
|
if (this.level > 3 /* ERROR */)
|
|
2722
3400
|
return;
|
|
2723
3401
|
const formatted = this.format(`[ERROR] ${message}`, args);
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
3402
|
+
this.write(formatted);
|
|
3403
|
+
}
|
|
3404
|
+
report(message) {
|
|
3405
|
+
const formatted = this.format(message, []);
|
|
3406
|
+
this.write(formatted);
|
|
2729
3407
|
}
|
|
2730
3408
|
getLevel() {
|
|
2731
3409
|
return this.level;
|
|
@@ -2740,17 +3418,17 @@ class SimpleLogger {
|
|
|
2740
3418
|
setGlobalLogFilePath("");
|
|
2741
3419
|
}
|
|
2742
3420
|
}
|
|
2743
|
-
setLogFile(
|
|
2744
|
-
this.logFilePath =
|
|
2745
|
-
setGlobalLogFilePath(
|
|
2746
|
-
if (!
|
|
3421
|
+
setLogFile(path2) {
|
|
3422
|
+
this.logFilePath = path2;
|
|
3423
|
+
setGlobalLogFilePath(path2);
|
|
3424
|
+
if (!path2)
|
|
2747
3425
|
return;
|
|
2748
3426
|
this.fileLoggingEnabled = true;
|
|
2749
|
-
const
|
|
3427
|
+
const fs2 = getFileSystem();
|
|
2750
3428
|
this.pendingInit = (async () => {
|
|
2751
|
-
const [error] = await
|
|
2752
|
-
await
|
|
2753
|
-
await
|
|
3429
|
+
const [error] = await catchError((async () => {
|
|
3430
|
+
await fs2.mkdir(fs2.path.dirname(path2));
|
|
3431
|
+
await fs2.writeFile(path2, "");
|
|
2754
3432
|
})());
|
|
2755
3433
|
if (error)
|
|
2756
3434
|
this.fileLoggingEnabled = false;
|
|
@@ -2804,12 +3482,12 @@ var jmespathSlot = singleton("JmespathCodec");
|
|
|
2804
3482
|
async function loadOutputCodecsAsync(needed) {
|
|
2805
3483
|
const loads = [];
|
|
2806
3484
|
if (needed.yaml && yamlSlot.get() === undefined) {
|
|
2807
|
-
loads.push(import("./js-yaml-
|
|
3485
|
+
loads.push(import("./js-yaml-88tdqrtd.js").then((mod) => {
|
|
2808
3486
|
yamlSlot.set(mod);
|
|
2809
3487
|
}));
|
|
2810
3488
|
}
|
|
2811
3489
|
if (needed.filter && jmespathSlot.get() === undefined) {
|
|
2812
|
-
loads.push(import("./index-
|
|
3490
|
+
loads.push(import("./index-gpd94m28.js").then((mod) => {
|
|
2813
3491
|
jmespathSlot.set(mod);
|
|
2814
3492
|
}));
|
|
2815
3493
|
}
|
|
@@ -3064,7 +3742,7 @@ function readRegistryValue(keyPath, valueName) {
|
|
|
3064
3742
|
if (process.platform !== "win32") {
|
|
3065
3743
|
return "";
|
|
3066
3744
|
}
|
|
3067
|
-
const [error, output] =
|
|
3745
|
+
const [error, output] = catchError(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
|
|
3068
3746
|
encoding: "utf-8",
|
|
3069
3747
|
stdio: ["pipe", "pipe", "pipe"]
|
|
3070
3748
|
}));
|
|
@@ -3087,27 +3765,41 @@ class LoggerTelemetryProvider {
|
|
|
3087
3765
|
...this.analyticsUniqueId ? { analyticsUniqueId: this.analyticsUniqueId } : {}
|
|
3088
3766
|
};
|
|
3089
3767
|
}
|
|
3090
|
-
async trackEvent(
|
|
3091
|
-
logger.debug(formatMessage("Event",
|
|
3768
|
+
async trackEvent({ name, properties }) {
|
|
3769
|
+
logger.debug(formatMessage("Event", name, this.enrich(properties)));
|
|
3092
3770
|
}
|
|
3093
|
-
async trackException(
|
|
3771
|
+
async trackException({
|
|
3772
|
+
error,
|
|
3773
|
+
properties
|
|
3774
|
+
}) {
|
|
3094
3775
|
logger.error(formatMessage("Exception", error.message, this.enrich({
|
|
3095
3776
|
...properties,
|
|
3096
3777
|
stack: error.stack
|
|
3097
3778
|
})));
|
|
3098
3779
|
}
|
|
3099
|
-
async trackRequest(
|
|
3780
|
+
async trackRequest({
|
|
3781
|
+
name,
|
|
3782
|
+
durationMs,
|
|
3783
|
+
success,
|
|
3784
|
+
properties
|
|
3785
|
+
}) {
|
|
3100
3786
|
logger.debug(formatMessage("Request", name, this.enrich({
|
|
3101
3787
|
...properties,
|
|
3102
|
-
duration: `${
|
|
3788
|
+
duration: `${durationMs}ms`,
|
|
3103
3789
|
success
|
|
3104
3790
|
})));
|
|
3105
3791
|
}
|
|
3106
|
-
async trackDependency(
|
|
3792
|
+
async trackDependency({
|
|
3793
|
+
name,
|
|
3794
|
+
type,
|
|
3795
|
+
durationMs,
|
|
3796
|
+
success,
|
|
3797
|
+
properties
|
|
3798
|
+
}) {
|
|
3107
3799
|
logger.debug(formatMessage("Dependency", name, this.enrich({
|
|
3108
3800
|
...properties,
|
|
3109
3801
|
type,
|
|
3110
|
-
duration: `${
|
|
3802
|
+
duration: `${durationMs}ms`,
|
|
3111
3803
|
success
|
|
3112
3804
|
})));
|
|
3113
3805
|
}
|
|
@@ -3363,144 +4055,16 @@ function getGlobalTelemetryProperties() {
|
|
|
3363
4055
|
return telemetryPropsSlot.get();
|
|
3364
4056
|
}
|
|
3365
4057
|
|
|
3366
|
-
// ../common/src/telemetry/
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
"secrets",
|
|
3374
|
-
"password",
|
|
3375
|
-
"passwords",
|
|
3376
|
-
"pwd",
|
|
3377
|
-
"credential",
|
|
3378
|
-
"credentials",
|
|
3379
|
-
"auth",
|
|
3380
|
-
"authentication",
|
|
3381
|
-
"authorization",
|
|
3382
|
-
"authority",
|
|
3383
|
-
"cert",
|
|
3384
|
-
"certificate",
|
|
3385
|
-
"certificates"
|
|
3386
|
-
]);
|
|
3387
|
-
var SENSITIVE_KEY_PREFIXES = new Set([
|
|
3388
|
-
"api",
|
|
3389
|
-
"access",
|
|
3390
|
-
"client",
|
|
3391
|
-
"private",
|
|
3392
|
-
"public",
|
|
3393
|
-
"signing",
|
|
3394
|
-
"encryption",
|
|
3395
|
-
"session",
|
|
3396
|
-
"master",
|
|
3397
|
-
"shared",
|
|
3398
|
-
"root",
|
|
3399
|
-
"ssh",
|
|
3400
|
-
"rsa",
|
|
3401
|
-
"aes",
|
|
3402
|
-
"hmac",
|
|
3403
|
-
"oauth"
|
|
3404
|
-
]);
|
|
3405
|
-
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;
|
|
3406
|
-
var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
3407
|
-
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
3408
|
-
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
3409
|
-
var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
|
|
3410
|
-
var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
|
|
3411
|
-
var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
|
|
3412
|
-
function shortHash(input) {
|
|
3413
|
-
let hash = 2166136261;
|
|
3414
|
-
for (let i = 0;i < input.length; i++) {
|
|
3415
|
-
hash ^= input.charCodeAt(i);
|
|
3416
|
-
hash = Math.imul(hash, 16777619);
|
|
3417
|
-
}
|
|
3418
|
-
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
3419
|
-
}
|
|
3420
|
-
function redactUrl(raw) {
|
|
3421
|
-
try {
|
|
3422
|
-
const url = new URL(raw);
|
|
3423
|
-
return `${url.protocol}//${url.host}`;
|
|
3424
|
-
} catch {
|
|
3425
|
-
return `url#${shortHash(raw)}`;
|
|
3426
|
-
}
|
|
3427
|
-
}
|
|
3428
|
-
function redactValueDetectors(value) {
|
|
3429
|
-
let out = value;
|
|
3430
|
-
out = out.replace(JWT_PATTERN, () => REDACTED);
|
|
3431
|
-
out = out.replace(URL_PATTERN, (match) => {
|
|
3432
|
-
const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
|
|
3433
|
-
const core = trailing ? match.slice(0, -trailing.length) : match;
|
|
3434
|
-
return `${redactUrl(core)}${trailing}`;
|
|
3435
|
-
});
|
|
3436
|
-
out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
|
|
3437
|
-
out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
|
|
3438
|
-
out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
|
|
3439
|
-
out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
|
|
3440
|
-
if (out.length > MAX_VALUE_LENGTH) {
|
|
3441
|
-
out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
|
|
3442
|
-
}
|
|
3443
|
-
return out;
|
|
3444
|
-
}
|
|
3445
|
-
function redactValue(value) {
|
|
3446
|
-
return redactValueDetectors(value);
|
|
3447
|
-
}
|
|
3448
|
-
function redactError(error) {
|
|
3449
|
-
const safe = new Error(redactValueDetectors(error.message ?? ""));
|
|
3450
|
-
safe.name = error.name;
|
|
3451
|
-
safe.stack = typeof error.stack === "string" ? redactValueDetectors(error.stack) : undefined;
|
|
3452
|
-
return safe;
|
|
3453
|
-
}
|
|
3454
|
-
function nameTokens(name) {
|
|
3455
|
-
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);
|
|
3456
|
-
}
|
|
3457
|
-
function isSensitiveName(name) {
|
|
3458
|
-
const tokens = nameTokens(name);
|
|
3459
|
-
for (let i = 0;i < tokens.length; i++) {
|
|
3460
|
-
const token = tokens[i];
|
|
3461
|
-
if (SENSITIVE_NAME_TOKENS.has(token)) {
|
|
3462
|
-
return true;
|
|
3463
|
-
}
|
|
3464
|
-
if (token === "key" || token === "keys") {
|
|
3465
|
-
const prev = tokens[i - 1];
|
|
3466
|
-
if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
|
|
3467
|
-
return true;
|
|
3468
|
-
}
|
|
3469
|
-
}
|
|
3470
|
-
}
|
|
3471
|
-
return false;
|
|
3472
|
-
}
|
|
3473
|
-
function redactProperty(name, value) {
|
|
3474
|
-
if (value === undefined || value === null) {
|
|
3475
|
-
return;
|
|
3476
|
-
}
|
|
3477
|
-
if (isSensitiveName(name)) {
|
|
3478
|
-
return REDACTED;
|
|
3479
|
-
}
|
|
3480
|
-
if (typeof value === "boolean" || typeof value === "number") {
|
|
3481
|
-
return value;
|
|
3482
|
-
}
|
|
3483
|
-
if (typeof value !== "string") {
|
|
3484
|
-
return "[OBJECT]";
|
|
3485
|
-
}
|
|
3486
|
-
return redactValueDetectors(value);
|
|
3487
|
-
}
|
|
3488
|
-
function redactProperties(properties) {
|
|
3489
|
-
const out = {};
|
|
3490
|
-
for (const [name, value] of Object.entries(properties)) {
|
|
3491
|
-
const redacted = redactProperty(name, value);
|
|
3492
|
-
if (redacted !== undefined) {
|
|
3493
|
-
out[name] = redacted;
|
|
3494
|
-
}
|
|
3495
|
-
}
|
|
3496
|
-
return out;
|
|
4058
|
+
// ../common/src/telemetry/span-clock.ts
|
|
4059
|
+
function startSpanClock() {
|
|
4060
|
+
const started = performance.now();
|
|
4061
|
+
return {
|
|
4062
|
+
startedAt: new Date(performance.timeOrigin + started),
|
|
4063
|
+
elapsedMs: () => performance.now() - started
|
|
4064
|
+
};
|
|
3497
4065
|
}
|
|
3498
4066
|
|
|
3499
4067
|
// ../common/src/telemetry/telemetry-service.ts
|
|
3500
|
-
var TELEMETRY_OPERATION_ID_PROPERTY = "uip.trace.operation_id";
|
|
3501
|
-
var TELEMETRY_PARENT_ID_PROPERTY = "uip.trace.parent_id";
|
|
3502
|
-
var TELEMETRY_SPAN_ID_PROPERTY = "uip.trace.span_id";
|
|
3503
|
-
|
|
3504
4068
|
class TelemetryService {
|
|
3505
4069
|
telemetryProvider;
|
|
3506
4070
|
contextStorage;
|
|
@@ -3520,36 +4084,39 @@ class TelemetryService {
|
|
|
3520
4084
|
this.defaultProperties = properties === undefined ? undefined : { ...this.defaultProperties, ...properties };
|
|
3521
4085
|
}
|
|
3522
4086
|
trackEvent(name, properties) {
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
4087
|
+
this.telemetryProvider.trackEvent({
|
|
4088
|
+
name: redactSpanName(name),
|
|
4089
|
+
properties: this.enrichProperties(properties),
|
|
4090
|
+
...this.leafCorrelation()
|
|
4091
|
+
});
|
|
3526
4092
|
}
|
|
3527
|
-
trackException(error, properties) {
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
4093
|
+
trackException(error, properties, context) {
|
|
4094
|
+
this.telemetryProvider.trackException({
|
|
4095
|
+
error: redactError(error),
|
|
4096
|
+
properties: this.enrichProperties(properties),
|
|
4097
|
+
...this.leafCorrelation(context)
|
|
4098
|
+
});
|
|
3531
4099
|
}
|
|
3532
4100
|
async trackRequest(name, fn, properties) {
|
|
3533
|
-
const parentContext = this.
|
|
4101
|
+
const parentContext = this.getActiveContext();
|
|
3534
4102
|
const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
|
|
3535
4103
|
const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
|
|
4104
|
+
const clock = startSpanClock();
|
|
3536
4105
|
const context = {
|
|
3537
4106
|
operationId,
|
|
3538
4107
|
...parentId !== undefined ? { parentId } : {},
|
|
3539
|
-
id: this.generateId()
|
|
4108
|
+
id: this.generateId(),
|
|
4109
|
+
startedAt: clock.startedAt
|
|
3540
4110
|
};
|
|
3541
|
-
const startTime = performance.now();
|
|
3542
4111
|
try {
|
|
3543
4112
|
const result = await this.contextStorage.run(context, fn);
|
|
3544
|
-
const durationMs =
|
|
3545
|
-
|
|
3546
|
-
await this.telemetryProvider.trackRequest(name, durationMs, true, enrichedProperties);
|
|
4113
|
+
const durationMs = clock.elapsedMs();
|
|
4114
|
+
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, true, properties, context));
|
|
3547
4115
|
return result;
|
|
3548
4116
|
} catch (error) {
|
|
3549
|
-
const durationMs =
|
|
4117
|
+
const durationMs = clock.elapsedMs();
|
|
3550
4118
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
3551
|
-
|
|
3552
|
-
await this.telemetryProvider.trackRequest(name, durationMs, false, enrichedProperties);
|
|
4119
|
+
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, context));
|
|
3553
4120
|
throw error;
|
|
3554
4121
|
}
|
|
3555
4122
|
}
|
|
@@ -3558,8 +4125,7 @@ class TelemetryService {
|
|
|
3558
4125
|
operationId: this.operationId ?? getTelemetryOperationId(),
|
|
3559
4126
|
id: this.generateId()
|
|
3560
4127
|
};
|
|
3561
|
-
|
|
3562
|
-
this.telemetryProvider.trackRequest(name, durationMs, success, enrichedProperties);
|
|
4128
|
+
this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, success, properties, requestContext));
|
|
3563
4129
|
}
|
|
3564
4130
|
createRequestContext() {
|
|
3565
4131
|
const operationId = this.operationId ?? getTelemetryOperationId();
|
|
@@ -3567,7 +4133,8 @@ class TelemetryService {
|
|
|
3567
4133
|
return {
|
|
3568
4134
|
operationId,
|
|
3569
4135
|
...parentId !== undefined ? { parentId } : {},
|
|
3570
|
-
id: this.generateId()
|
|
4136
|
+
id: this.generateId(),
|
|
4137
|
+
startedAt: startSpanClock().startedAt
|
|
3571
4138
|
};
|
|
3572
4139
|
}
|
|
3573
4140
|
inboundParentIdFor(operationId) {
|
|
@@ -3578,58 +4145,84 @@ class TelemetryService {
|
|
|
3578
4145
|
return this.contextStorage.run(context, fn);
|
|
3579
4146
|
}
|
|
3580
4147
|
createDependencyContext() {
|
|
3581
|
-
const parentContext = this.
|
|
4148
|
+
const parentContext = this.getActiveContext();
|
|
3582
4149
|
if (!parentContext) {
|
|
3583
4150
|
return;
|
|
3584
4151
|
}
|
|
3585
4152
|
return {
|
|
3586
4153
|
operationId: parentContext.operationId,
|
|
3587
4154
|
parentId: parentContext.id,
|
|
3588
|
-
id: this.generateId()
|
|
4155
|
+
id: this.generateId(),
|
|
4156
|
+
startedAt: startSpanClock().startedAt
|
|
3589
4157
|
};
|
|
3590
4158
|
}
|
|
3591
4159
|
trackDependencyResult(name, type, durationMs, success, properties, context, resultCode) {
|
|
3592
|
-
|
|
3593
|
-
|
|
4160
|
+
this.telemetryProvider.trackDependency({
|
|
4161
|
+
...this.spanFor(redactHttpDependencyName(name), durationMs, success, properties, context),
|
|
4162
|
+
type,
|
|
4163
|
+
...resultCode !== undefined ? { resultCode } : {}
|
|
4164
|
+
});
|
|
3594
4165
|
}
|
|
3595
4166
|
async trackDependencyOperation(name, type, fn, properties) {
|
|
3596
|
-
const
|
|
4167
|
+
const clock = startSpanClock();
|
|
4168
|
+
const parentContext = this.getActiveContext();
|
|
3597
4169
|
const childContext = parentContext !== undefined ? {
|
|
3598
4170
|
operationId: parentContext.operationId,
|
|
3599
4171
|
parentId: parentContext.id,
|
|
3600
|
-
id: this.generateId()
|
|
3601
|
-
|
|
3602
|
-
|
|
4172
|
+
id: this.generateId(),
|
|
4173
|
+
startedAt: clock.startedAt
|
|
4174
|
+
} : {
|
|
4175
|
+
...this.createRequestContext(),
|
|
4176
|
+
startedAt: clock.startedAt
|
|
4177
|
+
};
|
|
3603
4178
|
try {
|
|
3604
4179
|
const result = await this.contextStorage.run(childContext, fn);
|
|
3605
|
-
const durationMs =
|
|
3606
|
-
|
|
3607
|
-
|
|
4180
|
+
const durationMs = clock.elapsedMs();
|
|
4181
|
+
await this.telemetryProvider.trackDependency({
|
|
4182
|
+
...this.spanFor(name, durationMs, true, properties, childContext),
|
|
4183
|
+
type
|
|
4184
|
+
});
|
|
3608
4185
|
return result;
|
|
3609
4186
|
} catch (error) {
|
|
3610
|
-
const durationMs =
|
|
4187
|
+
const durationMs = clock.elapsedMs();
|
|
3611
4188
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
3612
|
-
|
|
3613
|
-
|
|
4189
|
+
await this.telemetryProvider.trackDependency({
|
|
4190
|
+
...this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, childContext),
|
|
4191
|
+
type
|
|
4192
|
+
});
|
|
3614
4193
|
throw error;
|
|
3615
4194
|
}
|
|
3616
4195
|
}
|
|
3617
|
-
|
|
4196
|
+
getActiveContext() {
|
|
3618
4197
|
return this.contextStorage.getContext();
|
|
3619
4198
|
}
|
|
3620
|
-
|
|
4199
|
+
leafCorrelation(explicit) {
|
|
4200
|
+
const context = explicit ?? this.getActiveContext();
|
|
4201
|
+
return {
|
|
4202
|
+
operationId: context?.operationId ?? this.operationId ?? getTelemetryOperationId(),
|
|
4203
|
+
...context !== undefined ? { parentId: context.id } : {}
|
|
4204
|
+
};
|
|
4205
|
+
}
|
|
4206
|
+
spanFor(name, durationMs, success, properties, context) {
|
|
4207
|
+
return {
|
|
4208
|
+
name: redactSpanName(name),
|
|
4209
|
+
durationMs,
|
|
4210
|
+
success,
|
|
4211
|
+
properties: this.enrichProperties(properties),
|
|
4212
|
+
operationId: context.operationId,
|
|
4213
|
+
...context.parentId !== undefined ? { parentId: context.parentId } : {},
|
|
4214
|
+
id: context.id,
|
|
4215
|
+
...context.startedAt !== undefined ? { startedAt: context.startedAt } : {}
|
|
4216
|
+
};
|
|
4217
|
+
}
|
|
4218
|
+
enrichProperties(properties) {
|
|
3621
4219
|
const globalProperties = getGlobalTelemetryProperties();
|
|
3622
4220
|
const enriched = {
|
|
3623
4221
|
...getExecutionContextTelemetryProperties(),
|
|
3624
4222
|
...globalProperties,
|
|
3625
4223
|
...this.defaultProperties,
|
|
3626
4224
|
...redactProperties(properties ?? {}),
|
|
3627
|
-
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
|
|
3628
|
-
...context ? {
|
|
3629
|
-
[TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
|
|
3630
|
-
...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
|
|
3631
|
-
[TELEMETRY_SPAN_ID_PROPERTY]: context.id
|
|
3632
|
-
} : {}
|
|
4225
|
+
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
|
|
3633
4226
|
};
|
|
3634
4227
|
return enriched;
|
|
3635
4228
|
}
|
|
@@ -3646,6 +4239,81 @@ class TelemetryService {
|
|
|
3646
4239
|
return hex;
|
|
3647
4240
|
}
|
|
3648
4241
|
}
|
|
4242
|
+
// ../common/src/timings.ts
|
|
4243
|
+
var TIMINGS_ENV_VAR = "UIP_TIMINGS";
|
|
4244
|
+
function createStorage2() {
|
|
4245
|
+
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
4246
|
+
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
4247
|
+
return {
|
|
4248
|
+
getStore: () => {
|
|
4249
|
+
return;
|
|
4250
|
+
},
|
|
4251
|
+
run: (_store, fn) => fn()
|
|
4252
|
+
};
|
|
4253
|
+
}
|
|
4254
|
+
return new mod.AsyncLocalStorage;
|
|
4255
|
+
}
|
|
4256
|
+
var storageSlot = singleton("TimingStorage");
|
|
4257
|
+
var stateSlot = singleton("Timings");
|
|
4258
|
+
var rootStartedSlot = singleton("TimingsRootStarted");
|
|
4259
|
+
var longLivedHostSlot = singleton("TimingsLongLivedHost");
|
|
4260
|
+
var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
|
|
4261
|
+
function newState(baseline) {
|
|
4262
|
+
return { baseline, httpMs: 0, httpCalls: 0 };
|
|
4263
|
+
}
|
|
4264
|
+
function getState() {
|
|
4265
|
+
const scoped = storage.getStore();
|
|
4266
|
+
if (scoped) {
|
|
4267
|
+
return scoped;
|
|
4268
|
+
}
|
|
4269
|
+
const pinned = livePinnedState();
|
|
4270
|
+
if (pinned !== undefined) {
|
|
4271
|
+
return pinned;
|
|
4272
|
+
}
|
|
4273
|
+
return newState(processStartIsInvocationStart() ? 0 : performance.now());
|
|
4274
|
+
}
|
|
4275
|
+
function livePinnedState() {
|
|
4276
|
+
const pinned = stateSlot.get();
|
|
4277
|
+
return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
|
|
4278
|
+
}
|
|
4279
|
+
function processStartIsInvocationStart() {
|
|
4280
|
+
return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
|
|
4281
|
+
}
|
|
4282
|
+
function timingsEnabled() {
|
|
4283
|
+
if (typeof process === "undefined") {
|
|
4284
|
+
return false;
|
|
4285
|
+
}
|
|
4286
|
+
const value = process.env?.[TIMINGS_ENV_VAR];
|
|
4287
|
+
if (value === undefined) {
|
|
4288
|
+
return false;
|
|
4289
|
+
}
|
|
4290
|
+
const normalized = value.trim().toLowerCase();
|
|
4291
|
+
return normalized === "1" || normalized === "true";
|
|
4292
|
+
}
|
|
4293
|
+
function recordExitCode(exitCode) {
|
|
4294
|
+
if (!timingsEnabled()) {
|
|
4295
|
+
return;
|
|
4296
|
+
}
|
|
4297
|
+
getState().exitCode = exitCode;
|
|
4298
|
+
}
|
|
4299
|
+
function invocationStartedAt() {
|
|
4300
|
+
return new Date(performance.timeOrigin + getState().baseline);
|
|
4301
|
+
}
|
|
4302
|
+
function invocationElapsedMs() {
|
|
4303
|
+
return performance.now() - getState().baseline;
|
|
4304
|
+
}
|
|
4305
|
+
function markCommandStart() {
|
|
4306
|
+
if (!timingsEnabled()) {
|
|
4307
|
+
return;
|
|
4308
|
+
}
|
|
4309
|
+
getState().commandStart = performance.now();
|
|
4310
|
+
}
|
|
4311
|
+
function recordCommandDuration(durationMs) {
|
|
4312
|
+
if (!timingsEnabled()) {
|
|
4313
|
+
return;
|
|
4314
|
+
}
|
|
4315
|
+
getState().commandMs = durationMs;
|
|
4316
|
+
}
|
|
3649
4317
|
// ../common/src/telemetry/proxy-http-agent.ts
|
|
3650
4318
|
var slot = singleton("ProxyAuthHttpsAgent");
|
|
3651
4319
|
|
|
@@ -3666,6 +4334,9 @@ function getGlobalTelemetryInstance() {
|
|
|
3666
4334
|
}
|
|
3667
4335
|
return;
|
|
3668
4336
|
}
|
|
4337
|
+
function setGlobalTelemetryInstance(instance) {
|
|
4338
|
+
telemetryInstanceSlot.set(instance);
|
|
4339
|
+
}
|
|
3669
4340
|
var _localTelemetryInstance;
|
|
3670
4341
|
function getTelemetryInstance() {
|
|
3671
4342
|
const global = getGlobalTelemetryInstance();
|
|
@@ -3673,6 +4344,7 @@ function getTelemetryInstance() {
|
|
|
3673
4344
|
return global;
|
|
3674
4345
|
if (!_localTelemetryInstance) {
|
|
3675
4346
|
_localTelemetryInstance = new TelemetryService(new LoggerTelemetryProvider, new NodeContextStorage);
|
|
4347
|
+
setGlobalTelemetryInstance(_localTelemetryInstance);
|
|
3676
4348
|
}
|
|
3677
4349
|
return _localTelemetryInstance;
|
|
3678
4350
|
}
|
|
@@ -3685,6 +4357,14 @@ var telemetry = new Proxy({}, {
|
|
|
3685
4357
|
});
|
|
3686
4358
|
|
|
3687
4359
|
// ../common/src/formatter.ts
|
|
4360
|
+
var ANSI_STYLES = {
|
|
4361
|
+
red: "\x1B[31m",
|
|
4362
|
+
dim: "\x1B[2m"
|
|
4363
|
+
};
|
|
4364
|
+
var ANSI_RESET = "\x1B[0m";
|
|
4365
|
+
function styleLine(line, style) {
|
|
4366
|
+
return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
|
|
4367
|
+
}
|
|
3688
4368
|
var CLI_ERROR_CODES = [
|
|
3689
4369
|
"invalid_argument",
|
|
3690
4370
|
"authentication_required",
|
|
@@ -3723,22 +4403,6 @@ var EXIT_CODES = {
|
|
|
3723
4403
|
ValidationError: 3,
|
|
3724
4404
|
TimeoutError: 4
|
|
3725
4405
|
};
|
|
3726
|
-
class SuccessOutput {
|
|
3727
|
-
Result = RESULTS.Success;
|
|
3728
|
-
Code;
|
|
3729
|
-
Data;
|
|
3730
|
-
Pagination;
|
|
3731
|
-
Instructions;
|
|
3732
|
-
Log;
|
|
3733
|
-
constructor(code, data) {
|
|
3734
|
-
this.Code = code;
|
|
3735
|
-
this.Data = data;
|
|
3736
|
-
const logPath = getLogFilePath();
|
|
3737
|
-
if (logPath) {
|
|
3738
|
-
this.Log = logPath;
|
|
3739
|
-
}
|
|
3740
|
-
}
|
|
3741
|
-
}
|
|
3742
4406
|
function escapeNonAscii(jsonText) {
|
|
3743
4407
|
return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
|
|
3744
4408
|
const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
|
|
@@ -3803,19 +4467,45 @@ function toPascalCaseKey(key) {
|
|
|
3803
4467
|
const lowerCamelKey = toLowerCamelCaseKey(key);
|
|
3804
4468
|
return lowerCamelKey ? lowerCamelKey.charAt(0).toUpperCase() + lowerCamelKey.slice(1) : lowerCamelKey;
|
|
3805
4469
|
}
|
|
3806
|
-
function
|
|
4470
|
+
function collectVerbatimRefs(value, into) {
|
|
4471
|
+
if (typeof value !== "object" || value === null)
|
|
4472
|
+
return;
|
|
4473
|
+
if (into.has(value))
|
|
4474
|
+
return;
|
|
4475
|
+
into.add(value);
|
|
4476
|
+
for (const nested of Array.isArray(value) ? value : Object.values(value)) {
|
|
4477
|
+
collectVerbatimRefs(nested, into);
|
|
4478
|
+
}
|
|
4479
|
+
}
|
|
4480
|
+
function toPascalCaseData(value, verbatimKeys, subtrees) {
|
|
4481
|
+
if (subtrees?.mode === "skip" && typeof value === "object" && value !== null && subtrees.refs.has(value)) {
|
|
4482
|
+
return value;
|
|
4483
|
+
}
|
|
3807
4484
|
if (Array.isArray(value))
|
|
3808
|
-
return value.map(toPascalCaseData);
|
|
4485
|
+
return value.map((entry) => toPascalCaseData(entry, verbatimKeys, subtrees));
|
|
3809
4486
|
if (!isPlainRecord(value))
|
|
3810
4487
|
return value;
|
|
3811
4488
|
const result = {};
|
|
3812
4489
|
for (const [key, nestedValue] of Object.entries(value)) {
|
|
3813
|
-
|
|
4490
|
+
const pascalKey = toPascalCaseKey(key);
|
|
4491
|
+
if (verbatimKeys?.has(pascalKey)) {
|
|
4492
|
+
result[pascalKey] = nestedValue;
|
|
4493
|
+
if (subtrees?.mode === "collect") {
|
|
4494
|
+
collectVerbatimRefs(nestedValue, subtrees.refs);
|
|
4495
|
+
}
|
|
4496
|
+
continue;
|
|
4497
|
+
}
|
|
4498
|
+
result[pascalKey] = toPascalCaseData(nestedValue, verbatimKeys, subtrees);
|
|
3814
4499
|
}
|
|
3815
4500
|
return result;
|
|
3816
4501
|
}
|
|
3817
|
-
function normalizeDataKeys(data) {
|
|
3818
|
-
return toPascalCaseData(data);
|
|
4502
|
+
function normalizeDataKeys(data, verbatimKeys, subtrees) {
|
|
4503
|
+
return toPascalCaseData(data, verbatimKeys, subtrees);
|
|
4504
|
+
}
|
|
4505
|
+
function toVerbatimKeySet(preserve) {
|
|
4506
|
+
if (!Array.isArray(preserve))
|
|
4507
|
+
return;
|
|
4508
|
+
return new Set(preserve.map(toPascalCaseKey));
|
|
3819
4509
|
}
|
|
3820
4510
|
function normalizeOutputKeys(data) {
|
|
3821
4511
|
const result = {};
|
|
@@ -3825,7 +4515,7 @@ function normalizeOutputKeys(data) {
|
|
|
3825
4515
|
}
|
|
3826
4516
|
return result;
|
|
3827
4517
|
}
|
|
3828
|
-
function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
4518
|
+
function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowStyle) {
|
|
3829
4519
|
if (!data) {
|
|
3830
4520
|
logFn("Empty response object. No data to display.");
|
|
3831
4521
|
return;
|
|
@@ -3860,7 +4550,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
3860
4550
|
if (hasData && !(rows !== null && rows.length === 0)) {
|
|
3861
4551
|
const logValue = data.Log;
|
|
3862
4552
|
if (rows !== null) {
|
|
3863
|
-
printResizableTable(rows, logFn, logValue);
|
|
4553
|
+
printResizableTable(rows, logFn, logValue, undefined, tableRowStyle);
|
|
3864
4554
|
} else {
|
|
3865
4555
|
printVerticalTable(data.Data, logFn, logValue);
|
|
3866
4556
|
}
|
|
@@ -3871,10 +4561,11 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
3871
4561
|
}
|
|
3872
4562
|
}
|
|
3873
4563
|
}
|
|
3874
|
-
function logOutput(data, format = "json") {
|
|
4564
|
+
function logOutput(data, format = "json", tableRowStyle) {
|
|
3875
4565
|
const sink = getOutputSink();
|
|
4566
|
+
const styleFn = sink.capabilities.isInteractive && sink.capabilities.supportsColor ? tableRowStyle : undefined;
|
|
3876
4567
|
printOutput(data, format, (msg) => sink.writeOut(`${msg}
|
|
3877
|
-
`), needsAsciiSafeJson(sink));
|
|
4568
|
+
`), needsAsciiSafeJson(sink), styleFn);
|
|
3878
4569
|
}
|
|
3879
4570
|
function cellToString(val) {
|
|
3880
4571
|
return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
|
|
@@ -3888,7 +4579,7 @@ function wrapText(text, width) {
|
|
|
3888
4579
|
}
|
|
3889
4580
|
return lines;
|
|
3890
4581
|
}
|
|
3891
|
-
function printTable(data, logFn, externalLogValue) {
|
|
4582
|
+
function printTable(data, logFn, externalLogValue, tableRowStyle) {
|
|
3892
4583
|
if (data.length === 0)
|
|
3893
4584
|
return;
|
|
3894
4585
|
const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
@@ -3898,7 +4589,7 @@ function printTable(data, logFn, externalLogValue) {
|
|
|
3898
4589
|
logFn(keys.map((_, i) => "-".repeat(maxWidths[i])).join("-|-"));
|
|
3899
4590
|
data.forEach((item) => {
|
|
3900
4591
|
const row = keys.map((key, i) => cellToString(item[key]).padEnd(maxWidths[i])).join(" | ");
|
|
3901
|
-
logFn(row);
|
|
4592
|
+
logFn(styleLine(row, tableRowStyle?.(item)));
|
|
3902
4593
|
});
|
|
3903
4594
|
if (externalLogValue) {
|
|
3904
4595
|
logFn("");
|
|
@@ -3941,14 +4632,14 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
|
3941
4632
|
logFn(`Log: ${externalLogValue}`);
|
|
3942
4633
|
}
|
|
3943
4634
|
}
|
|
3944
|
-
function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth) {
|
|
4635
|
+
function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
|
|
3945
4636
|
if (data.length === 0)
|
|
3946
4637
|
return;
|
|
3947
4638
|
const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
3948
4639
|
if (keys.length === 0)
|
|
3949
4640
|
return;
|
|
3950
4641
|
if (!process.stdout.isTTY) {
|
|
3951
|
-
printTable(data, logFn, externalLogValue);
|
|
4642
|
+
printTable(data, logFn, externalLogValue, tableRowStyle);
|
|
3952
4643
|
return;
|
|
3953
4644
|
}
|
|
3954
4645
|
const naturalWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
|
|
@@ -3956,7 +4647,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
|
|
|
3956
4647
|
const totalWidth = naturalWidths.reduce((a, b) => a + b, 0) + separatorTotal;
|
|
3957
4648
|
const termWidth = availableWidth ?? (process.stdout.columns || 120);
|
|
3958
4649
|
if (totalWidth <= termWidth) {
|
|
3959
|
-
printTable(data, logFn, externalLogValue);
|
|
4650
|
+
printTable(data, logFn, externalLogValue, tableRowStyle);
|
|
3960
4651
|
return;
|
|
3961
4652
|
}
|
|
3962
4653
|
const overflow = totalWidth - termWidth;
|
|
@@ -4002,6 +4693,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
|
|
|
4002
4693
|
logFn(header);
|
|
4003
4694
|
logFn(keys.map((_, i) => "-".repeat(finalWidths[i])).join("-|-"));
|
|
4004
4695
|
data.forEach((item) => {
|
|
4696
|
+
const style = tableRowStyle?.(item);
|
|
4005
4697
|
const cellLines = keys.map((key, i) => wrapText(cellToString(item[key]), finalWidths[i]));
|
|
4006
4698
|
const lineCount = Math.max(...cellLines.map((l) => l.length));
|
|
4007
4699
|
for (let line = 0;line < lineCount; line++) {
|
|
@@ -4009,7 +4701,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
|
|
|
4009
4701
|
const val = line < cellLines[i].length ? cellLines[i][line] : "";
|
|
4010
4702
|
return val.padEnd(finalWidths[i]);
|
|
4011
4703
|
}).join(" | ");
|
|
4012
|
-
logFn(row);
|
|
4704
|
+
logFn(styleLine(row, style));
|
|
4013
4705
|
}
|
|
4014
4706
|
});
|
|
4015
4707
|
if (externalLogValue) {
|
|
@@ -4153,30 +4845,36 @@ var OutputFormatter;
|
|
|
4153
4845
|
((OutputFormatter) => {
|
|
4154
4846
|
function success(data, options) {
|
|
4155
4847
|
data.Log ??= getLogFilePath() || undefined;
|
|
4156
|
-
const normalize =
|
|
4848
|
+
const normalize = options?.preserveDataKeys !== true;
|
|
4849
|
+
const verbatim = toVerbatimKeySet(options?.preserveDataKeys);
|
|
4850
|
+
const subtrees = verbatim && {
|
|
4851
|
+
refs: new Set,
|
|
4852
|
+
mode: "collect"
|
|
4853
|
+
};
|
|
4157
4854
|
if (normalize) {
|
|
4158
|
-
data.Data = normalizeDataKeys(data.Data);
|
|
4855
|
+
data.Data = normalizeDataKeys(data.Data, verbatim, subtrees);
|
|
4159
4856
|
}
|
|
4160
4857
|
const filter = getOutputFilter();
|
|
4161
4858
|
if (filter) {
|
|
4162
4859
|
const filtered = applyFilter(data.Data, filter);
|
|
4163
|
-
data.Data = normalize ? normalizeDataKeys(filtered) : filtered;
|
|
4860
|
+
data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
|
|
4164
4861
|
}
|
|
4165
|
-
logOutput(normalizeOutputKeys(data), getOutputFormat());
|
|
4862
|
+
logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
|
|
4166
4863
|
}
|
|
4167
4864
|
OutputFormatter.success = success;
|
|
4168
4865
|
function error(data) {
|
|
4169
4866
|
data.Log ??= getLogFilePath() || undefined;
|
|
4170
4867
|
data.ErrorCode ??= defaultErrorCodeForFailure(data);
|
|
4171
4868
|
data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
|
|
4172
|
-
|
|
4869
|
+
const exitCode = EXIT_CODES[data.Result] ?? 1;
|
|
4870
|
+
setExitCode(exitCode);
|
|
4173
4871
|
recordCommandFailureTelemetry({
|
|
4174
4872
|
result: data.Result,
|
|
4175
4873
|
errorCode: data.ErrorCode,
|
|
4176
4874
|
retry: data.Retry,
|
|
4177
4875
|
message: data.Message,
|
|
4178
4876
|
context: data.Context,
|
|
4179
|
-
exitCode
|
|
4877
|
+
exitCode,
|
|
4180
4878
|
errorClass: data.TelemetryErrorClass,
|
|
4181
4879
|
terminalOutcome: data.TelemetryTerminalOutcome,
|
|
4182
4880
|
terminalSignal: data.TelemetryTerminalSignal
|
|
@@ -4253,6 +4951,22 @@ var OutputFormatter;
|
|
|
4253
4951
|
OutputFormatter.formatToString = formatToString;
|
|
4254
4952
|
})(OutputFormatter ||= {});
|
|
4255
4953
|
|
|
4954
|
+
// ../../node_modules/commander/esm.mjs
|
|
4955
|
+
var import__ = __toESM(require_commander(), 1);
|
|
4956
|
+
var {
|
|
4957
|
+
program,
|
|
4958
|
+
createCommand,
|
|
4959
|
+
createArgument,
|
|
4960
|
+
createOption,
|
|
4961
|
+
CommanderError,
|
|
4962
|
+
InvalidArgumentError,
|
|
4963
|
+
InvalidOptionArgumentError,
|
|
4964
|
+
Command,
|
|
4965
|
+
Argument,
|
|
4966
|
+
Option,
|
|
4967
|
+
Help
|
|
4968
|
+
} = import__.default;
|
|
4969
|
+
|
|
4256
4970
|
// ../common/src/telemetry/command-attribution.ts
|
|
4257
4971
|
var LEGACY_SKILL_NAMESPACE = "uipath:";
|
|
4258
4972
|
var MAX_SKILL_NAME_LENGTH = 80;
|
|
@@ -4406,6 +5120,57 @@ function buildCommandTelemetryAttribution(commandPath, skillSource) {
|
|
|
4406
5120
|
};
|
|
4407
5121
|
}
|
|
4408
5122
|
|
|
5123
|
+
// ../common/src/telemetry/command-name.ts
|
|
5124
|
+
var TELEMETRY_COMMAND_ROOT = "uip";
|
|
5125
|
+
function commandTelemetryName(parts) {
|
|
5126
|
+
const tokens = [];
|
|
5127
|
+
for (const part of parts) {
|
|
5128
|
+
const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== TELEMETRY_COMMAND_ROOT);
|
|
5129
|
+
if (pieces.every(isCommandToken)) {
|
|
5130
|
+
tokens.push(...pieces);
|
|
5131
|
+
continue;
|
|
5132
|
+
}
|
|
5133
|
+
tokens.push(UNKNOWN_TOKEN);
|
|
5134
|
+
}
|
|
5135
|
+
return [TELEMETRY_COMMAND_ROOT, ...tokens].join(".");
|
|
5136
|
+
}
|
|
5137
|
+
var COMMAND_TOKEN_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
5138
|
+
var MAX_COMMAND_TOKEN_LENGTH = 32;
|
|
5139
|
+
var GUID_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
5140
|
+
function isCommandToken(token) {
|
|
5141
|
+
return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token) && !/^\d+$/.test(token);
|
|
5142
|
+
}
|
|
5143
|
+
var UNKNOWN_TOKEN = "<unknown>";
|
|
5144
|
+
|
|
5145
|
+
// ../common/src/telemetry/invocation-request.ts
|
|
5146
|
+
var requestContextSlot = singleton("TelemetryInvocationRequestContext");
|
|
5147
|
+
function activeContext() {
|
|
5148
|
+
return telemetry.getActiveContext?.();
|
|
5149
|
+
}
|
|
5150
|
+
function runWithInvocationRequest(fn) {
|
|
5151
|
+
const context = telemetry.createRequestContext();
|
|
5152
|
+
context.startedAt = invocationStartedAt();
|
|
5153
|
+
requestContextSlot.set(context);
|
|
5154
|
+
return telemetry.runWithContext(context, fn);
|
|
5155
|
+
}
|
|
5156
|
+
function ensureInvocationRequestScope(fn) {
|
|
5157
|
+
if (activeContext() !== undefined) {
|
|
5158
|
+
return fn();
|
|
5159
|
+
}
|
|
5160
|
+
const kept = requestContextSlot.get();
|
|
5161
|
+
return kept === undefined ? runWithInvocationRequest(fn) : telemetry.runWithContext(kept, fn);
|
|
5162
|
+
}
|
|
5163
|
+
function getInvocationRequestContext() {
|
|
5164
|
+
return activeContext() ?? requestContextSlot.get();
|
|
5165
|
+
}
|
|
5166
|
+
function emitInvocationRequest(name, success, properties) {
|
|
5167
|
+
const context = getInvocationRequestContext();
|
|
5168
|
+
telemetry.trackRequestResult(name, invocationElapsedMs(), success, properties, context);
|
|
5169
|
+
if (context !== undefined && requestContextSlot.get() === context) {
|
|
5170
|
+
requestContextSlot.clear();
|
|
5171
|
+
}
|
|
5172
|
+
}
|
|
5173
|
+
|
|
4409
5174
|
// ../common/src/trackedAction.ts
|
|
4410
5175
|
var pollSignalSlot = singleton("PollSignal");
|
|
4411
5176
|
var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
|
|
@@ -4413,28 +5178,74 @@ var retryHintValues = new Set(RETRY_HINTS);
|
|
|
4413
5178
|
var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
|
|
4414
5179
|
var processContext = {
|
|
4415
5180
|
exit: (code) => {
|
|
4416
|
-
|
|
5181
|
+
recordExitCode(code);
|
|
5182
|
+
setExitCode(code);
|
|
4417
5183
|
},
|
|
4418
5184
|
get pollSignal() {
|
|
4419
5185
|
return pollSignalSlot.get();
|
|
4420
5186
|
}
|
|
4421
5187
|
};
|
|
5188
|
+
var TELEMETRY_ARG_VALUE_WITHHELD = "<provided>";
|
|
5189
|
+
var TELEMETRY_ARG_VALUE_DEFAULTED = "<default>";
|
|
5190
|
+
function recordableArgValue(value, choices) {
|
|
5191
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
5192
|
+
return value;
|
|
5193
|
+
}
|
|
5194
|
+
if (choices && choices.length > 0) {
|
|
5195
|
+
if (typeof value === "string" && choices.includes(value)) {
|
|
5196
|
+
return value;
|
|
5197
|
+
}
|
|
5198
|
+
if (Array.isArray(value) && value.length > 0 && value.every((entry) => typeof entry === "string" && choices.includes(entry))) {
|
|
5199
|
+
return value.join(",");
|
|
5200
|
+
}
|
|
5201
|
+
}
|
|
5202
|
+
return TELEMETRY_ARG_VALUE_WITHHELD;
|
|
5203
|
+
}
|
|
4422
5204
|
function extractCommandParams(cmd) {
|
|
4423
5205
|
const params = {};
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
5206
|
+
forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
|
|
5207
|
+
const recordable = recordableArgValue(value, choices);
|
|
5208
|
+
params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
|
|
5209
|
+
});
|
|
5210
|
+
return params;
|
|
5211
|
+
}
|
|
5212
|
+
function isDefaultedOption(cmd, name) {
|
|
5213
|
+
const source = cmd.getOptionValueSource?.(name);
|
|
5214
|
+
return source === "default" || source === "implied";
|
|
5215
|
+
}
|
|
5216
|
+
function isDefaultedPositional(cmd, index) {
|
|
5217
|
+
return index >= (cmd.args?.length ?? 0);
|
|
5218
|
+
}
|
|
5219
|
+
function forEachSuppliedArgument(cmd, visit) {
|
|
4429
5220
|
const registered = cmd.registeredArguments ?? [];
|
|
4430
5221
|
const processed = cmd.processedArgs ?? [];
|
|
4431
5222
|
for (let i = 0;i < registered.length; i++) {
|
|
4432
|
-
|
|
5223
|
+
const name = registered[i].name();
|
|
5224
|
+
if (name && processed[i] !== undefined) {
|
|
5225
|
+
visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
|
|
5226
|
+
}
|
|
5227
|
+
}
|
|
5228
|
+
const choicesByAttribute = new Map;
|
|
5229
|
+
for (const option of cmd.options) {
|
|
5230
|
+
choicesByAttribute.set(option.attributeName(), option.argChoices);
|
|
4433
5231
|
}
|
|
4434
5232
|
for (const [key, value] of Object.entries(cmd.opts())) {
|
|
4435
|
-
|
|
5233
|
+
if (key && value !== undefined) {
|
|
5234
|
+
visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
|
|
5235
|
+
}
|
|
4436
5236
|
}
|
|
4437
|
-
|
|
5237
|
+
}
|
|
5238
|
+
function withheldArgumentValues(cmd) {
|
|
5239
|
+
const values = [];
|
|
5240
|
+
forEachSuppliedArgument(cmd, (_name, value, choices, defaulted) => {
|
|
5241
|
+
if (defaulted) {
|
|
5242
|
+
return;
|
|
5243
|
+
}
|
|
5244
|
+
if (recordableArgValue(value, choices) === TELEMETRY_ARG_VALUE_WITHHELD) {
|
|
5245
|
+
values.push(value);
|
|
5246
|
+
}
|
|
5247
|
+
});
|
|
5248
|
+
return values;
|
|
4438
5249
|
}
|
|
4439
5250
|
function deriveCommandPath(cmd) {
|
|
4440
5251
|
const parts = [];
|
|
@@ -4449,7 +5260,7 @@ function deriveCommandPath(cmd) {
|
|
|
4449
5260
|
if (parts.length > 1) {
|
|
4450
5261
|
parts.shift();
|
|
4451
5262
|
}
|
|
4452
|
-
return
|
|
5263
|
+
return commandTelemetryName(parts);
|
|
4453
5264
|
}
|
|
4454
5265
|
function isCliErrorCode(value) {
|
|
4455
5266
|
return typeof value === "string" && cliErrorCodeValues.has(value);
|
|
@@ -4489,68 +5300,77 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
4489
5300
|
});
|
|
4490
5301
|
const telemetryName = deriveCommandPath(command);
|
|
4491
5302
|
const props = typeof properties === "function" ? properties(...args) : properties;
|
|
4492
|
-
|
|
4493
|
-
const
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
5303
|
+
markCommandStart();
|
|
5304
|
+
const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
|
|
5305
|
+
try {
|
|
5306
|
+
const startTime = performance.now();
|
|
5307
|
+
let errorMessage;
|
|
5308
|
+
let fallbackExitCode = EXIT_CODES.Success;
|
|
5309
|
+
clearRecordedCommandFailureTelemetry();
|
|
5310
|
+
const [error] = await catchError(ensureInvocationRequestScope(() => {
|
|
5311
|
+
const violation = implicitLimitViolation(command);
|
|
5312
|
+
if (violation) {
|
|
5313
|
+
return Promise.reject(violation);
|
|
5314
|
+
}
|
|
5315
|
+
return fn(...args);
|
|
5316
|
+
}));
|
|
5317
|
+
if (error) {
|
|
5318
|
+
errorMessage = error instanceof Error ? error.message : String(error);
|
|
5319
|
+
logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
|
|
5320
|
+
const typed = error;
|
|
5321
|
+
const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
|
|
5322
|
+
const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
|
|
5323
|
+
const finalResult = customResult ?? RESULTS.Failure;
|
|
5324
|
+
const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
|
|
5325
|
+
const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
|
|
5326
|
+
const typedRetry = typed.retry ?? typed.Retry;
|
|
5327
|
+
const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
|
|
5328
|
+
const typedContext = typed.context ?? typed.Context;
|
|
5329
|
+
const customContext = isErrorContext(typedContext) ? typedContext : undefined;
|
|
5330
|
+
const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
|
|
5331
|
+
fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
|
|
5332
|
+
OutputFormatter.error({
|
|
5333
|
+
Result: finalResult,
|
|
5334
|
+
...customErrorCode ? { ErrorCode: customErrorCode } : {},
|
|
5335
|
+
Message: errorMessage,
|
|
5336
|
+
Instructions: customInstructions ?? commandHelpHint(telemetryName),
|
|
5337
|
+
...customRetry ? { Retry: customRetry } : {},
|
|
5338
|
+
...customContext ? { Context: customContext } : {}
|
|
5339
|
+
});
|
|
5340
|
+
context.exit(fallbackExitCode);
|
|
5341
|
+
}
|
|
5342
|
+
const durationMs = performance.now() - startTime;
|
|
5343
|
+
recordCommandDuration(durationMs);
|
|
5344
|
+
const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
|
|
5345
|
+
const recordedFailure = takeRecordedCommandFailureTelemetry();
|
|
5346
|
+
const success = !error && exitCode === 0;
|
|
5347
|
+
const terminalTelemetry = buildCommandTerminalTelemetryProperties({
|
|
5348
|
+
error,
|
|
5349
|
+
exitCode,
|
|
5350
|
+
recordedFailure,
|
|
5351
|
+
pollSignal: context.pollSignal
|
|
4526
5352
|
});
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
}
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
|
|
4549
|
-
command: "true",
|
|
4550
|
-
...terminalTelemetry,
|
|
4551
|
-
...errorMessage ? { errorMessage } : {}
|
|
4552
|
-
});
|
|
4553
|
-
telemetry.trackRequestResult(telemetryName, durationMs, success, baseProperties, requestContext);
|
|
5353
|
+
if (terminalTelemetry.error_class === "internal" && error) {
|
|
5354
|
+
telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { command_name: telemetryName }, getInvocationRequestContext());
|
|
5355
|
+
}
|
|
5356
|
+
const commandParams = extractCommandParams(command);
|
|
5357
|
+
if (props) {
|
|
5358
|
+
for (const key of Object.keys(props)) {
|
|
5359
|
+
delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
|
|
5360
|
+
}
|
|
5361
|
+
}
|
|
5362
|
+
const baseProperties = redactProperties({
|
|
5363
|
+
...commandParams,
|
|
5364
|
+
...props,
|
|
5365
|
+
...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
|
|
5366
|
+
command: "true",
|
|
5367
|
+
...terminalTelemetry,
|
|
5368
|
+
...errorMessage ? { errorMessage } : {}
|
|
5369
|
+
});
|
|
5370
|
+
emitInvocationRequest(telemetryName, success, baseProperties);
|
|
5371
|
+
} finally {
|
|
5372
|
+
releaseSuppliedArgumentValues(supplied);
|
|
5373
|
+
}
|
|
4554
5374
|
});
|
|
4555
5375
|
};
|
|
4556
5376
|
|
|
@@ -4559,6 +5379,18 @@ var GUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
|
|
|
4559
5379
|
function isGuid(value) {
|
|
4560
5380
|
return GUID_REGEX.test(value);
|
|
4561
5381
|
}
|
|
5382
|
+
// ../common/src/classified-failure.ts
|
|
5383
|
+
async function classifiedFailure(message, error) {
|
|
5384
|
+
const details = await extractErrorDetails(error);
|
|
5385
|
+
return {
|
|
5386
|
+
Result: RESULTS.Failure,
|
|
5387
|
+
ErrorCode: details.errorCode,
|
|
5388
|
+
Message: message,
|
|
5389
|
+
Instructions: details.message,
|
|
5390
|
+
Retry: details.retry,
|
|
5391
|
+
...details.context ? { Context: details.context } : {}
|
|
5392
|
+
};
|
|
5393
|
+
}
|
|
4562
5394
|
// ../common/src/command-examples.ts
|
|
4563
5395
|
var examplesByCommand = new WeakMap;
|
|
4564
5396
|
Command.prototype.examples = function(examples) {
|
|
@@ -4583,6 +5415,204 @@ var guardInstalledSlot = singleton("ConsoleGuardInstalled");
|
|
|
4583
5415
|
var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
|
|
4584
5416
|
// ../common/src/constants.ts
|
|
4585
5417
|
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
5418
|
+
// ../common/src/entity-name-rules.ts
|
|
5419
|
+
var RESERVED_SQL_KEYWORDS_LOWER = new Set(["group", "order"]);
|
|
5420
|
+
var RESERVED_FIELD_NAMES_LOWER = new Set([
|
|
5421
|
+
"id",
|
|
5422
|
+
"createdby",
|
|
5423
|
+
"createtime",
|
|
5424
|
+
"updatedby",
|
|
5425
|
+
"updatetime",
|
|
5426
|
+
"recordowner",
|
|
5427
|
+
"version"
|
|
5428
|
+
]);
|
|
5429
|
+
var RESERVED_KEYWORDS_LOWER = new Set([
|
|
5430
|
+
"abstract",
|
|
5431
|
+
"as",
|
|
5432
|
+
"base",
|
|
5433
|
+
"bool",
|
|
5434
|
+
"break",
|
|
5435
|
+
"byte",
|
|
5436
|
+
"case",
|
|
5437
|
+
"catch",
|
|
5438
|
+
"char",
|
|
5439
|
+
"checked",
|
|
5440
|
+
"class",
|
|
5441
|
+
"const",
|
|
5442
|
+
"continue",
|
|
5443
|
+
"decimal",
|
|
5444
|
+
"default",
|
|
5445
|
+
"delegate",
|
|
5446
|
+
"do",
|
|
5447
|
+
"double",
|
|
5448
|
+
"else",
|
|
5449
|
+
"enum",
|
|
5450
|
+
"event",
|
|
5451
|
+
"explicit",
|
|
5452
|
+
"extern",
|
|
5453
|
+
"false",
|
|
5454
|
+
"finally",
|
|
5455
|
+
"fixed",
|
|
5456
|
+
"float",
|
|
5457
|
+
"for",
|
|
5458
|
+
"foreach",
|
|
5459
|
+
"goto",
|
|
5460
|
+
"if",
|
|
5461
|
+
"implicit",
|
|
5462
|
+
"in",
|
|
5463
|
+
"int",
|
|
5464
|
+
"interface",
|
|
5465
|
+
"internal",
|
|
5466
|
+
"is",
|
|
5467
|
+
"lock",
|
|
5468
|
+
"long",
|
|
5469
|
+
"namespace",
|
|
5470
|
+
"new",
|
|
5471
|
+
"null",
|
|
5472
|
+
"object",
|
|
5473
|
+
"operator",
|
|
5474
|
+
"out",
|
|
5475
|
+
"override",
|
|
5476
|
+
"params",
|
|
5477
|
+
"private",
|
|
5478
|
+
"protected",
|
|
5479
|
+
"public",
|
|
5480
|
+
"readonly",
|
|
5481
|
+
"ref",
|
|
5482
|
+
"return",
|
|
5483
|
+
"sbyte",
|
|
5484
|
+
"sealed",
|
|
5485
|
+
"short",
|
|
5486
|
+
"sizeof",
|
|
5487
|
+
"stackalloc",
|
|
5488
|
+
"static",
|
|
5489
|
+
"string",
|
|
5490
|
+
"struct",
|
|
5491
|
+
"switch",
|
|
5492
|
+
"this",
|
|
5493
|
+
"throw",
|
|
5494
|
+
"true",
|
|
5495
|
+
"try",
|
|
5496
|
+
"typeof",
|
|
5497
|
+
"uint",
|
|
5498
|
+
"ulong",
|
|
5499
|
+
"unchecked",
|
|
5500
|
+
"unsafe",
|
|
5501
|
+
"ushort",
|
|
5502
|
+
"using",
|
|
5503
|
+
"virtual",
|
|
5504
|
+
"void",
|
|
5505
|
+
"volatile",
|
|
5506
|
+
"while",
|
|
5507
|
+
"addhandler",
|
|
5508
|
+
"addressof",
|
|
5509
|
+
"alias",
|
|
5510
|
+
"and",
|
|
5511
|
+
"andalso",
|
|
5512
|
+
"boolean",
|
|
5513
|
+
"byref",
|
|
5514
|
+
"byval",
|
|
5515
|
+
"call",
|
|
5516
|
+
"cbool",
|
|
5517
|
+
"cbyte",
|
|
5518
|
+
"cchar",
|
|
5519
|
+
"cdate",
|
|
5520
|
+
"cdbl",
|
|
5521
|
+
"cdec",
|
|
5522
|
+
"cint",
|
|
5523
|
+
"clng",
|
|
5524
|
+
"cobj",
|
|
5525
|
+
"csbyte",
|
|
5526
|
+
"cshort",
|
|
5527
|
+
"csng",
|
|
5528
|
+
"cstr",
|
|
5529
|
+
"ctype",
|
|
5530
|
+
"cuint",
|
|
5531
|
+
"culng",
|
|
5532
|
+
"cushort",
|
|
5533
|
+
"date",
|
|
5534
|
+
"declare",
|
|
5535
|
+
"dim",
|
|
5536
|
+
"directcast",
|
|
5537
|
+
"each",
|
|
5538
|
+
"elseif",
|
|
5539
|
+
"end",
|
|
5540
|
+
"endif",
|
|
5541
|
+
"erase",
|
|
5542
|
+
"error",
|
|
5543
|
+
"exit",
|
|
5544
|
+
"friend",
|
|
5545
|
+
"function",
|
|
5546
|
+
"get",
|
|
5547
|
+
"gettype",
|
|
5548
|
+
"getxmlnamespace",
|
|
5549
|
+
"global",
|
|
5550
|
+
"gosub",
|
|
5551
|
+
"goto",
|
|
5552
|
+
"handles",
|
|
5553
|
+
"implements",
|
|
5554
|
+
"imports",
|
|
5555
|
+
"inherits",
|
|
5556
|
+
"integer",
|
|
5557
|
+
"isnot",
|
|
5558
|
+
"let",
|
|
5559
|
+
"lib",
|
|
5560
|
+
"like",
|
|
5561
|
+
"loop",
|
|
5562
|
+
"me",
|
|
5563
|
+
"mod",
|
|
5564
|
+
"module",
|
|
5565
|
+
"mustinherit",
|
|
5566
|
+
"mustoverride",
|
|
5567
|
+
"mybase",
|
|
5568
|
+
"myclass",
|
|
5569
|
+
"narrowing",
|
|
5570
|
+
"next",
|
|
5571
|
+
"not",
|
|
5572
|
+
"nothing",
|
|
5573
|
+
"notinheritable",
|
|
5574
|
+
"notoverridable",
|
|
5575
|
+
"of",
|
|
5576
|
+
"on",
|
|
5577
|
+
"option",
|
|
5578
|
+
"optional",
|
|
5579
|
+
"or",
|
|
5580
|
+
"orelse",
|
|
5581
|
+
"overloads",
|
|
5582
|
+
"overridable",
|
|
5583
|
+
"overrides",
|
|
5584
|
+
"paramarray",
|
|
5585
|
+
"partial",
|
|
5586
|
+
"property",
|
|
5587
|
+
"raiseevent",
|
|
5588
|
+
"redim",
|
|
5589
|
+
"rem",
|
|
5590
|
+
"removehandler",
|
|
5591
|
+
"resume",
|
|
5592
|
+
"select",
|
|
5593
|
+
"set",
|
|
5594
|
+
"shadows",
|
|
5595
|
+
"shared",
|
|
5596
|
+
"single",
|
|
5597
|
+
"step",
|
|
5598
|
+
"stop",
|
|
5599
|
+
"structure",
|
|
5600
|
+
"sub",
|
|
5601
|
+
"synclock",
|
|
5602
|
+
"then",
|
|
5603
|
+
"to",
|
|
5604
|
+
"trycast",
|
|
5605
|
+
"uinteger",
|
|
5606
|
+
"ushort",
|
|
5607
|
+
"variant",
|
|
5608
|
+
"wend",
|
|
5609
|
+
"when",
|
|
5610
|
+
"widening",
|
|
5611
|
+
"with",
|
|
5612
|
+
"withevents",
|
|
5613
|
+
"writeonly",
|
|
5614
|
+
"xor"
|
|
5615
|
+
]);
|
|
4586
5616
|
// ../common/src/host-global-options.ts
|
|
4587
5617
|
var HOST_GLOBAL_OPTIONS_WITH_VALUE = [
|
|
4588
5618
|
"--output",
|
|
@@ -4739,6 +5769,40 @@ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
|
4739
5769
|
var shippedKeysSlot = singleton("ShipSucceededDedupeKeys");
|
|
4740
5770
|
// ../common/src/tool-provider.ts
|
|
4741
5771
|
var factorySlot = singleton("PackagerFactoryProvider");
|
|
5772
|
+
// ../auth/src/catch-error.ts
|
|
5773
|
+
function isPromiseLike2(value) {
|
|
5774
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
5775
|
+
}
|
|
5776
|
+
function catchError2(fnOrPromise) {
|
|
5777
|
+
if (isPromiseLike2(fnOrPromise)) {
|
|
5778
|
+
return settlePromiseLike2(fnOrPromise);
|
|
5779
|
+
}
|
|
5780
|
+
try {
|
|
5781
|
+
const result = fnOrPromise();
|
|
5782
|
+
if (isPromiseLike2(result)) {
|
|
5783
|
+
return settlePromiseLike2(result);
|
|
5784
|
+
}
|
|
5785
|
+
return [undefined, result];
|
|
5786
|
+
} catch (error) {
|
|
5787
|
+
return [
|
|
5788
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
5789
|
+
undefined
|
|
5790
|
+
];
|
|
5791
|
+
}
|
|
5792
|
+
}
|
|
5793
|
+
function settlePromiseLike2(thenable) {
|
|
5794
|
+
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
|
|
5795
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
5796
|
+
undefined
|
|
5797
|
+
]);
|
|
5798
|
+
}
|
|
5799
|
+
|
|
5800
|
+
// ../auth/src/constants.ts
|
|
5801
|
+
var UIPATH_HOME_DIR = ".uipath";
|
|
5802
|
+
var AUTH_FILENAME = ".auth";
|
|
5803
|
+
var DEFAULT_BASE_URL = "https://cloud.uipath.com";
|
|
5804
|
+
var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
|
|
5805
|
+
|
|
4742
5806
|
// ../auth/src/authProfile.ts
|
|
4743
5807
|
var DEFAULT_AUTH_PROFILE = "default";
|
|
4744
5808
|
var PROFILE_DIR = "profiles";
|
|
@@ -4750,7 +5814,7 @@ function isAuthProfileStorage(value) {
|
|
|
4750
5814
|
return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
|
|
4751
5815
|
}
|
|
4752
5816
|
function createProfileStorage() {
|
|
4753
|
-
const [error, mod] =
|
|
5817
|
+
const [error, mod] = catchError2(() => __require("node:async_hooks"));
|
|
4754
5818
|
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
4755
5819
|
return {
|
|
4756
5820
|
getStore: () => {
|
|
@@ -4766,9 +5830,9 @@ function getProfileStorage() {
|
|
|
4766
5830
|
if (isAuthProfileStorage(existing)) {
|
|
4767
5831
|
return existing;
|
|
4768
5832
|
}
|
|
4769
|
-
const
|
|
4770
|
-
globalSlot[AUTH_PROFILE_STORAGE_KEY] =
|
|
4771
|
-
return
|
|
5833
|
+
const storage2 = createProfileStorage();
|
|
5834
|
+
globalSlot[AUTH_PROFILE_STORAGE_KEY] = storage2;
|
|
5835
|
+
return storage2;
|
|
4772
5836
|
}
|
|
4773
5837
|
var profileStorage = getProfileStorage();
|
|
4774
5838
|
|
|
@@ -4799,8 +5863,8 @@ function resolveAuthProfileFilePath(profile) {
|
|
|
4799
5863
|
if (normalized === undefined) {
|
|
4800
5864
|
throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
|
|
4801
5865
|
}
|
|
4802
|
-
const
|
|
4803
|
-
return
|
|
5866
|
+
const fs2 = getFileSystem();
|
|
5867
|
+
return fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
|
|
4804
5868
|
}
|
|
4805
5869
|
function getActiveAuthProfileFilePath() {
|
|
4806
5870
|
const profile = getActiveAuthProfile();
|
|
@@ -4820,7 +5884,7 @@ class InvalidBaseUrlError extends Error {
|
|
|
4820
5884
|
super(`Invalid base URL: "${url}"
|
|
4821
5885
|
` + `Reason: ${reason}
|
|
4822
5886
|
|
|
4823
|
-
` + `Expected format: an https:// URL, e.g. https://cloud.uipath.com (commercial), https://govcloud.uipath.us (Public Sector), or your Automation Suite host (https://<your-host>).
|
|
5887
|
+
` + `Expected format: an https:// URL (or bare host — https:// is assumed), e.g. https://cloud.uipath.com (commercial), https://govcloud.uipath.us (Public Sector), or your Automation Suite host (https://<your-host>).
|
|
4824
5888
|
` + `You can specify the URL via:
|
|
4825
5889
|
` + ` • --authority flag
|
|
4826
5890
|
` + ` • UIPATH_URL environment variable
|
|
@@ -4841,10 +5905,16 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
|
|
|
4841
5905
|
while (baseUrl.endsWith("/")) {
|
|
4842
5906
|
baseUrl = baseUrl.slice(0, -1);
|
|
4843
5907
|
}
|
|
5908
|
+
const hasScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(baseUrl);
|
|
5909
|
+
const [hostCandidate] = baseUrl.split(/[/?#]/, 1);
|
|
5910
|
+
if (!hasScheme && hostCandidate.includes(".")) {
|
|
5911
|
+
baseUrl = `https://${baseUrl}`;
|
|
5912
|
+
}
|
|
4844
5913
|
const resolvedBaseUrl = baseUrl;
|
|
4845
|
-
const [urlError, url] =
|
|
5914
|
+
const [urlError, url] = catchError2(() => new URL(resolvedBaseUrl));
|
|
4846
5915
|
if (urlError) {
|
|
4847
|
-
|
|
5916
|
+
const shapeHint = !hasScheme && !hostCandidate.includes(".") ? ` "${rawUrl.trim()}" is not a URL or a host name. Pass the full authority URL — https://<host>, or just <host> (https:// is assumed).` : ` ${urlError instanceof Error ? urlError.message : "Unknown error"}`;
|
|
5917
|
+
throw new InvalidBaseUrlError(baseUrl, `Malformed URL.${shapeHint}`);
|
|
4848
5918
|
}
|
|
4849
5919
|
if (url.protocol !== "https:") {
|
|
4850
5920
|
throw new InvalidBaseUrlError(baseUrl, `Authority must use https:// scheme, got ${url.protocol}//. OIDC token exchange requires TLS end-to-end.`);
|
|
@@ -4899,6 +5969,11 @@ var resolveConfigAsync = async ({
|
|
|
4899
5969
|
};
|
|
4900
5970
|
};
|
|
4901
5971
|
|
|
5972
|
+
// ../auth/src/utils/platform.ts
|
|
5973
|
+
function isBrowser() {
|
|
5974
|
+
return typeof globalThis !== "undefined" && "window" in globalThis && "document" in globalThis;
|
|
5975
|
+
}
|
|
5976
|
+
|
|
4902
5977
|
// ../auth/src/utils/jwt.ts
|
|
4903
5978
|
class InvalidIssuerError extends Error {
|
|
4904
5979
|
expected;
|
|
@@ -4973,7 +6048,7 @@ var getTokenExpiration = (accessToken) => {
|
|
|
4973
6048
|
// ../auth/src/sessionIdentity.ts
|
|
4974
6049
|
var parseAuthFlow = (value) => value === "authorization_code" || value === "client_credentials" || value === "federated_credentials" ? value : undefined;
|
|
4975
6050
|
var decodeClaims = (accessToken) => {
|
|
4976
|
-
const [error, claims] =
|
|
6051
|
+
const [error, claims] = catchError2(() => parseJWT(accessToken));
|
|
4977
6052
|
return error ? undefined : claims;
|
|
4978
6053
|
};
|
|
4979
6054
|
var asString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
|
|
@@ -5057,27 +6132,48 @@ var requireEnv = (name) => {
|
|
|
5057
6132
|
}
|
|
5058
6133
|
return value;
|
|
5059
6134
|
};
|
|
6135
|
+
var OPAQUE_TOKEN_BASE_URL_VAR = "UIPATH_URL";
|
|
6136
|
+
var resolveBaseUrl = (rawUrl, failureContext) => {
|
|
6137
|
+
const [baseUrlError, baseUrl] = catchError2(() => normalizeAndValidateBaseUrl(rawUrl));
|
|
6138
|
+
if (baseUrlError) {
|
|
6139
|
+
if (baseUrlError instanceof InvalidBaseUrlError) {
|
|
6140
|
+
throw baseUrlError;
|
|
6141
|
+
}
|
|
6142
|
+
throw new EnvAuthConfigError(`${failureContext}: ` + `${baseUrlError instanceof Error ? baseUrlError.message : String(baseUrlError)}`);
|
|
6143
|
+
}
|
|
6144
|
+
return baseUrl;
|
|
6145
|
+
};
|
|
5060
6146
|
var readAuthFromEnv = () => {
|
|
5061
6147
|
const accessToken = requireEnv(ENV_AUTH_VARS.token);
|
|
5062
6148
|
const organizationName = requireEnv(ENV_AUTH_VARS.organizationName);
|
|
5063
6149
|
const organizationId = requireEnv(ENV_AUTH_VARS.organizationId);
|
|
5064
6150
|
const tenantName = requireEnv(ENV_AUTH_VARS.tenantName);
|
|
5065
6151
|
const tenantId = requireEnv(ENV_AUTH_VARS.tenantId);
|
|
5066
|
-
const [parseError, payload] =
|
|
6152
|
+
const [parseError, payload] = catchError2(() => parseJWT(accessToken));
|
|
5067
6153
|
if (parseError) {
|
|
5068
|
-
|
|
6154
|
+
const parseErrorMessage = parseError instanceof Error ? parseError.message : String(parseError);
|
|
6155
|
+
const rawUrl = process.env[OPAQUE_TOKEN_BASE_URL_VAR];
|
|
6156
|
+
if (!rawUrl) {
|
|
6157
|
+
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}).`);
|
|
6158
|
+
}
|
|
6159
|
+
const baseUrl2 = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
|
|
6160
|
+
return {
|
|
6161
|
+
loginStatus: "Logged in",
|
|
6162
|
+
accessToken,
|
|
6163
|
+
baseUrl: baseUrl2,
|
|
6164
|
+
organizationName,
|
|
6165
|
+
organizationId,
|
|
6166
|
+
tenantName,
|
|
6167
|
+
tenantId,
|
|
6168
|
+
source: "env-vars" /* EnvironmentVariables */,
|
|
6169
|
+
hint: "Token is opaque (not a JWT) - expiration and identity cannot be " + "determined locally. Commands will fail with 401 once it is revoked or " + `expired. If this was meant to be a JWT instead of a PAT, note: ${parseErrorMessage}`
|
|
6170
|
+
};
|
|
5069
6171
|
}
|
|
5070
6172
|
const iss = payload.iss;
|
|
5071
6173
|
if (typeof iss !== "string" || iss.length === 0) {
|
|
5072
6174
|
throw new EnvAuthConfigError(`${ENV_AUTH_VARS.token} has no 'iss' claim; cannot determine ` + `the UiPath server. Ensure the token was issued by a UiPath identity server.`);
|
|
5073
6175
|
}
|
|
5074
|
-
const
|
|
5075
|
-
if (baseUrlError) {
|
|
5076
|
-
if (baseUrlError instanceof InvalidBaseUrlError) {
|
|
5077
|
-
throw baseUrlError;
|
|
5078
|
-
}
|
|
5079
|
-
throw new EnvAuthConfigError(`Failed to derive server URL from token 'iss' claim: ` + `${baseUrlError instanceof Error ? baseUrlError.message : String(baseUrlError)}`);
|
|
5080
|
-
}
|
|
6176
|
+
const baseUrl = resolveBaseUrl(iss, "Failed to derive server URL from token 'iss' claim");
|
|
5081
6177
|
const expiration = getTokenExpiration(accessToken);
|
|
5082
6178
|
const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
|
|
5083
6179
|
const identity = resolveSessionIdentity(accessToken);
|
|
@@ -5103,8 +6199,8 @@ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
|
|
|
5103
6199
|
async function refreshTokenFingerprint(refreshToken) {
|
|
5104
6200
|
const bytes = new TextEncoder().encode(refreshToken);
|
|
5105
6201
|
if (globalThis.crypto?.subtle) {
|
|
5106
|
-
const
|
|
5107
|
-
return Array.from(new Uint8Array(
|
|
6202
|
+
const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
6203
|
+
return Array.from(new Uint8Array(digest2), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
|
|
5108
6204
|
}
|
|
5109
6205
|
const { createHash } = await import("node:crypto");
|
|
5110
6206
|
return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
@@ -5113,9 +6209,9 @@ function breakerPathFor(authPath) {
|
|
|
5113
6209
|
return `${authPath}${BREAKER_SUFFIX}`;
|
|
5114
6210
|
}
|
|
5115
6211
|
async function loadRefreshBreaker(authPath) {
|
|
5116
|
-
const
|
|
6212
|
+
const fs2 = getFileSystem();
|
|
5117
6213
|
try {
|
|
5118
|
-
const content = await
|
|
6214
|
+
const content = await fs2.readFile(breakerPathFor(authPath), "utf-8");
|
|
5119
6215
|
if (!content)
|
|
5120
6216
|
return {};
|
|
5121
6217
|
const parsed = JSON.parse(content);
|
|
@@ -5126,20 +6222,20 @@ async function loadRefreshBreaker(authPath) {
|
|
|
5126
6222
|
}
|
|
5127
6223
|
async function saveRefreshBreaker(authPath, state) {
|
|
5128
6224
|
try {
|
|
5129
|
-
const
|
|
5130
|
-
const
|
|
5131
|
-
await
|
|
5132
|
-
const tempPath = `${
|
|
5133
|
-
await
|
|
5134
|
-
await
|
|
6225
|
+
const fs2 = getFileSystem();
|
|
6226
|
+
const path2 = breakerPathFor(authPath);
|
|
6227
|
+
await fs2.mkdir(fs2.path.dirname(path2));
|
|
6228
|
+
const tempPath = `${path2}.tmp`;
|
|
6229
|
+
await fs2.writeFile(tempPath, JSON.stringify(state));
|
|
6230
|
+
await fs2.rename(tempPath, path2);
|
|
5135
6231
|
} catch {}
|
|
5136
6232
|
}
|
|
5137
6233
|
async function clearRefreshBreaker(authPath) {
|
|
5138
|
-
const
|
|
5139
|
-
const
|
|
6234
|
+
const fs2 = getFileSystem();
|
|
6235
|
+
const path2 = breakerPathFor(authPath);
|
|
5140
6236
|
try {
|
|
5141
|
-
if (await
|
|
5142
|
-
await
|
|
6237
|
+
if (await fs2.exists(path2)) {
|
|
6238
|
+
await fs2.rm(path2);
|
|
5143
6239
|
}
|
|
5144
6240
|
} catch {}
|
|
5145
6241
|
}
|
|
@@ -5160,43 +6256,43 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
|
5160
6256
|
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
5161
6257
|
var PIPE_NAME_MAX_LENGTH = 103;
|
|
5162
6258
|
var getRobotIpcPipeNames = async () => {
|
|
5163
|
-
const
|
|
5164
|
-
const username =
|
|
6259
|
+
const fs2 = getFileSystem();
|
|
6260
|
+
const username = fs2.env.getenv("USER") ?? fs2.env.getenv("USERNAME");
|
|
5165
6261
|
if (!username) {
|
|
5166
6262
|
throw new Error("Unable to determine current username");
|
|
5167
6263
|
}
|
|
5168
|
-
const tempPath =
|
|
5169
|
-
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) =>
|
|
6264
|
+
const tempPath = fs2.env.getenv("TMPDIR") ?? "/tmp/";
|
|
6265
|
+
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs2.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
|
|
5170
6266
|
};
|
|
5171
6267
|
var defaultIsRobotIpcAvailable = async () => {
|
|
5172
6268
|
if (process.platform === "win32") {
|
|
5173
6269
|
return true;
|
|
5174
6270
|
}
|
|
5175
|
-
const [pipeNamesError, pipeNames] = await
|
|
6271
|
+
const [pipeNamesError, pipeNames] = await catchError2(getRobotIpcPipeNames());
|
|
5176
6272
|
if (pipeNamesError || !pipeNames) {
|
|
5177
6273
|
return false;
|
|
5178
6274
|
}
|
|
5179
|
-
const
|
|
6275
|
+
const fs2 = getFileSystem();
|
|
5180
6276
|
for (const pipeName of pipeNames) {
|
|
5181
|
-
const [existsError, exists] = await
|
|
6277
|
+
const [existsError, exists] = await catchError2(fs2.exists(pipeName));
|
|
5182
6278
|
if (!existsError && exists === true) {
|
|
5183
6279
|
return true;
|
|
5184
6280
|
}
|
|
5185
6281
|
}
|
|
5186
6282
|
return false;
|
|
5187
6283
|
};
|
|
5188
|
-
var withTimeout = (promise, timeoutMs) => new Promise((
|
|
6284
|
+
var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
|
|
5189
6285
|
const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
5190
6286
|
promise.then((value) => {
|
|
5191
6287
|
clearTimeout(timer);
|
|
5192
|
-
|
|
6288
|
+
resolve2(value);
|
|
5193
6289
|
}, (error) => {
|
|
5194
6290
|
clearTimeout(timer);
|
|
5195
6291
|
reject(error);
|
|
5196
6292
|
});
|
|
5197
6293
|
});
|
|
5198
6294
|
var parseResourceUrl = (url) => {
|
|
5199
|
-
const [error, parsed] =
|
|
6295
|
+
const [error, parsed] = catchError2(() => new URL(url));
|
|
5200
6296
|
if (error || !parsed)
|
|
5201
6297
|
return;
|
|
5202
6298
|
const segments = parsed.pathname.split("/").filter(Boolean);
|
|
@@ -5216,7 +6312,7 @@ var defaultLoadModule = async () => {
|
|
|
5216
6312
|
if (!hostLoader) {
|
|
5217
6313
|
return;
|
|
5218
6314
|
}
|
|
5219
|
-
const [error, mod] = await
|
|
6315
|
+
const [error, mod] = await catchError2(() => hostLoader());
|
|
5220
6316
|
if (error || !mod) {
|
|
5221
6317
|
return;
|
|
5222
6318
|
}
|
|
@@ -5242,7 +6338,7 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
5242
6338
|
const mod = await loadModule();
|
|
5243
6339
|
if (!mod)
|
|
5244
6340
|
return;
|
|
5245
|
-
const [ctorError, proxy] =
|
|
6341
|
+
const [ctorError, proxy] = catchError2(() => new mod.RobotProxyConstructor);
|
|
5246
6342
|
if (ctorError || !proxy) {
|
|
5247
6343
|
return;
|
|
5248
6344
|
}
|
|
@@ -5265,7 +6361,7 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
5265
6361
|
let organizationIdFromToken;
|
|
5266
6362
|
let tenantIdFromToken;
|
|
5267
6363
|
let issuerFromToken;
|
|
5268
|
-
const [jwtError, claims] =
|
|
6364
|
+
const [jwtError, claims] = catchError2(() => parseJWT(accessToken));
|
|
5269
6365
|
if (!jwtError && claims) {
|
|
5270
6366
|
const rawOrgId = claims.prtId ?? claims.organizationId ?? claims.prt_id;
|
|
5271
6367
|
if (typeof rawOrgId === "string" && rawOrgId.length > 0) {
|
|
@@ -5292,7 +6388,7 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
5292
6388
|
} catch {
|
|
5293
6389
|
return;
|
|
5294
6390
|
} finally {
|
|
5295
|
-
await
|
|
6391
|
+
await catchError2(() => withTimeout(proxy.CloseAsync(), CLOSE_TIMEOUT_MS));
|
|
5296
6392
|
}
|
|
5297
6393
|
};
|
|
5298
6394
|
|
|
@@ -5362,9 +6458,9 @@ var errorCode = (err) => {
|
|
|
5362
6458
|
}
|
|
5363
6459
|
return "EUNKNOWN";
|
|
5364
6460
|
};
|
|
5365
|
-
var probeAsync = async (
|
|
6461
|
+
var probeAsync = async (fs2, candidate) => {
|
|
5366
6462
|
try {
|
|
5367
|
-
const stats = await
|
|
6463
|
+
const stats = await fs2.stat(candidate);
|
|
5368
6464
|
if (stats === null) {
|
|
5369
6465
|
return { exists: false };
|
|
5370
6466
|
}
|
|
@@ -5391,9 +6487,9 @@ var probeAsync = async (fs, candidate) => {
|
|
|
5391
6487
|
}
|
|
5392
6488
|
};
|
|
5393
6489
|
var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
|
|
5394
|
-
const
|
|
5395
|
-
if (
|
|
5396
|
-
const probe2 = await probeAsync(
|
|
6490
|
+
const fs2 = getFileSystem();
|
|
6491
|
+
if (fs2.path.isAbsolute(envFilePath)) {
|
|
6492
|
+
const probe2 = await probeAsync(fs2, envFilePath);
|
|
5397
6493
|
return probe2.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
|
|
5398
6494
|
exists: false,
|
|
5399
6495
|
absolutePath: envFilePath,
|
|
@@ -5401,11 +6497,11 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opt
|
|
|
5401
6497
|
...probe2.unusable ? { unusable: probe2.unusable } : {}
|
|
5402
6498
|
};
|
|
5403
6499
|
}
|
|
5404
|
-
const cwd = opts?.cwd ??
|
|
6500
|
+
const cwd = opts?.cwd ?? fs2.env.cwd();
|
|
5405
6501
|
let searchDir = cwd;
|
|
5406
6502
|
while (true) {
|
|
5407
|
-
const candidate =
|
|
5408
|
-
const probe2 = await probeAsync(
|
|
6503
|
+
const candidate = fs2.path.join(searchDir, envFilePath);
|
|
6504
|
+
const probe2 = await probeAsync(fs2, candidate);
|
|
5409
6505
|
if (probe2.exists) {
|
|
5410
6506
|
return {
|
|
5411
6507
|
exists: true,
|
|
@@ -5413,14 +6509,14 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opt
|
|
|
5413
6509
|
source: searchDir === cwd ? "cwd" : "ancestor"
|
|
5414
6510
|
};
|
|
5415
6511
|
}
|
|
5416
|
-
const parentDir =
|
|
6512
|
+
const parentDir = fs2.path.dirname(searchDir);
|
|
5417
6513
|
if (parentDir === searchDir) {
|
|
5418
6514
|
break;
|
|
5419
6515
|
}
|
|
5420
6516
|
searchDir = parentDir;
|
|
5421
6517
|
}
|
|
5422
|
-
const homePath =
|
|
5423
|
-
const probe = await probeAsync(
|
|
6518
|
+
const homePath = fs2.path.join(fs2.env.homedir(), envFilePath);
|
|
6519
|
+
const probe = await probeAsync(fs2, homePath);
|
|
5424
6520
|
if (probe.exists) {
|
|
5425
6521
|
return { exists: true, absolutePath: homePath, source: "home" };
|
|
5426
6522
|
}
|
|
@@ -5442,12 +6538,12 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
|
|
|
5442
6538
|
};
|
|
5443
6539
|
};
|
|
5444
6540
|
var loadEnvFileAsync = async ({ envPath }) => {
|
|
5445
|
-
const
|
|
5446
|
-
const absolutePath =
|
|
5447
|
-
if (!await
|
|
6541
|
+
const fs2 = getFileSystem();
|
|
6542
|
+
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
|
|
6543
|
+
if (!await fs2.exists(absolutePath)) {
|
|
5448
6544
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
5449
6545
|
}
|
|
5450
|
-
const content = await
|
|
6546
|
+
const content = await fs2.readFile(absolutePath, "utf-8");
|
|
5451
6547
|
if (content === null) {
|
|
5452
6548
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
5453
6549
|
}
|
|
@@ -5476,10 +6572,10 @@ var saveEnvFileAsync = async ({
|
|
|
5476
6572
|
data,
|
|
5477
6573
|
merge = true
|
|
5478
6574
|
}) => {
|
|
5479
|
-
const
|
|
5480
|
-
const absolutePath =
|
|
6575
|
+
const fs2 = getFileSystem();
|
|
6576
|
+
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.homedir(), envPath);
|
|
5481
6577
|
let existingData = {};
|
|
5482
|
-
if (merge && await
|
|
6578
|
+
if (merge && await fs2.exists(absolutePath)) {
|
|
5483
6579
|
try {
|
|
5484
6580
|
existingData = await loadEnvFileAsync({ envPath: absolutePath });
|
|
5485
6581
|
} catch {}
|
|
@@ -5497,11 +6593,11 @@ var saveEnvFileAsync = async ({
|
|
|
5497
6593
|
const content = `${lines.join(`
|
|
5498
6594
|
`)}
|
|
5499
6595
|
`;
|
|
5500
|
-
const dir =
|
|
5501
|
-
await
|
|
6596
|
+
const dir = fs2.path.dirname(absolutePath);
|
|
6597
|
+
await fs2.mkdir(dir);
|
|
5502
6598
|
const tempPath = `${absolutePath}.tmp`;
|
|
5503
|
-
await
|
|
5504
|
-
await
|
|
6599
|
+
await fs2.writeFile(tempPath, content);
|
|
6600
|
+
await fs2.rename(tempPath, absolutePath);
|
|
5505
6601
|
};
|
|
5506
6602
|
|
|
5507
6603
|
// ../auth/src/loginStatus.ts
|
|
@@ -5615,11 +6711,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
|
|
|
5615
6711
|
return { credentials };
|
|
5616
6712
|
}
|
|
5617
6713
|
async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
|
|
5618
|
-
const
|
|
5619
|
-
const globalPath =
|
|
6714
|
+
const fs2 = getFs();
|
|
6715
|
+
const globalPath = fs2.path.join(fs2.env.homedir(), envFilePath);
|
|
5620
6716
|
if (absolutePath === globalPath)
|
|
5621
6717
|
return;
|
|
5622
|
-
if (!await
|
|
6718
|
+
if (!await fs2.exists(globalPath))
|
|
5623
6719
|
return;
|
|
5624
6720
|
try {
|
|
5625
6721
|
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
@@ -6021,6 +7117,6 @@ var TENANT_SELECTION_CODES = new Set([
|
|
|
6021
7117
|
TENANT_SELECTION_REQUIRED_CODE,
|
|
6022
7118
|
INVALID_TENANT_CODE
|
|
6023
7119
|
]);
|
|
6024
|
-
export {
|
|
7120
|
+
export { catchError, extractErrorMessage, extractErrorMessageSync, RESULTS, OutputFormatter, classifiedFailure, Command, Option, processContext, isGuid, createHiddenDeprecatedTenantOption, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, getLoginStatusAsync, getAuthContext };
|
|
6025
7121
|
|
|
6026
|
-
//# debugId=
|
|
7122
|
+
//# debugId=E15459F05D16B58264756E2164756E21
|