@develit-services/notification 0.0.15 → 0.0.17
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.
- package/dist/export/worker.cjs +38 -24
- package/dist/export/worker.mjs +38 -24
- package/dist/export/wrangler.cjs +13 -0
- package/dist/export/wrangler.d.cts +24 -0
- package/dist/export/wrangler.d.mts +24 -0
- package/dist/export/wrangler.d.ts +24 -0
- package/dist/export/wrangler.mjs +13 -0
- package/package.json +1 -1
package/dist/export/worker.cjs
CHANGED
|
@@ -38,10 +38,6 @@ const iEmailSchema = z.z.object({
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
class IEmailConnector {
|
|
41
|
-
static providerName;
|
|
42
|
-
API_KEY;
|
|
43
|
-
SMTP_HOST;
|
|
44
|
-
SENDER;
|
|
45
41
|
constructor({
|
|
46
42
|
API_KEY,
|
|
47
43
|
SMTP_HOST,
|
|
@@ -54,7 +50,9 @@ class IEmailConnector {
|
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
class EcomailConnector extends IEmailConnector {
|
|
57
|
-
static
|
|
53
|
+
static {
|
|
54
|
+
this.providerName = "ecomail";
|
|
55
|
+
}
|
|
58
56
|
constructor({
|
|
59
57
|
API_KEY,
|
|
60
58
|
SMTP_HOST,
|
|
@@ -184,10 +182,6 @@ const sendSmsInputSchema = z.z.object({
|
|
|
184
182
|
});
|
|
185
183
|
|
|
186
184
|
class ISmsConnector {
|
|
187
|
-
static providerName;
|
|
188
|
-
ACCOUNT_ID;
|
|
189
|
-
AUTH_TOKEN;
|
|
190
|
-
SERVICE_ID;
|
|
191
185
|
constructor({
|
|
192
186
|
ACCOUNT_ID,
|
|
193
187
|
AUTH_TOKEN,
|
|
@@ -200,8 +194,9 @@ class ISmsConnector {
|
|
|
200
194
|
}
|
|
201
195
|
|
|
202
196
|
class TwilioConnector extends ISmsConnector {
|
|
203
|
-
static
|
|
204
|
-
|
|
197
|
+
static {
|
|
198
|
+
this.providerName = "twilio";
|
|
199
|
+
}
|
|
205
200
|
constructor({
|
|
206
201
|
ACCOUNT_ID,
|
|
207
202
|
AUTH_TOKEN,
|
|
@@ -281,7 +276,6 @@ const initiateSmsConnector = async (provider, accountId, authToken, serviceId) =
|
|
|
281
276
|
};
|
|
282
277
|
|
|
283
278
|
class SlackConnector {
|
|
284
|
-
webhooks;
|
|
285
279
|
constructor(webhooks) {
|
|
286
280
|
this.webhooks = webhooks;
|
|
287
281
|
}
|
|
@@ -303,20 +297,25 @@ class SlackConnector {
|
|
|
303
297
|
}
|
|
304
298
|
}
|
|
305
299
|
|
|
300
|
+
var __defProp = Object.defineProperty;
|
|
301
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
302
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
303
|
+
var result = __getOwnPropDesc(target, key) ;
|
|
304
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
305
|
+
if (decorator = decorators[i])
|
|
306
|
+
result = (decorator(target, key, result) ) || result;
|
|
307
|
+
if (result) __defProp(target, key, result);
|
|
308
|
+
return result;
|
|
309
|
+
};
|
|
306
310
|
class NotificationServiceBase extends backendSdk.develitWorker(
|
|
307
311
|
cloudflare_workers.WorkerEntrypoint
|
|
308
312
|
) {
|
|
309
|
-
name;
|
|
310
|
-
slackConnector = new SlackConnector(this.env.SLACK_WEBHOOKS);
|
|
311
|
-
emailConnector;
|
|
312
|
-
smsConnector;
|
|
313
|
-
db;
|
|
314
313
|
constructor(ctx, env) {
|
|
315
314
|
super(ctx, env);
|
|
315
|
+
this.slackConnector = new SlackConnector(this.env.SLACK_WEBHOOKS);
|
|
316
316
|
this.name = "notification-service";
|
|
317
317
|
this.db = d1.drizzle(this.env.NOTIFICATION_D1, { schema: tables });
|
|
318
318
|
}
|
|
319
|
-
@backendSdk.cloudflareQueue({ baseDelay: 60 })
|
|
320
319
|
async queue(batch) {
|
|
321
320
|
for (const message of batch.messages) {
|
|
322
321
|
this.logInput({ message });
|
|
@@ -390,7 +389,6 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
390
389
|
message.ack();
|
|
391
390
|
}
|
|
392
391
|
}
|
|
393
|
-
@backendSdk.action("private-send-email")
|
|
394
392
|
async _sendEmail(input) {
|
|
395
393
|
return this.handleAction(
|
|
396
394
|
{ data: input, schema: sendEmailInputSchema },
|
|
@@ -435,7 +433,6 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
435
433
|
}
|
|
436
434
|
);
|
|
437
435
|
}
|
|
438
|
-
@backendSdk.action("private-send-sms")
|
|
439
436
|
async _sendSms(input) {
|
|
440
437
|
return this.handleAction(
|
|
441
438
|
{ data: input, schema: sendSmsInputSchema },
|
|
@@ -467,7 +464,6 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
467
464
|
}
|
|
468
465
|
);
|
|
469
466
|
}
|
|
470
|
-
@backendSdk.action("public-send-email")
|
|
471
467
|
async sendEmail(input) {
|
|
472
468
|
return this.handleAction(
|
|
473
469
|
{ data: input, schema: sendEmailInputSchema },
|
|
@@ -488,7 +484,6 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
488
484
|
}
|
|
489
485
|
);
|
|
490
486
|
}
|
|
491
|
-
@backendSdk.action("public-send-sms")
|
|
492
487
|
async sendSms(input) {
|
|
493
488
|
return this.handleAction(
|
|
494
489
|
{ data: input, schema: sendSmsInputSchema },
|
|
@@ -515,13 +510,11 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
515
510
|
}
|
|
516
511
|
);
|
|
517
512
|
}
|
|
518
|
-
@backendSdk.action("send-push-notification")
|
|
519
513
|
async _sendPushNotification() {
|
|
520
514
|
this.logInput({});
|
|
521
515
|
this.logError({ error: "Method not implemented." });
|
|
522
516
|
throw new Error("Method not implemented.");
|
|
523
517
|
}
|
|
524
|
-
@backendSdk.action("send-slack-notification")
|
|
525
518
|
async sendSlackNotification(input) {
|
|
526
519
|
return this.handleAction(
|
|
527
520
|
{
|
|
@@ -537,6 +530,27 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
537
530
|
);
|
|
538
531
|
}
|
|
539
532
|
}
|
|
533
|
+
__decorateClass([
|
|
534
|
+
backendSdk.cloudflareQueue({ baseDelay: 60 })
|
|
535
|
+
], NotificationServiceBase.prototype, "queue");
|
|
536
|
+
__decorateClass([
|
|
537
|
+
backendSdk.action("private-send-email")
|
|
538
|
+
], NotificationServiceBase.prototype, "_sendEmail");
|
|
539
|
+
__decorateClass([
|
|
540
|
+
backendSdk.action("private-send-sms")
|
|
541
|
+
], NotificationServiceBase.prototype, "_sendSms");
|
|
542
|
+
__decorateClass([
|
|
543
|
+
backendSdk.action("public-send-email")
|
|
544
|
+
], NotificationServiceBase.prototype, "sendEmail");
|
|
545
|
+
__decorateClass([
|
|
546
|
+
backendSdk.action("public-send-sms")
|
|
547
|
+
], NotificationServiceBase.prototype, "sendSms");
|
|
548
|
+
__decorateClass([
|
|
549
|
+
backendSdk.action("send-push-notification")
|
|
550
|
+
], NotificationServiceBase.prototype, "_sendPushNotification");
|
|
551
|
+
__decorateClass([
|
|
552
|
+
backendSdk.action("send-slack-notification")
|
|
553
|
+
], NotificationServiceBase.prototype, "sendSlackNotification");
|
|
540
554
|
function defineNotificationService() {
|
|
541
555
|
return class NotificationService extends NotificationServiceBase {
|
|
542
556
|
constructor(ctx, env) {
|
package/dist/export/worker.mjs
CHANGED
|
@@ -29,10 +29,6 @@ const iEmailSchema = z.object({
|
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
class IEmailConnector {
|
|
32
|
-
static providerName;
|
|
33
|
-
API_KEY;
|
|
34
|
-
SMTP_HOST;
|
|
35
|
-
SENDER;
|
|
36
32
|
constructor({
|
|
37
33
|
API_KEY,
|
|
38
34
|
SMTP_HOST,
|
|
@@ -45,7 +41,9 @@ class IEmailConnector {
|
|
|
45
41
|
}
|
|
46
42
|
|
|
47
43
|
class EcomailConnector extends IEmailConnector {
|
|
48
|
-
static
|
|
44
|
+
static {
|
|
45
|
+
this.providerName = "ecomail";
|
|
46
|
+
}
|
|
49
47
|
constructor({
|
|
50
48
|
API_KEY,
|
|
51
49
|
SMTP_HOST,
|
|
@@ -175,10 +173,6 @@ const sendSmsInputSchema = z.object({
|
|
|
175
173
|
});
|
|
176
174
|
|
|
177
175
|
class ISmsConnector {
|
|
178
|
-
static providerName;
|
|
179
|
-
ACCOUNT_ID;
|
|
180
|
-
AUTH_TOKEN;
|
|
181
|
-
SERVICE_ID;
|
|
182
176
|
constructor({
|
|
183
177
|
ACCOUNT_ID,
|
|
184
178
|
AUTH_TOKEN,
|
|
@@ -191,8 +185,9 @@ class ISmsConnector {
|
|
|
191
185
|
}
|
|
192
186
|
|
|
193
187
|
class TwilioConnector extends ISmsConnector {
|
|
194
|
-
static
|
|
195
|
-
|
|
188
|
+
static {
|
|
189
|
+
this.providerName = "twilio";
|
|
190
|
+
}
|
|
196
191
|
constructor({
|
|
197
192
|
ACCOUNT_ID,
|
|
198
193
|
AUTH_TOKEN,
|
|
@@ -272,7 +267,6 @@ const initiateSmsConnector = async (provider, accountId, authToken, serviceId) =
|
|
|
272
267
|
};
|
|
273
268
|
|
|
274
269
|
class SlackConnector {
|
|
275
|
-
webhooks;
|
|
276
270
|
constructor(webhooks) {
|
|
277
271
|
this.webhooks = webhooks;
|
|
278
272
|
}
|
|
@@ -294,20 +288,25 @@ class SlackConnector {
|
|
|
294
288
|
}
|
|
295
289
|
}
|
|
296
290
|
|
|
291
|
+
var __defProp = Object.defineProperty;
|
|
292
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
293
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
294
|
+
var result = __getOwnPropDesc(target, key) ;
|
|
295
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
296
|
+
if (decorator = decorators[i])
|
|
297
|
+
result = (decorator(target, key, result) ) || result;
|
|
298
|
+
if (result) __defProp(target, key, result);
|
|
299
|
+
return result;
|
|
300
|
+
};
|
|
297
301
|
class NotificationServiceBase extends develitWorker(
|
|
298
302
|
WorkerEntrypoint
|
|
299
303
|
) {
|
|
300
|
-
name;
|
|
301
|
-
slackConnector = new SlackConnector(this.env.SLACK_WEBHOOKS);
|
|
302
|
-
emailConnector;
|
|
303
|
-
smsConnector;
|
|
304
|
-
db;
|
|
305
304
|
constructor(ctx, env) {
|
|
306
305
|
super(ctx, env);
|
|
306
|
+
this.slackConnector = new SlackConnector(this.env.SLACK_WEBHOOKS);
|
|
307
307
|
this.name = "notification-service";
|
|
308
308
|
this.db = drizzle(this.env.NOTIFICATION_D1, { schema: tables });
|
|
309
309
|
}
|
|
310
|
-
@cloudflareQueue({ baseDelay: 60 })
|
|
311
310
|
async queue(batch) {
|
|
312
311
|
for (const message of batch.messages) {
|
|
313
312
|
this.logInput({ message });
|
|
@@ -381,7 +380,6 @@ class NotificationServiceBase extends develitWorker(
|
|
|
381
380
|
message.ack();
|
|
382
381
|
}
|
|
383
382
|
}
|
|
384
|
-
@action("private-send-email")
|
|
385
383
|
async _sendEmail(input) {
|
|
386
384
|
return this.handleAction(
|
|
387
385
|
{ data: input, schema: sendEmailInputSchema },
|
|
@@ -426,7 +424,6 @@ class NotificationServiceBase extends develitWorker(
|
|
|
426
424
|
}
|
|
427
425
|
);
|
|
428
426
|
}
|
|
429
|
-
@action("private-send-sms")
|
|
430
427
|
async _sendSms(input) {
|
|
431
428
|
return this.handleAction(
|
|
432
429
|
{ data: input, schema: sendSmsInputSchema },
|
|
@@ -458,7 +455,6 @@ class NotificationServiceBase extends develitWorker(
|
|
|
458
455
|
}
|
|
459
456
|
);
|
|
460
457
|
}
|
|
461
|
-
@action("public-send-email")
|
|
462
458
|
async sendEmail(input) {
|
|
463
459
|
return this.handleAction(
|
|
464
460
|
{ data: input, schema: sendEmailInputSchema },
|
|
@@ -479,7 +475,6 @@ class NotificationServiceBase extends develitWorker(
|
|
|
479
475
|
}
|
|
480
476
|
);
|
|
481
477
|
}
|
|
482
|
-
@action("public-send-sms")
|
|
483
478
|
async sendSms(input) {
|
|
484
479
|
return this.handleAction(
|
|
485
480
|
{ data: input, schema: sendSmsInputSchema },
|
|
@@ -506,13 +501,11 @@ class NotificationServiceBase extends develitWorker(
|
|
|
506
501
|
}
|
|
507
502
|
);
|
|
508
503
|
}
|
|
509
|
-
@action("send-push-notification")
|
|
510
504
|
async _sendPushNotification() {
|
|
511
505
|
this.logInput({});
|
|
512
506
|
this.logError({ error: "Method not implemented." });
|
|
513
507
|
throw new Error("Method not implemented.");
|
|
514
508
|
}
|
|
515
|
-
@action("send-slack-notification")
|
|
516
509
|
async sendSlackNotification(input) {
|
|
517
510
|
return this.handleAction(
|
|
518
511
|
{
|
|
@@ -528,6 +521,27 @@ class NotificationServiceBase extends develitWorker(
|
|
|
528
521
|
);
|
|
529
522
|
}
|
|
530
523
|
}
|
|
524
|
+
__decorateClass([
|
|
525
|
+
cloudflareQueue({ baseDelay: 60 })
|
|
526
|
+
], NotificationServiceBase.prototype, "queue");
|
|
527
|
+
__decorateClass([
|
|
528
|
+
action("private-send-email")
|
|
529
|
+
], NotificationServiceBase.prototype, "_sendEmail");
|
|
530
|
+
__decorateClass([
|
|
531
|
+
action("private-send-sms")
|
|
532
|
+
], NotificationServiceBase.prototype, "_sendSms");
|
|
533
|
+
__decorateClass([
|
|
534
|
+
action("public-send-email")
|
|
535
|
+
], NotificationServiceBase.prototype, "sendEmail");
|
|
536
|
+
__decorateClass([
|
|
537
|
+
action("public-send-sms")
|
|
538
|
+
], NotificationServiceBase.prototype, "sendSms");
|
|
539
|
+
__decorateClass([
|
|
540
|
+
action("send-push-notification")
|
|
541
|
+
], NotificationServiceBase.prototype, "_sendPushNotification");
|
|
542
|
+
__decorateClass([
|
|
543
|
+
action("send-slack-notification")
|
|
544
|
+
], NotificationServiceBase.prototype, "sendSlackNotification");
|
|
531
545
|
function defineNotificationService() {
|
|
532
546
|
return class NotificationService extends NotificationServiceBase {
|
|
533
547
|
constructor(ctx, env) {
|
package/dist/export/wrangler.cjs
CHANGED
|
@@ -7,6 +7,19 @@ function defineNotificationServiceWrangler(config) {
|
|
|
7
7
|
main: "./src/index.ts",
|
|
8
8
|
compatibility_date: "2025-06-04",
|
|
9
9
|
compatibility_flags: ["nodejs_compat"],
|
|
10
|
+
observability: {
|
|
11
|
+
enabled: true,
|
|
12
|
+
head_sampling_rate: 1,
|
|
13
|
+
logs: {
|
|
14
|
+
invocation_logs: false
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
preview_urls: false,
|
|
18
|
+
workers_dev: false,
|
|
19
|
+
vars: {
|
|
20
|
+
...envs.local.vars,
|
|
21
|
+
ENVIRONMENT: "local"
|
|
22
|
+
},
|
|
10
23
|
d1_databases: [
|
|
11
24
|
{
|
|
12
25
|
binding: "NOTIFICATION_D1",
|
|
@@ -36,6 +36,30 @@ declare function defineNotificationServiceWrangler(config: NotificationServiceWr
|
|
|
36
36
|
main: string;
|
|
37
37
|
compatibility_date: string;
|
|
38
38
|
compatibility_flags: string[];
|
|
39
|
+
observability: {
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
head_sampling_rate: number;
|
|
42
|
+
logs: {
|
|
43
|
+
invocation_logs: boolean;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
preview_urls: boolean;
|
|
47
|
+
workers_dev: boolean;
|
|
48
|
+
vars: {
|
|
49
|
+
ENVIRONMENT: string;
|
|
50
|
+
EMAIL_PROVIDER: "ecomail";
|
|
51
|
+
EMAIL_SENDER: {
|
|
52
|
+
name: string;
|
|
53
|
+
email: string;
|
|
54
|
+
};
|
|
55
|
+
EMAIL_SMTP_HOST: string;
|
|
56
|
+
EMAIL_API_KEY: string;
|
|
57
|
+
SMS_PROVIDER: "twilio";
|
|
58
|
+
SMS_ACCOUNT_ID: string;
|
|
59
|
+
SMS_AUTH_TOKEN: string;
|
|
60
|
+
SMS_SERVICE_ID: string | number;
|
|
61
|
+
SLACK_WEBHOOKS: [string];
|
|
62
|
+
};
|
|
39
63
|
d1_databases: {
|
|
40
64
|
binding: string;
|
|
41
65
|
database_name: string;
|
|
@@ -36,6 +36,30 @@ declare function defineNotificationServiceWrangler(config: NotificationServiceWr
|
|
|
36
36
|
main: string;
|
|
37
37
|
compatibility_date: string;
|
|
38
38
|
compatibility_flags: string[];
|
|
39
|
+
observability: {
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
head_sampling_rate: number;
|
|
42
|
+
logs: {
|
|
43
|
+
invocation_logs: boolean;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
preview_urls: boolean;
|
|
47
|
+
workers_dev: boolean;
|
|
48
|
+
vars: {
|
|
49
|
+
ENVIRONMENT: string;
|
|
50
|
+
EMAIL_PROVIDER: "ecomail";
|
|
51
|
+
EMAIL_SENDER: {
|
|
52
|
+
name: string;
|
|
53
|
+
email: string;
|
|
54
|
+
};
|
|
55
|
+
EMAIL_SMTP_HOST: string;
|
|
56
|
+
EMAIL_API_KEY: string;
|
|
57
|
+
SMS_PROVIDER: "twilio";
|
|
58
|
+
SMS_ACCOUNT_ID: string;
|
|
59
|
+
SMS_AUTH_TOKEN: string;
|
|
60
|
+
SMS_SERVICE_ID: string | number;
|
|
61
|
+
SLACK_WEBHOOKS: [string];
|
|
62
|
+
};
|
|
39
63
|
d1_databases: {
|
|
40
64
|
binding: string;
|
|
41
65
|
database_name: string;
|
|
@@ -36,6 +36,30 @@ declare function defineNotificationServiceWrangler(config: NotificationServiceWr
|
|
|
36
36
|
main: string;
|
|
37
37
|
compatibility_date: string;
|
|
38
38
|
compatibility_flags: string[];
|
|
39
|
+
observability: {
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
head_sampling_rate: number;
|
|
42
|
+
logs: {
|
|
43
|
+
invocation_logs: boolean;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
preview_urls: boolean;
|
|
47
|
+
workers_dev: boolean;
|
|
48
|
+
vars: {
|
|
49
|
+
ENVIRONMENT: string;
|
|
50
|
+
EMAIL_PROVIDER: "ecomail";
|
|
51
|
+
EMAIL_SENDER: {
|
|
52
|
+
name: string;
|
|
53
|
+
email: string;
|
|
54
|
+
};
|
|
55
|
+
EMAIL_SMTP_HOST: string;
|
|
56
|
+
EMAIL_API_KEY: string;
|
|
57
|
+
SMS_PROVIDER: "twilio";
|
|
58
|
+
SMS_ACCOUNT_ID: string;
|
|
59
|
+
SMS_AUTH_TOKEN: string;
|
|
60
|
+
SMS_SERVICE_ID: string | number;
|
|
61
|
+
SLACK_WEBHOOKS: [string];
|
|
62
|
+
};
|
|
39
63
|
d1_databases: {
|
|
40
64
|
binding: string;
|
|
41
65
|
database_name: string;
|
package/dist/export/wrangler.mjs
CHANGED
|
@@ -5,6 +5,19 @@ function defineNotificationServiceWrangler(config) {
|
|
|
5
5
|
main: "./src/index.ts",
|
|
6
6
|
compatibility_date: "2025-06-04",
|
|
7
7
|
compatibility_flags: ["nodejs_compat"],
|
|
8
|
+
observability: {
|
|
9
|
+
enabled: true,
|
|
10
|
+
head_sampling_rate: 1,
|
|
11
|
+
logs: {
|
|
12
|
+
invocation_logs: false
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
preview_urls: false,
|
|
16
|
+
workers_dev: false,
|
|
17
|
+
vars: {
|
|
18
|
+
...envs.local.vars,
|
|
19
|
+
ENVIRONMENT: "local"
|
|
20
|
+
},
|
|
8
21
|
d1_databases: [
|
|
9
22
|
{
|
|
10
23
|
binding: "NOTIFICATION_D1",
|