@rh-support/utils 2.4.10-beta.6 → 2.5.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/README.md +0 -2
- package/lib/esm/apiUtils.d.ts +2 -2
- package/lib/esm/apiUtils.d.ts.map +1 -1
- package/lib/esm/apiUtils.js +18 -6
- package/lib/esm/csvUtils.d.ts +2 -2
- package/lib/esm/csvUtils.d.ts.map +1 -1
- package/lib/esm/csvUtils.js +9 -16
- package/lib/esm/dateUtils.d.ts +11 -9
- package/lib/esm/dateUtils.d.ts.map +1 -1
- package/lib/esm/dateUtils.js +96 -11
- package/lib/esm/dropdownUtils.d.ts +1 -1
- package/lib/esm/dropdownUtils.d.ts.map +1 -1
- package/lib/esm/eventUtils.d.ts +14 -2
- package/lib/esm/eventUtils.d.ts.map +1 -1
- package/lib/esm/eventUtils.js +101 -5
- package/lib/esm/hostNameUtils.d.ts.map +1 -1
- package/lib/esm/hydraConfigUtils.d.ts +1 -1
- package/lib/esm/hydraConfigUtils.d.ts.map +1 -1
- package/lib/esm/index.d.ts +0 -2
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +0 -2
- package/lib/esm/outlier.d.ts.map +1 -1
- package/lib/esm/promiseUtils.d.ts.map +1 -1
- package/lib/esm/recommendationUtils.js +2 -2
- package/lib/esm/searchApiUtils.d.ts +2 -2
- package/lib/esm/searchApiUtils.d.ts.map +1 -1
- package/lib/esm/searchApiUtils.js +3 -3
- package/lib/esm/solrUtils.d.ts +4 -4
- package/lib/esm/solrUtils.d.ts.map +1 -1
- package/lib/esm/solrUtils.js +1 -2
- package/lib/esm/translation-helper.d.ts +5 -1
- package/lib/esm/translation-helper.d.ts.map +1 -1
- package/lib/esm/translation-helper.js +1 -1
- package/lib/esm/urlUtils.d.ts +3 -1
- package/lib/esm/urlUtils.d.ts.map +1 -1
- package/lib/esm/urlUtils.js +14 -5
- package/lib/esm/validatorUtils.js +1 -1
- package/package.json +17 -31
- package/lib/cjs/apiUtils.d.ts +0 -17
- package/lib/cjs/apiUtils.d.ts.map +0 -1
- package/lib/cjs/apiUtils.js +0 -52
- package/lib/cjs/appUtils.d.ts +0 -11
- package/lib/cjs/appUtils.d.ts.map +0 -1
- package/lib/cjs/appUtils.js +0 -67
- package/lib/cjs/browserDetectionUtils.d.ts +0 -3
- package/lib/cjs/browserDetectionUtils.d.ts.map +0 -1
- package/lib/cjs/browserDetectionUtils.js +0 -9
- package/lib/cjs/cacheUtils.d.ts +0 -27
- package/lib/cjs/cacheUtils.d.ts.map +0 -1
- package/lib/cjs/cacheUtils.js +0 -137
- package/lib/cjs/caseUtils.d.ts +0 -40
- package/lib/cjs/caseUtils.d.ts.map +0 -1
- package/lib/cjs/caseUtils.js +0 -225
- package/lib/cjs/constants/preferredLanguages.d.ts +0 -33
- package/lib/cjs/constants/preferredLanguages.d.ts.map +0 -1
- package/lib/cjs/constants/preferredLanguages.js +0 -35
- package/lib/cjs/csvUtils.d.ts +0 -24
- package/lib/cjs/csvUtils.d.ts.map +0 -1
- package/lib/cjs/csvUtils.js +0 -109
- package/lib/cjs/customElementUtils.d.ts +0 -20
- package/lib/cjs/customElementUtils.d.ts.map +0 -1
- package/lib/cjs/customElementUtils.js +0 -23
- package/lib/cjs/dateUtils.d.ts +0 -16
- package/lib/cjs/dateUtils.d.ts.map +0 -1
- package/lib/cjs/dateUtils.js +0 -78
- package/lib/cjs/dropdownUtils.d.ts +0 -18
- package/lib/cjs/dropdownUtils.d.ts.map +0 -1
- package/lib/cjs/dropdownUtils.js +0 -59
- package/lib/cjs/eventUtils.d.ts +0 -9
- package/lib/cjs/eventUtils.d.ts.map +0 -1
- package/lib/cjs/eventUtils.js +0 -32
- package/lib/cjs/hostNameUtils.d.ts +0 -7
- package/lib/cjs/hostNameUtils.d.ts.map +0 -1
- package/lib/cjs/hostNameUtils.js +0 -35
- package/lib/cjs/hydraConfigUtils.d.ts +0 -14
- package/lib/cjs/hydraConfigUtils.d.ts.map +0 -1
- package/lib/cjs/hydraConfigUtils.js +0 -83
- package/lib/cjs/index.d.ts +0 -30
- package/lib/cjs/index.d.ts.map +0 -1
- package/lib/cjs/index.js +0 -41
- package/lib/cjs/insightRuleInfoUtils.d.ts +0 -4
- package/lib/cjs/insightRuleInfoUtils.d.ts.map +0 -1
- package/lib/cjs/insightRuleInfoUtils.js +0 -31
- package/lib/cjs/lruCacheUtils.d.ts +0 -13
- package/lib/cjs/lruCacheUtils.d.ts.map +0 -1
- package/lib/cjs/lruCacheUtils.js +0 -45
- package/lib/cjs/outlier.d.ts +0 -16
- package/lib/cjs/outlier.d.ts.map +0 -1
- package/lib/cjs/outlier.js +0 -48
- package/lib/cjs/productsUtils.d.ts +0 -33
- package/lib/cjs/productsUtils.d.ts.map +0 -1
- package/lib/cjs/productsUtils.js +0 -138
- package/lib/cjs/promiseUtils.d.ts +0 -8
- package/lib/cjs/promiseUtils.d.ts.map +0 -1
- package/lib/cjs/promiseUtils.js +0 -23
- package/lib/cjs/recommendationUtils.d.ts +0 -14
- package/lib/cjs/recommendationUtils.d.ts.map +0 -1
- package/lib/cjs/recommendationUtils.js +0 -61
- package/lib/cjs/scrollUtils.d.ts +0 -11
- package/lib/cjs/scrollUtils.d.ts.map +0 -1
- package/lib/cjs/scrollUtils.js +0 -74
- package/lib/cjs/searchApiUtils.d.ts +0 -44
- package/lib/cjs/searchApiUtils.d.ts.map +0 -1
- package/lib/cjs/searchApiUtils.js +0 -48
- package/lib/cjs/sentry.d.ts +0 -14
- package/lib/cjs/sentry.d.ts.map +0 -1
- package/lib/cjs/sentry.js +0 -40
- package/lib/cjs/solrUtils.d.ts +0 -74
- package/lib/cjs/solrUtils.d.ts.map +0 -1
- package/lib/cjs/solrUtils.js +0 -322
- package/lib/cjs/styleUtils.d.ts +0 -12
- package/lib/cjs/styleUtils.d.ts.map +0 -1
- package/lib/cjs/styleUtils.js +0 -34
- package/lib/cjs/tncUtil.d.ts +0 -16
- package/lib/cjs/tncUtil.d.ts.map +0 -1
- package/lib/cjs/tncUtil.js +0 -39
- package/lib/cjs/translation-helper.d.ts +0 -10
- package/lib/cjs/translation-helper.d.ts.map +0 -1
- package/lib/cjs/translation-helper.js +0 -23
- package/lib/cjs/urlUtils.d.ts +0 -19
- package/lib/cjs/urlUtils.d.ts.map +0 -1
- package/lib/cjs/urlUtils.js +0 -76
- package/lib/cjs/userUtils.d.ts +0 -3
- package/lib/cjs/userUtils.d.ts.map +0 -1
- package/lib/cjs/userUtils.js +0 -11
- package/lib/cjs/validatorUtils.d.ts +0 -11
- package/lib/cjs/validatorUtils.d.ts.map +0 -1
- package/lib/cjs/validatorUtils.js +0 -76
- package/lib/esm/customElementUtils.d.ts +0 -20
- package/lib/esm/customElementUtils.d.ts.map +0 -1
- package/lib/esm/customElementUtils.js +0 -19
- package/lib/esm/insightRuleInfoUtils.d.ts +0 -4
- package/lib/esm/insightRuleInfoUtils.d.ts.map +0 -1
- package/lib/esm/insightRuleInfoUtils.js +0 -23
package/lib/cjs/caseUtils.js
DELETED
|
@@ -1,225 +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.toOldCaseTypeSwitcher = exports.toOldCaseTypeMapper = exports.toNewCaseTypeSwitcher = exports.toNewCaseTypeMapper = exports.severitySort = exports.linkifyLinks = exports.areAllValidCaseNumbers = exports.isValidCaseNumber = exports.isOpenShiftOnlineProduct = exports.isSev2 = exports.isSev1 = exports.isPremiumEntitlement = exports.autoEnableFtsOnCaseViewEditPage = exports.isFtsEditableOnEditPage = exports.showFtsOnCaseViewEditPage = exports.showFtsOnCreateCasePage = exports.humanizeSize = exports.canManageCase = exports.NewCaseTypes = exports.PreviousCaseTypes = void 0;
|
|
7
|
-
const find_1 = __importDefault(require("lodash/find"));
|
|
8
|
-
const includes_1 = __importDefault(require("lodash/includes"));
|
|
9
|
-
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
10
|
-
// Old Case Types
|
|
11
|
-
var PreviousCaseTypes;
|
|
12
|
-
(function (PreviousCaseTypes) {
|
|
13
|
-
PreviousCaseTypes["DEFECT_BUG"] = "Defect / Bug";
|
|
14
|
-
PreviousCaseTypes["CERTIFICATION"] = "Certification";
|
|
15
|
-
PreviousCaseTypes["CONFIGURATION_ISSUE"] = "Configuration Issue";
|
|
16
|
-
PreviousCaseTypes["ACCOUNT_CUSTOMERSERVICE_REQUEST"] = "Account / Customer Service Request";
|
|
17
|
-
PreviousCaseTypes["USAGE_DOCUMENTATION_HELP"] = "Usage / Documentation Help";
|
|
18
|
-
PreviousCaseTypes["FEATURE_ENHANCEMENT"] = "Feature / Enhancement Request";
|
|
19
|
-
PreviousCaseTypes["RCA_ONLY"] = "RCA Only";
|
|
20
|
-
PreviousCaseTypes["OTHER"] = "Other";
|
|
21
|
-
})(PreviousCaseTypes = exports.PreviousCaseTypes || (exports.PreviousCaseTypes = {}));
|
|
22
|
-
// New Case Types
|
|
23
|
-
var NewCaseTypes;
|
|
24
|
-
(function (NewCaseTypes) {
|
|
25
|
-
NewCaseTypes["BUG_DEFECT"] = "Bug or defect";
|
|
26
|
-
NewCaseTypes["CERTIFICATION"] = "Certification";
|
|
27
|
-
NewCaseTypes["CONFIGURATION"] = "Configuration";
|
|
28
|
-
NewCaseTypes["CUSTOMER_SERVICE"] = "Customer service";
|
|
29
|
-
NewCaseTypes["USAGE_DOCS_HELP"] = "Usage & Docs help";
|
|
30
|
-
NewCaseTypes["IDEA"] = "Idea";
|
|
31
|
-
NewCaseTypes["ROOT_CAUSE_ANALYSIS"] = "Root cause analysis";
|
|
32
|
-
NewCaseTypes["OTHER"] = "Other";
|
|
33
|
-
})(NewCaseTypes = exports.NewCaseTypes || (exports.NewCaseTypes = {}));
|
|
34
|
-
function canManageCase(loggedInUserJwtToken) {
|
|
35
|
-
if (!loggedInUserJwtToken || !loggedInUserJwtToken.realm_access) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
return includes_1.default(loggedInUserJwtToken.realm_access.roles, 'portal_manage_cases');
|
|
39
|
-
}
|
|
40
|
-
exports.canManageCase = canManageCase;
|
|
41
|
-
function humanizeSize(fileSize) {
|
|
42
|
-
let i = -1;
|
|
43
|
-
let size = fileSize;
|
|
44
|
-
const byteUnits = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
45
|
-
do {
|
|
46
|
-
size = size / 1024;
|
|
47
|
-
i++;
|
|
48
|
-
} while (size >= 1024 && byteUnits[i + 1]);
|
|
49
|
-
return `${Math.max(size, 0.1).toFixed(1)} ${byteUnits[i]}`;
|
|
50
|
-
}
|
|
51
|
-
exports.humanizeSize = humanizeSize;
|
|
52
|
-
function showFtsOnCreateCasePage(slaProcessId, severity) {
|
|
53
|
-
return isPremiumEntitlement(slaProcessId) && isSev1(severity);
|
|
54
|
-
}
|
|
55
|
-
exports.showFtsOnCreateCasePage = showFtsOnCreateCasePage;
|
|
56
|
-
function showFtsOnCaseViewEditPage(slaProcessId, severity) {
|
|
57
|
-
return isPremiumEntitlement(slaProcessId) && (isSev1(severity) || isSev2(severity));
|
|
58
|
-
}
|
|
59
|
-
exports.showFtsOnCaseViewEditPage = showFtsOnCaseViewEditPage;
|
|
60
|
-
function isFtsEditableOnEditPage(slaProcessId, severity) {
|
|
61
|
-
return isPremiumEntitlement(slaProcessId) && isSev1(severity);
|
|
62
|
-
}
|
|
63
|
-
exports.isFtsEditableOnEditPage = isFtsEditableOnEditPage;
|
|
64
|
-
function autoEnableFtsOnCaseViewEditPage(slaProcessId, severity) {
|
|
65
|
-
return isPremiumEntitlement(slaProcessId) && isSev1(severity);
|
|
66
|
-
}
|
|
67
|
-
exports.autoEnableFtsOnCaseViewEditPage = autoEnableFtsOnCaseViewEditPage;
|
|
68
|
-
function isPremiumEntitlement(slaProcessId) {
|
|
69
|
-
return (slaProcessId === 'PREMIUM' ||
|
|
70
|
-
slaProcessId === 'AMC' ||
|
|
71
|
-
slaProcessId === 'PREMIUMPLUS' ||
|
|
72
|
-
slaProcessId === 'PREMIUM PLUS');
|
|
73
|
-
}
|
|
74
|
-
exports.isPremiumEntitlement = isPremiumEntitlement;
|
|
75
|
-
function isSev1(severity) {
|
|
76
|
-
return !!(severity && severity.charAt(0) === '1');
|
|
77
|
-
}
|
|
78
|
-
exports.isSev1 = isSev1;
|
|
79
|
-
function isSev2(severity) {
|
|
80
|
-
return !!(severity && severity.charAt(0) === '2');
|
|
81
|
-
}
|
|
82
|
-
exports.isSev2 = isSev2;
|
|
83
|
-
function isOpenShiftOnlineProduct(product) {
|
|
84
|
-
return product === 'Openshift Online';
|
|
85
|
-
}
|
|
86
|
-
exports.isOpenShiftOnlineProduct = isOpenShiftOnlineProduct;
|
|
87
|
-
function isValidCaseNumber(caseNumber) {
|
|
88
|
-
// eslint-disable-next-line no-useless-escape
|
|
89
|
-
const validCaseNumberFormat = /^\d{8}$/;
|
|
90
|
-
if (caseNumber && caseNumber.trim().match(validCaseNumberFormat)) {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
exports.isValidCaseNumber = isValidCaseNumber;
|
|
98
|
-
function areAllValidCaseNumbers(items) {
|
|
99
|
-
return isEmpty_1.default(find_1.default(items, (item) => !isValidCaseNumber(item.trim())));
|
|
100
|
-
}
|
|
101
|
-
exports.areAllValidCaseNumbers = areAllValidCaseNumbers;
|
|
102
|
-
function linkifyLinks(text = '') {
|
|
103
|
-
const replacePattern1 = /(\b(https:)\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/gim;
|
|
104
|
-
function getUrl(match) {
|
|
105
|
-
const openInNewTab = !match.includes('showModal=');
|
|
106
|
-
return `<a href="${match}"${openInNewTab ? ' target="_blank" rel="noopener noreferrer"' : ''}>${match}</a>`;
|
|
107
|
-
}
|
|
108
|
-
return text ? text.replace(replacePattern1, getUrl) : '';
|
|
109
|
-
}
|
|
110
|
-
exports.linkifyLinks = linkifyLinks;
|
|
111
|
-
// To sort severity values
|
|
112
|
-
function severitySort(sevA, sevB) {
|
|
113
|
-
if (sevA.split(' ')[0] > sevB.split(' ')[0]) {
|
|
114
|
-
return -1;
|
|
115
|
-
}
|
|
116
|
-
if (sevA.split(' ')[0] < sevB.split(' ')[0]) {
|
|
117
|
-
return 1;
|
|
118
|
-
}
|
|
119
|
-
if (sevA.split(' ')[0] === sevB.split(' ')[0]) {
|
|
120
|
-
return 0;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.severitySort = severitySort;
|
|
124
|
-
// To convert array of old case types to new support types
|
|
125
|
-
function toNewCaseTypeMapper(allCaseTypes) {
|
|
126
|
-
let newCaseTypeArray = allCaseTypes === null || allCaseTypes === void 0 ? void 0 : allCaseTypes.map((value) => {
|
|
127
|
-
switch (value) {
|
|
128
|
-
case PreviousCaseTypes.DEFECT_BUG:
|
|
129
|
-
return NewCaseTypes.BUG_DEFECT;
|
|
130
|
-
case PreviousCaseTypes.CERTIFICATION:
|
|
131
|
-
return NewCaseTypes.CERTIFICATION;
|
|
132
|
-
case PreviousCaseTypes.CONFIGURATION_ISSUE:
|
|
133
|
-
return NewCaseTypes.CONFIGURATION;
|
|
134
|
-
case PreviousCaseTypes.ACCOUNT_CUSTOMERSERVICE_REQUEST:
|
|
135
|
-
return NewCaseTypes.CUSTOMER_SERVICE;
|
|
136
|
-
case PreviousCaseTypes.USAGE_DOCUMENTATION_HELP:
|
|
137
|
-
return NewCaseTypes.USAGE_DOCS_HELP;
|
|
138
|
-
case PreviousCaseTypes.FEATURE_ENHANCEMENT:
|
|
139
|
-
return NewCaseTypes.IDEA;
|
|
140
|
-
case PreviousCaseTypes.RCA_ONLY:
|
|
141
|
-
return NewCaseTypes.ROOT_CAUSE_ANALYSIS;
|
|
142
|
-
case PreviousCaseTypes.OTHER:
|
|
143
|
-
return NewCaseTypes.OTHER;
|
|
144
|
-
default:
|
|
145
|
-
return value;
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
return newCaseTypeArray;
|
|
149
|
-
}
|
|
150
|
-
exports.toNewCaseTypeMapper = toNewCaseTypeMapper;
|
|
151
|
-
// To convert old case type to new support type
|
|
152
|
-
function toNewCaseTypeSwitcher(caseType) {
|
|
153
|
-
switch (caseType) {
|
|
154
|
-
case PreviousCaseTypes.DEFECT_BUG:
|
|
155
|
-
return NewCaseTypes.BUG_DEFECT;
|
|
156
|
-
case PreviousCaseTypes.CERTIFICATION:
|
|
157
|
-
return NewCaseTypes.CERTIFICATION;
|
|
158
|
-
case PreviousCaseTypes.CONFIGURATION_ISSUE:
|
|
159
|
-
return NewCaseTypes.CONFIGURATION;
|
|
160
|
-
case PreviousCaseTypes.ACCOUNT_CUSTOMERSERVICE_REQUEST:
|
|
161
|
-
return NewCaseTypes.CUSTOMER_SERVICE;
|
|
162
|
-
case PreviousCaseTypes.USAGE_DOCUMENTATION_HELP:
|
|
163
|
-
return NewCaseTypes.USAGE_DOCS_HELP;
|
|
164
|
-
case PreviousCaseTypes.FEATURE_ENHANCEMENT:
|
|
165
|
-
return NewCaseTypes.IDEA;
|
|
166
|
-
case PreviousCaseTypes.RCA_ONLY:
|
|
167
|
-
return NewCaseTypes.ROOT_CAUSE_ANALYSIS;
|
|
168
|
-
case PreviousCaseTypes.OTHER:
|
|
169
|
-
return NewCaseTypes.OTHER;
|
|
170
|
-
default:
|
|
171
|
-
return caseType;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
exports.toNewCaseTypeSwitcher = toNewCaseTypeSwitcher;
|
|
175
|
-
// To convert array of new support types to old case types
|
|
176
|
-
function toOldCaseTypeMapper(allCaseTypes) {
|
|
177
|
-
let oldCaseTypeArray = allCaseTypes === null || allCaseTypes === void 0 ? void 0 : allCaseTypes.map((value) => {
|
|
178
|
-
switch (value) {
|
|
179
|
-
case NewCaseTypes.BUG_DEFECT:
|
|
180
|
-
return PreviousCaseTypes.DEFECT_BUG;
|
|
181
|
-
case NewCaseTypes.CERTIFICATION:
|
|
182
|
-
return PreviousCaseTypes.CERTIFICATION;
|
|
183
|
-
case NewCaseTypes.CONFIGURATION:
|
|
184
|
-
return PreviousCaseTypes.CONFIGURATION_ISSUE;
|
|
185
|
-
case NewCaseTypes.CUSTOMER_SERVICE:
|
|
186
|
-
return PreviousCaseTypes.ACCOUNT_CUSTOMERSERVICE_REQUEST;
|
|
187
|
-
case NewCaseTypes.USAGE_DOCS_HELP:
|
|
188
|
-
return PreviousCaseTypes.USAGE_DOCUMENTATION_HELP;
|
|
189
|
-
case NewCaseTypes.IDEA:
|
|
190
|
-
return PreviousCaseTypes.FEATURE_ENHANCEMENT;
|
|
191
|
-
case NewCaseTypes.ROOT_CAUSE_ANALYSIS:
|
|
192
|
-
return PreviousCaseTypes.RCA_ONLY;
|
|
193
|
-
case NewCaseTypes.OTHER:
|
|
194
|
-
return PreviousCaseTypes.OTHER;
|
|
195
|
-
default:
|
|
196
|
-
return value;
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
return oldCaseTypeArray;
|
|
200
|
-
}
|
|
201
|
-
exports.toOldCaseTypeMapper = toOldCaseTypeMapper;
|
|
202
|
-
// To convert new support type to old case type
|
|
203
|
-
function toOldCaseTypeSwitcher(caseType) {
|
|
204
|
-
switch (caseType) {
|
|
205
|
-
case NewCaseTypes.BUG_DEFECT:
|
|
206
|
-
return PreviousCaseTypes.DEFECT_BUG;
|
|
207
|
-
case NewCaseTypes.CERTIFICATION:
|
|
208
|
-
return PreviousCaseTypes.CERTIFICATION;
|
|
209
|
-
case NewCaseTypes.CONFIGURATION:
|
|
210
|
-
return PreviousCaseTypes.CONFIGURATION_ISSUE;
|
|
211
|
-
case NewCaseTypes.CUSTOMER_SERVICE:
|
|
212
|
-
return PreviousCaseTypes.ACCOUNT_CUSTOMERSERVICE_REQUEST;
|
|
213
|
-
case NewCaseTypes.USAGE_DOCS_HELP:
|
|
214
|
-
return PreviousCaseTypes.USAGE_DOCUMENTATION_HELP;
|
|
215
|
-
case NewCaseTypes.IDEA:
|
|
216
|
-
return PreviousCaseTypes.FEATURE_ENHANCEMENT;
|
|
217
|
-
case NewCaseTypes.ROOT_CAUSE_ANALYSIS:
|
|
218
|
-
return PreviousCaseTypes.RCA_ONLY;
|
|
219
|
-
case NewCaseTypes.OTHER:
|
|
220
|
-
return PreviousCaseTypes.OTHER;
|
|
221
|
-
default:
|
|
222
|
-
return caseType;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
exports.toOldCaseTypeSwitcher = toOldCaseTypeSwitcher;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export declare const PreferredLanguages: {
|
|
2
|
-
languagesMap: {
|
|
3
|
-
en: string;
|
|
4
|
-
en_US: string;
|
|
5
|
-
ja: string;
|
|
6
|
-
zh_CN: string;
|
|
7
|
-
zh: string;
|
|
8
|
-
zh_HK: string;
|
|
9
|
-
zh_TW: string;
|
|
10
|
-
de: string;
|
|
11
|
-
es: string;
|
|
12
|
-
pt: string;
|
|
13
|
-
fr: string;
|
|
14
|
-
ko: string;
|
|
15
|
-
it: string;
|
|
16
|
-
ru: string;
|
|
17
|
-
gu: string;
|
|
18
|
-
or: string;
|
|
19
|
-
hi: string;
|
|
20
|
-
he: string;
|
|
21
|
-
mr: string;
|
|
22
|
-
te: string;
|
|
23
|
-
bn: string;
|
|
24
|
-
ml: string;
|
|
25
|
-
as: string;
|
|
26
|
-
pa: string;
|
|
27
|
-
ta: string;
|
|
28
|
-
kn: string;
|
|
29
|
-
si: string;
|
|
30
|
-
ar: string;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=preferredLanguages.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preferredLanguages.d.ts","sourceRoot":"","sources":["../../../src/constants/preferredLanguages.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+B9B,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PreferredLanguages = void 0;
|
|
4
|
-
exports.PreferredLanguages = {
|
|
5
|
-
languagesMap: {
|
|
6
|
-
en: 'English',
|
|
7
|
-
en_US: 'English',
|
|
8
|
-
ja: '日本語',
|
|
9
|
-
zh_CN: '中文 (中国)',
|
|
10
|
-
zh: '中文 (中国)',
|
|
11
|
-
zh_HK: 'Chinese (Hong Kong)',
|
|
12
|
-
zh_TW: 'Chinese (T)',
|
|
13
|
-
de: 'Deutsch',
|
|
14
|
-
es: 'Español',
|
|
15
|
-
pt: 'Português',
|
|
16
|
-
fr: 'Français',
|
|
17
|
-
ko: '한국어',
|
|
18
|
-
it: 'Italiano',
|
|
19
|
-
ru: 'Pу́сский',
|
|
20
|
-
gu: 'ગુજરાતી',
|
|
21
|
-
or: 'ଓଡ଼ିଆ',
|
|
22
|
-
hi: 'हिंदी',
|
|
23
|
-
he: 'Hebrew',
|
|
24
|
-
mr: 'मराठी',
|
|
25
|
-
te: 'తెలుగు',
|
|
26
|
-
bn: 'বাঙ্গালী',
|
|
27
|
-
ml: 'മലയാളം',
|
|
28
|
-
as: 'অসমীয়া',
|
|
29
|
-
pa: 'ਪੰਜਾਬੀ',
|
|
30
|
-
ta: 'தமிழ்',
|
|
31
|
-
kn: 'ಕನ್ನಡ',
|
|
32
|
-
si: 'සිංහල',
|
|
33
|
-
ar: 'العربية',
|
|
34
|
-
},
|
|
35
|
-
};
|
package/lib/cjs/csvUtils.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export interface ICSVHeader {
|
|
2
|
-
label: string;
|
|
3
|
-
key: string;
|
|
4
|
-
transform?: (data: any) => string | number;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Simple safari detection based on user agent test
|
|
8
|
-
*/
|
|
9
|
-
export declare const isSafari: () => boolean;
|
|
10
|
-
export declare const escapeDoubleQuotes: (data: any) => any;
|
|
11
|
-
export declare const isJsons: (array: any) => boolean;
|
|
12
|
-
export declare const isArrays: (array: any) => boolean;
|
|
13
|
-
export declare const jsonsHeaders: (array: any) => unknown[];
|
|
14
|
-
export declare const jsons2arrays: (jsons: any, headers: any) => any[];
|
|
15
|
-
export declare const getHeaderValue: (property: any, obj: any, transformFn?: (data: any) => any) => any;
|
|
16
|
-
export declare const elementOrEmpty: (element: any) => any;
|
|
17
|
-
export declare const joiner: (data: any, separator?: string, enclosingCharacter?: string) => any;
|
|
18
|
-
export declare const arrays2csv: (data: any[][], headers: any, separator: any, enclosingCharacter: any) => any;
|
|
19
|
-
export declare const jsons2csv: (data: any[], headers: any, separator: any, enclosingCharacter: any) => any;
|
|
20
|
-
export declare const string2csv: (data: string, headers: any, separator?: string, enclosingCharacter?: string) => string;
|
|
21
|
-
export declare const toCSV: (data: string | any[] | any[][], headers: any, separator?: string, enclosingCharacter?: string) => any;
|
|
22
|
-
export declare const buildURI: (data: string | any[] | any[][], headers: any, uFEFF?: boolean, separator?: string, enclosingCharacter?: string) => string;
|
|
23
|
-
export declare const downloadCSV: (data: string | any[] | any[][], headers: ICSVHeader[], fileName?: string, uFEFF?: boolean, separator?: string, enclosingCharacter?: string) => void;
|
|
24
|
-
//# sourceMappingURL=csvUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"csvUtils.d.ts","sourceRoot":"","sources":["../../src/csvUtils.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,UAAU;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,CAAC,IAAI,KAAA,KAAK,MAAM,GAAG,MAAM,CAAC;CACzC;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,eAAmE,CAAC;AAEzF,eAAO,MAAM,kBAAkB,oBAAiF,CAAC;AAGjH,eAAO,MAAM,OAAO,yBACgF,CAAC;AAErG,eAAO,MAAM,QAAQ,yBAA8E,CAAC;AAEpG,eAAO,MAAM,YAAY,2BACyE,CAAC;AAEnG,eAAO,MAAM,YAAY,qCAexB,CAAC;AAEF,eAAO,MAAM,cAAc,oEAkB1B,CAAC;AAEF,eAAO,MAAM,cAAc,uBAAyD,CAAC;AAErF,eAAO,MAAM,MAAM,qEAUlB,CAAC;AAEF,eAAO,MAAM,UAAU,SAAU,GAAG,EAAE,EAAE,+DACsC,CAAC;AAE/E,eAAO,MAAM,SAAS,SAAU,GAAG,EAAE,+DACiC,CAAC;AAEvE,eAAO,MAAM,UAAU,SAAU,MAAM,0EACmB,CAAC;AAE3D,eAAO,MAAM,KAAK,SAAU,MAAM,GAAG,GAAG,EAAE,GAAG,GAAG,EAAE,EAAE,uEAKnD,CAAC;AAEF,eAAO,MAAM,QAAQ,SACX,MAAM,GAAG,GAAG,EAAE,GAAG,GAAG,EAAE,EAAE,2FAcjC,CAAC;AAEF,eAAO,MAAM,WAAW,SACd,MAAM,GAAG,GAAG,EAAE,GAAG,GAAG,EAAE,EAAE,WACrB,UAAU,EAAE,8FAoBxB,CAAC"}
|
package/lib/cjs/csvUtils.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Most of it is copied from https://github.com/react-csv/react-csv/blob/master/src/core.js
|
|
3
|
-
// except we add the transform a column functionality and also we escape the double quotes
|
|
4
|
-
// for every value so that we dont break the csv
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.downloadCSV = exports.buildURI = exports.toCSV = exports.string2csv = exports.jsons2csv = exports.arrays2csv = exports.joiner = exports.elementOrEmpty = exports.getHeaderValue = exports.jsons2arrays = exports.jsonsHeaders = exports.isArrays = exports.isJsons = exports.escapeDoubleQuotes = exports.isSafari = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Simple safari detection based on user agent test
|
|
9
|
-
*/
|
|
10
|
-
const isSafari = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
11
|
-
exports.isSafari = isSafari;
|
|
12
|
-
const escapeDoubleQuotes = (data) => (data && typeof data === 'string' ? data.replace(/"/g, '""') : data);
|
|
13
|
-
exports.escapeDoubleQuotes = escapeDoubleQuotes;
|
|
14
|
-
const defaultTransformFn = (data) => data;
|
|
15
|
-
const isJsons = (array) => Array.isArray(array) && array.every((row) => typeof row === 'object' && !(row instanceof Array));
|
|
16
|
-
exports.isJsons = isJsons;
|
|
17
|
-
const isArrays = (array) => Array.isArray(array) && array.every((row) => Array.isArray(row));
|
|
18
|
-
exports.isArrays = isArrays;
|
|
19
|
-
const jsonsHeaders = (array) => Array.from(array.map((json) => Object.keys(json)).reduce((a, b) => new Set([...a, ...b]), []));
|
|
20
|
-
exports.jsonsHeaders = jsonsHeaders;
|
|
21
|
-
const jsons2arrays = (jsons, headers) => {
|
|
22
|
-
headers = headers || exports.jsonsHeaders(jsons);
|
|
23
|
-
// allow headers to have custom labels, defaulting to having the header data key be the label
|
|
24
|
-
let headerLabels = headers;
|
|
25
|
-
let headerKeys = headers;
|
|
26
|
-
if (exports.isJsons(headers)) {
|
|
27
|
-
headerLabels = headers.map((header) => header.label);
|
|
28
|
-
headerKeys = headers.map((header) => ({ key: header['key'], transformFn: header['transform'] }));
|
|
29
|
-
}
|
|
30
|
-
const data = jsons.map((object) => headerKeys.map((header) => exports.getHeaderValue(header.key, object, header.transformFn)));
|
|
31
|
-
return [headerLabels, ...data];
|
|
32
|
-
};
|
|
33
|
-
exports.jsons2arrays = jsons2arrays;
|
|
34
|
-
const getHeaderValue = (property, obj, transformFn = defaultTransformFn) => {
|
|
35
|
-
const foundValue = property
|
|
36
|
-
.replace(/\[([^\]]+)]/g, '.$1')
|
|
37
|
-
.split('.')
|
|
38
|
-
.reduce(function (o, p, i, arr) {
|
|
39
|
-
// if at any point the nested keys passed do not exist, splice the array so it doesnt keep reducing
|
|
40
|
-
if (o[p] === undefined) {
|
|
41
|
-
arr.splice(1);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
return exports.escapeDoubleQuotes(o[p]);
|
|
45
|
-
}
|
|
46
|
-
}, obj);
|
|
47
|
-
// if at any point the nested keys passed do not exist then looks for key `property` in object obj
|
|
48
|
-
return foundValue === undefined
|
|
49
|
-
? property in obj
|
|
50
|
-
? exports.escapeDoubleQuotes(obj[property])
|
|
51
|
-
: ''
|
|
52
|
-
: transformFn(foundValue);
|
|
53
|
-
};
|
|
54
|
-
exports.getHeaderValue = getHeaderValue;
|
|
55
|
-
const elementOrEmpty = (element) => (element || element === 0 ? element : '');
|
|
56
|
-
exports.elementOrEmpty = elementOrEmpty;
|
|
57
|
-
const joiner = (data, separator = ',', enclosingCharacter = '"') => {
|
|
58
|
-
return data
|
|
59
|
-
.filter((e) => e)
|
|
60
|
-
.map((row) => row
|
|
61
|
-
.map((element) => exports.elementOrEmpty(element))
|
|
62
|
-
.map((column) => `${enclosingCharacter}${column}${enclosingCharacter}`)
|
|
63
|
-
.join(separator))
|
|
64
|
-
.join(`\n`);
|
|
65
|
-
};
|
|
66
|
-
exports.joiner = joiner;
|
|
67
|
-
const arrays2csv = (data, headers, separator, enclosingCharacter) => exports.joiner(headers ? [headers, ...data] : data, separator, enclosingCharacter);
|
|
68
|
-
exports.arrays2csv = arrays2csv;
|
|
69
|
-
const jsons2csv = (data, headers, separator, enclosingCharacter) => exports.joiner(exports.jsons2arrays(data, headers), separator, enclosingCharacter);
|
|
70
|
-
exports.jsons2csv = jsons2csv;
|
|
71
|
-
const string2csv = (data, headers, separator = ',', enclosingCharacter = '"') => headers ? `${headers.join(separator)}\n${data}` : data;
|
|
72
|
-
exports.string2csv = string2csv;
|
|
73
|
-
const toCSV = (data, headers, separator = ',', enclosingCharacter = '"') => {
|
|
74
|
-
if (exports.isJsons(data))
|
|
75
|
-
return exports.jsons2csv(data, headers, separator, enclosingCharacter);
|
|
76
|
-
if (exports.isArrays(data))
|
|
77
|
-
return exports.arrays2csv(data, headers, separator, enclosingCharacter);
|
|
78
|
-
if (typeof data === 'string')
|
|
79
|
-
return exports.string2csv(data, headers, separator);
|
|
80
|
-
throw new TypeError(`Data should be a "String", "Array of arrays" OR "Array of objects" `);
|
|
81
|
-
};
|
|
82
|
-
exports.toCSV = toCSV;
|
|
83
|
-
const buildURI = (data, headers, uFEFF = true, separator = ',', enclosingCharacter = '"') => {
|
|
84
|
-
const csv = exports.toCSV(data, headers, separator, enclosingCharacter);
|
|
85
|
-
const type = exports.isSafari() ? 'application/csv' : 'text/csv';
|
|
86
|
-
const blob = new Blob([uFEFF ? '\uFEFF' : '', csv], { type });
|
|
87
|
-
const dataURI = `data:${type};charset=utf-8,${uFEFF ? '\uFEFF' : ''}${csv}`;
|
|
88
|
-
const URL = window.URL || window.webkitURL;
|
|
89
|
-
return typeof URL.createObjectURL === 'undefined' ? dataURI : URL.createObjectURL(blob);
|
|
90
|
-
};
|
|
91
|
-
exports.buildURI = buildURI;
|
|
92
|
-
const downloadCSV = (data, headers, fileName = 'csvGenerator', uFEFF = true, separator = ',', enclosingCharacter = '"') => {
|
|
93
|
-
// If this browser is IE 11, it does not support the `download` attribute
|
|
94
|
-
if (window.navigator.msSaveOrOpenBlob) {
|
|
95
|
-
let blob = new Blob([uFEFF ? '\uFEFF' : '', exports.toCSV(data, headers, separator, enclosingCharacter)]);
|
|
96
|
-
window.navigator.msSaveBlob(blob, fileName);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
const uri = exports.buildURI(data, headers);
|
|
100
|
-
const element = document.createElement('a');
|
|
101
|
-
element.setAttribute('href', uri);
|
|
102
|
-
element.setAttribute('target', '_self');
|
|
103
|
-
element.setAttribute('download', fileName);
|
|
104
|
-
document.body.appendChild(element);
|
|
105
|
-
element.click();
|
|
106
|
-
document.body.removeChild(element);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
exports.downloadCSV = downloadCSV;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare enum CustomElements {
|
|
2
|
-
pfeTabs = "pfe-tabs",
|
|
3
|
-
pfeCollapse = "pfe-collapse"
|
|
4
|
-
}
|
|
5
|
-
interface RequireCustomElementObject {
|
|
6
|
-
/** The custom element you want to check if it has been defined */
|
|
7
|
-
element: CustomElements;
|
|
8
|
-
/** cb that will be called if the custom element has yet to be defined */
|
|
9
|
-
requireCb: () => void;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* This function is to check if custom elements exist and require them if they do not.
|
|
13
|
-
* The check is needed because of how the packages are split and that patternfly elements
|
|
14
|
-
* use window.customElements.define without checking if it is already defined, which throws an
|
|
15
|
-
* error. Since our packages are split up and lazy loaded this check is necessary to make sure that
|
|
16
|
-
* the pfelement does not get defined twice.
|
|
17
|
-
*/
|
|
18
|
-
export declare function requireCustomElement(elements: RequireCustomElementObject[]): void;
|
|
19
|
-
export {};
|
|
20
|
-
//# sourceMappingURL=customElementUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customElementUtils.d.ts","sourceRoot":"","sources":["../../src/customElementUtils.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACtB,OAAO,aAAa;IACpB,WAAW,iBAAiB;CAC/B;AAED,UAAU,0BAA0B;IAChC,kEAAkE;IAClE,OAAO,EAAE,cAAc,CAAC;IAExB,yEAAyE;IACzE,SAAS,EAAE,MAAM,IAAI,CAAC;CACzB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,0BAA0B,EAAE,QAM1E"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requireCustomElement = exports.CustomElements = void 0;
|
|
4
|
-
var CustomElements;
|
|
5
|
-
(function (CustomElements) {
|
|
6
|
-
CustomElements["pfeTabs"] = "pfe-tabs";
|
|
7
|
-
CustomElements["pfeCollapse"] = "pfe-collapse";
|
|
8
|
-
})(CustomElements = exports.CustomElements || (exports.CustomElements = {}));
|
|
9
|
-
/**
|
|
10
|
-
* This function is to check if custom elements exist and require them if they do not.
|
|
11
|
-
* The check is needed because of how the packages are split and that patternfly elements
|
|
12
|
-
* use window.customElements.define without checking if it is already defined, which throws an
|
|
13
|
-
* error. Since our packages are split up and lazy loaded this check is necessary to make sure that
|
|
14
|
-
* the pfelement does not get defined twice.
|
|
15
|
-
*/
|
|
16
|
-
function requireCustomElement(elements) {
|
|
17
|
-
elements.forEach((elementObj) => {
|
|
18
|
-
if (window.customElements.get(elementObj.element) === undefined) {
|
|
19
|
-
elementObj.requireCb();
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
exports.requireCustomElement = requireCustomElement;
|
package/lib/cjs/dateUtils.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import moment from 'moment-timezone';
|
|
2
|
-
export declare const formatDate: (date: any, locale?: string, format?: Intl.DateTimeFormatOptions) => string;
|
|
3
|
-
export declare const formatDateTime: (date: any, locale?: string, format?: Intl.DateTimeFormatOptions) => string;
|
|
4
|
-
export declare const isoDate: (date: string) => string;
|
|
5
|
-
export declare const getTimezoneOffsetFromTZName: (tzName: string) => string;
|
|
6
|
-
export declare const getPastUTCDateFromNow: (pastDays: number) => string;
|
|
7
|
-
export declare const isCurrentDateSameAsOrBeforeDate: (date: string, granularity?: moment.unitOfTime.StartOf) => boolean;
|
|
8
|
-
export declare const isFutureDate: (date: string, granularity?: moment.unitOfTime.StartOf) => boolean;
|
|
9
|
-
declare type AddToDate = {
|
|
10
|
-
days: number;
|
|
11
|
-
date?: string;
|
|
12
|
-
};
|
|
13
|
-
export declare const addDaysToDate: (params: AddToDate) => moment.Moment;
|
|
14
|
-
export declare const trafficSplit: (testVariationWeight: number, dateString: string) => "A" | "B";
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=dateUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/dateUtils.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,eAAO,MAAM,UAAU,wCAGX,KAAK,qBAAqB,WASrC,CAAC;AAEF,eAAO,MAAM,cAAc,wCAGf,KAAK,qBAAqB,WAerC,CAAC;AAEF,eAAO,MAAM,OAAO,SAAU,MAAM,KAAG,MAAmC,CAAC;AAE3E,eAAO,MAAM,2BAA2B,WAAY,MAAM,WAEzD,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAExD,CAAC;AAEF,eAAO,MAAM,+BAA+B,SAClC,MAAM,gBACC,OAAO,UAAU,CAAC,OAAO,KACvC,OAEF,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,gBAAe,OAAO,UAAU,CAAC,OAAO,YAEhF,CAAC;AAEF,aAAK,SAAS,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,aAAa,WAAY,SAAS,kBAG9C,CAAC;AAOF,eAAO,MAAM,YAAY,wBAAyB,MAAM,cAAc,MAAM,cAe3E,CAAC"}
|
package/lib/cjs/dateUtils.js
DELETED
|
@@ -1,78 +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.trafficSplit = exports.addDaysToDate = exports.isFutureDate = exports.isCurrentDateSameAsOrBeforeDate = exports.getPastUTCDateFromNow = exports.getTimezoneOffsetFromTZName = exports.isoDate = exports.formatDateTime = exports.formatDate = void 0;
|
|
7
|
-
const moment_timezone_1 = __importDefault(require("moment-timezone"));
|
|
8
|
-
const formatDate = (date, locale = 'en-us', format = { month: 'short', day: 'numeric', year: 'numeric' }) => {
|
|
9
|
-
if (!date) {
|
|
10
|
-
return '';
|
|
11
|
-
}
|
|
12
|
-
if (!(date instanceof Date)) {
|
|
13
|
-
date = new Date(date);
|
|
14
|
-
}
|
|
15
|
-
return new Intl.DateTimeFormat(locale, format).format(date);
|
|
16
|
-
};
|
|
17
|
-
exports.formatDate = formatDate;
|
|
18
|
-
const formatDateTime = (date, locale = 'en-us', format = {
|
|
19
|
-
weekday: 'short',
|
|
20
|
-
month: 'short',
|
|
21
|
-
day: 'numeric',
|
|
22
|
-
year: 'numeric',
|
|
23
|
-
hour: '2-digit',
|
|
24
|
-
minute: '2-digit',
|
|
25
|
-
second: '2-digit',
|
|
26
|
-
timeZoneName: 'short',
|
|
27
|
-
}) => {
|
|
28
|
-
if (!date) {
|
|
29
|
-
return '';
|
|
30
|
-
}
|
|
31
|
-
return exports.formatDate(date, locale, format);
|
|
32
|
-
};
|
|
33
|
-
exports.formatDateTime = formatDateTime;
|
|
34
|
-
const isoDate = (date) => new Date(date).toString();
|
|
35
|
-
exports.isoDate = isoDate;
|
|
36
|
-
const getTimezoneOffsetFromTZName = (tzName) => {
|
|
37
|
-
return moment_timezone_1.default().tz(tzName).format('Z');
|
|
38
|
-
};
|
|
39
|
-
exports.getTimezoneOffsetFromTZName = getTimezoneOffsetFromTZName;
|
|
40
|
-
const getPastUTCDateFromNow = (pastDays) => {
|
|
41
|
-
return moment_timezone_1.default().subtract(pastDays, 'days').utc().format();
|
|
42
|
-
};
|
|
43
|
-
exports.getPastUTCDateFromNow = getPastUTCDateFromNow;
|
|
44
|
-
const isCurrentDateSameAsOrBeforeDate = (date, granularity = 'day') => {
|
|
45
|
-
return moment_timezone_1.default(moment_timezone_1.default.now()).isSameOrBefore(date, granularity);
|
|
46
|
-
};
|
|
47
|
-
exports.isCurrentDateSameAsOrBeforeDate = isCurrentDateSameAsOrBeforeDate;
|
|
48
|
-
const isFutureDate = (date, granularity = 'day') => {
|
|
49
|
-
return moment_timezone_1.default(date).isAfter(moment_timezone_1.default(), granularity);
|
|
50
|
-
};
|
|
51
|
-
exports.isFutureDate = isFutureDate;
|
|
52
|
-
const addDaysToDate = (params) => {
|
|
53
|
-
const { days, date = new Date() } = params;
|
|
54
|
-
return moment_timezone_1.default(date).add(days, 'days');
|
|
55
|
-
};
|
|
56
|
-
exports.addDaysToDate = addDaysToDate;
|
|
57
|
-
// split traffic based on time and weight
|
|
58
|
-
// for example, if testVariationWeight is 2 and the current time in seconds modulo 10 is less than 2,
|
|
59
|
-
// redirect to test version (20% of the time), else redirect to control version (80% of the time)
|
|
60
|
-
// @wieght: a number between 0 and 10
|
|
61
|
-
// @dateString: date string
|
|
62
|
-
const trafficSplit = (testVariationWeight, dateString) => {
|
|
63
|
-
if (testVariationWeight === 10)
|
|
64
|
-
return 'A'; // test
|
|
65
|
-
if (testVariationWeight === 0 || !testVariationWeight || isNaN(testVariationWeight))
|
|
66
|
-
return 'B'; // control
|
|
67
|
-
const date = new Date(dateString);
|
|
68
|
-
const seconds = date.getSeconds();
|
|
69
|
-
const totalWeight = 10;
|
|
70
|
-
const moduloResult = seconds % totalWeight;
|
|
71
|
-
if (moduloResult < testVariationWeight) {
|
|
72
|
-
return 'A';
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
return 'B';
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
exports.trafficSplit = trafficSplit;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { IKeyValue, IOption, KeyOfExtractedType } from '@rh-support/types/shared';
|
|
2
|
-
declare type labelKeyFunction<O> = (item: O) => string;
|
|
3
|
-
export interface IToOptionsConfig<O> {
|
|
4
|
-
labelKey?: labelKeyFunction<O> | KeyOfExtractedType<O, IOption<O>['label']>;
|
|
5
|
-
additionalInfoKey?: KeyOfExtractedType<O, IOption<O>['additionalInfo']>;
|
|
6
|
-
disabledKey?: KeyOfExtractedType<O, IOption<O>['disabled']>;
|
|
7
|
-
classNameFn?: (item: O) => string;
|
|
8
|
-
childrenKey?: KeyOfExtractedType<O, IOption<O>['children']>;
|
|
9
|
-
nonActionableItemKey?: KeyOfExtractedType<O, IOption<O>['isNonActionable']>;
|
|
10
|
-
nonSearchableItemKey?: KeyOfExtractedType<O, IOption<O>['isNotSearchable']>;
|
|
11
|
-
nonSelectableItemKey?: KeyOfExtractedType<O, IOption<O>['isNotSelectable']>;
|
|
12
|
-
actionItemKey?: KeyOfExtractedType<O, IOption<O>['actionItem']>;
|
|
13
|
-
}
|
|
14
|
-
export declare function toOption<O>(value: O, config?: IToOptionsConfig<O>): IOption<O>;
|
|
15
|
-
export declare function toOptions<T>(values: T[], config?: IToOptionsConfig<T>): Array<IOption<T>>;
|
|
16
|
-
export declare function getDropdownBtnPlaceholder(btnPlaceholder: string, selectedValues: string[] | IKeyValue<string>[], type: string, totalLength?: number, totalLengthString?: string): string;
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=dropdownUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dropdownUtils.d.ts","sourceRoot":"","sources":["../../src/dropdownUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAIlF,aAAK,gBAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;AAC/C,MAAM,WAAW,gBAAgB,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5E,iBAAiB,CAAC,EAAE,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACxE,WAAW,CAAC,EAAE,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5D,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAClC,WAAW,CAAC,EAAE,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5D,oBAAoB,CAAC,EAAE,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC5E,oBAAoB,CAAC,EAAE,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC5E,oBAAoB,CAAC,EAAE,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC5E,aAAa,CAAC,EAAE,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;CACnE;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,GAAE,gBAAgB,CAAC,CAAC,CAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CA+BlF;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,GAAE,gBAAgB,CAAC,CAAC,CAAM,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAE7F;AAED,wBAAgB,yBAAyB,CACrC,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,EAAE,EAC9C,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM,EACpB,iBAAiB,CAAC,EAAE,MAAM,GAC3B,MAAM,CAWR"}
|