@outliant/sunrise-utils 1.3.6 → 1.3.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 CHANGED
@@ -4,9 +4,23 @@ 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.8](https://github.com/outliant/sunrise-utils/compare/1.3.7...1.3.8)
8
+
9
+ - chore: update global search #86b428rnf [`#46`](https://github.com/outliant/sunrise-utils/pull/46)
10
+
11
+ #### [1.3.7](https://github.com/outliant/sunrise-utils/compare/1.3.6...1.3.7)
12
+
13
+ > 19 March 2025
14
+
15
+ - chore(release): 1.3.7 [`5b72ea7`](https://github.com/outliant/sunrise-utils/commit/5b72ea720549962b2c30dced6cbb66d44dc6a144)
16
+ - chore: task pipeline filter update [`61dfa2b`](https://github.com/outliant/sunrise-utils/commit/61dfa2b351e0e9a62bd34c50ccdb24aeac55cc56)
17
+
7
18
  #### [1.3.6](https://github.com/outliant/sunrise-utils/compare/1.3.5...1.3.6)
8
19
 
20
+ > 18 March 2025
21
+
9
22
  - chore: update project global search #86b428rnf [`#45`](https://github.com/outliant/sunrise-utils/pull/45)
23
+ - chore(release): 1.3.6 [`db08eb9`](https://github.com/outliant/sunrise-utils/commit/db08eb91e9863fcec2671189726b3f5ff6ef9fa9)
10
24
 
11
25
  #### [1.3.5](https://github.com/outliant/sunrise-utils/compare/1.3.4...1.3.5)
12
26
 
@@ -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
  : {
@@ -382,6 +382,9 @@ module.exports.buildTaskPipelineFilter = (filter, starredTaskIds) => {
382
382
  case 'dealinformation':
383
383
  case 'contactinformation':
384
384
  case 'ticketinformation':
385
+ case 'dealPropertyMappings':
386
+ case 'ticketPropertyMappings':
387
+ case 'contactPropertyMappings':
385
388
  case 'taskfield':
386
389
  return buildProjectFieldFilter(filter);
387
390
  case 'is_starred':
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.6",
4
+ "version": "1.3.8",
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
  }