@develit-services/notification 0.0.33 → 0.0.35

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.
@@ -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 twilio_connector = require('../shared/notification.0BUVxa7A.cjs');
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 = [twilio_connector.EcomailConnector].find(
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 = [twilio_connector.TwilioConnector].find(
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
  }
@@ -120,39 +98,6 @@ class NotificationServiceBase extends backendSdk.develitWorker(
120
98
  this.logInput({ message });
121
99
  let notificationAction;
122
100
  const { type, metadata, payload } = message.body;
123
- if (type === "email") {
124
- const [emailConnector, error2] = await backendSdk.useResult(
125
- initiateEmailConnector(
126
- this.env.EMAIL_PROVIDER,
127
- this.env.EMAIL_API_KEY,
128
- this.env.EMAIL_SMTP_HOST,
129
- this.env.EMAIL_SENDER_EMAIL,
130
- this.env.EMAIL_SENDER_NAME
131
- )
132
- );
133
- if (error2) {
134
- this.logError({ error: error2 });
135
- message.retry();
136
- continue;
137
- }
138
- this.emailConnector = emailConnector;
139
- }
140
- if (type === "sms") {
141
- const [smsConnector, error2] = await backendSdk.useResult(
142
- initiateSmsConnector(
143
- this.env.SMS_PROVIDER,
144
- this.env.SMS_ACCOUNT_ID,
145
- this.env.SMS_AUTH_TOKEN,
146
- this.env.SMS_SERVICE_ID
147
- )
148
- );
149
- if (error2) {
150
- this.logError({ error: error2 });
151
- message.retry();
152
- continue;
153
- }
154
- this.smsConnector = smsConnector;
155
- }
156
101
  switch (type) {
157
102
  case "email":
158
103
  notificationAction = async () => this._sendEmail({
@@ -191,7 +136,7 @@ class NotificationServiceBase extends backendSdk.develitWorker(
191
136
  }
192
137
  async _sendEmail(input) {
193
138
  return this.handleAction(
194
- { data: input, schema: twilio_connector.sendEmailInputSchema },
139
+ { data: input, schema: slack_connector.sendEmailInputSchema },
195
140
  { successMessage: "Email sent." },
196
141
  async (params) => {
197
142
  const {
@@ -231,7 +176,7 @@ class NotificationServiceBase extends backendSdk.develitWorker(
231
176
  }
232
177
  async _sendSms(input) {
233
178
  return this.handleAction(
234
- { data: input, schema: twilio_connector.sendSmsInputSchema },
179
+ { data: input, schema: slack_connector.sendSmsInputSchema },
235
180
  { successMessage: "Sms sent." },
236
181
  async (params) => {
237
182
  const {
@@ -242,6 +187,14 @@ class NotificationServiceBase extends backendSdk.develitWorker(
242
187
  initiator: { service, userId }
243
188
  }
244
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
+ }
245
198
  await this.smsConnector.sendSms({ message, to });
246
199
  const { command } = await createAuditLogCommand({
247
200
  db: this.db,
@@ -262,7 +215,7 @@ class NotificationServiceBase extends backendSdk.develitWorker(
262
215
  }
263
216
  async sendEmail(input) {
264
217
  return this.handleAction(
265
- { data: input, schema: twilio_connector.sendEmailInputSchema },
218
+ { data: input, schema: slack_connector.sendEmailInputSchema },
266
219
  { successMessage: "Email sent." },
267
220
  async (params) => {
268
221
  const { email, metadata } = params;
@@ -280,9 +233,22 @@ class NotificationServiceBase extends backendSdk.develitWorker(
280
233
  }
281
234
  );
282
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
+ }
283
249
  async sendSms(input) {
284
250
  return this.handleAction(
285
- { data: input, schema: twilio_connector.sendSmsInputSchema },
251
+ { data: input, schema: slack_connector.sendSmsInputSchema },
286
252
  { successMessage: "SMS sent." },
287
253
  async (params) => {
288
254
  const {
@@ -315,7 +281,7 @@ class NotificationServiceBase extends backendSdk.develitWorker(
315
281
  return this.handleAction(
316
282
  {
317
283
  data: input,
318
- schema: twilio_connector.sendSlackInputSchema
284
+ schema: slack_connector.sendSlackInputSchema
319
285
  },
320
286
  { successMessage: "Slack sent." },
321
287
  async (params) => {
@@ -338,6 +304,9 @@ __decorateClass([
338
304
  __decorateClass([
339
305
  backendSdk.action("public-send-email")
340
306
  ], NotificationServiceBase.prototype, "sendEmail");
307
+ __decorateClass([
308
+ backendSdk.action("public-send-email-sync")
309
+ ], NotificationServiceBase.prototype, "sendEmailSync");
341
310
  __decorateClass([
342
311
  backendSdk.action("public-send-sms")
343
312
  ], NotificationServiceBase.prototype, "sendSms");
@@ -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, S as SendEmailInput, b as SendEmailOutput, c as SendSmsInput, d as SendSmsOutput, e as SendSlackInput, f as SendSlackOutput } from '../shared/notification.CbDIA6Ri.cjs';
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;
@@ -26,6 +20,7 @@ declare class NotificationServiceBase extends NotificationServiceBase_base {
26
20
  protected _sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
27
21
  protected _sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
28
22
  sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
23
+ sendEmailSync(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
29
24
  sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
30
25
  protected _sendPushNotification(): Promise<IRPCResponse<{}>>;
31
26
  sendSlackNotification(input: SendSlackInput): Promise<IRPCResponse<SendSlackOutput>>;
@@ -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, S as SendEmailInput, b as SendEmailOutput, c as SendSmsInput, d as SendSmsOutput, e as SendSlackInput, f as SendSlackOutput } from '../shared/notification.CR2sU8BK.mjs';
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;
@@ -26,6 +20,7 @@ declare class NotificationServiceBase extends NotificationServiceBase_base {
26
20
  protected _sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
27
21
  protected _sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
28
22
  sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
23
+ sendEmailSync(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
29
24
  sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
30
25
  protected _sendPushNotification(): Promise<IRPCResponse<{}>>;
31
26
  sendSlackNotification(input: SendSlackInput): Promise<IRPCResponse<SendSlackOutput>>;
@@ -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, S as SendEmailInput, b as SendEmailOutput, c as SendSmsInput, d as SendSmsOutput, e as SendSlackInput, f as SendSlackOutput } from '../shared/notification.DqfsDSe7.js';
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;
@@ -26,6 +20,7 @@ declare class NotificationServiceBase extends NotificationServiceBase_base {
26
20
  protected _sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
27
21
  protected _sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
28
22
  sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
23
+ sendEmailSync(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
29
24
  sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
30
25
  protected _sendPushNotification(): Promise<IRPCResponse<{}>>;
31
26
  sendSlackNotification(input: SendSlackInput): Promise<IRPCResponse<SendSlackOutput>>;
@@ -1,5 +1,5 @@
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.CQgItTyx.mjs';
1
+ import { createInternalError, uuidv4, develitWorker, cloudflareQueue, action } from '@develit-io/backend-sdk';
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) => {
@@ -116,39 +94,6 @@ class NotificationServiceBase extends develitWorker(
116
94
  this.logInput({ message });
117
95
  let notificationAction;
118
96
  const { type, metadata, payload } = message.body;
119
- if (type === "email") {
120
- const [emailConnector, error2] = await useResult(
121
- initiateEmailConnector(
122
- this.env.EMAIL_PROVIDER,
123
- this.env.EMAIL_API_KEY,
124
- this.env.EMAIL_SMTP_HOST,
125
- this.env.EMAIL_SENDER_EMAIL,
126
- this.env.EMAIL_SENDER_NAME
127
- )
128
- );
129
- if (error2) {
130
- this.logError({ error: error2 });
131
- message.retry();
132
- continue;
133
- }
134
- this.emailConnector = emailConnector;
135
- }
136
- if (type === "sms") {
137
- const [smsConnector, error2] = await useResult(
138
- initiateSmsConnector(
139
- this.env.SMS_PROVIDER,
140
- this.env.SMS_ACCOUNT_ID,
141
- this.env.SMS_AUTH_TOKEN,
142
- this.env.SMS_SERVICE_ID
143
- )
144
- );
145
- if (error2) {
146
- this.logError({ error: error2 });
147
- message.retry();
148
- continue;
149
- }
150
- this.smsConnector = smsConnector;
151
- }
152
97
  switch (type) {
153
98
  case "email":
154
99
  notificationAction = async () => this._sendEmail({
@@ -238,6 +183,14 @@ class NotificationServiceBase extends develitWorker(
238
183
  initiator: { service, userId }
239
184
  }
240
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
+ }
241
194
  await this.smsConnector.sendSms({ message, to });
242
195
  const { command } = await createAuditLogCommand({
243
196
  db: this.db,
@@ -276,6 +229,19 @@ class NotificationServiceBase extends develitWorker(
276
229
  }
277
230
  );
278
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
+ }
279
245
  async sendSms(input) {
280
246
  return this.handleAction(
281
247
  { data: input, schema: sendSmsInputSchema },
@@ -334,6 +300,9 @@ __decorateClass([
334
300
  __decorateClass([
335
301
  action("public-send-email")
336
302
  ], NotificationServiceBase.prototype, "sendEmail");
303
+ __decorateClass([
304
+ action("public-send-email-sync")
305
+ ], NotificationServiceBase.prototype, "sendEmailSync");
337
306
  __decorateClass([
338
307
  action("public-send-sms")
339
308
  ], NotificationServiceBase.prototype, "sendSms");
@@ -46,7 +46,6 @@ declare function defineNotificationServiceWrangler(config: NotificationServiceWr
46
46
  invocation_logs: boolean;
47
47
  };
48
48
  };
49
- preview_urls: boolean;
50
49
  workers_dev: boolean;
51
50
  keep_vars: boolean;
52
51
  };
@@ -46,7 +46,6 @@ declare function defineNotificationServiceWrangler(config: NotificationServiceWr
46
46
  invocation_logs: boolean;
47
47
  };
48
48
  };
49
- preview_urls: boolean;
50
49
  workers_dev: boolean;
51
50
  keep_vars: boolean;
52
51
  };
@@ -46,7 +46,6 @@ declare function defineNotificationServiceWrangler(config: NotificationServiceWr
46
46
  invocation_logs: boolean;
47
47
  };
48
48
  };
49
- preview_urls: boolean;
50
49
  workers_dev: boolean;
51
50
  keep_vars: boolean;
52
51
  };
@@ -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 j, iAttachmentSchema as k, iEmailSchema as l, sendSlackInputSchema as n, sendSmsInputSchema as o, sendEmailInputSchema as s, tables as t };
223
- export type { NotificationQueueMessage as N, SendEmailInput as S, SendEmailOutput as b, SendSmsInput as c, SendSmsOutput as d, SendSlackInput as e, SendSlackOutput as f, IEmail as g, IContact as h, ISms as i, IAttachment as m, IPushNotification as p, ISlack as q };
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 j, iAttachmentSchema as k, iEmailSchema as l, sendSlackInputSchema as n, sendSmsInputSchema as o, sendEmailInputSchema as s, tables as t };
223
- export type { NotificationQueueMessage as N, SendEmailInput as S, SendEmailOutput as b, SendSmsInput as c, SendSmsOutput as d, SendSlackInput as e, SendSlackOutput as f, IEmail as g, IContact as h, ISms as i, IAttachment as m, IPushNotification as p, ISlack as q };
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 j, iAttachmentSchema as k, iEmailSchema as l, sendSlackInputSchema as n, sendSmsInputSchema as o, sendEmailInputSchema as s, tables as t };
223
- export type { NotificationQueueMessage as N, SendEmailInput as S, SendEmailOutput as b, SendSmsInput as c, SendSmsOutput as d, SendSlackInput as e, SendSlackOutput as f, IEmail as g, IContact as h, ISms as i, IAttachment as m, IPushNotification as p, ISlack as q };
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
- export { EcomailConnector as E, IEmailConnector as I, TwilioConnector as T, sendSmsInputSchema as a, sendSlackInputSchema as b, iAttachmentSchema as c, iEmailSchema as d, ISmsConnector as e, iContactSchema as i, sendEmailInputSchema as s };
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, g as IEmail, h as IContact, a as ISmsConnector, i as ISms, t as tables } from './shared/notification.CbDIA6Ri.cjs';
2
- export { m as IAttachment, p as IPushNotification, q as ISlack, N as NotificationQueueMessage, S as SendEmailInput, b as SendEmailOutput, e as SendSlackInput, f as SendSlackOutput, c as SendSmsInput, d as SendSmsOutput, k as iAttachmentSchema, j as iContactSchema, l as iEmailSchema, s as sendEmailInputSchema, n as sendSlackInputSchema, o as sendSmsInputSchema } from './shared/notification.CbDIA6Ri.cjs';
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, g as IEmail, h as IContact, a as ISmsConnector, i as ISms, t as tables } from './shared/notification.CR2sU8BK.mjs';
2
- export { m as IAttachment, p as IPushNotification, q as ISlack, N as NotificationQueueMessage, S as SendEmailInput, b as SendEmailOutput, e as SendSlackInput, f as SendSlackOutput, c as SendSmsInput, d as SendSmsOutput, k as iAttachmentSchema, j as iContactSchema, l as iEmailSchema, s as sendEmailInputSchema, n as sendSlackInputSchema, o as sendSmsInputSchema } from './shared/notification.CR2sU8BK.mjs';
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, g as IEmail, h as IContact, a as ISmsConnector, i as ISms, t as tables } from './shared/notification.DqfsDSe7.js';
2
- export { m as IAttachment, p as IPushNotification, q as ISlack, N as NotificationQueueMessage, S as SendEmailInput, b as SendEmailOutput, e as SendSlackInput, f as SendSlackOutput, c as SendSmsInput, d as SendSmsOutput, k as iAttachmentSchema, j as iContactSchema, l as iEmailSchema, s as sendEmailInputSchema, n as sendSlackInputSchema, o as sendSmsInputSchema } from './shared/notification.DqfsDSe7.js';
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.CQgItTyx.mjs';
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.33",
3
+ "version": "0.0.35",
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/@types.d.ts",
24
- "import": "./dist/@types.mjs",
25
- "require": "./dist/@types.cjs"
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,7 +30,7 @@
30
30
  "./dist"
31
31
  ],
32
32
  "scripts": {
33
- "dev": "wrangler dev --port 9233 --persist-to ../../.wrangler/state",
33
+ "dev": "wrangler dev --port 9235 --persist-to ../../.wrangler/state",
34
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",
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;