@develit-services/notification 0.0.34 → 0.1.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.
- package/dist/export/worker.cjs +30 -39
- package/dist/export/worker.d.cts +2 -1
- package/dist/export/worker.d.mts +2 -1
- package/dist/export/worker.d.ts +2 -1
- package/dist/export/worker.mjs +31 -40
- package/dist/export/wrangler.d.cts +2 -2
- package/dist/export/wrangler.d.mts +2 -2
- package/dist/export/wrangler.d.ts +2 -2
- package/dist/shared/{notification.BfmtOZWZ.d.cts → notification.7yl25yVk.d.cts} +2 -2
- package/dist/shared/{notification.CBHpc8d5.d.mts → notification.BiN8R884.d.mts} +2 -2
- package/dist/shared/{notification.jEQePmaL.d.cts → notification.CBrLTgQh.d.cts} +1 -1
- package/dist/shared/{notification.jEQePmaL.d.mts → notification.CBrLTgQh.d.mts} +1 -1
- package/dist/shared/{notification.jEQePmaL.d.ts → notification.CBrLTgQh.d.ts} +1 -1
- package/dist/shared/{notification.CTS2eEHl.d.ts → notification.Cwt3LtuI.d.ts} +2 -2
- package/dist/shared/{notification.BGfR3X_e.cjs → notification.Dk_5TX9v.cjs} +11 -13
- package/dist/shared/{notification.Di9LpjrD.mjs → notification.DkjmuyrV.mjs} +11 -13
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +3 -3
- package/dist/types.d.mts +3 -3
- package/dist/types.d.ts +3 -3
- package/dist/types.mjs +1 -1
- package/package.json +3 -3
package/dist/export/worker.cjs
CHANGED
|
@@ -3,18 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
6
|
-
const
|
|
6
|
+
const cloudflare_workers = require('cloudflare:workers');
|
|
7
|
+
const d1 = require('drizzle-orm/d1');
|
|
8
|
+
const slack_connector = require('../shared/notification.Dk_5TX9v.cjs');
|
|
7
9
|
const database_schema = require('../shared/notification.4b3eUEIG.cjs');
|
|
8
10
|
require('drizzle-orm');
|
|
9
11
|
require('drizzle-orm/sqlite-core');
|
|
10
|
-
const cloudflare_workers = require('cloudflare:workers');
|
|
11
|
-
const d1 = require('drizzle-orm/d1');
|
|
12
12
|
require('zod');
|
|
13
13
|
require('zod/v4');
|
|
14
14
|
require('twilio');
|
|
15
15
|
|
|
16
|
-
const tables = database_schema.schema;
|
|
17
|
-
|
|
18
16
|
const initiateEmailConnector = async (provider, apiKey, smtpHost, senderEmail, senderName) => {
|
|
19
17
|
const connector = [slack_connector.EcomailConnector].find(
|
|
20
18
|
(conn) => conn.providerName === provider
|
|
@@ -32,6 +30,8 @@ const initiateEmailConnector = async (provider, apiKey, smtpHost, senderEmail, s
|
|
|
32
30
|
});
|
|
33
31
|
};
|
|
34
32
|
|
|
33
|
+
const tables = database_schema.schema;
|
|
34
|
+
|
|
35
35
|
const createAuditLogCommand = async ({
|
|
36
36
|
db,
|
|
37
37
|
auditLog: {
|
|
@@ -89,7 +89,7 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
89
89
|
) {
|
|
90
90
|
constructor(ctx, env) {
|
|
91
91
|
super(ctx, env);
|
|
92
|
-
this.slackConnector = new slack_connector.SlackConnector(this.env.
|
|
92
|
+
this.slackConnector = new slack_connector.SlackConnector(this.env.SLACK_WEBHOOK);
|
|
93
93
|
this.name = "notification-service";
|
|
94
94
|
this.db = d1.drizzle(this.env.NOTIFICATION_D1, { schema: tables });
|
|
95
95
|
}
|
|
@@ -98,39 +98,6 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
98
98
|
this.logInput({ message });
|
|
99
99
|
let notificationAction;
|
|
100
100
|
const { type, metadata, payload } = message.body;
|
|
101
|
-
if (type === "email") {
|
|
102
|
-
const [emailConnector, error2] = await backendSdk.useResult(
|
|
103
|
-
initiateEmailConnector(
|
|
104
|
-
this.env.EMAIL_PROVIDER,
|
|
105
|
-
this.env.EMAIL_API_KEY,
|
|
106
|
-
this.env.EMAIL_SMTP_HOST,
|
|
107
|
-
this.env.EMAIL_SENDER_EMAIL,
|
|
108
|
-
this.env.EMAIL_SENDER_NAME
|
|
109
|
-
)
|
|
110
|
-
);
|
|
111
|
-
if (error2) {
|
|
112
|
-
this.logError({ error: error2 });
|
|
113
|
-
message.retry();
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
this.emailConnector = emailConnector;
|
|
117
|
-
}
|
|
118
|
-
if (type === "sms") {
|
|
119
|
-
const [smsConnector, error2] = await backendSdk.useResult(
|
|
120
|
-
initiateSmsConnector(
|
|
121
|
-
this.env.SMS_PROVIDER,
|
|
122
|
-
this.env.SMS_ACCOUNT_ID,
|
|
123
|
-
this.env.SMS_AUTH_TOKEN,
|
|
124
|
-
this.env.SMS_SERVICE_ID
|
|
125
|
-
)
|
|
126
|
-
);
|
|
127
|
-
if (error2) {
|
|
128
|
-
this.logError({ error: error2 });
|
|
129
|
-
message.retry();
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
this.smsConnector = smsConnector;
|
|
133
|
-
}
|
|
134
101
|
switch (type) {
|
|
135
102
|
case "email":
|
|
136
103
|
notificationAction = async () => this._sendEmail({
|
|
@@ -220,6 +187,14 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
220
187
|
initiator: { service, userId }
|
|
221
188
|
}
|
|
222
189
|
} = params;
|
|
190
|
+
if (!this.smsConnector) {
|
|
191
|
+
this.smsConnector = await initiateSmsConnector(
|
|
192
|
+
this.env.SMS_PROVIDER,
|
|
193
|
+
this.env.SMS_ACCOUNT_ID,
|
|
194
|
+
this.env.SMS_AUTH_TOKEN,
|
|
195
|
+
this.env.SMS_SERVICE_ID
|
|
196
|
+
);
|
|
197
|
+
}
|
|
223
198
|
await this.smsConnector.sendSms({ message, to });
|
|
224
199
|
const { command } = await createAuditLogCommand({
|
|
225
200
|
db: this.db,
|
|
@@ -258,6 +233,19 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
258
233
|
}
|
|
259
234
|
);
|
|
260
235
|
}
|
|
236
|
+
async sendEmailSync(input) {
|
|
237
|
+
return this.handleAction(
|
|
238
|
+
{ data: input, schema: slack_connector.sendEmailInputSchema },
|
|
239
|
+
{ successMessage: "Email sent." },
|
|
240
|
+
async (params) => {
|
|
241
|
+
const { email, metadata } = params;
|
|
242
|
+
return this._sendEmail({
|
|
243
|
+
email,
|
|
244
|
+
metadata
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
}
|
|
261
249
|
async sendSms(input) {
|
|
262
250
|
return this.handleAction(
|
|
263
251
|
{ data: input, schema: slack_connector.sendSmsInputSchema },
|
|
@@ -316,6 +304,9 @@ __decorateClass([
|
|
|
316
304
|
__decorateClass([
|
|
317
305
|
backendSdk.action("public-send-email")
|
|
318
306
|
], NotificationServiceBase.prototype, "sendEmail");
|
|
307
|
+
__decorateClass([
|
|
308
|
+
backendSdk.action("public-send-email-sync")
|
|
309
|
+
], NotificationServiceBase.prototype, "sendEmailSync");
|
|
319
310
|
__decorateClass([
|
|
320
311
|
backendSdk.action("public-send-sms")
|
|
321
312
|
], NotificationServiceBase.prototype, "sendSms");
|
package/dist/export/worker.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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.BfmtOZWZ.cjs';
|
|
4
3
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
4
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
5
|
+
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.7yl25yVk.cjs';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'zod/v4';
|
|
8
8
|
import '../shared/notification.BJyMXKGH.cjs';
|
|
@@ -20,6 +20,7 @@ declare class NotificationServiceBase extends NotificationServiceBase_base {
|
|
|
20
20
|
protected _sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
|
|
21
21
|
protected _sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
|
|
22
22
|
sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
|
|
23
|
+
sendEmailSync(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
|
|
23
24
|
sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
|
|
24
25
|
protected _sendPushNotification(): Promise<IRPCResponse<{}>>;
|
|
25
26
|
sendSlackNotification(input: SendSlackInput): Promise<IRPCResponse<SendSlackOutput>>;
|
package/dist/export/worker.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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.CBHpc8d5.mjs';
|
|
4
3
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
4
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
5
|
+
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.BiN8R884.mjs';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'zod/v4';
|
|
8
8
|
import '../shared/notification.BJyMXKGH.mjs';
|
|
@@ -20,6 +20,7 @@ declare class NotificationServiceBase extends NotificationServiceBase_base {
|
|
|
20
20
|
protected _sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
|
|
21
21
|
protected _sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
|
|
22
22
|
sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
|
|
23
|
+
sendEmailSync(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
|
|
23
24
|
sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
|
|
24
25
|
protected _sendPushNotification(): Promise<IRPCResponse<{}>>;
|
|
25
26
|
sendSlackNotification(input: SendSlackInput): Promise<IRPCResponse<SendSlackOutput>>;
|
package/dist/export/worker.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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.CTS2eEHl.js';
|
|
4
3
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
4
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
5
|
+
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.Cwt3LtuI.js';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'zod/v4';
|
|
8
8
|
import '../shared/notification.BJyMXKGH.js';
|
|
@@ -20,6 +20,7 @@ declare class NotificationServiceBase extends NotificationServiceBase_base {
|
|
|
20
20
|
protected _sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
|
|
21
21
|
protected _sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
|
|
22
22
|
sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
|
|
23
|
+
sendEmailSync(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
|
|
23
24
|
sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
|
|
24
25
|
protected _sendPushNotification(): Promise<IRPCResponse<{}>>;
|
|
25
26
|
sendSlackNotification(input: SendSlackInput): Promise<IRPCResponse<SendSlackOutput>>;
|
package/dist/export/worker.mjs
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { createInternalError, uuidv4, develitWorker,
|
|
2
|
-
import {
|
|
1
|
+
import { createInternalError, uuidv4, develitWorker, cloudflareQueue, action } from '@develit-io/backend-sdk';
|
|
2
|
+
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
3
|
+
import { drizzle } from 'drizzle-orm/d1';
|
|
4
|
+
import { E as EcomailConnector, T as TwilioConnector, S as SlackConnector, s as sendEmailInputSchema, a as sendSmsInputSchema, b as sendSlackInputSchema } from '../shared/notification.DkjmuyrV.mjs';
|
|
3
5
|
import { s as schema } from '../shared/notification.C0X8Orrh.mjs';
|
|
4
6
|
import 'drizzle-orm';
|
|
5
7
|
import 'drizzle-orm/sqlite-core';
|
|
6
|
-
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
7
|
-
import { drizzle } from 'drizzle-orm/d1';
|
|
8
8
|
import 'zod';
|
|
9
9
|
import 'zod/v4';
|
|
10
10
|
import 'twilio';
|
|
11
11
|
|
|
12
|
-
const tables = schema;
|
|
13
|
-
|
|
14
12
|
const initiateEmailConnector = async (provider, apiKey, smtpHost, senderEmail, senderName) => {
|
|
15
13
|
const connector = [EcomailConnector].find(
|
|
16
14
|
(conn) => conn.providerName === provider
|
|
@@ -28,6 +26,8 @@ const initiateEmailConnector = async (provider, apiKey, smtpHost, senderEmail, s
|
|
|
28
26
|
});
|
|
29
27
|
};
|
|
30
28
|
|
|
29
|
+
const tables = schema;
|
|
30
|
+
|
|
31
31
|
const createAuditLogCommand = async ({
|
|
32
32
|
db,
|
|
33
33
|
auditLog: {
|
|
@@ -85,7 +85,7 @@ class NotificationServiceBase extends develitWorker(
|
|
|
85
85
|
) {
|
|
86
86
|
constructor(ctx, env) {
|
|
87
87
|
super(ctx, env);
|
|
88
|
-
this.slackConnector = new SlackConnector(this.env.
|
|
88
|
+
this.slackConnector = new SlackConnector(this.env.SLACK_WEBHOOK);
|
|
89
89
|
this.name = "notification-service";
|
|
90
90
|
this.db = drizzle(this.env.NOTIFICATION_D1, { schema: tables });
|
|
91
91
|
}
|
|
@@ -94,39 +94,6 @@ class NotificationServiceBase extends develitWorker(
|
|
|
94
94
|
this.logInput({ message });
|
|
95
95
|
let notificationAction;
|
|
96
96
|
const { type, metadata, payload } = message.body;
|
|
97
|
-
if (type === "email") {
|
|
98
|
-
const [emailConnector, error2] = await useResult(
|
|
99
|
-
initiateEmailConnector(
|
|
100
|
-
this.env.EMAIL_PROVIDER,
|
|
101
|
-
this.env.EMAIL_API_KEY,
|
|
102
|
-
this.env.EMAIL_SMTP_HOST,
|
|
103
|
-
this.env.EMAIL_SENDER_EMAIL,
|
|
104
|
-
this.env.EMAIL_SENDER_NAME
|
|
105
|
-
)
|
|
106
|
-
);
|
|
107
|
-
if (error2) {
|
|
108
|
-
this.logError({ error: error2 });
|
|
109
|
-
message.retry();
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
this.emailConnector = emailConnector;
|
|
113
|
-
}
|
|
114
|
-
if (type === "sms") {
|
|
115
|
-
const [smsConnector, error2] = await useResult(
|
|
116
|
-
initiateSmsConnector(
|
|
117
|
-
this.env.SMS_PROVIDER,
|
|
118
|
-
this.env.SMS_ACCOUNT_ID,
|
|
119
|
-
this.env.SMS_AUTH_TOKEN,
|
|
120
|
-
this.env.SMS_SERVICE_ID
|
|
121
|
-
)
|
|
122
|
-
);
|
|
123
|
-
if (error2) {
|
|
124
|
-
this.logError({ error: error2 });
|
|
125
|
-
message.retry();
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
this.smsConnector = smsConnector;
|
|
129
|
-
}
|
|
130
97
|
switch (type) {
|
|
131
98
|
case "email":
|
|
132
99
|
notificationAction = async () => this._sendEmail({
|
|
@@ -216,6 +183,14 @@ class NotificationServiceBase extends develitWorker(
|
|
|
216
183
|
initiator: { service, userId }
|
|
217
184
|
}
|
|
218
185
|
} = params;
|
|
186
|
+
if (!this.smsConnector) {
|
|
187
|
+
this.smsConnector = await initiateSmsConnector(
|
|
188
|
+
this.env.SMS_PROVIDER,
|
|
189
|
+
this.env.SMS_ACCOUNT_ID,
|
|
190
|
+
this.env.SMS_AUTH_TOKEN,
|
|
191
|
+
this.env.SMS_SERVICE_ID
|
|
192
|
+
);
|
|
193
|
+
}
|
|
219
194
|
await this.smsConnector.sendSms({ message, to });
|
|
220
195
|
const { command } = await createAuditLogCommand({
|
|
221
196
|
db: this.db,
|
|
@@ -254,6 +229,19 @@ class NotificationServiceBase extends develitWorker(
|
|
|
254
229
|
}
|
|
255
230
|
);
|
|
256
231
|
}
|
|
232
|
+
async sendEmailSync(input) {
|
|
233
|
+
return this.handleAction(
|
|
234
|
+
{ data: input, schema: sendEmailInputSchema },
|
|
235
|
+
{ successMessage: "Email sent." },
|
|
236
|
+
async (params) => {
|
|
237
|
+
const { email, metadata } = params;
|
|
238
|
+
return this._sendEmail({
|
|
239
|
+
email,
|
|
240
|
+
metadata
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
}
|
|
257
245
|
async sendSms(input) {
|
|
258
246
|
return this.handleAction(
|
|
259
247
|
{ data: input, schema: sendSmsInputSchema },
|
|
@@ -312,6 +300,9 @@ __decorateClass([
|
|
|
312
300
|
__decorateClass([
|
|
313
301
|
action("public-send-email")
|
|
314
302
|
], NotificationServiceBase.prototype, "sendEmail");
|
|
303
|
+
__decorateClass([
|
|
304
|
+
action("public-send-email-sync")
|
|
305
|
+
], NotificationServiceBase.prototype, "sendEmailSync");
|
|
315
306
|
__decorateClass([
|
|
316
307
|
action("public-send-sms")
|
|
317
308
|
], NotificationServiceBase.prototype, "sendSms");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as NotificationServiceWranglerConfig } from '../shared/notification.
|
|
1
|
+
import { N as NotificationServiceWranglerConfig } from '../shared/notification.CBrLTgQh.cjs';
|
|
2
2
|
|
|
3
3
|
declare function defineNotificationServiceWrangler(config: NotificationServiceWranglerConfig): {
|
|
4
4
|
vars: {
|
|
@@ -10,7 +10,7 @@ declare function defineNotificationServiceWrangler(config: NotificationServiceWr
|
|
|
10
10
|
SMS_PROVIDER: "twilio";
|
|
11
11
|
SMS_ACCOUNT_ID: string;
|
|
12
12
|
SMS_SERVICE_ID: string | number;
|
|
13
|
-
|
|
13
|
+
SLACK_WEBHOOK: string;
|
|
14
14
|
EMAIL_API_KEY: string;
|
|
15
15
|
SMS_AUTH_TOKEN: string;
|
|
16
16
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as NotificationServiceWranglerConfig } from '../shared/notification.
|
|
1
|
+
import { N as NotificationServiceWranglerConfig } from '../shared/notification.CBrLTgQh.mjs';
|
|
2
2
|
|
|
3
3
|
declare function defineNotificationServiceWrangler(config: NotificationServiceWranglerConfig): {
|
|
4
4
|
vars: {
|
|
@@ -10,7 +10,7 @@ declare function defineNotificationServiceWrangler(config: NotificationServiceWr
|
|
|
10
10
|
SMS_PROVIDER: "twilio";
|
|
11
11
|
SMS_ACCOUNT_ID: string;
|
|
12
12
|
SMS_SERVICE_ID: string | number;
|
|
13
|
-
|
|
13
|
+
SLACK_WEBHOOK: string;
|
|
14
14
|
EMAIL_API_KEY: string;
|
|
15
15
|
SMS_AUTH_TOKEN: string;
|
|
16
16
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as NotificationServiceWranglerConfig } from '../shared/notification.
|
|
1
|
+
import { N as NotificationServiceWranglerConfig } from '../shared/notification.CBrLTgQh.js';
|
|
2
2
|
|
|
3
3
|
declare function defineNotificationServiceWrangler(config: NotificationServiceWranglerConfig): {
|
|
4
4
|
vars: {
|
|
@@ -10,7 +10,7 @@ declare function defineNotificationServiceWrangler(config: NotificationServiceWr
|
|
|
10
10
|
SMS_PROVIDER: "twilio";
|
|
11
11
|
SMS_ACCOUNT_ID: string;
|
|
12
12
|
SMS_SERVICE_ID: string | number;
|
|
13
|
-
|
|
13
|
+
SLACK_WEBHOOK: string;
|
|
14
14
|
EMAIL_API_KEY: string;
|
|
15
15
|
SMS_AUTH_TOKEN: string;
|
|
16
16
|
};
|
|
@@ -218,8 +218,8 @@ interface ISlack {
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
declare class SlackConnector {
|
|
221
|
-
private
|
|
222
|
-
constructor(
|
|
221
|
+
private webhook;
|
|
222
|
+
constructor(webhook: string);
|
|
223
223
|
sendNotificationToAllSlack(message: string): Promise<void>;
|
|
224
224
|
}
|
|
225
225
|
|
|
@@ -218,8 +218,8 @@ interface ISlack {
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
declare class SlackConnector {
|
|
221
|
-
private
|
|
222
|
-
constructor(
|
|
221
|
+
private webhook;
|
|
222
|
+
constructor(webhook: string);
|
|
223
223
|
sendNotificationToAllSlack(message: string): Promise<void>;
|
|
224
224
|
}
|
|
225
225
|
|
|
@@ -218,8 +218,8 @@ interface ISlack {
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
declare class SlackConnector {
|
|
221
|
-
private
|
|
222
|
-
constructor(
|
|
221
|
+
private webhook;
|
|
222
|
+
constructor(webhook: string);
|
|
223
223
|
sendNotificationToAllSlack(message: string): Promise<void>;
|
|
224
224
|
}
|
|
225
225
|
|
|
@@ -254,23 +254,21 @@ class TwilioConnector extends ISmsConnector {
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
class SlackConnector {
|
|
257
|
-
constructor(
|
|
258
|
-
this.
|
|
257
|
+
constructor(webhook) {
|
|
258
|
+
this.webhook = webhook;
|
|
259
259
|
}
|
|
260
260
|
async sendNotificationToAllSlack(message) {
|
|
261
261
|
const controller = new AbortController();
|
|
262
262
|
const timeoutId = setTimeout(() => controller.abort(), 3e3);
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
throw new Error("Failed sending Slack notification to " + message);
|
|
273
|
-
}
|
|
263
|
+
const response = await fetch(this.webhook, {
|
|
264
|
+
method: "POST",
|
|
265
|
+
body: JSON.stringify({ text: message }),
|
|
266
|
+
headers: { "Content-Type": "application/json" },
|
|
267
|
+
signal: controller.signal
|
|
268
|
+
});
|
|
269
|
+
clearTimeout(timeoutId);
|
|
270
|
+
if (!response.ok) {
|
|
271
|
+
throw new Error("Failed sending Slack notification to " + message);
|
|
274
272
|
}
|
|
275
273
|
}
|
|
276
274
|
}
|
|
@@ -247,23 +247,21 @@ class TwilioConnector extends ISmsConnector {
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
class SlackConnector {
|
|
250
|
-
constructor(
|
|
251
|
-
this.
|
|
250
|
+
constructor(webhook) {
|
|
251
|
+
this.webhook = webhook;
|
|
252
252
|
}
|
|
253
253
|
async sendNotificationToAllSlack(message) {
|
|
254
254
|
const controller = new AbortController();
|
|
255
255
|
const timeoutId = setTimeout(() => controller.abort(), 3e3);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
throw new Error("Failed sending Slack notification to " + message);
|
|
266
|
-
}
|
|
256
|
+
const response = await fetch(this.webhook, {
|
|
257
|
+
method: "POST",
|
|
258
|
+
body: JSON.stringify({ text: message }),
|
|
259
|
+
headers: { "Content-Type": "application/json" },
|
|
260
|
+
signal: controller.signal
|
|
261
|
+
});
|
|
262
|
+
clearTimeout(timeoutId);
|
|
263
|
+
if (!response.ok) {
|
|
264
|
+
throw new Error("Failed sending Slack notification to " + message);
|
|
267
265
|
}
|
|
268
266
|
}
|
|
269
267
|
}
|
package/dist/types.cjs
CHANGED
package/dist/types.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { I as IEmailConnector, h as IEmail, i as IContact, a as ISmsConnector, j as ISms, t as tables } from './shared/notification.
|
|
2
|
-
export { n as IAttachment, q as IPushNotification, r as ISlack, N as NotificationQueueMessage, b as SendEmailInput, c as SendEmailOutput, f as SendSlackInput, g as SendSlackOutput, d as SendSmsInput, e as SendSmsOutput, S as SlackConnector, l as iAttachmentSchema, k as iContactSchema, m as iEmailSchema, s as sendEmailInputSchema, o as sendSlackInputSchema, p as sendSmsInputSchema } from './shared/notification.
|
|
1
|
+
import { I as IEmailConnector, h as IEmail, i as IContact, a as ISmsConnector, j as ISms, t as tables } from './shared/notification.7yl25yVk.cjs';
|
|
2
|
+
export { n as IAttachment, q as IPushNotification, r as ISlack, N as NotificationQueueMessage, b as SendEmailInput, c as SendEmailOutput, f as SendSlackInput, g as SendSlackOutput, d as SendSmsInput, e as SendSmsOutput, S as SlackConnector, l as iAttachmentSchema, k as iContactSchema, m as iEmailSchema, s as sendEmailInputSchema, o as sendSlackInputSchema, p as sendSmsInputSchema } from './shared/notification.7yl25yVk.cjs';
|
|
3
3
|
import { InternalError } from '@develit-io/backend-sdk';
|
|
4
4
|
import twilio from 'twilio';
|
|
5
5
|
import { InferSelectModel, InferInsertModel } from 'drizzle-orm';
|
|
6
|
-
export { b as NotificationServiceEnv, a as NotificationServiceEnvironmentConfig, N as NotificationServiceWranglerConfig } from './shared/notification.
|
|
6
|
+
export { b as NotificationServiceEnv, a as NotificationServiceEnvironmentConfig, N as NotificationServiceWranglerConfig } from './shared/notification.CBrLTgQh.cjs';
|
|
7
7
|
import 'zod';
|
|
8
8
|
import 'zod/v4';
|
|
9
9
|
import './shared/notification.BJyMXKGH.cjs';
|
package/dist/types.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { I as IEmailConnector, h as IEmail, i as IContact, a as ISmsConnector, j as ISms, t as tables } from './shared/notification.
|
|
2
|
-
export { n as IAttachment, q as IPushNotification, r as ISlack, N as NotificationQueueMessage, b as SendEmailInput, c as SendEmailOutput, f as SendSlackInput, g as SendSlackOutput, d as SendSmsInput, e as SendSmsOutput, S as SlackConnector, l as iAttachmentSchema, k as iContactSchema, m as iEmailSchema, s as sendEmailInputSchema, o as sendSlackInputSchema, p as sendSmsInputSchema } from './shared/notification.
|
|
1
|
+
import { I as IEmailConnector, h as IEmail, i as IContact, a as ISmsConnector, j as ISms, t as tables } from './shared/notification.BiN8R884.mjs';
|
|
2
|
+
export { n as IAttachment, q as IPushNotification, r as ISlack, N as NotificationQueueMessage, b as SendEmailInput, c as SendEmailOutput, f as SendSlackInput, g as SendSlackOutput, d as SendSmsInput, e as SendSmsOutput, S as SlackConnector, l as iAttachmentSchema, k as iContactSchema, m as iEmailSchema, s as sendEmailInputSchema, o as sendSlackInputSchema, p as sendSmsInputSchema } from './shared/notification.BiN8R884.mjs';
|
|
3
3
|
import { InternalError } from '@develit-io/backend-sdk';
|
|
4
4
|
import twilio from 'twilio';
|
|
5
5
|
import { InferSelectModel, InferInsertModel } from 'drizzle-orm';
|
|
6
|
-
export { b as NotificationServiceEnv, a as NotificationServiceEnvironmentConfig, N as NotificationServiceWranglerConfig } from './shared/notification.
|
|
6
|
+
export { b as NotificationServiceEnv, a as NotificationServiceEnvironmentConfig, N as NotificationServiceWranglerConfig } from './shared/notification.CBrLTgQh.mjs';
|
|
7
7
|
import 'zod';
|
|
8
8
|
import 'zod/v4';
|
|
9
9
|
import './shared/notification.BJyMXKGH.mjs';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { I as IEmailConnector, h as IEmail, i as IContact, a as ISmsConnector, j as ISms, t as tables } from './shared/notification.
|
|
2
|
-
export { n as IAttachment, q as IPushNotification, r as ISlack, N as NotificationQueueMessage, b as SendEmailInput, c as SendEmailOutput, f as SendSlackInput, g as SendSlackOutput, d as SendSmsInput, e as SendSmsOutput, S as SlackConnector, l as iAttachmentSchema, k as iContactSchema, m as iEmailSchema, s as sendEmailInputSchema, o as sendSlackInputSchema, p as sendSmsInputSchema } from './shared/notification.
|
|
1
|
+
import { I as IEmailConnector, h as IEmail, i as IContact, a as ISmsConnector, j as ISms, t as tables } from './shared/notification.Cwt3LtuI.js';
|
|
2
|
+
export { n as IAttachment, q as IPushNotification, r as ISlack, N as NotificationQueueMessage, b as SendEmailInput, c as SendEmailOutput, f as SendSlackInput, g as SendSlackOutput, d as SendSmsInput, e as SendSmsOutput, S as SlackConnector, l as iAttachmentSchema, k as iContactSchema, m as iEmailSchema, s as sendEmailInputSchema, o as sendSlackInputSchema, p as sendSmsInputSchema } from './shared/notification.Cwt3LtuI.js';
|
|
3
3
|
import { InternalError } from '@develit-io/backend-sdk';
|
|
4
4
|
import twilio from 'twilio';
|
|
5
5
|
import { InferSelectModel, InferInsertModel } from 'drizzle-orm';
|
|
6
|
-
export { b as NotificationServiceEnv, a as NotificationServiceEnvironmentConfig, N as NotificationServiceWranglerConfig } from './shared/notification.
|
|
6
|
+
export { b as NotificationServiceEnv, a as NotificationServiceEnvironmentConfig, N as NotificationServiceWranglerConfig } from './shared/notification.CBrLTgQh.js';
|
|
7
7
|
import 'zod';
|
|
8
8
|
import 'zod/v4';
|
|
9
9
|
import './shared/notification.BJyMXKGH.js';
|
package/dist/types.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { E as EcomailConnector, I as IEmailConnector, e as ISmsConnector, S as SlackConnector, T as TwilioConnector, c as iAttachmentSchema, i as iContactSchema, d as iEmailSchema, s as sendEmailInputSchema, b as sendSlackInputSchema, a as sendSmsInputSchema } from './shared/notification.
|
|
1
|
+
export { E as EcomailConnector, I as IEmailConnector, e as ISmsConnector, S as SlackConnector, T as TwilioConnector, c as iAttachmentSchema, i as iContactSchema, d as iEmailSchema, s as sendEmailInputSchema, b as sendSlackInputSchema, a as sendSmsInputSchema } from './shared/notification.DkjmuyrV.mjs';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '@develit-io/backend-sdk';
|
|
4
4
|
import 'zod/v4';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@develit-services/notification",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"author": "Develit.io s.r.o.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"./dist"
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
|
-
"dev": "wrangler dev --port
|
|
34
|
-
"wrangler:generate": "develit wrangler:generate",
|
|
33
|
+
"dev": "wrangler dev --port 9235 --persist-to ../../.wrangler/state",
|
|
34
|
+
"wrangler:generate": "bunx develit wrangler:generate --types",
|
|
35
35
|
"db:init": "wrangler d1 execute develit-notification --local --persist-to ../../.wrangler/state --command=\"SELECT 'Creating database...' AS status;\"",
|
|
36
36
|
"db:generate": "drizzle-kit generate",
|
|
37
37
|
"db:migrate": "drizzle-kit migrate",
|