@outliant/sunrise-utils 1.1.7 → 1.1.8
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/CHANGELOG.md +11 -0
- package/helpers/isEmailValid.js +9 -0
- package/helpers/projectFilter/criticalPathFilter.js +5 -3
- package/helpers/projectFilter/projectFieldFilter.js +3 -2
- package/helpers/projectFilter/projectFilter.js +4 -3
- package/helpers/projectFilter/regionFilter.js +4 -2
- package/helpers/projectFilter/tagFilter.js +5 -3
- package/helpers/splitString.js +6 -0
- package/helpers/taskFilter/criticalPathFilter.js +3 -1
- package/helpers/taskFilter/index.js +2 -1
- package/helpers/taskFilter/onHoldFilter.js +3 -1
- package/helpers/taskFilter/ownerFilter.js +3 -1
- package/helpers/taskFilter/regionFilter.js +3 -1
- package/helpers/taskFilter/statusFilter.js +3 -1
- package/helpers/taskFilter/taskFieldFilter.js +3 -1
- package/lib/usersPipeline.js +34 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,9 +4,20 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [1.1.8](https://github.com/outliant/sunrise-utils/compare/1.1.7...1.1.8)
|
|
8
|
+
|
|
9
|
+
- chore: use split string helper [`#13`](https://github.com/outliant/sunrise-utils/pull/13)
|
|
10
|
+
- chore: update logic for user pipeline [`#12`](https://github.com/outliant/sunrise-utils/pull/12)
|
|
11
|
+
- chore: update users pipeline [`c0de2e6`](https://github.com/outliant/sunrise-utils/commit/c0de2e6bbacbeb1b8b96597473679f7f2424880e)
|
|
12
|
+
- chore: fix unit test [`84b880d`](https://github.com/outliant/sunrise-utils/commit/84b880d39497aa03257869702ecd0aa9f05b1d77)
|
|
13
|
+
- chore: fix test [`d7e1659`](https://github.com/outliant/sunrise-utils/commit/d7e1659d478e1787153deb0c6db79ebdf3105263)
|
|
14
|
+
|
|
7
15
|
#### [1.1.7](https://github.com/outliant/sunrise-utils/compare/1.1.6...1.1.7)
|
|
8
16
|
|
|
17
|
+
> 26 September 2023
|
|
18
|
+
|
|
9
19
|
- chore: update users pipeline [`#11`](https://github.com/outliant/sunrise-utils/pull/11)
|
|
20
|
+
- chore(release): 1.1.7 [`056a962`](https://github.com/outliant/sunrise-utils/commit/056a962aedcd0f9ee8e71cca2d1003db01a69057)
|
|
10
21
|
- chore: remove map [`6c6972b`](https://github.com/outliant/sunrise-utils/commit/6c6972b89bd60cb44bb48613ad206b785e1f1771)
|
|
11
22
|
- chore: use buildProjectFilter [`0cae6ce`](https://github.com/outliant/sunrise-utils/commit/0cae6ce4ca13dc56b98e9b98a6c6cff9881824c2)
|
|
12
23
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const isEmailValid = (email) => {
|
|
2
|
+
// The regular expression to match a valid email address.
|
|
3
|
+
const regex = /^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z]+$/;
|
|
4
|
+
|
|
5
|
+
// Return true if the string matches the regular expression, false otherwise.
|
|
6
|
+
return regex.test(email);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
module.exports = isEmailValid;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const splitString = require('../splitString');
|
|
2
|
+
|
|
1
3
|
module.exports = (filter) => {
|
|
2
4
|
switch (filter.condition) {
|
|
3
5
|
case 'is_equal':
|
|
@@ -21,7 +23,7 @@ module.exports.isEqual = (filter) => {
|
|
|
21
23
|
let value = filter.value;
|
|
22
24
|
|
|
23
25
|
if (typeof value === 'string') {
|
|
24
|
-
value = value
|
|
26
|
+
value = splitString(value);
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
return {
|
|
@@ -43,7 +45,7 @@ module.exports.containsAny = (filter) => {
|
|
|
43
45
|
let value = filter.value;
|
|
44
46
|
|
|
45
47
|
if (typeof value === 'string') {
|
|
46
|
-
value = value
|
|
48
|
+
value = splitString(value);
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
return {
|
|
@@ -65,7 +67,7 @@ module.exports.containsNone = (filter) => {
|
|
|
65
67
|
let value = filter.value;
|
|
66
68
|
|
|
67
69
|
if (typeof value === 'string') {
|
|
68
|
-
value = value
|
|
70
|
+
value = splitString(value);
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
return {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const moment = require('moment');
|
|
2
2
|
const { escapeElasticQuery } = require('../es');
|
|
3
|
+
const splitString = require('../splitString');
|
|
3
4
|
|
|
4
5
|
function getContainsMappingValue(filter) {
|
|
5
6
|
if (['text', 'textarea'].includes(filter.field_type)) {
|
|
@@ -162,7 +163,7 @@ module.exports.isAnyOf = (filter) => {
|
|
|
162
163
|
let value = filter.value;
|
|
163
164
|
|
|
164
165
|
if (typeof value === 'string') {
|
|
165
|
-
value = value
|
|
166
|
+
value = splitString(value);
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
if (filter.field_id) {
|
|
@@ -356,7 +357,7 @@ module.exports.isEqual = (filter) => {
|
|
|
356
357
|
let value = filter.value;
|
|
357
358
|
|
|
358
359
|
if (typeof value === 'string') {
|
|
359
|
-
value = value
|
|
360
|
+
value = splitString(value);
|
|
360
361
|
}
|
|
361
362
|
|
|
362
363
|
mappingValue = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const moment = require('moment');
|
|
2
2
|
const { escapeElasticQuery } = require('../es');
|
|
3
|
+
const splitString = require('../splitString');
|
|
3
4
|
|
|
4
5
|
module.exports = (filter) => {
|
|
5
6
|
switch (filter.condition) {
|
|
@@ -127,7 +128,7 @@ module.exports.isEqual = (filter) => {
|
|
|
127
128
|
|
|
128
129
|
if (filter.field_type === 'checkbox') {
|
|
129
130
|
const value = typeof filter.value === 'string'
|
|
130
|
-
? filter.value
|
|
131
|
+
? splitString(filter.value)
|
|
131
132
|
: filter.value;
|
|
132
133
|
|
|
133
134
|
const should = [];
|
|
@@ -160,7 +161,7 @@ module.exports.isEqual = (filter) => {
|
|
|
160
161
|
|
|
161
162
|
return {
|
|
162
163
|
term: {
|
|
163
|
-
|
|
164
|
+
[filter.type]: {
|
|
164
165
|
value: filter.value
|
|
165
166
|
}
|
|
166
167
|
}
|
|
@@ -383,7 +384,7 @@ module.exports.isNotEqual = (filter) => {
|
|
|
383
384
|
|
|
384
385
|
if (filter.field_type === 'checkbox') {
|
|
385
386
|
const value = typeof filter.value === 'string'
|
|
386
|
-
? filter.value
|
|
387
|
+
? splitString(filter.value)
|
|
387
388
|
: filter.value;
|
|
388
389
|
|
|
389
390
|
const should = [];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const splitString = require('../splitString');
|
|
2
|
+
|
|
1
3
|
module.exports = (filter) => {
|
|
2
4
|
switch (filter.condition) {
|
|
3
5
|
case 'contains_any':
|
|
@@ -15,7 +17,7 @@ module.exports.containsAny = (filter) => {
|
|
|
15
17
|
let value = filter.value;
|
|
16
18
|
|
|
17
19
|
if (typeof value === 'string') {
|
|
18
|
-
value = value
|
|
20
|
+
value = splitString(value);
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
return {
|
|
@@ -37,7 +39,7 @@ module.exports.containsNone = (filter) => {
|
|
|
37
39
|
let value = filter.value;
|
|
38
40
|
|
|
39
41
|
if (typeof value === 'string') {
|
|
40
|
-
value = value
|
|
42
|
+
value = splitString(value);
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
return {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const splitString = require('../splitString');
|
|
2
|
+
|
|
1
3
|
module.exports = (filter) => {
|
|
2
4
|
switch (filter.condition) {
|
|
3
5
|
case 'contains_any':
|
|
@@ -18,7 +20,7 @@ module.exports.containsAny = (filter) => {
|
|
|
18
20
|
let value = filter.value;
|
|
19
21
|
|
|
20
22
|
if (typeof value === 'string') {
|
|
21
|
-
value = value
|
|
23
|
+
value = splitString(value);
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
return {
|
|
@@ -40,7 +42,7 @@ module.exports.containsNone = (filter) => {
|
|
|
40
42
|
let value = filter.value;
|
|
41
43
|
|
|
42
44
|
if (typeof value === 'string') {
|
|
43
|
-
value = value
|
|
45
|
+
value = splitString(value);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
return {
|
|
@@ -62,7 +64,7 @@ module.exports.containsAll = (filter) => {
|
|
|
62
64
|
let value = filter.value;
|
|
63
65
|
|
|
64
66
|
if (typeof value === 'string') {
|
|
65
|
-
value = value
|
|
67
|
+
value = splitString(value);
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
return {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const splitString = require('../splitString');
|
|
2
|
+
|
|
1
3
|
module.exports = (filter) => {
|
|
2
4
|
switch (filter.condition) {
|
|
3
5
|
case 'is_empty':
|
|
@@ -106,7 +108,7 @@ module.exports.isAnyOf = (filter) => {
|
|
|
106
108
|
let value = filter.value;
|
|
107
109
|
|
|
108
110
|
if (typeof value === 'string') {
|
|
109
|
-
value = value
|
|
111
|
+
value = splitString(value);
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
return {
|
|
@@ -8,6 +8,7 @@ const buildOnHoldFilter = require('./onHoldFilter');
|
|
|
8
8
|
const buildAgeColorFilter = require('./buildAgeColorFilter');
|
|
9
9
|
const buildProjectFieldFilter = require('../projectFilter/projectFieldFilter');
|
|
10
10
|
const { PROJECT_BANNERS } = require('../../constants');
|
|
11
|
+
const splitString = require('../splitString');
|
|
11
12
|
|
|
12
13
|
module.exports.taskStatusOptions = [
|
|
13
14
|
{
|
|
@@ -231,7 +232,7 @@ module.exports.buildTaskPipelineFilter = (filter) => {
|
|
|
231
232
|
let value = filter.value;
|
|
232
233
|
|
|
233
234
|
if (typeof value === 'string') {
|
|
234
|
-
value = value
|
|
235
|
+
value = splitString(value);
|
|
235
236
|
}
|
|
236
237
|
|
|
237
238
|
return {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const splitString = require('../splitString');
|
|
2
|
+
|
|
1
3
|
module.exports = (filter) => {
|
|
2
4
|
switch (filter.condition) {
|
|
3
5
|
case 'is_empty':
|
|
@@ -79,7 +81,7 @@ module.exports.isAnyOf = (filter) => {
|
|
|
79
81
|
let value = filter.value;
|
|
80
82
|
|
|
81
83
|
if (typeof value === 'string') {
|
|
82
|
-
value = value
|
|
84
|
+
value = splitString(value);
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
const should = [];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const { validate: isUuid } = require('uuid');
|
|
2
2
|
|
|
3
|
+
const splitString = require('../splitString');
|
|
4
|
+
|
|
3
5
|
module.exports = (filter) => {
|
|
4
6
|
switch (filter.condition) {
|
|
5
7
|
case 'is_empty':
|
|
@@ -101,7 +103,7 @@ module.exports.isAnyOf = (filter) => {
|
|
|
101
103
|
let value = filter.value;
|
|
102
104
|
|
|
103
105
|
if (typeof value === 'string') {
|
|
104
|
-
value = value
|
|
106
|
+
value = splitString(value);
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
const should = [];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const splitString = require('../splitString');
|
|
2
|
+
|
|
1
3
|
module.exports = (filter) => {
|
|
2
4
|
switch (filter.condition) {
|
|
3
5
|
case 'is_empty':
|
|
@@ -45,7 +47,7 @@ module.exports.isEqual = (filter) => {
|
|
|
45
47
|
let value = filter.value;
|
|
46
48
|
|
|
47
49
|
if (typeof value === 'string') {
|
|
48
|
-
value = value
|
|
50
|
+
value = splitString(value);
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
return {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const splitString = require('../splitString');
|
|
2
|
+
|
|
1
3
|
module.exports = (filter) => {
|
|
2
4
|
switch (filter.condition) {
|
|
3
5
|
case 'is_empty':
|
|
@@ -142,7 +144,7 @@ module.exports.isAnyOf = (filter) => {
|
|
|
142
144
|
let value = filter.value;
|
|
143
145
|
|
|
144
146
|
if (typeof value === 'string') {
|
|
145
|
-
value = value
|
|
147
|
+
value = splitString(value);
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
const should = [];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const moment = require('moment');
|
|
2
2
|
|
|
3
|
+
const splitString = require('../splitString');
|
|
4
|
+
|
|
3
5
|
module.exports = (filter) => {
|
|
4
6
|
switch (filter.condition) {
|
|
5
7
|
case 'contains_any':
|
|
@@ -97,7 +99,7 @@ module.exports.isAnyOf = (filter) => {
|
|
|
97
99
|
let value = filter.value;
|
|
98
100
|
|
|
99
101
|
if (typeof value === 'string') {
|
|
100
|
-
value = value
|
|
102
|
+
value = splitString(value);
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
return {
|
package/lib/usersPipeline.js
CHANGED
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
const sortScript = require('../helpers/users/sortScript');
|
|
2
2
|
const buildProjectFilter = require('../helpers/projectFilter/projectFilter');
|
|
3
|
+
const isEmailValid = require('../helpers/isEmailValid');
|
|
3
4
|
|
|
4
5
|
// customer filters
|
|
5
6
|
const buildStatusFilter = require('../helpers/users/filters/status');
|
|
6
7
|
|
|
7
8
|
class UsersPipeline {
|
|
8
|
-
buildFiltersQuery(
|
|
9
|
-
|
|
9
|
+
buildFiltersQuery (
|
|
10
|
+
organizationId,
|
|
11
|
+
filters,
|
|
12
|
+
search
|
|
13
|
+
) {
|
|
14
|
+
const mustQuery = [
|
|
15
|
+
{
|
|
16
|
+
term: {
|
|
17
|
+
organizationId: {
|
|
18
|
+
value: organizationId
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
if (search) {
|
|
25
|
+
if (isEmailValid(search)) {
|
|
26
|
+
mustQuery.push({
|
|
27
|
+
match: {
|
|
28
|
+
email: search
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
mustQuery.push(
|
|
33
|
+
{
|
|
34
|
+
query_string: {
|
|
35
|
+
fields: ['name.raw', 'email.raw'],
|
|
36
|
+
query: `*${search}*`,
|
|
37
|
+
default_operator: 'AND'
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
10
42
|
|
|
11
43
|
for (const filter of filters) {
|
|
12
44
|
switch (filter.type) {
|