chore: export single User/Team Collection (#4359)

* chore: added query to export single TeamCollection data

* chore: added query to export single UserCollection data

* chore: fixed typo

* chore: completed requested changes in PR review
This commit is contained in:
Balu Babu
2024-09-27 16:55:47 +05:30
committed by GitHub
parent 421e6b76c9
commit fc37196354
5 changed files with 68 additions and 3 deletions

View File

@@ -186,6 +186,30 @@ export class UserCollectionResolver {
return jsonString.right;
}
@Query(() => String, {
description:
'Returns a JSON string of all the contents of a User Collection',
})
@UseGuards(GqlAuthGuard)
async exportUserCollectionToJSON(
@GqlUser() user: AuthUser,
@Args({
type: () => ID,
name: 'collectionID',
description: 'ID of the user collection',
})
collectionID: string,
) {
const jsonString =
await this.userCollectionService.exportUserCollectionToJSONObject(
user.uid,
collectionID,
);
if (E.isLeft(jsonString)) throwErr(jsonString.left as string);
return JSON.stringify(jsonString.right);
}
// Mutations
@Mutation(() => UserCollection, {
description: 'Creates root REST user collection(no parent user collection)',

View File

@@ -836,7 +836,7 @@ export class UserCollectionService {
* @param collectionID The Collection ID
* @returns A JSON string containing all the contents of a collection
*/
private async exportUserCollectionToJSONObject(
async exportUserCollectionToJSONObject(
userUID: string,
collectionID: string,
): Promise<E.Left<string> | E.Right<CollectionFolder>> {