@develit-services/notification 0.0.32 → 0.0.34
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 +9 -31
- package/dist/export/worker.d.cts +1 -7
- package/dist/export/worker.d.mts +1 -7
- package/dist/export/worker.d.ts +1 -7
- package/dist/export/worker.mjs +1 -23
- package/dist/export/wrangler.cjs +6 -15
- package/dist/export/wrangler.d.cts +15 -15
- package/dist/export/wrangler.d.mts +15 -15
- package/dist/export/wrangler.d.ts +15 -15
- package/dist/export/wrangler.mjs +6 -15
- package/dist/shared/{notification.0BUVxa7A.cjs → notification.BGfR3X_e.cjs} +23 -0
- package/dist/shared/{notification.CbDIA6Ri.d.cts → notification.BfmtOZWZ.d.cts} +8 -2
- package/dist/shared/{notification.CR2sU8BK.d.mts → notification.CBHpc8d5.d.mts} +8 -2
- package/dist/shared/{notification.DqfsDSe7.d.ts → notification.CTS2eEHl.d.ts} +8 -2
- package/dist/shared/{notification.CQgItTyx.mjs → notification.Di9LpjrD.mjs} +23 -1
- package/dist/types.cjs +27 -0
- package/dist/{@types.d.cts → types.d.cts} +2 -2
- package/dist/{@types.d.mts → types.d.mts} +2 -2
- package/dist/{@types.d.ts → types.d.ts} +2 -2
- package/dist/{@types.mjs → types.mjs} +1 -1
- package/package.json +12 -12
- package/dist/@types.cjs +0 -26
package/dist/export/worker.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
6
|
-
const
|
|
6
|
+
const slack_connector = require('../shared/notification.BGfR3X_e.cjs');
|
|
7
7
|
const database_schema = require('../shared/notification.4b3eUEIG.cjs');
|
|
8
8
|
require('drizzle-orm');
|
|
9
9
|
require('drizzle-orm/sqlite-core');
|
|
@@ -16,7 +16,7 @@ require('twilio');
|
|
|
16
16
|
const tables = database_schema.schema;
|
|
17
17
|
|
|
18
18
|
const initiateEmailConnector = async (provider, apiKey, smtpHost, senderEmail, senderName) => {
|
|
19
|
-
const connector = [
|
|
19
|
+
const connector = [slack_connector.EcomailConnector].find(
|
|
20
20
|
(conn) => conn.providerName === provider
|
|
21
21
|
);
|
|
22
22
|
if (!connector)
|
|
@@ -59,7 +59,7 @@ const createAuditLogCommand = async ({
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
const initiateSmsConnector = async (provider, accountId, authToken, serviceId) => {
|
|
62
|
-
const connector = [
|
|
62
|
+
const connector = [slack_connector.TwilioConnector].find(
|
|
63
63
|
(conn) => conn.providerName === provider
|
|
64
64
|
);
|
|
65
65
|
if (!connector)
|
|
@@ -74,28 +74,6 @@ const initiateSmsConnector = async (provider, accountId, authToken, serviceId) =
|
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
class SlackConnector {
|
|
78
|
-
constructor(webhooks) {
|
|
79
|
-
this.webhooks = webhooks;
|
|
80
|
-
}
|
|
81
|
-
async sendNotificationToAllSlack(message) {
|
|
82
|
-
const controller = new AbortController();
|
|
83
|
-
const timeoutId = setTimeout(() => controller.abort(), 3e3);
|
|
84
|
-
for (const webhook of this.webhooks) {
|
|
85
|
-
let response = await fetch(webhook, {
|
|
86
|
-
method: "POST",
|
|
87
|
-
body: JSON.stringify({ text: message }),
|
|
88
|
-
headers: { "Content-Type": "application/json" },
|
|
89
|
-
signal: controller.signal
|
|
90
|
-
});
|
|
91
|
-
clearTimeout(timeoutId);
|
|
92
|
-
if (!response.ok) {
|
|
93
|
-
throw new Error("Failed sending Slack notification to " + message);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
77
|
var __defProp = Object.defineProperty;
|
|
100
78
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
101
79
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -111,7 +89,7 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
111
89
|
) {
|
|
112
90
|
constructor(ctx, env) {
|
|
113
91
|
super(ctx, env);
|
|
114
|
-
this.slackConnector = new SlackConnector(this.env.SLACK_WEBHOOKS);
|
|
92
|
+
this.slackConnector = new slack_connector.SlackConnector(this.env.SLACK_WEBHOOKS);
|
|
115
93
|
this.name = "notification-service";
|
|
116
94
|
this.db = d1.drizzle(this.env.NOTIFICATION_D1, { schema: tables });
|
|
117
95
|
}
|
|
@@ -191,7 +169,7 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
191
169
|
}
|
|
192
170
|
async _sendEmail(input) {
|
|
193
171
|
return this.handleAction(
|
|
194
|
-
{ data: input, schema:
|
|
172
|
+
{ data: input, schema: slack_connector.sendEmailInputSchema },
|
|
195
173
|
{ successMessage: "Email sent." },
|
|
196
174
|
async (params) => {
|
|
197
175
|
const {
|
|
@@ -231,7 +209,7 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
231
209
|
}
|
|
232
210
|
async _sendSms(input) {
|
|
233
211
|
return this.handleAction(
|
|
234
|
-
{ data: input, schema:
|
|
212
|
+
{ data: input, schema: slack_connector.sendSmsInputSchema },
|
|
235
213
|
{ successMessage: "Sms sent." },
|
|
236
214
|
async (params) => {
|
|
237
215
|
const {
|
|
@@ -262,7 +240,7 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
262
240
|
}
|
|
263
241
|
async sendEmail(input) {
|
|
264
242
|
return this.handleAction(
|
|
265
|
-
{ data: input, schema:
|
|
243
|
+
{ data: input, schema: slack_connector.sendEmailInputSchema },
|
|
266
244
|
{ successMessage: "Email sent." },
|
|
267
245
|
async (params) => {
|
|
268
246
|
const { email, metadata } = params;
|
|
@@ -282,7 +260,7 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
282
260
|
}
|
|
283
261
|
async sendSms(input) {
|
|
284
262
|
return this.handleAction(
|
|
285
|
-
{ data: input, schema:
|
|
263
|
+
{ data: input, schema: slack_connector.sendSmsInputSchema },
|
|
286
264
|
{ successMessage: "SMS sent." },
|
|
287
265
|
async (params) => {
|
|
288
266
|
const {
|
|
@@ -315,7 +293,7 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
315
293
|
return this.handleAction(
|
|
316
294
|
{
|
|
317
295
|
data: input,
|
|
318
|
-
schema:
|
|
296
|
+
schema: slack_connector.sendSlackInputSchema
|
|
319
297
|
},
|
|
320
298
|
{ successMessage: "Slack sent." },
|
|
321
299
|
async (params) => {
|
package/dist/export/worker.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
2
2
|
import { IRPCResponse } from '@develit-io/backend-sdk';
|
|
3
|
-
import { I as IEmailConnector, a as ISmsConnector, t as tables, N as NotificationQueueMessage,
|
|
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
4
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
5
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
6
6
|
import 'zod';
|
|
@@ -8,12 +8,6 @@ import 'zod/v4';
|
|
|
8
8
|
import '../shared/notification.BJyMXKGH.cjs';
|
|
9
9
|
import 'drizzle-orm/sqlite-core';
|
|
10
10
|
|
|
11
|
-
declare class SlackConnector {
|
|
12
|
-
private webhooks;
|
|
13
|
-
constructor(webhooks: string[]);
|
|
14
|
-
sendNotificationToAllSlack(message: string): Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
11
|
declare const NotificationServiceBase_base: (abstract new (ctx: ExecutionContext, env: NotificationEnv) => WorkerEntrypoint<NotificationEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
|
|
18
12
|
declare class NotificationServiceBase extends NotificationServiceBase_base {
|
|
19
13
|
readonly name: string;
|
package/dist/export/worker.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
2
2
|
import { IRPCResponse } from '@develit-io/backend-sdk';
|
|
3
|
-
import { I as IEmailConnector, a as ISmsConnector, t as tables, N as NotificationQueueMessage,
|
|
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
4
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
5
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
6
6
|
import 'zod';
|
|
@@ -8,12 +8,6 @@ import 'zod/v4';
|
|
|
8
8
|
import '../shared/notification.BJyMXKGH.mjs';
|
|
9
9
|
import 'drizzle-orm/sqlite-core';
|
|
10
10
|
|
|
11
|
-
declare class SlackConnector {
|
|
12
|
-
private webhooks;
|
|
13
|
-
constructor(webhooks: string[]);
|
|
14
|
-
sendNotificationToAllSlack(message: string): Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
11
|
declare const NotificationServiceBase_base: (abstract new (ctx: ExecutionContext, env: NotificationEnv) => WorkerEntrypoint<NotificationEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
|
|
18
12
|
declare class NotificationServiceBase extends NotificationServiceBase_base {
|
|
19
13
|
readonly name: string;
|
package/dist/export/worker.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
2
2
|
import { IRPCResponse } from '@develit-io/backend-sdk';
|
|
3
|
-
import { I as IEmailConnector, a as ISmsConnector, t as tables, N as NotificationQueueMessage,
|
|
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
4
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
5
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
6
6
|
import 'zod';
|
|
@@ -8,12 +8,6 @@ import 'zod/v4';
|
|
|
8
8
|
import '../shared/notification.BJyMXKGH.js';
|
|
9
9
|
import 'drizzle-orm/sqlite-core';
|
|
10
10
|
|
|
11
|
-
declare class SlackConnector {
|
|
12
|
-
private webhooks;
|
|
13
|
-
constructor(webhooks: string[]);
|
|
14
|
-
sendNotificationToAllSlack(message: string): Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
11
|
declare const NotificationServiceBase_base: (abstract new (ctx: ExecutionContext, env: NotificationEnv) => WorkerEntrypoint<NotificationEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
|
|
18
12
|
declare class NotificationServiceBase extends NotificationServiceBase_base {
|
|
19
13
|
readonly name: string;
|
package/dist/export/worker.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createInternalError, uuidv4, develitWorker, useResult, cloudflareQueue, action } from '@develit-io/backend-sdk';
|
|
2
|
-
import { E as EcomailConnector, T as TwilioConnector, s as sendEmailInputSchema, a as sendSmsInputSchema, b as sendSlackInputSchema } from '../shared/notification.
|
|
2
|
+
import { E as EcomailConnector, T as TwilioConnector, S as SlackConnector, s as sendEmailInputSchema, a as sendSmsInputSchema, b as sendSlackInputSchema } from '../shared/notification.Di9LpjrD.mjs';
|
|
3
3
|
import { s as schema } from '../shared/notification.C0X8Orrh.mjs';
|
|
4
4
|
import 'drizzle-orm';
|
|
5
5
|
import 'drizzle-orm/sqlite-core';
|
|
@@ -70,28 +70,6 @@ const initiateSmsConnector = async (provider, accountId, authToken, serviceId) =
|
|
|
70
70
|
});
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
class SlackConnector {
|
|
74
|
-
constructor(webhooks) {
|
|
75
|
-
this.webhooks = webhooks;
|
|
76
|
-
}
|
|
77
|
-
async sendNotificationToAllSlack(message) {
|
|
78
|
-
const controller = new AbortController();
|
|
79
|
-
const timeoutId = setTimeout(() => controller.abort(), 3e3);
|
|
80
|
-
for (const webhook of this.webhooks) {
|
|
81
|
-
let response = await fetch(webhook, {
|
|
82
|
-
method: "POST",
|
|
83
|
-
body: JSON.stringify({ text: message }),
|
|
84
|
-
headers: { "Content-Type": "application/json" },
|
|
85
|
-
signal: controller.signal
|
|
86
|
-
});
|
|
87
|
-
clearTimeout(timeoutId);
|
|
88
|
-
if (!response.ok) {
|
|
89
|
-
throw new Error("Failed sending Slack notification to " + message);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
73
|
var __defProp = Object.defineProperty;
|
|
96
74
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
97
75
|
var __decorateClass = (decorators, target, key, kind) => {
|
package/dist/export/wrangler.cjs
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const backendSdk = require('@develit-io/backend-sdk');
|
|
4
|
+
|
|
3
5
|
function defineNotificationServiceWrangler(config) {
|
|
4
6
|
const { project, name, envs } = config;
|
|
5
7
|
const base = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
compatibility_flags: ["nodejs_compat"],
|
|
11
|
-
observability: {
|
|
12
|
-
enabled: true,
|
|
13
|
-
head_sampling_rate: 1,
|
|
14
|
-
logs: {
|
|
15
|
-
enabled: true,
|
|
16
|
-
invocation_logs: false
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
preview_urls: false,
|
|
20
|
-
workers_dev: false,
|
|
8
|
+
...backendSdk.composeWranglerBase({
|
|
9
|
+
project,
|
|
10
|
+
name
|
|
11
|
+
}),
|
|
21
12
|
vars: {
|
|
22
13
|
// Secrets
|
|
23
14
|
EMAIL_API_KEY: "[SECRET]",
|
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
import { N as NotificationServiceWranglerConfig } from '../shared/notification.jEQePmaL.cjs';
|
|
2
2
|
|
|
3
3
|
declare function defineNotificationServiceWrangler(config: NotificationServiceWranglerConfig): {
|
|
4
|
-
$schema: string;
|
|
5
|
-
name: string;
|
|
6
|
-
main: string;
|
|
7
|
-
compatibility_date: string;
|
|
8
|
-
compatibility_flags: string[];
|
|
9
|
-
observability: {
|
|
10
|
-
enabled: boolean;
|
|
11
|
-
head_sampling_rate: number;
|
|
12
|
-
logs: {
|
|
13
|
-
enabled: boolean;
|
|
14
|
-
invocation_logs: boolean;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
preview_urls: boolean;
|
|
18
|
-
workers_dev: boolean;
|
|
19
4
|
vars: {
|
|
20
5
|
ENVIRONMENT: string;
|
|
21
6
|
EMAIL_PROVIDER: "ecomail";
|
|
@@ -48,6 +33,21 @@ declare function defineNotificationServiceWrangler(config: NotificationServiceWr
|
|
|
48
33
|
}[];
|
|
49
34
|
};
|
|
50
35
|
env: Record<string, unknown>;
|
|
36
|
+
$schema: string;
|
|
37
|
+
name: string;
|
|
38
|
+
main: string;
|
|
39
|
+
compatibility_date: string;
|
|
40
|
+
compatibility_flags: string[];
|
|
41
|
+
observability: {
|
|
42
|
+
enabled: boolean;
|
|
43
|
+
head_sampling_rate: number;
|
|
44
|
+
logs: {
|
|
45
|
+
enabled: boolean;
|
|
46
|
+
invocation_logs: boolean;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
workers_dev: boolean;
|
|
50
|
+
keep_vars: boolean;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
export { defineNotificationServiceWrangler };
|
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
import { N as NotificationServiceWranglerConfig } from '../shared/notification.jEQePmaL.mjs';
|
|
2
2
|
|
|
3
3
|
declare function defineNotificationServiceWrangler(config: NotificationServiceWranglerConfig): {
|
|
4
|
-
$schema: string;
|
|
5
|
-
name: string;
|
|
6
|
-
main: string;
|
|
7
|
-
compatibility_date: string;
|
|
8
|
-
compatibility_flags: string[];
|
|
9
|
-
observability: {
|
|
10
|
-
enabled: boolean;
|
|
11
|
-
head_sampling_rate: number;
|
|
12
|
-
logs: {
|
|
13
|
-
enabled: boolean;
|
|
14
|
-
invocation_logs: boolean;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
preview_urls: boolean;
|
|
18
|
-
workers_dev: boolean;
|
|
19
4
|
vars: {
|
|
20
5
|
ENVIRONMENT: string;
|
|
21
6
|
EMAIL_PROVIDER: "ecomail";
|
|
@@ -48,6 +33,21 @@ declare function defineNotificationServiceWrangler(config: NotificationServiceWr
|
|
|
48
33
|
}[];
|
|
49
34
|
};
|
|
50
35
|
env: Record<string, unknown>;
|
|
36
|
+
$schema: string;
|
|
37
|
+
name: string;
|
|
38
|
+
main: string;
|
|
39
|
+
compatibility_date: string;
|
|
40
|
+
compatibility_flags: string[];
|
|
41
|
+
observability: {
|
|
42
|
+
enabled: boolean;
|
|
43
|
+
head_sampling_rate: number;
|
|
44
|
+
logs: {
|
|
45
|
+
enabled: boolean;
|
|
46
|
+
invocation_logs: boolean;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
workers_dev: boolean;
|
|
50
|
+
keep_vars: boolean;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
export { defineNotificationServiceWrangler };
|
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
import { N as NotificationServiceWranglerConfig } from '../shared/notification.jEQePmaL.js';
|
|
2
2
|
|
|
3
3
|
declare function defineNotificationServiceWrangler(config: NotificationServiceWranglerConfig): {
|
|
4
|
-
$schema: string;
|
|
5
|
-
name: string;
|
|
6
|
-
main: string;
|
|
7
|
-
compatibility_date: string;
|
|
8
|
-
compatibility_flags: string[];
|
|
9
|
-
observability: {
|
|
10
|
-
enabled: boolean;
|
|
11
|
-
head_sampling_rate: number;
|
|
12
|
-
logs: {
|
|
13
|
-
enabled: boolean;
|
|
14
|
-
invocation_logs: boolean;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
preview_urls: boolean;
|
|
18
|
-
workers_dev: boolean;
|
|
19
4
|
vars: {
|
|
20
5
|
ENVIRONMENT: string;
|
|
21
6
|
EMAIL_PROVIDER: "ecomail";
|
|
@@ -48,6 +33,21 @@ declare function defineNotificationServiceWrangler(config: NotificationServiceWr
|
|
|
48
33
|
}[];
|
|
49
34
|
};
|
|
50
35
|
env: Record<string, unknown>;
|
|
36
|
+
$schema: string;
|
|
37
|
+
name: string;
|
|
38
|
+
main: string;
|
|
39
|
+
compatibility_date: string;
|
|
40
|
+
compatibility_flags: string[];
|
|
41
|
+
observability: {
|
|
42
|
+
enabled: boolean;
|
|
43
|
+
head_sampling_rate: number;
|
|
44
|
+
logs: {
|
|
45
|
+
enabled: boolean;
|
|
46
|
+
invocation_logs: boolean;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
workers_dev: boolean;
|
|
50
|
+
keep_vars: boolean;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
export { defineNotificationServiceWrangler };
|
package/dist/export/wrangler.mjs
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
|
+
import { composeWranglerBase } from '@develit-io/backend-sdk';
|
|
2
|
+
|
|
1
3
|
function defineNotificationServiceWrangler(config) {
|
|
2
4
|
const { project, name, envs } = config;
|
|
3
5
|
const base = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
compatibility_flags: ["nodejs_compat"],
|
|
9
|
-
observability: {
|
|
10
|
-
enabled: true,
|
|
11
|
-
head_sampling_rate: 1,
|
|
12
|
-
logs: {
|
|
13
|
-
enabled: true,
|
|
14
|
-
invocation_logs: false
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
preview_urls: false,
|
|
18
|
-
workers_dev: false,
|
|
6
|
+
...composeWranglerBase({
|
|
7
|
+
project,
|
|
8
|
+
name
|
|
9
|
+
}),
|
|
19
10
|
vars: {
|
|
20
11
|
// Secrets
|
|
21
12
|
EMAIL_API_KEY: "[SECRET]",
|
|
@@ -253,9 +253,32 @@ class TwilioConnector extends ISmsConnector {
|
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
+
class SlackConnector {
|
|
257
|
+
constructor(webhooks) {
|
|
258
|
+
this.webhooks = webhooks;
|
|
259
|
+
}
|
|
260
|
+
async sendNotificationToAllSlack(message) {
|
|
261
|
+
const controller = new AbortController();
|
|
262
|
+
const timeoutId = setTimeout(() => controller.abort(), 3e3);
|
|
263
|
+
for (const webhook of this.webhooks) {
|
|
264
|
+
let response = await fetch(webhook, {
|
|
265
|
+
method: "POST",
|
|
266
|
+
body: JSON.stringify({ text: message }),
|
|
267
|
+
headers: { "Content-Type": "application/json" },
|
|
268
|
+
signal: controller.signal
|
|
269
|
+
});
|
|
270
|
+
clearTimeout(timeoutId);
|
|
271
|
+
if (!response.ok) {
|
|
272
|
+
throw new Error("Failed sending Slack notification to " + message);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
256
278
|
exports.EcomailConnector = EcomailConnector;
|
|
257
279
|
exports.IEmailConnector = IEmailConnector;
|
|
258
280
|
exports.ISmsConnector = ISmsConnector;
|
|
281
|
+
exports.SlackConnector = SlackConnector;
|
|
259
282
|
exports.TwilioConnector = TwilioConnector;
|
|
260
283
|
exports.iAttachmentSchema = iAttachmentSchema;
|
|
261
284
|
exports.iContactSchema = iContactSchema;
|
|
@@ -217,7 +217,13 @@ interface ISlack {
|
|
|
217
217
|
message: string;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
declare class SlackConnector {
|
|
221
|
+
private webhooks;
|
|
222
|
+
constructor(webhooks: string[]);
|
|
223
|
+
sendNotificationToAllSlack(message: string): Promise<void>;
|
|
224
|
+
}
|
|
225
|
+
|
|
220
226
|
declare const tables: typeof schema;
|
|
221
227
|
|
|
222
|
-
export { IEmailConnector as I, ISmsConnector as a, iContactSchema as
|
|
223
|
-
export type { NotificationQueueMessage as N, SendEmailInput as
|
|
228
|
+
export { IEmailConnector as I, SlackConnector as S, ISmsConnector as a, iContactSchema as k, iAttachmentSchema as l, iEmailSchema as m, sendSlackInputSchema as o, sendSmsInputSchema as p, sendEmailInputSchema as s, tables as t };
|
|
229
|
+
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 n, IPushNotification as q, ISlack as r };
|
|
@@ -217,7 +217,13 @@ interface ISlack {
|
|
|
217
217
|
message: string;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
declare class SlackConnector {
|
|
221
|
+
private webhooks;
|
|
222
|
+
constructor(webhooks: string[]);
|
|
223
|
+
sendNotificationToAllSlack(message: string): Promise<void>;
|
|
224
|
+
}
|
|
225
|
+
|
|
220
226
|
declare const tables: typeof schema;
|
|
221
227
|
|
|
222
|
-
export { IEmailConnector as I, ISmsConnector as a, iContactSchema as
|
|
223
|
-
export type { NotificationQueueMessage as N, SendEmailInput as
|
|
228
|
+
export { IEmailConnector as I, SlackConnector as S, ISmsConnector as a, iContactSchema as k, iAttachmentSchema as l, iEmailSchema as m, sendSlackInputSchema as o, sendSmsInputSchema as p, sendEmailInputSchema as s, tables as t };
|
|
229
|
+
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 n, IPushNotification as q, ISlack as r };
|
|
@@ -217,7 +217,13 @@ interface ISlack {
|
|
|
217
217
|
message: string;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
declare class SlackConnector {
|
|
221
|
+
private webhooks;
|
|
222
|
+
constructor(webhooks: string[]);
|
|
223
|
+
sendNotificationToAllSlack(message: string): Promise<void>;
|
|
224
|
+
}
|
|
225
|
+
|
|
220
226
|
declare const tables: typeof schema;
|
|
221
227
|
|
|
222
|
-
export { IEmailConnector as I, ISmsConnector as a, iContactSchema as
|
|
223
|
-
export type { NotificationQueueMessage as N, SendEmailInput as
|
|
228
|
+
export { IEmailConnector as I, SlackConnector as S, ISmsConnector as a, iContactSchema as k, iAttachmentSchema as l, iEmailSchema as m, sendSlackInputSchema as o, sendSmsInputSchema as p, sendEmailInputSchema as s, tables as t };
|
|
229
|
+
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 n, IPushNotification as q, ISlack as r };
|
|
@@ -246,4 +246,26 @@ class TwilioConnector extends ISmsConnector {
|
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
|
|
249
|
+
class SlackConnector {
|
|
250
|
+
constructor(webhooks) {
|
|
251
|
+
this.webhooks = webhooks;
|
|
252
|
+
}
|
|
253
|
+
async sendNotificationToAllSlack(message) {
|
|
254
|
+
const controller = new AbortController();
|
|
255
|
+
const timeoutId = setTimeout(() => controller.abort(), 3e3);
|
|
256
|
+
for (const webhook of this.webhooks) {
|
|
257
|
+
let response = await fetch(webhook, {
|
|
258
|
+
method: "POST",
|
|
259
|
+
body: JSON.stringify({ text: message }),
|
|
260
|
+
headers: { "Content-Type": "application/json" },
|
|
261
|
+
signal: controller.signal
|
|
262
|
+
});
|
|
263
|
+
clearTimeout(timeoutId);
|
|
264
|
+
if (!response.ok) {
|
|
265
|
+
throw new Error("Failed sending Slack notification to " + message);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export { EcomailConnector as E, IEmailConnector as I, SlackConnector as S, TwilioConnector as T, sendSmsInputSchema as a, sendSlackInputSchema as b, iAttachmentSchema as c, iEmailSchema as d, ISmsConnector as e, iContactSchema as i, sendEmailInputSchema as s };
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const slack_connector = require('./shared/notification.BGfR3X_e.cjs');
|
|
4
|
+
require('zod');
|
|
5
|
+
require('@develit-io/backend-sdk');
|
|
6
|
+
require('zod/v4');
|
|
7
|
+
require('twilio');
|
|
8
|
+
|
|
9
|
+
const AUDIT_LOG_EVENT_TYPES = [
|
|
10
|
+
"EMAIL",
|
|
11
|
+
"SMS",
|
|
12
|
+
"PUSH_NOTIFICATION",
|
|
13
|
+
"SLACK"
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
exports.EcomailConnector = slack_connector.EcomailConnector;
|
|
17
|
+
exports.IEmailConnector = slack_connector.IEmailConnector;
|
|
18
|
+
exports.ISmsConnector = slack_connector.ISmsConnector;
|
|
19
|
+
exports.SlackConnector = slack_connector.SlackConnector;
|
|
20
|
+
exports.TwilioConnector = slack_connector.TwilioConnector;
|
|
21
|
+
exports.iAttachmentSchema = slack_connector.iAttachmentSchema;
|
|
22
|
+
exports.iContactSchema = slack_connector.iContactSchema;
|
|
23
|
+
exports.iEmailSchema = slack_connector.iEmailSchema;
|
|
24
|
+
exports.sendEmailInputSchema = slack_connector.sendEmailInputSchema;
|
|
25
|
+
exports.sendSlackInputSchema = slack_connector.sendSlackInputSchema;
|
|
26
|
+
exports.sendSmsInputSchema = slack_connector.sendSmsInputSchema;
|
|
27
|
+
exports.AUDIT_LOG_EVENT_TYPES = AUDIT_LOG_EVENT_TYPES;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IEmailConnector,
|
|
2
|
-
export {
|
|
1
|
+
import { I as IEmailConnector, h as IEmail, i as IContact, a as ISmsConnector, j as ISms, t as tables } from './shared/notification.BfmtOZWZ.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.BfmtOZWZ.cjs';
|
|
3
3
|
import { InternalError } from '@develit-io/backend-sdk';
|
|
4
4
|
import twilio from 'twilio';
|
|
5
5
|
import { InferSelectModel, InferInsertModel } from 'drizzle-orm';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IEmailConnector,
|
|
2
|
-
export {
|
|
1
|
+
import { I as IEmailConnector, h as IEmail, i as IContact, a as ISmsConnector, j as ISms, t as tables } from './shared/notification.CBHpc8d5.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.CBHpc8d5.mjs';
|
|
3
3
|
import { InternalError } from '@develit-io/backend-sdk';
|
|
4
4
|
import twilio from 'twilio';
|
|
5
5
|
import { InferSelectModel, InferInsertModel } from 'drizzle-orm';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IEmailConnector,
|
|
2
|
-
export {
|
|
1
|
+
import { I as IEmailConnector, h as IEmail, i as IContact, a as ISmsConnector, j as ISms, t as tables } from './shared/notification.CTS2eEHl.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.CTS2eEHl.js';
|
|
3
3
|
import { InternalError } from '@develit-io/backend-sdk';
|
|
4
4
|
import twilio from 'twilio';
|
|
5
5
|
import { InferSelectModel, InferInsertModel } from 'drizzle-orm';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { E as EcomailConnector, I as IEmailConnector, e as ISmsConnector, 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.Di9LpjrD.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.0.34",
|
|
4
4
|
"author": "Develit.io s.r.o.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"require": "./dist/database/schema.cjs"
|
|
21
21
|
},
|
|
22
22
|
"./@types": {
|
|
23
|
-
"types": "./dist
|
|
24
|
-
"import": "./dist
|
|
25
|
-
"require": "./dist
|
|
23
|
+
"types": "./dist/types.d.ts",
|
|
24
|
+
"import": "./dist/types.mjs",
|
|
25
|
+
"require": "./dist/types.cjs"
|
|
26
26
|
},
|
|
27
27
|
"./package.json": "./package.json"
|
|
28
28
|
},
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"./dist"
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
|
-
"dev": "wrangler dev --port
|
|
34
|
-
"wrangler:generate": "
|
|
33
|
+
"dev": "wrangler dev --port 9234 --persist-to ../../.wrangler/state",
|
|
34
|
+
"wrangler:generate": "develit wrangler:generate",
|
|
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",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"release": "bun run build && bunx changelogen@latest --release --push && npm publish --access public"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@develit-io/backend-sdk": "
|
|
53
|
-
"drizzle-kit": "
|
|
54
|
-
"drizzle-orm": "
|
|
55
|
-
"drizzle-seed": "
|
|
56
|
-
"wrangler": "
|
|
57
|
-
"zod": "
|
|
52
|
+
"@develit-io/backend-sdk": "*",
|
|
53
|
+
"drizzle-kit": "*",
|
|
54
|
+
"drizzle-orm": "*",
|
|
55
|
+
"drizzle-seed": "*",
|
|
56
|
+
"wrangler": "*",
|
|
57
|
+
"zod": "*"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"twilio": "^5.10.3"
|
package/dist/@types.cjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const twilio_connector = require('./shared/notification.0BUVxa7A.cjs');
|
|
4
|
-
require('zod');
|
|
5
|
-
require('@develit-io/backend-sdk');
|
|
6
|
-
require('zod/v4');
|
|
7
|
-
require('twilio');
|
|
8
|
-
|
|
9
|
-
const AUDIT_LOG_EVENT_TYPES = [
|
|
10
|
-
"EMAIL",
|
|
11
|
-
"SMS",
|
|
12
|
-
"PUSH_NOTIFICATION",
|
|
13
|
-
"SLACK"
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
exports.EcomailConnector = twilio_connector.EcomailConnector;
|
|
17
|
-
exports.IEmailConnector = twilio_connector.IEmailConnector;
|
|
18
|
-
exports.ISmsConnector = twilio_connector.ISmsConnector;
|
|
19
|
-
exports.TwilioConnector = twilio_connector.TwilioConnector;
|
|
20
|
-
exports.iAttachmentSchema = twilio_connector.iAttachmentSchema;
|
|
21
|
-
exports.iContactSchema = twilio_connector.iContactSchema;
|
|
22
|
-
exports.iEmailSchema = twilio_connector.iEmailSchema;
|
|
23
|
-
exports.sendEmailInputSchema = twilio_connector.sendEmailInputSchema;
|
|
24
|
-
exports.sendSlackInputSchema = twilio_connector.sendSlackInputSchema;
|
|
25
|
-
exports.sendSmsInputSchema = twilio_connector.sendSmsInputSchema;
|
|
26
|
-
exports.AUDIT_LOG_EVENT_TYPES = AUDIT_LOG_EVENT_TYPES;
|