@uipath/model-hub-tool 1.202.1-preview.220 → 1.202.1-preview.239

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-qxdm1sfm.js";
6
+ } from "./tool-cvnzjz9g.js";
7
7
  import"./tool-1de529jm.js";
8
8
 
9
9
  // src/index.ts
@@ -2100,7 +2100,7 @@ var require_commander = __commonJS(function(exports) {
2100
2100
  var package_default = {
2101
2101
  name: "@uipath/model-hub-tool",
2102
2102
  license: "SEE LICENSE IN LICENSE.txt",
2103
- version: "1.202.1-preview.220",
2103
+ version: "1.202.1-preview.239",
2104
2104
  description: "CLI plugin for the UiPath Model Hub (LLM Gateway organization-scoped views).",
2105
2105
  private: false,
2106
2106
  repository: {
@@ -4790,7 +4790,165 @@ class FilterImplicitLimitError extends Error {
4790
4790
  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).";
4791
4791
  }
4792
4792
  }
4793
- function applyFilter(data, filter) {
4793
+ function countRecords(data) {
4794
+ if (Array.isArray(data))
4795
+ return data.length;
4796
+ return data == null ? 0 : 1;
4797
+ }
4798
+ function availableFields(data) {
4799
+ const records = Array.isArray(data) ? data : [data];
4800
+ const keys = new Set;
4801
+ for (const record of records) {
4802
+ if (record && typeof record === "object" && !Array.isArray(record)) {
4803
+ for (const key of Object.keys(record))
4804
+ keys.add(key);
4805
+ }
4806
+ }
4807
+ return [...keys];
4808
+ }
4809
+ function decodeQuotedIdentifier(whole, inner) {
4810
+ const [error, decoded] = catchError(() => JSON.parse(whole));
4811
+ if (!error && typeof decoded === "string")
4812
+ return decoded;
4813
+ return inner.replace(/\\(.)/g, "$1");
4814
+ }
4815
+ function referencedFields(filter) {
4816
+ const top = new Set;
4817
+ const nested = new Set;
4818
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
4819
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
4820
+ const quoted = [];
4821
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
4822
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
4823
+ if (!isAlias) {
4824
+ quoted.push({
4825
+ name: decodeQuotedIdentifier(whole, name),
4826
+ index,
4827
+ tail: isPathTail(withoutValueLiterals, index)
4828
+ });
4829
+ }
4830
+ return `"${" ".repeat(whole.length - 2)}"`;
4831
+ });
4832
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
4833
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
4834
+ const place = (name, index, tail) => {
4835
+ if (tail || index >= rootEnd)
4836
+ nested.add(name);
4837
+ else
4838
+ top.add(name);
4839
+ };
4840
+ for (const entry of quoted)
4841
+ place(entry.name, entry.index, entry.tail);
4842
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
4843
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
4844
+ for (const match of identifiers) {
4845
+ const [, name, trailing] = match;
4846
+ if (trailing || reserved.has(name))
4847
+ continue;
4848
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
4849
+ }
4850
+ return {
4851
+ top: [...top],
4852
+ nested: [...nested].filter((name) => !top.has(name)),
4853
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
4854
+ };
4855
+ }
4856
+ function appearsBelowTopLevel(data, name) {
4857
+ let budget = 2000;
4858
+ const visit = (value, depth) => {
4859
+ if (budget-- <= 0 || depth > 4)
4860
+ return false;
4861
+ if (value === null || typeof value !== "object")
4862
+ return false;
4863
+ if (Array.isArray(value))
4864
+ return value.some((entry) => visit(entry, depth));
4865
+ const record = value;
4866
+ if (depth > 0 && Object.hasOwn(record, name))
4867
+ return true;
4868
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
4869
+ };
4870
+ return visit(data, 0);
4871
+ }
4872
+ function alwaysNullKeys(records) {
4873
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
4874
+ if (objects.length === 0 || objects.length !== records.length)
4875
+ return [];
4876
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
4877
+ if (keys.length === 0)
4878
+ return [];
4879
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
4880
+ return nullKeys.length === keys.length ? nullKeys : [];
4881
+ }
4882
+ function carriesOnlyNulls(value) {
4883
+ if (value === null)
4884
+ return true;
4885
+ if (Array.isArray(value)) {
4886
+ return value.length > 0 && value.every(carriesOnlyNulls);
4887
+ }
4888
+ if (typeof value === "object" && value !== undefined) {
4889
+ const values = Object.values(value);
4890
+ return values.length > 0 && values.every(carriesOnlyNulls);
4891
+ }
4892
+ return false;
4893
+ }
4894
+ function nameList(names, cap2 = 12) {
4895
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
4896
+ const rest = names.length - shown.length;
4897
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
4898
+ }
4899
+ function buildFilterWarning(filter, data, outcome) {
4900
+ const present = availableFields(data);
4901
+ const refs = referencedFields(filter);
4902
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
4903
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
4904
+ const count = countRecords(data);
4905
+ const scope = `${count} record(s)`;
4906
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
4907
+ 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" : "";
4908
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
4909
+ let detail;
4910
+ let lede;
4911
+ if (outcome.kind === "null-elements") {
4912
+ lede = "returned only null values";
4913
+ const projected = `all ${outcome.count} of the elements it projected are null`;
4914
+ if (unknown.length > 0) {
4915
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4916
+ } else if (unchecked.length > 0) {
4917
+ detail = withSoundness(projected);
4918
+ } else {
4919
+ 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`;
4920
+ }
4921
+ } else if (outcome.kind === "null-rows") {
4922
+ lede = "returned only null values";
4923
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
4924
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
4925
+ } else if (outcome.kind === "null-values") {
4926
+ lede = "returned only null values";
4927
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
4928
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
4929
+ if (sameSet) {
4930
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
4931
+ } else if (unknown.length > 0) {
4932
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4933
+ } else {
4934
+ detail = withSoundness(`${projected} on all ${scope}`);
4935
+ }
4936
+ } else {
4937
+ lede = "returned nothing";
4938
+ if (unknown.length > 0) {
4939
+ detail = isNotAField(unknown);
4940
+ } else {
4941
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
4942
+ detail = withSoundness(`${selection} — it read ${scope}`);
4943
+ }
4944
+ }
4945
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
4946
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
4947
+ }
4948
+ function appendWarning(existing, note) {
4949
+ return existing ? `${existing} ${note}` : note;
4950
+ }
4951
+ function applyFilter(data, filter, onWarning) {
4794
4952
  const codec = requireJmespath();
4795
4953
  let result;
4796
4954
  try {
@@ -4798,9 +4956,34 @@ function applyFilter(data, filter) {
4798
4956
  } catch (err) {
4799
4957
  throw new FilterEvaluationError(filter, err);
4800
4958
  }
4801
- if (result == null)
4959
+ const inputCount = countRecords(data);
4960
+ const warn = (outcome) => {
4961
+ if (inputCount === 0)
4962
+ return;
4963
+ const note = buildFilterWarning(filter, data, outcome);
4964
+ getOutputSink().writeErr(`[WARN] ${note}
4965
+ `);
4966
+ onWarning?.(note);
4967
+ };
4968
+ const warnIfAllNull = (records) => {
4969
+ const keys = alwaysNullKeys(records);
4970
+ if (keys.length > 0)
4971
+ warn({ kind: "null-values", keys });
4972
+ };
4973
+ if (result == null) {
4974
+ warn({ kind: "empty" });
4802
4975
  return [];
4976
+ }
4803
4977
  if (Array.isArray(result)) {
4978
+ if (result.length === 0) {
4979
+ warn({ kind: "empty" });
4980
+ } else if (result.every((entry) => entry === null)) {
4981
+ warn({ kind: "null-elements", count: result.length });
4982
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
4983
+ warn({ kind: "null-rows", count: result.length });
4984
+ } else {
4985
+ warnIfAllNull(result);
4986
+ }
4804
4987
  if (result.length > 0 && typeof result[0] !== "object") {
4805
4988
  const fieldMatch = filter.match(/\.(\w+)$/);
4806
4989
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -4808,10 +4991,30 @@ function applyFilter(data, filter) {
4808
4991
  }
4809
4992
  return result;
4810
4993
  }
4811
- if (typeof result === "object")
4994
+ if (typeof result === "object") {
4995
+ warnIfAllNull([result]);
4812
4996
  return result;
4997
+ }
4813
4998
  return { Value: result };
4814
4999
  }
5000
+ function filterFailureData(envelope) {
5001
+ const filter = getOutputFilter();
5002
+ const data = envelope.Data;
5003
+ if (!filter || data == null)
5004
+ return;
5005
+ let note;
5006
+ const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
5007
+ note = n;
5008
+ }));
5009
+ if (filterError) {
5010
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
5011
+ return;
5012
+ }
5013
+ envelope.Data = filtered;
5014
+ if (note) {
5015
+ envelope.Warning = appendWarning(envelope.Warning, note);
5016
+ }
5017
+ }
4815
5018
  function defaultErrorCodeForResult(result) {
4816
5019
  switch (result) {
4817
5020
  case RESULTS.AuthenticationError:
@@ -4894,8 +5097,14 @@ var OutputFormatter;
4894
5097
  }
4895
5098
  const filter = getOutputFilter();
4896
5099
  if (filter) {
4897
- const filtered = applyFilter(data.Data, filter);
5100
+ let note;
5101
+ const filtered = applyFilter(data.Data, filter, (n) => {
5102
+ note = n;
5103
+ });
4898
5104
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
5105
+ if (note) {
5106
+ data.Warning = appendWarning(data.Warning, note);
5107
+ }
4899
5108
  }
4900
5109
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
4901
5110
  }
@@ -4923,6 +5132,7 @@ var OutputFormatter;
4923
5132
  delete envelope.TelemetryErrorClass;
4924
5133
  delete envelope.TelemetryTerminalOutcome;
4925
5134
  delete envelope.TelemetryTerminalSignal;
5135
+ filterFailureData(envelope);
4926
5136
  if (!suppressTelemetry) {
4927
5137
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
4928
5138
  result: data.Result,
@@ -4971,13 +5181,20 @@ var OutputFormatter;
4971
5181
  OutputFormatter.log = log;
4972
5182
  function formatToString(data) {
4973
5183
  const filter = getOutputFilter();
5184
+ const envelope = data;
4974
5185
  if ("Data" in data && data.Data != null) {
4975
5186
  data.Data = normalizeDataKeys(data.Data);
4976
5187
  if (filter) {
4977
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
5188
+ let note;
5189
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
5190
+ note = n;
5191
+ }));
5192
+ if (note) {
5193
+ envelope.Warning = appendWarning(envelope.Warning, note);
5194
+ }
4978
5195
  }
4979
5196
  }
4980
- const output = normalizeOutputKeys(data);
5197
+ const output = normalizeOutputKeys(envelope);
4981
5198
  const lines = [];
4982
5199
  const sink = getOutputSink();
4983
5200
  printOutput(output, getOutputFormat(), (msg) => {
@@ -8519,4 +8736,4 @@ var registerCommands = async (program2) => {
8519
8736
 
8520
8737
  export { Command, metadata, registerCommands };
8521
8738
 
8522
- //# debugId=99E7ECAA737471E664756E2164756E21
8739
+ //# debugId=0E52E06AA216D83264756E2164756E21
package/dist/tool.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-qxdm1sfm.js";
4
+ } from "./tool-cvnzjz9g.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/model-hub-tool",
3
3
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "1.202.1-preview.220",
4
+ "version": "1.202.1-preview.239",
5
5
  "description": "CLI plugin for the UiPath Model Hub (LLM Gateway organization-scoped views).",
6
6
  "private": false,
7
7
  "repository": {
@@ -26,5 +26,5 @@
26
26
  "files": [
27
27
  "dist"
28
28
  ],
29
- "gitHead": "a09041733b628c3f6b658a1f58349ea0f40bb492"
29
+ "gitHead": "97545a7857bdff7e6db62bbe13c6097607cf38f1"
30
30
  }