feat: duplicate REST/GraphQL collections (#4211)

Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
Co-authored-by: nivedin <nivedinp@gmail.com>
This commit is contained in:
James George
2024-07-29 06:07:34 -07:00
committed by GitHub
parent c24d5c5302
commit c9f92282bf
26 changed files with 734 additions and 105 deletions

View File

@@ -25,7 +25,11 @@ import {
UserCollectionExportJSONData,
} from './user-collections.model';
import { ReqType } from 'src/types/RequestTypes';
import { isValidLength, stringToJson } from 'src/utils';
import {
isValidLength,
stringToJson,
transformCollectionData,
} from 'src/utils';
import { CollectionFolder } from 'src/types/CollectionFolder';
@Injectable()
@@ -43,13 +47,15 @@ export class UserCollectionService {
* @returns UserCollection model
*/
private cast(collection: UserCollection) {
const data = transformCollectionData(collection.data);
return <UserCollectionModel>{
id: collection.id,
title: collection.title,
type: collection.type,
parentID: collection.parentID,
userID: collection.userUid,
data: !collection.data ? null : JSON.stringify(collection.data),
data,
};
}
@@ -871,6 +877,8 @@ export class UserCollectionService {
},
});
const data = transformCollectionData(collection.right.data);
const result: CollectionFolder = {
id: collection.right.id,
name: collection.right.title,
@@ -882,7 +890,7 @@ export class UserCollectionService {
...(x.request as Record<string, unknown>), // type casting x.request of type Prisma.JSONValue to an object to enable spread
};
}),
data: JSON.stringify(collection.right.data),
data,
};
return E.right(result);