@uipath/insights-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/{index-2fj08e7n.js → index-gpd94m28.js} +27 -27
- package/dist/{index-w03qc9m8.js → index-sby22td6.js} +4 -4
- package/dist/index.js +3 -6
- package/dist/{js-yaml-4ypbq2tt.js → js-yaml-88tdqrtd.js} +27 -19
- package/dist/{tool-0v6na3yp.js → tool-1de529jm.js} +9 -7
- package/dist/{tool-xmkb1ctj.js → tool-dcpxje5e.js} +2298 -699
- package/dist/tool.js +5 -8
- package/package.json +2 -2
- 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();
|
|
@@ -2112,7 +2100,7 @@ var require_commander = __commonJS((exports) => {
|
|
|
2112
2100
|
var package_default = {
|
|
2113
2101
|
name: "@uipath/insights-tool",
|
|
2114
2102
|
license: "MIT",
|
|
2115
|
-
version: "1.
|
|
2103
|
+
version: "1.202.0-preview.136",
|
|
2116
2104
|
description: "Query UiPath Insights data — jobs, failures, and performance metrics.",
|
|
2117
2105
|
private: false,
|
|
2118
2106
|
repository: {
|
|
@@ -2153,123 +2141,402 @@ var package_default = {
|
|
|
2153
2141
|
}
|
|
2154
2142
|
};
|
|
2155
2143
|
|
|
2156
|
-
// ../
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2144
|
+
// ../filesystem/src/node.ts
|
|
2145
|
+
import { randomUUID } from "node:crypto";
|
|
2146
|
+
import { existsSync } from "node:fs";
|
|
2147
|
+
import * as fs from "node:fs/promises";
|
|
2148
|
+
import * as os from "node:os";
|
|
2149
|
+
import * as path from "node:path";
|
|
2150
|
+
var LOCK_HEARTBEAT_MS = 5000;
|
|
2151
|
+
var LOCK_STALE_MS = 15000;
|
|
2152
|
+
var LOCK_MAX_WAIT_MS = 20000;
|
|
2153
|
+
var LOCK_MAX_HOLD_MS = 60000;
|
|
2154
|
+
var LOCK_RETRY_MIN_MS = 100;
|
|
2155
|
+
var LOCK_RETRY_JITTER_MS = 200;
|
|
2156
|
+
|
|
2157
|
+
class NodeFileSystem {
|
|
2158
|
+
path = {
|
|
2159
|
+
join: path.join,
|
|
2160
|
+
resolve: path.resolve,
|
|
2161
|
+
relative: path.relative,
|
|
2162
|
+
dirname: path.dirname,
|
|
2163
|
+
isAbsolute: path.isAbsolute,
|
|
2164
|
+
basename: path.basename
|
|
2165
|
+
};
|
|
2166
|
+
env = {
|
|
2167
|
+
cwd: process.cwd,
|
|
2168
|
+
homedir: os.homedir,
|
|
2169
|
+
tmpdir: os.tmpdir,
|
|
2170
|
+
getenv: (key) => process.env[key]
|
|
2171
|
+
};
|
|
2172
|
+
utils = {
|
|
2173
|
+
open: async (url) => {
|
|
2174
|
+
const { default: open } = await import("./index-sby22td6.js");
|
|
2175
|
+
await open(url);
|
|
2176
|
+
}
|
|
2177
|
+
};
|
|
2178
|
+
async readFile(path2, options) {
|
|
2179
|
+
try {
|
|
2180
|
+
if (options) {
|
|
2181
|
+
return await fs.readFile(path2, "utf-8");
|
|
2182
|
+
}
|
|
2183
|
+
return await fs.readFile(path2);
|
|
2184
|
+
} catch (error) {
|
|
2185
|
+
if (this.isEnoent(error))
|
|
2186
|
+
return null;
|
|
2187
|
+
throw error;
|
|
2188
|
+
}
|
|
2163
2189
|
}
|
|
2164
|
-
|
|
2165
|
-
const
|
|
2166
|
-
if (
|
|
2167
|
-
|
|
2190
|
+
async writeFile(filePath, data) {
|
|
2191
|
+
const dir = path.dirname(filePath);
|
|
2192
|
+
if (dir) {
|
|
2193
|
+
await fs.mkdir(dir, { recursive: true });
|
|
2168
2194
|
}
|
|
2169
|
-
|
|
2170
|
-
} catch (error) {
|
|
2171
|
-
return [
|
|
2172
|
-
error instanceof Error ? error : new Error(String(error)),
|
|
2173
|
-
undefined
|
|
2174
|
-
];
|
|
2195
|
+
await fs.writeFile(filePath, data);
|
|
2175
2196
|
}
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
undefined
|
|
2181
|
-
]);
|
|
2182
|
-
}
|
|
2183
|
-
|
|
2184
|
-
// ../common/src/error-handler.ts
|
|
2185
|
-
var NETWORK_ERROR_CODES = new Set([
|
|
2186
|
-
"ECONNREFUSED",
|
|
2187
|
-
"ECONNRESET",
|
|
2188
|
-
"ENOTFOUND",
|
|
2189
|
-
"EAI_AGAIN",
|
|
2190
|
-
"ETIMEDOUT",
|
|
2191
|
-
"EPIPE",
|
|
2192
|
-
"EHOSTUNREACH",
|
|
2193
|
-
"ENETUNREACH",
|
|
2194
|
-
"EAI_FAIL"
|
|
2195
|
-
]);
|
|
2196
|
-
var TLS_ERROR_CODES = new Set([
|
|
2197
|
-
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
2198
|
-
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
2199
|
-
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
2200
|
-
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
2201
|
-
"UNABLE_TO_GET_ISSUER_CERT",
|
|
2202
|
-
"CERT_HAS_EXPIRED",
|
|
2203
|
-
"CERT_UNTRUSTED",
|
|
2204
|
-
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
2205
|
-
]);
|
|
2206
|
-
var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
|
|
2207
|
-
var NETWORK_INSTRUCTIONS = "Could not reach the UiPath service. Check your network connection and " + "VPN, confirm any HTTP_PROXY/HTTPS_PROXY/NO_PROXY settings are correct, " + "then retry.";
|
|
2208
|
-
var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
|
|
2209
|
-
function describeConnectivityError(error) {
|
|
2210
|
-
for (const cur of walkErrorGraph(error)) {
|
|
2211
|
-
const code = typeof cur.code === "string" ? cur.code : undefined;
|
|
2212
|
-
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
2213
|
-
if (code && TLS_ERROR_CODES.has(code)) {
|
|
2214
|
-
return {
|
|
2215
|
-
code,
|
|
2216
|
-
kind: "tls",
|
|
2217
|
-
message: message ?? code,
|
|
2218
|
-
instructions: TLS_INSTRUCTIONS
|
|
2219
|
-
};
|
|
2197
|
+
async appendFile(filePath, data) {
|
|
2198
|
+
const dir = path.dirname(filePath);
|
|
2199
|
+
if (dir) {
|
|
2200
|
+
await fs.mkdir(dir, { recursive: true });
|
|
2220
2201
|
}
|
|
2221
|
-
|
|
2202
|
+
await fs.appendFile(filePath, data);
|
|
2203
|
+
}
|
|
2204
|
+
async readdir(dirPath) {
|
|
2205
|
+
try {
|
|
2206
|
+
return await fs.readdir(dirPath);
|
|
2207
|
+
} catch (error) {
|
|
2208
|
+
if (this.isEnoent(error))
|
|
2209
|
+
return [];
|
|
2210
|
+
throw error;
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
async stat(filePath) {
|
|
2214
|
+
try {
|
|
2215
|
+
const stats = await fs.stat(filePath);
|
|
2222
2216
|
return {
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2217
|
+
isFile: () => stats.isFile(),
|
|
2218
|
+
isDirectory: () => stats.isDirectory(),
|
|
2219
|
+
size: stats.size,
|
|
2220
|
+
mtimeMs: stats.mtimeMs
|
|
2227
2221
|
};
|
|
2222
|
+
} catch (error) {
|
|
2223
|
+
if (this.isEnoent(error))
|
|
2224
|
+
return null;
|
|
2225
|
+
throw error;
|
|
2228
2226
|
}
|
|
2229
2227
|
}
|
|
2230
|
-
|
|
2228
|
+
async exists(filePath) {
|
|
2229
|
+
return existsSync(filePath);
|
|
2230
|
+
}
|
|
2231
|
+
async mkdir(dirPath) {
|
|
2232
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
2233
|
+
}
|
|
2234
|
+
async acquireLock(lockPath) {
|
|
2235
|
+
const canonicalPath = await this.canonicalizeLockTarget(lockPath);
|
|
2236
|
+
const lockFile = `${canonicalPath}.lock`;
|
|
2237
|
+
const ownerId = randomUUID();
|
|
2238
|
+
const start = Date.now();
|
|
2239
|
+
while (true) {
|
|
2240
|
+
try {
|
|
2241
|
+
await fs.writeFile(lockFile, ownerId, { flag: "wx" });
|
|
2242
|
+
return this.createLockRelease(lockFile, ownerId);
|
|
2243
|
+
} catch (error) {
|
|
2244
|
+
if (!this.hasErrnoCode(error, "EEXIST")) {
|
|
2245
|
+
throw error;
|
|
2246
|
+
}
|
|
2247
|
+
const stats = await fs.stat(lockFile).catch(() => null);
|
|
2248
|
+
if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
|
|
2249
|
+
const reclaimed = await fs.rm(lockFile, { force: true }).then(() => true).catch(() => false);
|
|
2250
|
+
if (reclaimed)
|
|
2251
|
+
continue;
|
|
2252
|
+
}
|
|
2253
|
+
if (Date.now() - start > LOCK_MAX_WAIT_MS) {
|
|
2254
|
+
throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
|
|
2255
|
+
}
|
|
2256
|
+
await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
async canonicalizeLockTarget(lockPath) {
|
|
2261
|
+
const absolute = path.resolve(lockPath);
|
|
2262
|
+
const fullReal = await fs.realpath(absolute).catch(() => null);
|
|
2263
|
+
if (fullReal)
|
|
2264
|
+
return fullReal;
|
|
2265
|
+
const parent = path.dirname(absolute);
|
|
2266
|
+
const base = path.basename(absolute);
|
|
2267
|
+
const canonicalParent = await fs.realpath(parent).catch(() => parent);
|
|
2268
|
+
return path.join(canonicalParent, base);
|
|
2269
|
+
}
|
|
2270
|
+
createLockRelease(lockFile, ownerId) {
|
|
2271
|
+
const heartbeatStart = Date.now();
|
|
2272
|
+
let heartbeatTimer;
|
|
2273
|
+
let stopped = false;
|
|
2274
|
+
const stopHeartbeat = () => {
|
|
2275
|
+
stopped = true;
|
|
2276
|
+
if (heartbeatTimer)
|
|
2277
|
+
clearTimeout(heartbeatTimer);
|
|
2278
|
+
};
|
|
2279
|
+
const scheduleNextHeartbeat = () => {
|
|
2280
|
+
if (stopped)
|
|
2281
|
+
return;
|
|
2282
|
+
if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) {
|
|
2283
|
+
stopped = true;
|
|
2284
|
+
return;
|
|
2285
|
+
}
|
|
2286
|
+
heartbeatTimer = setTimeout(() => {
|
|
2287
|
+
runHeartbeat();
|
|
2288
|
+
}, LOCK_HEARTBEAT_MS);
|
|
2289
|
+
heartbeatTimer.unref?.();
|
|
2290
|
+
};
|
|
2291
|
+
const runHeartbeat = async () => {
|
|
2292
|
+
if (stopped)
|
|
2293
|
+
return;
|
|
2294
|
+
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
2295
|
+
if (stopped)
|
|
2296
|
+
return;
|
|
2297
|
+
if (current !== ownerId) {
|
|
2298
|
+
stopped = true;
|
|
2299
|
+
return;
|
|
2300
|
+
}
|
|
2301
|
+
const now = Date.now() / 1000;
|
|
2302
|
+
await fs.utimes(lockFile, now, now).catch(() => {});
|
|
2303
|
+
scheduleNextHeartbeat();
|
|
2304
|
+
};
|
|
2305
|
+
scheduleNextHeartbeat();
|
|
2306
|
+
let released = false;
|
|
2307
|
+
return async () => {
|
|
2308
|
+
if (released)
|
|
2309
|
+
return;
|
|
2310
|
+
released = true;
|
|
2311
|
+
stopHeartbeat();
|
|
2312
|
+
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
2313
|
+
if (current === ownerId) {
|
|
2314
|
+
await fs.rm(lockFile, { force: true });
|
|
2315
|
+
}
|
|
2316
|
+
};
|
|
2317
|
+
}
|
|
2318
|
+
async rm(filePath) {
|
|
2319
|
+
await fs.rm(filePath, { recursive: true, force: true });
|
|
2320
|
+
}
|
|
2321
|
+
async rename(oldPath, newPath) {
|
|
2322
|
+
await fs.rename(oldPath, newPath);
|
|
2323
|
+
}
|
|
2324
|
+
async realpath(filePath) {
|
|
2325
|
+
try {
|
|
2326
|
+
return await fs.realpath(filePath);
|
|
2327
|
+
} catch (error) {
|
|
2328
|
+
if (this.isEnoent(error))
|
|
2329
|
+
return filePath;
|
|
2330
|
+
throw error;
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
async getTempDir() {
|
|
2334
|
+
return await fs.mkdtemp(path.join(os.tmpdir(), "uipath-fs-"));
|
|
2335
|
+
}
|
|
2336
|
+
async copyDirectory(sourcePath, destPath) {
|
|
2337
|
+
const sourceStats = await this.stat(sourcePath);
|
|
2338
|
+
if (!sourceStats) {
|
|
2339
|
+
throw new Error(`Source directory does not exist: ${sourcePath}`);
|
|
2340
|
+
}
|
|
2341
|
+
if (!sourceStats.isDirectory()) {
|
|
2342
|
+
throw new Error(`Source path is not a directory: ${sourcePath}`);
|
|
2343
|
+
}
|
|
2344
|
+
await this.mkdir(destPath);
|
|
2345
|
+
const entries = await this.readdir(sourcePath);
|
|
2346
|
+
for (const entry of entries) {
|
|
2347
|
+
const srcEntry = path.join(sourcePath, entry);
|
|
2348
|
+
const destEntry = path.join(destPath, entry);
|
|
2349
|
+
const entryStats = await this.stat(srcEntry);
|
|
2350
|
+
if (!entryStats)
|
|
2351
|
+
continue;
|
|
2352
|
+
if (entryStats.isDirectory()) {
|
|
2353
|
+
await this.copyDirectory(srcEntry, destEntry);
|
|
2354
|
+
} else if (entryStats.isFile()) {
|
|
2355
|
+
const content = await this.readFile(srcEntry);
|
|
2356
|
+
if (content !== null) {
|
|
2357
|
+
await this.writeFile(destEntry, content);
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
isEnoent(error) {
|
|
2363
|
+
return this.hasErrnoCode(error, "ENOENT");
|
|
2364
|
+
}
|
|
2365
|
+
hasErrnoCode(error, code) {
|
|
2366
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
2367
|
+
}
|
|
2231
2368
|
}
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2369
|
+
|
|
2370
|
+
// ../filesystem/src/index.ts
|
|
2371
|
+
var fsInstance = new NodeFileSystem;
|
|
2372
|
+
var getFileSystem = () => fsInstance;
|
|
2373
|
+
|
|
2374
|
+
// ../common/src/telemetry/pseudonymize.ts
|
|
2375
|
+
var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
|
|
2376
|
+
var PSEUDONYM_HEX_LENGTH = 32;
|
|
2377
|
+
var SHA256_K = new Uint32Array([
|
|
2378
|
+
1116352408,
|
|
2379
|
+
1899447441,
|
|
2380
|
+
3049323471,
|
|
2381
|
+
3921009573,
|
|
2382
|
+
961987163,
|
|
2383
|
+
1508970993,
|
|
2384
|
+
2453635748,
|
|
2385
|
+
2870763221,
|
|
2386
|
+
3624381080,
|
|
2387
|
+
310598401,
|
|
2388
|
+
607225278,
|
|
2389
|
+
1426881987,
|
|
2390
|
+
1925078388,
|
|
2391
|
+
2162078206,
|
|
2392
|
+
2614888103,
|
|
2393
|
+
3248222580,
|
|
2394
|
+
3835390401,
|
|
2395
|
+
4022224774,
|
|
2396
|
+
264347078,
|
|
2397
|
+
604807628,
|
|
2398
|
+
770255983,
|
|
2399
|
+
1249150122,
|
|
2400
|
+
1555081692,
|
|
2401
|
+
1996064986,
|
|
2402
|
+
2554220882,
|
|
2403
|
+
2821834349,
|
|
2404
|
+
2952996808,
|
|
2405
|
+
3210313671,
|
|
2406
|
+
3336571891,
|
|
2407
|
+
3584528711,
|
|
2408
|
+
113926993,
|
|
2409
|
+
338241895,
|
|
2410
|
+
666307205,
|
|
2411
|
+
773529912,
|
|
2412
|
+
1294757372,
|
|
2413
|
+
1396182291,
|
|
2414
|
+
1695183700,
|
|
2415
|
+
1986661051,
|
|
2416
|
+
2177026350,
|
|
2417
|
+
2456956037,
|
|
2418
|
+
2730485921,
|
|
2419
|
+
2820302411,
|
|
2420
|
+
3259730800,
|
|
2421
|
+
3345764771,
|
|
2422
|
+
3516065817,
|
|
2423
|
+
3600352804,
|
|
2424
|
+
4094571909,
|
|
2425
|
+
275423344,
|
|
2426
|
+
430227734,
|
|
2427
|
+
506948616,
|
|
2428
|
+
659060556,
|
|
2429
|
+
883997877,
|
|
2430
|
+
958139571,
|
|
2431
|
+
1322822218,
|
|
2432
|
+
1537002063,
|
|
2433
|
+
1747873779,
|
|
2434
|
+
1955562222,
|
|
2435
|
+
2024104815,
|
|
2436
|
+
2227730452,
|
|
2437
|
+
2361852424,
|
|
2438
|
+
2428436474,
|
|
2439
|
+
2756734187,
|
|
2440
|
+
3204031479,
|
|
2441
|
+
3329325298
|
|
2442
|
+
]);
|
|
2443
|
+
var SHA256_INITIAL_STATE = new Uint32Array([
|
|
2444
|
+
1779033703,
|
|
2445
|
+
3144134277,
|
|
2446
|
+
1013904242,
|
|
2447
|
+
2773480762,
|
|
2448
|
+
1359893119,
|
|
2449
|
+
2600822924,
|
|
2450
|
+
528734635,
|
|
2451
|
+
1541459225
|
|
2452
|
+
]);
|
|
2453
|
+
function rotr(value, bits) {
|
|
2454
|
+
return (value >>> bits | value << 32 - bits) >>> 0;
|
|
2455
|
+
}
|
|
2456
|
+
function sha256Hex(input) {
|
|
2457
|
+
const bytes = new TextEncoder().encode(input);
|
|
2458
|
+
const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
|
|
2459
|
+
const buffer = new Uint8Array(paddedLength);
|
|
2460
|
+
buffer.set(bytes);
|
|
2461
|
+
buffer[bytes.length] = 128;
|
|
2462
|
+
const view = new DataView(buffer.buffer);
|
|
2463
|
+
const bitLength = bytes.length * 8;
|
|
2464
|
+
view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296));
|
|
2465
|
+
view.setUint32(paddedLength - 4, bitLength >>> 0);
|
|
2466
|
+
const state = SHA256_INITIAL_STATE.slice();
|
|
2467
|
+
const schedule = new Uint32Array(64);
|
|
2468
|
+
for (let offset = 0;offset < paddedLength; offset += 64) {
|
|
2469
|
+
for (let i = 0;i < 16; i++) {
|
|
2470
|
+
schedule[i] = view.getUint32(offset + i * 4);
|
|
2471
|
+
}
|
|
2472
|
+
for (let i = 16;i < 64; i++) {
|
|
2473
|
+
const x = schedule[i - 15];
|
|
2474
|
+
const y = schedule[i - 2];
|
|
2475
|
+
const s0 = (rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3) >>> 0;
|
|
2476
|
+
const s1 = (rotr(y, 17) ^ rotr(y, 19) ^ y >>> 10) >>> 0;
|
|
2477
|
+
schedule[i] = schedule[i - 16] + s0 + schedule[i - 7] + s1 >>> 0;
|
|
2478
|
+
}
|
|
2479
|
+
let a = state[0];
|
|
2480
|
+
let b = state[1];
|
|
2481
|
+
let c = state[2];
|
|
2482
|
+
let d = state[3];
|
|
2483
|
+
let e = state[4];
|
|
2484
|
+
let f = state[5];
|
|
2485
|
+
let g = state[6];
|
|
2486
|
+
let h = state[7];
|
|
2487
|
+
for (let i = 0;i < 64; i++) {
|
|
2488
|
+
const s1 = (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) >>> 0;
|
|
2489
|
+
const ch = (e & f ^ ~e & g) >>> 0;
|
|
2490
|
+
const temp1 = h + s1 + ch + SHA256_K[i] + schedule[i] >>> 0;
|
|
2491
|
+
const s0 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) >>> 0;
|
|
2492
|
+
const maj = (a & b ^ a & c ^ b & c) >>> 0;
|
|
2493
|
+
const temp2 = s0 + maj >>> 0;
|
|
2494
|
+
h = g;
|
|
2495
|
+
g = f;
|
|
2496
|
+
f = e;
|
|
2497
|
+
e = d + temp1 >>> 0;
|
|
2498
|
+
d = c;
|
|
2499
|
+
c = b;
|
|
2500
|
+
b = a;
|
|
2501
|
+
a = temp1 + temp2 >>> 0;
|
|
2502
|
+
}
|
|
2503
|
+
state[0] = state[0] + a >>> 0;
|
|
2504
|
+
state[1] = state[1] + b >>> 0;
|
|
2505
|
+
state[2] = state[2] + c >>> 0;
|
|
2506
|
+
state[3] = state[3] + d >>> 0;
|
|
2507
|
+
state[4] = state[4] + e >>> 0;
|
|
2508
|
+
state[5] = state[5] + f >>> 0;
|
|
2509
|
+
state[6] = state[6] + g >>> 0;
|
|
2510
|
+
state[7] = state[7] + h >>> 0;
|
|
2248
2511
|
}
|
|
2249
|
-
|
|
2512
|
+
let hex = "";
|
|
2513
|
+
for (const word of state) {
|
|
2514
|
+
hex += word.toString(16).padStart(8, "0");
|
|
2515
|
+
}
|
|
2516
|
+
return hex;
|
|
2517
|
+
}
|
|
2518
|
+
function resolveSha256Hex() {
|
|
2519
|
+
try {
|
|
2520
|
+
const nodeCrypto = __require("node:crypto");
|
|
2521
|
+
const createHash = nodeCrypto?.createHash;
|
|
2522
|
+
if (typeof createHash !== "function") {
|
|
2523
|
+
return sha256Hex;
|
|
2524
|
+
}
|
|
2525
|
+
const native = (input) => createHash("sha256").update(input, "utf8").digest("hex");
|
|
2526
|
+
return native("abc") === sha256Hex("abc") ? native : sha256Hex;
|
|
2527
|
+
} catch {
|
|
2528
|
+
return sha256Hex;
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
var cachedSha256Hex;
|
|
2532
|
+
function digest(input) {
|
|
2533
|
+
cachedSha256Hex ??= resolveSha256Hex();
|
|
2534
|
+
return cachedSha256Hex(input);
|
|
2535
|
+
}
|
|
2536
|
+
function pseudonymize(input) {
|
|
2537
|
+
return digest(`${PSEUDONYM_DOMAIN}${input}`).slice(0, PSEUDONYM_HEX_LENGTH);
|
|
2250
2538
|
}
|
|
2251
|
-
// ../../node_modules/commander/esm.mjs
|
|
2252
|
-
var import__ = __toESM(require_commander(), 1);
|
|
2253
|
-
var {
|
|
2254
|
-
program,
|
|
2255
|
-
createCommand,
|
|
2256
|
-
createArgument,
|
|
2257
|
-
createOption,
|
|
2258
|
-
CommanderError,
|
|
2259
|
-
InvalidArgumentError,
|
|
2260
|
-
InvalidOptionArgumentError,
|
|
2261
|
-
Command,
|
|
2262
|
-
Argument,
|
|
2263
|
-
Option,
|
|
2264
|
-
Help
|
|
2265
|
-
} = import__.default;
|
|
2266
2539
|
|
|
2267
|
-
// ../common/src/command-examples.ts
|
|
2268
|
-
var examplesByCommand = new WeakMap;
|
|
2269
|
-
Command.prototype.examples = function(examples) {
|
|
2270
|
-
examplesByCommand.set(this, examples);
|
|
2271
|
-
return this;
|
|
2272
|
-
};
|
|
2273
2540
|
// ../common/src/singleton.ts
|
|
2274
2541
|
var PREFIX = "@uipath/common/";
|
|
2275
2542
|
var _g = globalThis;
|
|
@@ -2300,82 +2567,480 @@ function singleton(ctorOrName) {
|
|
|
2300
2567
|
};
|
|
2301
2568
|
}
|
|
2302
2569
|
|
|
2303
|
-
// ../common/src/
|
|
2304
|
-
var
|
|
2305
|
-
function
|
|
2306
|
-
|
|
2570
|
+
// ../common/src/telemetry/supplied-values.ts
|
|
2571
|
+
var suppliedValuesSlot = singleton("TelemetrySuppliedArgumentValues");
|
|
2572
|
+
function activeEntries() {
|
|
2573
|
+
const existing = suppliedValuesSlot.get();
|
|
2574
|
+
return Array.isArray(existing) ? existing : [];
|
|
2575
|
+
}
|
|
2576
|
+
var MIN_SCRUBBABLE_LENGTH = 4;
|
|
2577
|
+
function recordSuppliedArgumentValues(values) {
|
|
2578
|
+
const flat = [];
|
|
2579
|
+
const push = (value) => {
|
|
2580
|
+
if (Array.isArray(value)) {
|
|
2581
|
+
for (const item of value) {
|
|
2582
|
+
push(item);
|
|
2583
|
+
}
|
|
2584
|
+
return;
|
|
2585
|
+
}
|
|
2586
|
+
if (typeof value === "string" && value.length >= MIN_SCRUBBABLE_LENGTH) {
|
|
2587
|
+
flat.push(value);
|
|
2588
|
+
}
|
|
2589
|
+
};
|
|
2590
|
+
push(values);
|
|
2591
|
+
const entry = { values: flat };
|
|
2592
|
+
suppliedValuesSlot.set([...activeEntries(), entry]);
|
|
2593
|
+
return entry;
|
|
2307
2594
|
}
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
return this.command(nameAndArgs, opts);
|
|
2311
|
-
}
|
|
2312
|
-
return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
|
|
2313
|
-
};
|
|
2314
|
-
|
|
2315
|
-
// ../common/src/output-context.ts
|
|
2316
|
-
function createStorage() {
|
|
2317
|
-
const [error, mod] = catchError2(() => __require("node:async_hooks"));
|
|
2318
|
-
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
2319
|
-
return {
|
|
2320
|
-
getStore: () => {
|
|
2321
|
-
return;
|
|
2322
|
-
},
|
|
2323
|
-
run: (_store, fn) => fn()
|
|
2324
|
-
};
|
|
2325
|
-
}
|
|
2326
|
-
return new mod.AsyncLocalStorage;
|
|
2595
|
+
function releaseSuppliedArgumentValues(entry) {
|
|
2596
|
+
suppliedValuesSlot.set(activeEntries().filter((held) => held !== entry));
|
|
2327
2597
|
}
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
writeLog: (str) => process.stdout.write(str),
|
|
2335
|
-
capabilities: {
|
|
2336
|
-
isInteractive: false,
|
|
2337
|
-
canReadInput: false,
|
|
2338
|
-
supportsColor: false,
|
|
2339
|
-
outputWidth: 80
|
|
2598
|
+
function getSuppliedArgumentValues() {
|
|
2599
|
+
const all = new Set;
|
|
2600
|
+
for (const entry of activeEntries()) {
|
|
2601
|
+
for (const value of entry.values) {
|
|
2602
|
+
all.add(value);
|
|
2603
|
+
}
|
|
2340
2604
|
}
|
|
2341
|
-
|
|
2342
|
-
function getOutputSink() {
|
|
2343
|
-
return outputStorage.getStore() ?? sinkSlot.get() ?? CONSOLE_FALLBACK;
|
|
2605
|
+
return [...all].sort((a, b) => b.length - a.length);
|
|
2344
2606
|
}
|
|
2345
2607
|
|
|
2346
|
-
// ../common/src/
|
|
2347
|
-
var
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
function
|
|
2352
|
-
return
|
|
2608
|
+
// ../common/src/telemetry/pii-redactor.ts
|
|
2609
|
+
var REDACTED = "[REDACTED]";
|
|
2610
|
+
var MAX_VALUE_LENGTH = 280;
|
|
2611
|
+
var MAX_STACK_LENGTH = 4096;
|
|
2612
|
+
var MAX_SCAN_LENGTH = MAX_STACK_LENGTH;
|
|
2613
|
+
function truncate(value, maxLength) {
|
|
2614
|
+
return value.length > maxLength ? `${value.slice(0, maxLength)}…` : value;
|
|
2353
2615
|
}
|
|
2354
|
-
var
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2616
|
+
var SENSITIVE_NAME_TOKENS = new Set([
|
|
2617
|
+
"token",
|
|
2618
|
+
"tokens",
|
|
2619
|
+
"secret",
|
|
2620
|
+
"secrets",
|
|
2621
|
+
"password",
|
|
2622
|
+
"passwords",
|
|
2623
|
+
"pwd",
|
|
2624
|
+
"credential",
|
|
2625
|
+
"credentials",
|
|
2626
|
+
"auth",
|
|
2627
|
+
"authentication",
|
|
2628
|
+
"authorization",
|
|
2629
|
+
"authority",
|
|
2630
|
+
"cert",
|
|
2631
|
+
"certificate",
|
|
2632
|
+
"certificates"
|
|
2633
|
+
]);
|
|
2634
|
+
var SENSITIVE_KEY_PREFIXES = new Set([
|
|
2635
|
+
"api",
|
|
2636
|
+
"access",
|
|
2637
|
+
"client",
|
|
2638
|
+
"private",
|
|
2639
|
+
"public",
|
|
2640
|
+
"signing",
|
|
2641
|
+
"encryption",
|
|
2642
|
+
"session",
|
|
2643
|
+
"master",
|
|
2644
|
+
"shared",
|
|
2645
|
+
"root",
|
|
2646
|
+
"ssh",
|
|
2647
|
+
"rsa",
|
|
2648
|
+
"aes",
|
|
2649
|
+
"hmac",
|
|
2650
|
+
"oauth"
|
|
2651
|
+
]);
|
|
2652
|
+
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;
|
|
2653
|
+
var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
2654
|
+
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
2655
|
+
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
2656
|
+
var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
|
|
2657
|
+
var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
|
|
2658
|
+
var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
|
|
2659
|
+
var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
|
|
2660
|
+
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;
|
|
2661
|
+
var SOURCE_FILE_EXTENSIONS = new Set([
|
|
2662
|
+
"ts",
|
|
2663
|
+
"tsx",
|
|
2664
|
+
"js",
|
|
2665
|
+
"jsx",
|
|
2666
|
+
"mjs",
|
|
2667
|
+
"cjs",
|
|
2668
|
+
"cts",
|
|
2669
|
+
"mts",
|
|
2670
|
+
"py",
|
|
2671
|
+
"cs",
|
|
2672
|
+
"java",
|
|
2673
|
+
"go",
|
|
2674
|
+
"rs",
|
|
2675
|
+
"rb",
|
|
2676
|
+
"php",
|
|
2677
|
+
"sh",
|
|
2678
|
+
"ps1",
|
|
2679
|
+
"json",
|
|
2680
|
+
"jsonc",
|
|
2681
|
+
"yaml",
|
|
2682
|
+
"yml",
|
|
2683
|
+
"xml",
|
|
2684
|
+
"xaml",
|
|
2685
|
+
"md",
|
|
2686
|
+
"txt",
|
|
2687
|
+
"log",
|
|
2688
|
+
"css",
|
|
2689
|
+
"html",
|
|
2690
|
+
"htm",
|
|
2691
|
+
"csproj",
|
|
2692
|
+
"nuspec",
|
|
2693
|
+
"sql"
|
|
2694
|
+
]);
|
|
2695
|
+
var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
|
|
2696
|
+
var QUOTED_LITERAL_MAX_SPAN = 200;
|
|
2697
|
+
var QUOTED_LITERAL_PATTERN = new RegExp([
|
|
2698
|
+
`(?<![A-Za-z0-9])'(?:[^\\
|
|
2699
|
+
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?'(?![A-Za-z0-9])`,
|
|
2700
|
+
`(?<![A-Za-z0-9])"(?:[^\\
|
|
2701
|
+
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
|
|
2702
|
+
].join("|"), "g");
|
|
2703
|
+
var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
|
|
2704
|
+
var COLLAPSED_BODY = "{…}";
|
|
2705
|
+
var COLLAPSED_BODY_MARKER = "\x01body\x01";
|
|
2706
|
+
var MAX_BODY_NESTING = 8;
|
|
2707
|
+
function collapseJsonBodies(text) {
|
|
2708
|
+
let out = text;
|
|
2709
|
+
for (let pass = 0;pass < MAX_BODY_NESTING; pass++) {
|
|
2710
|
+
const next = out.replace(JSON_BODY_PATTERN, COLLAPSED_BODY_MARKER);
|
|
2711
|
+
if (next === out) {
|
|
2712
|
+
break;
|
|
2713
|
+
}
|
|
2714
|
+
out = next;
|
|
2715
|
+
}
|
|
2716
|
+
return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
|
|
2717
|
+
}
|
|
2718
|
+
var TRAILING_PROSE_PUNCT = /[.,;:!?)\]}>'"]+$/;
|
|
2719
|
+
function peelTrailingPunctuation(match) {
|
|
2720
|
+
const trailing = match.match(TRAILING_PROSE_PUNCT)?.[0] ?? "";
|
|
2721
|
+
return trailing ? [match.slice(0, -trailing.length), trailing] : [match, ""];
|
|
2722
|
+
}
|
|
2723
|
+
function redactUrl(raw) {
|
|
2724
|
+
try {
|
|
2725
|
+
const url = new URL(raw);
|
|
2726
|
+
return `${url.protocol}//${url.host}`;
|
|
2727
|
+
} catch {
|
|
2728
|
+
return `url#${pseudonymize(raw)}`;
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
2731
|
+
function redactValueDetectors(value, maxLength = MAX_VALUE_LENGTH) {
|
|
2732
|
+
let out = truncate(value, MAX_SCAN_LENGTH);
|
|
2733
|
+
out = out.replace(JWT_PATTERN, () => REDACTED);
|
|
2734
|
+
out = out.replace(URL_PATTERN, (match) => {
|
|
2735
|
+
const [core, trailing] = peelTrailingPunctuation(match);
|
|
2736
|
+
return `${redactUrl(core)}${trailing}`;
|
|
2737
|
+
});
|
|
2738
|
+
out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
|
|
2739
|
+
out = out.replace(UNC_PATH_PATTERN, (_match, before, path2) => {
|
|
2740
|
+
const [core, trailing] = peelTrailingPunctuation(path2);
|
|
2741
|
+
return `${before}unc#${pseudonymize(core)}${trailing}`;
|
|
2742
|
+
});
|
|
2743
|
+
out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
|
|
2744
|
+
out = out.replace(UUID_PATTERN, (match) => `uuid#${pseudonymize(match)}`);
|
|
2745
|
+
out = out.replace(HOST_PORT_PATTERN, (match) => {
|
|
2746
|
+
const split = match.lastIndexOf(":");
|
|
2747
|
+
const host = match.slice(0, split);
|
|
2748
|
+
const extension = host.slice(host.lastIndexOf(".") + 1).toLowerCase();
|
|
2749
|
+
if (SOURCE_FILE_EXTENSIONS.has(extension)) {
|
|
2750
|
+
return match;
|
|
2751
|
+
}
|
|
2752
|
+
return `host#${pseudonymize(host)}:${match.slice(split + 1)}`;
|
|
2753
|
+
});
|
|
2754
|
+
out = out.replace(PADDED_BASE64_PATTERN, () => REDACTED);
|
|
2755
|
+
out = out.replace(BASE64_WITH_PLUS_PATTERN, (match) => match.includes("+") ? REDACTED : match);
|
|
2756
|
+
out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
|
|
2757
|
+
return truncate(out, maxLength);
|
|
2758
|
+
}
|
|
2759
|
+
function redactSpanName(name) {
|
|
2760
|
+
return redactValueDetectors(truncate(name, MAX_SCAN_LENGTH).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`));
|
|
2761
|
+
}
|
|
2762
|
+
var HTTP_DEPENDENCY_NAME = /^([A-Z]+) (\/.*)$/s;
|
|
2763
|
+
function redactHttpDependencyName(name) {
|
|
2764
|
+
const parts = HTTP_DEPENDENCY_NAME.exec(name);
|
|
2765
|
+
if (!parts) {
|
|
2766
|
+
return redactMessage(name);
|
|
2767
|
+
}
|
|
2768
|
+
return `${parts[1]} ${redactMessage(parts[2])}`;
|
|
2769
|
+
}
|
|
2770
|
+
function redactMessage(value) {
|
|
2771
|
+
let out = collapseJsonBodies(truncate(value, MAX_SCAN_LENGTH)).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`);
|
|
2772
|
+
for (const supplied of getSuppliedArgumentValues()) {
|
|
2773
|
+
out = out.split(supplied).join(REDACTED);
|
|
2774
|
+
}
|
|
2775
|
+
return redactValueDetectors(out);
|
|
2776
|
+
}
|
|
2777
|
+
var MESSAGE_NAMES = new Set([
|
|
2778
|
+
"message",
|
|
2779
|
+
"errormessage",
|
|
2780
|
+
"errmessage",
|
|
2781
|
+
"error_message",
|
|
2782
|
+
"msg",
|
|
2783
|
+
"detail",
|
|
2784
|
+
"details",
|
|
2785
|
+
"reason",
|
|
2786
|
+
"instructions",
|
|
2787
|
+
"warning"
|
|
2788
|
+
]);
|
|
2789
|
+
function isFreeFormValue(name, value) {
|
|
2790
|
+
return MESSAGE_NAMES.has(name.toLowerCase()) || /['"{[]/.test(value);
|
|
2791
|
+
}
|
|
2792
|
+
function redactError(error) {
|
|
2793
|
+
const safe = new Error(redactMessage(error.message ?? ""));
|
|
2794
|
+
safe.name = error.name;
|
|
2795
|
+
safe.stack = typeof error.stack === "string" ? redactStack(error.stack) : undefined;
|
|
2796
|
+
return safe;
|
|
2797
|
+
}
|
|
2798
|
+
function redactStack(stack) {
|
|
2799
|
+
const bounded = truncate(stack, MAX_STACK_LENGTH);
|
|
2800
|
+
const firstBreak = bounded.indexOf(`
|
|
2801
|
+
`);
|
|
2802
|
+
if (firstBreak === -1) {
|
|
2803
|
+
return redactMessage(bounded);
|
|
2804
|
+
}
|
|
2805
|
+
return `${redactMessage(bounded.slice(0, firstBreak))}
|
|
2806
|
+
${redactValueDetectors(bounded.slice(firstBreak + 1), MAX_STACK_LENGTH)}`;
|
|
2807
|
+
}
|
|
2808
|
+
function nameTokens(name) {
|
|
2809
|
+
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);
|
|
2810
|
+
}
|
|
2811
|
+
function isSensitiveName(name) {
|
|
2812
|
+
const tokens = nameTokens(name);
|
|
2813
|
+
for (let i = 0;i < tokens.length; i++) {
|
|
2814
|
+
const token = tokens[i];
|
|
2815
|
+
if (SENSITIVE_NAME_TOKENS.has(token)) {
|
|
2816
|
+
return true;
|
|
2817
|
+
}
|
|
2818
|
+
if (token === "key" || token === "keys") {
|
|
2819
|
+
const prev = tokens[i - 1];
|
|
2820
|
+
if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
|
|
2821
|
+
return true;
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
return false;
|
|
2826
|
+
}
|
|
2827
|
+
function redactProperty(name, value) {
|
|
2828
|
+
if (value === undefined || value === null) {
|
|
2829
|
+
return;
|
|
2830
|
+
}
|
|
2831
|
+
if (isSensitiveName(name)) {
|
|
2832
|
+
return REDACTED;
|
|
2833
|
+
}
|
|
2834
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
2835
|
+
return value;
|
|
2836
|
+
}
|
|
2837
|
+
if (typeof value !== "string") {
|
|
2838
|
+
return "[OBJECT]";
|
|
2839
|
+
}
|
|
2840
|
+
return isFreeFormValue(name, value) ? redactMessage(value) : redactValueDetectors(value);
|
|
2841
|
+
}
|
|
2842
|
+
function redactProperties(properties) {
|
|
2843
|
+
const out = {};
|
|
2844
|
+
for (const [name, value] of Object.entries(properties)) {
|
|
2845
|
+
const redacted = redactProperty(name, value);
|
|
2846
|
+
if (redacted !== undefined) {
|
|
2847
|
+
out[name] = redacted;
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
return out;
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
// ../common/src/catch-error.ts
|
|
2854
|
+
var MAX_SERIALIZED_LENGTH = 500;
|
|
2855
|
+
var TRUNCATION_SUFFIX = "…(truncated)";
|
|
2856
|
+
var REDACTED2 = "[REDACTED]";
|
|
2857
|
+
function cap(text) {
|
|
2858
|
+
return text.length > MAX_SERIALIZED_LENGTH ? `${text.slice(0, MAX_SERIALIZED_LENGTH)}${TRUNCATION_SUFFIX}` : text;
|
|
2859
|
+
}
|
|
2860
|
+
function omitSensitive(key, value) {
|
|
2861
|
+
return key.length > 0 && isSensitiveName(key) ? REDACTED2 : value;
|
|
2862
|
+
}
|
|
2863
|
+
function describeThrownValue(value) {
|
|
2864
|
+
if (typeof value !== "object" || value === null) {
|
|
2865
|
+
return String(value);
|
|
2866
|
+
}
|
|
2867
|
+
let message;
|
|
2868
|
+
try {
|
|
2869
|
+
message = value.message;
|
|
2870
|
+
} catch {
|
|
2871
|
+
message = undefined;
|
|
2872
|
+
}
|
|
2873
|
+
if (typeof message === "string" && message.length > 0) {
|
|
2874
|
+
return cap(message);
|
|
2875
|
+
}
|
|
2876
|
+
try {
|
|
2877
|
+
const json = JSON.stringify(value, omitSensitive);
|
|
2878
|
+
if (json !== undefined) {
|
|
2879
|
+
return cap(json);
|
|
2880
|
+
}
|
|
2881
|
+
} catch {}
|
|
2882
|
+
return String(value);
|
|
2883
|
+
}
|
|
2884
|
+
function toError(error) {
|
|
2885
|
+
return error instanceof Error ? error : new Error(describeThrownValue(error), { cause: error });
|
|
2886
|
+
}
|
|
2887
|
+
function isPromiseLike(value) {
|
|
2888
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
2889
|
+
}
|
|
2890
|
+
function catchError(fnOrPromise) {
|
|
2891
|
+
if (isPromiseLike(fnOrPromise)) {
|
|
2892
|
+
return settlePromiseLike(fnOrPromise);
|
|
2893
|
+
}
|
|
2894
|
+
try {
|
|
2895
|
+
const result = fnOrPromise();
|
|
2896
|
+
if (isPromiseLike(result)) {
|
|
2897
|
+
return settlePromiseLike(result);
|
|
2898
|
+
}
|
|
2899
|
+
return [undefined, result];
|
|
2900
|
+
} catch (error) {
|
|
2901
|
+
return [toError(error), undefined];
|
|
2902
|
+
}
|
|
2903
|
+
}
|
|
2904
|
+
function settlePromiseLike(thenable) {
|
|
2905
|
+
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2908
|
+
// ../common/src/error-handler.ts
|
|
2909
|
+
var NETWORK_ERROR_CODES = new Set([
|
|
2910
|
+
"ECONNREFUSED",
|
|
2911
|
+
"ECONNRESET",
|
|
2912
|
+
"ENOTFOUND",
|
|
2913
|
+
"EAI_AGAIN",
|
|
2914
|
+
"ETIMEDOUT",
|
|
2915
|
+
"EPIPE",
|
|
2916
|
+
"EHOSTUNREACH",
|
|
2917
|
+
"ENETUNREACH",
|
|
2918
|
+
"EAI_FAIL"
|
|
2919
|
+
]);
|
|
2920
|
+
var TLS_ERROR_CODES = new Set([
|
|
2921
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
2922
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
2923
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
2924
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
2925
|
+
"UNABLE_TO_GET_ISSUER_CERT",
|
|
2926
|
+
"CERT_HAS_EXPIRED",
|
|
2927
|
+
"CERT_UNTRUSTED",
|
|
2928
|
+
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
2929
|
+
]);
|
|
2930
|
+
var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
|
|
2931
|
+
var NETWORK_INSTRUCTIONS = "Could not reach the UiPath service. Check your network connection and " + "VPN, confirm any HTTP_PROXY/HTTPS_PROXY/NO_PROXY settings are correct, " + "then retry.";
|
|
2932
|
+
var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
|
|
2933
|
+
function describeConnectivityError(error) {
|
|
2934
|
+
for (const cur of walkErrorGraph(error)) {
|
|
2935
|
+
const code = typeof cur.code === "string" ? cur.code : undefined;
|
|
2936
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
2937
|
+
if (code && TLS_ERROR_CODES.has(code)) {
|
|
2938
|
+
return {
|
|
2939
|
+
code,
|
|
2940
|
+
kind: "tls",
|
|
2941
|
+
message: message ?? code,
|
|
2942
|
+
instructions: TLS_INSTRUCTIONS
|
|
2943
|
+
};
|
|
2944
|
+
}
|
|
2945
|
+
if (code && NETWORK_ERROR_CODES.has(code)) {
|
|
2946
|
+
return {
|
|
2947
|
+
code,
|
|
2948
|
+
kind: "network",
|
|
2949
|
+
message: message ?? code,
|
|
2950
|
+
instructions: NETWORK_INSTRUCTIONS
|
|
2951
|
+
};
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
return;
|
|
2955
|
+
}
|
|
2956
|
+
function* walkErrorGraph(error) {
|
|
2957
|
+
const queue = [error];
|
|
2958
|
+
const seen = new Set;
|
|
2959
|
+
for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
|
|
2960
|
+
const current = queue.shift();
|
|
2961
|
+
if (current === null || typeof current !== "object")
|
|
2962
|
+
continue;
|
|
2963
|
+
if (seen.has(current))
|
|
2964
|
+
continue;
|
|
2965
|
+
seen.add(current);
|
|
2966
|
+
const cur = current;
|
|
2967
|
+
yield cur;
|
|
2968
|
+
if (cur.cause !== undefined)
|
|
2969
|
+
queue.push(cur.cause);
|
|
2970
|
+
if (Array.isArray(cur.errors))
|
|
2971
|
+
queue.push(...cur.errors);
|
|
2972
|
+
}
|
|
2973
|
+
return;
|
|
2974
|
+
}
|
|
2975
|
+
// ../common/src/exit-code.ts
|
|
2976
|
+
function setExitCode(code) {
|
|
2977
|
+
process.exitCode = code;
|
|
2978
|
+
}
|
|
2979
|
+
|
|
2980
|
+
// ../common/src/output-context.ts
|
|
2981
|
+
function createStorage() {
|
|
2982
|
+
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
2983
|
+
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
2984
|
+
return {
|
|
2985
|
+
getStore: () => {
|
|
2986
|
+
return;
|
|
2987
|
+
},
|
|
2988
|
+
run: (_store, fn) => fn()
|
|
2989
|
+
};
|
|
2990
|
+
}
|
|
2991
|
+
return new mod.AsyncLocalStorage;
|
|
2992
|
+
}
|
|
2993
|
+
var storageSingleton = singleton("OutputStorage");
|
|
2994
|
+
var sinkSlot = singleton("OutputSink");
|
|
2995
|
+
var outputStorage = storageSingleton.getOrInit(createStorage, (v) => ("getStore" in v));
|
|
2996
|
+
var CONSOLE_FALLBACK = {
|
|
2997
|
+
writeOut: (str) => process.stdout.write(str),
|
|
2998
|
+
writeErr: (str) => process.stderr.write(str),
|
|
2999
|
+
writeLog: (str) => process.stdout.write(str),
|
|
3000
|
+
capabilities: {
|
|
3001
|
+
isInteractive: false,
|
|
3002
|
+
canReadInput: false,
|
|
3003
|
+
supportsColor: false,
|
|
3004
|
+
outputWidth: 80
|
|
3005
|
+
}
|
|
3006
|
+
};
|
|
3007
|
+
function getOutputSink() {
|
|
3008
|
+
return outputStorage.getStore() ?? sinkSlot.get() ?? CONSOLE_FALLBACK;
|
|
3009
|
+
}
|
|
3010
|
+
|
|
3011
|
+
// ../common/src/logger.ts
|
|
3012
|
+
var logFilePathSlot = singleton("logFilePath");
|
|
3013
|
+
function setGlobalLogFilePath(path2) {
|
|
3014
|
+
logFilePathSlot.set(path2);
|
|
3015
|
+
}
|
|
3016
|
+
function getGlobalLogFilePath() {
|
|
3017
|
+
return logFilePathSlot.get("");
|
|
3018
|
+
}
|
|
3019
|
+
var DEFAULT_LOG_LEVEL = 3 /* ERROR */;
|
|
3020
|
+
|
|
3021
|
+
class SimpleLogger {
|
|
3022
|
+
__brand = "SimpleLogger";
|
|
3023
|
+
level;
|
|
3024
|
+
logFilePath;
|
|
3025
|
+
fileLoggingEnabled;
|
|
3026
|
+
pendingWrites = Promise.resolve();
|
|
3027
|
+
pendingInit = Promise.resolve();
|
|
3028
|
+
constructor() {
|
|
3029
|
+
this.level = SimpleLogger.resolveLevel();
|
|
3030
|
+
this.logFilePath = "";
|
|
3031
|
+
this.fileLoggingEnabled = false;
|
|
3032
|
+
}
|
|
3033
|
+
static getInstance() {
|
|
3034
|
+
return loggerSingleton.getOrInit(() => new SimpleLogger, (v) => ("__brand" in v) && v.__brand === "SimpleLogger");
|
|
3035
|
+
}
|
|
3036
|
+
static resetInstance() {
|
|
3037
|
+
loggerSingleton.clear();
|
|
3038
|
+
}
|
|
3039
|
+
static isNode = typeof process !== "undefined" && !!process.versions?.node;
|
|
3040
|
+
static resolveLevel() {
|
|
3041
|
+
if (SimpleLogger.isNode) {
|
|
3042
|
+
const explicitLevel = SimpleLogger.parseLevel(process.env?.UIP_LOG_LEVEL ?? "");
|
|
3043
|
+
if (explicitLevel !== undefined)
|
|
2379
3044
|
return explicitLevel;
|
|
2380
3045
|
const debugVal = process.env?.DEBUG;
|
|
2381
3046
|
if (debugVal === "true" || debugVal === "1") {
|
|
@@ -2383,7 +3048,7 @@ class SimpleLogger {
|
|
|
2383
3048
|
}
|
|
2384
3049
|
return DEFAULT_LOG_LEVEL;
|
|
2385
3050
|
}
|
|
2386
|
-
const [localStorageError, hasDebug] =
|
|
3051
|
+
const [localStorageError, hasDebug] = catchError(() => typeof localStorage !== "undefined" && !!localStorage.getItem("debug"));
|
|
2387
3052
|
if (!localStorageError && hasDebug) {
|
|
2388
3053
|
return 0 /* DEBUG */;
|
|
2389
3054
|
}
|
|
@@ -2414,54 +3079,49 @@ class SimpleLogger {
|
|
|
2414
3079
|
return this.fileLoggingEnabled || !!getGlobalLogFilePath();
|
|
2415
3080
|
}
|
|
2416
3081
|
writeToFile(formatted) {
|
|
2417
|
-
const
|
|
2418
|
-
if (!
|
|
3082
|
+
const path2 = this.logFilePath || getGlobalLogFilePath();
|
|
3083
|
+
if (!path2)
|
|
2419
3084
|
return;
|
|
2420
3085
|
const timestamp = new Date().toISOString();
|
|
2421
3086
|
this.pendingWrites = Promise.all([
|
|
2422
3087
|
this.pendingWrites,
|
|
2423
3088
|
this.pendingInit
|
|
2424
|
-
]).then(() => getFileSystem().appendFile(
|
|
3089
|
+
]).then(() => getFileSystem().appendFile(path2, `${timestamp} ${formatted}`).catch(() => {}));
|
|
2425
3090
|
}
|
|
2426
|
-
|
|
2427
|
-
if (this.level > 0 /* DEBUG */)
|
|
2428
|
-
return;
|
|
2429
|
-
const formatted = this.format(`[DEBUG] ${message}`, args);
|
|
3091
|
+
write(formatted) {
|
|
2430
3092
|
if (this.isFileLoggingActive()) {
|
|
2431
3093
|
this.writeToFile(formatted);
|
|
2432
3094
|
} else {
|
|
2433
3095
|
getOutputSink().writeErr(formatted);
|
|
2434
3096
|
}
|
|
2435
3097
|
}
|
|
3098
|
+
debug(message, ...args) {
|
|
3099
|
+
if (this.level > 0 /* DEBUG */)
|
|
3100
|
+
return;
|
|
3101
|
+
const formatted = this.format(`[DEBUG] ${message}`, args);
|
|
3102
|
+
this.write(formatted);
|
|
3103
|
+
}
|
|
2436
3104
|
info(message, ...args) {
|
|
2437
3105
|
if (this.level > 1 /* INFO */)
|
|
2438
3106
|
return;
|
|
2439
3107
|
const formatted = this.format(message, args);
|
|
2440
|
-
|
|
2441
|
-
this.writeToFile(formatted);
|
|
2442
|
-
} else {
|
|
2443
|
-
getOutputSink().writeErr(formatted);
|
|
2444
|
-
}
|
|
3108
|
+
this.write(formatted);
|
|
2445
3109
|
}
|
|
2446
3110
|
warn(message, ...args) {
|
|
2447
3111
|
if (this.level > 2 /* WARN */)
|
|
2448
3112
|
return;
|
|
2449
3113
|
const formatted = this.format(`[WARN] ${message}`, args);
|
|
2450
|
-
|
|
2451
|
-
this.writeToFile(formatted);
|
|
2452
|
-
} else {
|
|
2453
|
-
getOutputSink().writeErr(formatted);
|
|
2454
|
-
}
|
|
3114
|
+
this.write(formatted);
|
|
2455
3115
|
}
|
|
2456
3116
|
error(message, ...args) {
|
|
2457
3117
|
if (this.level > 3 /* ERROR */)
|
|
2458
3118
|
return;
|
|
2459
3119
|
const formatted = this.format(`[ERROR] ${message}`, args);
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
3120
|
+
this.write(formatted);
|
|
3121
|
+
}
|
|
3122
|
+
report(message) {
|
|
3123
|
+
const formatted = this.format(message, []);
|
|
3124
|
+
this.write(formatted);
|
|
2465
3125
|
}
|
|
2466
3126
|
getLevel() {
|
|
2467
3127
|
return this.level;
|
|
@@ -2476,17 +3136,17 @@ class SimpleLogger {
|
|
|
2476
3136
|
setGlobalLogFilePath("");
|
|
2477
3137
|
}
|
|
2478
3138
|
}
|
|
2479
|
-
setLogFile(
|
|
2480
|
-
this.logFilePath =
|
|
2481
|
-
setGlobalLogFilePath(
|
|
2482
|
-
if (!
|
|
3139
|
+
setLogFile(path2) {
|
|
3140
|
+
this.logFilePath = path2;
|
|
3141
|
+
setGlobalLogFilePath(path2);
|
|
3142
|
+
if (!path2)
|
|
2483
3143
|
return;
|
|
2484
3144
|
this.fileLoggingEnabled = true;
|
|
2485
|
-
const
|
|
3145
|
+
const fs2 = getFileSystem();
|
|
2486
3146
|
this.pendingInit = (async () => {
|
|
2487
|
-
const [error] = await
|
|
2488
|
-
await
|
|
2489
|
-
await
|
|
3147
|
+
const [error] = await catchError((async () => {
|
|
3148
|
+
await fs2.mkdir(fs2.path.dirname(path2));
|
|
3149
|
+
await fs2.writeFile(path2, "");
|
|
2490
3150
|
})());
|
|
2491
3151
|
if (error)
|
|
2492
3152
|
this.fileLoggingEnabled = false;
|
|
@@ -2540,12 +3200,12 @@ var jmespathSlot = singleton("JmespathCodec");
|
|
|
2540
3200
|
async function loadOutputCodecsAsync(needed) {
|
|
2541
3201
|
const loads = [];
|
|
2542
3202
|
if (needed.yaml && yamlSlot.get() === undefined) {
|
|
2543
|
-
loads.push(import("./js-yaml-
|
|
3203
|
+
loads.push(import("./js-yaml-88tdqrtd.js").then((mod) => {
|
|
2544
3204
|
yamlSlot.set(mod);
|
|
2545
3205
|
}));
|
|
2546
3206
|
}
|
|
2547
3207
|
if (needed.filter && jmespathSlot.get() === undefined) {
|
|
2548
|
-
loads.push(import("./index-
|
|
3208
|
+
loads.push(import("./index-gpd94m28.js").then((mod) => {
|
|
2549
3209
|
jmespathSlot.set(mod);
|
|
2550
3210
|
}));
|
|
2551
3211
|
}
|
|
@@ -2800,7 +3460,7 @@ function readRegistryValue(keyPath, valueName) {
|
|
|
2800
3460
|
if (process.platform !== "win32") {
|
|
2801
3461
|
return "";
|
|
2802
3462
|
}
|
|
2803
|
-
const [error, output] =
|
|
3463
|
+
const [error, output] = catchError(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
|
|
2804
3464
|
encoding: "utf-8",
|
|
2805
3465
|
stdio: ["pipe", "pipe", "pipe"]
|
|
2806
3466
|
}));
|
|
@@ -2823,27 +3483,41 @@ class LoggerTelemetryProvider {
|
|
|
2823
3483
|
...this.analyticsUniqueId ? { analyticsUniqueId: this.analyticsUniqueId } : {}
|
|
2824
3484
|
};
|
|
2825
3485
|
}
|
|
2826
|
-
async trackEvent(
|
|
2827
|
-
logger.debug(formatMessage("Event",
|
|
3486
|
+
async trackEvent({ name, properties }) {
|
|
3487
|
+
logger.debug(formatMessage("Event", name, this.enrich(properties)));
|
|
2828
3488
|
}
|
|
2829
|
-
async trackException(
|
|
3489
|
+
async trackException({
|
|
3490
|
+
error,
|
|
3491
|
+
properties
|
|
3492
|
+
}) {
|
|
2830
3493
|
logger.error(formatMessage("Exception", error.message, this.enrich({
|
|
2831
3494
|
...properties,
|
|
2832
3495
|
stack: error.stack
|
|
2833
3496
|
})));
|
|
2834
3497
|
}
|
|
2835
|
-
async trackRequest(
|
|
3498
|
+
async trackRequest({
|
|
3499
|
+
name,
|
|
3500
|
+
durationMs,
|
|
3501
|
+
success,
|
|
3502
|
+
properties
|
|
3503
|
+
}) {
|
|
2836
3504
|
logger.debug(formatMessage("Request", name, this.enrich({
|
|
2837
3505
|
...properties,
|
|
2838
|
-
duration: `${
|
|
3506
|
+
duration: `${durationMs}ms`,
|
|
2839
3507
|
success
|
|
2840
3508
|
})));
|
|
2841
3509
|
}
|
|
2842
|
-
async trackDependency(
|
|
3510
|
+
async trackDependency({
|
|
3511
|
+
name,
|
|
3512
|
+
type,
|
|
3513
|
+
durationMs,
|
|
3514
|
+
success,
|
|
3515
|
+
properties
|
|
3516
|
+
}) {
|
|
2843
3517
|
logger.debug(formatMessage("Dependency", name, this.enrich({
|
|
2844
3518
|
...properties,
|
|
2845
3519
|
type,
|
|
2846
|
-
duration: `${
|
|
3520
|
+
duration: `${durationMs}ms`,
|
|
2847
3521
|
success
|
|
2848
3522
|
})));
|
|
2849
3523
|
}
|
|
@@ -3047,196 +3721,68 @@ function normalizeSessionId(value) {
|
|
|
3047
3721
|
return;
|
|
3048
3722
|
}
|
|
3049
3723
|
const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
|
|
3050
|
-
return cleaned || undefined;
|
|
3051
|
-
}
|
|
3052
|
-
function getConfiguredTelemetrySessionId() {
|
|
3053
|
-
return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
|
|
3054
|
-
}
|
|
3055
|
-
function getInheritedSession(env) {
|
|
3056
|
-
for (const candidate of INHERITED_SESSION_SOURCES) {
|
|
3057
|
-
const handle = normalizeSessionId(env[candidate.envVar]);
|
|
3058
|
-
if (handle) {
|
|
3059
|
-
return { id: handle, source: candidate.source };
|
|
3060
|
-
}
|
|
3061
|
-
}
|
|
3062
|
-
return;
|
|
3063
|
-
}
|
|
3064
|
-
function generateRandomSession() {
|
|
3065
|
-
const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
|
|
3066
|
-
crypto.getRandomValues(bytes);
|
|
3067
|
-
let hex = "";
|
|
3068
|
-
for (const byte of bytes) {
|
|
3069
|
-
hex += byte.toString(16).padStart(2, "0");
|
|
3070
|
-
}
|
|
3071
|
-
return { id: hex, source: "random" };
|
|
3072
|
-
}
|
|
3073
|
-
function resolveTelemetrySession() {
|
|
3074
|
-
const existing = telemetrySessionSlot.get();
|
|
3075
|
-
if (existing) {
|
|
3076
|
-
return existing;
|
|
3077
|
-
}
|
|
3078
|
-
const declaredHandle = getConfiguredTelemetrySessionId();
|
|
3079
|
-
const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
|
|
3080
|
-
telemetrySessionSlot.set(resolved);
|
|
3081
|
-
return resolved;
|
|
3082
|
-
}
|
|
3083
|
-
function getTelemetrySessionSource() {
|
|
3084
|
-
return resolveTelemetrySession().source;
|
|
3085
|
-
}
|
|
3086
|
-
function getTelemetryOperationId() {
|
|
3087
|
-
const existing = telemetryOperationIdSlot.get();
|
|
3088
|
-
if (existing) {
|
|
3089
|
-
return existing;
|
|
3090
|
-
}
|
|
3091
|
-
const inboundTraceId = getInboundTraceContext()?.traceId;
|
|
3092
|
-
const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
|
|
3093
|
-
telemetryOperationIdSlot.set(generated);
|
|
3094
|
-
return generated;
|
|
3095
|
-
}
|
|
3096
|
-
// ../common/src/telemetry/global-telemetry-properties.ts
|
|
3097
|
-
var telemetryPropsSlot = singleton("TelemetryDefaultProps");
|
|
3098
|
-
function getGlobalTelemetryProperties() {
|
|
3099
|
-
return telemetryPropsSlot.get();
|
|
3100
|
-
}
|
|
3101
|
-
|
|
3102
|
-
// ../common/src/telemetry/pii-redactor.ts
|
|
3103
|
-
var REDACTED = "[REDACTED]";
|
|
3104
|
-
var MAX_VALUE_LENGTH = 200;
|
|
3105
|
-
var SENSITIVE_NAME_TOKENS = new Set([
|
|
3106
|
-
"token",
|
|
3107
|
-
"tokens",
|
|
3108
|
-
"secret",
|
|
3109
|
-
"secrets",
|
|
3110
|
-
"password",
|
|
3111
|
-
"passwords",
|
|
3112
|
-
"pwd",
|
|
3113
|
-
"credential",
|
|
3114
|
-
"credentials",
|
|
3115
|
-
"auth",
|
|
3116
|
-
"authentication",
|
|
3117
|
-
"authorization",
|
|
3118
|
-
"authority",
|
|
3119
|
-
"cert",
|
|
3120
|
-
"certificate",
|
|
3121
|
-
"certificates"
|
|
3122
|
-
]);
|
|
3123
|
-
var SENSITIVE_KEY_PREFIXES = new Set([
|
|
3124
|
-
"api",
|
|
3125
|
-
"access",
|
|
3126
|
-
"client",
|
|
3127
|
-
"private",
|
|
3128
|
-
"public",
|
|
3129
|
-
"signing",
|
|
3130
|
-
"encryption",
|
|
3131
|
-
"session",
|
|
3132
|
-
"master",
|
|
3133
|
-
"shared",
|
|
3134
|
-
"root",
|
|
3135
|
-
"ssh",
|
|
3136
|
-
"rsa",
|
|
3137
|
-
"aes",
|
|
3138
|
-
"hmac",
|
|
3139
|
-
"oauth"
|
|
3140
|
-
]);
|
|
3141
|
-
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;
|
|
3142
|
-
var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
3143
|
-
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
3144
|
-
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
3145
|
-
var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
|
|
3146
|
-
var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
|
|
3147
|
-
var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
|
|
3148
|
-
function shortHash(input) {
|
|
3149
|
-
let hash = 2166136261;
|
|
3150
|
-
for (let i = 0;i < input.length; i++) {
|
|
3151
|
-
hash ^= input.charCodeAt(i);
|
|
3152
|
-
hash = Math.imul(hash, 16777619);
|
|
3153
|
-
}
|
|
3154
|
-
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
3155
|
-
}
|
|
3156
|
-
function redactUrl(raw) {
|
|
3157
|
-
try {
|
|
3158
|
-
const url = new URL(raw);
|
|
3159
|
-
return `${url.protocol}//${url.host}`;
|
|
3160
|
-
} catch {
|
|
3161
|
-
return `url#${shortHash(raw)}`;
|
|
3162
|
-
}
|
|
3163
|
-
}
|
|
3164
|
-
function redactValueDetectors(value) {
|
|
3165
|
-
let out = value;
|
|
3166
|
-
out = out.replace(JWT_PATTERN, () => REDACTED);
|
|
3167
|
-
out = out.replace(URL_PATTERN, (match) => {
|
|
3168
|
-
const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
|
|
3169
|
-
const core = trailing ? match.slice(0, -trailing.length) : match;
|
|
3170
|
-
return `${redactUrl(core)}${trailing}`;
|
|
3171
|
-
});
|
|
3172
|
-
out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
|
|
3173
|
-
out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
|
|
3174
|
-
out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
|
|
3175
|
-
out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
|
|
3176
|
-
if (out.length > MAX_VALUE_LENGTH) {
|
|
3177
|
-
out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
|
|
3178
|
-
}
|
|
3179
|
-
return out;
|
|
3180
|
-
}
|
|
3181
|
-
function redactValue(value) {
|
|
3182
|
-
return redactValueDetectors(value);
|
|
3183
|
-
}
|
|
3184
|
-
function redactError(error) {
|
|
3185
|
-
const safe = new Error(redactValueDetectors(error.message ?? ""));
|
|
3186
|
-
safe.name = error.name;
|
|
3187
|
-
safe.stack = typeof error.stack === "string" ? redactValueDetectors(error.stack) : undefined;
|
|
3188
|
-
return safe;
|
|
3724
|
+
return cleaned || undefined;
|
|
3189
3725
|
}
|
|
3190
|
-
function
|
|
3191
|
-
return
|
|
3726
|
+
function getConfiguredTelemetrySessionId() {
|
|
3727
|
+
return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
|
|
3192
3728
|
}
|
|
3193
|
-
function
|
|
3194
|
-
const
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
return true;
|
|
3199
|
-
}
|
|
3200
|
-
if (token === "key" || token === "keys") {
|
|
3201
|
-
const prev = tokens[i - 1];
|
|
3202
|
-
if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
|
|
3203
|
-
return true;
|
|
3204
|
-
}
|
|
3729
|
+
function getInheritedSession(env) {
|
|
3730
|
+
for (const candidate of INHERITED_SESSION_SOURCES) {
|
|
3731
|
+
const handle = normalizeSessionId(env[candidate.envVar]);
|
|
3732
|
+
if (handle) {
|
|
3733
|
+
return { id: handle, source: candidate.source };
|
|
3205
3734
|
}
|
|
3206
3735
|
}
|
|
3207
|
-
return
|
|
3736
|
+
return;
|
|
3208
3737
|
}
|
|
3209
|
-
function
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
}
|
|
3216
|
-
if (typeof value === "boolean" || typeof value === "number") {
|
|
3217
|
-
return value;
|
|
3738
|
+
function generateRandomSession() {
|
|
3739
|
+
const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
|
|
3740
|
+
crypto.getRandomValues(bytes);
|
|
3741
|
+
let hex = "";
|
|
3742
|
+
for (const byte of bytes) {
|
|
3743
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
3218
3744
|
}
|
|
3219
|
-
|
|
3220
|
-
|
|
3745
|
+
return { id: hex, source: "random" };
|
|
3746
|
+
}
|
|
3747
|
+
function resolveTelemetrySession() {
|
|
3748
|
+
const existing = telemetrySessionSlot.get();
|
|
3749
|
+
if (existing) {
|
|
3750
|
+
return existing;
|
|
3221
3751
|
}
|
|
3222
|
-
|
|
3752
|
+
const declaredHandle = getConfiguredTelemetrySessionId();
|
|
3753
|
+
const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
|
|
3754
|
+
telemetrySessionSlot.set(resolved);
|
|
3755
|
+
return resolved;
|
|
3223
3756
|
}
|
|
3224
|
-
function
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3757
|
+
function getTelemetrySessionSource() {
|
|
3758
|
+
return resolveTelemetrySession().source;
|
|
3759
|
+
}
|
|
3760
|
+
function getTelemetryOperationId() {
|
|
3761
|
+
const existing = telemetryOperationIdSlot.get();
|
|
3762
|
+
if (existing) {
|
|
3763
|
+
return existing;
|
|
3231
3764
|
}
|
|
3232
|
-
|
|
3765
|
+
const inboundTraceId = getInboundTraceContext()?.traceId;
|
|
3766
|
+
const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
|
|
3767
|
+
telemetryOperationIdSlot.set(generated);
|
|
3768
|
+
return generated;
|
|
3769
|
+
}
|
|
3770
|
+
// ../common/src/telemetry/global-telemetry-properties.ts
|
|
3771
|
+
var telemetryPropsSlot = singleton("TelemetryDefaultProps");
|
|
3772
|
+
function getGlobalTelemetryProperties() {
|
|
3773
|
+
return telemetryPropsSlot.get();
|
|
3233
3774
|
}
|
|
3234
3775
|
|
|
3235
|
-
// ../common/src/telemetry/
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3776
|
+
// ../common/src/telemetry/span-clock.ts
|
|
3777
|
+
function startSpanClock() {
|
|
3778
|
+
const started = performance.now();
|
|
3779
|
+
return {
|
|
3780
|
+
startedAt: new Date(performance.timeOrigin + started),
|
|
3781
|
+
elapsedMs: () => performance.now() - started
|
|
3782
|
+
};
|
|
3783
|
+
}
|
|
3239
3784
|
|
|
3785
|
+
// ../common/src/telemetry/telemetry-service.ts
|
|
3240
3786
|
class TelemetryService {
|
|
3241
3787
|
telemetryProvider;
|
|
3242
3788
|
contextStorage;
|
|
@@ -3256,36 +3802,39 @@ class TelemetryService {
|
|
|
3256
3802
|
this.defaultProperties = properties === undefined ? undefined : { ...this.defaultProperties, ...properties };
|
|
3257
3803
|
}
|
|
3258
3804
|
trackEvent(name, properties) {
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3805
|
+
this.telemetryProvider.trackEvent({
|
|
3806
|
+
name: redactSpanName(name),
|
|
3807
|
+
properties: this.enrichProperties(properties),
|
|
3808
|
+
...this.leafCorrelation()
|
|
3809
|
+
});
|
|
3262
3810
|
}
|
|
3263
|
-
trackException(error, properties) {
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3811
|
+
trackException(error, properties, context) {
|
|
3812
|
+
this.telemetryProvider.trackException({
|
|
3813
|
+
error: redactError(error),
|
|
3814
|
+
properties: this.enrichProperties(properties),
|
|
3815
|
+
...this.leafCorrelation(context)
|
|
3816
|
+
});
|
|
3267
3817
|
}
|
|
3268
3818
|
async trackRequest(name, fn, properties) {
|
|
3269
|
-
const parentContext = this.
|
|
3819
|
+
const parentContext = this.getActiveContext();
|
|
3270
3820
|
const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
|
|
3271
3821
|
const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
|
|
3822
|
+
const clock = startSpanClock();
|
|
3272
3823
|
const context = {
|
|
3273
3824
|
operationId,
|
|
3274
3825
|
...parentId !== undefined ? { parentId } : {},
|
|
3275
|
-
id: this.generateId()
|
|
3826
|
+
id: this.generateId(),
|
|
3827
|
+
startedAt: clock.startedAt
|
|
3276
3828
|
};
|
|
3277
|
-
const startTime = performance.now();
|
|
3278
3829
|
try {
|
|
3279
3830
|
const result = await this.contextStorage.run(context, fn);
|
|
3280
|
-
const durationMs =
|
|
3281
|
-
|
|
3282
|
-
await this.telemetryProvider.trackRequest(name, durationMs, true, enrichedProperties);
|
|
3831
|
+
const durationMs = clock.elapsedMs();
|
|
3832
|
+
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, true, properties, context));
|
|
3283
3833
|
return result;
|
|
3284
3834
|
} catch (error) {
|
|
3285
|
-
const durationMs =
|
|
3835
|
+
const durationMs = clock.elapsedMs();
|
|
3286
3836
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
3287
|
-
|
|
3288
|
-
await this.telemetryProvider.trackRequest(name, durationMs, false, enrichedProperties);
|
|
3837
|
+
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, context));
|
|
3289
3838
|
throw error;
|
|
3290
3839
|
}
|
|
3291
3840
|
}
|
|
@@ -3294,8 +3843,7 @@ class TelemetryService {
|
|
|
3294
3843
|
operationId: this.operationId ?? getTelemetryOperationId(),
|
|
3295
3844
|
id: this.generateId()
|
|
3296
3845
|
};
|
|
3297
|
-
|
|
3298
|
-
this.telemetryProvider.trackRequest(name, durationMs, success, enrichedProperties);
|
|
3846
|
+
this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, success, properties, requestContext));
|
|
3299
3847
|
}
|
|
3300
3848
|
createRequestContext() {
|
|
3301
3849
|
const operationId = this.operationId ?? getTelemetryOperationId();
|
|
@@ -3303,7 +3851,8 @@ class TelemetryService {
|
|
|
3303
3851
|
return {
|
|
3304
3852
|
operationId,
|
|
3305
3853
|
...parentId !== undefined ? { parentId } : {},
|
|
3306
|
-
id: this.generateId()
|
|
3854
|
+
id: this.generateId(),
|
|
3855
|
+
startedAt: startSpanClock().startedAt
|
|
3307
3856
|
};
|
|
3308
3857
|
}
|
|
3309
3858
|
inboundParentIdFor(operationId) {
|
|
@@ -3314,58 +3863,84 @@ class TelemetryService {
|
|
|
3314
3863
|
return this.contextStorage.run(context, fn);
|
|
3315
3864
|
}
|
|
3316
3865
|
createDependencyContext() {
|
|
3317
|
-
const parentContext = this.
|
|
3866
|
+
const parentContext = this.getActiveContext();
|
|
3318
3867
|
if (!parentContext) {
|
|
3319
3868
|
return;
|
|
3320
3869
|
}
|
|
3321
3870
|
return {
|
|
3322
3871
|
operationId: parentContext.operationId,
|
|
3323
3872
|
parentId: parentContext.id,
|
|
3324
|
-
id: this.generateId()
|
|
3873
|
+
id: this.generateId(),
|
|
3874
|
+
startedAt: startSpanClock().startedAt
|
|
3325
3875
|
};
|
|
3326
3876
|
}
|
|
3327
3877
|
trackDependencyResult(name, type, durationMs, success, properties, context, resultCode) {
|
|
3328
|
-
|
|
3329
|
-
|
|
3878
|
+
this.telemetryProvider.trackDependency({
|
|
3879
|
+
...this.spanFor(redactHttpDependencyName(name), durationMs, success, properties, context),
|
|
3880
|
+
type,
|
|
3881
|
+
...resultCode !== undefined ? { resultCode } : {}
|
|
3882
|
+
});
|
|
3330
3883
|
}
|
|
3331
3884
|
async trackDependencyOperation(name, type, fn, properties) {
|
|
3332
|
-
const
|
|
3885
|
+
const clock = startSpanClock();
|
|
3886
|
+
const parentContext = this.getActiveContext();
|
|
3333
3887
|
const childContext = parentContext !== undefined ? {
|
|
3334
3888
|
operationId: parentContext.operationId,
|
|
3335
3889
|
parentId: parentContext.id,
|
|
3336
|
-
id: this.generateId()
|
|
3337
|
-
|
|
3338
|
-
|
|
3890
|
+
id: this.generateId(),
|
|
3891
|
+
startedAt: clock.startedAt
|
|
3892
|
+
} : {
|
|
3893
|
+
...this.createRequestContext(),
|
|
3894
|
+
startedAt: clock.startedAt
|
|
3895
|
+
};
|
|
3339
3896
|
try {
|
|
3340
3897
|
const result = await this.contextStorage.run(childContext, fn);
|
|
3341
|
-
const durationMs =
|
|
3342
|
-
|
|
3343
|
-
|
|
3898
|
+
const durationMs = clock.elapsedMs();
|
|
3899
|
+
await this.telemetryProvider.trackDependency({
|
|
3900
|
+
...this.spanFor(name, durationMs, true, properties, childContext),
|
|
3901
|
+
type
|
|
3902
|
+
});
|
|
3344
3903
|
return result;
|
|
3345
3904
|
} catch (error) {
|
|
3346
|
-
const durationMs =
|
|
3905
|
+
const durationMs = clock.elapsedMs();
|
|
3347
3906
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
3348
|
-
|
|
3349
|
-
|
|
3907
|
+
await this.telemetryProvider.trackDependency({
|
|
3908
|
+
...this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, childContext),
|
|
3909
|
+
type
|
|
3910
|
+
});
|
|
3350
3911
|
throw error;
|
|
3351
3912
|
}
|
|
3352
3913
|
}
|
|
3353
|
-
|
|
3914
|
+
getActiveContext() {
|
|
3354
3915
|
return this.contextStorage.getContext();
|
|
3355
3916
|
}
|
|
3356
|
-
|
|
3917
|
+
leafCorrelation(explicit) {
|
|
3918
|
+
const context = explicit ?? this.getActiveContext();
|
|
3919
|
+
return {
|
|
3920
|
+
operationId: context?.operationId ?? this.operationId ?? getTelemetryOperationId(),
|
|
3921
|
+
...context !== undefined ? { parentId: context.id } : {}
|
|
3922
|
+
};
|
|
3923
|
+
}
|
|
3924
|
+
spanFor(name, durationMs, success, properties, context) {
|
|
3925
|
+
return {
|
|
3926
|
+
name: redactSpanName(name),
|
|
3927
|
+
durationMs,
|
|
3928
|
+
success,
|
|
3929
|
+
properties: this.enrichProperties(properties),
|
|
3930
|
+
operationId: context.operationId,
|
|
3931
|
+
...context.parentId !== undefined ? { parentId: context.parentId } : {},
|
|
3932
|
+
id: context.id,
|
|
3933
|
+
...context.startedAt !== undefined ? { startedAt: context.startedAt } : {}
|
|
3934
|
+
};
|
|
3935
|
+
}
|
|
3936
|
+
enrichProperties(properties) {
|
|
3357
3937
|
const globalProperties = getGlobalTelemetryProperties();
|
|
3358
3938
|
const enriched = {
|
|
3359
3939
|
...getExecutionContextTelemetryProperties(),
|
|
3360
3940
|
...globalProperties,
|
|
3361
3941
|
...this.defaultProperties,
|
|
3362
3942
|
...redactProperties(properties ?? {}),
|
|
3363
|
-
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
|
|
3364
|
-
...context ? {
|
|
3365
|
-
[TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
|
|
3366
|
-
...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
|
|
3367
|
-
[TELEMETRY_SPAN_ID_PROPERTY]: context.id
|
|
3368
|
-
} : {}
|
|
3943
|
+
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
|
|
3369
3944
|
};
|
|
3370
3945
|
return enriched;
|
|
3371
3946
|
}
|
|
@@ -3382,6 +3957,81 @@ class TelemetryService {
|
|
|
3382
3957
|
return hex;
|
|
3383
3958
|
}
|
|
3384
3959
|
}
|
|
3960
|
+
// ../common/src/timings.ts
|
|
3961
|
+
var TIMINGS_ENV_VAR = "UIP_TIMINGS";
|
|
3962
|
+
function createStorage2() {
|
|
3963
|
+
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
3964
|
+
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
3965
|
+
return {
|
|
3966
|
+
getStore: () => {
|
|
3967
|
+
return;
|
|
3968
|
+
},
|
|
3969
|
+
run: (_store, fn) => fn()
|
|
3970
|
+
};
|
|
3971
|
+
}
|
|
3972
|
+
return new mod.AsyncLocalStorage;
|
|
3973
|
+
}
|
|
3974
|
+
var storageSlot = singleton("TimingStorage");
|
|
3975
|
+
var stateSlot = singleton("Timings");
|
|
3976
|
+
var rootStartedSlot = singleton("TimingsRootStarted");
|
|
3977
|
+
var longLivedHostSlot = singleton("TimingsLongLivedHost");
|
|
3978
|
+
var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
|
|
3979
|
+
function newState(baseline) {
|
|
3980
|
+
return { baseline, httpMs: 0, httpCalls: 0 };
|
|
3981
|
+
}
|
|
3982
|
+
function getState() {
|
|
3983
|
+
const scoped = storage.getStore();
|
|
3984
|
+
if (scoped) {
|
|
3985
|
+
return scoped;
|
|
3986
|
+
}
|
|
3987
|
+
const pinned = livePinnedState();
|
|
3988
|
+
if (pinned !== undefined) {
|
|
3989
|
+
return pinned;
|
|
3990
|
+
}
|
|
3991
|
+
return newState(processStartIsInvocationStart() ? 0 : performance.now());
|
|
3992
|
+
}
|
|
3993
|
+
function livePinnedState() {
|
|
3994
|
+
const pinned = stateSlot.get();
|
|
3995
|
+
return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
|
|
3996
|
+
}
|
|
3997
|
+
function processStartIsInvocationStart() {
|
|
3998
|
+
return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
|
|
3999
|
+
}
|
|
4000
|
+
function timingsEnabled() {
|
|
4001
|
+
if (typeof process === "undefined") {
|
|
4002
|
+
return false;
|
|
4003
|
+
}
|
|
4004
|
+
const value = process.env?.[TIMINGS_ENV_VAR];
|
|
4005
|
+
if (value === undefined) {
|
|
4006
|
+
return false;
|
|
4007
|
+
}
|
|
4008
|
+
const normalized = value.trim().toLowerCase();
|
|
4009
|
+
return normalized === "1" || normalized === "true";
|
|
4010
|
+
}
|
|
4011
|
+
function recordExitCode(exitCode) {
|
|
4012
|
+
if (!timingsEnabled()) {
|
|
4013
|
+
return;
|
|
4014
|
+
}
|
|
4015
|
+
getState().exitCode = exitCode;
|
|
4016
|
+
}
|
|
4017
|
+
function invocationStartedAt() {
|
|
4018
|
+
return new Date(performance.timeOrigin + getState().baseline);
|
|
4019
|
+
}
|
|
4020
|
+
function invocationElapsedMs() {
|
|
4021
|
+
return performance.now() - getState().baseline;
|
|
4022
|
+
}
|
|
4023
|
+
function markCommandStart() {
|
|
4024
|
+
if (!timingsEnabled()) {
|
|
4025
|
+
return;
|
|
4026
|
+
}
|
|
4027
|
+
getState().commandStart = performance.now();
|
|
4028
|
+
}
|
|
4029
|
+
function recordCommandDuration(durationMs) {
|
|
4030
|
+
if (!timingsEnabled()) {
|
|
4031
|
+
return;
|
|
4032
|
+
}
|
|
4033
|
+
getState().commandMs = durationMs;
|
|
4034
|
+
}
|
|
3385
4035
|
// ../common/src/telemetry/proxy-http-agent.ts
|
|
3386
4036
|
var slot = singleton("ProxyAuthHttpsAgent");
|
|
3387
4037
|
|
|
@@ -3402,6 +4052,9 @@ function getGlobalTelemetryInstance() {
|
|
|
3402
4052
|
}
|
|
3403
4053
|
return;
|
|
3404
4054
|
}
|
|
4055
|
+
function setGlobalTelemetryInstance(instance) {
|
|
4056
|
+
telemetryInstanceSlot.set(instance);
|
|
4057
|
+
}
|
|
3405
4058
|
var _localTelemetryInstance;
|
|
3406
4059
|
function getTelemetryInstance() {
|
|
3407
4060
|
const global = getGlobalTelemetryInstance();
|
|
@@ -3409,6 +4062,7 @@ function getTelemetryInstance() {
|
|
|
3409
4062
|
return global;
|
|
3410
4063
|
if (!_localTelemetryInstance) {
|
|
3411
4064
|
_localTelemetryInstance = new TelemetryService(new LoggerTelemetryProvider, new NodeContextStorage);
|
|
4065
|
+
setGlobalTelemetryInstance(_localTelemetryInstance);
|
|
3412
4066
|
}
|
|
3413
4067
|
return _localTelemetryInstance;
|
|
3414
4068
|
}
|
|
@@ -3421,6 +4075,14 @@ var telemetry = new Proxy({}, {
|
|
|
3421
4075
|
});
|
|
3422
4076
|
|
|
3423
4077
|
// ../common/src/formatter.ts
|
|
4078
|
+
var ANSI_STYLES = {
|
|
4079
|
+
red: "\x1B[31m",
|
|
4080
|
+
dim: "\x1B[2m"
|
|
4081
|
+
};
|
|
4082
|
+
var ANSI_RESET = "\x1B[0m";
|
|
4083
|
+
function styleLine(line, style) {
|
|
4084
|
+
return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
|
|
4085
|
+
}
|
|
3424
4086
|
var CLI_ERROR_CODES = [
|
|
3425
4087
|
"invalid_argument",
|
|
3426
4088
|
"authentication_required",
|
|
@@ -3492,23 +4154,6 @@ function derivePaginationHasMore(returned, limit, offset, total, nextPage) {
|
|
|
3492
4154
|
}
|
|
3493
4155
|
return (offset ?? 0) + returned < total;
|
|
3494
4156
|
}
|
|
3495
|
-
|
|
3496
|
-
class SuccessOutput {
|
|
3497
|
-
Result = RESULTS.Success;
|
|
3498
|
-
Code;
|
|
3499
|
-
Data;
|
|
3500
|
-
Pagination;
|
|
3501
|
-
Instructions;
|
|
3502
|
-
Log;
|
|
3503
|
-
constructor(code, data) {
|
|
3504
|
-
this.Code = code;
|
|
3505
|
-
this.Data = data;
|
|
3506
|
-
const logPath = getLogFilePath();
|
|
3507
|
-
if (logPath) {
|
|
3508
|
-
this.Log = logPath;
|
|
3509
|
-
}
|
|
3510
|
-
}
|
|
3511
|
-
}
|
|
3512
4157
|
function escapeNonAscii(jsonText) {
|
|
3513
4158
|
return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
|
|
3514
4159
|
const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
|
|
@@ -3573,19 +4218,45 @@ function toPascalCaseKey(key) {
|
|
|
3573
4218
|
const lowerCamelKey = toLowerCamelCaseKey(key);
|
|
3574
4219
|
return lowerCamelKey ? lowerCamelKey.charAt(0).toUpperCase() + lowerCamelKey.slice(1) : lowerCamelKey;
|
|
3575
4220
|
}
|
|
3576
|
-
function
|
|
4221
|
+
function collectVerbatimRefs(value, into) {
|
|
4222
|
+
if (typeof value !== "object" || value === null)
|
|
4223
|
+
return;
|
|
4224
|
+
if (into.has(value))
|
|
4225
|
+
return;
|
|
4226
|
+
into.add(value);
|
|
4227
|
+
for (const nested of Array.isArray(value) ? value : Object.values(value)) {
|
|
4228
|
+
collectVerbatimRefs(nested, into);
|
|
4229
|
+
}
|
|
4230
|
+
}
|
|
4231
|
+
function toPascalCaseData(value, verbatimKeys, subtrees) {
|
|
4232
|
+
if (subtrees?.mode === "skip" && typeof value === "object" && value !== null && subtrees.refs.has(value)) {
|
|
4233
|
+
return value;
|
|
4234
|
+
}
|
|
3577
4235
|
if (Array.isArray(value))
|
|
3578
|
-
return value.map(toPascalCaseData);
|
|
4236
|
+
return value.map((entry) => toPascalCaseData(entry, verbatimKeys, subtrees));
|
|
3579
4237
|
if (!isPlainRecord(value))
|
|
3580
4238
|
return value;
|
|
3581
4239
|
const result = {};
|
|
3582
4240
|
for (const [key, nestedValue] of Object.entries(value)) {
|
|
3583
|
-
|
|
4241
|
+
const pascalKey = toPascalCaseKey(key);
|
|
4242
|
+
if (verbatimKeys?.has(pascalKey)) {
|
|
4243
|
+
result[pascalKey] = nestedValue;
|
|
4244
|
+
if (subtrees?.mode === "collect") {
|
|
4245
|
+
collectVerbatimRefs(nestedValue, subtrees.refs);
|
|
4246
|
+
}
|
|
4247
|
+
continue;
|
|
4248
|
+
}
|
|
4249
|
+
result[pascalKey] = toPascalCaseData(nestedValue, verbatimKeys, subtrees);
|
|
3584
4250
|
}
|
|
3585
4251
|
return result;
|
|
3586
4252
|
}
|
|
3587
|
-
function normalizeDataKeys(data) {
|
|
3588
|
-
return toPascalCaseData(data);
|
|
4253
|
+
function normalizeDataKeys(data, verbatimKeys, subtrees) {
|
|
4254
|
+
return toPascalCaseData(data, verbatimKeys, subtrees);
|
|
4255
|
+
}
|
|
4256
|
+
function toVerbatimKeySet(preserve) {
|
|
4257
|
+
if (!Array.isArray(preserve))
|
|
4258
|
+
return;
|
|
4259
|
+
return new Set(preserve.map(toPascalCaseKey));
|
|
3589
4260
|
}
|
|
3590
4261
|
function normalizeOutputKeys(data) {
|
|
3591
4262
|
const result = {};
|
|
@@ -3595,7 +4266,7 @@ function normalizeOutputKeys(data) {
|
|
|
3595
4266
|
}
|
|
3596
4267
|
return result;
|
|
3597
4268
|
}
|
|
3598
|
-
function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
4269
|
+
function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowStyle) {
|
|
3599
4270
|
if (!data) {
|
|
3600
4271
|
logFn("Empty response object. No data to display.");
|
|
3601
4272
|
return;
|
|
@@ -3630,7 +4301,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
3630
4301
|
if (hasData && !(rows !== null && rows.length === 0)) {
|
|
3631
4302
|
const logValue = data.Log;
|
|
3632
4303
|
if (rows !== null) {
|
|
3633
|
-
printResizableTable(rows, logFn, logValue);
|
|
4304
|
+
printResizableTable(rows, logFn, logValue, undefined, tableRowStyle);
|
|
3634
4305
|
} else {
|
|
3635
4306
|
printVerticalTable(data.Data, logFn, logValue);
|
|
3636
4307
|
}
|
|
@@ -3641,10 +4312,11 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
3641
4312
|
}
|
|
3642
4313
|
}
|
|
3643
4314
|
}
|
|
3644
|
-
function logOutput(data, format = "json") {
|
|
4315
|
+
function logOutput(data, format = "json", tableRowStyle) {
|
|
3645
4316
|
const sink = getOutputSink();
|
|
4317
|
+
const styleFn = sink.capabilities.isInteractive && sink.capabilities.supportsColor ? tableRowStyle : undefined;
|
|
3646
4318
|
printOutput(data, format, (msg) => sink.writeOut(`${msg}
|
|
3647
|
-
`), needsAsciiSafeJson(sink));
|
|
4319
|
+
`), needsAsciiSafeJson(sink), styleFn);
|
|
3648
4320
|
}
|
|
3649
4321
|
function cellToString(val) {
|
|
3650
4322
|
return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
|
|
@@ -3658,7 +4330,7 @@ function wrapText(text, width) {
|
|
|
3658
4330
|
}
|
|
3659
4331
|
return lines;
|
|
3660
4332
|
}
|
|
3661
|
-
function printTable(data, logFn, externalLogValue) {
|
|
4333
|
+
function printTable(data, logFn, externalLogValue, tableRowStyle) {
|
|
3662
4334
|
if (data.length === 0)
|
|
3663
4335
|
return;
|
|
3664
4336
|
const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
@@ -3668,7 +4340,7 @@ function printTable(data, logFn, externalLogValue) {
|
|
|
3668
4340
|
logFn(keys.map((_, i) => "-".repeat(maxWidths[i])).join("-|-"));
|
|
3669
4341
|
data.forEach((item) => {
|
|
3670
4342
|
const row = keys.map((key, i) => cellToString(item[key]).padEnd(maxWidths[i])).join(" | ");
|
|
3671
|
-
logFn(row);
|
|
4343
|
+
logFn(styleLine(row, tableRowStyle?.(item)));
|
|
3672
4344
|
});
|
|
3673
4345
|
if (externalLogValue) {
|
|
3674
4346
|
logFn("");
|
|
@@ -3711,14 +4383,14 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
|
3711
4383
|
logFn(`Log: ${externalLogValue}`);
|
|
3712
4384
|
}
|
|
3713
4385
|
}
|
|
3714
|
-
function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth) {
|
|
4386
|
+
function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
|
|
3715
4387
|
if (data.length === 0)
|
|
3716
4388
|
return;
|
|
3717
4389
|
const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
3718
4390
|
if (keys.length === 0)
|
|
3719
4391
|
return;
|
|
3720
4392
|
if (!process.stdout.isTTY) {
|
|
3721
|
-
printTable(data, logFn, externalLogValue);
|
|
4393
|
+
printTable(data, logFn, externalLogValue, tableRowStyle);
|
|
3722
4394
|
return;
|
|
3723
4395
|
}
|
|
3724
4396
|
const naturalWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
|
|
@@ -3726,7 +4398,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
|
|
|
3726
4398
|
const totalWidth = naturalWidths.reduce((a, b) => a + b, 0) + separatorTotal;
|
|
3727
4399
|
const termWidth = availableWidth ?? (process.stdout.columns || 120);
|
|
3728
4400
|
if (totalWidth <= termWidth) {
|
|
3729
|
-
printTable(data, logFn, externalLogValue);
|
|
4401
|
+
printTable(data, logFn, externalLogValue, tableRowStyle);
|
|
3730
4402
|
return;
|
|
3731
4403
|
}
|
|
3732
4404
|
const overflow = totalWidth - termWidth;
|
|
@@ -3772,6 +4444,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
|
|
|
3772
4444
|
logFn(header);
|
|
3773
4445
|
logFn(keys.map((_, i) => "-".repeat(finalWidths[i])).join("-|-"));
|
|
3774
4446
|
data.forEach((item) => {
|
|
4447
|
+
const style = tableRowStyle?.(item);
|
|
3775
4448
|
const cellLines = keys.map((key, i) => wrapText(cellToString(item[key]), finalWidths[i]));
|
|
3776
4449
|
const lineCount = Math.max(...cellLines.map((l) => l.length));
|
|
3777
4450
|
for (let line = 0;line < lineCount; line++) {
|
|
@@ -3779,7 +4452,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
|
|
|
3779
4452
|
const val = line < cellLines[i].length ? cellLines[i][line] : "";
|
|
3780
4453
|
return val.padEnd(finalWidths[i]);
|
|
3781
4454
|
}).join(" | ");
|
|
3782
|
-
logFn(row);
|
|
4455
|
+
logFn(styleLine(row, style));
|
|
3783
4456
|
}
|
|
3784
4457
|
});
|
|
3785
4458
|
if (externalLogValue) {
|
|
@@ -3923,30 +4596,36 @@ var OutputFormatter;
|
|
|
3923
4596
|
((OutputFormatter) => {
|
|
3924
4597
|
function success(data, options) {
|
|
3925
4598
|
data.Log ??= getLogFilePath() || undefined;
|
|
3926
|
-
const normalize =
|
|
4599
|
+
const normalize = options?.preserveDataKeys !== true;
|
|
4600
|
+
const verbatim = toVerbatimKeySet(options?.preserveDataKeys);
|
|
4601
|
+
const subtrees = verbatim && {
|
|
4602
|
+
refs: new Set,
|
|
4603
|
+
mode: "collect"
|
|
4604
|
+
};
|
|
3927
4605
|
if (normalize) {
|
|
3928
|
-
data.Data = normalizeDataKeys(data.Data);
|
|
4606
|
+
data.Data = normalizeDataKeys(data.Data, verbatim, subtrees);
|
|
3929
4607
|
}
|
|
3930
4608
|
const filter = getOutputFilter();
|
|
3931
4609
|
if (filter) {
|
|
3932
4610
|
const filtered = applyFilter(data.Data, filter);
|
|
3933
|
-
data.Data = normalize ? normalizeDataKeys(filtered) : filtered;
|
|
4611
|
+
data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
|
|
3934
4612
|
}
|
|
3935
|
-
logOutput(normalizeOutputKeys(data), getOutputFormat());
|
|
4613
|
+
logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
|
|
3936
4614
|
}
|
|
3937
4615
|
OutputFormatter.success = success;
|
|
3938
4616
|
function error(data) {
|
|
3939
4617
|
data.Log ??= getLogFilePath() || undefined;
|
|
3940
4618
|
data.ErrorCode ??= defaultErrorCodeForFailure(data);
|
|
3941
4619
|
data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
|
|
3942
|
-
|
|
4620
|
+
const exitCode = EXIT_CODES[data.Result] ?? 1;
|
|
4621
|
+
setExitCode(exitCode);
|
|
3943
4622
|
recordCommandFailureTelemetry({
|
|
3944
4623
|
result: data.Result,
|
|
3945
4624
|
errorCode: data.ErrorCode,
|
|
3946
4625
|
retry: data.Retry,
|
|
3947
4626
|
message: data.Message,
|
|
3948
4627
|
context: data.Context,
|
|
3949
|
-
exitCode
|
|
4628
|
+
exitCode,
|
|
3950
4629
|
errorClass: data.TelemetryErrorClass,
|
|
3951
4630
|
terminalOutcome: data.TelemetryTerminalOutcome,
|
|
3952
4631
|
terminalSignal: data.TelemetryTerminalSignal
|
|
@@ -4022,6 +4701,39 @@ var OutputFormatter;
|
|
|
4022
4701
|
}
|
|
4023
4702
|
OutputFormatter.formatToString = formatToString;
|
|
4024
4703
|
})(OutputFormatter ||= {});
|
|
4704
|
+
// ../../node_modules/commander/esm.mjs
|
|
4705
|
+
var import__ = __toESM(require_commander(), 1);
|
|
4706
|
+
var {
|
|
4707
|
+
program,
|
|
4708
|
+
createCommand,
|
|
4709
|
+
createArgument,
|
|
4710
|
+
createOption,
|
|
4711
|
+
CommanderError,
|
|
4712
|
+
InvalidArgumentError,
|
|
4713
|
+
InvalidOptionArgumentError,
|
|
4714
|
+
Command,
|
|
4715
|
+
Argument,
|
|
4716
|
+
Option,
|
|
4717
|
+
Help
|
|
4718
|
+
} = import__.default;
|
|
4719
|
+
|
|
4720
|
+
// ../common/src/command-examples.ts
|
|
4721
|
+
var examplesByCommand = new WeakMap;
|
|
4722
|
+
Command.prototype.examples = function(examples) {
|
|
4723
|
+
examplesByCommand.set(this, examples);
|
|
4724
|
+
return this;
|
|
4725
|
+
};
|
|
4726
|
+
// ../common/src/preview.ts
|
|
4727
|
+
var previewSlot = singleton("PreviewBuild");
|
|
4728
|
+
function isPreviewBuild() {
|
|
4729
|
+
return previewSlot.get(false) ?? false;
|
|
4730
|
+
}
|
|
4731
|
+
Command.prototype.previewCommand = function(nameAndArgs, opts) {
|
|
4732
|
+
if (isPreviewBuild()) {
|
|
4733
|
+
return this.command(nameAndArgs, opts);
|
|
4734
|
+
}
|
|
4735
|
+
return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
|
|
4736
|
+
};
|
|
4025
4737
|
|
|
4026
4738
|
// ../common/src/telemetry/command-attribution.ts
|
|
4027
4739
|
var LEGACY_SKILL_NAMESPACE = "uipath:";
|
|
@@ -4176,6 +4888,57 @@ function buildCommandTelemetryAttribution(commandPath, skillSource) {
|
|
|
4176
4888
|
};
|
|
4177
4889
|
}
|
|
4178
4890
|
|
|
4891
|
+
// ../common/src/telemetry/command-name.ts
|
|
4892
|
+
var TELEMETRY_COMMAND_ROOT = "uip";
|
|
4893
|
+
function commandTelemetryName(parts) {
|
|
4894
|
+
const tokens = [];
|
|
4895
|
+
for (const part of parts) {
|
|
4896
|
+
const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== TELEMETRY_COMMAND_ROOT);
|
|
4897
|
+
if (pieces.every(isCommandToken)) {
|
|
4898
|
+
tokens.push(...pieces);
|
|
4899
|
+
continue;
|
|
4900
|
+
}
|
|
4901
|
+
tokens.push(UNKNOWN_TOKEN);
|
|
4902
|
+
}
|
|
4903
|
+
return [TELEMETRY_COMMAND_ROOT, ...tokens].join(".");
|
|
4904
|
+
}
|
|
4905
|
+
var COMMAND_TOKEN_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
4906
|
+
var MAX_COMMAND_TOKEN_LENGTH = 32;
|
|
4907
|
+
var GUID_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
4908
|
+
function isCommandToken(token) {
|
|
4909
|
+
return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token) && !/^\d+$/.test(token);
|
|
4910
|
+
}
|
|
4911
|
+
var UNKNOWN_TOKEN = "<unknown>";
|
|
4912
|
+
|
|
4913
|
+
// ../common/src/telemetry/invocation-request.ts
|
|
4914
|
+
var requestContextSlot = singleton("TelemetryInvocationRequestContext");
|
|
4915
|
+
function activeContext() {
|
|
4916
|
+
return telemetry.getActiveContext?.();
|
|
4917
|
+
}
|
|
4918
|
+
function runWithInvocationRequest(fn) {
|
|
4919
|
+
const context = telemetry.createRequestContext();
|
|
4920
|
+
context.startedAt = invocationStartedAt();
|
|
4921
|
+
requestContextSlot.set(context);
|
|
4922
|
+
return telemetry.runWithContext(context, fn);
|
|
4923
|
+
}
|
|
4924
|
+
function ensureInvocationRequestScope(fn) {
|
|
4925
|
+
if (activeContext() !== undefined) {
|
|
4926
|
+
return fn();
|
|
4927
|
+
}
|
|
4928
|
+
const kept = requestContextSlot.get();
|
|
4929
|
+
return kept === undefined ? runWithInvocationRequest(fn) : telemetry.runWithContext(kept, fn);
|
|
4930
|
+
}
|
|
4931
|
+
function getInvocationRequestContext() {
|
|
4932
|
+
return activeContext() ?? requestContextSlot.get();
|
|
4933
|
+
}
|
|
4934
|
+
function emitInvocationRequest(name, success, properties) {
|
|
4935
|
+
const context = getInvocationRequestContext();
|
|
4936
|
+
telemetry.trackRequestResult(name, invocationElapsedMs(), success, properties, context);
|
|
4937
|
+
if (context !== undefined && requestContextSlot.get() === context) {
|
|
4938
|
+
requestContextSlot.clear();
|
|
4939
|
+
}
|
|
4940
|
+
}
|
|
4941
|
+
|
|
4179
4942
|
// ../common/src/trackedAction.ts
|
|
4180
4943
|
var pollSignalSlot = singleton("PollSignal");
|
|
4181
4944
|
var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
|
|
@@ -4183,28 +4946,74 @@ var retryHintValues = new Set(RETRY_HINTS);
|
|
|
4183
4946
|
var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
|
|
4184
4947
|
var processContext = {
|
|
4185
4948
|
exit: (code) => {
|
|
4186
|
-
|
|
4949
|
+
recordExitCode(code);
|
|
4950
|
+
setExitCode(code);
|
|
4187
4951
|
},
|
|
4188
4952
|
get pollSignal() {
|
|
4189
4953
|
return pollSignalSlot.get();
|
|
4190
4954
|
}
|
|
4191
4955
|
};
|
|
4956
|
+
var TELEMETRY_ARG_VALUE_WITHHELD = "<provided>";
|
|
4957
|
+
var TELEMETRY_ARG_VALUE_DEFAULTED = "<default>";
|
|
4958
|
+
function recordableArgValue(value, choices) {
|
|
4959
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
4960
|
+
return value;
|
|
4961
|
+
}
|
|
4962
|
+
if (choices && choices.length > 0) {
|
|
4963
|
+
if (typeof value === "string" && choices.includes(value)) {
|
|
4964
|
+
return value;
|
|
4965
|
+
}
|
|
4966
|
+
if (Array.isArray(value) && value.length > 0 && value.every((entry) => typeof entry === "string" && choices.includes(entry))) {
|
|
4967
|
+
return value.join(",");
|
|
4968
|
+
}
|
|
4969
|
+
}
|
|
4970
|
+
return TELEMETRY_ARG_VALUE_WITHHELD;
|
|
4971
|
+
}
|
|
4192
4972
|
function extractCommandParams(cmd) {
|
|
4193
4973
|
const params = {};
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4974
|
+
forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
|
|
4975
|
+
const recordable = recordableArgValue(value, choices);
|
|
4976
|
+
params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
|
|
4977
|
+
});
|
|
4978
|
+
return params;
|
|
4979
|
+
}
|
|
4980
|
+
function isDefaultedOption(cmd, name) {
|
|
4981
|
+
const source = cmd.getOptionValueSource?.(name);
|
|
4982
|
+
return source === "default" || source === "implied";
|
|
4983
|
+
}
|
|
4984
|
+
function isDefaultedPositional(cmd, index) {
|
|
4985
|
+
return index >= (cmd.args?.length ?? 0);
|
|
4986
|
+
}
|
|
4987
|
+
function forEachSuppliedArgument(cmd, visit) {
|
|
4199
4988
|
const registered = cmd.registeredArguments ?? [];
|
|
4200
4989
|
const processed = cmd.processedArgs ?? [];
|
|
4201
4990
|
for (let i = 0;i < registered.length; i++) {
|
|
4202
|
-
|
|
4991
|
+
const name = registered[i].name();
|
|
4992
|
+
if (name && processed[i] !== undefined) {
|
|
4993
|
+
visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
|
|
4994
|
+
}
|
|
4995
|
+
}
|
|
4996
|
+
const choicesByAttribute = new Map;
|
|
4997
|
+
for (const option of cmd.options) {
|
|
4998
|
+
choicesByAttribute.set(option.attributeName(), option.argChoices);
|
|
4203
4999
|
}
|
|
4204
5000
|
for (const [key, value] of Object.entries(cmd.opts())) {
|
|
4205
|
-
|
|
5001
|
+
if (key && value !== undefined) {
|
|
5002
|
+
visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
|
|
5003
|
+
}
|
|
4206
5004
|
}
|
|
4207
|
-
|
|
5005
|
+
}
|
|
5006
|
+
function withheldArgumentValues(cmd) {
|
|
5007
|
+
const values = [];
|
|
5008
|
+
forEachSuppliedArgument(cmd, (_name, value, choices, defaulted) => {
|
|
5009
|
+
if (defaulted) {
|
|
5010
|
+
return;
|
|
5011
|
+
}
|
|
5012
|
+
if (recordableArgValue(value, choices) === TELEMETRY_ARG_VALUE_WITHHELD) {
|
|
5013
|
+
values.push(value);
|
|
5014
|
+
}
|
|
5015
|
+
});
|
|
5016
|
+
return values;
|
|
4208
5017
|
}
|
|
4209
5018
|
function deriveCommandPath(cmd) {
|
|
4210
5019
|
const parts = [];
|
|
@@ -4219,7 +5028,7 @@ function deriveCommandPath(cmd) {
|
|
|
4219
5028
|
if (parts.length > 1) {
|
|
4220
5029
|
parts.shift();
|
|
4221
5030
|
}
|
|
4222
|
-
return
|
|
5031
|
+
return commandTelemetryName(parts);
|
|
4223
5032
|
}
|
|
4224
5033
|
function isCliErrorCode(value) {
|
|
4225
5034
|
return typeof value === "string" && cliErrorCodeValues.has(value);
|
|
@@ -4259,68 +5068,77 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
4259
5068
|
});
|
|
4260
5069
|
const telemetryName = deriveCommandPath(command);
|
|
4261
5070
|
const props = typeof properties === "function" ? properties(...args) : properties;
|
|
4262
|
-
|
|
4263
|
-
const
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
5071
|
+
markCommandStart();
|
|
5072
|
+
const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
|
|
5073
|
+
try {
|
|
5074
|
+
const startTime = performance.now();
|
|
5075
|
+
let errorMessage;
|
|
5076
|
+
let fallbackExitCode = EXIT_CODES.Success;
|
|
5077
|
+
clearRecordedCommandFailureTelemetry();
|
|
5078
|
+
const [error] = await catchError(ensureInvocationRequestScope(() => {
|
|
5079
|
+
const violation = implicitLimitViolation(command);
|
|
5080
|
+
if (violation) {
|
|
5081
|
+
return Promise.reject(violation);
|
|
5082
|
+
}
|
|
5083
|
+
return fn(...args);
|
|
5084
|
+
}));
|
|
5085
|
+
if (error) {
|
|
5086
|
+
errorMessage = error instanceof Error ? error.message : String(error);
|
|
5087
|
+
logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
|
|
5088
|
+
const typed = error;
|
|
5089
|
+
const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
|
|
5090
|
+
const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
|
|
5091
|
+
const finalResult = customResult ?? RESULTS.Failure;
|
|
5092
|
+
const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
|
|
5093
|
+
const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
|
|
5094
|
+
const typedRetry = typed.retry ?? typed.Retry;
|
|
5095
|
+
const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
|
|
5096
|
+
const typedContext = typed.context ?? typed.Context;
|
|
5097
|
+
const customContext = isErrorContext(typedContext) ? typedContext : undefined;
|
|
5098
|
+
const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
|
|
5099
|
+
fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
|
|
5100
|
+
OutputFormatter.error({
|
|
5101
|
+
Result: finalResult,
|
|
5102
|
+
...customErrorCode ? { ErrorCode: customErrorCode } : {},
|
|
5103
|
+
Message: errorMessage,
|
|
5104
|
+
Instructions: customInstructions ?? commandHelpHint(telemetryName),
|
|
5105
|
+
...customRetry ? { Retry: customRetry } : {},
|
|
5106
|
+
...customContext ? { Context: customContext } : {}
|
|
5107
|
+
});
|
|
5108
|
+
context.exit(fallbackExitCode);
|
|
5109
|
+
}
|
|
5110
|
+
const durationMs = performance.now() - startTime;
|
|
5111
|
+
recordCommandDuration(durationMs);
|
|
5112
|
+
const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
|
|
5113
|
+
const recordedFailure = takeRecordedCommandFailureTelemetry();
|
|
5114
|
+
const success = !error && exitCode === 0;
|
|
5115
|
+
const terminalTelemetry = buildCommandTerminalTelemetryProperties({
|
|
5116
|
+
error,
|
|
5117
|
+
exitCode,
|
|
5118
|
+
recordedFailure,
|
|
5119
|
+
pollSignal: context.pollSignal
|
|
4296
5120
|
});
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
}
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
|
|
4319
|
-
command: "true",
|
|
4320
|
-
...terminalTelemetry,
|
|
4321
|
-
...errorMessage ? { errorMessage } : {}
|
|
4322
|
-
});
|
|
4323
|
-
telemetry.trackRequestResult(telemetryName, durationMs, success, baseProperties, requestContext);
|
|
5121
|
+
if (terminalTelemetry.error_class === "internal" && error) {
|
|
5122
|
+
telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { command_name: telemetryName }, getInvocationRequestContext());
|
|
5123
|
+
}
|
|
5124
|
+
const commandParams = extractCommandParams(command);
|
|
5125
|
+
if (props) {
|
|
5126
|
+
for (const key of Object.keys(props)) {
|
|
5127
|
+
delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
|
|
5128
|
+
}
|
|
5129
|
+
}
|
|
5130
|
+
const baseProperties = redactProperties({
|
|
5131
|
+
...commandParams,
|
|
5132
|
+
...props,
|
|
5133
|
+
...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
|
|
5134
|
+
command: "true",
|
|
5135
|
+
...terminalTelemetry,
|
|
5136
|
+
...errorMessage ? { errorMessage } : {}
|
|
5137
|
+
});
|
|
5138
|
+
emitInvocationRequest(telemetryName, success, baseProperties);
|
|
5139
|
+
} finally {
|
|
5140
|
+
releaseSuppliedArgumentValues(supplied);
|
|
5141
|
+
}
|
|
4324
5142
|
});
|
|
4325
5143
|
};
|
|
4326
5144
|
// ../common/src/completer.ts
|
|
@@ -4330,6 +5148,204 @@ var guardInstalledSlot = singleton("ConsoleGuardInstalled");
|
|
|
4330
5148
|
var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
|
|
4331
5149
|
// ../common/src/constants.ts
|
|
4332
5150
|
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
5151
|
+
// ../common/src/entity-name-rules.ts
|
|
5152
|
+
var RESERVED_SQL_KEYWORDS_LOWER = new Set(["group", "order"]);
|
|
5153
|
+
var RESERVED_FIELD_NAMES_LOWER = new Set([
|
|
5154
|
+
"id",
|
|
5155
|
+
"createdby",
|
|
5156
|
+
"createtime",
|
|
5157
|
+
"updatedby",
|
|
5158
|
+
"updatetime",
|
|
5159
|
+
"recordowner",
|
|
5160
|
+
"version"
|
|
5161
|
+
]);
|
|
5162
|
+
var RESERVED_KEYWORDS_LOWER = new Set([
|
|
5163
|
+
"abstract",
|
|
5164
|
+
"as",
|
|
5165
|
+
"base",
|
|
5166
|
+
"bool",
|
|
5167
|
+
"break",
|
|
5168
|
+
"byte",
|
|
5169
|
+
"case",
|
|
5170
|
+
"catch",
|
|
5171
|
+
"char",
|
|
5172
|
+
"checked",
|
|
5173
|
+
"class",
|
|
5174
|
+
"const",
|
|
5175
|
+
"continue",
|
|
5176
|
+
"decimal",
|
|
5177
|
+
"default",
|
|
5178
|
+
"delegate",
|
|
5179
|
+
"do",
|
|
5180
|
+
"double",
|
|
5181
|
+
"else",
|
|
5182
|
+
"enum",
|
|
5183
|
+
"event",
|
|
5184
|
+
"explicit",
|
|
5185
|
+
"extern",
|
|
5186
|
+
"false",
|
|
5187
|
+
"finally",
|
|
5188
|
+
"fixed",
|
|
5189
|
+
"float",
|
|
5190
|
+
"for",
|
|
5191
|
+
"foreach",
|
|
5192
|
+
"goto",
|
|
5193
|
+
"if",
|
|
5194
|
+
"implicit",
|
|
5195
|
+
"in",
|
|
5196
|
+
"int",
|
|
5197
|
+
"interface",
|
|
5198
|
+
"internal",
|
|
5199
|
+
"is",
|
|
5200
|
+
"lock",
|
|
5201
|
+
"long",
|
|
5202
|
+
"namespace",
|
|
5203
|
+
"new",
|
|
5204
|
+
"null",
|
|
5205
|
+
"object",
|
|
5206
|
+
"operator",
|
|
5207
|
+
"out",
|
|
5208
|
+
"override",
|
|
5209
|
+
"params",
|
|
5210
|
+
"private",
|
|
5211
|
+
"protected",
|
|
5212
|
+
"public",
|
|
5213
|
+
"readonly",
|
|
5214
|
+
"ref",
|
|
5215
|
+
"return",
|
|
5216
|
+
"sbyte",
|
|
5217
|
+
"sealed",
|
|
5218
|
+
"short",
|
|
5219
|
+
"sizeof",
|
|
5220
|
+
"stackalloc",
|
|
5221
|
+
"static",
|
|
5222
|
+
"string",
|
|
5223
|
+
"struct",
|
|
5224
|
+
"switch",
|
|
5225
|
+
"this",
|
|
5226
|
+
"throw",
|
|
5227
|
+
"true",
|
|
5228
|
+
"try",
|
|
5229
|
+
"typeof",
|
|
5230
|
+
"uint",
|
|
5231
|
+
"ulong",
|
|
5232
|
+
"unchecked",
|
|
5233
|
+
"unsafe",
|
|
5234
|
+
"ushort",
|
|
5235
|
+
"using",
|
|
5236
|
+
"virtual",
|
|
5237
|
+
"void",
|
|
5238
|
+
"volatile",
|
|
5239
|
+
"while",
|
|
5240
|
+
"addhandler",
|
|
5241
|
+
"addressof",
|
|
5242
|
+
"alias",
|
|
5243
|
+
"and",
|
|
5244
|
+
"andalso",
|
|
5245
|
+
"boolean",
|
|
5246
|
+
"byref",
|
|
5247
|
+
"byval",
|
|
5248
|
+
"call",
|
|
5249
|
+
"cbool",
|
|
5250
|
+
"cbyte",
|
|
5251
|
+
"cchar",
|
|
5252
|
+
"cdate",
|
|
5253
|
+
"cdbl",
|
|
5254
|
+
"cdec",
|
|
5255
|
+
"cint",
|
|
5256
|
+
"clng",
|
|
5257
|
+
"cobj",
|
|
5258
|
+
"csbyte",
|
|
5259
|
+
"cshort",
|
|
5260
|
+
"csng",
|
|
5261
|
+
"cstr",
|
|
5262
|
+
"ctype",
|
|
5263
|
+
"cuint",
|
|
5264
|
+
"culng",
|
|
5265
|
+
"cushort",
|
|
5266
|
+
"date",
|
|
5267
|
+
"declare",
|
|
5268
|
+
"dim",
|
|
5269
|
+
"directcast",
|
|
5270
|
+
"each",
|
|
5271
|
+
"elseif",
|
|
5272
|
+
"end",
|
|
5273
|
+
"endif",
|
|
5274
|
+
"erase",
|
|
5275
|
+
"error",
|
|
5276
|
+
"exit",
|
|
5277
|
+
"friend",
|
|
5278
|
+
"function",
|
|
5279
|
+
"get",
|
|
5280
|
+
"gettype",
|
|
5281
|
+
"getxmlnamespace",
|
|
5282
|
+
"global",
|
|
5283
|
+
"gosub",
|
|
5284
|
+
"goto",
|
|
5285
|
+
"handles",
|
|
5286
|
+
"implements",
|
|
5287
|
+
"imports",
|
|
5288
|
+
"inherits",
|
|
5289
|
+
"integer",
|
|
5290
|
+
"isnot",
|
|
5291
|
+
"let",
|
|
5292
|
+
"lib",
|
|
5293
|
+
"like",
|
|
5294
|
+
"loop",
|
|
5295
|
+
"me",
|
|
5296
|
+
"mod",
|
|
5297
|
+
"module",
|
|
5298
|
+
"mustinherit",
|
|
5299
|
+
"mustoverride",
|
|
5300
|
+
"mybase",
|
|
5301
|
+
"myclass",
|
|
5302
|
+
"narrowing",
|
|
5303
|
+
"next",
|
|
5304
|
+
"not",
|
|
5305
|
+
"nothing",
|
|
5306
|
+
"notinheritable",
|
|
5307
|
+
"notoverridable",
|
|
5308
|
+
"of",
|
|
5309
|
+
"on",
|
|
5310
|
+
"option",
|
|
5311
|
+
"optional",
|
|
5312
|
+
"or",
|
|
5313
|
+
"orelse",
|
|
5314
|
+
"overloads",
|
|
5315
|
+
"overridable",
|
|
5316
|
+
"overrides",
|
|
5317
|
+
"paramarray",
|
|
5318
|
+
"partial",
|
|
5319
|
+
"property",
|
|
5320
|
+
"raiseevent",
|
|
5321
|
+
"redim",
|
|
5322
|
+
"rem",
|
|
5323
|
+
"removehandler",
|
|
5324
|
+
"resume",
|
|
5325
|
+
"select",
|
|
5326
|
+
"set",
|
|
5327
|
+
"shadows",
|
|
5328
|
+
"shared",
|
|
5329
|
+
"single",
|
|
5330
|
+
"step",
|
|
5331
|
+
"stop",
|
|
5332
|
+
"structure",
|
|
5333
|
+
"sub",
|
|
5334
|
+
"synclock",
|
|
5335
|
+
"then",
|
|
5336
|
+
"to",
|
|
5337
|
+
"trycast",
|
|
5338
|
+
"uinteger",
|
|
5339
|
+
"ushort",
|
|
5340
|
+
"variant",
|
|
5341
|
+
"wend",
|
|
5342
|
+
"when",
|
|
5343
|
+
"widening",
|
|
5344
|
+
"with",
|
|
5345
|
+
"withevents",
|
|
5346
|
+
"writeonly",
|
|
5347
|
+
"xor"
|
|
5348
|
+
]);
|
|
4333
5349
|
// ../common/src/host-global-options.ts
|
|
4334
5350
|
var HOST_GLOBAL_OPTIONS_WITH_VALUE = [
|
|
4335
5351
|
"--output",
|
|
@@ -4497,7 +5513,7 @@ class InsightsProtocolError extends Error {
|
|
|
4497
5513
|
var package_default2 = {
|
|
4498
5514
|
name: "@uipath/insights-sdk",
|
|
4499
5515
|
license: "MIT",
|
|
4500
|
-
version: "1.
|
|
5516
|
+
version: "1.202.0-preview.136",
|
|
4501
5517
|
description: "SDK for the UiPath Insights API — jobs, failures, and performance metrics.",
|
|
4502
5518
|
repository: {
|
|
4503
5519
|
type: "git",
|
|
@@ -4716,7 +5732,7 @@ function classifyErrorBody(text) {
|
|
|
4716
5732
|
if (head.startsWith("<!doctype") || head.startsWith("<html")) {
|
|
4717
5733
|
return "html";
|
|
4718
5734
|
}
|
|
4719
|
-
const [parseError] =
|
|
5735
|
+
const [parseError] = catchError(() => JSON.parse(text));
|
|
4720
5736
|
if (!parseError) {
|
|
4721
5737
|
return "json";
|
|
4722
5738
|
}
|
|
@@ -4745,10 +5761,10 @@ async function requestInsightsRoute(config, routeKey, request = {}) {
|
|
|
4745
5761
|
if (!route) {
|
|
4746
5762
|
throw new Error(`Unsupported Insights route "${routeKey}".`);
|
|
4747
5763
|
}
|
|
4748
|
-
const
|
|
4749
|
-
const url = `${config.baseUrl}/${encodePathSegment(routeKey, "organizationId", config.organizationId)}/${encodePathSegment(routeKey, "tenantName", config.tenantName)}/${SERVICE_ROOTS[route.service]}/${
|
|
5764
|
+
const path2 = buildRoutePath(routeKey, route.template, config, request.pathParams ?? {});
|
|
5765
|
+
const url = `${config.baseUrl}/${encodePathSegment(routeKey, "organizationId", config.organizationId)}/${encodePathSegment(routeKey, "tenantName", config.tenantName)}/${SERVICE_ROOTS[route.service]}/${path2}`;
|
|
4750
5766
|
const hasBody = request.body !== undefined;
|
|
4751
|
-
const [fetchError, response] = await
|
|
5767
|
+
const [fetchError, response] = await catchError(fetch(url, {
|
|
4752
5768
|
method: route.method,
|
|
4753
5769
|
headers: buildServiceHeaders(config, route.service, hasBody),
|
|
4754
5770
|
body: hasBody ? JSON.stringify(request.body) : undefined
|
|
@@ -4756,7 +5772,7 @@ async function requestInsightsRoute(config, routeKey, request = {}) {
|
|
|
4756
5772
|
if (fetchError) {
|
|
4757
5773
|
throw new InsightsNetworkError(route.template, fetchError);
|
|
4758
5774
|
}
|
|
4759
|
-
const [readError, text] = await
|
|
5775
|
+
const [readError, text] = await catchError(response.text());
|
|
4760
5776
|
if (readError) {
|
|
4761
5777
|
if (!response.ok) {
|
|
4762
5778
|
throw httpErrorFrom(response, route, "absent", readError);
|
|
@@ -4772,7 +5788,7 @@ async function requestInsightsRoute(config, routeKey, request = {}) {
|
|
|
4772
5788
|
}
|
|
4773
5789
|
throw new InsightsProtocolError(route.template, "empty response body");
|
|
4774
5790
|
}
|
|
4775
|
-
const [parseError, parsed] =
|
|
5791
|
+
const [parseError, parsed] = catchError(() => JSON.parse(text));
|
|
4776
5792
|
if (parseError) {
|
|
4777
5793
|
throw new InsightsProtocolError(route.template, "response body is not valid JSON");
|
|
4778
5794
|
}
|
|
@@ -4798,9 +5814,28 @@ async function getAlertDefinition(config, alertDefinitionId) {
|
|
|
4798
5814
|
async function checkAlertEntitlement(config) {
|
|
4799
5815
|
return requestInsightsRoute(config, "alertDefinitionsCheckEntitlement");
|
|
4800
5816
|
}
|
|
5817
|
+
function withSessionTenantId(config, request) {
|
|
5818
|
+
const base = typeof request === "object" && request !== null && !Array.isArray(request) ? request : {};
|
|
5819
|
+
return { ...base, tenantId: config.tenantId };
|
|
5820
|
+
}
|
|
5821
|
+
async function listAlertHistoryDetails(config, request) {
|
|
5822
|
+
return requestInsightsRoute(config, "alertHistoryDetails", {
|
|
5823
|
+
body: withSessionTenantId(config, request)
|
|
5824
|
+
});
|
|
5825
|
+
}
|
|
5826
|
+
async function getAlertHistoryMetrics(config, request) {
|
|
5827
|
+
return requestInsightsRoute(config, "alertHistoryMetrics", {
|
|
5828
|
+
body: withSessionTenantId(config, request)
|
|
5829
|
+
});
|
|
5830
|
+
}
|
|
5831
|
+
async function getDefaultDelivery(config, alertDeliveryId) {
|
|
5832
|
+
return requestInsightsRoute(config, "defaultDeliveryGet", {
|
|
5833
|
+
pathParams: { alertDeliveryId }
|
|
5834
|
+
});
|
|
5835
|
+
}
|
|
4801
5836
|
// ../insights-sdk/src/client.ts
|
|
4802
|
-
function buildInsightsUrl(config,
|
|
4803
|
-
return `${config.baseUrl}/${config.organizationId}/${config.tenantName}/insightsrtm_/api/v1.0/InsightsJobs${
|
|
5837
|
+
function buildInsightsUrl(config, path2) {
|
|
5838
|
+
return `${config.baseUrl}/${config.organizationId}/${config.tenantName}/insightsrtm_/api/v1.0/InsightsJobs${path2}`;
|
|
4804
5839
|
}
|
|
4805
5840
|
function buildHeaders(config) {
|
|
4806
5841
|
return {
|
|
@@ -4811,8 +5846,8 @@ function buildHeaders(config) {
|
|
|
4811
5846
|
"X-UiPath-Internal-TenantName": config.tenantName
|
|
4812
5847
|
};
|
|
4813
5848
|
}
|
|
4814
|
-
async function insightsPost(config,
|
|
4815
|
-
const url = buildInsightsUrl(config,
|
|
5849
|
+
async function insightsPost(config, path2, body) {
|
|
5850
|
+
const url = buildInsightsUrl(config, path2);
|
|
4816
5851
|
const headers = buildHeaders(config);
|
|
4817
5852
|
const response = await fetch(url, {
|
|
4818
5853
|
method: "POST",
|
|
@@ -4826,12 +5861,46 @@ async function insightsPost(config, path, body) {
|
|
|
4826
5861
|
const text = await response.text();
|
|
4827
5862
|
if (!text)
|
|
4828
5863
|
throw new Error("API returned an empty response body");
|
|
4829
|
-
const [parseErr, parsed] =
|
|
5864
|
+
const [parseErr, parsed] = catchError(() => JSON.parse(text));
|
|
4830
5865
|
if (parseErr) {
|
|
4831
5866
|
throw new Error(`Failed to parse API response body: ${parseErr.message}`);
|
|
4832
5867
|
}
|
|
4833
5868
|
return parsed;
|
|
4834
5869
|
}
|
|
5870
|
+
// ../auth/src/catch-error.ts
|
|
5871
|
+
function isPromiseLike2(value) {
|
|
5872
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
5873
|
+
}
|
|
5874
|
+
function catchError2(fnOrPromise) {
|
|
5875
|
+
if (isPromiseLike2(fnOrPromise)) {
|
|
5876
|
+
return settlePromiseLike2(fnOrPromise);
|
|
5877
|
+
}
|
|
5878
|
+
try {
|
|
5879
|
+
const result = fnOrPromise();
|
|
5880
|
+
if (isPromiseLike2(result)) {
|
|
5881
|
+
return settlePromiseLike2(result);
|
|
5882
|
+
}
|
|
5883
|
+
return [undefined, result];
|
|
5884
|
+
} catch (error) {
|
|
5885
|
+
return [
|
|
5886
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
5887
|
+
undefined
|
|
5888
|
+
];
|
|
5889
|
+
}
|
|
5890
|
+
}
|
|
5891
|
+
function settlePromiseLike2(thenable) {
|
|
5892
|
+
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
|
|
5893
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
5894
|
+
undefined
|
|
5895
|
+
]);
|
|
5896
|
+
}
|
|
5897
|
+
|
|
5898
|
+
// ../auth/src/constants.ts
|
|
5899
|
+
var UIPATH_HOME_DIR = ".uipath";
|
|
5900
|
+
var AUTH_FILENAME = ".auth";
|
|
5901
|
+
var DEFAULT_BASE_URL = "https://cloud.uipath.com";
|
|
5902
|
+
var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
|
|
5903
|
+
|
|
4835
5904
|
// ../auth/src/config.ts
|
|
4836
5905
|
var DEFAULT_CLIENT_ID = "36dea5b8-e8bb-423d-8e7b-c808df8f1c00";
|
|
4837
5906
|
var AUTH_FILE_CONFIG_KEY = Symbol.for("@uipath/auth/AuthFileConfig");
|
|
@@ -4845,7 +5914,7 @@ class InvalidBaseUrlError extends Error {
|
|
|
4845
5914
|
super(`Invalid base URL: "${url}"
|
|
4846
5915
|
` + `Reason: ${reason}
|
|
4847
5916
|
|
|
4848
|
-
` + `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>).
|
|
5917
|
+
` + `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>).
|
|
4849
5918
|
` + `You can specify the URL via:
|
|
4850
5919
|
` + ` • --authority flag
|
|
4851
5920
|
` + ` • UIPATH_URL environment variable
|
|
@@ -4866,10 +5935,16 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
|
|
|
4866
5935
|
while (baseUrl.endsWith("/")) {
|
|
4867
5936
|
baseUrl = baseUrl.slice(0, -1);
|
|
4868
5937
|
}
|
|
5938
|
+
const hasScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(baseUrl);
|
|
5939
|
+
const [hostCandidate] = baseUrl.split(/[/?#]/, 1);
|
|
5940
|
+
if (!hasScheme && hostCandidate.includes(".")) {
|
|
5941
|
+
baseUrl = `https://${baseUrl}`;
|
|
5942
|
+
}
|
|
4869
5943
|
const resolvedBaseUrl = baseUrl;
|
|
4870
|
-
const [urlError, url] =
|
|
5944
|
+
const [urlError, url] = catchError2(() => new URL(resolvedBaseUrl));
|
|
4871
5945
|
if (urlError) {
|
|
4872
|
-
|
|
5946
|
+
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"}`;
|
|
5947
|
+
throw new InvalidBaseUrlError(baseUrl, `Malformed URL.${shapeHint}`);
|
|
4873
5948
|
}
|
|
4874
5949
|
if (url.protocol !== "https:") {
|
|
4875
5950
|
throw new InvalidBaseUrlError(baseUrl, `Authority must use https:// scheme, got ${url.protocol}//. OIDC token exchange requires TLS end-to-end.`);
|
|
@@ -4924,6 +5999,11 @@ var resolveConfigAsync = async ({
|
|
|
4924
5999
|
};
|
|
4925
6000
|
};
|
|
4926
6001
|
|
|
6002
|
+
// ../auth/src/utils/platform.ts
|
|
6003
|
+
function isBrowser() {
|
|
6004
|
+
return typeof globalThis !== "undefined" && "window" in globalThis && "document" in globalThis;
|
|
6005
|
+
}
|
|
6006
|
+
|
|
4927
6007
|
// ../auth/src/authProfile.ts
|
|
4928
6008
|
var DEFAULT_AUTH_PROFILE = "default";
|
|
4929
6009
|
var PROFILE_DIR = "profiles";
|
|
@@ -4935,7 +6015,7 @@ function isAuthProfileStorage(value) {
|
|
|
4935
6015
|
return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
|
|
4936
6016
|
}
|
|
4937
6017
|
function createProfileStorage() {
|
|
4938
|
-
const [error, mod] =
|
|
6018
|
+
const [error, mod] = catchError2(() => __require("node:async_hooks"));
|
|
4939
6019
|
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
4940
6020
|
return {
|
|
4941
6021
|
getStore: () => {
|
|
@@ -4951,9 +6031,9 @@ function getProfileStorage() {
|
|
|
4951
6031
|
if (isAuthProfileStorage(existing)) {
|
|
4952
6032
|
return existing;
|
|
4953
6033
|
}
|
|
4954
|
-
const
|
|
4955
|
-
globalSlot2[AUTH_PROFILE_STORAGE_KEY] =
|
|
4956
|
-
return
|
|
6034
|
+
const storage2 = createProfileStorage();
|
|
6035
|
+
globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage2;
|
|
6036
|
+
return storage2;
|
|
4957
6037
|
}
|
|
4958
6038
|
var profileStorage = getProfileStorage();
|
|
4959
6039
|
|
|
@@ -4984,8 +6064,8 @@ function resolveAuthProfileFilePath(profile) {
|
|
|
4984
6064
|
if (normalized === undefined) {
|
|
4985
6065
|
throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
|
|
4986
6066
|
}
|
|
4987
|
-
const
|
|
4988
|
-
return
|
|
6067
|
+
const fs2 = getFileSystem();
|
|
6068
|
+
return fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
|
|
4989
6069
|
}
|
|
4990
6070
|
function getActiveAuthProfileFilePath() {
|
|
4991
6071
|
const profile = getActiveAuthProfile();
|
|
@@ -5066,7 +6146,7 @@ var getTokenExpiration = (accessToken) => {
|
|
|
5066
6146
|
// ../auth/src/sessionIdentity.ts
|
|
5067
6147
|
var parseAuthFlow = (value) => value === "authorization_code" || value === "client_credentials" || value === "federated_credentials" ? value : undefined;
|
|
5068
6148
|
var decodeClaims = (accessToken) => {
|
|
5069
|
-
const [error, claims] =
|
|
6149
|
+
const [error, claims] = catchError2(() => parseJWT(accessToken));
|
|
5070
6150
|
return error ? undefined : claims;
|
|
5071
6151
|
};
|
|
5072
6152
|
var asString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
|
|
@@ -5150,27 +6230,48 @@ var requireEnv = (name) => {
|
|
|
5150
6230
|
}
|
|
5151
6231
|
return value;
|
|
5152
6232
|
};
|
|
6233
|
+
var OPAQUE_TOKEN_BASE_URL_VAR = "UIPATH_URL";
|
|
6234
|
+
var resolveBaseUrl = (rawUrl, failureContext) => {
|
|
6235
|
+
const [baseUrlError, baseUrl] = catchError2(() => normalizeAndValidateBaseUrl(rawUrl));
|
|
6236
|
+
if (baseUrlError) {
|
|
6237
|
+
if (baseUrlError instanceof InvalidBaseUrlError) {
|
|
6238
|
+
throw baseUrlError;
|
|
6239
|
+
}
|
|
6240
|
+
throw new EnvAuthConfigError(`${failureContext}: ` + `${baseUrlError instanceof Error ? baseUrlError.message : String(baseUrlError)}`);
|
|
6241
|
+
}
|
|
6242
|
+
return baseUrl;
|
|
6243
|
+
};
|
|
5153
6244
|
var readAuthFromEnv = () => {
|
|
5154
6245
|
const accessToken = requireEnv(ENV_AUTH_VARS.token);
|
|
5155
6246
|
const organizationName = requireEnv(ENV_AUTH_VARS.organizationName);
|
|
5156
6247
|
const organizationId = requireEnv(ENV_AUTH_VARS.organizationId);
|
|
5157
6248
|
const tenantName = requireEnv(ENV_AUTH_VARS.tenantName);
|
|
5158
6249
|
const tenantId = requireEnv(ENV_AUTH_VARS.tenantId);
|
|
5159
|
-
const [parseError, payload] =
|
|
6250
|
+
const [parseError, payload] = catchError2(() => parseJWT(accessToken));
|
|
5160
6251
|
if (parseError) {
|
|
5161
|
-
|
|
6252
|
+
const parseErrorMessage = parseError instanceof Error ? parseError.message : String(parseError);
|
|
6253
|
+
const rawUrl = process.env[OPAQUE_TOKEN_BASE_URL_VAR];
|
|
6254
|
+
if (!rawUrl) {
|
|
6255
|
+
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}).`);
|
|
6256
|
+
}
|
|
6257
|
+
const baseUrl2 = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
|
|
6258
|
+
return {
|
|
6259
|
+
loginStatus: "Logged in",
|
|
6260
|
+
accessToken,
|
|
6261
|
+
baseUrl: baseUrl2,
|
|
6262
|
+
organizationName,
|
|
6263
|
+
organizationId,
|
|
6264
|
+
tenantName,
|
|
6265
|
+
tenantId,
|
|
6266
|
+
source: "env-vars" /* EnvironmentVariables */,
|
|
6267
|
+
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}`
|
|
6268
|
+
};
|
|
5162
6269
|
}
|
|
5163
6270
|
const iss = payload.iss;
|
|
5164
6271
|
if (typeof iss !== "string" || iss.length === 0) {
|
|
5165
6272
|
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.`);
|
|
5166
6273
|
}
|
|
5167
|
-
const
|
|
5168
|
-
if (baseUrlError) {
|
|
5169
|
-
if (baseUrlError instanceof InvalidBaseUrlError) {
|
|
5170
|
-
throw baseUrlError;
|
|
5171
|
-
}
|
|
5172
|
-
throw new EnvAuthConfigError(`Failed to derive server URL from token 'iss' claim: ` + `${baseUrlError instanceof Error ? baseUrlError.message : String(baseUrlError)}`);
|
|
5173
|
-
}
|
|
6274
|
+
const baseUrl = resolveBaseUrl(iss, "Failed to derive server URL from token 'iss' claim");
|
|
5174
6275
|
const expiration = getTokenExpiration(accessToken);
|
|
5175
6276
|
const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
|
|
5176
6277
|
const identity = resolveSessionIdentity(accessToken);
|
|
@@ -5196,8 +6297,8 @@ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
|
|
|
5196
6297
|
async function refreshTokenFingerprint(refreshToken) {
|
|
5197
6298
|
const bytes = new TextEncoder().encode(refreshToken);
|
|
5198
6299
|
if (globalThis.crypto?.subtle) {
|
|
5199
|
-
const
|
|
5200
|
-
return Array.from(new Uint8Array(
|
|
6300
|
+
const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
6301
|
+
return Array.from(new Uint8Array(digest2), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
|
|
5201
6302
|
}
|
|
5202
6303
|
const { createHash } = await import("node:crypto");
|
|
5203
6304
|
return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
@@ -5206,9 +6307,9 @@ function breakerPathFor(authPath) {
|
|
|
5206
6307
|
return `${authPath}${BREAKER_SUFFIX}`;
|
|
5207
6308
|
}
|
|
5208
6309
|
async function loadRefreshBreaker(authPath) {
|
|
5209
|
-
const
|
|
6310
|
+
const fs2 = getFileSystem();
|
|
5210
6311
|
try {
|
|
5211
|
-
const content = await
|
|
6312
|
+
const content = await fs2.readFile(breakerPathFor(authPath), "utf-8");
|
|
5212
6313
|
if (!content)
|
|
5213
6314
|
return {};
|
|
5214
6315
|
const parsed = JSON.parse(content);
|
|
@@ -5219,20 +6320,20 @@ async function loadRefreshBreaker(authPath) {
|
|
|
5219
6320
|
}
|
|
5220
6321
|
async function saveRefreshBreaker(authPath, state) {
|
|
5221
6322
|
try {
|
|
5222
|
-
const
|
|
5223
|
-
const
|
|
5224
|
-
await
|
|
5225
|
-
const tempPath = `${
|
|
5226
|
-
await
|
|
5227
|
-
await
|
|
6323
|
+
const fs2 = getFileSystem();
|
|
6324
|
+
const path2 = breakerPathFor(authPath);
|
|
6325
|
+
await fs2.mkdir(fs2.path.dirname(path2));
|
|
6326
|
+
const tempPath = `${path2}.tmp`;
|
|
6327
|
+
await fs2.writeFile(tempPath, JSON.stringify(state));
|
|
6328
|
+
await fs2.rename(tempPath, path2);
|
|
5228
6329
|
} catch {}
|
|
5229
6330
|
}
|
|
5230
6331
|
async function clearRefreshBreaker(authPath) {
|
|
5231
|
-
const
|
|
5232
|
-
const
|
|
6332
|
+
const fs2 = getFileSystem();
|
|
6333
|
+
const path2 = breakerPathFor(authPath);
|
|
5233
6334
|
try {
|
|
5234
|
-
if (await
|
|
5235
|
-
await
|
|
6335
|
+
if (await fs2.exists(path2)) {
|
|
6336
|
+
await fs2.rm(path2);
|
|
5236
6337
|
}
|
|
5237
6338
|
} catch {}
|
|
5238
6339
|
}
|
|
@@ -5253,43 +6354,43 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
|
5253
6354
|
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
5254
6355
|
var PIPE_NAME_MAX_LENGTH = 103;
|
|
5255
6356
|
var getRobotIpcPipeNames = async () => {
|
|
5256
|
-
const
|
|
5257
|
-
const username =
|
|
6357
|
+
const fs2 = getFileSystem();
|
|
6358
|
+
const username = fs2.env.getenv("USER") ?? fs2.env.getenv("USERNAME");
|
|
5258
6359
|
if (!username) {
|
|
5259
6360
|
throw new Error("Unable to determine current username");
|
|
5260
6361
|
}
|
|
5261
|
-
const tempPath =
|
|
5262
|
-
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) =>
|
|
6362
|
+
const tempPath = fs2.env.getenv("TMPDIR") ?? "/tmp/";
|
|
6363
|
+
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs2.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
|
|
5263
6364
|
};
|
|
5264
6365
|
var defaultIsRobotIpcAvailable = async () => {
|
|
5265
6366
|
if (process.platform === "win32") {
|
|
5266
6367
|
return true;
|
|
5267
6368
|
}
|
|
5268
|
-
const [pipeNamesError, pipeNames] = await
|
|
6369
|
+
const [pipeNamesError, pipeNames] = await catchError2(getRobotIpcPipeNames());
|
|
5269
6370
|
if (pipeNamesError || !pipeNames) {
|
|
5270
6371
|
return false;
|
|
5271
6372
|
}
|
|
5272
|
-
const
|
|
6373
|
+
const fs2 = getFileSystem();
|
|
5273
6374
|
for (const pipeName of pipeNames) {
|
|
5274
|
-
const [existsError, exists] = await
|
|
6375
|
+
const [existsError, exists] = await catchError2(fs2.exists(pipeName));
|
|
5275
6376
|
if (!existsError && exists === true) {
|
|
5276
6377
|
return true;
|
|
5277
6378
|
}
|
|
5278
6379
|
}
|
|
5279
6380
|
return false;
|
|
5280
6381
|
};
|
|
5281
|
-
var withTimeout = (promise, timeoutMs) => new Promise((
|
|
6382
|
+
var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
|
|
5282
6383
|
const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
5283
6384
|
promise.then((value) => {
|
|
5284
6385
|
clearTimeout(timer);
|
|
5285
|
-
|
|
6386
|
+
resolve2(value);
|
|
5286
6387
|
}, (error) => {
|
|
5287
6388
|
clearTimeout(timer);
|
|
5288
6389
|
reject(error);
|
|
5289
6390
|
});
|
|
5290
6391
|
});
|
|
5291
6392
|
var parseResourceUrl = (url) => {
|
|
5292
|
-
const [error, parsed] =
|
|
6393
|
+
const [error, parsed] = catchError2(() => new URL(url));
|
|
5293
6394
|
if (error || !parsed)
|
|
5294
6395
|
return;
|
|
5295
6396
|
const segments = parsed.pathname.split("/").filter(Boolean);
|
|
@@ -5309,7 +6410,7 @@ var defaultLoadModule = async () => {
|
|
|
5309
6410
|
if (!hostLoader) {
|
|
5310
6411
|
return;
|
|
5311
6412
|
}
|
|
5312
|
-
const [error, mod] = await
|
|
6413
|
+
const [error, mod] = await catchError2(() => hostLoader());
|
|
5313
6414
|
if (error || !mod) {
|
|
5314
6415
|
return;
|
|
5315
6416
|
}
|
|
@@ -5335,7 +6436,7 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
5335
6436
|
const mod = await loadModule();
|
|
5336
6437
|
if (!mod)
|
|
5337
6438
|
return;
|
|
5338
|
-
const [ctorError, proxy] =
|
|
6439
|
+
const [ctorError, proxy] = catchError2(() => new mod.RobotProxyConstructor);
|
|
5339
6440
|
if (ctorError || !proxy) {
|
|
5340
6441
|
return;
|
|
5341
6442
|
}
|
|
@@ -5358,7 +6459,7 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
5358
6459
|
let organizationIdFromToken;
|
|
5359
6460
|
let tenantIdFromToken;
|
|
5360
6461
|
let issuerFromToken;
|
|
5361
|
-
const [jwtError, claims] =
|
|
6462
|
+
const [jwtError, claims] = catchError2(() => parseJWT(accessToken));
|
|
5362
6463
|
if (!jwtError && claims) {
|
|
5363
6464
|
const rawOrgId = claims.prtId ?? claims.organizationId ?? claims.prt_id;
|
|
5364
6465
|
if (typeof rawOrgId === "string" && rawOrgId.length > 0) {
|
|
@@ -5385,7 +6486,7 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
5385
6486
|
} catch {
|
|
5386
6487
|
return;
|
|
5387
6488
|
} finally {
|
|
5388
|
-
await
|
|
6489
|
+
await catchError2(() => withTimeout(proxy.CloseAsync(), CLOSE_TIMEOUT_MS));
|
|
5389
6490
|
}
|
|
5390
6491
|
};
|
|
5391
6492
|
|
|
@@ -5455,9 +6556,9 @@ var errorCode = (err) => {
|
|
|
5455
6556
|
}
|
|
5456
6557
|
return "EUNKNOWN";
|
|
5457
6558
|
};
|
|
5458
|
-
var probeAsync = async (
|
|
6559
|
+
var probeAsync = async (fs2, candidate) => {
|
|
5459
6560
|
try {
|
|
5460
|
-
const stats = await
|
|
6561
|
+
const stats = await fs2.stat(candidate);
|
|
5461
6562
|
if (stats === null) {
|
|
5462
6563
|
return { exists: false };
|
|
5463
6564
|
}
|
|
@@ -5484,9 +6585,9 @@ var probeAsync = async (fs, candidate) => {
|
|
|
5484
6585
|
}
|
|
5485
6586
|
};
|
|
5486
6587
|
var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
|
|
5487
|
-
const
|
|
5488
|
-
if (
|
|
5489
|
-
const probe2 = await probeAsync(
|
|
6588
|
+
const fs2 = getFileSystem();
|
|
6589
|
+
if (fs2.path.isAbsolute(envFilePath)) {
|
|
6590
|
+
const probe2 = await probeAsync(fs2, envFilePath);
|
|
5490
6591
|
return probe2.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
|
|
5491
6592
|
exists: false,
|
|
5492
6593
|
absolutePath: envFilePath,
|
|
@@ -5494,11 +6595,11 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opt
|
|
|
5494
6595
|
...probe2.unusable ? { unusable: probe2.unusable } : {}
|
|
5495
6596
|
};
|
|
5496
6597
|
}
|
|
5497
|
-
const cwd = opts?.cwd ??
|
|
6598
|
+
const cwd = opts?.cwd ?? fs2.env.cwd();
|
|
5498
6599
|
let searchDir = cwd;
|
|
5499
6600
|
while (true) {
|
|
5500
|
-
const candidate =
|
|
5501
|
-
const probe2 = await probeAsync(
|
|
6601
|
+
const candidate = fs2.path.join(searchDir, envFilePath);
|
|
6602
|
+
const probe2 = await probeAsync(fs2, candidate);
|
|
5502
6603
|
if (probe2.exists) {
|
|
5503
6604
|
return {
|
|
5504
6605
|
exists: true,
|
|
@@ -5506,14 +6607,14 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opt
|
|
|
5506
6607
|
source: searchDir === cwd ? "cwd" : "ancestor"
|
|
5507
6608
|
};
|
|
5508
6609
|
}
|
|
5509
|
-
const parentDir =
|
|
6610
|
+
const parentDir = fs2.path.dirname(searchDir);
|
|
5510
6611
|
if (parentDir === searchDir) {
|
|
5511
6612
|
break;
|
|
5512
6613
|
}
|
|
5513
6614
|
searchDir = parentDir;
|
|
5514
6615
|
}
|
|
5515
|
-
const homePath =
|
|
5516
|
-
const probe = await probeAsync(
|
|
6616
|
+
const homePath = fs2.path.join(fs2.env.homedir(), envFilePath);
|
|
6617
|
+
const probe = await probeAsync(fs2, homePath);
|
|
5517
6618
|
if (probe.exists) {
|
|
5518
6619
|
return { exists: true, absolutePath: homePath, source: "home" };
|
|
5519
6620
|
}
|
|
@@ -5535,12 +6636,12 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
|
|
|
5535
6636
|
};
|
|
5536
6637
|
};
|
|
5537
6638
|
var loadEnvFileAsync = async ({ envPath }) => {
|
|
5538
|
-
const
|
|
5539
|
-
const absolutePath =
|
|
5540
|
-
if (!await
|
|
6639
|
+
const fs2 = getFileSystem();
|
|
6640
|
+
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
|
|
6641
|
+
if (!await fs2.exists(absolutePath)) {
|
|
5541
6642
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
5542
6643
|
}
|
|
5543
|
-
const content = await
|
|
6644
|
+
const content = await fs2.readFile(absolutePath, "utf-8");
|
|
5544
6645
|
if (content === null) {
|
|
5545
6646
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
5546
6647
|
}
|
|
@@ -5569,10 +6670,10 @@ var saveEnvFileAsync = async ({
|
|
|
5569
6670
|
data,
|
|
5570
6671
|
merge = true
|
|
5571
6672
|
}) => {
|
|
5572
|
-
const
|
|
5573
|
-
const absolutePath =
|
|
6673
|
+
const fs2 = getFileSystem();
|
|
6674
|
+
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.homedir(), envPath);
|
|
5574
6675
|
let existingData = {};
|
|
5575
|
-
if (merge && await
|
|
6676
|
+
if (merge && await fs2.exists(absolutePath)) {
|
|
5576
6677
|
try {
|
|
5577
6678
|
existingData = await loadEnvFileAsync({ envPath: absolutePath });
|
|
5578
6679
|
} catch {}
|
|
@@ -5590,11 +6691,11 @@ var saveEnvFileAsync = async ({
|
|
|
5590
6691
|
const content = `${lines.join(`
|
|
5591
6692
|
`)}
|
|
5592
6693
|
`;
|
|
5593
|
-
const dir =
|
|
5594
|
-
await
|
|
6694
|
+
const dir = fs2.path.dirname(absolutePath);
|
|
6695
|
+
await fs2.mkdir(dir);
|
|
5595
6696
|
const tempPath = `${absolutePath}.tmp`;
|
|
5596
|
-
await
|
|
5597
|
-
await
|
|
6697
|
+
await fs2.writeFile(tempPath, content);
|
|
6698
|
+
await fs2.rename(tempPath, absolutePath);
|
|
5598
6699
|
};
|
|
5599
6700
|
|
|
5600
6701
|
// ../auth/src/loginStatus.ts
|
|
@@ -5708,11 +6809,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
|
|
|
5708
6809
|
return { credentials };
|
|
5709
6810
|
}
|
|
5710
6811
|
async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
|
|
5711
|
-
const
|
|
5712
|
-
const globalPath =
|
|
6812
|
+
const fs2 = getFs();
|
|
6813
|
+
const globalPath = fs2.path.join(fs2.env.homedir(), envFilePath);
|
|
5713
6814
|
if (absolutePath === globalPath)
|
|
5714
6815
|
return;
|
|
5715
|
-
if (!await
|
|
6816
|
+
if (!await fs2.exists(globalPath))
|
|
5716
6817
|
return;
|
|
5717
6818
|
try {
|
|
5718
6819
|
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
@@ -6200,6 +7301,10 @@ async function listQueueFilters(config) {
|
|
|
6200
7301
|
async function listMachineFilters(config) {
|
|
6201
7302
|
return listFilters(config, "filtersAllMachines", isMachineFiltersResponse, "machine filters");
|
|
6202
7303
|
}
|
|
7304
|
+
// ../insights-sdk/src/rbac.ts
|
|
7305
|
+
async function listUsers(config) {
|
|
7306
|
+
return requestInsightsRoute(config, "usersList");
|
|
7307
|
+
}
|
|
6203
7308
|
// src/utils/output.ts
|
|
6204
7309
|
function fail(message, instructions) {
|
|
6205
7310
|
OutputFormatter.error({
|
|
@@ -6250,7 +7355,7 @@ function writeConfigError(error) {
|
|
|
6250
7355
|
processContext.exit(EXIT_CODES.AuthenticationError);
|
|
6251
7356
|
}
|
|
6252
7357
|
async function resolveInsightsConfig() {
|
|
6253
|
-
const [configError, config] = await
|
|
7358
|
+
const [configError, config] = await catchError(createInsightsConfig());
|
|
6254
7359
|
if (configError) {
|
|
6255
7360
|
writeConfigError(configError);
|
|
6256
7361
|
return null;
|
|
@@ -6288,6 +7393,33 @@ function writeInsightsNotFound(error, message, instructions) {
|
|
|
6288
7393
|
});
|
|
6289
7394
|
processContext.exit(EXIT_CODES.Failure);
|
|
6290
7395
|
}
|
|
7396
|
+
function surfaceUnavailableInstructions(family) {
|
|
7397
|
+
return [
|
|
7398
|
+
`The real-time APIs behind 'uip insights' are not enabled on every deployment: Automation Suite and Service Fabric serve only a converted subset, and the ${family.subject} routes are not in it.`,
|
|
7399
|
+
"This is not a statement about the tenant's data or your permissions, and neither logging in again nor retrying changes it.",
|
|
7400
|
+
"Run these commands against a cloud deployment instead."
|
|
7401
|
+
].join(" ");
|
|
7402
|
+
}
|
|
7403
|
+
function writeInsightsSurfaceUnavailable(error, family) {
|
|
7404
|
+
OutputFormatter.error({
|
|
7405
|
+
Result: RESULTS.ConfigError,
|
|
7406
|
+
ErrorCode: "configuration_error",
|
|
7407
|
+
Retry: "RetryWillNotFix",
|
|
7408
|
+
Message: `The Insights real-time API did not serve the ${family.subject} routes on this deployment. These routes are feature-gated to Cloud and Dedicated SaaS.`,
|
|
7409
|
+
Instructions: surfaceUnavailableInstructions(family),
|
|
7410
|
+
Context: httpErrorContext(error)
|
|
7411
|
+
});
|
|
7412
|
+
processContext.exit(EXIT_CODES.ConfigError);
|
|
7413
|
+
}
|
|
7414
|
+
function claimGatedSurface404(family) {
|
|
7415
|
+
return (error) => {
|
|
7416
|
+
if (error.status !== 404) {
|
|
7417
|
+
return false;
|
|
7418
|
+
}
|
|
7419
|
+
writeInsightsSurfaceUnavailable(error, family);
|
|
7420
|
+
return true;
|
|
7421
|
+
};
|
|
7422
|
+
}
|
|
6291
7423
|
function writeInsightsError(error, family) {
|
|
6292
7424
|
if (error instanceof InsightsHttpError) {
|
|
6293
7425
|
const context = httpErrorContext(error);
|
|
@@ -6357,22 +7489,34 @@ function compareRowKeys(a, b) {
|
|
|
6357
7489
|
}
|
|
6358
7490
|
return a < b ? -1 : 1;
|
|
6359
7491
|
}
|
|
7492
|
+
function claimHttpError(requestError, onHttpError) {
|
|
7493
|
+
if (requestError instanceof InsightsHttpError && onHttpError?.(requestError)) {
|
|
7494
|
+
ensureFailureExit();
|
|
7495
|
+
return true;
|
|
7496
|
+
}
|
|
7497
|
+
return false;
|
|
7498
|
+
}
|
|
6360
7499
|
async function executeInsightsList(options, fetchList, spec) {
|
|
6361
7500
|
const config = await resolveInsightsConfig();
|
|
6362
7501
|
if (config === null) {
|
|
6363
7502
|
return;
|
|
6364
7503
|
}
|
|
6365
|
-
const [requestError, response] = await
|
|
7504
|
+
const [requestError, response] = await catchError(fetchList(config));
|
|
6366
7505
|
if (requestError) {
|
|
7506
|
+
if (claimHttpError(requestError, spec.onHttpError)) {
|
|
7507
|
+
return;
|
|
7508
|
+
}
|
|
6367
7509
|
writeInsightsError(requestError, spec.family);
|
|
6368
7510
|
return;
|
|
6369
7511
|
}
|
|
6370
|
-
const [contractError,
|
|
7512
|
+
const [contractError, rows] = catchError(() => {
|
|
7513
|
+
const projected = spec.project(response);
|
|
7514
|
+
return spec.finalize ? spec.finalize(projected) : projected;
|
|
7515
|
+
});
|
|
6371
7516
|
if (contractError) {
|
|
6372
7517
|
writeInsightsError(contractError, spec.family);
|
|
6373
7518
|
return;
|
|
6374
7519
|
}
|
|
6375
|
-
const rows = spec.finalize ? spec.finalize(projected) : projected;
|
|
6376
7520
|
const offset = options.offset ?? 0;
|
|
6377
7521
|
const page = rows.slice(offset, offset + options.limit);
|
|
6378
7522
|
const pagination = new Pagination({
|
|
@@ -6381,12 +7525,13 @@ async function executeInsightsList(options, fetchList, spec) {
|
|
|
6381
7525
|
offset,
|
|
6382
7526
|
total: rows.length
|
|
6383
7527
|
});
|
|
7528
|
+
const instructions = spec.instructions(rows, page, pagination.HasMore);
|
|
6384
7529
|
OutputFormatter.success({
|
|
6385
7530
|
Result: RESULTS.Success,
|
|
6386
7531
|
Code: spec.code,
|
|
6387
7532
|
Data: page,
|
|
6388
7533
|
Pagination: pagination,
|
|
6389
|
-
Instructions:
|
|
7534
|
+
...instructions === "" ? {} : { Instructions: instructions }
|
|
6390
7535
|
});
|
|
6391
7536
|
}
|
|
6392
7537
|
async function executeInsightsGet(fetchOne, spec) {
|
|
@@ -6394,25 +7539,25 @@ async function executeInsightsGet(fetchOne, spec) {
|
|
|
6394
7539
|
if (config === null) {
|
|
6395
7540
|
return;
|
|
6396
7541
|
}
|
|
6397
|
-
const [requestError, response] = await
|
|
7542
|
+
const [requestError, response] = await catchError(fetchOne(config));
|
|
6398
7543
|
if (requestError) {
|
|
6399
|
-
if (requestError
|
|
6400
|
-
ensureFailureExit();
|
|
7544
|
+
if (claimHttpError(requestError, spec.onHttpError)) {
|
|
6401
7545
|
return;
|
|
6402
7546
|
}
|
|
6403
7547
|
writeInsightsError(requestError, spec.family);
|
|
6404
7548
|
return;
|
|
6405
7549
|
}
|
|
6406
|
-
const [contractError, data] =
|
|
7550
|
+
const [contractError, data] = catchError(() => spec.project(response, config));
|
|
6407
7551
|
if (contractError) {
|
|
6408
7552
|
writeInsightsError(contractError, spec.family);
|
|
6409
7553
|
return;
|
|
6410
7554
|
}
|
|
7555
|
+
const instructions = spec.instructions(data);
|
|
6411
7556
|
OutputFormatter.success({
|
|
6412
7557
|
Result: RESULTS.Success,
|
|
6413
7558
|
Code: spec.code,
|
|
6414
7559
|
Data: data,
|
|
6415
|
-
Instructions:
|
|
7560
|
+
...instructions === "" ? {} : { Instructions: instructions }
|
|
6416
7561
|
});
|
|
6417
7562
|
}
|
|
6418
7563
|
|
|
@@ -6423,6 +7568,38 @@ function isRecord2(value) {
|
|
|
6423
7568
|
function asRecord(value) {
|
|
6424
7569
|
return isRecord2(value) ? value : null;
|
|
6425
7570
|
}
|
|
7571
|
+
function pickScalar(value) {
|
|
7572
|
+
if (typeof value === "string") {
|
|
7573
|
+
return value;
|
|
7574
|
+
}
|
|
7575
|
+
if (typeof value === "number") {
|
|
7576
|
+
return value;
|
|
7577
|
+
}
|
|
7578
|
+
if (typeof value === "boolean") {
|
|
7579
|
+
return value;
|
|
7580
|
+
}
|
|
7581
|
+
return null;
|
|
7582
|
+
}
|
|
7583
|
+
function createContractGuards(newError) {
|
|
7584
|
+
return {
|
|
7585
|
+
requireKnownShape: (dto, fields, subject) => {
|
|
7586
|
+
if (fields.some((field) => dto[field] !== undefined)) {
|
|
7587
|
+
return;
|
|
7588
|
+
}
|
|
7589
|
+
throw newError(`Insights returned ${subject} carrying none of its expected fields (${fields.join(", ")}); the response shape does not match the contract`);
|
|
7590
|
+
},
|
|
7591
|
+
requireArrayField: (dto, field, subject) => {
|
|
7592
|
+
const value = dto[field];
|
|
7593
|
+
if (value === undefined || value === null) {
|
|
7594
|
+
return [];
|
|
7595
|
+
}
|
|
7596
|
+
if (!Array.isArray(value)) {
|
|
7597
|
+
throw newError(`Insights returned ${subject} whose ${field} is not an array`);
|
|
7598
|
+
}
|
|
7599
|
+
return value;
|
|
7600
|
+
}
|
|
7601
|
+
};
|
|
7602
|
+
}
|
|
6426
7603
|
|
|
6427
7604
|
// src/utils/alerts.ts
|
|
6428
7605
|
class AlertContractError extends Error {
|
|
@@ -6431,25 +7608,14 @@ class AlertContractError extends Error {
|
|
|
6431
7608
|
this.name = "AlertContractError";
|
|
6432
7609
|
}
|
|
6433
7610
|
}
|
|
7611
|
+
var { requireArrayField, requireKnownShape } = createContractGuards((message) => new AlertContractError(message));
|
|
6434
7612
|
var ALERTS_FAMILY = {
|
|
6435
7613
|
subject: "Alert",
|
|
6436
7614
|
forbiddenExtra: "A 403 here usually means the caller's Orchestrator folder access could not be resolved rather than an entitlement problem, so check the active tenant and your folder permissions first. 'uip insights alerts check-entitlement' reports entitlement separately.",
|
|
6437
7615
|
isContractError: (error) => error instanceof AlertContractError
|
|
6438
7616
|
};
|
|
6439
7617
|
var MAX_INT32 = 2147483647;
|
|
6440
|
-
|
|
6441
|
-
return parseBoundedInt(raw, label, { min: 1, max: MAX_INT32 });
|
|
6442
|
-
}
|
|
6443
|
-
function pickScalar(value) {
|
|
6444
|
-
if (value === undefined || value === null) {
|
|
6445
|
-
return null;
|
|
6446
|
-
}
|
|
6447
|
-
const kind = typeof value;
|
|
6448
|
-
if (kind === "string" || kind === "number" || kind === "boolean") {
|
|
6449
|
-
return value;
|
|
6450
|
-
}
|
|
6451
|
-
return null;
|
|
6452
|
-
}
|
|
7618
|
+
var parseRouteId = (label) => (raw) => parseBoundedInt(raw, label, { min: 1, max: MAX_INT32 });
|
|
6453
7619
|
var ENGINE_NAMES = { 0: "curated", 1: "query" };
|
|
6454
7620
|
var SIDE_EFFECT_NOTE = "This command also runs an entitlement and permission check that can bootstrap Insights permissions and queue a warehouse warmup, so it is not a free read.";
|
|
6455
7621
|
var ENTITLEMENT_SIDE_EFFECT_NOTE = "Running this check can bootstrap Insights permissions and queue a warehouse warmup, so it is not a free read.";
|
|
@@ -6468,7 +7634,7 @@ var ENGINE_UNKNOWN_NOTE = "One or more alerts report an alert engine this CLI do
|
|
|
6468
7634
|
var AGENTIC_BASE_NOTE = `Only active alert definitions tied to this process key are returned. ${FOLDER_KEYS_NOTE}`;
|
|
6469
7635
|
var ENTITLED_TRUE_NOTE = "True means the organization holds the Insights full-mode entitlement and the current caller passed the Insights admin check. While this is true, 'alerts list' and 'alerts get' are not entitlement-filtered, so an earlier partial-result warning from those commands does not apply. They still return only active alert definitions.";
|
|
6470
7636
|
var ENTITLED_FALSE_NOTE = "False means at least one of three things: the organization has no Insights full-mode entitlement, the caller is not an Insights admin, or the Insights portal service is unreachable in this tenant. The backend does not say which. While this is false, 'alerts list' and 'alerts get' return only alerts tied to a process key. The agentic list is unaffected.";
|
|
6471
|
-
var DEFINITION_NOT_FOUND_INSTRUCTIONS = `A 404 can mean the ID does not exist, the alert is inactive,
|
|
7637
|
+
var DEFINITION_NOT_FOUND_INSTRUCTIONS = `A 404 can mean the ID does not exist, the alert is inactive, the alert was filtered out because the tenant is not entitled to Insights alerts, or Insights alerts are not enabled on this deployment at all. ${ENTITLEMENT_FILTER_CLAUSE} 'uip insights alerts list' applies the same filter, so an ID missing there is not proof it does not exist; if that command also reports the surface unavailable, this deployment does not serve alerts. Run 'uip insights alerts check-entitlement' first. Both of those commands also run the entitlement and permission check, so neither is a free read.`;
|
|
6472
7638
|
function parseScopeValues(value) {
|
|
6473
7639
|
if (value === undefined || value === null) {
|
|
6474
7640
|
return [];
|
|
@@ -6476,7 +7642,7 @@ function parseScopeValues(value) {
|
|
|
6476
7642
|
if (typeof value !== "string") {
|
|
6477
7643
|
return (Array.isArray(value) ? value : [value]).map(pickScalar);
|
|
6478
7644
|
}
|
|
6479
|
-
const [parseError, parsed] =
|
|
7645
|
+
const [parseError, parsed] = catchError(() => JSON.parse(value));
|
|
6480
7646
|
if (!parseError && Array.isArray(parsed)) {
|
|
6481
7647
|
return parsed.map(pickScalar);
|
|
6482
7648
|
}
|
|
@@ -6624,7 +7790,8 @@ async function executeAlertsList(options, fetchList, variant) {
|
|
|
6624
7790
|
family: ALERTS_FAMILY,
|
|
6625
7791
|
project: projectDefinitionRows,
|
|
6626
7792
|
finalize: (rows) => [...rows].sort(compareDefinitionRows),
|
|
6627
|
-
instructions: (rows, page, hasMore) => buildListInstructions(variant, rows, page, hasMore)
|
|
7793
|
+
instructions: (rows, page, hasMore) => buildListInstructions(variant, rows, page, hasMore),
|
|
7794
|
+
onHttpError: claimGatedSurface404(ALERTS_FAMILY)
|
|
6628
7795
|
});
|
|
6629
7796
|
}
|
|
6630
7797
|
function buildGetInstructions(row) {
|
|
@@ -6658,8 +7825,11 @@ async function executeCheckEntitlement() {
|
|
|
6658
7825
|
if (config === null) {
|
|
6659
7826
|
return;
|
|
6660
7827
|
}
|
|
6661
|
-
const [requestError, response] = await
|
|
7828
|
+
const [requestError, response] = await catchError(checkAlertEntitlement(config));
|
|
6662
7829
|
if (requestError) {
|
|
7830
|
+
if (requestError instanceof InsightsHttpError && claimGatedSurface404(ALERTS_FAMILY)(requestError)) {
|
|
7831
|
+
return;
|
|
7832
|
+
}
|
|
6663
7833
|
writeInsightsError(requestError, ALERTS_FAMILY);
|
|
6664
7834
|
return;
|
|
6665
7835
|
}
|
|
@@ -6674,6 +7844,157 @@ async function executeCheckEntitlement() {
|
|
|
6674
7844
|
Instructions: `${response ? ENTITLED_TRUE_NOTE : ENTITLED_FALSE_NOTE} ${ENTITLEMENT_SIDE_EFFECT_NOTE}`
|
|
6675
7845
|
});
|
|
6676
7846
|
}
|
|
7847
|
+
var BACKEND_HISTORY_ROW_CAP = 1000;
|
|
7848
|
+
var HISTORY_ROW_FIELDS = [
|
|
7849
|
+
"alertId",
|
|
7850
|
+
"alertName",
|
|
7851
|
+
"timestamp",
|
|
7852
|
+
"severity",
|
|
7853
|
+
"triggerSpec",
|
|
7854
|
+
"computationSpec",
|
|
7855
|
+
"folderNames",
|
|
7856
|
+
"alertDeliveryId"
|
|
7857
|
+
];
|
|
7858
|
+
var METRICS_FIELDS = [
|
|
7859
|
+
"groupNames",
|
|
7860
|
+
"endTimeIntervals",
|
|
7861
|
+
"alertTriggerCount"
|
|
7862
|
+
];
|
|
7863
|
+
var DELIVERY_FIELDS = ["id", "type", "recipientIds", "tenantKey"];
|
|
7864
|
+
var HISTORY_EMPTY_NOTE = "No alert history rows matched in the requested time range for the current caller. That is not proof the alert never triggered.";
|
|
7865
|
+
var HISTORY_OVER_PAGED_SCOPE = " in the requested time range";
|
|
7866
|
+
var HISTORY_TRUNCATED_NOTE = `The backend returned its maximum of ${BACKEND_HISTORY_ROW_CAP} rows, newest first, so older triggers in this time range are not included. Narrow the time window to see them.`;
|
|
7867
|
+
var HISTORY_NOT_NOTIFICATION_NOTE = "A history row records that the alert fired, not that anyone was notified.";
|
|
7868
|
+
var HISTORY_TIME_UNIT_NOTE = "TriggeredAt is epoch seconds, not milliseconds or an ISO timestamp.";
|
|
7869
|
+
var HISTORY_FOLDER_FILTER_NOTE = "--folder-name matches folders by flattening each trigger's folder list, so a trigger sitting in two of the requested folders is returned twice here and counted twice by 'get-metrics'. Triggers that record no folder are dropped from a folder-filtered result.";
|
|
7870
|
+
var METRICS_GROUPING_NOTE = "Results are grouped by alert type. Counts holds one row of trigger counts per entry in Groups, and each count pairs with the interval end time at the same index in IntervalEndTimes.";
|
|
7871
|
+
function projectAlertHistoryRow(raw) {
|
|
7872
|
+
const dto = asRecord(raw);
|
|
7873
|
+
if (!dto) {
|
|
7874
|
+
throw new AlertContractError("Insights returned an alert history row that is not an object");
|
|
7875
|
+
}
|
|
7876
|
+
requireKnownShape(dto, HISTORY_ROW_FIELDS, "an alert history row");
|
|
7877
|
+
const trigger = asRecord(dto.triggerSpec);
|
|
7878
|
+
const computation = asRecord(dto.computationSpec);
|
|
7879
|
+
return {
|
|
7880
|
+
alertId: dto.alertId ?? null,
|
|
7881
|
+
alertName: dto.alertName ?? null,
|
|
7882
|
+
triggeredAt: dto.timestamp ?? null,
|
|
7883
|
+
severity: dto.severity ?? null,
|
|
7884
|
+
operator: trigger?.type ?? null,
|
|
7885
|
+
threshold: trigger?.value ?? null,
|
|
7886
|
+
metric: computation?.computation ?? null,
|
|
7887
|
+
metricState: computation?.filterValue ?? null,
|
|
7888
|
+
deliveryId: dto.alertDeliveryId ?? null
|
|
7889
|
+
};
|
|
7890
|
+
}
|
|
7891
|
+
function projectHistoryRows(response) {
|
|
7892
|
+
if (!Array.isArray(response)) {
|
|
7893
|
+
throw new AlertContractError("Insights returned an alert history list that is not an array");
|
|
7894
|
+
}
|
|
7895
|
+
return response.map(projectAlertHistoryRow);
|
|
7896
|
+
}
|
|
7897
|
+
function hasFolderFilter(request) {
|
|
7898
|
+
return Array.isArray(request.folders) && request.folders.length > 0;
|
|
7899
|
+
}
|
|
7900
|
+
function buildHistoryListInstructions(rows, page, hasMore, folderFiltered) {
|
|
7901
|
+
const parts = [];
|
|
7902
|
+
if (rows.length === 0) {
|
|
7903
|
+
parts.push(HISTORY_EMPTY_NOTE);
|
|
7904
|
+
} else if (page.length === 0) {
|
|
7905
|
+
parts.push(overPagedNote(rows.length, HISTORY_OVER_PAGED_SCOPE));
|
|
7906
|
+
}
|
|
7907
|
+
if (rows.length === BACKEND_HISTORY_ROW_CAP) {
|
|
7908
|
+
parts.push(HISTORY_TRUNCATED_NOTE);
|
|
7909
|
+
}
|
|
7910
|
+
if (hasMore) {
|
|
7911
|
+
parts.push(truncatedNote("a trigger"));
|
|
7912
|
+
}
|
|
7913
|
+
if (page.length > 0) {
|
|
7914
|
+
parts.push(HISTORY_TIME_UNIT_NOTE);
|
|
7915
|
+
}
|
|
7916
|
+
if (folderFiltered) {
|
|
7917
|
+
parts.push(HISTORY_FOLDER_FILTER_NOTE);
|
|
7918
|
+
}
|
|
7919
|
+
parts.push(HISTORY_NOT_NOTIFICATION_NOTE);
|
|
7920
|
+
return parts.join(" ");
|
|
7921
|
+
}
|
|
7922
|
+
async function executeAlertHistoryList(options, request) {
|
|
7923
|
+
await executeInsightsList(options, (config) => listAlertHistoryDetails(config, request), {
|
|
7924
|
+
code: "InsightsAlertHistoryList",
|
|
7925
|
+
family: ALERTS_FAMILY,
|
|
7926
|
+
project: projectHistoryRows,
|
|
7927
|
+
instructions: (rows, page, hasMore) => buildHistoryListInstructions(rows, page, hasMore, hasFolderFilter(request)),
|
|
7928
|
+
onHttpError: claimGatedSurface404(ALERTS_FAMILY)
|
|
7929
|
+
});
|
|
7930
|
+
}
|
|
7931
|
+
function buildMetricsInstructions(folderFiltered) {
|
|
7932
|
+
const parts = [METRICS_GROUPING_NOTE];
|
|
7933
|
+
if (folderFiltered) {
|
|
7934
|
+
parts.push(HISTORY_FOLDER_FILTER_NOTE);
|
|
7935
|
+
}
|
|
7936
|
+
return parts.join(" ");
|
|
7937
|
+
}
|
|
7938
|
+
function projectAlertHistoryMetrics(raw) {
|
|
7939
|
+
const dto = asRecord(raw);
|
|
7940
|
+
if (!dto) {
|
|
7941
|
+
throw new AlertContractError("Insights returned alert history metrics that are not an object");
|
|
7942
|
+
}
|
|
7943
|
+
const subject = "alert history metrics";
|
|
7944
|
+
requireKnownShape(dto, METRICS_FIELDS, subject);
|
|
7945
|
+
return {
|
|
7946
|
+
groups: requireArrayField(dto, "groupNames", subject),
|
|
7947
|
+
intervalEndTimes: requireArrayField(dto, "endTimeIntervals", subject),
|
|
7948
|
+
counts: requireArrayField(dto, "alertTriggerCount", subject)
|
|
7949
|
+
};
|
|
7950
|
+
}
|
|
7951
|
+
async function executeAlertHistoryMetrics(request) {
|
|
7952
|
+
await executeInsightsGet((config) => getAlertHistoryMetrics(config, request), {
|
|
7953
|
+
code: "InsightsAlertHistoryMetrics",
|
|
7954
|
+
family: ALERTS_FAMILY,
|
|
7955
|
+
project: (response) => projectAlertHistoryMetrics(response),
|
|
7956
|
+
onHttpError: claimGatedSurface404(ALERTS_FAMILY),
|
|
7957
|
+
instructions: () => buildMetricsInstructions(hasFolderFilter(request))
|
|
7958
|
+
});
|
|
7959
|
+
}
|
|
7960
|
+
var DELIVERY_INSTRUCTIONS = "Recipient identities are not returned by design. Use RecipientCount to confirm the delivery has recipients before referencing it.";
|
|
7961
|
+
var DELIVERY_NOT_FOUND_INSTRUCTIONS = "A 404 can mean the delivery ID does not exist or the delivery belongs to another tenant. Take the DeliveryId from a row returned by 'uip insights alerts list' or 'uip insights alert-history list'.";
|
|
7962
|
+
function projectAlertDelivery(raw, sessionTenantId) {
|
|
7963
|
+
const dto = asRecord(raw);
|
|
7964
|
+
if (!dto) {
|
|
7965
|
+
throw new AlertContractError("Insights returned an alert delivery that is not an object");
|
|
7966
|
+
}
|
|
7967
|
+
requireKnownShape(dto, DELIVERY_FIELDS, "an alert delivery");
|
|
7968
|
+
return {
|
|
7969
|
+
id: dto.id ?? null,
|
|
7970
|
+
type: dto.type ?? null,
|
|
7971
|
+
recipientCount: requireArrayField(dto, "recipientIds", "an alert delivery").length,
|
|
7972
|
+
tenantMatches: typeof dto.tenantKey === "string" && dto.tenantKey.toLowerCase() === sessionTenantId.toLowerCase()
|
|
7973
|
+
};
|
|
7974
|
+
}
|
|
7975
|
+
async function executeAlertDeliveryGet(deliveryId) {
|
|
7976
|
+
await executeInsightsGet((config) => getDefaultDelivery(config, deliveryId), {
|
|
7977
|
+
code: "InsightsAlertDeliveryGet",
|
|
7978
|
+
family: ALERTS_FAMILY,
|
|
7979
|
+
project: (response, config) => projectAlertDelivery(response, config.tenantId),
|
|
7980
|
+
instructions: () => DELIVERY_INSTRUCTIONS,
|
|
7981
|
+
onHttpError: (error) => {
|
|
7982
|
+
if (error.status !== 404) {
|
|
7983
|
+
return false;
|
|
7984
|
+
}
|
|
7985
|
+
writeInsightsNotFound(error, `Alert delivery ${deliveryId} was not found in the current tenant.`, DELIVERY_NOT_FOUND_INSTRUCTIONS);
|
|
7986
|
+
return true;
|
|
7987
|
+
}
|
|
7988
|
+
});
|
|
7989
|
+
}
|
|
7990
|
+
|
|
7991
|
+
// src/commands/alert-deliveries.ts
|
|
7992
|
+
function registerAlertDeliveriesCommand(program2) {
|
|
7993
|
+
const deliveriesCmd = program2.command("alert-deliveries").description("Read UiPath Insights alert delivery metadata");
|
|
7994
|
+
deliveriesCmd.command("get").description("Get metadata for one alert delivery by its integer ID").argument("<delivery-id>", "Alert delivery ID (integer)", parseRouteId("<delivery-id>")).trackedAction(processContext, async (deliveryId) => {
|
|
7995
|
+
await executeAlertDeliveryGet(String(deliveryId));
|
|
7996
|
+
});
|
|
7997
|
+
}
|
|
6677
7998
|
|
|
6678
7999
|
// src/utils/list-options.ts
|
|
6679
8000
|
var DEFAULT_LIMIT = 50;
|
|
@@ -6681,10 +8002,119 @@ function addListPaginationOptions(cmd) {
|
|
|
6681
8002
|
return cmd.option("-l, --limit <number>", "Maximum rows to return", parseLimit, DEFAULT_LIMIT).option("-o, --offset <number>", "Rows to skip before returning results", parseOffset);
|
|
6682
8003
|
}
|
|
6683
8004
|
|
|
6684
|
-
// src/
|
|
6685
|
-
|
|
6686
|
-
|
|
8005
|
+
// src/utils/validate.ts
|
|
8006
|
+
var TIME_GROUPING_SIZES = ["FifteenMinutes", "Hour", "Day"];
|
|
8007
|
+
var TENANT_FIELD_NAMES_LOWER = new Set(["tenantkey", "tenantid"]);
|
|
8008
|
+
function validateTimeSelection(selection) {
|
|
8009
|
+
const hasRelative = selection.timeRange !== undefined;
|
|
8010
|
+
const hasAbsolute = selection.since !== undefined || selection.until !== undefined;
|
|
8011
|
+
if (hasRelative && hasAbsolute) {
|
|
8012
|
+
return {
|
|
8013
|
+
message: "Provide either --time-range or the --since and --until pair, not both.",
|
|
8014
|
+
instructions: "Use --time-range <minutes> for a window ending now, or --since <epoch-seconds> with --until <epoch-seconds> for a fixed window."
|
|
8015
|
+
};
|
|
8016
|
+
}
|
|
8017
|
+
if (!hasRelative && !hasAbsolute) {
|
|
8018
|
+
return {
|
|
8019
|
+
message: "Missing required field: a time selection.",
|
|
8020
|
+
instructions: "Pass --time-range <minutes>, or --since <epoch-seconds> (optionally with --until)."
|
|
8021
|
+
};
|
|
8022
|
+
}
|
|
8023
|
+
if (selection.since !== undefined && selection.until !== undefined && selection.since >= selection.until) {
|
|
8024
|
+
return {
|
|
8025
|
+
message: "--since must be earlier than --until.",
|
|
8026
|
+
instructions: "Make --until strictly greater than --since. Both are epoch seconds (not milliseconds)."
|
|
8027
|
+
};
|
|
8028
|
+
}
|
|
8029
|
+
return null;
|
|
8030
|
+
}
|
|
8031
|
+
|
|
8032
|
+
// src/commands/alert-history.ts
|
|
8033
|
+
var MAX_EPOCH_SECONDS = 253402300799;
|
|
8034
|
+
var MAX_TIME_RANGE_MINUTES = 527040;
|
|
8035
|
+
var MIN_START_TIMESTAMP = 1;
|
|
8036
|
+
var SEVERITIES = ["INFO", "WARN", "ERROR", "NORMAL"];
|
|
8037
|
+
var parseTimeRange = (raw) => parseBoundedInt(raw, "--time-range", {
|
|
8038
|
+
min: 1,
|
|
8039
|
+
max: MAX_TIME_RANGE_MINUTES
|
|
8040
|
+
});
|
|
8041
|
+
var parseEpochSeconds = (flag) => (raw) => parseBoundedInt(raw, flag, { min: 0, max: MAX_EPOCH_SECONDS });
|
|
8042
|
+
function addHistoryFilterOptions(cmd) {
|
|
8043
|
+
return cmd.option("--time-range <minutes>", "Relative window ending now", parseTimeRange).option("--since <epoch-seconds>", "Absolute lower bound, epoch seconds", parseEpochSeconds("--since")).option("--until <epoch-seconds>", "Absolute upper bound, epoch seconds", parseEpochSeconds("--until")).option("--alert-name <name>", "Filter to one alert name").option("--folder-name <names...>", "Filter by folder name (names, not folder keys; repeatable)").addOption(new Option("--severity <severities...>", "Filter by severity, repeatable (NORMAL is kept for backwards compatibility)").choices(SEVERITIES));
|
|
8044
|
+
}
|
|
8045
|
+
function effectiveLowerBound(options) {
|
|
8046
|
+
if (options.since !== undefined) {
|
|
8047
|
+
return Math.max(options.since, MIN_START_TIMESTAMP);
|
|
8048
|
+
}
|
|
8049
|
+
if (options.until !== undefined) {
|
|
8050
|
+
return MIN_START_TIMESTAMP;
|
|
8051
|
+
}
|
|
8052
|
+
return;
|
|
8053
|
+
}
|
|
8054
|
+
function flooredSelection(options) {
|
|
8055
|
+
return {
|
|
8056
|
+
timeRange: options.timeRange,
|
|
8057
|
+
since: effectiveLowerBound(options),
|
|
8058
|
+
until: options.until
|
|
8059
|
+
};
|
|
8060
|
+
}
|
|
8061
|
+
function validateHistoryOptions(options) {
|
|
8062
|
+
const timeError = validateTimeSelection(flooredSelection(options));
|
|
8063
|
+
if (timeError) {
|
|
8064
|
+
failValidation(timeError.message, timeError.instructions);
|
|
8065
|
+
return false;
|
|
8066
|
+
}
|
|
8067
|
+
if (options.alertName !== undefined && options.alertName.trim() === "") {
|
|
8068
|
+
failValidation("--alert-name must not be empty.", "Pass the alert name shown on an 'alerts list' row, or omit the flag to include all alerts.");
|
|
8069
|
+
return false;
|
|
8070
|
+
}
|
|
8071
|
+
if (options.folderName?.some((name) => name.trim() === "")) {
|
|
8072
|
+
failValidation("--folder-name values must not be empty.", "Pass folder names (not folder keys), or omit the flag to include all folders.");
|
|
8073
|
+
return false;
|
|
8074
|
+
}
|
|
8075
|
+
return true;
|
|
8076
|
+
}
|
|
8077
|
+
function buildHistoryRequest(options) {
|
|
8078
|
+
const body = {};
|
|
8079
|
+
if (options.timeRange !== undefined) {
|
|
8080
|
+
body.startTimeStamp = Math.max(Math.floor(Date.now() / 1000) - options.timeRange * 60, MIN_START_TIMESTAMP);
|
|
8081
|
+
} else {
|
|
8082
|
+
body.startTimeStamp = flooredSelection(options).since ?? MIN_START_TIMESTAMP;
|
|
8083
|
+
if (options.until !== undefined) {
|
|
8084
|
+
body.endTimeStamp = options.until;
|
|
8085
|
+
}
|
|
8086
|
+
}
|
|
8087
|
+
if (options.alertName !== undefined) {
|
|
8088
|
+
body.alertName = options.alertName.trim();
|
|
8089
|
+
}
|
|
8090
|
+
if (options.folderName !== undefined) {
|
|
8091
|
+
body.folders = options.folderName.map((name) => name.trim());
|
|
8092
|
+
}
|
|
8093
|
+
if (options.severity !== undefined) {
|
|
8094
|
+
body.severity = options.severity;
|
|
8095
|
+
}
|
|
8096
|
+
return body;
|
|
8097
|
+
}
|
|
8098
|
+
function registerAlertHistoryCommand(program2) {
|
|
8099
|
+
const historyCmd = program2.command("alert-history").description("Read UiPath Insights alert trigger history");
|
|
8100
|
+
addListPaginationOptions(addHistoryFilterOptions(historyCmd.command("list").description("List alert trigger history rows in a time window, newest first"))).trackedAction(processContext, async (options) => {
|
|
8101
|
+
if (!validateHistoryOptions(options)) {
|
|
8102
|
+
return;
|
|
8103
|
+
}
|
|
8104
|
+
await executeAlertHistoryList(options, buildHistoryRequest(options));
|
|
8105
|
+
});
|
|
8106
|
+
addHistoryFilterOptions(historyCmd.command("get-metrics").description("Get alert trigger counts per time interval, grouped by alert type")).addOption(new Option("--time-grouping <size>", "Bucket size for the metric intervals").choices([...TIME_GROUPING_SIZES]).makeOptionMandatory()).trackedAction(processContext, async (options) => {
|
|
8107
|
+
if (!validateHistoryOptions(options)) {
|
|
8108
|
+
return;
|
|
8109
|
+
}
|
|
8110
|
+
await executeAlertHistoryMetrics({
|
|
8111
|
+
...buildHistoryRequest(options),
|
|
8112
|
+
timeGroupingSize: options.timeGrouping
|
|
8113
|
+
});
|
|
8114
|
+
});
|
|
6687
8115
|
}
|
|
8116
|
+
|
|
8117
|
+
// src/commands/alerts.ts
|
|
6688
8118
|
function registerAlertsCommand(program2) {
|
|
6689
8119
|
const alertsCmd = program2.command("alerts").description("Read UiPath Insights real-time alert definitions");
|
|
6690
8120
|
addListPaginationOptions(alertsCmd.command("list").description("List alert definitions visible to the current caller; with --agentic, the definitions for one process key").option("--agentic", "Use the agentic route, scoped to one process key").option("--process-key <key>", "Process key to scope the agentic list to (required with --agentic)")).trackedAction(processContext, async (options) => {
|
|
@@ -6700,7 +8130,7 @@ function registerAlertsCommand(program2) {
|
|
|
6700
8130
|
}
|
|
6701
8131
|
return executeAlertsList(options, (config) => listAlertDefinitions(config, {}), "all");
|
|
6702
8132
|
});
|
|
6703
|
-
alertsCmd.command("get").description("Get one alert definition by its integer ID").argument("<alert-id>", "Alert definition ID (integer)",
|
|
8133
|
+
alertsCmd.command("get").description("Get one alert definition by its integer ID").argument("<alert-id>", "Alert definition ID (integer)", parseRouteId("<alert-id>")).trackedAction(processContext, async (alertId) => {
|
|
6704
8134
|
await executeAlertGet(String(alertId));
|
|
6705
8135
|
});
|
|
6706
8136
|
alertsCmd.command("check-entitlement").description("Check whether this tenant is confirmed entitled to Insights alerts").trackedAction(processContext, async () => {
|
|
@@ -6757,7 +8187,8 @@ async function executeFilterList(options, fetchList, toRows, code) {
|
|
|
6757
8187
|
family: FILTERS_FAMILY,
|
|
6758
8188
|
project: toRows,
|
|
6759
8189
|
finalize: dedupeAndSortRows,
|
|
6760
|
-
instructions: (rows, page, hasMore) => listInstructions(rows.length, page.length, hasMore)
|
|
8190
|
+
instructions: (rows, page, hasMore) => listInstructions(rows.length, page.length, hasMore),
|
|
8191
|
+
onHttpError: claimGatedSurface404(FILTERS_FAMILY)
|
|
6761
8192
|
});
|
|
6762
8193
|
}
|
|
6763
8194
|
|
|
@@ -6878,7 +8309,7 @@ async function executeJobsEndpoint(options, endpointPath, code) {
|
|
|
6878
8309
|
processContext.exit(1);
|
|
6879
8310
|
return;
|
|
6880
8311
|
}
|
|
6881
|
-
const [configErr, config] = await
|
|
8312
|
+
const [configErr, config] = await catchError(createInsightsConfig(options.tenant));
|
|
6882
8313
|
if (configErr) {
|
|
6883
8314
|
OutputFormatter.error({
|
|
6884
8315
|
Result: RESULTS.Failure,
|
|
@@ -6889,7 +8320,7 @@ async function executeJobsEndpoint(options, endpointPath, code) {
|
|
|
6889
8320
|
return;
|
|
6890
8321
|
}
|
|
6891
8322
|
const body = buildRequestBody(config.tenantId, options);
|
|
6892
|
-
const [apiErr, result] = await
|
|
8323
|
+
const [apiErr, result] = await catchError(insightsPost(config, endpointPath, body));
|
|
6893
8324
|
if (apiErr) {
|
|
6894
8325
|
OutputFormatter.error({
|
|
6895
8326
|
Result: RESULTS.Failure,
|
|
@@ -6930,6 +8361,171 @@ function registerJobsCommand(program2) {
|
|
|
6930
8361
|
});
|
|
6931
8362
|
}
|
|
6932
8363
|
|
|
8364
|
+
// src/utils/rbac.ts
|
|
8365
|
+
class RbacContractError extends Error {
|
|
8366
|
+
constructor(message) {
|
|
8367
|
+
super(message);
|
|
8368
|
+
this.name = "RbacContractError";
|
|
8369
|
+
}
|
|
8370
|
+
}
|
|
8371
|
+
var { requireArrayField: requireArrayField2, requireKnownShape: requireKnownShape2 } = createContractGuards((message) => new RbacContractError(message));
|
|
8372
|
+
var MANAGEMENT_VIEW_NOTE = "Reading Insights RBAC requires the Insights Management View permission in the active tenant. This route also returns 403 for a session with no user identity, such as one signed in with client credentials, and such a session cannot read Insights RBAC at all.";
|
|
8373
|
+
function rbacFamily(subject) {
|
|
8374
|
+
return {
|
|
8375
|
+
subject,
|
|
8376
|
+
forbiddenExtra: MANAGEMENT_VIEW_NOTE,
|
|
8377
|
+
isContractError: (error) => error instanceof RbacContractError
|
|
8378
|
+
};
|
|
8379
|
+
}
|
|
8380
|
+
var EMPTY_LIST_SUFFIX = "An empty list is a successful result, not an error.";
|
|
8381
|
+
function unwrapPortalBody(raw, subject) {
|
|
8382
|
+
const record = asRecord(raw);
|
|
8383
|
+
if (record && typeof record.isSuccess === "boolean") {
|
|
8384
|
+
if (record.isSuccess !== true) {
|
|
8385
|
+
throw new RbacContractError(`Insights reported a failed ${subject} result inside a success response`);
|
|
8386
|
+
}
|
|
8387
|
+
if (record.result === undefined || record.result === null) {
|
|
8388
|
+
throw new RbacContractError(`Insights returned a legacy ${subject} envelope without a result`);
|
|
8389
|
+
}
|
|
8390
|
+
return record.result;
|
|
8391
|
+
}
|
|
8392
|
+
return raw;
|
|
8393
|
+
}
|
|
8394
|
+
var PRINCIPAL_FIELDS = ["id", "name", "roles"];
|
|
8395
|
+
var PRINCIPAL_WITHHELD_NOTE = "This view omits email and the nested role IDs. Pass --include-email to include them.";
|
|
8396
|
+
function roleName(role) {
|
|
8397
|
+
return typeof role === "string" ? role : pickScalar(asRecord(role)?.name);
|
|
8398
|
+
}
|
|
8399
|
+
function safeRole(role) {
|
|
8400
|
+
return { name: roleName(role) };
|
|
8401
|
+
}
|
|
8402
|
+
function fullRole(role) {
|
|
8403
|
+
if (typeof role === "string") {
|
|
8404
|
+
return { id: null, name: role };
|
|
8405
|
+
}
|
|
8406
|
+
return { id: pickScalar(asRecord(role)?.id), name: roleName(role) };
|
|
8407
|
+
}
|
|
8408
|
+
function projectPrincipal(raw, subject, full) {
|
|
8409
|
+
const dto = asRecord(raw);
|
|
8410
|
+
if (!dto) {
|
|
8411
|
+
throw new RbacContractError(`Insights returned a ${subject} that is not an object`);
|
|
8412
|
+
}
|
|
8413
|
+
const noun = `a ${subject}`;
|
|
8414
|
+
requireKnownShape2(dto, PRINCIPAL_FIELDS, noun);
|
|
8415
|
+
const roles = requireArrayField2(dto, "roles", noun);
|
|
8416
|
+
const row = {
|
|
8417
|
+
id: pickScalar(dto.id),
|
|
8418
|
+
name: pickScalar(dto.name),
|
|
8419
|
+
roles: full ? roles.map(fullRole) : roles.map(safeRole)
|
|
8420
|
+
};
|
|
8421
|
+
if (full) {
|
|
8422
|
+
row.email = pickScalar(dto.email);
|
|
8423
|
+
}
|
|
8424
|
+
return row;
|
|
8425
|
+
}
|
|
8426
|
+
function projectRowAt(row, index, subject, project, full) {
|
|
8427
|
+
try {
|
|
8428
|
+
return project(row, subject, full);
|
|
8429
|
+
} catch (error) {
|
|
8430
|
+
if (error instanceof RbacContractError) {
|
|
8431
|
+
throw new RbacContractError(`${error.message} (list element ${index})`);
|
|
8432
|
+
}
|
|
8433
|
+
throw error;
|
|
8434
|
+
}
|
|
8435
|
+
}
|
|
8436
|
+
function projectListRows(response, subject, project, full) {
|
|
8437
|
+
const body = unwrapPortalBody(response, subject);
|
|
8438
|
+
if (!Array.isArray(body)) {
|
|
8439
|
+
throw new RbacContractError(`Insights returned a ${subject} list that is not an array`);
|
|
8440
|
+
}
|
|
8441
|
+
const rows = body;
|
|
8442
|
+
const keyed = rows.map((raw, index) => {
|
|
8443
|
+
const row = projectRowAt(raw, index, subject, project, full);
|
|
8444
|
+
const tieKey = full ? JSON.stringify(projectRowAt(raw, index, subject, project, false)) : JSON.stringify(row);
|
|
8445
|
+
return { row, tieKey };
|
|
8446
|
+
});
|
|
8447
|
+
keyed.sort(compareRbacRows);
|
|
8448
|
+
return keyed.map((entry) => entry.row);
|
|
8449
|
+
}
|
|
8450
|
+
function sortKey(value) {
|
|
8451
|
+
return String(pickScalar(value) ?? "");
|
|
8452
|
+
}
|
|
8453
|
+
function compareRbacRows(a, b) {
|
|
8454
|
+
const nameA = sortKey(a.row.name);
|
|
8455
|
+
const nameB = sortKey(b.row.name);
|
|
8456
|
+
const byFoldedName = compareRowKeys(nameA.toLowerCase(), nameB.toLowerCase());
|
|
8457
|
+
if (byFoldedName !== 0) {
|
|
8458
|
+
return byFoldedName;
|
|
8459
|
+
}
|
|
8460
|
+
const byName = compareRowKeys(nameA, nameB);
|
|
8461
|
+
if (byName !== 0) {
|
|
8462
|
+
return byName;
|
|
8463
|
+
}
|
|
8464
|
+
const byId = compareRowKeys(sortKey(a.row.id), sortKey(b.row.id));
|
|
8465
|
+
if (byId !== 0) {
|
|
8466
|
+
return byId;
|
|
8467
|
+
}
|
|
8468
|
+
const bySharedKey = compareRowKeys(a.tieKey, b.tieKey);
|
|
8469
|
+
if (bySharedKey !== 0) {
|
|
8470
|
+
return bySharedKey;
|
|
8471
|
+
}
|
|
8472
|
+
return compareRowKeys(JSON.stringify(a.row), JSON.stringify(b.row));
|
|
8473
|
+
}
|
|
8474
|
+
function joinParts(parts) {
|
|
8475
|
+
return parts.filter((part) => part !== "").join(" ");
|
|
8476
|
+
}
|
|
8477
|
+
function buildListInstructions2(spec, total, returned, hasMore, full) {
|
|
8478
|
+
if (total === 0) {
|
|
8479
|
+
return joinParts([spec.emptyNote, EMPTY_LIST_SUFFIX]);
|
|
8480
|
+
}
|
|
8481
|
+
const withheld = full ? "" : spec.withheldNote;
|
|
8482
|
+
if (returned === 0) {
|
|
8483
|
+
return joinParts([overPagedNote(total), spec.standingNote, withheld]);
|
|
8484
|
+
}
|
|
8485
|
+
return joinParts([
|
|
8486
|
+
spec.standingNote,
|
|
8487
|
+
withheld,
|
|
8488
|
+
hasMore ? truncatedNote(`a ${spec.noun}`) : ""
|
|
8489
|
+
]);
|
|
8490
|
+
}
|
|
8491
|
+
function writeRbacListNotFound(error, subject) {
|
|
8492
|
+
writeInsightsNotFound(error, `The Insights ${subject} list returned HTTP 404.`, "This route cannot miss for data reasons; the active tenant likely does not have the Insights Portal service provisioned. Do not retry until the tenant changes.");
|
|
8493
|
+
}
|
|
8494
|
+
async function executeRbacList(options, fetchList, family, spec) {
|
|
8495
|
+
const full = options.includeEmail === true;
|
|
8496
|
+
await executeInsightsList(options, fetchList, {
|
|
8497
|
+
code: spec.code,
|
|
8498
|
+
family,
|
|
8499
|
+
project: (response) => projectListRows(response, family.subject, spec.project, full),
|
|
8500
|
+
instructions: (rows, page, hasMore) => buildListInstructions2(spec, rows.length, page.length, hasMore, full),
|
|
8501
|
+
onHttpError: (error) => {
|
|
8502
|
+
if (error.status !== 404) {
|
|
8503
|
+
return false;
|
|
8504
|
+
}
|
|
8505
|
+
writeRbacListNotFound(error, family.subject);
|
|
8506
|
+
return true;
|
|
8507
|
+
}
|
|
8508
|
+
});
|
|
8509
|
+
}
|
|
8510
|
+
|
|
8511
|
+
// src/commands/users.ts
|
|
8512
|
+
var USERS_FAMILY = rbacFamily("User");
|
|
8513
|
+
var USERS_LIST_NOTE = "Roles shown are the user's Insights roles in the active tenant, by name. A user's row is kept even when directory enrichment fails.";
|
|
8514
|
+
var USERS_EMPTY_NOTE = "A user's row is kept even when directory enrichment fails.";
|
|
8515
|
+
function registerUsersCommand(program2) {
|
|
8516
|
+
const usersCmd = program2.command("users").description("Read the Insights users of the active tenant");
|
|
8517
|
+
addListPaginationOptions(usersCmd.command("list").description("List tenant users visible to the current caller, with their Insights role names")).option("--include-email", "Include email addresses and nested role IDs in the output").trackedAction(processContext, async (options) => {
|
|
8518
|
+
await executeRbacList(options, listUsers, USERS_FAMILY, {
|
|
8519
|
+
code: "InsightsUsersList",
|
|
8520
|
+
project: projectPrincipal,
|
|
8521
|
+
standingNote: USERS_LIST_NOTE,
|
|
8522
|
+
withheldNote: PRINCIPAL_WITHHELD_NOTE,
|
|
8523
|
+
emptyNote: USERS_EMPTY_NOTE,
|
|
8524
|
+
noun: "user"
|
|
8525
|
+
});
|
|
8526
|
+
});
|
|
8527
|
+
}
|
|
8528
|
+
|
|
6933
8529
|
// src/tool.ts
|
|
6934
8530
|
var metadata = {
|
|
6935
8531
|
name: "insights-tool",
|
|
@@ -6944,8 +8540,11 @@ var registerCommands = async (program2) => {
|
|
|
6944
8540
|
registerFilterQueuesCommand(program2);
|
|
6945
8541
|
registerFilterMachinesCommand(program2);
|
|
6946
8542
|
registerAlertsCommand(program2);
|
|
8543
|
+
registerAlertHistoryCommand(program2);
|
|
8544
|
+
registerAlertDeliveriesCommand(program2);
|
|
8545
|
+
registerUsersCommand(program2);
|
|
6947
8546
|
};
|
|
6948
8547
|
|
|
6949
8548
|
export { Command, metadata, registerCommands };
|
|
6950
8549
|
|
|
6951
|
-
//# debugId=
|
|
8550
|
+
//# debugId=EAF8B77C7D18E99C64756E2164756E21
|