@outliant/sunrise-utils 1.1.10 → 1.1.11
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 +8 -0
- package/helpers/searchFilter.js +14 -0
- package/package.json +1 -1
- package/test/lib/projectPipeline.spec.js +194 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,9 +4,17 @@ 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.11](https://github.com/outliant/sunrise-utils/compare/1.1.10...1.1.11)
|
|
8
|
+
|
|
9
|
+
- chore: implement case insensitive search for id [`#16`](https://github.com/outliant/sunrise-utils/pull/16)
|
|
10
|
+
- chore: add test for projectPipeline utils [`b35d394`](https://github.com/outliant/sunrise-utils/commit/b35d394d98713d01c1149ef1a36f6c7c2cf4adab)
|
|
11
|
+
|
|
7
12
|
#### [1.1.10](https://github.com/outliant/sunrise-utils/compare/1.1.9...1.1.10)
|
|
8
13
|
|
|
14
|
+
> 10 October 2023
|
|
15
|
+
|
|
9
16
|
- chore: add days to complete function [`#15`](https://github.com/outliant/sunrise-utils/pull/15)
|
|
17
|
+
- chore(release): 1.1.10 [`7a19559`](https://github.com/outliant/sunrise-utils/commit/7a1955918dfc193a9e35cfb00d3ee8a649880095)
|
|
10
18
|
- chore: fix test [`8202713`](https://github.com/outliant/sunrise-utils/commit/8202713cafa50ee4ad6978ffcf588e93e821b429)
|
|
11
19
|
- chore: add type and remove console [`8bb18ae`](https://github.com/outliant/sunrise-utils/commit/8bb18ae2ff3e37fcee5f66f8b57cf7a1d45f3dad)
|
|
12
20
|
|
package/helpers/searchFilter.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { validate: isUuid } = require('uuid');
|
|
2
2
|
const { escapeElasticQuery } = require('./es');
|
|
3
|
+
const _ = require('lodash');
|
|
3
4
|
|
|
4
5
|
module.exports = (query = {}, searchFields = []) => {
|
|
5
6
|
const search = query.search;
|
|
@@ -27,6 +28,19 @@ module.exports = (query = {}, searchFields = []) => {
|
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
/**
|
|
32
|
+
* For case insensitive id search with hyphen
|
|
33
|
+
*/
|
|
34
|
+
_.split(search, '-').forEach(keyword => {
|
|
35
|
+
should.push({
|
|
36
|
+
wildcard: {
|
|
37
|
+
id: {
|
|
38
|
+
value: `*${keyword}*`
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
30
44
|
if (localFields.length > 0) {
|
|
31
45
|
if (isQueryQuoteWrapped) {
|
|
32
46
|
should.push({
|
package/package.json
CHANGED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-env node, mocha */
|
|
4
|
+
const { expect } = require('chai');
|
|
5
|
+
|
|
6
|
+
const projectPipeline = require('../../lib/projectPipeline');
|
|
7
|
+
|
|
8
|
+
describe('projectPipeline', function () {
|
|
9
|
+
describe('buildFiltersQuery', () => {
|
|
10
|
+
const ORG_ID = 'orgId';
|
|
11
|
+
const DEPARTMENT_ID = 'department_id';
|
|
12
|
+
const entries = [
|
|
13
|
+
{
|
|
14
|
+
search: 'COM-41853',
|
|
15
|
+
expected: {
|
|
16
|
+
bool: {
|
|
17
|
+
must: [
|
|
18
|
+
{
|
|
19
|
+
term: {
|
|
20
|
+
organization_id: {
|
|
21
|
+
value: ORG_ID
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
term: {
|
|
27
|
+
department_id: {
|
|
28
|
+
value: DEPARTMENT_ID
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
bool: {
|
|
34
|
+
should: [
|
|
35
|
+
{
|
|
36
|
+
wildcard: {
|
|
37
|
+
id: {
|
|
38
|
+
value: "*COM*"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
wildcard: {
|
|
44
|
+
id: {
|
|
45
|
+
value: "*41853*"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
multi_match: {
|
|
51
|
+
query: "COM-41853",
|
|
52
|
+
fields: [
|
|
53
|
+
"project_id^5"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
match_phrase_prefix: {
|
|
59
|
+
name: "COM-41853"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
search: 'com-41853',
|
|
71
|
+
expected: {
|
|
72
|
+
bool: {
|
|
73
|
+
must: [
|
|
74
|
+
{
|
|
75
|
+
term: {
|
|
76
|
+
organization_id: {
|
|
77
|
+
value: ORG_ID
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
term: {
|
|
83
|
+
department_id: {
|
|
84
|
+
value: DEPARTMENT_ID
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
bool: {
|
|
90
|
+
should: [
|
|
91
|
+
{
|
|
92
|
+
wildcard: {
|
|
93
|
+
id: {
|
|
94
|
+
value: "*com*"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
wildcard: {
|
|
100
|
+
id: {
|
|
101
|
+
value: "*41853*"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
multi_match: {
|
|
107
|
+
query: "com-41853",
|
|
108
|
+
fields: [
|
|
109
|
+
"project_id^5"
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
match_phrase_prefix: {
|
|
115
|
+
name: "com-41853"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
} },
|
|
124
|
+
{
|
|
125
|
+
search: '41853',
|
|
126
|
+
expected: {
|
|
127
|
+
bool: {
|
|
128
|
+
must: [
|
|
129
|
+
{
|
|
130
|
+
term: {
|
|
131
|
+
organization_id: {
|
|
132
|
+
value: ORG_ID
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
term: {
|
|
138
|
+
department_id: {
|
|
139
|
+
value: DEPARTMENT_ID
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
bool: {
|
|
145
|
+
should: [
|
|
146
|
+
{
|
|
147
|
+
wildcard: {
|
|
148
|
+
id: {
|
|
149
|
+
value: "*41853*"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
multi_match: {
|
|
155
|
+
query: "41853",
|
|
156
|
+
fields: [
|
|
157
|
+
"project_id^5"
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
match_phrase_prefix: {
|
|
163
|
+
name: "41853"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
} }
|
|
172
|
+
];
|
|
173
|
+
|
|
174
|
+
entries.forEach(entry => {
|
|
175
|
+
it(`it should search Project ID correctly for ${entry.search}`, (done) => {
|
|
176
|
+
const query = {
|
|
177
|
+
search: entry.search
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const result = projectPipeline.buildFiltersQuery(
|
|
181
|
+
ORG_ID,
|
|
182
|
+
DEPARTMENT_ID,
|
|
183
|
+
[],
|
|
184
|
+
query,
|
|
185
|
+
['project_id']
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
expect(result).to.deep.equal(entry.expected);
|
|
189
|
+
|
|
190
|
+
done();
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
});
|