@rh-support/utils 0.2.23 → 0.2.31

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
+ .
@@ -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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EF,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
@@ -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,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AE,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.23",
3
+ "version": "0.2.31",
4
4
  "description": "> TODO: description",
5
5
  "author": "Vikas Rathee <vrathee@redhat.com>",
6
6
  "license": "ISC",
@@ -63,8 +63,8 @@
63
63
  "dependencies": {
64
64
  "@cee-eng/hydrajs": "4.7.20",
65
65
  "@cee-eng/ui-toolkit": "1.1.6",
66
- "@rh-support/api": "^0.3.12",
67
- "@rh-support/types": "^0.2.2",
66
+ "@rh-support/api": "0.3.10",
67
+ "@rh-support/types": "0.2.0",
68
68
  "dompurify": "^2.2.6",
69
69
  "dot": "^1.1.3",
70
70
  "i18next": "^19.0.1",
@@ -87,5 +87,5 @@
87
87
  "@types/react-dom": "^17.0.9",
88
88
  "moment-timezone": "^0.5.32"
89
89
  },
90
- "gitHead": "70f8095b855f531eb814e85cb5a77908405fff5f"
90
+ "gitHead": "274324da926ca7deeaeba9fe702cacd0129941a1"
91
91
  }