@develit-services/notification 0.0.4 → 0.0.6

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/src.d.ts CHANGED
@@ -1,204 +1,3 @@
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';
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
1
  interface NotificationServiceEnvironmentConfig {
203
2
  queue?: {
204
3
  max_batch_size?: number;
@@ -230,232 +29,6 @@ interface NotificationServiceWranglerConfig {
230
29
  };
231
30
  }
232
31
 
233
- declare const auditLog: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
234
- name: "audit_log";
235
- schema: undefined;
236
- columns: {
237
- event: drizzle_orm_sqlite_core.SQLiteColumn<{
238
- name: "event";
239
- tableName: "audit_log";
240
- dataType: "string";
241
- columnType: "SQLiteText";
242
- data: "EMAIL" | "SMS" | "PUSH_NOTIFICATION" | "SLACK";
243
- driverParam: string;
244
- notNull: true;
245
- hasDefault: false;
246
- isPrimaryKey: false;
247
- isAutoincrement: false;
248
- hasRuntimeDefault: false;
249
- enumValues: [string, ...string[]];
250
- baseColumn: never;
251
- identity: undefined;
252
- generated: undefined;
253
- }, {}, {
254
- length: number | undefined;
255
- $type: "EMAIL" | "SMS" | "PUSH_NOTIFICATION" | "SLACK";
256
- }>;
257
- ip: drizzle_orm_sqlite_core.SQLiteColumn<{
258
- name: "ip";
259
- tableName: "audit_log";
260
- dataType: "string";
261
- columnType: "SQLiteText";
262
- data: string;
263
- driverParam: string;
264
- notNull: false;
265
- hasDefault: false;
266
- isPrimaryKey: false;
267
- isAutoincrement: false;
268
- hasRuntimeDefault: false;
269
- enumValues: [string, ...string[]];
270
- baseColumn: never;
271
- identity: undefined;
272
- generated: undefined;
273
- }, {}, {
274
- length: number | undefined;
275
- }>;
276
- userAgent: drizzle_orm_sqlite_core.SQLiteColumn<{
277
- name: "user_agent";
278
- tableName: "audit_log";
279
- dataType: "string";
280
- columnType: "SQLiteText";
281
- data: string;
282
- driverParam: string;
283
- notNull: false;
284
- hasDefault: false;
285
- isPrimaryKey: false;
286
- isAutoincrement: false;
287
- hasRuntimeDefault: false;
288
- enumValues: [string, ...string[]];
289
- baseColumn: never;
290
- identity: undefined;
291
- generated: undefined;
292
- }, {}, {
293
- length: number | undefined;
294
- }>;
295
- description: drizzle_orm_sqlite_core.SQLiteColumn<{
296
- name: "description";
297
- tableName: "audit_log";
298
- dataType: "string";
299
- columnType: "SQLiteText";
300
- data: string;
301
- driverParam: string;
302
- notNull: false;
303
- hasDefault: false;
304
- isPrimaryKey: false;
305
- isAutoincrement: false;
306
- hasRuntimeDefault: false;
307
- enumValues: [string, ...string[]];
308
- baseColumn: never;
309
- identity: undefined;
310
- generated: undefined;
311
- }, {}, {
312
- length: number | undefined;
313
- }>;
314
- initiatorService: drizzle_orm_sqlite_core.SQLiteColumn<{
315
- name: "initiator_service";
316
- tableName: "audit_log";
317
- dataType: "string";
318
- columnType: "SQLiteText";
319
- data: string;
320
- driverParam: string;
321
- notNull: true;
322
- hasDefault: false;
323
- isPrimaryKey: false;
324
- isAutoincrement: false;
325
- hasRuntimeDefault: false;
326
- enumValues: [string, ...string[]];
327
- baseColumn: never;
328
- identity: undefined;
329
- generated: undefined;
330
- }, {}, {
331
- length: number | undefined;
332
- }>;
333
- initiatorUserId: drizzle_orm_sqlite_core.SQLiteColumn<{
334
- name: "initiator_user_id";
335
- tableName: "audit_log";
336
- dataType: "string";
337
- columnType: "SQLiteText";
338
- data: string;
339
- driverParam: string;
340
- notNull: false;
341
- hasDefault: false;
342
- isPrimaryKey: false;
343
- isAutoincrement: false;
344
- hasRuntimeDefault: false;
345
- enumValues: [string, ...string[]];
346
- baseColumn: never;
347
- identity: undefined;
348
- generated: undefined;
349
- }, {}, {
350
- length: number | undefined;
351
- }>;
352
- id: drizzle_orm_sqlite_core.SQLiteColumn<{
353
- name: "id";
354
- tableName: "audit_log";
355
- dataType: "string";
356
- columnType: "SQLiteText";
357
- data: string;
358
- driverParam: string;
359
- notNull: true;
360
- hasDefault: false;
361
- isPrimaryKey: true;
362
- isAutoincrement: false;
363
- hasRuntimeDefault: false;
364
- enumValues: [string, ...string[]];
365
- baseColumn: never;
366
- identity: undefined;
367
- generated: undefined;
368
- }, {}, {
369
- length: number | undefined;
370
- }>;
371
- createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
372
- name: "created_at";
373
- tableName: "audit_log";
374
- dataType: "date";
375
- columnType: "SQLiteTimestamp";
376
- data: Date;
377
- driverParam: number;
378
- notNull: false;
379
- hasDefault: true;
380
- isPrimaryKey: false;
381
- isAutoincrement: false;
382
- hasRuntimeDefault: false;
383
- enumValues: undefined;
384
- baseColumn: never;
385
- identity: undefined;
386
- generated: undefined;
387
- }, {}, {}>;
388
- updatedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
389
- name: "updated_at";
390
- tableName: "audit_log";
391
- dataType: "date";
392
- columnType: "SQLiteTimestamp";
393
- data: Date;
394
- driverParam: number;
395
- notNull: false;
396
- hasDefault: true;
397
- isPrimaryKey: false;
398
- isAutoincrement: false;
399
- hasRuntimeDefault: false;
400
- enumValues: undefined;
401
- baseColumn: never;
402
- identity: undefined;
403
- generated: undefined;
404
- }, {}, {}>;
405
- deletedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
406
- name: "deleted_at";
407
- tableName: "audit_log";
408
- dataType: "date";
409
- columnType: "SQLiteTimestamp";
410
- data: Date;
411
- driverParam: number;
412
- notNull: false;
413
- hasDefault: true;
414
- isPrimaryKey: false;
415
- isAutoincrement: false;
416
- hasRuntimeDefault: false;
417
- enumValues: undefined;
418
- baseColumn: never;
419
- identity: undefined;
420
- generated: undefined;
421
- }, {}, {}>;
422
- };
423
- dialect: "sqlite";
424
- }>;
425
-
426
- declare const schema_auditLog: typeof auditLog;
427
- declare namespace schema {
428
- export {
429
- schema_auditLog as auditLog,
430
- };
431
- }
432
-
433
- declare const tables: typeof schema;
434
-
435
- declare class SlackConnector {
436
- private webhooks;
437
- constructor(webhooks: string[]);
438
- sendNotificationToAllSlack(message: string): Promise<void>;
439
- }
440
-
441
- declare const NotificationServiceBase_base: (abstract new (ctx: ExecutionContext, env: NotificationEnv) => WorkerEntrypoint<NotificationEnv>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
442
- declare class NotificationServiceBase extends NotificationServiceBase_base {
443
- readonly name: string;
444
- readonly slackConnector: SlackConnector;
445
- protected emailConnector: IEmailConnector;
446
- protected smsConnector: ISmsConnector;
447
- readonly db: DrizzleD1Database<typeof tables>;
448
- constructor(ctx: ExecutionContext, env: NotificationEnv);
449
- queue(batch: MessageBatch<NotificationQueueMessage>): Promise<void>;
450
- protected _sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
451
- protected _sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
452
- sendEmail(input: SendEmailInput): Promise<IRPCResponse<SendEmailOutput>>;
453
- sendSms(input: SendSmsInput): Promise<IRPCResponse<SendSmsOutput>>;
454
- protected _sendPushNotification(): Promise<IRPCResponse<{}>>;
455
- sendSlackNotification(input: SendSlackInput): Promise<IRPCResponse<SendSlackOutput>>;
456
- }
457
- declare function defineNotificationService(): new (ctx: ExecutionContext, env: NotificationEnv) => NotificationServiceBase;
458
-
459
32
  /** biome-ignore-all lint/suspicious/noExplicitAny: allow any */
460
33
 
461
34
  declare function defineNotificationServiceWrangler(config: NotificationServiceWranglerConfig): {
@@ -484,8 +57,4 @@ declare function defineNotificationServiceWrangler(config: NotificationServiceWr
484
57
  env: Record<string, any>;
485
58
  };
486
59
 
487
- declare const _default: new (ctx: ExecutionContext, env: NotificationEnv) => WorkerEntrypoint<NotificationEnv>;
488
-
489
- // @ts-ignore
490
- export = _default;
491
- export { defineNotificationService, defineNotificationServiceWrangler };
60
+ export { defineNotificationServiceWrangler };