feat: 🎸 Add indexedDb parser (#2068)

* feat: 🎸 Add indexedDb parser

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12164

---------

Co-authored-by: Lisbet Alvarez <lisbet.alvarez@hashicorp.com>
This commit is contained in:
Zhihe LiandLisbet Alvarez committed 2024-04-12 14:55:33 -04:00
1 parent bd5e3da1f4
commit d72fa0d6e3
24 files changed
+890 -178

No files matched your search

+7 -7
View File
@@ -9,8 +9,8 @@
*
* @example
* const filter = generateMQLFilterExpression({
* name: [{ contains: 'search text' }],
* scope: [{ equals: 'scope1'}, { equals: 'scope2' }],
* name: { logicalOperator: 'and', values: [{ notEquals: 'search text' }, { notEquals: 'test' }] },
* scope_id: [{ equals: 'scope1'}, { equals: 'scope2' }],
* });
*
* // (name % "search text") and (scope_id = "scope1" or scope_id = "scope2")
@@ -21,10 +21,10 @@ export function generateMQLFilterExpression(filterObj) {
}
const expressions = Object.entries(filterObj)
.map(([key, filterObjValue]) => {
const filterValueArray = Array.isArray(filterObjValue)
? filterObjValue
: filterObjValue.values;
.map(([key, filterArrayOrObject]) => {
const filterValueArray = Array.isArray(filterArrayOrObject)
? filterArrayOrObject
: filterArrayOrObject.values;
let clauses;
const filterValues = filterValueArray.map((filterObjValue) => {
@@ -53,7 +53,7 @@ export function generateMQLFilterExpression(filterObj) {
});
// Default to `or` if we don't have a logical operator
const { logicalOperator } = filterObjValue;
const { logicalOperator } = filterArrayOrObject;
if (logicalOperator === 'and') {
clauses = and(filterValues);
} else {