@rh-support/utils 2.1.46 → 2.2.0-alpha.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.
- package/lib/esm/dateUtils.d.ts +8 -7
- package/lib/esm/dateUtils.d.ts.map +1 -1
- package/lib/esm/dateUtils.js +10 -60
- package/lib/esm/eventUtils.d.ts +3 -13
- package/lib/esm/eventUtils.d.ts.map +1 -1
- package/lib/esm/eventUtils.js +5 -89
- package/lib/esm/graphqlClientUtils.d.ts +4 -0
- package/lib/esm/graphqlClientUtils.d.ts.map +1 -0
- package/lib/esm/graphqlClientUtils.js +36 -0
- package/lib/esm/graphqlFetchUtils.d.ts +22 -0
- package/lib/esm/graphqlFetchUtils.d.ts.map +1 -0
- package/lib/esm/graphqlFetchUtils.js +48 -0
- package/lib/esm/graphqlMutationUtils.d.ts +6 -0
- package/lib/esm/graphqlMutationUtils.d.ts.map +1 -0
- package/lib/esm/graphqlMutationUtils.js +112 -0
- package/lib/esm/graphqlQueries.d.ts +3 -0
- package/lib/esm/graphqlQueries.d.ts.map +1 -0
- package/lib/esm/graphqlQueries.js +54 -0
- package/lib/esm/index.d.ts +4 -0
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +4 -0
- package/lib/esm/validatorUtils.js +1 -1
- package/package.json +11 -6
package/lib/esm/dateUtils.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import moment from 'moment-timezone';
|
|
2
2
|
export declare const formatDate: (date: any, locale?: string, format?: Intl.DateTimeFormatOptions) => string;
|
|
3
3
|
export declare const formatDateTime: (date: any, locale?: string, format?: Intl.DateTimeFormatOptions) => string;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const isoDate: (date: string) => string;
|
|
5
5
|
export declare const getTimezoneOffsetFromTZName: (tzName: string) => string;
|
|
6
6
|
export declare const getPastUTCDateFromNow: (pastDays: number) => string;
|
|
7
|
-
export declare const
|
|
8
|
-
export
|
|
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
|
+
type AddToDate = {
|
|
9
10
|
days: number;
|
|
10
|
-
date?:
|
|
11
|
-
}
|
|
12
|
-
export declare const addDaysToDate: (params: AddToDate) =>
|
|
11
|
+
date?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const addDaysToDate: (params: AddToDate) => moment.Moment;
|
|
13
14
|
export declare const isValidDate: (dateString: string) => boolean;
|
|
14
15
|
export declare const trafficSplit: (testVariationWeight: number, dateString: string) => "A" | "B";
|
|
15
16
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/dateUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/dateUtils.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,eAAO,MAAM,UAAU,wCAGX,IAAI,CAAC,qBAAqB,WASrC,CAAC;AAEF,eAAO,MAAM,cAAc,wCAGf,IAAI,CAAC,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,MAAM,CAAC,UAAU,CAAC,OAAO,KACvC,OAEF,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,gBAAe,MAAM,CAAC,UAAU,CAAC,OAAO,YAEhF,CAAC;AAEF,KAAK,SAAS,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,aAAa,WAAY,SAAS,kBAG9C,CAAC;AAEF,eAAO,MAAM,WAAW,eAAgB,MAAM,YAI7C,CAAC;AAQF,eAAO,MAAM,YAAY,wBAAyB,MAAM,cAAc,MAAM,cAe3E,CAAC"}
|
package/lib/esm/dateUtils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { isValid, parseISO } from 'date-fns';
|
|
2
|
+
import moment from 'moment-timezone';
|
|
3
3
|
export const formatDate = (date, locale = 'en-us', format = { month: 'short', day: 'numeric', year: 'numeric' }) => {
|
|
4
4
|
if (!date) {
|
|
5
5
|
return '';
|
|
@@ -24,72 +24,22 @@ export const formatDateTime = (date, locale = 'en-us', format = {
|
|
|
24
24
|
}
|
|
25
25
|
return formatDate(date, locale, format);
|
|
26
26
|
};
|
|
27
|
-
export const
|
|
28
|
-
const parsedDate = parseISO(date);
|
|
29
|
-
const now = new Date();
|
|
30
|
-
let comparisonDate;
|
|
31
|
-
let comparisonNow;
|
|
32
|
-
switch (granularity) {
|
|
33
|
-
case 'day':
|
|
34
|
-
comparisonDate = startOfDay(parsedDate);
|
|
35
|
-
comparisonNow = startOfDay(now);
|
|
36
|
-
break;
|
|
37
|
-
case 'week':
|
|
38
|
-
comparisonDate = startOfWeek(parsedDate);
|
|
39
|
-
comparisonNow = startOfWeek(now);
|
|
40
|
-
break;
|
|
41
|
-
case 'month':
|
|
42
|
-
comparisonDate = startOfMonth(parsedDate);
|
|
43
|
-
comparisonNow = startOfMonth(now);
|
|
44
|
-
break;
|
|
45
|
-
case 'year':
|
|
46
|
-
comparisonDate = startOfYear(parsedDate);
|
|
47
|
-
comparisonNow = startOfYear(now);
|
|
48
|
-
break;
|
|
49
|
-
default:
|
|
50
|
-
throw new Error('Invalid granularity');
|
|
51
|
-
}
|
|
52
|
-
return isAfter(comparisonNow, comparisonDate);
|
|
53
|
-
};
|
|
27
|
+
export const isoDate = (date) => new Date(date).toString();
|
|
54
28
|
export const getTimezoneOffsetFromTZName = (tzName) => {
|
|
55
|
-
|
|
56
|
-
const zonedDate = fromZonedTime(date, tzName);
|
|
57
|
-
return format(zonedDate, 'xxx', { timeZone: tzName });
|
|
29
|
+
return moment().tz(tzName).format('Z');
|
|
58
30
|
};
|
|
59
31
|
export const getPastUTCDateFromNow = (pastDays) => {
|
|
60
|
-
|
|
61
|
-
|
|
32
|
+
return moment().subtract(pastDays, 'days').utc().format();
|
|
33
|
+
};
|
|
34
|
+
export const isCurrentDateSameAsOrBeforeDate = (date, granularity = 'day') => {
|
|
35
|
+
return moment(moment.now()).isSameOrBefore(date, granularity);
|
|
62
36
|
};
|
|
63
37
|
export const isFutureDate = (date, granularity = 'day') => {
|
|
64
|
-
|
|
65
|
-
const now = new Date();
|
|
66
|
-
let comparisonDate;
|
|
67
|
-
let comparisonNow;
|
|
68
|
-
switch (granularity) {
|
|
69
|
-
case 'day':
|
|
70
|
-
comparisonDate = startOfDay(parsedDate);
|
|
71
|
-
comparisonNow = startOfDay(now);
|
|
72
|
-
break;
|
|
73
|
-
case 'week':
|
|
74
|
-
comparisonDate = startOfWeek(parsedDate);
|
|
75
|
-
comparisonNow = startOfWeek(now);
|
|
76
|
-
break;
|
|
77
|
-
case 'month':
|
|
78
|
-
comparisonDate = startOfMonth(parsedDate);
|
|
79
|
-
comparisonNow = startOfMonth(now);
|
|
80
|
-
break;
|
|
81
|
-
case 'year':
|
|
82
|
-
comparisonDate = startOfYear(parsedDate);
|
|
83
|
-
comparisonNow = startOfYear(now);
|
|
84
|
-
break;
|
|
85
|
-
default:
|
|
86
|
-
throw new Error('Invalid granularity');
|
|
87
|
-
}
|
|
88
|
-
return isAfter(comparisonDate, comparisonNow);
|
|
38
|
+
return moment(date).isAfter(moment(), granularity);
|
|
89
39
|
};
|
|
90
40
|
export const addDaysToDate = (params) => {
|
|
91
41
|
const { days, date = new Date() } = params;
|
|
92
|
-
return
|
|
42
|
+
return moment(date).add(days, 'days');
|
|
93
43
|
};
|
|
94
44
|
export const isValidDate = (dateString) => {
|
|
95
45
|
const parsedDate = parseISO(dateString);
|
package/lib/esm/eventUtils.d.ts
CHANGED
|
@@ -5,17 +5,7 @@ export interface IPendoTrackEventProperty {
|
|
|
5
5
|
declare function haltEvent(event: React.SyntheticEvent<{}>): void;
|
|
6
6
|
declare function pendoTrackEvent(name: any, properties?: IPendoTrackEventProperty): void;
|
|
7
7
|
declare function dtmTrackEvent(eventName: string, stepName: string, caseNumber?: string, product?: string): void;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* @returns the track event page name
|
|
12
|
-
*/
|
|
13
|
-
export declare function getPageName(pathname: string): string;
|
|
14
|
-
declare function dtmTrackEventCaseCreationStepEncountered(caseSection: boolean, stepName: string, caseNumber?: string, caseType?: string, caseTitle?: string, product?: string, version?: string): void;
|
|
15
|
-
export declare function dtmTrackEventCaseStepEncountered(stepName: 'close' | 'comment' | 'follow' | 'review', caseNumber?: string, product?: string, version?: string): void;
|
|
16
|
-
export declare function dtmTrackEventPageLoadStarted(pageName: string): void;
|
|
17
|
-
declare function dtmTrackEventRecommendationListingItemClicked(url: string, activityName: string, contentListingRegion: string, contentID: string, contentPosition: number, contentTitle: string, contentUrl: string, displayFeature: string, displayFeatureTitle: string): void;
|
|
18
|
-
declare function dtmTrackEventRecommendationListingDisplayed(contentListingRegion: any, activityName: any, listing: any, resultsCount: any): void;
|
|
19
|
-
export declare function dtmTrackEventUploadFileToAnalyze(caseSection: boolean, stepName: string, caseType?: string, caseTitle?: string, product?: string, version?: string): void;
|
|
20
|
-
export { haltEvent, pendoTrackEvent, dtmTrackEvent, dtmTrackEventCaseCreationStepEncountered, dtmTrackEventRecommendationListingItemClicked, dtmTrackEventRecommendationListingDisplayed, };
|
|
8
|
+
declare function dtmTrackEventCaseStartStopped(stepName: string, caseNumber?: string, product?: string): void;
|
|
9
|
+
declare function dtmTrackEventCaseDetailsSolutionDocs(stepName: string, caseNumber?: string, product?: string): void;
|
|
10
|
+
export { haltEvent, pendoTrackEvent, dtmTrackEvent, dtmTrackEventCaseStartStopped, dtmTrackEventCaseDetailsSolutionDocs, };
|
|
21
11
|
//# sourceMappingURL=eventUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventUtils.d.ts","sourceRoot":"","sources":["../../src/eventUtils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,wBAAwB;IACrC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED,iBAAS,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC,QAKjD;AAKD,iBAAS,eAAe,CAAC,IAAI,KAAA,EAAE,UAAU,GAAE,wBAA6B,QAMvE;AAED,iBAAS,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,QAUhG;AAED
|
|
1
|
+
{"version":3,"file":"eventUtils.d.ts","sourceRoot":"","sources":["../../src/eventUtils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,wBAAwB;IACrC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED,iBAAS,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC,QAKjD;AAKD,iBAAS,eAAe,CAAC,IAAI,KAAA,EAAE,UAAU,GAAE,wBAA6B,QAMvE;AAED,iBAAS,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,QAUhG;AAED,iBAAS,6BAA6B,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,QAE7F;AAED,iBAAS,oCAAoC,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,QAEpG;AAED,OAAO,EACH,SAAS,EACT,eAAe,EACf,aAAa,EACb,6BAA6B,EAC7B,oCAAoC,GACvC,CAAC"}
|
package/lib/esm/eventUtils.js
CHANGED
|
@@ -27,94 +27,10 @@ function dtmTrackEvent(eventName, stepName, caseNumber, product) {
|
|
|
27
27
|
},
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* @param pathname the current pathname
|
|
33
|
-
* @returns the track event page name
|
|
34
|
-
*/
|
|
35
|
-
export function getPageName(pathname) {
|
|
36
|
-
return `cp|support|cases|${pathname.replace('#', '').split('/').filter(Boolean).join('|')}`;
|
|
30
|
+
function dtmTrackEventCaseStartStopped(stepName, caseNumber, product) {
|
|
31
|
+
dtmTrackEvent('Case Step Encountered', stepName, caseNumber, product);
|
|
37
32
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const event = 'Case Creation Step Encountered';
|
|
41
|
-
const caseObject = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ type: 'cp-support', caseSection: caseSection ? 'case' : 'troubleshoot', stepName }, (caseNumber && { caseNumber })), (version && { caseProductVersion: version })), (caseType && { caseType })), (caseTitle && { caseTitle })), (product && { caseProduct: product }));
|
|
42
|
-
(window.appEventData || []).push({
|
|
43
|
-
event,
|
|
44
|
-
case: caseObject,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
// https://github.com/further-external/redhat-datalayer/blob/main/EDDL/global-datalayer.md#Page-Load-Started
|
|
48
|
-
export function dtmTrackEventCaseStepEncountered(stepName, caseNumber, product, version) {
|
|
49
|
-
const event = 'Case Step Encountered';
|
|
50
|
-
const caseObject = Object.assign(Object.assign({ type: 'cp-support', stepName }, (caseNumber && { caseNumber })), (product && { caseProduct: `${product}|${version}` }));
|
|
51
|
-
(window.appEventData || []).push({
|
|
52
|
-
event,
|
|
53
|
-
case: caseObject,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
// https://github.com/further-external/redhat-datalayer/blob/main/EDDL/global-datalayer.md#Page-Load-Started
|
|
57
|
-
export function dtmTrackEventPageLoadStarted(pageName) {
|
|
58
|
-
const event = 'Page Load Started';
|
|
59
|
-
const caseObject = {
|
|
60
|
-
type: 'cp-support',
|
|
61
|
-
pageName,
|
|
62
|
-
};
|
|
63
|
-
(window.appEventData || []).push({
|
|
64
|
-
event,
|
|
65
|
-
case: caseObject,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
// https://github.com/further-external/redhat-datalayer/blob/main/EDDL/global-datalayer.md#recommendation-listing-item-clicked
|
|
69
|
-
function dtmTrackEventRecommendationListingItemClicked(url, activityName, contentListingRegion, contentID, contentPosition, contentTitle, contentUrl, displayFeature, displayFeatureTitle) {
|
|
70
|
-
(window.appEventData || []).push({
|
|
71
|
-
event: 'Recommendation Listing Item Clicked',
|
|
72
|
-
linkInfo: {
|
|
73
|
-
href: url,
|
|
74
|
-
linkType: 'list',
|
|
75
|
-
linkTypeName: 'listing result click',
|
|
76
|
-
targetHost: 'access.redhat.com',
|
|
77
|
-
text: 'text',
|
|
78
|
-
},
|
|
79
|
-
listingItemClicked: {
|
|
80
|
-
activityName,
|
|
81
|
-
contentListingRegion,
|
|
82
|
-
listing: [
|
|
83
|
-
{
|
|
84
|
-
content: {
|
|
85
|
-
contentID,
|
|
86
|
-
contentPosition,
|
|
87
|
-
contentTitle,
|
|
88
|
-
contentUrl,
|
|
89
|
-
displayFeature,
|
|
90
|
-
displayFeatureTitle,
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
listingType: 'Support Cases',
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
// https://github.com/further-external/redhat-datalayer/blob/main/EDDL/global-datalayer.md#recommendation-listing-displayed
|
|
99
|
-
function dtmTrackEventRecommendationListingDisplayed(contentListingRegion, activityName, listing, resultsCount) {
|
|
100
|
-
(window.appEventData || []).push({
|
|
101
|
-
event: 'Recommendation Listing Displayed',
|
|
102
|
-
listingDisplayed: {
|
|
103
|
-
activityName,
|
|
104
|
-
contentListingRegion,
|
|
105
|
-
listing,
|
|
106
|
-
listingType: 'content',
|
|
107
|
-
resultsCount,
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
// https://github.com/further-external/redhat-datalayer/blob/main/EDDL/global-datalayer.md#Page-Load-Started
|
|
112
|
-
export function dtmTrackEventUploadFileToAnalyze(caseSection, stepName, caseType, caseTitle, product, version) {
|
|
113
|
-
const eventName = 'Upload File to Analyze';
|
|
114
|
-
const caseObject = Object.assign(Object.assign(Object.assign(Object.assign({ type: 'cp-support', caseSection: caseSection ? 'case' : 'troubleshoot', stepName }, (product && { caseProduct: product })), (version && { caseProductVersion: version })), (caseType && { caseType })), (caseTitle && { caseTitle }));
|
|
115
|
-
(window.appEventData || []).push({
|
|
116
|
-
event: eventName,
|
|
117
|
-
case: caseObject,
|
|
118
|
-
});
|
|
33
|
+
function dtmTrackEventCaseDetailsSolutionDocs(stepName, caseNumber, product) {
|
|
34
|
+
dtmTrackEvent('Case details solution docs', stepName, caseNumber, product);
|
|
119
35
|
}
|
|
120
|
-
export { haltEvent, pendoTrackEvent, dtmTrackEvent,
|
|
36
|
+
export { haltEvent, pendoTrackEvent, dtmTrackEvent, dtmTrackEventCaseStartStopped, dtmTrackEventCaseDetailsSolutionDocs, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphqlClientUtils.d.ts","sourceRoot":"","sources":["../../src/graphqlClientUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAiB,MAAM,gBAAgB,CAAC;AAqC7D,QAAA,MAAM,aAAa,8DAGjB,CAAC;AAEH,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ApolloClient, InMemoryCache } from '@apollo/client';
|
|
2
|
+
// import { setContext } from '@apollo/client/link/context';
|
|
3
|
+
// import { onError } from '@apollo/client/link/error';
|
|
4
|
+
console.log('graphql client file1');
|
|
5
|
+
// const httpLink = createHttpLink({
|
|
6
|
+
// uri: 'http://localhost:4000/graphql',
|
|
7
|
+
// });
|
|
8
|
+
// Auth link to include authentication tokens
|
|
9
|
+
// const authLink = setContext((_, { headers }) => {
|
|
10
|
+
// const token = localStorage.getItem('authToken');
|
|
11
|
+
// return {
|
|
12
|
+
// headers: {
|
|
13
|
+
// ...headers,
|
|
14
|
+
// authorization: token ? `Bearer ${token}` : '',
|
|
15
|
+
// },
|
|
16
|
+
// };
|
|
17
|
+
// });
|
|
18
|
+
// Error handling link
|
|
19
|
+
// const errorLink = onError(({ graphQLErrors, networkError }) => {
|
|
20
|
+
// if (graphQLErrors) {
|
|
21
|
+
// graphQLErrors.forEach(({ message, locations, path }) =>
|
|
22
|
+
// console.error(`[GraphQL error]: Message: ${message}, Location: ${JSON.stringify(locations)}, Path: ${path}`)
|
|
23
|
+
// );
|
|
24
|
+
// }
|
|
25
|
+
// if (networkError) {
|
|
26
|
+
// console.error(`[Network error]: ${networkError}`);
|
|
27
|
+
// }
|
|
28
|
+
// });
|
|
29
|
+
// Combine links
|
|
30
|
+
// const link = ApolloLink.from([authLink, errorLink as unknown as ApolloLink, httpLink]);
|
|
31
|
+
// Initialize Apollo Client
|
|
32
|
+
const graphqlClient = new ApolloClient({
|
|
33
|
+
uri: 'http://localhost:4000/graphql',
|
|
34
|
+
cache: new InMemoryCache(),
|
|
35
|
+
});
|
|
36
|
+
export { graphqlClient };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DocumentNode } from 'graphql';
|
|
2
|
+
export interface GraphQLRequest<TVariables> {
|
|
3
|
+
query: DocumentNode;
|
|
4
|
+
variables?: TVariables;
|
|
5
|
+
}
|
|
6
|
+
export interface GraphQLResponse<TData> {
|
|
7
|
+
data?: TData;
|
|
8
|
+
errors?: Array<{
|
|
9
|
+
message: string;
|
|
10
|
+
locations?: Array<{
|
|
11
|
+
line: number;
|
|
12
|
+
column: number;
|
|
13
|
+
}>;
|
|
14
|
+
path?: Array<string | number>;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
export declare function getAuthToken(): string | null;
|
|
18
|
+
export declare function getAuthHeaders(): {
|
|
19
|
+
[key: string]: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function graphqlFetch<TData, TVariables = {}>(request: GraphQLRequest<TVariables>): Promise<TData>;
|
|
22
|
+
//# sourceMappingURL=graphqlFetchUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphqlFetchUtils.d.ts","sourceRoot":"","sources":["../../src/graphqlFetchUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,WAAW,cAAc,CAAC,UAAU;IACtC,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,CAAC,EAAE,UAAU,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe,CAAC,KAAK;IAClC,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,MAAM,CAAC,EAAE,KAAK,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QACpD,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;KACjC,CAAC,CAAC;CACN;AAED,wBAAgB,YAAY,IAAI,MAAM,GAAG,IAAI,CAE5C;AAED,wBAAgB,cAAc,IAAI;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAQ1D;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,EAAE,EAAE,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAgC9G"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
export function getAuthToken() {
|
|
11
|
+
var _a;
|
|
12
|
+
return ((_a = window === null || window === void 0 ? void 0 : window.sessionjs) === null || _a === void 0 ? void 0 : _a.getEncodedToken()) || '';
|
|
13
|
+
}
|
|
14
|
+
export function getAuthHeaders() {
|
|
15
|
+
const token = getAuthToken();
|
|
16
|
+
if (token) {
|
|
17
|
+
return {
|
|
18
|
+
Authorization: `Bearer ${token}`,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
export function graphqlFetch(request) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
const { query, variables } = request;
|
|
27
|
+
const queryString = typeof query === 'string' ? query : (_a = query.loc) === null || _a === void 0 ? void 0 : _a.source.body;
|
|
28
|
+
const response = yield fetch('https://vpn.graphql.dev.redhat.com/graphql', {
|
|
29
|
+
method: 'POST',
|
|
30
|
+
headers: Object.assign({ 'Content-Type': 'application/json', 'apollographql-client-name': 'portal-case-management', 'apollographql-client-version': 'latest' }, getAuthHeaders()),
|
|
31
|
+
body: JSON.stringify({
|
|
32
|
+
query: queryString,
|
|
33
|
+
variables,
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
const responseBody = yield response.json();
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
throw new Error(((_c = (_b = responseBody.errors) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.message) || 'Network response was not ok');
|
|
39
|
+
}
|
|
40
|
+
if (responseBody.errors) {
|
|
41
|
+
throw new Error(responseBody.errors.map((err) => err.message).join(', '));
|
|
42
|
+
}
|
|
43
|
+
if (!responseBody.data) {
|
|
44
|
+
throw new Error('No data returned from GraphQL');
|
|
45
|
+
}
|
|
46
|
+
return responseBody.data;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const CREATE_SESSION: import("@apollo/client").DocumentNode;
|
|
2
|
+
declare const UPDATE_SESSION: import("@apollo/client").DocumentNode;
|
|
3
|
+
declare const CREATE_SESSION_RESOURCE: import("@apollo/client").DocumentNode;
|
|
4
|
+
declare const UPDATE_SESSION_RESOURCE: import("@apollo/client").DocumentNode;
|
|
5
|
+
export { CREATE_SESSION, UPDATE_SESSION, CREATE_SESSION_RESOURCE, UPDATE_SESSION_RESOURCE };
|
|
6
|
+
//# sourceMappingURL=graphqlMutationUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphqlMutationUtils.d.ts","sourceRoot":"","sources":["../../src/graphqlMutationUtils.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,cAAc,uCA+CnB,CAAC;AAEF,QAAA,MAAM,cAAc,uCA+CnB,CAAC;AAEF,QAAA,MAAM,uBAAuB,uCAM5B,CAAC;AAEF,QAAA,MAAM,uBAAuB,uCAM5B,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
const CREATE_SESSION = gql `
|
|
3
|
+
mutation CreateSession($input: CreateSessionInput!) {
|
|
4
|
+
pcm_create_session(input: $input) {
|
|
5
|
+
id
|
|
6
|
+
isActive
|
|
7
|
+
createdBy
|
|
8
|
+
modifiedBy
|
|
9
|
+
createdDate
|
|
10
|
+
modifiedDate
|
|
11
|
+
userAgent
|
|
12
|
+
originatingSystem
|
|
13
|
+
hasVisitedResources
|
|
14
|
+
referrerUrl
|
|
15
|
+
caseCreationError
|
|
16
|
+
isInternal
|
|
17
|
+
isResolved
|
|
18
|
+
isActive
|
|
19
|
+
pcmSessionDetails {
|
|
20
|
+
id
|
|
21
|
+
environment
|
|
22
|
+
description
|
|
23
|
+
sessionId
|
|
24
|
+
product
|
|
25
|
+
version
|
|
26
|
+
summary
|
|
27
|
+
issue
|
|
28
|
+
environment
|
|
29
|
+
periodicityOfIssue
|
|
30
|
+
timeFramesAndUrgency
|
|
31
|
+
type
|
|
32
|
+
severity
|
|
33
|
+
sla
|
|
34
|
+
accountNumber
|
|
35
|
+
folderNumber
|
|
36
|
+
contactSsoUsername
|
|
37
|
+
notifiedUsersInternal
|
|
38
|
+
notifiedUsersExternal
|
|
39
|
+
clusterId
|
|
40
|
+
noClusterIdReason
|
|
41
|
+
caseAlternateId
|
|
42
|
+
phoneCountryCode
|
|
43
|
+
noClusterIdReasonExplanation
|
|
44
|
+
phoneAreaCodePrefixLineNumber
|
|
45
|
+
screenSessionRequested
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
const UPDATE_SESSION = gql `
|
|
51
|
+
mutation UpdateSession($input: UpdateSessionInput!) {
|
|
52
|
+
pcm_update_session(input: $input) {
|
|
53
|
+
id
|
|
54
|
+
isActive
|
|
55
|
+
createdBy
|
|
56
|
+
modifiedBy
|
|
57
|
+
createdDate
|
|
58
|
+
modifiedDate
|
|
59
|
+
userAgent
|
|
60
|
+
originatingSystem
|
|
61
|
+
hasVisitedResources
|
|
62
|
+
referrerUrl
|
|
63
|
+
caseCreationError
|
|
64
|
+
isInternal
|
|
65
|
+
isResolved
|
|
66
|
+
isActive
|
|
67
|
+
pcmSessionDetails {
|
|
68
|
+
id
|
|
69
|
+
environment
|
|
70
|
+
description
|
|
71
|
+
sessionId
|
|
72
|
+
product
|
|
73
|
+
version
|
|
74
|
+
summary
|
|
75
|
+
issue
|
|
76
|
+
environment
|
|
77
|
+
periodicityOfIssue
|
|
78
|
+
timeFramesAndUrgency
|
|
79
|
+
type
|
|
80
|
+
severity
|
|
81
|
+
sla
|
|
82
|
+
accountNumber
|
|
83
|
+
folderNumber
|
|
84
|
+
contactSsoUsername
|
|
85
|
+
notifiedUsersInternal
|
|
86
|
+
notifiedUsersExternal
|
|
87
|
+
clusterId
|
|
88
|
+
noClusterIdReason
|
|
89
|
+
caseAlternateId
|
|
90
|
+
phoneCountryCode
|
|
91
|
+
noClusterIdReasonExplanation
|
|
92
|
+
phoneAreaCodePrefixLineNumber
|
|
93
|
+
screenSessionRequested
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
`;
|
|
98
|
+
const CREATE_SESSION_RESOURCE = gql `
|
|
99
|
+
mutation CreateSessionResource($input: CreateSessionResourceInput!) {
|
|
100
|
+
pcm_create_session_resource(input: $input) {
|
|
101
|
+
resourceOriginId
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
const UPDATE_SESSION_RESOURCE = gql `
|
|
106
|
+
mutation UpdateSessionResource($input: UpdateSessionResourceInput!) {
|
|
107
|
+
pcm_update_session_resource(input: $input) {
|
|
108
|
+
resourceOriginId
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
`;
|
|
112
|
+
export { CREATE_SESSION, UPDATE_SESSION, CREATE_SESSION_RESOURCE, UPDATE_SESSION_RESOURCE };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphqlQueries.d.ts","sourceRoot":"","sources":["../../src/graphqlQueries.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,WAAW,uCAmDhB,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
const GET_SESSION = gql `
|
|
3
|
+
query Pcm_session($filters: SessionFilterInput, $first: Int!) {
|
|
4
|
+
pcm_session(filters: $filters, first: $first) {
|
|
5
|
+
edges {
|
|
6
|
+
node {
|
|
7
|
+
id
|
|
8
|
+
isActive
|
|
9
|
+
createdBy
|
|
10
|
+
modifiedBy
|
|
11
|
+
createdDate
|
|
12
|
+
modifiedDate
|
|
13
|
+
userAgent
|
|
14
|
+
originatingSystem
|
|
15
|
+
hasVisitedResources
|
|
16
|
+
referrerUrl
|
|
17
|
+
caseCreationError
|
|
18
|
+
isInternal
|
|
19
|
+
isResolved
|
|
20
|
+
isActive
|
|
21
|
+
pcmSessionDetails {
|
|
22
|
+
id
|
|
23
|
+
environment
|
|
24
|
+
description
|
|
25
|
+
sessionId
|
|
26
|
+
product
|
|
27
|
+
version
|
|
28
|
+
summary
|
|
29
|
+
issue
|
|
30
|
+
environment
|
|
31
|
+
periodicityOfIssue
|
|
32
|
+
timeFramesAndUrgency
|
|
33
|
+
type
|
|
34
|
+
severity
|
|
35
|
+
sla
|
|
36
|
+
accountNumber
|
|
37
|
+
folderNumber
|
|
38
|
+
contactSsoUsername
|
|
39
|
+
notifiedUsersInternal
|
|
40
|
+
notifiedUsersExternal
|
|
41
|
+
clusterId
|
|
42
|
+
noClusterIdReason
|
|
43
|
+
caseAlternateId
|
|
44
|
+
phoneCountryCode
|
|
45
|
+
noClusterIdReasonExplanation
|
|
46
|
+
phoneAreaCodePrefixLineNumber
|
|
47
|
+
screenSessionRequested
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
export { GET_SESSION };
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -25,4 +25,8 @@ export * from './outlier';
|
|
|
25
25
|
export * from './sentry';
|
|
26
26
|
export * from './constants/preferredLanguages';
|
|
27
27
|
export * from './tncUtil';
|
|
28
|
+
export * from './graphqlClientUtils';
|
|
29
|
+
export * from './graphqlQueries';
|
|
30
|
+
export * from './graphqlFetchUtils';
|
|
31
|
+
export * from './graphqlMutationUtils';
|
|
28
32
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,gCAAgC,CAAC;AAC/C,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,gCAAgC,CAAC;AAC/C,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC"}
|
package/lib/esm/index.js
CHANGED
|
@@ -25,3 +25,7 @@ export * from './outlier';
|
|
|
25
25
|
export * from './sentry';
|
|
26
26
|
export * from './constants/preferredLanguages';
|
|
27
27
|
export * from './tncUtil';
|
|
28
|
+
export * from './graphqlClientUtils';
|
|
29
|
+
export * from './graphqlQueries';
|
|
30
|
+
export * from './graphqlFetchUtils';
|
|
31
|
+
export * from './graphqlMutationUtils';
|
|
@@ -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
|
-
"
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-alpha.0",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "Vikas Rathee <vrathee@redhat.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -41,21 +41,25 @@
|
|
|
41
41
|
"prepublishOnly": "npm run build"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@
|
|
44
|
+
"@apollo/client": "^3.11.8",
|
|
45
|
+
"@cee-eng/hydrajs": "4.17.26",
|
|
46
|
+
"graphql": "^16.9.0",
|
|
45
47
|
"localforage": "^1.10.0",
|
|
46
48
|
"lodash": "^4.17.21",
|
|
47
49
|
"qs": "^6.7.0",
|
|
48
50
|
"solr-query-builder": "1.0.1"
|
|
49
51
|
},
|
|
50
52
|
"dependencies": {
|
|
51
|
-
"@
|
|
53
|
+
"@apollo/client": "^3.11.8",
|
|
54
|
+
"@cee-eng/hydrajs": "4.17.26",
|
|
52
55
|
"@rh-support/types": "2.0.4",
|
|
53
56
|
"date-fns": "3.6.0",
|
|
54
|
-
"date-fns-tz": "^3.1.3",
|
|
55
57
|
"dompurify": "^2.2.6",
|
|
58
|
+
"graphql": "^16.9.0",
|
|
56
59
|
"localforage": "^1.10.0",
|
|
57
60
|
"lodash": "^4.17.21",
|
|
58
61
|
"lucene": "^2.1.1",
|
|
62
|
+
"marked": "^1.2.4",
|
|
59
63
|
"qs": "^6.7.0",
|
|
60
64
|
"solr-query-builder": "1.0.1"
|
|
61
65
|
},
|
|
@@ -68,11 +72,12 @@
|
|
|
68
72
|
"@types/qs": "^6.9.1",
|
|
69
73
|
"i18next": "^23.15.0",
|
|
70
74
|
"jest": "^29.7.0",
|
|
71
|
-
"jest-environment-jsdom": "^29.7.0"
|
|
75
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
76
|
+
"moment-timezone": "^0.5.45"
|
|
72
77
|
},
|
|
73
78
|
"browserslist": [
|
|
74
79
|
"defaults and supports es6-module",
|
|
75
80
|
"maintained node versions"
|
|
76
81
|
],
|
|
77
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "adbfb4aacbf67de864e57d292d02fedc7589567b"
|
|
78
83
|
}
|