@budibase/shared-core 2.31.8 → 2.32.0
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 +4 -7
- package/dist/index.js +9 -9
- package/dist/index.js.map +2 -2
- package/dist/index.js.meta.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/filters.d.ts
CHANGED
|
@@ -66,16 +66,13 @@ export declare class ColumnSplitter {
|
|
|
66
66
|
*/
|
|
67
67
|
export declare const buildQuery: (filter: SearchFilter[]) => SearchFilters;
|
|
68
68
|
export declare function fixupFilterArrays(filters: SearchFilters): SearchFilters;
|
|
69
|
-
export declare
|
|
69
|
+
export declare function search<T>(docs: Record<string, T>[], query: RowSearchParams): SearchResponse<Record<string, T>>;
|
|
70
70
|
/**
|
|
71
71
|
* Performs a client-side search on an array of data
|
|
72
72
|
* @param docs the data
|
|
73
73
|
* @param query the JSON query
|
|
74
|
-
* @param findInDoc optional fn when trying to extract a value
|
|
75
|
-
* from custom doc type e.g. Google Sheets
|
|
76
|
-
*
|
|
77
74
|
*/
|
|
78
|
-
export declare
|
|
75
|
+
export declare function runQuery<T extends Record<string, any>>(docs: T[], query: SearchFilters): T[];
|
|
79
76
|
/**
|
|
80
77
|
* Performs a client-side sort from the equivalent server-side lucene sort
|
|
81
78
|
* parameters.
|
|
@@ -84,12 +81,12 @@ export declare const runQuery: (docs: Record<string, any>[], query: SearchFilter
|
|
|
84
81
|
* @param sortOrder the sort order ("ascending" or "descending")
|
|
85
82
|
* @param sortType the type of sort ("string" or "number")
|
|
86
83
|
*/
|
|
87
|
-
export declare
|
|
84
|
+
export declare function sort<T extends Record<string, any>>(docs: T[], sort: keyof T, sortOrder: SortOrder, sortType?: SortType): T[];
|
|
88
85
|
/**
|
|
89
86
|
* Limits the specified docs to the specified number of rows from the equivalent
|
|
90
87
|
* server-side lucene limit parameters.
|
|
91
88
|
* @param docs the data
|
|
92
89
|
* @param limit the number of docs to limit to
|
|
93
90
|
*/
|
|
94
|
-
export declare
|
|
91
|
+
export declare function limit<T>(docs: T[], limit: string): T[];
|
|
95
92
|
export declare const hasFilters: (query?: SearchFilters) => boolean;
|
package/dist/index.js
CHANGED
|
@@ -10891,7 +10891,7 @@ function fixupFilterArrays(filters) {
|
|
|
10891
10891
|
recurseLogicalOperators(filters, fixupFilterArrays);
|
|
10892
10892
|
return filters;
|
|
10893
10893
|
}
|
|
10894
|
-
|
|
10894
|
+
function search(docs, query) {
|
|
10895
10895
|
let result = runQuery(docs, query.query);
|
|
10896
10896
|
if (query.sort) {
|
|
10897
10897
|
result = sort(result, query.sort, query.sortOrder || "ascending" /* ASCENDING */);
|
|
@@ -10905,8 +10905,8 @@ var search = (docs, query) => {
|
|
|
10905
10905
|
response.totalRows = totalRows;
|
|
10906
10906
|
}
|
|
10907
10907
|
return response;
|
|
10908
|
-
}
|
|
10909
|
-
|
|
10908
|
+
}
|
|
10909
|
+
function runQuery(docs, query) {
|
|
10910
10910
|
if (!docs || !Array.isArray(docs)) {
|
|
10911
10911
|
return [];
|
|
10912
10912
|
}
|
|
@@ -10920,7 +10920,7 @@ var runQuery = (docs, query, findInDoc = deepGet) => {
|
|
|
10920
10920
|
}
|
|
10921
10921
|
const match = (type, test) => (doc) => {
|
|
10922
10922
|
for (const [key, testValue] of Object.entries(query[type] || {})) {
|
|
10923
|
-
const valueToCheck = isLogicalSearchOperator(type) ? doc :
|
|
10923
|
+
const valueToCheck = isLogicalSearchOperator(type) ? doc : deepGet(doc, removeKeyNumbering(key));
|
|
10924
10924
|
const result = test(valueToCheck, testValue);
|
|
10925
10925
|
if (query.allOr && result) {
|
|
10926
10926
|
return true;
|
|
@@ -11144,8 +11144,8 @@ var runQuery = (docs, query, findInDoc = deepGet) => {
|
|
|
11144
11144
|
}
|
|
11145
11145
|
};
|
|
11146
11146
|
return docs.filter(docMatch);
|
|
11147
|
-
}
|
|
11148
|
-
|
|
11147
|
+
}
|
|
11148
|
+
function sort(docs, sort2, sortOrder, sortType = "string" /* STRING */) {
|
|
11149
11149
|
if (!sort2 || !sortOrder || !sortType) {
|
|
11150
11150
|
return docs;
|
|
11151
11151
|
}
|
|
@@ -11167,14 +11167,14 @@ var sort = (docs, sort2, sortOrder, sortType = "string" /* STRING */) => {
|
|
|
11167
11167
|
}
|
|
11168
11168
|
return result;
|
|
11169
11169
|
});
|
|
11170
|
-
}
|
|
11171
|
-
|
|
11170
|
+
}
|
|
11171
|
+
function limit(docs, limit2) {
|
|
11172
11172
|
const numLimit = parseFloat(limit2);
|
|
11173
11173
|
if (isNaN(numLimit)) {
|
|
11174
11174
|
return docs;
|
|
11175
11175
|
}
|
|
11176
11176
|
return docs.slice(0, numLimit);
|
|
11177
|
-
}
|
|
11177
|
+
}
|
|
11178
11178
|
var hasFilters = (query) => {
|
|
11179
11179
|
if (!query) {
|
|
11180
11180
|
return false;
|