@budibase/shared-core 2.8.31-alpha.0 → 2.8.31

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 (55) hide show
  1. package/dist/cjs/src/constants.d.ts +87 -0
  2. package/dist/cjs/src/constants.js +94 -0
  3. package/dist/cjs/src/constants.js.map +1 -0
  4. package/dist/cjs/src/filters.d.ts +94 -0
  5. package/dist/cjs/src/filters.js +367 -0
  6. package/dist/cjs/src/filters.js.map +1 -0
  7. package/dist/cjs/src/helpers/helpers.d.ts +29 -0
  8. package/dist/cjs/src/helpers/helpers.js +90 -0
  9. package/dist/cjs/src/helpers/helpers.js.map +1 -0
  10. package/dist/cjs/src/helpers/index.d.ts +2 -0
  11. package/dist/cjs/src/helpers/index.js +19 -0
  12. package/dist/cjs/src/helpers/index.js.map +1 -0
  13. package/dist/cjs/src/helpers/integrations.d.ts +3 -0
  14. package/dist/cjs/src/helpers/integrations.js +22 -0
  15. package/dist/cjs/src/helpers/integrations.js.map +1 -0
  16. package/dist/cjs/src/index.d.ts +4 -0
  17. package/dist/cjs/src/index.js +34 -0
  18. package/dist/cjs/src/index.js.map +1 -0
  19. package/dist/cjs/src/tsconfig-cjs.build.tsbuildinfo +1 -0
  20. package/dist/cjs/src/utils.d.ts +2 -0
  21. package/dist/cjs/src/utils.js +50 -0
  22. package/dist/cjs/src/utils.js.map +1 -0
  23. package/dist/mjs/src/constants.d.ts +87 -0
  24. package/dist/mjs/src/constants.js +91 -0
  25. package/dist/mjs/src/constants.js.map +1 -0
  26. package/dist/mjs/src/filters.d.ts +94 -0
  27. package/dist/mjs/src/filters.js +356 -0
  28. package/dist/mjs/src/filters.js.map +1 -0
  29. package/dist/mjs/src/helpers/helpers.d.ts +29 -0
  30. package/dist/mjs/src/helpers/helpers.js +82 -0
  31. package/dist/mjs/src/helpers/helpers.js.map +1 -0
  32. package/dist/mjs/src/helpers/index.d.ts +2 -0
  33. package/dist/mjs/src/helpers/index.js +3 -0
  34. package/dist/mjs/src/helpers/index.js.map +1 -0
  35. package/dist/mjs/src/helpers/integrations.d.ts +3 -0
  36. package/dist/mjs/src/helpers/integrations.js +17 -0
  37. package/dist/mjs/src/helpers/integrations.js.map +1 -0
  38. package/dist/mjs/src/index.d.ts +4 -0
  39. package/dist/mjs/src/index.js +5 -0
  40. package/dist/mjs/src/index.js.map +1 -0
  41. package/dist/mjs/src/tsconfig.build.tsbuildinfo +1 -0
  42. package/dist/mjs/src/utils.d.ts +2 -0
  43. package/dist/mjs/src/utils.js +34 -0
  44. package/dist/mjs/src/utils.js.map +1 -0
  45. package/package.json +25 -11
  46. package/src/constants.ts +0 -6
  47. package/src/index.ts +0 -1
  48. package/tsconfig-base.build.json +25 -0
  49. package/tsconfig-cjs.build.json +8 -0
  50. package/tsconfig.build.json +5 -22
  51. package/tsconfig.json +3 -6
  52. package/src/sdk/documents/applications.ts +0 -35
  53. package/src/sdk/documents/index.ts +0 -2
  54. package/src/sdk/documents/users.ts +0 -62
  55. package/src/sdk/index.ts +0 -1
@@ -0,0 +1,87 @@
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
+ };
69
+ export declare enum SocketEvent {
70
+ UserUpdate = "UserUpdate",
71
+ UserDisconnect = "UserDisconnect",
72
+ Heartbeat = "Heartbeat"
73
+ }
74
+ export declare enum GridSocketEvent {
75
+ RowChange = "RowChange",
76
+ TableChange = "TableChange",
77
+ SelectTable = "SelectTable",
78
+ SelectCell = "SelectCell"
79
+ }
80
+ export declare enum BuilderSocketEvent {
81
+ SelectApp = "SelectApp",
82
+ TableChange = "TableChange",
83
+ DatasourceChange = "DatasourceChange",
84
+ LockTransfer = "LockTransfer"
85
+ }
86
+ export declare const SocketSessionTTL = 60;
87
+ export declare const ValidColumnNameRegex: RegExp;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidColumnNameRegex = exports.SocketSessionTTL = exports.BuilderSocketEvent = exports.GridSocketEvent = exports.SocketEvent = 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
+ var SocketEvent;
73
+ (function (SocketEvent) {
74
+ SocketEvent["UserUpdate"] = "UserUpdate";
75
+ SocketEvent["UserDisconnect"] = "UserDisconnect";
76
+ SocketEvent["Heartbeat"] = "Heartbeat";
77
+ })(SocketEvent = exports.SocketEvent || (exports.SocketEvent = {}));
78
+ var GridSocketEvent;
79
+ (function (GridSocketEvent) {
80
+ GridSocketEvent["RowChange"] = "RowChange";
81
+ GridSocketEvent["TableChange"] = "TableChange";
82
+ GridSocketEvent["SelectTable"] = "SelectTable";
83
+ GridSocketEvent["SelectCell"] = "SelectCell";
84
+ })(GridSocketEvent = exports.GridSocketEvent || (exports.GridSocketEvent = {}));
85
+ var BuilderSocketEvent;
86
+ (function (BuilderSocketEvent) {
87
+ BuilderSocketEvent["SelectApp"] = "SelectApp";
88
+ BuilderSocketEvent["TableChange"] = "TableChange";
89
+ BuilderSocketEvent["DatasourceChange"] = "DatasourceChange";
90
+ BuilderSocketEvent["LockTransfer"] = "LockTransfer";
91
+ })(BuilderSocketEvent = exports.BuilderSocketEvent || (exports.BuilderSocketEvent = {}));
92
+ exports.SocketSessionTTL = 60;
93
+ exports.ValidColumnNameRegex = /^[_a-zA-Z0-9\s]*$/g;
94
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants.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CACF,CAAA;AAED,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,gDAAiC,CAAA;IACjC,sCAAuB,CAAA;AACzB,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAED,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,0CAAuB,CAAA;IACvB,8CAA2B,CAAA;IAC3B,8CAA2B,CAAA;IAC3B,4CAAyB,CAAA;AAC3B,CAAC,EALW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAK1B;AAED,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,6CAAuB,CAAA;IACvB,iDAA2B,CAAA;IAC3B,2DAAqC,CAAA;IACrC,mDAA6B,CAAA;AAC/B,CAAC,EALW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAK7B;AAEY,QAAA,gBAAgB,GAAG,EAAE,CAAA;AACrB,QAAA,oBAAoB,GAAG,oBAAoB,CAAA"}
@@ -0,0 +1,94 @@
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 declare const hasFilters: (query?: Query) => boolean;
94
+ export {};
@@ -0,0 +1,367 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasFilters = 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" || type === "bigint") {
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
+ // Only allow equal/not equal for _id in SQL 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 (field === "_id" && externalTable) {
62
+ ops = [Op.Equals, Op.NotEquals, Op.In];
63
+ }
64
+ return ops;
65
+ };
66
+ exports.getValidOperatorsForType = getValidOperatorsForType;
67
+ /**
68
+ * Operators which do not support empty strings as values
69
+ */
70
+ exports.NoEmptyFilterStrings = [
71
+ constants_1.OperatorOptions.StartsWith.value,
72
+ constants_1.OperatorOptions.Like.value,
73
+ constants_1.OperatorOptions.Equals.value,
74
+ constants_1.OperatorOptions.NotEquals.value,
75
+ constants_1.OperatorOptions.Contains.value,
76
+ constants_1.OperatorOptions.NotContains.value,
77
+ ];
78
+ /**
79
+ * Removes any fields that contain empty strings that would cause inconsistent
80
+ * behaviour with how backend tables are filtered (no value means no filter).
81
+ */
82
+ const cleanupQuery = (query) => {
83
+ if (!query) {
84
+ return query;
85
+ }
86
+ for (let filterField of exports.NoEmptyFilterStrings) {
87
+ if (!query[filterField]) {
88
+ continue;
89
+ }
90
+ for (let [key, value] of Object.entries(query[filterField])) {
91
+ if (value == null || value === "") {
92
+ delete query[filterField][key];
93
+ }
94
+ }
95
+ }
96
+ return query;
97
+ };
98
+ /**
99
+ * Removes a numeric prefix on field names designed to give fields uniqueness
100
+ */
101
+ const removeKeyNumbering = (key) => {
102
+ if (typeof key === "string" && key.match(/\d[0-9]*:/g) != null) {
103
+ const parts = key.split(":");
104
+ parts.shift();
105
+ return parts.join(":");
106
+ }
107
+ else {
108
+ return key;
109
+ }
110
+ };
111
+ /**
112
+ * Builds a lucene JSON query from the filter structure generated in the builder
113
+ * @param filter the builder filter structure
114
+ */
115
+ const buildLuceneQuery = (filter) => {
116
+ let query = {
117
+ string: {},
118
+ fuzzy: {},
119
+ range: {},
120
+ equal: {},
121
+ notEqual: {},
122
+ empty: {},
123
+ notEmpty: {},
124
+ contains: {},
125
+ notContains: {},
126
+ oneOf: {},
127
+ containsAny: {},
128
+ };
129
+ if (Array.isArray(filter)) {
130
+ filter.forEach(expression => {
131
+ var _a, _b, _c;
132
+ let { operator, field, type, value, externalType } = expression;
133
+ const isHbs = typeof value === "string" && (value.match(HBS_REGEX) || []).length > 0;
134
+ // Parse all values into correct types
135
+ if (operator === "allOr") {
136
+ query.allOr = true;
137
+ return;
138
+ }
139
+ if (type === "datetime" &&
140
+ !isHbs &&
141
+ operator !== "empty" &&
142
+ operator !== "notEmpty") {
143
+ // Ensure date value is a valid date and parse into correct format
144
+ if (!value) {
145
+ return;
146
+ }
147
+ try {
148
+ value = new Date(value).toISOString();
149
+ }
150
+ catch (error) {
151
+ return;
152
+ }
153
+ }
154
+ if (type === "number" && typeof value === "string") {
155
+ if (operator === "oneOf") {
156
+ value = value.split(",").map(item => parseFloat(item));
157
+ }
158
+ else if (!isHbs) {
159
+ value = parseFloat(value);
160
+ }
161
+ }
162
+ if (type === "boolean") {
163
+ value = ((_a = `${value}`) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "true";
164
+ }
165
+ if (["contains", "notContains", "containsAny"].includes(operator) &&
166
+ type === "array" &&
167
+ typeof value === "string") {
168
+ value = value.split(",");
169
+ }
170
+ if (operator.startsWith("range") && query.range) {
171
+ const minint = ((_b = constants_1.SqlNumberTypeRangeMap[externalType]) === null || _b === void 0 ? void 0 : _b.min) || Number.MIN_SAFE_INTEGER;
172
+ const maxint = ((_c = constants_1.SqlNumberTypeRangeMap[externalType]) === null || _c === void 0 ? void 0 : _c.max) || Number.MAX_SAFE_INTEGER;
173
+ if (!query.range[field]) {
174
+ query.range[field] = {
175
+ low: type === "number" ? minint : "0000-00-00T00:00:00.000Z",
176
+ high: type === "number" ? maxint : "9999-00-00T00:00:00.000Z",
177
+ };
178
+ }
179
+ if (operator === "rangeLow" && value != null && value !== "") {
180
+ query.range[field].low = value;
181
+ }
182
+ else if (operator === "rangeHigh" &&
183
+ value != null &&
184
+ value !== "") {
185
+ query.range[field].high = value;
186
+ }
187
+ }
188
+ else if (query[operator]) {
189
+ if (type === "boolean") {
190
+ // Transform boolean filters to cope with null.
191
+ // "equals false" needs to be "not equals true"
192
+ // "not equals false" needs to be "equals true"
193
+ if (operator === "equal" && value === false) {
194
+ query.notEqual = query.notEqual || {};
195
+ query.notEqual[field] = true;
196
+ }
197
+ else if (operator === "notEqual" && value === false) {
198
+ query.equal = query.equal || {};
199
+ query.equal[field] = true;
200
+ }
201
+ else {
202
+ query[operator] = query[operator] || {};
203
+ query[operator][field] = value;
204
+ }
205
+ }
206
+ else {
207
+ query[operator] = query[operator] || {};
208
+ query[operator][field] = value;
209
+ }
210
+ }
211
+ });
212
+ }
213
+ return query;
214
+ };
215
+ exports.buildLuceneQuery = buildLuceneQuery;
216
+ /**
217
+ * Performs a client-side lucene search on an array of data
218
+ * @param docs the data
219
+ * @param query the JSON lucene query
220
+ */
221
+ const runLuceneQuery = (docs, query) => {
222
+ if (!docs || !Array.isArray(docs)) {
223
+ return [];
224
+ }
225
+ if (!query) {
226
+ return docs;
227
+ }
228
+ // Make query consistent first
229
+ query = cleanupQuery(query);
230
+ // Iterates over a set of filters and evaluates a fail function against a doc
231
+ const match = (type, failFn) => (doc) => {
232
+ const filters = Object.entries(query[type] || {});
233
+ for (let i = 0; i < filters.length; i++) {
234
+ const [key, testValue] = filters[i];
235
+ const docValue = (0, helpers_1.deepGet)(doc, removeKeyNumbering(key));
236
+ if (failFn(docValue, testValue)) {
237
+ return false;
238
+ }
239
+ }
240
+ return true;
241
+ };
242
+ // Process a string match (fails if the value does not start with the string)
243
+ const stringMatch = match("string", (docValue, testValue) => {
244
+ return (!docValue || !(docValue === null || docValue === void 0 ? void 0 : docValue.toLowerCase().startsWith(testValue === null || testValue === void 0 ? void 0 : testValue.toLowerCase())));
245
+ });
246
+ // Process a fuzzy match (treat the same as starts with when running locally)
247
+ const fuzzyMatch = match("fuzzy", (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 range match
251
+ const rangeMatch = match("range", (docValue, testValue) => {
252
+ return (docValue == null ||
253
+ docValue === "" ||
254
+ +docValue < testValue.low ||
255
+ +docValue > testValue.high);
256
+ });
257
+ // Process an equal match (fails if the value is different)
258
+ const equalMatch = match("equal", (docValue, testValue) => {
259
+ return testValue != null && testValue !== "" && docValue !== testValue;
260
+ });
261
+ // Process a not-equal match (fails if the value is the same)
262
+ const notEqualMatch = match("notEqual", (docValue, testValue) => {
263
+ return testValue != null && testValue !== "" && docValue === testValue;
264
+ });
265
+ // Process an empty match (fails if the value is not empty)
266
+ const emptyMatch = match("empty", (docValue) => {
267
+ return docValue != null && docValue !== "";
268
+ });
269
+ // Process a not-empty match (fails is the value is empty)
270
+ const notEmptyMatch = match("notEmpty", (docValue) => {
271
+ return docValue == null || docValue === "";
272
+ });
273
+ // Process an includes match (fails if the value is not included)
274
+ const oneOf = match("oneOf", (docValue, testValue) => {
275
+ if (typeof testValue === "string") {
276
+ testValue = testValue.split(",");
277
+ if (typeof docValue === "number") {
278
+ testValue = testValue.map((item) => parseFloat(item));
279
+ }
280
+ }
281
+ return !(testValue === null || testValue === void 0 ? void 0 : testValue.includes(docValue));
282
+ });
283
+ const containsAny = match("containsAny", (docValue, testValue) => {
284
+ return !(docValue === null || docValue === void 0 ? void 0 : docValue.includes(...testValue));
285
+ });
286
+ const contains = match("contains", (docValue, testValue) => {
287
+ return !(testValue === null || testValue === void 0 ? void 0 : testValue.every((item) => docValue === null || docValue === void 0 ? void 0 : docValue.includes(item)));
288
+ });
289
+ const notContains = match("notContains", (docValue, testValue) => {
290
+ return testValue === null || testValue === void 0 ? void 0 : testValue.every((item) => docValue === null || docValue === void 0 ? void 0 : docValue.includes(item));
291
+ });
292
+ // Match a document against all criteria
293
+ const docMatch = (doc) => {
294
+ return (stringMatch(doc) &&
295
+ fuzzyMatch(doc) &&
296
+ rangeMatch(doc) &&
297
+ equalMatch(doc) &&
298
+ notEqualMatch(doc) &&
299
+ emptyMatch(doc) &&
300
+ notEmptyMatch(doc) &&
301
+ oneOf(doc) &&
302
+ contains(doc) &&
303
+ containsAny(doc) &&
304
+ notContains(doc));
305
+ };
306
+ // Process all docs
307
+ return docs.filter(docMatch);
308
+ };
309
+ exports.runLuceneQuery = runLuceneQuery;
310
+ /**
311
+ * Performs a client-side sort from the equivalent server-side lucene sort
312
+ * parameters.
313
+ * @param docs the data
314
+ * @param sort the sort column
315
+ * @param sortOrder the sort order ("ascending" or "descending")
316
+ * @param sortType the type of sort ("string" or "number")
317
+ */
318
+ const luceneSort = (docs, sort, sortOrder, sortType = types_1.SortType.STRING) => {
319
+ if (!sort || !sortOrder || !sortType) {
320
+ return docs;
321
+ }
322
+ const parse = sortType === "string" ? (x) => `${x}` : (x) => parseFloat(x);
323
+ return docs
324
+ .slice()
325
+ .sort((a, b) => {
326
+ const colA = parse(a[sort]);
327
+ const colB = parse(b[sort]);
328
+ if (sortOrder.toLowerCase() === "descending") {
329
+ return colA > colB ? -1 : 1;
330
+ }
331
+ else {
332
+ return colA > colB ? 1 : -1;
333
+ }
334
+ });
335
+ };
336
+ exports.luceneSort = luceneSort;
337
+ /**
338
+ * Limits the specified docs to the specified number of rows from the equivalent
339
+ * server-side lucene limit parameters.
340
+ * @param docs the data
341
+ * @param limit the number of docs to limit to
342
+ */
343
+ const luceneLimit = (docs, limit) => {
344
+ const numLimit = parseFloat(limit);
345
+ if (isNaN(numLimit)) {
346
+ return docs;
347
+ }
348
+ return docs.slice(0, numLimit);
349
+ };
350
+ exports.luceneLimit = luceneLimit;
351
+ const hasFilters = (query) => {
352
+ if (!query) {
353
+ return false;
354
+ }
355
+ const skipped = ["allOr"];
356
+ for (let [key, value] of Object.entries(query)) {
357
+ if (skipped.includes(key) || typeof value !== "object") {
358
+ continue;
359
+ }
360
+ if (Object.keys(value).length !== 0) {
361
+ return true;
362
+ }
363
+ }
364
+ return false;
365
+ };
366
+ exports.hasFilters = hasFilters;
367
+ //# 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,IAA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