@uipath/orchestrator-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-bb482eec.js";
6
+ } from "./tool-jxrps2dw.js";
7
7
  import"./tool-ayyhwvs8.js";
8
8
  import"./tool-1de529jm.js";
9
9
 
@@ -2104,7 +2104,7 @@ var package_default = {
2104
2104
  name: "@uipath/orchestrator-tool",
2105
2105
  author: "UiPath",
2106
2106
  license: "SEE LICENSE IN LICENSE.txt",
2107
- version: "1.203.0-preview.235",
2107
+ version: "1.203.0-preview.240",
2108
2108
  description: "Manage Orchestrator folders, jobs, processes, and releases.",
2109
2109
  private: false,
2110
2110
  repository: {
@@ -4859,7 +4859,165 @@ class FilterImplicitLimitError extends Error {
4859
4859
  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).";
4860
4860
  }
4861
4861
  }
4862
- function applyFilter(data, filter) {
4862
+ function countRecords(data) {
4863
+ if (Array.isArray(data))
4864
+ return data.length;
4865
+ return data == null ? 0 : 1;
4866
+ }
4867
+ function availableFields(data) {
4868
+ const records = Array.isArray(data) ? data : [data];
4869
+ const keys = new Set;
4870
+ for (const record of records) {
4871
+ if (record && typeof record === "object" && !Array.isArray(record)) {
4872
+ for (const key of Object.keys(record))
4873
+ keys.add(key);
4874
+ }
4875
+ }
4876
+ return [...keys];
4877
+ }
4878
+ function decodeQuotedIdentifier(whole, inner) {
4879
+ const [error, decoded] = catchError(() => JSON.parse(whole));
4880
+ if (!error && typeof decoded === "string")
4881
+ return decoded;
4882
+ return inner.replace(/\\(.)/g, "$1");
4883
+ }
4884
+ function referencedFields(filter) {
4885
+ const top = new Set;
4886
+ const nested = new Set;
4887
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
4888
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
4889
+ const quoted = [];
4890
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
4891
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
4892
+ if (!isAlias) {
4893
+ quoted.push({
4894
+ name: decodeQuotedIdentifier(whole, name),
4895
+ index,
4896
+ tail: isPathTail(withoutValueLiterals, index)
4897
+ });
4898
+ }
4899
+ return `"${" ".repeat(whole.length - 2)}"`;
4900
+ });
4901
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
4902
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
4903
+ const place = (name, index, tail) => {
4904
+ if (tail || index >= rootEnd)
4905
+ nested.add(name);
4906
+ else
4907
+ top.add(name);
4908
+ };
4909
+ for (const entry of quoted)
4910
+ place(entry.name, entry.index, entry.tail);
4911
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
4912
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
4913
+ for (const match of identifiers) {
4914
+ const [, name, trailing] = match;
4915
+ if (trailing || reserved.has(name))
4916
+ continue;
4917
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
4918
+ }
4919
+ return {
4920
+ top: [...top],
4921
+ nested: [...nested].filter((name) => !top.has(name)),
4922
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
4923
+ };
4924
+ }
4925
+ function appearsBelowTopLevel(data, name) {
4926
+ let budget = 2000;
4927
+ const visit = (value, depth) => {
4928
+ if (budget-- <= 0 || depth > 4)
4929
+ return false;
4930
+ if (value === null || typeof value !== "object")
4931
+ return false;
4932
+ if (Array.isArray(value))
4933
+ return value.some((entry) => visit(entry, depth));
4934
+ const record = value;
4935
+ if (depth > 0 && Object.hasOwn(record, name))
4936
+ return true;
4937
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
4938
+ };
4939
+ return visit(data, 0);
4940
+ }
4941
+ function alwaysNullKeys(records) {
4942
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
4943
+ if (objects.length === 0 || objects.length !== records.length)
4944
+ return [];
4945
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
4946
+ if (keys.length === 0)
4947
+ return [];
4948
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
4949
+ return nullKeys.length === keys.length ? nullKeys : [];
4950
+ }
4951
+ function carriesOnlyNulls(value) {
4952
+ if (value === null)
4953
+ return true;
4954
+ if (Array.isArray(value)) {
4955
+ return value.length > 0 && value.every(carriesOnlyNulls);
4956
+ }
4957
+ if (typeof value === "object" && value !== undefined) {
4958
+ const values = Object.values(value);
4959
+ return values.length > 0 && values.every(carriesOnlyNulls);
4960
+ }
4961
+ return false;
4962
+ }
4963
+ function nameList(names, cap2 = 12) {
4964
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
4965
+ const rest = names.length - shown.length;
4966
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
4967
+ }
4968
+ function buildFilterWarning(filter, data, outcome) {
4969
+ const present = availableFields(data);
4970
+ const refs = referencedFields(filter);
4971
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
4972
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
4973
+ const count = countRecords(data);
4974
+ const scope = `${count} record(s)`;
4975
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
4976
+ 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" : "";
4977
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
4978
+ let detail;
4979
+ let lede;
4980
+ if (outcome.kind === "null-elements") {
4981
+ lede = "returned only null values";
4982
+ const projected = `all ${outcome.count} of the elements it projected are null`;
4983
+ if (unknown.length > 0) {
4984
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4985
+ } else if (unchecked.length > 0) {
4986
+ detail = withSoundness(projected);
4987
+ } else {
4988
+ 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`;
4989
+ }
4990
+ } else if (outcome.kind === "null-rows") {
4991
+ lede = "returned only null values";
4992
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
4993
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
4994
+ } else if (outcome.kind === "null-values") {
4995
+ lede = "returned only null values";
4996
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
4997
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
4998
+ if (sameSet) {
4999
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
5000
+ } else if (unknown.length > 0) {
5001
+ detail = `${projected}, because ${isNotAField(unknown)}`;
5002
+ } else {
5003
+ detail = withSoundness(`${projected} on all ${scope}`);
5004
+ }
5005
+ } else {
5006
+ lede = "returned nothing";
5007
+ if (unknown.length > 0) {
5008
+ detail = isNotAField(unknown);
5009
+ } else {
5010
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
5011
+ detail = withSoundness(`${selection} — it read ${scope}`);
5012
+ }
5013
+ }
5014
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
5015
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
5016
+ }
5017
+ function appendWarning(existing, note) {
5018
+ return existing ? `${existing} ${note}` : note;
5019
+ }
5020
+ function applyFilter(data, filter, onWarning) {
4863
5021
  const codec = requireJmespath();
4864
5022
  let result;
4865
5023
  try {
@@ -4867,9 +5025,34 @@ function applyFilter(data, filter) {
4867
5025
  } catch (err) {
4868
5026
  throw new FilterEvaluationError(filter, err);
4869
5027
  }
4870
- if (result == null)
5028
+ const inputCount = countRecords(data);
5029
+ const warn = (outcome) => {
5030
+ if (inputCount === 0)
5031
+ return;
5032
+ const note = buildFilterWarning(filter, data, outcome);
5033
+ getOutputSink().writeErr(`[WARN] ${note}
5034
+ `);
5035
+ onWarning?.(note);
5036
+ };
5037
+ const warnIfAllNull = (records) => {
5038
+ const keys = alwaysNullKeys(records);
5039
+ if (keys.length > 0)
5040
+ warn({ kind: "null-values", keys });
5041
+ };
5042
+ if (result == null) {
5043
+ warn({ kind: "empty" });
4871
5044
  return [];
5045
+ }
4872
5046
  if (Array.isArray(result)) {
5047
+ if (result.length === 0) {
5048
+ warn({ kind: "empty" });
5049
+ } else if (result.every((entry) => entry === null)) {
5050
+ warn({ kind: "null-elements", count: result.length });
5051
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
5052
+ warn({ kind: "null-rows", count: result.length });
5053
+ } else {
5054
+ warnIfAllNull(result);
5055
+ }
4873
5056
  if (result.length > 0 && typeof result[0] !== "object") {
4874
5057
  const fieldMatch = filter.match(/\.(\w+)$/);
4875
5058
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -4877,10 +5060,30 @@ function applyFilter(data, filter) {
4877
5060
  }
4878
5061
  return result;
4879
5062
  }
4880
- if (typeof result === "object")
5063
+ if (typeof result === "object") {
5064
+ warnIfAllNull([result]);
4881
5065
  return result;
5066
+ }
4882
5067
  return { Value: result };
4883
5068
  }
5069
+ function filterFailureData(envelope) {
5070
+ const filter = getOutputFilter();
5071
+ const data = envelope.Data;
5072
+ if (!filter || data == null)
5073
+ return;
5074
+ let note;
5075
+ const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
5076
+ note = n;
5077
+ }));
5078
+ if (filterError) {
5079
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
5080
+ return;
5081
+ }
5082
+ envelope.Data = filtered;
5083
+ if (note) {
5084
+ envelope.Warning = appendWarning(envelope.Warning, note);
5085
+ }
5086
+ }
4884
5087
  function defaultErrorCodeForResult(result) {
4885
5088
  switch (result) {
4886
5089
  case RESULTS.AuthenticationError:
@@ -4963,8 +5166,14 @@ var OutputFormatter;
4963
5166
  }
4964
5167
  const filter = getOutputFilter();
4965
5168
  if (filter) {
4966
- const filtered = applyFilter(data.Data, filter);
5169
+ let note;
5170
+ const filtered = applyFilter(data.Data, filter, (n) => {
5171
+ note = n;
5172
+ });
4967
5173
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
5174
+ if (note) {
5175
+ data.Warning = appendWarning(data.Warning, note);
5176
+ }
4968
5177
  }
4969
5178
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
4970
5179
  }
@@ -4992,6 +5201,7 @@ var OutputFormatter;
4992
5201
  delete envelope.TelemetryErrorClass;
4993
5202
  delete envelope.TelemetryTerminalOutcome;
4994
5203
  delete envelope.TelemetryTerminalSignal;
5204
+ filterFailureData(envelope);
4995
5205
  if (!suppressTelemetry) {
4996
5206
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
4997
5207
  result: data.Result,
@@ -5040,13 +5250,20 @@ var OutputFormatter;
5040
5250
  OutputFormatter.log = log;
5041
5251
  function formatToString(data) {
5042
5252
  const filter = getOutputFilter();
5253
+ const envelope = data;
5043
5254
  if ("Data" in data && data.Data != null) {
5044
5255
  data.Data = normalizeDataKeys(data.Data);
5045
5256
  if (filter) {
5046
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
5257
+ let note;
5258
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
5259
+ note = n;
5260
+ }));
5261
+ if (note) {
5262
+ envelope.Warning = appendWarning(envelope.Warning, note);
5263
+ }
5047
5264
  }
5048
5265
  }
5049
- const output = normalizeOutputKeys(data);
5266
+ const output = normalizeOutputKeys(envelope);
5050
5267
  const lines = [];
5051
5268
  const sink = getOutputSink();
5052
5269
  printOutput(output, getOutputFormat(), (msg) => {
@@ -43712,4 +43929,4 @@ var registerCommands = async (program2) => {
43712
43929
 
43713
43930
  export { Command, metadata, registerCommands };
43714
43931
 
43715
- //# debugId=AE99425EE722A04D64756E2164756E21
43932
+ //# debugId=D24BBBF049D1651F64756E2164756E21
package/dist/tool.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-bb482eec.js";
4
+ } from "./tool-jxrps2dw.js";
5
5
  import"./tool-ayyhwvs8.js";
6
6
  import"./tool-1de529jm.js";
7
7
  export {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/orchestrator-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": "Manage Orchestrator folders, jobs, processes, and releases.",
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
  }