@fibery/expression-utils 9.4.1 → 9.5.1
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/lib/index.d.ts +17 -1
- package/lib/index.js +6 -1
- package/lib/src/filter-expression/index.d.ts +11 -0
- package/lib/src/filter-expression/index.js +42 -0
- package/lib/src/filter-expression/operatorUtils.d.ts +39 -0
- package/lib/src/filter-expression/operatorUtils.js +174 -0
- package/lib/src/filter-expression/operators.d.ts +3017 -0
- package/lib/src/filter-expression/operators.js +717 -0
- package/lib/src/filter-expression/pattern-match.d.ts +17 -0
- package/lib/src/filter-expression/pattern-match.js +134 -0
- package/lib/src/filter-expression/patternMatchPlaceholders.d.ts +59 -0
- package/lib/src/filter-expression/patternMatchPlaceholders.js +143 -0
- package/lib/src/filter-expression/patternToExpression.d.ts +4 -0
- package/lib/src/filter-expression/patternToExpression.js +49 -0
- package/lib/src/filter-expression/types.d.ts +24 -0
- package/lib/src/filter-expression/types.js +2 -0
- package/lib/src/utils.d.ts +6 -0
- package/lib/src/utils.js +34 -1
- package/lib/src/visitors.d.ts +2 -2
- package/package.json +8 -2
|
@@ -0,0 +1,717 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.operatorDateIsWithin = exports.operatorDateIsNotEmptyV2 = exports.operatorDateIsNotEmptyV1 = exports.operatorDateIsEmptyV2 = exports.operatorDateIsEmptyV1 = exports.operatorDateIs = exports.operatorBoolIs = exports.operatorCollectionIsNotEmpty = exports.operatorCollectionIsEmpty = exports.operatorCollectionDoesNotContainAnyOf = exports.operatorCollectionDoesNotContainMe = exports.operatorCollectionDoesNotContain = exports.operatorCollectionContainsAnyOf = exports.withoutLastIdAccess = exports.operatorCollectionContainsMe = exports.operatorCollectionContains = exports.operatorLocationIsNotEmpty = exports.operatorLocationIsEmpty = exports.operatorLocationDoesNotContain = exports.operatorLocationContains = exports.operatorTextIsNotEmptyV2 = exports.operatorTextIsNotEmptyV1 = exports.operatorTextIsEmptyV2 = exports.operatorTextIsEmptyV1 = exports.operatorNumberIsNotEmptyV2 = exports.operatorNumberIsNotEmptyV1 = exports.operatorNumberIsEmptyV2 = exports.operatorNumberIsEmptyV1 = exports.operatorLessThanOrEqual = exports.operatorGreaterThanOrEqual = exports.operatorLessThan = exports.operatorGreaterThan = exports.operatorNumberDoesNotEqual = exports.operatorTextEndsWith = exports.operatorTextStartsWith = exports.operatorTextDoesNotContain = exports.operatorTextContains = exports.operatorTextIsNot = exports.operatorTextExactlyIs = exports.operatorTextIs = exports.operatorUserRoleIsAnyOf = exports.operatorNumberEquals = exports.operatorReferenceIsNotEmpty = exports.operatorReferenceIsEmpty = exports.operatorReferenceIsNoneOf = exports.operatorReferenceIsNot = exports.operatorReferenceIsAnyOf = exports.operatorReferenceIs = exports.operatorReferenceIsNotMe = exports.operatorReferenceIsMe = void 0;
|
|
7
|
+
exports.hiddenValidOperators = exports.operators = exports.operatorsGroups = exports.operatorsGroupsWithoutMe = exports.operatorDateTimeIsOnOrAfter = exports.operatorDateTimeIsOnOrBefore = exports.operatorDateTimeIsAfter = exports.operatorDateTimeIsBefore = exports.operatorDateTimeIsWithin = exports.operatorDateTimeIs = exports.operatorDateIsOnOrAfter = exports.operatorDateIsAfter = exports.operatorDateIsOnOrBefore = exports.operatorDateIsBefore = void 0;
|
|
8
|
+
/* eslint-disable max-lines */
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
+
const uuid_1 = require("uuid");
|
|
11
|
+
const params_placeholders_1 = require("../params-placeholders");
|
|
12
|
+
const operatorUtils_1 = require("./operatorUtils");
|
|
13
|
+
const pattern_match_1 = require("./pattern-match");
|
|
14
|
+
const patternMatchPlaceholders_1 = require("./patternMatchPlaceholders");
|
|
15
|
+
const patternToExpression_1 = require("./patternToExpression");
|
|
16
|
+
const referenceIsMePattern = ["=", patternMatchPlaceholders_1.referenceExpressionPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)((x) => x === "$my-id")];
|
|
17
|
+
const referenceIsNotMePattern = ["!=", patternMatchPlaceholders_1.referenceExpressionPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)((x) => x === "$my-id")];
|
|
18
|
+
const getReferenceMeOperator = ({ id, title, pattern }) => {
|
|
19
|
+
return {
|
|
20
|
+
type: ":operator-type/unary",
|
|
21
|
+
id,
|
|
22
|
+
title,
|
|
23
|
+
customMatch: (where, params, typeObject) => {
|
|
24
|
+
const { matchSuccess, matches } = (0, pattern_match_1.doPatternMatch)(where, params, pattern, typeObject);
|
|
25
|
+
if (matchSuccess) {
|
|
26
|
+
return { matchSuccess, expression: matches[0].value };
|
|
27
|
+
}
|
|
28
|
+
return { matchSuccess: false };
|
|
29
|
+
},
|
|
30
|
+
customConvertToWhereExpression: (expression, value, getNextParamName) => {
|
|
31
|
+
return (0, patternToExpression_1.convertToExpression)(pattern, expression, "$my-id", getNextParamName);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.operatorReferenceIsMe = getReferenceMeOperator({
|
|
36
|
+
id: ":operator/reference-is-me",
|
|
37
|
+
title: "is Me",
|
|
38
|
+
pattern: referenceIsMePattern,
|
|
39
|
+
});
|
|
40
|
+
exports.operatorReferenceIsNotMe = getReferenceMeOperator({
|
|
41
|
+
id: ":operator/reference-is-not-me",
|
|
42
|
+
title: "is not Me",
|
|
43
|
+
pattern: referenceIsNotMePattern,
|
|
44
|
+
});
|
|
45
|
+
function isValidReferenceUUID(val) {
|
|
46
|
+
// nil UUID should be accepted because "11111111-1111-1111-1111-111111111111" is used as
|
|
47
|
+
// non-existing UUID for case when one type has enum type but another type does not
|
|
48
|
+
// temporary disable bcz fix opens up another bugs like unable to create entity with pre-set filters and so on
|
|
49
|
+
// return isUUID.anyNonNil(val) || val === "11111111-1111-1111-1111-111111111111";
|
|
50
|
+
return (0, uuid_1.validate)(val) || (lodash_1.default.isString(val) && (0, params_placeholders_1.isDynamicFilterParam)(val));
|
|
51
|
+
}
|
|
52
|
+
exports.operatorReferenceIs = {
|
|
53
|
+
id: ":operator/reference-is",
|
|
54
|
+
title: "is",
|
|
55
|
+
pattern: ["=", patternMatchPlaceholders_1.referenceExpressionPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)((val) => isValidReferenceUUID(val))],
|
|
56
|
+
type: ":operator-type/binary",
|
|
57
|
+
};
|
|
58
|
+
exports.operatorReferenceIsAnyOf = {
|
|
59
|
+
id: ":operator/reference-is-any-of",
|
|
60
|
+
title: "is any of",
|
|
61
|
+
pattern: ["q/in", patternMatchPlaceholders_1.referenceExpressionPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)((val) => val !== null)],
|
|
62
|
+
type: ":operator-type/binary",
|
|
63
|
+
};
|
|
64
|
+
exports.operatorReferenceIsNot = {
|
|
65
|
+
id: ":operator/reference-is-not",
|
|
66
|
+
title: "is not",
|
|
67
|
+
pattern: ["!=", patternMatchPlaceholders_1.referenceExpressionPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)((val) => isValidReferenceUUID(val))],
|
|
68
|
+
type: ":operator-type/binary",
|
|
69
|
+
};
|
|
70
|
+
exports.operatorReferenceIsNoneOf = {
|
|
71
|
+
id: ":operator/reference-is-none-of",
|
|
72
|
+
title: "is none of",
|
|
73
|
+
pattern: ["q/not-in", patternMatchPlaceholders_1.referenceExpressionPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)((val) => val !== null)],
|
|
74
|
+
type: ":operator-type/binary",
|
|
75
|
+
};
|
|
76
|
+
exports.operatorReferenceIsEmpty = {
|
|
77
|
+
id: ":operator/reference-is-empty",
|
|
78
|
+
title: "is empty",
|
|
79
|
+
pattern: ["=", patternMatchPlaceholders_1.referenceExpressionPlaceholder, (0, patternMatchPlaceholders_1.getConstantPlaceholder)(null)],
|
|
80
|
+
type: ":operator-type/unary",
|
|
81
|
+
};
|
|
82
|
+
exports.operatorReferenceIsNotEmpty = {
|
|
83
|
+
id: ":operator/reference-is-not-empty",
|
|
84
|
+
title: "is not empty",
|
|
85
|
+
pattern: ["!=", patternMatchPlaceholders_1.referenceExpressionPlaceholder, (0, patternMatchPlaceholders_1.getConstantPlaceholder)(null)],
|
|
86
|
+
type: ":operator-type/unary",
|
|
87
|
+
};
|
|
88
|
+
exports.operatorNumberEquals = {
|
|
89
|
+
id: ":operator/equals",
|
|
90
|
+
title: "=",
|
|
91
|
+
pattern: ["=", patternMatchPlaceholders_1.numberFieldPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)((x) => x !== null)],
|
|
92
|
+
type: ":operator-type/binary",
|
|
93
|
+
};
|
|
94
|
+
exports.operatorUserRoleIsAnyOf = {
|
|
95
|
+
id: ":operator/user-role-is-any-of",
|
|
96
|
+
title: "is any of",
|
|
97
|
+
pattern: [
|
|
98
|
+
"q/in",
|
|
99
|
+
patternMatchPlaceholders_1.textFieldPlaceholder,
|
|
100
|
+
(0, patternMatchPlaceholders_1.getParamPlaceholder)((x) => lodash_1.default.isArray(x) && x.every((item) => lodash_1.default.isString(item))),
|
|
101
|
+
],
|
|
102
|
+
type: ":operator-type/binary",
|
|
103
|
+
};
|
|
104
|
+
exports.operatorTextIs = {
|
|
105
|
+
id: ":operator/string-equals",
|
|
106
|
+
title: "is",
|
|
107
|
+
pattern: ["q/equals-ignoring-case?", patternMatchPlaceholders_1.textFieldPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
108
|
+
type: ":operator-type/binary",
|
|
109
|
+
};
|
|
110
|
+
exports.operatorTextExactlyIs = {
|
|
111
|
+
id: ":operator/string-equals-exact",
|
|
112
|
+
title: "=",
|
|
113
|
+
pattern: ["=", patternMatchPlaceholders_1.textFieldPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
114
|
+
type: ":operator-type/binary",
|
|
115
|
+
};
|
|
116
|
+
exports.operatorTextIsNot = {
|
|
117
|
+
id: ":operator/string-not-equals",
|
|
118
|
+
title: "is not",
|
|
119
|
+
pattern: ["q/not-equals-ignoring-case?", patternMatchPlaceholders_1.textFieldPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
120
|
+
type: ":operator-type/binary",
|
|
121
|
+
};
|
|
122
|
+
exports.operatorTextContains = {
|
|
123
|
+
id: ":operator/string-contains",
|
|
124
|
+
title: "contains",
|
|
125
|
+
pattern: ["q/contains", patternMatchPlaceholders_1.textFieldPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
126
|
+
type: ":operator-type/binary",
|
|
127
|
+
};
|
|
128
|
+
exports.operatorTextDoesNotContain = {
|
|
129
|
+
id: ":operator/string-does-not-contain",
|
|
130
|
+
title: "does not contain",
|
|
131
|
+
pattern: ["q/not-contains", patternMatchPlaceholders_1.textFieldPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
132
|
+
type: ":operator-type/binary",
|
|
133
|
+
};
|
|
134
|
+
exports.operatorTextStartsWith = {
|
|
135
|
+
id: ":operator/string-starts-with",
|
|
136
|
+
title: "starts with",
|
|
137
|
+
pattern: ["q/starts-with-ignoring-case?", patternMatchPlaceholders_1.textFieldPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
138
|
+
type: ":operator-type/binary",
|
|
139
|
+
};
|
|
140
|
+
exports.operatorTextEndsWith = {
|
|
141
|
+
id: ":operator/string-ends-with",
|
|
142
|
+
title: "ends with",
|
|
143
|
+
pattern: ["q/ends-with-ignoring-case?", patternMatchPlaceholders_1.textFieldPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
144
|
+
type: ":operator-type/binary",
|
|
145
|
+
};
|
|
146
|
+
exports.operatorNumberDoesNotEqual = {
|
|
147
|
+
id: ":operator/does-not-equal",
|
|
148
|
+
title: "≠",
|
|
149
|
+
pattern: ["!=", patternMatchPlaceholders_1.numberFieldPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)((x) => x !== null)],
|
|
150
|
+
type: ":operator-type/binary",
|
|
151
|
+
};
|
|
152
|
+
exports.operatorGreaterThan = {
|
|
153
|
+
id: ":operator/greater-than",
|
|
154
|
+
title: ">",
|
|
155
|
+
pattern: [">", patternMatchPlaceholders_1.numberFieldPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
156
|
+
type: ":operator-type/binary",
|
|
157
|
+
};
|
|
158
|
+
exports.operatorLessThan = {
|
|
159
|
+
id: ":operator/less-than",
|
|
160
|
+
title: "<",
|
|
161
|
+
pattern: ["<", patternMatchPlaceholders_1.numberFieldPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
162
|
+
type: ":operator-type/binary",
|
|
163
|
+
};
|
|
164
|
+
exports.operatorGreaterThanOrEqual = {
|
|
165
|
+
id: ":operator/greater-than-or-equal",
|
|
166
|
+
title: "≥",
|
|
167
|
+
pattern: [">=", patternMatchPlaceholders_1.numberFieldPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
168
|
+
type: ":operator-type/binary",
|
|
169
|
+
};
|
|
170
|
+
exports.operatorLessThanOrEqual = {
|
|
171
|
+
id: ":operator/less-than-or-equal",
|
|
172
|
+
title: "≤",
|
|
173
|
+
pattern: ["<=", patternMatchPlaceholders_1.numberFieldPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
174
|
+
type: ":operator-type/binary",
|
|
175
|
+
};
|
|
176
|
+
exports.operatorNumberIsEmptyV1 = {
|
|
177
|
+
id: ":operator/number-is-empty",
|
|
178
|
+
title: "is empty",
|
|
179
|
+
pattern: ["=", patternMatchPlaceholders_1.numberFieldPlaceholder, (0, patternMatchPlaceholders_1.getConstantPlaceholder)(null)],
|
|
180
|
+
type: ":operator-type/unary",
|
|
181
|
+
};
|
|
182
|
+
exports.operatorNumberIsEmptyV2 = {
|
|
183
|
+
id: ":operator/number-is-empty",
|
|
184
|
+
title: "is empty",
|
|
185
|
+
pattern: ["=", ["q/null?", patternMatchPlaceholders_1.numberFieldPlaceholder], (0, patternMatchPlaceholders_1.getConstantPlaceholder)(true)],
|
|
186
|
+
type: ":operator-type/unary",
|
|
187
|
+
};
|
|
188
|
+
exports.operatorNumberIsNotEmptyV1 = {
|
|
189
|
+
id: ":operator/number-is-not-empty",
|
|
190
|
+
title: "is not empty",
|
|
191
|
+
pattern: ["!=", patternMatchPlaceholders_1.numberFieldPlaceholder, (0, patternMatchPlaceholders_1.getConstantPlaceholder)(null)],
|
|
192
|
+
type: ":operator-type/unary",
|
|
193
|
+
};
|
|
194
|
+
exports.operatorNumberIsNotEmptyV2 = {
|
|
195
|
+
id: ":operator/number-is-not-empty",
|
|
196
|
+
title: "is not empty",
|
|
197
|
+
pattern: ["=", ["q/null?", patternMatchPlaceholders_1.numberFieldPlaceholder], (0, patternMatchPlaceholders_1.getConstantPlaceholder)(false)],
|
|
198
|
+
type: ":operator-type/unary",
|
|
199
|
+
};
|
|
200
|
+
exports.operatorTextIsEmptyV1 = {
|
|
201
|
+
id: ":operator/text-is-empty",
|
|
202
|
+
title: "is empty",
|
|
203
|
+
pattern: ["=", patternMatchPlaceholders_1.textFieldPlaceholder, (0, patternMatchPlaceholders_1.getConstantPlaceholder)(null)],
|
|
204
|
+
type: ":operator-type/unary",
|
|
205
|
+
};
|
|
206
|
+
exports.operatorTextIsEmptyV2 = {
|
|
207
|
+
id: ":operator/text-is-empty",
|
|
208
|
+
title: "is empty",
|
|
209
|
+
pattern: ["=", ["q/null-or-empty?", patternMatchPlaceholders_1.textFieldPlaceholder], (0, patternMatchPlaceholders_1.getConstantPlaceholder)(true)],
|
|
210
|
+
type: ":operator-type/unary",
|
|
211
|
+
};
|
|
212
|
+
exports.operatorTextIsNotEmptyV1 = {
|
|
213
|
+
id: ":operator/text-is-not-empty",
|
|
214
|
+
title: "is not empty",
|
|
215
|
+
pattern: ["!=", patternMatchPlaceholders_1.textFieldPlaceholder, (0, patternMatchPlaceholders_1.getConstantPlaceholder)(null)],
|
|
216
|
+
type: ":operator-type/unary",
|
|
217
|
+
};
|
|
218
|
+
exports.operatorTextIsNotEmptyV2 = {
|
|
219
|
+
id: ":operator/text-is-not-empty",
|
|
220
|
+
title: "is not empty",
|
|
221
|
+
pattern: ["=", ["q/null-or-empty?", patternMatchPlaceholders_1.textFieldPlaceholder], (0, patternMatchPlaceholders_1.getConstantPlaceholder)(false)],
|
|
222
|
+
type: ":operator-type/unary",
|
|
223
|
+
};
|
|
224
|
+
exports.operatorLocationContains = {
|
|
225
|
+
id: ":operator/location-contains",
|
|
226
|
+
title: "contains",
|
|
227
|
+
pattern: ["q/contains", ["q/address", patternMatchPlaceholders_1.locationFieldPlaceholder], (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
228
|
+
type: ":operator-type/binary",
|
|
229
|
+
};
|
|
230
|
+
exports.operatorLocationDoesNotContain = {
|
|
231
|
+
id: ":operator/location-does-not-contain",
|
|
232
|
+
title: "does not contain",
|
|
233
|
+
pattern: ["q/not-contains", ["q/address", patternMatchPlaceholders_1.locationFieldPlaceholder], (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
234
|
+
type: ":operator-type/binary",
|
|
235
|
+
};
|
|
236
|
+
exports.operatorLocationIsEmpty = {
|
|
237
|
+
id: ":operator/location-is-empty",
|
|
238
|
+
title: "is empty",
|
|
239
|
+
pattern: ["=", patternMatchPlaceholders_1.locationFieldPlaceholder, (0, patternMatchPlaceholders_1.getConstantPlaceholder)(null)],
|
|
240
|
+
type: ":operator-type/unary",
|
|
241
|
+
};
|
|
242
|
+
exports.operatorLocationIsNotEmpty = {
|
|
243
|
+
id: ":operator/location-is-not-empty",
|
|
244
|
+
title: "is not empty",
|
|
245
|
+
pattern: ["!=", patternMatchPlaceholders_1.locationFieldPlaceholder, (0, patternMatchPlaceholders_1.getConstantPlaceholder)(null)],
|
|
246
|
+
type: ":operator-type/unary",
|
|
247
|
+
};
|
|
248
|
+
const getCollectionContainsPattern = (paramMatchFn) => {
|
|
249
|
+
return [
|
|
250
|
+
">",
|
|
251
|
+
{
|
|
252
|
+
"q/from": patternMatchPlaceholders_1.referenceCollectionFieldPlaceholder,
|
|
253
|
+
"q/select": ["q/count", ["fibery/id"]],
|
|
254
|
+
"q/where": ["=", ["fibery/id"], (0, patternMatchPlaceholders_1.getParamPlaceholder)(paramMatchFn)],
|
|
255
|
+
"q/limit": "q/no-limit",
|
|
256
|
+
},
|
|
257
|
+
(0, patternMatchPlaceholders_1.getConstantPlaceholder)(0),
|
|
258
|
+
];
|
|
259
|
+
};
|
|
260
|
+
const getCollectionContainsAnyOfPattern = (comparisonOperator) => [
|
|
261
|
+
comparisonOperator,
|
|
262
|
+
{
|
|
263
|
+
"q/from": patternMatchPlaceholders_1.referenceCollectionFieldPlaceholder,
|
|
264
|
+
"q/select": ["q/count", ["fibery/id"]],
|
|
265
|
+
"q/where": [
|
|
266
|
+
"q/in",
|
|
267
|
+
["fibery/id"],
|
|
268
|
+
(0, patternMatchPlaceholders_1.getParamPlaceholder)((x) => lodash_1.default.isArray(x) && x.every((item) => isValidReferenceUUID(item))),
|
|
269
|
+
],
|
|
270
|
+
"q/limit": "q/no-limit",
|
|
271
|
+
},
|
|
272
|
+
(0, patternMatchPlaceholders_1.getConstantPlaceholder)(0),
|
|
273
|
+
];
|
|
274
|
+
const collectionContainsAnyOfPattern = getCollectionContainsAnyOfPattern(">");
|
|
275
|
+
const collectionDoesNotContainAnyOfPattern = getCollectionContainsAnyOfPattern("=");
|
|
276
|
+
const collectionContainsPattern = getCollectionContainsPattern((x) => isValidReferenceUUID(x));
|
|
277
|
+
const collectionContainsMePattern = getCollectionContainsPattern((x) => x === "$my-id");
|
|
278
|
+
const getCollectionDoesNotContainPattern = (paramMatchFn) => [
|
|
279
|
+
"=",
|
|
280
|
+
{
|
|
281
|
+
"q/from": patternMatchPlaceholders_1.referenceCollectionFieldPlaceholder,
|
|
282
|
+
"q/select": ["q/count", ["fibery/id"]],
|
|
283
|
+
"q/where": ["=", ["fibery/id"], (0, patternMatchPlaceholders_1.getParamPlaceholder)(paramMatchFn)],
|
|
284
|
+
"q/limit": "q/no-limit",
|
|
285
|
+
},
|
|
286
|
+
(0, patternMatchPlaceholders_1.getConstantPlaceholder)(0),
|
|
287
|
+
];
|
|
288
|
+
const collectionDoesNotContainPattern = getCollectionDoesNotContainPattern((x) => isValidReferenceUUID(x));
|
|
289
|
+
const collectionDoesNotContainMePattern = getCollectionDoesNotContainPattern((x) => x === "$my-id");
|
|
290
|
+
exports.operatorCollectionContains = {
|
|
291
|
+
id: ":operator/collection-contains",
|
|
292
|
+
title: "contains",
|
|
293
|
+
customMatch: (where, params, typeObject) => {
|
|
294
|
+
const { matchSuccess, matches } = (0, pattern_match_1.doPatternMatch)(where, params, collectionContainsPattern, typeObject);
|
|
295
|
+
if (matchSuccess) {
|
|
296
|
+
return {
|
|
297
|
+
matchSuccess,
|
|
298
|
+
expression: [...matches[0].value, "fibery/id"],
|
|
299
|
+
value: matches[1].value,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
return { matchSuccess: false };
|
|
303
|
+
},
|
|
304
|
+
customConvertToWhereExpression: (expression, value, getNextParamName) => {
|
|
305
|
+
return (0, patternToExpression_1.convertToExpression)(collectionContainsPattern, (0, exports.withoutLastIdAccess)(expression), value, getNextParamName);
|
|
306
|
+
},
|
|
307
|
+
type: ":operator-type/binary",
|
|
308
|
+
};
|
|
309
|
+
const getOperatorCollectionMe = ({ id, title, pattern }) => ({
|
|
310
|
+
id,
|
|
311
|
+
title,
|
|
312
|
+
customMatch: (where, params, typeObject) => {
|
|
313
|
+
const { matchSuccess, matches } = (0, pattern_match_1.doPatternMatch)(where, params, pattern, typeObject);
|
|
314
|
+
if (matchSuccess) {
|
|
315
|
+
return { matchSuccess, expression: [...matches[0].value, "fibery/id"] };
|
|
316
|
+
}
|
|
317
|
+
return { matchSuccess: false };
|
|
318
|
+
},
|
|
319
|
+
customConvertToWhereExpression: (expression, value, getNextParamName) => {
|
|
320
|
+
return (0, patternToExpression_1.convertToExpression)(pattern, (0, exports.withoutLastIdAccess)(expression), "$my-id", getNextParamName);
|
|
321
|
+
},
|
|
322
|
+
type: ":operator-type/unary",
|
|
323
|
+
});
|
|
324
|
+
exports.operatorCollectionContainsMe = getOperatorCollectionMe({
|
|
325
|
+
id: ":operator/collection-contains-me",
|
|
326
|
+
title: "contains Me",
|
|
327
|
+
pattern: collectionContainsMePattern,
|
|
328
|
+
});
|
|
329
|
+
const withoutLastIdAccess = (expression) => {
|
|
330
|
+
if (!lodash_1.default.last(expression) === "fibery/id") {
|
|
331
|
+
throw new Error("not supported");
|
|
332
|
+
}
|
|
333
|
+
return expression.slice(0, -1);
|
|
334
|
+
};
|
|
335
|
+
exports.withoutLastIdAccess = withoutLastIdAccess;
|
|
336
|
+
exports.operatorCollectionContainsAnyOf = {
|
|
337
|
+
id: ":operator/collection-contains-any-of",
|
|
338
|
+
title: "contains any of",
|
|
339
|
+
customMatch: (where, params, typeObject) => {
|
|
340
|
+
const { matchSuccess, matches } = (0, pattern_match_1.doPatternMatch)(where, params, collectionContainsAnyOfPattern, typeObject);
|
|
341
|
+
if (matchSuccess) {
|
|
342
|
+
return {
|
|
343
|
+
matchSuccess,
|
|
344
|
+
expression: [...matches[0].value, "fibery/id"],
|
|
345
|
+
value: matches[1].value,
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
return { matchSuccess: false };
|
|
349
|
+
},
|
|
350
|
+
customConvertToWhereExpression: (expression, value, getNextParamName) => {
|
|
351
|
+
return (0, patternToExpression_1.convertToExpression)(collectionContainsAnyOfPattern, (0, exports.withoutLastIdAccess)(expression), value, getNextParamName);
|
|
352
|
+
},
|
|
353
|
+
type: ":operator-type/binary",
|
|
354
|
+
};
|
|
355
|
+
exports.operatorCollectionDoesNotContain = {
|
|
356
|
+
id: ":operator/collection-does-not-contain",
|
|
357
|
+
title: "does not contain",
|
|
358
|
+
customMatch: (where, params, typeObject) => {
|
|
359
|
+
const { matchSuccess, matches } = (0, pattern_match_1.doPatternMatch)(where, params, collectionDoesNotContainPattern, typeObject);
|
|
360
|
+
if (matchSuccess) {
|
|
361
|
+
return {
|
|
362
|
+
matchSuccess,
|
|
363
|
+
expression: [...matches[0].value, "fibery/id"],
|
|
364
|
+
value: matches[1].value,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
return { matchSuccess: false };
|
|
368
|
+
},
|
|
369
|
+
customConvertToWhereExpression: (expression, value, getNextParamName) => {
|
|
370
|
+
return (0, patternToExpression_1.convertToExpression)(collectionDoesNotContainPattern, (0, exports.withoutLastIdAccess)(expression), value, getNextParamName);
|
|
371
|
+
},
|
|
372
|
+
type: ":operator-type/binary",
|
|
373
|
+
};
|
|
374
|
+
exports.operatorCollectionDoesNotContainMe = getOperatorCollectionMe({
|
|
375
|
+
id: ":operator/collection-does-not-contain-me",
|
|
376
|
+
title: "does not contain Me",
|
|
377
|
+
pattern: collectionDoesNotContainMePattern,
|
|
378
|
+
});
|
|
379
|
+
exports.operatorCollectionDoesNotContainAnyOf = {
|
|
380
|
+
id: ":operator/collection-does-not-contain-any-of",
|
|
381
|
+
title: "contains none of",
|
|
382
|
+
customMatch: (where, params, typeObject) => {
|
|
383
|
+
const { matchSuccess, matches } = (0, pattern_match_1.doPatternMatch)(where, params, collectionDoesNotContainAnyOfPattern, typeObject);
|
|
384
|
+
if (matchSuccess) {
|
|
385
|
+
return {
|
|
386
|
+
matchSuccess,
|
|
387
|
+
expression: [...matches[0].value, "fibery/id"],
|
|
388
|
+
value: matches[1].value,
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
return { matchSuccess: false };
|
|
392
|
+
},
|
|
393
|
+
customConvertToWhereExpression: (expression, value, getNextParamName) => {
|
|
394
|
+
return (0, patternToExpression_1.convertToExpression)(collectionDoesNotContainAnyOfPattern, (0, exports.withoutLastIdAccess)(expression), value, getNextParamName);
|
|
395
|
+
},
|
|
396
|
+
type: ":operator-type/binary",
|
|
397
|
+
};
|
|
398
|
+
exports.operatorCollectionIsEmpty = {
|
|
399
|
+
id: ":operator/is-collection-empty",
|
|
400
|
+
title: "is empty",
|
|
401
|
+
pattern: ["=", ["q/count", patternMatchPlaceholders_1.referenceCollectionExpressionPlaceholder], (0, patternMatchPlaceholders_1.getConstantPlaceholder)(0)],
|
|
402
|
+
type: ":operator-type/unary",
|
|
403
|
+
};
|
|
404
|
+
exports.operatorCollectionIsNotEmpty = {
|
|
405
|
+
id: ":operator/is-collection-not-empty",
|
|
406
|
+
title: "is not empty",
|
|
407
|
+
pattern: [">", ["q/count", patternMatchPlaceholders_1.referenceCollectionExpressionPlaceholder], (0, patternMatchPlaceholders_1.getConstantPlaceholder)(0)],
|
|
408
|
+
type: ":operator-type/unary",
|
|
409
|
+
};
|
|
410
|
+
exports.operatorBoolIs = {
|
|
411
|
+
id: ":operator/bool-is",
|
|
412
|
+
title: "is",
|
|
413
|
+
customMatch: (where, params, typeObject) => {
|
|
414
|
+
{
|
|
415
|
+
const { matchSuccess, matches } = (0, pattern_match_1.doPatternMatch)(where, params, ["=", patternMatchPlaceholders_1.boolFieldPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)((x) => x === true || x === false)], typeObject);
|
|
416
|
+
if (matchSuccess) {
|
|
417
|
+
return {
|
|
418
|
+
matchSuccess,
|
|
419
|
+
expression: matches[0].value,
|
|
420
|
+
value: matches[1].value,
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
{
|
|
425
|
+
// This is old expression version, just for backward compatibility.
|
|
426
|
+
const { matchSuccess, matches } = (0, pattern_match_1.doPatternMatch)(where, params, [
|
|
427
|
+
"or",
|
|
428
|
+
["=", patternMatchPlaceholders_1.boolFieldPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)((x) => x === false)],
|
|
429
|
+
["=", patternMatchPlaceholders_1.boolFieldPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)((x) => x === null)],
|
|
430
|
+
], typeObject);
|
|
431
|
+
if (matchSuccess) {
|
|
432
|
+
return { matchSuccess, expression: matches[0].value, value: false };
|
|
433
|
+
}
|
|
434
|
+
return { matchSuccess: false };
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
customConvertToWhereExpression: (expression, value, getNextParamName) => {
|
|
438
|
+
const paramName = getNextParamName();
|
|
439
|
+
return {
|
|
440
|
+
expression: ["=", expression, paramName],
|
|
441
|
+
params: { [paramName]: value || false },
|
|
442
|
+
};
|
|
443
|
+
},
|
|
444
|
+
type: ":operator-type/binary",
|
|
445
|
+
};
|
|
446
|
+
exports.operatorDateIs = {
|
|
447
|
+
id: ":operator/date-is",
|
|
448
|
+
title: "is",
|
|
449
|
+
pattern: ["=", patternMatchPlaceholders_1.dateOrDateRangeExpressionPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)((x) => x !== null)],
|
|
450
|
+
type: ":operator-type/binary",
|
|
451
|
+
};
|
|
452
|
+
exports.operatorDateIsEmptyV1 = {
|
|
453
|
+
id: ":operator/date-is-empty",
|
|
454
|
+
title: "is empty",
|
|
455
|
+
pattern: ["=", patternMatchPlaceholders_1.anyDateExpressionPlaceholder, (0, patternMatchPlaceholders_1.getConstantPlaceholder)(null)],
|
|
456
|
+
type: ":operator-type/unary",
|
|
457
|
+
};
|
|
458
|
+
exports.operatorDateIsEmptyV2 = {
|
|
459
|
+
id: ":operator/date-is-empty",
|
|
460
|
+
title: "is empty",
|
|
461
|
+
pattern: ["=", ["q/null?", patternMatchPlaceholders_1.anyDateExpressionPlaceholder], (0, patternMatchPlaceholders_1.getConstantPlaceholder)(true)],
|
|
462
|
+
type: ":operator-type/unary",
|
|
463
|
+
};
|
|
464
|
+
exports.operatorDateIsNotEmptyV1 = {
|
|
465
|
+
id: ":operator/date-is-not-empty",
|
|
466
|
+
title: "is not empty",
|
|
467
|
+
pattern: ["!=", patternMatchPlaceholders_1.anyDateExpressionPlaceholder, (0, patternMatchPlaceholders_1.getConstantPlaceholder)(null)],
|
|
468
|
+
type: ":operator-type/unary",
|
|
469
|
+
};
|
|
470
|
+
exports.operatorDateIsNotEmptyV2 = {
|
|
471
|
+
id: ":operator/date-is-not-empty",
|
|
472
|
+
title: "is not empty",
|
|
473
|
+
pattern: ["=", ["q/null?", patternMatchPlaceholders_1.anyDateExpressionPlaceholder], (0, patternMatchPlaceholders_1.getConstantPlaceholder)(false)],
|
|
474
|
+
type: ":operator-type/unary",
|
|
475
|
+
};
|
|
476
|
+
exports.operatorDateIsWithin = {
|
|
477
|
+
id: ":operator/date-is-within",
|
|
478
|
+
title: "is within",
|
|
479
|
+
customMatch: (0, operatorUtils_1.getWithinOperatorCustomMatchFn)(patternMatchPlaceholders_1.dateOrDateRangeExpressionPlaceholder, false),
|
|
480
|
+
customConvertToWhereExpression: (0, operatorUtils_1.getWithinOperatorCustomConvertFn)(false),
|
|
481
|
+
type: ":operator-type/binary",
|
|
482
|
+
};
|
|
483
|
+
exports.operatorDateIsBefore = {
|
|
484
|
+
id: ":operator/date-is-before",
|
|
485
|
+
title: "is earlier than",
|
|
486
|
+
pattern: ["<", patternMatchPlaceholders_1.dateOrDateRangeExpressionPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
487
|
+
type: ":operator-type/binary",
|
|
488
|
+
};
|
|
489
|
+
exports.operatorDateIsOnOrBefore = {
|
|
490
|
+
id: ":operator/date-is-on-or-before",
|
|
491
|
+
title: "is on or earlier than",
|
|
492
|
+
pattern: ["<=", patternMatchPlaceholders_1.dateOrDateRangeExpressionPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
493
|
+
type: ":operator-type/binary",
|
|
494
|
+
};
|
|
495
|
+
exports.operatorDateIsAfter = {
|
|
496
|
+
id: ":operator/date-is-after",
|
|
497
|
+
title: "is later than",
|
|
498
|
+
pattern: [">", patternMatchPlaceholders_1.dateOrDateRangeExpressionPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
499
|
+
type: ":operator-type/binary",
|
|
500
|
+
};
|
|
501
|
+
exports.operatorDateIsOnOrAfter = {
|
|
502
|
+
id: ":operator/date-is-on-or-after",
|
|
503
|
+
title: "is on or later than",
|
|
504
|
+
pattern: [">=", patternMatchPlaceholders_1.dateOrDateRangeExpressionPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
505
|
+
type: ":operator-type/binary",
|
|
506
|
+
};
|
|
507
|
+
exports.operatorDateTimeIs = {
|
|
508
|
+
id: ":operator/date-time-is",
|
|
509
|
+
title: "is",
|
|
510
|
+
customMatch: (where, params, typeObject) => {
|
|
511
|
+
{
|
|
512
|
+
const { matchSuccess, matches: [firstFieldMatch, firstParamMatch, secondFieldMatch, secondParamMatch], } = (0, pattern_match_1.doPatternMatch)(where, params, [
|
|
513
|
+
"and",
|
|
514
|
+
[">=", patternMatchPlaceholders_1.dateTimeOrDateTimeRangeExpressionPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
515
|
+
["<=", patternMatchPlaceholders_1.dateTimeOrDateTimeRangeExpressionPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)()],
|
|
516
|
+
], typeObject);
|
|
517
|
+
if (matchSuccess && lodash_1.default.isEqual(firstFieldMatch.value, secondFieldMatch.value)) {
|
|
518
|
+
if (params_placeholders_1.paramsPlaceholdersLookup[firstParamMatch.value] && params_placeholders_1.paramsPlaceholdersLookup[secondParamMatch.value]) {
|
|
519
|
+
const value = lodash_1.default.findKey(params_placeholders_1.dateToDateTimeIntervalLookup, (val) => val.start === firstParamMatch.value && val.end === secondParamMatch.value);
|
|
520
|
+
return { matchSuccess, expression: firstFieldMatch.value, value };
|
|
521
|
+
}
|
|
522
|
+
const firstParamRelativeDateInfo = (0, params_placeholders_1.parseRelativeDatePlaceholder)(firstParamMatch.value);
|
|
523
|
+
const secondParamRelativeDateInfo = (0, params_placeholders_1.parseRelativeDatePlaceholder)(secondParamMatch.value);
|
|
524
|
+
if (firstParamRelativeDateInfo && secondParamRelativeDateInfo) {
|
|
525
|
+
const value = (0, params_placeholders_1.toRelativeDatePlaceholder)({
|
|
526
|
+
...firstParamRelativeDateInfo,
|
|
527
|
+
isStartOfInterval: undefined,
|
|
528
|
+
});
|
|
529
|
+
return { matchSuccess, expression: firstFieldMatch.value, value };
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
{
|
|
534
|
+
const { matchSuccess, matches: [fieldMatch, paramMatch], } = (0, pattern_match_1.doPatternMatch)(where, params, ["=", patternMatchPlaceholders_1.dateTimeOrDateTimeRangeExpressionPlaceholder, (0, patternMatchPlaceholders_1.getParamPlaceholder)((x) => lodash_1.default.isString(x) && (0, operatorUtils_1.isDateTime)(x))], typeObject);
|
|
535
|
+
if (matchSuccess) {
|
|
536
|
+
return {
|
|
537
|
+
matchSuccess,
|
|
538
|
+
expression: fieldMatch.value,
|
|
539
|
+
value: paramMatch.value,
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
return { matchSuccess: false };
|
|
544
|
+
},
|
|
545
|
+
customConvertToWhereExpression: (expression, value, getNextParamName) => {
|
|
546
|
+
const dateTimePlaceholders = params_placeholders_1.dateToDateTimeIntervalLookup[value];
|
|
547
|
+
let relativeDateInfo = null;
|
|
548
|
+
if (dateTimePlaceholders) {
|
|
549
|
+
const { start, end } = dateTimePlaceholders;
|
|
550
|
+
return {
|
|
551
|
+
expression: ["and", [">=", expression, start], ["<=", expression, end]],
|
|
552
|
+
params: { [start]: start, [end]: end },
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
else if ((relativeDateInfo = (0, params_placeholders_1.parseRelativeDatePlaceholder)(value))) {
|
|
556
|
+
let startRelativePlaceholder = (0, params_placeholders_1.toRelativeDatePlaceholder)({
|
|
557
|
+
...relativeDateInfo,
|
|
558
|
+
isStartOfInterval: true,
|
|
559
|
+
unitForStart: "day",
|
|
560
|
+
});
|
|
561
|
+
let endRelativePlaceholder = (0, params_placeholders_1.toRelativeDatePlaceholder)({
|
|
562
|
+
...relativeDateInfo,
|
|
563
|
+
isStartOfInterval: false,
|
|
564
|
+
unitForStart: "day",
|
|
565
|
+
});
|
|
566
|
+
return {
|
|
567
|
+
expression: ["and", [">=", expression, startRelativePlaceholder], ["<=", expression, endRelativePlaceholder]],
|
|
568
|
+
params: {
|
|
569
|
+
[startRelativePlaceholder]: startRelativePlaceholder,
|
|
570
|
+
[endRelativePlaceholder]: endRelativePlaceholder,
|
|
571
|
+
},
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
const dateParamName = getNextParamName();
|
|
576
|
+
return {
|
|
577
|
+
expression: ["=", expression, dateParamName],
|
|
578
|
+
params: { [dateParamName]: value },
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
},
|
|
582
|
+
type: ":operator-type/binary",
|
|
583
|
+
};
|
|
584
|
+
exports.operatorDateTimeIsWithin = {
|
|
585
|
+
id: ":operator/date-time-is-within",
|
|
586
|
+
title: "is within",
|
|
587
|
+
customMatch: (0, operatorUtils_1.getWithinOperatorCustomMatchFn)(patternMatchPlaceholders_1.dateTimeOrDateTimeRangeExpressionPlaceholder, true),
|
|
588
|
+
customConvertToWhereExpression: (0, operatorUtils_1.getWithinOperatorCustomConvertFn)(true),
|
|
589
|
+
type: ":operator-type/binary",
|
|
590
|
+
};
|
|
591
|
+
exports.operatorDateTimeIsBefore = (0, operatorUtils_1.getCompareOperatorForDateTime)(":operator/date-time-is-before", "is earlier than", "<", true);
|
|
592
|
+
exports.operatorDateTimeIsAfter = (0, operatorUtils_1.getCompareOperatorForDateTime)(":operator/date-time-is-after", "is later than", ">", false);
|
|
593
|
+
exports.operatorDateTimeIsOnOrBefore = (0, operatorUtils_1.getCompareOperatorForDateTime)(":operator/date-time-is-on-or-before", "is on or earlier than", "<=", false);
|
|
594
|
+
exports.operatorDateTimeIsOnOrAfter = (0, operatorUtils_1.getCompareOperatorForDateTime)(":operator/date-time-is-on-or-after", "is on or later than", ">=", true);
|
|
595
|
+
exports.operatorsGroupsWithoutMe = {
|
|
596
|
+
":filter-type/reference": [
|
|
597
|
+
exports.operatorReferenceIsAnyOf,
|
|
598
|
+
exports.operatorReferenceIsNoneOf,
|
|
599
|
+
exports.operatorReferenceIs,
|
|
600
|
+
exports.operatorReferenceIsNot,
|
|
601
|
+
exports.operatorReferenceIsEmpty,
|
|
602
|
+
exports.operatorReferenceIsNotEmpty,
|
|
603
|
+
],
|
|
604
|
+
":filter-type/user-reference": [
|
|
605
|
+
exports.operatorReferenceIsAnyOf,
|
|
606
|
+
exports.operatorReferenceIsNoneOf,
|
|
607
|
+
exports.operatorReferenceIs,
|
|
608
|
+
exports.operatorReferenceIsNot,
|
|
609
|
+
exports.operatorReferenceIsEmpty,
|
|
610
|
+
exports.operatorReferenceIsNotEmpty,
|
|
611
|
+
],
|
|
612
|
+
":filter-type/single-select": [
|
|
613
|
+
exports.operatorReferenceIsAnyOf,
|
|
614
|
+
exports.operatorReferenceIsNoneOf,
|
|
615
|
+
exports.operatorReferenceIs,
|
|
616
|
+
exports.operatorReferenceIsNot,
|
|
617
|
+
exports.operatorReferenceIsEmpty,
|
|
618
|
+
exports.operatorReferenceIsNotEmpty,
|
|
619
|
+
],
|
|
620
|
+
":filter-type/multi-select": [
|
|
621
|
+
exports.operatorCollectionContainsAnyOf,
|
|
622
|
+
exports.operatorCollectionDoesNotContainAnyOf,
|
|
623
|
+
exports.operatorCollectionContains,
|
|
624
|
+
exports.operatorCollectionDoesNotContain,
|
|
625
|
+
exports.operatorCollectionIsEmpty,
|
|
626
|
+
exports.operatorCollectionIsNotEmpty,
|
|
627
|
+
],
|
|
628
|
+
":filter-type/reference-collection": [
|
|
629
|
+
exports.operatorCollectionContainsAnyOf,
|
|
630
|
+
exports.operatorCollectionDoesNotContainAnyOf,
|
|
631
|
+
exports.operatorCollectionContains,
|
|
632
|
+
exports.operatorCollectionDoesNotContain,
|
|
633
|
+
exports.operatorCollectionIsEmpty,
|
|
634
|
+
exports.operatorCollectionIsNotEmpty,
|
|
635
|
+
],
|
|
636
|
+
":filter-type/user-reference-collection": [
|
|
637
|
+
exports.operatorCollectionContainsAnyOf,
|
|
638
|
+
exports.operatorCollectionDoesNotContainAnyOf,
|
|
639
|
+
exports.operatorCollectionContains,
|
|
640
|
+
exports.operatorCollectionDoesNotContain,
|
|
641
|
+
exports.operatorCollectionIsEmpty,
|
|
642
|
+
exports.operatorCollectionIsNotEmpty,
|
|
643
|
+
],
|
|
644
|
+
":filter-type/text": [
|
|
645
|
+
exports.operatorTextContains,
|
|
646
|
+
exports.operatorTextDoesNotContain,
|
|
647
|
+
exports.operatorTextIs,
|
|
648
|
+
exports.operatorTextIsNot,
|
|
649
|
+
exports.operatorTextStartsWith,
|
|
650
|
+
exports.operatorTextEndsWith,
|
|
651
|
+
exports.operatorTextIsEmptyV2,
|
|
652
|
+
exports.operatorTextIsNotEmptyV2,
|
|
653
|
+
],
|
|
654
|
+
":filter-type/number": [
|
|
655
|
+
exports.operatorNumberEquals,
|
|
656
|
+
exports.operatorNumberDoesNotEqual,
|
|
657
|
+
exports.operatorGreaterThan,
|
|
658
|
+
exports.operatorLessThan,
|
|
659
|
+
exports.operatorGreaterThanOrEqual,
|
|
660
|
+
exports.operatorLessThanOrEqual,
|
|
661
|
+
exports.operatorNumberIsEmptyV2,
|
|
662
|
+
exports.operatorNumberIsNotEmptyV2,
|
|
663
|
+
],
|
|
664
|
+
":filter-type/bool": [exports.operatorBoolIs],
|
|
665
|
+
":filter-type/date": [
|
|
666
|
+
exports.operatorDateIs,
|
|
667
|
+
exports.operatorDateIsWithin,
|
|
668
|
+
exports.operatorDateIsBefore,
|
|
669
|
+
exports.operatorDateIsAfter,
|
|
670
|
+
exports.operatorDateIsOnOrBefore,
|
|
671
|
+
exports.operatorDateIsOnOrAfter,
|
|
672
|
+
exports.operatorDateIsEmptyV2,
|
|
673
|
+
exports.operatorDateIsNotEmptyV2,
|
|
674
|
+
],
|
|
675
|
+
":filter-type/date-time": [
|
|
676
|
+
exports.operatorDateTimeIs,
|
|
677
|
+
exports.operatorDateTimeIsWithin,
|
|
678
|
+
exports.operatorDateTimeIsBefore,
|
|
679
|
+
exports.operatorDateTimeIsAfter,
|
|
680
|
+
exports.operatorDateTimeIsOnOrBefore,
|
|
681
|
+
exports.operatorDateTimeIsOnOrAfter,
|
|
682
|
+
exports.operatorDateIsEmptyV2,
|
|
683
|
+
exports.operatorDateIsNotEmptyV2,
|
|
684
|
+
],
|
|
685
|
+
":filter-type/location": [
|
|
686
|
+
exports.operatorLocationContains,
|
|
687
|
+
exports.operatorLocationDoesNotContain,
|
|
688
|
+
exports.operatorLocationIsEmpty,
|
|
689
|
+
exports.operatorLocationIsNotEmpty,
|
|
690
|
+
],
|
|
691
|
+
":filter-type/user-role": [exports.operatorUserRoleIsAnyOf],
|
|
692
|
+
};
|
|
693
|
+
exports.operatorsGroups = lodash_1.default.mapValues(exports.operatorsGroupsWithoutMe, (value, key) => {
|
|
694
|
+
if (key === ":filter-type/user-reference") {
|
|
695
|
+
return [exports.operatorReferenceIsMe, exports.operatorReferenceIsNotMe].concat(value);
|
|
696
|
+
}
|
|
697
|
+
else if (key === ":filter-type/user-reference-collection") {
|
|
698
|
+
return [exports.operatorCollectionContainsMe, exports.operatorCollectionDoesNotContainMe].concat(value);
|
|
699
|
+
}
|
|
700
|
+
else {
|
|
701
|
+
return value;
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
exports.operators = lodash_1.default.uniq(lodash_1.default.flatten(Object.values(exports.operatorsGroups))).concat([
|
|
705
|
+
// these operators are used only for backward compatibility. You can't select them on UI.
|
|
706
|
+
// https://the.fibery.io/SoftDev/User~Story/Empty-operator-in-Filters-on-view-should-work-the-same-way-as-IsEmpty-in-formulas-1972
|
|
707
|
+
exports.operatorTextIsEmptyV1,
|
|
708
|
+
exports.operatorTextIsNotEmptyV1,
|
|
709
|
+
exports.operatorDateIsEmptyV1,
|
|
710
|
+
exports.operatorDateIsNotEmptyV1,
|
|
711
|
+
exports.operatorNumberIsEmptyV1,
|
|
712
|
+
exports.operatorNumberIsNotEmptyV1,
|
|
713
|
+
// needed for unique value deduplication view
|
|
714
|
+
// https://the.fibery.io/favorites/Product_Management/feature/6495
|
|
715
|
+
exports.operatorTextExactlyIs,
|
|
716
|
+
]);
|
|
717
|
+
exports.hiddenValidOperators = [exports.operatorTextExactlyIs];
|