@uipath/insights-tool 1.202.1 → 1.203.0-preview.180
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.js +1 -1
- package/dist/{tool-tbk23qsk.js → tool-5gc9p0dn.js} +531 -144
- package/dist/tool.js +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -2099,8 +2099,9 @@ var require_commander = __commonJS(function(exports) {
|
|
|
2099
2099
|
// package.json
|
|
2100
2100
|
var package_default = {
|
|
2101
2101
|
name: "@uipath/insights-tool",
|
|
2102
|
+
author: "UiPath",
|
|
2102
2103
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
2103
|
-
version: "1.
|
|
2104
|
+
version: "1.203.0-preview.180",
|
|
2104
2105
|
description: "Query UiPath Insights data — jobs, failures, and performance metrics.",
|
|
2105
2106
|
private: false,
|
|
2106
2107
|
repository: {
|
|
@@ -2653,7 +2654,7 @@ var UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{1
|
|
|
2653
2654
|
var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
2654
2655
|
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
2655
2656
|
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 PADDED_BASE64_PATTERN = /(?<![A-Za-z0-9+/])[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
|
|
2657
2658
|
var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
|
|
2658
2659
|
var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
|
|
2659
2660
|
var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
|
|
@@ -2700,7 +2701,7 @@ var QUOTED_LITERAL_PATTERN = new RegExp([
|
|
|
2700
2701
|
`(?<![A-Za-z0-9])"(?:[^\\
|
|
2701
2702
|
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
|
|
2702
2703
|
].join("|"), "g");
|
|
2703
|
-
var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
|
|
2704
|
+
var JSON_BODY_PATTERN = /[{[][^{}[\]:,]*[:,][^{}[\]]*[\]}]/g;
|
|
2704
2705
|
var COLLAPSED_BODY = "{…}";
|
|
2705
2706
|
var COLLAPSED_BODY_MARKER = "\x01body\x01";
|
|
2706
2707
|
var MAX_BODY_NESTING = 8;
|
|
@@ -2715,10 +2716,13 @@ function collapseJsonBodies(text) {
|
|
|
2715
2716
|
}
|
|
2716
2717
|
return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
|
|
2717
2718
|
}
|
|
2718
|
-
var TRAILING_PROSE_PUNCT =
|
|
2719
|
+
var TRAILING_PROSE_PUNCT = `.,;:!?)]}>'"`;
|
|
2719
2720
|
function peelTrailingPunctuation(match) {
|
|
2720
|
-
|
|
2721
|
-
|
|
2721
|
+
let end = match.length;
|
|
2722
|
+
while (end > 0 && TRAILING_PROSE_PUNCT.includes(match[end - 1])) {
|
|
2723
|
+
end -= 1;
|
|
2724
|
+
}
|
|
2725
|
+
return [match.slice(0, end), match.slice(end)];
|
|
2722
2726
|
}
|
|
2723
2727
|
function redactUrl(raw) {
|
|
2724
2728
|
try {
|
|
@@ -3462,7 +3466,8 @@ function readRegistryValue(keyPath, valueName) {
|
|
|
3462
3466
|
}
|
|
3463
3467
|
const [error, output] = catchError(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
|
|
3464
3468
|
encoding: "utf-8",
|
|
3465
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
3469
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
3470
|
+
windowsHide: true
|
|
3466
3471
|
}));
|
|
3467
3472
|
if (error) {
|
|
3468
3473
|
return "";
|
|
@@ -4177,28 +4182,32 @@ function isPlainRecord(value) {
|
|
|
4177
4182
|
const prototype = Object.getPrototypeOf(value);
|
|
4178
4183
|
return prototype === Object.prototype || prototype === null;
|
|
4179
4184
|
}
|
|
4180
|
-
function
|
|
4185
|
+
function splitPagedEnvelope(value) {
|
|
4181
4186
|
if (Array.isArray(value) || !isPlainRecord(value))
|
|
4182
4187
|
return null;
|
|
4183
|
-
const entries = Object.
|
|
4188
|
+
const entries = Object.entries(value);
|
|
4184
4189
|
if (entries.length === 0)
|
|
4185
4190
|
return null;
|
|
4186
|
-
let
|
|
4187
|
-
|
|
4188
|
-
for (const entry of entries) {
|
|
4191
|
+
let found = null;
|
|
4192
|
+
const meta = Object.create(null);
|
|
4193
|
+
for (const [key, entry] of entries) {
|
|
4189
4194
|
if (Array.isArray(entry)) {
|
|
4190
|
-
if (
|
|
4195
|
+
if (found !== null)
|
|
4191
4196
|
return null;
|
|
4192
|
-
|
|
4197
|
+
found = { key, rows: entry };
|
|
4193
4198
|
} else if (entry !== null && typeof entry === "object") {
|
|
4194
4199
|
return null;
|
|
4195
4200
|
} else {
|
|
4196
|
-
|
|
4201
|
+
meta[key] = entry;
|
|
4197
4202
|
}
|
|
4198
4203
|
}
|
|
4199
|
-
if (
|
|
4204
|
+
if (found === null || Object.keys(meta).length === 0)
|
|
4200
4205
|
return null;
|
|
4201
|
-
return
|
|
4206
|
+
return { ...found, meta };
|
|
4207
|
+
}
|
|
4208
|
+
function extractPagedRows(value) {
|
|
4209
|
+
const paged = splitPagedEnvelope(value);
|
|
4210
|
+
return paged === null ? null : paged.rows;
|
|
4202
4211
|
}
|
|
4203
4212
|
function toLowerCamelCaseKey(key) {
|
|
4204
4213
|
if (!key)
|
|
@@ -4302,6 +4311,9 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
|
|
|
4302
4311
|
}
|
|
4303
4312
|
break;
|
|
4304
4313
|
}
|
|
4314
|
+
case "markdown":
|
|
4315
|
+
logFn(renderMarkdown(data));
|
|
4316
|
+
break;
|
|
4305
4317
|
default: {
|
|
4306
4318
|
const hasData = "Data" in data && data.Data != null;
|
|
4307
4319
|
const pagedRows = hasData ? extractPagedRows(data.Data) : null;
|
|
@@ -4326,6 +4338,10 @@ function logOutput(data, format = "json", tableRowStyle) {
|
|
|
4326
4338
|
printOutput(data, format, (msg) => sink.writeOut(`${msg}
|
|
4327
4339
|
`), needsAsciiSafeJson(sink), styleFn);
|
|
4328
4340
|
}
|
|
4341
|
+
var PLUMBING_KEYS = new Set(["code", "log"]);
|
|
4342
|
+
function isPlumbingKey(key) {
|
|
4343
|
+
return PLUMBING_KEYS.has(key.toLowerCase());
|
|
4344
|
+
}
|
|
4329
4345
|
function cellToString(val) {
|
|
4330
4346
|
return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
|
|
4331
4347
|
}
|
|
@@ -4341,7 +4357,7 @@ function wrapText(text, width) {
|
|
|
4341
4357
|
function printTable(data, logFn, externalLogValue, tableRowStyle) {
|
|
4342
4358
|
if (data.length === 0)
|
|
4343
4359
|
return;
|
|
4344
|
-
const keys = Object.keys(data[0]).filter((key) => !
|
|
4360
|
+
const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
|
|
4345
4361
|
const maxWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
|
|
4346
4362
|
const header = keys.map((key, i) => key.padEnd(maxWidths[i])).join(" | ");
|
|
4347
4363
|
logFn(header);
|
|
@@ -4363,7 +4379,7 @@ function isNonEmptyPlainObject(value) {
|
|
|
4363
4379
|
}
|
|
4364
4380
|
var NESTED_INDENT = " ";
|
|
4365
4381
|
function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
4366
|
-
const keys = Object.keys(data).filter((key) => !
|
|
4382
|
+
const keys = Object.keys(data).filter((key) => !isPlumbingKey(key));
|
|
4367
4383
|
if (keys.length === 0)
|
|
4368
4384
|
return;
|
|
4369
4385
|
const isBlockValue = (value) => isPlainObjectArray(value) || isNonEmptyPlainObject(value);
|
|
@@ -4394,7 +4410,7 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
|
4394
4410
|
function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
|
|
4395
4411
|
if (data.length === 0)
|
|
4396
4412
|
return;
|
|
4397
|
-
const keys = Object.keys(data[0]).filter((key) => !
|
|
4413
|
+
const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
|
|
4398
4414
|
if (keys.length === 0)
|
|
4399
4415
|
return;
|
|
4400
4416
|
if (!process.stdout.isTTY) {
|
|
@@ -4468,6 +4484,220 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
|
|
|
4468
4484
|
logFn(`Log: ${externalLogValue}`);
|
|
4469
4485
|
}
|
|
4470
4486
|
}
|
|
4487
|
+
var MARKDOWN_MAX_CELL = 200;
|
|
4488
|
+
var MARKDOWN_MAX_DEPTH = 3;
|
|
4489
|
+
function markdownHeading(depth) {
|
|
4490
|
+
return "#".repeat(Math.min(3 + depth, 6));
|
|
4491
|
+
}
|
|
4492
|
+
var BACKTICK_RUN = /`+/g;
|
|
4493
|
+
function fencedBlock(text) {
|
|
4494
|
+
const first = text.trimStart()[0];
|
|
4495
|
+
const language = first === "<" ? "xml" : first === "{" || first === "[" ? "json" : "";
|
|
4496
|
+
const longestRun = Math.max(0, ...Array.from(text.matchAll(BACKTICK_RUN), (match) => match[0].length));
|
|
4497
|
+
const fence = "`".repeat(Math.max(3, longestRun + 1));
|
|
4498
|
+
return `${fence}${language}
|
|
4499
|
+
${text}
|
|
4500
|
+
${fence}`;
|
|
4501
|
+
}
|
|
4502
|
+
function collapseNewlineRuns(text) {
|
|
4503
|
+
return text.split(/(\s+)/).map((part, index) => index % 2 === 1 && part.includes(`
|
|
4504
|
+
`) ? " " : part).join("");
|
|
4505
|
+
}
|
|
4506
|
+
function markdownCell(value) {
|
|
4507
|
+
const text = value instanceof Date ? value.toISOString() : cellToString(value);
|
|
4508
|
+
return collapseNewlineRuns(text).replace(/\|/g, "\\|");
|
|
4509
|
+
}
|
|
4510
|
+
function markdownLabel(key) {
|
|
4511
|
+
return collapseNewlineRuns(key).replace(/[\\`*|]/g, "\\$&");
|
|
4512
|
+
}
|
|
4513
|
+
function withoutPlumbing(record) {
|
|
4514
|
+
const kept = Object.create(null);
|
|
4515
|
+
for (const [key, value] of Object.entries(record)) {
|
|
4516
|
+
if (!isPlumbingKey(key))
|
|
4517
|
+
kept[key] = value;
|
|
4518
|
+
}
|
|
4519
|
+
return kept;
|
|
4520
|
+
}
|
|
4521
|
+
function rowsWithoutPlumbing(rows) {
|
|
4522
|
+
return rows.map((row) => isPlainRecord(row) ? withoutPlumbing(row) : row);
|
|
4523
|
+
}
|
|
4524
|
+
function markdownTable(rows) {
|
|
4525
|
+
const columns = [];
|
|
4526
|
+
const seen = new Set;
|
|
4527
|
+
for (const row of rows) {
|
|
4528
|
+
for (const key of Object.keys(row)) {
|
|
4529
|
+
if (!seen.has(key)) {
|
|
4530
|
+
seen.add(key);
|
|
4531
|
+
columns.push(key);
|
|
4532
|
+
}
|
|
4533
|
+
}
|
|
4534
|
+
}
|
|
4535
|
+
if (columns.length === 0)
|
|
4536
|
+
return null;
|
|
4537
|
+
const cells = rows.map((row) => columns.map((key) => markdownCell(row[key])));
|
|
4538
|
+
if (cells.some((row) => row.some((c) => c.length > MARKDOWN_MAX_CELL))) {
|
|
4539
|
+
return null;
|
|
4540
|
+
}
|
|
4541
|
+
return [
|
|
4542
|
+
`| ${columns.map(markdownLabel).join(" | ")} |`,
|
|
4543
|
+
`| ${columns.map(() => "---").join(" | ")} |`,
|
|
4544
|
+
...cells.map((row) => `| ${row.join(" | ")} |`)
|
|
4545
|
+
].join(`
|
|
4546
|
+
`);
|
|
4547
|
+
}
|
|
4548
|
+
function extractMessageSequence(rows) {
|
|
4549
|
+
const messages = [];
|
|
4550
|
+
for (const row of rows) {
|
|
4551
|
+
const message = extractSingleMessage(row);
|
|
4552
|
+
if (message === null)
|
|
4553
|
+
return null;
|
|
4554
|
+
messages.push(message);
|
|
4555
|
+
}
|
|
4556
|
+
return messages.join(`
|
|
4557
|
+
|
|
4558
|
+
`);
|
|
4559
|
+
}
|
|
4560
|
+
function markdownRows(rows, depth) {
|
|
4561
|
+
if (rows.length === 0)
|
|
4562
|
+
return "(none)";
|
|
4563
|
+
if (!isPlainObjectArray(rows)) {
|
|
4564
|
+
return rows.map((item) => `- ${markdownCell(item)}`).join(`
|
|
4565
|
+
`);
|
|
4566
|
+
}
|
|
4567
|
+
const prose = extractMessageSequence(rows);
|
|
4568
|
+
if (prose !== null)
|
|
4569
|
+
return prose;
|
|
4570
|
+
const table = markdownTable(rows);
|
|
4571
|
+
if (table !== null)
|
|
4572
|
+
return table;
|
|
4573
|
+
if (depth >= MARKDOWN_MAX_DEPTH) {
|
|
4574
|
+
return fencedBlock(JSON.stringify(rows, null, 2));
|
|
4575
|
+
}
|
|
4576
|
+
return rows.map((row, index) => [
|
|
4577
|
+
`${markdownHeading(depth)} ${index + 1}`,
|
|
4578
|
+
markdownObject(row, depth + 1)
|
|
4579
|
+
].join(`
|
|
4580
|
+
|
|
4581
|
+
`)).join(`
|
|
4582
|
+
|
|
4583
|
+
`);
|
|
4584
|
+
}
|
|
4585
|
+
function markdownObject(obj, depth) {
|
|
4586
|
+
const scalars = [];
|
|
4587
|
+
const blocks = [];
|
|
4588
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
4589
|
+
if (value === undefined)
|
|
4590
|
+
continue;
|
|
4591
|
+
const label = markdownLabel(key);
|
|
4592
|
+
if (Array.isArray(value)) {
|
|
4593
|
+
blocks.push(`${markdownHeading(depth)} ${label}
|
|
4594
|
+
|
|
4595
|
+
${markdownRows(value, depth + 1)}`);
|
|
4596
|
+
} else if (isNonEmptyPlainObject(value)) {
|
|
4597
|
+
const nested = depth < MARKDOWN_MAX_DEPTH ? markdownObject(value, depth + 1) : fencedBlock(JSON.stringify(value, null, 2));
|
|
4598
|
+
if (nested !== "") {
|
|
4599
|
+
blocks.push(`${markdownHeading(depth)} ${label}
|
|
4600
|
+
|
|
4601
|
+
${nested}`);
|
|
4602
|
+
}
|
|
4603
|
+
} else if (typeof value === "string" && value.includes(`
|
|
4604
|
+
`)) {
|
|
4605
|
+
blocks.push(`**${label}:**
|
|
4606
|
+
|
|
4607
|
+
${fencedBlock(value)}`);
|
|
4608
|
+
} else {
|
|
4609
|
+
scalars.push(`**${label}:** ${markdownCell(value)}`);
|
|
4610
|
+
}
|
|
4611
|
+
}
|
|
4612
|
+
const sections = scalars.length > 0 ? [scalars.join(`
|
|
4613
|
+
`)] : [];
|
|
4614
|
+
sections.push(...blocks);
|
|
4615
|
+
return sections.join(`
|
|
4616
|
+
|
|
4617
|
+
`);
|
|
4618
|
+
}
|
|
4619
|
+
function extractSingleMessage(payload) {
|
|
4620
|
+
if (!isPlainRecord(payload))
|
|
4621
|
+
return null;
|
|
4622
|
+
const keys = Object.keys(payload);
|
|
4623
|
+
if (keys.length !== 1 || keys[0].toLowerCase() !== "message")
|
|
4624
|
+
return null;
|
|
4625
|
+
const value = payload[keys[0]];
|
|
4626
|
+
return typeof value === "string" ? value : null;
|
|
4627
|
+
}
|
|
4628
|
+
function markdownPayload(payload) {
|
|
4629
|
+
const message = extractSingleMessage(payload);
|
|
4630
|
+
if (message !== null)
|
|
4631
|
+
return message;
|
|
4632
|
+
if (Array.isArray(payload)) {
|
|
4633
|
+
return markdownRows(rowsWithoutPlumbing(payload), 0);
|
|
4634
|
+
}
|
|
4635
|
+
const visible = withoutPlumbing(payload);
|
|
4636
|
+
const paged = splitPagedEnvelope(visible);
|
|
4637
|
+
if (paged !== null) {
|
|
4638
|
+
const meta = markdownObject(paged.meta, 0);
|
|
4639
|
+
const rows = `${markdownHeading(0)} ${markdownLabel(paged.key)}
|
|
4640
|
+
|
|
4641
|
+
${markdownRows(rowsWithoutPlumbing(paged.rows), 1)}`;
|
|
4642
|
+
return meta === "" ? rows : `${meta}
|
|
4643
|
+
|
|
4644
|
+
${rows}`;
|
|
4645
|
+
}
|
|
4646
|
+
return markdownObject(visible, 0);
|
|
4647
|
+
}
|
|
4648
|
+
function isPaginationWorthShowing(value) {
|
|
4649
|
+
if (typeof value !== "object" || value === null)
|
|
4650
|
+
return false;
|
|
4651
|
+
const page = value;
|
|
4652
|
+
return page.HasMore === true || typeof page.Offset === "number" && page.Offset > 0;
|
|
4653
|
+
}
|
|
4654
|
+
function markdownEnvelopeNotes(data) {
|
|
4655
|
+
const envelope = data;
|
|
4656
|
+
const notes = [];
|
|
4657
|
+
const warning = envelope.Warning;
|
|
4658
|
+
if (typeof warning === "string" && warning !== "") {
|
|
4659
|
+
notes.push(`> **Warning:** ${warning}`);
|
|
4660
|
+
}
|
|
4661
|
+
const instructions = envelope.Instructions;
|
|
4662
|
+
if (typeof instructions === "string" && instructions !== "") {
|
|
4663
|
+
notes.push(`> ${instructions}`);
|
|
4664
|
+
}
|
|
4665
|
+
const pagination = envelope.Pagination;
|
|
4666
|
+
if (isPaginationWorthShowing(pagination)) {
|
|
4667
|
+
const body = markdownObject(pagination, 1);
|
|
4668
|
+
if (body !== "") {
|
|
4669
|
+
notes.push(`${markdownHeading(0)} Pagination
|
|
4670
|
+
|
|
4671
|
+
${body}`);
|
|
4672
|
+
}
|
|
4673
|
+
}
|
|
4674
|
+
const log = envelope.Log;
|
|
4675
|
+
if (typeof log === "string" && log !== "") {
|
|
4676
|
+
notes.push(`**Log:** ${log}`);
|
|
4677
|
+
}
|
|
4678
|
+
return notes;
|
|
4679
|
+
}
|
|
4680
|
+
function renderMarkdown(data) {
|
|
4681
|
+
if (data.Result !== RESULTS.Success) {
|
|
4682
|
+
const failure = data;
|
|
4683
|
+
const sections = [`**Failed:** ${failure.Message}`];
|
|
4684
|
+
if (failure.Data != null) {
|
|
4685
|
+
sections.push(markdownPayload(failure.Data));
|
|
4686
|
+
}
|
|
4687
|
+
if (failure.Instructions) {
|
|
4688
|
+
sections.push(`> ${failure.Instructions}`);
|
|
4689
|
+
}
|
|
4690
|
+
return sections.filter((section) => section !== "").join(`
|
|
4691
|
+
|
|
4692
|
+
`);
|
|
4693
|
+
}
|
|
4694
|
+
if (!("Data" in data) || data.Data == null) {
|
|
4695
|
+
return markdownObject(withoutPlumbing(data), 0);
|
|
4696
|
+
}
|
|
4697
|
+
return [markdownPayload(data.Data), ...markdownEnvelopeNotes(data)].filter((section) => section !== "").join(`
|
|
4698
|
+
|
|
4699
|
+
`);
|
|
4700
|
+
}
|
|
4471
4701
|
function toYaml(data) {
|
|
4472
4702
|
const codec = getYamlCodec();
|
|
4473
4703
|
if (!codec) {
|
|
@@ -5346,6 +5576,11 @@ var RESERVED_KEYWORDS_LOWER = new Set([
|
|
|
5346
5576
|
"writeonly",
|
|
5347
5577
|
"xor"
|
|
5348
5578
|
]);
|
|
5579
|
+
// ../common/src/guid.ts
|
|
5580
|
+
var GUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
5581
|
+
function isGuid(value) {
|
|
5582
|
+
return GUID_REGEX.test(value);
|
|
5583
|
+
}
|
|
5349
5584
|
// ../common/src/host-global-options.ts
|
|
5350
5585
|
var HOST_GLOBAL_OPTIONS_WITH_VALUE = [
|
|
5351
5586
|
"--output",
|
|
@@ -5512,8 +5747,9 @@ class InsightsProtocolError extends Error {
|
|
|
5512
5747
|
// ../insights-sdk/package.json
|
|
5513
5748
|
var package_default2 = {
|
|
5514
5749
|
name: "@uipath/insights-sdk",
|
|
5750
|
+
author: "UiPath",
|
|
5515
5751
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
5516
|
-
version: "1.
|
|
5752
|
+
version: "1.203.0-preview.180",
|
|
5517
5753
|
description: "SDK for the UiPath Insights API — jobs, failures, and performance metrics.",
|
|
5518
5754
|
repository: {
|
|
5519
5755
|
type: "git",
|
|
@@ -6635,16 +6871,7 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
|
|
|
6635
6871
|
errorMessage: location.source === "absolute" ? `Environment file not found: ${envFilePath}` : `Unable to locate environment file: ${envFilePath}. Run 'uip login' to authenticate.`
|
|
6636
6872
|
};
|
|
6637
6873
|
};
|
|
6638
|
-
var
|
|
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)) {
|
|
6642
|
-
throw new Error(`Environment file not found: ${envPath}`);
|
|
6643
|
-
}
|
|
6644
|
-
const content = await fs2.readFile(absolutePath, "utf-8");
|
|
6645
|
-
if (content === null) {
|
|
6646
|
-
throw new Error(`Environment file not found: ${envPath}`);
|
|
6647
|
-
}
|
|
6874
|
+
var parseEnvContent = (content) => {
|
|
6648
6875
|
const env = {};
|
|
6649
6876
|
for (const line of content.split(`
|
|
6650
6877
|
`)) {
|
|
@@ -6665,6 +6892,18 @@ var loadEnvFileAsync = async ({ envPath }) => {
|
|
|
6665
6892
|
}
|
|
6666
6893
|
return env;
|
|
6667
6894
|
};
|
|
6895
|
+
var loadEnvFileAsync = async ({ envPath }) => {
|
|
6896
|
+
const fs2 = getFileSystem();
|
|
6897
|
+
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
|
|
6898
|
+
if (!await fs2.exists(absolutePath)) {
|
|
6899
|
+
throw new Error(`Environment file not found: ${envPath}`);
|
|
6900
|
+
}
|
|
6901
|
+
const content = await fs2.readFile(absolutePath, "utf-8");
|
|
6902
|
+
if (content === null) {
|
|
6903
|
+
throw new Error(`Environment file not found: ${envPath}`);
|
|
6904
|
+
}
|
|
6905
|
+
return parseEnvContent(content);
|
|
6906
|
+
};
|
|
6668
6907
|
var saveEnvFileAsync = async ({
|
|
6669
6908
|
envPath,
|
|
6670
6909
|
data,
|
|
@@ -7305,6 +7544,27 @@ async function listMachineFilters(config) {
|
|
|
7305
7544
|
async function listUsers(config) {
|
|
7306
7545
|
return requestInsightsRoute(config, "usersList");
|
|
7307
7546
|
}
|
|
7547
|
+
async function getUser(config, userId) {
|
|
7548
|
+
return requestInsightsRoute(config, "usersGet", {
|
|
7549
|
+
pathParams: { userId }
|
|
7550
|
+
});
|
|
7551
|
+
}
|
|
7552
|
+
async function listRoles(config) {
|
|
7553
|
+
return requestInsightsRoute(config, "rolesList");
|
|
7554
|
+
}
|
|
7555
|
+
async function getRole(config, roleId) {
|
|
7556
|
+
return requestInsightsRoute(config, "rolesGet", {
|
|
7557
|
+
pathParams: { roleId }
|
|
7558
|
+
});
|
|
7559
|
+
}
|
|
7560
|
+
async function listGroups(config) {
|
|
7561
|
+
return requestInsightsRoute(config, "groupsList");
|
|
7562
|
+
}
|
|
7563
|
+
async function getGroup(config, groupId) {
|
|
7564
|
+
return requestInsightsRoute(config, "groupsGet", {
|
|
7565
|
+
pathParams: { groupId }
|
|
7566
|
+
});
|
|
7567
|
+
}
|
|
7308
7568
|
// src/utils/output.ts
|
|
7309
7569
|
function fail(message, instructions) {
|
|
7310
7570
|
OutputFormatter.error({
|
|
@@ -8256,111 +8516,6 @@ function registerFilterQueuesCommand(program2) {
|
|
|
8256
8516
|
});
|
|
8257
8517
|
}
|
|
8258
8518
|
|
|
8259
|
-
// src/commands/jobs.ts
|
|
8260
|
-
function collect(val, prev) {
|
|
8261
|
-
return prev ? [...prev, val] : [val];
|
|
8262
|
-
}
|
|
8263
|
-
function parseIntOption(name) {
|
|
8264
|
-
return (val) => {
|
|
8265
|
-
const n = Number.parseInt(val, 10);
|
|
8266
|
-
if (Number.isNaN(n)) {
|
|
8267
|
-
throw new Error(`--${name} must be a number, got: ${val}`);
|
|
8268
|
-
}
|
|
8269
|
-
return n;
|
|
8270
|
-
};
|
|
8271
|
-
}
|
|
8272
|
-
function addJobsFilterOptions(cmd) {
|
|
8273
|
-
return cmd.addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--time-range <minutes>", "Relative time range in minutes (e.g. 1440 for 1 day, 43200 for 30 days)", parseIntOption("time-range")).option("--started-after <epoch-ms>", "Absolute start time as Unix epoch milliseconds", parseIntOption("started-after")).option("--started-before <epoch-ms>", "Absolute end time as Unix epoch milliseconds", parseIntOption("started-before")).option("--folder-key <guid>", "Folder key filter (repeatable)", collect).option("--process-name <name>", "Process name filter (repeatable)", collect).option("--machine-name <name>", "Machine name filter (repeatable)", collect).option("--timezone-offset <minutes>", "Client timezone offset in minutes from UTC", parseIntOption("timezone-offset"));
|
|
8274
|
-
}
|
|
8275
|
-
function buildRequestBody(tenantId, options) {
|
|
8276
|
-
const request = { tenantId };
|
|
8277
|
-
if (options.timeRange !== undefined) {
|
|
8278
|
-
request.relativeTimeRange = options.timeRange;
|
|
8279
|
-
}
|
|
8280
|
-
if (options.startedAfter !== undefined) {
|
|
8281
|
-
request.absoluteStartTime = options.startedAfter;
|
|
8282
|
-
}
|
|
8283
|
-
if (options.startedBefore !== undefined) {
|
|
8284
|
-
request.absoluteEndTime = options.startedBefore;
|
|
8285
|
-
}
|
|
8286
|
-
if (options.folderKey) {
|
|
8287
|
-
request.folderFilter = options.folderKey;
|
|
8288
|
-
}
|
|
8289
|
-
if (options.processName) {
|
|
8290
|
-
request.processFilter = options.processName;
|
|
8291
|
-
}
|
|
8292
|
-
if (options.machineName) {
|
|
8293
|
-
request.machineFilter = options.machineName;
|
|
8294
|
-
}
|
|
8295
|
-
if (options.timezoneOffset !== undefined) {
|
|
8296
|
-
request.timezoneOffsetInMinutes = options.timezoneOffset;
|
|
8297
|
-
}
|
|
8298
|
-
return request;
|
|
8299
|
-
}
|
|
8300
|
-
async function executeJobsEndpoint(options, endpointPath, code) {
|
|
8301
|
-
const hasRelative = options.timeRange !== undefined;
|
|
8302
|
-
const hasAbsolute = options.startedAfter !== undefined && options.startedBefore !== undefined;
|
|
8303
|
-
if (!hasRelative && !hasAbsolute) {
|
|
8304
|
-
OutputFormatter.error({
|
|
8305
|
-
Result: RESULTS.Failure,
|
|
8306
|
-
Message: "A time range is required. Provide --time-range <minutes>, or both --started-after <epoch-ms> and --started-before <epoch-ms>.",
|
|
8307
|
-
Instructions: "Example: --time-range 1440 (last 24 hours) or --time-range 43200 (last 30 days)."
|
|
8308
|
-
});
|
|
8309
|
-
processContext.exit(1);
|
|
8310
|
-
return;
|
|
8311
|
-
}
|
|
8312
|
-
const [configErr, config] = await catchError(createInsightsConfig(options.tenant));
|
|
8313
|
-
if (configErr) {
|
|
8314
|
-
OutputFormatter.error({
|
|
8315
|
-
Result: RESULTS.Failure,
|
|
8316
|
-
Message: configErr.message,
|
|
8317
|
-
Instructions: "Run 'uip login' to authenticate first."
|
|
8318
|
-
});
|
|
8319
|
-
processContext.exit(1);
|
|
8320
|
-
return;
|
|
8321
|
-
}
|
|
8322
|
-
const body = buildRequestBody(config.tenantId, options);
|
|
8323
|
-
const [apiErr, result] = await catchError(insightsPost(config, endpointPath, body));
|
|
8324
|
-
if (apiErr) {
|
|
8325
|
-
OutputFormatter.error({
|
|
8326
|
-
Result: RESULTS.Failure,
|
|
8327
|
-
Message: apiErr.message,
|
|
8328
|
-
Instructions: "Check your authentication, tenant, and filter parameters."
|
|
8329
|
-
});
|
|
8330
|
-
processContext.exit(1);
|
|
8331
|
-
return;
|
|
8332
|
-
}
|
|
8333
|
-
OutputFormatter.success({
|
|
8334
|
-
Result: "Success",
|
|
8335
|
-
Code: code,
|
|
8336
|
-
Data: result
|
|
8337
|
-
});
|
|
8338
|
-
}
|
|
8339
|
-
function registerJobsCommand(program2) {
|
|
8340
|
-
const jobsCmd = program2.command("jobs").description("Query Insights job execution data");
|
|
8341
|
-
addJobsFilterOptions(jobsCmd.command("summary").description("Get jobs summary: total count, successful count, and average processing time")).trackedAction(processContext, async (options) => {
|
|
8342
|
-
await executeJobsEndpoint(options, "/summary", "InsightsJobsSummary");
|
|
8343
|
-
});
|
|
8344
|
-
addJobsFilterOptions(jobsCmd.command("completed-timeline").description("Get completed jobs over time, grouped by job state")).trackedAction(processContext, async (options) => {
|
|
8345
|
-
await executeJobsEndpoint(options, "/completed-timeline", "InsightsJobsCompletedTimeline");
|
|
8346
|
-
});
|
|
8347
|
-
addJobsFilterOptions(jobsCmd.command("uncompleted-timeline").description("Get uncompleted (running/pending) jobs over time")).trackedAction(processContext, async (options) => {
|
|
8348
|
-
await executeJobsEndpoint(options, "/uncompleted-timeline", "InsightsJobsUncompletedTimeline");
|
|
8349
|
-
});
|
|
8350
|
-
addJobsFilterOptions(jobsCmd.command("top-failures").description("Get processes with the most job failures")).trackedAction(processContext, async (options) => {
|
|
8351
|
-
await executeJobsEndpoint(options, "/top-failures", "InsightsJobsTopFailures");
|
|
8352
|
-
});
|
|
8353
|
-
addJobsFilterOptions(jobsCmd.command("failures-by-reason").description("Get job failures grouped by exception reason")).trackedAction(processContext, async (options) => {
|
|
8354
|
-
await executeJobsEndpoint(options, "/failures-by-reason", "InsightsJobsFailuresByReason");
|
|
8355
|
-
});
|
|
8356
|
-
addJobsFilterOptions(jobsCmd.command("process-details").description("Get detailed per-process job breakdown with counts by state")).trackedAction(processContext, async (options) => {
|
|
8357
|
-
await executeJobsEndpoint(options, "/process-details", "InsightsJobsProcessDetails");
|
|
8358
|
-
});
|
|
8359
|
-
addJobsFilterOptions(jobsCmd.command("failure-details").description("Get detailed failure information for drill-down investigation")).trackedAction(processContext, async (options) => {
|
|
8360
|
-
await executeJobsEndpoint(options, "/failure-details", "InsightsJobsFailureDetails");
|
|
8361
|
-
});
|
|
8362
|
-
}
|
|
8363
|
-
|
|
8364
8519
|
// src/utils/rbac.ts
|
|
8365
8520
|
class RbacContractError extends Error {
|
|
8366
8521
|
constructor(message) {
|
|
@@ -8370,10 +8525,11 @@ class RbacContractError extends Error {
|
|
|
8370
8525
|
}
|
|
8371
8526
|
var { requireArrayField: requireArrayField2, requireKnownShape: requireKnownShape2 } = createContractGuards((message) => new RbacContractError(message));
|
|
8372
8527
|
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) {
|
|
8528
|
+
function rbacFamily(subject, notFoundExtra = "") {
|
|
8374
8529
|
return {
|
|
8375
8530
|
subject,
|
|
8376
8531
|
forbiddenExtra: MANAGEMENT_VIEW_NOTE,
|
|
8532
|
+
notFoundExtra,
|
|
8377
8533
|
isContractError: (error) => error instanceof RbacContractError
|
|
8378
8534
|
};
|
|
8379
8535
|
}
|
|
@@ -8392,10 +8548,15 @@ function unwrapPortalBody(raw, subject) {
|
|
|
8392
8548
|
return raw;
|
|
8393
8549
|
}
|
|
8394
8550
|
var PRINCIPAL_FIELDS = ["id", "name", "roles"];
|
|
8551
|
+
var ROLE_FIELDS = ["id", "name", "actions"];
|
|
8395
8552
|
var PRINCIPAL_WITHHELD_NOTE = "This view omits email and the nested role IDs. Pass --include-email to include them.";
|
|
8553
|
+
function addIncludeEmailOption(cmd) {
|
|
8554
|
+
return cmd.option("--include-email", "Include email addresses and nested role IDs in the output");
|
|
8555
|
+
}
|
|
8396
8556
|
function roleName(role) {
|
|
8397
8557
|
return typeof role === "string" ? role : pickScalar(asRecord(role)?.name);
|
|
8398
8558
|
}
|
|
8559
|
+
var ROLE_WITHHELD_NOTE = "This view omits the role resource string, which can carry the organization and tenant GUIDs. Pass --include-resource to include it.";
|
|
8399
8560
|
function safeRole(role) {
|
|
8400
8561
|
return { name: roleName(role) };
|
|
8401
8562
|
}
|
|
@@ -8423,6 +8584,24 @@ function projectPrincipal(raw, subject, full) {
|
|
|
8423
8584
|
}
|
|
8424
8585
|
return row;
|
|
8425
8586
|
}
|
|
8587
|
+
function projectRole(raw, subject, full) {
|
|
8588
|
+
const dto = asRecord(raw);
|
|
8589
|
+
if (!dto) {
|
|
8590
|
+
throw new RbacContractError(`Insights returned a ${subject} that is not an object`);
|
|
8591
|
+
}
|
|
8592
|
+
const noun = `a ${subject}`;
|
|
8593
|
+
requireKnownShape2(dto, ROLE_FIELDS, noun);
|
|
8594
|
+
const actions = requireArrayField2(dto, "actions", noun);
|
|
8595
|
+
const row = {
|
|
8596
|
+
id: pickScalar(dto.id),
|
|
8597
|
+
name: pickScalar(dto.name),
|
|
8598
|
+
actions: actions.map(pickScalar)
|
|
8599
|
+
};
|
|
8600
|
+
if (full) {
|
|
8601
|
+
row.resource = pickScalar(dto.resource);
|
|
8602
|
+
}
|
|
8603
|
+
return row;
|
|
8604
|
+
}
|
|
8426
8605
|
function projectRowAt(row, index, subject, project, full) {
|
|
8427
8606
|
try {
|
|
8428
8607
|
return project(row, subject, full);
|
|
@@ -8488,11 +8667,16 @@ function buildListInstructions2(spec, total, returned, hasMore, full) {
|
|
|
8488
8667
|
hasMore ? truncatedNote(`a ${spec.noun}`) : ""
|
|
8489
8668
|
]);
|
|
8490
8669
|
}
|
|
8670
|
+
function writeRbacGetNotFound(error, family, id) {
|
|
8671
|
+
writeInsightsNotFound(error, `${family.subject} ${id} was not found in the active Insights tenant, or is not visible there.`, joinParts([
|
|
8672
|
+
family.notFoundExtra,
|
|
8673
|
+
"If every Insights RBAC command returns 404, the tenant may not have the Insights Portal service provisioned."
|
|
8674
|
+
]));
|
|
8675
|
+
}
|
|
8491
8676
|
function writeRbacListNotFound(error, subject) {
|
|
8492
8677
|
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
8678
|
}
|
|
8494
|
-
async function executeRbacList(options, fetchList, family, spec) {
|
|
8495
|
-
const full = options.includeEmail === true;
|
|
8679
|
+
async function executeRbacList(options, fetchList, family, spec, full) {
|
|
8496
8680
|
await executeInsightsList(options, fetchList, {
|
|
8497
8681
|
code: spec.code,
|
|
8498
8682
|
family,
|
|
@@ -8507,22 +8691,223 @@ async function executeRbacList(options, fetchList, family, spec) {
|
|
|
8507
8691
|
}
|
|
8508
8692
|
});
|
|
8509
8693
|
}
|
|
8694
|
+
async function executeRbacGet(id, fetchOne, family, spec, full) {
|
|
8695
|
+
await executeInsightsGet((config) => fetchOne(config, id), {
|
|
8696
|
+
code: spec.code,
|
|
8697
|
+
family,
|
|
8698
|
+
project: (response) => spec.project(unwrapPortalBody(response, family.subject), family.subject, full),
|
|
8699
|
+
instructions: () => joinParts([spec.standingNote, full ? "" : spec.withheldNote]),
|
|
8700
|
+
onHttpError: (error) => {
|
|
8701
|
+
if (error.status !== 404) {
|
|
8702
|
+
return false;
|
|
8703
|
+
}
|
|
8704
|
+
writeRbacGetNotFound(error, family, id);
|
|
8705
|
+
return true;
|
|
8706
|
+
}
|
|
8707
|
+
});
|
|
8708
|
+
}
|
|
8709
|
+
var requireRbacGuid = (noun, discoveryCommand) => (value) => {
|
|
8710
|
+
if (isGuid(value)) {
|
|
8711
|
+
return true;
|
|
8712
|
+
}
|
|
8713
|
+
failValidation(`${noun}-id must be a GUID.`, `Run '${discoveryCommand}' to find a ${noun} ID.`);
|
|
8714
|
+
return false;
|
|
8715
|
+
};
|
|
8716
|
+
|
|
8717
|
+
// src/commands/groups.ts
|
|
8718
|
+
var requireGroupGuid = requireRbacGuid("group", "uip insights groups list");
|
|
8719
|
+
var GROUPS_LIST_NOTE = "Roles shown are the group's Insights roles in the active tenant, by name; 'uip insights roles list' maps a role name to its role GUID and back. Directory filtering can omit unresolved groups, so a missing row is not proof the stored group does not exist. Listing groups resolves each row through the directory, one cached call per group in sequence. 'uip insights groups get' returns the same fields as a row here and can persist refreshed directory name and email fields for the group, so read the row here when it is enough.";
|
|
8720
|
+
var GROUPS_EMPTY_NOTE = "Directory filtering can omit unresolved groups, so a missing row is not proof the stored group does not exist. Listing groups resolves each row through the directory, one cached call per group in sequence.";
|
|
8721
|
+
var GROUPS_GET_NOTE = "Roles shown are the group's Insights roles in the active tenant, by name; 'uip insights roles list' maps a role name to its role GUID and back. This command can persist refreshed directory name and email fields for the group. It is read-shaped but not a pure read.";
|
|
8722
|
+
var GROUPS_NOT_FOUND_EXTRA = "A group the directory cannot resolve also returns 404, so this is not proof the stored group does not exist.";
|
|
8723
|
+
var GROUPS_FAMILY = rbacFamily("Group", GROUPS_NOT_FOUND_EXTRA);
|
|
8724
|
+
function registerGroupsCommand(program2) {
|
|
8725
|
+
const groupsCmd = program2.command("groups").description("Read the Insights groups of the active tenant");
|
|
8726
|
+
addIncludeEmailOption(addListPaginationOptions(groupsCmd.command("list").description("List tenant groups visible to the current caller, with their Insights role names; directory filtering can omit unresolved groups, and each row costs a cached directory call"))).trackedAction(processContext, async (options) => {
|
|
8727
|
+
await executeRbacList(options, listGroups, GROUPS_FAMILY, {
|
|
8728
|
+
code: "InsightsGroupsList",
|
|
8729
|
+
project: projectPrincipal,
|
|
8730
|
+
standingNote: GROUPS_LIST_NOTE,
|
|
8731
|
+
withheldNote: PRINCIPAL_WITHHELD_NOTE,
|
|
8732
|
+
emptyNote: GROUPS_EMPTY_NOTE,
|
|
8733
|
+
noun: "group"
|
|
8734
|
+
}, options.includeEmail === true);
|
|
8735
|
+
});
|
|
8736
|
+
addIncludeEmailOption(groupsCmd.command("get").description("Get one Insights group by its GUID; this can persist refreshed directory name and email fields").argument("<group-id>", "Group GUID")).trackedAction(processContext, async (groupId, options) => {
|
|
8737
|
+
if (!requireGroupGuid(groupId)) {
|
|
8738
|
+
return;
|
|
8739
|
+
}
|
|
8740
|
+
await executeRbacGet(groupId, getGroup, GROUPS_FAMILY, {
|
|
8741
|
+
code: "InsightsGroupGet",
|
|
8742
|
+
project: projectPrincipal,
|
|
8743
|
+
standingNote: GROUPS_GET_NOTE,
|
|
8744
|
+
withheldNote: PRINCIPAL_WITHHELD_NOTE
|
|
8745
|
+
}, options.includeEmail === true);
|
|
8746
|
+
});
|
|
8747
|
+
}
|
|
8748
|
+
|
|
8749
|
+
// src/commands/jobs.ts
|
|
8750
|
+
function collect(val, prev) {
|
|
8751
|
+
return prev ? [...prev, val] : [val];
|
|
8752
|
+
}
|
|
8753
|
+
function parseIntOption(name) {
|
|
8754
|
+
return (val) => {
|
|
8755
|
+
const n = Number.parseInt(val, 10);
|
|
8756
|
+
if (Number.isNaN(n)) {
|
|
8757
|
+
throw new Error(`--${name} must be a number, got: ${val}`);
|
|
8758
|
+
}
|
|
8759
|
+
return n;
|
|
8760
|
+
};
|
|
8761
|
+
}
|
|
8762
|
+
function addJobsFilterOptions(cmd) {
|
|
8763
|
+
return cmd.addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--time-range <minutes>", "Relative time range in minutes (e.g. 1440 for 1 day, 43200 for 30 days)", parseIntOption("time-range")).option("--started-after <epoch-ms>", "Absolute start time as Unix epoch milliseconds", parseIntOption("started-after")).option("--started-before <epoch-ms>", "Absolute end time as Unix epoch milliseconds", parseIntOption("started-before")).option("--folder-key <guid>", "Folder key filter (repeatable)", collect).option("--process-name <name>", "Process name filter (repeatable)", collect).option("--machine-name <name>", "Machine name filter (repeatable)", collect).option("--timezone-offset <minutes>", "Client timezone offset in minutes from UTC", parseIntOption("timezone-offset"));
|
|
8764
|
+
}
|
|
8765
|
+
function buildRequestBody(tenantId, options) {
|
|
8766
|
+
const request = { tenantId };
|
|
8767
|
+
if (options.timeRange !== undefined) {
|
|
8768
|
+
request.relativeTimeRange = options.timeRange;
|
|
8769
|
+
}
|
|
8770
|
+
if (options.startedAfter !== undefined) {
|
|
8771
|
+
request.absoluteStartTime = options.startedAfter;
|
|
8772
|
+
}
|
|
8773
|
+
if (options.startedBefore !== undefined) {
|
|
8774
|
+
request.absoluteEndTime = options.startedBefore;
|
|
8775
|
+
}
|
|
8776
|
+
if (options.folderKey) {
|
|
8777
|
+
request.folderFilter = options.folderKey;
|
|
8778
|
+
}
|
|
8779
|
+
if (options.processName) {
|
|
8780
|
+
request.processFilter = options.processName;
|
|
8781
|
+
}
|
|
8782
|
+
if (options.machineName) {
|
|
8783
|
+
request.machineFilter = options.machineName;
|
|
8784
|
+
}
|
|
8785
|
+
if (options.timezoneOffset !== undefined) {
|
|
8786
|
+
request.timezoneOffsetInMinutes = options.timezoneOffset;
|
|
8787
|
+
}
|
|
8788
|
+
return request;
|
|
8789
|
+
}
|
|
8790
|
+
async function executeJobsEndpoint(options, endpointPath, code) {
|
|
8791
|
+
const hasRelative = options.timeRange !== undefined;
|
|
8792
|
+
const hasAbsolute = options.startedAfter !== undefined && options.startedBefore !== undefined;
|
|
8793
|
+
if (!hasRelative && !hasAbsolute) {
|
|
8794
|
+
OutputFormatter.error({
|
|
8795
|
+
Result: RESULTS.Failure,
|
|
8796
|
+
Message: "A time range is required. Provide --time-range <minutes>, or both --started-after <epoch-ms> and --started-before <epoch-ms>.",
|
|
8797
|
+
Instructions: "Example: --time-range 1440 (last 24 hours) or --time-range 43200 (last 30 days)."
|
|
8798
|
+
});
|
|
8799
|
+
processContext.exit(1);
|
|
8800
|
+
return;
|
|
8801
|
+
}
|
|
8802
|
+
const [configErr, config] = await catchError(createInsightsConfig(options.tenant));
|
|
8803
|
+
if (configErr) {
|
|
8804
|
+
OutputFormatter.error({
|
|
8805
|
+
Result: RESULTS.Failure,
|
|
8806
|
+
Message: configErr.message,
|
|
8807
|
+
Instructions: "Run 'uip login' to authenticate first."
|
|
8808
|
+
});
|
|
8809
|
+
processContext.exit(1);
|
|
8810
|
+
return;
|
|
8811
|
+
}
|
|
8812
|
+
const body = buildRequestBody(config.tenantId, options);
|
|
8813
|
+
const [apiErr, result] = await catchError(insightsPost(config, endpointPath, body));
|
|
8814
|
+
if (apiErr) {
|
|
8815
|
+
OutputFormatter.error({
|
|
8816
|
+
Result: RESULTS.Failure,
|
|
8817
|
+
Message: apiErr.message,
|
|
8818
|
+
Instructions: "Check your authentication, tenant, and filter parameters."
|
|
8819
|
+
});
|
|
8820
|
+
processContext.exit(1);
|
|
8821
|
+
return;
|
|
8822
|
+
}
|
|
8823
|
+
OutputFormatter.success({
|
|
8824
|
+
Result: "Success",
|
|
8825
|
+
Code: code,
|
|
8826
|
+
Data: result
|
|
8827
|
+
});
|
|
8828
|
+
}
|
|
8829
|
+
function registerJobsCommand(program2) {
|
|
8830
|
+
const jobsCmd = program2.command("jobs").description("Query Insights job execution data");
|
|
8831
|
+
addJobsFilterOptions(jobsCmd.command("summary").description("Get jobs summary: total count, successful count, and average processing time")).trackedAction(processContext, async (options) => {
|
|
8832
|
+
await executeJobsEndpoint(options, "/summary", "InsightsJobsSummary");
|
|
8833
|
+
});
|
|
8834
|
+
addJobsFilterOptions(jobsCmd.command("completed-timeline").description("Get completed jobs over time, grouped by job state")).trackedAction(processContext, async (options) => {
|
|
8835
|
+
await executeJobsEndpoint(options, "/completed-timeline", "InsightsJobsCompletedTimeline");
|
|
8836
|
+
});
|
|
8837
|
+
addJobsFilterOptions(jobsCmd.command("uncompleted-timeline").description("Get uncompleted (running/pending) jobs over time")).trackedAction(processContext, async (options) => {
|
|
8838
|
+
await executeJobsEndpoint(options, "/uncompleted-timeline", "InsightsJobsUncompletedTimeline");
|
|
8839
|
+
});
|
|
8840
|
+
addJobsFilterOptions(jobsCmd.command("top-failures").description("Get processes with the most job failures")).trackedAction(processContext, async (options) => {
|
|
8841
|
+
await executeJobsEndpoint(options, "/top-failures", "InsightsJobsTopFailures");
|
|
8842
|
+
});
|
|
8843
|
+
addJobsFilterOptions(jobsCmd.command("failures-by-reason").description("Get job failures grouped by exception reason")).trackedAction(processContext, async (options) => {
|
|
8844
|
+
await executeJobsEndpoint(options, "/failures-by-reason", "InsightsJobsFailuresByReason");
|
|
8845
|
+
});
|
|
8846
|
+
addJobsFilterOptions(jobsCmd.command("process-details").description("Get detailed per-process job breakdown with counts by state")).trackedAction(processContext, async (options) => {
|
|
8847
|
+
await executeJobsEndpoint(options, "/process-details", "InsightsJobsProcessDetails");
|
|
8848
|
+
});
|
|
8849
|
+
addJobsFilterOptions(jobsCmd.command("failure-details").description("Get detailed failure information for drill-down investigation")).trackedAction(processContext, async (options) => {
|
|
8850
|
+
await executeJobsEndpoint(options, "/failure-details", "InsightsJobsFailureDetails");
|
|
8851
|
+
});
|
|
8852
|
+
}
|
|
8853
|
+
|
|
8854
|
+
// src/commands/roles.ts
|
|
8855
|
+
var ROLES_FAMILY = rbacFamily("Role");
|
|
8856
|
+
var requireRoleGuid = requireRbacGuid("role", "uip insights roles list");
|
|
8857
|
+
var ROLES_LIST_NOTE = "Role names can be entitlement-filtered: a role missing from this list can still exist and 'roles get' can still resolve it. Listing roles can trigger a cached entitlement call to Licensing. 'uip insights users list' and 'uip insights groups list' show these roles by name on each principal's row.";
|
|
8858
|
+
var INCLUDE_RESOURCE_DESCRIPTION = "Include the role resource string, which can carry the organization and tenant GUIDs, in the output";
|
|
8859
|
+
function registerRolesCommand(program2) {
|
|
8860
|
+
const rolesCmd = program2.command("roles").description("Read the Insights roles of the active tenant");
|
|
8861
|
+
addListPaginationOptions(rolesCmd.command("list").description("List Insights roles visible to the current caller; the list can be entitlement-filtered and can trigger a cached Licensing call")).option("--include-resource", INCLUDE_RESOURCE_DESCRIPTION).trackedAction(processContext, async (options) => {
|
|
8862
|
+
await executeRbacList(options, listRoles, ROLES_FAMILY, {
|
|
8863
|
+
code: "InsightsRolesList",
|
|
8864
|
+
project: projectRole,
|
|
8865
|
+
standingNote: ROLES_LIST_NOTE,
|
|
8866
|
+
withheldNote: ROLE_WITHHELD_NOTE,
|
|
8867
|
+
emptyNote: ROLES_LIST_NOTE,
|
|
8868
|
+
noun: "role"
|
|
8869
|
+
}, options.includeResource === true);
|
|
8870
|
+
});
|
|
8871
|
+
rolesCmd.command("get").description("Get one Insights role by its GUID; the list's entitlement filter does not apply here").argument("<role-id>", "Role GUID").option("--include-resource", INCLUDE_RESOURCE_DESCRIPTION).trackedAction(processContext, async (roleId, options) => {
|
|
8872
|
+
if (!requireRoleGuid(roleId)) {
|
|
8873
|
+
return;
|
|
8874
|
+
}
|
|
8875
|
+
await executeRbacGet(roleId, getRole, ROLES_FAMILY, {
|
|
8876
|
+
code: "InsightsRoleGet",
|
|
8877
|
+
project: projectRole,
|
|
8878
|
+
standingNote: "",
|
|
8879
|
+
withheldNote: ROLE_WITHHELD_NOTE
|
|
8880
|
+
}, options.includeResource === true);
|
|
8881
|
+
});
|
|
8882
|
+
}
|
|
8510
8883
|
|
|
8511
8884
|
// src/commands/users.ts
|
|
8512
8885
|
var USERS_FAMILY = rbacFamily("User");
|
|
8513
|
-
var
|
|
8886
|
+
var requireUserGuid = requireRbacGuid("user", "uip insights users list");
|
|
8887
|
+
var USERS_STANDING_NOTE = "Roles shown are the user's Insights roles in the active tenant, by name; 'uip insights roles list' maps a role name to its role GUID and back. A user's row is kept even when directory enrichment fails.";
|
|
8514
8888
|
var USERS_EMPTY_NOTE = "A user's row is kept even when directory enrichment fails.";
|
|
8515
8889
|
function registerUsersCommand(program2) {
|
|
8516
8890
|
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"))
|
|
8891
|
+
addIncludeEmailOption(addListPaginationOptions(usersCmd.command("list").description("List tenant users visible to the current caller, with their Insights role names"))).trackedAction(processContext, async (options) => {
|
|
8518
8892
|
await executeRbacList(options, listUsers, USERS_FAMILY, {
|
|
8519
8893
|
code: "InsightsUsersList",
|
|
8520
8894
|
project: projectPrincipal,
|
|
8521
|
-
standingNote:
|
|
8895
|
+
standingNote: USERS_STANDING_NOTE,
|
|
8522
8896
|
withheldNote: PRINCIPAL_WITHHELD_NOTE,
|
|
8523
8897
|
emptyNote: USERS_EMPTY_NOTE,
|
|
8524
8898
|
noun: "user"
|
|
8525
|
-
});
|
|
8899
|
+
}, options.includeEmail === true);
|
|
8900
|
+
});
|
|
8901
|
+
addIncludeEmailOption(usersCmd.command("get").description("Get one Insights user by its GUID").argument("<user-id>", "User GUID")).trackedAction(processContext, async (userId, options) => {
|
|
8902
|
+
if (!requireUserGuid(userId)) {
|
|
8903
|
+
return;
|
|
8904
|
+
}
|
|
8905
|
+
await executeRbacGet(userId, getUser, USERS_FAMILY, {
|
|
8906
|
+
code: "InsightsUserGet",
|
|
8907
|
+
project: projectPrincipal,
|
|
8908
|
+
standingNote: USERS_STANDING_NOTE,
|
|
8909
|
+
withheldNote: PRINCIPAL_WITHHELD_NOTE
|
|
8910
|
+
}, options.includeEmail === true);
|
|
8526
8911
|
});
|
|
8527
8912
|
}
|
|
8528
8913
|
|
|
@@ -8543,8 +8928,10 @@ var registerCommands = async (program2) => {
|
|
|
8543
8928
|
registerAlertHistoryCommand(program2);
|
|
8544
8929
|
registerAlertDeliveriesCommand(program2);
|
|
8545
8930
|
registerUsersCommand(program2);
|
|
8931
|
+
registerRolesCommand(program2);
|
|
8932
|
+
registerGroupsCommand(program2);
|
|
8546
8933
|
};
|
|
8547
8934
|
|
|
8548
8935
|
export { Command, metadata, registerCommands };
|
|
8549
8936
|
|
|
8550
|
-
//# debugId=
|
|
8937
|
+
//# debugId=57995FF7C3817AA764756E2164756E21
|
package/dist/tool.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/insights-tool",
|
|
3
|
+
"author": "UiPath",
|
|
3
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
4
|
-
"version": "1.
|
|
5
|
+
"version": "1.203.0-preview.180",
|
|
5
6
|
"description": "Query UiPath Insights data — jobs, failures, and performance metrics.",
|
|
6
7
|
"private": false,
|
|
7
8
|
"repository": {
|
|
@@ -26,5 +27,5 @@
|
|
|
26
27
|
"files": [
|
|
27
28
|
"dist"
|
|
28
29
|
],
|
|
29
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "4e0a51e3ab2c9d89afd3d35a7b087a7fa58133a0"
|
|
30
31
|
}
|