@outliant/sunrise-utils 1.3.7 → 1.3.9

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 CHANGED
@@ -4,8 +4,22 @@ 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.3.9](https://github.com/outliant/sunrise-utils/compare/1.3.8...1.3.9)
8
+
9
+ - chore: updated project pipeline critical path filter [`65eab79`](https://github.com/outliant/sunrise-utils/commit/65eab7911843b69045eb5ce8e2ba43e18982c15c)
10
+
11
+ #### [1.3.8](https://github.com/outliant/sunrise-utils/compare/1.3.7...1.3.8)
12
+
13
+ > 20 March 2025
14
+
15
+ - chore: update global search #86b428rnf [`#46`](https://github.com/outliant/sunrise-utils/pull/46)
16
+ - chore(release): 1.3.8 [`1d4512f`](https://github.com/outliant/sunrise-utils/commit/1d4512f0b7c3be8db0558c2a766b1d1807b53d9d)
17
+
7
18
  #### [1.3.7](https://github.com/outliant/sunrise-utils/compare/1.3.6...1.3.7)
8
19
 
20
+ > 19 March 2025
21
+
22
+ - chore(release): 1.3.7 [`5b72ea7`](https://github.com/outliant/sunrise-utils/commit/5b72ea720549962b2c30dced6cbb66d44dc6a144)
9
23
  - chore: task pipeline filter update [`61dfa2b`](https://github.com/outliant/sunrise-utils/commit/61dfa2b351e0e9a62bd34c50ccdb24aeac55cc56)
10
24
 
11
25
  #### [1.3.6](https://github.com/outliant/sunrise-utils/compare/1.3.5...1.3.6)
@@ -6,20 +6,21 @@ module.exports = (filter) => {
6
6
  case 'is_equal':
7
7
  return module.exports.isEqual(filter);
8
8
  case 'contains_any':
9
+ case 'is_any_of':
9
10
  return module.exports.containsAny(filter);
10
11
  case 'contains_none':
11
12
  case 'not_equal':
12
13
  return module.exports.containsNone(filter);
13
14
  case 'is_none_of':
14
- return isNoneOf(
15
- filter,
16
- module.exports.isEqual
17
- );
15
+ return isNoneOf(filter, module.exports.isEqual);
18
16
  case 'greater_than_or_equal':
19
17
  return module.exports.greaterThanOrEqual(filter);
20
18
  case 'less_than_or_equal':
21
19
  return module.exports.lessThanOrEqual(filter);
22
-
20
+ case 'is_empty':
21
+ return module.exports.isEmpty();
22
+ case 'is_not_empty':
23
+ return module.exports.isNotEmpty();
23
24
  default:
24
25
  return null;
25
26
  }
@@ -122,3 +123,69 @@ module.exports.lessThanOrEqual = (filter) => {
122
123
  }
123
124
  };
124
125
  };
126
+
127
+ module.exports.isEmpty = () => {
128
+ return {
129
+ bool: {
130
+ should: [
131
+ {
132
+ bool: {
133
+ must_not: [
134
+ {
135
+ exists: {
136
+ field: 'critical_path'
137
+ }
138
+ }
139
+ ]
140
+ }
141
+ },
142
+ {
143
+ bool: {
144
+ must_not: [
145
+ {
146
+ exists: {
147
+ field: 'critical_path.stage_id'
148
+ }
149
+ }
150
+ ]
151
+ }
152
+ },
153
+ {
154
+ term: {
155
+ 'critical_path.stage_id': {
156
+ value: ''
157
+ }
158
+ }
159
+ }
160
+ ]
161
+ }
162
+ };
163
+ };
164
+
165
+ module.exports.isNotEmpty = () => {
166
+ return {
167
+ bool: {
168
+ must: [
169
+ {
170
+ exists: {
171
+ field: 'critical_path'
172
+ }
173
+ },
174
+ {
175
+ exists: {
176
+ field: 'critical_path.stage_id'
177
+ }
178
+ }
179
+ ],
180
+ must_not: [
181
+ {
182
+ term: {
183
+ 'critical_path.stage_id': {
184
+ value: ''
185
+ }
186
+ }
187
+ }
188
+ ]
189
+ }
190
+ };
191
+ };
@@ -22,8 +22,15 @@ module.exports = (query = {}, searchFields = [], isGlobalSearch = false) => {
22
22
  should.push(
23
23
  isGlobalSearch
24
24
  ? {
25
- terms: {
26
- _id: _.split(searchString, ' ') || []
25
+ bool: {
26
+ should: _.flatMap(
27
+ _.split(_.replace(searchString, /ser-|com-/gi, ''), ' ').filter(Boolean),
28
+ term => [
29
+ { term: { _id: `SER-${term}` } },
30
+ { term: { _id: `COM-${term}` } },
31
+ { term: { _id: term } }
32
+ ]
33
+ )
27
34
  }
28
35
  }
29
36
  : {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@outliant/sunrise-utils",
3
3
  "description": "Helper functions for project Sunrise",
4
- "version": "1.3.7",
4
+ "version": "1.3.9",
5
5
  "license": "ISC",
6
6
  "author": "Outliant",
7
7
  "main": "index.js",
@@ -2,6 +2,7 @@
2
2
 
3
3
  /* eslint-env node, mocha */
4
4
  const { expect } = require('chai');
5
+ const _ = require('lodash');
5
6
 
6
7
  const projectPipeline = require('../../lib/projectPipeline');
7
8
 
@@ -274,7 +275,7 @@ describe('projectPipeline', function () {
274
275
 
275
276
  it('should generate es query source params for global search', () => {
276
277
  const params = {
277
- search: '41853 SER-69 COM-69',
278
+ search: '41853 69 SER-69 allan DoNALD Vikram RalPH',
278
279
  projectSearchFields: [
279
280
  'name',
280
281
  'id',
@@ -298,14 +299,42 @@ describe('projectPipeline', function () {
298
299
  expect(result).to.be.deep.equal({
299
300
  bool: {
300
301
  must: [
301
- { term: { organization_id: { value: ORG_ID } } },
302
- { term: { department_id: { value: DEPARTMENT_ID } } },
302
+ {
303
+ term: {
304
+ organization_id: { value: 'orgId' }
305
+ }
306
+ },
307
+ {
308
+ term: {
309
+ department_id: { value: 'department_id' }
310
+ }
311
+ },
303
312
  {
304
313
  bool: {
305
314
  should: [
306
- { terms: { _id: params.search.split(' ') } },
307
- { multi_match: { query: params.search, fields: ['name^5', 'id^5'] } },
308
- { match_phrase_prefix: { name: params.search } },
315
+ {
316
+ bool: {
317
+ should: _.flatMap(
318
+ _.split(_.replace(params.search, /ser-|com-/gi, ''), ' ').filter(Boolean),
319
+ term => [
320
+ { term: { _id: `SER-${term}` } },
321
+ { term: { _id: `COM-${term}` } },
322
+ { term: { _id: term } }
323
+ ]
324
+ )
325
+ }
326
+ },
327
+ {
328
+ multi_match: {
329
+ query: params.search,
330
+ fields: ['name^5', 'id^5']
331
+ }
332
+ },
333
+ {
334
+ match_phrase_prefix: {
335
+ name: params.search
336
+ }
337
+ },
309
338
  {
310
339
  function_score: {
311
340
  query: {
@@ -314,8 +343,19 @@ describe('projectPipeline', function () {
314
343
  query: {
315
344
  bool: {
316
345
  must: [
317
- { term: { 'fields.id': { value: params.projectSearchFields[3] } } },
318
- { match: { 'fields.text.analyzed': { query: params.search, operator: 'or' } } }
346
+ {
347
+ term: {
348
+ 'fields.id': { value: '4ef2760a-083a-466b-b761-667856aeb5ee' }
349
+ }
350
+ },
351
+ {
352
+ match: {
353
+ 'fields.text.analyzed': {
354
+ query: params.search,
355
+ operator: 'or'
356
+ }
357
+ }
358
+ }
319
359
  ]
320
360
  }
321
361
  }
@@ -333,12 +373,27 @@ describe('projectPipeline', function () {
333
373
  query: {
334
374
  bool: {
335
375
  must: [
336
- { term: { 'fields.id': { value: params.projectSearchFields[3] } } },
376
+ {
377
+ term: {
378
+ 'fields.id': { value: '4ef2760a-083a-466b-b761-667856aeb5ee' }
379
+ }
380
+ },
337
381
  {
338
382
  bool: {
339
383
  should: [
340
- { match: { 'fields.text.analyzed': { query: params.search, operator: 'and' } } },
341
- { match_phrase_prefix: { 'fields.text.analyzed': params.search } }
384
+ {
385
+ match: {
386
+ 'fields.text.analyzed': {
387
+ query: params.search,
388
+ operator: 'and'
389
+ }
390
+ }
391
+ },
392
+ {
393
+ match_phrase_prefix: {
394
+ 'fields.text.analyzed': params.search
395
+ }
396
+ }
342
397
  ]
343
398
  }
344
399
  }