@uipath/oms-commands 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/index.js +284 -34
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -2610,7 +2610,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
2610
2610
  var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
2611
2611
  var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
2612
2612
  var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
2613
- var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
2613
+ var PADDED_BASE64_PATTERN = /(?<![A-Za-z0-9+/])[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
2614
2614
  var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
2615
2615
  var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
2616
2616
  var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
@@ -2657,7 +2657,7 @@ var QUOTED_LITERAL_PATTERN = new RegExp([
2657
2657
  `(?<![A-Za-z0-9])"(?:[^\\
2658
2658
  ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
2659
2659
  ].join("|"), "g");
2660
- var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
2660
+ var JSON_BODY_PATTERN = /[{[][^{}[\]:,]*[:,][^{}[\]]*[\]}]/g;
2661
2661
  var COLLAPSED_BODY = "{…}";
2662
2662
  var COLLAPSED_BODY_MARKER = "\x01body\x01";
2663
2663
  var MAX_BODY_NESTING = 8;
@@ -2672,10 +2672,13 @@ function collapseJsonBodies(text) {
2672
2672
  }
2673
2673
  return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
2674
2674
  }
2675
- var TRAILING_PROSE_PUNCT = /[.,;:!?)\]}>'"]+$/;
2675
+ var TRAILING_PROSE_PUNCT = `.,;:!?)]}>'"`;
2676
2676
  function peelTrailingPunctuation(match) {
2677
- const trailing = match.match(TRAILING_PROSE_PUNCT)?.[0] ?? "";
2678
- return trailing ? [match.slice(0, -trailing.length), trailing] : [match, ""];
2677
+ let end = match.length;
2678
+ while (end > 0 && TRAILING_PROSE_PUNCT.includes(match[end - 1])) {
2679
+ end -= 1;
2680
+ }
2681
+ return [match.slice(0, end), match.slice(end)];
2679
2682
  }
2680
2683
  function redactUrl(raw) {
2681
2684
  try {
@@ -2978,6 +2981,22 @@ function parseHttpStatusFromMessage(message) {
2978
2981
  const status = Number(match[1]);
2979
2982
  return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
2980
2983
  }
2984
+ function findHttpStatusInGraph(error) {
2985
+ for (const node of walkErrorGraph(error)) {
2986
+ const response = node.response;
2987
+ const explicit = typeof node.status === "number" ? node.status : response?.status;
2988
+ if (typeof explicit === "number" && explicit >= 400 && explicit <= 599) {
2989
+ return explicit;
2990
+ }
2991
+ if (typeof node.message === "string") {
2992
+ const parsed = parseHttpStatusFromMessage(node.message);
2993
+ if (parsed !== undefined && parsed >= 400) {
2994
+ return parsed;
2995
+ }
2996
+ }
2997
+ }
2998
+ return;
2999
+ }
2981
3000
  function isHtmlDocument(body) {
2982
3001
  return /^\s*(<!doctype html|<html\b)/i.test(body);
2983
3002
  }
@@ -3091,7 +3110,8 @@ async function extractErrorDetails(error, options) {
3091
3110
  }
3092
3111
  let message;
3093
3112
  let result = "Failure";
3094
- const classification = classifyError(status, error);
3113
+ const classificationStatus = status ?? findHttpStatusInGraph(error);
3114
+ const classification = classifyError(classificationStatus, error);
3095
3115
  let retry = classification.retry;
3096
3116
  if (status === 401) {
3097
3117
  message = DEFAULT_401;
@@ -3167,8 +3187,8 @@ async function extractErrorDetails(error, options) {
3167
3187
  details = describeThrownValue(error);
3168
3188
  }
3169
3189
  const context = {};
3170
- if (status) {
3171
- context.httpStatus = status;
3190
+ if (classificationStatus) {
3191
+ context.httpStatus = classificationStatus;
3172
3192
  }
3173
3193
  if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
3174
3194
  context.errorCode = parsedBody.errorCode;
@@ -3730,7 +3750,8 @@ function readRegistryValue(keyPath, valueName) {
3730
3750
  }
3731
3751
  const [error, output] = catchError(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
3732
3752
  encoding: "utf-8",
3733
- stdio: ["pipe", "pipe", "pipe"]
3753
+ stdio: ["pipe", "pipe", "pipe"],
3754
+ windowsHide: true
3734
3755
  }));
3735
3756
  if (error) {
3736
3757
  return "";
@@ -4412,28 +4433,32 @@ function isPlainRecord(value) {
4412
4433
  const prototype = Object.getPrototypeOf(value);
4413
4434
  return prototype === Object.prototype || prototype === null;
4414
4435
  }
4415
- function extractPagedRows(value) {
4436
+ function splitPagedEnvelope(value) {
4416
4437
  if (Array.isArray(value) || !isPlainRecord(value))
4417
4438
  return null;
4418
- const entries = Object.values(value);
4439
+ const entries = Object.entries(value);
4419
4440
  if (entries.length === 0)
4420
4441
  return null;
4421
- let rows = null;
4422
- let hasScalarSibling = false;
4423
- for (const entry of entries) {
4442
+ let found = null;
4443
+ const meta = Object.create(null);
4444
+ for (const [key, entry] of entries) {
4424
4445
  if (Array.isArray(entry)) {
4425
- if (rows !== null)
4446
+ if (found !== null)
4426
4447
  return null;
4427
- rows = entry;
4448
+ found = { key, rows: entry };
4428
4449
  } else if (entry !== null && typeof entry === "object") {
4429
4450
  return null;
4430
4451
  } else {
4431
- hasScalarSibling = true;
4452
+ meta[key] = entry;
4432
4453
  }
4433
4454
  }
4434
- if (rows === null || !hasScalarSibling)
4455
+ if (found === null || Object.keys(meta).length === 0)
4435
4456
  return null;
4436
- return rows;
4457
+ return { ...found, meta };
4458
+ }
4459
+ function extractPagedRows(value) {
4460
+ const paged = splitPagedEnvelope(value);
4461
+ return paged === null ? null : paged.rows;
4437
4462
  }
4438
4463
  function toLowerCamelCaseKey(key) {
4439
4464
  if (!key)
@@ -4537,6 +4562,9 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
4537
4562
  }
4538
4563
  break;
4539
4564
  }
4565
+ case "markdown":
4566
+ logFn(renderMarkdown(data));
4567
+ break;
4540
4568
  default: {
4541
4569
  const hasData = "Data" in data && data.Data != null;
4542
4570
  const pagedRows = hasData ? extractPagedRows(data.Data) : null;
@@ -4561,6 +4589,10 @@ function logOutput(data, format = "json", tableRowStyle) {
4561
4589
  printOutput(data, format, (msg) => sink.writeOut(`${msg}
4562
4590
  `), needsAsciiSafeJson(sink), styleFn);
4563
4591
  }
4592
+ var PLUMBING_KEYS = new Set(["code", "log"]);
4593
+ function isPlumbingKey(key) {
4594
+ return PLUMBING_KEYS.has(key.toLowerCase());
4595
+ }
4564
4596
  function cellToString(val) {
4565
4597
  return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
4566
4598
  }
@@ -4576,7 +4608,7 @@ function wrapText(text, width) {
4576
4608
  function printTable(data, logFn, externalLogValue, tableRowStyle) {
4577
4609
  if (data.length === 0)
4578
4610
  return;
4579
- const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
4611
+ const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
4580
4612
  const maxWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
4581
4613
  const header = keys.map((key, i) => key.padEnd(maxWidths[i])).join(" | ");
4582
4614
  logFn(header);
@@ -4598,7 +4630,7 @@ function isNonEmptyPlainObject(value) {
4598
4630
  }
4599
4631
  var NESTED_INDENT = " ";
4600
4632
  function printVerticalTable(data, logFn = console.log, externalLogValue) {
4601
- const keys = Object.keys(data).filter((key) => !["code", "log"].includes(key.toLowerCase()));
4633
+ const keys = Object.keys(data).filter((key) => !isPlumbingKey(key));
4602
4634
  if (keys.length === 0)
4603
4635
  return;
4604
4636
  const isBlockValue = (value) => isPlainObjectArray(value) || isNonEmptyPlainObject(value);
@@ -4629,7 +4661,7 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
4629
4661
  function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
4630
4662
  if (data.length === 0)
4631
4663
  return;
4632
- const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
4664
+ const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
4633
4665
  if (keys.length === 0)
4634
4666
  return;
4635
4667
  if (!process.stdout.isTTY) {
@@ -4703,6 +4735,220 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
4703
4735
  logFn(`Log: ${externalLogValue}`);
4704
4736
  }
4705
4737
  }
4738
+ var MARKDOWN_MAX_CELL = 200;
4739
+ var MARKDOWN_MAX_DEPTH = 3;
4740
+ function markdownHeading(depth) {
4741
+ return "#".repeat(Math.min(3 + depth, 6));
4742
+ }
4743
+ var BACKTICK_RUN = /`+/g;
4744
+ function fencedBlock(text) {
4745
+ const first = text.trimStart()[0];
4746
+ const language = first === "<" ? "xml" : first === "{" || first === "[" ? "json" : "";
4747
+ const longestRun = Math.max(0, ...Array.from(text.matchAll(BACKTICK_RUN), (match) => match[0].length));
4748
+ const fence = "`".repeat(Math.max(3, longestRun + 1));
4749
+ return `${fence}${language}
4750
+ ${text}
4751
+ ${fence}`;
4752
+ }
4753
+ function collapseNewlineRuns(text) {
4754
+ return text.split(/(\s+)/).map((part, index) => index % 2 === 1 && part.includes(`
4755
+ `) ? " " : part).join("");
4756
+ }
4757
+ function markdownCell(value) {
4758
+ const text = value instanceof Date ? value.toISOString() : cellToString(value);
4759
+ return collapseNewlineRuns(text).replace(/\|/g, "\\|");
4760
+ }
4761
+ function markdownLabel(key) {
4762
+ return collapseNewlineRuns(key).replace(/[\\`*|]/g, "\\$&");
4763
+ }
4764
+ function withoutPlumbing(record) {
4765
+ const kept = Object.create(null);
4766
+ for (const [key, value] of Object.entries(record)) {
4767
+ if (!isPlumbingKey(key))
4768
+ kept[key] = value;
4769
+ }
4770
+ return kept;
4771
+ }
4772
+ function rowsWithoutPlumbing(rows) {
4773
+ return rows.map((row) => isPlainRecord(row) ? withoutPlumbing(row) : row);
4774
+ }
4775
+ function markdownTable(rows) {
4776
+ const columns = [];
4777
+ const seen = new Set;
4778
+ for (const row of rows) {
4779
+ for (const key of Object.keys(row)) {
4780
+ if (!seen.has(key)) {
4781
+ seen.add(key);
4782
+ columns.push(key);
4783
+ }
4784
+ }
4785
+ }
4786
+ if (columns.length === 0)
4787
+ return null;
4788
+ const cells = rows.map((row) => columns.map((key) => markdownCell(row[key])));
4789
+ if (cells.some((row) => row.some((c) => c.length > MARKDOWN_MAX_CELL))) {
4790
+ return null;
4791
+ }
4792
+ return [
4793
+ `| ${columns.map(markdownLabel).join(" | ")} |`,
4794
+ `| ${columns.map(() => "---").join(" | ")} |`,
4795
+ ...cells.map((row) => `| ${row.join(" | ")} |`)
4796
+ ].join(`
4797
+ `);
4798
+ }
4799
+ function extractMessageSequence(rows) {
4800
+ const messages = [];
4801
+ for (const row of rows) {
4802
+ const message = extractSingleMessage(row);
4803
+ if (message === null)
4804
+ return null;
4805
+ messages.push(message);
4806
+ }
4807
+ return messages.join(`
4808
+
4809
+ `);
4810
+ }
4811
+ function markdownRows(rows, depth) {
4812
+ if (rows.length === 0)
4813
+ return "(none)";
4814
+ if (!isPlainObjectArray(rows)) {
4815
+ return rows.map((item) => `- ${markdownCell(item)}`).join(`
4816
+ `);
4817
+ }
4818
+ const prose = extractMessageSequence(rows);
4819
+ if (prose !== null)
4820
+ return prose;
4821
+ const table = markdownTable(rows);
4822
+ if (table !== null)
4823
+ return table;
4824
+ if (depth >= MARKDOWN_MAX_DEPTH) {
4825
+ return fencedBlock(JSON.stringify(rows, null, 2));
4826
+ }
4827
+ return rows.map((row, index) => [
4828
+ `${markdownHeading(depth)} ${index + 1}`,
4829
+ markdownObject(row, depth + 1)
4830
+ ].join(`
4831
+
4832
+ `)).join(`
4833
+
4834
+ `);
4835
+ }
4836
+ function markdownObject(obj, depth) {
4837
+ const scalars = [];
4838
+ const blocks = [];
4839
+ for (const [key, value] of Object.entries(obj)) {
4840
+ if (value === undefined)
4841
+ continue;
4842
+ const label = markdownLabel(key);
4843
+ if (Array.isArray(value)) {
4844
+ blocks.push(`${markdownHeading(depth)} ${label}
4845
+
4846
+ ${markdownRows(value, depth + 1)}`);
4847
+ } else if (isNonEmptyPlainObject(value)) {
4848
+ const nested = depth < MARKDOWN_MAX_DEPTH ? markdownObject(value, depth + 1) : fencedBlock(JSON.stringify(value, null, 2));
4849
+ if (nested !== "") {
4850
+ blocks.push(`${markdownHeading(depth)} ${label}
4851
+
4852
+ ${nested}`);
4853
+ }
4854
+ } else if (typeof value === "string" && value.includes(`
4855
+ `)) {
4856
+ blocks.push(`**${label}:**
4857
+
4858
+ ${fencedBlock(value)}`);
4859
+ } else {
4860
+ scalars.push(`**${label}:** ${markdownCell(value)}`);
4861
+ }
4862
+ }
4863
+ const sections = scalars.length > 0 ? [scalars.join(`
4864
+ `)] : [];
4865
+ sections.push(...blocks);
4866
+ return sections.join(`
4867
+
4868
+ `);
4869
+ }
4870
+ function extractSingleMessage(payload) {
4871
+ if (!isPlainRecord(payload))
4872
+ return null;
4873
+ const keys = Object.keys(payload);
4874
+ if (keys.length !== 1 || keys[0].toLowerCase() !== "message")
4875
+ return null;
4876
+ const value = payload[keys[0]];
4877
+ return typeof value === "string" ? value : null;
4878
+ }
4879
+ function markdownPayload(payload) {
4880
+ const message = extractSingleMessage(payload);
4881
+ if (message !== null)
4882
+ return message;
4883
+ if (Array.isArray(payload)) {
4884
+ return markdownRows(rowsWithoutPlumbing(payload), 0);
4885
+ }
4886
+ const visible = withoutPlumbing(payload);
4887
+ const paged = splitPagedEnvelope(visible);
4888
+ if (paged !== null) {
4889
+ const meta = markdownObject(paged.meta, 0);
4890
+ const rows = `${markdownHeading(0)} ${markdownLabel(paged.key)}
4891
+
4892
+ ${markdownRows(rowsWithoutPlumbing(paged.rows), 1)}`;
4893
+ return meta === "" ? rows : `${meta}
4894
+
4895
+ ${rows}`;
4896
+ }
4897
+ return markdownObject(visible, 0);
4898
+ }
4899
+ function isPaginationWorthShowing(value) {
4900
+ if (typeof value !== "object" || value === null)
4901
+ return false;
4902
+ const page = value;
4903
+ return page.HasMore === true || typeof page.Offset === "number" && page.Offset > 0;
4904
+ }
4905
+ function markdownEnvelopeNotes(data) {
4906
+ const envelope = data;
4907
+ const notes = [];
4908
+ const warning = envelope.Warning;
4909
+ if (typeof warning === "string" && warning !== "") {
4910
+ notes.push(`> **Warning:** ${warning}`);
4911
+ }
4912
+ const instructions = envelope.Instructions;
4913
+ if (typeof instructions === "string" && instructions !== "") {
4914
+ notes.push(`> ${instructions}`);
4915
+ }
4916
+ const pagination = envelope.Pagination;
4917
+ if (isPaginationWorthShowing(pagination)) {
4918
+ const body = markdownObject(pagination, 1);
4919
+ if (body !== "") {
4920
+ notes.push(`${markdownHeading(0)} Pagination
4921
+
4922
+ ${body}`);
4923
+ }
4924
+ }
4925
+ const log = envelope.Log;
4926
+ if (typeof log === "string" && log !== "") {
4927
+ notes.push(`**Log:** ${log}`);
4928
+ }
4929
+ return notes;
4930
+ }
4931
+ function renderMarkdown(data) {
4932
+ if (data.Result !== RESULTS.Success) {
4933
+ const failure = data;
4934
+ const sections = [`**Failed:** ${failure.Message}`];
4935
+ if (failure.Data != null) {
4936
+ sections.push(markdownPayload(failure.Data));
4937
+ }
4938
+ if (failure.Instructions) {
4939
+ sections.push(`> ${failure.Instructions}`);
4940
+ }
4941
+ return sections.filter((section) => section !== "").join(`
4942
+
4943
+ `);
4944
+ }
4945
+ if (!("Data" in data) || data.Data == null) {
4946
+ return markdownObject(withoutPlumbing(data), 0);
4947
+ }
4948
+ return [markdownPayload(data.Data), ...markdownEnvelopeNotes(data)].filter((section) => section !== "").join(`
4949
+
4950
+ `);
4951
+ }
4706
4952
  function toYaml(data) {
4707
4953
  const codec = getYamlCodec();
4708
4954
  if (!codec) {
@@ -6534,8 +6780,9 @@ function querystringSingleKey3(key, value, keyPrefix = "") {
6534
6780
  // ../oms-sdk/package.json
6535
6781
  var package_default = {
6536
6782
  name: "@uipath/oms-sdk",
6783
+ author: "UiPath",
6537
6784
  license: "SEE LICENSE IN LICENSE.txt",
6538
- version: "1.202.0",
6785
+ version: "1.203.0",
6539
6786
  description: "SDK for the UiPath Organization Management Service API.",
6540
6787
  repository: {
6541
6788
  type: "git",
@@ -11728,16 +11975,7 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
11728
11975
  errorMessage: location.source === "absolute" ? `Environment file not found: ${envFilePath}` : `Unable to locate environment file: ${envFilePath}. Run 'uip login' to authenticate.`
11729
11976
  };
11730
11977
  };
11731
- var loadEnvFileAsync = async ({ envPath }) => {
11732
- const fs2 = getFileSystem();
11733
- const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
11734
- if (!await fs2.exists(absolutePath)) {
11735
- throw new Error(`Environment file not found: ${envPath}`);
11736
- }
11737
- const content = await fs2.readFile(absolutePath, "utf-8");
11738
- if (content === null) {
11739
- throw new Error(`Environment file not found: ${envPath}`);
11740
- }
11978
+ var parseEnvContent = (content) => {
11741
11979
  const env = {};
11742
11980
  for (const line of content.split(`
11743
11981
  `)) {
@@ -11758,6 +11996,18 @@ var loadEnvFileAsync = async ({ envPath }) => {
11758
11996
  }
11759
11997
  return env;
11760
11998
  };
11999
+ var loadEnvFileAsync = async ({ envPath }) => {
12000
+ const fs2 = getFileSystem();
12001
+ const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
12002
+ if (!await fs2.exists(absolutePath)) {
12003
+ throw new Error(`Environment file not found: ${envPath}`);
12004
+ }
12005
+ const content = await fs2.readFile(absolutePath, "utf-8");
12006
+ if (content === null) {
12007
+ throw new Error(`Environment file not found: ${envPath}`);
12008
+ }
12009
+ return parseEnvContent(content);
12010
+ };
11761
12011
  var saveEnvFileAsync = async ({
11762
12012
  envPath,
11763
12013
  data,
@@ -13516,4 +13766,4 @@ export {
13516
13766
  registerCommands
13517
13767
  };
13518
13768
 
13519
- //# debugId=5BD46A91F990B55764756E2164756E21
13769
+ //# debugId=A876B4B73A00529C64756E2164756E21
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@uipath/oms-commands",
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": "Admin CLI commands for the UiPath Organization Management Service. Library composed by admin-tool, not a standalone CLI tool.",
6
7
  "private": false,
7
8
  "repository": {
@@ -25,5 +26,5 @@
25
26
  "files": [
26
27
  "dist"
27
28
  ],
28
- "gitHead": "23b5a7038ead7264439af18f8b807c7cc99a29d5"
29
+ "gitHead": "3a42062ba731afca4595ba9aa8a80afc9667528d"
29
30
  }