@gravito/flare 1.0.0-alpha.2 → 1.0.0-alpha.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/README.md CHANGED
@@ -1,26 +1,26 @@
1
1
  # @gravito/flare
2
2
 
3
- 輕量、高效的通知系統,支援多種通道(郵件、資料庫、廣播、Slack、SMS)。借鑑 Laravel 架構但保持 Gravito 的核心價值(高效能、低耗、輕量、AI 友善)。
3
+ > Lightweight, high-performance notifications for Gravito with multi-channel delivery (mail, database, broadcast, Slack, SMS).
4
4
 
5
- > **狀態**:v0.1.0 - 核心功能已完成,支援多種通知通道
5
+ **Status**: v0.1.0 - core features complete with multiple channel support.
6
6
 
7
- ## 特性
7
+ ## Features
8
8
 
9
- - **零運行時開銷**:純類型包裝,直接委派給驅動
10
- - **多通道支援**:郵件、資料庫、廣播、SlackSMS
11
- - **完全模組化**:按需安裝通道,核心包極小
12
- - **隊列化支援**:整合 `@gravito/stream`,支援異步發送
13
- - **AI 友善**:完整的型別推導、清晰的 JSDoc、直觀的 API
9
+ - **Zero runtime overhead**: Pure type wrappers that delegate to channel drivers
10
+ - **Multi-channel delivery**: Mail, database, broadcast, Slack, SMS
11
+ - **Modular by design**: Install only the channels you need
12
+ - **Queue support**: Works with `@gravito/stream` for async delivery
13
+ - **AI-friendly**: Strong typing, clear JSDoc, and predictable APIs
14
14
 
15
- ## 安裝
15
+ ## Installation
16
16
 
17
17
  ```bash
18
18
  bun add @gravito/flare
19
19
  ```
20
20
 
21
- ## 快速開始
21
+ ## Quick Start
22
22
 
23
- ### 1. 建立通知類別
23
+ ### 1. Create a notification
24
24
 
25
25
  ```typescript
26
26
  import { Notification } from '@gravito/flare'
@@ -56,7 +56,7 @@ class InvoicePaid extends Notification {
56
56
  }
57
57
  ```
58
58
 
59
- ### 2. 配置 OrbitFlare
59
+ ### 2. Configure OrbitFlare
60
60
 
61
61
  ```typescript
62
62
  import { PlanetCore } from 'gravito-core'
@@ -82,23 +82,23 @@ const core = await PlanetCore.boot({
82
82
  })
83
83
  ```
84
84
 
85
- ### 3. 發送通知
85
+ ### 3. Send a notification
86
86
 
87
87
  ```typescript
88
- // Controller
88
+ // In a controller
89
89
  const notifications = c.get('notifications') as NotificationManager
90
90
 
91
91
  await notifications.send(user, new InvoicePaid(invoice))
92
92
  ```
93
93
 
94
- ### 4. 隊列化通知
94
+ ## Queueing Notifications
95
95
 
96
96
  ```typescript
97
97
  import { Notification, ShouldQueue } from '@gravito/flare'
98
98
 
99
99
  class SendEmailNotification extends Notification implements ShouldQueue {
100
100
  queue = 'notifications'
101
- delay = 60 // 延遲 60
101
+ delay = 60 // delay by 60 seconds
102
102
 
103
103
  via(user: Notifiable): string[] {
104
104
  return ['mail']
@@ -113,15 +113,14 @@ class SendEmailNotification extends Notification implements ShouldQueue {
113
113
  }
114
114
  }
115
115
 
116
- // 自動推送到隊列
117
116
  await notifications.send(user, new SendEmailNotification())
118
117
  ```
119
118
 
120
- ## 通道
119
+ ## Channels
121
120
 
122
- ### 郵件通道
121
+ ### Mail
123
122
 
124
- 需要安裝 `@gravito/signal`:
123
+ Requires `@gravito/signal`:
125
124
 
126
125
  ```typescript
127
126
  via(user: Notifiable): string[] {
@@ -138,9 +137,9 @@ toMail(user: Notifiable): MailMessage {
138
137
  }
139
138
  ```
140
139
 
141
- ### 資料庫通道
140
+ ### Database
142
141
 
143
- 需要資料庫服務支援:
142
+ Requires database support:
144
143
 
145
144
  ```typescript
146
145
  via(user: Notifiable): string[] {
@@ -155,9 +154,9 @@ toDatabase(user: Notifiable): DatabaseNotification {
155
154
  }
156
155
  ```
157
156
 
158
- ### 廣播通道
157
+ ### Broadcast
159
158
 
160
- 需要安裝 `@gravito/radiance`:
159
+ Requires `@gravito/radiance`:
161
160
 
162
161
  ```typescript
163
162
  via(user: Notifiable): string[] {
@@ -172,7 +171,7 @@ toBroadcast(user: Notifiable): BroadcastNotification {
172
171
  }
173
172
  ```
174
173
 
175
- ### Slack 通道
174
+ ### Slack
176
175
 
177
176
  ```typescript
178
177
  via(user: Notifiable): string[] {
@@ -187,7 +186,7 @@ toSlack(user: Notifiable): SlackMessage {
187
186
  }
188
187
  ```
189
188
 
190
- ### SMS 通道
189
+ ### SMS
191
190
 
192
191
  ```typescript
193
192
  via(user: Notifiable): string[] {
@@ -202,29 +201,28 @@ toSms(user: Notifiable): SmsMessage {
202
201
  }
203
202
  ```
204
203
 
205
- ## API 參考
204
+ ## API Reference
206
205
 
207
206
  ### Notification
208
207
 
209
- 所有通知都應該繼承 `Notification` 類別。
208
+ Every notification should extend `Notification`.
210
209
 
211
- #### 方法
210
+ #### Methods
212
211
 
213
- - `via(notifiable: Notifiable): string[]` - 指定通知通道(必須實作)
214
- - `toMail(notifiable: Notifiable): MailMessage` - 郵件訊息(可選)
215
- - `toDatabase(notifiable: Notifiable): DatabaseNotification` - 資料庫通知(可選)
216
- - `toBroadcast(notifiable: Notifiable): BroadcastNotification` - 廣播通知(可選)
217
- - `toSlack(notifiable: Notifiable): SlackMessage` - Slack 訊息(可選)
218
- - `toSms(notifiable: Notifiable): SmsMessage` - SMS 訊息(可選)
212
+ - `via(notifiable: Notifiable): string[]` - Choose delivery channels (required)
213
+ - `toMail(notifiable: Notifiable): MailMessage` - Mail payload (optional)
214
+ - `toDatabase(notifiable: Notifiable): DatabaseNotification` - Database payload (optional)
215
+ - `toBroadcast(notifiable: Notifiable): BroadcastNotification` - Broadcast payload (optional)
216
+ - `toSlack(notifiable: Notifiable): SlackMessage` - Slack payload (optional)
217
+ - `toSms(notifiable: Notifiable): SmsMessage` - SMS payload (optional)
219
218
 
220
219
  ### NotificationManager
221
220
 
222
- #### 方法
221
+ #### Methods
223
222
 
224
- - `send(notifiable: Notifiable, notification: Notification): Promise<void>` - 發送通知
225
- - `channel(name: string, channel: NotificationChannel): void` - 註冊自訂通道
223
+ - `send(notifiable: Notifiable, notification: Notification): Promise<void>` - Send notification
224
+ - `channel(name: string, channel: NotificationChannel): void` - Register a custom channel
226
225
 
227
- ## 授權
226
+ ## License
228
227
 
229
228
  MIT © Carl Lee
230
-
@@ -0,0 +1,35 @@
1
+ # @gravito/flare
2
+
3
+ > Gravito 的通知模組,支援郵件、資料庫、廣播、Slack、SMS 等多種通道。
4
+
5
+ ## 安裝
6
+
7
+ ```bash
8
+ bun add @gravito/flare
9
+ ```
10
+
11
+ ## 快速開始
12
+
13
+ ```typescript
14
+ import { Notification } from '@gravito/flare'
15
+ import type { MailMessage, Notifiable } from '@gravito/flare'
16
+
17
+ class WelcomeUser extends Notification {
18
+ via(user: Notifiable): string[] {
19
+ return ['mail']
20
+ }
21
+
22
+ toMail(user: Notifiable): MailMessage {
23
+ return {
24
+ subject: 'Welcome!',
25
+ view: 'emails.welcome',
26
+ to: user.email,
27
+ }
28
+ }
29
+ }
30
+ ```
31
+
32
+ ```typescript
33
+ const notifications = c.get('notifications')
34
+ await notifications.send(user, new WelcomeUser())
35
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravito/flare",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,12 +38,12 @@
38
38
  "author": "Carl Lee <carllee0520@gmail.com>",
39
39
  "license": "MIT",
40
40
  "dependencies": {
41
- "gravito-core": "1.0.0-beta.2"
41
+ "gravito-core": "1.0.0-beta.5"
42
42
  },
43
43
  "peerDependencies": {
44
- "@gravito/stream": "1.0.0-alpha.2",
45
- "@gravito/signal": "1.0.0-alpha.2",
46
- "@gravito/radiance": "1.0.0-alpha.2"
44
+ "@gravito/stream": "1.0.0-alpha.6",
45
+ "@gravito/signal": "1.0.0-alpha.6",
46
+ "@gravito/radiance": "1.0.0-alpha.6"
47
47
  },
48
48
  "devDependencies": {
49
49
  "bun-types": "latest",