@uipath/insights-tool 1.203.0-preview.235 → 1.203.0-preview.240

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-n9d2j1pa.js";
6
+ } from "./tool-2ss0yckg.js";
7
7
  import"./tool-1de529jm.js";
8
8
 
9
9
  // src/index.ts
@@ -2101,7 +2101,7 @@ var package_default = {
2101
2101
  name: "@uipath/insights-tool",
2102
2102
  author: "UiPath",
2103
2103
  license: "SEE LICENSE IN LICENSE.txt",
2104
- version: "1.203.0-preview.235",
2104
+ version: "1.203.0-preview.240",
2105
2105
  description: "Query UiPath Insights data — jobs, failures, and performance metrics.",
2106
2106
  private: false,
2107
2107
  repository: {
@@ -4741,7 +4741,165 @@ class FilterImplicitLimitError extends Error {
4741
4741
  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).";
4742
4742
  }
4743
4743
  }
4744
- function applyFilter(data, filter) {
4744
+ function countRecords(data) {
4745
+ if (Array.isArray(data))
4746
+ return data.length;
4747
+ return data == null ? 0 : 1;
4748
+ }
4749
+ function availableFields(data) {
4750
+ const records = Array.isArray(data) ? data : [data];
4751
+ const keys = new Set;
4752
+ for (const record of records) {
4753
+ if (record && typeof record === "object" && !Array.isArray(record)) {
4754
+ for (const key of Object.keys(record))
4755
+ keys.add(key);
4756
+ }
4757
+ }
4758
+ return [...keys];
4759
+ }
4760
+ function decodeQuotedIdentifier(whole, inner) {
4761
+ const [error, decoded] = catchError(() => JSON.parse(whole));
4762
+ if (!error && typeof decoded === "string")
4763
+ return decoded;
4764
+ return inner.replace(/\\(.)/g, "$1");
4765
+ }
4766
+ function referencedFields(filter) {
4767
+ const top = new Set;
4768
+ const nested = new Set;
4769
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
4770
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
4771
+ const quoted = [];
4772
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
4773
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
4774
+ if (!isAlias) {
4775
+ quoted.push({
4776
+ name: decodeQuotedIdentifier(whole, name),
4777
+ index,
4778
+ tail: isPathTail(withoutValueLiterals, index)
4779
+ });
4780
+ }
4781
+ return `"${" ".repeat(whole.length - 2)}"`;
4782
+ });
4783
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
4784
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
4785
+ const place = (name, index, tail) => {
4786
+ if (tail || index >= rootEnd)
4787
+ nested.add(name);
4788
+ else
4789
+ top.add(name);
4790
+ };
4791
+ for (const entry of quoted)
4792
+ place(entry.name, entry.index, entry.tail);
4793
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
4794
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
4795
+ for (const match of identifiers) {
4796
+ const [, name, trailing] = match;
4797
+ if (trailing || reserved.has(name))
4798
+ continue;
4799
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
4800
+ }
4801
+ return {
4802
+ top: [...top],
4803
+ nested: [...nested].filter((name) => !top.has(name)),
4804
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
4805
+ };
4806
+ }
4807
+ function appearsBelowTopLevel(data, name) {
4808
+ let budget = 2000;
4809
+ const visit = (value, depth) => {
4810
+ if (budget-- <= 0 || depth > 4)
4811
+ return false;
4812
+ if (value === null || typeof value !== "object")
4813
+ return false;
4814
+ if (Array.isArray(value))
4815
+ return value.some((entry) => visit(entry, depth));
4816
+ const record = value;
4817
+ if (depth > 0 && Object.hasOwn(record, name))
4818
+ return true;
4819
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
4820
+ };
4821
+ return visit(data, 0);
4822
+ }
4823
+ function alwaysNullKeys(records) {
4824
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
4825
+ if (objects.length === 0 || objects.length !== records.length)
4826
+ return [];
4827
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
4828
+ if (keys.length === 0)
4829
+ return [];
4830
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
4831
+ return nullKeys.length === keys.length ? nullKeys : [];
4832
+ }
4833
+ function carriesOnlyNulls(value) {
4834
+ if (value === null)
4835
+ return true;
4836
+ if (Array.isArray(value)) {
4837
+ return value.length > 0 && value.every(carriesOnlyNulls);
4838
+ }
4839
+ if (typeof value === "object" && value !== undefined) {
4840
+ const values = Object.values(value);
4841
+ return values.length > 0 && values.every(carriesOnlyNulls);
4842
+ }
4843
+ return false;
4844
+ }
4845
+ function nameList(names, cap2 = 12) {
4846
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
4847
+ const rest = names.length - shown.length;
4848
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
4849
+ }
4850
+ function buildFilterWarning(filter, data, outcome) {
4851
+ const present = availableFields(data);
4852
+ const refs = referencedFields(filter);
4853
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
4854
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
4855
+ const count = countRecords(data);
4856
+ const scope = `${count} record(s)`;
4857
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
4858
+ 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" : "";
4859
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
4860
+ let detail;
4861
+ let lede;
4862
+ if (outcome.kind === "null-elements") {
4863
+ lede = "returned only null values";
4864
+ const projected = `all ${outcome.count} of the elements it projected are null`;
4865
+ if (unknown.length > 0) {
4866
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4867
+ } else if (unchecked.length > 0) {
4868
+ detail = withSoundness(projected);
4869
+ } else {
4870
+ 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`;
4871
+ }
4872
+ } else if (outcome.kind === "null-rows") {
4873
+ lede = "returned only null values";
4874
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
4875
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
4876
+ } else if (outcome.kind === "null-values") {
4877
+ lede = "returned only null values";
4878
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
4879
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
4880
+ if (sameSet) {
4881
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
4882
+ } else if (unknown.length > 0) {
4883
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4884
+ } else {
4885
+ detail = withSoundness(`${projected} on all ${scope}`);
4886
+ }
4887
+ } else {
4888
+ lede = "returned nothing";
4889
+ if (unknown.length > 0) {
4890
+ detail = isNotAField(unknown);
4891
+ } else {
4892
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
4893
+ detail = withSoundness(`${selection} — it read ${scope}`);
4894
+ }
4895
+ }
4896
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
4897
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
4898
+ }
4899
+ function appendWarning(existing, note) {
4900
+ return existing ? `${existing} ${note}` : note;
4901
+ }
4902
+ function applyFilter(data, filter, onWarning) {
4745
4903
  const codec = requireJmespath();
4746
4904
  let result;
4747
4905
  try {
@@ -4749,9 +4907,34 @@ function applyFilter(data, filter) {
4749
4907
  } catch (err) {
4750
4908
  throw new FilterEvaluationError(filter, err);
4751
4909
  }
4752
- if (result == null)
4910
+ const inputCount = countRecords(data);
4911
+ const warn = (outcome) => {
4912
+ if (inputCount === 0)
4913
+ return;
4914
+ const note = buildFilterWarning(filter, data, outcome);
4915
+ getOutputSink().writeErr(`[WARN] ${note}
4916
+ `);
4917
+ onWarning?.(note);
4918
+ };
4919
+ const warnIfAllNull = (records) => {
4920
+ const keys = alwaysNullKeys(records);
4921
+ if (keys.length > 0)
4922
+ warn({ kind: "null-values", keys });
4923
+ };
4924
+ if (result == null) {
4925
+ warn({ kind: "empty" });
4753
4926
  return [];
4927
+ }
4754
4928
  if (Array.isArray(result)) {
4929
+ if (result.length === 0) {
4930
+ warn({ kind: "empty" });
4931
+ } else if (result.every((entry) => entry === null)) {
4932
+ warn({ kind: "null-elements", count: result.length });
4933
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
4934
+ warn({ kind: "null-rows", count: result.length });
4935
+ } else {
4936
+ warnIfAllNull(result);
4937
+ }
4755
4938
  if (result.length > 0 && typeof result[0] !== "object") {
4756
4939
  const fieldMatch = filter.match(/\.(\w+)$/);
4757
4940
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -4759,10 +4942,30 @@ function applyFilter(data, filter) {
4759
4942
  }
4760
4943
  return result;
4761
4944
  }
4762
- if (typeof result === "object")
4945
+ if (typeof result === "object") {
4946
+ warnIfAllNull([result]);
4763
4947
  return result;
4948
+ }
4764
4949
  return { Value: result };
4765
4950
  }
4951
+ function filterFailureData(envelope) {
4952
+ const filter = getOutputFilter();
4953
+ const data = envelope.Data;
4954
+ if (!filter || data == null)
4955
+ return;
4956
+ let note;
4957
+ const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
4958
+ note = n;
4959
+ }));
4960
+ if (filterError) {
4961
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
4962
+ return;
4963
+ }
4964
+ envelope.Data = filtered;
4965
+ if (note) {
4966
+ envelope.Warning = appendWarning(envelope.Warning, note);
4967
+ }
4968
+ }
4766
4969
  function defaultErrorCodeForResult(result) {
4767
4970
  switch (result) {
4768
4971
  case RESULTS.AuthenticationError:
@@ -4845,8 +5048,14 @@ var OutputFormatter;
4845
5048
  }
4846
5049
  const filter = getOutputFilter();
4847
5050
  if (filter) {
4848
- const filtered = applyFilter(data.Data, filter);
5051
+ let note;
5052
+ const filtered = applyFilter(data.Data, filter, (n) => {
5053
+ note = n;
5054
+ });
4849
5055
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
5056
+ if (note) {
5057
+ data.Warning = appendWarning(data.Warning, note);
5058
+ }
4850
5059
  }
4851
5060
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
4852
5061
  }
@@ -4874,6 +5083,7 @@ var OutputFormatter;
4874
5083
  delete envelope.TelemetryErrorClass;
4875
5084
  delete envelope.TelemetryTerminalOutcome;
4876
5085
  delete envelope.TelemetryTerminalSignal;
5086
+ filterFailureData(envelope);
4877
5087
  if (!suppressTelemetry) {
4878
5088
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
4879
5089
  result: data.Result,
@@ -4922,13 +5132,20 @@ var OutputFormatter;
4922
5132
  OutputFormatter.log = log;
4923
5133
  function formatToString(data) {
4924
5134
  const filter = getOutputFilter();
5135
+ const envelope = data;
4925
5136
  if ("Data" in data && data.Data != null) {
4926
5137
  data.Data = normalizeDataKeys(data.Data);
4927
5138
  if (filter) {
4928
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
5139
+ let note;
5140
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
5141
+ note = n;
5142
+ }));
5143
+ if (note) {
5144
+ envelope.Warning = appendWarning(envelope.Warning, note);
5145
+ }
4929
5146
  }
4930
5147
  }
4931
- const output = normalizeOutputKeys(data);
5148
+ const output = normalizeOutputKeys(envelope);
4932
5149
  const lines = [];
4933
5150
  const sink = getOutputSink();
4934
5151
  printOutput(output, getOutputFormat(), (msg) => {
@@ -5749,7 +5966,7 @@ var package_default2 = {
5749
5966
  name: "@uipath/insights-sdk",
5750
5967
  author: "UiPath",
5751
5968
  license: "SEE LICENSE IN LICENSE.txt",
5752
- version: "1.203.0-preview.235",
5969
+ version: "1.203.0-preview.240",
5753
5970
  description: "SDK for the UiPath Insights API — jobs, failures, and performance metrics.",
5754
5971
  repository: {
5755
5972
  type: "git",
@@ -8934,4 +9151,4 @@ var registerCommands = async (program2) => {
8934
9151
 
8935
9152
  export { Command, metadata, registerCommands };
8936
9153
 
8937
- //# debugId=89135E9F760A7F0664756E2164756E21
9154
+ //# debugId=C76AF07E0F33169B64756E2164756E21
package/dist/tool.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-n9d2j1pa.js";
4
+ } from "./tool-2ss0yckg.js";
5
5
  import"./tool-1de529jm.js";
6
6
  export {
7
7
  metadata,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/insights-tool",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.203.0-preview.235",
5
+ "version": "1.203.0-preview.240",
6
6
  "description": "Query UiPath Insights data — jobs, failures, and performance metrics.",
7
7
  "private": false,
8
8
  "repository": {
@@ -27,5 +27,5 @@
27
27
  "files": [
28
28
  "dist"
29
29
  ],
30
- "gitHead": "4788b04c17a4429e5a994af2c3eba3898d1c4b13"
30
+ "gitHead": "95409ea61d359dff5465afaf59cb3a5efae542af"
31
31
  }