@budibase/shared-core 2.4.8-alpha.0 → 2.4.8-alpha.3

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.
Files changed (39) hide show
  1. package/LICENSE +7 -0
  2. package/dist/cjs/package.json +30 -0
  3. package/dist/cjs/src/constants.d.ts +68 -0
  4. package/dist/cjs/src/constants.js +72 -0
  5. package/dist/cjs/src/constants.js.map +1 -0
  6. package/dist/cjs/src/filters.d.ts +93 -0
  7. package/dist/cjs/src/filters.js +355 -0
  8. package/dist/cjs/src/filters.js.map +1 -0
  9. package/dist/cjs/src/helpers.d.ts +13 -0
  10. package/dist/cjs/src/helpers.js +28 -0
  11. package/dist/cjs/src/helpers.js.map +1 -0
  12. package/dist/cjs/src/index.d.ts +4 -0
  13. package/dist/cjs/src/index.js +34 -0
  14. package/dist/cjs/src/index.js.map +1 -0
  15. package/dist/cjs/src/utils.d.ts +1 -0
  16. package/dist/cjs/src/utils.js +8 -0
  17. package/dist/cjs/src/utils.js.map +1 -0
  18. package/dist/cjs/tsconfig-cjs.build.tsbuildinfo +1 -0
  19. package/dist/mjs/package.json +30 -0
  20. package/dist/mjs/src/constants.d.ts +68 -0
  21. package/dist/mjs/src/constants.js +69 -0
  22. package/dist/mjs/src/constants.js.map +1 -0
  23. package/dist/mjs/src/filters.d.ts +93 -0
  24. package/dist/mjs/src/filters.js +345 -0
  25. package/dist/mjs/src/filters.js.map +1 -0
  26. package/dist/mjs/src/helpers.d.ts +13 -0
  27. package/dist/mjs/src/helpers.js +24 -0
  28. package/dist/mjs/src/helpers.js.map +1 -0
  29. package/dist/mjs/src/index.d.ts +4 -0
  30. package/dist/mjs/src/index.js +5 -0
  31. package/dist/mjs/src/index.js.map +1 -0
  32. package/dist/mjs/src/utils.d.ts +1 -0
  33. package/dist/mjs/src/utils.js +4 -0
  34. package/dist/mjs/src/utils.js.map +1 -0
  35. package/dist/mjs/tsconfig.build.tsbuildinfo +1 -0
  36. package/package.json +17 -9
  37. package/tsconfig-base.build.json +25 -0
  38. package/tsconfig-cjs.build.json +8 -0
  39. package/tsconfig.build.json +5 -22
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2019-2021, Budibase Ltd.
2
+
3
+ Each Budibase package has its own license, please check the license file in each package.
4
+
5
+ You can consider Budibase to be GPLv3 licensed overall.
6
+
7
+ The apps that you build with Budibase do not package any GPLv3 licensed code, thus do not fall under those restrictions.
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@budibase/shared-core",
3
+ "version": "2.4.8-alpha.2",
4
+ "description": "Shared data utils",
5
+ "main": "dist/cjs/src/index.js",
6
+ "types": "dist/mjs/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/mjs/src/index.js",
10
+ "require": "./dist/cjs/src/index.js"
11
+ },
12
+ "./package.json": "./dist/mjs/package.json"
13
+ },
14
+ "author": "Budibase",
15
+ "license": "GPL-3.0",
16
+ "scripts": {
17
+ "prebuild": "rimraf dist/",
18
+ "build": "tsc -p tsconfig.build.json && tsc -p tsconfig-cjs.build.json",
19
+ "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
20
+ "dev:builder": "yarn prebuild && concurrently \"tsc -p tsconfig.build.json --watch\" \"tsc -p tsconfig-cjs.build.json --watch\""
21
+ },
22
+ "dependencies": {
23
+ "@budibase/types": "2.4.5-alpha.0"
24
+ },
25
+ "devDependencies": {
26
+ "concurrently": "^7.6.0",
27
+ "typescript": "4.7.3",
28
+ "rimraf": "3.0.2"
29
+ }
30
+ }
@@ -0,0 +1,68 @@
1
+ export declare const OperatorOptions: {
2
+ Equals: {
3
+ value: string;
4
+ label: string;
5
+ };
6
+ NotEquals: {
7
+ value: string;
8
+ label: string;
9
+ };
10
+ Empty: {
11
+ value: string;
12
+ label: string;
13
+ };
14
+ NotEmpty: {
15
+ value: string;
16
+ label: string;
17
+ };
18
+ StartsWith: {
19
+ value: string;
20
+ label: string;
21
+ };
22
+ Like: {
23
+ value: string;
24
+ label: string;
25
+ };
26
+ MoreThan: {
27
+ value: string;
28
+ label: string;
29
+ };
30
+ LessThan: {
31
+ value: string;
32
+ label: string;
33
+ };
34
+ Contains: {
35
+ value: string;
36
+ label: string;
37
+ };
38
+ NotContains: {
39
+ value: string;
40
+ label: string;
41
+ };
42
+ In: {
43
+ value: string;
44
+ label: string;
45
+ };
46
+ ContainsAny: {
47
+ value: string;
48
+ label: string;
49
+ };
50
+ };
51
+ export declare const SqlNumberTypeRangeMap: {
52
+ integer: {
53
+ max: number;
54
+ min: number;
55
+ };
56
+ int: {
57
+ max: number;
58
+ min: number;
59
+ };
60
+ smallint: {
61
+ max: number;
62
+ min: number;
63
+ };
64
+ mediumint: {
65
+ max: number;
66
+ min: number;
67
+ };
68
+ };
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SqlNumberTypeRangeMap = exports.OperatorOptions = void 0;
4
+ exports.OperatorOptions = {
5
+ Equals: {
6
+ value: "equal",
7
+ label: "Equals",
8
+ },
9
+ NotEquals: {
10
+ value: "notEqual",
11
+ label: "Not equals",
12
+ },
13
+ Empty: {
14
+ value: "empty",
15
+ label: "Is empty",
16
+ },
17
+ NotEmpty: {
18
+ value: "notEmpty",
19
+ label: "Is not empty",
20
+ },
21
+ StartsWith: {
22
+ value: "string",
23
+ label: "Starts with",
24
+ },
25
+ Like: {
26
+ value: "fuzzy",
27
+ label: "Like",
28
+ },
29
+ MoreThan: {
30
+ value: "rangeLow",
31
+ label: "More than or equal to",
32
+ },
33
+ LessThan: {
34
+ value: "rangeHigh",
35
+ label: "Less than or equal to",
36
+ },
37
+ Contains: {
38
+ value: "contains",
39
+ label: "Contains",
40
+ },
41
+ NotContains: {
42
+ value: "notContains",
43
+ label: "Does not contain",
44
+ },
45
+ In: {
46
+ value: "oneOf",
47
+ label: "Is in",
48
+ },
49
+ ContainsAny: {
50
+ value: "containsAny",
51
+ label: "Has any",
52
+ },
53
+ };
54
+ exports.SqlNumberTypeRangeMap = {
55
+ integer: {
56
+ max: 2147483647,
57
+ min: -2147483648,
58
+ },
59
+ int: {
60
+ max: 2147483647,
61
+ min: -2147483648,
62
+ },
63
+ smallint: {
64
+ max: 32767,
65
+ min: -32768,
66
+ },
67
+ mediumint: {
68
+ max: 8388607,
69
+ min: -8388608,
70
+ },
71
+ };
72
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG;IAC7B,MAAM,EAAE;QACN,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,QAAQ;KAChB;IACD,SAAS,EAAE;QACT,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,YAAY;KACpB;IACD,KAAK,EAAE;QACL,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,UAAU;KAClB;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,cAAc;KACtB;IACD,UAAU,EAAE;QACV,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,aAAa;KACrB;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,MAAM;KACd;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,uBAAuB;KAC/B;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,WAAW;QAClB,KAAK,EAAE,uBAAuB;KAC/B;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,UAAU;KAClB;IACD,WAAW,EAAE;QACX,KAAK,EAAE,aAAa;QACpB,KAAK,EAAE,kBAAkB;KAC1B;IACD,EAAE,EAAE;QACF,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,OAAO;KACf;IACD,WAAW,EAAE;QACX,KAAK,EAAE,aAAa;QACpB,KAAK,EAAE,SAAS;KACjB;CACF,CAAA;AAEY,QAAA,qBAAqB,GAAG;IACnC,OAAO,EAAE;QACP,GAAG,EAAE,UAAU;QACf,GAAG,EAAE,CAAC,UAAU;KACjB;IACD,GAAG,EAAE;QACH,GAAG,EAAE,UAAU;QACf,GAAG,EAAE,CAAC,UAAU;KACjB;IACD,QAAQ,EAAE;QACR,GAAG,EAAE,KAAK;QACV,GAAG,EAAE,CAAC,KAAK;KACZ;IACD,SAAS,EAAE;QACT,GAAG,EAAE,OAAO;QACZ,GAAG,EAAE,CAAC,OAAO;KACd;CACF,CAAA"}
@@ -0,0 +1,93 @@
1
+ import { Datasource, FieldType, SortDirection, SortType } from "@budibase/types";
2
+ import { SqlNumberTypeRangeMap } from "./constants";
3
+ /**
4
+ * Returns the valid operator options for a certain data type
5
+ * @param type the data type
6
+ */
7
+ export declare const getValidOperatorsForType: (type: FieldType, field: string, datasource: Datasource & {
8
+ tableId: any;
9
+ }) => {
10
+ value: string;
11
+ label: string;
12
+ }[];
13
+ /**
14
+ * Operators which do not support empty strings as values
15
+ */
16
+ export declare const NoEmptyFilterStrings: (keyof QueryFields)[];
17
+ declare type Filter = {
18
+ operator: keyof Query;
19
+ field: string;
20
+ type: any;
21
+ value: any;
22
+ externalType: keyof typeof SqlNumberTypeRangeMap;
23
+ };
24
+ declare type Query = QueryFields & QueryConfig;
25
+ declare type QueryFields = {
26
+ string?: {
27
+ [key: string]: string;
28
+ };
29
+ fuzzy?: {
30
+ [key: string]: string;
31
+ };
32
+ range?: {
33
+ [key: string]: {
34
+ high: number | string;
35
+ low: number | string;
36
+ };
37
+ };
38
+ equal?: {
39
+ [key: string]: any;
40
+ };
41
+ notEqual?: {
42
+ [key: string]: any;
43
+ };
44
+ empty?: {
45
+ [key: string]: any;
46
+ };
47
+ notEmpty?: {
48
+ [key: string]: any;
49
+ };
50
+ oneOf?: {
51
+ [key: string]: any[];
52
+ };
53
+ contains?: {
54
+ [key: string]: any[];
55
+ };
56
+ notContains?: {
57
+ [key: string]: any[];
58
+ };
59
+ containsAny?: {
60
+ [key: string]: any[];
61
+ };
62
+ };
63
+ declare type QueryConfig = {
64
+ allOr?: boolean;
65
+ };
66
+ /**
67
+ * Builds a lucene JSON query from the filter structure generated in the builder
68
+ * @param filter the builder filter structure
69
+ */
70
+ export declare const buildLuceneQuery: (filter: Filter[]) => Query;
71
+ /**
72
+ * Performs a client-side lucene search on an array of data
73
+ * @param docs the data
74
+ * @param query the JSON lucene query
75
+ */
76
+ export declare const runLuceneQuery: (docs: any[], query?: Query) => any[];
77
+ /**
78
+ * Performs a client-side sort from the equivalent server-side lucene sort
79
+ * parameters.
80
+ * @param docs the data
81
+ * @param sort the sort column
82
+ * @param sortOrder the sort order ("ascending" or "descending")
83
+ * @param sortType the type of sort ("string" or "number")
84
+ */
85
+ export declare const luceneSort: (docs: any[], sort: string, sortOrder: SortDirection, sortType?: SortType) => any[];
86
+ /**
87
+ * Limits the specified docs to the specified number of rows from the equivalent
88
+ * server-side lucene limit parameters.
89
+ * @param docs the data
90
+ * @param limit the number of docs to limit to
91
+ */
92
+ export declare const luceneLimit: (docs: any[], limit: string) => any[];
93
+ export {};
@@ -0,0 +1,355 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.luceneLimit = exports.luceneSort = exports.runLuceneQuery = exports.buildLuceneQuery = exports.NoEmptyFilterStrings = exports.getValidOperatorsForType = void 0;
4
+ const types_1 = require("@budibase/types");
5
+ const constants_1 = require("./constants");
6
+ const helpers_1 = require("./helpers");
7
+ const HBS_REGEX = /{{([^{].*?)}}/g;
8
+ /**
9
+ * Returns the valid operator options for a certain data type
10
+ * @param type the data type
11
+ */
12
+ const getValidOperatorsForType = (type, field, datasource // TODO: is this table id ever populated?
13
+ ) => {
14
+ var _a;
15
+ const Op = constants_1.OperatorOptions;
16
+ const stringOps = [
17
+ Op.Equals,
18
+ Op.NotEquals,
19
+ Op.StartsWith,
20
+ Op.Like,
21
+ Op.Empty,
22
+ Op.NotEmpty,
23
+ Op.In,
24
+ ];
25
+ const numOps = [
26
+ Op.Equals,
27
+ Op.NotEquals,
28
+ Op.MoreThan,
29
+ Op.LessThan,
30
+ Op.Empty,
31
+ Op.NotEmpty,
32
+ Op.In,
33
+ ];
34
+ let ops = [];
35
+ if (type === "string") {
36
+ ops = stringOps;
37
+ }
38
+ else if (type === "number") {
39
+ ops = numOps;
40
+ }
41
+ else if (type === "options") {
42
+ ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.In];
43
+ }
44
+ else if (type === "array") {
45
+ ops = [Op.Contains, Op.NotContains, Op.Empty, Op.NotEmpty, Op.ContainsAny];
46
+ }
47
+ else if (type === "boolean") {
48
+ ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty];
49
+ }
50
+ else if (type === "longform") {
51
+ ops = stringOps;
52
+ }
53
+ else if (type === "datetime") {
54
+ ops = numOps;
55
+ }
56
+ else if (type === "formula") {
57
+ ops = stringOps.concat([Op.MoreThan, Op.LessThan]);
58
+ }
59
+ // Filter out "like" for internal tables
60
+ const externalTable = (_a = datasource === null || datasource === void 0 ? void 0 : datasource.tableId) === null || _a === void 0 ? void 0 : _a.includes("datasource_plus");
61
+ if ((datasource === null || datasource === void 0 ? void 0 : datasource.type) === "table" && !externalTable) {
62
+ ops = ops.filter(x => x !== Op.Like);
63
+ }
64
+ // Only allow equal/not equal for _id in SQL tables
65
+ if (field === "_id" && externalTable) {
66
+ ops = [Op.Equals, Op.NotEquals];
67
+ }
68
+ return ops;
69
+ };
70
+ exports.getValidOperatorsForType = getValidOperatorsForType;
71
+ /**
72
+ * Operators which do not support empty strings as values
73
+ */
74
+ exports.NoEmptyFilterStrings = [
75
+ constants_1.OperatorOptions.StartsWith.value,
76
+ constants_1.OperatorOptions.Like.value,
77
+ constants_1.OperatorOptions.Equals.value,
78
+ constants_1.OperatorOptions.NotEquals.value,
79
+ constants_1.OperatorOptions.Contains.value,
80
+ constants_1.OperatorOptions.NotContains.value,
81
+ ];
82
+ /**
83
+ * Removes any fields that contain empty strings that would cause inconsistent
84
+ * behaviour with how backend tables are filtered (no value means no filter).
85
+ */
86
+ const cleanupQuery = (query) => {
87
+ if (!query) {
88
+ return query;
89
+ }
90
+ for (let filterField of exports.NoEmptyFilterStrings) {
91
+ if (!query[filterField]) {
92
+ continue;
93
+ }
94
+ for (let [key, value] of Object.entries(query[filterField])) {
95
+ if (value == null || value === "") {
96
+ delete query[filterField][key];
97
+ }
98
+ }
99
+ }
100
+ return query;
101
+ };
102
+ /**
103
+ * Removes a numeric prefix on field names designed to give fields uniqueness
104
+ */
105
+ const removeKeyNumbering = (key) => {
106
+ if (typeof key === "string" && key.match(/\d[0-9]*:/g) != null) {
107
+ const parts = key.split(":");
108
+ parts.shift();
109
+ return parts.join(":");
110
+ }
111
+ else {
112
+ return key;
113
+ }
114
+ };
115
+ /**
116
+ * Builds a lucene JSON query from the filter structure generated in the builder
117
+ * @param filter the builder filter structure
118
+ */
119
+ const buildLuceneQuery = (filter) => {
120
+ let query = {
121
+ string: {},
122
+ fuzzy: {},
123
+ range: {},
124
+ equal: {},
125
+ notEqual: {},
126
+ empty: {},
127
+ notEmpty: {},
128
+ contains: {},
129
+ notContains: {},
130
+ oneOf: {},
131
+ containsAny: {},
132
+ };
133
+ if (Array.isArray(filter)) {
134
+ filter.forEach(expression => {
135
+ var _a, _b, _c;
136
+ let { operator, field, type, value, externalType } = expression;
137
+ const isHbs = typeof value === "string" && (value.match(HBS_REGEX) || []).length > 0;
138
+ // Parse all values into correct types
139
+ if (operator === "allOr") {
140
+ query.allOr = true;
141
+ return;
142
+ }
143
+ if (type === "datetime" &&
144
+ !isHbs &&
145
+ operator !== "empty" &&
146
+ operator !== "notEmpty") {
147
+ // Ensure date value is a valid date and parse into correct format
148
+ if (!value) {
149
+ return;
150
+ }
151
+ try {
152
+ value = new Date(value).toISOString();
153
+ }
154
+ catch (error) {
155
+ return;
156
+ }
157
+ }
158
+ if (type === "number" && typeof value === "string") {
159
+ if (operator === "oneOf") {
160
+ value = value.split(",").map(item => parseFloat(item));
161
+ }
162
+ else if (!isHbs) {
163
+ value = parseFloat(value);
164
+ }
165
+ }
166
+ if (type === "boolean") {
167
+ value = ((_a = `${value}`) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "true";
168
+ }
169
+ if (["contains", "notContains", "containsAny"].includes(operator) &&
170
+ type === "array" &&
171
+ typeof value === "string") {
172
+ value = value.split(",");
173
+ }
174
+ if (operator.startsWith("range") && query.range) {
175
+ const minint = ((_b = constants_1.SqlNumberTypeRangeMap[externalType]) === null || _b === void 0 ? void 0 : _b.min) || Number.MIN_SAFE_INTEGER;
176
+ const maxint = ((_c = constants_1.SqlNumberTypeRangeMap[externalType]) === null || _c === void 0 ? void 0 : _c.max) || Number.MAX_SAFE_INTEGER;
177
+ if (!query.range[field]) {
178
+ query.range[field] = {
179
+ low: type === "number" ? minint : "0000-00-00T00:00:00.000Z",
180
+ high: type === "number" ? maxint : "9999-00-00T00:00:00.000Z",
181
+ };
182
+ }
183
+ if (operator === "rangeLow" && value != null && value !== "") {
184
+ query.range[field].low = value;
185
+ }
186
+ else if (operator === "rangeHigh" &&
187
+ value != null &&
188
+ value !== "") {
189
+ query.range[field].high = value;
190
+ }
191
+ }
192
+ else if (query[operator]) {
193
+ if (type === "boolean") {
194
+ // Transform boolean filters to cope with null.
195
+ // "equals false" needs to be "not equals true"
196
+ // "not equals false" needs to be "equals true"
197
+ if (operator === "equal" && value === false) {
198
+ query.notEqual = query.notEqual || {};
199
+ query.notEqual[field] = true;
200
+ }
201
+ else if (operator === "notEqual" && value === false) {
202
+ query.equal = query.equal || {};
203
+ query.equal[field] = true;
204
+ }
205
+ else {
206
+ query[operator] = query[operator] || {};
207
+ query[operator][field] = value;
208
+ }
209
+ }
210
+ else {
211
+ query[operator] = query[operator] || {};
212
+ query[operator][field] = value;
213
+ }
214
+ }
215
+ });
216
+ }
217
+ return query;
218
+ };
219
+ exports.buildLuceneQuery = buildLuceneQuery;
220
+ /**
221
+ * Performs a client-side lucene search on an array of data
222
+ * @param docs the data
223
+ * @param query the JSON lucene query
224
+ */
225
+ const runLuceneQuery = (docs, query) => {
226
+ if (!docs || !Array.isArray(docs)) {
227
+ return [];
228
+ }
229
+ if (!query) {
230
+ return docs;
231
+ }
232
+ // Make query consistent first
233
+ query = cleanupQuery(query);
234
+ // Iterates over a set of filters and evaluates a fail function against a doc
235
+ const match = (type, failFn) => (doc) => {
236
+ const filters = Object.entries(query[type] || {});
237
+ for (let i = 0; i < filters.length; i++) {
238
+ const [key, testValue] = filters[i];
239
+ const docValue = (0, helpers_1.deepGet)(doc, removeKeyNumbering(key));
240
+ if (failFn(docValue, testValue)) {
241
+ return false;
242
+ }
243
+ }
244
+ return true;
245
+ };
246
+ // Process a string match (fails if the value does not start with the string)
247
+ const stringMatch = match("string", (docValue, testValue) => {
248
+ return (!docValue || !(docValue === null || docValue === void 0 ? void 0 : docValue.toLowerCase().startsWith(testValue === null || testValue === void 0 ? void 0 : testValue.toLowerCase())));
249
+ });
250
+ // Process a fuzzy match (treat the same as starts with when running locally)
251
+ const fuzzyMatch = match("fuzzy", (docValue, testValue) => {
252
+ return (!docValue || !(docValue === null || docValue === void 0 ? void 0 : docValue.toLowerCase().startsWith(testValue === null || testValue === void 0 ? void 0 : testValue.toLowerCase())));
253
+ });
254
+ // Process a range match
255
+ const rangeMatch = match("range", (docValue, testValue) => {
256
+ return (docValue == null ||
257
+ docValue === "" ||
258
+ docValue < testValue.low ||
259
+ docValue > testValue.high);
260
+ });
261
+ // Process an equal match (fails if the value is different)
262
+ const equalMatch = match("equal", (docValue, testValue) => {
263
+ return testValue != null && testValue !== "" && docValue !== testValue;
264
+ });
265
+ // Process a not-equal match (fails if the value is the same)
266
+ const notEqualMatch = match("notEqual", (docValue, testValue) => {
267
+ return testValue != null && testValue !== "" && docValue === testValue;
268
+ });
269
+ // Process an empty match (fails if the value is not empty)
270
+ const emptyMatch = match("empty", (docValue) => {
271
+ return docValue != null && docValue !== "";
272
+ });
273
+ // Process a not-empty match (fails is the value is empty)
274
+ const notEmptyMatch = match("notEmpty", (docValue) => {
275
+ return docValue == null || docValue === "";
276
+ });
277
+ // Process an includes match (fails if the value is not included)
278
+ const oneOf = match("oneOf", (docValue, testValue) => {
279
+ if (typeof testValue === "string") {
280
+ testValue = testValue.split(",");
281
+ if (typeof docValue === "number") {
282
+ testValue = testValue.map((item) => parseFloat(item));
283
+ }
284
+ }
285
+ return !(testValue === null || testValue === void 0 ? void 0 : testValue.includes(docValue));
286
+ });
287
+ const containsAny = match("containsAny", (docValue, testValue) => {
288
+ return !(docValue === null || docValue === void 0 ? void 0 : docValue.includes(...testValue));
289
+ });
290
+ const contains = match("contains", (docValue, testValue) => {
291
+ return !(testValue === null || testValue === void 0 ? void 0 : testValue.every((item) => docValue === null || docValue === void 0 ? void 0 : docValue.includes(item)));
292
+ });
293
+ const notContains = match("notContains", (docValue, testValue) => {
294
+ return testValue === null || testValue === void 0 ? void 0 : testValue.every((item) => docValue === null || docValue === void 0 ? void 0 : docValue.includes(item));
295
+ });
296
+ // Match a document against all criteria
297
+ const docMatch = (doc) => {
298
+ return (stringMatch(doc) &&
299
+ fuzzyMatch(doc) &&
300
+ rangeMatch(doc) &&
301
+ equalMatch(doc) &&
302
+ notEqualMatch(doc) &&
303
+ emptyMatch(doc) &&
304
+ notEmptyMatch(doc) &&
305
+ oneOf(doc) &&
306
+ contains(doc) &&
307
+ containsAny(doc) &&
308
+ notContains(doc));
309
+ };
310
+ // Process all docs
311
+ return docs.filter(docMatch);
312
+ };
313
+ exports.runLuceneQuery = runLuceneQuery;
314
+ /**
315
+ * Performs a client-side sort from the equivalent server-side lucene sort
316
+ * parameters.
317
+ * @param docs the data
318
+ * @param sort the sort column
319
+ * @param sortOrder the sort order ("ascending" or "descending")
320
+ * @param sortType the type of sort ("string" or "number")
321
+ */
322
+ const luceneSort = (docs, sort, sortOrder, sortType = types_1.SortType.STRING) => {
323
+ if (!sort || !sortOrder || !sortType) {
324
+ return docs;
325
+ }
326
+ const parse = sortType === "string" ? (x) => `${x}` : (x) => parseFloat(x);
327
+ return docs
328
+ .slice()
329
+ .sort((a, b) => {
330
+ const colA = parse(a[sort]);
331
+ const colB = parse(b[sort]);
332
+ if (sortOrder.toLowerCase() === "descending") {
333
+ return colA > colB ? -1 : 1;
334
+ }
335
+ else {
336
+ return colA > colB ? 1 : -1;
337
+ }
338
+ });
339
+ };
340
+ exports.luceneSort = luceneSort;
341
+ /**
342
+ * Limits the specified docs to the specified number of rows from the equivalent
343
+ * server-side lucene limit parameters.
344
+ * @param docs the data
345
+ * @param limit the number of docs to limit to
346
+ */
347
+ const luceneLimit = (docs, limit) => {
348
+ const numLimit = parseFloat(limit);
349
+ if (isNaN(numLimit)) {
350
+ return docs;
351
+ }
352
+ return docs.slice(0, numLimit);
353
+ };
354
+ exports.luceneLimit = luceneLimit;
355
+ //# sourceMappingURL=filters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../src/filters.ts"],"names":[],"mappings":";;;AAAA,2CAAgF;AAChF,2CAAoE;AACpE,uCAAmC;AAEnC,MAAM,SAAS,GAAG,gBAAgB,CAAA;AAElC;;;GAGG;AACI,MAAM,wBAAwB,GAAG,CACtC,IAAe,EACf,KAAa,EACb,UAAyC,CAAC,yCAAyC;EACnF,EAAE;;IACF,MAAM,EAAE,GAAG,2BAAe,CAAA;IAC1B,MAAM,SAAS,GAAG;QAChB,EAAE,CAAC,MAAM;QACT,EAAE,CAAC,SAAS;QACZ,EAAE,CAAC,UAAU;QACb,EAAE,CAAC,IAAI;QACP,EAAE,CAAC,KAAK;QACR,EAAE,CAAC,QAAQ;QACX,EAAE,CAAC,EAAE;KACN,CAAA;IACD,MAAM,MAAM,GAAG;QACb,EAAE,CAAC,MAAM;QACT,EAAE,CAAC,SAAS;QACZ,EAAE,CAAC,QAAQ;QACX,EAAE,CAAC,QAAQ;QACX,EAAE,CAAC,KAAK;QACR,EAAE,CAAC,QAAQ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".
4
+ * Exact matches of keys with dots in them take precedence over nested keys of
5
+ * the same path - e.g. getting "a.b" from { "a.b": "foo", a: { b: "bar" } }
6
+ * will return "foo" over "bar".
7
+ * @param obj the object
8
+ * @param key the key
9
+ * @return {*|null} the value or null if a value was not found for this key
10
+ */
11
+ export declare const deepGet: (obj: {
12
+ [x: string]: any;
13
+ }, key: string) => any;