From bd4fac451c714f75f00925e7148ad79b4a2fc8fe Mon Sep 17 00:00:00 2001 From: "Fabien \"egg\" O'Carroll" Date: Thu, 1 Jun 2023 00:15:36 -0400 Subject: [PATCH] Update CollectionsService to remove CollectionPost usage --- ghost/collections/src/CollectionPost.ts | 47 ------------------- .../src/CollectionsPostsRepositoryInMemory.ts | 17 ------- .../src/CollectionsRepositoryInMemory.ts | 13 ----- 3 files changed, 77 deletions(-) delete mode 100644 ghost/collections/src/CollectionPost.ts delete mode 100644 ghost/collections/src/CollectionsPostsRepositoryInMemory.ts diff --git a/ghost/collections/src/CollectionPost.ts b/ghost/collections/src/CollectionPost.ts deleted file mode 100644 index 9b89e69316..0000000000 --- a/ghost/collections/src/CollectionPost.ts +++ /dev/null @@ -1,47 +0,0 @@ -import {ValidationError} from '@tryghost/errors'; -import tpl from '@tryghost/tpl'; -import ObjectID from 'bson-objectid'; - -const messages = { - invalidIDProvided: 'Invalid ID provided for CollectionPost' -}; - -export class CollectionPost { - id: string; - postId: string; - collectionId: string; - sortOrder: number; - deleted: boolean; - - constructor(data: any) { - this.id = data.id; - this.postId = data.postId; - this.collectionId = data.collectionId; - this.sortOrder = data.sortOder; - this.deleted = data.deleted; - } - - static async create(data: any): Promise { - let id; - - if (!data.id) { - id = new ObjectID(); - } else if (typeof data.id === 'string') { - id = ObjectID.createFromHexString(data.id); - } else if (data.id instanceof ObjectID) { - id = data.id; - } else { - throw new ValidationError({ - message: tpl(messages.invalidIDProvided) - }); - } - - return new CollectionPost({ - id: id.toHexString(), - postId: data.post_id, - collectionId: data.collection_id, - sortOrder: data.sort_order, // NOTE: make sort_order required during creation - deleted: false - }); - } -} diff --git a/ghost/collections/src/CollectionsPostsRepositoryInMemory.ts b/ghost/collections/src/CollectionsPostsRepositoryInMemory.ts deleted file mode 100644 index 99317b8fa8..0000000000 --- a/ghost/collections/src/CollectionsPostsRepositoryInMemory.ts +++ /dev/null @@ -1,17 +0,0 @@ -import {InMemoryRepository} from '@tryghost/in-memory-repository'; -import {CollectionPost} from './CollectionPost'; - -export class CollectionsPostsRepositoryInMemory extends InMemoryRepository { - constructor() { - super(); - } - - protected toPrimitive(entity: CollectionPost): object { - return { - id: entity.id, - post_id: entity.postId, - collection_id: entity.collectionId, - sort_order: entity.sortOrder - }; - } -} diff --git a/ghost/collections/src/CollectionsRepositoryInMemory.ts b/ghost/collections/src/CollectionsRepositoryInMemory.ts index ad3a8295ce..3f2813bbcf 100644 --- a/ghost/collections/src/CollectionsRepositoryInMemory.ts +++ b/ghost/collections/src/CollectionsRepositoryInMemory.ts @@ -1,20 +1,7 @@ import {InMemoryRepository} from '@tryghost/in-memory-repository'; import {Collection} from './Collection'; -import {CollectionPost} from './CollectionPost'; export class CollectionsRepositoryInMemory extends InMemoryRepository { - collectionsPostsRepository: any; - - constructor(deps: any) { - super(); - - this.collectionsPostsRepository = deps.collectionsPostsRepository; - } - - async saveCollectionPost(collectionPost: CollectionPost) { - await this.collectionsPostsRepository.save(collectionPost); - } - protected toPrimitive(entity: Collection): object { return { title: entity.title,