@rh-support/utils 2.0.0 → 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 (48) 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 +1 -1
  5. package/lib/cjs/caseUtils.d.ts.map +1 -1
  6. package/lib/cjs/caseUtils.js +16 -17
  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 +8 -10
  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.js +6 -19
  26. package/lib/cjs/solrUtils.js +81 -108
  27. package/lib/cjs/tncUtil.d.ts +16 -0
  28. package/lib/cjs/tncUtil.d.ts.map +1 -0
  29. package/lib/cjs/tncUtil.js +39 -0
  30. package/lib/cjs/translation-helper.js +2 -2
  31. package/lib/cjs/urlUtils.js +25 -38
  32. package/lib/cjs/userUtils.js +2 -2
  33. package/lib/cjs/validatorUtils.d.ts.map +1 -1
  34. package/lib/cjs/validatorUtils.js +9 -7
  35. package/lib/esm/caseUtils.d.ts +1 -1
  36. package/lib/esm/caseUtils.d.ts.map +1 -1
  37. package/lib/esm/caseUtils.js +1 -1
  38. package/lib/esm/index.d.ts +1 -0
  39. package/lib/esm/index.d.ts.map +1 -1
  40. package/lib/esm/index.js +1 -0
  41. package/lib/esm/productsUtils.js +3 -3
  42. package/lib/esm/searchApiUtils.js +1 -1
  43. package/lib/esm/tncUtil.d.ts +16 -0
  44. package/lib/esm/tncUtil.d.ts.map +1 -0
  45. package/lib/esm/tncUtil.js +31 -0
  46. package/lib/esm/validatorUtils.d.ts.map +1 -1
  47. package/lib/esm/validatorUtils.js +2 -0
  48. package/package.json +12 -9
@@ -0,0 +1,16 @@
1
+ export declare const TncConstants: {
2
+ HOSTS: {
3
+ DEV: string;
4
+ QA: string;
5
+ Stage: string;
6
+ PROD: string;
7
+ };
8
+ PARTNER_SHARE_SITE_CODE: string;
9
+ PARTNER_SHARE_EVENT_CODE: string;
10
+ REMOTER_RIDER_EVENT_CODE: string;
11
+ REMOTE_RIDER_SITE_CODE: string;
12
+ PARTNER_SHARE_LINK_ACCOUNT_SITE_CODE: string;
13
+ };
14
+ export declare function getTnCHost(): string;
15
+ export declare function baseTnCUrl(): string;
16
+ //# sourceMappingURL=tncUtil.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tncUtil.d.ts","sourceRoot":"","sources":["../../src/tncUtil.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;;;;;;;;;;;CAYxB,CAAC;AAEF,wBAAgB,UAAU,WAYzB;AAED,wBAAgB,UAAU,WAGzB"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.baseTnCUrl = exports.getTnCHost = exports.TncConstants = void 0;
7
+ const hydrajs_1 = __importDefault(require("@cee-eng/hydrajs"));
8
+ exports.TncConstants = {
9
+ HOSTS: {
10
+ DEV: 'ams-dev1.devlab.redhat.com',
11
+ QA: 'www.qa.redhat.com',
12
+ Stage: 'www.stage.redhat.com',
13
+ PROD: 'www.redhat.com',
14
+ },
15
+ PARTNER_SHARE_SITE_CODE: 'customerPortal',
16
+ PARTNER_SHARE_EVENT_CODE: 'partnerAuthorization',
17
+ REMOTER_RIDER_EVENT_CODE: 'remoteAccessRider',
18
+ REMOTE_RIDER_SITE_CODE: 'remoteAccessRider',
19
+ PARTNER_SHARE_LINK_ACCOUNT_SITE_CODE: 'customerPortal_linkAccount',
20
+ };
21
+ function getTnCHost() {
22
+ const env = hydrajs_1.default.Env.getEnvName();
23
+ switch (env) {
24
+ case 'QA':
25
+ return exports.TncConstants.HOSTS.QA;
26
+ case 'DEV':
27
+ return exports.TncConstants.HOSTS.DEV;
28
+ case 'Stage':
29
+ return exports.TncConstants.HOSTS.Stage;
30
+ default:
31
+ return exports.TncConstants.HOSTS.PROD;
32
+ }
33
+ }
34
+ exports.getTnCHost = getTnCHost;
35
+ function baseTnCUrl() {
36
+ const wejava_host = getTnCHost();
37
+ return `https://${wejava_host}/wapps/tnc/ackrequired`;
38
+ }
39
+ exports.baseTnCUrl = baseTnCUrl;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getText = void 0;
7
- var i18next_1 = __importDefault(require("i18next"));
7
+ const i18next_1 = __importDefault(require("i18next"));
8
8
  /**
9
9
  * Translate the string using i18n.t
10
10
  * @param {string} key the string to be translated
@@ -14,7 +14,7 @@ var i18next_1 = __importDefault(require("i18next"));
14
14
  * use getText only in the case when neither <Trans /> nor useTranslation() is available
15
15
  */
16
16
  function getText(key, args) {
17
- var translatedString = i18next_1.default.t(key, args);
17
+ const translatedString = i18next_1.default.t(key, args);
18
18
  if (!translatedString) {
19
19
  return key;
20
20
  }
@@ -1,32 +1,21 @@
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
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
4
  };
16
5
  Object.defineProperty(exports, "__esModule", { value: true });
17
6
  exports.isValidUrl = exports.getUpdatedQueryString = exports.getDrupalResIdIfTypeFromUrl = exports.getDrupalResIdFromUrl = exports.getResTypeFromUrl = exports.getRedhatDotComHost = exports.REDHAT_DOT_COM_HOSTNAMES = exports.getStringifiedParams = exports.getUrlParsedParams = void 0;
18
- var pickBy_1 = __importDefault(require("lodash/pickBy"));
19
- var qs_1 = __importDefault(require("qs"));
7
+ const pickBy_1 = __importDefault(require("lodash/pickBy"));
8
+ const qs_1 = __importDefault(require("qs"));
20
9
  // parses url query params to an obj
21
10
  function getUrlParsedParams(urlParams, options) {
22
- var defaultOptions = { ignoreQueryPrefix: true };
23
- return qs_1.default.parse(urlParams, __assign(__assign({}, defaultOptions), options));
11
+ const defaultOptions = { ignoreQueryPrefix: true };
12
+ return qs_1.default.parse(urlParams, Object.assign(Object.assign({}, defaultOptions), options));
24
13
  }
25
14
  exports.getUrlParsedParams = getUrlParsedParams;
26
15
  // converts an obj to url query params
27
16
  function getStringifiedParams(object, options) {
28
- var defaultOptions = { arrayFormat: 'repeat', encode: false };
29
- return qs_1.default.stringify(object, __assign(__assign({}, defaultOptions), options));
17
+ const defaultOptions = { arrayFormat: 'repeat', encode: false };
18
+ return qs_1.default.stringify(object, Object.assign(Object.assign({}, defaultOptions), options));
30
19
  }
31
20
  exports.getStringifiedParams = getStringifiedParams;
32
21
  exports.REDHAT_DOT_COM_HOSTNAMES = {
@@ -35,7 +24,7 @@ exports.REDHAT_DOT_COM_HOSTNAMES = {
35
24
  DEV: 'https://www.dev.redhat.com',
36
25
  PROD: 'https://www.redhat.com',
37
26
  };
38
- var getRedhatDotComHost = function (env) {
27
+ const getRedhatDotComHost = (env) => {
39
28
  switch (env) {
40
29
  case 'QA':
41
30
  return exports.REDHAT_DOT_COM_HOSTNAMES.QA;
@@ -48,42 +37,40 @@ var getRedhatDotComHost = function (env) {
48
37
  }
49
38
  };
50
39
  exports.getRedhatDotComHost = getRedhatDotComHost;
51
- var drupalUrlRegexp = /^(https:\/\/access?.?\w+.redhat.com)?\/(\w+)\/(\d+)\S*$/;
52
- var openshiftDocUrlRegexp = /^https:\/\/docs.openshift.com\//;
53
- var getResTypeFromUrl = function (url) {
54
- var drupalUrl = drupalUrlRegexp.exec(url);
55
- var isOpenshiftDocUrl = openshiftDocUrlRegexp.test(url);
40
+ const drupalUrlRegexp = /^(https:\/\/access?.?\w+.redhat.com)?\/(\w+)\/(\d+)\S*$/;
41
+ const openshiftDocUrlRegexp = /^https:\/\/docs.openshift.com\//;
42
+ const getResTypeFromUrl = (url) => {
43
+ const drupalUrl = drupalUrlRegexp.exec(url);
44
+ const isOpenshiftDocUrl = openshiftDocUrlRegexp.test(url);
56
45
  return (drupalUrl === null || drupalUrl === void 0 ? void 0 : drupalUrl[2]) ? drupalUrl === null || drupalUrl === void 0 ? void 0 : drupalUrl[2] : isOpenshiftDocUrl ? 'documentation' : 'unknown';
57
46
  };
58
47
  exports.getResTypeFromUrl = getResTypeFromUrl;
59
- var getDrupalResIdFromUrl = function (url) {
60
- var m = drupalUrlRegexp.exec(url);
48
+ const getDrupalResIdFromUrl = (url) => {
49
+ let m = drupalUrlRegexp.exec(url);
61
50
  return m === null || m === void 0 ? void 0 : m[2];
62
51
  };
63
52
  exports.getDrupalResIdFromUrl = getDrupalResIdFromUrl;
64
- var getDrupalResIdIfTypeFromUrl = function (url, resourceTypes) {
53
+ const getDrupalResIdIfTypeFromUrl = (url, resourceTypes = ['solutions', 'articles']) => {
65
54
  var _a;
66
- if (resourceTypes === void 0) { resourceTypes = ['solutions', 'articles']; }
67
- var m = drupalUrlRegexp.exec(url);
68
- var resourceType = (_a = m === null || m === void 0 ? void 0 : m[2]) !== null && _a !== void 0 ? _a : '';
69
- var resourceId = m === null || m === void 0 ? void 0 : m[3];
55
+ let m = drupalUrlRegexp.exec(url);
56
+ const resourceType = (_a = m === null || m === void 0 ? void 0 : m[2]) !== null && _a !== void 0 ? _a : '';
57
+ const resourceId = m === null || m === void 0 ? void 0 : m[3];
70
58
  return resourceTypes.includes(resourceType) && !isNaN(parseInt(resourceId)) ? parseInt(resourceId) : undefined;
71
59
  };
72
60
  exports.getDrupalResIdIfTypeFromUrl = getDrupalResIdIfTypeFromUrl;
73
- var isFieldValueEmpty = function (value) {
61
+ const isFieldValueEmpty = function (value) {
74
62
  return value === '' || value === undefined || value === null;
75
63
  };
76
- var getUpdatedQueryString = function (currentQuery, newQuery, _a) {
77
- var _b = _a.resetSearchParams, resetSearchParams = _b === void 0 ? false : _b, _c = _a.removeEmptyParams, removeEmptyParams = _c === void 0 ? false : _c;
78
- var currentQueryObj = typeof currentQuery === 'string' ? getUrlParsedParams(currentQuery) : currentQuery;
79
- var mergedQueryObject = __assign(__assign({}, currentQueryObj), newQuery);
80
- var updatedQuery = removeEmptyParams
81
- ? pickBy_1.default(mergedQueryObject, function (item) { return !isFieldValueEmpty(item); })
64
+ const getUpdatedQueryString = (currentQuery, newQuery, { resetSearchParams = false, removeEmptyParams = false }) => {
65
+ const currentQueryObj = typeof currentQuery === 'string' ? getUrlParsedParams(currentQuery) : currentQuery;
66
+ const mergedQueryObject = Object.assign(Object.assign({}, currentQueryObj), newQuery);
67
+ const updatedQuery = removeEmptyParams
68
+ ? pickBy_1.default(mergedQueryObject, (item) => !isFieldValueEmpty(item))
82
69
  : mergedQueryObject;
83
70
  return !resetSearchParams ? getStringifiedParams(updatedQuery) : getStringifiedParams(newQuery);
84
71
  };
85
72
  exports.getUpdatedQueryString = getUpdatedQueryString;
86
- var isValidUrl = function (url) {
73
+ const isValidUrl = (url) => {
87
74
  return /^(http(s)?:\/\/)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/.test(url);
88
75
  };
89
76
  exports.isValidUrl = isValidUrl;
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.sortHydraContacts = void 0;
7
- var sortBy_1 = __importDefault(require("lodash/sortBy"));
8
- var sortHydraContacts = function (hydraContacts) {
7
+ const sortBy_1 = __importDefault(require("lodash/sortBy"));
8
+ const sortHydraContacts = (hydraContacts) => {
9
9
  return sortBy_1.default(hydraContacts, 'firstName', 'lastName');
10
10
  };
11
11
  exports.sortHydraContacts = sortHydraContacts;
@@ -1 +1 @@
1
- {"version":3,"file":"validatorUtils.d.ts","sourceRoot":"","sources":["../../src/validatorUtils.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY,EAAE,MACgY,CAAC;AACrZ,QAAA,MAAM,UAAU,QAGf,CAAC;AAGF,iBAAS,YAAY,CAAC,MAAM,KAAA,WAM3B;AAED,iBAAS,cAAc,CAAC,MAAM,KAAA,WAM7B;AAED,iBAAS,cAAc,CAAC,MAAM,KAAA,WAM7B;AAED,iBAAS,WAAW,CAAC,MAAM,KAAA,WAO1B;AAED,iBAAS,QAAQ,CAAC,GAAG,EAAE,MAAM,WAE5B;AAED,iBAAS,gBAAgB,CAAC,OAAO,EAAE,MAAM,WAiBxC;AAED,iBAAS,WAAW,CAAC,QAAQ,KAAA,WAE5B;AAED,OAAO,EACH,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,UAAU,EACV,WAAW,EACX,WAAW,GACd,CAAC"}
1
+ {"version":3,"file":"validatorUtils.d.ts","sourceRoot":"","sources":["../../src/validatorUtils.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY,EAAE,MACgY,CAAC;AACrZ,QAAA,MAAM,UAAU,QAGf,CAAC;AAIF,iBAAS,YAAY,CAAC,MAAM,KAAA,WAM3B;AAGD,iBAAS,cAAc,CAAC,MAAM,KAAA,WAM7B;AAED,iBAAS,cAAc,CAAC,MAAM,KAAA,WAM7B;AAED,iBAAS,WAAW,CAAC,MAAM,KAAA,WAO1B;AAED,iBAAS,QAAQ,CAAC,GAAG,EAAE,MAAM,WAE5B;AAED,iBAAS,gBAAgB,CAAC,OAAO,EAAE,MAAM,WAiBxC;AAED,iBAAS,WAAW,CAAC,QAAQ,KAAA,WAE5B;AAED,OAAO,EACH,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,UAAU,EACV,WAAW,EACX,WAAW,GACd,CAAC"}
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isImageFile = exports.isValidGuid = exports.mailformat = exports.emojiPattern = exports.isEmojiPattern = exports.isValidRHEmail = exports.isRegularVersion = exports.isNumber = exports.isEmailValid = void 0;
4
- var emojiPattern = /[\u{1f300}-\u{1f5ff}\u{1f900}-\u{1f9ff}\u{1f600}-\u{1f64f}\u{1f680}-\u{1f6ff}\u{2600}-\u{26ff}\u{2700}-\u{27bf}\u{1f1e6}-\u{1f1ff}\u{1f191}-\u{1f251}\u{1f004}\u{1f0cf}\u{1f170}-\u{1f171}\u{1f17e}-\u{1f17f}\u{1f18e}\u{3030}\u{2b50}\u{2b55}\u{2934}-\u{2935}\u{2b05}-\u{2b07}\u{2b1b}-\u{2b1c}\u{3297}\u{3299}\u{303d}\u{00a9}\u{00ae}\u{2122}\u{23f3}\u{24c2}\u{23e9}-\u{23ef}\u{25b6}\u{23f8}-\u{23fa}]/gu;
4
+ const emojiPattern = /[\u{1f300}-\u{1f5ff}\u{1f900}-\u{1f9ff}\u{1f600}-\u{1f64f}\u{1f680}-\u{1f6ff}\u{2600}-\u{26ff}\u{2700}-\u{27bf}\u{1f1e6}-\u{1f1ff}\u{1f191}-\u{1f251}\u{1f004}\u{1f0cf}\u{1f170}-\u{1f171}\u{1f17e}-\u{1f17f}\u{1f18e}\u{3030}\u{2b50}\u{2b55}\u{2934}-\u{2935}\u{2b05}-\u{2b07}\u{2b1b}-\u{2b1c}\u{3297}\u{3299}\u{303d}\u{00a9}\u{00ae}\u{2122}\u{23f3}\u{24c2}\u{23e9}-\u{23ef}\u{25b6}\u{23f8}-\u{23fa}]/gu;
5
5
  exports.emojiPattern = emojiPattern;
6
- var mailformat = new RegExp(
6
+ const mailformat = new RegExp(
7
7
  // eslint-disable-next-line no-control-regex
8
8
  "([!#-'*+/-9=?A-Z^-~-]+(.[!#-'*+/-9=?A-Z^-~-]+)*|\"([]!#-[^-~ \t]|(\\[\t -~]))+\")@([!#-'*+/-9=?A-Z^-~-]+(.[!#-'*+/-9=?A-Z^-~-]+)*|[[\t -Z^-~]*])");
9
9
  exports.mailformat = mailformat;
10
- var imageRegex = /^image\/(gif|png|jpeg)$/;
10
+ const imageRegex = /^image\/(gif|png|jpeg)$/;
11
+ // To check if email is valid
11
12
  function isEmailValid(object) {
12
13
  if (object.match(mailformat)) {
13
14
  return true;
@@ -17,6 +18,7 @@ function isEmailValid(object) {
17
18
  }
18
19
  }
19
20
  exports.isEmailValid = isEmailValid;
21
+ // To check if email is RH email
20
22
  function isValidRHEmail(object) {
21
23
  if (object.match(mailformat) && object.search('redhat.com') > 0) {
22
24
  return true;
@@ -36,7 +38,7 @@ function isEmojiPattern(object) {
36
38
  }
37
39
  exports.isEmojiPattern = isEmojiPattern;
38
40
  function isValidGuid(object) {
39
- var guidFormat = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
41
+ const guidFormat = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
40
42
  if (object.match(guidFormat)) {
41
43
  return true;
42
44
  }
@@ -51,10 +53,10 @@ function isNumber(str) {
51
53
  exports.isNumber = isNumber;
52
54
  function isRegularVersion(version) {
53
55
  // 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)
54
- var versionPartsArray = version.split(' ');
56
+ const versionPartsArray = version.split(' ');
55
57
  // find the index that has the version and split it into its pars
56
- var indexOfVersion = versionPartsArray.findIndex(function (p) { return p.includes('.'); });
57
- var splitArray = indexOfVersion > -1 ? versionPartsArray[indexOfVersion].split('.') : version.split('.');
58
+ const indexOfVersion = versionPartsArray.findIndex((p) => p.includes('.'));
59
+ const splitArray = indexOfVersion > -1 ? versionPartsArray[indexOfVersion].split('.') : version.split('.');
58
60
  // if the length of the split array is not 2, or 3 it is not a regular version
59
61
  // b/c version === major.minor.patch (patch === component in the request body)
60
62
  if (splitArray.length !== 2 && splitArray.length !== 3 && splitArray.length !== 4)
@@ -14,7 +14,7 @@ export declare enum NewCaseTypes {
14
14
  CERTIFICATION = "Certification",
15
15
  CONFIGURATION = "Configuration",
16
16
  CUSTOMER_SERVICE = "Customer service",
17
- USAGE_DOCS_HELP = "Documentation",
17
+ USAGE_DOCS_HELP = "Usage & Docs help",
18
18
  IDEA = "Idea",
19
19
  ROOT_CAUSE_ANALYSIS = "Root cause analysis",
20
20
  OTHER = "Other"
@@ -1 +1 @@
1
- {"version":3,"file":"caseUtils.d.ts","sourceRoot":"","sources":["../../src/caseUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAM3D,oBAAY,iBAAiB;IACzB,UAAU,iBAAiB;IAC3B,aAAa,kBAAkB;IAC/B,mBAAmB,wBAAwB;IAC3C,+BAA+B,uCAAuC;IACtE,wBAAwB,+BAA+B;IACvD,mBAAmB,kCAAkC;IACrD,QAAQ,aAAa;IACrB,KAAK,UAAU;CAClB;AAGD,oBAAY,YAAY;IACpB,UAAU,kBAAkB;IAC5B,aAAa,kBAAkB;IAC/B,aAAa,k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AgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEjE;AACD,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,WAQ/D;AACD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,WAErD;AAED,wBAAgB,YAAY,CAAC,IAAI,SAAK,UAOrC;AAGD,wBAAgB,YAAY,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,cAUtC;AAGD,wBAAgB,mBAAmB,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,YAwB1D;AAGD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,GAAG,OAqBlD;AAGD,wBAAgB,mBAAmB,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,YAwB1D;AAGD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,GAAG,OAqBlD"}
@@ -20,7 +20,7 @@ export var NewCaseTypes;
20
20
  NewCaseTypes["CERTIFICATION"] = "Certification";
21
21
  NewCaseTypes["CONFIGURATION"] = "Configuration";
22
22
  NewCaseTypes["CUSTOMER_SERVICE"] = "Customer service";
23
- NewCaseTypes["USAGE_DOCS_HELP"] = "Documentation";
23
+ NewCaseTypes["USAGE_DOCS_HELP"] = "Usage & Docs help";
24
24
  NewCaseTypes["IDEA"] = "Idea";
25
25
  NewCaseTypes["ROOT_CAUSE_ANALYSIS"] = "Root cause analysis";
26
26
  NewCaseTypes["OTHER"] = "Other";
@@ -26,4 +26,5 @@ export * from './translation-helper';
26
26
  export * from './outlier';
27
27
  export * from './sentry';
28
28
  export * from './constants/preferredLanguages';
29
+ export * from './tncUtil';
29
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts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AAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,gCAAgC,CAAC;AAC/C,cAAc,WAAW,CAAC"}
package/lib/esm/index.js CHANGED
@@ -26,3 +26,4 @@ export * from './translation-helper';
26
26
  export * from './outlier';
27
27
  export * from './sentry';
28
28
  export * from './constants/preferredLanguages';
29
+ export * from './tncUtil';
@@ -9,9 +9,9 @@ import { isNumber } from './validatorUtils';
9
9
  export const handleProductSearchResponse = (productsResultAll, productsResultEntitled = [], topCount = 5) => {
10
10
  const productsResultEntitledMap = {};
11
11
  forEach(productsResultEntitled, (p) => {
12
- // if (p.supportedForCustomer) { // Needs confirmation froom CCM team before adding
12
+ // If (p.supportedForCustomer)
13
+ // Needs confirmation froom CCM team before adding
13
14
  productsResultEntitledMap[`${p.name}`] = p;
14
- // }
15
15
  });
16
16
  const productsResult = map(productsResultAll, (product) => {
17
17
  var _c, _d;
@@ -21,7 +21,7 @@ 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
- // we get products based on the highest number of support cases
24
+ // We get products based on the highest number of support cases
25
25
  const topProducts = getTopProducts(productsResult, topCount);
26
26
  const productsResultSorted = orderBy(productsResult, ['product'], ['asc']);
27
27
  return {
@@ -1,4 +1,4 @@
1
- import { cloneDeep } from 'lodash';
1
+ import cloneDeep from 'lodash/cloneDeep';
2
2
  export const documentKindToInclude = 'documentKind:("Solution" OR "Video" OR "Article" OR "Errata" OR "Vulnerability" OR "Cve" OR "LabInfo")';
3
3
  export const issuesDefaultParamsObj = {
4
4
  q: '*:*',
@@ -0,0 +1,16 @@
1
+ export declare const TncConstants: {
2
+ HOSTS: {
3
+ DEV: string;
4
+ QA: string;
5
+ Stage: string;
6
+ PROD: string;
7
+ };
8
+ PARTNER_SHARE_SITE_CODE: string;
9
+ PARTNER_SHARE_EVENT_CODE: string;
10
+ REMOTER_RIDER_EVENT_CODE: string;
11
+ REMOTE_RIDER_SITE_CODE: string;
12
+ PARTNER_SHARE_LINK_ACCOUNT_SITE_CODE: string;
13
+ };
14
+ export declare function getTnCHost(): string;
15
+ export declare function baseTnCUrl(): string;
16
+ //# sourceMappingURL=tncUtil.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tncUtil.d.ts","sourceRoot":"","sources":["../../src/tncUtil.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;;;;;;;;;;;CAYxB,CAAC;AAEF,wBAAgB,UAAU,WAYzB;AAED,wBAAgB,UAAU,WAGzB"}
@@ -0,0 +1,31 @@
1
+ import hydrajs from '@cee-eng/hydrajs';
2
+ export const TncConstants = {
3
+ HOSTS: {
4
+ DEV: 'ams-dev1.devlab.redhat.com',
5
+ QA: 'www.qa.redhat.com',
6
+ Stage: 'www.stage.redhat.com',
7
+ PROD: 'www.redhat.com',
8
+ },
9
+ PARTNER_SHARE_SITE_CODE: 'customerPortal',
10
+ PARTNER_SHARE_EVENT_CODE: 'partnerAuthorization',
11
+ REMOTER_RIDER_EVENT_CODE: 'remoteAccessRider',
12
+ REMOTE_RIDER_SITE_CODE: 'remoteAccessRider',
13
+ PARTNER_SHARE_LINK_ACCOUNT_SITE_CODE: 'customerPortal_linkAccount',
14
+ };
15
+ export function getTnCHost() {
16
+ const env = hydrajs.Env.getEnvName();
17
+ switch (env) {
18
+ case 'QA':
19
+ return TncConstants.HOSTS.QA;
20
+ case 'DEV':
21
+ return TncConstants.HOSTS.DEV;
22
+ case 'Stage':
23
+ return TncConstants.HOSTS.Stage;
24
+ default:
25
+ return TncConstants.HOSTS.PROD;
26
+ }
27
+ }
28
+ export function baseTnCUrl() {
29
+ const wejava_host = getTnCHost();
30
+ return `https://${wejava_host}/wapps/tnc/ackrequired`;
31
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"validatorUtils.d.ts","sourceRoot":"","sources":["../../src/validatorUtils.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY,EAAE,MACgY,CAAC;AACrZ,QAAA,MAAM,UAAU,QAGf,CAAC;AAGF,iBAAS,YAAY,CAAC,MAAM,KAAA,WAM3B;AAED,iBAAS,cAAc,CAAC,MAAM,KAAA,WAM7B;AAED,iBAAS,cAAc,CAAC,MAAM,KAAA,WAM7B;AAED,iBAAS,WAAW,CAAC,MAAM,KAAA,WAO1B;AAED,iBAAS,QAAQ,CAAC,GAAG,EAAE,MAAM,WAE5B;AAED,iBAAS,gBAAgB,CAAC,OAAO,EAAE,MAAM,WAiBxC;AAED,iBAAS,WAAW,CAAC,QAAQ,KAAA,WAE5B;AAED,OAAO,EACH,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,UAAU,EACV,WAAW,EACX,WAAW,GACd,CAAC"}
1
+ {"version":3,"file":"validatorUtils.d.ts","sourceRoot":"","sources":["../../src/validatorUtils.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY,EAAE,MACgY,CAAC;AACrZ,QAAA,MAAM,UAAU,QAGf,CAAC;AAIF,iBAAS,YAAY,CAAC,MAAM,KAAA,WAM3B;AAGD,iBAAS,cAAc,CAAC,MAAM,KAAA,WAM7B;AAED,iBAAS,cAAc,CAAC,MAAM,KAAA,WAM7B;AAED,iBAAS,WAAW,CAAC,MAAM,KAAA,WAO1B;AAED,iBAAS,QAAQ,CAAC,GAAG,EAAE,MAAM,WAE5B;AAED,iBAAS,gBAAgB,CAAC,OAAO,EAAE,MAAM,WAiBxC;AAED,iBAAS,WAAW,CAAC,QAAQ,KAAA,WAE5B;AAED,OAAO,EACH,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,UAAU,EACV,WAAW,EACX,WAAW,GACd,CAAC"}
@@ -3,6 +3,7 @@ const mailformat = new RegExp(
3
3
  // eslint-disable-next-line no-control-regex
4
4
  "([!#-'*+/-9=?A-Z^-~-]+(.[!#-'*+/-9=?A-Z^-~-]+)*|\"([]!#-[^-~ \t]|(\\[\t -~]))+\")@([!#-'*+/-9=?A-Z^-~-]+(.[!#-'*+/-9=?A-Z^-~-]+)*|[[\t -Z^-~]*])");
5
5
  const imageRegex = /^image\/(gif|png|jpeg)$/;
6
+ // To check if email is valid
6
7
  function isEmailValid(object) {
7
8
  if (object.match(mailformat)) {
8
9
  return true;
@@ -11,6 +12,7 @@ function isEmailValid(object) {
11
12
  return false;
12
13
  }
13
14
  }
15
+ // To check if email is RH email
14
16
  function isValidRHEmail(object) {
15
17
  if (object.match(mailformat) && object.search('redhat.com') > 0) {
16
18
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/utils",
3
- "version": "2.0.0",
3
+ "version": "2.0.1-beta-1",
4
4
  "description": "> TODO: description",
5
5
  "author": "Vikas Rathee <vrathee@redhat.com>",
6
6
  "license": "ISC",
@@ -38,21 +38,20 @@
38
38
  "clean": "../../node_modules/.bin/rimraf lib config/tsconfig.tsbuildinfo",
39
39
  "test:watch": "./../../node_modules/.bin/jest --watch",
40
40
  "test:unit": "./../../node_modules/.bin/jest -c ./../../configs/tests/jest.config.unit.js",
41
- "test:coverage": "./../../node_modules/.bin/jest -c ./../../configs/tests/jest.config.coverage.js",
41
+ "test:coverage": "./../../node_modules/.bin/jest --all -c ./../../configs/tests/jest.config.coverage.js",
42
42
  "test:changes": "./../../node_modules/.bin/jest --passWithNoTests -c ./../../configs/tests/jest-only-changed-from-upstream.js",
43
43
  "test": "npm run test:changes",
44
44
  "prepublish": "npm run clean && npm run build:esm",
45
45
  "prepublishOnly": "npm run build"
46
46
  },
47
47
  "peerDependencies": {
48
- "@cee-eng/hydrajs": "4.15.71",
48
+ "@cee-eng/hydrajs": "4.16.4",
49
49
  "@cee-eng/ui-toolkit": "1.1.6",
50
- "@rh-support/types": "0.2.0",
51
50
  "dompurify": "^2.2.6",
52
51
  "i18next": "^19.0.1",
53
52
  "js-markdown-extra": "^1.2.4",
54
53
  "lazysizes": "^5.3.2",
55
- "localforage": "^1.7.3",
54
+ "localforage": "^1.10.0",
56
55
  "lodash": "^4.17.21",
57
56
  "marked": "^1.2.4",
58
57
  "moment-timezone": "^0.5.32",
@@ -60,15 +59,15 @@
60
59
  "solr-query-builder": "1.0.1"
61
60
  },
62
61
  "dependencies": {
63
- "@cee-eng/hydrajs": "4.15.71",
62
+ "@cee-eng/hydrajs": "4.16.4",
64
63
  "@cee-eng/ui-toolkit": "1.1.6",
65
- "@rh-support/types": "2.0.0",
64
+ "@rh-support/types": "2.0.2",
66
65
  "dompurify": "^2.2.6",
67
66
  "dot": "^1.1.3",
68
67
  "i18next": "^19.0.1",
69
68
  "js-markdown-extra": "^1.2.4",
70
69
  "lazysizes": "^5.3.2",
71
- "localforage": "^1.7.3",
70
+ "localforage": "^1.10.0",
72
71
  "lodash": "^4.17.21",
73
72
  "lucene": "^2.1.1",
74
73
  "marked": "^1.2.4",
@@ -85,5 +84,9 @@
85
84
  "@types/react-dom": "^17.0.9",
86
85
  "moment-timezone": "^0.5.40"
87
86
  },
88
- "gitHead": "a8012bb04d9b5073b5cc97507c93da6745be2102"
87
+ "browserslist": [
88
+ "defaults and supports es6-module",
89
+ "maintained node versions"
90
+ ],
91
+ "gitHead": "c382d611cbe5e1520adb25c9a9d0737b80a09748"
89
92
  }