@uipath/solution-sdk 1.203.0-preview.233 → 1.203.0-preview.237

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.
@@ -4758,7 +4758,165 @@ class FilterImplicitLimitError extends Error {
4758
4758
  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).";
4759
4759
  }
4760
4760
  }
4761
- function applyFilter(data, filter) {
4761
+ function countRecords(data) {
4762
+ if (Array.isArray(data))
4763
+ return data.length;
4764
+ return data == null ? 0 : 1;
4765
+ }
4766
+ function availableFields(data) {
4767
+ const records = Array.isArray(data) ? data : [data];
4768
+ const keys = new Set;
4769
+ for (const record of records) {
4770
+ if (record && typeof record === "object" && !Array.isArray(record)) {
4771
+ for (const key of Object.keys(record))
4772
+ keys.add(key);
4773
+ }
4774
+ }
4775
+ return [...keys];
4776
+ }
4777
+ function decodeQuotedIdentifier(whole, inner) {
4778
+ const [error, decoded] = catchError(() => JSON.parse(whole));
4779
+ if (!error && typeof decoded === "string")
4780
+ return decoded;
4781
+ return inner.replace(/\\(.)/g, "$1");
4782
+ }
4783
+ function referencedFields(filter) {
4784
+ const top = new Set;
4785
+ const nested = new Set;
4786
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
4787
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
4788
+ const quoted = [];
4789
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
4790
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
4791
+ if (!isAlias) {
4792
+ quoted.push({
4793
+ name: decodeQuotedIdentifier(whole, name),
4794
+ index,
4795
+ tail: isPathTail(withoutValueLiterals, index)
4796
+ });
4797
+ }
4798
+ return `"${" ".repeat(whole.length - 2)}"`;
4799
+ });
4800
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
4801
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
4802
+ const place = (name, index, tail) => {
4803
+ if (tail || index >= rootEnd)
4804
+ nested.add(name);
4805
+ else
4806
+ top.add(name);
4807
+ };
4808
+ for (const entry of quoted)
4809
+ place(entry.name, entry.index, entry.tail);
4810
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
4811
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
4812
+ for (const match of identifiers) {
4813
+ const [, name, trailing] = match;
4814
+ if (trailing || reserved.has(name))
4815
+ continue;
4816
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
4817
+ }
4818
+ return {
4819
+ top: [...top],
4820
+ nested: [...nested].filter((name) => !top.has(name)),
4821
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
4822
+ };
4823
+ }
4824
+ function appearsBelowTopLevel(data, name) {
4825
+ let budget = 2000;
4826
+ const visit = (value, depth) => {
4827
+ if (budget-- <= 0 || depth > 4)
4828
+ return false;
4829
+ if (value === null || typeof value !== "object")
4830
+ return false;
4831
+ if (Array.isArray(value))
4832
+ return value.some((entry) => visit(entry, depth));
4833
+ const record = value;
4834
+ if (depth > 0 && Object.hasOwn(record, name))
4835
+ return true;
4836
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
4837
+ };
4838
+ return visit(data, 0);
4839
+ }
4840
+ function alwaysNullKeys(records) {
4841
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
4842
+ if (objects.length === 0 || objects.length !== records.length)
4843
+ return [];
4844
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
4845
+ if (keys.length === 0)
4846
+ return [];
4847
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
4848
+ return nullKeys.length === keys.length ? nullKeys : [];
4849
+ }
4850
+ function carriesOnlyNulls(value) {
4851
+ if (value === null)
4852
+ return true;
4853
+ if (Array.isArray(value)) {
4854
+ return value.length > 0 && value.every(carriesOnlyNulls);
4855
+ }
4856
+ if (typeof value === "object" && value !== undefined) {
4857
+ const values = Object.values(value);
4858
+ return values.length > 0 && values.every(carriesOnlyNulls);
4859
+ }
4860
+ return false;
4861
+ }
4862
+ function nameList(names, cap2 = 12) {
4863
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
4864
+ const rest = names.length - shown.length;
4865
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
4866
+ }
4867
+ function buildFilterWarning(filter, data, outcome) {
4868
+ const present = availableFields(data);
4869
+ const refs = referencedFields(filter);
4870
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
4871
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
4872
+ const count = countRecords(data);
4873
+ const scope = `${count} record(s)`;
4874
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
4875
+ 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" : "";
4876
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
4877
+ let detail;
4878
+ let lede;
4879
+ if (outcome.kind === "null-elements") {
4880
+ lede = "returned only null values";
4881
+ const projected = `all ${outcome.count} of the elements it projected are null`;
4882
+ if (unknown.length > 0) {
4883
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4884
+ } else if (unchecked.length > 0) {
4885
+ detail = withSoundness(projected);
4886
+ } else {
4887
+ 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`;
4888
+ }
4889
+ } else if (outcome.kind === "null-rows") {
4890
+ lede = "returned only null values";
4891
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
4892
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
4893
+ } else if (outcome.kind === "null-values") {
4894
+ lede = "returned only null values";
4895
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
4896
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
4897
+ if (sameSet) {
4898
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
4899
+ } else if (unknown.length > 0) {
4900
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4901
+ } else {
4902
+ detail = withSoundness(`${projected} on all ${scope}`);
4903
+ }
4904
+ } else {
4905
+ lede = "returned nothing";
4906
+ if (unknown.length > 0) {
4907
+ detail = isNotAField(unknown);
4908
+ } else {
4909
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
4910
+ detail = withSoundness(`${selection} — it read ${scope}`);
4911
+ }
4912
+ }
4913
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
4914
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
4915
+ }
4916
+ function appendWarning(existing, note) {
4917
+ return existing ? `${existing} ${note}` : note;
4918
+ }
4919
+ function applyFilter(data, filter, onWarning) {
4762
4920
  const codec = requireJmespath();
4763
4921
  let result;
4764
4922
  try {
@@ -4766,9 +4924,34 @@ function applyFilter(data, filter) {
4766
4924
  } catch (err) {
4767
4925
  throw new FilterEvaluationError(filter, err);
4768
4926
  }
4769
- if (result == null)
4927
+ const inputCount = countRecords(data);
4928
+ const warn = (outcome) => {
4929
+ if (inputCount === 0)
4930
+ return;
4931
+ const note = buildFilterWarning(filter, data, outcome);
4932
+ getOutputSink().writeErr(`[WARN] ${note}
4933
+ `);
4934
+ onWarning?.(note);
4935
+ };
4936
+ const warnIfAllNull = (records) => {
4937
+ const keys = alwaysNullKeys(records);
4938
+ if (keys.length > 0)
4939
+ warn({ kind: "null-values", keys });
4940
+ };
4941
+ if (result == null) {
4942
+ warn({ kind: "empty" });
4770
4943
  return [];
4944
+ }
4771
4945
  if (Array.isArray(result)) {
4946
+ if (result.length === 0) {
4947
+ warn({ kind: "empty" });
4948
+ } else if (result.every((entry) => entry === null)) {
4949
+ warn({ kind: "null-elements", count: result.length });
4950
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
4951
+ warn({ kind: "null-rows", count: result.length });
4952
+ } else {
4953
+ warnIfAllNull(result);
4954
+ }
4772
4955
  if (result.length > 0 && typeof result[0] !== "object") {
4773
4956
  const fieldMatch = filter.match(/\.(\w+)$/);
4774
4957
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -4776,10 +4959,30 @@ function applyFilter(data, filter) {
4776
4959
  }
4777
4960
  return result;
4778
4961
  }
4779
- if (typeof result === "object")
4962
+ if (typeof result === "object") {
4963
+ warnIfAllNull([result]);
4780
4964
  return result;
4965
+ }
4781
4966
  return { Value: result };
4782
4967
  }
4968
+ function filterFailureData(envelope) {
4969
+ const filter = getOutputFilter();
4970
+ const data = envelope.Data;
4971
+ if (!filter || data == null)
4972
+ return;
4973
+ let note;
4974
+ const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
4975
+ note = n;
4976
+ }));
4977
+ if (filterError) {
4978
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
4979
+ return;
4980
+ }
4981
+ envelope.Data = filtered;
4982
+ if (note) {
4983
+ envelope.Warning = appendWarning(envelope.Warning, note);
4984
+ }
4985
+ }
4783
4986
  function defaultErrorCodeForResult(result) {
4784
4987
  switch (result) {
4785
4988
  case RESULTS.AuthenticationError:
@@ -4862,8 +5065,14 @@ var OutputFormatter;
4862
5065
  }
4863
5066
  const filter = getOutputFilter();
4864
5067
  if (filter) {
4865
- const filtered = applyFilter(data.Data, filter);
5068
+ let note;
5069
+ const filtered = applyFilter(data.Data, filter, (n) => {
5070
+ note = n;
5071
+ });
4866
5072
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
5073
+ if (note) {
5074
+ data.Warning = appendWarning(data.Warning, note);
5075
+ }
4867
5076
  }
4868
5077
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
4869
5078
  }
@@ -4891,6 +5100,7 @@ var OutputFormatter;
4891
5100
  delete envelope.TelemetryErrorClass;
4892
5101
  delete envelope.TelemetryTerminalOutcome;
4893
5102
  delete envelope.TelemetryTerminalSignal;
5103
+ filterFailureData(envelope);
4894
5104
  if (!suppressTelemetry) {
4895
5105
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
4896
5106
  result: data.Result,
@@ -4939,13 +5149,20 @@ var OutputFormatter;
4939
5149
  OutputFormatter.log = log;
4940
5150
  function formatToString(data) {
4941
5151
  const filter = getOutputFilter();
5152
+ const envelope = data;
4942
5153
  if ("Data" in data && data.Data != null) {
4943
5154
  data.Data = normalizeDataKeys(data.Data);
4944
5155
  if (filter) {
4945
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
5156
+ let note;
5157
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
5158
+ note = n;
5159
+ }));
5160
+ if (note) {
5161
+ envelope.Warning = appendWarning(envelope.Warning, note);
5162
+ }
4946
5163
  }
4947
5164
  }
4948
- const output = normalizeOutputKeys(data);
5165
+ const output = normalizeOutputKeys(envelope);
4949
5166
  const lines = [];
4950
5167
  const sink = getOutputSink();
4951
5168
  printOutput(output, getOutputFormat(), (msg) => {
@@ -6919,4 +7136,4 @@ function zipSync(data, opts) {
6919
7136
 
6920
7137
  export { getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, catchError, extractErrorMessage, logger, RESULTS, summarizePlatformBody, isGuid, normalizeProjectType, toPortableRelativePath, readUipxFile, createSolutionManifest, autoScaffoldSolution, prepareProjectLocation, resolveSolutionDir, updateUipxSolutionId, findSolutionFile, updateSolutionFile, tryRegisterProjectInParentSolution, findNearestParentUipxFile, readSolutionManifest, isProjectRegisteredInSolution, findSolutionFileUpward, zipSync };
6921
7138
 
6922
- //# debugId=DDD1A4A5D2E9F9B264756E2164756E21
7139
+ //# debugId=2F5DE0DC874ED29F64756E2164756E21
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ import {
22
22
  updateSolutionFile,
23
23
  updateUipxSolutionId,
24
24
  zipSync
25
- } from "./index-4zqv4bn2.js";
25
+ } from "./index-z20j4jst.js";
26
26
  import"./index-g0hcxnae.js";
27
27
  import"./index-1de529jm.js";
28
28
 
@@ -326,7 +326,7 @@ var package_default = {
326
326
  name: "@uipath/solution-sdk",
327
327
  author: "UiPath",
328
328
  license: "SEE LICENSE IN LICENSE.txt",
329
- version: "1.203.0-preview.233",
329
+ version: "1.203.0-preview.237",
330
330
  repository: {
331
331
  type: "git",
332
332
  url: "https://github.com/UiPath/cli.git",
@@ -5275,4 +5275,4 @@ export {
5275
5275
  uploadOrOverwriteSolution
5276
5276
  };
5277
5277
 
5278
- //# debugId=B983A6501AB9272364756E2164756E21
5278
+ //# debugId=7BD76502015057BB64756E2164756E21
@@ -18,7 +18,7 @@ import {
18
18
  logger,
19
19
  normalizeProjectType,
20
20
  toPortableRelativePath
21
- } from "../index-4zqv4bn2.js";
21
+ } from "../index-z20j4jst.js";
22
22
  import {
23
23
  getAuthContext,
24
24
  getLoginStatusAsync,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/solution-sdk",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.203.0-preview.233",
5
+ "version": "1.203.0-preview.237",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/UiPath/cli.git",
@@ -40,5 +40,5 @@
40
40
  "dist"
41
41
  ],
42
42
  "private": false,
43
- "gitHead": "641614a6f9817662baaf51dabdebbfa2a9334b1b"
43
+ "gitHead": "4ad3e17a66f2c7fb7fe1f0e3e04a5b6175a0a9a3"
44
44
  }