@develit-services/notification 0.0.2 → 0.0.4

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 (62) hide show
  1. package/dist/src.cjs +636 -0
  2. package/dist/src.d.cts +491 -0
  3. package/dist/src.d.mts +489 -0
  4. package/dist/src.d.ts +491 -0
  5. package/dist/src.mjs +625 -0
  6. package/package.json +17 -1
  7. package/@types/consts/audit-log.consts.ts +0 -7
  8. package/@types/consts/index.ts +0 -1
  9. package/@types/database/audit-log.types.ts +0 -7
  10. package/@types/database/index.ts +0 -1
  11. package/@types/email/IEmail.connector.ts +0 -21
  12. package/@types/email/IEmail.types.ts +0 -25
  13. package/@types/email/ecomail/ecomail.connector.ts +0 -140
  14. package/@types/email/ecomail/ecomail.types.ts +0 -27
  15. package/@types/email/ecomail/index.ts +0 -2
  16. package/@types/email/index.ts +0 -3
  17. package/@types/index.ts +0 -9
  18. package/@types/io/index.ts +0 -3
  19. package/@types/io/sendEmail.ts +0 -18
  20. package/@types/io/sendSlack.ts +0 -19
  21. package/@types/io/sendSms.ts +0 -20
  22. package/@types/pushNotification/IPushNotification.ts +0 -1
  23. package/@types/pushNotification/index.ts +0 -1
  24. package/@types/queue.ts +0 -24
  25. package/@types/service.ts +0 -30
  26. package/@types/slack/ISlack.types.ts +0 -3
  27. package/@types/slack/index.ts +0 -1
  28. package/@types/slack/slack.connector.ts +0 -27
  29. package/@types/sms/ISms.connector.ts +0 -22
  30. package/@types/sms/ISms.types.ts +0 -4
  31. package/@types/sms/index.ts +0 -3
  32. package/@types/sms/twilio/index.ts +0 -1
  33. package/@types/sms/twilio/twilio.connector.ts +0 -36
  34. package/CHANGELOG.md +0 -28
  35. package/build.config.ts +0 -28
  36. package/drizzle.config.ts +0 -3
  37. package/src/database/drizzle.ts +0 -6
  38. package/src/database/migrations/0000_funny_beast.sql +0 -12
  39. package/src/database/migrations/meta/0000_snapshot.json +0 -101
  40. package/src/database/migrations/meta/_journal.json +0 -13
  41. package/src/database/schema/audit-log.schema.ts +0 -13
  42. package/src/database/schema/index.ts +0 -1
  43. package/src/defineNotificationService.ts +0 -321
  44. package/src/defineNotificationWrangler.ts +0 -78
  45. package/src/index.ts +0 -9
  46. package/src/utils/connectors.ts +0 -1
  47. package/src/utils/database/command/create-audit-log.command.ts +0 -34
  48. package/src/utils/database/command/index.ts +0 -1
  49. package/src/utils/database/index.ts +0 -1
  50. package/src/utils/email.ts +0 -25
  51. package/src/utils/index.ts +0 -3
  52. package/src/utils/sms.ts +0 -28
  53. package/test/env.d.ts +0 -7
  54. package/test/integration/sendEmail.test.ts +0 -88
  55. package/test/setup/migrations.ts +0 -3
  56. package/test/unit/connectors/ecomail.connector.ts +0 -715
  57. package/test/unit/email.test.ts +0 -55
  58. package/tsconfig.json +0 -3
  59. package/vitest.config.ts +0 -31
  60. package/worker-configuration.d.ts +0 -25
  61. package/wrangler.jsonc +0 -199
  62. package/wrangler.ts +0 -106
@@ -1,55 +0,0 @@
1
- // import { initiateEmailConnector } from '@develit-services/notification/src/utils'
2
- import { describe, expect, it } from 'vitest'
3
-
4
- describe('unit placeholder', () => {
5
- it('should pass', () => {
6
- expect(true).toBe(true)
7
- })
8
- })
9
-
10
- // describe('initiateEmailConnector', () => {
11
- // describe('should initiate email connector when', () => {
12
- // it('the input is valid', () => {
13
- // const result = initiateEmailConnector(
14
- // 'ecomail',
15
- // '2de39f9c-d098-4cfc-93d9-5396a2f19a06',
16
- // 'smtp.gmail.com',
17
- // {
18
- // email: 'example@gmail.com',
19
- // name: undefined,
20
- // },
21
- // )
22
- // expect(result).toEqual({
23
- // API_KEY: '2de39f9c-d098-4cfc-93d9-5396a2f19a06',
24
- // SENDER: {
25
- // email: 'example@gmail.com',
26
- // name: undefined,
27
- // },
28
- // SMTP_HOST: 'smtp.gmail.com',
29
- // })
30
- // })
31
- // })
32
-
33
- // describe('should return an error when', () => {
34
- // it('the given email provider is not supported', () => {
35
- // expect(
36
- // async () =>
37
- // await initiateEmailConnector(
38
- // 'fakemail',
39
- // '2de39f9c-d098-4cfc-93d9-5396a2f19a06',
40
- // 'smtp.gmail.com',
41
- // {
42
- // email: 'example@gmail.com',
43
- // name: undefined,
44
- // },
45
- // ),
46
- // ).rejects.toThrowError(
47
- // expect.objectContaining({
48
- // code: 'UNKNOWN_ERROR',
49
- // message: 'Unsupported email provider',
50
- // status: 404,
51
- // }),
52
- // )
53
- // })
54
- // })
55
- // })
package/tsconfig.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json"
3
- }
package/vitest.config.ts DELETED
@@ -1,31 +0,0 @@
1
- import {
2
- defineWorkersProject,
3
- readD1Migrations,
4
- } from '@cloudflare/vitest-pool-workers/config'
5
-
6
- export default defineWorkersProject({
7
- test: {
8
- printConsoleTrace: true,
9
- deps: {
10
- optimizer: {
11
- ssr: {
12
- enabled: true,
13
- include: ['@develit-io/backend-sdk'],
14
- },
15
- },
16
- },
17
- poolOptions: {
18
- workers: {
19
- singleWorker: true,
20
- miniflare: {
21
- bindings: {
22
- MIGRATIONS: await readD1Migrations('./src/database/migrations'),
23
- },
24
- },
25
- wrangler: {
26
- configPath: './wrangler.jsonc',
27
- },
28
- },
29
- },
30
- },
31
- })
@@ -1,25 +0,0 @@
1
- /* eslint-disable */
2
- // Generated by Wrangler by running `wrangler types --include-runtime false --env-interface NotificationEnv` (hash: f27bf2311bf7e2e03c649acaff98bf39)
3
- declare namespace Cloudflare {
4
- interface Env {
5
- EMAIL_PROVIDER: "ecomail";
6
- EMAIL_SENDER: {"email":"noreply@notify.develit.io","name":"develit"};
7
- EMAIL_SMTP_HOST: "notify.develit.io";
8
- EMAIL_API_KEY: "";
9
- SMS_PROVIDER: "twilio";
10
- SMS_ACCOUNT_ID: "";
11
- SMS_AUTH_TOKEN: "";
12
- SMS_SERVICE_ID: "";
13
- SLACK_WEBHOOKS: [""];
14
- ENVIRONMENT: "dev" | "test" | "staging" | "production";
15
- NOTIFICATION_D1: D1Database;
16
- NOTIFICATIONS_QUEUE: Queue;
17
- }
18
- }
19
- interface NotificationEnv extends Cloudflare.Env {}
20
- type StringifyValues<EnvType extends Record<string, unknown>> = {
21
- [Binding in keyof EnvType]: EnvType[Binding] extends string ? EnvType[Binding] : string;
22
- };
23
- declare namespace NodeJS {
24
- interface ProcessEnv extends StringifyValues<Pick<Cloudflare.Env, "EMAIL_PROVIDER" | "EMAIL_SENDER" | "EMAIL_SMTP_HOST" | "EMAIL_API_KEY" | "SMS_PROVIDER" | "SMS_ACCOUNT_ID" | "SMS_AUTH_TOKEN" | "SMS_SERVICE_ID" | "SLACK_WEBHOOKS" | "ENVIRONMENT">> {}
25
- }
package/wrangler.jsonc DELETED
@@ -1,199 +0,0 @@
1
- // ⚠️ AUTO-GENERATED FILE. DO NOT EDIT.
2
- // To make changes, update wrangler.ts and re-run the generation script.
3
-
4
- {
5
- "name": "develit-notification",
6
- "main": "./src/index.ts",
7
- "compatibility_date": "2025-06-04",
8
- "compatibility_flags": ["nodejs_compat"],
9
- "d1_databases": [
10
- {
11
- "binding": "NOTIFICATION_D1",
12
- "database_name": "develit-notification",
13
- "database_id": "00000000-da3f-4c28-a72c-4cb2920f7a3e",
14
- "migrations_dir": "./src/database/migrations"
15
- }
16
- ],
17
- "queues": {
18
- "producers": [
19
- {
20
- "binding": "NOTIFICATIONS_QUEUE",
21
- "queue": "develit-notification"
22
- }
23
- ],
24
- "consumers": [
25
- {
26
- "queue": "develit-notification",
27
- "max_batch_size": 1,
28
- "max_batch_timeout": 5,
29
- "dead_letter_queue": "develit-notification-dlq"
30
- }
31
- ]
32
- },
33
- "env": {
34
- "dev": {
35
- "vars": {
36
- "EMAIL_PROVIDER": "ecomail",
37
- "EMAIL_SENDER": {
38
- "email": "noreply@notify.develit.io",
39
- "name": "develit"
40
- },
41
- "EMAIL_SMTP_HOST": "notify.develit.io",
42
- "EMAIL_API_KEY": "",
43
- "SMS_PROVIDER": "twilio",
44
- "SMS_ACCOUNT_ID": "",
45
- "SMS_AUTH_TOKEN": "",
46
- "SMS_SERVICE_ID": "",
47
- "SLACK_WEBHOOKS": [""],
48
- "ENVIRONMENT": "dev"
49
- },
50
- "d1_databases": [
51
- {
52
- "binding": "NOTIFICATION_D1",
53
- "database_name": "develit-notification-dev",
54
- "database_id": "5ee14d35-25a8-4f6a-835d-bbb7cf335b48",
55
- "migrations_dir": "./src/database/migrations"
56
- }
57
- ],
58
- "queues": {
59
- "producers": [
60
- {
61
- "binding": "NOTIFICATIONS_QUEUE",
62
- "queue": "develit-notification-dev"
63
- }
64
- ],
65
- "consumers": [
66
- {
67
- "queue": "develit-notification-dev",
68
- "max_batch_size": 1,
69
- "max_batch_timeout": 5,
70
- "dead_letter_queue": "develit-notification-dlq-dev"
71
- }
72
- ]
73
- }
74
- },
75
- "test": {
76
- "vars": {
77
- "EMAIL_PROVIDER": "ecomail",
78
- "EMAIL_SENDER": {
79
- "email": "noreply@notify.develit.io",
80
- "name": "develit"
81
- },
82
- "EMAIL_SMTP_HOST": "notify.develit.io",
83
- "EMAIL_API_KEY": "",
84
- "SMS_PROVIDER": "twilio",
85
- "SMS_ACCOUNT_ID": "",
86
- "SMS_AUTH_TOKEN": "",
87
- "SMS_SERVICE_ID": "",
88
- "SLACK_WEBHOOKS": [""],
89
- "ENVIRONMENT": "test"
90
- },
91
- "d1_databases": [
92
- {
93
- "binding": "NOTIFICATION_D1",
94
- "database_name": "develit-notification-test",
95
- "database_id": "aa97cfa8-bf12-4e0d-837d-ef14e716db0d",
96
- "migrations_dir": "./src/database/migrations"
97
- }
98
- ],
99
- "queues": {
100
- "producers": [
101
- {
102
- "binding": "NOTIFICATIONS_QUEUE",
103
- "queue": "develit-notification-test"
104
- }
105
- ],
106
- "consumers": [
107
- {
108
- "queue": "develit-notification-test",
109
- "max_batch_size": 1,
110
- "max_batch_timeout": 5,
111
- "dead_letter_queue": "develit-notification-dlq-test"
112
- }
113
- ]
114
- }
115
- },
116
- "staging": {
117
- "vars": {
118
- "EMAIL_PROVIDER": "ecomail",
119
- "EMAIL_SENDER": {
120
- "email": "noreply@notify.develit.io",
121
- "name": "develit"
122
- },
123
- "EMAIL_SMTP_HOST": "notify.develit.io",
124
- "EMAIL_API_KEY": "",
125
- "SMS_PROVIDER": "twilio",
126
- "SMS_ACCOUNT_ID": "",
127
- "SMS_AUTH_TOKEN": "",
128
- "SMS_SERVICE_ID": "",
129
- "SLACK_WEBHOOKS": [""],
130
- "ENVIRONMENT": "staging"
131
- },
132
- "d1_databases": [
133
- {
134
- "binding": "NOTIFICATION_D1",
135
- "database_name": "develit-notification-staging",
136
- "database_id": "38ada081-b75d-4814-b162-02e89baa6e35",
137
- "migrations_dir": "./src/database/migrations"
138
- }
139
- ],
140
- "queues": {
141
- "producers": [
142
- {
143
- "binding": "NOTIFICATIONS_QUEUE",
144
- "queue": "develit-notification-staging"
145
- }
146
- ],
147
- "consumers": [
148
- {
149
- "queue": "develit-notification-staging",
150
- "max_batch_size": 1,
151
- "max_batch_timeout": 5,
152
- "dead_letter_queue": "develit-notification-dlq-staging"
153
- }
154
- ]
155
- }
156
- },
157
- "production": {
158
- "vars": {
159
- "EMAIL_PROVIDER": "ecomail",
160
- "EMAIL_SENDER": {
161
- "email": "noreply@notify.develit.io",
162
- "name": "develit"
163
- },
164
- "EMAIL_SMTP_HOST": "notify.develit.io",
165
- "EMAIL_API_KEY": "",
166
- "SMS_PROVIDER": "twilio",
167
- "SMS_ACCOUNT_ID": "",
168
- "SMS_AUTH_TOKEN": "",
169
- "SMS_SERVICE_ID": "",
170
- "SLACK_WEBHOOKS": [""],
171
- "ENVIRONMENT": "production"
172
- },
173
- "d1_databases": [
174
- {
175
- "binding": "NOTIFICATION_D1",
176
- "database_name": "develit-notification-production",
177
- "database_id": "a1b7886f-cba5-46da-871b-8a02ec50c8c4",
178
- "migrations_dir": "./src/database/migrations"
179
- }
180
- ],
181
- "queues": {
182
- "producers": [
183
- {
184
- "binding": "NOTIFICATIONS_QUEUE",
185
- "queue": "develit-notification-production"
186
- }
187
- ],
188
- "consumers": [
189
- {
190
- "queue": "develit-notification-production",
191
- "max_batch_size": 1,
192
- "max_batch_timeout": 5,
193
- "dead_letter_queue": "develit-notification-dlq-production"
194
- }
195
- ]
196
- }
197
- }
198
- }
199
- }
package/wrangler.ts DELETED
@@ -1,106 +0,0 @@
1
- import { defineNotificationServiceWrangler } from './src/defineNotificationWrangler'
2
-
3
- export default defineNotificationServiceWrangler({
4
- name: 'develit-notification',
5
- envs: {
6
- local: {
7
- d1: {
8
- id: '00000000-da3f-4c28-a72c-4cb2920f7a3e',
9
- },
10
- vars: {
11
- EMAIL_PROVIDER: 'ecomail',
12
- EMAIL_SENDER: {
13
- email: 'noreply@notify.develit.io',
14
- name: 'develit',
15
- },
16
- EMAIL_SMTP_HOST: 'notify.develit.io',
17
- EMAIL_API_KEY: '',
18
- SMS_PROVIDER: 'twilio',
19
- SMS_ACCOUNT_ID: '',
20
- SMS_AUTH_TOKEN: '',
21
- SMS_SERVICE_ID: '',
22
- SLACK_WEBHOOKS: [''],
23
- },
24
- },
25
- dev: {
26
- d1: {
27
- id: '5ee14d35-25a8-4f6a-835d-bbb7cf335b48',
28
- },
29
- vars: {
30
- EMAIL_PROVIDER: 'ecomail',
31
- EMAIL_SENDER: {
32
- email: 'noreply@notify.develit.io',
33
- name: 'develit',
34
- },
35
- EMAIL_SMTP_HOST: 'notify.develit.io',
36
- EMAIL_API_KEY: '',
37
- SMS_PROVIDER: 'twilio',
38
- SMS_ACCOUNT_ID: '',
39
- SMS_AUTH_TOKEN: '',
40
- SMS_SERVICE_ID: '',
41
- SLACK_WEBHOOKS: [''],
42
- },
43
- },
44
- test: {
45
- d1: {
46
- id: 'aa97cfa8-bf12-4e0d-837d-ef14e716db0d',
47
- },
48
- vars: {
49
- EMAIL_PROVIDER: 'ecomail',
50
- EMAIL_SENDER: {
51
- email: 'noreply@notify.develit.io',
52
- name: 'develit',
53
- },
54
- EMAIL_SMTP_HOST: 'notify.develit.io',
55
- EMAIL_API_KEY: '',
56
- SMS_PROVIDER: 'twilio',
57
- SMS_ACCOUNT_ID: '',
58
- SMS_AUTH_TOKEN: '',
59
- SMS_SERVICE_ID: '',
60
- SLACK_WEBHOOKS: [''],
61
- },
62
- },
63
- staging: {
64
- d1: {
65
- id: '38ada081-b75d-4814-b162-02e89baa6e35',
66
- },
67
- queue: {
68
- max_batch_size: 1,
69
- max_batch_timeout: 5,
70
- },
71
- vars: {
72
- EMAIL_PROVIDER: 'ecomail',
73
- EMAIL_SENDER: {
74
- email: 'noreply@notify.develit.io',
75
- name: 'develit',
76
- },
77
- EMAIL_SMTP_HOST: 'notify.develit.io',
78
- EMAIL_API_KEY: '',
79
- SMS_PROVIDER: 'twilio',
80
- SMS_ACCOUNT_ID: '',
81
- SMS_AUTH_TOKEN: '',
82
- SMS_SERVICE_ID: '',
83
- SLACK_WEBHOOKS: [''],
84
- },
85
- },
86
- production: {
87
- d1: {
88
- id: 'a1b7886f-cba5-46da-871b-8a02ec50c8c4',
89
- },
90
- vars: {
91
- EMAIL_PROVIDER: 'ecomail',
92
- EMAIL_SENDER: {
93
- email: 'noreply@notify.develit.io',
94
- name: 'develit',
95
- },
96
- EMAIL_SMTP_HOST: 'notify.develit.io',
97
- EMAIL_API_KEY: '',
98
- SMS_PROVIDER: 'twilio',
99
- SMS_ACCOUNT_ID: '',
100
- SMS_AUTH_TOKEN: '',
101
- SMS_SERVICE_ID: '',
102
- SLACK_WEBHOOKS: [''],
103
- },
104
- },
105
- },
106
- })