@develit-services/notification 0.0.2 → 0.0.3

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.
@@ -1,4 +1,4 @@
1
- import type { IContact, IEmail } from '@develit-services/notification/@types'
1
+ import type { IContact, IEmail } from '../../@types'
2
2
 
3
3
  export abstract class IEmailConnector {
4
4
  static providerName: string
@@ -1,5 +1,4 @@
1
1
  import { useResult } from '@develit-io/backend-sdk'
2
- // TODO: Tests fail when imported as from '@services/notification/@types'`
3
2
  import {
4
3
  type EMAttachment,
5
4
  type EMContact,
@@ -7,7 +6,7 @@ import {
7
6
  type IContact,
8
7
  type IEmail,
9
8
  IEmailConnector,
10
- } from '@services/notification/@types/email'
9
+ } from '../../email'
11
10
 
12
11
  export class EcomailConnector extends IEmailConnector {
13
12
  static providerName = 'ecomail'
@@ -1,4 +1,4 @@
1
- import { iEmailSchema } from '@services/notification/@types'
1
+ import { iEmailSchema } from '../'
2
2
  import z from 'zod'
3
3
 
4
4
  export const sendEmailInputSchema = z.object({
package/@types/queue.ts CHANGED
@@ -1,9 +1,4 @@
1
- import type {
2
- IEmail,
3
- IPushNotification,
4
- ISlack,
5
- ISms,
6
- } from '@services/notification/@types'
1
+ import type { IEmail, IPushNotification, ISlack, ISms } from './'
7
2
 
8
3
  export interface NotificationQueueMessage {
9
4
  type: 'email' | 'sms' | 'pushNotification' | 'slack'
@@ -1,5 +1,5 @@
1
1
  import type { InternalError } from '@develit-io/backend-sdk'
2
- import type { ISms } from '@services/notification/@types'
2
+ import type { ISms } from '../'
3
3
 
4
4
  export abstract class ISmsConnector {
5
5
  static providerName: string
@@ -1,9 +1,8 @@
1
- // TODO: Tests fail when imported as from '@services/notification/@types'`
2
1
  import {
3
2
  type InternalError,
4
3
  createInternalError,
5
4
  } from '@develit-io/backend-sdk'
6
- import { type ISms, ISmsConnector } from '@services/notification/@types/sms'
5
+ import { type ISms, ISmsConnector } from '../'
7
6
  import twilio from 'twilio'
8
7
 
9
8
  export class TwilioConnector extends ISmsConnector {
package/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
3
 
4
+ ## v0.0.3
5
+
6
+ [compare changes](https://github.com/develit-io/develit-services/compare/v0.0.2...v0.0.3)
7
+
4
8
  ## v0.0.2
5
9
 
6
10
 
package/build.config.ts CHANGED
@@ -4,6 +4,7 @@ export default defineBuildConfig({
4
4
  entries: ['./src'],
5
5
  outDir: 'dist',
6
6
  declaration: true,
7
+ failOnWarn: false,
7
8
  rollup: {
8
9
  emitCJS: true,
9
10
  },
package/package.json CHANGED
@@ -1,8 +1,19 @@
1
1
  {
2
2
  "name": "@develit-services/notification",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "author": "Develit.io s.r.o.",
5
5
  "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/src.mjs",
9
+ "require": "./dist/src.cjs",
10
+ "types": "./dist/src.d.ts"
11
+ },
12
+ "./package.json": "./package.json"
13
+ },
14
+ "bin": {
15
+ "notification-wrangler": "./scripts/generate-wrangler.ts"
16
+ },
6
17
  "scripts": {
7
18
  "postinstall": "bun cf:typegen",
8
19
  "wrangler:generate": "bun ./scripts/generate-wrangler.ts",
@@ -1,5 +1,5 @@
1
1
  import { base } from '@develit-io/backend-sdk'
2
- import type { AuditLogEventType } from '@services/notification/@types'
2
+ import type { AuditLogEventType } from '../../../@types'
3
3
  import { sqliteTable, text } from 'drizzle-orm/sqlite-core'
4
4
 
5
5
  export const auditLog = sqliteTable('audit_log', {
@@ -20,13 +20,13 @@ import {
20
20
  sendEmailInputSchema,
21
21
  sendSlackInputSchema,
22
22
  sendSmsInputSchema,
23
- } from '@develit-services/notification/@types'
24
- import { tables } from '@develit-services/notification/src/database/drizzle'
23
+ } from '../@types'
24
+ import { tables } from './database/drizzle'
25
25
  import {
26
26
  createAuditLogCommand,
27
27
  initiateEmailConnector,
28
28
  initiateSmsConnector,
29
- } from '@develit-services/notification/src/utils'
29
+ } from './utils'
30
30
  import { WorkerEntrypoint } from 'cloudflare:workers'
31
31
  import { type DrizzleD1Database, drizzle } from 'drizzle-orm/d1'
32
32
  import { SlackConnector } from '../@types/slack/slack.connector'
@@ -120,6 +120,10 @@ export class NotificationServiceBase extends develitWorker(
120
120
  metadata,
121
121
  })
122
122
  break
123
+ default:
124
+ this.logError({ error: `Unknown notification type: ${type}` })
125
+ message.retry()
126
+ continue
123
127
  }
124
128
 
125
129
  const { error, message: errorMessage } = await notificationAction()
@@ -135,7 +139,7 @@ export class NotificationServiceBase extends develitWorker(
135
139
  }
136
140
 
137
141
  @action('private-send-email')
138
- private async _sendEmail(
142
+ protected async _sendEmail(
139
143
  input: SendEmailInput,
140
144
  ): Promise<IRPCResponse<SendEmailOutput>> {
141
145
  return this.handleAction(
@@ -189,7 +193,7 @@ export class NotificationServiceBase extends develitWorker(
189
193
  }
190
194
 
191
195
  @action('private-send-sms')
192
- private async _sendSms(
196
+ protected async _sendSms(
193
197
  input: SendSmsInput,
194
198
  ): Promise<IRPCResponse<SendSmsOutput>> {
195
199
  return this.handleAction(
@@ -284,7 +288,7 @@ export class NotificationServiceBase extends develitWorker(
284
288
  }
285
289
 
286
290
  @action('send-push-notification')
287
- private async _sendPushNotification(): Promise<IRPCResponse<{}>> {
291
+ protected async _sendPushNotification(): Promise<IRPCResponse<{}>> {
288
292
  this.logInput({})
289
293
 
290
294
  this.logError({ error: 'Method not implemented.' })
@@ -312,7 +316,10 @@ export class NotificationServiceBase extends develitWorker(
312
316
  }
313
317
  }
314
318
 
315
- export function defineNotificationService() {
319
+ export function defineNotificationService(): new (
320
+ ctx: ExecutionContext,
321
+ env: NotificationEnv,
322
+ ) => NotificationServiceBase {
316
323
  return class NotificationService extends NotificationServiceBase {
317
324
  constructor(ctx: ExecutionContext, env: NotificationEnv) {
318
325
  super(ctx, env)
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { defineNotificationService } from './defineNotificationService'
2
+ import { defineNotificationServiceWrangler } from './defineNotificationWrangler'
2
3
  import type { WorkerEntrypoint } from 'cloudflare:workers'
3
4
 
4
5
  const NotificationService = defineNotificationService()
@@ -7,3 +8,5 @@ export default NotificationService as new (
7
8
  ctx: ExecutionContext,
8
9
  env: NotificationEnv,
9
10
  ) => WorkerEntrypoint<NotificationEnv>
11
+
12
+ export { defineNotificationService, defineNotificationServiceWrangler }
@@ -1,6 +1,6 @@
1
1
  import { uuidv4 } from '@develit-io/backend-sdk'
2
- import type { AuditLogInsertType } from '@services/notification/@types'
3
- import { tables } from '@services/notification/src/database/drizzle'
2
+ import type { AuditLogInsertType } from '../../../../@types'
3
+ import { tables } from '../../../database/drizzle'
4
4
  import type { DrizzleD1Database } from 'drizzle-orm/d1'
5
5
 
6
6
  export const createAuditLogCommand = async ({
@@ -3,7 +3,7 @@ import {
3
3
  EcomailConnector,
4
4
  type IContact,
5
5
  type IEmailConnector,
6
- } from '@services/notification/@types'
6
+ } from '../../@types'
7
7
 
8
8
  export const initiateEmailConnector = async (
9
9
  provider: string,
package/src/utils/sms.ts CHANGED
@@ -1,8 +1,5 @@
1
1
  import { createInternalError } from '@develit-io/backend-sdk'
2
- import {
3
- type ISmsConnector,
4
- TwilioConnector,
5
- } from '@services/notification/@types/sms'
2
+ import { type ISmsConnector, TwilioConnector } from '../../@types'
6
3
 
7
4
  export const initiateSmsConnector = async (
8
5
  provider: string,
@@ -4,7 +4,7 @@
4
4
  // EcomailConnector,
5
5
  // IContact,
6
6
  // IEmail,
7
- // } from '@services/notification/@types'
7
+ // } from '../../@types'
8
8
  // import { afterEach, describe, expect, it, vi } from 'vitest'
9
9
 
10
10
  // describe('EcomailConnector', () => {
package/wrangler.jsonc CHANGED
@@ -5,7 +5,9 @@
5
5
  "name": "develit-notification",
6
6
  "main": "./src/index.ts",
7
7
  "compatibility_date": "2025-06-04",
8
- "compatibility_flags": ["nodejs_compat"],
8
+ "compatibility_flags": [
9
+ "nodejs_compat"
10
+ ],
9
11
  "d1_databases": [
10
12
  {
11
13
  "binding": "NOTIFICATION_D1",
@@ -44,7 +46,9 @@
44
46
  "SMS_ACCOUNT_ID": "",
45
47
  "SMS_AUTH_TOKEN": "",
46
48
  "SMS_SERVICE_ID": "",
47
- "SLACK_WEBHOOKS": [""],
49
+ "SLACK_WEBHOOKS": [
50
+ ""
51
+ ],
48
52
  "ENVIRONMENT": "dev"
49
53
  },
50
54
  "d1_databases": [
@@ -85,7 +89,9 @@
85
89
  "SMS_ACCOUNT_ID": "",
86
90
  "SMS_AUTH_TOKEN": "",
87
91
  "SMS_SERVICE_ID": "",
88
- "SLACK_WEBHOOKS": [""],
92
+ "SLACK_WEBHOOKS": [
93
+ ""
94
+ ],
89
95
  "ENVIRONMENT": "test"
90
96
  },
91
97
  "d1_databases": [
@@ -126,7 +132,9 @@
126
132
  "SMS_ACCOUNT_ID": "",
127
133
  "SMS_AUTH_TOKEN": "",
128
134
  "SMS_SERVICE_ID": "",
129
- "SLACK_WEBHOOKS": [""],
135
+ "SLACK_WEBHOOKS": [
136
+ ""
137
+ ],
130
138
  "ENVIRONMENT": "staging"
131
139
  },
132
140
  "d1_databases": [
@@ -167,7 +175,9 @@
167
175
  "SMS_ACCOUNT_ID": "",
168
176
  "SMS_AUTH_TOKEN": "",
169
177
  "SMS_SERVICE_ID": "",
170
- "SLACK_WEBHOOKS": [""],
178
+ "SLACK_WEBHOOKS": [
179
+ ""
180
+ ],
171
181
  "ENVIRONMENT": "production"
172
182
  },
173
183
  "d1_databases": [
@@ -196,4 +206,4 @@
196
206
  }
197
207
  }
198
208
  }
199
- }
209
+ }