@uipath/vertical-solutions-tool 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
@@ -3,7 +3,7 @@ import {
3
3
  Command,
4
4
  metadata,
5
5
  registerCommands
6
- } from "./tool-dzggec3b.js";
6
+ } from "./tool-sa5nqssd.js";
7
7
  import"./tool-mpvp5rqs.js";
8
8
  import"./tool-1yh8g550.js";
9
9
 
@@ -6864,7 +6864,7 @@ var require_src6 = __commonJS(function(exports) {
6864
6864
  var package_default = {
6865
6865
  name: "@uipath/vertical-solutions-tool",
6866
6866
  license: "SEE LICENSE IN LICENSE.txt",
6867
- version: "1.202.1-preview.220",
6867
+ version: "1.202.1-preview.238",
6868
6868
  description: "Scaffold and generate Vertical Solution projects.",
6869
6869
  private: false,
6870
6870
  repository: {
@@ -9214,7 +9214,165 @@ class FilterImplicitLimitError extends Error {
9214
9214
  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).";
9215
9215
  }
9216
9216
  }
9217
- function applyFilter(data, filter) {
9217
+ function countRecords(data) {
9218
+ if (Array.isArray(data))
9219
+ return data.length;
9220
+ return data == null ? 0 : 1;
9221
+ }
9222
+ function availableFields(data) {
9223
+ const records = Array.isArray(data) ? data : [data];
9224
+ const keys = new Set;
9225
+ for (const record of records) {
9226
+ if (record && typeof record === "object" && !Array.isArray(record)) {
9227
+ for (const key of Object.keys(record))
9228
+ keys.add(key);
9229
+ }
9230
+ }
9231
+ return [...keys];
9232
+ }
9233
+ function decodeQuotedIdentifier(whole, inner) {
9234
+ const [error, decoded] = catchError(() => JSON.parse(whole));
9235
+ if (!error && typeof decoded === "string")
9236
+ return decoded;
9237
+ return inner.replace(/\\(.)/g, "$1");
9238
+ }
9239
+ function referencedFields(filter) {
9240
+ const top = new Set;
9241
+ const nested = new Set;
9242
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
9243
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
9244
+ const quoted = [];
9245
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
9246
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
9247
+ if (!isAlias) {
9248
+ quoted.push({
9249
+ name: decodeQuotedIdentifier(whole, name),
9250
+ index,
9251
+ tail: isPathTail(withoutValueLiterals, index)
9252
+ });
9253
+ }
9254
+ return `"${" ".repeat(whole.length - 2)}"`;
9255
+ });
9256
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
9257
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
9258
+ const place = (name, index, tail) => {
9259
+ if (tail || index >= rootEnd)
9260
+ nested.add(name);
9261
+ else
9262
+ top.add(name);
9263
+ };
9264
+ for (const entry of quoted)
9265
+ place(entry.name, entry.index, entry.tail);
9266
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
9267
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
9268
+ for (const match of identifiers) {
9269
+ const [, name, trailing] = match;
9270
+ if (trailing || reserved.has(name))
9271
+ continue;
9272
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
9273
+ }
9274
+ return {
9275
+ top: [...top],
9276
+ nested: [...nested].filter((name) => !top.has(name)),
9277
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
9278
+ };
9279
+ }
9280
+ function appearsBelowTopLevel(data, name) {
9281
+ let budget = 2000;
9282
+ const visit = (value, depth) => {
9283
+ if (budget-- <= 0 || depth > 4)
9284
+ return false;
9285
+ if (value === null || typeof value !== "object")
9286
+ return false;
9287
+ if (Array.isArray(value))
9288
+ return value.some((entry) => visit(entry, depth));
9289
+ const record = value;
9290
+ if (depth > 0 && Object.hasOwn(record, name))
9291
+ return true;
9292
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
9293
+ };
9294
+ return visit(data, 0);
9295
+ }
9296
+ function alwaysNullKeys(records) {
9297
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
9298
+ if (objects.length === 0 || objects.length !== records.length)
9299
+ return [];
9300
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
9301
+ if (keys.length === 0)
9302
+ return [];
9303
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
9304
+ return nullKeys.length === keys.length ? nullKeys : [];
9305
+ }
9306
+ function carriesOnlyNulls(value) {
9307
+ if (value === null)
9308
+ return true;
9309
+ if (Array.isArray(value)) {
9310
+ return value.length > 0 && value.every(carriesOnlyNulls);
9311
+ }
9312
+ if (typeof value === "object" && value !== undefined) {
9313
+ const values = Object.values(value);
9314
+ return values.length > 0 && values.every(carriesOnlyNulls);
9315
+ }
9316
+ return false;
9317
+ }
9318
+ function nameList(names, cap2 = 12) {
9319
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
9320
+ const rest = names.length - shown.length;
9321
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
9322
+ }
9323
+ function buildFilterWarning(filter, data, outcome) {
9324
+ const present = availableFields(data);
9325
+ const refs = referencedFields(filter);
9326
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
9327
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
9328
+ const count = countRecords(data);
9329
+ const scope = `${count} record(s)`;
9330
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
9331
+ 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" : "";
9332
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
9333
+ let detail;
9334
+ let lede;
9335
+ if (outcome.kind === "null-elements") {
9336
+ lede = "returned only null values";
9337
+ const projected = `all ${outcome.count} of the elements it projected are null`;
9338
+ if (unknown.length > 0) {
9339
+ detail = `${projected}, because ${isNotAField(unknown)}`;
9340
+ } else if (unchecked.length > 0) {
9341
+ detail = withSoundness(projected);
9342
+ } else {
9343
+ 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`;
9344
+ }
9345
+ } else if (outcome.kind === "null-rows") {
9346
+ lede = "returned only null values";
9347
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
9348
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
9349
+ } else if (outcome.kind === "null-values") {
9350
+ lede = "returned only null values";
9351
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
9352
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
9353
+ if (sameSet) {
9354
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
9355
+ } else if (unknown.length > 0) {
9356
+ detail = `${projected}, because ${isNotAField(unknown)}`;
9357
+ } else {
9358
+ detail = withSoundness(`${projected} on all ${scope}`);
9359
+ }
9360
+ } else {
9361
+ lede = "returned nothing";
9362
+ if (unknown.length > 0) {
9363
+ detail = isNotAField(unknown);
9364
+ } else {
9365
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
9366
+ detail = withSoundness(`${selection} — it read ${scope}`);
9367
+ }
9368
+ }
9369
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
9370
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
9371
+ }
9372
+ function appendWarning(existing, note) {
9373
+ return existing ? `${existing} ${note}` : note;
9374
+ }
9375
+ function applyFilter(data, filter, onWarning) {
9218
9376
  const codec = requireJmespath();
9219
9377
  let result;
9220
9378
  try {
@@ -9222,9 +9380,34 @@ function applyFilter(data, filter) {
9222
9380
  } catch (err) {
9223
9381
  throw new FilterEvaluationError(filter, err);
9224
9382
  }
9225
- if (result == null)
9383
+ const inputCount = countRecords(data);
9384
+ const warn = (outcome) => {
9385
+ if (inputCount === 0)
9386
+ return;
9387
+ const note = buildFilterWarning(filter, data, outcome);
9388
+ getOutputSink().writeErr(`[WARN] ${note}
9389
+ `);
9390
+ onWarning?.(note);
9391
+ };
9392
+ const warnIfAllNull = (records) => {
9393
+ const keys = alwaysNullKeys(records);
9394
+ if (keys.length > 0)
9395
+ warn({ kind: "null-values", keys });
9396
+ };
9397
+ if (result == null) {
9398
+ warn({ kind: "empty" });
9226
9399
  return [];
9400
+ }
9227
9401
  if (Array.isArray(result)) {
9402
+ if (result.length === 0) {
9403
+ warn({ kind: "empty" });
9404
+ } else if (result.every((entry) => entry === null)) {
9405
+ warn({ kind: "null-elements", count: result.length });
9406
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
9407
+ warn({ kind: "null-rows", count: result.length });
9408
+ } else {
9409
+ warnIfAllNull(result);
9410
+ }
9228
9411
  if (result.length > 0 && typeof result[0] !== "object") {
9229
9412
  const fieldMatch = filter.match(/\.(\w+)$/);
9230
9413
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -9232,10 +9415,30 @@ function applyFilter(data, filter) {
9232
9415
  }
9233
9416
  return result;
9234
9417
  }
9235
- if (typeof result === "object")
9418
+ if (typeof result === "object") {
9419
+ warnIfAllNull([result]);
9236
9420
  return result;
9421
+ }
9237
9422
  return { Value: result };
9238
9423
  }
9424
+ function filterFailureData(envelope) {
9425
+ const filter = getOutputFilter();
9426
+ const data = envelope.Data;
9427
+ if (!filter || data == null)
9428
+ return;
9429
+ let note;
9430
+ const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
9431
+ note = n;
9432
+ }));
9433
+ if (filterError) {
9434
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
9435
+ return;
9436
+ }
9437
+ envelope.Data = filtered;
9438
+ if (note) {
9439
+ envelope.Warning = appendWarning(envelope.Warning, note);
9440
+ }
9441
+ }
9239
9442
  function defaultErrorCodeForResult(result) {
9240
9443
  switch (result) {
9241
9444
  case RESULTS.AuthenticationError:
@@ -9318,8 +9521,14 @@ var OutputFormatter;
9318
9521
  }
9319
9522
  const filter = getOutputFilter();
9320
9523
  if (filter) {
9321
- const filtered = applyFilter(data.Data, filter);
9524
+ let note;
9525
+ const filtered = applyFilter(data.Data, filter, (n) => {
9526
+ note = n;
9527
+ });
9322
9528
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
9529
+ if (note) {
9530
+ data.Warning = appendWarning(data.Warning, note);
9531
+ }
9323
9532
  }
9324
9533
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
9325
9534
  }
@@ -9347,6 +9556,7 @@ var OutputFormatter;
9347
9556
  delete envelope.TelemetryErrorClass;
9348
9557
  delete envelope.TelemetryTerminalOutcome;
9349
9558
  delete envelope.TelemetryTerminalSignal;
9559
+ filterFailureData(envelope);
9350
9560
  if (!suppressTelemetry) {
9351
9561
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
9352
9562
  result: data.Result,
@@ -9395,13 +9605,20 @@ var OutputFormatter;
9395
9605
  OutputFormatter.log = log;
9396
9606
  function formatToString(data) {
9397
9607
  const filter = getOutputFilter();
9608
+ const envelope = data;
9398
9609
  if ("Data" in data && data.Data != null) {
9399
9610
  data.Data = normalizeDataKeys(data.Data);
9400
9611
  if (filter) {
9401
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
9612
+ let note;
9613
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
9614
+ note = n;
9615
+ }));
9616
+ if (note) {
9617
+ envelope.Warning = appendWarning(envelope.Warning, note);
9618
+ }
9402
9619
  }
9403
9620
  }
9404
- const output = normalizeOutputKeys(data);
9621
+ const output = normalizeOutputKeys(envelope);
9405
9622
  const lines = [];
9406
9623
  const sink = getOutputSink();
9407
9624
  printOutput(output, getOutputFormat(), (msg) => {
@@ -44317,4 +44534,4 @@ var registerCommands = async (program2) => {
44317
44534
 
44318
44535
  export { Command, metadata, registerCommands };
44319
44536
 
44320
- //# debugId=B28D7BC12629E35B64756E2164756E21
44537
+ //# debugId=79827E078D6FFB5A64756E2164756E21
package/dist/tool.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-dzggec3b.js";
4
+ } from "./tool-sa5nqssd.js";
5
5
  import"./tool-mpvp5rqs.js";
6
6
  import"./tool-1yh8g550.js";
7
7
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/vertical-solutions-tool",
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": "Scaffold and generate Vertical Solution projects.",
6
6
  "private": false,
7
7
  "repository": {
@@ -34,5 +34,5 @@
34
34
  "files": [
35
35
  "dist"
36
36
  ],
37
- "gitHead": "a09041733b628c3f6b658a1f58349ea0f40bb492"
37
+ "gitHead": "537e43df1d3583633cfd3a0b88634f9ce3ba9d6b"
38
38
  }