@develit-services/notification 0.0.35 → 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.
@@ -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 slack_connector = require('../shared/notification.BGfR3X_e.cjs');
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.SLACK_WEBHOOKS);
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
  }
@@ -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';
@@ -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';
@@ -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';
@@ -1,16 +1,14 @@
1
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';
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.SLACK_WEBHOOKS);
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
  }
@@ -1,4 +1,4 @@
1
- import { N as NotificationServiceWranglerConfig } from '../shared/notification.jEQePmaL.cjs';
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
- SLACK_WEBHOOKS: [string];
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.jEQePmaL.mjs';
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
- SLACK_WEBHOOKS: [string];
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.jEQePmaL.js';
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
- SLACK_WEBHOOKS: [string];
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 webhooks;
222
- constructor(webhooks: string[]);
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 webhooks;
222
- constructor(webhooks: string[]);
221
+ private webhook;
222
+ constructor(webhook: string);
223
223
  sendNotificationToAllSlack(message: string): Promise<void>;
224
224
  }
225
225
 
@@ -14,7 +14,7 @@ interface NotificationServiceEnvironmentConfig {
14
14
  SMS_PROVIDER: 'twilio';
15
15
  SMS_ACCOUNT_ID: string;
16
16
  SMS_SERVICE_ID: string | number;
17
- SLACK_WEBHOOKS: [string];
17
+ SLACK_WEBHOOK: string;
18
18
  };
19
19
  }
20
20
  interface NotificationServiceWranglerConfig {
@@ -14,7 +14,7 @@ interface NotificationServiceEnvironmentConfig {
14
14
  SMS_PROVIDER: 'twilio';
15
15
  SMS_ACCOUNT_ID: string;
16
16
  SMS_SERVICE_ID: string | number;
17
- SLACK_WEBHOOKS: [string];
17
+ SLACK_WEBHOOK: string;
18
18
  };
19
19
  }
20
20
  interface NotificationServiceWranglerConfig {
@@ -14,7 +14,7 @@ interface NotificationServiceEnvironmentConfig {
14
14
  SMS_PROVIDER: 'twilio';
15
15
  SMS_ACCOUNT_ID: string;
16
16
  SMS_SERVICE_ID: string | number;
17
- SLACK_WEBHOOKS: [string];
17
+ SLACK_WEBHOOK: string;
18
18
  };
19
19
  }
20
20
  interface NotificationServiceWranglerConfig {
@@ -218,8 +218,8 @@ interface ISlack {
218
218
  }
219
219
 
220
220
  declare class SlackConnector {
221
- private webhooks;
222
- constructor(webhooks: string[]);
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(webhooks) {
258
- this.webhooks = webhooks;
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
- 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
- }
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(webhooks) {
251
- this.webhooks = webhooks;
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
- 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
- }
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
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const slack_connector = require('./shared/notification.BGfR3X_e.cjs');
3
+ const slack_connector = require('./shared/notification.Dk_5TX9v.cjs');
4
4
  require('zod');
5
5
  require('@develit-io/backend-sdk');
6
6
  require('zod/v4');
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.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';
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.jEQePmaL.cjs';
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.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';
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.jEQePmaL.mjs';
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.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';
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.jEQePmaL.js';
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.Di9LpjrD.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.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.35",
3
+ "version": "0.1.0",
4
4
  "author": "Develit.io s.r.o.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -31,7 +31,7 @@
31
31
  ],
32
32
  "scripts": {
33
33
  "dev": "wrangler dev --port 9235 --persist-to ../../.wrangler/state",
34
- "wrangler:generate": "develit wrangler:generate",
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",