@rh-support/utils 0.2.21 → 0.2.32

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/README.md CHANGED
@@ -9,3 +9,5 @@ import utils from 'utils';
9
9
 
10
10
  // TODO: DEMONSTRATE API
11
11
  ```
12
+
13
+ .
@@ -22,4 +22,5 @@ export * from './customElementUtils';
22
22
  export * from './userUtils';
23
23
  export * from './styleUtils';
24
24
  export * from './translation-helper';
25
+ export * from './outlier';
25
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC"}
package/lib/cjs/index.js CHANGED
@@ -34,3 +34,4 @@ __exportStar(require("./customElementUtils"), exports);
34
34
  __exportStar(require("./userUtils"), exports);
35
35
  __exportStar(require("./styleUtils"), exports);
36
36
  __exportStar(require("./translation-helper"), exports);
37
+ __exportStar(require("./outlier"), exports);
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Outlier Function
3
+ * Refer: https://www.cuemath.com/outlier-formula/
4
+ *
5
+ * An outlier function which takers array of number and find high outlier and low outlier
6
+ * 1. Taker array of number and sort then in ascending order.
7
+ * 2. Calculate first(q1) and third(q3) quartile.
8
+ * 3. Calculate inter-quartile(iqr) range (q3-q1).
9
+ * 4. Find the upper boundary value by formula q3 + iqr*1.5.
10
+ * 5. Find the lower boundary value by formula q1 - iqr*1.5
11
+ *
12
+ * @param {number[]} numbers
13
+ * @returns {number[]} upper and lower boundary value
14
+ */
15
+ export declare const outlier: (array: Array<number>) => Array<number>;
16
+ //# sourceMappingURL=outlier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outlier.d.ts","sourceRoot":"","sources":["../../src/outlier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,OAAO,UAAW,MAAM,MAAM,CAAC,KAAG,MAAM,MAAM,CAkC1D,CAAC"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ /**
3
+ * Outlier Function
4
+ * Refer: https://www.cuemath.com/outlier-formula/
5
+ *
6
+ * An outlier function which takers array of number and find high outlier and low outlier
7
+ * 1. Taker array of number and sort then in ascending order.
8
+ * 2. Calculate first(q1) and third(q3) quartile.
9
+ * 3. Calculate inter-quartile(iqr) range (q3-q1).
10
+ * 4. Find the upper boundary value by formula q3 + iqr*1.5.
11
+ * 5. Find the lower boundary value by formula q1 - iqr*1.5
12
+ *
13
+ * @param {number[]} numbers
14
+ * @returns {number[]} upper and lower boundary value
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.outlier = void 0;
18
+ var outlier = function (array) {
19
+ // Take array length
20
+ var arrayLength = array.length;
21
+ // Check if length is smaller than four then return array result as it is
22
+ if (arrayLength < 4) {
23
+ return array;
24
+ }
25
+ var q1, q3, iqr, upperBoundary, lowerBoundary;
26
+ // Make a copy of array plus sort it in ascending order
27
+ var sortedArray = array.slice().sort(function (a, b) { return a - b; });
28
+ // Find the quartiles range
29
+ // If median is odd adjust the index by minus one
30
+ if (((arrayLength - 1) / 4) % 1 === 0 || (arrayLength / 4) % 1 === 0) {
31
+ q1 = (1 / 2) * (sortedArray[Math.floor(arrayLength / 4) - 1] + sortedArray[Math.floor(arrayLength / 4)]);
32
+ q3 =
33
+ (1 / 2) *
34
+ (sortedArray[Math.ceil(arrayLength * (3 / 4)) - 1] + sortedArray[Math.ceil(arrayLength * (3 / 4))]);
35
+ }
36
+ else {
37
+ q1 = sortedArray[Math.floor(arrayLength / 4)];
38
+ q3 = sortedArray[Math.floor(arrayLength * (3 / 4))];
39
+ }
40
+ // Calculate inter-quartile range
41
+ iqr = q3 - q1;
42
+ // upper boundary
43
+ upperBoundary = q3 + iqr * 1.5;
44
+ // lower boundary
45
+ lowerBoundary = q1 - iqr * 1.5;
46
+ return [upperBoundary, lowerBoundary];
47
+ };
48
+ exports.outlier = outlier;
@@ -5,6 +5,13 @@ export interface ITroubleshootProductResponse {
5
5
  productsResult: Partial<ISEProduct>[];
6
6
  }
7
7
  export declare const handleProductSearchResponse: (productsResultAll: ISEProduct[], productsResultEntitled?: IProductV2[]) => ITroubleshootProductResponse;
8
+ /**
9
+ * This method is used for parsing `hydra/rest/products/contact/{userName}` response form API
10
+ * and need to create partial response like method `handleProductSearchResponse`
11
+ * @param productsResultEntitled IProductV2[]
12
+ * @returns ITroubleshootProductResponse
13
+ */
14
+ export declare const handleEntitledProductResponse: (productsResultEntitled?: IProductV2[]) => ITroubleshootProductResponse;
8
15
  /**
9
16
  * Tries to get top 5 products with priority given to recentlyFiledAgainst
10
17
  * before checking general top products from un-authed SE API
@@ -1 +1 @@
1
- {"version":3,"file":"productsUtils.d.ts","sourceRoot":"","sources":["../../src/productsUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAWhF,MAAM,WAAW,4BAA4B;IACzC,WAAW,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;IACnC,aAAa,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;IACrC,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;CACzC;AAED,eAAO,MAAM,2BAA2B,sBACjB,UAAU,EAAE,2BACP,UAAU,EAAE,KACrC,4BA6BF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,yBAO7D;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,WAE/C;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAEzD;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAEzD;AAED,eAAO,MAAM,aAAa,OAAQ,MAAM,MAAM,MAAM,eAmBnD,CAAC;AAEF,eAAO,MAAM,WAAW,QAAS,MAAM,EAAE,aAExC,CAAC;AAEF,UAAU,sBAAsB;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,sBAAsB,CAkBlE"}
1
+ {"version":3,"file":"productsUtils.d.ts","sourceRoot":"","sources":["../../src/productsUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAWhF,MAAM,WAAW,4BAA4B;IACzC,WAAW,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;IACnC,aAAa,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;IACrC,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;CACzC;AAED,eAAO,MAAM,2BAA2B,sBACjB,UAAU,EAAE,2BACP,UAAU,EAAE,KACrC,4BA6BF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,4BACd,UAAU,EAAE,KACrC,4BAcF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,yBAO7D;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,WAE/C;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAEzD;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAEzD;AAED,eAAO,MAAM,aAAa,OAAQ,MAAM,MAAM,MAAM,eAmBnD,CAAC;AAEF,eAAO,MAAM,WAAW,QAAS,MAAM,EAAE,aAExC,CAAC;AAEF,UAAU,sBAAsB;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,sBAAsB,CAkBlE"}
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.getVersion = exports.versionSort = exports.versionSorter = exports.getUniqueSortedVersions = exports.getVersionIfOnlyVersion = exports.isOnlyVersion = exports.getTopProducts = exports.handleProductSearchResponse = void 0;
38
+ exports.getVersion = exports.versionSort = exports.versionSorter = exports.getUniqueSortedVersions = exports.getVersionIfOnlyVersion = exports.isOnlyVersion = exports.getTopProducts = exports.handleEntitledProductResponse = exports.handleProductSearchResponse = void 0;
39
39
  var difference_1 = __importDefault(require("lodash/difference"));
40
40
  var forEach_1 = __importDefault(require("lodash/forEach"));
41
41
  var isEmpty_1 = __importDefault(require("lodash/isEmpty"));
@@ -71,6 +71,26 @@ var handleProductSearchResponse = function (productsResultAll, productsResultEnt
71
71
  };
72
72
  };
73
73
  exports.handleProductSearchResponse = handleProductSearchResponse;
74
+ /**
75
+ * This method is used for parsing `hydra/rest/products/contact/{userName}` response form API
76
+ * and need to create partial response like method `handleProductSearchResponse`
77
+ * @param productsResultEntitled IProductV2[]
78
+ * @returns ITroubleshootProductResponse
79
+ */
80
+ var handleEntitledProductResponse = function (productsResultEntitled) {
81
+ if (productsResultEntitled === void 0) { productsResultEntitled = []; }
82
+ var productsResult = productsResultEntitled.map(function (product) {
83
+ return __assign(__assign({}, product), { product: product.name });
84
+ });
85
+ var topProducts = getTopProducts(productsResult);
86
+ var productsResultSorted = orderBy_1.default(productsResult, ['product'], ['asc']);
87
+ return {
88
+ productsResult: productsResultSorted,
89
+ topProducts: topProducts,
90
+ otherProducts: difference_1.default(productsResultSorted, topProducts),
91
+ };
92
+ };
93
+ exports.handleEntitledProductResponse = handleEntitledProductResponse;
74
94
  /**
75
95
  * Tries to get top 5 products with priority given to recentlyFiledAgainst
76
96
  * before checking general top products from un-authed SE API
@@ -22,4 +22,5 @@ export * from './customElementUtils';
22
22
  export * from './userUtils';
23
23
  export * from './styleUtils';
24
24
  export * from './translation-helper';
25
+ export * from './outlier';
25
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC"}
package/lib/esm/index.js CHANGED
@@ -22,3 +22,4 @@ export * from './customElementUtils';
22
22
  export * from './userUtils';
23
23
  export * from './styleUtils';
24
24
  export * from './translation-helper';
25
+ export * from './outlier';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Outlier Function
3
+ * Refer: https://www.cuemath.com/outlier-formula/
4
+ *
5
+ * An outlier function which takers array of number and find high outlier and low outlier
6
+ * 1. Taker array of number and sort then in ascending order.
7
+ * 2. Calculate first(q1) and third(q3) quartile.
8
+ * 3. Calculate inter-quartile(iqr) range (q3-q1).
9
+ * 4. Find the upper boundary value by formula q3 + iqr*1.5.
10
+ * 5. Find the lower boundary value by formula q1 - iqr*1.5
11
+ *
12
+ * @param {number[]} numbers
13
+ * @returns {number[]} upper and lower boundary value
14
+ */
15
+ export declare const outlier: (array: Array<number>) => Array<number>;
16
+ //# sourceMappingURL=outlier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outlier.d.ts","sourceRoot":"","sources":["../../src/outlier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,OAAO,UAAW,MAAM,MAAM,CAAC,KAAG,MAAM,MAAM,CAkC1D,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Outlier Function
3
+ * Refer: https://www.cuemath.com/outlier-formula/
4
+ *
5
+ * An outlier function which takers array of number and find high outlier and low outlier
6
+ * 1. Taker array of number and sort then in ascending order.
7
+ * 2. Calculate first(q1) and third(q3) quartile.
8
+ * 3. Calculate inter-quartile(iqr) range (q3-q1).
9
+ * 4. Find the upper boundary value by formula q3 + iqr*1.5.
10
+ * 5. Find the lower boundary value by formula q1 - iqr*1.5
11
+ *
12
+ * @param {number[]} numbers
13
+ * @returns {number[]} upper and lower boundary value
14
+ */
15
+ export const outlier = (array) => {
16
+ // Take array length
17
+ const arrayLength = array.length;
18
+ // Check if length is smaller than four then return array result as it is
19
+ if (arrayLength < 4) {
20
+ return array;
21
+ }
22
+ let q1, q3, iqr, upperBoundary, lowerBoundary;
23
+ // Make a copy of array plus sort it in ascending order
24
+ const sortedArray = array.slice().sort((a, b) => a - b);
25
+ // Find the quartiles range
26
+ // If median is odd adjust the index by minus one
27
+ if (((arrayLength - 1) / 4) % 1 === 0 || (arrayLength / 4) % 1 === 0) {
28
+ q1 = (1 / 2) * (sortedArray[Math.floor(arrayLength / 4) - 1] + sortedArray[Math.floor(arrayLength / 4)]);
29
+ q3 =
30
+ (1 / 2) *
31
+ (sortedArray[Math.ceil(arrayLength * (3 / 4)) - 1] + sortedArray[Math.ceil(arrayLength * (3 / 4))]);
32
+ }
33
+ else {
34
+ q1 = sortedArray[Math.floor(arrayLength / 4)];
35
+ q3 = sortedArray[Math.floor(arrayLength * (3 / 4))];
36
+ }
37
+ // Calculate inter-quartile range
38
+ iqr = q3 - q1;
39
+ // upper boundary
40
+ upperBoundary = q3 + iqr * 1.5;
41
+ // lower boundary
42
+ lowerBoundary = q1 - iqr * 1.5;
43
+ return [upperBoundary, lowerBoundary];
44
+ };
@@ -5,6 +5,13 @@ export interface ITroubleshootProductResponse {
5
5
  productsResult: Partial<ISEProduct>[];
6
6
  }
7
7
  export declare const handleProductSearchResponse: (productsResultAll: ISEProduct[], productsResultEntitled?: IProductV2[]) => ITroubleshootProductResponse;
8
+ /**
9
+ * This method is used for parsing `hydra/rest/products/contact/{userName}` response form API
10
+ * and need to create partial response like method `handleProductSearchResponse`
11
+ * @param productsResultEntitled IProductV2[]
12
+ * @returns ITroubleshootProductResponse
13
+ */
14
+ export declare const handleEntitledProductResponse: (productsResultEntitled?: IProductV2[]) => ITroubleshootProductResponse;
8
15
  /**
9
16
  * Tries to get top 5 products with priority given to recentlyFiledAgainst
10
17
  * before checking general top products from un-authed SE API
@@ -1 +1 @@
1
- {"version":3,"file":"productsUtils.d.ts","sourceRoot":"","sources":["../../src/productsUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAWhF,MAAM,WAAW,4BAA4B;IACzC,WAAW,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;IACnC,aAAa,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;IACrC,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;CACzC;AAED,eAAO,MAAM,2BAA2B,sBACjB,UAAU,EAAE,2BACP,UAAU,EAAE,KACrC,4BA6BF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,yBAO7D;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,WAE/C;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAEzD;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAEzD;AAED,eAAO,MAAM,aAAa,OAAQ,MAAM,MAAM,MAAM,eAmBnD,CAAC;AAEF,eAAO,MAAM,WAAW,QAAS,MAAM,EAAE,aAExC,CAAC;AAEF,UAAU,sBAAsB;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,sBAAsB,CAkBlE"}
1
+ {"version":3,"file":"productsUtils.d.ts","sourceRoot":"","sources":["../../src/productsUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAWhF,MAAM,WAAW,4BAA4B;IACzC,WAAW,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;IACnC,aAAa,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;IACrC,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;CACzC;AAED,eAAO,MAAM,2BAA2B,sBACjB,UAAU,EAAE,2BACP,UAAU,EAAE,KACrC,4BA6BF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,4BACd,UAAU,EAAE,KACrC,4BAcF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,yBAO7D;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,WAE/C;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAEzD;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAEzD;AAED,eAAO,MAAM,aAAa,OAAQ,MAAM,MAAM,MAAM,eAmBnD,CAAC;AAEF,eAAO,MAAM,WAAW,QAAS,MAAM,EAAE,aAExC,CAAC;AAEF,UAAU,sBAAsB;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,sBAAsB,CAkBlE"}
@@ -31,6 +31,24 @@ export const handleProductSearchResponse = (productsResultAll, productsResultEnt
31
31
  otherProducts: difference(productsResultSorted, topProducts),
32
32
  };
33
33
  };
34
+ /**
35
+ * This method is used for parsing `hydra/rest/products/contact/{userName}` response form API
36
+ * and need to create partial response like method `handleProductSearchResponse`
37
+ * @param productsResultEntitled IProductV2[]
38
+ * @returns ITroubleshootProductResponse
39
+ */
40
+ export const handleEntitledProductResponse = (productsResultEntitled = []) => {
41
+ const productsResult = productsResultEntitled.map((product) => {
42
+ return Object.assign(Object.assign({}, product), { product: product.name });
43
+ });
44
+ const topProducts = getTopProducts(productsResult);
45
+ const productsResultSorted = orderBy(productsResult, ['product'], ['asc']);
46
+ return {
47
+ productsResult: productsResultSorted,
48
+ topProducts,
49
+ otherProducts: difference(productsResultSorted, topProducts),
50
+ };
51
+ };
34
52
  /**
35
53
  * Tries to get top 5 products with priority given to recentlyFiledAgainst
36
54
  * before checking general top products from un-authed SE API
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/utils",
3
- "version": "0.2.21",
3
+ "version": "0.2.32",
4
4
  "description": "> TODO: description",
5
5
  "author": "Vikas Rathee <vrathee@redhat.com>",
6
6
  "license": "ISC",
@@ -45,7 +45,7 @@
45
45
  "prepublishOnly": "npm run build"
46
46
  },
47
47
  "peerDependencies": {
48
- "@cee-eng/hydrajs": "4.7.20",
48
+ "@cee-eng/hydrajs": "4.7.22",
49
49
  "@cee-eng/ui-toolkit": "1.1.6",
50
50
  "@rh-support/api": "0.3.9",
51
51
  "@rh-support/types": "0.2.0",
@@ -61,9 +61,9 @@
61
61
  "solr-query-builder": "1.0.1"
62
62
  },
63
63
  "dependencies": {
64
- "@cee-eng/hydrajs": "4.7.20",
64
+ "@cee-eng/hydrajs": "4.7.22",
65
65
  "@cee-eng/ui-toolkit": "1.1.6",
66
- "@rh-support/api": "0.3.10",
66
+ "@rh-support/api": "0.3.13",
67
67
  "@rh-support/types": "0.2.0",
68
68
  "dompurify": "^2.2.6",
69
69
  "dot": "^1.1.3",
@@ -87,5 +87,5 @@
87
87
  "@types/react-dom": "^17.0.9",
88
88
  "moment-timezone": "^0.5.32"
89
89
  },
90
- "gitHead": "cb0d1a0aad49e869ec8b6f6192c49d710dcf37cb"
90
+ "gitHead": "3d97efe5cebb4e398f73d61326cad31e087aa63f"
91
91
  }