@uipath/platform-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.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Command,
4
4
  metadata,
5
5
  registerCommands
6
- } from "./tool-5ms531bq.js";
6
+ } from "./tool-j5khq8fv.js";
7
7
  import"./tool-1de529jm.js";
8
8
 
9
9
  // src/index.ts
@@ -27336,7 +27336,7 @@ var require_dist2 = __commonJS(function(exports) {
27336
27336
  var package_default = {
27337
27337
  name: "@uipath/platform-tool",
27338
27338
  license: "SEE LICENSE IN LICENSE.txt",
27339
- version: "1.202.1-preview.217",
27339
+ version: "1.202.1-preview.238",
27340
27340
  description: "Manage UiPath platform-level resources such as tenant licensing.",
27341
27341
  publishConfig: {
27342
27342
  registry: "https://npm.pkg.github.com/"
@@ -31435,7 +31435,165 @@ class FilterImplicitLimitError extends Error {
31435
31435
  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).";
31436
31436
  }
31437
31437
  }
31438
- function applyFilter(data, filter) {
31438
+ function countRecords(data) {
31439
+ if (Array.isArray(data))
31440
+ return data.length;
31441
+ return data == null ? 0 : 1;
31442
+ }
31443
+ function availableFields(data) {
31444
+ const records = Array.isArray(data) ? data : [data];
31445
+ const keys = new Set;
31446
+ for (const record of records) {
31447
+ if (record && typeof record === "object" && !Array.isArray(record)) {
31448
+ for (const key of Object.keys(record))
31449
+ keys.add(key);
31450
+ }
31451
+ }
31452
+ return [...keys];
31453
+ }
31454
+ function decodeQuotedIdentifier(whole, inner) {
31455
+ const [error, decoded] = catchError2(() => JSON.parse(whole));
31456
+ if (!error && typeof decoded === "string")
31457
+ return decoded;
31458
+ return inner.replace(/\\(.)/g, "$1");
31459
+ }
31460
+ function referencedFields(filter) {
31461
+ const top = new Set;
31462
+ const nested = new Set;
31463
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
31464
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
31465
+ const quoted = [];
31466
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
31467
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
31468
+ if (!isAlias) {
31469
+ quoted.push({
31470
+ name: decodeQuotedIdentifier(whole, name),
31471
+ index,
31472
+ tail: isPathTail(withoutValueLiterals, index)
31473
+ });
31474
+ }
31475
+ return `"${" ".repeat(whole.length - 2)}"`;
31476
+ });
31477
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
31478
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
31479
+ const place = (name, index, tail) => {
31480
+ if (tail || index >= rootEnd)
31481
+ nested.add(name);
31482
+ else
31483
+ top.add(name);
31484
+ };
31485
+ for (const entry of quoted)
31486
+ place(entry.name, entry.index, entry.tail);
31487
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
31488
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
31489
+ for (const match of identifiers) {
31490
+ const [, name, trailing] = match;
31491
+ if (trailing || reserved.has(name))
31492
+ continue;
31493
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
31494
+ }
31495
+ return {
31496
+ top: [...top],
31497
+ nested: [...nested].filter((name) => !top.has(name)),
31498
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
31499
+ };
31500
+ }
31501
+ function appearsBelowTopLevel(data, name) {
31502
+ let budget = 2000;
31503
+ const visit = (value, depth) => {
31504
+ if (budget-- <= 0 || depth > 4)
31505
+ return false;
31506
+ if (value === null || typeof value !== "object")
31507
+ return false;
31508
+ if (Array.isArray(value))
31509
+ return value.some((entry) => visit(entry, depth));
31510
+ const record = value;
31511
+ if (depth > 0 && Object.hasOwn(record, name))
31512
+ return true;
31513
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
31514
+ };
31515
+ return visit(data, 0);
31516
+ }
31517
+ function alwaysNullKeys(records) {
31518
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
31519
+ if (objects.length === 0 || objects.length !== records.length)
31520
+ return [];
31521
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
31522
+ if (keys.length === 0)
31523
+ return [];
31524
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
31525
+ return nullKeys.length === keys.length ? nullKeys : [];
31526
+ }
31527
+ function carriesOnlyNulls(value) {
31528
+ if (value === null)
31529
+ return true;
31530
+ if (Array.isArray(value)) {
31531
+ return value.length > 0 && value.every(carriesOnlyNulls);
31532
+ }
31533
+ if (typeof value === "object" && value !== undefined) {
31534
+ const values = Object.values(value);
31535
+ return values.length > 0 && values.every(carriesOnlyNulls);
31536
+ }
31537
+ return false;
31538
+ }
31539
+ function nameList(names, cap2 = 12) {
31540
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
31541
+ const rest = names.length - shown.length;
31542
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
31543
+ }
31544
+ function buildFilterWarning(filter, data, outcome) {
31545
+ const present = availableFields(data);
31546
+ const refs = referencedFields(filter);
31547
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
31548
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
31549
+ const count = countRecords(data);
31550
+ const scope = `${count} record(s)`;
31551
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
31552
+ 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" : "";
31553
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
31554
+ let detail;
31555
+ let lede;
31556
+ if (outcome.kind === "null-elements") {
31557
+ lede = "returned only null values";
31558
+ const projected = `all ${outcome.count} of the elements it projected are null`;
31559
+ if (unknown.length > 0) {
31560
+ detail = `${projected}, because ${isNotAField(unknown)}`;
31561
+ } else if (unchecked.length > 0) {
31562
+ detail = withSoundness(projected);
31563
+ } else {
31564
+ 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`;
31565
+ }
31566
+ } else if (outcome.kind === "null-rows") {
31567
+ lede = "returned only null values";
31568
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
31569
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
31570
+ } else if (outcome.kind === "null-values") {
31571
+ lede = "returned only null values";
31572
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
31573
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
31574
+ if (sameSet) {
31575
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
31576
+ } else if (unknown.length > 0) {
31577
+ detail = `${projected}, because ${isNotAField(unknown)}`;
31578
+ } else {
31579
+ detail = withSoundness(`${projected} on all ${scope}`);
31580
+ }
31581
+ } else {
31582
+ lede = "returned nothing";
31583
+ if (unknown.length > 0) {
31584
+ detail = isNotAField(unknown);
31585
+ } else {
31586
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
31587
+ detail = withSoundness(`${selection} — it read ${scope}`);
31588
+ }
31589
+ }
31590
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
31591
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
31592
+ }
31593
+ function appendWarning(existing, note) {
31594
+ return existing ? `${existing} ${note}` : note;
31595
+ }
31596
+ function applyFilter(data, filter, onWarning) {
31439
31597
  const codec = requireJmespath();
31440
31598
  let result;
31441
31599
  try {
@@ -31443,9 +31601,34 @@ function applyFilter(data, filter) {
31443
31601
  } catch (err) {
31444
31602
  throw new FilterEvaluationError(filter, err);
31445
31603
  }
31446
- if (result == null)
31604
+ const inputCount = countRecords(data);
31605
+ const warn = (outcome) => {
31606
+ if (inputCount === 0)
31607
+ return;
31608
+ const note = buildFilterWarning(filter, data, outcome);
31609
+ getOutputSink().writeErr(`[WARN] ${note}
31610
+ `);
31611
+ onWarning?.(note);
31612
+ };
31613
+ const warnIfAllNull = (records) => {
31614
+ const keys = alwaysNullKeys(records);
31615
+ if (keys.length > 0)
31616
+ warn({ kind: "null-values", keys });
31617
+ };
31618
+ if (result == null) {
31619
+ warn({ kind: "empty" });
31447
31620
  return [];
31621
+ }
31448
31622
  if (Array.isArray(result)) {
31623
+ if (result.length === 0) {
31624
+ warn({ kind: "empty" });
31625
+ } else if (result.every((entry) => entry === null)) {
31626
+ warn({ kind: "null-elements", count: result.length });
31627
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
31628
+ warn({ kind: "null-rows", count: result.length });
31629
+ } else {
31630
+ warnIfAllNull(result);
31631
+ }
31449
31632
  if (result.length > 0 && typeof result[0] !== "object") {
31450
31633
  const fieldMatch = filter.match(/\.(\w+)$/);
31451
31634
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -31453,10 +31636,30 @@ function applyFilter(data, filter) {
31453
31636
  }
31454
31637
  return result;
31455
31638
  }
31456
- if (typeof result === "object")
31639
+ if (typeof result === "object") {
31640
+ warnIfAllNull([result]);
31457
31641
  return result;
31642
+ }
31458
31643
  return { Value: result };
31459
31644
  }
31645
+ function filterFailureData(envelope) {
31646
+ const filter = getOutputFilter();
31647
+ const data = envelope.Data;
31648
+ if (!filter || data == null)
31649
+ return;
31650
+ let note;
31651
+ const [filterError, filtered] = catchError2(() => applyFilter(data, filter, (n) => {
31652
+ note = n;
31653
+ }));
31654
+ if (filterError) {
31655
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
31656
+ return;
31657
+ }
31658
+ envelope.Data = filtered;
31659
+ if (note) {
31660
+ envelope.Warning = appendWarning(envelope.Warning, note);
31661
+ }
31662
+ }
31460
31663
  function defaultErrorCodeForResult(result) {
31461
31664
  switch (result) {
31462
31665
  case RESULTS.AuthenticationError:
@@ -31539,8 +31742,14 @@ var OutputFormatter;
31539
31742
  }
31540
31743
  const filter = getOutputFilter();
31541
31744
  if (filter) {
31542
- const filtered = applyFilter(data.Data, filter);
31745
+ let note;
31746
+ const filtered = applyFilter(data.Data, filter, (n) => {
31747
+ note = n;
31748
+ });
31543
31749
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
31750
+ if (note) {
31751
+ data.Warning = appendWarning(data.Warning, note);
31752
+ }
31544
31753
  }
31545
31754
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
31546
31755
  }
@@ -31568,6 +31777,7 @@ var OutputFormatter;
31568
31777
  delete envelope.TelemetryErrorClass;
31569
31778
  delete envelope.TelemetryTerminalOutcome;
31570
31779
  delete envelope.TelemetryTerminalSignal;
31780
+ filterFailureData(envelope);
31571
31781
  if (!suppressTelemetry) {
31572
31782
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
31573
31783
  result: data.Result,
@@ -31616,13 +31826,20 @@ var OutputFormatter;
31616
31826
  OutputFormatter.log = log;
31617
31827
  function formatToString(data) {
31618
31828
  const filter = getOutputFilter();
31829
+ const envelope = data;
31619
31830
  if ("Data" in data && data.Data != null) {
31620
31831
  data.Data = normalizeDataKeys(data.Data);
31621
31832
  if (filter) {
31622
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
31833
+ let note;
31834
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
31835
+ note = n;
31836
+ }));
31837
+ if (note) {
31838
+ envelope.Warning = appendWarning(envelope.Warning, note);
31839
+ }
31623
31840
  }
31624
31841
  }
31625
- const output = normalizeOutputKeys(data);
31842
+ const output = normalizeOutputKeys(envelope);
31626
31843
  const lines = [];
31627
31844
  const sink = getOutputSink();
31628
31845
  printOutput(output, getOutputFormat(), (msg) => {
@@ -36404,4 +36621,4 @@ var registerCommands = async (program2) => {
36404
36621
 
36405
36622
  export { Command, metadata, registerCommands };
36406
36623
 
36407
- //# debugId=30DBCCC8914E1D0864756E2164756E21
36624
+ //# debugId=038E87CD62F2DE4264756E2164756E21
package/dist/tool.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-5ms531bq.js";
4
+ } from "./tool-j5khq8fv.js";
5
5
  import"./tool-1de529jm.js";
6
6
  export {
7
7
  metadata,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/platform-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": "Manage UiPath platform-level resources such as tenant licensing.",
6
6
  "publishConfig": {
7
7
  "registry": "https://registry.npmjs.org/"
@@ -20,5 +20,5 @@
20
20
  "keywords": [
21
21
  "cli-tool"
22
22
  ],
23
- "gitHead": "bd513110d03342230901ece289a303e5a0009404"
23
+ "gitHead": "537e43df1d3583633cfd3a0b88634f9ce3ba9d6b"
24
24
  }