@uipath/docsai-tool 1.203.0-preview.233 → 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-qbmfjqjg.js → tool-mvgq27ny.js} +225 -8
- package/dist/tool.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -9095,7 +9095,7 @@ var package_default = {
|
|
|
9095
9095
|
name: "@uipath/docsai-tool",
|
|
9096
9096
|
author: "UiPath",
|
|
9097
9097
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
9098
|
-
version: "1.203.0-preview.
|
|
9098
|
+
version: "1.203.0-preview.237",
|
|
9099
9099
|
description: "Search UiPath documentation with AI-powered answers.",
|
|
9100
9100
|
private: false,
|
|
9101
9101
|
repository: {
|
|
@@ -11677,7 +11677,165 @@ class FilterImplicitLimitError extends Error {
|
|
|
11677
11677
|
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).";
|
|
11678
11678
|
}
|
|
11679
11679
|
}
|
|
11680
|
-
function
|
|
11680
|
+
function countRecords(data) {
|
|
11681
|
+
if (Array.isArray(data))
|
|
11682
|
+
return data.length;
|
|
11683
|
+
return data == null ? 0 : 1;
|
|
11684
|
+
}
|
|
11685
|
+
function availableFields(data) {
|
|
11686
|
+
const records = Array.isArray(data) ? data : [data];
|
|
11687
|
+
const keys = new Set;
|
|
11688
|
+
for (const record of records) {
|
|
11689
|
+
if (record && typeof record === "object" && !Array.isArray(record)) {
|
|
11690
|
+
for (const key of Object.keys(record))
|
|
11691
|
+
keys.add(key);
|
|
11692
|
+
}
|
|
11693
|
+
}
|
|
11694
|
+
return [...keys];
|
|
11695
|
+
}
|
|
11696
|
+
function decodeQuotedIdentifier(whole, inner) {
|
|
11697
|
+
const [error, decoded] = catchError(() => JSON.parse(whole));
|
|
11698
|
+
if (!error && typeof decoded === "string")
|
|
11699
|
+
return decoded;
|
|
11700
|
+
return inner.replace(/\\(.)/g, "$1");
|
|
11701
|
+
}
|
|
11702
|
+
function referencedFields(filter) {
|
|
11703
|
+
const top = new Set;
|
|
11704
|
+
const nested = new Set;
|
|
11705
|
+
const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
|
|
11706
|
+
const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
|
|
11707
|
+
const quoted = [];
|
|
11708
|
+
const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
|
|
11709
|
+
const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
|
|
11710
|
+
if (!isAlias) {
|
|
11711
|
+
quoted.push({
|
|
11712
|
+
name: decodeQuotedIdentifier(whole, name),
|
|
11713
|
+
index,
|
|
11714
|
+
tail: isPathTail(withoutValueLiterals, index)
|
|
11715
|
+
});
|
|
11716
|
+
}
|
|
11717
|
+
return `"${" ".repeat(whole.length - 2)}"`;
|
|
11718
|
+
});
|
|
11719
|
+
const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
|
|
11720
|
+
const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
|
|
11721
|
+
const place = (name, index, tail) => {
|
|
11722
|
+
if (tail || index >= rootEnd)
|
|
11723
|
+
nested.add(name);
|
|
11724
|
+
else
|
|
11725
|
+
top.add(name);
|
|
11726
|
+
};
|
|
11727
|
+
for (const entry of quoted)
|
|
11728
|
+
place(entry.name, entry.index, entry.tail);
|
|
11729
|
+
const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
|
|
11730
|
+
const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
|
|
11731
|
+
for (const match of identifiers) {
|
|
11732
|
+
const [, name, trailing] = match;
|
|
11733
|
+
if (trailing || reserved.has(name))
|
|
11734
|
+
continue;
|
|
11735
|
+
place(name, match.index, isPathTail(withoutLiterals, match.index));
|
|
11736
|
+
}
|
|
11737
|
+
return {
|
|
11738
|
+
top: [...top],
|
|
11739
|
+
nested: [...nested].filter((name) => !top.has(name)),
|
|
11740
|
+
hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
|
|
11741
|
+
};
|
|
11742
|
+
}
|
|
11743
|
+
function appearsBelowTopLevel(data, name) {
|
|
11744
|
+
let budget = 2000;
|
|
11745
|
+
const visit = (value, depth) => {
|
|
11746
|
+
if (budget-- <= 0 || depth > 4)
|
|
11747
|
+
return false;
|
|
11748
|
+
if (value === null || typeof value !== "object")
|
|
11749
|
+
return false;
|
|
11750
|
+
if (Array.isArray(value))
|
|
11751
|
+
return value.some((entry) => visit(entry, depth));
|
|
11752
|
+
const record = value;
|
|
11753
|
+
if (depth > 0 && Object.hasOwn(record, name))
|
|
11754
|
+
return true;
|
|
11755
|
+
return Object.values(record).some((entry) => visit(entry, depth + 1));
|
|
11756
|
+
};
|
|
11757
|
+
return visit(data, 0);
|
|
11758
|
+
}
|
|
11759
|
+
function alwaysNullKeys(records) {
|
|
11760
|
+
const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
|
|
11761
|
+
if (objects.length === 0 || objects.length !== records.length)
|
|
11762
|
+
return [];
|
|
11763
|
+
const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
|
|
11764
|
+
if (keys.length === 0)
|
|
11765
|
+
return [];
|
|
11766
|
+
const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
|
|
11767
|
+
return nullKeys.length === keys.length ? nullKeys : [];
|
|
11768
|
+
}
|
|
11769
|
+
function carriesOnlyNulls(value) {
|
|
11770
|
+
if (value === null)
|
|
11771
|
+
return true;
|
|
11772
|
+
if (Array.isArray(value)) {
|
|
11773
|
+
return value.length > 0 && value.every(carriesOnlyNulls);
|
|
11774
|
+
}
|
|
11775
|
+
if (typeof value === "object" && value !== undefined) {
|
|
11776
|
+
const values = Object.values(value);
|
|
11777
|
+
return values.length > 0 && values.every(carriesOnlyNulls);
|
|
11778
|
+
}
|
|
11779
|
+
return false;
|
|
11780
|
+
}
|
|
11781
|
+
function nameList(names, cap2 = 12) {
|
|
11782
|
+
const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
|
|
11783
|
+
const rest = names.length - shown.length;
|
|
11784
|
+
return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
|
|
11785
|
+
}
|
|
11786
|
+
function buildFilterWarning(filter, data, outcome) {
|
|
11787
|
+
const present = availableFields(data);
|
|
11788
|
+
const refs = referencedFields(filter);
|
|
11789
|
+
const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
|
|
11790
|
+
const unchecked = refs.nested.filter((name) => !present.includes(name));
|
|
11791
|
+
const count = countRecords(data);
|
|
11792
|
+
const scope = `${count} record(s)`;
|
|
11793
|
+
const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
|
|
11794
|
+
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" : "";
|
|
11795
|
+
const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
|
|
11796
|
+
let detail;
|
|
11797
|
+
let lede;
|
|
11798
|
+
if (outcome.kind === "null-elements") {
|
|
11799
|
+
lede = "returned only null values";
|
|
11800
|
+
const projected = `all ${outcome.count} of the elements it projected are null`;
|
|
11801
|
+
if (unknown.length > 0) {
|
|
11802
|
+
detail = `${projected}, because ${isNotAField(unknown)}`;
|
|
11803
|
+
} else if (unchecked.length > 0) {
|
|
11804
|
+
detail = withSoundness(projected);
|
|
11805
|
+
} else {
|
|
11806
|
+
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`;
|
|
11807
|
+
}
|
|
11808
|
+
} else if (outcome.kind === "null-rows") {
|
|
11809
|
+
lede = "returned only null values";
|
|
11810
|
+
const projected = `every value it projected is null on all ${outcome.count} row(s)`;
|
|
11811
|
+
detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
|
|
11812
|
+
} else if (outcome.kind === "null-values") {
|
|
11813
|
+
lede = "returned only null values";
|
|
11814
|
+
const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
|
|
11815
|
+
const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
|
|
11816
|
+
if (sameSet) {
|
|
11817
|
+
detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
|
|
11818
|
+
} else if (unknown.length > 0) {
|
|
11819
|
+
detail = `${projected}, because ${isNotAField(unknown)}`;
|
|
11820
|
+
} else {
|
|
11821
|
+
detail = withSoundness(`${projected} on all ${scope}`);
|
|
11822
|
+
}
|
|
11823
|
+
} else {
|
|
11824
|
+
lede = "returned nothing";
|
|
11825
|
+
if (unknown.length > 0) {
|
|
11826
|
+
detail = isNotAField(unknown);
|
|
11827
|
+
} else {
|
|
11828
|
+
const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
|
|
11829
|
+
detail = withSoundness(`${selection} — it read ${scope}`);
|
|
11830
|
+
}
|
|
11831
|
+
}
|
|
11832
|
+
const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
|
|
11833
|
+
return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
|
|
11834
|
+
}
|
|
11835
|
+
function appendWarning(existing, note) {
|
|
11836
|
+
return existing ? `${existing} ${note}` : note;
|
|
11837
|
+
}
|
|
11838
|
+
function applyFilter(data, filter, onWarning) {
|
|
11681
11839
|
const codec = requireJmespath();
|
|
11682
11840
|
let result;
|
|
11683
11841
|
try {
|
|
@@ -11685,9 +11843,34 @@ function applyFilter(data, filter) {
|
|
|
11685
11843
|
} catch (err) {
|
|
11686
11844
|
throw new FilterEvaluationError(filter, err);
|
|
11687
11845
|
}
|
|
11688
|
-
|
|
11846
|
+
const inputCount = countRecords(data);
|
|
11847
|
+
const warn = (outcome) => {
|
|
11848
|
+
if (inputCount === 0)
|
|
11849
|
+
return;
|
|
11850
|
+
const note = buildFilterWarning(filter, data, outcome);
|
|
11851
|
+
getOutputSink().writeErr(`[WARN] ${note}
|
|
11852
|
+
`);
|
|
11853
|
+
onWarning?.(note);
|
|
11854
|
+
};
|
|
11855
|
+
const warnIfAllNull = (records) => {
|
|
11856
|
+
const keys = alwaysNullKeys(records);
|
|
11857
|
+
if (keys.length > 0)
|
|
11858
|
+
warn({ kind: "null-values", keys });
|
|
11859
|
+
};
|
|
11860
|
+
if (result == null) {
|
|
11861
|
+
warn({ kind: "empty" });
|
|
11689
11862
|
return [];
|
|
11863
|
+
}
|
|
11690
11864
|
if (Array.isArray(result)) {
|
|
11865
|
+
if (result.length === 0) {
|
|
11866
|
+
warn({ kind: "empty" });
|
|
11867
|
+
} else if (result.every((entry) => entry === null)) {
|
|
11868
|
+
warn({ kind: "null-elements", count: result.length });
|
|
11869
|
+
} else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
|
|
11870
|
+
warn({ kind: "null-rows", count: result.length });
|
|
11871
|
+
} else {
|
|
11872
|
+
warnIfAllNull(result);
|
|
11873
|
+
}
|
|
11691
11874
|
if (result.length > 0 && typeof result[0] !== "object") {
|
|
11692
11875
|
const fieldMatch = filter.match(/\.(\w+)$/);
|
|
11693
11876
|
const key = fieldMatch ? fieldMatch[1] : "Value";
|
|
@@ -11695,10 +11878,30 @@ function applyFilter(data, filter) {
|
|
|
11695
11878
|
}
|
|
11696
11879
|
return result;
|
|
11697
11880
|
}
|
|
11698
|
-
if (typeof result === "object")
|
|
11881
|
+
if (typeof result === "object") {
|
|
11882
|
+
warnIfAllNull([result]);
|
|
11699
11883
|
return result;
|
|
11884
|
+
}
|
|
11700
11885
|
return { Value: result };
|
|
11701
11886
|
}
|
|
11887
|
+
function filterFailureData(envelope) {
|
|
11888
|
+
const filter = getOutputFilter();
|
|
11889
|
+
const data = envelope.Data;
|
|
11890
|
+
if (!filter || data == null)
|
|
11891
|
+
return;
|
|
11892
|
+
let note;
|
|
11893
|
+
const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
|
|
11894
|
+
note = n;
|
|
11895
|
+
}));
|
|
11896
|
+
if (filterError) {
|
|
11897
|
+
envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
|
|
11898
|
+
return;
|
|
11899
|
+
}
|
|
11900
|
+
envelope.Data = filtered;
|
|
11901
|
+
if (note) {
|
|
11902
|
+
envelope.Warning = appendWarning(envelope.Warning, note);
|
|
11903
|
+
}
|
|
11904
|
+
}
|
|
11702
11905
|
function defaultErrorCodeForResult(result) {
|
|
11703
11906
|
switch (result) {
|
|
11704
11907
|
case RESULTS.AuthenticationError:
|
|
@@ -11781,8 +11984,14 @@ var OutputFormatter;
|
|
|
11781
11984
|
}
|
|
11782
11985
|
const filter = getOutputFilter();
|
|
11783
11986
|
if (filter) {
|
|
11784
|
-
|
|
11987
|
+
let note;
|
|
11988
|
+
const filtered = applyFilter(data.Data, filter, (n) => {
|
|
11989
|
+
note = n;
|
|
11990
|
+
});
|
|
11785
11991
|
data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
|
|
11992
|
+
if (note) {
|
|
11993
|
+
data.Warning = appendWarning(data.Warning, note);
|
|
11994
|
+
}
|
|
11786
11995
|
}
|
|
11787
11996
|
logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
|
|
11788
11997
|
}
|
|
@@ -11810,6 +12019,7 @@ var OutputFormatter;
|
|
|
11810
12019
|
delete envelope.TelemetryErrorClass;
|
|
11811
12020
|
delete envelope.TelemetryTerminalOutcome;
|
|
11812
12021
|
delete envelope.TelemetryTerminalSignal;
|
|
12022
|
+
filterFailureData(envelope);
|
|
11813
12023
|
if (!suppressTelemetry) {
|
|
11814
12024
|
telemetry.trackEvent(CommonTelemetryEvents.Error, {
|
|
11815
12025
|
result: data.Result,
|
|
@@ -11858,13 +12068,20 @@ var OutputFormatter;
|
|
|
11858
12068
|
OutputFormatter.log = log;
|
|
11859
12069
|
function formatToString(data) {
|
|
11860
12070
|
const filter = getOutputFilter();
|
|
12071
|
+
const envelope = data;
|
|
11861
12072
|
if ("Data" in data && data.Data != null) {
|
|
11862
12073
|
data.Data = normalizeDataKeys(data.Data);
|
|
11863
12074
|
if (filter) {
|
|
11864
|
-
|
|
12075
|
+
let note;
|
|
12076
|
+
data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
|
|
12077
|
+
note = n;
|
|
12078
|
+
}));
|
|
12079
|
+
if (note) {
|
|
12080
|
+
envelope.Warning = appendWarning(envelope.Warning, note);
|
|
12081
|
+
}
|
|
11865
12082
|
}
|
|
11866
12083
|
}
|
|
11867
|
-
const output = normalizeOutputKeys(
|
|
12084
|
+
const output = normalizeOutputKeys(envelope);
|
|
11868
12085
|
const lines = [];
|
|
11869
12086
|
const sink = getOutputSink();
|
|
11870
12087
|
printOutput(output, getOutputFormat(), (msg) => {
|
|
@@ -23361,4 +23578,4 @@ var registerCommands = async (program2) => {
|
|
|
23361
23578
|
|
|
23362
23579
|
export { Command, metadata, registerCommands };
|
|
23363
23580
|
|
|
23364
|
-
//# debugId=
|
|
23581
|
+
//# debugId=5C81D48776C2218064756E2164756E21
|
package/dist/tool.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@uipath/docsai-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": "Search UiPath documentation with AI-powered answers.",
|
|
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
|
}
|