diff --git a/package.json b/package.json index 12ba099..a458420 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "airhorn", - "version": "4.0.0", + "version": "3.1.0", "description": "Cloud Notification Library", "type": "module", "main": "./dist/airhorn.js", @@ -48,7 +48,7 @@ "firebase-admin": "^12.4.0", "gray-matter": "^4.0.3", "mongodb": "^6.9.0", - "twilio": "^5.3.1" + "twilio": "^5.3.3" }, "files": [ "dist", diff --git a/src/airhorn.ts b/src/airhorn.ts index 6c645fe..c49fdb4 100644 --- a/src/airhorn.ts +++ b/src/airhorn.ts @@ -2,10 +2,9 @@ import { TemplateService } from './template-service.js'; import { ProviderService } from './provider-service.js'; import { AirhornProviderType } from './provider-type.js'; import { type AirhornSubscription } from './subscription.js'; -import { AirhornNotificationStatus, type AirhornNotification } from './notification.js'; import { AirhornQueue, type AirhornQueueProvider } from './queue.js'; import { - AirhornStore, type CreateAirhornNotification, type AirhornStoreProvider, type CreateAirhornSubscription, + AirhornStore, type AirhornStoreProvider, type CreateAirhornSubscription, } from './store.js'; export type AirhornOptions = { @@ -149,22 +148,6 @@ export class Airhorn { throw new Error('Airhorn store not available'); } - - public async publishNotification(notification: CreateAirhornNotification): Promise { - if (this._queue && this._store) { - const updatedNotification = await this._store.createNotification(notification); - - await this._queue.publishNotification(updatedNotification); - - updatedNotification.status = AirhornNotificationStatus.QUEUED; - - await this._store.updateNotification(updatedNotification); - - return; - } - - throw new Error('Airhorn queue and store needed for notifications'); - } } export { AirhornProviderType } from './provider-type.js'; diff --git a/test/airhorn.test.ts b/test/airhorn.test.ts index 0a92b53..007ee71 100644 --- a/test/airhorn.test.ts +++ b/test/airhorn.test.ts @@ -333,38 +333,4 @@ describe('Airhorn - Notification / Queue', async () => { const airhorn = new Airhorn({QUEUE_PROVIDER}); expect(airhorn.queue?.provider).toBeDefined(); }); - test('Airhorn Queue Publish Notification', async () => { - const QUEUE_PROVIDER = providerMock; - const STORE_PROVIDER = new MongoStoreProvider({uri: 'mongodb://localhost:27017/airhorn'}); - const createNotification: CreateAirhornNotification = { - to: 'john@doe.org', - from: 'me@you.com', - subscriptionId: '1234', - externalId: '1234', - providerType: AirhornProviderType.SMTP, - status: AirhornNotificationStatus.QUEUED, - templateName: 'test-template', - templateData: {}, - providerName: 'smtp', - }; - - const airhorn = new Airhorn({QUEUE_PROVIDER, STORE_PROVIDER}); - await airhorn.publishNotification(createNotification); - }); - test('Airhorn Queue Publish Notification with no Store', async () => { - const QUEUE_PROVIDER = providerMock; - const airhorn = new Airhorn({QUEUE_PROVIDER}); - const createNotification: CreateAirhornNotification = { - to: 'john@doe.org', - from: 'me@you.com', - subscriptionId: '1234', - externalId: '1234', - providerType: AirhornProviderType.SMTP, - status: AirhornNotificationStatus.QUEUED, - templateName: 'test-template', - templateData: {}, - providerName: 'smtp', - }; - await expect(airhorn.publishNotification(createNotification)).rejects.toThrowError(new Error('Airhorn queue and store needed for notifications')); - }); });