@develit-services/notification 0.0.6 → 0.0.7

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/worker.cjs CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  const backendSdk = require('@develit-io/backend-sdk');
4
6
  const z = require('zod');
5
7
  const v4 = require('zod/v4');
@@ -559,4 +561,5 @@ function defineNotificationService() {
559
561
 
560
562
  const NotificationService = defineNotificationService();
561
563
 
562
- module.exports = NotificationService;
564
+ exports.default = NotificationService;
565
+ exports.defineNotificationService = defineNotificationService;
package/dist/worker.d.cts CHANGED
@@ -1,5 +1,432 @@
1
+ import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
2
+ import { InternalError, IRPCResponse } from '@develit-io/backend-sdk';
3
+ import z$1, { z } from 'zod';
4
+ import { z as z$2 } from 'zod/v4';
5
+ import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
1
6
  import { WorkerEntrypoint } from 'cloudflare:workers';
7
+ import { DrizzleD1Database } from 'drizzle-orm/d1';
8
+
9
+ declare const iContactSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
10
+ email: z.ZodString;
11
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
12
+ }, z.core.$strip>]>;
13
+ declare const iEmailSchema: z.ZodObject<{
14
+ to: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
15
+ email: z.ZodString;
16
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
17
+ }, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
18
+ email: z.ZodString;
19
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
20
+ }, z.core.$strip>]>>]>;
21
+ replyTo: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
22
+ email: z.ZodString;
23
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
24
+ }, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
25
+ email: z.ZodString;
26
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
27
+ }, z.core.$strip>]>>]>>;
28
+ cc: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
29
+ email: z.ZodString;
30
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
31
+ }, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
32
+ email: z.ZodString;
33
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
34
+ }, z.core.$strip>]>>]>>;
35
+ bcc: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
36
+ email: z.ZodString;
37
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
38
+ }, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
39
+ email: z.ZodString;
40
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
41
+ }, z.core.$strip>]>>]>>;
42
+ from: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
43
+ email: z.ZodString;
44
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
45
+ }, z.core.$strip>]>>;
46
+ subject: z.ZodString;
47
+ text: z.ZodOptional<z.ZodString>;
48
+ html: z.ZodOptional<z.ZodString>;
49
+ templateId: z.ZodOptional<z.ZodNumber>;
50
+ templateVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
51
+ }, z.core.$strip>;
52
+ type IContact = z.infer<typeof iContactSchema>;
53
+ type IEmail = z.infer<typeof iEmailSchema>;
54
+
55
+ declare abstract class IEmailConnector {
56
+ static providerName: string;
57
+ API_KEY: string;
58
+ SMTP_HOST: string;
59
+ SENDER: IContact;
60
+ protected constructor({ API_KEY, SMTP_HOST, SENDER, }: {
61
+ API_KEY: string;
62
+ SMTP_HOST: string;
63
+ SENDER: IContact;
64
+ });
65
+ abstract sendEmail(email: IEmail): Promise<Response | null>;
66
+ }
67
+
68
+ declare const sendEmailInputSchema: z$1.ZodObject<{
69
+ email: z$1.ZodObject<{
70
+ to: z$1.ZodUnion<readonly [z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
71
+ email: z$1.ZodString;
72
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
73
+ }, z$1.core.$strip>]>, z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
74
+ email: z$1.ZodString;
75
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
76
+ }, z$1.core.$strip>]>>]>;
77
+ replyTo: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
78
+ email: z$1.ZodString;
79
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
80
+ }, z$1.core.$strip>]>, z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
81
+ email: z$1.ZodString;
82
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
83
+ }, z$1.core.$strip>]>>]>>;
84
+ cc: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
85
+ email: z$1.ZodString;
86
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
87
+ }, z$1.core.$strip>]>, z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
88
+ email: z$1.ZodString;
89
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
90
+ }, z$1.core.$strip>]>>]>>;
91
+ bcc: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
92
+ email: z$1.ZodString;
93
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
94
+ }, z$1.core.$strip>]>, z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
95
+ email: z$1.ZodString;
96
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
97
+ }, z$1.core.$strip>]>>]>>;
98
+ from: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
99
+ email: z$1.ZodString;
100
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
101
+ }, z$1.core.$strip>]>>;
102
+ subject: z$1.ZodString;
103
+ text: z$1.ZodOptional<z$1.ZodString>;
104
+ html: z$1.ZodOptional<z$1.ZodString>;
105
+ templateId: z$1.ZodOptional<z$1.ZodNumber>;
106
+ templateVariables: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
107
+ }, z$1.core.$strip>;
108
+ metadata: z$1.ZodObject<{
109
+ userAgent: z$1.ZodOptional<z$1.ZodString>;
110
+ ip: z$1.ZodOptional<z$1.ZodUnion<[z$1.ZodIPv4, z$1.ZodIPv6]>>;
111
+ initiator: z$1.ZodObject<{
112
+ service: z$1.ZodString;
113
+ userId: z$1.ZodOptional<z$1.ZodString>;
114
+ }, z$1.core.$strip>;
115
+ }, z$1.core.$strip>;
116
+ }, z$1.core.$strip>;
117
+ interface SendEmailInput extends z$1.infer<typeof sendEmailInputSchema> {
118
+ }
119
+ interface SendEmailOutput {
120
+ }
121
+
122
+ declare const sendSlackInputSchema: z$2.ZodObject<{
123
+ slack: z$2.ZodObject<{
124
+ message: z$2.ZodString;
125
+ }, z$2.core.$strip>;
126
+ metadata: z$2.ZodObject<{
127
+ userAgent: z$2.ZodOptional<z$2.ZodString>;
128
+ ip: z$2.ZodOptional<z$2.ZodUnion<[z$2.ZodIPv4, z$2.ZodIPv6]>>;
129
+ initiator: z$2.ZodObject<{
130
+ service: z$2.ZodString;
131
+ userId: z$2.ZodOptional<z$2.ZodString>;
132
+ }, z$2.core.$strip>;
133
+ }, z$2.core.$strip>;
134
+ }, z$2.core.$strip>;
135
+ interface SendSlackInput extends z$2.infer<typeof sendSlackInputSchema> {
136
+ }
137
+ interface SendSlackOutput {
138
+ }
139
+
140
+ declare const sendSmsInputSchema: z.ZodObject<{
141
+ sms: z.ZodObject<{
142
+ message: z.ZodString;
143
+ to: z.ZodString;
144
+ }, z.core.$strip>;
145
+ metadata: z.ZodObject<{
146
+ userAgent: z.ZodOptional<z.ZodString>;
147
+ ip: z.ZodOptional<z.ZodUnion<[z.ZodIPv4, z.ZodIPv6]>>;
148
+ initiator: z.ZodObject<{
149
+ service: z.ZodString;
150
+ userId: z.ZodOptional<z.ZodString>;
151
+ }, z.core.$strip>;
152
+ }, z.core.$strip>;
153
+ }, z.core.$strip>;
154
+ interface SendSmsInput extends z.infer<typeof sendSmsInputSchema> {
155
+ }
156
+ interface SendSmsOutput {
157
+ }
158
+
159
+ interface IPushNotification {
160
+ }
161
+
162
+ interface NotificationQueueMessage {
163
+ type: 'email' | 'sms' | 'pushNotification' | 'slack';
164
+ metadata: {
165
+ userAgent?: string;
166
+ ip?: string;
167
+ initiator: {
168
+ service: string;
169
+ userId?: string;
170
+ };
171
+ };
172
+ payload: {
173
+ email?: IEmail;
174
+ sms?: ISms;
175
+ pushNotification?: IPushNotification;
176
+ slack?: ISlack;
177
+ };
178
+ }
179
+
180
+ interface ISms {
181
+ message: string;
182
+ to: string;
183
+ }
184
+
185
+ declare abstract class ISmsConnector {
186
+ static providerName: string;
187
+ ACCOUNT_ID: string;
188
+ AUTH_TOKEN: string;
189
+ SERVICE_ID: string;
190
+ protected constructor({ ACCOUNT_ID, AUTH_TOKEN, SERVICE_ID, }: {
191
+ ACCOUNT_ID: string;
192
+ AUTH_TOKEN: string;
193
+ SERVICE_ID: string;
194
+ });
195
+ abstract sendSms(sms: ISms): Promise<InternalError | void>;
196
+ }
197
+
198
+ interface ISlack {
199
+ message: string;
200
+ }
201
+
202
+ declare const auditLog: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
203
+ name: "audit_log";
204
+ schema: undefined;
205
+ columns: {
206
+ event: drizzle_orm_sqlite_core.SQLiteColumn<{
207
+ name: "event";
208
+ tableName: "audit_log";
209
+ dataType: "string";
210
+ columnType: "SQLiteText";
211
+ data: "EMAIL" | "SMS" | "PUSH_NOTIFICATION" | "SLACK";
212
+ driverParam: string;
213
+ notNull: true;
214
+ hasDefault: false;
215
+ isPrimaryKey: false;
216
+ isAutoincrement: false;
217
+ hasRuntimeDefault: false;
218
+ enumValues: [string, ...string[]];
219
+ baseColumn: never;
220
+ identity: undefined;
221
+ generated: undefined;
222
+ }, {}, {
223
+ length: number | undefined;
224
+ $type: "EMAIL" | "SMS" | "PUSH_NOTIFICATION" | "SLACK";
225
+ }>;
226
+ ip: drizzle_orm_sqlite_core.SQLiteColumn<{
227
+ name: "ip";
228
+ tableName: "audit_log";
229
+ dataType: "string";
230
+ columnType: "SQLiteText";
231
+ data: string;
232
+ driverParam: string;
233
+ notNull: false;
234
+ hasDefault: false;
235
+ isPrimaryKey: false;
236
+ isAutoincrement: false;
237
+ hasRuntimeDefault: false;
238
+ enumValues: [string, ...string[]];
239
+ baseColumn: never;
240
+ identity: undefined;
241
+ generated: undefined;
242
+ }, {}, {
243
+ length: number | undefined;
244
+ }>;
245
+ userAgent: drizzle_orm_sqlite_core.SQLiteColumn<{
246
+ name: "user_agent";
247
+ tableName: "audit_log";
248
+ dataType: "string";
249
+ columnType: "SQLiteText";
250
+ data: string;
251
+ driverParam: string;
252
+ notNull: false;
253
+ hasDefault: false;
254
+ isPrimaryKey: false;
255
+ isAutoincrement: false;
256
+ hasRuntimeDefault: false;
257
+ enumValues: [string, ...string[]];
258
+ baseColumn: never;
259
+ identity: undefined;
260
+ generated: undefined;
261
+ }, {}, {
262
+ length: number | undefined;
263
+ }>;
264
+ description: drizzle_orm_sqlite_core.SQLiteColumn<{
265
+ name: "description";
266
+ tableName: "audit_log";
267
+ dataType: "string";
268
+ columnType: "SQLiteText";
269
+ data: string;
270
+ driverParam: string;
271
+ notNull: false;
272
+ hasDefault: false;
273
+ isPrimaryKey: false;
274
+ isAutoincrement: false;
275
+ hasRuntimeDefault: false;
276
+ enumValues: [string, ...string[]];
277
+ baseColumn: never;
278
+ identity: undefined;
279
+ generated: undefined;
280
+ }, {}, {
281
+ length: number | undefined;
282
+ }>;
283
+ initiatorService: drizzle_orm_sqlite_core.SQLiteColumn<{
284
+ name: "initiator_service";
285
+ tableName: "audit_log";
286
+ dataType: "string";
287
+ columnType: "SQLiteText";
288
+ data: string;
289
+ driverParam: string;
290
+ notNull: true;
291
+ hasDefault: false;
292
+ isPrimaryKey: false;
293
+ isAutoincrement: false;
294
+ hasRuntimeDefault: false;
295
+ enumValues: [string, ...string[]];
296
+ baseColumn: never;
297
+ identity: undefined;
298
+ generated: undefined;
299
+ }, {}, {
300
+ length: number | undefined;
301
+ }>;
302
+ initiatorUserId: drizzle_orm_sqlite_core.SQLiteColumn<{
303
+ name: "initiator_user_id";
304
+ tableName: "audit_log";
305
+ dataType: "string";
306
+ columnType: "SQLiteText";
307
+ data: string;
308
+ driverParam: string;
309
+ notNull: false;
310
+ hasDefault: false;
311
+ isPrimaryKey: false;
312
+ isAutoincrement: false;
313
+ hasRuntimeDefault: false;
314
+ enumValues: [string, ...string[]];
315
+ baseColumn: never;
316
+ identity: undefined;
317
+ generated: undefined;
318
+ }, {}, {
319
+ length: number | undefined;
320
+ }>;
321
+ id: drizzle_orm_sqlite_core.SQLiteColumn<{
322
+ name: "id";
323
+ tableName: "audit_log";
324
+ dataType: "string";
325
+ columnType: "SQLiteText";
326
+ data: string;
327
+ driverParam: string;
328
+ notNull: true;
329
+ hasDefault: false;
330
+ isPrimaryKey: true;
331
+ isAutoincrement: false;
332
+ hasRuntimeDefault: false;
333
+ enumValues: [string, ...string[]];
334
+ baseColumn: never;
335
+ identity: undefined;
336
+ generated: undefined;
337
+ }, {}, {
338
+ length: number | undefined;
339
+ }>;
340
+ createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
341
+ name: "created_at";
342
+ tableName: "audit_log";
343
+ dataType: "date";
344
+ columnType: "SQLiteTimestamp";
345
+ data: Date;
346
+ driverParam: number;
347
+ notNull: false;
348
+ hasDefault: true;
349
+ isPrimaryKey: false;
350
+ isAutoincrement: false;
351
+ hasRuntimeDefault: false;
352
+ enumValues: undefined;
353
+ baseColumn: never;
354
+ identity: undefined;
355
+ generated: undefined;
356
+ }, {}, {}>;
357
+ updatedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
358
+ name: "updated_at";
359
+ tableName: "audit_log";
360
+ dataType: "date";
361
+ columnType: "SQLiteTimestamp";
362
+ data: Date;
363
+ driverParam: number;
364
+ notNull: false;
365
+ hasDefault: true;
366
+ isPrimaryKey: false;
367
+ isAutoincrement: false;
368
+ hasRuntimeDefault: false;
369
+ enumValues: undefined;
370
+ baseColumn: never;
371
+ identity: undefined;
372
+ generated: undefined;
373
+ }, {}, {}>;
374
+ deletedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
375
+ name: "deleted_at";
376
+ tableName: "audit_log";
377
+ dataType: "date";
378
+ columnType: "SQLiteTimestamp";
379
+ data: Date;
380
+ driverParam: number;
381
+ notNull: false;
382
+ hasDefault: true;
383
+ isPrimaryKey: false;
384
+ isAutoincrement: false;
385
+ hasRuntimeDefault: false;
386
+ enumValues: undefined;
387
+ baseColumn: never;
388
+ identity: undefined;
389
+ generated: undefined;
390
+ }, {}, {}>;
391
+ };
392
+ dialect: "sqlite";
393
+ }>;
394
+
395
+ declare const schema_auditLog: typeof auditLog;
396
+ declare namespace schema {
397
+ export {
398
+ schema_auditLog as auditLog,
399
+ };
400
+ }
401
+
402
+ declare const tables: typeof schema;
403
+
404
+ declare class SlackConnector {
405
+ private webhooks;
406
+ constructor(webhooks: string[]);
407
+ sendNotificationToAllSlack(message: string): Promise<void>;
408
+ }
409
+
410
+ declare const NotificationServiceBase_base: (abstract new (ctx: ExecutionContext, env: NotificationEnv) => WorkerEntrypoint<NotificationEnv>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
411
+ declare class NotificationServiceBase extends NotificationServiceBase_base {
412
+ readonly name: string;
413
+ readonly slackConnector: SlackConnector;
414
+ protected emailConnector: IEmailConnector;
415
+ protected smsConnector: ISmsConnector;
416
+ readonly db: DrizzleD1Database<typeof tables>;
417
+ constructor(ctx: ExecutionContext, env: NotificationEnv);
418
+ queue(batch: MessageBatch<NotificationQueueMessage>): Promise<void>;
419
+ protected _sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
420
+ protected _sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
421
+ sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
422
+ sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
423
+ protected _sendPushNotification(): Promise<IRPCResponse<{}>>;
424
+ sendSlackNotification(input: SendSlackInput): Promise<IRPCResponse<SendSlackOutput>>;
425
+ }
426
+ declare function defineNotificationService(): new (ctx: ExecutionContext, env: NotificationEnv) => NotificationServiceBase;
2
427
 
3
428
  declare const _default: new (ctx: ExecutionContext, env: NotificationEnv) => WorkerEntrypoint<NotificationEnv>;
4
429
 
430
+ // @ts-ignore
5
431
  export = _default;
432
+ export { defineNotificationService };
package/dist/worker.d.mts CHANGED
@@ -1,5 +1,430 @@
1
+ import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
2
+ import { InternalError, IRPCResponse } from '@develit-io/backend-sdk';
3
+ import z$1, { z } from 'zod';
4
+ import { z as z$2 } from 'zod/v4';
5
+ import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
1
6
  import { WorkerEntrypoint } from 'cloudflare:workers';
7
+ import { DrizzleD1Database } from 'drizzle-orm/d1';
8
+
9
+ declare const iContactSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
10
+ email: z.ZodString;
11
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
12
+ }, z.core.$strip>]>;
13
+ declare const iEmailSchema: z.ZodObject<{
14
+ to: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
15
+ email: z.ZodString;
16
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
17
+ }, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
18
+ email: z.ZodString;
19
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
20
+ }, z.core.$strip>]>>]>;
21
+ replyTo: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
22
+ email: z.ZodString;
23
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
24
+ }, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
25
+ email: z.ZodString;
26
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
27
+ }, z.core.$strip>]>>]>>;
28
+ cc: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
29
+ email: z.ZodString;
30
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
31
+ }, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
32
+ email: z.ZodString;
33
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
34
+ }, z.core.$strip>]>>]>>;
35
+ bcc: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
36
+ email: z.ZodString;
37
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
38
+ }, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
39
+ email: z.ZodString;
40
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
41
+ }, z.core.$strip>]>>]>>;
42
+ from: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
43
+ email: z.ZodString;
44
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
45
+ }, z.core.$strip>]>>;
46
+ subject: z.ZodString;
47
+ text: z.ZodOptional<z.ZodString>;
48
+ html: z.ZodOptional<z.ZodString>;
49
+ templateId: z.ZodOptional<z.ZodNumber>;
50
+ templateVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
51
+ }, z.core.$strip>;
52
+ type IContact = z.infer<typeof iContactSchema>;
53
+ type IEmail = z.infer<typeof iEmailSchema>;
54
+
55
+ declare abstract class IEmailConnector {
56
+ static providerName: string;
57
+ API_KEY: string;
58
+ SMTP_HOST: string;
59
+ SENDER: IContact;
60
+ protected constructor({ API_KEY, SMTP_HOST, SENDER, }: {
61
+ API_KEY: string;
62
+ SMTP_HOST: string;
63
+ SENDER: IContact;
64
+ });
65
+ abstract sendEmail(email: IEmail): Promise<Response | null>;
66
+ }
67
+
68
+ declare const sendEmailInputSchema: z$1.ZodObject<{
69
+ email: z$1.ZodObject<{
70
+ to: z$1.ZodUnion<readonly [z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
71
+ email: z$1.ZodString;
72
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
73
+ }, z$1.core.$strip>]>, z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
74
+ email: z$1.ZodString;
75
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
76
+ }, z$1.core.$strip>]>>]>;
77
+ replyTo: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
78
+ email: z$1.ZodString;
79
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
80
+ }, z$1.core.$strip>]>, z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
81
+ email: z$1.ZodString;
82
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
83
+ }, z$1.core.$strip>]>>]>>;
84
+ cc: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
85
+ email: z$1.ZodString;
86
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
87
+ }, z$1.core.$strip>]>, z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
88
+ email: z$1.ZodString;
89
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
90
+ }, z$1.core.$strip>]>>]>>;
91
+ bcc: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
92
+ email: z$1.ZodString;
93
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
94
+ }, z$1.core.$strip>]>, z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
95
+ email: z$1.ZodString;
96
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
97
+ }, z$1.core.$strip>]>>]>>;
98
+ from: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
99
+ email: z$1.ZodString;
100
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
101
+ }, z$1.core.$strip>]>>;
102
+ subject: z$1.ZodString;
103
+ text: z$1.ZodOptional<z$1.ZodString>;
104
+ html: z$1.ZodOptional<z$1.ZodString>;
105
+ templateId: z$1.ZodOptional<z$1.ZodNumber>;
106
+ templateVariables: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
107
+ }, z$1.core.$strip>;
108
+ metadata: z$1.ZodObject<{
109
+ userAgent: z$1.ZodOptional<z$1.ZodString>;
110
+ ip: z$1.ZodOptional<z$1.ZodUnion<[z$1.ZodIPv4, z$1.ZodIPv6]>>;
111
+ initiator: z$1.ZodObject<{
112
+ service: z$1.ZodString;
113
+ userId: z$1.ZodOptional<z$1.ZodString>;
114
+ }, z$1.core.$strip>;
115
+ }, z$1.core.$strip>;
116
+ }, z$1.core.$strip>;
117
+ interface SendEmailInput extends z$1.infer<typeof sendEmailInputSchema> {
118
+ }
119
+ interface SendEmailOutput {
120
+ }
121
+
122
+ declare const sendSlackInputSchema: z$2.ZodObject<{
123
+ slack: z$2.ZodObject<{
124
+ message: z$2.ZodString;
125
+ }, z$2.core.$strip>;
126
+ metadata: z$2.ZodObject<{
127
+ userAgent: z$2.ZodOptional<z$2.ZodString>;
128
+ ip: z$2.ZodOptional<z$2.ZodUnion<[z$2.ZodIPv4, z$2.ZodIPv6]>>;
129
+ initiator: z$2.ZodObject<{
130
+ service: z$2.ZodString;
131
+ userId: z$2.ZodOptional<z$2.ZodString>;
132
+ }, z$2.core.$strip>;
133
+ }, z$2.core.$strip>;
134
+ }, z$2.core.$strip>;
135
+ interface SendSlackInput extends z$2.infer<typeof sendSlackInputSchema> {
136
+ }
137
+ interface SendSlackOutput {
138
+ }
139
+
140
+ declare const sendSmsInputSchema: z.ZodObject<{
141
+ sms: z.ZodObject<{
142
+ message: z.ZodString;
143
+ to: z.ZodString;
144
+ }, z.core.$strip>;
145
+ metadata: z.ZodObject<{
146
+ userAgent: z.ZodOptional<z.ZodString>;
147
+ ip: z.ZodOptional<z.ZodUnion<[z.ZodIPv4, z.ZodIPv6]>>;
148
+ initiator: z.ZodObject<{
149
+ service: z.ZodString;
150
+ userId: z.ZodOptional<z.ZodString>;
151
+ }, z.core.$strip>;
152
+ }, z.core.$strip>;
153
+ }, z.core.$strip>;
154
+ interface SendSmsInput extends z.infer<typeof sendSmsInputSchema> {
155
+ }
156
+ interface SendSmsOutput {
157
+ }
158
+
159
+ interface IPushNotification {
160
+ }
161
+
162
+ interface NotificationQueueMessage {
163
+ type: 'email' | 'sms' | 'pushNotification' | 'slack';
164
+ metadata: {
165
+ userAgent?: string;
166
+ ip?: string;
167
+ initiator: {
168
+ service: string;
169
+ userId?: string;
170
+ };
171
+ };
172
+ payload: {
173
+ email?: IEmail;
174
+ sms?: ISms;
175
+ pushNotification?: IPushNotification;
176
+ slack?: ISlack;
177
+ };
178
+ }
179
+
180
+ interface ISms {
181
+ message: string;
182
+ to: string;
183
+ }
184
+
185
+ declare abstract class ISmsConnector {
186
+ static providerName: string;
187
+ ACCOUNT_ID: string;
188
+ AUTH_TOKEN: string;
189
+ SERVICE_ID: string;
190
+ protected constructor({ ACCOUNT_ID, AUTH_TOKEN, SERVICE_ID, }: {
191
+ ACCOUNT_ID: string;
192
+ AUTH_TOKEN: string;
193
+ SERVICE_ID: string;
194
+ });
195
+ abstract sendSms(sms: ISms): Promise<InternalError | void>;
196
+ }
197
+
198
+ interface ISlack {
199
+ message: string;
200
+ }
201
+
202
+ declare const auditLog: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
203
+ name: "audit_log";
204
+ schema: undefined;
205
+ columns: {
206
+ event: drizzle_orm_sqlite_core.SQLiteColumn<{
207
+ name: "event";
208
+ tableName: "audit_log";
209
+ dataType: "string";
210
+ columnType: "SQLiteText";
211
+ data: "EMAIL" | "SMS" | "PUSH_NOTIFICATION" | "SLACK";
212
+ driverParam: string;
213
+ notNull: true;
214
+ hasDefault: false;
215
+ isPrimaryKey: false;
216
+ isAutoincrement: false;
217
+ hasRuntimeDefault: false;
218
+ enumValues: [string, ...string[]];
219
+ baseColumn: never;
220
+ identity: undefined;
221
+ generated: undefined;
222
+ }, {}, {
223
+ length: number | undefined;
224
+ $type: "EMAIL" | "SMS" | "PUSH_NOTIFICATION" | "SLACK";
225
+ }>;
226
+ ip: drizzle_orm_sqlite_core.SQLiteColumn<{
227
+ name: "ip";
228
+ tableName: "audit_log";
229
+ dataType: "string";
230
+ columnType: "SQLiteText";
231
+ data: string;
232
+ driverParam: string;
233
+ notNull: false;
234
+ hasDefault: false;
235
+ isPrimaryKey: false;
236
+ isAutoincrement: false;
237
+ hasRuntimeDefault: false;
238
+ enumValues: [string, ...string[]];
239
+ baseColumn: never;
240
+ identity: undefined;
241
+ generated: undefined;
242
+ }, {}, {
243
+ length: number | undefined;
244
+ }>;
245
+ userAgent: drizzle_orm_sqlite_core.SQLiteColumn<{
246
+ name: "user_agent";
247
+ tableName: "audit_log";
248
+ dataType: "string";
249
+ columnType: "SQLiteText";
250
+ data: string;
251
+ driverParam: string;
252
+ notNull: false;
253
+ hasDefault: false;
254
+ isPrimaryKey: false;
255
+ isAutoincrement: false;
256
+ hasRuntimeDefault: false;
257
+ enumValues: [string, ...string[]];
258
+ baseColumn: never;
259
+ identity: undefined;
260
+ generated: undefined;
261
+ }, {}, {
262
+ length: number | undefined;
263
+ }>;
264
+ description: drizzle_orm_sqlite_core.SQLiteColumn<{
265
+ name: "description";
266
+ tableName: "audit_log";
267
+ dataType: "string";
268
+ columnType: "SQLiteText";
269
+ data: string;
270
+ driverParam: string;
271
+ notNull: false;
272
+ hasDefault: false;
273
+ isPrimaryKey: false;
274
+ isAutoincrement: false;
275
+ hasRuntimeDefault: false;
276
+ enumValues: [string, ...string[]];
277
+ baseColumn: never;
278
+ identity: undefined;
279
+ generated: undefined;
280
+ }, {}, {
281
+ length: number | undefined;
282
+ }>;
283
+ initiatorService: drizzle_orm_sqlite_core.SQLiteColumn<{
284
+ name: "initiator_service";
285
+ tableName: "audit_log";
286
+ dataType: "string";
287
+ columnType: "SQLiteText";
288
+ data: string;
289
+ driverParam: string;
290
+ notNull: true;
291
+ hasDefault: false;
292
+ isPrimaryKey: false;
293
+ isAutoincrement: false;
294
+ hasRuntimeDefault: false;
295
+ enumValues: [string, ...string[]];
296
+ baseColumn: never;
297
+ identity: undefined;
298
+ generated: undefined;
299
+ }, {}, {
300
+ length: number | undefined;
301
+ }>;
302
+ initiatorUserId: drizzle_orm_sqlite_core.SQLiteColumn<{
303
+ name: "initiator_user_id";
304
+ tableName: "audit_log";
305
+ dataType: "string";
306
+ columnType: "SQLiteText";
307
+ data: string;
308
+ driverParam: string;
309
+ notNull: false;
310
+ hasDefault: false;
311
+ isPrimaryKey: false;
312
+ isAutoincrement: false;
313
+ hasRuntimeDefault: false;
314
+ enumValues: [string, ...string[]];
315
+ baseColumn: never;
316
+ identity: undefined;
317
+ generated: undefined;
318
+ }, {}, {
319
+ length: number | undefined;
320
+ }>;
321
+ id: drizzle_orm_sqlite_core.SQLiteColumn<{
322
+ name: "id";
323
+ tableName: "audit_log";
324
+ dataType: "string";
325
+ columnType: "SQLiteText";
326
+ data: string;
327
+ driverParam: string;
328
+ notNull: true;
329
+ hasDefault: false;
330
+ isPrimaryKey: true;
331
+ isAutoincrement: false;
332
+ hasRuntimeDefault: false;
333
+ enumValues: [string, ...string[]];
334
+ baseColumn: never;
335
+ identity: undefined;
336
+ generated: undefined;
337
+ }, {}, {
338
+ length: number | undefined;
339
+ }>;
340
+ createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
341
+ name: "created_at";
342
+ tableName: "audit_log";
343
+ dataType: "date";
344
+ columnType: "SQLiteTimestamp";
345
+ data: Date;
346
+ driverParam: number;
347
+ notNull: false;
348
+ hasDefault: true;
349
+ isPrimaryKey: false;
350
+ isAutoincrement: false;
351
+ hasRuntimeDefault: false;
352
+ enumValues: undefined;
353
+ baseColumn: never;
354
+ identity: undefined;
355
+ generated: undefined;
356
+ }, {}, {}>;
357
+ updatedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
358
+ name: "updated_at";
359
+ tableName: "audit_log";
360
+ dataType: "date";
361
+ columnType: "SQLiteTimestamp";
362
+ data: Date;
363
+ driverParam: number;
364
+ notNull: false;
365
+ hasDefault: true;
366
+ isPrimaryKey: false;
367
+ isAutoincrement: false;
368
+ hasRuntimeDefault: false;
369
+ enumValues: undefined;
370
+ baseColumn: never;
371
+ identity: undefined;
372
+ generated: undefined;
373
+ }, {}, {}>;
374
+ deletedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
375
+ name: "deleted_at";
376
+ tableName: "audit_log";
377
+ dataType: "date";
378
+ columnType: "SQLiteTimestamp";
379
+ data: Date;
380
+ driverParam: number;
381
+ notNull: false;
382
+ hasDefault: true;
383
+ isPrimaryKey: false;
384
+ isAutoincrement: false;
385
+ hasRuntimeDefault: false;
386
+ enumValues: undefined;
387
+ baseColumn: never;
388
+ identity: undefined;
389
+ generated: undefined;
390
+ }, {}, {}>;
391
+ };
392
+ dialect: "sqlite";
393
+ }>;
394
+
395
+ declare const schema_auditLog: typeof auditLog;
396
+ declare namespace schema {
397
+ export {
398
+ schema_auditLog as auditLog,
399
+ };
400
+ }
401
+
402
+ declare const tables: typeof schema;
403
+
404
+ declare class SlackConnector {
405
+ private webhooks;
406
+ constructor(webhooks: string[]);
407
+ sendNotificationToAllSlack(message: string): Promise<void>;
408
+ }
409
+
410
+ declare const NotificationServiceBase_base: (abstract new (ctx: ExecutionContext, env: NotificationEnv) => WorkerEntrypoint<NotificationEnv>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
411
+ declare class NotificationServiceBase extends NotificationServiceBase_base {
412
+ readonly name: string;
413
+ readonly slackConnector: SlackConnector;
414
+ protected emailConnector: IEmailConnector;
415
+ protected smsConnector: ISmsConnector;
416
+ readonly db: DrizzleD1Database<typeof tables>;
417
+ constructor(ctx: ExecutionContext, env: NotificationEnv);
418
+ queue(batch: MessageBatch<NotificationQueueMessage>): Promise<void>;
419
+ protected _sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
420
+ protected _sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
421
+ sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
422
+ sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
423
+ protected _sendPushNotification(): Promise<IRPCResponse<{}>>;
424
+ sendSlackNotification(input: SendSlackInput): Promise<IRPCResponse<SendSlackOutput>>;
425
+ }
426
+ declare function defineNotificationService(): new (ctx: ExecutionContext, env: NotificationEnv) => NotificationServiceBase;
2
427
 
3
428
  declare const _default: new (ctx: ExecutionContext, env: NotificationEnv) => WorkerEntrypoint<NotificationEnv>;
4
429
 
5
- export { _default as default };
430
+ export { _default as default, defineNotificationService };
package/dist/worker.d.ts CHANGED
@@ -1,5 +1,432 @@
1
+ import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
2
+ import { InternalError, IRPCResponse } from '@develit-io/backend-sdk';
3
+ import z$1, { z } from 'zod';
4
+ import { z as z$2 } from 'zod/v4';
5
+ import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
1
6
  import { WorkerEntrypoint } from 'cloudflare:workers';
7
+ import { DrizzleD1Database } from 'drizzle-orm/d1';
8
+
9
+ declare const iContactSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
10
+ email: z.ZodString;
11
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
12
+ }, z.core.$strip>]>;
13
+ declare const iEmailSchema: z.ZodObject<{
14
+ to: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
15
+ email: z.ZodString;
16
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
17
+ }, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
18
+ email: z.ZodString;
19
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
20
+ }, z.core.$strip>]>>]>;
21
+ replyTo: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
22
+ email: z.ZodString;
23
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
24
+ }, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
25
+ email: z.ZodString;
26
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
27
+ }, z.core.$strip>]>>]>>;
28
+ cc: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
29
+ email: z.ZodString;
30
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
31
+ }, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
32
+ email: z.ZodString;
33
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
34
+ }, z.core.$strip>]>>]>>;
35
+ bcc: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
36
+ email: z.ZodString;
37
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
38
+ }, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
39
+ email: z.ZodString;
40
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
41
+ }, z.core.$strip>]>>]>>;
42
+ from: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
43
+ email: z.ZodString;
44
+ name: z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>;
45
+ }, z.core.$strip>]>>;
46
+ subject: z.ZodString;
47
+ text: z.ZodOptional<z.ZodString>;
48
+ html: z.ZodOptional<z.ZodString>;
49
+ templateId: z.ZodOptional<z.ZodNumber>;
50
+ templateVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
51
+ }, z.core.$strip>;
52
+ type IContact = z.infer<typeof iContactSchema>;
53
+ type IEmail = z.infer<typeof iEmailSchema>;
54
+
55
+ declare abstract class IEmailConnector {
56
+ static providerName: string;
57
+ API_KEY: string;
58
+ SMTP_HOST: string;
59
+ SENDER: IContact;
60
+ protected constructor({ API_KEY, SMTP_HOST, SENDER, }: {
61
+ API_KEY: string;
62
+ SMTP_HOST: string;
63
+ SENDER: IContact;
64
+ });
65
+ abstract sendEmail(email: IEmail): Promise<Response | null>;
66
+ }
67
+
68
+ declare const sendEmailInputSchema: z$1.ZodObject<{
69
+ email: z$1.ZodObject<{
70
+ to: z$1.ZodUnion<readonly [z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
71
+ email: z$1.ZodString;
72
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
73
+ }, z$1.core.$strip>]>, z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
74
+ email: z$1.ZodString;
75
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
76
+ }, z$1.core.$strip>]>>]>;
77
+ replyTo: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
78
+ email: z$1.ZodString;
79
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
80
+ }, z$1.core.$strip>]>, z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
81
+ email: z$1.ZodString;
82
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
83
+ }, z$1.core.$strip>]>>]>>;
84
+ cc: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
85
+ email: z$1.ZodString;
86
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
87
+ }, z$1.core.$strip>]>, z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
88
+ email: z$1.ZodString;
89
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
90
+ }, z$1.core.$strip>]>>]>>;
91
+ bcc: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
92
+ email: z$1.ZodString;
93
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
94
+ }, z$1.core.$strip>]>, z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
95
+ email: z$1.ZodString;
96
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
97
+ }, z$1.core.$strip>]>>]>>;
98
+ from: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
99
+ email: z$1.ZodString;
100
+ name: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodUndefined]>;
101
+ }, z$1.core.$strip>]>>;
102
+ subject: z$1.ZodString;
103
+ text: z$1.ZodOptional<z$1.ZodString>;
104
+ html: z$1.ZodOptional<z$1.ZodString>;
105
+ templateId: z$1.ZodOptional<z$1.ZodNumber>;
106
+ templateVariables: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
107
+ }, z$1.core.$strip>;
108
+ metadata: z$1.ZodObject<{
109
+ userAgent: z$1.ZodOptional<z$1.ZodString>;
110
+ ip: z$1.ZodOptional<z$1.ZodUnion<[z$1.ZodIPv4, z$1.ZodIPv6]>>;
111
+ initiator: z$1.ZodObject<{
112
+ service: z$1.ZodString;
113
+ userId: z$1.ZodOptional<z$1.ZodString>;
114
+ }, z$1.core.$strip>;
115
+ }, z$1.core.$strip>;
116
+ }, z$1.core.$strip>;
117
+ interface SendEmailInput extends z$1.infer<typeof sendEmailInputSchema> {
118
+ }
119
+ interface SendEmailOutput {
120
+ }
121
+
122
+ declare const sendSlackInputSchema: z$2.ZodObject<{
123
+ slack: z$2.ZodObject<{
124
+ message: z$2.ZodString;
125
+ }, z$2.core.$strip>;
126
+ metadata: z$2.ZodObject<{
127
+ userAgent: z$2.ZodOptional<z$2.ZodString>;
128
+ ip: z$2.ZodOptional<z$2.ZodUnion<[z$2.ZodIPv4, z$2.ZodIPv6]>>;
129
+ initiator: z$2.ZodObject<{
130
+ service: z$2.ZodString;
131
+ userId: z$2.ZodOptional<z$2.ZodString>;
132
+ }, z$2.core.$strip>;
133
+ }, z$2.core.$strip>;
134
+ }, z$2.core.$strip>;
135
+ interface SendSlackInput extends z$2.infer<typeof sendSlackInputSchema> {
136
+ }
137
+ interface SendSlackOutput {
138
+ }
139
+
140
+ declare const sendSmsInputSchema: z.ZodObject<{
141
+ sms: z.ZodObject<{
142
+ message: z.ZodString;
143
+ to: z.ZodString;
144
+ }, z.core.$strip>;
145
+ metadata: z.ZodObject<{
146
+ userAgent: z.ZodOptional<z.ZodString>;
147
+ ip: z.ZodOptional<z.ZodUnion<[z.ZodIPv4, z.ZodIPv6]>>;
148
+ initiator: z.ZodObject<{
149
+ service: z.ZodString;
150
+ userId: z.ZodOptional<z.ZodString>;
151
+ }, z.core.$strip>;
152
+ }, z.core.$strip>;
153
+ }, z.core.$strip>;
154
+ interface SendSmsInput extends z.infer<typeof sendSmsInputSchema> {
155
+ }
156
+ interface SendSmsOutput {
157
+ }
158
+
159
+ interface IPushNotification {
160
+ }
161
+
162
+ interface NotificationQueueMessage {
163
+ type: 'email' | 'sms' | 'pushNotification' | 'slack';
164
+ metadata: {
165
+ userAgent?: string;
166
+ ip?: string;
167
+ initiator: {
168
+ service: string;
169
+ userId?: string;
170
+ };
171
+ };
172
+ payload: {
173
+ email?: IEmail;
174
+ sms?: ISms;
175
+ pushNotification?: IPushNotification;
176
+ slack?: ISlack;
177
+ };
178
+ }
179
+
180
+ interface ISms {
181
+ message: string;
182
+ to: string;
183
+ }
184
+
185
+ declare abstract class ISmsConnector {
186
+ static providerName: string;
187
+ ACCOUNT_ID: string;
188
+ AUTH_TOKEN: string;
189
+ SERVICE_ID: string;
190
+ protected constructor({ ACCOUNT_ID, AUTH_TOKEN, SERVICE_ID, }: {
191
+ ACCOUNT_ID: string;
192
+ AUTH_TOKEN: string;
193
+ SERVICE_ID: string;
194
+ });
195
+ abstract sendSms(sms: ISms): Promise<InternalError | void>;
196
+ }
197
+
198
+ interface ISlack {
199
+ message: string;
200
+ }
201
+
202
+ declare const auditLog: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
203
+ name: "audit_log";
204
+ schema: undefined;
205
+ columns: {
206
+ event: drizzle_orm_sqlite_core.SQLiteColumn<{
207
+ name: "event";
208
+ tableName: "audit_log";
209
+ dataType: "string";
210
+ columnType: "SQLiteText";
211
+ data: "EMAIL" | "SMS" | "PUSH_NOTIFICATION" | "SLACK";
212
+ driverParam: string;
213
+ notNull: true;
214
+ hasDefault: false;
215
+ isPrimaryKey: false;
216
+ isAutoincrement: false;
217
+ hasRuntimeDefault: false;
218
+ enumValues: [string, ...string[]];
219
+ baseColumn: never;
220
+ identity: undefined;
221
+ generated: undefined;
222
+ }, {}, {
223
+ length: number | undefined;
224
+ $type: "EMAIL" | "SMS" | "PUSH_NOTIFICATION" | "SLACK";
225
+ }>;
226
+ ip: drizzle_orm_sqlite_core.SQLiteColumn<{
227
+ name: "ip";
228
+ tableName: "audit_log";
229
+ dataType: "string";
230
+ columnType: "SQLiteText";
231
+ data: string;
232
+ driverParam: string;
233
+ notNull: false;
234
+ hasDefault: false;
235
+ isPrimaryKey: false;
236
+ isAutoincrement: false;
237
+ hasRuntimeDefault: false;
238
+ enumValues: [string, ...string[]];
239
+ baseColumn: never;
240
+ identity: undefined;
241
+ generated: undefined;
242
+ }, {}, {
243
+ length: number | undefined;
244
+ }>;
245
+ userAgent: drizzle_orm_sqlite_core.SQLiteColumn<{
246
+ name: "user_agent";
247
+ tableName: "audit_log";
248
+ dataType: "string";
249
+ columnType: "SQLiteText";
250
+ data: string;
251
+ driverParam: string;
252
+ notNull: false;
253
+ hasDefault: false;
254
+ isPrimaryKey: false;
255
+ isAutoincrement: false;
256
+ hasRuntimeDefault: false;
257
+ enumValues: [string, ...string[]];
258
+ baseColumn: never;
259
+ identity: undefined;
260
+ generated: undefined;
261
+ }, {}, {
262
+ length: number | undefined;
263
+ }>;
264
+ description: drizzle_orm_sqlite_core.SQLiteColumn<{
265
+ name: "description";
266
+ tableName: "audit_log";
267
+ dataType: "string";
268
+ columnType: "SQLiteText";
269
+ data: string;
270
+ driverParam: string;
271
+ notNull: false;
272
+ hasDefault: false;
273
+ isPrimaryKey: false;
274
+ isAutoincrement: false;
275
+ hasRuntimeDefault: false;
276
+ enumValues: [string, ...string[]];
277
+ baseColumn: never;
278
+ identity: undefined;
279
+ generated: undefined;
280
+ }, {}, {
281
+ length: number | undefined;
282
+ }>;
283
+ initiatorService: drizzle_orm_sqlite_core.SQLiteColumn<{
284
+ name: "initiator_service";
285
+ tableName: "audit_log";
286
+ dataType: "string";
287
+ columnType: "SQLiteText";
288
+ data: string;
289
+ driverParam: string;
290
+ notNull: true;
291
+ hasDefault: false;
292
+ isPrimaryKey: false;
293
+ isAutoincrement: false;
294
+ hasRuntimeDefault: false;
295
+ enumValues: [string, ...string[]];
296
+ baseColumn: never;
297
+ identity: undefined;
298
+ generated: undefined;
299
+ }, {}, {
300
+ length: number | undefined;
301
+ }>;
302
+ initiatorUserId: drizzle_orm_sqlite_core.SQLiteColumn<{
303
+ name: "initiator_user_id";
304
+ tableName: "audit_log";
305
+ dataType: "string";
306
+ columnType: "SQLiteText";
307
+ data: string;
308
+ driverParam: string;
309
+ notNull: false;
310
+ hasDefault: false;
311
+ isPrimaryKey: false;
312
+ isAutoincrement: false;
313
+ hasRuntimeDefault: false;
314
+ enumValues: [string, ...string[]];
315
+ baseColumn: never;
316
+ identity: undefined;
317
+ generated: undefined;
318
+ }, {}, {
319
+ length: number | undefined;
320
+ }>;
321
+ id: drizzle_orm_sqlite_core.SQLiteColumn<{
322
+ name: "id";
323
+ tableName: "audit_log";
324
+ dataType: "string";
325
+ columnType: "SQLiteText";
326
+ data: string;
327
+ driverParam: string;
328
+ notNull: true;
329
+ hasDefault: false;
330
+ isPrimaryKey: true;
331
+ isAutoincrement: false;
332
+ hasRuntimeDefault: false;
333
+ enumValues: [string, ...string[]];
334
+ baseColumn: never;
335
+ identity: undefined;
336
+ generated: undefined;
337
+ }, {}, {
338
+ length: number | undefined;
339
+ }>;
340
+ createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
341
+ name: "created_at";
342
+ tableName: "audit_log";
343
+ dataType: "date";
344
+ columnType: "SQLiteTimestamp";
345
+ data: Date;
346
+ driverParam: number;
347
+ notNull: false;
348
+ hasDefault: true;
349
+ isPrimaryKey: false;
350
+ isAutoincrement: false;
351
+ hasRuntimeDefault: false;
352
+ enumValues: undefined;
353
+ baseColumn: never;
354
+ identity: undefined;
355
+ generated: undefined;
356
+ }, {}, {}>;
357
+ updatedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
358
+ name: "updated_at";
359
+ tableName: "audit_log";
360
+ dataType: "date";
361
+ columnType: "SQLiteTimestamp";
362
+ data: Date;
363
+ driverParam: number;
364
+ notNull: false;
365
+ hasDefault: true;
366
+ isPrimaryKey: false;
367
+ isAutoincrement: false;
368
+ hasRuntimeDefault: false;
369
+ enumValues: undefined;
370
+ baseColumn: never;
371
+ identity: undefined;
372
+ generated: undefined;
373
+ }, {}, {}>;
374
+ deletedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
375
+ name: "deleted_at";
376
+ tableName: "audit_log";
377
+ dataType: "date";
378
+ columnType: "SQLiteTimestamp";
379
+ data: Date;
380
+ driverParam: number;
381
+ notNull: false;
382
+ hasDefault: true;
383
+ isPrimaryKey: false;
384
+ isAutoincrement: false;
385
+ hasRuntimeDefault: false;
386
+ enumValues: undefined;
387
+ baseColumn: never;
388
+ identity: undefined;
389
+ generated: undefined;
390
+ }, {}, {}>;
391
+ };
392
+ dialect: "sqlite";
393
+ }>;
394
+
395
+ declare const schema_auditLog: typeof auditLog;
396
+ declare namespace schema {
397
+ export {
398
+ schema_auditLog as auditLog,
399
+ };
400
+ }
401
+
402
+ declare const tables: typeof schema;
403
+
404
+ declare class SlackConnector {
405
+ private webhooks;
406
+ constructor(webhooks: string[]);
407
+ sendNotificationToAllSlack(message: string): Promise<void>;
408
+ }
409
+
410
+ declare const NotificationServiceBase_base: (abstract new (ctx: ExecutionContext, env: NotificationEnv) => WorkerEntrypoint<NotificationEnv>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
411
+ declare class NotificationServiceBase extends NotificationServiceBase_base {
412
+ readonly name: string;
413
+ readonly slackConnector: SlackConnector;
414
+ protected emailConnector: IEmailConnector;
415
+ protected smsConnector: ISmsConnector;
416
+ readonly db: DrizzleD1Database<typeof tables>;
417
+ constructor(ctx: ExecutionContext, env: NotificationEnv);
418
+ queue(batch: MessageBatch<NotificationQueueMessage>): Promise<void>;
419
+ protected _sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
420
+ protected _sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
421
+ sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
422
+ sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
423
+ protected _sendPushNotification(): Promise<IRPCResponse<{}>>;
424
+ sendSlackNotification(input: SendSlackInput): Promise<IRPCResponse<SendSlackOutput>>;
425
+ }
426
+ declare function defineNotificationService(): new (ctx: ExecutionContext, env: NotificationEnv) => NotificationServiceBase;
2
427
 
3
428
  declare const _default: new (ctx: ExecutionContext, env: NotificationEnv) => WorkerEntrypoint<NotificationEnv>;
4
429
 
430
+ // @ts-ignore
5
431
  export = _default;
432
+ export { defineNotificationService };
package/dist/worker.mjs CHANGED
@@ -552,4 +552,4 @@ function defineNotificationService() {
552
552
 
553
553
  const NotificationService = defineNotificationService();
554
554
 
555
- export { NotificationService as default };
555
+ export { NotificationService as default, defineNotificationService };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-services/notification",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "author": "Develit.io s.r.o.",
5
5
  "type": "module",
6
6
  "exports": {