@uipath/model-hub-tool 1.203.0-preview.235 → 1.203.0-preview.237
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 +1 -1
- package/dist/{tool-75amjjbn.js → tool-84rx7zq8.js} +225 -8
- package/dist/tool.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2101,7 +2101,7 @@ var package_default = {
|
|
|
2101
2101
|
name: "@uipath/model-hub-tool",
|
|
2102
2102
|
author: "UiPath",
|
|
2103
2103
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
2104
|
-
version: "1.203.0-preview.
|
|
2104
|
+
version: "1.203.0-preview.237",
|
|
2105
2105
|
description: "CLI plugin for the UiPath Model Hub (LLM Gateway organization-scoped views).",
|
|
2106
2106
|
private: false,
|
|
2107
2107
|
repository: {
|
|
@@ -5037,7 +5037,165 @@ class FilterImplicitLimitError extends Error {
|
|
|
5037
5037
|
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).";
|
|
5038
5038
|
}
|
|
5039
5039
|
}
|
|
5040
|
-
function
|
|
5040
|
+
function countRecords(data) {
|
|
5041
|
+
if (Array.isArray(data))
|
|
5042
|
+
return data.length;
|
|
5043
|
+
return data == null ? 0 : 1;
|
|
5044
|
+
}
|
|
5045
|
+
function availableFields(data) {
|
|
5046
|
+
const records = Array.isArray(data) ? data : [data];
|
|
5047
|
+
const keys = new Set;
|
|
5048
|
+
for (const record of records) {
|
|
5049
|
+
if (record && typeof record === "object" && !Array.isArray(record)) {
|
|
5050
|
+
for (const key of Object.keys(record))
|
|
5051
|
+
keys.add(key);
|
|
5052
|
+
}
|
|
5053
|
+
}
|
|
5054
|
+
return [...keys];
|
|
5055
|
+
}
|
|
5056
|
+
function decodeQuotedIdentifier(whole, inner) {
|
|
5057
|
+
const [error, decoded] = catchError(() => JSON.parse(whole));
|
|
5058
|
+
if (!error && typeof decoded === "string")
|
|
5059
|
+
return decoded;
|
|
5060
|
+
return inner.replace(/\\(.)/g, "$1");
|
|
5061
|
+
}
|
|
5062
|
+
function referencedFields(filter) {
|
|
5063
|
+
const top = new Set;
|
|
5064
|
+
const nested = new Set;
|
|
5065
|
+
const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
|
|
5066
|
+
const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
|
|
5067
|
+
const quoted = [];
|
|
5068
|
+
const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
|
|
5069
|
+
const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
|
|
5070
|
+
if (!isAlias) {
|
|
5071
|
+
quoted.push({
|
|
5072
|
+
name: decodeQuotedIdentifier(whole, name),
|
|
5073
|
+
index,
|
|
5074
|
+
tail: isPathTail(withoutValueLiterals, index)
|
|
5075
|
+
});
|
|
5076
|
+
}
|
|
5077
|
+
return `"${" ".repeat(whole.length - 2)}"`;
|
|
5078
|
+
});
|
|
5079
|
+
const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
|
|
5080
|
+
const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
|
|
5081
|
+
const place = (name, index, tail) => {
|
|
5082
|
+
if (tail || index >= rootEnd)
|
|
5083
|
+
nested.add(name);
|
|
5084
|
+
else
|
|
5085
|
+
top.add(name);
|
|
5086
|
+
};
|
|
5087
|
+
for (const entry of quoted)
|
|
5088
|
+
place(entry.name, entry.index, entry.tail);
|
|
5089
|
+
const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
|
|
5090
|
+
const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
|
|
5091
|
+
for (const match of identifiers) {
|
|
5092
|
+
const [, name, trailing] = match;
|
|
5093
|
+
if (trailing || reserved.has(name))
|
|
5094
|
+
continue;
|
|
5095
|
+
place(name, match.index, isPathTail(withoutLiterals, match.index));
|
|
5096
|
+
}
|
|
5097
|
+
return {
|
|
5098
|
+
top: [...top],
|
|
5099
|
+
nested: [...nested].filter((name) => !top.has(name)),
|
|
5100
|
+
hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
|
|
5101
|
+
};
|
|
5102
|
+
}
|
|
5103
|
+
function appearsBelowTopLevel(data, name) {
|
|
5104
|
+
let budget = 2000;
|
|
5105
|
+
const visit = (value, depth) => {
|
|
5106
|
+
if (budget-- <= 0 || depth > 4)
|
|
5107
|
+
return false;
|
|
5108
|
+
if (value === null || typeof value !== "object")
|
|
5109
|
+
return false;
|
|
5110
|
+
if (Array.isArray(value))
|
|
5111
|
+
return value.some((entry) => visit(entry, depth));
|
|
5112
|
+
const record = value;
|
|
5113
|
+
if (depth > 0 && Object.hasOwn(record, name))
|
|
5114
|
+
return true;
|
|
5115
|
+
return Object.values(record).some((entry) => visit(entry, depth + 1));
|
|
5116
|
+
};
|
|
5117
|
+
return visit(data, 0);
|
|
5118
|
+
}
|
|
5119
|
+
function alwaysNullKeys(records) {
|
|
5120
|
+
const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
|
|
5121
|
+
if (objects.length === 0 || objects.length !== records.length)
|
|
5122
|
+
return [];
|
|
5123
|
+
const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
|
|
5124
|
+
if (keys.length === 0)
|
|
5125
|
+
return [];
|
|
5126
|
+
const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
|
|
5127
|
+
return nullKeys.length === keys.length ? nullKeys : [];
|
|
5128
|
+
}
|
|
5129
|
+
function carriesOnlyNulls(value) {
|
|
5130
|
+
if (value === null)
|
|
5131
|
+
return true;
|
|
5132
|
+
if (Array.isArray(value)) {
|
|
5133
|
+
return value.length > 0 && value.every(carriesOnlyNulls);
|
|
5134
|
+
}
|
|
5135
|
+
if (typeof value === "object" && value !== undefined) {
|
|
5136
|
+
const values = Object.values(value);
|
|
5137
|
+
return values.length > 0 && values.every(carriesOnlyNulls);
|
|
5138
|
+
}
|
|
5139
|
+
return false;
|
|
5140
|
+
}
|
|
5141
|
+
function nameList(names, cap2 = 12) {
|
|
5142
|
+
const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
|
|
5143
|
+
const rest = names.length - shown.length;
|
|
5144
|
+
return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
|
|
5145
|
+
}
|
|
5146
|
+
function buildFilterWarning(filter, data, outcome) {
|
|
5147
|
+
const present = availableFields(data);
|
|
5148
|
+
const refs = referencedFields(filter);
|
|
5149
|
+
const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
|
|
5150
|
+
const unchecked = refs.nested.filter((name) => !present.includes(name));
|
|
5151
|
+
const count = countRecords(data);
|
|
5152
|
+
const scope = `${count} record(s)`;
|
|
5153
|
+
const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
|
|
5154
|
+
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" : "";
|
|
5155
|
+
const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
|
|
5156
|
+
let detail;
|
|
5157
|
+
let lede;
|
|
5158
|
+
if (outcome.kind === "null-elements") {
|
|
5159
|
+
lede = "returned only null values";
|
|
5160
|
+
const projected = `all ${outcome.count} of the elements it projected are null`;
|
|
5161
|
+
if (unknown.length > 0) {
|
|
5162
|
+
detail = `${projected}, because ${isNotAField(unknown)}`;
|
|
5163
|
+
} else if (unchecked.length > 0) {
|
|
5164
|
+
detail = withSoundness(projected);
|
|
5165
|
+
} else {
|
|
5166
|
+
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`;
|
|
5167
|
+
}
|
|
5168
|
+
} else if (outcome.kind === "null-rows") {
|
|
5169
|
+
lede = "returned only null values";
|
|
5170
|
+
const projected = `every value it projected is null on all ${outcome.count} row(s)`;
|
|
5171
|
+
detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
|
|
5172
|
+
} else if (outcome.kind === "null-values") {
|
|
5173
|
+
lede = "returned only null values";
|
|
5174
|
+
const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
|
|
5175
|
+
const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
|
|
5176
|
+
if (sameSet) {
|
|
5177
|
+
detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
|
|
5178
|
+
} else if (unknown.length > 0) {
|
|
5179
|
+
detail = `${projected}, because ${isNotAField(unknown)}`;
|
|
5180
|
+
} else {
|
|
5181
|
+
detail = withSoundness(`${projected} on all ${scope}`);
|
|
5182
|
+
}
|
|
5183
|
+
} else {
|
|
5184
|
+
lede = "returned nothing";
|
|
5185
|
+
if (unknown.length > 0) {
|
|
5186
|
+
detail = isNotAField(unknown);
|
|
5187
|
+
} else {
|
|
5188
|
+
const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
|
|
5189
|
+
detail = withSoundness(`${selection} — it read ${scope}`);
|
|
5190
|
+
}
|
|
5191
|
+
}
|
|
5192
|
+
const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
|
|
5193
|
+
return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
|
|
5194
|
+
}
|
|
5195
|
+
function appendWarning(existing, note) {
|
|
5196
|
+
return existing ? `${existing} ${note}` : note;
|
|
5197
|
+
}
|
|
5198
|
+
function applyFilter(data, filter, onWarning) {
|
|
5041
5199
|
const codec = requireJmespath();
|
|
5042
5200
|
let result;
|
|
5043
5201
|
try {
|
|
@@ -5045,9 +5203,34 @@ function applyFilter(data, filter) {
|
|
|
5045
5203
|
} catch (err) {
|
|
5046
5204
|
throw new FilterEvaluationError(filter, err);
|
|
5047
5205
|
}
|
|
5048
|
-
|
|
5206
|
+
const inputCount = countRecords(data);
|
|
5207
|
+
const warn = (outcome) => {
|
|
5208
|
+
if (inputCount === 0)
|
|
5209
|
+
return;
|
|
5210
|
+
const note = buildFilterWarning(filter, data, outcome);
|
|
5211
|
+
getOutputSink().writeErr(`[WARN] ${note}
|
|
5212
|
+
`);
|
|
5213
|
+
onWarning?.(note);
|
|
5214
|
+
};
|
|
5215
|
+
const warnIfAllNull = (records) => {
|
|
5216
|
+
const keys = alwaysNullKeys(records);
|
|
5217
|
+
if (keys.length > 0)
|
|
5218
|
+
warn({ kind: "null-values", keys });
|
|
5219
|
+
};
|
|
5220
|
+
if (result == null) {
|
|
5221
|
+
warn({ kind: "empty" });
|
|
5049
5222
|
return [];
|
|
5223
|
+
}
|
|
5050
5224
|
if (Array.isArray(result)) {
|
|
5225
|
+
if (result.length === 0) {
|
|
5226
|
+
warn({ kind: "empty" });
|
|
5227
|
+
} else if (result.every((entry) => entry === null)) {
|
|
5228
|
+
warn({ kind: "null-elements", count: result.length });
|
|
5229
|
+
} else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
|
|
5230
|
+
warn({ kind: "null-rows", count: result.length });
|
|
5231
|
+
} else {
|
|
5232
|
+
warnIfAllNull(result);
|
|
5233
|
+
}
|
|
5051
5234
|
if (result.length > 0 && typeof result[0] !== "object") {
|
|
5052
5235
|
const fieldMatch = filter.match(/\.(\w+)$/);
|
|
5053
5236
|
const key = fieldMatch ? fieldMatch[1] : "Value";
|
|
@@ -5055,10 +5238,30 @@ function applyFilter(data, filter) {
|
|
|
5055
5238
|
}
|
|
5056
5239
|
return result;
|
|
5057
5240
|
}
|
|
5058
|
-
if (typeof result === "object")
|
|
5241
|
+
if (typeof result === "object") {
|
|
5242
|
+
warnIfAllNull([result]);
|
|
5059
5243
|
return result;
|
|
5244
|
+
}
|
|
5060
5245
|
return { Value: result };
|
|
5061
5246
|
}
|
|
5247
|
+
function filterFailureData(envelope) {
|
|
5248
|
+
const filter = getOutputFilter();
|
|
5249
|
+
const data = envelope.Data;
|
|
5250
|
+
if (!filter || data == null)
|
|
5251
|
+
return;
|
|
5252
|
+
let note;
|
|
5253
|
+
const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
|
|
5254
|
+
note = n;
|
|
5255
|
+
}));
|
|
5256
|
+
if (filterError) {
|
|
5257
|
+
envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
|
|
5258
|
+
return;
|
|
5259
|
+
}
|
|
5260
|
+
envelope.Data = filtered;
|
|
5261
|
+
if (note) {
|
|
5262
|
+
envelope.Warning = appendWarning(envelope.Warning, note);
|
|
5263
|
+
}
|
|
5264
|
+
}
|
|
5062
5265
|
function defaultErrorCodeForResult(result) {
|
|
5063
5266
|
switch (result) {
|
|
5064
5267
|
case RESULTS.AuthenticationError:
|
|
@@ -5141,8 +5344,14 @@ var OutputFormatter;
|
|
|
5141
5344
|
}
|
|
5142
5345
|
const filter = getOutputFilter();
|
|
5143
5346
|
if (filter) {
|
|
5144
|
-
|
|
5347
|
+
let note;
|
|
5348
|
+
const filtered = applyFilter(data.Data, filter, (n) => {
|
|
5349
|
+
note = n;
|
|
5350
|
+
});
|
|
5145
5351
|
data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
|
|
5352
|
+
if (note) {
|
|
5353
|
+
data.Warning = appendWarning(data.Warning, note);
|
|
5354
|
+
}
|
|
5146
5355
|
}
|
|
5147
5356
|
logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
|
|
5148
5357
|
}
|
|
@@ -5170,6 +5379,7 @@ var OutputFormatter;
|
|
|
5170
5379
|
delete envelope.TelemetryErrorClass;
|
|
5171
5380
|
delete envelope.TelemetryTerminalOutcome;
|
|
5172
5381
|
delete envelope.TelemetryTerminalSignal;
|
|
5382
|
+
filterFailureData(envelope);
|
|
5173
5383
|
if (!suppressTelemetry) {
|
|
5174
5384
|
telemetry.trackEvent(CommonTelemetryEvents.Error, {
|
|
5175
5385
|
result: data.Result,
|
|
@@ -5218,13 +5428,20 @@ var OutputFormatter;
|
|
|
5218
5428
|
OutputFormatter.log = log;
|
|
5219
5429
|
function formatToString(data) {
|
|
5220
5430
|
const filter = getOutputFilter();
|
|
5431
|
+
const envelope = data;
|
|
5221
5432
|
if ("Data" in data && data.Data != null) {
|
|
5222
5433
|
data.Data = normalizeDataKeys(data.Data);
|
|
5223
5434
|
if (filter) {
|
|
5224
|
-
|
|
5435
|
+
let note;
|
|
5436
|
+
data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
|
|
5437
|
+
note = n;
|
|
5438
|
+
}));
|
|
5439
|
+
if (note) {
|
|
5440
|
+
envelope.Warning = appendWarning(envelope.Warning, note);
|
|
5441
|
+
}
|
|
5225
5442
|
}
|
|
5226
5443
|
}
|
|
5227
|
-
const output = normalizeOutputKeys(
|
|
5444
|
+
const output = normalizeOutputKeys(envelope);
|
|
5228
5445
|
const lines = [];
|
|
5229
5446
|
const sink = getOutputSink();
|
|
5230
5447
|
printOutput(output, getOutputFormat(), (msg) => {
|
|
@@ -8770,4 +8987,4 @@ var registerCommands = async (program2) => {
|
|
|
8770
8987
|
|
|
8771
8988
|
export { Command, metadata, registerCommands };
|
|
8772
8989
|
|
|
8773
|
-
//# debugId=
|
|
8990
|
+
//# debugId=07EBA872319C310764756E2164756E21
|
package/dist/tool.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@uipath/model-hub-tool",
|
|
3
3
|
"author": "UiPath",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
|
-
"version": "1.203.0-preview.
|
|
5
|
+
"version": "1.203.0-preview.237",
|
|
6
6
|
"description": "CLI plugin for the UiPath Model Hub (LLM Gateway organization-scoped views).",
|
|
7
7
|
"private": false,
|
|
8
8
|
"repository": {
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"files": [
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "4ad3e17a66f2c7fb7fe1f0e3e04a5b6175a0a9a3"
|
|
31
31
|
}
|