@rh-support/utils 0.2.34-alpha-0 → 0.2.36

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.
@@ -6,4 +6,10 @@ export declare const getTimezoneOffsetFromTZName: (tzName: string) => string;
6
6
  export declare const getPastUTCDateFromNow: (pastDays: number) => string;
7
7
  export declare const isCurrentDateSameAsOrBeforeDate: (date: string, granularity?: moment.unitOfTime.StartOf) => boolean;
8
8
  export declare const isFutureDate: (date: string, granularity?: moment.unitOfTime.StartOf) => boolean;
9
+ declare type AddToDate = {
10
+ days: number;
11
+ date?: string;
12
+ };
13
+ export declare const addDaysToDate: (params: AddToDate) => moment.Moment;
14
+ export {};
9
15
  //# sourceMappingURL=dateUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/dateUtils.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,eAAO,MAAM,UAAU,wCAGX,KAAK,qBAAqB,WASrC,CAAC;AAEF,eAAO,MAAM,cAAc,wCAGf,KAAK,qBAAqB,WAerC,CAAC;AAEF,eAAO,MAAM,OAAO,SAAU,MAAM,KAAG,MAAmC,CAAC;AAE3E,eAAO,MAAM,2BAA2B,WAAY,MAAM,WAEzD,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAExD,CAAC;AAEF,eAAO,MAAM,+BAA+B,SAClC,MAAM,gBACC,OAAO,UAAU,CAAC,OAAO,KACvC,OAEF,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,gBAAe,OAAO,UAAU,CAAC,OAAO,YAEhF,CAAC"}
1
+ {"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/dateUtils.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,eAAO,MAAM,UAAU,wCAGX,KAAK,qBAAqB,WASrC,CAAC;AAEF,eAAO,MAAM,cAAc,wCAGf,KAAK,qBAAqB,WAerC,CAAC;AAEF,eAAO,MAAM,OAAO,SAAU,MAAM,KAAG,MAAmC,CAAC;AAE3E,eAAO,MAAM,2BAA2B,WAAY,MAAM,WAEzD,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAExD,CAAC;AAEF,eAAO,MAAM,+BAA+B,SAClC,MAAM,gBACC,OAAO,UAAU,CAAC,OAAO,KACvC,OAEF,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,gBAAe,OAAO,UAAU,CAAC,OAAO,YAEhF,CAAC;AAEF,aAAK,SAAS,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,aAAa,WAAY,SAAS,kBAG9C,CAAC"}
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isFutureDate = exports.isCurrentDateSameAsOrBeforeDate = exports.getPastUTCDateFromNow = exports.getTimezoneOffsetFromTZName = exports.isoDate = exports.formatDateTime = exports.formatDate = void 0;
6
+ exports.addDaysToDate = exports.isFutureDate = exports.isCurrentDateSameAsOrBeforeDate = exports.getPastUTCDateFromNow = exports.getTimezoneOffsetFromTZName = exports.isoDate = exports.formatDateTime = exports.formatDate = void 0;
7
7
  var moment_timezone_1 = __importDefault(require("moment-timezone"));
8
8
  var formatDate = function (date, locale, format) {
9
9
  if (locale === void 0) { locale = 'en-us'; }
@@ -55,3 +55,8 @@ var isFutureDate = function (date, granularity) {
55
55
  return moment_timezone_1.default(date).isAfter(moment_timezone_1.default(), granularity);
56
56
  };
57
57
  exports.isFutureDate = isFutureDate;
58
+ var addDaysToDate = function (params) {
59
+ var days = params.days, _a = params.date, date = _a === void 0 ? new Date() : _a;
60
+ return moment_timezone_1.default(date).add(days, 'days');
61
+ };
62
+ exports.addDaysToDate = addDaysToDate;
@@ -5,6 +5,13 @@ export interface ITroubleshootProductResponse {
5
5
  productsResult: Partial<ISEProduct>[];
6
6
  }
7
7
  export declare const handleProductSearchResponse: (productsResultAll: ISEProduct[], productsResultEntitled?: IProductV2[], topCount?: number) => 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 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,aAC1B,MAAM,KACjB,4BA4BF,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,uBAA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AM,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, isEntitledProduct: true });
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 products with priority given to recentlyFiledAgainst
76
96
  * before checking general top products from un-authed SE API
@@ -6,4 +6,10 @@ export declare const getTimezoneOffsetFromTZName: (tzName: string) => string;
6
6
  export declare const getPastUTCDateFromNow: (pastDays: number) => string;
7
7
  export declare const isCurrentDateSameAsOrBeforeDate: (date: string, granularity?: moment.unitOfTime.StartOf) => boolean;
8
8
  export declare const isFutureDate: (date: string, granularity?: moment.unitOfTime.StartOf) => boolean;
9
+ declare type AddToDate = {
10
+ days: number;
11
+ date?: string;
12
+ };
13
+ export declare const addDaysToDate: (params: AddToDate) => moment.Moment;
14
+ export {};
9
15
  //# sourceMappingURL=dateUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/dateUtils.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,eAAO,MAAM,UAAU,wCAGX,KAAK,qBAAqB,WASrC,CAAC;AAEF,eAAO,MAAM,cAAc,wCAGf,KAAK,qBAAqB,WAerC,CAAC;AAEF,eAAO,MAAM,OAAO,SAAU,MAAM,KAAG,MAAmC,CAAC;AAE3E,eAAO,MAAM,2BAA2B,WAAY,MAAM,WAEzD,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAExD,CAAC;AAEF,eAAO,MAAM,+BAA+B,SAClC,MAAM,gBACC,OAAO,UAAU,CAAC,OAAO,KACvC,OAEF,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,gBAAe,OAAO,UAAU,CAAC,OAAO,YAEhF,CAAC"}
1
+ {"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/dateUtils.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,eAAO,MAAM,UAAU,wCAGX,KAAK,qBAAqB,WASrC,CAAC;AAEF,eAAO,MAAM,cAAc,wCAGf,KAAK,qBAAqB,WAerC,CAAC;AAEF,eAAO,MAAM,OAAO,SAAU,MAAM,KAAG,MAAmC,CAAC;AAE3E,eAAO,MAAM,2BAA2B,WAAY,MAAM,WAEzD,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAExD,CAAC;AAEF,eAAO,MAAM,+BAA+B,SAClC,MAAM,gBACC,OAAO,UAAU,CAAC,OAAO,KACvC,OAEF,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,gBAAe,OAAO,UAAU,CAAC,OAAO,YAEhF,CAAC;AAEF,aAAK,SAAS,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,aAAa,WAAY,SAAS,kBAG9C,CAAC"}
@@ -36,3 +36,7 @@ export const isCurrentDateSameAsOrBeforeDate = (date, granularity = 'day') => {
36
36
  export const isFutureDate = (date, granularity = 'day') => {
37
37
  return moment(date).isAfter(moment(), granularity);
38
38
  };
39
+ export const addDaysToDate = (params) => {
40
+ const { days, date = new Date() } = params;
41
+ return moment(date).add(days, 'days');
42
+ };
@@ -5,6 +5,13 @@ export interface ITroubleshootProductResponse {
5
5
  productsResult: Partial<ISEProduct>[];
6
6
  }
7
7
  export declare const handleProductSearchResponse: (productsResultAll: ISEProduct[], productsResultEntitled?: IProductV2[], topCount?: number) => 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 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,aAC1B,MAAM,KACjB,4BA4BF,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"}
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,4BAeF,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"}
@@ -30,6 +30,24 @@ export const handleProductSearchResponse = (productsResultAll, productsResultEnt
30
30
  otherProducts: difference(productsResultSorted, topProducts),
31
31
  };
32
32
  };
33
+ /**
34
+ * This method is used for parsing `hydra/rest/products/contact/{userName}` response form API
35
+ * and need to create partial response like method `handleProductSearchResponse`
36
+ * @param productsResultEntitled IProductV2[]
37
+ * @returns ITroubleshootProductResponse
38
+ */
39
+ export const handleEntitledProductResponse = (productsResultEntitled = []) => {
40
+ const productsResult = productsResultEntitled.map((product) => {
41
+ return Object.assign(Object.assign({}, product), { product: product.name, isEntitledProduct: true });
42
+ });
43
+ const topProducts = getTopProducts(productsResult);
44
+ const productsResultSorted = orderBy(productsResult, ['product'], ['asc']);
45
+ return {
46
+ productsResult: productsResultSorted,
47
+ topProducts,
48
+ otherProducts: difference(productsResultSorted, topProducts),
49
+ };
50
+ };
33
51
  /**
34
52
  * Tries to get top products with priority given to recentlyFiledAgainst
35
53
  * 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.34-alpha-0",
3
+ "version": "0.2.36",
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.22",
48
+ "@cee-eng/hydrajs": "4.9.1",
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.22",
64
+ "@cee-eng/hydrajs": "4.9.1",
65
65
  "@cee-eng/ui-toolkit": "1.1.6",
66
- "@rh-support/api": "0.3.13",
66
+ "@rh-support/api": "0.3.15",
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": "c493eace4748f428da4c41f386381e609dd39651"
90
+ "gitHead": "ad255c7391384f7369695275fcd43481f4298974"
91
91
  }