@develit-services/notification 0.5.1 → 0.6.1

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 (35) hide show
  1. package/README.md +62 -5
  2. package/dist/database/schema.cjs +4 -6
  3. package/dist/database/schema.d.cts +6 -2
  4. package/dist/database/schema.d.mts +6 -2
  5. package/dist/database/schema.d.ts +6 -2
  6. package/dist/database/schema.mjs +5 -3
  7. package/dist/export/worker.cjs +290 -66
  8. package/dist/export/worker.d.cts +22 -3
  9. package/dist/export/worker.d.mts +22 -3
  10. package/dist/export/worker.d.ts +22 -3
  11. package/dist/export/worker.mjs +282 -58
  12. package/dist/export/wrangler.cjs +19 -1
  13. package/dist/export/wrangler.d.cts +5 -1
  14. package/dist/export/wrangler.d.mts +5 -1
  15. package/dist/export/wrangler.d.ts +5 -1
  16. package/dist/export/wrangler.mjs +19 -1
  17. package/dist/shared/{notification.B0pktSz9.cjs → notification.BLPB8Ib2.cjs} +79 -0
  18. package/dist/shared/{notification.DWuoMDHY.d.ts → notification.BiG4Q650.d.cts} +98 -6
  19. package/dist/shared/{notification.B4ZLWDCP.d.cts → notification.BiG4Q650.d.mts} +98 -6
  20. package/dist/shared/{notification.CpFoKjoN.d.mts → notification.BiG4Q650.d.ts} +98 -6
  21. package/dist/shared/{notification.CmITLO7E.mjs → notification.CP_hFlNt.mjs} +75 -1
  22. package/dist/shared/{notification.BB9Jl8DI.d.mts → notification.CdlaOUd0.d.cts} +3 -0
  23. package/dist/shared/{notification.BB9Jl8DI.d.ts → notification.CdlaOUd0.d.mts} +3 -0
  24. package/dist/shared/{notification.BB9Jl8DI.d.cts → notification.CdlaOUd0.d.ts} +3 -0
  25. package/dist/types.cjs +19 -19
  26. package/dist/types.d.cts +5 -16
  27. package/dist/types.d.mts +5 -16
  28. package/dist/types.d.ts +5 -16
  29. package/dist/types.mjs +2 -10
  30. package/package.json +3 -3
  31. package/dist/shared/notification.4b3eUEIG.cjs +0 -22
  32. package/dist/shared/notification.BWLPh6Gb.d.cts +0 -140
  33. package/dist/shared/notification.BWLPh6Gb.d.mts +0 -140
  34. package/dist/shared/notification.BWLPh6Gb.d.ts +0 -140
  35. package/dist/shared/notification.C0X8Orrh.mjs +0 -19
@@ -25,11 +25,21 @@ function defineNotificationServiceWrangler(config) {
25
25
  migrations_dir: "./src/database/migrations"
26
26
  }
27
27
  ],
28
+ kv_namespaces: envs.local.kv ? [
29
+ {
30
+ binding: "RECEIVED_EMAILS_KV",
31
+ id: envs.local.kv.id
32
+ }
33
+ ] : [],
28
34
  queues: {
29
35
  producers: [
30
36
  {
31
37
  binding: "NOTIFICATIONS_QUEUE",
32
38
  queue: `${project}-notifications`
39
+ },
40
+ {
41
+ binding: "AUDIT_LOGS_QUEUE",
42
+ queue: `${project}-audit-logs`
33
43
  }
34
44
  ],
35
45
  consumers: [
@@ -58,7 +68,15 @@ function defineNotificationServiceWrangler(config) {
58
68
  database_id: envCfg.d1.id,
59
69
  migrations_dir: "./src/database/migrations"
60
70
  }
61
- ]
71
+ ],
72
+ ...envCfg.kv && {
73
+ kv_namespaces: [
74
+ {
75
+ binding: "RECEIVED_EMAILS_KV",
76
+ id: envCfg.kv.id
77
+ }
78
+ ]
79
+ }
62
80
  };
63
81
  }
64
82
  return base;
@@ -4,6 +4,7 @@ const z = require('zod');
4
4
  const backendSdk = require('@develit-io/backend-sdk');
5
5
  const v4 = require('zod/v4');
6
6
  const twilio = require('twilio');
7
+ const signature = require('@develit-io/backend-sdk/signature');
7
8
 
8
9
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
9
10
 
@@ -77,6 +78,21 @@ class IEmailConnector {
77
78
  }
78
79
  }
79
80
 
81
+ const getReceivedEmailsInputSchema = z.z.object({
82
+ recipient: z.z.email("Invalid email address"),
83
+ limit: z.z.number().min(1).max(100).optional().default(10),
84
+ includeContent: z.z.boolean().optional().default(true)
85
+ });
86
+ const waitForEmailInputSchema = z.z.object({
87
+ recipient: z.z.email("Invalid email address"),
88
+ subject: z.z.string().optional(),
89
+ timeout: z.z.number().min(1e3).max(6e4).optional().default(1e4),
90
+ pollInterval: z.z.number().min(100).max(5e3).optional().default(500)
91
+ });
92
+ const clearReceivedEmailsInputSchema = z.z.object({
93
+ recipient: z.z.email("Invalid email address")
94
+ });
95
+
80
96
  class EcomailConnector extends IEmailConnector {
81
97
  static {
82
98
  this.providerName = "ecomail";
@@ -220,6 +236,22 @@ const sendSmsInputSchema = z.z.object({
220
236
  })
221
237
  });
222
238
 
239
+ const sendWebhookInputSchema = v4.z.object({
240
+ webhook: v4.z.object({
241
+ url: v4.z.url(),
242
+ payload: v4.z.record(v4.z.string(), v4.z.unknown()),
243
+ headers: v4.z.record(v4.z.string(), v4.z.string()).optional()
244
+ }),
245
+ metadata: v4.z.object({
246
+ userAgent: v4.z.string().optional(),
247
+ ip: v4.z.ipv4().or(v4.z.ipv6()).optional(),
248
+ initiator: v4.z.object({
249
+ service: v4.z.string(),
250
+ userId: v4.z.string().optional()
251
+ })
252
+ })
253
+ });
254
+
223
255
  class ISmsConnector {
224
256
  constructor({
225
257
  ACCOUNT_ID,
@@ -292,14 +324,61 @@ class SlackConnector {
292
324
  }
293
325
  }
294
326
 
327
+ class WebhookConnector {
328
+ constructor(privateKey) {
329
+ this.privateKey = privateKey;
330
+ }
331
+ async sendWebhook(webhook) {
332
+ const body = JSON.stringify(webhook.payload);
333
+ const signature$1 = await signature.signPayload({
334
+ payload: body,
335
+ privateKey: this.privateKey
336
+ });
337
+ const controller = new AbortController();
338
+ const timeoutId = setTimeout(() => controller.abort(), 1e4);
339
+ let response;
340
+ try {
341
+ response = await fetch(webhook.url, {
342
+ method: "POST",
343
+ body,
344
+ headers: {
345
+ "Content-Type": "application/json",
346
+ "X-Webhook-Signature": signature$1,
347
+ ...webhook.headers
348
+ },
349
+ signal: controller.signal
350
+ });
351
+ } catch (error) {
352
+ clearTimeout(timeoutId);
353
+ throw backendSdk.createInternalError(error, {
354
+ message: "Webhook: request timed out",
355
+ code: "CONN-N-07",
356
+ status: 504
357
+ });
358
+ }
359
+ clearTimeout(timeoutId);
360
+ if (!response.ok)
361
+ throw backendSdk.createInternalError(null, {
362
+ message: `Webhook: delivery failed (${response.status})`,
363
+ code: "CONN-N-06",
364
+ status: 502
365
+ });
366
+ }
367
+ }
368
+
295
369
  exports.EcomailConnector = EcomailConnector;
296
370
  exports.IEmailConnector = IEmailConnector;
297
371
  exports.ISmsConnector = ISmsConnector;
298
372
  exports.SlackConnector = SlackConnector;
299
373
  exports.TwilioConnector = TwilioConnector;
374
+ exports.WebhookConnector = WebhookConnector;
375
+ exports.clearReceivedEmailsInputSchema = clearReceivedEmailsInputSchema;
376
+ exports.getReceivedEmailsInputSchema = getReceivedEmailsInputSchema;
300
377
  exports.iAttachmentSchema = iAttachmentSchema;
301
378
  exports.iContactSchema = iContactSchema;
302
379
  exports.iEmailSchema = iEmailSchema;
303
380
  exports.sendEmailInputSchema = sendEmailInputSchema;
304
381
  exports.sendSlackInputSchema = sendSlackInputSchema;
305
382
  exports.sendSmsInputSchema = sendSmsInputSchema;
383
+ exports.sendWebhookInputSchema = sendWebhookInputSchema;
384
+ exports.waitForEmailInputSchema = waitForEmailInputSchema;
@@ -1,9 +1,6 @@
1
- import { s as schema } from './notification.BWLPh6Gb.js';
2
1
  import z$1, { z } from 'zod';
3
2
  import { z as z$2 } from 'zod/v4';
4
3
 
5
- declare const tables: typeof schema;
6
-
7
4
  declare const iContactSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
8
5
  email: z.ZodString;
9
6
  name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
@@ -78,6 +75,68 @@ declare abstract class IEmailConnector {
78
75
  abstract sendEmail(email: IEmail): Promise<void>;
79
76
  }
80
77
 
78
+ /**
79
+ * Received Email structure (matches email-receiver format)
80
+ */
81
+ interface ReceivedEmail {
82
+ messageId: string;
83
+ from: string;
84
+ to: string;
85
+ subject: string;
86
+ text?: string;
87
+ html?: string;
88
+ headers: Record<string, string>;
89
+ receivedAt: string;
90
+ size: number;
91
+ raw?: string;
92
+ }
93
+ /**
94
+ * Input schema for getting received emails
95
+ */
96
+ declare const getReceivedEmailsInputSchema: z.ZodObject<{
97
+ recipient: z.ZodEmail;
98
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
99
+ includeContent: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
100
+ }, z.core.$strip>;
101
+ type GetReceivedEmailsInput = z.infer<typeof getReceivedEmailsInputSchema>;
102
+ /**
103
+ * Output schema for getting received emails
104
+ */
105
+ interface GetReceivedEmailsOutput {
106
+ emails: ReceivedEmail[];
107
+ count: number;
108
+ }
109
+ /**
110
+ * Input schema for waiting for email (E2E tests helper)
111
+ */
112
+ declare const waitForEmailInputSchema: z.ZodObject<{
113
+ recipient: z.ZodEmail;
114
+ subject: z.ZodOptional<z.ZodString>;
115
+ timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
116
+ pollInterval: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
117
+ }, z.core.$strip>;
118
+ type WaitForEmailInput = z.infer<typeof waitForEmailInputSchema>;
119
+ /**
120
+ * Output schema for waiting for email
121
+ */
122
+ interface WaitForEmailOutput {
123
+ email: ReceivedEmail | null;
124
+ found: boolean;
125
+ }
126
+ /**
127
+ * Input schema for clearing received emails
128
+ */
129
+ declare const clearReceivedEmailsInputSchema: z.ZodObject<{
130
+ recipient: z.ZodEmail;
131
+ }, z.core.$strip>;
132
+ type ClearReceivedEmailsInput = z.infer<typeof clearReceivedEmailsInputSchema>;
133
+ /**
134
+ * Output schema for clearing received emails
135
+ */
136
+ interface ClearReceivedEmailsOutput {
137
+ deleted: number;
138
+ }
139
+
81
140
  declare const sendEmailInputSchema: z$1.ZodObject<{
82
141
  email: z$1.ZodObject<{
83
142
  to: z$1.ZodUnion<readonly [z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
@@ -175,11 +234,31 @@ interface SendSmsInput extends z.infer<typeof sendSmsInputSchema> {
175
234
  interface SendSmsOutput {
176
235
  }
177
236
 
237
+ declare const sendWebhookInputSchema: z$2.ZodObject<{
238
+ webhook: z$2.ZodObject<{
239
+ url: z$2.ZodURL;
240
+ payload: z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>;
241
+ headers: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodString>>;
242
+ }, z$2.core.$strip>;
243
+ metadata: z$2.ZodObject<{
244
+ userAgent: z$2.ZodOptional<z$2.ZodString>;
245
+ ip: z$2.ZodOptional<z$2.ZodUnion<[z$2.ZodIPv4, z$2.ZodIPv6]>>;
246
+ initiator: z$2.ZodObject<{
247
+ service: z$2.ZodString;
248
+ userId: z$2.ZodOptional<z$2.ZodString>;
249
+ }, z$2.core.$strip>;
250
+ }, z$2.core.$strip>;
251
+ }, z$2.core.$strip>;
252
+ interface SendWebhookInput extends z$2.infer<typeof sendWebhookInputSchema> {
253
+ }
254
+ interface SendWebhookOutput {
255
+ }
256
+
178
257
  interface IPushNotification {
179
258
  }
180
259
 
181
260
  interface NotificationQueueMessage {
182
- type: 'email' | 'sms' | 'pushNotification' | 'slack';
261
+ type: 'email' | 'sms' | 'pushNotification' | 'slack' | 'webhook';
183
262
  metadata: {
184
263
  userAgent?: string;
185
264
  ip?: string;
@@ -193,6 +272,7 @@ interface NotificationQueueMessage {
193
272
  sms?: ISms;
194
273
  pushNotification?: IPushNotification;
195
274
  slack?: ISlack;
275
+ webhook?: IWebhook;
196
276
  };
197
277
  }
198
278
 
@@ -224,5 +304,17 @@ declare class SlackConnector {
224
304
  sendNotificationToAllSlack(message: string): Promise<void>;
225
305
  }
226
306
 
227
- export { IEmailConnector as I, SlackConnector as S, ISmsConnector as a, iAttachmentSchema as n, iContactSchema as o, iEmailSchema as p, sendSlackInputSchema as q, sendSmsInputSchema as r, sendEmailInputSchema as s, tables as t };
228
- export type { NotificationQueueMessage as N, SendEmailInput as b, SendEmailOutput as c, SendSmsInput as d, SendSmsOutput as e, SendSlackInput as f, SendSlackOutput as g, IEmail as h, IContact as i, ISms as j, IAttachment as k, IPushNotification as l, ISlack as m };
307
+ interface IWebhook {
308
+ url: string;
309
+ payload: Record<string, unknown>;
310
+ headers?: Record<string, string>;
311
+ }
312
+
313
+ declare class WebhookConnector {
314
+ private privateKey;
315
+ constructor(privateKey: string);
316
+ sendWebhook(webhook: IWebhook): Promise<void>;
317
+ }
318
+
319
+ export { sendSlackInputSchema as A, sendSmsInputSchema as B, sendWebhookInputSchema as D, waitForEmailInputSchema as E, IEmailConnector as I, SlackConnector as S, WebhookConnector as W, ISmsConnector as a, clearReceivedEmailsInputSchema as u, getReceivedEmailsInputSchema as v, iAttachmentSchema as w, iContactSchema as x, iEmailSchema as y, sendEmailInputSchema as z };
320
+ export type { ClearReceivedEmailsInput as C, GetReceivedEmailsInput as G, NotificationQueueMessage as N, ReceivedEmail as R, SendEmailInput as b, SendEmailOutput as c, SendSmsInput as d, SendSmsOutput as e, SendSlackInput as f, SendSlackOutput as g, SendWebhookInput as h, SendWebhookOutput as i, GetReceivedEmailsOutput as j, WaitForEmailInput as k, WaitForEmailOutput as l, ClearReceivedEmailsOutput as m, IEmail as n, IContact as o, ISms as p, IAttachment as q, IPushNotification as r, ISlack as s, IWebhook as t };
@@ -1,9 +1,6 @@
1
- import { s as schema } from './notification.BWLPh6Gb.cjs';
2
1
  import z$1, { z } from 'zod';
3
2
  import { z as z$2 } from 'zod/v4';
4
3
 
5
- declare const tables: typeof schema;
6
-
7
4
  declare const iContactSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
8
5
  email: z.ZodString;
9
6
  name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
@@ -78,6 +75,68 @@ declare abstract class IEmailConnector {
78
75
  abstract sendEmail(email: IEmail): Promise<void>;
79
76
  }
80
77
 
78
+ /**
79
+ * Received Email structure (matches email-receiver format)
80
+ */
81
+ interface ReceivedEmail {
82
+ messageId: string;
83
+ from: string;
84
+ to: string;
85
+ subject: string;
86
+ text?: string;
87
+ html?: string;
88
+ headers: Record<string, string>;
89
+ receivedAt: string;
90
+ size: number;
91
+ raw?: string;
92
+ }
93
+ /**
94
+ * Input schema for getting received emails
95
+ */
96
+ declare const getReceivedEmailsInputSchema: z.ZodObject<{
97
+ recipient: z.ZodEmail;
98
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
99
+ includeContent: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
100
+ }, z.core.$strip>;
101
+ type GetReceivedEmailsInput = z.infer<typeof getReceivedEmailsInputSchema>;
102
+ /**
103
+ * Output schema for getting received emails
104
+ */
105
+ interface GetReceivedEmailsOutput {
106
+ emails: ReceivedEmail[];
107
+ count: number;
108
+ }
109
+ /**
110
+ * Input schema for waiting for email (E2E tests helper)
111
+ */
112
+ declare const waitForEmailInputSchema: z.ZodObject<{
113
+ recipient: z.ZodEmail;
114
+ subject: z.ZodOptional<z.ZodString>;
115
+ timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
116
+ pollInterval: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
117
+ }, z.core.$strip>;
118
+ type WaitForEmailInput = z.infer<typeof waitForEmailInputSchema>;
119
+ /**
120
+ * Output schema for waiting for email
121
+ */
122
+ interface WaitForEmailOutput {
123
+ email: ReceivedEmail | null;
124
+ found: boolean;
125
+ }
126
+ /**
127
+ * Input schema for clearing received emails
128
+ */
129
+ declare const clearReceivedEmailsInputSchema: z.ZodObject<{
130
+ recipient: z.ZodEmail;
131
+ }, z.core.$strip>;
132
+ type ClearReceivedEmailsInput = z.infer<typeof clearReceivedEmailsInputSchema>;
133
+ /**
134
+ * Output schema for clearing received emails
135
+ */
136
+ interface ClearReceivedEmailsOutput {
137
+ deleted: number;
138
+ }
139
+
81
140
  declare const sendEmailInputSchema: z$1.ZodObject<{
82
141
  email: z$1.ZodObject<{
83
142
  to: z$1.ZodUnion<readonly [z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
@@ -175,11 +234,31 @@ interface SendSmsInput extends z.infer<typeof sendSmsInputSchema> {
175
234
  interface SendSmsOutput {
176
235
  }
177
236
 
237
+ declare const sendWebhookInputSchema: z$2.ZodObject<{
238
+ webhook: z$2.ZodObject<{
239
+ url: z$2.ZodURL;
240
+ payload: z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>;
241
+ headers: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodString>>;
242
+ }, z$2.core.$strip>;
243
+ metadata: z$2.ZodObject<{
244
+ userAgent: z$2.ZodOptional<z$2.ZodString>;
245
+ ip: z$2.ZodOptional<z$2.ZodUnion<[z$2.ZodIPv4, z$2.ZodIPv6]>>;
246
+ initiator: z$2.ZodObject<{
247
+ service: z$2.ZodString;
248
+ userId: z$2.ZodOptional<z$2.ZodString>;
249
+ }, z$2.core.$strip>;
250
+ }, z$2.core.$strip>;
251
+ }, z$2.core.$strip>;
252
+ interface SendWebhookInput extends z$2.infer<typeof sendWebhookInputSchema> {
253
+ }
254
+ interface SendWebhookOutput {
255
+ }
256
+
178
257
  interface IPushNotification {
179
258
  }
180
259
 
181
260
  interface NotificationQueueMessage {
182
- type: 'email' | 'sms' | 'pushNotification' | 'slack';
261
+ type: 'email' | 'sms' | 'pushNotification' | 'slack' | 'webhook';
183
262
  metadata: {
184
263
  userAgent?: string;
185
264
  ip?: string;
@@ -193,6 +272,7 @@ interface NotificationQueueMessage {
193
272
  sms?: ISms;
194
273
  pushNotification?: IPushNotification;
195
274
  slack?: ISlack;
275
+ webhook?: IWebhook;
196
276
  };
197
277
  }
198
278
 
@@ -224,5 +304,17 @@ declare class SlackConnector {
224
304
  sendNotificationToAllSlack(message: string): Promise<void>;
225
305
  }
226
306
 
227
- export { IEmailConnector as I, SlackConnector as S, ISmsConnector as a, iAttachmentSchema as n, iContactSchema as o, iEmailSchema as p, sendSlackInputSchema as q, sendSmsInputSchema as r, sendEmailInputSchema as s, tables as t };
228
- export type { NotificationQueueMessage as N, SendEmailInput as b, SendEmailOutput as c, SendSmsInput as d, SendSmsOutput as e, SendSlackInput as f, SendSlackOutput as g, IEmail as h, IContact as i, ISms as j, IAttachment as k, IPushNotification as l, ISlack as m };
307
+ interface IWebhook {
308
+ url: string;
309
+ payload: Record<string, unknown>;
310
+ headers?: Record<string, string>;
311
+ }
312
+
313
+ declare class WebhookConnector {
314
+ private privateKey;
315
+ constructor(privateKey: string);
316
+ sendWebhook(webhook: IWebhook): Promise<void>;
317
+ }
318
+
319
+ export { sendSlackInputSchema as A, sendSmsInputSchema as B, sendWebhookInputSchema as D, waitForEmailInputSchema as E, IEmailConnector as I, SlackConnector as S, WebhookConnector as W, ISmsConnector as a, clearReceivedEmailsInputSchema as u, getReceivedEmailsInputSchema as v, iAttachmentSchema as w, iContactSchema as x, iEmailSchema as y, sendEmailInputSchema as z };
320
+ export type { ClearReceivedEmailsInput as C, GetReceivedEmailsInput as G, NotificationQueueMessage as N, ReceivedEmail as R, SendEmailInput as b, SendEmailOutput as c, SendSmsInput as d, SendSmsOutput as e, SendSlackInput as f, SendSlackOutput as g, SendWebhookInput as h, SendWebhookOutput as i, GetReceivedEmailsOutput as j, WaitForEmailInput as k, WaitForEmailOutput as l, ClearReceivedEmailsOutput as m, IEmail as n, IContact as o, ISms as p, IAttachment as q, IPushNotification as r, ISlack as s, IWebhook as t };
@@ -1,9 +1,6 @@
1
- import { s as schema } from './notification.BWLPh6Gb.mjs';
2
1
  import z$1, { z } from 'zod';
3
2
  import { z as z$2 } from 'zod/v4';
4
3
 
5
- declare const tables: typeof schema;
6
-
7
4
  declare const iContactSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
8
5
  email: z.ZodString;
9
6
  name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
@@ -78,6 +75,68 @@ declare abstract class IEmailConnector {
78
75
  abstract sendEmail(email: IEmail): Promise<void>;
79
76
  }
80
77
 
78
+ /**
79
+ * Received Email structure (matches email-receiver format)
80
+ */
81
+ interface ReceivedEmail {
82
+ messageId: string;
83
+ from: string;
84
+ to: string;
85
+ subject: string;
86
+ text?: string;
87
+ html?: string;
88
+ headers: Record<string, string>;
89
+ receivedAt: string;
90
+ size: number;
91
+ raw?: string;
92
+ }
93
+ /**
94
+ * Input schema for getting received emails
95
+ */
96
+ declare const getReceivedEmailsInputSchema: z.ZodObject<{
97
+ recipient: z.ZodEmail;
98
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
99
+ includeContent: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
100
+ }, z.core.$strip>;
101
+ type GetReceivedEmailsInput = z.infer<typeof getReceivedEmailsInputSchema>;
102
+ /**
103
+ * Output schema for getting received emails
104
+ */
105
+ interface GetReceivedEmailsOutput {
106
+ emails: ReceivedEmail[];
107
+ count: number;
108
+ }
109
+ /**
110
+ * Input schema for waiting for email (E2E tests helper)
111
+ */
112
+ declare const waitForEmailInputSchema: z.ZodObject<{
113
+ recipient: z.ZodEmail;
114
+ subject: z.ZodOptional<z.ZodString>;
115
+ timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
116
+ pollInterval: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
117
+ }, z.core.$strip>;
118
+ type WaitForEmailInput = z.infer<typeof waitForEmailInputSchema>;
119
+ /**
120
+ * Output schema for waiting for email
121
+ */
122
+ interface WaitForEmailOutput {
123
+ email: ReceivedEmail | null;
124
+ found: boolean;
125
+ }
126
+ /**
127
+ * Input schema for clearing received emails
128
+ */
129
+ declare const clearReceivedEmailsInputSchema: z.ZodObject<{
130
+ recipient: z.ZodEmail;
131
+ }, z.core.$strip>;
132
+ type ClearReceivedEmailsInput = z.infer<typeof clearReceivedEmailsInputSchema>;
133
+ /**
134
+ * Output schema for clearing received emails
135
+ */
136
+ interface ClearReceivedEmailsOutput {
137
+ deleted: number;
138
+ }
139
+
81
140
  declare const sendEmailInputSchema: z$1.ZodObject<{
82
141
  email: z$1.ZodObject<{
83
142
  to: z$1.ZodUnion<readonly [z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
@@ -175,11 +234,31 @@ interface SendSmsInput extends z.infer<typeof sendSmsInputSchema> {
175
234
  interface SendSmsOutput {
176
235
  }
177
236
 
237
+ declare const sendWebhookInputSchema: z$2.ZodObject<{
238
+ webhook: z$2.ZodObject<{
239
+ url: z$2.ZodURL;
240
+ payload: z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>;
241
+ headers: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodString>>;
242
+ }, z$2.core.$strip>;
243
+ metadata: z$2.ZodObject<{
244
+ userAgent: z$2.ZodOptional<z$2.ZodString>;
245
+ ip: z$2.ZodOptional<z$2.ZodUnion<[z$2.ZodIPv4, z$2.ZodIPv6]>>;
246
+ initiator: z$2.ZodObject<{
247
+ service: z$2.ZodString;
248
+ userId: z$2.ZodOptional<z$2.ZodString>;
249
+ }, z$2.core.$strip>;
250
+ }, z$2.core.$strip>;
251
+ }, z$2.core.$strip>;
252
+ interface SendWebhookInput extends z$2.infer<typeof sendWebhookInputSchema> {
253
+ }
254
+ interface SendWebhookOutput {
255
+ }
256
+
178
257
  interface IPushNotification {
179
258
  }
180
259
 
181
260
  interface NotificationQueueMessage {
182
- type: 'email' | 'sms' | 'pushNotification' | 'slack';
261
+ type: 'email' | 'sms' | 'pushNotification' | 'slack' | 'webhook';
183
262
  metadata: {
184
263
  userAgent?: string;
185
264
  ip?: string;
@@ -193,6 +272,7 @@ interface NotificationQueueMessage {
193
272
  sms?: ISms;
194
273
  pushNotification?: IPushNotification;
195
274
  slack?: ISlack;
275
+ webhook?: IWebhook;
196
276
  };
197
277
  }
198
278
 
@@ -224,5 +304,17 @@ declare class SlackConnector {
224
304
  sendNotificationToAllSlack(message: string): Promise<void>;
225
305
  }
226
306
 
227
- export { IEmailConnector as I, SlackConnector as S, ISmsConnector as a, iAttachmentSchema as n, iContactSchema as o, iEmailSchema as p, sendSlackInputSchema as q, sendSmsInputSchema as r, sendEmailInputSchema as s, tables as t };
228
- export type { NotificationQueueMessage as N, SendEmailInput as b, SendEmailOutput as c, SendSmsInput as d, SendSmsOutput as e, SendSlackInput as f, SendSlackOutput as g, IEmail as h, IContact as i, ISms as j, IAttachment as k, IPushNotification as l, ISlack as m };
307
+ interface IWebhook {
308
+ url: string;
309
+ payload: Record<string, unknown>;
310
+ headers?: Record<string, string>;
311
+ }
312
+
313
+ declare class WebhookConnector {
314
+ private privateKey;
315
+ constructor(privateKey: string);
316
+ sendWebhook(webhook: IWebhook): Promise<void>;
317
+ }
318
+
319
+ export { sendSlackInputSchema as A, sendSmsInputSchema as B, sendWebhookInputSchema as D, waitForEmailInputSchema as E, IEmailConnector as I, SlackConnector as S, WebhookConnector as W, ISmsConnector as a, clearReceivedEmailsInputSchema as u, getReceivedEmailsInputSchema as v, iAttachmentSchema as w, iContactSchema as x, iEmailSchema as y, sendEmailInputSchema as z };
320
+ export type { ClearReceivedEmailsInput as C, GetReceivedEmailsInput as G, NotificationQueueMessage as N, ReceivedEmail as R, SendEmailInput as b, SendEmailOutput as c, SendSmsInput as d, SendSmsOutput as e, SendSlackInput as f, SendSlackOutput as g, SendWebhookInput as h, SendWebhookOutput as i, GetReceivedEmailsOutput as j, WaitForEmailInput as k, WaitForEmailOutput as l, ClearReceivedEmailsOutput as m, IEmail as n, IContact as o, ISms as p, IAttachment as q, IPushNotification as r, ISlack as s, IWebhook as t };
@@ -2,6 +2,7 @@ import z$1, { z } from 'zod';
2
2
  import { useFetch, createInternalError } from '@develit-io/backend-sdk';
3
3
  import { z as z$2 } from 'zod/v4';
4
4
  import twilio from 'twilio';
5
+ import { signPayload } from '@develit-io/backend-sdk/signature';
5
6
 
6
7
  const iContactSchema = z.union([
7
8
  z.string(),
@@ -70,6 +71,21 @@ class IEmailConnector {
70
71
  }
71
72
  }
72
73
 
74
+ const getReceivedEmailsInputSchema = z.object({
75
+ recipient: z.email("Invalid email address"),
76
+ limit: z.number().min(1).max(100).optional().default(10),
77
+ includeContent: z.boolean().optional().default(true)
78
+ });
79
+ const waitForEmailInputSchema = z.object({
80
+ recipient: z.email("Invalid email address"),
81
+ subject: z.string().optional(),
82
+ timeout: z.number().min(1e3).max(6e4).optional().default(1e4),
83
+ pollInterval: z.number().min(100).max(5e3).optional().default(500)
84
+ });
85
+ const clearReceivedEmailsInputSchema = z.object({
86
+ recipient: z.email("Invalid email address")
87
+ });
88
+
73
89
  class EcomailConnector extends IEmailConnector {
74
90
  static {
75
91
  this.providerName = "ecomail";
@@ -213,6 +229,22 @@ const sendSmsInputSchema = z.object({
213
229
  })
214
230
  });
215
231
 
232
+ const sendWebhookInputSchema = z$2.object({
233
+ webhook: z$2.object({
234
+ url: z$2.url(),
235
+ payload: z$2.record(z$2.string(), z$2.unknown()),
236
+ headers: z$2.record(z$2.string(), z$2.string()).optional()
237
+ }),
238
+ metadata: z$2.object({
239
+ userAgent: z$2.string().optional(),
240
+ ip: z$2.ipv4().or(z$2.ipv6()).optional(),
241
+ initiator: z$2.object({
242
+ service: z$2.string(),
243
+ userId: z$2.string().optional()
244
+ })
245
+ })
246
+ });
247
+
216
248
  class ISmsConnector {
217
249
  constructor({
218
250
  ACCOUNT_ID,
@@ -285,4 +317,46 @@ class SlackConnector {
285
317
  }
286
318
  }
287
319
 
288
- export { EcomailConnector as E, IEmailConnector as I, SlackConnector as S, TwilioConnector as T, sendSmsInputSchema as a, sendSlackInputSchema as b, ISmsConnector as c, iContactSchema as d, iEmailSchema as e, iAttachmentSchema as i, sendEmailInputSchema as s };
320
+ class WebhookConnector {
321
+ constructor(privateKey) {
322
+ this.privateKey = privateKey;
323
+ }
324
+ async sendWebhook(webhook) {
325
+ const body = JSON.stringify(webhook.payload);
326
+ const signature = await signPayload({
327
+ payload: body,
328
+ privateKey: this.privateKey
329
+ });
330
+ const controller = new AbortController();
331
+ const timeoutId = setTimeout(() => controller.abort(), 1e4);
332
+ let response;
333
+ try {
334
+ response = await fetch(webhook.url, {
335
+ method: "POST",
336
+ body,
337
+ headers: {
338
+ "Content-Type": "application/json",
339
+ "X-Webhook-Signature": signature,
340
+ ...webhook.headers
341
+ },
342
+ signal: controller.signal
343
+ });
344
+ } catch (error) {
345
+ clearTimeout(timeoutId);
346
+ throw createInternalError(error, {
347
+ message: "Webhook: request timed out",
348
+ code: "CONN-N-07",
349
+ status: 504
350
+ });
351
+ }
352
+ clearTimeout(timeoutId);
353
+ if (!response.ok)
354
+ throw createInternalError(null, {
355
+ message: `Webhook: delivery failed (${response.status})`,
356
+ code: "CONN-N-06",
357
+ status: 502
358
+ });
359
+ }
360
+ }
361
+
362
+ export { EcomailConnector as E, IEmailConnector as I, SlackConnector as S, TwilioConnector as T, WebhookConnector as W, ISmsConnector as a, iContactSchema as b, clearReceivedEmailsInputSchema as c, iEmailSchema as d, sendSlackInputSchema as e, sendSmsInputSchema as f, getReceivedEmailsInputSchema as g, sendWebhookInputSchema as h, iAttachmentSchema as i, sendEmailInputSchema as s, waitForEmailInputSchema as w };
@@ -6,6 +6,9 @@ interface NotificationServiceEnvironmentConfig {
6
6
  d1: {
7
7
  id: string;
8
8
  };
9
+ kv?: {
10
+ id: string;
11
+ };
9
12
  vars: {
10
13
  EMAIL_PROVIDER: 'ecomail';
11
14
  EMAIL_SENDER_EMAIL: string;
@@ -6,6 +6,9 @@ interface NotificationServiceEnvironmentConfig {
6
6
  d1: {
7
7
  id: string;
8
8
  };
9
+ kv?: {
10
+ id: string;
11
+ };
9
12
  vars: {
10
13
  EMAIL_PROVIDER: 'ecomail';
11
14
  EMAIL_SENDER_EMAIL: string;