@betterlu/notiflu 0.0.0-stage → 2.0.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 +625 -2
- package/dist/client.d.ts +92 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +232 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +7 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/eventReceiver.d.ts +4 -0
- package/dist/eventReceiver.d.ts.map +1 -0
- package/dist/eventReceiver.js +115 -0
- package/dist/eventReceiver.js.map +1 -0
- package/dist/events.d.ts +10 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +439 -0
- package/dist/events.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 +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/signature.d.ts +10 -0
- package/dist/signature.d.ts.map +1 -0
- package/dist/signature.js +29 -0
- package/dist/signature.js.map +1 -0
- package/dist/transport.d.ts +16 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +119 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +1007 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -4
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,1007 @@
|
|
|
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 declare const NOTIFLU_ENV_URL_VAR = "NOTIFLU_URL";
|
|
7
|
+
export declare const ENV_URL_VARS: readonly ["NOTIFLU_URL", "NOTIF_URL"];
|
|
8
|
+
export interface ClientOptions {
|
|
9
|
+
/** Origin only (no `/api`). Defaults to `NOTIFLU_URL`, then `NOTIF_URL`, or `http://localhost:8778`. */
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
fetch?: typeof globalThis.fetch;
|
|
12
|
+
/** Abort each request after this many milliseconds. */
|
|
13
|
+
timeoutMs?: number;
|
|
14
|
+
logger?: EventLogger;
|
|
15
|
+
emitBufferSize?: number;
|
|
16
|
+
emitRetryDelaysMs?: number[];
|
|
17
|
+
/** Maximum concurrent background emit publishes (default 4). */
|
|
18
|
+
emitConcurrency?: number;
|
|
19
|
+
}
|
|
20
|
+
export type Provider = "telegram" | "messenger" | "discord" | "line" | "email" | "chatlu" | "webpush" | "notiflu";
|
|
21
|
+
export type Format = "plain" | "markdown" | "html";
|
|
22
|
+
export type NotificationStatus = "pending" | "processing" | "sent" | "failed";
|
|
23
|
+
export type CorrelationMethod = "unmatched" | "reply_metadata" | "known_sender" | "sender_recent_sent" | "ambiguous";
|
|
24
|
+
export type CorrelationConfidence = "none" | "medium" | "high";
|
|
25
|
+
export interface NotificationOptions {
|
|
26
|
+
disableNotification?: boolean;
|
|
27
|
+
protectContent?: boolean;
|
|
28
|
+
linkPreview?: boolean;
|
|
29
|
+
threadId?: string | number;
|
|
30
|
+
replyToMessageId?: string | number;
|
|
31
|
+
replyMarkup?: unknown;
|
|
32
|
+
messengerTag?: string | false | null;
|
|
33
|
+
username?: string;
|
|
34
|
+
avatarUrl?: string;
|
|
35
|
+
/** Required for email channels. */
|
|
36
|
+
subject?: string;
|
|
37
|
+
/** Web push notification title (webpush channels). Defaults to "Notification". */
|
|
38
|
+
title?: string;
|
|
39
|
+
/** Web push click-through URL (webpush channels). */
|
|
40
|
+
url?: string;
|
|
41
|
+
/** Web push icon path (webpush channels). */
|
|
42
|
+
icon?: string;
|
|
43
|
+
/** Web push badge path (webpush channels). */
|
|
44
|
+
badge?: string;
|
|
45
|
+
/** Web push TTL in seconds (webpush channels). Overrides the channel default. */
|
|
46
|
+
ttl?: number;
|
|
47
|
+
/** Web push target filter: person (webpush channels, used when chatId is omitted). */
|
|
48
|
+
person?: string | string[];
|
|
49
|
+
/** Web push target filter: app (webpush channels, used when chatId is omitted). */
|
|
50
|
+
app?: string;
|
|
51
|
+
/** Web push collapse tag. */
|
|
52
|
+
tag?: string;
|
|
53
|
+
/** Web push interactive action buttons (max 2). */
|
|
54
|
+
actions?: PushAction[] | NotifluAction[];
|
|
55
|
+
/** Web push custom data payload (max 2 KB). */
|
|
56
|
+
data?: Record<string, unknown>;
|
|
57
|
+
/** Web push flag to keep notification active until interacted with. */
|
|
58
|
+
requireInteraction?: boolean;
|
|
59
|
+
/** ChatLu/Matrix in-reply-to event ID. */
|
|
60
|
+
replyToEventId?: string;
|
|
61
|
+
/** ChatLu/Matrix thread root event ID. */
|
|
62
|
+
threadRootEventId?: string;
|
|
63
|
+
/** ChatLu/Matrix event ID to edit/replace (m.replace). */
|
|
64
|
+
editEventId?: string;
|
|
65
|
+
/**
|
|
66
|
+
* ChatLu/Matrix custom event content. Only keys starting with `com.agentlu.`
|
|
67
|
+
* are merged into the Matrix event content (max 16 KB).
|
|
68
|
+
*/
|
|
69
|
+
extraContent?: Record<string, unknown>;
|
|
70
|
+
push?: boolean;
|
|
71
|
+
priority?: "min" | "low" | "default" | "high" | "urgent";
|
|
72
|
+
image?: string;
|
|
73
|
+
lines?: string[];
|
|
74
|
+
progress?: NotifluProgress;
|
|
75
|
+
ongoing?: boolean;
|
|
76
|
+
timeoutAfter?: number;
|
|
77
|
+
countdownTo?: string;
|
|
78
|
+
sensitive?: boolean;
|
|
79
|
+
fullScreen?: boolean;
|
|
80
|
+
dismiss?: boolean;
|
|
81
|
+
}
|
|
82
|
+
export interface PushAction {
|
|
83
|
+
action: string;
|
|
84
|
+
title: string;
|
|
85
|
+
icon?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface NotifluAction {
|
|
88
|
+
id: string;
|
|
89
|
+
title: string;
|
|
90
|
+
url?: string;
|
|
91
|
+
input?: boolean;
|
|
92
|
+
placeholder?: string;
|
|
93
|
+
choices?: string[];
|
|
94
|
+
snooze?: number;
|
|
95
|
+
undoSeconds?: number;
|
|
96
|
+
}
|
|
97
|
+
export interface NotifluProgress {
|
|
98
|
+
value: number;
|
|
99
|
+
max: number;
|
|
100
|
+
label?: string;
|
|
101
|
+
points?: Array<{
|
|
102
|
+
at: number;
|
|
103
|
+
label?: string;
|
|
104
|
+
}>;
|
|
105
|
+
indeterminate?: boolean;
|
|
106
|
+
}
|
|
107
|
+
export interface Recipient {
|
|
108
|
+
chatId?: string | null;
|
|
109
|
+
psid?: string | null;
|
|
110
|
+
}
|
|
111
|
+
export interface SendNotificationRequest {
|
|
112
|
+
/** Channel name, provider type (`telegram` | …), or channel ObjectId. */
|
|
113
|
+
channel?: string;
|
|
114
|
+
/** Alternate field for `channel`. */
|
|
115
|
+
channelId?: string;
|
|
116
|
+
message: string;
|
|
117
|
+
/** Alias name first, else raw chat id. */
|
|
118
|
+
chatId?: string;
|
|
119
|
+
/** Alias-only (back-compat). */
|
|
120
|
+
user?: string;
|
|
121
|
+
/** Alias-only (back-compat). */
|
|
122
|
+
userName?: string;
|
|
123
|
+
recipient?: Recipient;
|
|
124
|
+
format?: Format;
|
|
125
|
+
options?: NotificationOptions;
|
|
126
|
+
source?: string;
|
|
127
|
+
correlationId?: string;
|
|
128
|
+
/**
|
|
129
|
+
* Dedupe key scoped to the channel. Replaying the same key with the same
|
|
130
|
+
* payload returns the existing notification (`deduped: true`); a different
|
|
131
|
+
* payload fails with a 409 `NotifError`.
|
|
132
|
+
*/
|
|
133
|
+
idempotencyKey?: string;
|
|
134
|
+
/** Wait up to 5 seconds for the send to settle before resolving. */
|
|
135
|
+
wait?: boolean;
|
|
136
|
+
/** Wait up to this many milliseconds (0–15000) for the send to settle. */
|
|
137
|
+
waitMs?: number;
|
|
138
|
+
}
|
|
139
|
+
export interface NotificationError {
|
|
140
|
+
code?: string;
|
|
141
|
+
message?: string;
|
|
142
|
+
retryable?: boolean;
|
|
143
|
+
raw?: unknown;
|
|
144
|
+
at?: string;
|
|
145
|
+
}
|
|
146
|
+
export interface Notification {
|
|
147
|
+
_id: string;
|
|
148
|
+
channel: string;
|
|
149
|
+
channelId: string;
|
|
150
|
+
provider: Provider;
|
|
151
|
+
message: string;
|
|
152
|
+
format: Format;
|
|
153
|
+
recipient: Recipient;
|
|
154
|
+
chatId: string | null;
|
|
155
|
+
alias: string | null;
|
|
156
|
+
userName: string | null;
|
|
157
|
+
options: NotificationOptions | null;
|
|
158
|
+
status: NotificationStatus;
|
|
159
|
+
/** Present when the send used an idempotency key. */
|
|
160
|
+
idempotencyKey?: string;
|
|
161
|
+
/** True when this response replayed an existing notification with the same key. */
|
|
162
|
+
deduped?: boolean;
|
|
163
|
+
attempts: number;
|
|
164
|
+
maxAttempts: number;
|
|
165
|
+
nextAttemptAt: string;
|
|
166
|
+
lastAttemptAt: string | null;
|
|
167
|
+
providerMessageId: string | null;
|
|
168
|
+
providerResponse: unknown;
|
|
169
|
+
error: NotificationError | null;
|
|
170
|
+
createdAt: string;
|
|
171
|
+
updatedAt: string;
|
|
172
|
+
source?: string | null;
|
|
173
|
+
correlationId?: string;
|
|
174
|
+
audience?: string[];
|
|
175
|
+
readBy?: Record<string, string>;
|
|
176
|
+
engagement?: NotificationEngagement[];
|
|
177
|
+
pushMirror?: {
|
|
178
|
+
notificationId?: string;
|
|
179
|
+
skipped?: string;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
export interface NotificationEngagement {
|
|
183
|
+
type: "delivered" | "opened" | "dismissed" | "action";
|
|
184
|
+
person: string;
|
|
185
|
+
installationId: string;
|
|
186
|
+
eventId?: string;
|
|
187
|
+
actionId?: string;
|
|
188
|
+
replyText?: string;
|
|
189
|
+
at: string;
|
|
190
|
+
}
|
|
191
|
+
export interface ListNotificationsQuery {
|
|
192
|
+
/** Channel name, or provider type (`telegram` filters by provider). */
|
|
193
|
+
channel?: string;
|
|
194
|
+
status?: NotificationStatus;
|
|
195
|
+
recipient?: string;
|
|
196
|
+
/** Default 50, max 50. */
|
|
197
|
+
limit?: number;
|
|
198
|
+
}
|
|
199
|
+
export interface TelegramChannelConfig {
|
|
200
|
+
botToken?: string;
|
|
201
|
+
webhookSecretToken?: string;
|
|
202
|
+
}
|
|
203
|
+
export interface MessengerChannelConfig {
|
|
204
|
+
pageAccessToken?: string;
|
|
205
|
+
apiVersion?: string;
|
|
206
|
+
verifyToken?: string;
|
|
207
|
+
appSecret?: string;
|
|
208
|
+
}
|
|
209
|
+
export interface DiscordChannelConfig {
|
|
210
|
+
webhookUrl?: string;
|
|
211
|
+
botToken?: string;
|
|
212
|
+
username?: string;
|
|
213
|
+
}
|
|
214
|
+
export interface LineChannelConfig {
|
|
215
|
+
channelAccessToken?: string;
|
|
216
|
+
channelSecret?: string;
|
|
217
|
+
}
|
|
218
|
+
export interface EmailChannelConfig {
|
|
219
|
+
host?: string;
|
|
220
|
+
port?: number;
|
|
221
|
+
secure?: boolean;
|
|
222
|
+
user?: string;
|
|
223
|
+
pass?: string;
|
|
224
|
+
from?: string;
|
|
225
|
+
fromName?: string;
|
|
226
|
+
}
|
|
227
|
+
export interface ChatluChannelConfig {
|
|
228
|
+
/** Matrix homeserver base URL, e.g. `http://127.0.0.1:8008`. */
|
|
229
|
+
homeserverUrl?: string;
|
|
230
|
+
/** Bot user access token (sent as `Authorization: Bearer`). */
|
|
231
|
+
accessToken?: string;
|
|
232
|
+
/** Whether inbound Matrix sync long-polling is enabled. */
|
|
233
|
+
inbound?: boolean;
|
|
234
|
+
/** Forward Matrix annotations to subscribers; subscribers must explicitly opt in with `events: ["m.reaction"]`. Defaults to false. */
|
|
235
|
+
forwardReactions?: boolean;
|
|
236
|
+
/** Advertise `card_actions` in `GET /api/chatlu/bots` so ChatLu sends hidden card taps. Defaults to false. */
|
|
237
|
+
cardActions?: boolean;
|
|
238
|
+
/** Allowed inviter Matrix user IDs who can invite the bot to rooms. */
|
|
239
|
+
allowedInviters?: string[];
|
|
240
|
+
}
|
|
241
|
+
export interface WebPushChannelConfig {
|
|
242
|
+
/** VAPID contact, e.g. `mailto:you@example.com`. Falls back to `WEBPUSH_VAPID_SUBJECT`. */
|
|
243
|
+
vapidSubject?: string;
|
|
244
|
+
/** VAPID public key. Falls back to `WEBPUSH_VAPID_PUBLIC_KEY`. */
|
|
245
|
+
vapidPublicKey?: string;
|
|
246
|
+
/** VAPID private key. Falls back to `WEBPUSH_VAPID_PRIVATE_KEY`. */
|
|
247
|
+
vapidPrivateKey?: string;
|
|
248
|
+
/** Push TTL in seconds, default 21600. */
|
|
249
|
+
ttl?: number;
|
|
250
|
+
}
|
|
251
|
+
export type ChannelConfig = TelegramChannelConfig | MessengerChannelConfig | DiscordChannelConfig | LineChannelConfig | EmailChannelConfig | ChatluChannelConfig | WebPushChannelConfig | Record<string, string | undefined>;
|
|
252
|
+
export interface Channel {
|
|
253
|
+
_id: string;
|
|
254
|
+
name: string;
|
|
255
|
+
provider: Provider;
|
|
256
|
+
config: ChannelConfig;
|
|
257
|
+
isDefault: boolean;
|
|
258
|
+
createdAt: string;
|
|
259
|
+
updatedAt: string;
|
|
260
|
+
}
|
|
261
|
+
export interface CreateChannelRequest {
|
|
262
|
+
name: string;
|
|
263
|
+
provider: Provider;
|
|
264
|
+
isDefault?: boolean;
|
|
265
|
+
config: ChannelConfig;
|
|
266
|
+
}
|
|
267
|
+
export interface UpdateChannelRequest {
|
|
268
|
+
name?: string;
|
|
269
|
+
provider?: Provider;
|
|
270
|
+
isDefault?: boolean;
|
|
271
|
+
config?: ChannelConfig;
|
|
272
|
+
}
|
|
273
|
+
export interface RegisterWebhookRequest {
|
|
274
|
+
baseUrl?: string;
|
|
275
|
+
}
|
|
276
|
+
export interface RegisterWebhookResult {
|
|
277
|
+
webhookUrl: string;
|
|
278
|
+
raw: unknown;
|
|
279
|
+
}
|
|
280
|
+
export interface Alias {
|
|
281
|
+
_id: string;
|
|
282
|
+
name: string;
|
|
283
|
+
normalizedName: string;
|
|
284
|
+
mappings: Record<string, string>;
|
|
285
|
+
createdAt: string;
|
|
286
|
+
updatedAt: string;
|
|
287
|
+
person?: boolean;
|
|
288
|
+
displayName?: string;
|
|
289
|
+
identities?: {
|
|
290
|
+
emails?: string[];
|
|
291
|
+
matrixUserIds?: string[];
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
export interface CreateAliasRequest {
|
|
295
|
+
name: string;
|
|
296
|
+
mappings: Record<string, string>;
|
|
297
|
+
person?: boolean;
|
|
298
|
+
displayName?: string;
|
|
299
|
+
identities?: {
|
|
300
|
+
emails?: string[];
|
|
301
|
+
matrixUserIds?: string[];
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
export interface UpdateAliasRequest {
|
|
305
|
+
name?: string;
|
|
306
|
+
mappings?: Record<string, string>;
|
|
307
|
+
person?: boolean;
|
|
308
|
+
displayName?: string;
|
|
309
|
+
identities?: {
|
|
310
|
+
emails?: string[];
|
|
311
|
+
matrixUserIds?: string[];
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
export interface ListAliasesQuery {
|
|
315
|
+
/** true = person aliases only, false = non-person aliases only. */
|
|
316
|
+
person?: boolean;
|
|
317
|
+
/** Exact alias name (case-insensitive). */
|
|
318
|
+
name?: string;
|
|
319
|
+
/** Default 500, max 500. */
|
|
320
|
+
limit?: number;
|
|
321
|
+
}
|
|
322
|
+
export interface NormalizedInboundReaction {
|
|
323
|
+
key: string;
|
|
324
|
+
targetEventId: string;
|
|
325
|
+
}
|
|
326
|
+
export interface InboundResponse {
|
|
327
|
+
_id: string;
|
|
328
|
+
channel: string;
|
|
329
|
+
channelId: string | null;
|
|
330
|
+
provider?: Provider;
|
|
331
|
+
providerEventId: string;
|
|
332
|
+
providerMessageId: string | null;
|
|
333
|
+
senderId: string | null;
|
|
334
|
+
recipientId: string | null;
|
|
335
|
+
/** Present for a reaction when its membership display name is available. */
|
|
336
|
+
senderDisplayName?: string | null;
|
|
337
|
+
messageText: string | null;
|
|
338
|
+
eventType: string | null;
|
|
339
|
+
/** Present only for opt-in Matrix reaction events. */
|
|
340
|
+
kind?: "reaction";
|
|
341
|
+
reaction?: NormalizedInboundReaction;
|
|
342
|
+
eventId?: string;
|
|
343
|
+
/** Matrix origin-server timestamp in milliseconds. */
|
|
344
|
+
timestamp?: number;
|
|
345
|
+
replyToProviderMessageId?: string | null;
|
|
346
|
+
replyToSender?: string | null;
|
|
347
|
+
threadRootId?: string | null;
|
|
348
|
+
threadRootSender?: string | null;
|
|
349
|
+
rawPayload?: unknown;
|
|
350
|
+
matchedNotificationId: string | null;
|
|
351
|
+
matchedAliasId: string | null;
|
|
352
|
+
matchedUserId: string | null;
|
|
353
|
+
correlationMethod?: CorrelationMethod;
|
|
354
|
+
correlationConfidence?: CorrelationConfidence;
|
|
355
|
+
isMatched: boolean;
|
|
356
|
+
receivedAt: string;
|
|
357
|
+
createdAt: string;
|
|
358
|
+
updatedAt: string;
|
|
359
|
+
}
|
|
360
|
+
export interface ListInboundQuery {
|
|
361
|
+
/** Channel name, or provider type. */
|
|
362
|
+
channel?: string;
|
|
363
|
+
matched?: boolean;
|
|
364
|
+
senderId?: string;
|
|
365
|
+
aliasId?: string;
|
|
366
|
+
userId?: string;
|
|
367
|
+
channelId?: string;
|
|
368
|
+
notificationId?: string;
|
|
369
|
+
/** Default 50, max 100. */
|
|
370
|
+
limit?: number;
|
|
371
|
+
}
|
|
372
|
+
export interface PushSubscriptionKeys {
|
|
373
|
+
p256dh: string;
|
|
374
|
+
auth: string;
|
|
375
|
+
}
|
|
376
|
+
export interface PushSubscription {
|
|
377
|
+
_id: string;
|
|
378
|
+
/** Person the browser belongs to, e.g. `larry`. Defaults to `agent`. */
|
|
379
|
+
person: string;
|
|
380
|
+
/** App that registered the subscription, e.g. `cartlu`. */
|
|
381
|
+
app: string;
|
|
382
|
+
endpoint: string;
|
|
383
|
+
keys: PushSubscriptionKeys;
|
|
384
|
+
createdAt: string;
|
|
385
|
+
updatedAt: string;
|
|
386
|
+
}
|
|
387
|
+
export interface RegisterPushSubscriptionRequest {
|
|
388
|
+
/** App name, e.g. `cartlu`. */
|
|
389
|
+
app: string;
|
|
390
|
+
endpoint: string;
|
|
391
|
+
keys: PushSubscriptionKeys;
|
|
392
|
+
/** Person name; defaults to `agent`. */
|
|
393
|
+
person?: string;
|
|
394
|
+
}
|
|
395
|
+
export interface ListPushSubscriptionsQuery {
|
|
396
|
+
person?: string;
|
|
397
|
+
app?: string;
|
|
398
|
+
/** Exact push endpoint URL. */
|
|
399
|
+
endpoint?: string;
|
|
400
|
+
/** Default 200, max 500. */
|
|
401
|
+
limit?: number;
|
|
402
|
+
}
|
|
403
|
+
export interface DeletePushSubscriptionRequest {
|
|
404
|
+
/** Subscription id. */
|
|
405
|
+
id?: string;
|
|
406
|
+
/** Or the endpoint URL. */
|
|
407
|
+
endpoint?: string;
|
|
408
|
+
}
|
|
409
|
+
export interface ChatluSyncLoopHealth {
|
|
410
|
+
/** Channel id of the ChatLu bot channel. */
|
|
411
|
+
channelId: string;
|
|
412
|
+
/** Channel name used in NotifLu. */
|
|
413
|
+
channel: string;
|
|
414
|
+
/** Whether this bot's sync loop is currently attached. */
|
|
415
|
+
active: boolean;
|
|
416
|
+
/** Matrix user id of the bot, when known. */
|
|
417
|
+
botUserId: string | null;
|
|
418
|
+
/** `ok` after a successful whoami, `rejected` after an M_UNKNOWN_TOKEN. */
|
|
419
|
+
tokenStatus: "ok" | "rejected" | "unknown";
|
|
420
|
+
/** Last successful `/sync` pass. */
|
|
421
|
+
lastSyncAt: string | null;
|
|
422
|
+
/** Last fatal or reset error. */
|
|
423
|
+
lastErrorAt: string | null;
|
|
424
|
+
/** Matrix errcode of the last error (`M_UNKNOWN_POS`, `M_UNKNOWN_TOKEN`, ...). */
|
|
425
|
+
lastErrorCode: string | null;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Per-bot ChatLu sync state. Informational only: a rejected token or stalled
|
|
429
|
+
* sync does not change the top-level `ok` flag or the HTTP status.
|
|
430
|
+
*/
|
|
431
|
+
export interface ChatluSyncHealth {
|
|
432
|
+
running: boolean;
|
|
433
|
+
loops: ChatluSyncLoopHealth[];
|
|
434
|
+
}
|
|
435
|
+
export interface HealthResponse {
|
|
436
|
+
ok: boolean;
|
|
437
|
+
workerRunning: boolean;
|
|
438
|
+
notificationCount: number;
|
|
439
|
+
aliasCount: number;
|
|
440
|
+
channelCount: number;
|
|
441
|
+
channels: Channel[];
|
|
442
|
+
providers: Provider[];
|
|
443
|
+
chatluSync?: ChatluSyncHealth;
|
|
444
|
+
}
|
|
445
|
+
export interface InboundSubscription {
|
|
446
|
+
_id: string;
|
|
447
|
+
channel: string;
|
|
448
|
+
url: string;
|
|
449
|
+
secret?: string;
|
|
450
|
+
/** Event type filters; reactions are delivered only when this explicitly includes `m.reaction`. */
|
|
451
|
+
events?: string[];
|
|
452
|
+
createdAt: string;
|
|
453
|
+
updatedAt: string;
|
|
454
|
+
}
|
|
455
|
+
export interface CreateInboundSubscriptionRequest {
|
|
456
|
+
channel: string;
|
|
457
|
+
url: string;
|
|
458
|
+
secret: string;
|
|
459
|
+
/** Include `m.reaction` to opt in to Matrix reaction webhooks. */
|
|
460
|
+
events?: string[];
|
|
461
|
+
}
|
|
462
|
+
export interface ListInboundSubscriptionsQuery {
|
|
463
|
+
channel?: string;
|
|
464
|
+
limit?: number;
|
|
465
|
+
}
|
|
466
|
+
export interface NormalizedInboundMedia {
|
|
467
|
+
/** Matrix content URI (mxc://server/id) — download with `channelMediaDownload`. */
|
|
468
|
+
mxc: string;
|
|
469
|
+
mimetype?: string;
|
|
470
|
+
size?: number;
|
|
471
|
+
filename?: string;
|
|
472
|
+
duration?: number;
|
|
473
|
+
}
|
|
474
|
+
/** Client-provided speech-to-text for a voice note (`lu.chatlu.transcript`). */
|
|
475
|
+
export interface NormalizedInboundTranscript {
|
|
476
|
+
text: string;
|
|
477
|
+
source?: string | null;
|
|
478
|
+
}
|
|
479
|
+
export interface NormalizedInboundEvent {
|
|
480
|
+
id: string;
|
|
481
|
+
channel: string;
|
|
482
|
+
provider: Provider;
|
|
483
|
+
providerEventId: string;
|
|
484
|
+
/** Present only for opt-in Matrix reaction events. */
|
|
485
|
+
kind?: "reaction";
|
|
486
|
+
reaction?: NormalizedInboundReaction;
|
|
487
|
+
/** Matrix event ID of the reaction itself. */
|
|
488
|
+
eventId?: string;
|
|
489
|
+
/** Matrix origin-server timestamp in milliseconds. */
|
|
490
|
+
timestamp?: number;
|
|
491
|
+
/** Reaction sender display name, included only when available. */
|
|
492
|
+
senderDisplayName?: string | null;
|
|
493
|
+
roomId?: string | null;
|
|
494
|
+
chatId?: string | null;
|
|
495
|
+
sender: string;
|
|
496
|
+
text: string;
|
|
497
|
+
html?: string;
|
|
498
|
+
replyTo?: string;
|
|
499
|
+
/** MXID of the sender of the replied-to event, when NotifLu can resolve it. */
|
|
500
|
+
replyToSender?: string;
|
|
501
|
+
threadRoot?: string;
|
|
502
|
+
/** Matrix event ID of the thread root (same as `threadRoot`). */
|
|
503
|
+
threadRootId?: string;
|
|
504
|
+
/** MXID of the sender of the thread root, when NotifLu can resolve it. */
|
|
505
|
+
threadRootSender?: string;
|
|
506
|
+
/** Matrix event type, e.g. `m.text`, `m.image`, `m.file`, `m.audio`, `m.video`. */
|
|
507
|
+
msgtype?: string;
|
|
508
|
+
/** Present for media events (m.image / m.file / m.audio / m.video). */
|
|
509
|
+
media?: NormalizedInboundMedia;
|
|
510
|
+
/** Client-provided transcript for voice notes, when the sender included one. */
|
|
511
|
+
transcript?: NormalizedInboundTranscript;
|
|
512
|
+
mentionsBot?: boolean;
|
|
513
|
+
/** Distinguishes direct @mentions ("direct") from bare display-name mentions ("display_name") on ChatLu. */
|
|
514
|
+
mentionKind?: "direct" | "display_name";
|
|
515
|
+
isDirect?: boolean;
|
|
516
|
+
receivedAt: string;
|
|
517
|
+
raw: unknown;
|
|
518
|
+
}
|
|
519
|
+
export interface InboundDelivery {
|
|
520
|
+
_id: string;
|
|
521
|
+
subscriptionId: string;
|
|
522
|
+
inboundResponseId: string;
|
|
523
|
+
channel: string;
|
|
524
|
+
provider: Provider;
|
|
525
|
+
url: string;
|
|
526
|
+
status: "pending" | "processing" | "sent" | "failed";
|
|
527
|
+
attempts: number;
|
|
528
|
+
maxAttempts: number;
|
|
529
|
+
nextAttemptAt: string;
|
|
530
|
+
lastAttemptAt: string | null;
|
|
531
|
+
responseStatus: number | null;
|
|
532
|
+
error: unknown;
|
|
533
|
+
createdAt: string;
|
|
534
|
+
updatedAt: string;
|
|
535
|
+
}
|
|
536
|
+
export interface ListInboundDeliveriesQuery {
|
|
537
|
+
subscriptionId?: string;
|
|
538
|
+
channel?: string;
|
|
539
|
+
status?: string;
|
|
540
|
+
limit?: number;
|
|
541
|
+
}
|
|
542
|
+
export interface ChannelTypingRequest {
|
|
543
|
+
roomId: string;
|
|
544
|
+
typing?: boolean;
|
|
545
|
+
timeoutMs?: number;
|
|
546
|
+
}
|
|
547
|
+
export interface ChannelTypingResult {
|
|
548
|
+
roomId: string;
|
|
549
|
+
typing: boolean;
|
|
550
|
+
}
|
|
551
|
+
export interface ChannelReactionRequest {
|
|
552
|
+
/** Target room ID or room alias. */
|
|
553
|
+
roomId: string;
|
|
554
|
+
/** Matrix event ID to react to. */
|
|
555
|
+
eventId: string;
|
|
556
|
+
/** Reaction key — typically an emoji. */
|
|
557
|
+
key: string;
|
|
558
|
+
}
|
|
559
|
+
export interface ChannelReactionResult {
|
|
560
|
+
roomId: string;
|
|
561
|
+
eventId: string;
|
|
562
|
+
key: string;
|
|
563
|
+
/** Matrix event ID of the sent `m.reaction`. */
|
|
564
|
+
messageId: string | null;
|
|
565
|
+
}
|
|
566
|
+
export interface ChannelMediaDownloadResult {
|
|
567
|
+
/** Content type reported by the homeserver (defaults to application/octet-stream). */
|
|
568
|
+
contentType: string;
|
|
569
|
+
/** Raw media bytes. */
|
|
570
|
+
bytes: ArrayBuffer;
|
|
571
|
+
/** Original file name when the homeserver reports one. */
|
|
572
|
+
filename?: string;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Media message request for a ChatLu/Matrix channel. `file` is a base64 string
|
|
576
|
+
* (data: URIs accepted) or raw bytes (`Uint8Array` / `ArrayBuffer`), which the
|
|
577
|
+
* SDK base64-encodes for transport.
|
|
578
|
+
*/
|
|
579
|
+
export interface ChannelMediaRequest {
|
|
580
|
+
/** Target room ID or room alias. */
|
|
581
|
+
roomId?: string;
|
|
582
|
+
/** Alternate field for `roomId`. */
|
|
583
|
+
chatId?: string;
|
|
584
|
+
file: string | Uint8Array | ArrayBuffer;
|
|
585
|
+
filename?: string;
|
|
586
|
+
/** Content type; defaults from a data: URI or application/octet-stream. */
|
|
587
|
+
mimetype?: string;
|
|
588
|
+
/** Auto-detected from mimetype (image/* → m.image, audio/* → m.audio, video/* → m.video, else m.file). */
|
|
589
|
+
msgtype?: "m.image" | "m.file" | "m.audio" | "m.video";
|
|
590
|
+
/** Optional caption; the file name moves to `info.filename` (MSC2530). */
|
|
591
|
+
caption?: string;
|
|
592
|
+
/** Matrix event ID to reply to. */
|
|
593
|
+
replyToEventId?: string;
|
|
594
|
+
/** Matrix thread root event ID. */
|
|
595
|
+
threadRootEventId?: string;
|
|
596
|
+
/**
|
|
597
|
+
* Custom event content for ChatLu/Matrix. Only keys starting with
|
|
598
|
+
* `com.agentlu.` are merged (max 16 KB).
|
|
599
|
+
*/
|
|
600
|
+
extraContent?: Record<string, unknown>;
|
|
601
|
+
}
|
|
602
|
+
export interface ChannelMediaResult {
|
|
603
|
+
/** Matrix event ID of the sent `m.room.message`. */
|
|
604
|
+
eventId: string | null;
|
|
605
|
+
/** Matrix content URI of the uploaded file. */
|
|
606
|
+
mxc: string;
|
|
607
|
+
roomId: string;
|
|
608
|
+
msgtype: string;
|
|
609
|
+
}
|
|
610
|
+
export interface ChannelDirectRoomResult {
|
|
611
|
+
roomId: string;
|
|
612
|
+
/** True when a new room was created, false when an existing DM was reused. */
|
|
613
|
+
created: boolean;
|
|
614
|
+
}
|
|
615
|
+
export interface ChannelProfile {
|
|
616
|
+
userId: string;
|
|
617
|
+
displayName: string | null;
|
|
618
|
+
avatarUrl: string | null;
|
|
619
|
+
}
|
|
620
|
+
export type ChannelProfileAvatar = {
|
|
621
|
+
mxc: string;
|
|
622
|
+
} | {
|
|
623
|
+
base64: string;
|
|
624
|
+
mimetype: string;
|
|
625
|
+
filename?: string;
|
|
626
|
+
};
|
|
627
|
+
export type SetChannelProfileRequest = {
|
|
628
|
+
displayName: string;
|
|
629
|
+
avatar?: ChannelProfileAvatar;
|
|
630
|
+
} | {
|
|
631
|
+
displayName?: string;
|
|
632
|
+
avatar: ChannelProfileAvatar;
|
|
633
|
+
};
|
|
634
|
+
export interface ChannelRoom {
|
|
635
|
+
roomId: string;
|
|
636
|
+
name: string | null;
|
|
637
|
+
isDirect: boolean;
|
|
638
|
+
memberCount: number;
|
|
639
|
+
}
|
|
640
|
+
export interface ChannelRoomMessage {
|
|
641
|
+
providerEventId: string;
|
|
642
|
+
sender: string;
|
|
643
|
+
text: string;
|
|
644
|
+
msgtype: string;
|
|
645
|
+
media: NormalizedInboundMedia | null;
|
|
646
|
+
transcript: NormalizedInboundTranscript | null;
|
|
647
|
+
replyTo: string | null;
|
|
648
|
+
threadRootId: string | null;
|
|
649
|
+
/** ISO timestamp from the Matrix event, when present. */
|
|
650
|
+
timestamp: string | null;
|
|
651
|
+
}
|
|
652
|
+
export interface ChannelRoomMessages {
|
|
653
|
+
roomId: string;
|
|
654
|
+
/** Newest first. */
|
|
655
|
+
events: ChannelRoomMessage[];
|
|
656
|
+
}
|
|
657
|
+
export interface CreateChannelRoomRequest {
|
|
658
|
+
/** Room name, 1–100 characters. */
|
|
659
|
+
name: string;
|
|
660
|
+
/** Matrix user IDs to invite (max 50). Agent bots that will join must be included; the channel bot's own MXID is ignored. */
|
|
661
|
+
invite?: string[];
|
|
662
|
+
}
|
|
663
|
+
export interface ChannelCreatedRoom {
|
|
664
|
+
roomId: string;
|
|
665
|
+
name: string;
|
|
666
|
+
}
|
|
667
|
+
export interface ChannelJoinResult {
|
|
668
|
+
joined: true;
|
|
669
|
+
roomId: string;
|
|
670
|
+
}
|
|
671
|
+
export interface ChannelLeaveResult {
|
|
672
|
+
left: true;
|
|
673
|
+
}
|
|
674
|
+
export type NotifluPerson = "larry" | "misa";
|
|
675
|
+
export interface AppPerson {
|
|
676
|
+
name: NotifluPerson;
|
|
677
|
+
displayName: string;
|
|
678
|
+
count30d: number;
|
|
679
|
+
}
|
|
680
|
+
export interface AppDevice {
|
|
681
|
+
_id: string;
|
|
682
|
+
installationId: string;
|
|
683
|
+
person: NotifluPerson;
|
|
684
|
+
deviceName?: string;
|
|
685
|
+
model?: string;
|
|
686
|
+
appVersion?: string;
|
|
687
|
+
sdkInt?: number;
|
|
688
|
+
createdAt: string;
|
|
689
|
+
updatedAt: string;
|
|
690
|
+
lastSeenAt: string;
|
|
691
|
+
}
|
|
692
|
+
export interface RegisterAppDeviceRequest {
|
|
693
|
+
installationId: string;
|
|
694
|
+
person: NotifluPerson;
|
|
695
|
+
fcmToken: string;
|
|
696
|
+
deviceName?: string;
|
|
697
|
+
model?: string;
|
|
698
|
+
appVersion?: string;
|
|
699
|
+
sdkInt?: number;
|
|
700
|
+
}
|
|
701
|
+
export interface AppNotificationDelivery {
|
|
702
|
+
id: string;
|
|
703
|
+
channel: string;
|
|
704
|
+
provider: Provider;
|
|
705
|
+
status: NotificationStatus;
|
|
706
|
+
error: NotificationError | null;
|
|
707
|
+
createdAt: string | null;
|
|
708
|
+
lastAttemptAt: string | null;
|
|
709
|
+
devices?: Array<{
|
|
710
|
+
installationId: string;
|
|
711
|
+
person: string | null;
|
|
712
|
+
status: string | null;
|
|
713
|
+
deliveredAt: string | null;
|
|
714
|
+
openedAt: string | null;
|
|
715
|
+
}>;
|
|
716
|
+
}
|
|
717
|
+
export interface AppLastReply {
|
|
718
|
+
text: string;
|
|
719
|
+
sender: string | null;
|
|
720
|
+
at: string | null;
|
|
721
|
+
}
|
|
722
|
+
export interface AppFeedItem {
|
|
723
|
+
id: string;
|
|
724
|
+
correlationId: string;
|
|
725
|
+
source: string | null;
|
|
726
|
+
title: string;
|
|
727
|
+
message: string;
|
|
728
|
+
format: Format;
|
|
729
|
+
priority: NonNullable<NotificationOptions["priority"]>;
|
|
730
|
+
createdAt: string | null;
|
|
731
|
+
url: string | null;
|
|
732
|
+
image: string | null;
|
|
733
|
+
audience: string[];
|
|
734
|
+
read: boolean;
|
|
735
|
+
tag: string | null;
|
|
736
|
+
progress: NotifluProgress | null;
|
|
737
|
+
actions: Array<PushAction | NotifluAction>;
|
|
738
|
+
deliveries: AppNotificationDelivery[];
|
|
739
|
+
lastReply?: AppLastReply;
|
|
740
|
+
}
|
|
741
|
+
export interface AppNotificationDetail extends AppFeedItem {
|
|
742
|
+
engagement: NotificationEngagement[];
|
|
743
|
+
inboundResponses: Array<AppLastReply & {
|
|
744
|
+
id: string;
|
|
745
|
+
channel: string;
|
|
746
|
+
provider: Provider;
|
|
747
|
+
}>;
|
|
748
|
+
}
|
|
749
|
+
export interface AppFeedQuery {
|
|
750
|
+
person: NotifluPerson;
|
|
751
|
+
scope?: "mine" | "household";
|
|
752
|
+
cursor?: string;
|
|
753
|
+
limit?: number;
|
|
754
|
+
provider?: Provider;
|
|
755
|
+
source?: string;
|
|
756
|
+
status?: NotificationStatus;
|
|
757
|
+
q?: string;
|
|
758
|
+
unread?: 1;
|
|
759
|
+
}
|
|
760
|
+
export interface AppFeedPage {
|
|
761
|
+
items: AppFeedItem[];
|
|
762
|
+
nextCursor: string | null;
|
|
763
|
+
}
|
|
764
|
+
export interface AppEventRequest {
|
|
765
|
+
installationId: string;
|
|
766
|
+
person: NotifluPerson;
|
|
767
|
+
type: NotificationEngagement["type"];
|
|
768
|
+
eventId?: string;
|
|
769
|
+
actionId?: string;
|
|
770
|
+
replyText?: string;
|
|
771
|
+
}
|
|
772
|
+
export interface AppEventResult extends NotificationEngagement {
|
|
773
|
+
queuedDeliveries: number;
|
|
774
|
+
duplicate?: boolean;
|
|
775
|
+
}
|
|
776
|
+
export interface AppSourceSummary {
|
|
777
|
+
source: string;
|
|
778
|
+
count7d: number;
|
|
779
|
+
/** Oldest to newest, seven daily counts. */
|
|
780
|
+
daily: number[];
|
|
781
|
+
lastAt: string | null;
|
|
782
|
+
}
|
|
783
|
+
export interface AppTestPushResult {
|
|
784
|
+
id: string;
|
|
785
|
+
status: NotificationStatus;
|
|
786
|
+
}
|
|
787
|
+
export type NotifluEventUrgency = "fyi" | "today" | "now";
|
|
788
|
+
/** Event sequence cursor. The events API serializes bigint sequence values as JSON numbers. */
|
|
789
|
+
export type EventSeq = number;
|
|
790
|
+
export interface NotifluEvent {
|
|
791
|
+
specversion: "1.0";
|
|
792
|
+
id: string;
|
|
793
|
+
source: string;
|
|
794
|
+
type: string;
|
|
795
|
+
subject?: string;
|
|
796
|
+
time: string;
|
|
797
|
+
datacontenttype: "application/json";
|
|
798
|
+
dataschema?: string;
|
|
799
|
+
data: Record<string, unknown>;
|
|
800
|
+
title?: string;
|
|
801
|
+
urgency: NotifluEventUrgency;
|
|
802
|
+
expiresat: string;
|
|
803
|
+
person?: string;
|
|
804
|
+
causationid?: string;
|
|
805
|
+
correlationid?: string;
|
|
806
|
+
seq: EventSeq;
|
|
807
|
+
receivedat: string;
|
|
808
|
+
hops: number;
|
|
809
|
+
}
|
|
810
|
+
export interface PublishInput {
|
|
811
|
+
id?: string;
|
|
812
|
+
source: string;
|
|
813
|
+
type: string;
|
|
814
|
+
subject?: string;
|
|
815
|
+
specversion?: "1.0";
|
|
816
|
+
time?: string;
|
|
817
|
+
datacontenttype?: "application/json";
|
|
818
|
+
dataschema?: string;
|
|
819
|
+
data: Record<string, unknown>;
|
|
820
|
+
title?: string;
|
|
821
|
+
urgency?: NotifluEventUrgency;
|
|
822
|
+
expiresat?: string;
|
|
823
|
+
person?: string;
|
|
824
|
+
causationid?: string;
|
|
825
|
+
correlationid?: string;
|
|
826
|
+
}
|
|
827
|
+
export interface EventCausation {
|
|
828
|
+
id: string;
|
|
829
|
+
correlationid?: string;
|
|
830
|
+
}
|
|
831
|
+
export interface PublishEventsOptions {
|
|
832
|
+
causedBy?: EventCausation;
|
|
833
|
+
}
|
|
834
|
+
export type PublishOptions = PublishEventsOptions;
|
|
835
|
+
export interface PublishedEvent {
|
|
836
|
+
id: string;
|
|
837
|
+
seq: EventSeq;
|
|
838
|
+
duplicate: boolean;
|
|
839
|
+
}
|
|
840
|
+
export interface PublishEventsResult {
|
|
841
|
+
events: PublishedEvent[];
|
|
842
|
+
}
|
|
843
|
+
export type PublishResult = PublishEventsResult;
|
|
844
|
+
export type EventLogHandler = (message: string, context?: unknown) => void;
|
|
845
|
+
export interface EventLogger {
|
|
846
|
+
debug?: EventLogHandler;
|
|
847
|
+
info?: EventLogHandler;
|
|
848
|
+
warn?: EventLogHandler;
|
|
849
|
+
error?: EventLogHandler;
|
|
850
|
+
log?: EventLogHandler;
|
|
851
|
+
}
|
|
852
|
+
export interface EmitEventsOptions extends PublishEventsOptions {
|
|
853
|
+
logger?: EventLogger;
|
|
854
|
+
retryDelaysMs?: number[];
|
|
855
|
+
}
|
|
856
|
+
export type EmitOptions = EmitEventsOptions;
|
|
857
|
+
export interface ListEventsQuery {
|
|
858
|
+
after?: EventSeq;
|
|
859
|
+
types?: string | string[];
|
|
860
|
+
source?: string;
|
|
861
|
+
limit?: number;
|
|
862
|
+
}
|
|
863
|
+
export interface ListEventsResult {
|
|
864
|
+
events: NotifluEvent[];
|
|
865
|
+
next: EventSeq | null;
|
|
866
|
+
}
|
|
867
|
+
export type EventSubscriptionOrigin = "catalog" | "api" | "legacy-inbound";
|
|
868
|
+
export type EventSubscriptionPayloadFormat = "envelope" | "legacy-inbound";
|
|
869
|
+
export type EventSubscriptionWhere = Record<string, unknown>;
|
|
870
|
+
export interface EventSubscription {
|
|
871
|
+
id: string;
|
|
872
|
+
origin: EventSubscriptionOrigin;
|
|
873
|
+
service: string | null;
|
|
874
|
+
name: string;
|
|
875
|
+
types: string[];
|
|
876
|
+
exclude: string[];
|
|
877
|
+
sources: string[];
|
|
878
|
+
where: EventSubscriptionWhere;
|
|
879
|
+
path: string | null;
|
|
880
|
+
url: string | null;
|
|
881
|
+
hasSecret: boolean;
|
|
882
|
+
maxAttempts: number;
|
|
883
|
+
enabled: boolean;
|
|
884
|
+
startSeq: EventSeq;
|
|
885
|
+
format: EventSubscriptionPayloadFormat;
|
|
886
|
+
createdAt: string;
|
|
887
|
+
updatedAt: string;
|
|
888
|
+
}
|
|
889
|
+
export interface CreateEventSubscriptionRequest {
|
|
890
|
+
name?: string;
|
|
891
|
+
types: string[];
|
|
892
|
+
exclude?: string[];
|
|
893
|
+
sources?: string[];
|
|
894
|
+
where?: EventSubscriptionWhere;
|
|
895
|
+
service?: string;
|
|
896
|
+
url: string;
|
|
897
|
+
secret?: string;
|
|
898
|
+
enabled?: boolean;
|
|
899
|
+
maxAttempts?: number;
|
|
900
|
+
startSeq?: EventSeq;
|
|
901
|
+
}
|
|
902
|
+
export interface ListEventSubscriptionsQuery {
|
|
903
|
+
origin?: EventSubscriptionOrigin;
|
|
904
|
+
service?: string;
|
|
905
|
+
enabled?: boolean;
|
|
906
|
+
limit?: number;
|
|
907
|
+
}
|
|
908
|
+
export interface ListEventSubscriptionsResult {
|
|
909
|
+
subscriptions: EventSubscription[];
|
|
910
|
+
}
|
|
911
|
+
export interface DeleteEventSubscriptionResult {
|
|
912
|
+
deleted: true;
|
|
913
|
+
id: string;
|
|
914
|
+
}
|
|
915
|
+
export type EventDeliveryStatus = "pending" | "delivering" | "delivered" | "dead";
|
|
916
|
+
export interface EventDelivery {
|
|
917
|
+
id: string;
|
|
918
|
+
eventSeq: EventSeq;
|
|
919
|
+
eventId: string;
|
|
920
|
+
eventSource: string;
|
|
921
|
+
eventType: string;
|
|
922
|
+
subscriptionId: string;
|
|
923
|
+
status: EventDeliveryStatus;
|
|
924
|
+
attempts: number;
|
|
925
|
+
nextAttemptAt: string;
|
|
926
|
+
lastStatus: number | null;
|
|
927
|
+
lastError: string | null;
|
|
928
|
+
deliveredAt: string | null;
|
|
929
|
+
createdAt: string;
|
|
930
|
+
updatedAt: string;
|
|
931
|
+
}
|
|
932
|
+
export interface ListEventDeliveriesQuery {
|
|
933
|
+
subscription?: string;
|
|
934
|
+
status?: EventDeliveryStatus;
|
|
935
|
+
eventSeq?: number;
|
|
936
|
+
limit?: number;
|
|
937
|
+
}
|
|
938
|
+
export interface ListEventDeliveriesResult {
|
|
939
|
+
deliveries: EventDelivery[];
|
|
940
|
+
}
|
|
941
|
+
export interface RedriveEventDeliveryResult {
|
|
942
|
+
redriven: number;
|
|
943
|
+
delivery: EventDelivery;
|
|
944
|
+
}
|
|
945
|
+
export interface RedriveEventSubscriptionOptions {
|
|
946
|
+
status?: "dead";
|
|
947
|
+
}
|
|
948
|
+
export interface RedriveEventSubscriptionResult {
|
|
949
|
+
redriven: number;
|
|
950
|
+
}
|
|
951
|
+
export interface EventStats {
|
|
952
|
+
events: {
|
|
953
|
+
total: number;
|
|
954
|
+
last24h: number;
|
|
955
|
+
};
|
|
956
|
+
deliveries: Record<EventDeliveryStatus, number>;
|
|
957
|
+
subscriptions: {
|
|
958
|
+
total: number;
|
|
959
|
+
enabled: number;
|
|
960
|
+
};
|
|
961
|
+
catalog: {
|
|
962
|
+
lastSyncAt: string | null;
|
|
963
|
+
degraded: boolean;
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
export interface NotifluEventsNamespace {
|
|
967
|
+
publish: (input: PublishInput | PublishInput[], options?: PublishEventsOptions) => Promise<PublishEventsResult>;
|
|
968
|
+
emit: (input: PublishInput | PublishInput[], options?: EmitEventsOptions) => Promise<void>;
|
|
969
|
+
list: (query?: ListEventsQuery) => Promise<ListEventsResult>;
|
|
970
|
+
get: (source: string, id: string) => Promise<NotifluEvent>;
|
|
971
|
+
subscriptions: {
|
|
972
|
+
list: (query?: ListEventSubscriptionsQuery) => Promise<ListEventSubscriptionsResult>;
|
|
973
|
+
create: (request: CreateEventSubscriptionRequest) => Promise<EventSubscription>;
|
|
974
|
+
delete: (id: string) => Promise<DeleteEventSubscriptionResult>;
|
|
975
|
+
};
|
|
976
|
+
deliveries: {
|
|
977
|
+
list: (query?: ListEventDeliveriesQuery) => Promise<ListEventDeliveriesResult>;
|
|
978
|
+
};
|
|
979
|
+
redrive: (deliveryId: string) => Promise<RedriveEventDeliveryResult>;
|
|
980
|
+
redriveSubscription: (subscriptionId: string, options?: RedriveEventSubscriptionOptions) => Promise<RedriveEventSubscriptionResult>;
|
|
981
|
+
stats: () => Promise<EventStats>;
|
|
982
|
+
}
|
|
983
|
+
export type EventDeliveryHeaderValue = string | string[] | undefined;
|
|
984
|
+
export type EventDeliveryHeaders = Record<string, EventDeliveryHeaderValue> | {
|
|
985
|
+
get: (name: string) => string | null | undefined;
|
|
986
|
+
};
|
|
987
|
+
export interface ParseEventDeliveryInput {
|
|
988
|
+
headers: EventDeliveryHeaders;
|
|
989
|
+
body?: unknown;
|
|
990
|
+
rawBody?: string | Uint8Array;
|
|
991
|
+
secret?: string;
|
|
992
|
+
}
|
|
993
|
+
export interface ParsedEventDelivery {
|
|
994
|
+
event: NotifluEvent;
|
|
995
|
+
deliveryId?: string;
|
|
996
|
+
attempt?: number;
|
|
997
|
+
subscription?: string;
|
|
998
|
+
}
|
|
999
|
+
export interface CreateEventDeduperOptions {
|
|
1000
|
+
max?: number;
|
|
1001
|
+
}
|
|
1002
|
+
export interface EventDeduper {
|
|
1003
|
+
seen: (event: Pick<NotifluEvent, "source" | "id">) => boolean;
|
|
1004
|
+
clear: () => void;
|
|
1005
|
+
readonly size: number;
|
|
1006
|
+
}
|
|
1007
|
+
//# sourceMappingURL=types.d.ts.map
|