@outliant/sunrise-utils 1.1.15 → 1.1.17
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 +15 -0
- package/helpers/projectFilter/index.js +1 -0
- package/helpers/taskFilter/index.js +6 -0
- package/helpers/taskFilter/statusFilter.js +12 -0
- package/index.d.ts +5 -0
- package/index.js +3 -1
- package/lib/fieldConditions.js +8 -8
- package/lib/queries.js +57 -0
- package/package.json +1 -1
- package/test/helpers/taskFilter/statusFilter.spec.js +49 -4
- package/test/lib/queries.spec.js +65 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,9 +4,24 @@ 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.17](https://github.com/outliant/sunrise-utils/compare/1.1.16...1.1.17)
|
|
8
|
+
|
|
9
|
+
- chore: update task status filter #863hbxjkt [`#23`](https://github.com/outliant/sunrise-utils/pull/23)
|
|
10
|
+
- chore: clean up is_paused filter #863hbxjkt [`f098a15`](https://github.com/outliant/sunrise-utils/commit/f098a15636cc2bb8fcd1c2bfc3fb9f4ceec5fc89)
|
|
11
|
+
|
|
12
|
+
#### [1.1.16](https://github.com/outliant/sunrise-utils/compare/1.1.15...1.1.16)
|
|
13
|
+
|
|
14
|
+
> 13 December 2023
|
|
15
|
+
|
|
16
|
+
- chore: update is none of filter #85ztm47dj [`#22`](https://github.com/outliant/sunrise-utils/pull/22)
|
|
17
|
+
- chore(release): 1.1.16 [`e322032`](https://github.com/outliant/sunrise-utils/commit/e32203205b74ae0e079612ab842451b210263051)
|
|
18
|
+
|
|
7
19
|
#### [1.1.15](https://github.com/outliant/sunrise-utils/compare/1.1.14...1.1.15)
|
|
8
20
|
|
|
21
|
+
> 13 December 2023
|
|
22
|
+
|
|
9
23
|
- chore: update common filter import #85ztm47dj [`#21`](https://github.com/outliant/sunrise-utils/pull/21)
|
|
24
|
+
- chore(release): 1.1.15 [`4cbf8e8`](https://github.com/outliant/sunrise-utils/commit/4cbf8e86857fa5c853e5403aba89413701a0e032)
|
|
10
25
|
|
|
11
26
|
#### [1.1.14](https://github.com/outliant/sunrise-utils/compare/1.1.13...1.1.14)
|
|
12
27
|
|
|
@@ -32,6 +32,11 @@ module.exports.taskStatusOptions = [
|
|
|
32
32
|
{
|
|
33
33
|
label: 'Overdue',
|
|
34
34
|
value: 'overdue'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
validate: (validator) => validator && validator.isCommercial(),
|
|
38
|
+
label: 'Paused',
|
|
39
|
+
value: 'paused'
|
|
35
40
|
}
|
|
36
41
|
];
|
|
37
42
|
|
|
@@ -123,6 +128,7 @@ module.exports.defaultCustomColumns = [
|
|
|
123
128
|
]
|
|
124
129
|
},
|
|
125
130
|
{
|
|
131
|
+
validate: (validator) => validator && validator.isCommercial(),
|
|
126
132
|
name: 'Is Paused',
|
|
127
133
|
value: 'is_paused',
|
|
128
134
|
type: 'is_paused',
|
package/index.d.ts
CHANGED
|
@@ -69,6 +69,11 @@ declare namespace Utils {
|
|
|
69
69
|
): any;
|
|
70
70
|
export function buildSortScript(query?: Query, customSort?: any[]): any;
|
|
71
71
|
}
|
|
72
|
+
|
|
73
|
+
namespace queries {
|
|
74
|
+
export function getIsPausedQuery(): any;
|
|
75
|
+
export function getNotIsPausedQuery(): any;
|
|
76
|
+
}
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
export = Utils;
|
package/index.js
CHANGED
|
@@ -3,11 +3,13 @@ const fieldConditions = require('./lib/fieldConditions');
|
|
|
3
3
|
const taskPipeline = require('./lib/taskPipeline');
|
|
4
4
|
const projectPipeline = require('./lib/projectPipeline');
|
|
5
5
|
const usersPipeline = require('./lib/usersPipeline');
|
|
6
|
+
const queries = require('./lib/queries');
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
|
8
9
|
log,
|
|
9
10
|
fieldConditions,
|
|
10
11
|
taskPipeline,
|
|
11
12
|
projectPipeline,
|
|
12
|
-
usersPipeline
|
|
13
|
+
usersPipeline,
|
|
14
|
+
queries
|
|
13
15
|
};
|
package/lib/fieldConditions.js
CHANGED
|
@@ -20,6 +20,10 @@ module.exports.conditions = {
|
|
|
20
20
|
label: 'Is any of',
|
|
21
21
|
value: 'is_any_of'
|
|
22
22
|
},
|
|
23
|
+
{
|
|
24
|
+
label: 'Is None Of',
|
|
25
|
+
value: 'is_none_of'
|
|
26
|
+
},
|
|
23
27
|
{
|
|
24
28
|
label: 'Contains Any',
|
|
25
29
|
value: 'contains_any'
|
|
@@ -27,10 +31,6 @@ module.exports.conditions = {
|
|
|
27
31
|
{
|
|
28
32
|
label: 'Contains None',
|
|
29
33
|
value: 'contains_none'
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
label: 'Is None Of',
|
|
33
|
-
value: 'is_none_of'
|
|
34
34
|
}
|
|
35
35
|
],
|
|
36
36
|
textarea: [
|
|
@@ -54,6 +54,10 @@ module.exports.conditions = {
|
|
|
54
54
|
label: 'Is any of',
|
|
55
55
|
value: 'is_any_of'
|
|
56
56
|
},
|
|
57
|
+
{
|
|
58
|
+
label: 'Is None Of',
|
|
59
|
+
value: 'is_none_of'
|
|
60
|
+
},
|
|
57
61
|
{
|
|
58
62
|
label: 'Contains Any',
|
|
59
63
|
value: 'contains_any'
|
|
@@ -61,10 +65,6 @@ module.exports.conditions = {
|
|
|
61
65
|
{
|
|
62
66
|
label: 'Contains None',
|
|
63
67
|
value: 'contains_none'
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
label: 'Is None Of',
|
|
67
|
-
value: 'is_none_of'
|
|
68
68
|
}
|
|
69
69
|
],
|
|
70
70
|
number: [
|
package/lib/queries.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates an Elasticsearch query for filtering based on 'is_paused' equals to 'true'.
|
|
3
|
+
*
|
|
4
|
+
* @returns {Object} - Elasticsearch query object.
|
|
5
|
+
*/
|
|
6
|
+
module.exports.getIsPausedQuery = () => {
|
|
7
|
+
return {
|
|
8
|
+
bool: {
|
|
9
|
+
must: [
|
|
10
|
+
{
|
|
11
|
+
term: {
|
|
12
|
+
is_paused: true
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Generates an Elasticsearch query for filtering based on 'is_paused' equal to 'false' or doesn't exist.
|
|
22
|
+
*
|
|
23
|
+
* @returns {Object} - Elasticsearch query object.
|
|
24
|
+
*/
|
|
25
|
+
module.exports.getNotIsPausedQuery = () => {
|
|
26
|
+
return {
|
|
27
|
+
bool: {
|
|
28
|
+
should: [
|
|
29
|
+
{
|
|
30
|
+
match: {
|
|
31
|
+
is_paused: false
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
bool: {
|
|
36
|
+
should: [
|
|
37
|
+
{
|
|
38
|
+
exists: {
|
|
39
|
+
field: 'is_paused'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
bool: {
|
|
44
|
+
must_not: {
|
|
45
|
+
exists: {
|
|
46
|
+
field: 'is_paused'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
};
|
package/package.json
CHANGED
|
@@ -54,6 +54,23 @@ describe('taskFilter/statusFilter', function () {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
|
+
{
|
|
58
|
+
input: {
|
|
59
|
+
condition: 'is_equal',
|
|
60
|
+
field_id: '',
|
|
61
|
+
type: 'status',
|
|
62
|
+
field_type: 'select',
|
|
63
|
+
value: 'paused',
|
|
64
|
+
second_value: ''
|
|
65
|
+
},
|
|
66
|
+
output: {
|
|
67
|
+
bool: {
|
|
68
|
+
must: [
|
|
69
|
+
{ term: { is_paused: true } }
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
57
74
|
{
|
|
58
75
|
input: {
|
|
59
76
|
condition: 'is_equal',
|
|
@@ -128,7 +145,7 @@ describe('taskFilter/statusFilter', function () {
|
|
|
128
145
|
field_id: '',
|
|
129
146
|
type: 'status',
|
|
130
147
|
field_type: 'select',
|
|
131
|
-
value: 'new;on_hold',
|
|
148
|
+
value: 'new;on_hold;paused',
|
|
132
149
|
second_value: ''
|
|
133
150
|
},
|
|
134
151
|
output: {
|
|
@@ -142,7 +159,8 @@ describe('taskFilter/statusFilter', function () {
|
|
|
142
159
|
]
|
|
143
160
|
}
|
|
144
161
|
},
|
|
145
|
-
{ bool: { must: [{ term: { on_hold: true } }] } }
|
|
162
|
+
{ bool: { must: [{ term: { on_hold: true } }] } },
|
|
163
|
+
{ bool: { must: [{ term: { is_paused: true } }] } }
|
|
146
164
|
]
|
|
147
165
|
}
|
|
148
166
|
}
|
|
@@ -153,7 +171,33 @@ describe('taskFilter/statusFilter', function () {
|
|
|
153
171
|
field_id: '',
|
|
154
172
|
type: 'status',
|
|
155
173
|
field_type: 'select',
|
|
156
|
-
value:
|
|
174
|
+
value: 'new,on_hold,paused',
|
|
175
|
+
second_value: ''
|
|
176
|
+
},
|
|
177
|
+
output: {
|
|
178
|
+
bool: {
|
|
179
|
+
should: [
|
|
180
|
+
{
|
|
181
|
+
bool: {
|
|
182
|
+
must: [
|
|
183
|
+
{ term: { is_ready: false } },
|
|
184
|
+
{ term: { is_complete: false } }
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
{ bool: { must: [{ term: { on_hold: true } }] } },
|
|
189
|
+
{ bool: { must: [{ term: { is_paused: true } }] } }
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
input: {
|
|
196
|
+
condition: 'is_any_of',
|
|
197
|
+
field_id: '',
|
|
198
|
+
type: 'status',
|
|
199
|
+
field_type: 'select',
|
|
200
|
+
value: ['new', 'on_hold', 'paused'],
|
|
157
201
|
second_value: ''
|
|
158
202
|
},
|
|
159
203
|
output: {
|
|
@@ -167,7 +211,8 @@ describe('taskFilter/statusFilter', function () {
|
|
|
167
211
|
]
|
|
168
212
|
}
|
|
169
213
|
},
|
|
170
|
-
{ bool: { must: [{ term: { on_hold: true } }] } }
|
|
214
|
+
{ bool: { must: [{ term: { on_hold: true } }] } },
|
|
215
|
+
{ bool: { must: [{ term: { is_paused: true } }] } }
|
|
171
216
|
]
|
|
172
217
|
}
|
|
173
218
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-env node, mocha */
|
|
4
|
+
const { expect } = require('chai');
|
|
5
|
+
|
|
6
|
+
// To test
|
|
7
|
+
const queries = require('../../lib/queries');
|
|
8
|
+
|
|
9
|
+
describe('queries', function () {
|
|
10
|
+
describe('getIsPausedQuery', () => {
|
|
11
|
+
it('should return an \'is_paused\' query', () => {
|
|
12
|
+
const output = queries.getIsPausedQuery();
|
|
13
|
+
|
|
14
|
+
expect(output).to.be.deep.equal({
|
|
15
|
+
bool: {
|
|
16
|
+
must: [
|
|
17
|
+
{
|
|
18
|
+
term: {
|
|
19
|
+
is_paused: true
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('getNotIsPausedQuery', () => {
|
|
29
|
+
it('should return a \'not is_paused\' query', () => {
|
|
30
|
+
const output = queries.getNotIsPausedQuery();
|
|
31
|
+
|
|
32
|
+
expect(output).to.be.deep.equal({
|
|
33
|
+
bool: {
|
|
34
|
+
should: [
|
|
35
|
+
{
|
|
36
|
+
match: {
|
|
37
|
+
is_paused: false
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
bool: {
|
|
42
|
+
should: [
|
|
43
|
+
{
|
|
44
|
+
exists: {
|
|
45
|
+
field: 'is_paused'
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
bool: {
|
|
50
|
+
must_not: {
|
|
51
|
+
exists: {
|
|
52
|
+
field: 'is_paused'
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|