diff --git a/packages/node/src/lib/messages/messages.interface.ts b/packages/node/src/lib/messages/messages.interface.ts index 377e901c7ea..2c47a2f5462 100644 --- a/packages/node/src/lib/messages/messages.interface.ts +++ b/packages/node/src/lib/messages/messages.interface.ts @@ -3,6 +3,7 @@ import { ChannelTypeEnum } from '@novu/shared'; export interface IMessages { deleteById(messageId: string); list(data?: IMessagesPayload); + deleteByTransactionId(transactionId: string); } export interface IMessagesPayload { diff --git a/packages/node/src/lib/messages/messages.ts b/packages/node/src/lib/messages/messages.ts index 40b2e30c2fb..4178a44b3de 100644 --- a/packages/node/src/lib/messages/messages.ts +++ b/packages/node/src/lib/messages/messages.ts @@ -19,7 +19,21 @@ export class Messages extends WithHttp implements IMessages { }); } + /** + * Deletes a single message notification by messageId. + * + * @param {string} messageId - The MongoDB ID of the message to delete. + */ async deleteById(messageId: string) { return await this.http.delete(`${BASE_PATH}/${messageId}`); } + + /** + * Deletes multiple message notifications by transactionId. + * + * @param {string} transactionId - The unique identifier of the event whose notifications will be deleted. + */ + async deleteByTransactionId(transactionId: string) { + return await this.http.delete(`${BASE_PATH}/transaction/${transactionId}`); + } }