@rh-support/utils 1.0.91-beta.4 → 2.0.1-beta-1

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.
Files changed (51) hide show
  1. package/lib/cjs/apiUtils.js +10 -24
  2. package/lib/cjs/appUtils.js +18 -19
  3. package/lib/cjs/cacheUtils.js +53 -93
  4. package/lib/cjs/caseUtils.d.ts +24 -0
  5. package/lib/cjs/caseUtils.d.ts.map +1 -1
  6. package/lib/cjs/caseUtils.js +141 -15
  7. package/lib/cjs/csvUtils.js +38 -87
  8. package/lib/cjs/customElementUtils.js +1 -1
  9. package/lib/cjs/dateUtils.js +19 -25
  10. package/lib/cjs/dropdownUtils.js +23 -15
  11. package/lib/cjs/eventUtils.js +4 -5
  12. package/lib/cjs/hostNameUtils.js +7 -7
  13. package/lib/cjs/hydraConfigUtils.js +14 -37
  14. package/lib/cjs/index.d.ts +1 -0
  15. package/lib/cjs/index.d.ts.map +1 -1
  16. package/lib/cjs/index.js +1 -0
  17. package/lib/cjs/insightRuleInfoUtils.js +7 -7
  18. package/lib/cjs/lruCacheUtils.js +18 -20
  19. package/lib/cjs/outlier.js +4 -4
  20. package/lib/cjs/productsUtils.js +41 -77
  21. package/lib/cjs/promiseUtils.js +9 -44
  22. package/lib/cjs/recommendationUtils.js +7 -19
  23. package/lib/cjs/scrollUtils.js +14 -25
  24. package/lib/cjs/searchApiUtils.js +12 -20
  25. package/lib/cjs/sentry.d.ts.map +1 -1
  26. package/lib/cjs/sentry.js +6 -19
  27. package/lib/cjs/solrUtils.js +81 -108
  28. package/lib/cjs/tncUtil.d.ts +16 -0
  29. package/lib/cjs/tncUtil.d.ts.map +1 -0
  30. package/lib/cjs/tncUtil.js +39 -0
  31. package/lib/cjs/translation-helper.js +2 -2
  32. package/lib/cjs/urlUtils.js +25 -38
  33. package/lib/cjs/userUtils.js +2 -2
  34. package/lib/cjs/validatorUtils.d.ts.map +1 -1
  35. package/lib/cjs/validatorUtils.js +9 -7
  36. package/lib/esm/caseUtils.d.ts +24 -0
  37. package/lib/esm/caseUtils.d.ts.map +1 -1
  38. package/lib/esm/caseUtils.js +123 -0
  39. package/lib/esm/dropdownUtils.js +15 -5
  40. package/lib/esm/index.d.ts +1 -0
  41. package/lib/esm/index.d.ts.map +1 -1
  42. package/lib/esm/index.js +1 -0
  43. package/lib/esm/productsUtils.js +3 -3
  44. package/lib/esm/searchApiUtils.js +1 -1
  45. package/lib/esm/sentry.d.ts.map +1 -1
  46. package/lib/esm/tncUtil.d.ts +16 -0
  47. package/lib/esm/tncUtil.d.ts.map +1 -0
  48. package/lib/esm/tncUtil.js +31 -0
  49. package/lib/esm/validatorUtils.d.ts.map +1 -1
  50. package/lib/esm/validatorUtils.js +2 -0
  51. package/package.json +14 -11
@@ -4,39 +4,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.haventLoadedProductsMetadata = exports.haventLoadedMetadata = exports.getApiDeletionStatus = exports.getApiUpdationStatus = exports.getApiCreationStatus = exports.getApiResourceObject = void 0;
7
- var isEmpty_1 = __importDefault(require("lodash/isEmpty"));
8
- function getApiResourceObject(data, isFetching, isError, errorMessage, error) {
9
- if (data === void 0) { data = undefined; }
10
- if (isFetching === void 0) { isFetching = false; }
11
- if (isError === void 0) { isError = false; }
12
- if (errorMessage === void 0) { errorMessage = ''; }
13
- if (error === void 0) { error = null; }
14
- return { data: data, isFetching: isFetching, isError: isError, errorMessage: errorMessage, error: error };
7
+ const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
8
+ function getApiResourceObject(data = undefined, isFetching = false, isError = false, errorMessage = '', error = null) {
9
+ return { data, isFetching, isError, errorMessage, error };
15
10
  }
16
11
  exports.getApiResourceObject = getApiResourceObject;
17
- function getApiCreationStatus(isCreating, isError, errorMessage) {
18
- if (isCreating === void 0) { isCreating = false; }
19
- if (isError === void 0) { isError = false; }
20
- if (errorMessage === void 0) { errorMessage = ''; }
21
- return { isCreating: isCreating, isError: isError, errorMessage: errorMessage };
12
+ function getApiCreationStatus(isCreating = false, isError = false, errorMessage = '') {
13
+ return { isCreating, isError, errorMessage };
22
14
  }
23
15
  exports.getApiCreationStatus = getApiCreationStatus;
24
- function getApiUpdationStatus(isUpdating, isError, errorMessage) {
25
- if (isUpdating === void 0) { isUpdating = false; }
26
- if (isError === void 0) { isError = false; }
27
- if (errorMessage === void 0) { errorMessage = ''; }
28
- return { isUpdating: isUpdating, isError: isError, errorMessage: errorMessage };
16
+ function getApiUpdationStatus(isUpdating = false, isError = false, errorMessage = '') {
17
+ return { isUpdating, isError, errorMessage };
29
18
  }
30
19
  exports.getApiUpdationStatus = getApiUpdationStatus;
31
- function getApiDeletionStatus(isDeleting, isError, errorMessage) {
32
- if (isDeleting === void 0) { isDeleting = false; }
33
- if (isError === void 0) { isError = false; }
34
- if (errorMessage === void 0) { errorMessage = ''; }
35
- return { isDeleting: isDeleting, isError: isError, errorMessage: errorMessage };
20
+ function getApiDeletionStatus(isDeleting = false, isError = false, errorMessage = '') {
21
+ return { isDeleting, isError, errorMessage };
36
22
  }
37
23
  exports.getApiDeletionStatus = getApiDeletionStatus;
38
24
  function haventLoadedMetadata(apiResponse, isEmptyCallback) {
39
- var isDataEmpty = isEmptyCallback ? isEmptyCallback : isEmpty_1.default;
25
+ const isDataEmpty = isEmptyCallback ? isEmptyCallback : isEmpty_1.default;
40
26
  return isDataEmpty(apiResponse.data) && !apiResponse.isFetching && !apiResponse.isError;
41
27
  }
42
28
  exports.haventLoadedMetadata = haventLoadedMetadata;
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.setSecuredSupport = exports.getUserAgentForCaseMode = exports.setStrataHeaders = exports.getStrataHeaders = exports.getAppVersion = exports.getAccessHostname = void 0;
7
- var get_1 = __importDefault(require("lodash/get"));
8
- var getAccessHostname = function () {
7
+ const get_1 = __importDefault(require("lodash/get"));
8
+ const getAccessHostname = () => {
9
9
  // returns the current access.redhat.com hostname (e.g if qa then would return access.qa.redhat.com)
10
10
  if (typeof window !== 'undefined' && window) {
11
11
  if (prodHostNames.indexOf(window.location.hostname) !== -1) {
@@ -26,18 +26,18 @@ var getAccessHostname = function () {
26
26
  }
27
27
  };
28
28
  exports.getAccessHostname = getAccessHostname;
29
- var getAppVersion = function () {
29
+ const getAppVersion = () => {
30
30
  return get_1.default(window.seVersionInfo || window.supportVersionInfo || {}, 'packageVersion');
31
31
  };
32
32
  exports.getAppVersion = getAppVersion;
33
- var strataHeaders = {};
34
- var getStrataHeaders = function (appName, accountNumber) { return ({
35
- redhat_client: appName + " " + exports.getAppVersion(),
33
+ const strataHeaders = {};
34
+ const getStrataHeaders = (appName, accountNumber) => ({
35
+ redhat_client: `${appName} ${exports.getAppVersion()}`,
36
36
  account_number: accountNumber,
37
- }); };
37
+ });
38
38
  exports.getStrataHeaders = getStrataHeaders;
39
- var setStrataHeaders = function (appName, accountNumber) {
40
- var newStrataHeaders = exports.getStrataHeaders(appName, accountNumber);
39
+ const setStrataHeaders = (appName, accountNumber) => {
40
+ const newStrataHeaders = exports.getStrataHeaders(appName, accountNumber);
41
41
  strataHeaders.redhat_client = newStrataHeaders.redhat_client;
42
42
  strataHeaders.account_number = newStrataHeaders.account_number;
43
43
  };
@@ -45,23 +45,22 @@ exports.setStrataHeaders = setStrataHeaders;
45
45
  // Host names for all the app's different environments.
46
46
  // the actual redhat url needs to always be in the first position of the arrays
47
47
  // because the getAccessHostname function depends on that being the case for getting the current access hostname.
48
- var prodHostNames = [
48
+ const prodHostNames = [
49
49
  'access.redhat.com',
50
50
  'prod.foo.redhat.com',
51
51
  'fooprod.redhat.com',
52
52
  'attachment-viewer.cee.redhat.com',
53
53
  ];
54
- var qaHostNames = ['access.qa.redhat.com', 'qa.foo.redhat.com', 'fooqa.redhat.com', 'sos-viewer.corp.qa.redhat.com'];
55
- var fteHostNames = ['access.devgssfte.devlab.phx1.redhat.com', 'fte.foo.redhat.com', 'foofte.redhat.com'];
56
- var ciHostNames = ['access.devgssci.devlab.phx1.redhat.com', 'ci.foo.redhat.com', 'fooci.redhat.com'];
57
- var stageHostNames = ['access.stage.redhat.com', 'stage.foo.redhat.com', 'foostage.redhat.com'];
58
- var getUserAgentForCaseMode = function (isCaseCreate) {
59
- return isCaseCreate ? "Portal Case Management " + exports.getAppVersion() : "Solution Engine " + exports.getAppVersion();
54
+ const qaHostNames = ['access.qa.redhat.com', 'qa.foo.redhat.com', 'fooqa.redhat.com', 'sos-viewer.corp.qa.redhat.com'];
55
+ const fteHostNames = ['access.devgssfte.devlab.phx1.redhat.com', 'fte.foo.redhat.com', 'foofte.redhat.com'];
56
+ const ciHostNames = ['access.devgssci.devlab.phx1.redhat.com', 'ci.foo.redhat.com', 'fooci.redhat.com'];
57
+ const stageHostNames = ['access.stage.redhat.com', 'stage.foo.redhat.com', 'foostage.redhat.com'];
58
+ const getUserAgentForCaseMode = (isCaseCreate) => {
59
+ return isCaseCreate ? `Portal Case Management ${exports.getAppVersion()}` : `Solution Engine ${exports.getAppVersion()}`;
60
60
  };
61
61
  exports.getUserAgentForCaseMode = getUserAgentForCaseMode;
62
- var securedSupport = { pathPrefix: '', isGs4: false };
63
- var setSecuredSupport = function (isGs4) {
64
- if (isGs4 === void 0) { isGs4 = false; }
62
+ const securedSupport = { pathPrefix: '', isGs4: false };
63
+ const setSecuredSupport = (isGs4 = false) => {
65
64
  securedSupport.isGs4 = isGs4;
66
65
  securedSupport.pathPrefix = isGs4 ? '/secure-support' : '';
67
66
  };
@@ -8,62 +8,34 @@ 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
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
13
  };
41
14
  Object.defineProperty(exports, "__esModule", { value: true });
42
15
  exports.CacheUtilsService = exports.isFirefox = void 0;
43
- var filter_1 = __importDefault(require("lodash/filter"));
44
- var forEach_1 = __importDefault(require("lodash/forEach"));
45
- var includes_1 = __importDefault(require("lodash/includes"));
16
+ const filter_1 = __importDefault(require("lodash/filter"));
17
+ const forEach_1 = __importDefault(require("lodash/forEach"));
18
+ const includes_1 = __importDefault(require("lodash/includes"));
46
19
  function isFirefox() {
47
20
  return 'MozAppearance' in document.documentElement.style;
48
21
  }
49
22
  exports.isFirefox = isFirefox;
50
- var CacheUtilsService = /** @class */ (function () {
51
- function CacheUtilsService(localForage, options) {
52
- var _this = this;
23
+ class CacheUtilsService {
24
+ constructor(localForage, options) {
53
25
  this.indexDBAvailable = true;
54
26
  // For FF only attempt to determine if indexDB is available, this mainly affects
55
27
  // FF private mode
56
28
  localForage.config(options);
57
29
  try {
58
30
  if (isFirefox() && window.indexedDB) {
59
- var db = indexedDB.open('test');
60
- db.onerror = function () {
61
- _this.indexDBAvailable = false;
31
+ const db = indexedDB.open('test');
32
+ db.onerror = () => {
33
+ this.indexDBAvailable = false;
62
34
  };
63
35
  }
64
36
  }
65
37
  catch (e) {
66
- console.warn("IndexDB unavailable.");
38
+ console.warn(`IndexDB unavailable.`);
67
39
  this.indexDBAvailable = false;
68
40
  }
69
41
  // For FF, if indexDB isn't available and localStorage is, prefer localStorage
@@ -76,59 +48,59 @@ var CacheUtilsService = /** @class */ (function () {
76
48
  }
77
49
  this.localForage = localForage;
78
50
  }
79
- CacheUtilsService.prototype.makeKey = function (namespace, key) {
80
- return namespace + "-" + key;
81
- };
82
- CacheUtilsService.prototype.set = function (namespace, key, obj, options) {
51
+ makeKey(namespace, key) {
52
+ return `${namespace}-${key}`;
53
+ }
54
+ set(namespace, key, obj, options) {
83
55
  if (!obj.lastModifiedDate) {
84
56
  obj.lastModifiedDate = new Date().toISOString();
85
57
  }
86
58
  return this.setWithFullKey(this.makeKey(namespace, key), obj);
87
- };
88
- CacheUtilsService.prototype.setWithFullKey = function (key, obj) {
59
+ }
60
+ setWithFullKey(key, obj) {
89
61
  try {
90
62
  return this.localForage.setItem(key, obj);
91
63
  }
92
64
  catch (e) {
93
- console.warn("Unable to set " + key + " due to: " + e.message);
65
+ console.warn(`Unable to set ${key} due to: ${e.message}`);
94
66
  }
95
- };
96
- CacheUtilsService.prototype.get = function (namespace, key) {
67
+ }
68
+ get(namespace, key) {
97
69
  return this.getWithFullKey(this.makeKey(namespace, key));
98
- };
99
- CacheUtilsService.prototype.getWithFullKey = function (key) {
70
+ }
71
+ getWithFullKey(key) {
100
72
  try {
101
73
  return this.localForage.getItem(key);
102
74
  }
103
75
  catch (e) {
104
- console.warn("Unable to get " + key + " due to: " + e.message);
76
+ console.warn(`Unable to get ${key} due to: ${e.message}`);
105
77
  }
106
- };
107
- CacheUtilsService.prototype.delete = function (namespace, key) {
78
+ }
79
+ delete(namespace, key) {
108
80
  return this.deleteWithFullKey(this.makeKey(namespace, key));
109
- };
110
- CacheUtilsService.prototype.deleteWithFullKey = function (key) {
81
+ }
82
+ deleteWithFullKey(key) {
111
83
  try {
112
84
  return this.localForage.removeItem(key);
113
85
  }
114
86
  catch (e) {
115
- console.warn("Unable to delete " + key + " due to: " + e.message);
87
+ console.warn(`Unable to delete ${key} due to: ${e.message}`);
116
88
  }
117
- };
118
- CacheUtilsService.prototype.clear = function () {
89
+ }
90
+ clear() {
119
91
  try {
120
92
  return this.localForage.clear();
121
93
  }
122
94
  catch (e) {
123
- console.warn("Unable to clear all cache: " + e.message);
95
+ console.warn(`Unable to clear all cache: ${e.message}`);
124
96
  }
125
- };
126
- CacheUtilsService.prototype.keys = function (namespace) {
97
+ }
98
+ keys(namespace) {
127
99
  try {
128
100
  if (namespace) {
129
- return this.localForage.keys().then(function (keys) {
101
+ return this.localForage.keys().then((keys) => {
130
102
  if (keys) {
131
- return filter_1.default(keys, function (key) { return includes_1.default(key, namespace); });
103
+ return filter_1.default(keys, (key) => includes_1.default(key, namespace));
132
104
  }
133
105
  else {
134
106
  return [];
@@ -140,38 +112,26 @@ var CacheUtilsService = /** @class */ (function () {
140
112
  }
141
113
  }
142
114
  catch (e) {
143
- console.warn("Unable to get keys from namespace " + namespace + " due to: " + e.message);
115
+ console.warn(`Unable to get keys from namespace ${namespace} due to: ${e.message}`);
144
116
  }
145
- };
146
- CacheUtilsService.prototype.expireCache = function () {
147
- return __awaiter(this, void 0, void 0, function () {
148
- var keys, e_1;
149
- var _this = this;
150
- return __generator(this, function (_a) {
151
- switch (_a.label) {
152
- case 0:
153
- _a.trys.push([0, 2, , 3]);
154
- return [4 /*yield*/, this.keys()];
155
- case 1:
156
- keys = _a.sent();
157
- forEach_1.default(keys, function (k) {
158
- _this.localForage.getItem(k).then(function (c) {
159
- if (c.expiresAt && +new Date() > c.expiresAt) {
160
- _this.localForage.removeItem(k);
161
- }
162
- });
163
- });
164
- return [3 /*break*/, 3];
165
- case 2:
166
- e_1 = _a.sent();
167
- console.warn("Could not expire indexdb cache: " + e_1.message);
168
- return [3 /*break*/, 3];
169
- case 3: return [2 /*return*/];
170
- }
171
- });
117
+ }
118
+ expireCache() {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ try {
121
+ const keys = yield this.keys();
122
+ forEach_1.default(keys, (k) => {
123
+ this.localForage.getItem(k).then((c) => {
124
+ if (c.expiresAt && +new Date() > c.expiresAt) {
125
+ this.localForage.removeItem(k);
126
+ }
127
+ });
128
+ });
129
+ }
130
+ catch (e) {
131
+ console.warn(`Could not expire indexdb cache: ${e.message}`);
132
+ }
172
133
  });
173
- };
174
- CacheUtilsService.localStorageAvailable = true;
175
- return CacheUtilsService;
176
- }());
134
+ }
135
+ }
177
136
  exports.CacheUtilsService = CacheUtilsService;
137
+ CacheUtilsService.localStorageAvailable = true;
@@ -1,4 +1,24 @@
1
1
  import { IPortalJwtToken } from '@rh-support/types/shared';
2
+ export declare enum PreviousCaseTypes {
3
+ DEFECT_BUG = "Defect / Bug",
4
+ CERTIFICATION = "Certification",
5
+ CONFIGURATION_ISSUE = "Configuration Issue",
6
+ ACCOUNT_CUSTOMERSERVICE_REQUEST = "Account / Customer Service Request",
7
+ USAGE_DOCUMENTATION_HELP = "Usage / Documentation Help",
8
+ FEATURE_ENHANCEMENT = "Feature / Enhancement Request",
9
+ RCA_ONLY = "RCA Only",
10
+ OTHER = "Other"
11
+ }
12
+ export declare enum NewCaseTypes {
13
+ BUG_DEFECT = "Bug or defect",
14
+ CERTIFICATION = "Certification",
15
+ CONFIGURATION = "Configuration",
16
+ CUSTOMER_SERVICE = "Customer service",
17
+ USAGE_DOCS_HELP = "Usage & Docs help",
18
+ IDEA = "Idea",
19
+ ROOT_CAUSE_ANALYSIS = "Root cause analysis",
20
+ OTHER = "Other"
21
+ }
2
22
  export declare function canManageCase(loggedInUserJwtToken: Partial<IPortalJwtToken>): boolean;
3
23
  export declare function humanizeSize(fileSize: number): string;
4
24
  export declare function showFtsOnCreateCasePage(slaProcessId: string, severity: string): boolean;
@@ -13,4 +33,8 @@ export declare function isValidCaseNumber(caseNumber: string | undefined): boole
13
33
  export declare function areAllValidCaseNumbers(items: string[]): boolean;
14
34
  export declare function linkifyLinks(text?: string): string;
15
35
  export declare function severitySort(sevA: any, sevB: any): 0 | 1 | -1;
36
+ export declare function toNewCaseTypeMapper(allCaseTypes?: string[]): string[];
37
+ export declare function toNewCaseTypeSwitcher(caseType: any): any;
38
+ export declare function toOldCaseTypeMapper(allCaseTypes?: string[]): string[];
39
+ export declare function toOldCaseTypeSwitcher(caseType: any): any;
16
40
  //# sourceMappingURL=caseUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"caseUtils.d.ts","sourceRoot":"","sources":["../../src/caseUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAK3D,wBAAgB,aAAa,CAAC,oBAAoB,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,OAAO,CAMrF;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CASrD;AAED,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEvF;AAED,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzF;AACD,wBAAgB,uBAAuB,CAAC,YAAY,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mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.severitySort = exports.linkifyLinks = exports.areAllValidCaseNumbers = exports.isValidCaseNumber = exports.isOpenShiftOnlineProduct = exports.isSev2 = exports.isSev1 = exports.isPremiumEntitlement = exports.autoEnableFtsOnCaseViewEditPage = exports.isFtsEditableOnEditPage = exports.showFtsOnCaseViewEditPage = exports.showFtsOnCreateCasePage = exports.humanizeSize = exports.canManageCase = void 0;
7
- var find_1 = __importDefault(require("lodash/find"));
8
- var includes_1 = __importDefault(require("lodash/includes"));
9
- var isEmpty_1 = __importDefault(require("lodash/isEmpty"));
6
+ exports.toOldCaseTypeSwitcher = exports.toOldCaseTypeMapper = exports.toNewCaseTypeSwitcher = exports.toNewCaseTypeMapper = exports.severitySort = exports.linkifyLinks = exports.areAllValidCaseNumbers = exports.isValidCaseNumber = exports.isOpenShiftOnlineProduct = exports.isSev2 = exports.isSev1 = exports.isPremiumEntitlement = exports.autoEnableFtsOnCaseViewEditPage = exports.isFtsEditableOnEditPage = exports.showFtsOnCaseViewEditPage = exports.showFtsOnCreateCasePage = exports.humanizeSize = exports.canManageCase = exports.NewCaseTypes = exports.PreviousCaseTypes = void 0;
7
+ const find_1 = __importDefault(require("lodash/find"));
8
+ const includes_1 = __importDefault(require("lodash/includes"));
9
+ const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
10
+ // Old Case Types
11
+ var PreviousCaseTypes;
12
+ (function (PreviousCaseTypes) {
13
+ PreviousCaseTypes["DEFECT_BUG"] = "Defect / Bug";
14
+ PreviousCaseTypes["CERTIFICATION"] = "Certification";
15
+ PreviousCaseTypes["CONFIGURATION_ISSUE"] = "Configuration Issue";
16
+ PreviousCaseTypes["ACCOUNT_CUSTOMERSERVICE_REQUEST"] = "Account / Customer Service Request";
17
+ PreviousCaseTypes["USAGE_DOCUMENTATION_HELP"] = "Usage / Documentation Help";
18
+ PreviousCaseTypes["FEATURE_ENHANCEMENT"] = "Feature / Enhancement Request";
19
+ PreviousCaseTypes["RCA_ONLY"] = "RCA Only";
20
+ PreviousCaseTypes["OTHER"] = "Other";
21
+ })(PreviousCaseTypes = exports.PreviousCaseTypes || (exports.PreviousCaseTypes = {}));
22
+ // New Case Types
23
+ var NewCaseTypes;
24
+ (function (NewCaseTypes) {
25
+ NewCaseTypes["BUG_DEFECT"] = "Bug or defect";
26
+ NewCaseTypes["CERTIFICATION"] = "Certification";
27
+ NewCaseTypes["CONFIGURATION"] = "Configuration";
28
+ NewCaseTypes["CUSTOMER_SERVICE"] = "Customer service";
29
+ NewCaseTypes["USAGE_DOCS_HELP"] = "Usage & Docs help";
30
+ NewCaseTypes["IDEA"] = "Idea";
31
+ NewCaseTypes["ROOT_CAUSE_ANALYSIS"] = "Root cause analysis";
32
+ NewCaseTypes["OTHER"] = "Other";
33
+ })(NewCaseTypes = exports.NewCaseTypes || (exports.NewCaseTypes = {}));
10
34
  function canManageCase(loggedInUserJwtToken) {
11
35
  if (!loggedInUserJwtToken || !loggedInUserJwtToken.realm_access) {
12
36
  return false;
@@ -15,14 +39,14 @@ function canManageCase(loggedInUserJwtToken) {
15
39
  }
16
40
  exports.canManageCase = canManageCase;
17
41
  function humanizeSize(fileSize) {
18
- var i = -1;
19
- var size = fileSize;
20
- var byteUnits = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
42
+ let i = -1;
43
+ let size = fileSize;
44
+ const byteUnits = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
21
45
  do {
22
46
  size = size / 1024;
23
47
  i++;
24
48
  } while (size >= 1024 && byteUnits[i + 1]);
25
- return Math.max(size, 0.1).toFixed(1) + " " + byteUnits[i];
49
+ return `${Math.max(size, 0.1).toFixed(1)} ${byteUnits[i]}`;
26
50
  }
27
51
  exports.humanizeSize = humanizeSize;
28
52
  function showFtsOnCreateCasePage(slaProcessId, severity) {
@@ -62,7 +86,7 @@ function isOpenShiftOnlineProduct(product) {
62
86
  exports.isOpenShiftOnlineProduct = isOpenShiftOnlineProduct;
63
87
  function isValidCaseNumber(caseNumber) {
64
88
  // eslint-disable-next-line no-useless-escape
65
- var validCaseNumberFormat = /^\d{8}$/;
89
+ const validCaseNumberFormat = /^\d{8}$/;
66
90
  if (caseNumber && caseNumber.trim().match(validCaseNumberFormat)) {
67
91
  return true;
68
92
  }
@@ -72,19 +96,19 @@ function isValidCaseNumber(caseNumber) {
72
96
  }
73
97
  exports.isValidCaseNumber = isValidCaseNumber;
74
98
  function areAllValidCaseNumbers(items) {
75
- return isEmpty_1.default(find_1.default(items, function (item) { return !isValidCaseNumber(item.trim()); }));
99
+ return isEmpty_1.default(find_1.default(items, (item) => !isValidCaseNumber(item.trim())));
76
100
  }
77
101
  exports.areAllValidCaseNumbers = areAllValidCaseNumbers;
78
- function linkifyLinks(text) {
79
- if (text === void 0) { text = ''; }
80
- var replacePattern1 = /(\b(https:)\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/gim;
102
+ function linkifyLinks(text = '') {
103
+ const replacePattern1 = /(\b(https:)\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/gim;
81
104
  function getUrl(match) {
82
- var openInNewTab = !match.includes('showModal=');
83
- return "<a href=\"" + match + "\"" + (openInNewTab ? ' target="_blank" rel="noopener noreferrer"' : '') + ">" + match + "</a>";
105
+ const openInNewTab = !match.includes('showModal=');
106
+ return `<a href="${match}"${openInNewTab ? ' target="_blank" rel="noopener noreferrer"' : ''}>${match}</a>`;
84
107
  }
85
108
  return text ? text.replace(replacePattern1, getUrl) : '';
86
109
  }
87
110
  exports.linkifyLinks = linkifyLinks;
111
+ // To sort severity values
88
112
  function severitySort(sevA, sevB) {
89
113
  if (sevA.split(' ')[0] > sevB.split(' ')[0]) {
90
114
  return -1;
@@ -97,3 +121,105 @@ function severitySort(sevA, sevB) {
97
121
  }
98
122
  }
99
123
  exports.severitySort = severitySort;
124
+ // To convert array of old case types to new support types
125
+ function toNewCaseTypeMapper(allCaseTypes) {
126
+ let newCaseTypeArray = allCaseTypes === null || allCaseTypes === void 0 ? void 0 : allCaseTypes.map((value) => {
127
+ switch (value) {
128
+ case PreviousCaseTypes.DEFECT_BUG:
129
+ return NewCaseTypes.BUG_DEFECT;
130
+ case PreviousCaseTypes.CERTIFICATION:
131
+ return NewCaseTypes.CERTIFICATION;
132
+ case PreviousCaseTypes.CONFIGURATION_ISSUE:
133
+ return NewCaseTypes.CONFIGURATION;
134
+ case PreviousCaseTypes.ACCOUNT_CUSTOMERSERVICE_REQUEST:
135
+ return NewCaseTypes.CUSTOMER_SERVICE;
136
+ case PreviousCaseTypes.USAGE_DOCUMENTATION_HELP:
137
+ return NewCaseTypes.USAGE_DOCS_HELP;
138
+ case PreviousCaseTypes.FEATURE_ENHANCEMENT:
139
+ return NewCaseTypes.IDEA;
140
+ case PreviousCaseTypes.RCA_ONLY:
141
+ return NewCaseTypes.ROOT_CAUSE_ANALYSIS;
142
+ case PreviousCaseTypes.OTHER:
143
+ return NewCaseTypes.OTHER;
144
+ default:
145
+ return value;
146
+ }
147
+ });
148
+ return newCaseTypeArray;
149
+ }
150
+ exports.toNewCaseTypeMapper = toNewCaseTypeMapper;
151
+ // To convert old case type to new support type
152
+ function toNewCaseTypeSwitcher(caseType) {
153
+ switch (caseType) {
154
+ case PreviousCaseTypes.DEFECT_BUG:
155
+ return NewCaseTypes.BUG_DEFECT;
156
+ case PreviousCaseTypes.CERTIFICATION:
157
+ return NewCaseTypes.CERTIFICATION;
158
+ case PreviousCaseTypes.CONFIGURATION_ISSUE:
159
+ return NewCaseTypes.CONFIGURATION;
160
+ case PreviousCaseTypes.ACCOUNT_CUSTOMERSERVICE_REQUEST:
161
+ return NewCaseTypes.CUSTOMER_SERVICE;
162
+ case PreviousCaseTypes.USAGE_DOCUMENTATION_HELP:
163
+ return NewCaseTypes.USAGE_DOCS_HELP;
164
+ case PreviousCaseTypes.FEATURE_ENHANCEMENT:
165
+ return NewCaseTypes.IDEA;
166
+ case PreviousCaseTypes.RCA_ONLY:
167
+ return NewCaseTypes.ROOT_CAUSE_ANALYSIS;
168
+ case PreviousCaseTypes.OTHER:
169
+ return NewCaseTypes.OTHER;
170
+ default:
171
+ return caseType;
172
+ }
173
+ }
174
+ exports.toNewCaseTypeSwitcher = toNewCaseTypeSwitcher;
175
+ // To convert array of new support types to old case types
176
+ function toOldCaseTypeMapper(allCaseTypes) {
177
+ let oldCaseTypeArray = allCaseTypes === null || allCaseTypes === void 0 ? void 0 : allCaseTypes.map((value) => {
178
+ switch (value) {
179
+ case NewCaseTypes.BUG_DEFECT:
180
+ return PreviousCaseTypes.DEFECT_BUG;
181
+ case NewCaseTypes.CERTIFICATION:
182
+ return PreviousCaseTypes.CERTIFICATION;
183
+ case NewCaseTypes.CONFIGURATION:
184
+ return PreviousCaseTypes.CONFIGURATION_ISSUE;
185
+ case NewCaseTypes.CUSTOMER_SERVICE:
186
+ return PreviousCaseTypes.ACCOUNT_CUSTOMERSERVICE_REQUEST;
187
+ case NewCaseTypes.USAGE_DOCS_HELP:
188
+ return PreviousCaseTypes.USAGE_DOCUMENTATION_HELP;
189
+ case NewCaseTypes.IDEA:
190
+ return PreviousCaseTypes.FEATURE_ENHANCEMENT;
191
+ case NewCaseTypes.ROOT_CAUSE_ANALYSIS:
192
+ return PreviousCaseTypes.RCA_ONLY;
193
+ case NewCaseTypes.OTHER:
194
+ return PreviousCaseTypes.OTHER;
195
+ default:
196
+ return value;
197
+ }
198
+ });
199
+ return oldCaseTypeArray;
200
+ }
201
+ exports.toOldCaseTypeMapper = toOldCaseTypeMapper;
202
+ // To convert new support type to old case type
203
+ function toOldCaseTypeSwitcher(caseType) {
204
+ switch (caseType) {
205
+ case NewCaseTypes.BUG_DEFECT:
206
+ return PreviousCaseTypes.DEFECT_BUG;
207
+ case NewCaseTypes.CERTIFICATION:
208
+ return PreviousCaseTypes.CERTIFICATION;
209
+ case NewCaseTypes.CONFIGURATION:
210
+ return PreviousCaseTypes.CONFIGURATION_ISSUE;
211
+ case NewCaseTypes.CUSTOMER_SERVICE:
212
+ return PreviousCaseTypes.ACCOUNT_CUSTOMERSERVICE_REQUEST;
213
+ case NewCaseTypes.USAGE_DOCS_HELP:
214
+ return PreviousCaseTypes.USAGE_DOCUMENTATION_HELP;
215
+ case NewCaseTypes.IDEA:
216
+ return PreviousCaseTypes.FEATURE_ENHANCEMENT;
217
+ case NewCaseTypes.ROOT_CAUSE_ANALYSIS:
218
+ return PreviousCaseTypes.RCA_ONLY;
219
+ case NewCaseTypes.OTHER:
220
+ return PreviousCaseTypes.OTHER;
221
+ default:
222
+ return caseType;
223
+ }
224
+ }
225
+ exports.toOldCaseTypeSwitcher = toOldCaseTypeSwitcher;