@uipath/function-tool 1.202.1-preview.217 → 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.
Files changed (2) hide show
  1. package/dist/tool.js +449 -15
  2. package/package.json +2 -2
package/dist/tool.js CHANGED
@@ -2103,7 +2103,7 @@ var require_commander3 = __commonJS(function(exports) {
2103
2103
  var package_default = {
2104
2104
  name: "@uipath/function-tool",
2105
2105
  license: "SEE LICENSE IN LICENSE.txt",
2106
- version: "1.202.1-preview.217",
2106
+ version: "1.202.1-preview.238",
2107
2107
  description: "UiPath CLI tool for JS/TS and Python Functions — thin passthrough to uipath-functions / uipath",
2108
2108
  keywords: [
2109
2109
  "uipcli-tool",
@@ -11836,7 +11836,165 @@ class FilterImplicitLimitError extends Error {
11836
11836
  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).";
11837
11837
  }
11838
11838
  }
11839
- function applyFilter(data, filter) {
11839
+ function countRecords(data) {
11840
+ if (Array.isArray(data))
11841
+ return data.length;
11842
+ return data == null ? 0 : 1;
11843
+ }
11844
+ function availableFields(data) {
11845
+ const records = Array.isArray(data) ? data : [data];
11846
+ const keys = new Set;
11847
+ for (const record of records) {
11848
+ if (record && typeof record === "object" && !Array.isArray(record)) {
11849
+ for (const key of Object.keys(record))
11850
+ keys.add(key);
11851
+ }
11852
+ }
11853
+ return [...keys];
11854
+ }
11855
+ function decodeQuotedIdentifier(whole, inner) {
11856
+ const [error, decoded] = catchError(() => JSON.parse(whole));
11857
+ if (!error && typeof decoded === "string")
11858
+ return decoded;
11859
+ return inner.replace(/\\(.)/g, "$1");
11860
+ }
11861
+ function referencedFields(filter) {
11862
+ const top = new Set;
11863
+ const nested = new Set;
11864
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
11865
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
11866
+ const quoted = [];
11867
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
11868
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
11869
+ if (!isAlias) {
11870
+ quoted.push({
11871
+ name: decodeQuotedIdentifier(whole, name),
11872
+ index,
11873
+ tail: isPathTail(withoutValueLiterals, index)
11874
+ });
11875
+ }
11876
+ return `"${" ".repeat(whole.length - 2)}"`;
11877
+ });
11878
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
11879
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
11880
+ const place = (name, index, tail) => {
11881
+ if (tail || index >= rootEnd)
11882
+ nested.add(name);
11883
+ else
11884
+ top.add(name);
11885
+ };
11886
+ for (const entry of quoted)
11887
+ place(entry.name, entry.index, entry.tail);
11888
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
11889
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
11890
+ for (const match of identifiers) {
11891
+ const [, name, trailing] = match;
11892
+ if (trailing || reserved.has(name))
11893
+ continue;
11894
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
11895
+ }
11896
+ return {
11897
+ top: [...top],
11898
+ nested: [...nested].filter((name) => !top.has(name)),
11899
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
11900
+ };
11901
+ }
11902
+ function appearsBelowTopLevel(data, name) {
11903
+ let budget = 2000;
11904
+ const visit = (value, depth) => {
11905
+ if (budget-- <= 0 || depth > 4)
11906
+ return false;
11907
+ if (value === null || typeof value !== "object")
11908
+ return false;
11909
+ if (Array.isArray(value))
11910
+ return value.some((entry) => visit(entry, depth));
11911
+ const record = value;
11912
+ if (depth > 0 && Object.hasOwn(record, name))
11913
+ return true;
11914
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
11915
+ };
11916
+ return visit(data, 0);
11917
+ }
11918
+ function alwaysNullKeys(records) {
11919
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
11920
+ if (objects.length === 0 || objects.length !== records.length)
11921
+ return [];
11922
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
11923
+ if (keys.length === 0)
11924
+ return [];
11925
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
11926
+ return nullKeys.length === keys.length ? nullKeys : [];
11927
+ }
11928
+ function carriesOnlyNulls(value) {
11929
+ if (value === null)
11930
+ return true;
11931
+ if (Array.isArray(value)) {
11932
+ return value.length > 0 && value.every(carriesOnlyNulls);
11933
+ }
11934
+ if (typeof value === "object" && value !== undefined) {
11935
+ const values = Object.values(value);
11936
+ return values.length > 0 && values.every(carriesOnlyNulls);
11937
+ }
11938
+ return false;
11939
+ }
11940
+ function nameList(names, cap2 = 12) {
11941
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
11942
+ const rest = names.length - shown.length;
11943
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
11944
+ }
11945
+ function buildFilterWarning(filter, data, outcome) {
11946
+ const present = availableFields(data);
11947
+ const refs = referencedFields(filter);
11948
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
11949
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
11950
+ const count = countRecords(data);
11951
+ const scope = `${count} record(s)`;
11952
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
11953
+ 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" : "";
11954
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
11955
+ let detail;
11956
+ let lede;
11957
+ if (outcome.kind === "null-elements") {
11958
+ lede = "returned only null values";
11959
+ const projected = `all ${outcome.count} of the elements it projected are null`;
11960
+ if (unknown.length > 0) {
11961
+ detail = `${projected}, because ${isNotAField(unknown)}`;
11962
+ } else if (unchecked.length > 0) {
11963
+ detail = withSoundness(projected);
11964
+ } else {
11965
+ 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`;
11966
+ }
11967
+ } else if (outcome.kind === "null-rows") {
11968
+ lede = "returned only null values";
11969
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
11970
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
11971
+ } else if (outcome.kind === "null-values") {
11972
+ lede = "returned only null values";
11973
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
11974
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
11975
+ if (sameSet) {
11976
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
11977
+ } else if (unknown.length > 0) {
11978
+ detail = `${projected}, because ${isNotAField(unknown)}`;
11979
+ } else {
11980
+ detail = withSoundness(`${projected} on all ${scope}`);
11981
+ }
11982
+ } else {
11983
+ lede = "returned nothing";
11984
+ if (unknown.length > 0) {
11985
+ detail = isNotAField(unknown);
11986
+ } else {
11987
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
11988
+ detail = withSoundness(`${selection} — it read ${scope}`);
11989
+ }
11990
+ }
11991
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
11992
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
11993
+ }
11994
+ function appendWarning(existing, note) {
11995
+ return existing ? `${existing} ${note}` : note;
11996
+ }
11997
+ function applyFilter(data, filter, onWarning) {
11840
11998
  const codec = requireJmespath();
11841
11999
  let result;
11842
12000
  try {
@@ -11844,9 +12002,34 @@ function applyFilter(data, filter) {
11844
12002
  } catch (err) {
11845
12003
  throw new FilterEvaluationError(filter, err);
11846
12004
  }
11847
- if (result == null)
12005
+ const inputCount = countRecords(data);
12006
+ const warn = (outcome) => {
12007
+ if (inputCount === 0)
12008
+ return;
12009
+ const note = buildFilterWarning(filter, data, outcome);
12010
+ getOutputSink().writeErr(`[WARN] ${note}
12011
+ `);
12012
+ onWarning?.(note);
12013
+ };
12014
+ const warnIfAllNull = (records) => {
12015
+ const keys = alwaysNullKeys(records);
12016
+ if (keys.length > 0)
12017
+ warn({ kind: "null-values", keys });
12018
+ };
12019
+ if (result == null) {
12020
+ warn({ kind: "empty" });
11848
12021
  return [];
12022
+ }
11849
12023
  if (Array.isArray(result)) {
12024
+ if (result.length === 0) {
12025
+ warn({ kind: "empty" });
12026
+ } else if (result.every((entry) => entry === null)) {
12027
+ warn({ kind: "null-elements", count: result.length });
12028
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
12029
+ warn({ kind: "null-rows", count: result.length });
12030
+ } else {
12031
+ warnIfAllNull(result);
12032
+ }
11850
12033
  if (result.length > 0 && typeof result[0] !== "object") {
11851
12034
  const fieldMatch = filter.match(/\.(\w+)$/);
11852
12035
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -11854,10 +12037,30 @@ function applyFilter(data, filter) {
11854
12037
  }
11855
12038
  return result;
11856
12039
  }
11857
- if (typeof result === "object")
12040
+ if (typeof result === "object") {
12041
+ warnIfAllNull([result]);
11858
12042
  return result;
12043
+ }
11859
12044
  return { Value: result };
11860
12045
  }
12046
+ function filterFailureData(envelope) {
12047
+ const filter = getOutputFilter();
12048
+ const data = envelope.Data;
12049
+ if (!filter || data == null)
12050
+ return;
12051
+ let note;
12052
+ const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
12053
+ note = n;
12054
+ }));
12055
+ if (filterError) {
12056
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
12057
+ return;
12058
+ }
12059
+ envelope.Data = filtered;
12060
+ if (note) {
12061
+ envelope.Warning = appendWarning(envelope.Warning, note);
12062
+ }
12063
+ }
11861
12064
  function defaultErrorCodeForResult(result) {
11862
12065
  switch (result) {
11863
12066
  case RESULTS.AuthenticationError:
@@ -11940,8 +12143,14 @@ var OutputFormatter;
11940
12143
  }
11941
12144
  const filter = getOutputFilter();
11942
12145
  if (filter) {
11943
- const filtered = applyFilter(data.Data, filter);
12146
+ let note;
12147
+ const filtered = applyFilter(data.Data, filter, (n) => {
12148
+ note = n;
12149
+ });
11944
12150
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
12151
+ if (note) {
12152
+ data.Warning = appendWarning(data.Warning, note);
12153
+ }
11945
12154
  }
11946
12155
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
11947
12156
  }
@@ -11969,6 +12178,7 @@ var OutputFormatter;
11969
12178
  delete envelope.TelemetryErrorClass;
11970
12179
  delete envelope.TelemetryTerminalOutcome;
11971
12180
  delete envelope.TelemetryTerminalSignal;
12181
+ filterFailureData(envelope);
11972
12182
  if (!suppressTelemetry) {
11973
12183
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
11974
12184
  result: data.Result,
@@ -12017,13 +12227,20 @@ var OutputFormatter;
12017
12227
  OutputFormatter2.log = log;
12018
12228
  function formatToString(data) {
12019
12229
  const filter = getOutputFilter();
12230
+ const envelope = data;
12020
12231
  if ("Data" in data && data.Data != null) {
12021
12232
  data.Data = normalizeDataKeys(data.Data);
12022
12233
  if (filter) {
12023
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
12234
+ let note;
12235
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
12236
+ note = n;
12237
+ }));
12238
+ if (note) {
12239
+ envelope.Warning = appendWarning(envelope.Warning, note);
12240
+ }
12024
12241
  }
12025
12242
  }
12026
- const output = normalizeOutputKeys(data);
12243
+ const output = normalizeOutputKeys(envelope);
12027
12244
  const lines = [];
12028
12245
  const sink = getOutputSink();
12029
12246
  printOutput(output, getOutputFormat(), (msg) => {
@@ -21673,7 +21890,7 @@ function querystringSingleKey(key, value, keyPrefix = "") {
21673
21890
  var package_default2 = {
21674
21891
  name: "@uipath/solution-sdk",
21675
21892
  license: "SEE LICENSE IN LICENSE.txt",
21676
- version: "1.202.1-preview.217",
21893
+ version: "1.202.1-preview.238",
21677
21894
  repository: {
21678
21895
  type: "git",
21679
21896
  url: "https://github.com/UiPath/cli.git",
@@ -23933,7 +24150,165 @@ class FilterImplicitLimitError2 extends Error {
23933
24150
  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).";
23934
24151
  }
23935
24152
  }
23936
- function applyFilter2(data, filter) {
24153
+ function countRecords2(data) {
24154
+ if (Array.isArray(data))
24155
+ return data.length;
24156
+ return data == null ? 0 : 1;
24157
+ }
24158
+ function availableFields2(data) {
24159
+ const records = Array.isArray(data) ? data : [data];
24160
+ const keys = new Set;
24161
+ for (const record of records) {
24162
+ if (record && typeof record === "object" && !Array.isArray(record)) {
24163
+ for (const key of Object.keys(record))
24164
+ keys.add(key);
24165
+ }
24166
+ }
24167
+ return [...keys];
24168
+ }
24169
+ function decodeQuotedIdentifier2(whole, inner) {
24170
+ const [error, decoded] = catchError2(() => JSON.parse(whole));
24171
+ if (!error && typeof decoded === "string")
24172
+ return decoded;
24173
+ return inner.replace(/\\(.)/g, "$1");
24174
+ }
24175
+ function referencedFields2(filter) {
24176
+ const top = new Set;
24177
+ const nested = new Set;
24178
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
24179
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
24180
+ const quoted = [];
24181
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
24182
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
24183
+ if (!isAlias) {
24184
+ quoted.push({
24185
+ name: decodeQuotedIdentifier2(whole, name),
24186
+ index,
24187
+ tail: isPathTail(withoutValueLiterals, index)
24188
+ });
24189
+ }
24190
+ return `"${" ".repeat(whole.length - 2)}"`;
24191
+ });
24192
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
24193
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
24194
+ const place = (name, index, tail) => {
24195
+ if (tail || index >= rootEnd)
24196
+ nested.add(name);
24197
+ else
24198
+ top.add(name);
24199
+ };
24200
+ for (const entry of quoted)
24201
+ place(entry.name, entry.index, entry.tail);
24202
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
24203
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
24204
+ for (const match of identifiers) {
24205
+ const [, name, trailing] = match;
24206
+ if (trailing || reserved.has(name))
24207
+ continue;
24208
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
24209
+ }
24210
+ return {
24211
+ top: [...top],
24212
+ nested: [...nested].filter((name) => !top.has(name)),
24213
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
24214
+ };
24215
+ }
24216
+ function appearsBelowTopLevel2(data, name) {
24217
+ let budget = 2000;
24218
+ const visit = (value, depth) => {
24219
+ if (budget-- <= 0 || depth > 4)
24220
+ return false;
24221
+ if (value === null || typeof value !== "object")
24222
+ return false;
24223
+ if (Array.isArray(value))
24224
+ return value.some((entry) => visit(entry, depth));
24225
+ const record = value;
24226
+ if (depth > 0 && Object.hasOwn(record, name))
24227
+ return true;
24228
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
24229
+ };
24230
+ return visit(data, 0);
24231
+ }
24232
+ function alwaysNullKeys2(records) {
24233
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
24234
+ if (objects.length === 0 || objects.length !== records.length)
24235
+ return [];
24236
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
24237
+ if (keys.length === 0)
24238
+ return [];
24239
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
24240
+ return nullKeys.length === keys.length ? nullKeys : [];
24241
+ }
24242
+ function carriesOnlyNulls2(value) {
24243
+ if (value === null)
24244
+ return true;
24245
+ if (Array.isArray(value)) {
24246
+ return value.length > 0 && value.every(carriesOnlyNulls2);
24247
+ }
24248
+ if (typeof value === "object" && value !== undefined) {
24249
+ const values = Object.values(value);
24250
+ return values.length > 0 && values.every(carriesOnlyNulls2);
24251
+ }
24252
+ return false;
24253
+ }
24254
+ function nameList2(names, cap22 = 12) {
24255
+ const shown = names.slice(0, cap22).map((n) => `\`${n}\``);
24256
+ const rest = names.length - shown.length;
24257
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
24258
+ }
24259
+ function buildFilterWarning2(filter, data, outcome) {
24260
+ const present = availableFields2(data);
24261
+ const refs = referencedFields2(filter);
24262
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel2(data, name));
24263
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
24264
+ const count = countRecords2(data);
24265
+ const scope = `${count} record(s)`;
24266
+ const isNotAField = (names) => `${nameList2(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
24267
+ const soundness = unchecked.length > 0 ? `${nameList2(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" : "";
24268
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
24269
+ let detail;
24270
+ let lede;
24271
+ if (outcome.kind === "null-elements") {
24272
+ lede = "returned only null values";
24273
+ const projected = `all ${outcome.count} of the elements it projected are null`;
24274
+ if (unknown.length > 0) {
24275
+ detail = `${projected}, because ${isNotAField(unknown)}`;
24276
+ } else if (unchecked.length > 0) {
24277
+ detail = withSoundness(projected);
24278
+ } else {
24279
+ 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`;
24280
+ }
24281
+ } else if (outcome.kind === "null-rows") {
24282
+ lede = "returned only null values";
24283
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
24284
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
24285
+ } else if (outcome.kind === "null-values") {
24286
+ lede = "returned only null values";
24287
+ const projected = `every key it projected (${nameList2(outcome.keys)}) is null`;
24288
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
24289
+ if (sameSet) {
24290
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
24291
+ } else if (unknown.length > 0) {
24292
+ detail = `${projected}, because ${isNotAField(unknown)}`;
24293
+ } else {
24294
+ detail = withSoundness(`${projected} on all ${scope}`);
24295
+ }
24296
+ } else {
24297
+ lede = "returned nothing";
24298
+ if (unknown.length > 0) {
24299
+ detail = isNotAField(unknown);
24300
+ } else {
24301
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
24302
+ detail = withSoundness(`${selection} — it read ${scope}`);
24303
+ }
24304
+ }
24305
+ const fields = present.length > 0 ? ` Available fields: ${nameList2(present)}.` : "";
24306
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
24307
+ }
24308
+ function appendWarning2(existing, note) {
24309
+ return existing ? `${existing} ${note}` : note;
24310
+ }
24311
+ function applyFilter2(data, filter, onWarning) {
23937
24312
  const codec = requireJmespath2();
23938
24313
  let result;
23939
24314
  try {
@@ -23941,9 +24316,34 @@ function applyFilter2(data, filter) {
23941
24316
  } catch (err) {
23942
24317
  throw new FilterEvaluationError2(filter, err);
23943
24318
  }
23944
- if (result == null)
24319
+ const inputCount = countRecords2(data);
24320
+ const warn = (outcome) => {
24321
+ if (inputCount === 0)
24322
+ return;
24323
+ const note = buildFilterWarning2(filter, data, outcome);
24324
+ getOutputSink2().writeErr(`[WARN] ${note}
24325
+ `);
24326
+ onWarning?.(note);
24327
+ };
24328
+ const warnIfAllNull = (records) => {
24329
+ const keys = alwaysNullKeys2(records);
24330
+ if (keys.length > 0)
24331
+ warn({ kind: "null-values", keys });
24332
+ };
24333
+ if (result == null) {
24334
+ warn({ kind: "empty" });
23945
24335
  return [];
24336
+ }
23946
24337
  if (Array.isArray(result)) {
24338
+ if (result.length === 0) {
24339
+ warn({ kind: "empty" });
24340
+ } else if (result.every((entry) => entry === null)) {
24341
+ warn({ kind: "null-elements", count: result.length });
24342
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls2(result)) {
24343
+ warn({ kind: "null-rows", count: result.length });
24344
+ } else {
24345
+ warnIfAllNull(result);
24346
+ }
23947
24347
  if (result.length > 0 && typeof result[0] !== "object") {
23948
24348
  const fieldMatch = filter.match(/\.(\w+)$/);
23949
24349
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -23951,10 +24351,30 @@ function applyFilter2(data, filter) {
23951
24351
  }
23952
24352
  return result;
23953
24353
  }
23954
- if (typeof result === "object")
24354
+ if (typeof result === "object") {
24355
+ warnIfAllNull([result]);
23955
24356
  return result;
24357
+ }
23956
24358
  return { Value: result };
23957
24359
  }
24360
+ function filterFailureData2(envelope) {
24361
+ const filter = getOutputFilter2();
24362
+ const data = envelope.Data;
24363
+ if (!filter || data == null)
24364
+ return;
24365
+ let note;
24366
+ const [filterError, filtered] = catchError2(() => applyFilter2(data, filter, (n) => {
24367
+ note = n;
24368
+ }));
24369
+ if (filterError) {
24370
+ envelope.Warning = appendWarning2(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
24371
+ return;
24372
+ }
24373
+ envelope.Data = filtered;
24374
+ if (note) {
24375
+ envelope.Warning = appendWarning2(envelope.Warning, note);
24376
+ }
24377
+ }
23958
24378
  function defaultErrorCodeForResult2(result) {
23959
24379
  switch (result) {
23960
24380
  case RESULTS2.AuthenticationError:
@@ -24037,8 +24457,14 @@ var OutputFormatter2;
24037
24457
  }
24038
24458
  const filter = getOutputFilter2();
24039
24459
  if (filter) {
24040
- const filtered = applyFilter2(data.Data, filter);
24460
+ let note;
24461
+ const filtered = applyFilter2(data.Data, filter, (n) => {
24462
+ note = n;
24463
+ });
24041
24464
  data.Data = normalize ? normalizeDataKeys2(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
24465
+ if (note) {
24466
+ data.Warning = appendWarning2(data.Warning, note);
24467
+ }
24042
24468
  }
24043
24469
  logOutput2(normalizeOutputKeys2(data), getOutputFormat2(), options?.tableRowStyle);
24044
24470
  }
@@ -24066,6 +24492,7 @@ var OutputFormatter2;
24066
24492
  delete envelope.TelemetryErrorClass;
24067
24493
  delete envelope.TelemetryTerminalOutcome;
24068
24494
  delete envelope.TelemetryTerminalSignal;
24495
+ filterFailureData2(envelope);
24069
24496
  if (!suppressTelemetry) {
24070
24497
  telemetry2.trackEvent(CommonTelemetryEvents2.Error, {
24071
24498
  result: data.Result,
@@ -24114,13 +24541,20 @@ var OutputFormatter2;
24114
24541
  OutputFormatter3.log = log;
24115
24542
  function formatToString(data) {
24116
24543
  const filter = getOutputFilter2();
24544
+ const envelope = data;
24117
24545
  if ("Data" in data && data.Data != null) {
24118
24546
  data.Data = normalizeDataKeys2(data.Data);
24119
24547
  if (filter) {
24120
- data.Data = normalizeDataKeys2(applyFilter2(data.Data, filter));
24548
+ let note;
24549
+ data.Data = normalizeDataKeys2(applyFilter2(data.Data, filter, (n) => {
24550
+ note = n;
24551
+ }));
24552
+ if (note) {
24553
+ envelope.Warning = appendWarning2(envelope.Warning, note);
24554
+ }
24121
24555
  }
24122
24556
  }
24123
- const output = normalizeOutputKeys2(data);
24557
+ const output = normalizeOutputKeys2(envelope);
24124
24558
  const lines = [];
24125
24559
  const sink = getOutputSink2();
24126
24560
  printOutput2(output, getOutputFormat2(), (msg) => {
@@ -28867,4 +29301,4 @@ export {
28867
29301
  registerCommands
28868
29302
  };
28869
29303
 
28870
- //# debugId=2A3C249E0256347E64756E2164756E21
29304
+ //# debugId=1068BA15E713013864756E2164756E21
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/function-tool",
3
3
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "1.202.1-preview.217",
4
+ "version": "1.202.1-preview.238",
5
5
  "description": "UiPath CLI tool for JS/TS and Python Functions — thin passthrough to uipath-functions / uipath",
6
6
  "keywords": [
7
7
  "uipcli-tool",
@@ -34,5 +34,5 @@
34
34
  "dependencies": {
35
35
  "typescript": "^5.7.0"
36
36
  },
37
- "gitHead": "bd513110d03342230901ece289a303e5a0009404"
37
+ "gitHead": "537e43df1d3583633cfd3a0b88634f9ce3ba9d6b"
38
38
  }