@betterlu/notif 0.0.0-stage → 1.2.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.
- package/LICENSE +21 -0
- package/README.md +261 -2
- package/dist/client.d.ts +30 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +89 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +5 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +9 -0
- package/dist/errors.js.map +1 -0
- package/dist/html.d.ts +3 -0
- package/dist/html.d.ts.map +1 -0
- package/dist/html.js +12 -0
- package/dist/html.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/transport.d.ts +12 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +55 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +275 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +43 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 betterlu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,262 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @betterlu/notif
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Client SDK for [notif](https://github.com/happyx94/notif) — async Telegram / Messenger / Discord / LINE / email / ChatLu / web push notifications with aliases, retries, and inbound replies.
|
|
4
|
+
|
|
5
|
+
Requires Node.js >= 18 (uses native `fetch`). Zero runtime dependencies.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @betterlu/notif
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { NotifClient } from "@betterlu/notif";
|
|
17
|
+
|
|
18
|
+
const client = new NotifClient(); // http://localhost:8778
|
|
19
|
+
// or: new NotifClient({ baseUrl: process.env.NOTIF_URL });
|
|
20
|
+
|
|
21
|
+
const n = await client.send({
|
|
22
|
+
channel: "telegram",
|
|
23
|
+
chatId: "larry",
|
|
24
|
+
message: "Deploy finished",
|
|
25
|
+
});
|
|
26
|
+
console.log(n._id, n.status); // pending — worker delivers async
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`baseUrl` is the **origin only** (no `/api`). Defaults to `NOTIF_URL` or `http://localhost:8778`.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
export NOTIF_URL=http://localhost:8778
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Send a notification
|
|
36
|
+
|
|
37
|
+
`send()` enqueues a job (HTTP 202). Status starts as `pending`; the worker delivers it.
|
|
38
|
+
|
|
39
|
+
| Field | Type | Notes |
|
|
40
|
+
|-------|------|--------|
|
|
41
|
+
| `channel` | string | Channel name, provider type (`telegram` \| `messenger` \| `discord` \| `line` \| `email` \| `chatlu` \| `webpush`), or ObjectId |
|
|
42
|
+
| `message` | string | Required |
|
|
43
|
+
| `chatId` | string | Alias name first, else raw chat id (webpush: subscription id) |
|
|
44
|
+
| `user` / `userName` | string | Alias-only (back-compat) |
|
|
45
|
+
| `recipient` | `{ chatId?, psid? }` | Raw recipient |
|
|
46
|
+
| `format` | `plain` \| `markdown` \| `html` | Auto-detected if omitted |
|
|
47
|
+
| `options` | object | Provider extras (see below) |
|
|
48
|
+
|
|
49
|
+
`chatId` looks up an alias first, then treats the value as a raw id. Discord **webhook** channels may omit `chatId`. Discord bot, LINE, Telegram, Messenger, and ChatLu require it; web push may omit it when `options.person` / `options.app` select registered subscriptions.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// Alias
|
|
53
|
+
await client.send({ channel: "telegram", chatId: "larry", message: "Hello" });
|
|
54
|
+
|
|
55
|
+
// Raw chat id
|
|
56
|
+
await client.send({ channel: "default-telegram", chatId: "123456789", message: "Hello" });
|
|
57
|
+
|
|
58
|
+
// HTML
|
|
59
|
+
await client.send({
|
|
60
|
+
channel: "telegram",
|
|
61
|
+
userName: "larry",
|
|
62
|
+
message: "<b>Alert</b> disk is full",
|
|
63
|
+
format: "html",
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Discord webhook (chatId optional)
|
|
67
|
+
await client.send({
|
|
68
|
+
channel: "alerts-discord",
|
|
69
|
+
message: "Build passed",
|
|
70
|
+
options: { username: "ci", avatarUrl: "https://example.com/bot.png" },
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Web push to one subscription id
|
|
74
|
+
await client.send({
|
|
75
|
+
channel: "webpush",
|
|
76
|
+
chatId: subscriptionId,
|
|
77
|
+
message: "Need milk",
|
|
78
|
+
options: { title: "cartlu", url: "/" },
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Web push to every subscription of a person/app
|
|
82
|
+
await client.send({
|
|
83
|
+
channel: "webpush",
|
|
84
|
+
message: "Need milk",
|
|
85
|
+
options: { title: "cartlu", url: "/", app: "cartlu", person: "larry" },
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Shorthand
|
|
89
|
+
await client.notify("Hello", { channel: "telegram", chatId: "larry" });
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Options
|
|
93
|
+
|
|
94
|
+
| Key | Providers |
|
|
95
|
+
|-----|-----------|
|
|
96
|
+
| `disableNotification` | Telegram, Discord, LINE (silent) |
|
|
97
|
+
| `protectContent` | Telegram |
|
|
98
|
+
| `linkPreview` | Telegram |
|
|
99
|
+
| `threadId` | Telegram, Discord (webhook path), ChatLu (Matrix thread event id) |
|
|
100
|
+
| `replyToMessageId` | Telegram, ChatLu (Matrix event id) |
|
|
101
|
+
| `replyMarkup` | Telegram |
|
|
102
|
+
| `messengerTag` | Messenger (`false` → `RESPONSE`; omit for `MESSAGE_TAG`) |
|
|
103
|
+
| `username` / `avatarUrl` | Discord webhook |
|
|
104
|
+
| `subject` | Email (**required**) |
|
|
105
|
+
| `title` / `url` / `icon` / `badge` | Web push (title defaults to `"Notification"`) |
|
|
106
|
+
| `ttl` | Web push TTL seconds (overrides channel default) |
|
|
107
|
+
| `person` / `app` | Web push target filters (used when `chatId` is omitted) |
|
|
108
|
+
|
|
109
|
+
## Status, retry, delete
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
const items = await client.listNotifications({ status: "failed", limit: 20 });
|
|
113
|
+
const one = await client.getNotification(id);
|
|
114
|
+
await client.retryNotification(id); // failed → pending
|
|
115
|
+
await client.deleteNotification(id);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`listNotifications` filters: `channel` (name or provider type), `status`, `recipient` (regex on chatId/alias), `limit` (default 20, max 50).
|
|
119
|
+
|
|
120
|
+
## Channels
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
const channels = await client.listChannels();
|
|
124
|
+
const ch = await client.createChannel({
|
|
125
|
+
name: "alerts-telegram",
|
|
126
|
+
provider: "telegram",
|
|
127
|
+
isDefault: false,
|
|
128
|
+
config: { botToken: "..." },
|
|
129
|
+
});
|
|
130
|
+
await client.updateChannel(ch._id, { isDefault: true });
|
|
131
|
+
await client.registerWebhook(ch._id, { baseUrl: "https://example.com" }); // telegram only
|
|
132
|
+
await client.deleteChannel(ch._id);
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Secrets in responses are masked (`abcd••••wxyz`).
|
|
136
|
+
|
|
137
|
+
### Channel config by provider
|
|
138
|
+
|
|
139
|
+
| Provider | Required | Optional |
|
|
140
|
+
|----------|----------|----------|
|
|
141
|
+
| `telegram` | `botToken` | `webhookSecretToken` |
|
|
142
|
+
| `messenger` | `pageAccessToken` | `apiVersion`, `verifyToken`, `appSecret` |
|
|
143
|
+
| `discord` | `webhookUrl` and/or `botToken` | `username` |
|
|
144
|
+
| `line` | `channelAccessToken` | `channelSecret` |
|
|
145
|
+
| `email` | `host`, `user`, `pass` | `port` (587), `secure` (false), `from`, `fromName` |
|
|
146
|
+
| `chatlu` | `homeserverUrl`, `accessToken` | — |
|
|
147
|
+
| `webpush` | — | `vapidSubject`, `vapidPublicKey`, `vapidPrivateKey`, `ttl` (fallback: `WEBPUSH_VAPID_*` env) |
|
|
148
|
+
|
|
149
|
+
Name: `^[a-zA-Z0-9_-]+$`, not reserved (`telegram` / `messenger` / `discord` / `line` / `email` / `chatlu` / `webpush`).
|
|
150
|
+
|
|
151
|
+
Email channels send over SMTP and require `options.subject`; `chatId` is the recipient address (alias lookup applies first).
|
|
152
|
+
|
|
153
|
+
ChatLu channels deliver to Matrix rooms via the homeserver's client API; `chatId` is a room ID (`!room:chatlu.lan`) or room alias (`#room:chatlu.lan`). Create the bot with `scripts/chatlu-bot-setup.sh`.
|
|
154
|
+
|
|
155
|
+
## Web push subscriptions
|
|
156
|
+
|
|
157
|
+
Apps register their browser push subscriptions so notif can deliver `webpush` notifications (no `web-push` dependency needed in the app). Keyed by `endpoint`; `person` defaults to `agent`.
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
await client.registerPushSubscription({
|
|
161
|
+
app: "cartlu",
|
|
162
|
+
person: "larry",
|
|
163
|
+
endpoint: sub.endpoint,
|
|
164
|
+
keys: { p256dh: sub.keys.p256dh, auth: sub.keys.auth },
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
const subs = await client.listPushSubscriptions({ app: "cartlu", person: "larry" });
|
|
168
|
+
await client.deletePushSubscription({ id: subs[0]._id }); // or { endpoint }
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Expired endpoints (404/410 from the push service) are dropped automatically at delivery time. Web push channels need VAPID config: on the channel (`vapidSubject` / `vapidPublicKey` / `vapidPrivateKey` / `ttl`) or `WEBPUSH_VAPID_SUBJECT` / `WEBPUSH_VAPID_PUBLIC_KEY` / `WEBPUSH_VAPID_PRIVATE_KEY` / `WEBPUSH_TTL` env.
|
|
172
|
+
|
|
173
|
+
## Aliases
|
|
174
|
+
|
|
175
|
+
Friendly name → per-channel chat ids.
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
await client.createAlias({
|
|
179
|
+
name: "larry",
|
|
180
|
+
mappings: { "default-telegram": "123456789", "alerts-discord": "987654321" },
|
|
181
|
+
});
|
|
182
|
+
const aliases = await client.listAliases();
|
|
183
|
+
await client.updateAlias(id, { mappings: { "default-telegram": "111" } });
|
|
184
|
+
await client.deleteAlias(id);
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Inbound replies
|
|
188
|
+
|
|
189
|
+
Telegram / Messenger / LINE webhooks persist inbound events. List omits `rawPayload`; `getInbound` includes it.
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
const replies = await client.listInbound({ channel: "telegram", matched: true, limit: 20 });
|
|
193
|
+
const full = await client.getInbound(replies[0]._id);
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Health
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
const h = await client.health();
|
|
200
|
+
// { ok, workerRunning, notificationCount, aliasCount, channelCount, channels, providers }
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Errors
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
import { NotifClient, NotifError } from "@betterlu/notif";
|
|
207
|
+
|
|
208
|
+
try {
|
|
209
|
+
await client.send({ channel: "telegram", message: "" });
|
|
210
|
+
} catch (err) {
|
|
211
|
+
if (err instanceof NotifError) {
|
|
212
|
+
console.error(err.status, err.message); // 400 message is required
|
|
213
|
+
} else {
|
|
214
|
+
throw err;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
No auth. Inject `fetch` for tests or custom middleware:
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
const client = new NotifClient({
|
|
223
|
+
baseUrl: "http://localhost:8778",
|
|
224
|
+
fetch: myFetch,
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## API reference
|
|
229
|
+
|
|
230
|
+
### `NotifClient`
|
|
231
|
+
|
|
232
|
+
| Method | Returns | Description |
|
|
233
|
+
|--------|---------|-------------|
|
|
234
|
+
| `health()` | `HealthResponse` | Worker + channel list |
|
|
235
|
+
| `send(req)` | `Notification` | Enqueue (202) |
|
|
236
|
+
| `notify(message, opts?)` | `Notification` | Shorthand for `send` |
|
|
237
|
+
| `notifyTelegramHtml(user, html)` | `Notification` | Telegram HTML to an alias (`userName`) |
|
|
238
|
+
| `escapeHtml(value)` | `string` | Escape `& < > " '` for Telegram HTML |
|
|
239
|
+
| `listNotifications(query?)` | `Notification[]` | Filter queue |
|
|
240
|
+
| `getNotification(id)` | `Notification` | One notification |
|
|
241
|
+
| `retryNotification(id)` | `Notification` | Re-queue a failed send |
|
|
242
|
+
| `deleteNotification(id)` | `Notification` | Delete |
|
|
243
|
+
| `listChannels()` | `Channel[]` | All channels |
|
|
244
|
+
| `getChannel(id)` | `Channel` | One channel (secrets masked) |
|
|
245
|
+
| `createChannel(req)` | `Channel` | Create |
|
|
246
|
+
| `updateChannel(id, req)` | `Channel` | Partial update |
|
|
247
|
+
| `deleteChannel(id)` | `Channel` | Delete |
|
|
248
|
+
| `registerWebhook(id, req?)` | `RegisterWebhookResult` | Telegram `setWebhook` |
|
|
249
|
+
| `registerPushSubscription(req)` | `PushSubscription` | Upsert a web push subscription by endpoint |
|
|
250
|
+
| `listPushSubscriptions(query?)` | `PushSubscription[]` | Filter by `person`, `app`, `limit` |
|
|
251
|
+
| `deletePushSubscription({ id?, endpoint? })` | `PushSubscription` | Delete a subscription |
|
|
252
|
+
| `listAliases(query?)` | `Alias[]` | All aliases |
|
|
253
|
+
| `getAlias(id)` | `Alias` | One alias |
|
|
254
|
+
| `createAlias(req)` | `Alias` | Create |
|
|
255
|
+
| `updateAlias(id, req)` | `Alias` | Update |
|
|
256
|
+
| `deleteAlias(id)` | `Alias` | Delete |
|
|
257
|
+
| `listInbound(query?)` | `InboundResponse[]` | Inbound events (no `rawPayload`) |
|
|
258
|
+
| `getInbound(id)` | `InboundResponse` | One inbound (includes `rawPayload`) |
|
|
259
|
+
|
|
260
|
+
## License
|
|
261
|
+
|
|
262
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Alias, Channel, ClientOptions, CreateAliasRequest, CreateChannelRequest, HealthResponse, InboundResponse, ListAliasesQuery, ListInboundQuery, ListNotificationsQuery, Notification, RegisterWebhookRequest, RegisterWebhookResult, SendNotificationRequest, UpdateAliasRequest, UpdateChannelRequest, PushSubscription, RegisterPushSubscriptionRequest, ListPushSubscriptionsQuery, DeletePushSubscriptionRequest } from "./types.js";
|
|
2
|
+
export declare class NotifClient {
|
|
3
|
+
private readonly transport;
|
|
4
|
+
constructor(options?: ClientOptions);
|
|
5
|
+
health(): Promise<HealthResponse>;
|
|
6
|
+
send(request: SendNotificationRequest): Promise<Notification>;
|
|
7
|
+
notify(message: string, opts?: Omit<SendNotificationRequest, "message">): Promise<Notification>;
|
|
8
|
+
notifyTelegramHtml(user: string, html: string): Promise<Notification>;
|
|
9
|
+
listNotifications(query?: ListNotificationsQuery): Promise<Notification[]>;
|
|
10
|
+
getNotification(id: string): Promise<Notification>;
|
|
11
|
+
retryNotification(id: string): Promise<Notification>;
|
|
12
|
+
deleteNotification(id: string): Promise<Notification>;
|
|
13
|
+
listChannels(): Promise<Channel[]>;
|
|
14
|
+
getChannel(id: string): Promise<Channel>;
|
|
15
|
+
createChannel(request: CreateChannelRequest): Promise<Channel>;
|
|
16
|
+
updateChannel(id: string, request: UpdateChannelRequest): Promise<Channel>;
|
|
17
|
+
deleteChannel(id: string): Promise<Channel>;
|
|
18
|
+
registerWebhook(id: string, request?: RegisterWebhookRequest): Promise<RegisterWebhookResult>;
|
|
19
|
+
registerPushSubscription(request: RegisterPushSubscriptionRequest): Promise<PushSubscription>;
|
|
20
|
+
listPushSubscriptions(query?: ListPushSubscriptionsQuery): Promise<PushSubscription[]>;
|
|
21
|
+
deletePushSubscription(request: DeletePushSubscriptionRequest): Promise<PushSubscription>;
|
|
22
|
+
listAliases(query?: ListAliasesQuery): Promise<Alias[]>;
|
|
23
|
+
getAlias(id: string): Promise<Alias>;
|
|
24
|
+
createAlias(request: CreateAliasRequest): Promise<Alias>;
|
|
25
|
+
updateAlias(id: string, request: UpdateAliasRequest): Promise<Alias>;
|
|
26
|
+
deleteAlias(id: string): Promise<Alias>;
|
|
27
|
+
listInbound(query?: ListInboundQuery): Promise<InboundResponse[]>;
|
|
28
|
+
getInbound(id: string): Promise<InboundResponse>;
|
|
29
|
+
}
|
|
30
|
+
//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";
|
|
3
|
+
function resolveBaseUrl(baseUrl) {
|
|
4
|
+
const raw = baseUrl ?? (typeof process !== "undefined" ? process.env[ENV_URL_VAR] : undefined) ?? DEFAULT_BASE_URL;
|
|
5
|
+
return raw.replace(/\/+$/, "");
|
|
6
|
+
}
|
|
7
|
+
export class NotifClient {
|
|
8
|
+
transport;
|
|
9
|
+
constructor(options = {}) {
|
|
10
|
+
this.transport = createTransport({
|
|
11
|
+
baseUrl: resolveBaseUrl(options.baseUrl),
|
|
12
|
+
fetch: options.fetch,
|
|
13
|
+
timeoutMs: options.timeoutMs,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
async health() {
|
|
17
|
+
return this.transport.request("GET", "/api/health");
|
|
18
|
+
}
|
|
19
|
+
async send(request) {
|
|
20
|
+
return this.transport.request("POST", "/api/notifications", request);
|
|
21
|
+
}
|
|
22
|
+
async notify(message, opts = {}) {
|
|
23
|
+
return this.send({ ...opts, message });
|
|
24
|
+
}
|
|
25
|
+
async notifyTelegramHtml(user, html) {
|
|
26
|
+
return this.send({ channel: "telegram", userName: user, message: html, format: "html" });
|
|
27
|
+
}
|
|
28
|
+
async listNotifications(query = {}) {
|
|
29
|
+
return this.transport.request("GET", "/api/notifications", undefined, query);
|
|
30
|
+
}
|
|
31
|
+
async getNotification(id) {
|
|
32
|
+
return this.transport.request("GET", `/api/notifications/${id}`);
|
|
33
|
+
}
|
|
34
|
+
async retryNotification(id) {
|
|
35
|
+
return this.transport.request("POST", `/api/notifications/${id}/retry`);
|
|
36
|
+
}
|
|
37
|
+
async deleteNotification(id) {
|
|
38
|
+
return this.transport.request("DELETE", `/api/notifications/${id}`);
|
|
39
|
+
}
|
|
40
|
+
async listChannels() {
|
|
41
|
+
return this.transport.request("GET", "/api/channels");
|
|
42
|
+
}
|
|
43
|
+
async getChannel(id) {
|
|
44
|
+
return this.transport.request("GET", `/api/channels/${id}`);
|
|
45
|
+
}
|
|
46
|
+
async createChannel(request) {
|
|
47
|
+
return this.transport.request("POST", "/api/channels", request);
|
|
48
|
+
}
|
|
49
|
+
async updateChannel(id, request) {
|
|
50
|
+
return this.transport.request("PUT", `/api/channels/${id}`, request);
|
|
51
|
+
}
|
|
52
|
+
async deleteChannel(id) {
|
|
53
|
+
return this.transport.request("DELETE", `/api/channels/${id}`);
|
|
54
|
+
}
|
|
55
|
+
async registerWebhook(id, request = {}) {
|
|
56
|
+
return this.transport.request("POST", `/api/channels/${id}/register-webhook`, request);
|
|
57
|
+
}
|
|
58
|
+
async registerPushSubscription(request) {
|
|
59
|
+
return this.transport.request("POST", "/api/push/subscriptions", request);
|
|
60
|
+
}
|
|
61
|
+
async listPushSubscriptions(query = {}) {
|
|
62
|
+
return this.transport.request("GET", "/api/push/subscriptions", undefined, query);
|
|
63
|
+
}
|
|
64
|
+
async deletePushSubscription(request) {
|
|
65
|
+
return this.transport.request("DELETE", "/api/push/subscriptions", request);
|
|
66
|
+
}
|
|
67
|
+
async listAliases(query = {}) {
|
|
68
|
+
return this.transport.request("GET", "/api/aliases", undefined, query);
|
|
69
|
+
}
|
|
70
|
+
async getAlias(id) {
|
|
71
|
+
return this.transport.request("GET", `/api/aliases/${id}`);
|
|
72
|
+
}
|
|
73
|
+
async createAlias(request) {
|
|
74
|
+
return this.transport.request("POST", "/api/aliases", request);
|
|
75
|
+
}
|
|
76
|
+
async updateAlias(id, request) {
|
|
77
|
+
return this.transport.request("PUT", `/api/aliases/${id}`, request);
|
|
78
|
+
}
|
|
79
|
+
async deleteAlias(id) {
|
|
80
|
+
return this.transport.request("DELETE", `/api/aliases/${id}`);
|
|
81
|
+
}
|
|
82
|
+
async listInbound(query = {}) {
|
|
83
|
+
return this.transport.request("GET", "/api/inbound-responses", undefined, query);
|
|
84
|
+
}
|
|
85
|
+
async getInbound(id) {
|
|
86
|
+
return this.transport.request("GET", `/api/inbound-responses/${id}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|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C;IACxE,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,EAAU,EAAE,OAA2B;QACvD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAQ,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,EAAU;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAQ,QAAQ,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,QAA0B,EAAE;QAC5C,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAoB,KAAK,EAAE,wBAAwB,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACtG,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAU;QACzB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAkB,KAAK,EAAE,0BAA0B,EAAE,EAAE,CAAC,CAAC;IACxF,CAAC;CACF"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEnB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK5C"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnB,MAAM,CAAS;IAE/B,YAAY,MAAc,EAAE,OAAe;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF"}
|
package/dist/html.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../src/html.ts"],"names":[],"mappings":"AAQA,yGAAyG;AACzG,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD"}
|
package/dist/html.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const REPLACEMENTS = {
|
|
2
|
+
"&": "&",
|
|
3
|
+
"<": "<",
|
|
4
|
+
">": ">",
|
|
5
|
+
'"': """,
|
|
6
|
+
"'": "'",
|
|
7
|
+
};
|
|
8
|
+
/** Escape text for Telegram HTML. `&` is handled in the same pass so entities are not double-escaped. */
|
|
9
|
+
export function escapeHtml(value) {
|
|
10
|
+
return value.replace(/[&<>"']/g, (char) => REPLACEMENTS[char]);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=html.js.map
|
package/dist/html.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../src/html.ts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAA2B;IAC3C,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,OAAO;CACb,CAAC;AAEF,yGAAyG;AACzG,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAE,CAAC,CAAC;AAClE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { NotifClient } from "./client.js";
|
|
2
|
+
export { escapeHtml } from "./html.js";
|
|
3
|
+
export { NotifError } from "./errors.js";
|
|
4
|
+
export { ENDPOINTS, DEFAULT_BASE_URL, ENV_URL_VAR } from "./types.js";
|
|
5
|
+
export type { ClientOptions, Provider, Format, NotificationStatus, CorrelationMethod, CorrelationConfidence, NotificationOptions, Recipient, SendNotificationRequest, NotificationError, Notification, ListNotificationsQuery, TelegramChannelConfig, MessengerChannelConfig, DiscordChannelConfig, LineChannelConfig, ChatluChannelConfig, WebPushChannelConfig, ChannelConfig, Channel, CreateChannelRequest, UpdateChannelRequest, RegisterWebhookRequest, RegisterWebhookResult, Alias, CreateAliasRequest, UpdateAliasRequest, ListAliasesQuery, InboundResponse, ListInboundQuery, PushSubscriptionKeys, PushSubscription, RegisterPushSubscriptionRequest, ListPushSubscriptionsQuery, DeletePushSubscriptionRequest, HealthResponse, } from "./types.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACtE,YAAY,EACV,aAAa,EACb,QAAQ,EACR,MAAM,EACN,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,SAAS,EACT,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EACZ,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,OAAO,EACP,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,EACL,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,+BAA+B,EAC/B,0BAA0B,EAC1B,6BAA6B,EAC7B,cAAc,GACf,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface TransportOptions {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
fetch?: typeof globalThis.fetch;
|
|
4
|
+
timeoutMs?: number;
|
|
5
|
+
}
|
|
6
|
+
type QueryParams = object;
|
|
7
|
+
export declare function createTransport(opts: TransportOptions): {
|
|
8
|
+
request: <T>(method: string, path: string, body?: unknown, query?: QueryParams) => Promise<T>;
|
|
9
|
+
};
|
|
10
|
+
export type Transport = ReturnType<typeof createTransport>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAQD,KAAK,WAAW,GAAG,MAAM,CAAC;AA8D1B,wBAAgB,eAAe,CAAC,IAAI,EAAE,gBAAgB;cAExC,CAAC,UACD,MAAM,QACR,MAAM,SACL,OAAO,UACN,WAAW;EAGxB;AAED,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { NotifError } from "./errors.js";
|
|
2
|
+
function toQuery(params) {
|
|
3
|
+
if (!params)
|
|
4
|
+
return "";
|
|
5
|
+
const search = new URLSearchParams();
|
|
6
|
+
for (const [key, value] of Object.entries(params)) {
|
|
7
|
+
if (value === undefined)
|
|
8
|
+
continue;
|
|
9
|
+
search.set(key, String(value));
|
|
10
|
+
}
|
|
11
|
+
const qs = search.toString();
|
|
12
|
+
return qs ? `?${qs}` : "";
|
|
13
|
+
}
|
|
14
|
+
async function request(opts, method, path, body, query) {
|
|
15
|
+
const fetchFn = opts.fetch ?? globalThis.fetch;
|
|
16
|
+
const url = `${opts.baseUrl}${path}${toQuery(query)}`;
|
|
17
|
+
const headers = {};
|
|
18
|
+
let reqBody;
|
|
19
|
+
if (body !== undefined) {
|
|
20
|
+
headers["Content-Type"] = "application/json";
|
|
21
|
+
reqBody = JSON.stringify(body);
|
|
22
|
+
}
|
|
23
|
+
const res = await fetchFn(url, {
|
|
24
|
+
method,
|
|
25
|
+
headers,
|
|
26
|
+
body: reqBody,
|
|
27
|
+
signal: opts.timeoutMs ? AbortSignal.timeout(opts.timeoutMs) : undefined,
|
|
28
|
+
});
|
|
29
|
+
let json;
|
|
30
|
+
try {
|
|
31
|
+
json = (await res.json());
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
if (!res.ok) {
|
|
35
|
+
throw new NotifError(res.status, `HTTP ${res.status}`);
|
|
36
|
+
}
|
|
37
|
+
throw new NotifError(res.status, "Response is not JSON");
|
|
38
|
+
}
|
|
39
|
+
if (!res.ok) {
|
|
40
|
+
const message = json && typeof json === "object" && "error" in json && typeof json.error === "string"
|
|
41
|
+
? json.error
|
|
42
|
+
: `HTTP ${res.status}`;
|
|
43
|
+
throw new NotifError(res.status, message);
|
|
44
|
+
}
|
|
45
|
+
if (json && typeof json === "object" && "data" in json && json.ok === true) {
|
|
46
|
+
return json.data;
|
|
47
|
+
}
|
|
48
|
+
return json;
|
|
49
|
+
}
|
|
50
|
+
export function createTransport(opts) {
|
|
51
|
+
return {
|
|
52
|
+
request: (method, path, body, query) => request(opts, method, path, body, query),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAgBzC,SAAS,OAAO,CAAC,MAAoB;IACnC,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACjC,CAAC;IACD,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC7B,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5B,CAAC;AAED,KAAK,UAAU,OAAO,CACpB,IAAsB,EACtB,MAAc,EACd,IAAY,EACZ,IAAc,EACd,KAAmB;IAEnB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;IAC/C,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;IAEtD,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,IAAI,OAA2B,CAAC;IAChC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,CAAC,cAAc,CAAC,GAAG,kBAA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AC;IAED,OAAO,IAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAsB;IACpD,OAAO;QACL,OAAO,EAAE,CACP,MAAc,EACd,IAAY,EACZ,IAAc,EACd,KAAmB,EACnB,EAAE,CAAC,OAAO,CAAI,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC;KACjD,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
export declare const ENDPOINTS: {
|
|
2
|
+
readonly local: "http://localhost:8778";
|
|
3
|
+
};
|
|
4
|
+
export declare const DEFAULT_BASE_URL: "http://localhost:8778";
|
|
5
|
+
export declare const ENV_URL_VAR = "NOTIF_URL";
|
|
6
|
+
export interface ClientOptions {
|
|
7
|
+
/** Origin only (no `/api`). Defaults to `NOTIF_URL` or `http://localhost:8778`. */
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
fetch?: typeof globalThis.fetch;
|
|
10
|
+
/** Abort each request after this many milliseconds. */
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
}
|
|
13
|
+
export type Provider = "telegram" | "messenger" | "discord" | "line" | "email" | "chatlu" | "webpush";
|
|
14
|
+
export type Format = "plain" | "markdown" | "html";
|
|
15
|
+
export type NotificationStatus = "pending" | "processing" | "sent" | "failed";
|
|
16
|
+
export type CorrelationMethod = "unmatched" | "reply_metadata" | "known_sender" | "sender_recent_sent" | "ambiguous";
|
|
17
|
+
export type CorrelationConfidence = "none" | "medium" | "high";
|
|
18
|
+
export interface NotificationOptions {
|
|
19
|
+
disableNotification?: boolean;
|
|
20
|
+
protectContent?: boolean;
|
|
21
|
+
linkPreview?: boolean;
|
|
22
|
+
threadId?: string | number;
|
|
23
|
+
replyToMessageId?: string | number;
|
|
24
|
+
replyMarkup?: unknown;
|
|
25
|
+
messengerTag?: string | false | null;
|
|
26
|
+
username?: string;
|
|
27
|
+
avatarUrl?: string;
|
|
28
|
+
/** Required for email channels. */
|
|
29
|
+
subject?: string;
|
|
30
|
+
/** Web push notification title (webpush channels). Defaults to "Notification". */
|
|
31
|
+
title?: string;
|
|
32
|
+
/** Web push click-through URL (webpush channels). */
|
|
33
|
+
url?: string;
|
|
34
|
+
/** Web push icon path (webpush channels). */
|
|
35
|
+
icon?: string;
|
|
36
|
+
/** Web push badge path (webpush channels). */
|
|
37
|
+
badge?: string;
|
|
38
|
+
/** Web push TTL in seconds (webpush channels). Overrides the channel default. */
|
|
39
|
+
ttl?: number;
|
|
40
|
+
/** Web push target filter: person (webpush channels, used when chatId is omitted). */
|
|
41
|
+
person?: string;
|
|
42
|
+
/** Web push target filter: app (webpush channels, used when chatId is omitted). */
|
|
43
|
+
app?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface Recipient {
|
|
46
|
+
chatId?: string | null;
|
|
47
|
+
psid?: string | null;
|
|
48
|
+
}
|
|
49
|
+
export interface SendNotificationRequest {
|
|
50
|
+
/** Channel name, provider type (`telegram` | …), or channel ObjectId. */
|
|
51
|
+
channel?: string;
|
|
52
|
+
/** Alternate field for `channel`. */
|
|
53
|
+
channelId?: string;
|
|
54
|
+
message: string;
|
|
55
|
+
/** Alias name first, else raw chat id. */
|
|
56
|
+
chatId?: string;
|
|
57
|
+
/** Alias-only (back-compat). */
|
|
58
|
+
user?: string;
|
|
59
|
+
/** Alias-only (back-compat). */
|
|
60
|
+
userName?: string;
|
|
61
|
+
recipient?: Recipient;
|
|
62
|
+
format?: Format;
|
|
63
|
+
options?: NotificationOptions;
|
|
64
|
+
}
|
|
65
|
+
export interface NotificationError {
|
|
66
|
+
code?: string;
|
|
67
|
+
message?: string;
|
|
68
|
+
retryable?: boolean;
|
|
69
|
+
raw?: unknown;
|
|
70
|
+
at?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface Notification {
|
|
73
|
+
_id: string;
|
|
74
|
+
channel: string;
|
|
75
|
+
channelId: string;
|
|
76
|
+
provider: Provider;
|
|
77
|
+
message: string;
|
|
78
|
+
format: Format;
|
|
79
|
+
recipient: Recipient;
|
|
80
|
+
chatId: string | null;
|
|
81
|
+
alias: string | null;
|
|
82
|
+
userName: string | null;
|
|
83
|
+
options: NotificationOptions | null;
|
|
84
|
+
status: NotificationStatus;
|
|
85
|
+
attempts: number;
|
|
86
|
+
maxAttempts: number;
|
|
87
|
+
nextAttemptAt: string;
|
|
88
|
+
lastAttemptAt: string | null;
|
|
89
|
+
providerMessageId: string | null;
|
|
90
|
+
providerResponse: unknown;
|
|
91
|
+
error: NotificationError | null;
|
|
92
|
+
createdAt: string;
|
|
93
|
+
updatedAt: string;
|
|
94
|
+
}
|
|
95
|
+
export interface ListNotificationsQuery {
|
|
96
|
+
/** Channel name, or provider type (`telegram` filters by provider). */
|
|
97
|
+
channel?: string;
|
|
98
|
+
status?: NotificationStatus;
|
|
99
|
+
recipient?: string;
|
|
100
|
+
/** Default 50, max 50. */
|
|
101
|
+
limit?: number;
|
|
102
|
+
}
|
|
103
|
+
export interface TelegramChannelConfig {
|
|
104
|
+
botToken?: string;
|
|
105
|
+
webhookSecretToken?: string;
|
|
106
|
+
}
|
|
107
|
+
export interface MessengerChannelConfig {
|
|
108
|
+
pageAccessToken?: string;
|
|
109
|
+
apiVersion?: string;
|
|
110
|
+
verifyToken?: string;
|
|
111
|
+
appSecret?: string;
|
|
112
|
+
}
|
|
113
|
+
export interface DiscordChannelConfig {
|
|
114
|
+
webhookUrl?: string;
|
|
115
|
+
botToken?: string;
|
|
116
|
+
username?: string;
|
|
117
|
+
}
|
|
118
|
+
export interface LineChannelConfig {
|
|
119
|
+
channelAccessToken?: string;
|
|
120
|
+
channelSecret?: string;
|
|
121
|
+
}
|
|
122
|
+
export interface EmailChannelConfig {
|
|
123
|
+
host?: string;
|
|
124
|
+
port?: number;
|
|
125
|
+
secure?: boolean;
|
|
126
|
+
user?: string;
|
|
127
|
+
pass?: string;
|
|
128
|
+
from?: string;
|
|
129
|
+
fromName?: string;
|
|
130
|
+
}
|
|
131
|
+
export interface ChatluChannelConfig {
|
|
132
|
+
/** Matrix homeserver base URL, e.g. `http://127.0.0.1:8008`. */
|
|
133
|
+
homeserverUrl?: string;
|
|
134
|
+
/** Bot user access token (sent as `Authorization: Bearer`). */
|
|
135
|
+
accessToken?: string;
|
|
136
|
+
}
|
|
137
|
+
export interface WebPushChannelConfig {
|
|
138
|
+
/** VAPID contact, e.g. `mailto:you@example.com`. Falls back to `WEBPUSH_VAPID_SUBJECT`. */
|
|
139
|
+
vapidSubject?: string;
|
|
140
|
+
/** VAPID public key. Falls back to `WEBPUSH_VAPID_PUBLIC_KEY`. */
|
|
141
|
+
vapidPublicKey?: string;
|
|
142
|
+
/** VAPID private key. Falls back to `WEBPUSH_VAPID_PRIVATE_KEY`. */
|
|
143
|
+
vapidPrivateKey?: string;
|
|
144
|
+
/** Push TTL in seconds, default 21600. */
|
|
145
|
+
ttl?: number;
|
|
146
|
+
}
|
|
147
|
+
export type ChannelConfig = TelegramChannelConfig | MessengerChannelConfig | DiscordChannelConfig | LineChannelConfig | EmailChannelConfig | ChatluChannelConfig | WebPushChannelConfig | Record<string, string | undefined>;
|
|
148
|
+
export interface Channel {
|
|
149
|
+
_id: string;
|
|
150
|
+
name: string;
|
|
151
|
+
provider: Provider;
|
|
152
|
+
config: ChannelConfig;
|
|
153
|
+
isDefault: boolean;
|
|
154
|
+
createdAt: string;
|
|
155
|
+
updatedAt: string;
|
|
156
|
+
}
|
|
157
|
+
export interface CreateChannelRequest {
|
|
158
|
+
name: string;
|
|
159
|
+
provider: Provider;
|
|
160
|
+
isDefault?: boolean;
|
|
161
|
+
config: ChannelConfig;
|
|
162
|
+
}
|
|
163
|
+
export interface UpdateChannelRequest {
|
|
164
|
+
name?: string;
|
|
165
|
+
provider?: Provider;
|
|
166
|
+
isDefault?: boolean;
|
|
167
|
+
config?: ChannelConfig;
|
|
168
|
+
}
|
|
169
|
+
export interface RegisterWebhookRequest {
|
|
170
|
+
baseUrl?: string;
|
|
171
|
+
}
|
|
172
|
+
export interface RegisterWebhookResult {
|
|
173
|
+
webhookUrl: string;
|
|
174
|
+
raw: unknown;
|
|
175
|
+
}
|
|
176
|
+
export interface Alias {
|
|
177
|
+
_id: string;
|
|
178
|
+
name: string;
|
|
179
|
+
normalizedName: string;
|
|
180
|
+
mappings: Record<string, string>;
|
|
181
|
+
createdAt: string;
|
|
182
|
+
updatedAt: string;
|
|
183
|
+
}
|
|
184
|
+
export interface CreateAliasRequest {
|
|
185
|
+
name: string;
|
|
186
|
+
mappings: Record<string, string>;
|
|
187
|
+
}
|
|
188
|
+
export interface UpdateAliasRequest {
|
|
189
|
+
name?: string;
|
|
190
|
+
mappings?: Record<string, string>;
|
|
191
|
+
}
|
|
192
|
+
export interface ListAliasesQuery {
|
|
193
|
+
/** Default 500, max 500. */
|
|
194
|
+
limit?: number;
|
|
195
|
+
}
|
|
196
|
+
export interface InboundResponse {
|
|
197
|
+
_id: string;
|
|
198
|
+
channel: string;
|
|
199
|
+
channelId: string | null;
|
|
200
|
+
provider?: Provider;
|
|
201
|
+
providerEventId: string;
|
|
202
|
+
providerMessageId: string | null;
|
|
203
|
+
senderId: string | null;
|
|
204
|
+
recipientId: string | null;
|
|
205
|
+
senderDisplayName: string | null;
|
|
206
|
+
messageText: string | null;
|
|
207
|
+
eventType: string | null;
|
|
208
|
+
rawPayload?: unknown;
|
|
209
|
+
matchedNotificationId: string | null;
|
|
210
|
+
matchedAliasId: string | null;
|
|
211
|
+
matchedUserId: string | null;
|
|
212
|
+
correlationMethod?: CorrelationMethod;
|
|
213
|
+
correlationConfidence?: CorrelationConfidence;
|
|
214
|
+
isMatched: boolean;
|
|
215
|
+
receivedAt: string;
|
|
216
|
+
createdAt: string;
|
|
217
|
+
updatedAt: string;
|
|
218
|
+
}
|
|
219
|
+
export interface ListInboundQuery {
|
|
220
|
+
/** Channel name, or provider type. */
|
|
221
|
+
channel?: string;
|
|
222
|
+
matched?: boolean;
|
|
223
|
+
senderId?: string;
|
|
224
|
+
aliasId?: string;
|
|
225
|
+
userId?: string;
|
|
226
|
+
channelId?: string;
|
|
227
|
+
notificationId?: string;
|
|
228
|
+
/** Default 50, max 100. */
|
|
229
|
+
limit?: number;
|
|
230
|
+
}
|
|
231
|
+
export interface PushSubscriptionKeys {
|
|
232
|
+
p256dh: string;
|
|
233
|
+
auth: string;
|
|
234
|
+
}
|
|
235
|
+
export interface PushSubscription {
|
|
236
|
+
_id: string;
|
|
237
|
+
/** Person the browser belongs to, e.g. `larry`. Defaults to `agent`. */
|
|
238
|
+
person: string;
|
|
239
|
+
/** App that registered the subscription, e.g. `cartlu`. */
|
|
240
|
+
app: string;
|
|
241
|
+
endpoint: string;
|
|
242
|
+
keys: PushSubscriptionKeys;
|
|
243
|
+
createdAt: string;
|
|
244
|
+
updatedAt: string;
|
|
245
|
+
}
|
|
246
|
+
export interface RegisterPushSubscriptionRequest {
|
|
247
|
+
/** App name, e.g. `cartlu`. */
|
|
248
|
+
app: string;
|
|
249
|
+
endpoint: string;
|
|
250
|
+
keys: PushSubscriptionKeys;
|
|
251
|
+
/** Person name; defaults to `agent`. */
|
|
252
|
+
person?: string;
|
|
253
|
+
}
|
|
254
|
+
export interface ListPushSubscriptionsQuery {
|
|
255
|
+
person?: string;
|
|
256
|
+
app?: string;
|
|
257
|
+
/** Default 200, max 500. */
|
|
258
|
+
limit?: number;
|
|
259
|
+
}
|
|
260
|
+
export interface DeletePushSubscriptionRequest {
|
|
261
|
+
/** Subscription id. */
|
|
262
|
+
id?: string;
|
|
263
|
+
/** Or the endpoint URL. */
|
|
264
|
+
endpoint?: string;
|
|
265
|
+
}
|
|
266
|
+
export interface HealthResponse {
|
|
267
|
+
ok: boolean;
|
|
268
|
+
workerRunning: boolean;
|
|
269
|
+
notificationCount: number;
|
|
270
|
+
aliasCount: number;
|
|
271
|
+
channelCount: number;
|
|
272
|
+
channels: Channel[];
|
|
273
|
+
providers: Provider[];
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=types.d.ts.map
|
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W,GAAG,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@betterlu/notif",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Client SDK for notif — async Telegram / Messenger / Discord / LINE / email / ChatLu / web push notifications",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "rm -rf dist && tsc",
|
|
20
|
+
"typecheck": "tsc --noEmit",
|
|
21
|
+
"prepublishOnly": "npm run build",
|
|
22
|
+
"clean": "rm -rf dist"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"notif",
|
|
29
|
+
"notifications",
|
|
30
|
+
"telegram",
|
|
31
|
+
"messenger",
|
|
32
|
+
"discord",
|
|
33
|
+
"line",
|
|
34
|
+
"sdk"
|
|
35
|
+
],
|
|
36
|
+
"author": "betterlu",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "^22.10.0",
|
|
43
|
+
"typescript": "^5.7.3"
|
|
44
|
+
}
|
|
45
|
+
}
|