@rh-support/utils 2.1.45 → 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.
@@ -1,15 +1,16 @@
1
- type Granularity = 'day' | 'week' | 'month' | 'year';
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 isCurrentDateAfterDate: (date: string, granularity?: Granularity) => boolean;
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 isFutureDate: (date: string, granularity?: Granularity) => boolean;
8
- export interface AddToDate {
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?: Date | string | number;
11
- }
12
- export declare const addDaysToDate: (params: AddToDate) => Date;
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":"AAaA,KAAK,WAAW,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAErD,eAAO,MAAM,UAAU,wCAGX,IAAI,CAAC,qBAAqB,WASrC,CAAC;AAEF,eAAO,MAAM,cAAc,wCAGf,IAAI,CAAC,qBAAqB,WAerC,CAAC;AAEF,eAAO,MAAM,sBAAsB,SAAU,MAAM,gBAAe,WAAW,KAAW,OA4BvF,CAAC;AAEF,eAAO,MAAM,2BAA2B,WAAY,MAAM,KAAG,MAI5D,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAGxD,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,gBAAe,WAAW,KAAW,OA6B7E,CAAC;AAEF,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;CACjC;AAED,eAAO,MAAM,aAAa,WAAY,SAAS,KAAG,IAGjD,CAAC;AAEF,eAAO,MAAM,WAAW,eAAgB,MAAM,YAI7C,CAAC;AAOF,eAAO,MAAM,YAAY,wBAAyB,MAAM,cAAc,MAAM,cAe3E,CAAC"}
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"}
@@ -1,5 +1,5 @@
1
- import { addDays, isAfter, isValid, parseISO, startOfDay, startOfMonth, startOfWeek, startOfYear, subDays, } from 'date-fns';
2
- import { format, formatInTimeZone, fromZonedTime } from 'date-fns-tz';
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 isCurrentDateAfterDate = (date, granularity = 'day') => {
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
- const date = new Date();
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
- const date = subDays(new Date(), pastDays);
61
- return formatInTimeZone(date, 'UTC', "yyyy-MM-dd'T'HH:mm:ss'Z'");
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
- const parsedDate = parseISO(date);
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 addDays(new Date(date), days);
42
+ return moment(date).add(days, 'days');
93
43
  };
94
44
  export const isValidDate = (dateString) => {
95
45
  const parsedDate = parseISO(dateString);
@@ -5,8 +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
- declare function dtmTrackEventCaseCreationStepEncountered(caseSection: boolean, stepName: string, caseNumber?: string, caseType?: string, caseTitle?: string, product?: string, version?: string): void;
9
- declare function dtmTrackEventRecommendationListingItemClicked(url: string, activityName: string, contentListingRegion: string, contentID: string, contentPosition: number, contentTitle: string, contentUrl: string): void;
10
- declare function dtmTrackEventRecommendationListingDisplayed(contentListingRegion: any, activityName: any, listing: any, resultsCount: any): void;
11
- 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, };
12
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;AAGD,iBAAS,wCAAwC,CAC7C,WAAW,EAAE,OAAO,EACpB,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,QAenB;AAGD,iBAAS,6CAA6C,CAClD,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,oBAAoB,EAAE,MAAM,EAC5B,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,QA6BrB;AAGD,iBAAS,2CAA2C,CAAC,oBAAoB,KAAA,EAAE,YAAY,KAAA,EAAE,OAAO,KAAA,EAAE,YAAY,KAAA,QAW7G;AAED,OAAO,EACH,SAAS,EACT,eAAe,EACf,aAAa,EACb,wCAAwC,EACxC,6CAA6C,EAC7C,2CAA2C,GAC9C,CAAC"}
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"}
@@ -27,54 +27,10 @@ function dtmTrackEvent(eventName, stepName, caseNumber, product) {
27
27
  },
28
28
  });
29
29
  }
30
- // https://github.com/further-external/redhat-datalayer/blob/main/EDDL/global-datalayer.md#case-creation-step-encountered
31
- function dtmTrackEventCaseCreationStepEncountered(caseSection, stepName, caseNumber, caseType, caseTitle, product, version) {
32
- (window.appEventData || []).push({
33
- event: 'Case Creation Step Encountered',
34
- case: 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 })),
35
- });
36
- }
37
- // https://github.com/further-external/redhat-datalayer/blob/main/EDDL/global-datalayer.md#recommendation-listing-item-clicked
38
- function dtmTrackEventRecommendationListingItemClicked(url, activityName, contentListingRegion, contentID, contentPosition, contentTitle, contentUrl) {
39
- (window.appEventData || []).push({
40
- event: 'Recommendation Listing Item Clicked',
41
- linkInfo: {
42
- href: url,
43
- linkType: 'list',
44
- linkTypeName: 'listing result click',
45
- targetHost: 'access.redhat.com',
46
- text: 'text',
47
- },
48
- listingItemClicked: {
49
- activityName,
50
- contentListingRegion,
51
- listing: [
52
- {
53
- content: {
54
- contentID,
55
- contentPosition,
56
- contentTitle,
57
- contentUrl,
58
- displayFeature: 'recommended',
59
- displayFeatureTitle: 'listingItemClicked',
60
- },
61
- },
62
- ],
63
- listingType: 'listingItemClicked',
64
- },
65
- });
30
+ function dtmTrackEventCaseStartStopped(stepName, caseNumber, product) {
31
+ dtmTrackEvent('Case Step Encountered', stepName, caseNumber, product);
66
32
  }
67
- // https://github.com/further-external/redhat-datalayer/blob/main/EDDL/global-datalayer.md#recommendation-listing-displayed
68
- function dtmTrackEventRecommendationListingDisplayed(contentListingRegion, activityName, listing, resultsCount) {
69
- (window.appEventData || []).push({
70
- event: 'Recommendation Listing Displayed',
71
- listingDisplayed: {
72
- activityName,
73
- contentListingRegion,
74
- listing,
75
- listingType: 'content',
76
- resultsCount,
77
- },
78
- });
33
+ function dtmTrackEventCaseDetailsSolutionDocs(stepName, caseNumber, product) {
34
+ dtmTrackEvent('Case details solution docs', stepName, caseNumber, product);
79
35
  }
80
- export { haltEvent, pendoTrackEvent, dtmTrackEvent, dtmTrackEventCaseCreationStepEncountered, dtmTrackEventRecommendationListingItemClicked, dtmTrackEventRecommendationListingDisplayed, };
36
+ export { haltEvent, pendoTrackEvent, dtmTrackEvent, dtmTrackEventCaseStartStopped, dtmTrackEventCaseDetailsSolutionDocs, };
@@ -0,0 +1,4 @@
1
+ import { ApolloClient } from '@apollo/client';
2
+ declare const graphqlClient: ApolloClient<import("@apollo/client").NormalizedCacheObject>;
3
+ export { graphqlClient };
4
+ //# sourceMappingURL=graphqlClientUtils.d.ts.map
@@ -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,3 @@
1
+ declare const GET_SESSION: import("@apollo/client").DocumentNode;
2
+ export { GET_SESSION };
3
+ //# sourceMappingURL=graphqlQueries.d.ts.map
@@ -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 };
@@ -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
@@ -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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/utils",
3
- "version": "2.1.45",
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
- "@cee-eng/hydrajs": "4.17.27",
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
- "@cee-eng/hydrajs": "4.17.27",
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": "672881ff1c4cabf0dee016387c49f6abbdc952a7"
82
+ "gitHead": "adbfb4aacbf67de864e57d292d02fedc7589567b"
78
83
  }