@rh-support/utils 2.0.7 → 2.0.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.
@@ -4,10 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.addDaysToDate = exports.isFutureDate = exports.isCurrentDateSameAsOrBeforeDate = exports.getPastUTCDateFromNow = exports.getTimezoneOffsetFromTZName = exports.isoDate = exports.formatDateTime = exports.formatDate = void 0;
7
- var moment_timezone_1 = __importDefault(require("moment-timezone"));
8
- var formatDate = function (date, locale, format) {
9
- if (locale === void 0) { locale = 'en-us'; }
10
- if (format === void 0) { format = { month: 'short', day: 'numeric', year: 'numeric' }; }
7
+ const moment_timezone_1 = __importDefault(require("moment-timezone"));
8
+ const formatDate = (date, locale = 'en-us', format = { month: 'short', day: 'numeric', year: 'numeric' }) => {
11
9
  if (!date) {
12
10
  return '';
13
11
  }
@@ -17,46 +15,42 @@ var formatDate = function (date, locale, format) {
17
15
  return new Intl.DateTimeFormat(locale, format).format(date);
18
16
  };
19
17
  exports.formatDate = formatDate;
20
- var formatDateTime = function (date, locale, format) {
21
- if (locale === void 0) { locale = 'en-us'; }
22
- if (format === void 0) { format = {
23
- weekday: 'short',
24
- month: 'short',
25
- day: 'numeric',
26
- year: 'numeric',
27
- hour: '2-digit',
28
- minute: '2-digit',
29
- second: '2-digit',
30
- timeZoneName: 'short',
31
- }; }
18
+ const formatDateTime = (date, locale = 'en-us', format = {
19
+ weekday: 'short',
20
+ month: 'short',
21
+ day: 'numeric',
22
+ year: 'numeric',
23
+ hour: '2-digit',
24
+ minute: '2-digit',
25
+ second: '2-digit',
26
+ timeZoneName: 'short',
27
+ }) => {
32
28
  if (!date) {
33
29
  return '';
34
30
  }
35
31
  return exports.formatDate(date, locale, format);
36
32
  };
37
33
  exports.formatDateTime = formatDateTime;
38
- var isoDate = function (date) { return new Date(date).toString(); };
34
+ const isoDate = (date) => new Date(date).toString();
39
35
  exports.isoDate = isoDate;
40
- var getTimezoneOffsetFromTZName = function (tzName) {
36
+ const getTimezoneOffsetFromTZName = (tzName) => {
41
37
  return moment_timezone_1.default().tz(tzName).format('Z');
42
38
  };
43
39
  exports.getTimezoneOffsetFromTZName = getTimezoneOffsetFromTZName;
44
- var getPastUTCDateFromNow = function (pastDays) {
40
+ const getPastUTCDateFromNow = (pastDays) => {
45
41
  return moment_timezone_1.default().subtract(pastDays, 'days').utc().format();
46
42
  };
47
43
  exports.getPastUTCDateFromNow = getPastUTCDateFromNow;
48
- var isCurrentDateSameAsOrBeforeDate = function (date, granularity) {
49
- if (granularity === void 0) { granularity = 'day'; }
44
+ const isCurrentDateSameAsOrBeforeDate = (date, granularity = 'day') => {
50
45
  return moment_timezone_1.default(moment_timezone_1.default.now()).isSameOrBefore(date, granularity);
51
46
  };
52
47
  exports.isCurrentDateSameAsOrBeforeDate = isCurrentDateSameAsOrBeforeDate;
53
- var isFutureDate = function (date, granularity) {
54
- if (granularity === void 0) { granularity = 'day'; }
48
+ const isFutureDate = (date, granularity = 'day') => {
55
49
  return moment_timezone_1.default(date).isAfter(moment_timezone_1.default(), granularity);
56
50
  };
57
51
  exports.isFutureDate = isFutureDate;
58
- var addDaysToDate = function (params) {
59
- var days = params.days, _a = params.date, date = _a === void 0 ? new Date() : _a;
52
+ const addDaysToDate = (params) => {
53
+ const { days, date = new Date() } = params;
60
54
  return moment_timezone_1.default(date).add(days, 'days');
61
55
  };
62
56
  exports.addDaysToDate = addDaysToDate;
@@ -4,12 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getDropdownBtnPlaceholder = exports.toOptions = exports.toOption = void 0;
7
- var isFunction_1 = __importDefault(require("lodash/isFunction"));
8
- var map_1 = __importDefault(require("lodash/map"));
9
- function toOption(value, config) {
10
- if (config === void 0) { config = {}; }
7
+ const isFunction_1 = __importDefault(require("lodash/isFunction"));
8
+ const map_1 = __importDefault(require("lodash/map"));
9
+ function toOption(value, config = {}) {
11
10
  return (value && {
12
- value: value,
11
+ value,
13
12
  label: ((config === null || config === void 0 ? void 0 : config.labelKey)
14
13
  ? isFunction_1.default(config === null || config === void 0 ? void 0 : config.labelKey)
15
14
  ? config === null || config === void 0 ? void 0 : config.labelKey(value)
@@ -38,9 +37,8 @@ function toOption(value, config) {
38
37
  });
39
38
  }
40
39
  exports.toOption = toOption;
41
- function toOptions(values, config) {
42
- if (config === void 0) { config = {}; }
43
- return map_1.default(values, function (v) { return toOption(v, config); });
40
+ function toOptions(values, config = {}) {
41
+ return map_1.default(values, (v) => toOption(v, config));
44
42
  }
45
43
  exports.toOptions = toOptions;
46
44
  function getDropdownBtnPlaceholder(btnPlaceholder, selectedValues, type, totalLength, totalLengthString) {
@@ -48,14 +46,14 @@ function getDropdownBtnPlaceholder(btnPlaceholder, selectedValues, type, totalLe
48
46
  return btnPlaceholder;
49
47
  }
50
48
  else if (selectedValues && selectedValues.length === 1) {
51
- var selectedItem = selectedValues[0];
49
+ const selectedItem = selectedValues[0];
52
50
  return typeof selectedItem === 'string' ? selectedItem : selectedItem.value;
53
51
  }
54
52
  else if (selectedValues && totalLength && selectedValues.length === totalLength) {
55
53
  return totalLengthString || btnPlaceholder;
56
54
  }
57
55
  else {
58
- return selectedValues.length + " " + type + " selected";
56
+ return `${selectedValues.length} ${type} selected`;
59
57
  }
60
58
  }
61
59
  exports.getDropdownBtnPlaceholder = getDropdownBtnPlaceholder;
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.dtmTrackEvent = exports.pendoTrackEvent = exports.haltEvent = void 0;
7
- var hydrajs_1 = require("@cee-eng/hydrajs");
8
- var isEmpty_1 = __importDefault(require("lodash/isEmpty"));
7
+ const hydrajs_1 = require("@cee-eng/hydrajs");
8
+ const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
9
9
  function haltEvent(event) {
10
10
  if (event) {
11
11
  event.stopPropagation();
@@ -16,9 +16,8 @@ exports.haltEvent = haltEvent;
16
16
  // https://support.pendo.io/hc/en-us/articles/360032294291-Track-Events-Configuration
17
17
  // if event name is not exist in the pendo then it will create
18
18
  // new event otherwise it will update existing event.
19
- function pendoTrackEvent(name, properties) {
20
- if (properties === void 0) { properties = {}; }
21
- var pendo = window.pendo;
19
+ function pendoTrackEvent(name, properties = {}) {
20
+ const pendo = window.pendo;
22
21
  // log the event for prod and local envirnoment
23
22
  if (!isEmpty_1.default(pendo) && (hydrajs_1.Env.getEnvName() === hydrajs_1.Env.EnvNames.PROD || hydrajs_1.Env.isLocalEnv())) {
24
23
  pendo.track(name, properties);
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSFDCSecureSupportCaseLink = exports.getSFDCEnv = exports.APP_HOST_NAMES = void 0;
4
- var hydrajs_1 = require("@cee-eng/hydrajs");
4
+ const hydrajs_1 = require("@cee-eng/hydrajs");
5
5
  var APP_HOST_NAMES;
6
6
  (function (APP_HOST_NAMES) {
7
7
  APP_HOST_NAMES["supportHubHostName"] = "supportHubHostName";
8
8
  })(APP_HOST_NAMES || (APP_HOST_NAMES = {}));
9
9
  exports.APP_HOST_NAMES = APP_HOST_NAMES;
10
- var getSFDCEnv = function () {
11
- var env = hydrajs_1.Env.getEnvName();
10
+ const getSFDCEnv = () => {
11
+ const env = hydrajs_1.Env.getEnvName();
12
12
  // Prod HostName
13
- var hostName = 'gss.my.salesforce.com';
13
+ let hostName = 'gss.my.salesforce.com';
14
14
  switch (env) {
15
15
  case hydrajs_1.Env.EnvNames.QA:
16
16
  hostName = 'gss--qa.cs53.my.salesforce.com';
@@ -28,8 +28,8 @@ var getSFDCEnv = function () {
28
28
  return hostName;
29
29
  };
30
30
  exports.getSFDCEnv = getSFDCEnv;
31
- var getSFDCSecureSupportCaseLink = function (caseNumber) {
32
- var hostName = getSFDCEnv();
33
- return "https://" + hostName + "/apex/Support#/cases/" + caseNumber;
31
+ const getSFDCSecureSupportCaseLink = (caseNumber) => {
32
+ const hostName = getSFDCEnv();
33
+ return `https://${hostName}/apex/Support#/cases/${caseNumber}`;
34
34
  };
35
35
  exports.getSFDCSecureSupportCaseLink = getSFDCSecureSupportCaseLink;
@@ -1,35 +1,14 @@
1
1
  "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
19
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
20
- to[j] = from[i];
21
- return to;
22
- };
23
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
24
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
25
4
  };
26
5
  Object.defineProperty(exports, "__esModule", { value: true });
27
6
  exports.getFieldInParts = exports.getConfigField = exports.PCM_CONFIG_FIELD_TYPE = void 0;
28
- var concat_1 = __importDefault(require("lodash/concat"));
29
- var map_1 = __importDefault(require("lodash/map"));
30
- var merge_1 = __importDefault(require("lodash/merge"));
31
- var reduce_1 = __importDefault(require("lodash/reduce"));
32
- var startsWith_1 = __importDefault(require("lodash/startsWith"));
7
+ const concat_1 = __importDefault(require("lodash/concat"));
8
+ const map_1 = __importDefault(require("lodash/map"));
9
+ const merge_1 = __importDefault(require("lodash/merge"));
10
+ const reduce_1 = __importDefault(require("lodash/reduce"));
11
+ const startsWith_1 = __importDefault(require("lodash/startsWith"));
33
12
  var PCM_CONFIG_FIELD_TYPE;
34
13
  (function (PCM_CONFIG_FIELD_TYPE) {
35
14
  PCM_CONFIG_FIELD_TYPE["JSON"] = "JSON";
@@ -38,10 +17,9 @@ var PCM_CONFIG_FIELD_TYPE;
38
17
  PCM_CONFIG_FIELD_TYPE["FEATURE_FLAG"] = "FEATURE-FLAG";
39
18
  PCM_CONFIG_FIELD_TYPE["STRING_COMMA_SEPERATED"] = "STRING-COMMA-SEPERATED";
40
19
  })(PCM_CONFIG_FIELD_TYPE = exports.PCM_CONFIG_FIELD_TYPE || (exports.PCM_CONFIG_FIELD_TYPE = {}));
41
- function getConfigField(config, fieldName, fieldType) {
42
- if (fieldType === void 0) { fieldType = null; }
43
- var values = reduce_1.default(config, function (result, v) {
44
- return v.fieldName.startsWith(fieldName) ? __spreadArray(__spreadArray([], __read(result)), [v.fieldValue]) : result;
20
+ function getConfigField(config, fieldName, fieldType = null) {
21
+ let values = reduce_1.default(config, (result, v) => {
22
+ return v.fieldName.startsWith(fieldName) ? [...result, v.fieldValue] : result;
45
23
  }, []);
46
24
  if (fieldType && fieldType === PCM_CONFIG_FIELD_TYPE.FEATURE_FLAG) {
47
25
  return values.length === 0 ? false : Boolean(parseInt(values[0]));
@@ -51,7 +29,7 @@ function getConfigField(config, fieldName, fieldType) {
51
29
  if (!fieldType)
52
30
  return values;
53
31
  try {
54
- var parsed = values.map(function (value) { return JSON.parse(value); });
32
+ const parsed = values.map((value) => JSON.parse(value));
55
33
  if (fieldType === PCM_CONFIG_FIELD_TYPE.JSON)
56
34
  return parsed;
57
35
  if (fieldType === PCM_CONFIG_FIELD_TYPE.JSON_ARRAY)
@@ -64,10 +42,9 @@ function getConfigField(config, fieldName, fieldType) {
64
42
  }
65
43
  }
66
44
  exports.getConfigField = getConfigField;
67
- var getFieldInParts = function (config, fieldName, fieldType) {
68
- if (fieldType === void 0) { fieldType = null; }
69
- var values = reduce_1.default(config, function (result, v) {
70
- return startsWith_1.default(v.fieldName, fieldName) ? __spreadArray(__spreadArray([], __read(result)), [v.fieldValue]) : result;
45
+ const getFieldInParts = (config, fieldName, fieldType = null) => {
46
+ const values = reduce_1.default(config, (result, v) => {
47
+ return startsWith_1.default(v.fieldName, fieldName) ? [...result, v.fieldValue] : result;
71
48
  }, []);
72
49
  if (values.length === 0) {
73
50
  return null;
@@ -77,11 +54,11 @@ var getFieldInParts = function (config, fieldName, fieldType) {
77
54
  }
78
55
  try {
79
56
  if (fieldType === 'STRING-COMMA-SEPERATED') {
80
- return reduce_1.default(values, function (acc, value) {
57
+ return reduce_1.default(values, (acc, value) => {
81
58
  return acc.concat(value.split(','));
82
59
  }, []);
83
60
  }
84
- var parsed = map_1.default(values, JSON.parse);
61
+ const parsed = map_1.default(values, JSON.parse);
85
62
  if (fieldType === 'JSON') {
86
63
  return parsed;
87
64
  }
@@ -4,23 +4,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.parseDotTemplate = exports.getRuleReasonHtml = void 0;
7
- var ui_toolkit_1 = require("@cee-eng/ui-toolkit");
8
- var doT_1 = __importDefault(require("dot/doT"));
9
- var assign_1 = __importDefault(require("lodash/assign"));
7
+ const ui_toolkit_1 = require("@cee-eng/ui-toolkit");
8
+ const doT_1 = __importDefault(require("dot/doT"));
9
+ const assign_1 = __importDefault(require("lodash/assign"));
10
10
  doT_1.default.templateSettings = assign_1.default({}, doT_1.default.templateSettings, {
11
11
  varname: 'pydata',
12
12
  strip: false,
13
13
  });
14
14
  function getRuleReasonHtml(ruleReason, reportDetails) {
15
- var resultText = parseDotTemplate(ruleReason, reportDetails);
16
- var html = ui_toolkit_1.markdownToHTML(resultText);
15
+ const resultText = parseDotTemplate(ruleReason, reportDetails);
16
+ const html = ui_toolkit_1.markdownToHTML(resultText);
17
17
  return html;
18
18
  }
19
19
  exports.getRuleReasonHtml = getRuleReasonHtml;
20
20
  function parseDotTemplate(dotString, reportDetails) {
21
- var parsedDotString = '';
21
+ let parsedDotString = '';
22
22
  try {
23
- var tempFn = doT_1.default.template(dotString);
23
+ const tempFn = doT_1.default.template(dotString);
24
24
  parsedDotString = tempFn(reportDetails);
25
25
  }
26
26
  catch (e) {
@@ -1,22 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LRUCache = void 0;
4
- var LRUCache = /** @class */ (function () {
5
- function LRUCache(max) {
6
- if (max === void 0) { max = 10; }
4
+ class LRUCache {
5
+ constructor(max = 10) {
7
6
  this.max = max;
8
7
  this.cache = new Map();
9
8
  }
10
- LRUCache.prototype.get = function (key) {
11
- var item = this.cache.get(key);
9
+ get(key) {
10
+ let item = this.cache.get(key);
12
11
  if (item) {
13
12
  // refresh key
14
13
  this.cache.delete(key);
15
14
  this.cache.set(key, item);
16
15
  }
17
16
  return item;
18
- };
19
- LRUCache.prototype.set = function (key, val) {
17
+ }
18
+ set(key, val) {
20
19
  // refresh key
21
20
  if (this.cache.has(key))
22
21
  this.cache.delete(key);
@@ -24,24 +23,23 @@ var LRUCache = /** @class */ (function () {
24
23
  else if (this.cache.size === this.max)
25
24
  this.cache.delete(this.first());
26
25
  this.cache.set(key, val);
27
- };
28
- LRUCache.prototype.has = function (key) {
26
+ }
27
+ has(key) {
29
28
  return this.cache.has(key);
30
- };
31
- LRUCache.prototype.size = function () {
29
+ }
30
+ size() {
32
31
  return this.cache.size;
33
- };
34
- LRUCache.prototype.first = function () {
32
+ }
33
+ first() {
35
34
  return this.cache.keys().next().value;
36
- };
37
- LRUCache.prototype.peek = function (key) {
35
+ }
36
+ peek(key) {
38
37
  if (this.cache.has(key)) {
39
38
  return this.cache.get(key);
40
39
  }
41
- };
42
- LRUCache.prototype.clear = function () {
40
+ }
41
+ clear() {
43
42
  this.cache.clear();
44
- };
45
- return LRUCache;
46
- }());
43
+ }
44
+ }
47
45
  exports.LRUCache = LRUCache;
@@ -15,16 +15,16 @@
15
15
  */
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.outlier = void 0;
18
- var outlier = function (array) {
18
+ const outlier = (array) => {
19
19
  // Take array length
20
- var arrayLength = array.length;
20
+ const arrayLength = array.length;
21
21
  // Check if length is smaller than four then return array result as it is
22
22
  if (arrayLength < 4) {
23
23
  return array;
24
24
  }
25
- var q1, q3, iqr, upperBoundary, lowerBoundary;
25
+ let q1, q3, iqr, upperBoundary, lowerBoundary;
26
26
  // Make a copy of array plus sort it in ascending order
27
- var sortedArray = array.slice().sort(function (a, b) { return a - b; });
27
+ const sortedArray = array.slice().sort((a, b) => a - b);
28
28
  // Find the quartiles range
29
29
  // If median is odd adjust the index by minus one
30
30
  if (((arrayLength - 1) / 4) % 1 === 0 || (arrayLength / 4) % 1 === 0) {
@@ -1,72 +1,38 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __read = (this && this.__read) || function (o, n) {
14
- var m = typeof Symbol === "function" && o[Symbol.iterator];
15
- if (!m) return o;
16
- var i = m.call(o), r, ar = [], e;
17
- try {
18
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
- }
20
- catch (error) { e = { error: error }; }
21
- finally {
22
- try {
23
- if (r && !r.done && (m = i["return"])) m.call(i);
24
- }
25
- finally { if (e) throw e.error; }
26
- }
27
- return ar;
28
- };
29
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
30
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
31
- to[j] = from[i];
32
- return to;
33
- };
34
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
35
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
4
  };
37
5
  Object.defineProperty(exports, "__esModule", { value: true });
38
6
  exports.isSpecialSupportOfferingEnabled = exports.getVersion = exports.versionSort = exports.versionSorter = exports.getUniqueSortedVersions = exports.getVersionIfOnlyVersion = exports.isOnlyVersion = exports.getTopProducts = exports.handleEntitledProductResponse = exports.handleProductSearchResponse = void 0;
39
- var difference_1 = __importDefault(require("lodash/difference"));
40
- var forEach_1 = __importDefault(require("lodash/forEach"));
41
- var isEmpty_1 = __importDefault(require("lodash/isEmpty"));
42
- var map_1 = __importDefault(require("lodash/map"));
43
- var orderBy_1 = __importDefault(require("lodash/orderBy"));
44
- var remove_1 = __importDefault(require("lodash/remove"));
45
- var uniq_1 = __importDefault(require("lodash/uniq"));
46
- var validatorUtils_1 = require("./validatorUtils");
47
- var handleProductSearchResponse = function (productsResultAll, productsResultEntitled, topCount) {
48
- if (productsResultEntitled === void 0) { productsResultEntitled = []; }
49
- if (topCount === void 0) { topCount = 5; }
50
- var productsResultEntitledMap = {};
51
- forEach_1.default(productsResultEntitled, function (p) {
7
+ const difference_1 = __importDefault(require("lodash/difference"));
8
+ const forEach_1 = __importDefault(require("lodash/forEach"));
9
+ const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
10
+ const map_1 = __importDefault(require("lodash/map"));
11
+ const orderBy_1 = __importDefault(require("lodash/orderBy"));
12
+ const remove_1 = __importDefault(require("lodash/remove"));
13
+ const uniq_1 = __importDefault(require("lodash/uniq"));
14
+ const validatorUtils_1 = require("./validatorUtils");
15
+ const handleProductSearchResponse = (productsResultAll, productsResultEntitled = [], topCount = 5) => {
16
+ const productsResultEntitledMap = {};
17
+ forEach_1.default(productsResultEntitled, (p) => {
52
18
  // If (p.supportedForCustomer)
53
19
  // Needs confirmation froom CCM team before adding
54
- productsResultEntitledMap["" + p.name] = p;
20
+ productsResultEntitledMap[`${p.name}`] = p;
55
21
  });
56
- var productsResult = map_1.default(productsResultAll, function (product) {
22
+ const productsResult = map_1.default(productsResultAll, (product) => {
57
23
  var _c, _d;
58
- var entitledProduct = productsResultEntitledMap[product.product];
59
- var uniqueVersions = getUniqueSortedVersions(product.versions);
60
- return __assign(__assign(__assign({}, product), entitledProduct), { versions: uniqueVersions, isEntitledProduct: !isEmpty_1.default(entitledProduct), featuredVersion: ((_c = product.versions) === null || _c === void 0 ? void 0 : _c.includes(product.featuredVersion))
24
+ const entitledProduct = productsResultEntitledMap[product.product];
25
+ const uniqueVersions = getUniqueSortedVersions(product.versions);
26
+ return Object.assign(Object.assign(Object.assign({}, product), entitledProduct), { versions: uniqueVersions, isEntitledProduct: !isEmpty_1.default(entitledProduct), featuredVersion: ((_c = product.versions) === null || _c === void 0 ? void 0 : _c.includes(product.featuredVersion))
61
27
  ? product.featuredVersion
62
28
  : (_d = product === null || product === void 0 ? void 0 : product.versions[0]) !== null && _d !== void 0 ? _d : '' });
63
29
  });
64
30
  // We get products based on the highest number of support cases
65
- var topProducts = getTopProducts(productsResult, topCount);
66
- var productsResultSorted = orderBy_1.default(productsResult, ['product'], ['asc']);
31
+ const topProducts = getTopProducts(productsResult, topCount);
32
+ const productsResultSorted = orderBy_1.default(productsResult, ['product'], ['asc']);
67
33
  return {
68
34
  productsResult: productsResultSorted,
69
- topProducts: topProducts,
35
+ topProducts,
70
36
  otherProducts: difference_1.default(productsResultSorted, topProducts),
71
37
  };
72
38
  };
@@ -77,16 +43,15 @@ exports.handleProductSearchResponse = handleProductSearchResponse;
77
43
  * @param productsResultEntitled IProductV2[]
78
44
  * @returns ITroubleshootProductResponse
79
45
  */
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 });
46
+ const handleEntitledProductResponse = (productsResultEntitled = []) => {
47
+ const productsResult = productsResultEntitled.map((product) => {
48
+ return Object.assign(Object.assign({}, product), { product: product.name, isEntitledProduct: true });
84
49
  });
85
- var topProducts = getTopProducts(productsResult);
86
- var productsResultSorted = orderBy_1.default(productsResult, ['product'], ['asc']);
50
+ const topProducts = getTopProducts(productsResult);
51
+ const productsResultSorted = orderBy_1.default(productsResult, ['product'], ['asc']);
87
52
  return {
88
53
  productsResult: productsResultSorted,
89
- topProducts: topProducts,
54
+ topProducts,
90
55
  otherProducts: difference_1.default(productsResultSorted, topProducts),
91
56
  };
92
57
  };
@@ -96,12 +61,11 @@ exports.handleEntitledProductResponse = handleEntitledProductResponse;
96
61
  * before checking general top products from un-authed SE API
97
62
  * @param products Partial<ISEProduct>
98
63
  */
99
- function getTopProducts(products, topCount) {
100
- if (topCount === void 0) { topCount = 5; }
101
- var toReturn = remove_1.default(__spreadArray([], __read(products)), function (o) { return o.recentlyFiledAgainst; });
64
+ function getTopProducts(products, topCount = 5) {
65
+ const toReturn = remove_1.default([...products], (o) => o.recentlyFiledAgainst);
102
66
  if (toReturn.length < topCount) {
103
- var generalTopProducts = remove_1.default(__spreadArray([], __read(products)), function (o) { return !o.recentlyFiledAgainst && o.isTopProduct; });
104
- toReturn.push.apply(toReturn, __spreadArray([], __read(generalTopProducts)));
67
+ const generalTopProducts = remove_1.default([...products], (o) => !o.recentlyFiledAgainst && o.isTopProduct);
68
+ toReturn.push(...generalTopProducts);
105
69
  }
106
70
  return toReturn.slice(0, topCount);
107
71
  }
@@ -118,13 +82,13 @@ function getUniqueSortedVersions(versions) {
118
82
  return exports.versionSort(uniq_1.default(versions));
119
83
  }
120
84
  exports.getUniqueSortedVersions = getUniqueSortedVersions;
121
- var versionSorter = function (_a, _b) {
85
+ const versionSorter = (_a, _b) => {
122
86
  //Added because of wrong order of versions
123
- var a = _a.match(/(\d+|\w+)/gm);
124
- var b = _b.match(/(\d+|\w+)/gm);
87
+ let a = _a.match(/(\d+|\w+)/gm);
88
+ let b = _b.match(/(\d+|\w+)/gm);
125
89
  for (var i = 0; i < (a.length > b.length ? a.length : b.length); i++) {
126
- var x = parseInt(a[i]) || a[i];
127
- var y = parseInt(b[i]) || b[i];
90
+ const x = parseInt(a[i]) || a[i];
91
+ const y = parseInt(b[i]) || b[i];
128
92
  if (x === undefined || x < y) {
129
93
  return 1;
130
94
  }
@@ -141,16 +105,16 @@ var versionSorter = function (_a, _b) {
141
105
  return 0;
142
106
  };
143
107
  exports.versionSorter = versionSorter;
144
- var versionSort = function (arr) {
108
+ const versionSort = (arr) => {
145
109
  return arr.sort(exports.versionSorter);
146
110
  };
147
111
  exports.versionSort = versionSort;
148
112
  function getVersion(version) {
149
113
  // splits the version into its parts because some versions can have words in front of them (e.g. Red Hat Build of Thorntail - Thorntail 1.x)
150
- var versionPartsArray = version.split(' ');
114
+ const versionPartsArray = version.split(' ');
151
115
  // find the index that has the version and split it into its parts
152
- var indexOfVersion = versionPartsArray.findIndex(function (p) { return p.includes('.'); });
153
- var splitArray = indexOfVersion > -1 ? versionPartsArray[indexOfVersion].split('.') : version.split('.');
116
+ const indexOfVersion = versionPartsArray.findIndex((p) => p.includes('.'));
117
+ const splitArray = indexOfVersion > -1 ? versionPartsArray[indexOfVersion].split('.') : version.split('.');
154
118
  // if the length of the split array is not 2, or 3 it is not a regular version
155
119
  // b/c version === major.minor.patch (patch === component in the request body)
156
120
  if (splitArray.length !== 2 && splitArray.length !== 3 && splitArray.length !== 4)
@@ -168,9 +132,7 @@ function getVersion(version) {
168
132
  exports.getVersion = getVersion;
169
133
  function isSpecialSupportOfferingEnabled(allProducts, selectedProduct) {
170
134
  var _c;
171
- var productDetails = (((_c = allProducts.data) === null || _c === void 0 ? void 0 : _c.productsResult) || []).find(function (product) {
172
- return product === selectedProduct && product.hasSpecialSupportOffering ? true : false;
173
- });
135
+ const productDetails = (((_c = allProducts.data) === null || _c === void 0 ? void 0 : _c.productsResult) || []).find((product) => product === selectedProduct && product.hasSpecialSupportOffering ? true : false);
174
136
  return productDetails ? true : false;
175
137
  }
176
138
  exports.isSpecialSupportOfferingEnabled = isSpecialSupportOfferingEnabled;
@@ -8,51 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
11
  Object.defineProperty(exports, "__esModule", { value: true });
39
12
  exports.promiseReflection = void 0;
40
13
  // Promise.allSetteled is not supported in IE11. Here we use a helper function to mock the functionality
41
- var promiseReflection = function (p) { return __awaiter(void 0, void 0, void 0, function () {
42
- var v, e_1;
43
- return __generator(this, function (_a) {
44
- switch (_a.label) {
45
- case 0:
46
- _a.trys.push([0, 2, , 3]);
47
- return [4 /*yield*/, p];
48
- case 1:
49
- v = _a.sent();
50
- return [2 /*return*/, { v: v, status: 'fulfilled' }];
51
- case 2:
52
- e_1 = _a.sent();
53
- return [2 /*return*/, { e: e_1, status: 'rejected' }];
54
- case 3: return [2 /*return*/];
55
- }
56
- });
57
- }); };
14
+ const promiseReflection = (p) => __awaiter(void 0, void 0, void 0, function* () {
15
+ try {
16
+ const v = yield p;
17
+ return { v, status: 'fulfilled' };
18
+ }
19
+ catch (e) {
20
+ return { e, status: 'rejected' };
21
+ }
22
+ });
58
23
  exports.promiseReflection = promiseReflection;