@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.
- package/lib/cjs/apiUtils.js +10 -24
- package/lib/cjs/appUtils.js +18 -19
- package/lib/cjs/cacheUtils.js +53 -93
- package/lib/cjs/caseUtils.d.ts +24 -0
- package/lib/cjs/caseUtils.d.ts.map +1 -1
- package/lib/cjs/caseUtils.js +141 -15
- package/lib/cjs/csvUtils.js +38 -87
- package/lib/cjs/customElementUtils.js +1 -1
- package/lib/cjs/dateUtils.js +19 -25
- package/lib/cjs/dropdownUtils.js +23 -15
- package/lib/cjs/eventUtils.js +4 -5
- package/lib/cjs/hostNameUtils.js +7 -7
- package/lib/cjs/hydraConfigUtils.js +14 -37
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/insightRuleInfoUtils.js +7 -7
- package/lib/cjs/lruCacheUtils.js +18 -20
- package/lib/cjs/outlier.js +4 -4
- package/lib/cjs/productsUtils.js +41 -77
- package/lib/cjs/promiseUtils.js +9 -44
- package/lib/cjs/recommendationUtils.js +7 -19
- package/lib/cjs/scrollUtils.js +14 -25
- package/lib/cjs/searchApiUtils.js +12 -20
- package/lib/cjs/sentry.d.ts.map +1 -1
- package/lib/cjs/sentry.js +6 -19
- package/lib/cjs/solrUtils.js +81 -108
- package/lib/cjs/tncUtil.d.ts +16 -0
- package/lib/cjs/tncUtil.d.ts.map +1 -0
- package/lib/cjs/tncUtil.js +39 -0
- package/lib/cjs/translation-helper.js +2 -2
- package/lib/cjs/urlUtils.js +25 -38
- package/lib/cjs/userUtils.js +2 -2
- package/lib/cjs/validatorUtils.d.ts.map +1 -1
- package/lib/cjs/validatorUtils.js +9 -7
- package/lib/esm/caseUtils.d.ts +24 -0
- package/lib/esm/caseUtils.d.ts.map +1 -1
- package/lib/esm/caseUtils.js +123 -0
- package/lib/esm/dropdownUtils.js +15 -5
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/productsUtils.js +3 -3
- package/lib/esm/searchApiUtils.js +1 -1
- package/lib/esm/sentry.d.ts.map +1 -1
- package/lib/esm/tncUtil.d.ts +16 -0
- package/lib/esm/tncUtil.d.ts.map +1 -0
- package/lib/esm/tncUtil.js +31 -0
- package/lib/esm/validatorUtils.d.ts.map +1 -1
- package/lib/esm/validatorUtils.js +2 -0
- package/package.json +14 -11
package/lib/cjs/solrUtils.js
CHANGED
|
@@ -1,119 +1,96 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
19
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
20
|
-
to[j] = from[i];
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
4
|
};
|
|
26
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
6
|
exports.parseSolrQuery = exports.buildSolrQuery = exports.solrResponseToPivotFields = exports.solrResponseToFacetFields = exports.solr = void 0;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
7
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
8
|
+
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
9
|
+
const lucene_1 = __importDefault(require("lucene"));
|
|
10
|
+
const solr_query_builder_1 = __importDefault(require("solr-query-builder"));
|
|
32
11
|
function If(cond, v) {
|
|
33
12
|
return !isEmpty_1.default(cond) ? v || cond : '';
|
|
34
13
|
}
|
|
35
|
-
function processFQValue(val,
|
|
36
|
-
var join = _a.join;
|
|
14
|
+
function processFQValue(val, { join }) {
|
|
37
15
|
// val can be one of
|
|
38
16
|
// ['certificatoin', 'ecosystem'] (array)
|
|
39
17
|
// OR 'certification|ecosystem' (stringifiedArray seprated with pipe)
|
|
40
18
|
// OR 'certification' (string)
|
|
41
19
|
// OR '*' (star is a special case)
|
|
42
|
-
|
|
20
|
+
const _val = Array.isArray(val) ? val : val.split('|').length === 1 ? val : val.split('|');
|
|
43
21
|
if (Array.isArray(_val)) {
|
|
44
|
-
return
|
|
22
|
+
return `(${_val.map((v) => `"${v}"`).join(` ${join} `)})`;
|
|
45
23
|
}
|
|
46
24
|
else if (val === '*') {
|
|
47
25
|
return val;
|
|
48
26
|
}
|
|
49
27
|
else {
|
|
50
|
-
return "
|
|
28
|
+
return `"${_val}"`;
|
|
51
29
|
}
|
|
52
30
|
}
|
|
53
31
|
function solr(init) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
fq:
|
|
60
|
-
if (options === void 0) { options = { processValue: { join: 'OR' } }; }
|
|
32
|
+
let query = init || {};
|
|
33
|
+
let beginOr = false;
|
|
34
|
+
let partialOrQuery = [];
|
|
35
|
+
let partialTag = [];
|
|
36
|
+
const solr = {
|
|
37
|
+
fq: (k, v, tag, options = { processValue: { join: 'OR' } }) => {
|
|
61
38
|
if (isEmpty_1.default(v))
|
|
62
39
|
return solr;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
40
|
+
const _fq = query.fq || [];
|
|
41
|
+
const _tag = If(tag, `{!tag=${tag}}`);
|
|
42
|
+
const _v = processFQValue(v, options.processValue);
|
|
43
|
+
const pair = `${k}:${_v}`;
|
|
44
|
+
const newfq = [..._fq, `${_tag}${pair}`];
|
|
68
45
|
if (!beginOr) {
|
|
69
46
|
query = Object.assign({}, query, { fq: newfq });
|
|
70
47
|
}
|
|
71
48
|
else {
|
|
72
49
|
if (tag) {
|
|
73
|
-
partialTag =
|
|
50
|
+
partialTag = [...partialTag, tag];
|
|
74
51
|
}
|
|
75
|
-
partialOrQuery =
|
|
52
|
+
partialOrQuery = [...partialOrQuery, `${pair}`];
|
|
76
53
|
}
|
|
77
54
|
return solr;
|
|
78
55
|
},
|
|
79
|
-
preBuiltfq:
|
|
56
|
+
preBuiltfq: (k, v, tag) => {
|
|
80
57
|
if (isEmpty_1.default(v))
|
|
81
58
|
return solr;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
59
|
+
const _fq = query.fq || [];
|
|
60
|
+
const _tag = If(tag, `{!tag=${tag}}`);
|
|
61
|
+
const newfq = [..._fq, `${_tag}${v}`];
|
|
85
62
|
query = Object.assign({}, query, { fq: newfq });
|
|
86
63
|
return solr;
|
|
87
64
|
},
|
|
88
|
-
facetField:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
65
|
+
facetField: (facet, excludeTags) => {
|
|
66
|
+
const _facetField = query['facet.field'] || [];
|
|
67
|
+
const _excludeTags = If(excludeTags, `{!ex=${excludeTags && excludeTags.join(',')}}`);
|
|
68
|
+
const newFacetField = [..._facetField, `${_excludeTags}${facet}`];
|
|
92
69
|
query = Object.assign({}, query, { 'facet.field': newFacetField });
|
|
93
70
|
return solr;
|
|
94
71
|
},
|
|
95
|
-
pivotField:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
72
|
+
pivotField: (pivot, excludeTags) => {
|
|
73
|
+
const _facetPivot = query['facet.pivot'] || [];
|
|
74
|
+
const _excludeTags = If(excludeTags, `{!ex=${excludeTags && excludeTags.join(',')}}`);
|
|
75
|
+
const newPivotField = [..._facetPivot, `${_excludeTags}${pivot}`];
|
|
99
76
|
query = Object.assign({}, query, { 'facet.pivot': newPivotField });
|
|
100
77
|
return solr;
|
|
101
78
|
},
|
|
102
|
-
value:
|
|
79
|
+
value: () => {
|
|
103
80
|
return query;
|
|
104
81
|
},
|
|
105
|
-
beginOr:
|
|
82
|
+
beginOr: () => {
|
|
106
83
|
beginOr = true;
|
|
107
84
|
partialOrQuery = [];
|
|
108
85
|
partialTag = [];
|
|
109
86
|
return solr;
|
|
110
87
|
},
|
|
111
|
-
endOr:
|
|
88
|
+
endOr: () => {
|
|
112
89
|
beginOr = false;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
90
|
+
const _fq = query.fq || [];
|
|
91
|
+
const _tag = partialTag.length > 0 ? `{!tag=${partialTag}}` : '';
|
|
92
|
+
const orQuery = partialOrQuery.join(' OR ');
|
|
93
|
+
const newFq = [..._fq, `${_tag}${orQuery}`];
|
|
117
94
|
query = Object.assign({}, query, { fq: newFq });
|
|
118
95
|
return solr;
|
|
119
96
|
},
|
|
@@ -128,15 +105,15 @@ exports.solr = solr;
|
|
|
128
105
|
* with key being the facet key and value being of type IFacetResponse
|
|
129
106
|
*/
|
|
130
107
|
function solrResponseToFacetFields(solrResponse) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
Object.keys(solrFacets).forEach(
|
|
134
|
-
|
|
108
|
+
const solrFacets = get_1.default(solrResponse, 'facet_counts.facet_fields', {});
|
|
109
|
+
const facets = {};
|
|
110
|
+
Object.keys(solrFacets).forEach((_facetKey) => {
|
|
111
|
+
const facetKey = _facetKey;
|
|
135
112
|
facets[facetKey] = [];
|
|
136
|
-
for (
|
|
113
|
+
for (let i = 0; i < solrFacets[facetKey].length; i += 2) {
|
|
137
114
|
// take every second element
|
|
138
115
|
// replace non-breakable spaces with space
|
|
139
|
-
|
|
116
|
+
const item = solrFacets[facetKey][i].replace(/\s/g, ' ');
|
|
140
117
|
if (item) {
|
|
141
118
|
facets[facetKey].push({ value: item, count: solrFacets[facetKey][i + 1] });
|
|
142
119
|
}
|
|
@@ -153,12 +130,12 @@ exports.solrResponseToFacetFields = solrResponseToFacetFields;
|
|
|
153
130
|
* value being of type IFacetResponse and also next pivot as the key and its value again of type IFacetResponse.
|
|
154
131
|
*/
|
|
155
132
|
function solrResponseToPivotFields(solrResponse) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
Object.keys(solrPivots).forEach(
|
|
159
|
-
|
|
133
|
+
const solrPivots = get_1.default(solrResponse, 'facet_counts.facet_pivot', {});
|
|
134
|
+
const pivots = {};
|
|
135
|
+
Object.keys(solrPivots).forEach((_pivotKey) => {
|
|
136
|
+
const pivotKey = _pivotKey;
|
|
160
137
|
pivots[pivotKey] = [];
|
|
161
|
-
for (
|
|
138
|
+
for (let i = 0; i < solrPivots[pivotKey].length; i++) {
|
|
162
139
|
pivots[pivotKey].push(createPivotObject(solrPivots[pivotKey][i]));
|
|
163
140
|
}
|
|
164
141
|
});
|
|
@@ -166,17 +143,17 @@ function solrResponseToPivotFields(solrResponse) {
|
|
|
166
143
|
}
|
|
167
144
|
exports.solrResponseToPivotFields = solrResponseToPivotFields;
|
|
168
145
|
function createPivotObject(data) {
|
|
169
|
-
|
|
146
|
+
const valueObj = {
|
|
170
147
|
field: data.field,
|
|
171
148
|
value: data.value,
|
|
172
149
|
count: data.count,
|
|
173
150
|
};
|
|
174
151
|
if (data.pivot && data.pivot.length > 0) {
|
|
175
|
-
|
|
152
|
+
const pivotValuesMap = data.pivot.map((item) => ({
|
|
176
153
|
value: item.value,
|
|
177
154
|
count: item.count,
|
|
178
|
-
})
|
|
179
|
-
|
|
155
|
+
}));
|
|
156
|
+
const pivotKey = data.pivot[0].field;
|
|
180
157
|
valueObj[pivotKey] = pivotValuesMap;
|
|
181
158
|
}
|
|
182
159
|
return valueObj;
|
|
@@ -188,19 +165,18 @@ function createPivotObject(data) {
|
|
|
188
165
|
* string query by ORing the values of same type(for ex. all the version will be ORed) and ANDing the
|
|
189
166
|
* children values with parent values. Uses solr-query-builder library internally
|
|
190
167
|
*/
|
|
191
|
-
function buildSolrQuery(fieldValueMap, wrapWithParentheses) {
|
|
192
|
-
|
|
193
|
-
var solrQuery = new solr_query_builder_1.default();
|
|
168
|
+
function buildSolrQuery(fieldValueMap, wrapWithParentheses = false) {
|
|
169
|
+
let solrQuery = new solr_query_builder_1.default();
|
|
194
170
|
wrapWithParentheses && solrQuery.begin();
|
|
195
|
-
Object.keys(fieldValueMap).forEach(
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
currentItem.forEach(
|
|
171
|
+
Object.keys(fieldValueMap).forEach((key) => {
|
|
172
|
+
const fields = key.split(',');
|
|
173
|
+
const noOfPasses = fields.length;
|
|
174
|
+
const currentItem = fieldValueMap[key] || [];
|
|
175
|
+
currentItem.forEach((item, index, array) => {
|
|
200
176
|
solrQuery = solrQuery.begin().where(item['field']).equals(item['value']);
|
|
201
|
-
|
|
177
|
+
let currentPass = 0;
|
|
202
178
|
currentPass++;
|
|
203
|
-
|
|
179
|
+
const itemForQuery = item[fields[currentPass]];
|
|
204
180
|
if (currentPass === noOfPasses - 1) {
|
|
205
181
|
solrQuery = joinValuesWithOr(solrQuery, itemForQuery);
|
|
206
182
|
}
|
|
@@ -222,8 +198,8 @@ function joinValuesWithOr(currentQuery, values) {
|
|
|
222
198
|
if (values.length < 1) {
|
|
223
199
|
return currentQuery;
|
|
224
200
|
}
|
|
225
|
-
|
|
226
|
-
values.forEach(
|
|
201
|
+
let _currentQuery = currentQuery.begin();
|
|
202
|
+
values.forEach((item, index, array) => {
|
|
227
203
|
_currentQuery = _currentQuery.where(item['field']).equals(item['value']);
|
|
228
204
|
if (index !== array.length - 1) {
|
|
229
205
|
_currentQuery = _currentQuery.or();
|
|
@@ -232,7 +208,7 @@ function joinValuesWithOr(currentQuery, values) {
|
|
|
232
208
|
return _currentQuery.end();
|
|
233
209
|
}
|
|
234
210
|
function makeQueryRecursively(currentQuery, values, currentPass, noOfPasses, fields) {
|
|
235
|
-
values.forEach(
|
|
211
|
+
values.forEach((i, index, array) => {
|
|
236
212
|
currentQuery = currentQuery.begin();
|
|
237
213
|
currentQuery = currentQuery.where(i['field']).equals(i['value']);
|
|
238
214
|
if (currentPass === noOfPasses - 1) {
|
|
@@ -258,11 +234,11 @@ function makeQueryRecursively(currentQuery, values, currentPass, noOfPasses, fie
|
|
|
258
234
|
function parseSolrQuery(query) {
|
|
259
235
|
if (!query)
|
|
260
236
|
return {};
|
|
261
|
-
|
|
237
|
+
const parsedQuery = lucene_1.default.parse(query);
|
|
262
238
|
if (isEmpty_1.default(parsedQuery)) {
|
|
263
239
|
return {};
|
|
264
240
|
}
|
|
265
|
-
|
|
241
|
+
const filterObject = {};
|
|
266
242
|
traverseTree(parsedQuery, filterObject);
|
|
267
243
|
return filterObject;
|
|
268
244
|
}
|
|
@@ -299,12 +275,11 @@ function traverseTree(ast, filterObject) {
|
|
|
299
275
|
}
|
|
300
276
|
}
|
|
301
277
|
function calculateSolrField(node, filterObject) {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
var fieldValues = [];
|
|
278
|
+
const fieldName = node.field;
|
|
279
|
+
const fieldValues = [];
|
|
305
280
|
getValues(node, fieldValues);
|
|
306
281
|
if (filterObject[fieldName]) {
|
|
307
|
-
|
|
282
|
+
filterObject[fieldName].push(...fieldValues);
|
|
308
283
|
}
|
|
309
284
|
else {
|
|
310
285
|
filterObject[fieldName] = fieldValues;
|
|
@@ -314,18 +289,16 @@ function calculateSolrField(node, filterObject) {
|
|
|
314
289
|
// HINT: To make it support more level create new getPivotValues
|
|
315
290
|
// function instead of using getValues
|
|
316
291
|
function calculateSolrPivotField(node, filterObject) {
|
|
317
|
-
var _a;
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
var vals = [];
|
|
292
|
+
var _a, _b;
|
|
293
|
+
const pivot0Field = (_a = node === null || node === void 0 ? void 0 : node.left) === null || _a === void 0 ? void 0 : _a.field;
|
|
294
|
+
const pivot0Value = (_b = node === null || node === void 0 ? void 0 : node.left) === null || _b === void 0 ? void 0 : _b.term;
|
|
295
|
+
const vals = [];
|
|
322
296
|
getValues(node.right, vals);
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
_a);
|
|
297
|
+
const a = {
|
|
298
|
+
field: pivot0Field,
|
|
299
|
+
value: pivot0Value,
|
|
300
|
+
[node.right.left.field]: vals,
|
|
301
|
+
};
|
|
329
302
|
if (filterObject[pivot0Field]) {
|
|
330
303
|
filterObject[pivot0Field].push(a);
|
|
331
304
|
}
|
|
@@ -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
|
-
|
|
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
|
-
|
|
17
|
+
const translatedString = i18next_1.default.t(key, args);
|
|
18
18
|
if (!translatedString) {
|
|
19
19
|
return key;
|
|
20
20
|
}
|
package/lib/cjs/urlUtils.js
CHANGED
|
@@ -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
|
-
|
|
19
|
-
|
|
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
|
-
|
|
23
|
-
return qs_1.default.parse(urlParams,
|
|
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
|
-
|
|
29
|
-
return qs_1.default.stringify(object,
|
|
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
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
60
|
-
|
|
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
|
-
|
|
53
|
+
const getDrupalResIdIfTypeFromUrl = (url, resourceTypes = ['solutions', 'articles']) => {
|
|
65
54
|
var _a;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
61
|
+
const isFieldValueEmpty = function (value) {
|
|
74
62
|
return value === '' || value === undefined || value === null;
|
|
75
63
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
73
|
+
const isValidUrl = (url) => {
|
|
87
74
|
return /^(http(s)?:\/\/)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/.test(url);
|
|
88
75
|
};
|
|
89
76
|
exports.isValidUrl = isValidUrl;
|
package/lib/cjs/userUtils.js
CHANGED
|
@@ -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
|
-
|
|
8
|
-
|
|
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;
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
56
|
+
const versionPartsArray = version.split(' ');
|
|
55
57
|
// find the index that has the version and split it into its pars
|
|
56
|
-
|
|
57
|
-
|
|
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)
|
package/lib/esm/caseUtils.d.ts
CHANGED
|
@@ -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;
|
|
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,kBAAkB;IAC/B,gBAAgB,qBAAqB;IACrC,eAAe,sBAAsB;IACrC,IAAI,SAAS;IACb,mBAAmB,wBAAwB;IAC3C,KAAK,UAAU;CAClB;AAED,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,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEvF;AACD,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE/F;AAED,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAOlE;AAED,wBAAgB,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"}
|