@teselagen/ui 0.7.33-beta.4 → 0.7.33-beta.6
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/DataTable/utils/queryParams.d.ts +8 -11
- package/DataTable/utils/tableQueryParamsToHasuraClauses.d.ts +12 -0
- package/index.cjs.js +186 -43
- package/index.es.js +186 -43
- package/package.json +1 -1
- package/src/DataTable/Columns.js +1 -1
- package/src/DataTable/DisplayOptions.js +1 -1
- package/src/DataTable/index.js +2 -2
- package/src/DataTable/utils/filterLocalEntitiesToHasura.js +20 -0
- package/src/DataTable/utils/filterLocalEntitiesToHasura.test.js +118 -46
- package/src/DataTable/utils/initializeHasuraWhereAndFilter.js +0 -1
- package/src/DataTable/utils/queryParams.js +43 -29
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +180 -40
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.test.js +8 -21
- package/src/DataTable/utils/withTableParams.js +2 -2
- package/DataTable/utils/simplifyHasuraWhere.d.ts +0 -1
- package/src/DataTable/utils/simplifyHasuraWhere.js +0 -80
- package/src/DataTable/utils/simplifyHasuraWhere.test.js +0 -73
package/index.es.js
CHANGED
|
@@ -19384,6 +19384,7 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19384
19384
|
// Add schema as a parameter
|
|
19385
19385
|
additionalFilter
|
|
19386
19386
|
}) {
|
|
19387
|
+
const ccFields = getFieldsMappedByCCDisplayName(schema);
|
|
19387
19388
|
let where = {};
|
|
19388
19389
|
const order_by = {};
|
|
19389
19390
|
const limit = pageSize || 25;
|
|
@@ -19395,9 +19396,8 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19395
19396
|
if (searchDisabled || field.filterDisabled || type2 === "color") return;
|
|
19396
19397
|
const filterValue = searchTerm;
|
|
19397
19398
|
if (type2 === "string" || type2 === "lookup") {
|
|
19398
|
-
|
|
19399
|
-
|
|
19400
|
-
});
|
|
19399
|
+
const o2 = set$1({}, path2, { _ilike: `%${filterValue}%` });
|
|
19400
|
+
searchTermFilters.push(o2);
|
|
19401
19401
|
} else if (type2 === "boolean") {
|
|
19402
19402
|
let regex;
|
|
19403
19403
|
try {
|
|
@@ -19406,19 +19406,16 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19406
19406
|
}
|
|
19407
19407
|
if (regex) {
|
|
19408
19408
|
if ("true".replace(regex, "") !== "true") {
|
|
19409
|
-
|
|
19410
|
-
|
|
19411
|
-
});
|
|
19409
|
+
const o2 = set$1({}, path2, { _eq: true });
|
|
19410
|
+
searchTermFilters.push(o2);
|
|
19412
19411
|
} else if ("false".replace(regex, "") !== "false") {
|
|
19413
|
-
|
|
19414
|
-
|
|
19415
|
-
});
|
|
19412
|
+
const o2 = set$1({}, path2, { _eq: false });
|
|
19413
|
+
searchTermFilters.push(o2);
|
|
19416
19414
|
}
|
|
19417
19415
|
}
|
|
19418
19416
|
} else if ((type2 === "number" || type2 === "integer") && !isNaN(filterValue)) {
|
|
19419
|
-
|
|
19420
|
-
|
|
19421
|
-
});
|
|
19417
|
+
const o2 = set$1({}, path2, { _eq: parseFloat(filterValue) });
|
|
19418
|
+
searchTermFilters.push(o2);
|
|
19422
19419
|
}
|
|
19423
19420
|
});
|
|
19424
19421
|
if (searchTermFilters.length > 0) {
|
|
@@ -19431,32 +19428,134 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19431
19428
|
}
|
|
19432
19429
|
if (filters && filters.length > 0) {
|
|
19433
19430
|
const filterClauses = filters.map((filter2) => {
|
|
19434
|
-
|
|
19431
|
+
let { selectedFilter, filterOn, filterValue } = filter2;
|
|
19432
|
+
const fieldSchema = ccFields[filterOn] || {};
|
|
19433
|
+
const { path: path2, reference: reference2, type: type2 } = fieldSchema;
|
|
19434
|
+
let stringFilterValue = filterValue && filterValue.toString ? filterValue.toString() : filterValue;
|
|
19435
|
+
if (stringFilterValue === false) {
|
|
19436
|
+
stringFilterValue = "false";
|
|
19437
|
+
} else {
|
|
19438
|
+
stringFilterValue = stringFilterValue || "";
|
|
19439
|
+
}
|
|
19440
|
+
const arrayFilterValue = Array.isArray(filterValue) ? filterValue : stringFilterValue.split(";");
|
|
19441
|
+
if (type2 === "number" || type2 === "integer") {
|
|
19442
|
+
filterValue = Array.isArray(filterValue) ? filterValue.map((val) => Number(val)) : Number(filterValue);
|
|
19443
|
+
}
|
|
19444
|
+
if (fieldSchema.normalizeFilter) {
|
|
19445
|
+
filterValue = fieldSchema.normalizeFilter(
|
|
19446
|
+
filterValue,
|
|
19447
|
+
selectedFilter,
|
|
19448
|
+
filterOn
|
|
19449
|
+
);
|
|
19450
|
+
}
|
|
19451
|
+
if (reference2) {
|
|
19452
|
+
filterOn = reference2.sourceField;
|
|
19453
|
+
} else {
|
|
19454
|
+
filterOn = path2 || filterOn;
|
|
19455
|
+
}
|
|
19435
19456
|
switch (selectedFilter) {
|
|
19436
|
-
case "
|
|
19457
|
+
case "none":
|
|
19458
|
+
return {};
|
|
19459
|
+
case "startsWith":
|
|
19460
|
+
return { [filterOn]: { _ilike: `${filterValue}%` } };
|
|
19461
|
+
case "endsWith":
|
|
19462
|
+
return { [filterOn]: { _ilike: `%${filterValue}` } };
|
|
19463
|
+
case "contains":
|
|
19437
19464
|
return { [filterOn]: { _ilike: `%${filterValue}%` } };
|
|
19438
|
-
case "
|
|
19465
|
+
case "notContains":
|
|
19466
|
+
return { [filterOn]: { _not_ilike: `%${filterValue}%` } };
|
|
19467
|
+
case "isExactly":
|
|
19439
19468
|
return { [filterOn]: { _eq: filterValue } };
|
|
19440
|
-
case "
|
|
19441
|
-
return {
|
|
19442
|
-
|
|
19443
|
-
|
|
19444
|
-
|
|
19469
|
+
case "isEmpty":
|
|
19470
|
+
return {
|
|
19471
|
+
_or: [
|
|
19472
|
+
{ [filterOn]: { _eq: "" } },
|
|
19473
|
+
{ [filterOn]: { _is_null: true } }
|
|
19474
|
+
]
|
|
19475
|
+
};
|
|
19476
|
+
case "notEmpty":
|
|
19477
|
+
return {
|
|
19478
|
+
_and: [
|
|
19479
|
+
{ [filterOn]: { _neq: "" } },
|
|
19480
|
+
{ [filterOn]: { _is_null: false } }
|
|
19481
|
+
]
|
|
19482
|
+
};
|
|
19483
|
+
case "inList":
|
|
19484
|
+
return { [filterOn]: { _in: filterValue } };
|
|
19485
|
+
case "notInList":
|
|
19486
|
+
return { [filterOn]: { _nin: filterValue } };
|
|
19487
|
+
case "true":
|
|
19488
|
+
return { [filterOn]: { _eq: true } };
|
|
19489
|
+
case "false":
|
|
19490
|
+
return { [filterOn]: { _eq: false } };
|
|
19491
|
+
case "dateIs":
|
|
19492
|
+
return { [filterOn]: { _eq: filterValue } };
|
|
19493
|
+
case "notBetween":
|
|
19494
|
+
return {
|
|
19495
|
+
_or: [
|
|
19496
|
+
{
|
|
19497
|
+
[filterOn]: {
|
|
19498
|
+
_lt: new Date(arrayFilterValue[0])
|
|
19499
|
+
}
|
|
19500
|
+
},
|
|
19501
|
+
{
|
|
19502
|
+
[filterOn]: {
|
|
19503
|
+
_gt: new Date(
|
|
19504
|
+
new Date(arrayFilterValue[1]).setHours(23, 59)
|
|
19505
|
+
)
|
|
19506
|
+
}
|
|
19507
|
+
}
|
|
19508
|
+
]
|
|
19509
|
+
};
|
|
19510
|
+
case "isBetween":
|
|
19511
|
+
return {
|
|
19512
|
+
[filterOn]: {
|
|
19513
|
+
_gte: new Date(arrayFilterValue[0]),
|
|
19514
|
+
_lte: new Date(new Date(arrayFilterValue[1]).setHours(23, 59))
|
|
19515
|
+
}
|
|
19516
|
+
};
|
|
19517
|
+
case "isBefore":
|
|
19518
|
+
return { [filterOn]: { _lt: new Date(filterValue) } };
|
|
19519
|
+
case "isAfter":
|
|
19520
|
+
return { [filterOn]: { _gt: new Date(filterValue) } };
|
|
19521
|
+
case "greaterThan":
|
|
19445
19522
|
return { [filterOn]: { _gt: parseFloat(filterValue) } };
|
|
19446
|
-
case "
|
|
19523
|
+
case "lessThan":
|
|
19447
19524
|
return { [filterOn]: { _lt: parseFloat(filterValue) } };
|
|
19448
|
-
case "
|
|
19449
|
-
return {
|
|
19450
|
-
|
|
19451
|
-
|
|
19452
|
-
|
|
19453
|
-
|
|
19454
|
-
|
|
19455
|
-
|
|
19525
|
+
case "inRange":
|
|
19526
|
+
return {
|
|
19527
|
+
[filterOn]: {
|
|
19528
|
+
_gte: parseFloat(arrayFilterValue[0]),
|
|
19529
|
+
_lte: parseFloat(arrayFilterValue[1])
|
|
19530
|
+
}
|
|
19531
|
+
};
|
|
19532
|
+
case "outsideRange":
|
|
19533
|
+
return {
|
|
19534
|
+
_or: [
|
|
19535
|
+
{
|
|
19536
|
+
[filterOn]: {
|
|
19537
|
+
_lt: parseFloat(arrayFilterValue[0])
|
|
19538
|
+
}
|
|
19539
|
+
},
|
|
19540
|
+
{
|
|
19541
|
+
[filterOn]: {
|
|
19542
|
+
_gt: parseFloat(arrayFilterValue[1])
|
|
19543
|
+
}
|
|
19544
|
+
}
|
|
19545
|
+
]
|
|
19546
|
+
};
|
|
19547
|
+
case "equalTo":
|
|
19548
|
+
return { [filterOn]: { _eq: parseFloat(filterValue) } };
|
|
19549
|
+
case "regex":
|
|
19550
|
+
return { [filterOn]: { _regex: filterValue } };
|
|
19456
19551
|
default:
|
|
19457
19552
|
console.warn(`Unsupported filter type: ${selectedFilter}`);
|
|
19458
19553
|
return {};
|
|
19459
19554
|
}
|
|
19555
|
+
}).map((filter2) => {
|
|
19556
|
+
const o2 = {};
|
|
19557
|
+
set$1(o2, Object.keys(filter2)[0], filter2[Object.keys(filter2)[0]]);
|
|
19558
|
+
return o2;
|
|
19460
19559
|
});
|
|
19461
19560
|
if (filterClauses.length > 0) {
|
|
19462
19561
|
if (Object.keys(where).length > 0) {
|
|
@@ -19479,6 +19578,21 @@ function tableQueryParamsToHasuraClauses({
|
|
|
19479
19578
|
return { where, order_by, limit, offset: offset3 };
|
|
19480
19579
|
}
|
|
19481
19580
|
__name(tableQueryParamsToHasuraClauses, "tableQueryParamsToHasuraClauses");
|
|
19581
|
+
function getFieldsMappedByCCDisplayName(schema) {
|
|
19582
|
+
if (!schema || !schema.fields) return {};
|
|
19583
|
+
return schema.fields.reduce((acc, field) => {
|
|
19584
|
+
const ccDisplayName = getCCDisplayName(field);
|
|
19585
|
+
acc[ccDisplayName] = field;
|
|
19586
|
+
return acc;
|
|
19587
|
+
}, {});
|
|
19588
|
+
}
|
|
19589
|
+
__name(getFieldsMappedByCCDisplayName, "getFieldsMappedByCCDisplayName");
|
|
19590
|
+
function getCCDisplayName(field) {
|
|
19591
|
+
return camelCase(
|
|
19592
|
+
typeof field.displayName === "string" ? field.displayName : field.path
|
|
19593
|
+
);
|
|
19594
|
+
}
|
|
19595
|
+
__name(getCCDisplayName, "getCCDisplayName");
|
|
19482
19596
|
function filterLocalEntitiesToHasura(records, { where, order_by, limit, offset: offset3, isInfinite } = {}) {
|
|
19483
19597
|
let filteredRecords = [...records];
|
|
19484
19598
|
if (where) {
|
|
@@ -19508,10 +19622,16 @@ function applyWhereClause(records, where) {
|
|
|
19508
19622
|
}
|
|
19509
19623
|
for (const key in filter2) {
|
|
19510
19624
|
if (key === "_and") {
|
|
19625
|
+
if (isEmpty$1(filter2[key])) {
|
|
19626
|
+
continue;
|
|
19627
|
+
}
|
|
19511
19628
|
if (!every(filter2[key], (subFilter) => applyFilter(record, subFilter))) {
|
|
19512
19629
|
return false;
|
|
19513
19630
|
}
|
|
19514
19631
|
} else if (key === "_or") {
|
|
19632
|
+
if (isEmpty$1(filter2[key])) {
|
|
19633
|
+
continue;
|
|
19634
|
+
}
|
|
19515
19635
|
if (!some(filter2[key], (subFilter) => applyFilter(record, subFilter))) {
|
|
19516
19636
|
return false;
|
|
19517
19637
|
}
|
|
@@ -19522,6 +19642,9 @@ function applyWhereClause(records, where) {
|
|
|
19522
19642
|
} else {
|
|
19523
19643
|
const value = record[key];
|
|
19524
19644
|
const conditions = filter2[key];
|
|
19645
|
+
if (isObject$2(value) && isObject$2(conditions) && !hasOperator(conditions)) {
|
|
19646
|
+
return applyFilter(value, conditions);
|
|
19647
|
+
}
|
|
19525
19648
|
for (const operator in conditions) {
|
|
19526
19649
|
const conditionValue = conditions[operator];
|
|
19527
19650
|
if (operator === "_gt" && conditions._lt) {
|
|
@@ -19619,6 +19742,10 @@ function applyWhereClause(records, where) {
|
|
|
19619
19742
|
return true;
|
|
19620
19743
|
}
|
|
19621
19744
|
__name(applyFilter, "applyFilter");
|
|
19745
|
+
function hasOperator(obj) {
|
|
19746
|
+
return Object.keys(obj).some((key) => key.startsWith("_"));
|
|
19747
|
+
}
|
|
19748
|
+
__name(hasOperator, "hasOperator");
|
|
19622
19749
|
return records.filter((record) => applyFilter(record, where));
|
|
19623
19750
|
}
|
|
19624
19751
|
__name(applyWhereClause, "applyWhereClause");
|
|
@@ -19667,12 +19794,6 @@ function safeParse(val) {
|
|
|
19667
19794
|
}
|
|
19668
19795
|
}
|
|
19669
19796
|
__name(safeParse, "safeParse");
|
|
19670
|
-
function getCCDisplayName(field) {
|
|
19671
|
-
return camelCase(
|
|
19672
|
-
typeof field.displayName === "string" ? field.displayName : field.path
|
|
19673
|
-
);
|
|
19674
|
-
}
|
|
19675
|
-
__name(getCCDisplayName, "getCCDisplayName");
|
|
19676
19797
|
function getCurrentParamsFromUrl(location2, isSimple) {
|
|
19677
19798
|
let { search: search2 } = location2;
|
|
19678
19799
|
if (isSimple) {
|
|
@@ -19841,7 +19962,7 @@ function getQueryParams({
|
|
|
19841
19962
|
isLocalCall,
|
|
19842
19963
|
additionalFilter,
|
|
19843
19964
|
doNotCoercePageSize,
|
|
19844
|
-
|
|
19965
|
+
noOrderError,
|
|
19845
19966
|
// isCodeModel,
|
|
19846
19967
|
ownProps
|
|
19847
19968
|
}) {
|
|
@@ -19865,11 +19986,31 @@ function getQueryParams({
|
|
|
19865
19986
|
)[0];
|
|
19866
19987
|
pageSize = closest;
|
|
19867
19988
|
}
|
|
19868
|
-
const
|
|
19989
|
+
const cleanedOrder = [];
|
|
19990
|
+
if (order2 && order2.length) {
|
|
19991
|
+
const ccFields = getFieldsMappedByCCDisplayName(schema);
|
|
19992
|
+
order2.forEach((orderVal) => {
|
|
19993
|
+
const ccDisplayName = orderVal.replace(/^-/gi, "");
|
|
19994
|
+
const schemaForField = ccFields[ccDisplayName];
|
|
19995
|
+
if (schemaForField) {
|
|
19996
|
+
const { path: path2 } = schemaForField;
|
|
19997
|
+
const reversed = ccDisplayName !== orderVal;
|
|
19998
|
+
const prefix2 = reversed ? "-" : "";
|
|
19999
|
+
cleanedOrder.push(prefix2 + path2);
|
|
20000
|
+
} else {
|
|
20001
|
+
!noOrderError && console.error(
|
|
20002
|
+
"No schema for field found!",
|
|
20003
|
+
ccDisplayName,
|
|
20004
|
+
JSON.stringify(schema.fields, null, 2)
|
|
20005
|
+
);
|
|
20006
|
+
}
|
|
20007
|
+
});
|
|
20008
|
+
}
|
|
20009
|
+
let toRet = {
|
|
19869
20010
|
//these are values that might be generally useful for the wrapped component
|
|
19870
20011
|
page,
|
|
19871
20012
|
pageSize: ownProps.controlled_pageSize || pageSize,
|
|
19872
|
-
order:
|
|
20013
|
+
order: cleanedOrder,
|
|
19873
20014
|
filters,
|
|
19874
20015
|
searchTerm
|
|
19875
20016
|
};
|
|
@@ -19878,21 +20019,22 @@ function getQueryParams({
|
|
|
19878
20019
|
pageSize,
|
|
19879
20020
|
searchTerm,
|
|
19880
20021
|
filters,
|
|
19881
|
-
order:
|
|
20022
|
+
order: cleanedOrder,
|
|
19882
20023
|
schema
|
|
19883
20024
|
});
|
|
19884
20025
|
initializeHasuraWhereAndFilter(additionalFilter, where, currentParams);
|
|
19885
20026
|
addCustomColumnFilters(where, schema.fields, currentParams);
|
|
19886
20027
|
if (isLocalCall) {
|
|
19887
|
-
|
|
20028
|
+
toRet = __spreadValues(__spreadValues({}, toRet), filterLocalEntitiesToHasura(entities, {
|
|
19888
20029
|
where,
|
|
19889
20030
|
order_by,
|
|
19890
20031
|
limit,
|
|
19891
20032
|
offset: offset3,
|
|
19892
20033
|
isInfinite
|
|
19893
|
-
});
|
|
20034
|
+
}));
|
|
20035
|
+
return toRet;
|
|
19894
20036
|
} else {
|
|
19895
|
-
return __spreadProps(__spreadValues({},
|
|
20037
|
+
return __spreadProps(__spreadValues({}, toRet), {
|
|
19896
20038
|
variables: {
|
|
19897
20039
|
where,
|
|
19898
20040
|
order_by,
|
|
@@ -56347,7 +56489,7 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
56347
56489
|
}) : !val;
|
|
56348
56490
|
});
|
|
56349
56491
|
}
|
|
56350
|
-
if (noValsForField) {
|
|
56492
|
+
if (noValsForField && entities.length) {
|
|
56351
56493
|
return __spreadProps(__spreadValues({}, field), {
|
|
56352
56494
|
isHidden: true,
|
|
56353
56495
|
isForcedHidden: true
|
|
@@ -71610,6 +71752,7 @@ const useTableParams = /* @__PURE__ */ __name((props) => {
|
|
|
71610
71752
|
isInfinite: isInfinite || isSimple && !withPaging,
|
|
71611
71753
|
isLocalCall,
|
|
71612
71754
|
additionalFilter,
|
|
71755
|
+
noOrderError,
|
|
71613
71756
|
ownProps: passingProps
|
|
71614
71757
|
});
|
|
71615
71758
|
}, [
|
package/package.json
CHANGED
package/src/DataTable/Columns.js
CHANGED
|
@@ -33,10 +33,10 @@ import getTextFromEl from "../utils/getTextFromEl";
|
|
|
33
33
|
import rowClick, { finalizeSelection } from "./utils/rowClick";
|
|
34
34
|
import { editCellHelper } from "./editCellHelper";
|
|
35
35
|
import { getCellVal } from "./getCellVal";
|
|
36
|
-
import { getCCDisplayName } from "./utils/queryParams";
|
|
37
36
|
import { useDispatch } from "react-redux";
|
|
38
37
|
import { change as _change } from "redux-form";
|
|
39
38
|
import { RenderCell } from "./RenderCell";
|
|
39
|
+
import { getCCDisplayName } from "./utils/tableQueryParamsToHasuraClauses";
|
|
40
40
|
|
|
41
41
|
dayjs.extend(localizedFormat);
|
|
42
42
|
|
package/src/DataTable/index.js
CHANGED
|
@@ -92,7 +92,6 @@ import { viewColumn, openColumn, multiViewColumn } from "./viewColumn";
|
|
|
92
92
|
import convertSchema from "./utils/convertSchema";
|
|
93
93
|
import TableFormTrackerContext from "./TableFormTrackerContext";
|
|
94
94
|
import {
|
|
95
|
-
getCCDisplayName,
|
|
96
95
|
getCurrentParamsFromUrl,
|
|
97
96
|
getQueryParams,
|
|
98
97
|
makeDataTableHandlers,
|
|
@@ -103,6 +102,7 @@ import { formValueSelector, change as _change } from "redux-form";
|
|
|
103
102
|
import { throwFormError } from "../throwFormError";
|
|
104
103
|
import { isObservableArray, toJS } from "mobx";
|
|
105
104
|
import { isBeingCalledExcessively } from "../utils/isBeingCalledExcessively";
|
|
105
|
+
import { getCCDisplayName } from "./utils/tableQueryParamsToHasuraClauses";
|
|
106
106
|
|
|
107
107
|
enablePatches();
|
|
108
108
|
const IS_LINUX = window.navigator.platform.toLowerCase().search("linux") > -1;
|
|
@@ -603,7 +603,7 @@ const DataTable = ({
|
|
|
603
603
|
: !val;
|
|
604
604
|
});
|
|
605
605
|
}
|
|
606
|
-
if (noValsForField) {
|
|
606
|
+
if (noValsForField && entities.length) {
|
|
607
607
|
return {
|
|
608
608
|
...field,
|
|
609
609
|
isHidden: true,
|
|
@@ -56,10 +56,16 @@ function applyWhereClause(records, where) {
|
|
|
56
56
|
|
|
57
57
|
for (const key in filter) {
|
|
58
58
|
if (key === "_and") {
|
|
59
|
+
if (isEmpty(filter[key])) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
59
62
|
if (!every(filter[key], subFilter => applyFilter(record, subFilter))) {
|
|
60
63
|
return false;
|
|
61
64
|
}
|
|
62
65
|
} else if (key === "_or") {
|
|
66
|
+
if (isEmpty(filter[key])) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
63
69
|
if (!some(filter[key], subFilter => applyFilter(record, subFilter))) {
|
|
64
70
|
return false;
|
|
65
71
|
}
|
|
@@ -71,6 +77,15 @@ function applyWhereClause(records, where) {
|
|
|
71
77
|
const value = record[key];
|
|
72
78
|
const conditions = filter[key];
|
|
73
79
|
|
|
80
|
+
// Handle nested object properties
|
|
81
|
+
if (
|
|
82
|
+
isObject(value) &&
|
|
83
|
+
isObject(conditions) &&
|
|
84
|
+
!hasOperator(conditions)
|
|
85
|
+
) {
|
|
86
|
+
return applyFilter(value, conditions);
|
|
87
|
+
}
|
|
88
|
+
|
|
74
89
|
for (const operator in conditions) {
|
|
75
90
|
const conditionValue = conditions[operator];
|
|
76
91
|
|
|
@@ -202,6 +217,11 @@ function applyWhereClause(records, where) {
|
|
|
202
217
|
return true;
|
|
203
218
|
}
|
|
204
219
|
|
|
220
|
+
// Helper to check if an object contains any Hasura operators
|
|
221
|
+
function hasOperator(obj) {
|
|
222
|
+
return Object.keys(obj).some(key => key.startsWith("_"));
|
|
223
|
+
}
|
|
224
|
+
|
|
205
225
|
return records.filter(record => applyFilter(record, where));
|
|
206
226
|
}
|
|
207
227
|
|