refactor: refactoring Team-Collections with reordering in self-host (HBE-150) (#34)

* chore: removed firebase module as a dependency from team-collection module

* chore: modified team-collection resolver file to use input-args types

* chore: modified getTeamOfCollection service method and resolver

* chore: modified getParentOfCollection service method in team-collection module

* chore: modified getChildrenOfCollection service method in team-collection module

* chore: added new fields to TeamCollection model in prisma schema file

* chore: modified getCollection service method and resolver in team-collection module

* chore: modified createCollection service method and resolver in team-collection module

* chore: created cast helper function to resolve issue with creation mutation in team-collection

* chore: modified teamCollectionRemoved subscription return types

* chore: removed return types from subscriptions in team-collection module

* chore: removed all instances of getTeamCollections service method in team-collection module

* feat: added mutation to handle moving collections and supporting subscriptions

* feat: added mutation to re-ordering team-collection order

* chore: added teacher comments to both collection modules

* test: added test cases for getTeamOfCollection service method

* test: added test cases for getParentOfCollection service method

* test: added test cases for getChildrenOfCollection service method

* test: added test cases for getTeamRootCollections service method

* test: added test cases for getCollection service method

* test: added test cases for createCollection service method

* chore: renamed renameCollection to renameUserCollection in UserCollection module

* test: added test cases for renameCollection service method

* test: added test cases for deleteCollection service method

* test: added test cases for moveCollection service method

* test: added test cases for updateCollectionOrder service method

* chore: added import and export to JSON mutations to team-collection module

* chore: created replaceCollectionsWithJSON mutation in team-collection module

* chore: moved the mutation and service method of importCollectionFromFirestore to the end of file

* chore: added helper comments to all import,export functions

* chore: exportCollectionsToJSON service method orders collections and requests in ascending order

* chore: added test cases for importCollectionsFromJSON service method

* chore: added ToDo to write test cases for exportCollectionsToJSON

* chore: removed prisma migration folder

* chore: completed all changes requested in inital PR review

* chore: completed all changes requested in second  PR review

* chore: completed all changes requested in third PR review
This commit is contained in:
Balu Babu
2023-03-09 19:37:40 +05:30
committed by GitHub
parent 9b76d62753
commit 2a715d5348
19 changed files with 3079 additions and 2694 deletions

View File

@@ -43,13 +43,13 @@ export class TeamRequestResolver {
return this.teamRequestService.getTeamOfRequest(req);
}
@ResolveField(() => TeamCollection, {
description: 'Collection the request belongs to',
complexity: 3,
})
collection(@Parent() req: TeamRequest): Promise<TeamCollection> {
return this.teamRequestService.getCollectionOfRequest(req);
}
// @ResolveField(() => TeamCollection, {
// description: 'Collection the request belongs to',
// complexity: 3,
// })
// collection(@Parent() req: TeamRequest): Promise<TeamCollection> {
// return this.teamRequestService.getCollectionOfRequest(req);
// }
// Query
@Query(() => [TeamRequest], {
@@ -126,29 +126,29 @@ export class TeamRequestResolver {
);
}
// Mutation
@Mutation(() => TeamRequest, {
description: 'Create a request in the given collection.',
})
@UseGuards(GqlAuthGuard, GqlCollectionTeamMemberGuard)
@RequiresTeamRole(TeamMemberRole.EDITOR, TeamMemberRole.OWNER)
createRequestInCollection(
@Args({
name: 'collectionID',
description: 'ID of the collection',
type: () => ID,
})
collectionID: string,
@Args({
name: 'data',
type: () => CreateTeamRequestInput,
description:
'The request data (stringified JSON of Hoppscotch request object)',
})
data: CreateTeamRequestInput,
): Promise<TeamRequest> {
return this.teamRequestService.createTeamRequest(collectionID, data);
}
// // Mutation
// @Mutation(() => TeamRequest, {
// description: 'Create a request in the given collection.',
// })
// @UseGuards(GqlAuthGuard, GqlCollectionTeamMemberGuard)
// @RequiresTeamRole(TeamMemberRole.EDITOR, TeamMemberRole.OWNER)
// createRequestInCollection(
// @Args({
// name: 'collectionID',
// description: 'ID of the collection',
// type: () => ID,
// })
// collectionID: string,
// @Args({
// name: 'data',
// type: () => CreateTeamRequestInput,
// description:
// 'The request data (stringified JSON of Hoppscotch request object)',
// })
// data: CreateTeamRequestInput,
// ): Promise<TeamRequest> {
// return this.teamRequestService.createTeamRequest(collectionID, data);
// }
@Mutation(() => TeamRequest, {
description: 'Update a request with the given ID',
@@ -190,30 +190,30 @@ export class TeamRequestResolver {
return true;
}
@Mutation(() => TeamRequest, {
description: 'Move a request to the given collection',
})
@UseGuards(GqlAuthGuard, GqlRequestTeamMemberGuard)
@RequiresTeamRole(TeamMemberRole.EDITOR, TeamMemberRole.OWNER)
moveRequest(
@Args({
name: 'requestID',
description: 'ID of the request to move',
type: () => ID,
})
requestID: string,
@Args({
name: 'destCollID',
description: 'ID of the collection to move the request to',
type: () => ID,
})
destCollID: string,
): Promise<TeamRequest> {
return pipe(
this.teamRequestService.moveRequest(requestID, destCollID),
TE.getOrElse((e) => throwErr(e)),
)();
}
// @Mutation(() => TeamRequest, {
// description: 'Move a request to the given collection',
// })
// @UseGuards(GqlAuthGuard, GqlRequestTeamMemberGuard)
// @RequiresTeamRole(TeamMemberRole.EDITOR, TeamMemberRole.OWNER)
// moveRequest(
// @Args({
// name: 'requestID',
// description: 'ID of the request to move',
// type: () => ID,
// })
// requestID: string,
// @Args({
// name: 'destCollID',
// description: 'ID of the collection to move the request to',
// type: () => ID,
// })
// destCollID: string,
// ): Promise<TeamRequest> {
// return pipe(
// this.teamRequestService.moveRequest(requestID, destCollID),
// TE.getOrElse((e) => throwErr(e)),
// )();
// }
// Subscriptions
@Subscription(() => TeamRequest, {