@ludo.ninja/api 2.8.58 → 2.8.60
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/build/config/index.js +43 -83
- package/build/graphql_tools/__generated__/adminHost/schema.d.ts +53 -0
- package/build/graphql_tools/__generated__/adminHost/schema.js +36 -2
- package/build/index.d.ts +11 -0
- package/package.json +1 -1
- package/src/config/index.ts +71 -125
- package/src/graphql_tools/__generated__/adminHost/schema.ts +68 -0
- package/tsconfig.tsbuildinfo +1 -1
package/build/config/index.js
CHANGED
|
@@ -24,92 +24,60 @@ const resolvePendingRequests = () => {
|
|
|
24
24
|
pendingRequests = [];
|
|
25
25
|
};
|
|
26
26
|
let apolloClient;
|
|
27
|
+
const handleTokenRefresh = (operation, forward) => {
|
|
28
|
+
const { refreshToken } = (0, cookies_1.getCookies)();
|
|
29
|
+
const client = apolloClient ?? createApolloClient();
|
|
30
|
+
if (!isRefreshing) {
|
|
31
|
+
isRefreshing = true;
|
|
32
|
+
return (0, client_1.fromPromise)(client
|
|
33
|
+
.mutate({
|
|
34
|
+
context: { uri: index_1.hosts.authHost },
|
|
35
|
+
variables: { refreshToken },
|
|
36
|
+
mutation: index_1.authSchema.RefreshTokenDocument,
|
|
37
|
+
})
|
|
38
|
+
.then(({ data: { refreshToken: { tokenAuth, tokenRefresh } } }) => {
|
|
39
|
+
(0, cookies_1.refreshCookies)(tokenAuth, tokenRefresh, mainDomain);
|
|
40
|
+
resolvePendingRequests();
|
|
41
|
+
return true;
|
|
42
|
+
})
|
|
43
|
+
.catch(async () => {
|
|
44
|
+
await apolloClient?.mutate({
|
|
45
|
+
context: { uri: index_1.hosts.authHost },
|
|
46
|
+
mutation: index_1.authSchema.RevokeTokenDocument,
|
|
47
|
+
});
|
|
48
|
+
(0, cookies_1.destroyCookies)(mainDomain);
|
|
49
|
+
pendingRequests = [];
|
|
50
|
+
window.location.reload();
|
|
51
|
+
return false;
|
|
52
|
+
})
|
|
53
|
+
.finally(() => {
|
|
54
|
+
isRefreshing = false;
|
|
55
|
+
})).filter((value) => Boolean(value));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return (0, client_1.fromPromise)(new Promise((resolve) => {
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
pendingRequests.push(() => resolve());
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
};
|
|
27
64
|
const errorLink = (0, error_1.onError)(({ graphQLErrors, networkError, operation, forward }) => {
|
|
28
|
-
const { authToken
|
|
65
|
+
const { authToken } = (0, cookies_1.getCookies)();
|
|
29
66
|
if (graphQLErrors) {
|
|
30
67
|
graphQLErrors.forEach(({ message, locations, path }) => console.warn(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`));
|
|
31
68
|
for (const err of graphQLErrors) {
|
|
32
69
|
if (err.message.includes("Auth token not found") && authToken) {
|
|
33
|
-
|
|
34
|
-
const client = apolloClient ?? createApolloClient();
|
|
35
|
-
if (!isRefreshing) {
|
|
36
|
-
isRefreshing = true;
|
|
37
|
-
forward$ = (0, client_1.fromPromise)(client
|
|
38
|
-
.mutate({
|
|
39
|
-
context: { uri: index_1.hosts.authHost },
|
|
40
|
-
variables: { refreshToken },
|
|
41
|
-
mutation: index_1.authSchema.RefreshTokenDocument,
|
|
42
|
-
})
|
|
43
|
-
.then(({ data: { refreshToken: { tokenAuth, tokenRefresh }, }, }) => {
|
|
44
|
-
(0, cookies_1.refreshCookies)(tokenAuth, tokenRefresh, mainDomain);
|
|
45
|
-
resolvePendingRequests();
|
|
46
|
-
return true;
|
|
47
|
-
})
|
|
48
|
-
.catch(async () => {
|
|
49
|
-
await apolloClient?.mutate({
|
|
50
|
-
context: { uri: index_1.hosts.authHost },
|
|
51
|
-
mutation: index_1.authSchema.RevokeTokenDocument,
|
|
52
|
-
});
|
|
53
|
-
(0, cookies_1.destroyCookies)(mainDomain);
|
|
54
|
-
pendingRequests = [];
|
|
55
|
-
window.location.reload();
|
|
56
|
-
return false;
|
|
57
|
-
})
|
|
58
|
-
.finally(() => {
|
|
59
|
-
isRefreshing = false;
|
|
60
|
-
})).filter((value) => Boolean(value));
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
forward$ = (0, client_1.fromPromise)(new Promise((resolve) => {
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
65
|
-
// @ts-ignore
|
|
66
|
-
pendingRequests.push(() => resolve());
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
return forward$.flatMap(() => forward(operation));
|
|
70
|
+
return handleTokenRefresh(operation, forward).flatMap(() => forward(operation));
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
if (networkError) {
|
|
74
75
|
console.warn(`[Network error]: ${networkError}`);
|
|
76
|
+
if (networkError.message.includes("503")) {
|
|
77
|
+
console.error(`[503 Service Unavailable]: ${networkError.message}`);
|
|
78
|
+
}
|
|
75
79
|
if (networkError.message.includes("401") && authToken) {
|
|
76
|
-
|
|
77
|
-
const client = apolloClient ?? createApolloClient();
|
|
78
|
-
if (!isRefreshing) {
|
|
79
|
-
isRefreshing = true;
|
|
80
|
-
forward$ = (0, client_1.fromPromise)(client
|
|
81
|
-
.mutate({
|
|
82
|
-
context: { uri: index_1.hosts.authHost },
|
|
83
|
-
variables: { refreshToken },
|
|
84
|
-
mutation: index_1.authSchema.RefreshTokenDocument,
|
|
85
|
-
})
|
|
86
|
-
.then(({ data: { refreshToken: { tokenAuth, tokenRefresh }, }, }) => {
|
|
87
|
-
(0, cookies_1.refreshCookies)(tokenAuth, tokenRefresh, mainDomain);
|
|
88
|
-
resolvePendingRequests();
|
|
89
|
-
return true;
|
|
90
|
-
})
|
|
91
|
-
.catch(async () => {
|
|
92
|
-
await apolloClient?.mutate({
|
|
93
|
-
context: { uri: index_1.hosts.authHost },
|
|
94
|
-
mutation: index_1.authSchema.RevokeTokenDocument,
|
|
95
|
-
});
|
|
96
|
-
(0, cookies_1.destroyCookies)(mainDomain);
|
|
97
|
-
pendingRequests = [];
|
|
98
|
-
window.location.reload();
|
|
99
|
-
return false;
|
|
100
|
-
})
|
|
101
|
-
.finally(() => {
|
|
102
|
-
isRefreshing = false;
|
|
103
|
-
})).filter((value) => Boolean(value));
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
forward$ = (0, client_1.fromPromise)(new Promise((resolve) => {
|
|
107
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
108
|
-
// @ts-ignore
|
|
109
|
-
pendingRequests.push(() => resolve());
|
|
110
|
-
}));
|
|
111
|
-
}
|
|
112
|
-
return forward$.flatMap(() => forward(operation));
|
|
80
|
+
return handleTokenRefresh(operation, forward).flatMap(() => forward(operation));
|
|
113
81
|
}
|
|
114
82
|
}
|
|
115
83
|
});
|
|
@@ -158,26 +126,18 @@ function createApolloClient() {
|
|
|
158
126
|
function initializeApollo(initialState = null, domain) {
|
|
159
127
|
const _apolloClient = apolloClient ?? createApolloClient();
|
|
160
128
|
mainDomain = domain || '';
|
|
161
|
-
// If your page has Next.js data fetching methods that use Apollo Client, the initial state
|
|
162
|
-
// gets hydrated here
|
|
163
129
|
if (initialState) {
|
|
164
|
-
// Get existing cache, loaded during client side data fetching
|
|
165
130
|
const existingCache = _apolloClient.extract();
|
|
166
|
-
// Merge the initialState from getStaticProps/getServerSideProps in the existing cache
|
|
167
131
|
const data = (0, deepmerge_1.default)(existingCache, initialState, {
|
|
168
|
-
// combine arrays using object equality (like in sets)
|
|
169
132
|
arrayMerge: (destinationArray, sourceArray) => [
|
|
170
133
|
...sourceArray,
|
|
171
134
|
...destinationArray.filter((d) => sourceArray.every((s) => !(0, lodash_isequal_1.default)(d, s))),
|
|
172
135
|
],
|
|
173
136
|
});
|
|
174
|
-
// Restore the cache with the merged data
|
|
175
137
|
_apolloClient.cache.restore(data);
|
|
176
138
|
}
|
|
177
|
-
// For SSG and SSR always create a new Apollo Client
|
|
178
139
|
if (typeof window === "undefined")
|
|
179
140
|
return _apolloClient;
|
|
180
|
-
// Create the Apollo Client once in the client
|
|
181
141
|
if (!apolloClient)
|
|
182
142
|
apolloClient = _apolloClient;
|
|
183
143
|
return _apolloClient;
|
|
@@ -242,6 +242,12 @@ export type ICategoryInput = {
|
|
|
242
242
|
name: Scalars['String'];
|
|
243
243
|
matchingWords: Array<Scalars['String']>;
|
|
244
244
|
};
|
|
245
|
+
export type ICheckInviteCodeData = {
|
|
246
|
+
code: Scalars['String'];
|
|
247
|
+
isUsed: Scalars['Boolean'];
|
|
248
|
+
usedTimes: Scalars['Int'];
|
|
249
|
+
maxUsagesLimit: Scalars['Int'];
|
|
250
|
+
};
|
|
245
251
|
export type IContactSupportFilterInput = {
|
|
246
252
|
idTerm?: Maybe<Scalars['String']>;
|
|
247
253
|
userIdTerm?: Maybe<Scalars['String']>;
|
|
@@ -483,6 +489,7 @@ export type IQuery = {
|
|
|
483
489
|
fetchUserFeedbackPage: IUserFeedbackPage;
|
|
484
490
|
fetchRegistrationInvitePage: IRegistrationInvitePage;
|
|
485
491
|
fetchAdminInvitesPage: IInvitesPage;
|
|
492
|
+
checkInviteCode: ICheckInviteCodeData;
|
|
486
493
|
fetchAdminOpportunitiesPage: IOpportunitiesPage;
|
|
487
494
|
fetchAdminCategories: Array<IAdminCategory>;
|
|
488
495
|
fetchAdminCategoriesPage: ICategoriesPage;
|
|
@@ -533,6 +540,9 @@ export type IQueryFetchAdminInvitesPageArgs = {
|
|
|
533
540
|
sort: IInvitesSortInput;
|
|
534
541
|
page: IAdminPageInput;
|
|
535
542
|
};
|
|
543
|
+
export type IQueryCheckInviteCodeArgs = {
|
|
544
|
+
code: Scalars['String'];
|
|
545
|
+
};
|
|
536
546
|
export type IQueryFetchAdminOpportunitiesPageArgs = {
|
|
537
547
|
filter: IOpportunitiesFilterInput;
|
|
538
548
|
sort: IOpportunitiesSortInput;
|
|
@@ -754,6 +764,7 @@ export type IResolversTypes = {
|
|
|
754
764
|
CategoriesPage: ResolverTypeWrapper<ICategoriesPage>;
|
|
755
765
|
CategoriesSortInput: ICategoriesSortInput;
|
|
756
766
|
CategoryInput: ICategoryInput;
|
|
767
|
+
CheckInviteCodeData: ResolverTypeWrapper<ICheckInviteCodeData>;
|
|
757
768
|
ContactSupportFilterInput: IContactSupportFilterInput;
|
|
758
769
|
ContactSupportPage: ResolverTypeWrapper<IContactSupportPage>;
|
|
759
770
|
ContactSupportSortInput: IContactSupportSortInput;
|
|
@@ -832,6 +843,7 @@ export type IResolversParentTypes = {
|
|
|
832
843
|
CategoriesPage: ICategoriesPage;
|
|
833
844
|
CategoriesSortInput: ICategoriesSortInput;
|
|
834
845
|
CategoryInput: ICategoryInput;
|
|
846
|
+
CheckInviteCodeData: ICheckInviteCodeData;
|
|
835
847
|
ContactSupportFilterInput: IContactSupportFilterInput;
|
|
836
848
|
ContactSupportPage: IContactSupportPage;
|
|
837
849
|
ContactSupportSortInput: IContactSupportSortInput;
|
|
@@ -1062,6 +1074,13 @@ export type ICategoriesPageResolvers<ContextType = any, ParentType extends IReso
|
|
|
1062
1074
|
nextPage?: Resolver<Maybe<IResolversTypes['AdminPage']>, ParentType, ContextType>;
|
|
1063
1075
|
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
|
|
1064
1076
|
};
|
|
1077
|
+
export type ICheckInviteCodeDataResolvers<ContextType = any, ParentType extends IResolversParentTypes['CheckInviteCodeData'] = IResolversParentTypes['CheckInviteCodeData']> = {
|
|
1078
|
+
code?: Resolver<IResolversTypes['String'], ParentType, ContextType>;
|
|
1079
|
+
isUsed?: Resolver<IResolversTypes['Boolean'], ParentType, ContextType>;
|
|
1080
|
+
usedTimes?: Resolver<IResolversTypes['Int'], ParentType, ContextType>;
|
|
1081
|
+
maxUsagesLimit?: Resolver<IResolversTypes['Int'], ParentType, ContextType>;
|
|
1082
|
+
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
|
|
1083
|
+
};
|
|
1065
1084
|
export type IContactSupportPageResolvers<ContextType = any, ParentType extends IResolversParentTypes['ContactSupportPage'] = IResolversParentTypes['ContactSupportPage']> = {
|
|
1066
1085
|
contactSupports?: Resolver<Array<IResolversTypes['AdminContactSupport']>, ParentType, ContextType>;
|
|
1067
1086
|
nextPage?: Resolver<Maybe<IResolversTypes['AdminPage']>, ParentType, ContextType>;
|
|
@@ -1128,6 +1147,7 @@ export type IQueryResolvers<ContextType = any, ParentType extends IResolversPare
|
|
|
1128
1147
|
fetchUserFeedbackPage?: Resolver<IResolversTypes['UserFeedbackPage'], ParentType, ContextType, RequireFields<IQueryFetchUserFeedbackPageArgs, 'filter' | 'sort' | 'page'>>;
|
|
1129
1148
|
fetchRegistrationInvitePage?: Resolver<IResolversTypes['RegistrationInvitePage'], ParentType, ContextType, RequireFields<IQueryFetchRegistrationInvitePageArgs, 'filter' | 'sort' | 'page'>>;
|
|
1130
1149
|
fetchAdminInvitesPage?: Resolver<IResolversTypes['InvitesPage'], ParentType, ContextType, RequireFields<IQueryFetchAdminInvitesPageArgs, 'filter' | 'sort' | 'page'>>;
|
|
1150
|
+
checkInviteCode?: Resolver<IResolversTypes['CheckInviteCodeData'], ParentType, ContextType, RequireFields<IQueryCheckInviteCodeArgs, 'code'>>;
|
|
1131
1151
|
fetchAdminOpportunitiesPage?: Resolver<IResolversTypes['OpportunitiesPage'], ParentType, ContextType, RequireFields<IQueryFetchAdminOpportunitiesPageArgs, 'filter' | 'sort' | 'page'>>;
|
|
1132
1152
|
fetchAdminCategories?: Resolver<Array<IResolversTypes['AdminCategory']>, ParentType, ContextType>;
|
|
1133
1153
|
fetchAdminCategoriesPage?: Resolver<IResolversTypes['CategoriesPage'], ParentType, ContextType, RequireFields<IQueryFetchAdminCategoriesPageArgs, 'filter' | 'sort' | 'page'>>;
|
|
@@ -1215,6 +1235,7 @@ export type IResolvers<ContextType = any> = {
|
|
|
1215
1235
|
AdminXp?: IAdminXpResolvers<ContextType>;
|
|
1216
1236
|
BrandsPage?: IBrandsPageResolvers<ContextType>;
|
|
1217
1237
|
CategoriesPage?: ICategoriesPageResolvers<ContextType>;
|
|
1238
|
+
CheckInviteCodeData?: ICheckInviteCodeDataResolvers<ContextType>;
|
|
1218
1239
|
ContactSupportPage?: IContactSupportPageResolvers<ContextType>;
|
|
1219
1240
|
ContentReportPage?: IContentReportPageResolvers<ContextType>;
|
|
1220
1241
|
FormOpportunityPage?: IFormOpportunityPageResolvers<ContextType>;
|
|
@@ -1285,6 +1306,12 @@ export type IUpdateProfileStatusMutationVariables = Exact<{
|
|
|
1285
1306
|
isActive: Scalars['Boolean'];
|
|
1286
1307
|
}>;
|
|
1287
1308
|
export type IUpdateProfileStatusMutation = Pick<IMutation, 'updateProfileStatus'>;
|
|
1309
|
+
export type ICheckInviteCodeQueryVariables = Exact<{
|
|
1310
|
+
code: Scalars['String'];
|
|
1311
|
+
}>;
|
|
1312
|
+
export type ICheckInviteCodeQuery = {
|
|
1313
|
+
checkInviteCode: Pick<ICheckInviteCodeData, 'code' | 'isUsed' | 'usedTimes' | 'maxUsagesLimit'>;
|
|
1314
|
+
};
|
|
1288
1315
|
export type IFetchContactSupportPageQueryVariables = Exact<{
|
|
1289
1316
|
filter: IContactSupportFilterInput;
|
|
1290
1317
|
sort: IContactSupportSortInput;
|
|
@@ -1706,6 +1733,32 @@ export declare function useUpdateProfileStatusMutation(baseOptions?: Apollo.Muta
|
|
|
1706
1733
|
export type UpdateProfileStatusMutationHookResult = ReturnType<typeof useUpdateProfileStatusMutation>;
|
|
1707
1734
|
export type UpdateProfileStatusMutationResult = Apollo.MutationResult<IUpdateProfileStatusMutation>;
|
|
1708
1735
|
export type UpdateProfileStatusMutationOptions = Apollo.BaseMutationOptions<IUpdateProfileStatusMutation, IUpdateProfileStatusMutationVariables>;
|
|
1736
|
+
export declare const CheckInviteCodeDocument: Apollo.DocumentNode;
|
|
1737
|
+
/**
|
|
1738
|
+
* __useCheckInviteCodeQuery__
|
|
1739
|
+
*
|
|
1740
|
+
* To run a query within a React component, call `useCheckInviteCodeQuery` and pass it any options that fit your needs.
|
|
1741
|
+
* When your component renders, `useCheckInviteCodeQuery` returns an object from Apollo Client that contains loading, error, and data properties
|
|
1742
|
+
* you can use to render your UI.
|
|
1743
|
+
*
|
|
1744
|
+
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
|
|
1745
|
+
*
|
|
1746
|
+
* @example
|
|
1747
|
+
* const { data, loading, error } = useCheckInviteCodeQuery({
|
|
1748
|
+
* variables: {
|
|
1749
|
+
* code: // value for 'code'
|
|
1750
|
+
* },
|
|
1751
|
+
* });
|
|
1752
|
+
*/
|
|
1753
|
+
export declare function useCheckInviteCodeQuery(baseOptions: Apollo.QueryHookOptions<ICheckInviteCodeQuery, ICheckInviteCodeQueryVariables>): Apollo.QueryResult<ICheckInviteCodeQuery, Exact<{
|
|
1754
|
+
code: string;
|
|
1755
|
+
}>>;
|
|
1756
|
+
export declare function useCheckInviteCodeLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ICheckInviteCodeQuery, ICheckInviteCodeQueryVariables>): Apollo.LazyQueryResultTuple<ICheckInviteCodeQuery, Exact<{
|
|
1757
|
+
code: string;
|
|
1758
|
+
}>>;
|
|
1759
|
+
export type CheckInviteCodeQueryHookResult = ReturnType<typeof useCheckInviteCodeQuery>;
|
|
1760
|
+
export type CheckInviteCodeLazyQueryHookResult = ReturnType<typeof useCheckInviteCodeLazyQuery>;
|
|
1761
|
+
export type CheckInviteCodeQueryResult = Apollo.QueryResult<ICheckInviteCodeQuery, ICheckInviteCodeQueryVariables>;
|
|
1709
1762
|
export declare const FetchContactSupportPageDocument: Apollo.DocumentNode;
|
|
1710
1763
|
/**
|
|
1711
1764
|
* __useFetchContactSupportPageQuery__
|
|
@@ -23,8 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
exports.useFetchBlockchainsLazyQuery = exports.useFetchBlockchainsQuery = exports.FetchBlockchainsDocument = exports.useFetchAdminXpPageLazyQuery = exports.useFetchAdminXpPageQuery = exports.FetchAdminXpPageDocument = exports.useFetchAdminUsersPageLazyQuery = exports.useFetchAdminUsersPageQuery = exports.FetchAdminUsersPageDocument = exports.useFetchAdminReferralsPageLazyQuery = exports.useFetchAdminReferralsPageQuery = exports.FetchAdminReferralsPageDocument = exports.useFetchAdminOpportunitiesPageLazyQuery = exports.useFetchAdminOpportunitiesPageQuery = exports.FetchAdminOpportunitiesPageDocument = exports.useFetchAdminInvitesPageLazyQuery = exports.useFetchAdminInvitesPageQuery = exports.FetchAdminInvitesPageDocument = exports.useFetchAdminCategoriesPageLazyQuery = exports.useFetchAdminCategoriesPageQuery = void 0;
|
|
26
|
+
exports.FetchAdminCategoriesDocument = exports.useFetchAdminBrandsPageLazyQuery = exports.useFetchAdminBrandsPageQuery = exports.FetchAdminBrandsPageDocument = exports.useFetchAdminBrandsLazyQuery = exports.useFetchAdminBrandsQuery = exports.FetchAdminBrandsDocument = exports.useFetchUserFeedbackPageLazyQuery = exports.useFetchUserFeedbackPageQuery = exports.FetchUserFeedbackPageDocument = exports.useFetchRegistrationInvitePageLazyQuery = exports.useFetchRegistrationInvitePageQuery = exports.FetchRegistrationInvitePageDocument = exports.useFetchPartnershipInquiryPageLazyQuery = exports.useFetchPartnershipInquiryPageQuery = exports.FetchPartnershipInquiryPageDocument = exports.useFetchInvestorInquiryPageLazyQuery = exports.useFetchInvestorInquiryPageQuery = exports.FetchInvestorInquiryPageDocument = exports.useFetchFormOpportunityPageLazyQuery = exports.useFetchFormOpportunityPageQuery = exports.FetchFormOpportunityPageDocument = exports.useFetchContentReportPageLazyQuery = exports.useFetchContentReportPageQuery = exports.FetchContentReportPageDocument = exports.useFetchContactSupportPageLazyQuery = exports.useFetchContactSupportPageQuery = exports.FetchContactSupportPageDocument = exports.useCheckInviteCodeLazyQuery = exports.useCheckInviteCodeQuery = exports.CheckInviteCodeDocument = exports.useUpdateProfileStatusMutation = exports.UpdateProfileStatusDocument = exports.useUpdateCategoryArchivedStatusMutation = exports.UpdateCategoryArchivedStatusDocument = exports.useUpdateBrandArchivedStatusMutation = exports.UpdateBrandArchivedStatusDocument = exports.useRemoveInviteCodeMutation = exports.RemoveInviteCodeDocument = exports.useAddInviteCodesMutation = exports.AddInviteCodesDocument = exports.useCreateAdminOpportunityMutation = exports.CreateAdminOpportunityDocument = exports.useCreateBrandMutation = exports.CreateBrandDocument = exports.useCreateCategoryMutation = exports.CreateCategoryDocument = exports.useChangeXpPointsMutation = exports.ChangeXpPointsDocument = exports.ISortDirection = void 0;
|
|
27
|
+
exports.useFetchBlockchainsLazyQuery = exports.useFetchBlockchainsQuery = exports.FetchBlockchainsDocument = exports.useFetchAdminXpPageLazyQuery = exports.useFetchAdminXpPageQuery = exports.FetchAdminXpPageDocument = exports.useFetchAdminUsersPageLazyQuery = exports.useFetchAdminUsersPageQuery = exports.FetchAdminUsersPageDocument = exports.useFetchAdminReferralsPageLazyQuery = exports.useFetchAdminReferralsPageQuery = exports.FetchAdminReferralsPageDocument = exports.useFetchAdminOpportunitiesPageLazyQuery = exports.useFetchAdminOpportunitiesPageQuery = exports.FetchAdminOpportunitiesPageDocument = exports.useFetchAdminInvitesPageLazyQuery = exports.useFetchAdminInvitesPageQuery = exports.FetchAdminInvitesPageDocument = exports.useFetchAdminCategoriesPageLazyQuery = exports.useFetchAdminCategoriesPageQuery = exports.FetchAdminCategoriesPageDocument = exports.useFetchAdminCategoriesLazyQuery = exports.useFetchAdminCategoriesQuery = void 0;
|
|
28
28
|
const client_1 = require("@apollo/client");
|
|
29
29
|
const Apollo = __importStar(require("@apollo/client"));
|
|
30
30
|
/** front-end asked for lower case values */
|
|
@@ -275,6 +275,40 @@ function useUpdateProfileStatusMutation(baseOptions) {
|
|
|
275
275
|
return Apollo.useMutation(exports.UpdateProfileStatusDocument, baseOptions);
|
|
276
276
|
}
|
|
277
277
|
exports.useUpdateProfileStatusMutation = useUpdateProfileStatusMutation;
|
|
278
|
+
exports.CheckInviteCodeDocument = (0, client_1.gql) `
|
|
279
|
+
query CheckInviteCode($code: String!) {
|
|
280
|
+
checkInviteCode(code: $code) {
|
|
281
|
+
code
|
|
282
|
+
isUsed
|
|
283
|
+
usedTimes
|
|
284
|
+
maxUsagesLimit
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
`;
|
|
288
|
+
/**
|
|
289
|
+
* __useCheckInviteCodeQuery__
|
|
290
|
+
*
|
|
291
|
+
* To run a query within a React component, call `useCheckInviteCodeQuery` and pass it any options that fit your needs.
|
|
292
|
+
* When your component renders, `useCheckInviteCodeQuery` returns an object from Apollo Client that contains loading, error, and data properties
|
|
293
|
+
* you can use to render your UI.
|
|
294
|
+
*
|
|
295
|
+
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* const { data, loading, error } = useCheckInviteCodeQuery({
|
|
299
|
+
* variables: {
|
|
300
|
+
* code: // value for 'code'
|
|
301
|
+
* },
|
|
302
|
+
* });
|
|
303
|
+
*/
|
|
304
|
+
function useCheckInviteCodeQuery(baseOptions) {
|
|
305
|
+
return Apollo.useQuery(exports.CheckInviteCodeDocument, baseOptions);
|
|
306
|
+
}
|
|
307
|
+
exports.useCheckInviteCodeQuery = useCheckInviteCodeQuery;
|
|
308
|
+
function useCheckInviteCodeLazyQuery(baseOptions) {
|
|
309
|
+
return Apollo.useLazyQuery(exports.CheckInviteCodeDocument, baseOptions);
|
|
310
|
+
}
|
|
311
|
+
exports.useCheckInviteCodeLazyQuery = useCheckInviteCodeLazyQuery;
|
|
278
312
|
exports.FetchContactSupportPageDocument = (0, client_1.gql) `
|
|
279
313
|
query FetchContactSupportPage($filter: ContactSupportFilterInput!, $sort: ContactSupportSortInput!, $page: AdminPageInput!) {
|
|
280
314
|
fetchContactSupportPage(filter: $filter, sort: $sort, page: $page) {
|
package/build/index.d.ts
CHANGED
|
@@ -1145,6 +1145,16 @@ declare const schema: {
|
|
|
1145
1145
|
userId: string;
|
|
1146
1146
|
isActive: boolean;
|
|
1147
1147
|
}>, import("@apollo/client").DefaultContext, import("@apollo/client").ApolloCache<any>>;
|
|
1148
|
+
useCheckInviteCodeQuery(baseOptions: import("@apollo/client").QueryHookOptions<adminSchema.ICheckInviteCodeQuery, adminSchema.Exact<{
|
|
1149
|
+
code: string;
|
|
1150
|
+
}>>): import("@apollo/client").QueryResult<adminSchema.ICheckInviteCodeQuery, adminSchema.Exact<{
|
|
1151
|
+
code: string;
|
|
1152
|
+
}>>;
|
|
1153
|
+
useCheckInviteCodeLazyQuery(baseOptions?: import("@apollo/client").LazyQueryHookOptions<adminSchema.ICheckInviteCodeQuery, adminSchema.Exact<{
|
|
1154
|
+
code: string;
|
|
1155
|
+
}>> | undefined): import("@apollo/client").LazyQueryResultTuple<adminSchema.ICheckInviteCodeQuery, adminSchema.Exact<{
|
|
1156
|
+
code: string;
|
|
1157
|
+
}>>;
|
|
1148
1158
|
useFetchContactSupportPageQuery(baseOptions: import("@apollo/client").QueryHookOptions<adminSchema.IFetchContactSupportPageQuery, adminSchema.Exact<{
|
|
1149
1159
|
filter: adminSchema.IContactSupportFilterInput;
|
|
1150
1160
|
sort: adminSchema.IContactSupportSortInput;
|
|
@@ -1437,6 +1447,7 @@ declare const schema: {
|
|
|
1437
1447
|
UpdateBrandArchivedStatusDocument: import("graphql").DocumentNode;
|
|
1438
1448
|
UpdateCategoryArchivedStatusDocument: import("graphql").DocumentNode;
|
|
1439
1449
|
UpdateProfileStatusDocument: import("graphql").DocumentNode;
|
|
1450
|
+
CheckInviteCodeDocument: import("graphql").DocumentNode;
|
|
1440
1451
|
FetchContactSupportPageDocument: import("graphql").DocumentNode;
|
|
1441
1452
|
FetchContentReportPageDocument: import("graphql").DocumentNode;
|
|
1442
1453
|
FetchFormOpportunityPageDocument: import("graphql").DocumentNode;
|
package/package.json
CHANGED
package/src/config/index.ts
CHANGED
|
@@ -7,17 +7,17 @@ import {
|
|
|
7
7
|
split,
|
|
8
8
|
ApolloLink,
|
|
9
9
|
} from "@apollo/client";
|
|
10
|
-
import {onError} from "@apollo/client/link/error";
|
|
11
|
-
import {setContext} from "@apollo/client/link/context";
|
|
12
|
-
import {createUploadLink} from "apollo-upload-client";
|
|
10
|
+
import { onError } from "@apollo/client/link/error";
|
|
11
|
+
import { setContext } from "@apollo/client/link/context";
|
|
12
|
+
import { createUploadLink } from "apollo-upload-client";
|
|
13
13
|
import merge from "deepmerge";
|
|
14
14
|
import isEqual from "lodash.isequal";
|
|
15
|
-
import {destroyCookies, getCookies, refreshCookies} from "../cookies";
|
|
16
|
-
import {typePoliciesPortal} from "./typePolicies";
|
|
17
|
-
import {GraphQLWsLink} from "@apollo/client/link/subscriptions";
|
|
18
|
-
import {getMainDefinition} from "@apollo/client/utilities";
|
|
19
|
-
import {createClient} from "graphql-ws";
|
|
20
|
-
import {hosts, authSchema as schema} from "../index";
|
|
15
|
+
import { destroyCookies, getCookies, refreshCookies } from "../cookies";
|
|
16
|
+
import { typePoliciesPortal } from "./typePolicies";
|
|
17
|
+
import { GraphQLWsLink } from "@apollo/client/link/subscriptions";
|
|
18
|
+
import { getMainDefinition } from "@apollo/client/utilities";
|
|
19
|
+
import { createClient } from "graphql-ws";
|
|
20
|
+
import { hosts, authSchema as schema } from "../index";
|
|
21
21
|
|
|
22
22
|
let isRefreshing = false;
|
|
23
23
|
let pendingRequests: never[] = [];
|
|
@@ -30,63 +30,59 @@ const resolvePendingRequests = () => {
|
|
|
30
30
|
|
|
31
31
|
let apolloClient: ApolloClient<NormalizedCacheObject> | undefined;
|
|
32
32
|
|
|
33
|
-
const
|
|
34
|
-
const {
|
|
33
|
+
const handleTokenRefresh = (operation: any, forward: any) => {
|
|
34
|
+
const { refreshToken } = getCookies();
|
|
35
|
+
const client = apolloClient ?? createApolloClient();
|
|
36
|
+
|
|
37
|
+
if (!isRefreshing) {
|
|
38
|
+
isRefreshing = true;
|
|
39
|
+
return fromPromise(
|
|
40
|
+
client
|
|
41
|
+
.mutate({
|
|
42
|
+
context: { uri: hosts.authHost },
|
|
43
|
+
variables: { refreshToken },
|
|
44
|
+
mutation: schema.RefreshTokenDocument,
|
|
45
|
+
})
|
|
46
|
+
.then(({ data: { refreshToken: { tokenAuth, tokenRefresh } } }) => {
|
|
47
|
+
refreshCookies(tokenAuth, tokenRefresh, mainDomain);
|
|
48
|
+
resolvePendingRequests();
|
|
49
|
+
return true;
|
|
50
|
+
})
|
|
51
|
+
.catch(async () => {
|
|
52
|
+
await apolloClient?.mutate({
|
|
53
|
+
context: { uri: hosts.authHost },
|
|
54
|
+
mutation: schema.RevokeTokenDocument,
|
|
55
|
+
});
|
|
56
|
+
destroyCookies(mainDomain);
|
|
57
|
+
pendingRequests = [];
|
|
58
|
+
window.location.reload();
|
|
59
|
+
return false;
|
|
60
|
+
})
|
|
61
|
+
.finally(() => {
|
|
62
|
+
isRefreshing = false;
|
|
63
|
+
})
|
|
64
|
+
).filter((value) => Boolean(value));
|
|
65
|
+
} else {
|
|
66
|
+
return fromPromise(
|
|
67
|
+
new Promise((resolve) => {
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
pendingRequests.push(() => resolve());
|
|
70
|
+
})
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const errorLink = onError(({ graphQLErrors, networkError, operation, forward }) => {
|
|
76
|
+
const { authToken } = getCookies();
|
|
35
77
|
|
|
36
78
|
if (graphQLErrors) {
|
|
37
|
-
graphQLErrors.forEach(({message, locations, path}) =>
|
|
38
|
-
console.warn(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`)
|
|
79
|
+
graphQLErrors.forEach(({ message, locations, path }) =>
|
|
80
|
+
console.warn(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`)
|
|
39
81
|
);
|
|
40
82
|
|
|
41
83
|
for (const err of graphQLErrors) {
|
|
42
84
|
if (err.message.includes("Auth token not found") && authToken) {
|
|
43
|
-
|
|
44
|
-
const client = apolloClient ?? createApolloClient();
|
|
45
|
-
if (!isRefreshing) {
|
|
46
|
-
isRefreshing = true;
|
|
47
|
-
forward$ = fromPromise(
|
|
48
|
-
client
|
|
49
|
-
.mutate({
|
|
50
|
-
context: {uri: hosts.authHost},
|
|
51
|
-
variables: {refreshToken},
|
|
52
|
-
mutation: schema.RefreshTokenDocument,
|
|
53
|
-
})
|
|
54
|
-
.then(
|
|
55
|
-
({
|
|
56
|
-
data: {
|
|
57
|
-
refreshToken: {tokenAuth, tokenRefresh},
|
|
58
|
-
},
|
|
59
|
-
}) => {
|
|
60
|
-
refreshCookies(tokenAuth, tokenRefresh, mainDomain);
|
|
61
|
-
resolvePendingRequests();
|
|
62
|
-
return true;
|
|
63
|
-
},
|
|
64
|
-
)
|
|
65
|
-
.catch(async () => {
|
|
66
|
-
await apolloClient?.mutate({
|
|
67
|
-
context: {uri: hosts.authHost},
|
|
68
|
-
mutation: schema.RevokeTokenDocument,
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
destroyCookies(mainDomain);
|
|
72
|
-
pendingRequests = [];
|
|
73
|
-
window.location.reload();
|
|
74
|
-
return false;
|
|
75
|
-
})
|
|
76
|
-
.finally(() => {
|
|
77
|
-
isRefreshing = false;
|
|
78
|
-
}),
|
|
79
|
-
).filter((value) => Boolean(value));
|
|
80
|
-
} else {
|
|
81
|
-
forward$ = fromPromise(
|
|
82
|
-
new Promise((resolve) => {
|
|
83
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
84
|
-
// @ts-ignore
|
|
85
|
-
pendingRequests.push(() => resolve());
|
|
86
|
-
}),
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
return forward$.flatMap(() => forward(operation));
|
|
85
|
+
return handleTokenRefresh(operation, forward).flatMap(() => forward(operation));
|
|
90
86
|
}
|
|
91
87
|
}
|
|
92
88
|
}
|
|
@@ -94,66 +90,24 @@ const errorLink = onError(({graphQLErrors, networkError, operation, forward}) =>
|
|
|
94
90
|
if (networkError) {
|
|
95
91
|
console.warn(`[Network error]: ${networkError}`);
|
|
96
92
|
|
|
93
|
+
if (networkError.message.includes("503")) {
|
|
94
|
+
console.error(`[503 Service Unavailable]: ${networkError.message}`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
97
|
if (networkError.message.includes("401") && authToken) {
|
|
98
|
-
|
|
99
|
-
const client = apolloClient ?? createApolloClient();
|
|
100
|
-
if (!isRefreshing) {
|
|
101
|
-
isRefreshing = true;
|
|
102
|
-
forward$ = fromPromise(
|
|
103
|
-
client
|
|
104
|
-
.mutate({
|
|
105
|
-
context: {uri: hosts.authHost},
|
|
106
|
-
variables: {refreshToken},
|
|
107
|
-
mutation: schema.RefreshTokenDocument,
|
|
108
|
-
})
|
|
109
|
-
.then(
|
|
110
|
-
({
|
|
111
|
-
data: {
|
|
112
|
-
refreshToken: {tokenAuth, tokenRefresh},
|
|
113
|
-
},
|
|
114
|
-
}) => {
|
|
115
|
-
refreshCookies(tokenAuth, tokenRefresh, mainDomain);
|
|
116
|
-
resolvePendingRequests();
|
|
117
|
-
return true;
|
|
118
|
-
},
|
|
119
|
-
)
|
|
120
|
-
.catch(async () => {
|
|
121
|
-
await apolloClient?.mutate({
|
|
122
|
-
context: {uri: hosts.authHost},
|
|
123
|
-
mutation: schema.RevokeTokenDocument,
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
destroyCookies(mainDomain);
|
|
127
|
-
pendingRequests = [];
|
|
128
|
-
window.location.reload();
|
|
129
|
-
return false;
|
|
130
|
-
})
|
|
131
|
-
.finally(() => {
|
|
132
|
-
isRefreshing = false;
|
|
133
|
-
}),
|
|
134
|
-
).filter((value) => Boolean(value));
|
|
135
|
-
} else {
|
|
136
|
-
forward$ = fromPromise(
|
|
137
|
-
new Promise((resolve) => {
|
|
138
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
139
|
-
// @ts-ignore
|
|
140
|
-
pendingRequests.push(() => resolve());
|
|
141
|
-
}),
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
return forward$.flatMap(() => forward(operation));
|
|
98
|
+
return handleTokenRefresh(operation, forward).flatMap(() => forward(operation));
|
|
145
99
|
}
|
|
146
100
|
}
|
|
147
101
|
});
|
|
148
102
|
|
|
149
|
-
const authLink = setContext(async (operation, {headers}) => {
|
|
150
|
-
const {authToken} = getCookies();
|
|
103
|
+
const authLink = setContext(async (operation, { headers }) => {
|
|
104
|
+
const { authToken } = getCookies();
|
|
151
105
|
|
|
152
106
|
const header = authToken
|
|
153
107
|
? {
|
|
154
|
-
headers: {...headers, "x-client-authorization": `${authToken}`},
|
|
108
|
+
headers: { ...headers, "x-client-authorization": `${authToken}` },
|
|
155
109
|
}
|
|
156
|
-
: {headers: {...headers}};
|
|
110
|
+
: { headers: { ...headers } };
|
|
157
111
|
|
|
158
112
|
return {
|
|
159
113
|
headers: header.headers,
|
|
@@ -174,7 +128,7 @@ const wsLink =
|
|
|
174
128
|
connected: () => console.log("GraphQLWsLink connected"),
|
|
175
129
|
closed: () => console.log("GraphQLWsLink closed"),
|
|
176
130
|
},
|
|
177
|
-
})
|
|
131
|
+
})
|
|
178
132
|
)
|
|
179
133
|
: null;
|
|
180
134
|
|
|
@@ -183,12 +137,12 @@ const opsLink: ApolloLink = from([errorLink, authLink, httpLink as unknown as Ap
|
|
|
183
137
|
const terminatingLink =
|
|
184
138
|
typeof window !== "undefined" && wsLink !== null
|
|
185
139
|
? split(
|
|
186
|
-
({query}) => {
|
|
140
|
+
({ query }) => {
|
|
187
141
|
const definition = getMainDefinition(query);
|
|
188
142
|
return definition.kind === "OperationDefinition" && definition.operation === "subscription";
|
|
189
143
|
},
|
|
190
144
|
wsLink,
|
|
191
|
-
opsLink
|
|
145
|
+
opsLink
|
|
192
146
|
)
|
|
193
147
|
: httpLink;
|
|
194
148
|
|
|
@@ -198,8 +152,8 @@ function createApolloClient() {
|
|
|
198
152
|
link: terminatingLink as ApolloLink,
|
|
199
153
|
cache: new InMemoryCache({
|
|
200
154
|
typePolicies: typePoliciesPortal,
|
|
201
|
-
|
|
202
|
-
|
|
155
|
+
addTypename: true,
|
|
156
|
+
resultCaching: true,
|
|
203
157
|
}),
|
|
204
158
|
});
|
|
205
159
|
}
|
|
@@ -208,27 +162,19 @@ export function initializeApollo(initialState = null, domain?: string) {
|
|
|
208
162
|
const _apolloClient = apolloClient ?? createApolloClient();
|
|
209
163
|
mainDomain = domain || '';
|
|
210
164
|
|
|
211
|
-
// If your page has Next.js data fetching methods that use Apollo Client, the initial state
|
|
212
|
-
// gets hydrated here
|
|
213
165
|
if (initialState) {
|
|
214
|
-
// Get existing cache, loaded during client side data fetching
|
|
215
166
|
const existingCache = _apolloClient.extract();
|
|
216
|
-
|
|
217
|
-
// Merge the initialState from getStaticProps/getServerSideProps in the existing cache
|
|
218
167
|
const data = merge(existingCache, initialState, {
|
|
219
|
-
// combine arrays using object equality (like in sets)
|
|
220
168
|
arrayMerge: (destinationArray, sourceArray) => [
|
|
221
169
|
...sourceArray,
|
|
222
170
|
...destinationArray.filter((d) => sourceArray.every((s) => !isEqual(d, s))),
|
|
223
171
|
],
|
|
224
172
|
});
|
|
225
173
|
|
|
226
|
-
// Restore the cache with the merged data
|
|
227
174
|
_apolloClient.cache.restore(data);
|
|
228
175
|
}
|
|
229
|
-
|
|
176
|
+
|
|
230
177
|
if (typeof window === "undefined") return _apolloClient;
|
|
231
|
-
// Create the Apollo Client once in the client
|
|
232
178
|
if (!apolloClient) apolloClient = _apolloClient;
|
|
233
179
|
|
|
234
180
|
return _apolloClient;
|