@budibase/shared-core 2.32.11 → 2.32.12
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/filters.d.ts +12 -4
- package/dist/index.js +280 -92
- package/dist/index.js.map +4 -4
- package/dist/index.js.meta.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils.d.ts +10 -1
- package/package.json +3 -3
package/dist/filters.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Datasource, BBReferenceFieldSubType, FieldType, FormulaType,
|
|
1
|
+
import { Datasource, BBReferenceFieldSubType, FieldType, FormulaType, LegacyFilter, SearchFilters, SearchQueryFields, SortType, FieldConstraints, SortOrder, RowSearchParams, SearchResponse, Table, SearchFilterGroup } from "@budibase/types";
|
|
2
2
|
/**
|
|
3
3
|
* Returns the valid operator options for a certain data type
|
|
4
4
|
*/
|
|
@@ -60,11 +60,19 @@ export declare class ColumnSplitter {
|
|
|
60
60
|
column: string;
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
+
export declare const buildQueryLegacy: (filter?: LegacyFilter[] | SearchFilters) => SearchFilters | undefined;
|
|
63
64
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
65
|
+
* Converts a **SearchFilterGroup** filter definition into a grouped
|
|
66
|
+
* search query of type **SearchFilters**
|
|
67
|
+
*
|
|
68
|
+
* Legacy support remains for the old **SearchFilter[]** format.
|
|
69
|
+
* These will be migrated to an appropriate **SearchFilters** object, if encountered
|
|
70
|
+
*
|
|
71
|
+
* @param filter
|
|
72
|
+
*
|
|
73
|
+
* @returns {SearchFilters}
|
|
66
74
|
*/
|
|
67
|
-
export declare const buildQuery: (filter
|
|
75
|
+
export declare const buildQuery: (filter?: SearchFilterGroup | LegacyFilter[]) => SearchFilters | undefined;
|
|
68
76
|
export declare function fixupFilterArrays(filters: SearchFilters): SearchFilters;
|
|
69
77
|
export declare function search<T>(docs: Record<string, T>[], query: RowSearchParams): SearchResponse<Record<string, T>>;
|
|
70
78
|
/**
|
package/dist/index.js
CHANGED
|
@@ -17470,6 +17470,7 @@ __export(filters_exports, {
|
|
|
17470
17470
|
ColumnSplitter: () => ColumnSplitter,
|
|
17471
17471
|
NoEmptyFilterStrings: () => NoEmptyFilterStrings,
|
|
17472
17472
|
buildQuery: () => buildQuery,
|
|
17473
|
+
buildQueryLegacy: () => buildQueryLegacy,
|
|
17473
17474
|
cleanupQuery: () => cleanupQuery,
|
|
17474
17475
|
fixupFilterArrays: () => fixupFilterArrays,
|
|
17475
17476
|
getKeyNumbering: () => getKeyNumbering,
|
|
@@ -17485,6 +17486,156 @@ __export(filters_exports, {
|
|
|
17485
17486
|
});
|
|
17486
17487
|
var import_dayjs = __toESM(require_dayjs_min());
|
|
17487
17488
|
|
|
17489
|
+
// src/utils.ts
|
|
17490
|
+
var utils_exports = {};
|
|
17491
|
+
__export(utils_exports, {
|
|
17492
|
+
filterValueToLabel: () => filterValueToLabel,
|
|
17493
|
+
hasSchema: () => hasSchema,
|
|
17494
|
+
isSupportedUserSearch: () => isSupportedUserSearch,
|
|
17495
|
+
parallelForeach: () => parallelForeach,
|
|
17496
|
+
processSearchFilters: () => processSearchFilters,
|
|
17497
|
+
trimOtherProps: () => trimOtherProps,
|
|
17498
|
+
unreachable: () => unreachable
|
|
17499
|
+
});
|
|
17500
|
+
function unreachable(value, message = `No such case in exhaustive switch: ${value}`) {
|
|
17501
|
+
throw new Error(message);
|
|
17502
|
+
}
|
|
17503
|
+
async function parallelForeach(items, task, maxConcurrency) {
|
|
17504
|
+
const promises = [];
|
|
17505
|
+
let index = 0;
|
|
17506
|
+
const processItem = async (item) => {
|
|
17507
|
+
try {
|
|
17508
|
+
await task(item);
|
|
17509
|
+
} finally {
|
|
17510
|
+
processNext();
|
|
17511
|
+
}
|
|
17512
|
+
};
|
|
17513
|
+
const processNext = () => {
|
|
17514
|
+
if (index >= items.length) {
|
|
17515
|
+
return;
|
|
17516
|
+
}
|
|
17517
|
+
const item = items[index];
|
|
17518
|
+
index++;
|
|
17519
|
+
const promise = processItem(item);
|
|
17520
|
+
promises.push(promise);
|
|
17521
|
+
if (promises.length >= maxConcurrency) {
|
|
17522
|
+
Promise.race(promises).then(processNext);
|
|
17523
|
+
} else {
|
|
17524
|
+
processNext();
|
|
17525
|
+
}
|
|
17526
|
+
};
|
|
17527
|
+
processNext();
|
|
17528
|
+
await Promise.all(promises);
|
|
17529
|
+
}
|
|
17530
|
+
function filterValueToLabel() {
|
|
17531
|
+
return Object.keys(OperatorOptions).reduce(
|
|
17532
|
+
(acc, key) => {
|
|
17533
|
+
const ops = OperatorOptions;
|
|
17534
|
+
const op = ops[key];
|
|
17535
|
+
acc[op["value"]] = op.label;
|
|
17536
|
+
return acc;
|
|
17537
|
+
},
|
|
17538
|
+
{}
|
|
17539
|
+
);
|
|
17540
|
+
}
|
|
17541
|
+
function hasSchema(test) {
|
|
17542
|
+
return typeof test === "object" && !Array.isArray(test) && test !== null && !(test instanceof Date) && Object.keys(test).length > 0;
|
|
17543
|
+
}
|
|
17544
|
+
function trimOtherProps(object, allowedProps) {
|
|
17545
|
+
const result = Object.keys(object).filter((key) => allowedProps.includes(key)).reduce(
|
|
17546
|
+
(acc, key) => ({ ...acc, [key]: object[key] }),
|
|
17547
|
+
{}
|
|
17548
|
+
);
|
|
17549
|
+
return result;
|
|
17550
|
+
}
|
|
17551
|
+
function isSupportedUserSearch(query) {
|
|
17552
|
+
const allowed = [
|
|
17553
|
+
{ op: "string" /* STRING */, key: "email" },
|
|
17554
|
+
{ op: "equal" /* EQUAL */, key: "_id" },
|
|
17555
|
+
{ op: "oneOf" /* ONE_OF */, key: "_id" }
|
|
17556
|
+
];
|
|
17557
|
+
for (let [key, operation] of Object.entries(query)) {
|
|
17558
|
+
if (typeof operation !== "object") {
|
|
17559
|
+
return false;
|
|
17560
|
+
}
|
|
17561
|
+
const fields = Object.keys(operation || {});
|
|
17562
|
+
if (fields.length === 0) {
|
|
17563
|
+
continue;
|
|
17564
|
+
}
|
|
17565
|
+
const allowedOperation = allowed.find(
|
|
17566
|
+
(allow) => allow.op === key && fields.length === 1 && fields[0] === allow.key
|
|
17567
|
+
);
|
|
17568
|
+
if (!allowedOperation) {
|
|
17569
|
+
return false;
|
|
17570
|
+
}
|
|
17571
|
+
}
|
|
17572
|
+
return true;
|
|
17573
|
+
}
|
|
17574
|
+
var processSearchFilters = (filters) => {
|
|
17575
|
+
if (!filters) {
|
|
17576
|
+
return;
|
|
17577
|
+
}
|
|
17578
|
+
const defaultCfg = {
|
|
17579
|
+
logicalOperator: "all" /* ALL */,
|
|
17580
|
+
groups: []
|
|
17581
|
+
};
|
|
17582
|
+
const filterAllowedKeys = [
|
|
17583
|
+
"field",
|
|
17584
|
+
"operator",
|
|
17585
|
+
"value",
|
|
17586
|
+
"type",
|
|
17587
|
+
"externalType",
|
|
17588
|
+
"valueType",
|
|
17589
|
+
"noValue",
|
|
17590
|
+
"formulaType"
|
|
17591
|
+
];
|
|
17592
|
+
if (Array.isArray(filters)) {
|
|
17593
|
+
let baseGroup = {
|
|
17594
|
+
filters: [],
|
|
17595
|
+
logicalOperator: "all" /* ALL */
|
|
17596
|
+
};
|
|
17597
|
+
return filters.reduce((acc, filter) => {
|
|
17598
|
+
const filterPropertyKeys = Object.keys(filter).sort((a, b) => {
|
|
17599
|
+
return a.localeCompare(b);
|
|
17600
|
+
}).filter((key) => key in filter);
|
|
17601
|
+
if (filterPropertyKeys.length == 1) {
|
|
17602
|
+
const key = filterPropertyKeys[0], value = filter[key];
|
|
17603
|
+
if (key === "onEmptyFilter") {
|
|
17604
|
+
acc.onEmptyFilter = value;
|
|
17605
|
+
} else if (key === "operator" && value === "allOr") {
|
|
17606
|
+
baseGroup.logicalOperator = "any" /* ANY */;
|
|
17607
|
+
}
|
|
17608
|
+
return acc;
|
|
17609
|
+
}
|
|
17610
|
+
const allowedFilterSettings = filterPropertyKeys.reduce(
|
|
17611
|
+
(acc2, key) => {
|
|
17612
|
+
const value = filter[key];
|
|
17613
|
+
if (filterAllowedKeys.includes(key)) {
|
|
17614
|
+
if (key === "field") {
|
|
17615
|
+
acc2.push([key, removeKeyNumbering(value)]);
|
|
17616
|
+
} else {
|
|
17617
|
+
acc2.push([key, value]);
|
|
17618
|
+
}
|
|
17619
|
+
}
|
|
17620
|
+
return acc2;
|
|
17621
|
+
},
|
|
17622
|
+
[]
|
|
17623
|
+
);
|
|
17624
|
+
const migratedFilter = Object.fromEntries(
|
|
17625
|
+
allowedFilterSettings
|
|
17626
|
+
);
|
|
17627
|
+
baseGroup.filters.push(migratedFilter);
|
|
17628
|
+
if (!acc.groups || !acc.groups.length) {
|
|
17629
|
+
acc.groups = [baseGroup];
|
|
17630
|
+
}
|
|
17631
|
+
return acc;
|
|
17632
|
+
}, defaultCfg);
|
|
17633
|
+
} else if (!filters?.groups) {
|
|
17634
|
+
return;
|
|
17635
|
+
}
|
|
17636
|
+
return filters;
|
|
17637
|
+
};
|
|
17638
|
+
|
|
17488
17639
|
// src/helpers/index.ts
|
|
17489
17640
|
var helpers_exports = {};
|
|
17490
17641
|
__export(helpers_exports, {
|
|
@@ -17780,7 +17931,7 @@ var NoEmptyFilterStrings = [
|
|
|
17780
17931
|
];
|
|
17781
17932
|
function recurseLogicalOperators(filters, fn) {
|
|
17782
17933
|
for (const logical of LOGICAL_OPERATORS) {
|
|
17783
|
-
if (filters
|
|
17934
|
+
if (filters[logical]) {
|
|
17784
17935
|
filters[logical].conditions = filters[logical].conditions.map(
|
|
17785
17936
|
(condition) => fn(condition)
|
|
17786
17937
|
);
|
|
@@ -17800,9 +17951,6 @@ function recurseSearchFilters(filters, processFn) {
|
|
|
17800
17951
|
return filters;
|
|
17801
17952
|
}
|
|
17802
17953
|
var cleanupQuery = (query) => {
|
|
17803
|
-
if (!query) {
|
|
17804
|
-
return query;
|
|
17805
|
-
}
|
|
17806
17954
|
for (let filterField of NoEmptyFilterStrings) {
|
|
17807
17955
|
if (!query[filterField]) {
|
|
17808
17956
|
continue;
|
|
@@ -17893,7 +18041,106 @@ var ColumnSplitter = class {
|
|
|
17893
18041
|
};
|
|
17894
18042
|
}
|
|
17895
18043
|
};
|
|
17896
|
-
var
|
|
18044
|
+
var buildCondition = (expression) => {
|
|
18045
|
+
let query = {
|
|
18046
|
+
string: {},
|
|
18047
|
+
fuzzy: {},
|
|
18048
|
+
range: {},
|
|
18049
|
+
equal: {},
|
|
18050
|
+
notEqual: {},
|
|
18051
|
+
empty: {},
|
|
18052
|
+
notEmpty: {},
|
|
18053
|
+
contains: {},
|
|
18054
|
+
notContains: {},
|
|
18055
|
+
oneOf: {},
|
|
18056
|
+
containsAny: {}
|
|
18057
|
+
};
|
|
18058
|
+
let { operator, field, type, value, externalType, onEmptyFilter } = expression;
|
|
18059
|
+
if (!operator || !field) {
|
|
18060
|
+
return;
|
|
18061
|
+
}
|
|
18062
|
+
const queryOperator = operator;
|
|
18063
|
+
const isHbs = typeof value === "string" && (value.match(HBS_REGEX) || []).length > 0;
|
|
18064
|
+
if (operator === "allOr") {
|
|
18065
|
+
query.allOr = true;
|
|
18066
|
+
return;
|
|
18067
|
+
}
|
|
18068
|
+
if (onEmptyFilter) {
|
|
18069
|
+
query.onEmptyFilter = onEmptyFilter;
|
|
18070
|
+
return;
|
|
18071
|
+
}
|
|
18072
|
+
if (queryOperator === "empty" || queryOperator === "notEmpty") {
|
|
18073
|
+
value = null;
|
|
18074
|
+
}
|
|
18075
|
+
if (type === "datetime" && !isHbs && queryOperator !== "empty" && queryOperator !== "notEmpty") {
|
|
18076
|
+
if (!value) {
|
|
18077
|
+
return;
|
|
18078
|
+
}
|
|
18079
|
+
try {
|
|
18080
|
+
value = new Date(value).toISOString();
|
|
18081
|
+
} catch (error) {
|
|
18082
|
+
return;
|
|
18083
|
+
}
|
|
18084
|
+
}
|
|
18085
|
+
if (type === "number" && typeof value === "string" && !isHbs) {
|
|
18086
|
+
if (queryOperator === "oneOf") {
|
|
18087
|
+
value = value.split(",").map((item) => parseFloat(item));
|
|
18088
|
+
} else {
|
|
18089
|
+
value = parseFloat(value);
|
|
18090
|
+
}
|
|
18091
|
+
}
|
|
18092
|
+
if (type === "boolean") {
|
|
18093
|
+
value = `${value}`?.toLowerCase() === "true";
|
|
18094
|
+
}
|
|
18095
|
+
if (["contains", "notContains", "containsAny"].includes(
|
|
18096
|
+
operator.toLocaleString()
|
|
18097
|
+
) && type === "array" && typeof value === "string") {
|
|
18098
|
+
value = value.split(",");
|
|
18099
|
+
}
|
|
18100
|
+
if (operator.toLocaleString().startsWith("range") && query.range) {
|
|
18101
|
+
const minint = SqlNumberTypeRangeMap[externalType]?.min || Number.MIN_SAFE_INTEGER;
|
|
18102
|
+
const maxint = SqlNumberTypeRangeMap[externalType]?.max || Number.MAX_SAFE_INTEGER;
|
|
18103
|
+
if (!query.range[field]) {
|
|
18104
|
+
query.range[field] = {
|
|
18105
|
+
low: type === "number" ? minint : "0000-00-00T00:00:00.000Z",
|
|
18106
|
+
high: type === "number" ? maxint : "9999-00-00T00:00:00.000Z"
|
|
18107
|
+
};
|
|
18108
|
+
}
|
|
18109
|
+
if (operator === "rangeLow" && value != null && value !== "") {
|
|
18110
|
+
query.range[field] = {
|
|
18111
|
+
...query.range[field],
|
|
18112
|
+
low: value
|
|
18113
|
+
};
|
|
18114
|
+
} else if (operator === "rangeHigh" && value != null && value !== "") {
|
|
18115
|
+
query.range[field] = {
|
|
18116
|
+
...query.range[field],
|
|
18117
|
+
high: value
|
|
18118
|
+
};
|
|
18119
|
+
}
|
|
18120
|
+
} else if (isLogicalSearchOperator(queryOperator)) {
|
|
18121
|
+
} else if (query[queryOperator] && operator !== "onEmptyFilter") {
|
|
18122
|
+
if (type === "boolean") {
|
|
18123
|
+
if (queryOperator === "equal" && value === false) {
|
|
18124
|
+
query.notEqual = query.notEqual || {};
|
|
18125
|
+
query.notEqual[field] = true;
|
|
18126
|
+
} else if (queryOperator === "notEqual" && value === false) {
|
|
18127
|
+
query.equal = query.equal || {};
|
|
18128
|
+
query.equal[field] = true;
|
|
18129
|
+
} else {
|
|
18130
|
+
query[queryOperator] ??= {};
|
|
18131
|
+
query[queryOperator][field] = value;
|
|
18132
|
+
}
|
|
18133
|
+
} else {
|
|
18134
|
+
query[queryOperator] ??= {};
|
|
18135
|
+
query[queryOperator][field] = value;
|
|
18136
|
+
}
|
|
18137
|
+
}
|
|
18138
|
+
return query;
|
|
18139
|
+
};
|
|
18140
|
+
var buildQueryLegacy = (filter) => {
|
|
18141
|
+
if (!Array.isArray(filter)) {
|
|
18142
|
+
return filter;
|
|
18143
|
+
}
|
|
17897
18144
|
let query = {
|
|
17898
18145
|
string: {},
|
|
17899
18146
|
fuzzy: {},
|
|
@@ -17942,10 +18189,12 @@ var buildQuery = (filter) => {
|
|
|
17942
18189
|
if (type === "boolean") {
|
|
17943
18190
|
value = `${value}`?.toLowerCase() === "true";
|
|
17944
18191
|
}
|
|
17945
|
-
if (["contains", "notContains", "containsAny"].includes(
|
|
18192
|
+
if (["contains", "notContains", "containsAny"].includes(
|
|
18193
|
+
operator.toLocaleString()
|
|
18194
|
+
) && type === "array" && typeof value === "string") {
|
|
17946
18195
|
value = value.split(",");
|
|
17947
18196
|
}
|
|
17948
|
-
if (operator.startsWith("range") && query.range) {
|
|
18197
|
+
if (operator.toLocaleString().startsWith("range") && query.range) {
|
|
17949
18198
|
const minint = SqlNumberTypeRangeMap[externalType]?.min || Number.MIN_SAFE_INTEGER;
|
|
17950
18199
|
const maxint = SqlNumberTypeRangeMap[externalType]?.max || Number.MAX_SAFE_INTEGER;
|
|
17951
18200
|
if (!query.range[field]) {
|
|
@@ -17986,6 +18235,30 @@ var buildQuery = (filter) => {
|
|
|
17986
18235
|
});
|
|
17987
18236
|
return query;
|
|
17988
18237
|
};
|
|
18238
|
+
var buildQuery = (filter) => {
|
|
18239
|
+
const parsedFilter = processSearchFilters(filter);
|
|
18240
|
+
if (!parsedFilter) {
|
|
18241
|
+
return;
|
|
18242
|
+
}
|
|
18243
|
+
const operatorMap = {
|
|
18244
|
+
["all" /* ALL */]: "$and" /* AND */,
|
|
18245
|
+
["any" /* ANY */]: "$or" /* OR */
|
|
18246
|
+
};
|
|
18247
|
+
const globalOnEmpty = parsedFilter.onEmptyFilter ? parsedFilter.onEmptyFilter : null;
|
|
18248
|
+
const globalOperator = operatorMap[parsedFilter.logicalOperator];
|
|
18249
|
+
return {
|
|
18250
|
+
...globalOnEmpty ? { onEmptyFilter: globalOnEmpty } : {},
|
|
18251
|
+
[globalOperator]: {
|
|
18252
|
+
conditions: parsedFilter.groups?.map((group) => {
|
|
18253
|
+
return {
|
|
18254
|
+
[operatorMap[group.logicalOperator]]: {
|
|
18255
|
+
conditions: group.filters?.map((x) => buildCondition(x)).filter((filter2) => filter2)
|
|
18256
|
+
}
|
|
18257
|
+
};
|
|
18258
|
+
})
|
|
18259
|
+
}
|
|
18260
|
+
};
|
|
18261
|
+
};
|
|
17989
18262
|
function fixupFilterArrays(filters) {
|
|
17990
18263
|
for (const searchField of Object.values(ArrayOperator)) {
|
|
17991
18264
|
const field = filters[searchField];
|
|
@@ -18326,91 +18599,6 @@ var hasFilters = (query) => {
|
|
|
18326
18599
|
return check(query);
|
|
18327
18600
|
};
|
|
18328
18601
|
|
|
18329
|
-
// src/utils.ts
|
|
18330
|
-
var utils_exports = {};
|
|
18331
|
-
__export(utils_exports, {
|
|
18332
|
-
filterValueToLabel: () => filterValueToLabel,
|
|
18333
|
-
hasSchema: () => hasSchema,
|
|
18334
|
-
isSupportedUserSearch: () => isSupportedUserSearch,
|
|
18335
|
-
parallelForeach: () => parallelForeach,
|
|
18336
|
-
trimOtherProps: () => trimOtherProps,
|
|
18337
|
-
unreachable: () => unreachable
|
|
18338
|
-
});
|
|
18339
|
-
function unreachable(value, message = `No such case in exhaustive switch: ${value}`) {
|
|
18340
|
-
throw new Error(message);
|
|
18341
|
-
}
|
|
18342
|
-
async function parallelForeach(items, task, maxConcurrency) {
|
|
18343
|
-
const promises = [];
|
|
18344
|
-
let index = 0;
|
|
18345
|
-
const processItem = async (item) => {
|
|
18346
|
-
try {
|
|
18347
|
-
await task(item);
|
|
18348
|
-
} finally {
|
|
18349
|
-
processNext();
|
|
18350
|
-
}
|
|
18351
|
-
};
|
|
18352
|
-
const processNext = () => {
|
|
18353
|
-
if (index >= items.length) {
|
|
18354
|
-
return;
|
|
18355
|
-
}
|
|
18356
|
-
const item = items[index];
|
|
18357
|
-
index++;
|
|
18358
|
-
const promise = processItem(item);
|
|
18359
|
-
promises.push(promise);
|
|
18360
|
-
if (promises.length >= maxConcurrency) {
|
|
18361
|
-
Promise.race(promises).then(processNext);
|
|
18362
|
-
} else {
|
|
18363
|
-
processNext();
|
|
18364
|
-
}
|
|
18365
|
-
};
|
|
18366
|
-
processNext();
|
|
18367
|
-
await Promise.all(promises);
|
|
18368
|
-
}
|
|
18369
|
-
function filterValueToLabel() {
|
|
18370
|
-
return Object.keys(OperatorOptions).reduce(
|
|
18371
|
-
(acc, key) => {
|
|
18372
|
-
const ops = OperatorOptions;
|
|
18373
|
-
const op = ops[key];
|
|
18374
|
-
acc[op["value"]] = op.label;
|
|
18375
|
-
return acc;
|
|
18376
|
-
},
|
|
18377
|
-
{}
|
|
18378
|
-
);
|
|
18379
|
-
}
|
|
18380
|
-
function hasSchema(test) {
|
|
18381
|
-
return typeof test === "object" && !Array.isArray(test) && test !== null && !(test instanceof Date) && Object.keys(test).length > 0;
|
|
18382
|
-
}
|
|
18383
|
-
function trimOtherProps(object, allowedProps) {
|
|
18384
|
-
const result = Object.keys(object).filter((key) => allowedProps.includes(key)).reduce(
|
|
18385
|
-
(acc, key) => ({ ...acc, [key]: object[key] }),
|
|
18386
|
-
{}
|
|
18387
|
-
);
|
|
18388
|
-
return result;
|
|
18389
|
-
}
|
|
18390
|
-
function isSupportedUserSearch(query) {
|
|
18391
|
-
const allowed = [
|
|
18392
|
-
{ op: "string" /* STRING */, key: "email" },
|
|
18393
|
-
{ op: "equal" /* EQUAL */, key: "_id" },
|
|
18394
|
-
{ op: "oneOf" /* ONE_OF */, key: "_id" }
|
|
18395
|
-
];
|
|
18396
|
-
for (let [key, operation] of Object.entries(query)) {
|
|
18397
|
-
if (typeof operation !== "object") {
|
|
18398
|
-
return false;
|
|
18399
|
-
}
|
|
18400
|
-
const fields = Object.keys(operation || {});
|
|
18401
|
-
if (fields.length === 0) {
|
|
18402
|
-
continue;
|
|
18403
|
-
}
|
|
18404
|
-
const allowedOperation = allowed.find(
|
|
18405
|
-
(allow) => allow.op === key && fields.length === 1 && fields[0] === allow.key
|
|
18406
|
-
);
|
|
18407
|
-
if (!allowedOperation) {
|
|
18408
|
-
return false;
|
|
18409
|
-
}
|
|
18410
|
-
}
|
|
18411
|
-
return true;
|
|
18412
|
-
}
|
|
18413
|
-
|
|
18414
18602
|
// src/sdk/index.ts
|
|
18415
18603
|
var sdk_exports = {};
|
|
18416
18604
|
__export(sdk_exports, {
|