@uipath/guardrails-tool 1.202.0 → 1.203.0-preview.160

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.
Files changed (2) hide show
  1. package/dist/tool.js +264 -31
  2. package/package.json +3 -2
package/dist/tool.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/guardrails-tool",
2102
+ author: "UiPath",
2102
2103
  license: "SEE LICENSE IN LICENSE.txt",
2103
- version: "1.202.0",
2104
+ version: "1.203.0-preview.160",
2104
2105
  description: "CLI plugin for UiPath AI Trust Layer guardrail configurations.",
2105
2106
  private: false,
2106
2107
  repository: {
@@ -2650,7 +2651,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
2650
2651
  var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
2651
2652
  var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
2652
2653
  var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
2653
- var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
2654
+ var PADDED_BASE64_PATTERN = /(?<![A-Za-z0-9+/])[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
2654
2655
  var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
2655
2656
  var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
2656
2657
  var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
@@ -2697,7 +2698,7 @@ var QUOTED_LITERAL_PATTERN = new RegExp([
2697
2698
  `(?<![A-Za-z0-9])"(?:[^\\
2698
2699
  ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
2699
2700
  ].join("|"), "g");
2700
- var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
2701
+ var JSON_BODY_PATTERN = /[{[][^{}[\]:,]*[:,][^{}[\]]*[\]}]/g;
2701
2702
  var COLLAPSED_BODY = "{…}";
2702
2703
  var COLLAPSED_BODY_MARKER = "\x01body\x01";
2703
2704
  var MAX_BODY_NESTING = 8;
@@ -2712,10 +2713,13 @@ function collapseJsonBodies(text) {
2712
2713
  }
2713
2714
  return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
2714
2715
  }
2715
- var TRAILING_PROSE_PUNCT = /[.,;:!?)\]}>'"]+$/;
2716
+ var TRAILING_PROSE_PUNCT = `.,;:!?)]}>'"`;
2716
2717
  function peelTrailingPunctuation(match) {
2717
- const trailing = match.match(TRAILING_PROSE_PUNCT)?.[0] ?? "";
2718
- return trailing ? [match.slice(0, -trailing.length), trailing] : [match, ""];
2718
+ let end = match.length;
2719
+ while (end > 0 && TRAILING_PROSE_PUNCT.includes(match[end - 1])) {
2720
+ end -= 1;
2721
+ }
2722
+ return [match.slice(0, end), match.slice(end)];
2719
2723
  }
2720
2724
  function redactUrl(raw) {
2721
2725
  try {
@@ -3417,7 +3421,8 @@ function readRegistryValue(keyPath, valueName) {
3417
3421
  }
3418
3422
  const [error, output] = catchError(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
3419
3423
  encoding: "utf-8",
3420
- stdio: ["pipe", "pipe", "pipe"]
3424
+ stdio: ["pipe", "pipe", "pipe"],
3425
+ windowsHide: true
3421
3426
  }));
3422
3427
  if (error) {
3423
3428
  return "";
@@ -4099,28 +4104,32 @@ function isPlainRecord(value) {
4099
4104
  const prototype = Object.getPrototypeOf(value);
4100
4105
  return prototype === Object.prototype || prototype === null;
4101
4106
  }
4102
- function extractPagedRows(value) {
4107
+ function splitPagedEnvelope(value) {
4103
4108
  if (Array.isArray(value) || !isPlainRecord(value))
4104
4109
  return null;
4105
- const entries = Object.values(value);
4110
+ const entries = Object.entries(value);
4106
4111
  if (entries.length === 0)
4107
4112
  return null;
4108
- let rows = null;
4109
- let hasScalarSibling = false;
4110
- for (const entry of entries) {
4113
+ let found = null;
4114
+ const meta = Object.create(null);
4115
+ for (const [key, entry] of entries) {
4111
4116
  if (Array.isArray(entry)) {
4112
- if (rows !== null)
4117
+ if (found !== null)
4113
4118
  return null;
4114
- rows = entry;
4119
+ found = { key, rows: entry };
4115
4120
  } else if (entry !== null && typeof entry === "object") {
4116
4121
  return null;
4117
4122
  } else {
4118
- hasScalarSibling = true;
4123
+ meta[key] = entry;
4119
4124
  }
4120
4125
  }
4121
- if (rows === null || !hasScalarSibling)
4126
+ if (found === null || Object.keys(meta).length === 0)
4122
4127
  return null;
4123
- return rows;
4128
+ return { ...found, meta };
4129
+ }
4130
+ function extractPagedRows(value) {
4131
+ const paged = splitPagedEnvelope(value);
4132
+ return paged === null ? null : paged.rows;
4124
4133
  }
4125
4134
  function toLowerCamelCaseKey(key) {
4126
4135
  if (!key)
@@ -4224,6 +4233,9 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
4224
4233
  }
4225
4234
  break;
4226
4235
  }
4236
+ case "markdown":
4237
+ logFn(renderMarkdown(data));
4238
+ break;
4227
4239
  default: {
4228
4240
  const hasData = "Data" in data && data.Data != null;
4229
4241
  const pagedRows = hasData ? extractPagedRows(data.Data) : null;
@@ -4248,6 +4260,10 @@ function logOutput(data, format = "json", tableRowStyle) {
4248
4260
  printOutput(data, format, (msg) => sink.writeOut(`${msg}
4249
4261
  `), needsAsciiSafeJson(sink), styleFn);
4250
4262
  }
4263
+ var PLUMBING_KEYS = new Set(["code", "log"]);
4264
+ function isPlumbingKey(key) {
4265
+ return PLUMBING_KEYS.has(key.toLowerCase());
4266
+ }
4251
4267
  function cellToString(val) {
4252
4268
  return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
4253
4269
  }
@@ -4263,7 +4279,7 @@ function wrapText(text, width) {
4263
4279
  function printTable(data, logFn, externalLogValue, tableRowStyle) {
4264
4280
  if (data.length === 0)
4265
4281
  return;
4266
- const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
4282
+ const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
4267
4283
  const maxWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
4268
4284
  const header = keys.map((key, i) => key.padEnd(maxWidths[i])).join(" | ");
4269
4285
  logFn(header);
@@ -4285,7 +4301,7 @@ function isNonEmptyPlainObject(value) {
4285
4301
  }
4286
4302
  var NESTED_INDENT = " ";
4287
4303
  function printVerticalTable(data, logFn = console.log, externalLogValue) {
4288
- const keys = Object.keys(data).filter((key) => !["code", "log"].includes(key.toLowerCase()));
4304
+ const keys = Object.keys(data).filter((key) => !isPlumbingKey(key));
4289
4305
  if (keys.length === 0)
4290
4306
  return;
4291
4307
  const isBlockValue = (value) => isPlainObjectArray(value) || isNonEmptyPlainObject(value);
@@ -4316,7 +4332,7 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
4316
4332
  function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
4317
4333
  if (data.length === 0)
4318
4334
  return;
4319
- const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
4335
+ const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
4320
4336
  if (keys.length === 0)
4321
4337
  return;
4322
4338
  if (!process.stdout.isTTY) {
@@ -4390,6 +4406,220 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
4390
4406
  logFn(`Log: ${externalLogValue}`);
4391
4407
  }
4392
4408
  }
4409
+ var MARKDOWN_MAX_CELL = 200;
4410
+ var MARKDOWN_MAX_DEPTH = 3;
4411
+ function markdownHeading(depth) {
4412
+ return "#".repeat(Math.min(3 + depth, 6));
4413
+ }
4414
+ var BACKTICK_RUN = /`+/g;
4415
+ function fencedBlock(text) {
4416
+ const first = text.trimStart()[0];
4417
+ const language = first === "<" ? "xml" : first === "{" || first === "[" ? "json" : "";
4418
+ const longestRun = Math.max(0, ...Array.from(text.matchAll(BACKTICK_RUN), (match) => match[0].length));
4419
+ const fence = "`".repeat(Math.max(3, longestRun + 1));
4420
+ return `${fence}${language}
4421
+ ${text}
4422
+ ${fence}`;
4423
+ }
4424
+ function collapseNewlineRuns(text) {
4425
+ return text.split(/(\s+)/).map((part, index) => index % 2 === 1 && part.includes(`
4426
+ `) ? " " : part).join("");
4427
+ }
4428
+ function markdownCell(value) {
4429
+ const text = value instanceof Date ? value.toISOString() : cellToString(value);
4430
+ return collapseNewlineRuns(text).replace(/\|/g, "\\|");
4431
+ }
4432
+ function markdownLabel(key) {
4433
+ return collapseNewlineRuns(key).replace(/[\\`*|]/g, "\\$&");
4434
+ }
4435
+ function withoutPlumbing(record) {
4436
+ const kept = Object.create(null);
4437
+ for (const [key, value] of Object.entries(record)) {
4438
+ if (!isPlumbingKey(key))
4439
+ kept[key] = value;
4440
+ }
4441
+ return kept;
4442
+ }
4443
+ function rowsWithoutPlumbing(rows) {
4444
+ return rows.map((row) => isPlainRecord(row) ? withoutPlumbing(row) : row);
4445
+ }
4446
+ function markdownTable(rows) {
4447
+ const columns = [];
4448
+ const seen = new Set;
4449
+ for (const row of rows) {
4450
+ for (const key of Object.keys(row)) {
4451
+ if (!seen.has(key)) {
4452
+ seen.add(key);
4453
+ columns.push(key);
4454
+ }
4455
+ }
4456
+ }
4457
+ if (columns.length === 0)
4458
+ return null;
4459
+ const cells = rows.map((row) => columns.map((key) => markdownCell(row[key])));
4460
+ if (cells.some((row) => row.some((c) => c.length > MARKDOWN_MAX_CELL))) {
4461
+ return null;
4462
+ }
4463
+ return [
4464
+ `| ${columns.map(markdownLabel).join(" | ")} |`,
4465
+ `| ${columns.map(() => "---").join(" | ")} |`,
4466
+ ...cells.map((row) => `| ${row.join(" | ")} |`)
4467
+ ].join(`
4468
+ `);
4469
+ }
4470
+ function extractMessageSequence(rows) {
4471
+ const messages = [];
4472
+ for (const row of rows) {
4473
+ const message = extractSingleMessage(row);
4474
+ if (message === null)
4475
+ return null;
4476
+ messages.push(message);
4477
+ }
4478
+ return messages.join(`
4479
+
4480
+ `);
4481
+ }
4482
+ function markdownRows(rows, depth) {
4483
+ if (rows.length === 0)
4484
+ return "(none)";
4485
+ if (!isPlainObjectArray(rows)) {
4486
+ return rows.map((item) => `- ${markdownCell(item)}`).join(`
4487
+ `);
4488
+ }
4489
+ const prose = extractMessageSequence(rows);
4490
+ if (prose !== null)
4491
+ return prose;
4492
+ const table = markdownTable(rows);
4493
+ if (table !== null)
4494
+ return table;
4495
+ if (depth >= MARKDOWN_MAX_DEPTH) {
4496
+ return fencedBlock(JSON.stringify(rows, null, 2));
4497
+ }
4498
+ return rows.map((row, index) => [
4499
+ `${markdownHeading(depth)} ${index + 1}`,
4500
+ markdownObject(row, depth + 1)
4501
+ ].join(`
4502
+
4503
+ `)).join(`
4504
+
4505
+ `);
4506
+ }
4507
+ function markdownObject(obj, depth) {
4508
+ const scalars = [];
4509
+ const blocks = [];
4510
+ for (const [key, value] of Object.entries(obj)) {
4511
+ if (value === undefined)
4512
+ continue;
4513
+ const label = markdownLabel(key);
4514
+ if (Array.isArray(value)) {
4515
+ blocks.push(`${markdownHeading(depth)} ${label}
4516
+
4517
+ ${markdownRows(value, depth + 1)}`);
4518
+ } else if (isNonEmptyPlainObject(value)) {
4519
+ const nested = depth < MARKDOWN_MAX_DEPTH ? markdownObject(value, depth + 1) : fencedBlock(JSON.stringify(value, null, 2));
4520
+ if (nested !== "") {
4521
+ blocks.push(`${markdownHeading(depth)} ${label}
4522
+
4523
+ ${nested}`);
4524
+ }
4525
+ } else if (typeof value === "string" && value.includes(`
4526
+ `)) {
4527
+ blocks.push(`**${label}:**
4528
+
4529
+ ${fencedBlock(value)}`);
4530
+ } else {
4531
+ scalars.push(`**${label}:** ${markdownCell(value)}`);
4532
+ }
4533
+ }
4534
+ const sections = scalars.length > 0 ? [scalars.join(`
4535
+ `)] : [];
4536
+ sections.push(...blocks);
4537
+ return sections.join(`
4538
+
4539
+ `);
4540
+ }
4541
+ function extractSingleMessage(payload) {
4542
+ if (!isPlainRecord(payload))
4543
+ return null;
4544
+ const keys = Object.keys(payload);
4545
+ if (keys.length !== 1 || keys[0].toLowerCase() !== "message")
4546
+ return null;
4547
+ const value = payload[keys[0]];
4548
+ return typeof value === "string" ? value : null;
4549
+ }
4550
+ function markdownPayload(payload) {
4551
+ const message = extractSingleMessage(payload);
4552
+ if (message !== null)
4553
+ return message;
4554
+ if (Array.isArray(payload)) {
4555
+ return markdownRows(rowsWithoutPlumbing(payload), 0);
4556
+ }
4557
+ const visible = withoutPlumbing(payload);
4558
+ const paged = splitPagedEnvelope(visible);
4559
+ if (paged !== null) {
4560
+ const meta = markdownObject(paged.meta, 0);
4561
+ const rows = `${markdownHeading(0)} ${markdownLabel(paged.key)}
4562
+
4563
+ ${markdownRows(rowsWithoutPlumbing(paged.rows), 1)}`;
4564
+ return meta === "" ? rows : `${meta}
4565
+
4566
+ ${rows}`;
4567
+ }
4568
+ return markdownObject(visible, 0);
4569
+ }
4570
+ function isPaginationWorthShowing(value) {
4571
+ if (typeof value !== "object" || value === null)
4572
+ return false;
4573
+ const page = value;
4574
+ return page.HasMore === true || typeof page.Offset === "number" && page.Offset > 0;
4575
+ }
4576
+ function markdownEnvelopeNotes(data) {
4577
+ const envelope = data;
4578
+ const notes = [];
4579
+ const warning = envelope.Warning;
4580
+ if (typeof warning === "string" && warning !== "") {
4581
+ notes.push(`> **Warning:** ${warning}`);
4582
+ }
4583
+ const instructions = envelope.Instructions;
4584
+ if (typeof instructions === "string" && instructions !== "") {
4585
+ notes.push(`> ${instructions}`);
4586
+ }
4587
+ const pagination = envelope.Pagination;
4588
+ if (isPaginationWorthShowing(pagination)) {
4589
+ const body = markdownObject(pagination, 1);
4590
+ if (body !== "") {
4591
+ notes.push(`${markdownHeading(0)} Pagination
4592
+
4593
+ ${body}`);
4594
+ }
4595
+ }
4596
+ const log = envelope.Log;
4597
+ if (typeof log === "string" && log !== "") {
4598
+ notes.push(`**Log:** ${log}`);
4599
+ }
4600
+ return notes;
4601
+ }
4602
+ function renderMarkdown(data) {
4603
+ if (data.Result !== RESULTS.Success) {
4604
+ const failure = data;
4605
+ const sections = [`**Failed:** ${failure.Message}`];
4606
+ if (failure.Data != null) {
4607
+ sections.push(markdownPayload(failure.Data));
4608
+ }
4609
+ if (failure.Instructions) {
4610
+ sections.push(`> ${failure.Instructions}`);
4611
+ }
4612
+ return sections.filter((section) => section !== "").join(`
4613
+
4614
+ `);
4615
+ }
4616
+ if (!("Data" in data) || data.Data == null) {
4617
+ return markdownObject(withoutPlumbing(data), 0);
4618
+ }
4619
+ return [markdownPayload(data.Data), ...markdownEnvelopeNotes(data)].filter((section) => section !== "").join(`
4620
+
4621
+ `);
4622
+ }
4393
4623
  function toYaml(data) {
4394
4624
  const codec = getYamlCodec();
4395
4625
  if (!codec) {
@@ -6134,16 +6364,7 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
6134
6364
  errorMessage: location.source === "absolute" ? `Environment file not found: ${envFilePath}` : `Unable to locate environment file: ${envFilePath}. Run 'uip login' to authenticate.`
6135
6365
  };
6136
6366
  };
6137
- var loadEnvFileAsync = async ({ envPath }) => {
6138
- const fs2 = getFileSystem();
6139
- const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
6140
- if (!await fs2.exists(absolutePath)) {
6141
- throw new Error(`Environment file not found: ${envPath}`);
6142
- }
6143
- const content = await fs2.readFile(absolutePath, "utf-8");
6144
- if (content === null) {
6145
- throw new Error(`Environment file not found: ${envPath}`);
6146
- }
6367
+ var parseEnvContent = (content) => {
6147
6368
  const env = {};
6148
6369
  for (const line of content.split(`
6149
6370
  `)) {
@@ -6164,6 +6385,18 @@ var loadEnvFileAsync = async ({ envPath }) => {
6164
6385
  }
6165
6386
  return env;
6166
6387
  };
6388
+ var loadEnvFileAsync = async ({ envPath }) => {
6389
+ const fs2 = getFileSystem();
6390
+ const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
6391
+ if (!await fs2.exists(absolutePath)) {
6392
+ throw new Error(`Environment file not found: ${envPath}`);
6393
+ }
6394
+ const content = await fs2.readFile(absolutePath, "utf-8");
6395
+ if (content === null) {
6396
+ throw new Error(`Environment file not found: ${envPath}`);
6397
+ }
6398
+ return parseEnvContent(content);
6399
+ };
6167
6400
  var saveEnvFileAsync = async ({
6168
6401
  envPath,
6169
6402
  data,
@@ -7218,4 +7451,4 @@ export {
7218
7451
  registerCommands
7219
7452
  };
7220
7453
 
7221
- //# debugId=6D6A4B73945B146364756E2164756E21
7454
+ //# debugId=FD62F94FD6DB7B5864756E2164756E21
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@uipath/guardrails-tool",
3
+ "author": "UiPath",
3
4
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "1.202.0",
5
+ "version": "1.203.0-preview.160",
5
6
  "description": "CLI plugin for UiPath AI Trust Layer guardrail configurations.",
6
7
  "private": false,
7
8
  "repository": {
@@ -23,5 +24,5 @@
23
24
  "files": [
24
25
  "dist"
25
26
  ],
26
- "gitHead": "23b5a7038ead7264439af18f8b807c7cc99a29d5"
27
+ "gitHead": "3a42062ba731afca4595ba9aa8a80afc9667528d"
27
28
  }