From 0c8e05dc1a843107e8cf2ee0fffbbb8d455ff337 Mon Sep 17 00:00:00 2001 From: Rafael de Jesus Guzman Torres Date: Tue, 9 Jun 2026 21:09:37 -0600 Subject: [PATCH] feat: repository for project module added and type for notifications --- .../core/interfaces/NotificationParams.ts | 1 + .../modules/notification/core/model/Notification.ts | 13 ++++++++++++- .../notification/core/types/NotificationTypes.ts | 6 ++++++ .../project/core/interfaces/ProjectCriteria.ts | 12 ++++++++++++ .../project/core/repository/ProjectRepository.ts | 10 ++++++++++ .../notification/core/model/Notification.test.ts | 8 ++++++++ 6 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 backend/src/modules/notification/core/types/NotificationTypes.ts create mode 100644 backend/src/modules/project/core/interfaces/ProjectCriteria.ts create mode 100644 backend/src/modules/project/core/repository/ProjectRepository.ts diff --git a/backend/src/modules/notification/core/interfaces/NotificationParams.ts b/backend/src/modules/notification/core/interfaces/NotificationParams.ts index 7abd878a..5e7034b5 100644 --- a/backend/src/modules/notification/core/interfaces/NotificationParams.ts +++ b/backend/src/modules/notification/core/interfaces/NotificationParams.ts @@ -6,4 +6,5 @@ export default interface NotificationParams { status: AllowedNotificationStatus; idUser: string; deletedAt: Date | null; + type: string; } diff --git a/backend/src/modules/notification/core/model/Notification.ts b/backend/src/modules/notification/core/model/Notification.ts index f7ebcdfb..86f7edca 100644 --- a/backend/src/modules/notification/core/model/Notification.ts +++ b/backend/src/modules/notification/core/model/Notification.ts @@ -8,20 +8,24 @@ import NotificationAlreadyRead from '../error/NotificationAlreadyRead'; import type NotificationParams from '../interfaces/NotificationParams'; import IdNotification from '../objects/IdNotification'; import NotificationStatus from '../objects/NotificationStatus'; +import type { NotificationTypes } from '../types/NotificationTypes'; export default class Notification extends Entity { private eventKey!: string; private status!: NotificationStatus; + private type!: NotificationTypes; private constructor( idNotification: IdNotification, eventKey: string, status: NotificationStatus, + type: NotificationTypes, idUser: IdEntity, ) { super(idNotification, idUser); this.eventKey = eventKey; this.status = status; + this.type = type; } public static create( @@ -30,8 +34,9 @@ export default class Notification extends Entity { eventKey: string, idUser: IdEntity, actor: IdEntity, + type: NotificationTypes, ): Notification { - const notification = new Notification(idNotification, eventKey, NotificationStatus.unread(), idUser); + const notification = new Notification(idNotification, eventKey, NotificationStatus.unread(), type, idUser); notification.create(); notification.addEvent( new NotificationCreated(key, DateTime.now(), actor, idUser, idNotification, notification.toPrimitives()), @@ -44,6 +49,7 @@ export default class Notification extends Entity { new IdNotification(params.id), params.eventKey, NotificationStatus.create(params.status), + params.type as NotificationTypes, new IdEntity(params.idUser), ); @@ -81,6 +87,10 @@ export default class Notification extends Entity { return super.getOwner() as IdEntity; } + public getType(): NotificationTypes { + return this.type; + } + public toPrimitives(): NotificationParams { return { id: this.getId().getID(), @@ -88,6 +98,7 @@ export default class Notification extends Entity { status: this.status.getStatus(), idUser: this.getIdUser().getID(), deletedAt: super.getDeletedAt().toPrimitive(), + type: this.type, }; } } diff --git a/backend/src/modules/notification/core/types/NotificationTypes.ts b/backend/src/modules/notification/core/types/NotificationTypes.ts new file mode 100644 index 00000000..91c2ea94 --- /dev/null +++ b/backend/src/modules/notification/core/types/NotificationTypes.ts @@ -0,0 +1,6 @@ +export const NOTIFICATION_TYPES = ['INFO', 'INVITATION'] as const; + +export enum NotificationTypes { + info = 'INFO', + invitation = 'INVITATION', +} diff --git a/backend/src/modules/project/core/interfaces/ProjectCriteria.ts b/backend/src/modules/project/core/interfaces/ProjectCriteria.ts new file mode 100644 index 00000000..c373a76a --- /dev/null +++ b/backend/src/modules/project/core/interfaces/ProjectCriteria.ts @@ -0,0 +1,12 @@ +export default interface ProjectCriteria{ + page?: number; + limit?: number; + title?: string; + archived?: boolean; + closed?: boolean; + idUser?: string; + watching?: boolean; + favorited?: boolean; + sortBy?: 'ASC' | 'DESC'; + priority?: 'WATCHING' | 'FAVORITE' | 'ALL'; +} diff --git a/backend/src/modules/project/core/repository/ProjectRepository.ts b/backend/src/modules/project/core/repository/ProjectRepository.ts new file mode 100644 index 00000000..55b5e341 --- /dev/null +++ b/backend/src/modules/project/core/repository/ProjectRepository.ts @@ -0,0 +1,10 @@ +import type IdEntity from "../../../shared/core/objects/IdEntity"; +import type ProjectCriteria from "../interfaces/ProjectCriteria"; +import type Project from "../model/Project"; + +export default interface ProjectRepository { + create(project: Project): Promise; + update(project: Project): Promise; + getById(id: IdEntity): Promise; + getByCriteria(criteria: ProjectCriteria): Promise; +} diff --git a/backend/tests/modules/notification/core/model/Notification.test.ts b/backend/tests/modules/notification/core/model/Notification.test.ts index 9fa03950..ea0f6a21 100644 --- a/backend/tests/modules/notification/core/model/Notification.test.ts +++ b/backend/tests/modules/notification/core/model/Notification.test.ts @@ -3,6 +3,7 @@ import NotificationAlreadyRead from '../../../../../src/modules/notification/cor import Notification from '../../../../../src/modules/notification/core/model/Notification'; import IdNotification from '../../../../../src/modules/notification/core/objects/IdNotification'; import { AllowedNotificationStatus } from '../../../../../src/modules/notification/core/types/AllowedNotificationStatus'; +import { NotificationTypes } from '../../../../../src/modules/notification/core/types/NotificationTypes'; import type DomainEvent from '../../../../../src/modules/shared/core/events/DomainEvent'; import IdEntity from '../../../../../src/modules/shared/core/objects/IdEntity'; @@ -17,6 +18,7 @@ const createNotificationParams = ( eventKey: string; status: AllowedNotificationStatus; idUser: string; + type: NotificationTypes; deletedAt: Date | null; key: string; }>, @@ -25,6 +27,7 @@ const createNotificationParams = ( eventKey: EVENT_ID, status: AllowedNotificationStatus.unread, idUser: USER_ID, + type: NotificationTypes.info, deletedAt: null, key: 'test-key', ...overrides, @@ -39,6 +42,7 @@ const buildNotification = (overrides?: Parameters { expect(notification.getEventKey()).toBe(EVENT_ID); expect(notification.getIdUser().getID()).toBe(USER_ID); expect(notification.getStatus().getStatus()).toBe(AllowedNotificationStatus.unread); + expect(notification.getType()).toBe(NotificationTypes.info); expect(notification.exists()).toBe(true); }); @@ -124,6 +129,7 @@ describe('Notification Entity', () => { eventKey: params.eventKey, status: params.status, idUser: params.idUser, + type: params.type, deletedAt: params.deletedAt, }); }); @@ -137,6 +143,7 @@ describe('Notification Entity', () => { expect(notification.getEventKey()).toBe(params.eventKey); expect(notification.getIdUser().getID()).toBe(params.idUser); expect(notification.getStatus().getStatus()).toBe(AllowedNotificationStatus.read); + expect(notification.getType()).toBe(params.type); }); it('should preserve immutable details after marking as read', () => { @@ -148,6 +155,7 @@ describe('Notification Entity', () => { expect(primitives.id).toBe(DEFAULT_ID); expect(primitives.eventKey).toBe(EVENT_ID); expect(primitives.idUser).toBe(USER_ID); + expect(primitives.type).toBe(NotificationTypes.info); expect(primitives.status).toBe(AllowedNotificationStatus.read); }); });