@develit-services/notification 0.5.0 → 0.6.0

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 +239 -0
  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 +270 -69
  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 +262 -61
  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.Dk_5TX9v.cjs → notification.BLPB8Ib2.cjs} +109 -11
  18. package/dist/shared/{notification.2rSOcFrr.d.cts → notification.BiG4Q650.d.cts} +99 -8
  19. package/dist/shared/{notification.C1quYqlT.d.mts → notification.BiG4Q650.d.mts} +99 -8
  20. package/dist/shared/{notification.oEdhCsu_.d.ts → notification.BiG4Q650.d.ts} +99 -8
  21. package/dist/shared/{notification.CM_WoR0y.mjs → notification.CP_hFlNt.mjs} +105 -12
  22. package/dist/shared/{notification.BB9Jl8DI.d.ts → notification.CdlaOUd0.d.cts} +3 -0
  23. package/dist/shared/{notification.BB9Jl8DI.d.cts → notification.CdlaOUd0.d.mts} +3 -0
  24. package/dist/shared/{notification.BB9Jl8DI.d.mts → notification.CdlaOUd0.d.ts} +3 -0
  25. package/dist/types.cjs +19 -19
  26. package/dist/types.d.cts +6 -18
  27. package/dist/types.d.mts +6 -18
  28. package/dist/types.d.ts +6 -18
  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
@@ -3,10 +3,11 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const backendSdk = require('@develit-io/backend-sdk');
6
- const database_schema = require('../shared/notification.4b3eUEIG.cjs');
6
+ const database_schema = require('../database/schema.cjs');
7
7
  require('drizzle-orm');
8
8
  require('drizzle-orm/sqlite-core');
9
- const slack_connector = require('../shared/notification.Dk_5TX9v.cjs');
9
+ const webhook_connector = require('../shared/notification.BLPB8Ib2.cjs');
10
+ require('@develit-io/backend-sdk/signature');
10
11
  const cloudflare_workers = require('cloudflare:workers');
11
12
  const d1 = require('drizzle-orm/d1');
12
13
  require('zod');
@@ -16,12 +17,13 @@ require('twilio');
16
17
  const tables = database_schema.schema;
17
18
 
18
19
  const initiateEmailConnector = async (provider, apiKey, smtpHost, senderEmail, senderName) => {
19
- const connector = [slack_connector.EcomailConnector].find(
20
+ const connector = [webhook_connector.EcomailConnector].find(
20
21
  (conn) => conn.providerName === provider
21
22
  );
22
23
  if (!connector)
23
24
  throw backendSdk.createInternalError(null, {
24
25
  message: "Unsupported email provider",
26
+ code: "VALID-N-01",
25
27
  status: 404
26
28
  });
27
29
  return new connector({
@@ -32,39 +34,18 @@ const initiateEmailConnector = async (provider, apiKey, smtpHost, senderEmail, s
32
34
  });
33
35
  };
34
36
 
35
- const createAuditLogCommand = async ({
36
- db,
37
- auditLog: {
38
- event,
39
- description,
40
- initiatorService,
41
- initiatorUserId,
42
- ip,
43
- userAgent
44
- }
45
- }) => {
46
- const command = db.insert(tables.auditLog).values({
47
- id: backendSdk.uuidv4(),
48
- createdAt: /* @__PURE__ */ new Date(),
49
- event,
50
- description,
51
- ip,
52
- userAgent,
53
- initiatorService,
54
- initiatorUserId
55
- });
56
- return {
57
- command
58
- };
59
- };
37
+ function generateEmailKVPattern(recipient) {
38
+ return `email:${recipient}:`;
39
+ }
60
40
 
61
41
  const initiateSmsConnector = async (provider, accountId, authToken, serviceId) => {
62
- const connector = [slack_connector.TwilioConnector].find(
42
+ const connector = [webhook_connector.TwilioConnector].find(
63
43
  (conn) => conn.providerName === provider
64
44
  );
65
45
  if (!connector)
66
46
  throw backendSdk.createInternalError(null, {
67
- message: "Unsupported sms provider",
47
+ message: "Unsupported SMS provider",
48
+ code: "VALID-N-02",
68
49
  status: 404
69
50
  });
70
51
  return new connector({
@@ -89,7 +70,7 @@ let NotificationServiceBase = class extends backendSdk.develitWorker(
89
70
  ) {
90
71
  constructor(ctx, env) {
91
72
  super(ctx, env);
92
- this.slackConnector = new slack_connector.SlackConnector(this.env.SLACK_WEBHOOK);
73
+ this.slackConnector = new webhook_connector.SlackConnector(this.env.SLACK_WEBHOOK);
93
74
  this.db = d1.drizzle(this.env.NOTIFICATION_D1, { schema: tables });
94
75
  }
95
76
  async queue(batch) {
@@ -119,6 +100,12 @@ let NotificationServiceBase = class extends backendSdk.develitWorker(
119
100
  metadata
120
101
  });
121
102
  break;
103
+ case "webhook":
104
+ notificationAction = async () => this._sendWebhook({
105
+ webhook: payload.webhook,
106
+ metadata
107
+ });
108
+ break;
122
109
  default:
123
110
  this.logError({ error: `Unknown notification type: ${type}` });
124
111
  message.retry();
@@ -135,7 +122,7 @@ let NotificationServiceBase = class extends backendSdk.develitWorker(
135
122
  }
136
123
  async _sendEmail(input) {
137
124
  return this.handleAction(
138
- { data: input, schema: slack_connector.sendEmailInputSchema },
125
+ { data: input, schema: webhook_connector.sendEmailInputSchema },
139
126
  { successMessage: "Email sent." },
140
127
  async (params) => {
141
128
  const {
@@ -143,7 +130,7 @@ let NotificationServiceBase = class extends backendSdk.develitWorker(
143
130
  metadata: {
144
131
  ip,
145
132
  userAgent,
146
- initiator: { service: service2, userId }
133
+ initiator: { userId }
147
134
  }
148
135
  } = params;
149
136
  if (!this.emailConnector) {
@@ -158,26 +145,31 @@ let NotificationServiceBase = class extends backendSdk.develitWorker(
158
145
  );
159
146
  }
160
147
  await this.emailConnector.sendEmail(email);
161
- const { command } = await createAuditLogCommand({
162
- db: this.db,
163
- auditLog: {
164
- id: backendSdk.uuidv4(),
165
- event: "EMAIL",
166
- ip,
167
- initiatorService: service2,
168
- initiatorUserId: userId,
169
- userAgent,
170
- description: JSON.stringify(input)
171
- }
148
+ await this.pushToQueue(this.env.AUDIT_LOGS_QUEUE, {
149
+ logType: "event",
150
+ service: "notification",
151
+ correlationId: backendSdk.uuidv4(),
152
+ eventType: "notification.email_sent",
153
+ actorUserId: userId,
154
+ actorEmail: userId || "SYSTEM",
155
+ targetType: "email",
156
+ targetId: email.to,
157
+ sourceIp: ip,
158
+ userAgent,
159
+ outcome: "success",
160
+ description: `Email sent to ${email.to}`,
161
+ details: JSON.stringify({
162
+ subject: email.subject,
163
+ templateId: email.templateId
164
+ })
172
165
  });
173
- await this.db.batch([command]);
174
166
  return {};
175
167
  }
176
168
  );
177
169
  }
178
170
  async _sendSms(input) {
179
171
  return this.handleAction(
180
- { data: input, schema: slack_connector.sendSmsInputSchema },
172
+ { data: input, schema: webhook_connector.sendSmsInputSchema },
181
173
  { successMessage: "Sms sent." },
182
174
  async (params) => {
183
175
  const {
@@ -185,7 +177,7 @@ let NotificationServiceBase = class extends backendSdk.develitWorker(
185
177
  metadata: {
186
178
  ip,
187
179
  userAgent,
188
- initiator: { service: service2, userId }
180
+ initiator: { userId }
189
181
  }
190
182
  } = params;
191
183
  if (!this.smsConnector) {
@@ -203,26 +195,28 @@ let NotificationServiceBase = class extends backendSdk.develitWorker(
203
195
  );
204
196
  }
205
197
  await this.smsConnector.sendSms({ message, to });
206
- const { command } = await createAuditLogCommand({
207
- db: this.db,
208
- auditLog: {
209
- id: backendSdk.uuidv4(),
210
- event: "SMS",
211
- ip,
212
- userAgent,
213
- initiatorService: service2,
214
- initiatorUserId: userId,
215
- description: JSON.stringify(input)
216
- }
198
+ await this.pushToQueue(this.env.AUDIT_LOGS_QUEUE, {
199
+ logType: "event",
200
+ service: "notification",
201
+ correlationId: backendSdk.uuidv4(),
202
+ eventType: "notification.sms_sent",
203
+ actorUserId: userId,
204
+ actorEmail: userId || "SYSTEM",
205
+ targetType: "sms",
206
+ targetId: to,
207
+ sourceIp: ip,
208
+ userAgent,
209
+ outcome: "success",
210
+ description: `SMS sent to ${to}`,
211
+ details: JSON.stringify({ message })
217
212
  });
218
- await this.db.batch([command]);
219
213
  return {};
220
214
  }
221
215
  );
222
216
  }
223
217
  async sendEmail(input) {
224
218
  return this.handleAction(
225
- { data: input, schema: slack_connector.sendEmailInputSchema },
219
+ { data: input, schema: webhook_connector.sendEmailInputSchema },
226
220
  { successMessage: "Email sent." },
227
221
  async (params) => {
228
222
  const { email, metadata } = params;
@@ -242,7 +236,7 @@ let NotificationServiceBase = class extends backendSdk.develitWorker(
242
236
  }
243
237
  async sendEmailSync(input) {
244
238
  return this.handleAction(
245
- { data: input, schema: slack_connector.sendEmailInputSchema },
239
+ { data: input, schema: webhook_connector.sendEmailInputSchema },
246
240
  { successMessage: "Email sent." },
247
241
  async (params) => {
248
242
  const { email, metadata } = params;
@@ -255,7 +249,7 @@ let NotificationServiceBase = class extends backendSdk.develitWorker(
255
249
  }
256
250
  async sendSms(input) {
257
251
  return this.handleAction(
258
- { data: input, schema: slack_connector.sendSmsInputSchema },
252
+ { data: input, schema: webhook_connector.sendSmsInputSchema },
259
253
  { successMessage: "SMS sent." },
260
254
  async (params) => {
261
255
  const {
@@ -280,15 +274,19 @@ let NotificationServiceBase = class extends backendSdk.develitWorker(
280
274
  );
281
275
  }
282
276
  async _sendPushNotification() {
283
- this.logInput({});
284
- this.logError({ error: "Method not implemented." });
285
- throw new Error("Method not implemented.");
277
+ return this.handleAction(null, { successMessage: "" }, async () => {
278
+ throw backendSdk.createInternalError(null, {
279
+ message: "Push notifications not implemented",
280
+ code: "SYS-N-01",
281
+ status: 501
282
+ });
283
+ });
286
284
  }
287
285
  async sendSlackNotification(input) {
288
286
  return this.handleAction(
289
287
  {
290
288
  data: input,
291
- schema: slack_connector.sendSlackInputSchema
289
+ schema: webhook_connector.sendSlackInputSchema
292
290
  },
293
291
  { successMessage: "Slack sent." },
294
292
  async (params) => {
@@ -298,6 +296,194 @@ let NotificationServiceBase = class extends backendSdk.develitWorker(
298
296
  }
299
297
  );
300
298
  }
299
+ async sendWebhook(input) {
300
+ return this.handleAction(
301
+ { data: input, schema: webhook_connector.sendWebhookInputSchema },
302
+ { successMessage: "Webhook queued." },
303
+ async (params) => {
304
+ const { webhook, metadata } = params;
305
+ await this.pushToQueue(
306
+ this.env.NOTIFICATIONS_QUEUE,
307
+ {
308
+ type: "webhook",
309
+ payload: {
310
+ webhook
311
+ },
312
+ metadata
313
+ }
314
+ );
315
+ return {};
316
+ }
317
+ );
318
+ }
319
+ async _sendWebhook(input) {
320
+ return this.handleAction(
321
+ { data: input, schema: webhook_connector.sendWebhookInputSchema },
322
+ { successMessage: "Webhook sent." },
323
+ async (params) => {
324
+ const {
325
+ webhook,
326
+ metadata: {
327
+ ip,
328
+ userAgent,
329
+ initiator: { userId }
330
+ }
331
+ } = params;
332
+ if (!this.webhookConnector) {
333
+ const privateKey = (await this.env.SECRETS_STORE.get({
334
+ secretName: "NOTIFICATION_SERVICE_WEBHOOK_SIGNING_KEY"
335
+ })).data?.secretValue;
336
+ if (!privateKey) {
337
+ throw backendSdk.createInternalError(null, {
338
+ message: "NOTIFICATION_SERVICE_WEBHOOK_SIGNING_KEY is not configured",
339
+ code: "SYS-N-02",
340
+ status: 500
341
+ });
342
+ }
343
+ this.webhookConnector = new webhook_connector.WebhookConnector(privateKey);
344
+ }
345
+ await this.webhookConnector.sendWebhook(webhook);
346
+ await this.pushToQueue(this.env.AUDIT_LOGS_QUEUE, {
347
+ logType: "event",
348
+ service: "notification",
349
+ correlationId: backendSdk.uuidv4(),
350
+ eventType: "notification.webhook_sent",
351
+ actorUserId: userId,
352
+ actorEmail: userId || "SYSTEM",
353
+ targetType: "webhook",
354
+ targetId: webhook.url,
355
+ sourceIp: ip,
356
+ userAgent,
357
+ outcome: "success",
358
+ description: `Webhook sent to ${webhook.url}`,
359
+ details: JSON.stringify({
360
+ url: webhook.url
361
+ })
362
+ });
363
+ return {};
364
+ }
365
+ );
366
+ }
367
+ async getReceivedEmails(input) {
368
+ return this.handleAction(
369
+ {
370
+ data: input,
371
+ schema: webhook_connector.getReceivedEmailsInputSchema
372
+ },
373
+ { successMessage: "Emails retrieved." },
374
+ async (params) => {
375
+ const { recipient, limit, includeContent } = params;
376
+ if (!this.env.RECEIVED_EMAILS_KV) {
377
+ throw new Error("RECEIVED_EMAILS_KV binding is not configured");
378
+ }
379
+ const pattern = generateEmailKVPattern(recipient);
380
+ const list = await this.env.RECEIVED_EMAILS_KV.list({
381
+ prefix: pattern,
382
+ limit
383
+ });
384
+ const emails = [];
385
+ for (const key of list.keys) {
386
+ const emailData = await this.env.RECEIVED_EMAILS_KV.get(
387
+ key.name,
388
+ "json"
389
+ );
390
+ if (emailData) {
391
+ const email = emailData;
392
+ if (!includeContent) {
393
+ delete email.text;
394
+ delete email.html;
395
+ delete email.raw;
396
+ }
397
+ emails.push(email);
398
+ }
399
+ }
400
+ emails.sort(
401
+ (a, b) => new Date(b.receivedAt).getTime() - new Date(a.receivedAt).getTime()
402
+ );
403
+ return {
404
+ emails,
405
+ count: emails.length
406
+ };
407
+ }
408
+ );
409
+ }
410
+ async waitForEmail(input) {
411
+ return this.handleAction(
412
+ {
413
+ data: input,
414
+ schema: webhook_connector.waitForEmailInputSchema
415
+ },
416
+ { successMessage: "Email check completed." },
417
+ async (params) => {
418
+ const { recipient, subject, timeout, pollInterval } = params;
419
+ if (!this.env.RECEIVED_EMAILS_KV) {
420
+ throw new Error("RECEIVED_EMAILS_KV binding is not configured");
421
+ }
422
+ const maxTimeout = Math.min(timeout || 5e3, 5e3);
423
+ const safeInterval = Math.max(pollInterval || 500, 100);
424
+ const startTime = Date.now();
425
+ const maxIterations = Math.ceil(maxTimeout / safeInterval);
426
+ let iterations = 0;
427
+ while (Date.now() - startTime < maxTimeout && iterations < maxIterations) {
428
+ const pattern = generateEmailKVPattern(recipient);
429
+ const list = await this.env.RECEIVED_EMAILS_KV.list({
430
+ prefix: pattern,
431
+ limit: 50
432
+ });
433
+ for (const key of list.keys) {
434
+ const emailData = await this.env.RECEIVED_EMAILS_KV.get(
435
+ key.name,
436
+ "json"
437
+ );
438
+ if (emailData) {
439
+ const email = emailData;
440
+ if (!subject || email.subject.includes(subject)) {
441
+ return {
442
+ email,
443
+ found: true
444
+ };
445
+ }
446
+ }
447
+ }
448
+ iterations++;
449
+ if (iterations < maxIterations && Date.now() - startTime < maxTimeout - safeInterval) {
450
+ await new Promise((resolve) => setTimeout(resolve, safeInterval));
451
+ }
452
+ }
453
+ return {
454
+ email: null,
455
+ found: false
456
+ };
457
+ }
458
+ );
459
+ }
460
+ async clearReceivedEmails(input) {
461
+ return this.handleAction(
462
+ {
463
+ data: input,
464
+ schema: webhook_connector.clearReceivedEmailsInputSchema
465
+ },
466
+ { successMessage: "Emails cleared." },
467
+ async (params) => {
468
+ const { recipient } = params;
469
+ if (!this.env.RECEIVED_EMAILS_KV) {
470
+ throw new Error("RECEIVED_EMAILS_KV binding is not configured");
471
+ }
472
+ const pattern = generateEmailKVPattern(recipient);
473
+ const list = await this.env.RECEIVED_EMAILS_KV.list({
474
+ prefix: pattern
475
+ });
476
+ let deleted = 0;
477
+ for (const key of list.keys) {
478
+ await this.env.RECEIVED_EMAILS_KV.delete(key.name);
479
+ deleted++;
480
+ }
481
+ return {
482
+ deleted
483
+ };
484
+ }
485
+ );
486
+ }
301
487
  };
302
488
  __decorateClass([
303
489
  backendSdk.cloudflareQueue({ baseDelay: 60 })
@@ -309,13 +495,13 @@ __decorateClass([
309
495
  backendSdk.action("private-send-sms")
310
496
  ], NotificationServiceBase.prototype, "_sendSms", 1);
311
497
  __decorateClass([
312
- backendSdk.action("public-send-email")
498
+ backendSdk.action("send-email")
313
499
  ], NotificationServiceBase.prototype, "sendEmail", 1);
314
500
  __decorateClass([
315
- backendSdk.action("public-send-email-sync")
501
+ backendSdk.action("send-email-sync")
316
502
  ], NotificationServiceBase.prototype, "sendEmailSync", 1);
317
503
  __decorateClass([
318
- backendSdk.action("public-send-sms")
504
+ backendSdk.action("send-sms")
319
505
  ], NotificationServiceBase.prototype, "sendSms", 1);
320
506
  __decorateClass([
321
507
  backendSdk.action("send-push-notification")
@@ -323,6 +509,21 @@ __decorateClass([
323
509
  __decorateClass([
324
510
  backendSdk.action("send-slack-notification")
325
511
  ], NotificationServiceBase.prototype, "sendSlackNotification", 1);
512
+ __decorateClass([
513
+ backendSdk.action("send-webhook")
514
+ ], NotificationServiceBase.prototype, "sendWebhook", 1);
515
+ __decorateClass([
516
+ backendSdk.action("private-send-webhook")
517
+ ], NotificationServiceBase.prototype, "_sendWebhook", 1);
518
+ __decorateClass([
519
+ backendSdk.action("get-received-emails")
520
+ ], NotificationServiceBase.prototype, "getReceivedEmails", 1);
521
+ __decorateClass([
522
+ backendSdk.action("wait-for-email")
523
+ ], NotificationServiceBase.prototype, "waitForEmail", 1);
524
+ __decorateClass([
525
+ backendSdk.action("clear-received-emails")
526
+ ], NotificationServiceBase.prototype, "clearReceivedEmails", 1);
326
527
  NotificationServiceBase = __decorateClass([
327
528
  backendSdk.service("notification")
328
529
  ], NotificationServiceBase);
@@ -1,16 +1,18 @@
1
1
  import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
2
2
  import { IRPCResponse } from '@develit-io/backend-sdk';
3
- import { S as SlackConnector, I as IEmailConnector, a as ISmsConnector, t as tables, N as NotificationQueueMessage, b as SendEmailInput, c as SendEmailOutput, d as SendSmsInput, e as SendSmsOutput, f as SendSlackInput, g as SendSlackOutput } from '../shared/notification.2rSOcFrr.cjs';
3
+ import { s as schema } from '../database/schema.cjs';
4
+ import { S as SlackConnector, W as WebhookConnector, I as IEmailConnector, a as ISmsConnector, N as NotificationQueueMessage, b as SendEmailInput, c as SendEmailOutput, d as SendSmsInput, e as SendSmsOutput, f as SendSlackInput, g as SendSlackOutput, h as SendWebhookInput, i as SendWebhookOutput, G as GetReceivedEmailsInput, j as GetReceivedEmailsOutput, k as WaitForEmailInput, l as WaitForEmailOutput, C as ClearReceivedEmailsInput, m as ClearReceivedEmailsOutput } from '../shared/notification.BiG4Q650.cjs';
4
5
  import { WorkerEntrypoint } from 'cloudflare:workers';
5
6
  import { DrizzleD1Database } from 'drizzle-orm/d1';
6
- import '../shared/notification.BWLPh6Gb.cjs';
7
- import 'drizzle-orm/sqlite-core';
8
7
  import 'zod';
9
8
  import 'zod/v4';
10
9
 
10
+ declare const tables: typeof schema;
11
+
11
12
  declare const NotificationServiceBase_base: (abstract new (ctx: ExecutionContext, env: NotificationEnv) => WorkerEntrypoint<NotificationEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
12
13
  declare class NotificationServiceBase extends NotificationServiceBase_base {
13
14
  readonly slackConnector: SlackConnector;
15
+ protected webhookConnector: WebhookConnector;
14
16
  protected emailConnector: IEmailConnector;
15
17
  protected smsConnector: ISmsConnector;
16
18
  readonly db: DrizzleD1Database<typeof tables>;
@@ -23,6 +25,23 @@ declare class NotificationServiceBase extends NotificationServiceBase_base {
23
25
  sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
24
26
  protected _sendPushNotification(): Promise<IRPCResponse<{}>>;
25
27
  sendSlackNotification(input: SendSlackInput): Promise<IRPCResponse<SendSlackOutput>>;
28
+ sendWebhook(input: SendWebhookInput): Promise<IRPCResponse<SendWebhookOutput>>;
29
+ protected _sendWebhook(input: SendWebhookInput): Promise<IRPCResponse<SendWebhookOutput>>;
30
+ /**
31
+ * Get received emails from KV storage
32
+ * Used primarily for E2E testing
33
+ */
34
+ getReceivedEmails(input: GetReceivedEmailsInput): Promise<IRPCResponse<GetReceivedEmailsOutput>>;
35
+ /**
36
+ * Wait for an email to arrive (polling helper for E2E tests)
37
+ * NOTE: Limited to 5 second timeout to prevent blocking
38
+ */
39
+ waitForEmail(input: WaitForEmailInput): Promise<IRPCResponse<WaitForEmailOutput>>;
40
+ /**
41
+ * Clear received emails for a recipient (cleanup helper)
42
+ * Used primarily for E2E testing
43
+ */
44
+ clearReceivedEmails(input: ClearReceivedEmailsInput): Promise<IRPCResponse<ClearReceivedEmailsOutput>>;
26
45
  }
27
46
  declare function defineNotificationService(): new (ctx: ExecutionContext, env: NotificationEnv) => NotificationServiceBase;
28
47
 
@@ -1,16 +1,18 @@
1
1
  import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
2
2
  import { IRPCResponse } from '@develit-io/backend-sdk';
3
- import { S as SlackConnector, I as IEmailConnector, a as ISmsConnector, t as tables, N as NotificationQueueMessage, b as SendEmailInput, c as SendEmailOutput, d as SendSmsInput, e as SendSmsOutput, f as SendSlackInput, g as SendSlackOutput } from '../shared/notification.C1quYqlT.mjs';
3
+ import { s as schema } from '../database/schema.mjs';
4
+ import { S as SlackConnector, W as WebhookConnector, I as IEmailConnector, a as ISmsConnector, N as NotificationQueueMessage, b as SendEmailInput, c as SendEmailOutput, d as SendSmsInput, e as SendSmsOutput, f as SendSlackInput, g as SendSlackOutput, h as SendWebhookInput, i as SendWebhookOutput, G as GetReceivedEmailsInput, j as GetReceivedEmailsOutput, k as WaitForEmailInput, l as WaitForEmailOutput, C as ClearReceivedEmailsInput, m as ClearReceivedEmailsOutput } from '../shared/notification.BiG4Q650.mjs';
4
5
  import { WorkerEntrypoint } from 'cloudflare:workers';
5
6
  import { DrizzleD1Database } from 'drizzle-orm/d1';
6
- import '../shared/notification.BWLPh6Gb.mjs';
7
- import 'drizzle-orm/sqlite-core';
8
7
  import 'zod';
9
8
  import 'zod/v4';
10
9
 
10
+ declare const tables: typeof schema;
11
+
11
12
  declare const NotificationServiceBase_base: (abstract new (ctx: ExecutionContext, env: NotificationEnv) => WorkerEntrypoint<NotificationEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
12
13
  declare class NotificationServiceBase extends NotificationServiceBase_base {
13
14
  readonly slackConnector: SlackConnector;
15
+ protected webhookConnector: WebhookConnector;
14
16
  protected emailConnector: IEmailConnector;
15
17
  protected smsConnector: ISmsConnector;
16
18
  readonly db: DrizzleD1Database<typeof tables>;
@@ -23,6 +25,23 @@ declare class NotificationServiceBase extends NotificationServiceBase_base {
23
25
  sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
24
26
  protected _sendPushNotification(): Promise<IRPCResponse<{}>>;
25
27
  sendSlackNotification(input: SendSlackInput): Promise<IRPCResponse<SendSlackOutput>>;
28
+ sendWebhook(input: SendWebhookInput): Promise<IRPCResponse<SendWebhookOutput>>;
29
+ protected _sendWebhook(input: SendWebhookInput): Promise<IRPCResponse<SendWebhookOutput>>;
30
+ /**
31
+ * Get received emails from KV storage
32
+ * Used primarily for E2E testing
33
+ */
34
+ getReceivedEmails(input: GetReceivedEmailsInput): Promise<IRPCResponse<GetReceivedEmailsOutput>>;
35
+ /**
36
+ * Wait for an email to arrive (polling helper for E2E tests)
37
+ * NOTE: Limited to 5 second timeout to prevent blocking
38
+ */
39
+ waitForEmail(input: WaitForEmailInput): Promise<IRPCResponse<WaitForEmailOutput>>;
40
+ /**
41
+ * Clear received emails for a recipient (cleanup helper)
42
+ * Used primarily for E2E testing
43
+ */
44
+ clearReceivedEmails(input: ClearReceivedEmailsInput): Promise<IRPCResponse<ClearReceivedEmailsOutput>>;
26
45
  }
27
46
  declare function defineNotificationService(): new (ctx: ExecutionContext, env: NotificationEnv) => NotificationServiceBase;
28
47
 
@@ -1,16 +1,18 @@
1
1
  import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
2
2
  import { IRPCResponse } from '@develit-io/backend-sdk';
3
- import { S as SlackConnector, I as IEmailConnector, a as ISmsConnector, t as tables, N as NotificationQueueMessage, b as SendEmailInput, c as SendEmailOutput, d as SendSmsInput, e as SendSmsOutput, f as SendSlackInput, g as SendSlackOutput } from '../shared/notification.oEdhCsu_.js';
3
+ import { s as schema } from '../database/schema.js';
4
+ import { S as SlackConnector, W as WebhookConnector, I as IEmailConnector, a as ISmsConnector, N as NotificationQueueMessage, b as SendEmailInput, c as SendEmailOutput, d as SendSmsInput, e as SendSmsOutput, f as SendSlackInput, g as SendSlackOutput, h as SendWebhookInput, i as SendWebhookOutput, G as GetReceivedEmailsInput, j as GetReceivedEmailsOutput, k as WaitForEmailInput, l as WaitForEmailOutput, C as ClearReceivedEmailsInput, m as ClearReceivedEmailsOutput } from '../shared/notification.BiG4Q650.js';
4
5
  import { WorkerEntrypoint } from 'cloudflare:workers';
5
6
  import { DrizzleD1Database } from 'drizzle-orm/d1';
6
- import '../shared/notification.BWLPh6Gb.js';
7
- import 'drizzle-orm/sqlite-core';
8
7
  import 'zod';
9
8
  import 'zod/v4';
10
9
 
10
+ declare const tables: typeof schema;
11
+
11
12
  declare const NotificationServiceBase_base: (abstract new (ctx: ExecutionContext, env: NotificationEnv) => WorkerEntrypoint<NotificationEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
12
13
  declare class NotificationServiceBase extends NotificationServiceBase_base {
13
14
  readonly slackConnector: SlackConnector;
15
+ protected webhookConnector: WebhookConnector;
14
16
  protected emailConnector: IEmailConnector;
15
17
  protected smsConnector: ISmsConnector;
16
18
  readonly db: DrizzleD1Database<typeof tables>;
@@ -23,6 +25,23 @@ declare class NotificationServiceBase extends NotificationServiceBase_base {
23
25
  sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
24
26
  protected _sendPushNotification(): Promise<IRPCResponse<{}>>;
25
27
  sendSlackNotification(input: SendSlackInput): Promise<IRPCResponse<SendSlackOutput>>;
28
+ sendWebhook(input: SendWebhookInput): Promise<IRPCResponse<SendWebhookOutput>>;
29
+ protected _sendWebhook(input: SendWebhookInput): Promise<IRPCResponse<SendWebhookOutput>>;
30
+ /**
31
+ * Get received emails from KV storage
32
+ * Used primarily for E2E testing
33
+ */
34
+ getReceivedEmails(input: GetReceivedEmailsInput): Promise<IRPCResponse<GetReceivedEmailsOutput>>;
35
+ /**
36
+ * Wait for an email to arrive (polling helper for E2E tests)
37
+ * NOTE: Limited to 5 second timeout to prevent blocking
38
+ */
39
+ waitForEmail(input: WaitForEmailInput): Promise<IRPCResponse<WaitForEmailOutput>>;
40
+ /**
41
+ * Clear received emails for a recipient (cleanup helper)
42
+ * Used primarily for E2E testing
43
+ */
44
+ clearReceivedEmails(input: ClearReceivedEmailsInput): Promise<IRPCResponse<ClearReceivedEmailsOutput>>;
26
45
  }
27
46
  declare function defineNotificationService(): new (ctx: ExecutionContext, env: NotificationEnv) => NotificationServiceBase;
28
47