@develit-services/notification 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/@types/consts/audit-log.consts.ts +7 -0
  2. package/@types/consts/index.ts +1 -0
  3. package/@types/database/audit-log.types.ts +7 -0
  4. package/@types/database/index.ts +1 -0
  5. package/@types/email/IEmail.connector.ts +21 -0
  6. package/@types/email/IEmail.types.ts +25 -0
  7. package/@types/email/ecomail/ecomail.connector.ts +140 -0
  8. package/@types/email/ecomail/ecomail.types.ts +27 -0
  9. package/@types/email/ecomail/index.ts +2 -0
  10. package/@types/email/index.ts +3 -0
  11. package/@types/index.ts +9 -0
  12. package/@types/io/index.ts +3 -0
  13. package/@types/io/sendEmail.ts +18 -0
  14. package/@types/io/sendSlack.ts +19 -0
  15. package/@types/io/sendSms.ts +20 -0
  16. package/@types/pushNotification/IPushNotification.ts +1 -0
  17. package/@types/pushNotification/index.ts +1 -0
  18. package/@types/queue.ts +24 -0
  19. package/@types/service.ts +30 -0
  20. package/@types/slack/ISlack.types.ts +3 -0
  21. package/@types/slack/index.ts +1 -0
  22. package/@types/slack/slack.connector.ts +27 -0
  23. package/@types/sms/ISms.connector.ts +22 -0
  24. package/@types/sms/ISms.types.ts +4 -0
  25. package/@types/sms/index.ts +3 -0
  26. package/@types/sms/twilio/index.ts +1 -0
  27. package/@types/sms/twilio/twilio.connector.ts +36 -0
  28. package/CHANGELOG.md +28 -0
  29. package/build.config.ts +28 -0
  30. package/drizzle.config.ts +3 -0
  31. package/package.json +40 -0
  32. package/scripts/generate-wrangler.ts +13 -0
  33. package/src/database/drizzle.ts +6 -0
  34. package/src/database/migrations/0000_funny_beast.sql +12 -0
  35. package/src/database/migrations/meta/0000_snapshot.json +101 -0
  36. package/src/database/migrations/meta/_journal.json +13 -0
  37. package/src/database/schema/audit-log.schema.ts +13 -0
  38. package/src/database/schema/index.ts +1 -0
  39. package/src/defineNotificationService.ts +321 -0
  40. package/src/defineNotificationWrangler.ts +78 -0
  41. package/src/index.ts +9 -0
  42. package/src/utils/connectors.ts +1 -0
  43. package/src/utils/database/command/create-audit-log.command.ts +34 -0
  44. package/src/utils/database/command/index.ts +1 -0
  45. package/src/utils/database/index.ts +1 -0
  46. package/src/utils/email.ts +25 -0
  47. package/src/utils/index.ts +3 -0
  48. package/src/utils/sms.ts +28 -0
  49. package/test/env.d.ts +7 -0
  50. package/test/integration/sendEmail.test.ts +88 -0
  51. package/test/setup/migrations.ts +3 -0
  52. package/test/unit/connectors/ecomail.connector.ts +715 -0
  53. package/test/unit/email.test.ts +55 -0
  54. package/tsconfig.json +3 -0
  55. package/vitest.config.ts +31 -0
  56. package/worker-configuration.d.ts +25 -0
  57. package/wrangler.jsonc +199 -0
  58. package/wrangler.ts +106 -0
@@ -0,0 +1,88 @@
1
+ // import { SELF } from 'cloudflare:test'
2
+ import { describe, expect, it } from 'vitest'
3
+
4
+ describe('integration placeholder', () => {
5
+ it('should pass', () => {
6
+ expect(true).toBe(true)
7
+ })
8
+ })
9
+
10
+ // // class MockEmailConnector extends IEmailConnector {
11
+ // // constructor() {
12
+ // // super({
13
+ // // API_KEY: 'mock_api_key',
14
+ // // SMTP_HOST: 'mock_smtp_host',
15
+ // // SENDER: { email: 'sender@example.com', name: 'Sender Name' } as IContact,
16
+ // // })
17
+ // // }
18
+
19
+ // // async sendEmail(email: IEmail): Promise<Response | null> {
20
+ // // // Mock implementation for success case
21
+
22
+ // // return Promise.resolve(new Response('Email sent.', { status: 200 }))
23
+ // // }
24
+ // // }
25
+
26
+ // describe('sendEmail', () => {
27
+ // // beforeEach(() => {
28
+ // // vi.resetModules()
29
+ // // vi.doUnmock('../../@types/email/IEmail.connector')
30
+ // // })
31
+ // describe('should return a successful response when', () => {
32
+ // it('the input is valid', async () => {
33
+ // const { status, message, data, error } = await SELF.sendEmail({
34
+ // email: {
35
+ // to: 'anna@example.com',
36
+ // replyTo: 'anna@example.com',
37
+ // cc: 'manager@example.com',
38
+ // bcc: 'admin@example.com',
39
+ // from: 'ben@example.com',
40
+ // subject: 'Meeting Reminder',
41
+ // text: 'Hi! Meeting tomorrow!',
42
+ // html: undefined,
43
+ // templateId: 0,
44
+ // templateVariables: {},
45
+ // },
46
+ // metadata: {
47
+ // userAgent: 'v8',
48
+ // initiator: {
49
+ // service: 'test',
50
+ // },
51
+ // },
52
+ // })
53
+
54
+ // expect(error).toBeFalsy()
55
+ // expect(status).toEqual(200)
56
+ // expect(message).toEqual('Email sent.')
57
+ // expect(data).toEqual({})
58
+ // })
59
+ // })
60
+
61
+ // // describe('should return an error when', () => {
62
+ // // it('the input is valid', async () => {
63
+ // // vi.doMock('../../@types/email/IEmail.connector', () => ({
64
+ // // sendEmail: vi.fn().mockRejectedValueOnce(new Error('Error mock')),
65
+ // // }))
66
+
67
+ // // const { status, message, data, error } = await SELF.sendEmail({
68
+ // // email: {
69
+ // // to: 'anna@example.com',
70
+ // // replyTo: 'anna@example.com',
71
+ // // cc: 'manager@example.com',
72
+ // // bcc: 'admin@example.com',
73
+ // // from: 'ben@example.com',
74
+ // // subject: 'Meeting Reminder',
75
+ // // text: 'Hi! Meeting tomorrow!',
76
+ // // html: undefined,
77
+ // // templateId: 0,
78
+ // // templateVariables: {},
79
+ // // },
80
+ // // })
81
+
82
+ // // expect(error).toBeTruthy()
83
+ // // expect(status).toEqual(500)
84
+ // // expect(message).toEqual('')
85
+ // // expect(data).toEqual(null)
86
+ // // })
87
+ // // })
88
+ // })
@@ -0,0 +1,3 @@
1
+ import { applyD1Migrations, env } from 'cloudflare:test'
2
+
3
+ await applyD1Migrations(env.NOTIFICATION_D1, env.MIGRATIONS)