@uipath/project-packager 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
@@ -24215,7 +24215,7 @@ import { translate as translate3 } from "@uipath/solutionpackager-tool-core";
24215
24215
  var package_default = {
24216
24216
  name: "@uipath/project-packager",
24217
24217
  license: "SEE LICENSE IN LICENSE.txt",
24218
- version: "1.202.1-preview.220",
24218
+ version: "1.202.1-preview.238",
24219
24219
  description: "UiPath Project Packager - core library for packing individual UiPath projects",
24220
24220
  type: "module",
24221
24221
  main: "./dist/index.js",
@@ -25503,4 +25503,4 @@ export {
25503
25503
  signNupkgsAsync
25504
25504
  };
25505
25505
 
25506
- //# debugId=B7EB7D585C020E2A64756E2164756E21
25506
+ //# debugId=4DC18E9C22F61C4E64756E2164756E21
package/dist/node.js CHANGED
@@ -10977,7 +10977,165 @@ class FilterImplicitLimitError extends Error {
10977
10977
  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).";
10978
10978
  }
10979
10979
  }
10980
- function applyFilter(data, filter) {
10980
+ function countRecords(data) {
10981
+ if (Array.isArray(data))
10982
+ return data.length;
10983
+ return data == null ? 0 : 1;
10984
+ }
10985
+ function availableFields(data) {
10986
+ const records = Array.isArray(data) ? data : [data];
10987
+ const keys = new Set;
10988
+ for (const record of records) {
10989
+ if (record && typeof record === "object" && !Array.isArray(record)) {
10990
+ for (const key of Object.keys(record))
10991
+ keys.add(key);
10992
+ }
10993
+ }
10994
+ return [...keys];
10995
+ }
10996
+ function decodeQuotedIdentifier(whole, inner) {
10997
+ const [error, decoded] = catchError(() => JSON.parse(whole));
10998
+ if (!error && typeof decoded === "string")
10999
+ return decoded;
11000
+ return inner.replace(/\\(.)/g, "$1");
11001
+ }
11002
+ function referencedFields(filter) {
11003
+ const top = new Set;
11004
+ const nested = new Set;
11005
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
11006
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
11007
+ const quoted = [];
11008
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
11009
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
11010
+ if (!isAlias) {
11011
+ quoted.push({
11012
+ name: decodeQuotedIdentifier(whole, name),
11013
+ index,
11014
+ tail: isPathTail(withoutValueLiterals, index)
11015
+ });
11016
+ }
11017
+ return `"${" ".repeat(whole.length - 2)}"`;
11018
+ });
11019
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
11020
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
11021
+ const place = (name, index, tail) => {
11022
+ if (tail || index >= rootEnd)
11023
+ nested.add(name);
11024
+ else
11025
+ top.add(name);
11026
+ };
11027
+ for (const entry of quoted)
11028
+ place(entry.name, entry.index, entry.tail);
11029
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
11030
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
11031
+ for (const match of identifiers) {
11032
+ const [, name, trailing] = match;
11033
+ if (trailing || reserved.has(name))
11034
+ continue;
11035
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
11036
+ }
11037
+ return {
11038
+ top: [...top],
11039
+ nested: [...nested].filter((name) => !top.has(name)),
11040
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
11041
+ };
11042
+ }
11043
+ function appearsBelowTopLevel(data, name) {
11044
+ let budget = 2000;
11045
+ const visit = (value, depth) => {
11046
+ if (budget-- <= 0 || depth > 4)
11047
+ return false;
11048
+ if (value === null || typeof value !== "object")
11049
+ return false;
11050
+ if (Array.isArray(value))
11051
+ return value.some((entry) => visit(entry, depth));
11052
+ const record = value;
11053
+ if (depth > 0 && Object.hasOwn(record, name))
11054
+ return true;
11055
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
11056
+ };
11057
+ return visit(data, 0);
11058
+ }
11059
+ function alwaysNullKeys(records) {
11060
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
11061
+ if (objects.length === 0 || objects.length !== records.length)
11062
+ return [];
11063
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
11064
+ if (keys.length === 0)
11065
+ return [];
11066
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
11067
+ return nullKeys.length === keys.length ? nullKeys : [];
11068
+ }
11069
+ function carriesOnlyNulls(value) {
11070
+ if (value === null)
11071
+ return true;
11072
+ if (Array.isArray(value)) {
11073
+ return value.length > 0 && value.every(carriesOnlyNulls);
11074
+ }
11075
+ if (typeof value === "object" && value !== undefined) {
11076
+ const values = Object.values(value);
11077
+ return values.length > 0 && values.every(carriesOnlyNulls);
11078
+ }
11079
+ return false;
11080
+ }
11081
+ function nameList(names, cap2 = 12) {
11082
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
11083
+ const rest = names.length - shown.length;
11084
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
11085
+ }
11086
+ function buildFilterWarning(filter, data, outcome) {
11087
+ const present = availableFields(data);
11088
+ const refs = referencedFields(filter);
11089
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
11090
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
11091
+ const count = countRecords(data);
11092
+ const scope = `${count} record(s)`;
11093
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
11094
+ 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" : "";
11095
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
11096
+ let detail;
11097
+ let lede;
11098
+ if (outcome.kind === "null-elements") {
11099
+ lede = "returned only null values";
11100
+ const projected = `all ${outcome.count} of the elements it projected are null`;
11101
+ if (unknown.length > 0) {
11102
+ detail = `${projected}, because ${isNotAField(unknown)}`;
11103
+ } else if (unchecked.length > 0) {
11104
+ detail = withSoundness(projected);
11105
+ } else {
11106
+ 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`;
11107
+ }
11108
+ } else if (outcome.kind === "null-rows") {
11109
+ lede = "returned only null values";
11110
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
11111
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
11112
+ } else if (outcome.kind === "null-values") {
11113
+ lede = "returned only null values";
11114
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
11115
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
11116
+ if (sameSet) {
11117
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
11118
+ } else if (unknown.length > 0) {
11119
+ detail = `${projected}, because ${isNotAField(unknown)}`;
11120
+ } else {
11121
+ detail = withSoundness(`${projected} on all ${scope}`);
11122
+ }
11123
+ } else {
11124
+ lede = "returned nothing";
11125
+ if (unknown.length > 0) {
11126
+ detail = isNotAField(unknown);
11127
+ } else {
11128
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
11129
+ detail = withSoundness(`${selection} — it read ${scope}`);
11130
+ }
11131
+ }
11132
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
11133
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
11134
+ }
11135
+ function appendWarning(existing, note) {
11136
+ return existing ? `${existing} ${note}` : note;
11137
+ }
11138
+ function applyFilter(data, filter, onWarning) {
10981
11139
  const codec = requireJmespath();
10982
11140
  let result;
10983
11141
  try {
@@ -10985,9 +11143,34 @@ function applyFilter(data, filter) {
10985
11143
  } catch (err) {
10986
11144
  throw new FilterEvaluationError(filter, err);
10987
11145
  }
10988
- if (result == null)
11146
+ const inputCount = countRecords(data);
11147
+ const warn = (outcome) => {
11148
+ if (inputCount === 0)
11149
+ return;
11150
+ const note = buildFilterWarning(filter, data, outcome);
11151
+ getOutputSink().writeErr(`[WARN] ${note}
11152
+ `);
11153
+ onWarning?.(note);
11154
+ };
11155
+ const warnIfAllNull = (records) => {
11156
+ const keys = alwaysNullKeys(records);
11157
+ if (keys.length > 0)
11158
+ warn({ kind: "null-values", keys });
11159
+ };
11160
+ if (result == null) {
11161
+ warn({ kind: "empty" });
10989
11162
  return [];
11163
+ }
10990
11164
  if (Array.isArray(result)) {
11165
+ if (result.length === 0) {
11166
+ warn({ kind: "empty" });
11167
+ } else if (result.every((entry) => entry === null)) {
11168
+ warn({ kind: "null-elements", count: result.length });
11169
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
11170
+ warn({ kind: "null-rows", count: result.length });
11171
+ } else {
11172
+ warnIfAllNull(result);
11173
+ }
10991
11174
  if (result.length > 0 && typeof result[0] !== "object") {
10992
11175
  const fieldMatch = filter.match(/\.(\w+)$/);
10993
11176
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -10995,10 +11178,30 @@ function applyFilter(data, filter) {
10995
11178
  }
10996
11179
  return result;
10997
11180
  }
10998
- if (typeof result === "object")
11181
+ if (typeof result === "object") {
11182
+ warnIfAllNull([result]);
10999
11183
  return result;
11184
+ }
11000
11185
  return { Value: result };
11001
11186
  }
11187
+ function filterFailureData(envelope) {
11188
+ const filter = getOutputFilter();
11189
+ const data = envelope.Data;
11190
+ if (!filter || data == null)
11191
+ return;
11192
+ let note;
11193
+ const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
11194
+ note = n;
11195
+ }));
11196
+ if (filterError) {
11197
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
11198
+ return;
11199
+ }
11200
+ envelope.Data = filtered;
11201
+ if (note) {
11202
+ envelope.Warning = appendWarning(envelope.Warning, note);
11203
+ }
11204
+ }
11002
11205
  function defaultErrorCodeForResult(result) {
11003
11206
  switch (result) {
11004
11207
  case RESULTS.AuthenticationError:
@@ -11081,8 +11284,14 @@ var OutputFormatter;
11081
11284
  }
11082
11285
  const filter = getOutputFilter();
11083
11286
  if (filter) {
11084
- const filtered = applyFilter(data.Data, filter);
11287
+ let note;
11288
+ const filtered = applyFilter(data.Data, filter, (n) => {
11289
+ note = n;
11290
+ });
11085
11291
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
11292
+ if (note) {
11293
+ data.Warning = appendWarning(data.Warning, note);
11294
+ }
11086
11295
  }
11087
11296
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
11088
11297
  }
@@ -11110,6 +11319,7 @@ var OutputFormatter;
11110
11319
  delete envelope.TelemetryErrorClass;
11111
11320
  delete envelope.TelemetryTerminalOutcome;
11112
11321
  delete envelope.TelemetryTerminalSignal;
11322
+ filterFailureData(envelope);
11113
11323
  if (!suppressTelemetry) {
11114
11324
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
11115
11325
  result: data.Result,
@@ -11158,13 +11368,20 @@ var OutputFormatter;
11158
11368
  OutputFormatter2.log = log;
11159
11369
  function formatToString(data) {
11160
11370
  const filter = getOutputFilter();
11371
+ const envelope = data;
11161
11372
  if ("Data" in data && data.Data != null) {
11162
11373
  data.Data = normalizeDataKeys(data.Data);
11163
11374
  if (filter) {
11164
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
11375
+ let note;
11376
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
11377
+ note = n;
11378
+ }));
11379
+ if (note) {
11380
+ envelope.Warning = appendWarning(envelope.Warning, note);
11381
+ }
11165
11382
  }
11166
11383
  }
11167
- const output = normalizeOutputKeys(data);
11384
+ const output = normalizeOutputKeys(envelope);
11168
11385
  const lines = [];
11169
11386
  const sink = getOutputSink();
11170
11387
  printOutput(output, getOutputFormat(), (msg) => {
@@ -13288,7 +13505,7 @@ import { translate as translate9 } from "@uipath/solutionpackager-tool-core";
13288
13505
  var package_default = {
13289
13506
  name: "@uipath/project-packager",
13290
13507
  license: "SEE LICENSE IN LICENSE.txt",
13291
- version: "1.202.1-preview.220",
13508
+ version: "1.202.1-preview.238",
13292
13509
  description: "UiPath Project Packager - core library for packing individual UiPath projects",
13293
13510
  type: "module",
13294
13511
  main: "./dist/index.js",
@@ -13745,4 +13962,4 @@ export {
13745
13962
  signNupkgsAsync
13746
13963
  };
13747
13964
 
13748
- //# debugId=059195F7F52B332D64756E2164756E21
13965
+ //# debugId=932D3D345FF9A96B64756E2164756E21
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/project-packager",
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": "UiPath Project Packager - core library for packing individual UiPath projects",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
@@ -39,5 +39,5 @@
39
39
  "peerDependencies": {
40
40
  "fflate": "^0.8.2"
41
41
  },
42
- "gitHead": "a09041733b628c3f6b658a1f58349ea0f40bb492"
42
+ "gitHead": "537e43df1d3583633cfd3a0b88634f9ce3ba9d6b"
43
43
  }