synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
59 lines (58 loc) • 1.76 kB
JavaScript
import { SYNAPSE_ENTITY_ID_REGEX as u } from "../../utils/functions/RegularExpressions.js";
import { ColumnSingleValueFilterOperator as d } from "@sage-bionetworks/synapse-types";
import { getFileColumnModelId as p } from "../SynapseTable/SynapseTableUtils.js";
import { getWordCount as h } from "../TextField/TextFieldWithWordLimit.js";
function x(e) {
const t = e.match(/^"(.+?)"\s*@\d+$/);
return t ? t[1] : "";
}
function M(e, t = {
textMatchesMode: "NATURAL_LANGUAGE"
}) {
const { textMatchesMode: r, distance: a = 0 } = t;
let o = e;
if (r == "BOOLEAN") {
const m = h(e), n = Math.max(a, m);
o = `"${e.replaceAll('"', "")}" @${n}`;
}
return {
concreteType: "org.sagebionetworks.repo.model.table.TextMatchesQueryFilter",
searchExpression: o,
searchMode: t.textMatchesMode
};
}
function E(e, t, r, a) {
const { additionalFilters: o = [] } = e.query, l = p(t);
if (r.match(u) && l) {
const i = {
concreteType: "org.sagebionetworks.repo.model.table.ColumnSingleValueQueryFilter",
columnName: (t?.filter(
(s) => s.id === l
))[0].name,
operator: d.IN,
values: [r]
}, c = o.find(
(s) => s.concreteType == i.concreteType && s.columnName == i.columnName
);
if (c)
return c.values.includes(r) || c.values.push(r), e;
o.push(i);
} else {
const n = M(
r,
a
);
if (o.find(
(c) => c.concreteType == n.concreteType && c.searchExpression == n.searchExpression
))
return e;
o.push(n);
}
return e.query.additionalFilters = o, e;
}
export {
x as getSearchTextFromBooleanModeSearchExpression,
M as getTextMatchesQueryFilter,
E as updateQueryUsingSearchTerm
};
//# sourceMappingURL=FullTextSearchUtils.js.map