@rh-support/utils 0.2.32 → 0.2.33
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.
|
@@ -4,7 +4,7 @@ export interface ITroubleshootProductResponse {
|
|
|
4
4
|
otherProducts: Partial<ISEProduct>[];
|
|
5
5
|
productsResult: Partial<ISEProduct>[];
|
|
6
6
|
}
|
|
7
|
-
export declare const handleProductSearchResponse: (productsResultAll: ISEProduct[], productsResultEntitled?: IProductV2[]) => ITroubleshootProductResponse;
|
|
7
|
+
export declare const handleProductSearchResponse: (productsResultAll: ISEProduct[], productsResultEntitled?: IProductV2[], topCount?: number) => ITroubleshootProductResponse;
|
|
8
8
|
/**
|
|
9
9
|
* This method is used for parsing `hydra/rest/products/contact/{userName}` response form API
|
|
10
10
|
* and need to create partial response like method `handleProductSearchResponse`
|
|
@@ -13,11 +13,11 @@ export declare const handleProductSearchResponse: (productsResultAll: ISEProduct
|
|
|
13
13
|
*/
|
|
14
14
|
export declare const handleEntitledProductResponse: (productsResultEntitled?: IProductV2[]) => ITroubleshootProductResponse;
|
|
15
15
|
/**
|
|
16
|
-
* Tries to get top
|
|
16
|
+
* Tries to get top products with priority given to recentlyFiledAgainst
|
|
17
17
|
* before checking general top products from un-authed SE API
|
|
18
18
|
* @param products Partial<ISEProduct>
|
|
19
19
|
*/
|
|
20
|
-
export declare function getTopProducts(products: Partial<ISEProduct>[]): Partial<ISEProduct>[];
|
|
20
|
+
export declare function getTopProducts(products: Partial<ISEProduct>[], topCount?: number): Partial<ISEProduct>[];
|
|
21
21
|
export declare function isOnlyVersion(versions: string[]): boolean;
|
|
22
22
|
export declare function getVersionIfOnlyVersion(versions: string[]): string;
|
|
23
23
|
export declare function getUniqueSortedVersions(versions: string[]): string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"productsUtils.d.ts","sourceRoot":"","sources":["../../src/productsUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EA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AAM,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"}
|
package/lib/cjs/productsUtils.js
CHANGED
|
@@ -44,8 +44,9 @@ var orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
|
44
44
|
var remove_1 = __importDefault(require("lodash/remove"));
|
|
45
45
|
var uniq_1 = __importDefault(require("lodash/uniq"));
|
|
46
46
|
var validatorUtils_1 = require("./validatorUtils");
|
|
47
|
-
var handleProductSearchResponse = function (productsResultAll, productsResultEntitled) {
|
|
47
|
+
var handleProductSearchResponse = function (productsResultAll, productsResultEntitled, topCount) {
|
|
48
48
|
if (productsResultEntitled === void 0) { productsResultEntitled = []; }
|
|
49
|
+
if (topCount === void 0) { topCount = 5; }
|
|
49
50
|
var productsResultEntitledMap = {};
|
|
50
51
|
forEach_1.default(productsResultEntitled, function (p) {
|
|
51
52
|
// if (p.supportedForCustomer) { // Needs confirmation froom CCM team before adding
|
|
@@ -60,9 +61,8 @@ var handleProductSearchResponse = function (productsResultAll, productsResultEnt
|
|
|
60
61
|
? product.featuredVersion
|
|
61
62
|
: (_d = product === null || product === void 0 ? void 0 : product.versions[0]) !== null && _d !== void 0 ? _d : '' });
|
|
62
63
|
});
|
|
63
|
-
// first top 5 products before sorting
|
|
64
64
|
// we get products based on the highest number of support cases
|
|
65
|
-
var topProducts = getTopProducts(productsResult);
|
|
65
|
+
var topProducts = getTopProducts(productsResult, topCount);
|
|
66
66
|
var productsResultSorted = orderBy_1.default(productsResult, ['product'], ['asc']);
|
|
67
67
|
return {
|
|
68
68
|
productsResult: productsResultSorted,
|
|
@@ -92,17 +92,18 @@ var handleEntitledProductResponse = function (productsResultEntitled) {
|
|
|
92
92
|
};
|
|
93
93
|
exports.handleEntitledProductResponse = handleEntitledProductResponse;
|
|
94
94
|
/**
|
|
95
|
-
* Tries to get top
|
|
95
|
+
* Tries to get top products with priority given to recentlyFiledAgainst
|
|
96
96
|
* before checking general top products from un-authed SE API
|
|
97
97
|
* @param products Partial<ISEProduct>
|
|
98
98
|
*/
|
|
99
|
-
function getTopProducts(products) {
|
|
99
|
+
function getTopProducts(products, topCount) {
|
|
100
|
+
if (topCount === void 0) { topCount = 5; }
|
|
100
101
|
var toReturn = remove_1.default(__spreadArray([], __read(products)), function (o) { return o.recentlyFiledAgainst; });
|
|
101
|
-
if (toReturn.length <
|
|
102
|
+
if (toReturn.length < topCount) {
|
|
102
103
|
var generalTopProducts = remove_1.default(__spreadArray([], __read(products)), function (o) { return !o.recentlyFiledAgainst && o.isTopProduct; });
|
|
103
104
|
toReturn.push.apply(toReturn, __spreadArray([], __read(generalTopProducts)));
|
|
104
105
|
}
|
|
105
|
-
return toReturn.slice(0,
|
|
106
|
+
return toReturn.slice(0, topCount);
|
|
106
107
|
}
|
|
107
108
|
exports.getTopProducts = getTopProducts;
|
|
108
109
|
function isOnlyVersion(versions) {
|
|
@@ -4,7 +4,7 @@ export interface ITroubleshootProductResponse {
|
|
|
4
4
|
otherProducts: Partial<ISEProduct>[];
|
|
5
5
|
productsResult: Partial<ISEProduct>[];
|
|
6
6
|
}
|
|
7
|
-
export declare const handleProductSearchResponse: (productsResultAll: ISEProduct[], productsResultEntitled?: IProductV2[]) => ITroubleshootProductResponse;
|
|
7
|
+
export declare const handleProductSearchResponse: (productsResultAll: ISEProduct[], productsResultEntitled?: IProductV2[], topCount?: number) => ITroubleshootProductResponse;
|
|
8
8
|
/**
|
|
9
9
|
* This method is used for parsing `hydra/rest/products/contact/{userName}` response form API
|
|
10
10
|
* and need to create partial response like method `handleProductSearchResponse`
|
|
@@ -13,11 +13,11 @@ export declare const handleProductSearchResponse: (productsResultAll: ISEProduct
|
|
|
13
13
|
*/
|
|
14
14
|
export declare const handleEntitledProductResponse: (productsResultEntitled?: IProductV2[]) => ITroubleshootProductResponse;
|
|
15
15
|
/**
|
|
16
|
-
* Tries to get top
|
|
16
|
+
* Tries to get top products with priority given to recentlyFiledAgainst
|
|
17
17
|
* before checking general top products from un-authed SE API
|
|
18
18
|
* @param products Partial<ISEProduct>
|
|
19
19
|
*/
|
|
20
|
-
export declare function getTopProducts(products: Partial<ISEProduct>[]): Partial<ISEProduct>[];
|
|
20
|
+
export declare function getTopProducts(products: Partial<ISEProduct>[], topCount?: number): Partial<ISEProduct>[];
|
|
21
21
|
export declare function isOnlyVersion(versions: string[]): boolean;
|
|
22
22
|
export declare function getVersionIfOnlyVersion(versions: string[]): string;
|
|
23
23
|
export declare function getUniqueSortedVersions(versions: string[]): string[];
|
|
@@ -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,
|
|
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,aAC1B,MAAM,KACjB,4BA4BF,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,EAAE,QAAQ,SAAI,GAAG,OAAO,CAAC,UAAU,CAAC,EAAE,CAOnG;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"}
|
package/lib/esm/productsUtils.js
CHANGED
|
@@ -6,7 +6,7 @@ import orderBy from 'lodash/orderBy';
|
|
|
6
6
|
import filter from 'lodash/remove';
|
|
7
7
|
import uniq from 'lodash/uniq';
|
|
8
8
|
import { isNumber } from './validatorUtils';
|
|
9
|
-
export const handleProductSearchResponse = (productsResultAll, productsResultEntitled = []) => {
|
|
9
|
+
export const handleProductSearchResponse = (productsResultAll, productsResultEntitled = [], topCount = 5) => {
|
|
10
10
|
const productsResultEntitledMap = {};
|
|
11
11
|
forEach(productsResultEntitled, (p) => {
|
|
12
12
|
// if (p.supportedForCustomer) { // Needs confirmation froom CCM team before adding
|
|
@@ -21,9 +21,8 @@ export const handleProductSearchResponse = (productsResultAll, productsResultEnt
|
|
|
21
21
|
? product.featuredVersion
|
|
22
22
|
: (_d = product === null || product === void 0 ? void 0 : product.versions[0]) !== null && _d !== void 0 ? _d : '' });
|
|
23
23
|
});
|
|
24
|
-
// first top 5 products before sorting
|
|
25
24
|
// we get products based on the highest number of support cases
|
|
26
|
-
const topProducts = getTopProducts(productsResult);
|
|
25
|
+
const topProducts = getTopProducts(productsResult, topCount);
|
|
27
26
|
const productsResultSorted = orderBy(productsResult, ['product'], ['asc']);
|
|
28
27
|
return {
|
|
29
28
|
productsResult: productsResultSorted,
|
|
@@ -50,17 +49,17 @@ export const handleEntitledProductResponse = (productsResultEntitled = []) => {
|
|
|
50
49
|
};
|
|
51
50
|
};
|
|
52
51
|
/**
|
|
53
|
-
* Tries to get top
|
|
52
|
+
* Tries to get top products with priority given to recentlyFiledAgainst
|
|
54
53
|
* before checking general top products from un-authed SE API
|
|
55
54
|
* @param products Partial<ISEProduct>
|
|
56
55
|
*/
|
|
57
|
-
export function getTopProducts(products) {
|
|
56
|
+
export function getTopProducts(products, topCount = 5) {
|
|
58
57
|
const toReturn = filter([...products], (o) => o.recentlyFiledAgainst);
|
|
59
|
-
if (toReturn.length <
|
|
58
|
+
if (toReturn.length < topCount) {
|
|
60
59
|
const generalTopProducts = filter([...products], (o) => !o.recentlyFiledAgainst && o.isTopProduct);
|
|
61
60
|
toReturn.push(...generalTopProducts);
|
|
62
61
|
}
|
|
63
|
-
return toReturn.slice(0,
|
|
62
|
+
return toReturn.slice(0, topCount);
|
|
64
63
|
}
|
|
65
64
|
export function isOnlyVersion(versions) {
|
|
66
65
|
return (versions === null || versions === void 0 ? void 0 : versions.length) && versions.length === 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.33",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "Vikas Rathee <vrathee@redhat.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"@types/react-dom": "^17.0.9",
|
|
88
88
|
"moment-timezone": "^0.5.32"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "5797cf1fd9b2d2406fa93933f91fcc0b0729e7a8"
|
|
91
91
|
}
|