@uipath/aops-tool 1.202.1-preview.220 → 1.202.1-preview.238

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 CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Command,
4
4
  metadata,
5
5
  registerCommands
6
- } from "./tool-4mb3ywhc.js";
6
+ } from "./tool-9z3bpbg8.js";
7
7
  import"./tool-1de529jm.js";
8
8
 
9
9
  // src/index.ts
@@ -2100,7 +2100,7 @@ var require_commander = __commonJS(function(exports) {
2100
2100
  var package_default = {
2101
2101
  name: "@uipath/aops-tool",
2102
2102
  license: "SEE LICENSE IN LICENSE.txt",
2103
- version: "1.202.1-preview.220",
2103
+ version: "1.202.1-preview.238",
2104
2104
  description: "Manage UiPath StudioAdmin AOps — connections, repos, projects, solutions, pipelines, executions.",
2105
2105
  private: false,
2106
2106
  repository: {
@@ -4792,7 +4792,165 @@ class FilterImplicitLimitError extends Error {
4792
4792
  this.instructions = "Pass --limit <n> to choose how many records the filter applies to. " + "To filter over all records, pass the command's maximum accepted --limit (see the option's description in --help).";
4793
4793
  }
4794
4794
  }
4795
- function applyFilter(data, filter) {
4795
+ function countRecords(data) {
4796
+ if (Array.isArray(data))
4797
+ return data.length;
4798
+ return data == null ? 0 : 1;
4799
+ }
4800
+ function availableFields(data) {
4801
+ const records = Array.isArray(data) ? data : [data];
4802
+ const keys = new Set;
4803
+ for (const record of records) {
4804
+ if (record && typeof record === "object" && !Array.isArray(record)) {
4805
+ for (const key of Object.keys(record))
4806
+ keys.add(key);
4807
+ }
4808
+ }
4809
+ return [...keys];
4810
+ }
4811
+ function decodeQuotedIdentifier(whole, inner) {
4812
+ const [error, decoded] = catchError(() => JSON.parse(whole));
4813
+ if (!error && typeof decoded === "string")
4814
+ return decoded;
4815
+ return inner.replace(/\\(.)/g, "$1");
4816
+ }
4817
+ function referencedFields(filter) {
4818
+ const top = new Set;
4819
+ const nested = new Set;
4820
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
4821
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
4822
+ const quoted = [];
4823
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
4824
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
4825
+ if (!isAlias) {
4826
+ quoted.push({
4827
+ name: decodeQuotedIdentifier(whole, name),
4828
+ index,
4829
+ tail: isPathTail(withoutValueLiterals, index)
4830
+ });
4831
+ }
4832
+ return `"${" ".repeat(whole.length - 2)}"`;
4833
+ });
4834
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
4835
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
4836
+ const place = (name, index, tail) => {
4837
+ if (tail || index >= rootEnd)
4838
+ nested.add(name);
4839
+ else
4840
+ top.add(name);
4841
+ };
4842
+ for (const entry of quoted)
4843
+ place(entry.name, entry.index, entry.tail);
4844
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
4845
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
4846
+ for (const match of identifiers) {
4847
+ const [, name, trailing] = match;
4848
+ if (trailing || reserved.has(name))
4849
+ continue;
4850
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
4851
+ }
4852
+ return {
4853
+ top: [...top],
4854
+ nested: [...nested].filter((name) => !top.has(name)),
4855
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
4856
+ };
4857
+ }
4858
+ function appearsBelowTopLevel(data, name) {
4859
+ let budget = 2000;
4860
+ const visit = (value, depth) => {
4861
+ if (budget-- <= 0 || depth > 4)
4862
+ return false;
4863
+ if (value === null || typeof value !== "object")
4864
+ return false;
4865
+ if (Array.isArray(value))
4866
+ return value.some((entry) => visit(entry, depth));
4867
+ const record = value;
4868
+ if (depth > 0 && Object.hasOwn(record, name))
4869
+ return true;
4870
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
4871
+ };
4872
+ return visit(data, 0);
4873
+ }
4874
+ function alwaysNullKeys(records) {
4875
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
4876
+ if (objects.length === 0 || objects.length !== records.length)
4877
+ return [];
4878
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
4879
+ if (keys.length === 0)
4880
+ return [];
4881
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
4882
+ return nullKeys.length === keys.length ? nullKeys : [];
4883
+ }
4884
+ function carriesOnlyNulls(value) {
4885
+ if (value === null)
4886
+ return true;
4887
+ if (Array.isArray(value)) {
4888
+ return value.length > 0 && value.every(carriesOnlyNulls);
4889
+ }
4890
+ if (typeof value === "object" && value !== undefined) {
4891
+ const values = Object.values(value);
4892
+ return values.length > 0 && values.every(carriesOnlyNulls);
4893
+ }
4894
+ return false;
4895
+ }
4896
+ function nameList(names, cap2 = 12) {
4897
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
4898
+ const rest = names.length - shown.length;
4899
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
4900
+ }
4901
+ function buildFilterWarning(filter, data, outcome) {
4902
+ const present = availableFields(data);
4903
+ const refs = referencedFields(filter);
4904
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
4905
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
4906
+ const count = countRecords(data);
4907
+ const scope = `${count} record(s)`;
4908
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
4909
+ const soundness = unchecked.length > 0 ? `${nameList(unchecked)} ${unchecked.length === 1 ? "reads" : "read"} below the top level, so ${unchecked.length === 1 ? "it was" : "they were"} not checked against the record keys` : refs.top.length > 0 ? "every field it names exists" : "";
4910
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
4911
+ let detail;
4912
+ let lede;
4913
+ if (outcome.kind === "null-elements") {
4914
+ lede = "returned only null values";
4915
+ const projected = `all ${outcome.count} of the elements it projected are null`;
4916
+ if (unknown.length > 0) {
4917
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4918
+ } else if (unchecked.length > 0) {
4919
+ detail = withSoundness(projected);
4920
+ } else {
4921
+ detail = `${projected}, and every field it names exists — a multi-select list ` + `(\`[A, B]\`) reads each entry against \`Data\` itself, so on a list ` + `result use \`[].[A, B]\` or \`[].{a: A, b: B}\` to read the records`;
4922
+ }
4923
+ } else if (outcome.kind === "null-rows") {
4924
+ lede = "returned only null values";
4925
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
4926
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
4927
+ } else if (outcome.kind === "null-values") {
4928
+ lede = "returned only null values";
4929
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
4930
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
4931
+ if (sameSet) {
4932
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
4933
+ } else if (unknown.length > 0) {
4934
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4935
+ } else {
4936
+ detail = withSoundness(`${projected} on all ${scope}`);
4937
+ }
4938
+ } else {
4939
+ lede = "returned nothing";
4940
+ if (unknown.length > 0) {
4941
+ detail = isNotAField(unknown);
4942
+ } else {
4943
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
4944
+ detail = withSoundness(`${selection} — it read ${scope}`);
4945
+ }
4946
+ }
4947
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
4948
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
4949
+ }
4950
+ function appendWarning(existing, note) {
4951
+ return existing ? `${existing} ${note}` : note;
4952
+ }
4953
+ function applyFilter(data, filter, onWarning) {
4796
4954
  const codec = requireJmespath();
4797
4955
  let result;
4798
4956
  try {
@@ -4800,9 +4958,34 @@ function applyFilter(data, filter) {
4800
4958
  } catch (err) {
4801
4959
  throw new FilterEvaluationError(filter, err);
4802
4960
  }
4803
- if (result == null)
4961
+ const inputCount = countRecords(data);
4962
+ const warn = (outcome) => {
4963
+ if (inputCount === 0)
4964
+ return;
4965
+ const note = buildFilterWarning(filter, data, outcome);
4966
+ getOutputSink().writeErr(`[WARN] ${note}
4967
+ `);
4968
+ onWarning?.(note);
4969
+ };
4970
+ const warnIfAllNull = (records) => {
4971
+ const keys = alwaysNullKeys(records);
4972
+ if (keys.length > 0)
4973
+ warn({ kind: "null-values", keys });
4974
+ };
4975
+ if (result == null) {
4976
+ warn({ kind: "empty" });
4804
4977
  return [];
4978
+ }
4805
4979
  if (Array.isArray(result)) {
4980
+ if (result.length === 0) {
4981
+ warn({ kind: "empty" });
4982
+ } else if (result.every((entry) => entry === null)) {
4983
+ warn({ kind: "null-elements", count: result.length });
4984
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
4985
+ warn({ kind: "null-rows", count: result.length });
4986
+ } else {
4987
+ warnIfAllNull(result);
4988
+ }
4806
4989
  if (result.length > 0 && typeof result[0] !== "object") {
4807
4990
  const fieldMatch = filter.match(/\.(\w+)$/);
4808
4991
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -4810,10 +4993,30 @@ function applyFilter(data, filter) {
4810
4993
  }
4811
4994
  return result;
4812
4995
  }
4813
- if (typeof result === "object")
4996
+ if (typeof result === "object") {
4997
+ warnIfAllNull([result]);
4814
4998
  return result;
4999
+ }
4815
5000
  return { Value: result };
4816
5001
  }
5002
+ function filterFailureData(envelope) {
5003
+ const filter = getOutputFilter();
5004
+ const data = envelope.Data;
5005
+ if (!filter || data == null)
5006
+ return;
5007
+ let note;
5008
+ const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
5009
+ note = n;
5010
+ }));
5011
+ if (filterError) {
5012
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
5013
+ return;
5014
+ }
5015
+ envelope.Data = filtered;
5016
+ if (note) {
5017
+ envelope.Warning = appendWarning(envelope.Warning, note);
5018
+ }
5019
+ }
4817
5020
  function defaultErrorCodeForResult(result) {
4818
5021
  switch (result) {
4819
5022
  case RESULTS.AuthenticationError:
@@ -4896,8 +5099,14 @@ var OutputFormatter;
4896
5099
  }
4897
5100
  const filter = getOutputFilter();
4898
5101
  if (filter) {
4899
- const filtered = applyFilter(data.Data, filter);
5102
+ let note;
5103
+ const filtered = applyFilter(data.Data, filter, (n) => {
5104
+ note = n;
5105
+ });
4900
5106
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
5107
+ if (note) {
5108
+ data.Warning = appendWarning(data.Warning, note);
5109
+ }
4901
5110
  }
4902
5111
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
4903
5112
  }
@@ -4925,6 +5134,7 @@ var OutputFormatter;
4925
5134
  delete envelope.TelemetryErrorClass;
4926
5135
  delete envelope.TelemetryTerminalOutcome;
4927
5136
  delete envelope.TelemetryTerminalSignal;
5137
+ filterFailureData(envelope);
4928
5138
  if (!suppressTelemetry) {
4929
5139
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
4930
5140
  result: data.Result,
@@ -4973,13 +5183,20 @@ var OutputFormatter;
4973
5183
  OutputFormatter.log = log;
4974
5184
  function formatToString(data) {
4975
5185
  const filter = getOutputFilter();
5186
+ const envelope = data;
4976
5187
  if ("Data" in data && data.Data != null) {
4977
5188
  data.Data = normalizeDataKeys(data.Data);
4978
5189
  if (filter) {
4979
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
5190
+ let note;
5191
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
5192
+ note = n;
5193
+ }));
5194
+ if (note) {
5195
+ envelope.Warning = appendWarning(envelope.Warning, note);
5196
+ }
4980
5197
  }
4981
5198
  }
4982
- const output = normalizeOutputKeys(data);
5199
+ const output = normalizeOutputKeys(envelope);
4983
5200
  const lines = [];
4984
5201
  const sink = getOutputSink();
4985
5202
  printOutput(output, getOutputFormat(), (msg) => {
@@ -13162,4 +13379,4 @@ var registerCommands = async (program2) => {
13162
13379
 
13163
13380
  export { Command, metadata, registerCommands };
13164
13381
 
13165
- //# debugId=4D06412FAA8580DA64756E2164756E21
13382
+ //# debugId=302178D55D8134C464756E2164756E21
package/dist/tool.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-4mb3ywhc.js";
4
+ } from "./tool-9z3bpbg8.js";
5
5
  import"./tool-1de529jm.js";
6
6
  export {
7
7
  metadata,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/aops-tool",
3
3
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "1.202.1-preview.220",
4
+ "version": "1.202.1-preview.238",
5
5
  "description": "Manage UiPath StudioAdmin AOps — connections, repos, projects, solutions, pipelines, executions.",
6
6
  "private": false,
7
7
  "repository": {
@@ -26,5 +26,5 @@
26
26
  "files": [
27
27
  "dist"
28
28
  ],
29
- "gitHead": "a09041733b628c3f6b658a1f58349ea0f40bb492"
29
+ "gitHead": "537e43df1d3583633cfd3a0b88634f9ce3ba9d6b"
30
30
  }