@messenger-box/platform-client 0.0.1-alpha.318 → 0.0.1-alpha.346
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/CHANGELOG.md +8 -0
- package/jest.config.js +9 -8
- package/lib/generated-model.d.ts +77 -8
- package/lib/index.js +25 -2
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/src/generated-model.tsx +88 -8
- package/src/graphql/mutations/organization-mutation.gql +10 -0
- package/src/tests/mutation/__snapshots__/set-device-token.test.ts.snap +18 -0
- package/src/tests/mutation/set-device-token.test.ts +85 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@messenger-box/platform-client",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.346",
|
|
4
4
|
"description": "Sample core for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"build:lib:watch": "yarn build:lib -- --watch",
|
|
14
14
|
"jest": "./node_modules/.bin/jest",
|
|
15
15
|
"prepublish": "yarn build",
|
|
16
|
-
"test": "jest",
|
|
16
|
+
"test": "jest --updateSnapshot",
|
|
17
17
|
"test:debug": "npm test -- --runInBand",
|
|
18
18
|
"test:watch": "npm test -- --watch",
|
|
19
19
|
"watch": "yarn build:lib:watch"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@container-stack/file-info-client": "^0.0.35-alpha.34",
|
|
23
|
-
"@messenger-box/core": "0.0.1-alpha.
|
|
23
|
+
"@messenger-box/core": "0.0.1-alpha.338",
|
|
24
24
|
"key-mirror": "1.0.1",
|
|
25
25
|
"moment-timezone": "0.5.33"
|
|
26
26
|
},
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"typescript": {
|
|
35
35
|
"definition": "lib/index.d.ts"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "54d5cc6da6ef71b82d9a858a7d08754e0879e364"
|
|
38
38
|
}
|
package/src/generated-model.tsx
CHANGED
|
@@ -1288,10 +1288,10 @@ export type IMutation = {
|
|
|
1288
1288
|
removedUserAuthIntegration?: Maybe<Scalars['Boolean']>;
|
|
1289
1289
|
renewAuthToken?: Maybe<IAuthTokens>;
|
|
1290
1290
|
resendOrganizationInvitation?: Maybe<Scalars['Boolean']>;
|
|
1291
|
-
resendUserEmailVerificationEmail?: Maybe<Scalars['Boolean']>;
|
|
1292
1291
|
resetUserPassword?: Maybe<Scalars['Boolean']>;
|
|
1293
1292
|
saveMembersToChannel?: Maybe<IChannel>;
|
|
1294
1293
|
sendEmailOTP: Scalars['Boolean'];
|
|
1294
|
+
sendEmailVerificationToken?: Maybe<Scalars['Boolean']>;
|
|
1295
1295
|
sendMessage?: Maybe<IPost>;
|
|
1296
1296
|
sendNotificationOfUnreadMessages: Scalars['Boolean'];
|
|
1297
1297
|
sendOrganizationInvitation?: Maybe<Scalars['Boolean']>;
|
|
@@ -1323,7 +1323,8 @@ export type IMutation = {
|
|
|
1323
1323
|
updateUserAccount?: Maybe<Scalars['Boolean']>;
|
|
1324
1324
|
uploadPhoto: Scalars['String'];
|
|
1325
1325
|
uploadVerifyImage?: Maybe<Scalars['String']>;
|
|
1326
|
-
|
|
1326
|
+
validatePasswordResetOtp?: Maybe<Scalars['Boolean']>;
|
|
1327
|
+
validateUserEmailVerificationToken?: Maybe<Scalars['Boolean']>;
|
|
1327
1328
|
viewChannel: Scalars['Boolean'];
|
|
1328
1329
|
};
|
|
1329
1330
|
|
|
@@ -1536,6 +1537,8 @@ export type IMutationInitializeAuthorizationCodeFlowArgs = {
|
|
|
1536
1537
|
|
|
1537
1538
|
export type IMutationInitializePopupIntegrationAuthorizationArgs = {
|
|
1538
1539
|
code?: Maybe<Scalars['String']>;
|
|
1540
|
+
codeVerifier?: Maybe<Scalars['String']>;
|
|
1541
|
+
platform?: Maybe<IDeviceInfoPlatform>;
|
|
1539
1542
|
};
|
|
1540
1543
|
|
|
1541
1544
|
|
|
@@ -1651,6 +1654,11 @@ export type IMutationSendEmailOtpArgs = {
|
|
|
1651
1654
|
};
|
|
1652
1655
|
|
|
1653
1656
|
|
|
1657
|
+
export type IMutationSendEmailVerificationTokenArgs = {
|
|
1658
|
+
email: Scalars['String'];
|
|
1659
|
+
};
|
|
1660
|
+
|
|
1661
|
+
|
|
1654
1662
|
export type IMutationSendMessageArgs = {
|
|
1655
1663
|
channelId: Scalars['String'];
|
|
1656
1664
|
messageInput: IMessageInput;
|
|
@@ -1844,8 +1852,14 @@ export type IMutationUploadVerifyImageArgs = {
|
|
|
1844
1852
|
};
|
|
1845
1853
|
|
|
1846
1854
|
|
|
1847
|
-
export type
|
|
1848
|
-
|
|
1855
|
+
export type IMutationValidatePasswordResetOtpArgs = {
|
|
1856
|
+
email: Scalars['String'];
|
|
1857
|
+
code: Scalars['String'];
|
|
1858
|
+
};
|
|
1859
|
+
|
|
1860
|
+
|
|
1861
|
+
export type IMutationValidateUserEmailVerificationTokenArgs = {
|
|
1862
|
+
code: Scalars['String'];
|
|
1849
1863
|
};
|
|
1850
1864
|
|
|
1851
1865
|
|
|
@@ -2604,7 +2618,12 @@ export type IQuery = {
|
|
|
2604
2618
|
dummy?: Maybe<Scalars['Int']>;
|
|
2605
2619
|
/** Fetches a User from Auth0 Service */
|
|
2606
2620
|
fetchAuth0User?: Maybe<IUserProfile>;
|
|
2621
|
+
/**
|
|
2622
|
+
* fetchUserAuthorizedDevices
|
|
2623
|
+
* @deprecated not used
|
|
2624
|
+
*/
|
|
2607
2625
|
fetchUserAuthorizedDevices?: Maybe<Array<Maybe<IUserDevice>>>;
|
|
2626
|
+
fetchUserSessions?: Maybe<Array<Maybe<IUserSession>>>;
|
|
2608
2627
|
fileInfo: IFileInfo;
|
|
2609
2628
|
filesInfo: IFilesInfo;
|
|
2610
2629
|
getAccounts?: Maybe<Array<Maybe<IUserAccount>>>;
|
|
@@ -3517,8 +3536,9 @@ export type IUserOrgInput = {
|
|
|
3517
3536
|
};
|
|
3518
3537
|
|
|
3519
3538
|
export type IUserPasswordResetInput = {
|
|
3520
|
-
|
|
3521
|
-
|
|
3539
|
+
newPassword: Scalars['String'];
|
|
3540
|
+
currentPassword: Scalars['String'];
|
|
3541
|
+
email: Scalars['String'];
|
|
3522
3542
|
};
|
|
3523
3543
|
|
|
3524
3544
|
export type IUserPreviousValues = {
|
|
@@ -3563,6 +3583,14 @@ export type IUserProfile = IIAuth0User & IIAuth0UserProfile & IIAuth0Token & {
|
|
|
3563
3583
|
nonce?: Maybe<Scalars['String']>;
|
|
3564
3584
|
};
|
|
3565
3585
|
|
|
3586
|
+
export type IUserSession = {
|
|
3587
|
+
__typename?: 'UserSession';
|
|
3588
|
+
sessionId?: Maybe<Scalars['String']>;
|
|
3589
|
+
deviceInfo?: Maybe<IUserAuth0SessionDeviceInfo>;
|
|
3590
|
+
lastLoginAt?: Maybe<Scalars['Date']>;
|
|
3591
|
+
lastLoginIp?: Maybe<Scalars['String']>;
|
|
3592
|
+
};
|
|
3593
|
+
|
|
3566
3594
|
export type IUserSessionId = {
|
|
3567
3595
|
__typename?: 'UserSessionId';
|
|
3568
3596
|
sessionId?: Maybe<Scalars['String']>;
|
|
@@ -4034,6 +4062,19 @@ export type IDeleteMessageFileMutation = (
|
|
|
4034
4062
|
& Pick<IMutation, 'deleteMessageFile'>
|
|
4035
4063
|
);
|
|
4036
4064
|
|
|
4065
|
+
export type ICreateOrganizationMutationVariables = Exact<{
|
|
4066
|
+
organization: IOrganizationCreateRequest;
|
|
4067
|
+
}>;
|
|
4068
|
+
|
|
4069
|
+
|
|
4070
|
+
export type ICreateOrganizationMutation = (
|
|
4071
|
+
{ __typename?: 'Mutation' }
|
|
4072
|
+
& { createOrganization?: Maybe<(
|
|
4073
|
+
{ __typename?: 'Organization' }
|
|
4074
|
+
& Pick<IOrganization, 'id' | 'name' | 'title' | 'description' | 'createdAt' | 'updatedAt'>
|
|
4075
|
+
)> }
|
|
4076
|
+
);
|
|
4077
|
+
|
|
4037
4078
|
export type ICreateTeamMutationVariables = Exact<{
|
|
4038
4079
|
request: ITeamCreationRequest;
|
|
4039
4080
|
}>;
|
|
@@ -4687,6 +4728,7 @@ export type IResolversTypes = {
|
|
|
4687
4728
|
UserPasswordResetInput: IUserPasswordResetInput;
|
|
4688
4729
|
UserPreviousValues: ResolverTypeWrapper<IUserPreviousValues>;
|
|
4689
4730
|
UserProfile: ResolverTypeWrapper<IUserProfile>;
|
|
4731
|
+
UserSession: ResolverTypeWrapper<IUserSession>;
|
|
4690
4732
|
UserSessionId: ResolverTypeWrapper<IUserSessionId>;
|
|
4691
4733
|
UserSettings: ResolverTypeWrapper<IUserSettings>;
|
|
4692
4734
|
UserToken: ResolverTypeWrapper<IUserToken>;
|
|
@@ -4922,6 +4964,7 @@ export type IResolversParentTypes = {
|
|
|
4922
4964
|
UserPasswordResetInput: IUserPasswordResetInput;
|
|
4923
4965
|
UserPreviousValues: IUserPreviousValues;
|
|
4924
4966
|
UserProfile: IUserProfile;
|
|
4967
|
+
UserSession: IUserSession;
|
|
4925
4968
|
UserSessionId: IUserSessionId;
|
|
4926
4969
|
UserSettings: IUserSettings;
|
|
4927
4970
|
UserToken: IUserToken;
|
|
@@ -5695,10 +5738,10 @@ export type IMutationResolvers<ContextType = any, ParentType extends IResolversP
|
|
|
5695
5738
|
removedUserAuthIntegration?: Resolver<Maybe<IResolversTypes['Boolean']>, ParentType, ContextType, RequireFields<IMutationRemovedUserAuthIntegrationArgs, never>>;
|
|
5696
5739
|
renewAuthToken?: Resolver<Maybe<IResolversTypes['AuthTokens']>, ParentType, ContextType, RequireFields<IMutationRenewAuthTokenArgs, never>>;
|
|
5697
5740
|
resendOrganizationInvitation?: Resolver<Maybe<IResolversTypes['Boolean']>, ParentType, ContextType, RequireFields<IMutationResendOrganizationInvitationArgs, 'id'>>;
|
|
5698
|
-
resendUserEmailVerificationEmail?: Resolver<Maybe<IResolversTypes['Boolean']>, ParentType, ContextType>;
|
|
5699
5741
|
resetUserPassword?: Resolver<Maybe<IResolversTypes['Boolean']>, ParentType, ContextType, RequireFields<IMutationResetUserPasswordArgs, 'input'>>;
|
|
5700
5742
|
saveMembersToChannel?: Resolver<Maybe<IResolversTypes['Channel']>, ParentType, ContextType, RequireFields<IMutationSaveMembersToChannelArgs, 'membersId' | 'channelId'>>;
|
|
5701
5743
|
sendEmailOTP?: Resolver<IResolversTypes['Boolean'], ParentType, ContextType, RequireFields<IMutationSendEmailOtpArgs, 'email'>>;
|
|
5744
|
+
sendEmailVerificationToken?: Resolver<Maybe<IResolversTypes['Boolean']>, ParentType, ContextType, RequireFields<IMutationSendEmailVerificationTokenArgs, 'email'>>;
|
|
5702
5745
|
sendMessage?: Resolver<Maybe<IResolversTypes['Post']>, ParentType, ContextType, RequireFields<IMutationSendMessageArgs, 'channelId' | 'messageInput'>>;
|
|
5703
5746
|
sendNotificationOfUnreadMessages?: Resolver<IResolversTypes['Boolean'], ParentType, ContextType, RequireFields<IMutationSendNotificationOfUnreadMessagesArgs, 'unit' | 'value'>>;
|
|
5704
5747
|
sendOrganizationInvitation?: Resolver<Maybe<IResolversTypes['Boolean']>, ParentType, ContextType, RequireFields<IMutationSendOrganizationInvitationArgs, never>>;
|
|
@@ -5729,7 +5772,8 @@ export type IMutationResolvers<ContextType = any, ParentType extends IResolversP
|
|
|
5729
5772
|
updateUserAccount?: Resolver<Maybe<IResolversTypes['Boolean']>, ParentType, ContextType, RequireFields<IMutationUpdateUserAccountArgs, never>>;
|
|
5730
5773
|
uploadPhoto?: Resolver<IResolversTypes['String'], ParentType, ContextType, RequireFields<IMutationUploadPhotoArgs, 'id' | 'image'>>;
|
|
5731
5774
|
uploadVerifyImage?: Resolver<Maybe<IResolversTypes['String']>, ParentType, ContextType, RequireFields<IMutationUploadVerifyImageArgs, 'image'>>;
|
|
5732
|
-
|
|
5775
|
+
validatePasswordResetOtp?: Resolver<Maybe<IResolversTypes['Boolean']>, ParentType, ContextType, RequireFields<IMutationValidatePasswordResetOtpArgs, 'email' | 'code'>>;
|
|
5776
|
+
validateUserEmailVerificationToken?: Resolver<Maybe<IResolversTypes['Boolean']>, ParentType, ContextType, RequireFields<IMutationValidateUserEmailVerificationTokenArgs, 'code'>>;
|
|
5733
5777
|
viewChannel?: Resolver<IResolversTypes['Boolean'], ParentType, ContextType, RequireFields<IMutationViewChannelArgs, 'id'>>;
|
|
5734
5778
|
};
|
|
5735
5779
|
|
|
@@ -6177,6 +6221,7 @@ export type IQueryResolvers<ContextType = any, ParentType extends IResolversPare
|
|
|
6177
6221
|
dummy?: Resolver<Maybe<IResolversTypes['Int']>, ParentType, ContextType>;
|
|
6178
6222
|
fetchAuth0User?: Resolver<Maybe<IResolversTypes['UserProfile']>, ParentType, ContextType, RequireFields<IQueryFetchAuth0UserArgs, 'auth0UserId'>>;
|
|
6179
6223
|
fetchUserAuthorizedDevices?: Resolver<Maybe<Array<Maybe<IResolversTypes['UserDevice']>>>, ParentType, ContextType, RequireFields<IQueryFetchUserAuthorizedDevicesArgs, 'auth0UserId'>>;
|
|
6224
|
+
fetchUserSessions?: Resolver<Maybe<Array<Maybe<IResolversTypes['UserSession']>>>, ParentType, ContextType>;
|
|
6180
6225
|
fileInfo?: Resolver<IResolversTypes['FileInfo'], ParentType, ContextType, RequireFields<IQueryFileInfoArgs, 'id'>>;
|
|
6181
6226
|
filesInfo?: Resolver<IResolversTypes['FilesInfo'], ParentType, ContextType, RequireFields<IQueryFilesInfoArgs, never>>;
|
|
6182
6227
|
getAccounts?: Resolver<Maybe<Array<Maybe<IResolversTypes['UserAccount']>>>, ParentType, ContextType, RequireFields<IQueryGetAccountsArgs, never>>;
|
|
@@ -6524,6 +6569,14 @@ export type IUserProfileResolvers<ContextType = any, ParentType extends IResolve
|
|
|
6524
6569
|
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
|
|
6525
6570
|
};
|
|
6526
6571
|
|
|
6572
|
+
export type IUserSessionResolvers<ContextType = any, ParentType extends IResolversParentTypes['UserSession'] = IResolversParentTypes['UserSession']> = {
|
|
6573
|
+
sessionId?: Resolver<Maybe<IResolversTypes['String']>, ParentType, ContextType>;
|
|
6574
|
+
deviceInfo?: Resolver<Maybe<IResolversTypes['UserAuth0SessionDeviceInfo']>, ParentType, ContextType>;
|
|
6575
|
+
lastLoginAt?: Resolver<Maybe<IResolversTypes['Date']>, ParentType, ContextType>;
|
|
6576
|
+
lastLoginIp?: Resolver<Maybe<IResolversTypes['String']>, ParentType, ContextType>;
|
|
6577
|
+
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
|
|
6578
|
+
};
|
|
6579
|
+
|
|
6527
6580
|
export type IUserSessionIdResolvers<ContextType = any, ParentType extends IResolversParentTypes['UserSessionId'] = IResolversParentTypes['UserSessionId']> = {
|
|
6528
6581
|
sessionId?: Resolver<Maybe<IResolversTypes['String']>, ParentType, ContextType>;
|
|
6529
6582
|
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
|
|
@@ -6717,6 +6770,7 @@ export type IResolvers<ContextType = any> = {
|
|
|
6717
6770
|
UserOrg?: IUserOrgResolvers<ContextType>;
|
|
6718
6771
|
UserPreviousValues?: IUserPreviousValuesResolvers<ContextType>;
|
|
6719
6772
|
UserProfile?: IUserProfileResolvers<ContextType>;
|
|
6773
|
+
UserSession?: IUserSessionResolvers<ContextType>;
|
|
6720
6774
|
UserSessionId?: IUserSessionIdResolvers<ContextType>;
|
|
6721
6775
|
UserSettings?: IUserSettingsResolvers<ContextType>;
|
|
6722
6776
|
UserToken?: IUserTokenResolvers<ContextType>;
|
|
@@ -7144,6 +7198,32 @@ export function useDeleteMessageFileMutation(baseOptions?: Apollo.MutationHookOp
|
|
|
7144
7198
|
export type DeleteMessageFileMutationHookResult = ReturnType<typeof useDeleteMessageFileMutation>;
|
|
7145
7199
|
export type DeleteMessageFileMutationResult = Apollo.MutationResult<IDeleteMessageFileMutation>;
|
|
7146
7200
|
export type DeleteMessageFileMutationOptions = Apollo.BaseMutationOptions<IDeleteMessageFileMutation, IDeleteMessageFileMutationVariables>;
|
|
7201
|
+
export const CreateOrganizationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateOrganization"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"organization"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"OrganizationCreateRequest"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createOrganization"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"organization"},"value":{"kind":"Variable","name":{"kind":"Name","value":"organization"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode;
|
|
7202
|
+
|
|
7203
|
+
/**
|
|
7204
|
+
* __useCreateOrganizationMutation__
|
|
7205
|
+
*
|
|
7206
|
+
* To run a mutation, you first call `useCreateOrganizationMutation` within a React component and pass it any options that fit your needs.
|
|
7207
|
+
* When your component renders, `useCreateOrganizationMutation` returns a tuple that includes:
|
|
7208
|
+
* - A mutate function that you can call at any time to execute the mutation
|
|
7209
|
+
* - An object with fields that represent the current status of the mutation's execution
|
|
7210
|
+
*
|
|
7211
|
+
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
|
|
7212
|
+
*
|
|
7213
|
+
* @example
|
|
7214
|
+
* const [createOrganizationMutation, { data, loading, error }] = useCreateOrganizationMutation({
|
|
7215
|
+
* variables: {
|
|
7216
|
+
* organization: // value for 'organization'
|
|
7217
|
+
* },
|
|
7218
|
+
* });
|
|
7219
|
+
*/
|
|
7220
|
+
export function useCreateOrganizationMutation(baseOptions?: Apollo.MutationHookOptions<ICreateOrganizationMutation, ICreateOrganizationMutationVariables>) {
|
|
7221
|
+
const options = {...defaultOptions, ...baseOptions}
|
|
7222
|
+
return Apollo.useMutation<ICreateOrganizationMutation, ICreateOrganizationMutationVariables>(CreateOrganizationDocument, options);
|
|
7223
|
+
}
|
|
7224
|
+
export type CreateOrganizationMutationHookResult = ReturnType<typeof useCreateOrganizationMutation>;
|
|
7225
|
+
export type CreateOrganizationMutationResult = Apollo.MutationResult<ICreateOrganizationMutation>;
|
|
7226
|
+
export type CreateOrganizationMutationOptions = Apollo.BaseMutationOptions<ICreateOrganizationMutation, ICreateOrganizationMutationVariables>;
|
|
7147
7227
|
export const CreateTeamDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateTeam"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"request"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"TeamCreationRequest"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createTeam"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"request"},"value":{"kind":"Variable","name":{"kind":"Name","value":"request"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"orgName"}},{"kind":"Field","name":{"kind":"Name","value":"title"}}]}}]}}]} as unknown as DocumentNode;
|
|
7148
7228
|
|
|
7149
7229
|
/**
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Set expo token test Set expo token 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"getDeviceToken": {
|
|
6
|
+
"tokens": [
|
|
7
|
+
{
|
|
8
|
+
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InRhcnVudXBhZGh5YXlkZXYyMDIyQGdtYWlsLmNvbSIsImlhdCI6MTY3MTE4MTQ1NSwiZXhwIjoxNjcxMjY3ODU1fQ.XQTWTuUW3HUo4pviGgK2bEvd79e4BIYPgLKfItx5OEo",
|
|
9
|
+
"type": "EMAIL_VERIFICATION",
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"token": "ExponentPushToken[_RzGb5J887HIJpVzH9_07h]",
|
|
13
|
+
"type": "EXPO_NOTIFICATION_TOKEN",
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import fetch from 'node-fetch';
|
|
2
|
+
|
|
3
|
+
describe('Set expo token test', () => {
|
|
4
|
+
const API = 'http://localhost:8091/graphql';
|
|
5
|
+
const bearerToken =
|
|
6
|
+
'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlJFRkdOalEzTlRJNFJUY3dNRVV5TXpRNVJFTTNORE0wUkVWRU56VTJOemd6TkRVME16RXpSUSJ9.eyJpc3MiOiJodHRwczovL2Rldi1jZGViYXNlLmF1dGgwLmNvbS8iLCJzdWIiOiJnb29nbGUtb2F1dGgyfDExMzQ4ODQ2MzgxMTAwODMyNDMxNiIsImF1ZCI6WyJodHRwczovL2Rldi1jZGViYXNlLmF1dGgwLmNvbS9hcGkvdjIvIiwiaHR0cHM6Ly9kZXYtY2RlYmFzZS5hdXRoMC5jb20vdXNlcmluZm8iXSwiaWF0IjoxNjgzNzkwNTM4LCJleHAiOjE2ODM4NzY5MzgsImF6cCI6IlQ5WE0yOTJsMzNYYjEyUlZQdlJJZnJiNWhZVFpzUm1lIiwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSBlbWFpbCByZWFkOmN1cnJlbnRfdXNlciB1cGRhdGU6Y3VycmVudF91c2VyX2lkZW50aXRpZXMgb2ZmbGluZV9hY2Nlc3MifQ.Ft_sRo0f3J0vGCckes0r2AuJpr21KZPgkCow9kRxyCpuoffKNu34o9XebFWNX_fP4GQlT68Nj71EDsQA7AMlvCwv5IvZVeYdTeCYNcDa7FwmXhRsGUxH-lOlqp-KZjKI3BB_AwVUFNh9w5EaEcAXOgqK-00DKbuUniXygH2fckMXevMB1s6q9De167G-YwTmyKbVQUDCNA6pemsgB6CiaZkf2MF_7LETGcSl3TgY-WN6AP9gjZh8HayK3la4sbrfdJ05gIF32yFrSm5kiM84F3y2f-2m6FT6AzbrlBGr3nBaL1vYOYpxrRHOIq3y_HvBGxr4yJGPrZdLcC5VjEoGsg';
|
|
7
|
+
const expoToken = 'ExponentPushToken[_RzGb5J887HIJpVzH9_07h]';
|
|
8
|
+
|
|
9
|
+
it('Set expo token', async () => {
|
|
10
|
+
const tokensquery: any = `
|
|
11
|
+
getDeviceToken
|
|
12
|
+
{
|
|
13
|
+
tokens
|
|
14
|
+
{
|
|
15
|
+
token
|
|
16
|
+
type
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
const query = `
|
|
22
|
+
mutation SetDeviceToken($deviceToken: String) {
|
|
23
|
+
setDeviceToken(deviceToken: $deviceToken) {
|
|
24
|
+
tokens {
|
|
25
|
+
token
|
|
26
|
+
type
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
let getTokens = await fetch(API, {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
headers: {
|
|
35
|
+
'Content-Type': 'application/json',
|
|
36
|
+
Authorization: bearerToken,
|
|
37
|
+
},
|
|
38
|
+
body: JSON.stringify({
|
|
39
|
+
query: `{${tokensquery}}`,
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
let tokensResponse = await getTokens.json();
|
|
44
|
+
if (tokensResponse) {
|
|
45
|
+
const checkExpoTokens: any =
|
|
46
|
+
tokensResponse?.data?.getDeviceToken?.tokens?.filter(
|
|
47
|
+
(t: any) => t?.type === 'EXPO_NOTIFICATION_TOKEN' && t?.token == expoToken,
|
|
48
|
+
) ?? null;
|
|
49
|
+
|
|
50
|
+
if (checkExpoTokens && checkExpoTokens?.length == 0) {
|
|
51
|
+
let response = await fetch(API, {
|
|
52
|
+
method: 'POST',
|
|
53
|
+
headers: {
|
|
54
|
+
'Content-Type': 'application/json',
|
|
55
|
+
Authorization: bearerToken,
|
|
56
|
+
},
|
|
57
|
+
body: JSON.stringify({
|
|
58
|
+
query,
|
|
59
|
+
variables: {
|
|
60
|
+
deviceToken: expoToken,
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
});
|
|
64
|
+
let result = await response.json();
|
|
65
|
+
if (result) expect(result?.data).toMatchSnapshot();
|
|
66
|
+
} else expect(tokensResponse?.data).toMatchSnapshot();
|
|
67
|
+
} else {
|
|
68
|
+
let response = await fetch(API, {
|
|
69
|
+
method: 'POST',
|
|
70
|
+
headers: {
|
|
71
|
+
'Content-Type': 'application/json',
|
|
72
|
+
Authorization: bearerToken,
|
|
73
|
+
},
|
|
74
|
+
body: JSON.stringify({
|
|
75
|
+
query,
|
|
76
|
+
variables: {
|
|
77
|
+
deviceToken: expoToken,
|
|
78
|
+
},
|
|
79
|
+
}),
|
|
80
|
+
});
|
|
81
|
+
let result = await response.json();
|
|
82
|
+
expect(result?.data).toMatchSnapshot();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|