@rh-support/utils 2.4.10-beta.6 → 2.5.0

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 (134) hide show
  1. package/README.md +0 -2
  2. package/lib/esm/apiUtils.d.ts +2 -2
  3. package/lib/esm/apiUtils.d.ts.map +1 -1
  4. package/lib/esm/apiUtils.js +18 -6
  5. package/lib/esm/csvUtils.d.ts +2 -2
  6. package/lib/esm/csvUtils.d.ts.map +1 -1
  7. package/lib/esm/csvUtils.js +9 -16
  8. package/lib/esm/dateUtils.d.ts +11 -9
  9. package/lib/esm/dateUtils.d.ts.map +1 -1
  10. package/lib/esm/dateUtils.js +96 -11
  11. package/lib/esm/dropdownUtils.d.ts +1 -1
  12. package/lib/esm/dropdownUtils.d.ts.map +1 -1
  13. package/lib/esm/eventUtils.d.ts +14 -2
  14. package/lib/esm/eventUtils.d.ts.map +1 -1
  15. package/lib/esm/eventUtils.js +101 -5
  16. package/lib/esm/hostNameUtils.d.ts.map +1 -1
  17. package/lib/esm/hydraConfigUtils.d.ts +1 -1
  18. package/lib/esm/hydraConfigUtils.d.ts.map +1 -1
  19. package/lib/esm/index.d.ts +0 -2
  20. package/lib/esm/index.d.ts.map +1 -1
  21. package/lib/esm/index.js +0 -2
  22. package/lib/esm/outlier.d.ts.map +1 -1
  23. package/lib/esm/promiseUtils.d.ts.map +1 -1
  24. package/lib/esm/recommendationUtils.js +2 -2
  25. package/lib/esm/searchApiUtils.d.ts +2 -2
  26. package/lib/esm/searchApiUtils.d.ts.map +1 -1
  27. package/lib/esm/searchApiUtils.js +3 -3
  28. package/lib/esm/solrUtils.d.ts +4 -4
  29. package/lib/esm/solrUtils.d.ts.map +1 -1
  30. package/lib/esm/solrUtils.js +1 -2
  31. package/lib/esm/translation-helper.d.ts +5 -1
  32. package/lib/esm/translation-helper.d.ts.map +1 -1
  33. package/lib/esm/translation-helper.js +1 -1
  34. package/lib/esm/urlUtils.d.ts +3 -1
  35. package/lib/esm/urlUtils.d.ts.map +1 -1
  36. package/lib/esm/urlUtils.js +14 -5
  37. package/lib/esm/validatorUtils.js +1 -1
  38. package/package.json +17 -31
  39. package/lib/cjs/apiUtils.d.ts +0 -17
  40. package/lib/cjs/apiUtils.d.ts.map +0 -1
  41. package/lib/cjs/apiUtils.js +0 -52
  42. package/lib/cjs/appUtils.d.ts +0 -11
  43. package/lib/cjs/appUtils.d.ts.map +0 -1
  44. package/lib/cjs/appUtils.js +0 -67
  45. package/lib/cjs/browserDetectionUtils.d.ts +0 -3
  46. package/lib/cjs/browserDetectionUtils.d.ts.map +0 -1
  47. package/lib/cjs/browserDetectionUtils.js +0 -9
  48. package/lib/cjs/cacheUtils.d.ts +0 -27
  49. package/lib/cjs/cacheUtils.d.ts.map +0 -1
  50. package/lib/cjs/cacheUtils.js +0 -137
  51. package/lib/cjs/caseUtils.d.ts +0 -40
  52. package/lib/cjs/caseUtils.d.ts.map +0 -1
  53. package/lib/cjs/caseUtils.js +0 -225
  54. package/lib/cjs/constants/preferredLanguages.d.ts +0 -33
  55. package/lib/cjs/constants/preferredLanguages.d.ts.map +0 -1
  56. package/lib/cjs/constants/preferredLanguages.js +0 -35
  57. package/lib/cjs/csvUtils.d.ts +0 -24
  58. package/lib/cjs/csvUtils.d.ts.map +0 -1
  59. package/lib/cjs/csvUtils.js +0 -109
  60. package/lib/cjs/customElementUtils.d.ts +0 -20
  61. package/lib/cjs/customElementUtils.d.ts.map +0 -1
  62. package/lib/cjs/customElementUtils.js +0 -23
  63. package/lib/cjs/dateUtils.d.ts +0 -16
  64. package/lib/cjs/dateUtils.d.ts.map +0 -1
  65. package/lib/cjs/dateUtils.js +0 -78
  66. package/lib/cjs/dropdownUtils.d.ts +0 -18
  67. package/lib/cjs/dropdownUtils.d.ts.map +0 -1
  68. package/lib/cjs/dropdownUtils.js +0 -59
  69. package/lib/cjs/eventUtils.d.ts +0 -9
  70. package/lib/cjs/eventUtils.d.ts.map +0 -1
  71. package/lib/cjs/eventUtils.js +0 -32
  72. package/lib/cjs/hostNameUtils.d.ts +0 -7
  73. package/lib/cjs/hostNameUtils.d.ts.map +0 -1
  74. package/lib/cjs/hostNameUtils.js +0 -35
  75. package/lib/cjs/hydraConfigUtils.d.ts +0 -14
  76. package/lib/cjs/hydraConfigUtils.d.ts.map +0 -1
  77. package/lib/cjs/hydraConfigUtils.js +0 -83
  78. package/lib/cjs/index.d.ts +0 -30
  79. package/lib/cjs/index.d.ts.map +0 -1
  80. package/lib/cjs/index.js +0 -41
  81. package/lib/cjs/insightRuleInfoUtils.d.ts +0 -4
  82. package/lib/cjs/insightRuleInfoUtils.d.ts.map +0 -1
  83. package/lib/cjs/insightRuleInfoUtils.js +0 -31
  84. package/lib/cjs/lruCacheUtils.d.ts +0 -13
  85. package/lib/cjs/lruCacheUtils.d.ts.map +0 -1
  86. package/lib/cjs/lruCacheUtils.js +0 -45
  87. package/lib/cjs/outlier.d.ts +0 -16
  88. package/lib/cjs/outlier.d.ts.map +0 -1
  89. package/lib/cjs/outlier.js +0 -48
  90. package/lib/cjs/productsUtils.d.ts +0 -33
  91. package/lib/cjs/productsUtils.d.ts.map +0 -1
  92. package/lib/cjs/productsUtils.js +0 -138
  93. package/lib/cjs/promiseUtils.d.ts +0 -8
  94. package/lib/cjs/promiseUtils.d.ts.map +0 -1
  95. package/lib/cjs/promiseUtils.js +0 -23
  96. package/lib/cjs/recommendationUtils.d.ts +0 -14
  97. package/lib/cjs/recommendationUtils.d.ts.map +0 -1
  98. package/lib/cjs/recommendationUtils.js +0 -61
  99. package/lib/cjs/scrollUtils.d.ts +0 -11
  100. package/lib/cjs/scrollUtils.d.ts.map +0 -1
  101. package/lib/cjs/scrollUtils.js +0 -74
  102. package/lib/cjs/searchApiUtils.d.ts +0 -44
  103. package/lib/cjs/searchApiUtils.d.ts.map +0 -1
  104. package/lib/cjs/searchApiUtils.js +0 -48
  105. package/lib/cjs/sentry.d.ts +0 -14
  106. package/lib/cjs/sentry.d.ts.map +0 -1
  107. package/lib/cjs/sentry.js +0 -40
  108. package/lib/cjs/solrUtils.d.ts +0 -74
  109. package/lib/cjs/solrUtils.d.ts.map +0 -1
  110. package/lib/cjs/solrUtils.js +0 -322
  111. package/lib/cjs/styleUtils.d.ts +0 -12
  112. package/lib/cjs/styleUtils.d.ts.map +0 -1
  113. package/lib/cjs/styleUtils.js +0 -34
  114. package/lib/cjs/tncUtil.d.ts +0 -16
  115. package/lib/cjs/tncUtil.d.ts.map +0 -1
  116. package/lib/cjs/tncUtil.js +0 -39
  117. package/lib/cjs/translation-helper.d.ts +0 -10
  118. package/lib/cjs/translation-helper.d.ts.map +0 -1
  119. package/lib/cjs/translation-helper.js +0 -23
  120. package/lib/cjs/urlUtils.d.ts +0 -19
  121. package/lib/cjs/urlUtils.d.ts.map +0 -1
  122. package/lib/cjs/urlUtils.js +0 -76
  123. package/lib/cjs/userUtils.d.ts +0 -3
  124. package/lib/cjs/userUtils.d.ts.map +0 -1
  125. package/lib/cjs/userUtils.js +0 -11
  126. package/lib/cjs/validatorUtils.d.ts +0 -11
  127. package/lib/cjs/validatorUtils.d.ts.map +0 -1
  128. package/lib/cjs/validatorUtils.js +0 -76
  129. package/lib/esm/customElementUtils.d.ts +0 -20
  130. package/lib/esm/customElementUtils.d.ts.map +0 -1
  131. package/lib/esm/customElementUtils.js +0 -19
  132. package/lib/esm/insightRuleInfoUtils.d.ts +0 -4
  133. package/lib/esm/insightRuleInfoUtils.d.ts.map +0 -1
  134. package/lib/esm/insightRuleInfoUtils.js +0 -23
@@ -1 +1 @@
1
- {"version":3,"file":"solrUtils.d.ts","sourceRoot":"","sources":["../../src/solrUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAM1D,MAAM,WAAW,OAAO;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC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QAAQ,MAAM;;;;;oBAmBlC,MAAM,KAAK,MAAM,GAAG,MAAM,EAAE,QAAQ,MAAM;wBAWtC,MAAM,gBAAgB,MAAM,EAAE;wBAS9B,MAAM,gBAAgB,MAAM,EAAE;iBAOvC,OAAO;;;EAoBzB;AAED,MAAM,MAAM,0BAA0B,CAAC,CAAC,IAAI;KACvC,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE;CACtC,CAAC;AAEF;;;;;GAKG;AAEH,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,0BAA0B,CAAC,CAAC,CAAC,CAmB7G;AAED,MAAM,MAAM,0BAA0B,CAAC,CAAC,EAAE,CAAC,IAAI;KAC1C,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;CACzB,CAAC;AAEF;;;;;;GAMG;AAEH,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,0BAA0B,CAAC,CAAC,EAAE,CAAC,CAAC,CAYnH;AAmBD;;;;;;GAMG;AAEH,wBAAgB,cAAc,CAAC,aAAa,KAAA,EAAE,mBAAmB,UAAQ,OA4BxE;AA+BD;;;;;;;;GAQG;AAEH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,MAU3C"}
@@ -124,8 +124,7 @@ export function solrResponseToFacetFields(solrResponse) {
124
124
  export function solrResponseToPivotFields(solrResponse) {
125
125
  const solrPivots = get(solrResponse, 'facet_counts.facet_pivot', {});
126
126
  const pivots = {};
127
- Object.keys(solrPivots).forEach((_pivotKey) => {
128
- const pivotKey = _pivotKey;
127
+ Object.keys(solrPivots).forEach((pivotKey) => {
129
128
  pivots[pivotKey] = [];
130
129
  for (let i = 0; i < solrPivots[pivotKey].length; i++) {
131
130
  pivots[pivotKey].push(createPivotObject(solrPivots[pivotKey][i]));
@@ -1,3 +1,6 @@
1
+ type InterpolationArgs = {
2
+ [key: string]: string | number;
3
+ };
1
4
  /**
2
5
  * Translate the string using i18n.t
3
6
  * @param {string} key the string to be translated
@@ -6,5 +9,6 @@
6
9
  *
7
10
  * use getText only in the case when neither <Trans /> nor useTranslation() is available
8
11
  */
9
- export declare function getText(key: string, args?: object): string;
12
+ export declare function getText(key: string, args?: InterpolationArgs): string;
13
+ export {};
10
14
  //# sourceMappingURL=translation-helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"translation-helper.d.ts","sourceRoot":"","sources":["../../src/translation-helper.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAM1D"}
1
+ {"version":3,"file":"translation-helper.d.ts","sourceRoot":"","sources":["../../src/translation-helper.ts"],"names":[],"mappings":"AAEA,KAAK,iBAAiB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAE5D;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAMrE"}
@@ -8,7 +8,7 @@ import i18next from 'i18next';
8
8
  * use getText only in the case when neither <Trans /> nor useTranslation() is available
9
9
  */
10
10
  export function getText(key, args) {
11
- const translatedString = i18next.t(key, args);
11
+ const translatedString = args ? i18next.t(key, args) : i18next.t(key);
12
12
  if (!translatedString) {
13
13
  return key;
14
14
  }
@@ -1,5 +1,7 @@
1
1
  import { IParseOptions, IStringifyOptions } from 'qs';
2
- export declare function getUrlParsedParams(urlParams: string, options?: IParseOptions): any;
2
+ export declare function getUrlParsedParams(urlParams: string, options?: IParseOptions): {
3
+ [key: string]: unknown;
4
+ };
3
5
  export declare function getStringifiedParams<T>(object: T, options?: IStringifyOptions): string;
4
6
  export declare const REDHAT_DOT_COM_HOSTNAMES: {
5
7
  QA: string;
@@ -1 +1 @@
1
- {"version":3,"file":"urlUtils.d.ts","sourceRoot":"","sources":["../../src/urlUtils.ts"],"names":[],"mappings":"AACA,OAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAC;AAG1D,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,OAG5E;AAGD,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,iBAAiB,UAG7E;AAED,eAAO,MAAM,wBAAwB;;;;;CAKpC,CAAC;AAEF,eAAO,MAAM,mBAAmB,sBAW/B,CAAC;AAKF,eAAO,MAAM,iBAAiB,QAAS,MAAM,WAK5C,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAAS,MAAM,WAGhD,CAAC;AAEF,eAAO,MAAM,2BAA2B,QAC/B,MAAM,kBACI,MAAM,EAAE,KACxB,MAKF,CAAC;AAMF,eAAO,MAAM,qBAAqB,iBAChB,MAAM,GAAG,MAAM,YACnB,MAAM;;;MAEjB,MAOF,CAAC;AAEF,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,OAExC,CAAC"}
1
+ {"version":3,"file":"urlUtils.d.ts","sourceRoot":"","sources":["../../src/urlUtils.ts"],"names":[],"mappings":"AACA,OAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAC;AAG1D,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa;;EAG5E;AAGD,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,iBAAiB,UAG7E;AAED,eAAO,MAAM,wBAAwB;;;;;CAKpC,CAAC;AAEF,eAAO,MAAM,mBAAmB,sBAW/B,CAAC;AAIF,eAAO,MAAM,iBAAiB,QAAS,MAAM,WAY5C,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAAS,MAAM,WAGhD,CAAC;AAEF,eAAO,MAAM,2BAA2B,QAC/B,MAAM,kBACI,MAAM,EAAE,KACxB,MAKF,CAAC;AAMF,eAAO,MAAM,qBAAqB,iBAChB,MAAM,GAAG,MAAM,YACnB,MAAM;;;MAEjB,MAOF,CAAC;AAEF,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,OAExC,CAAC"}
@@ -29,11 +29,20 @@ export const getRedhatDotComHost = (env) => {
29
29
  }
30
30
  };
31
31
  const drupalUrlRegexp = /^(https:\/\/access?.?\w+.redhat.com)?\/(\w+)\/(\d+)\S*$/;
32
- const openshiftDocUrlRegexp = /^https:\/\/docs.openshift.com\//;
33
32
  export const getResTypeFromUrl = (url) => {
34
- const drupalUrl = drupalUrlRegexp.exec(url);
35
- const isOpenshiftDocUrl = openshiftDocUrlRegexp.test(url);
36
- return (drupalUrl === null || drupalUrl === void 0 ? void 0 : drupalUrl[2]) ? drupalUrl === null || drupalUrl === void 0 ? void 0 : drupalUrl[2] : isOpenshiftDocUrl ? 'documentation' : 'unknown';
33
+ if (!url)
34
+ return '';
35
+ if (url.includes('https://')) {
36
+ const { hostname, pathname } = new URL(url);
37
+ if (hostname.includes('openshift'))
38
+ return 'documentation';
39
+ const [, type] = pathname.split('/');
40
+ return type ? type : 'unknown';
41
+ }
42
+ else {
43
+ const [, type] = url.split('/');
44
+ return type ? type : 'unknown';
45
+ }
37
46
  };
38
47
  export const getDrupalResIdFromUrl = (url) => {
39
48
  let m = drupalUrlRegexp.exec(url);
@@ -58,5 +67,5 @@ export const getUpdatedQueryString = (currentQuery, newQuery, { resetSearchParam
58
67
  return !resetSearchParams ? getStringifiedParams(updatedQuery) : getStringifiedParams(newQuery);
59
68
  };
60
69
  export const isValidUrl = (url) => {
61
- return /^(http(s)?:\/\/)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/.test(url);
70
+ return /^^(https?|ftp):\/\/[^\s/$.?#].[^\s]*\??([^#\s]*)$/.test(url);
62
71
  };
@@ -1,7 +1,7 @@
1
1
  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;
2
2
  const mailformat = new RegExp(
3
3
  // eslint-disable-next-line no-control-regex
4
- "([!#-'*+/-9=?A-Z^-~-]+(.[!#-'*+/-9=?A-Z^-~-]+)*|\"([]!#-[^-~ \t]|(\\[\t -~]))+\")@([!#-'*+/-9=?A-Z^-~-]+(.[!#-'*+/-9=?A-Z^-~-]+)*|[[\t -Z^-~]*])");
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
6
  // To check if email is valid
7
7
  function isEmailValid(object) {
package/package.json CHANGED
@@ -1,17 +1,14 @@
1
1
  {
2
2
  "name": "@rh-support/utils",
3
- "version": "2.4.10-beta.6",
3
+ "version": "2.5.0",
4
4
  "description": "> TODO: description",
5
5
  "author": "Vikas Rathee <vrathee@redhat.com>",
6
6
  "license": "ISC",
7
- "main": "lib/cjs/index.js",
8
- "module": "lib/esm/index.js",
9
- "jsnext:main": "lib/esm/index.js",
10
- "types": "lib/esm/index.d.ts",
7
+ "module": "./lib/esm/index.js",
8
+ "types": "./lib/esm/index.d.ts",
11
9
  "sideEffects": false,
12
10
  "directories": {
13
- "lib": "lib",
14
- "cjs": "lib/cjs"
11
+ "lib": "./lib"
15
12
  },
16
13
  "files": [
17
14
  "lib/*",
@@ -33,8 +30,7 @@
33
30
  "scripts": {
34
31
  "build:watch": "../../node_modules/.bin/tsc -w -p config/tsconfig.json",
35
32
  "build:esm": "../../node_modules/.bin/tsc -p config/tsconfig.json",
36
- "build:cjs": "../../node_modules/.bin/tsc -p config/tsconfig-umd.json",
37
- "build": "npm run clean && (npm run build:esm & npm run build:cjs)",
33
+ "build": "npm run clean && npm run build:esm",
38
34
  "clean": "../../node_modules/.bin/rimraf lib config/tsconfig.tsbuildinfo",
39
35
  "test:watch": "./../../node_modules/.bin/jest --watch",
40
36
  "test:unit": "./../../node_modules/.bin/jest -c ./../../configs/tests/jest.config.unit.js",
@@ -45,48 +41,38 @@
45
41
  "prepublishOnly": "npm run build"
46
42
  },
47
43
  "peerDependencies": {
48
- "@cee-eng/hydrajs": "4.16.43",
49
- "@cee-eng/ui-toolkit": "1.1.6",
50
- "dompurify": "^2.2.6",
51
- "i18next": "^19.0.1",
52
- "js-markdown-extra": "^1.2.4",
53
- "lazysizes": "^5.3.2",
44
+ "@cee-eng/hydrajs": "4.17.36",
54
45
  "localforage": "^1.10.0",
55
46
  "lodash": "^4.17.21",
56
- "marked": "^1.2.4",
57
- "moment-timezone": "^0.5.32",
58
47
  "qs": "^6.7.0",
59
48
  "solr-query-builder": "1.0.1"
60
49
  },
61
50
  "dependencies": {
62
- "@cee-eng/hydrajs": "4.16.43",
63
- "@cee-eng/ui-toolkit": "1.1.6",
64
- "@rh-support/types": "2.0.2",
51
+ "@cee-eng/hydrajs": "4.17.36",
52
+ "@rh-support/types": "2.0.4",
53
+ "date-fns": "3.6.0",
54
+ "date-fns-tz": "^3.1.3",
65
55
  "dompurify": "^2.2.6",
66
- "dot": "^1.1.3",
67
- "i18next": "^19.0.1",
68
- "js-markdown-extra": "^1.2.4",
69
- "lazysizes": "^5.3.2",
70
56
  "localforage": "^1.10.0",
71
57
  "lodash": "^4.17.21",
72
58
  "lucene": "^2.1.1",
73
- "marked": "^1.2.4",
74
- "qs": "^6.11.0",
59
+ "qs": "^6.7.0",
75
60
  "solr-query-builder": "1.0.1"
76
61
  },
77
62
  "devDependencies": {
78
63
  "@types/dompurify": "^2.2.1",
64
+ "@types/jest": "^29.5.11",
79
65
  "@types/lodash": "^4.14.140",
80
66
  "@types/lucene": "^2.1.0",
81
- "@types/marked": "^1.1.0",
67
+ "@types/node": "^20.11.3",
82
68
  "@types/qs": "^6.9.1",
83
- "@types/react": "^17.0.14",
84
- "@types/react-dom": "^17.0.9",
85
- "moment-timezone": "^0.5.40"
69
+ "i18next": "^23.15.0",
70
+ "jest": "^29.7.0",
71
+ "jest-environment-jsdom": "^29.7.0"
86
72
  },
87
73
  "browserslist": [
88
74
  "defaults and supports es6-module",
89
75
  "maintained node versions"
90
76
  ],
91
- "gitHead": "f4caba45a2ffbc0cb441fdd30630769b447931d1"
77
+ "gitHead": "908b440e3c6cd625c77178c3205f4e2908630446"
92
78
  }
@@ -1,17 +0,0 @@
1
- import { IApiCreateState, IApiDeleteState, IApiResponseDetails, IApiUpdateState } from '@rh-support/types/shared';
2
- import { ITroubleshootProductResponse } from './productsUtils';
3
- export declare function getApiResourceObject<T>(data?: T, isFetching?: boolean, isError?: boolean, errorMessage?: string, error?: Error): IApiResponseDetails<T>;
4
- export declare function getApiCreationStatus(isCreating?: boolean, isError?: boolean, errorMessage?: string): IApiCreateState;
5
- export declare function getApiUpdationStatus(isUpdating?: boolean, isError?: boolean, errorMessage?: string): IApiUpdateState;
6
- export declare function getApiDeletionStatus(isDeleting?: boolean, isError?: boolean, errorMessage?: string): IApiDeleteState;
7
- export declare function haventLoadedMetadata<T>(apiResponse: IApiResponseDetails<T>, isEmptyCallback?: (data: T) => boolean): boolean;
8
- export declare function haventLoadedProductsMetadata(apiResponse: IApiResponseDetails<ITroubleshootProductResponse>): boolean;
9
- /**
10
- * We are firstly remove the special characters from the string and then encode the string. After that
11
- * we are trimming text as per limit set and then decode the string.
12
- * @param description Description string
13
- * @param limit Limit to trim the string
14
- * @returns
15
- */
16
- export declare const getTrimmedSpecialCharacters: (description?: string, limit?: number) => string;
17
- //# sourceMappingURL=apiUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apiUtils.d.ts","sourceRoot":"","sources":["../../src/apiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAIlH,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAE/D,wBAAgB,oBAAoB,CAAC,CAAC,EAClC,IAAI,GAAE,CAAa,EACnB,UAAU,GAAE,OAAe,EAC3B,OAAO,GAAE,OAAe,EACxB,YAAY,GAAE,MAAW,EACzB,KAAK,GAAE,KAAY,GACpB,mBAAmB,CAAC,CAAC,CAAC,CAExB;AAED,wBAAgB,oBAAoB,CAChC,UAAU,GAAE,OAAe,EAC3B,OAAO,GAAE,OAAe,EACxB,YAAY,GAAE,MAAW,GAC1B,eAAe,CAEjB;AACD,wBAAgB,oBAAoB,CAChC,UAAU,GAAE,OAAe,EAC3B,OAAO,GAAE,OAAe,EACxB,YAAY,GAAE,MAAW,GAC1B,eAAe,CAEjB;AACD,wBAAgB,oBAAoB,CAChC,UAAU,GAAE,OAAe,EAC3B,OAAO,GAAE,OAAe,EACxB,YAAY,GAAE,MAAW,GAC1B,eAAe,CAEjB;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EAClC,WAAW,EAAE,mBAAmB,CAAC,CAAC,CAAC,EACnC,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,GACvC,OAAO,CAGT;AAED,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,mBAAmB,CAAC,4BAA4B,CAAC,GAAG,OAAO,CAEpH;AAED;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,kDASvC,CAAC"}
@@ -1,52 +0,0 @@
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.getTrimmedSpecialCharacters = exports.haventLoadedProductsMetadata = exports.haventLoadedMetadata = exports.getApiDeletionStatus = exports.getApiUpdationStatus = exports.getApiCreationStatus = exports.getApiResourceObject = void 0;
7
- const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
8
- const trim_1 = __importDefault(require("lodash/trim"));
9
- function getApiResourceObject(data = undefined, isFetching = false, isError = false, errorMessage = '', error = null) {
10
- return { data, isFetching, isError, errorMessage, error };
11
- }
12
- exports.getApiResourceObject = getApiResourceObject;
13
- function getApiCreationStatus(isCreating = false, isError = false, errorMessage = '') {
14
- return { isCreating, isError, errorMessage };
15
- }
16
- exports.getApiCreationStatus = getApiCreationStatus;
17
- function getApiUpdationStatus(isUpdating = false, isError = false, errorMessage = '') {
18
- return { isUpdating, isError, errorMessage };
19
- }
20
- exports.getApiUpdationStatus = getApiUpdationStatus;
21
- function getApiDeletionStatus(isDeleting = false, isError = false, errorMessage = '') {
22
- return { isDeleting, isError, errorMessage };
23
- }
24
- exports.getApiDeletionStatus = getApiDeletionStatus;
25
- function haventLoadedMetadata(apiResponse, isEmptyCallback) {
26
- const isDataEmpty = isEmptyCallback ? isEmptyCallback : isEmpty_1.default;
27
- return isDataEmpty(apiResponse.data) && !apiResponse.isFetching && !apiResponse.isError;
28
- }
29
- exports.haventLoadedMetadata = haventLoadedMetadata;
30
- function haventLoadedProductsMetadata(apiResponse) {
31
- return isEmpty_1.default(apiResponse.data.productsResult) && !apiResponse.isFetching && !apiResponse.isError;
32
- }
33
- exports.haventLoadedProductsMetadata = haventLoadedProductsMetadata;
34
- /**
35
- * We are firstly remove the special characters from the string and then encode the string. After that
36
- * we are trimming text as per limit set and then decode the string.
37
- * @param description Description string
38
- * @param limit Limit to trim the string
39
- * @returns
40
- */
41
- const getTrimmedSpecialCharacters = (description = '', limit = 4000) => {
42
- if (description) {
43
- const removeSpecialCharacters = trim_1.default(description.replace(/[^a-zA-Z0-9 ]/g, '').replace(/ {2,}/g, ' '));
44
- const encodedDescription = encodeURIComponent(removeSpecialCharacters);
45
- const trimmedDescription = encodedDescription.slice(0, limit);
46
- return decodeURIComponent(trimmedDescription) || '';
47
- }
48
- else {
49
- return description;
50
- }
51
- };
52
- exports.getTrimmedSpecialCharacters = getTrimmedSpecialCharacters;
@@ -1,11 +0,0 @@
1
- export declare const getAccessHostname: () => string;
2
- export declare const getAppVersion: () => any;
3
- export interface IStrataHeaders {
4
- redhat_client?: string;
5
- account_number?: string;
6
- }
7
- export declare const getStrataHeaders: (appName: string, accountNumber: string) => IStrataHeaders;
8
- export declare const setStrataHeaders: (appName: string, accountNumber: string) => void;
9
- export declare const getUserAgentForCaseMode: (isCaseCreate: boolean) => string;
10
- export declare const setSecuredSupport: (isGs4?: boolean) => void;
11
- //# sourceMappingURL=appUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"appUtils.d.ts","sourceRoot":"","sources":["../../src/appUtils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,cAe7B,CAAC;AAEF,eAAO,MAAM,aAAa,WAEzB,CAAC;AAEF,MAAM,WAAW,cAAc;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAGD,eAAO,MAAM,gBAAgB,YAAa,MAAM,iBAAiB,MAAM,KAAG,cAGxE,CAAC;AAEH,eAAO,MAAM,gBAAgB,YAAa,MAAM,iBAAiB,MAAM,SAItE,CAAC;AAgBF,eAAO,MAAM,uBAAuB,iBAAkB,OAAO,WAE5D,CAAC;AAGF,eAAO,MAAM,iBAAiB,WAAW,OAAO,SAG/C,CAAC"}
@@ -1,67 +0,0 @@
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.setSecuredSupport = exports.getUserAgentForCaseMode = exports.setStrataHeaders = exports.getStrataHeaders = exports.getAppVersion = exports.getAccessHostname = void 0;
7
- const get_1 = __importDefault(require("lodash/get"));
8
- const getAccessHostname = () => {
9
- // returns the current access.redhat.com hostname (e.g if qa then would return access.qa.redhat.com)
10
- if (typeof window !== 'undefined' && window) {
11
- if (prodHostNames.indexOf(window.location.hostname) !== -1) {
12
- return prodHostNames[0];
13
- }
14
- else if (qaHostNames.indexOf(window.location.hostname) !== -1) {
15
- return qaHostNames[0];
16
- }
17
- else if (fteHostNames.indexOf(window.location.hostname) !== -1) {
18
- return fteHostNames[0];
19
- }
20
- else if (ciHostNames.indexOf(window.location.hostname) !== -1) {
21
- return ciHostNames[0];
22
- }
23
- else if (stageHostNames.indexOf(window.location.hostname) !== -1) {
24
- return stageHostNames[0];
25
- }
26
- }
27
- };
28
- exports.getAccessHostname = getAccessHostname;
29
- const getAppVersion = () => {
30
- return get_1.default(window.seVersionInfo || window.supportVersionInfo || {}, 'packageVersion');
31
- };
32
- exports.getAppVersion = getAppVersion;
33
- const strataHeaders = {};
34
- const getStrataHeaders = (appName, accountNumber) => ({
35
- redhat_client: `${appName} ${exports.getAppVersion()}`,
36
- account_number: accountNumber,
37
- });
38
- exports.getStrataHeaders = getStrataHeaders;
39
- const setStrataHeaders = (appName, accountNumber) => {
40
- const newStrataHeaders = exports.getStrataHeaders(appName, accountNumber);
41
- strataHeaders.redhat_client = newStrataHeaders.redhat_client;
42
- strataHeaders.account_number = newStrataHeaders.account_number;
43
- };
44
- exports.setStrataHeaders = setStrataHeaders;
45
- // Host names for all the app's different environments.
46
- // the actual redhat url needs to always be in the first position of the arrays
47
- // because the getAccessHostname function depends on that being the case for getting the current access hostname.
48
- const prodHostNames = [
49
- 'access.redhat.com',
50
- 'prod.foo.redhat.com',
51
- 'fooprod.redhat.com',
52
- 'attachment-viewer.cee.redhat.com',
53
- ];
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
- };
61
- exports.getUserAgentForCaseMode = getUserAgentForCaseMode;
62
- const securedSupport = { pathPrefix: '', isGs4: false };
63
- const setSecuredSupport = (isGs4 = false) => {
64
- securedSupport.isGs4 = isGs4;
65
- securedSupport.pathPrefix = isGs4 ? '/secure-support' : '';
66
- };
67
- exports.setSecuredSupport = setSecuredSupport;
@@ -1,3 +0,0 @@
1
- declare function isiOS(): boolean;
2
- export { isiOS };
3
- //# sourceMappingURL=browserDetectionUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"browserDetectionUtils.d.ts","sourceRoot":"","sources":["../../src/browserDetectionUtils.ts"],"names":[],"mappings":"AAAA,iBAAS,KAAK,YAQb;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isiOS = void 0;
4
- function isiOS() {
5
- return (['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform) ||
6
- // iPad on iOS 13 detection
7
- (navigator.userAgent.includes('Mac') && 'ontouchend' in document));
8
- }
9
- exports.isiOS = isiOS;
@@ -1,27 +0,0 @@
1
- import lf from 'localforage';
2
- export interface IBaseCache<T> {
3
- lastModifiedDate?: string;
4
- value: T;
5
- expiresAt?: number;
6
- }
7
- export interface ICacheOptions {
8
- expireAt?: number;
9
- }
10
- export declare function isFirefox(): boolean;
11
- export declare class CacheUtilsService<P extends string> {
12
- private localForage;
13
- indexDBAvailable: boolean;
14
- static localStorageAvailable: boolean;
15
- constructor(localForage: typeof lf, options: LocalForageOptions);
16
- makeKey(namespace: P, key: string): string;
17
- set<S extends IBaseCache<T>, T>(namespace: P, key: string, obj: S, options?: ICacheOptions): Promise<S>;
18
- setWithFullKey<S extends IBaseCache<T>, T>(key: string, obj: S): Promise<S>;
19
- get<S>(namespace: P, key: string): Promise<S>;
20
- getWithFullKey<S>(key: string): Promise<S>;
21
- delete(namespace: P, key: string): Promise<void>;
22
- deleteWithFullKey(key: string): Promise<void>;
23
- clear(): Promise<void>;
24
- keys(namespace?: P): Promise<string[]>;
25
- expireCache(): Promise<void>;
26
- }
27
- //# sourceMappingURL=cacheUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cacheUtils.d.ts","sourceRoot":"","sources":["../../src/cacheUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAK7B,MAAM,WAAW,UAAU,CAAC,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,CAAC,CAAC;IACT,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,SAAS,YAExB;AAED,qBAAa,iBAAiB,CAAC,CAAC,SAAS,MAAM;IAC3C,OAAO,CAAC,WAAW,CAAY;IACxB,gBAAgB,EAAE,OAAO,CAAQ;IACxC,MAAM,CAAC,qBAAqB,EAAE,OAAO,CAAQ;gBACjC,WAAW,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,kBAAkB;IA2B/D,OAAO,CAAC,SAAS,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM;IAIjC,GAAG,CAAC,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC;IAOvG,cAAc,CAAC,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAQ3E,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAI7C,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAQ1C,MAAM,CAAC,SAAS,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ7C,KAAK;IAQL,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAkBhC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAcrC"}
@@ -1,137 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.CacheUtilsService = exports.isFirefox = void 0;
16
- const filter_1 = __importDefault(require("lodash/filter"));
17
- const forEach_1 = __importDefault(require("lodash/forEach"));
18
- const includes_1 = __importDefault(require("lodash/includes"));
19
- function isFirefox() {
20
- return 'MozAppearance' in document.documentElement.style;
21
- }
22
- exports.isFirefox = isFirefox;
23
- class CacheUtilsService {
24
- constructor(localForage, options) {
25
- this.indexDBAvailable = true;
26
- // For FF only attempt to determine if indexDB is available, this mainly affects
27
- // FF private mode
28
- localForage.config(options);
29
- try {
30
- if (isFirefox() && window.indexedDB) {
31
- const db = indexedDB.open('test');
32
- db.onerror = () => {
33
- this.indexDBAvailable = false;
34
- };
35
- }
36
- }
37
- catch (e) {
38
- console.warn(`IndexDB unavailable.`);
39
- this.indexDBAvailable = false;
40
- }
41
- // For FF, if indexDB isn't available and localStorage is, prefer localStorage
42
- if (isFirefox() && !this.indexDBAvailable && CacheUtilsService.localStorageAvailable) {
43
- localForage.setDriver([localForage.LOCALSTORAGE, localForage.WEBSQL]);
44
- }
45
- else if (isFirefox() && !this.indexDBAvailable && !CacheUtilsService.localStorageAvailable) {
46
- // If indexDB and localStorage aren't available, try WEBSQL as a last resort
47
- localForage.setDriver([localForage.WEBSQL]);
48
- }
49
- this.localForage = localForage;
50
- }
51
- makeKey(namespace, key) {
52
- return `${namespace}-${key}`;
53
- }
54
- set(namespace, key, obj, options) {
55
- if (!obj.lastModifiedDate) {
56
- obj.lastModifiedDate = new Date().toISOString();
57
- }
58
- return this.setWithFullKey(this.makeKey(namespace, key), obj);
59
- }
60
- setWithFullKey(key, obj) {
61
- try {
62
- return this.localForage.setItem(key, obj);
63
- }
64
- catch (e) {
65
- console.warn(`Unable to set ${key} due to: ${e.message}`);
66
- }
67
- }
68
- get(namespace, key) {
69
- return this.getWithFullKey(this.makeKey(namespace, key));
70
- }
71
- getWithFullKey(key) {
72
- try {
73
- return this.localForage.getItem(key);
74
- }
75
- catch (e) {
76
- console.warn(`Unable to get ${key} due to: ${e.message}`);
77
- }
78
- }
79
- delete(namespace, key) {
80
- return this.deleteWithFullKey(this.makeKey(namespace, key));
81
- }
82
- deleteWithFullKey(key) {
83
- try {
84
- return this.localForage.removeItem(key);
85
- }
86
- catch (e) {
87
- console.warn(`Unable to delete ${key} due to: ${e.message}`);
88
- }
89
- }
90
- clear() {
91
- try {
92
- return this.localForage.clear();
93
- }
94
- catch (e) {
95
- console.warn(`Unable to clear all cache: ${e.message}`);
96
- }
97
- }
98
- keys(namespace) {
99
- try {
100
- if (namespace) {
101
- return this.localForage.keys().then((keys) => {
102
- if (keys) {
103
- return filter_1.default(keys, (key) => includes_1.default(key, namespace));
104
- }
105
- else {
106
- return [];
107
- }
108
- });
109
- }
110
- else {
111
- return this.localForage.keys();
112
- }
113
- }
114
- catch (e) {
115
- console.warn(`Unable to get keys from namespace ${namespace} due to: ${e.message}`);
116
- }
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
- }
133
- });
134
- }
135
- }
136
- exports.CacheUtilsService = CacheUtilsService;
137
- CacheUtilsService.localStorageAvailable = true;
@@ -1,40 +0,0 @@
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
- }
22
- export declare function canManageCase(loggedInUserJwtToken: Partial<IPortalJwtToken>): boolean;
23
- export declare function humanizeSize(fileSize: number): string;
24
- export declare function showFtsOnCreateCasePage(slaProcessId: string, severity: string): boolean;
25
- export declare function showFtsOnCaseViewEditPage(slaProcessId: string, severity: string): boolean;
26
- export declare function isFtsEditableOnEditPage(slaProcessId: string, severity: string): boolean;
27
- export declare function autoEnableFtsOnCaseViewEditPage(slaProcessId: string, severity: string): boolean;
28
- export declare function isPremiumEntitlement(slaProcessId: string): boolean;
29
- export declare function isSev1(severity: string): boolean;
30
- export declare function isSev2(severity: string): boolean;
31
- export declare function isOpenShiftOnlineProduct(product: string): boolean;
32
- export declare function isValidCaseNumber(caseNumber: string | undefined): boolean;
33
- export declare function areAllValidCaseNumbers(items: string[]): boolean;
34
- export declare function linkifyLinks(text?: string): string;
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;
40
- //# sourceMappingURL=caseUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"caseUtils.d.ts","sourceRoot":"","sources":["../../src/caseUtils.ts"],"names":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