@theokit/gateway 0.11.0 → 0.12.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/CHANGELOG.md +133 -0
- package/README.md +63 -3
- package/dist/index.cjs +231 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +199 -17
- package/dist/index.d.ts +199 -17
- package/dist/index.js +231 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -247,6 +247,89 @@ interface MatrixMessageEvent extends BaseMessageEvent {
|
|
|
247
247
|
readonly raw: unknown;
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
|
+
/** Signal-specific event variant (B-354), received from `signal-cli jsonRpc`. */
|
|
251
|
+
interface SignalMessageEvent extends BaseMessageEvent {
|
|
252
|
+
readonly platform: "signal";
|
|
253
|
+
readonly signal: {
|
|
254
|
+
/** Envelope timestamp (ms since epoch); Signal's own message id. */
|
|
255
|
+
readonly timestamp: number;
|
|
256
|
+
/** Sender's phone number, when signal-cli knows it. */
|
|
257
|
+
readonly sourceNumber?: string;
|
|
258
|
+
/** Sender's account UUID, when signal-cli knows it. */
|
|
259
|
+
readonly sourceUuid?: string;
|
|
260
|
+
/** Group id, present only for a group message. */
|
|
261
|
+
readonly groupId?: string;
|
|
262
|
+
/** Raw signal-cli envelope — escape hatch. */
|
|
263
|
+
readonly raw: unknown;
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/** iMessage-specific event variant (B-355), received from `imsg rpc` on a signed-in Mac. */
|
|
267
|
+
interface IMessageMessageEvent extends BaseMessageEvent {
|
|
268
|
+
readonly platform: "imessage";
|
|
269
|
+
readonly imessage: {
|
|
270
|
+
/** `imsg`'s numeric chat id; the send target for a reply. */
|
|
271
|
+
readonly chatId: number;
|
|
272
|
+
/** Messages' own message GUID. */
|
|
273
|
+
readonly guid: string;
|
|
274
|
+
/** `imsg`'s `is_group` for the chat; agrees with `channel.type === "group"`. */
|
|
275
|
+
readonly isGroup: boolean;
|
|
276
|
+
/** Participant handles (phone numbers or emails) as `imsg` reports them for the chat. */
|
|
277
|
+
readonly participants: readonly string[];
|
|
278
|
+
/** Raw `imsg` notification payload — escape hatch. */
|
|
279
|
+
readonly raw: unknown;
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
/** Google Chat-specific event variant (B-356), posted to the Chat app's HTTPS endpoint. */
|
|
283
|
+
interface GoogleChatMessageEvent extends BaseMessageEvent {
|
|
284
|
+
readonly platform: "google_chat";
|
|
285
|
+
readonly google_chat: {
|
|
286
|
+
/** The message's resource name, `spaces/<space>/messages/<message>`. */
|
|
287
|
+
readonly messageName: string;
|
|
288
|
+
/** The space's resource name, `spaces/<space>`; the send target for a reply. */
|
|
289
|
+
readonly spaceName: string;
|
|
290
|
+
/** The space's `spaceType` (`SPACE`, `GROUP_CHAT` or `DIRECT_MESSAGE`), when Chat sent one. */
|
|
291
|
+
readonly spaceType?: string;
|
|
292
|
+
/** The thread's resource name, when the message is in a thread. */
|
|
293
|
+
readonly threadName?: string;
|
|
294
|
+
/** Raw Chat event — escape hatch. */
|
|
295
|
+
readonly raw: unknown;
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
/** IRC-specific event variant (B-357), read from a PRIVMSG on the adapter's own connection. */
|
|
299
|
+
interface IrcMessageEvent extends BaseMessageEvent {
|
|
300
|
+
readonly platform: "irc";
|
|
301
|
+
readonly irc: {
|
|
302
|
+
/** Where the PRIVMSG was addressed: a channel, `#name`, or the adapter's own nick for a DM. */
|
|
303
|
+
readonly target: string;
|
|
304
|
+
/** The sender's nick, from the line's prefix. */
|
|
305
|
+
readonly nick: string;
|
|
306
|
+
/** True for a CTCP ACTION (`/me`); `text` then holds the action without its CTCP framing. */
|
|
307
|
+
readonly action: boolean;
|
|
308
|
+
/** The line's IRCv3 message tags, unescaped; empty when the server sent none. */
|
|
309
|
+
readonly tags: Readonly<Record<string, string>>;
|
|
310
|
+
/** The raw line as the server sent it, without CRLF — escape hatch. */
|
|
311
|
+
readonly raw: string;
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Nextcloud Talk event variant (B-358), read from a bot webhook `Create` activity that carried a
|
|
316
|
+
* signature the adapter verified.
|
|
317
|
+
*/
|
|
318
|
+
interface NextcloudTalkMessageEvent extends BaseMessageEvent {
|
|
319
|
+
readonly platform: "nextcloud_talk";
|
|
320
|
+
readonly nextcloud_talk: {
|
|
321
|
+
/** The conversation's token, the `target.id` of the activity; a reply goes to it. */
|
|
322
|
+
readonly roomToken: string;
|
|
323
|
+
/** Talk's id for the message, the activity's `object.id`. */
|
|
324
|
+
readonly messageId: string;
|
|
325
|
+
/** Who wrote it, as Talk names actors: `users/<id>`, `guests/<id>`, `bots/<id>`… */
|
|
326
|
+
readonly actorId: string;
|
|
327
|
+
/** The id of the message this one answers, when it is a reply. */
|
|
328
|
+
readonly replyToId?: string;
|
|
329
|
+
/** The parsed webhook body — escape hatch. */
|
|
330
|
+
readonly raw: unknown;
|
|
331
|
+
};
|
|
332
|
+
}
|
|
250
333
|
/**
|
|
251
334
|
* The open registry every platform's inbound event is filed under.
|
|
252
335
|
*
|
|
@@ -262,7 +345,7 @@ interface MatrixMessageEvent extends BaseMessageEvent {
|
|
|
262
345
|
* ```typescript
|
|
263
346
|
* declare module "@theokit/gateway" {
|
|
264
347
|
* interface PlatformEventRegistry {
|
|
265
|
-
*
|
|
348
|
+
* acmechat: AcmeChatMessageEvent;
|
|
266
349
|
* }
|
|
267
350
|
* }
|
|
268
351
|
* ```
|
|
@@ -280,6 +363,11 @@ interface PlatformEventRegistry {
|
|
|
280
363
|
mattermost: MattermostMessageEvent;
|
|
281
364
|
line: LineMessageEvent;
|
|
282
365
|
matrix: MatrixMessageEvent;
|
|
366
|
+
signal: SignalMessageEvent;
|
|
367
|
+
imessage: IMessageMessageEvent;
|
|
368
|
+
google_chat: GoogleChatMessageEvent;
|
|
369
|
+
irc: IrcMessageEvent;
|
|
370
|
+
nextcloud_talk: NextcloudTalkMessageEvent;
|
|
283
371
|
}
|
|
284
372
|
/**
|
|
285
373
|
* `true` only for `any` — the one type that would otherwise swallow the union.
|
|
@@ -309,7 +397,7 @@ type LiteralKey<K> = string extends K ? never : K;
|
|
|
309
397
|
* `TS2339: Property 'telegram' does not exist on type 'never'`.
|
|
310
398
|
*
|
|
311
399
|
* It also fixes a second measured defect for free. Mapping over `keyof` directly is HOMOMORPHIC, so
|
|
312
|
-
* an OPTIONAL entry (`
|
|
400
|
+
* an OPTIONAL entry (`acmechat?: Event`, a shape an author writes by accident) kept its modifier and
|
|
313
401
|
* injected `undefined` into the union — `TS18048: 'e' is possibly 'undefined'` on a plain `switch`.
|
|
314
402
|
* Mapping over a computed key set is not homomorphic and drops the modifier. A `-?` was written
|
|
315
403
|
* here first as an explicit belt; the gate showed it could not be made to matter while this type is
|
|
@@ -332,11 +420,11 @@ type LiteralKeysOf<R> = keyof {
|
|
|
332
420
|
* earlier version of this docblock said it was — measured false twice over. Filtering the VALUE
|
|
333
421
|
* alone left two shapes that break every consumer rather than only their author:
|
|
334
422
|
* `{ [key: string]: … }` made `keyof` yield `string | number`, so the union and the platform name
|
|
335
|
-
* both collapsed to `never`; and `
|
|
423
|
+
* both collapsed to `never`; and `acmechat?: …` kept its optional modifier through a homomorphic
|
|
336
424
|
* mapping and injected `undefined` into the union. Both are handled above — the first by
|
|
337
425
|
* {@link LiteralKeysOf}, the second by the `-?` on the mapping. What remains true, and is the
|
|
338
426
|
* honest version of the original claim:
|
|
339
|
-
* a `Record<PlatformName, T>` written against the
|
|
427
|
+
* a `Record<PlatformName, T>` written against the first-party platforms still fails to compile, because the rejected
|
|
340
428
|
* key is gone from `PlatformName` while the consumer's literal map is not. What the exclusion buys
|
|
341
429
|
* is that the failure is a missing-key error at the consumer's own map rather than a silent loss
|
|
342
430
|
* of narrowing everywhere.
|
|
@@ -412,7 +500,8 @@ interface SendResult {
|
|
|
412
500
|
* Abstract base for all platform adapters.
|
|
413
501
|
*
|
|
414
502
|
* Subclasses implement `connect`, `disconnect`, `sendMessage`, `onInbound`.
|
|
415
|
-
* Lifecycle defaults (`startTyping`, `stopTyping`) noop unless overridden
|
|
503
|
+
* Lifecycle defaults (`startTyping`, `stopTyping`) noop unless overridden; `editMessage` refuses
|
|
504
|
+
* with `edit_unsupported` unless overridden.
|
|
416
505
|
*
|
|
417
506
|
* **Contract:**
|
|
418
507
|
* - `connect()` is idempotent. Calling twice returns true the second time.
|
|
@@ -422,6 +511,15 @@ interface SendResult {
|
|
|
422
511
|
* - `onInbound(handler)` returns an unsubscribe function. EC-H: calling
|
|
423
512
|
* `onInbound` twice replaces the previous handler — does NOT stack.
|
|
424
513
|
* - `sendMessage` with empty text returns `{ ok: false, code: "empty_text" }`.
|
|
514
|
+
* - `supportsEdit` says whether the adapter has an edit call. It is `false` unless the adapter
|
|
515
|
+
* overrides it, and it MUST NOT change with `connect()`. `true` does not promise that every
|
|
516
|
+
* edit is accepted: an adapter whose injected client lacks the edit call (Matrix) still answers
|
|
517
|
+
* `edit_unsupported`, which a caller handles like any other refusal.
|
|
518
|
+
* - `editMessage` returns a `SendResult` and never throws on platform errors. The default refuses
|
|
519
|
+
* with `edit_unsupported` and makes no platform call.
|
|
520
|
+
* - Edits are not ordered by the adapter. Two edits of one message id in flight at once reach the
|
|
521
|
+
* platform in either order, so a caller awaits each edit before the next, or keeps one in flight
|
|
522
|
+
* and coalesces to the latest text.
|
|
425
523
|
*
|
|
426
524
|
* @public
|
|
427
525
|
*/
|
|
@@ -442,8 +540,8 @@ declare abstract class BasePlatformAdapter {
|
|
|
442
540
|
* process nor the connection. Two adapters used to discard the rejection with `void`, which under
|
|
443
541
|
* Node's default ends the process, and two more reported it as a platform-client error, sending
|
|
444
542
|
* whoever debugged their own handler to the wrong repository. Eight had converged on the right
|
|
445
|
-
* behaviour without anything writing it down; `tests/lint/adapter-contract.test.ts` now holds
|
|
446
|
-
*
|
|
543
|
+
* behaviour without anything writing it down; `tests/lint/adapter-contract.test.ts` now holds every
|
|
544
|
+
* adapter to it.
|
|
447
545
|
*/
|
|
448
546
|
abstract onInbound(handler: (event: MessageEvent) => Promise<void>): () => void;
|
|
449
547
|
/**
|
|
@@ -476,6 +574,27 @@ declare abstract class BasePlatformAdapter {
|
|
|
476
574
|
* is taken from `this.platform`, which is the only part that differed between them.
|
|
477
575
|
*/
|
|
478
576
|
protected runHandler(handler: ((event: MessageEvent) => Promise<void>) | undefined, event: MessageEvent): Promise<"ok" | "no_handler" | "handler_threw">;
|
|
577
|
+
/**
|
|
578
|
+
* Whether {@link editMessage} can replace the text of a message this adapter sent.
|
|
579
|
+
*
|
|
580
|
+
* Read it before starting a preview: on `false`, send the final text instead. An adapter sets
|
|
581
|
+
* it at construction and MUST NOT change it with `connect()`. Annotated as `boolean` so that an
|
|
582
|
+
* edit-capable adapter can override it with `true`.
|
|
583
|
+
*/
|
|
584
|
+
readonly supportsEdit: boolean;
|
|
585
|
+
/**
|
|
586
|
+
* Replace the text of a message this adapter sent, keeping its id.
|
|
587
|
+
*
|
|
588
|
+
* Returns `{ ok: true, messageId }` on success and a `SendResult` error otherwise; it never
|
|
589
|
+
* throws on platform errors. An edit-capable adapter applies, with no request, the same local
|
|
590
|
+
* checks its `sendMessage` applies (such as `empty_text`, and `not_connected` where the send
|
|
591
|
+
* checks the connection), plus `invalid_message_id`, and `edit_too_long` where the adapter
|
|
592
|
+
* splits text: an edit that would need more than one platform message is refused, never split.
|
|
593
|
+
*
|
|
594
|
+
* Default: refuses with `edit_unsupported`, makes no platform call, and checks nothing else
|
|
595
|
+
* first, so capability is answered before input.
|
|
596
|
+
*/
|
|
597
|
+
editMessage(_messageId: string, _out: OutboundMessage): Promise<SendResult>;
|
|
479
598
|
/** Lifecycle: emit a typing indicator. Default: noop. */
|
|
480
599
|
startTyping(_channelId: string): Promise<void>;
|
|
481
600
|
/** Lifecycle: stop the typing indicator. Default: noop. */
|
|
@@ -627,6 +746,16 @@ interface CreateChannelsResult {
|
|
|
627
746
|
* missing key, and its `create` is never called. A `GatewayConfigurationError` thrown by `create`
|
|
628
747
|
* is reported the same way. Any other throw is a defect, not a configuration fault, and propagates.
|
|
629
748
|
*
|
|
749
|
+
* Only one adapter per platform is built, because the runner routes replies and `stop()` by
|
|
750
|
+
* platform. The first entry built for a platform wins; a later entry for that platform is rejected
|
|
751
|
+
* with a `GatewayConfigurationError` coded `duplicate_channel`, before its required fields are
|
|
752
|
+
* checked, and its `create` is never called. An entry rejected for its configuration built
|
|
753
|
+
* nothing, so it does not claim its platform.
|
|
754
|
+
*
|
|
755
|
+
* The runner keys adapters by the adapter's own `platform`, so an adapter must report the platform
|
|
756
|
+
* its descriptor declares. One that reports another is discarded unconnected and its entry is
|
|
757
|
+
* rejected with a `GatewayConfigurationError` coded `platform_mismatch`; it claims no platform.
|
|
758
|
+
*
|
|
630
759
|
* @public
|
|
631
760
|
*/
|
|
632
761
|
declare function createChannels(entries: ReadonlyArray<ChannelEntry>): CreateChannelsResult;
|
|
@@ -888,6 +1017,8 @@ declare class GatewayRunner {
|
|
|
888
1017
|
/** Slash command registry: name → handler (word-boundary match, EC-A). */
|
|
889
1018
|
private readonly commands;
|
|
890
1019
|
private startResult;
|
|
1020
|
+
/** The start that has not settled yet, shared by every overlapping `start()` call. */
|
|
1021
|
+
private startInFlight;
|
|
891
1022
|
private stopped;
|
|
892
1023
|
constructor(opts: GatewayRunnerOptions);
|
|
893
1024
|
/**
|
|
@@ -903,13 +1034,32 @@ declare class GatewayRunner {
|
|
|
903
1034
|
* Resolves with what connected. A second call after the first resolved returns the same result
|
|
904
1035
|
* without connecting again.
|
|
905
1036
|
*
|
|
1037
|
+
* Overlapping calls share one start; a start overtaken by stop resolves with no adapter connected.
|
|
1038
|
+
* A call made before `stop()` while another is still connecting connects nothing and settles
|
|
1039
|
+
* with it; a call made after `stop()` throws `runner_stopped`. When `stop()` runs before the
|
|
1040
|
+
* connect settles, the adapters that connected are disconnected, no inbound dispatch is wired,
|
|
1041
|
+
* and the start resolves `{ connected: [], failed }`, keeping the `"isolate"` failures. Under
|
|
1042
|
+
* `"rollback"`, a connect that fails still rejects the start.
|
|
1043
|
+
*
|
|
1044
|
+
* Under `connectFailure: "rollback"`, every connect settles before the rollback, so a failing
|
|
1045
|
+
* start rejects only once its slowest connect settles, as a successful one resolves only then.
|
|
1046
|
+
*
|
|
1047
|
+
* An adapter whose `disconnect()` fails while a start rolls back, or while a start that `stop()`
|
|
1048
|
+
* overtook gives its adapters back, is named on stderr with the error redacted; how the start
|
|
1049
|
+
* settles does not change.
|
|
1050
|
+
*
|
|
906
1051
|
* @throws {GatewayLifecycleError} `runner_stopped` — the runner was already
|
|
907
1052
|
* stopped. A stopped runner is spent; construct a new one.
|
|
908
|
-
* @throws {Error} under the default `connectFailure: "rollback"`, the first connect failure, after
|
|
909
|
-
* adapters that did connect were disconnected.
|
|
1053
|
+
* @throws {Error} under the default `connectFailure: "rollback"`, the first connect failure, after
|
|
1054
|
+
* every connect settled and the adapters that did connect were disconnected.
|
|
910
1055
|
*/
|
|
911
1056
|
start(): Promise<StartResult>;
|
|
912
|
-
|
|
1057
|
+
private runStart;
|
|
1058
|
+
/**
|
|
1059
|
+
* All or nothing: when any connect fails, disconnect the adapters that did connect, then rethrow
|
|
1060
|
+
* the first failure. Every connect settles before the rollback: rolling back while one is still
|
|
1061
|
+
* pending left that adapter live once it connected.
|
|
1062
|
+
*/
|
|
913
1063
|
private connectAllOrRollback;
|
|
914
1064
|
/**
|
|
915
1065
|
* Connect every adapter and keep the ones that connected. The `async` wrapper turns a
|
|
@@ -920,7 +1070,12 @@ declare class GatewayRunner {
|
|
|
920
1070
|
private wireInbound;
|
|
921
1071
|
/**
|
|
922
1072
|
* Stop the runner. Drains in-flight handlers up to `drainTimeoutMs`,
|
|
923
|
-
* then disconnects adapters. Idempotent (EC-E).
|
|
1073
|
+
* then disconnects adapters. Idempotent (EC-E). A disconnect that fails does not make `stop()`
|
|
1074
|
+
* reject and does not stop the other disconnects; it is written to stderr, redacted, naming the
|
|
1075
|
+
* platform.
|
|
1076
|
+
*
|
|
1077
|
+
* An adapter still connecting under an in-flight start is released when that start settles;
|
|
1078
|
+
* `stop()` does not wait for it.
|
|
924
1079
|
*/
|
|
925
1080
|
stop(): Promise<void>;
|
|
926
1081
|
/**
|
|
@@ -1056,7 +1211,7 @@ interface ChannelRendering {
|
|
|
1056
1211
|
*
|
|
1057
1212
|
* @param platform - the destination, typically `event.platform` of the inbound message
|
|
1058
1213
|
* @returns the `{ translate, format }` pair for that platform
|
|
1059
|
-
* @throws RangeError when `platform` is not one of the
|
|
1214
|
+
* @throws RangeError when `platform` is not one of the platforms this package knows. Answering with
|
|
1060
1215
|
* nothing would let the presenter fall back to identity and `markdown`, which is the defect this
|
|
1061
1216
|
* function exists to remove.
|
|
1062
1217
|
* @public
|
|
@@ -1179,7 +1334,7 @@ declare function toDialect(text: string, platform: string): string;
|
|
|
1179
1334
|
*
|
|
1180
1335
|
* The core had no HTTP concern, and `express` is a peer dependency of exactly the two packages that
|
|
1181
1336
|
* duplicate this — so the obvious objection to putting it here is that it would impose express on
|
|
1182
|
-
*
|
|
1337
|
+
* every adapter.
|
|
1183
1338
|
*
|
|
1184
1339
|
* It does not, because nothing here imports express. Every shape below is structural: a request is
|
|
1185
1340
|
* whatever has `readableEnded` and `on`, a listener is whatever has `listen` and `close`. The
|
|
@@ -1194,16 +1349,22 @@ declare function toDialect(text: string, platform: string): string;
|
|
|
1194
1349
|
interface RawBodyRequest {
|
|
1195
1350
|
readonly readableEnded?: boolean;
|
|
1196
1351
|
readonly complete?: boolean;
|
|
1352
|
+
readonly headers?: Readonly<Record<string, string | string[] | undefined>>;
|
|
1197
1353
|
setEncoding(encoding: string): unknown;
|
|
1198
1354
|
on(event: string, listener: (arg: never) => void): unknown;
|
|
1199
1355
|
}
|
|
1200
1356
|
/** What a started listener must be able to do. `http.Server` satisfies it. */
|
|
1201
1357
|
interface ListenerLike {
|
|
1202
1358
|
close(cb?: (err?: Error) => void): unknown;
|
|
1359
|
+
/** Where Express 4's `listen` reports a failure to bind; `http.Server` has it. */
|
|
1360
|
+
once?(event: "error", listener: (err: Error) => void): unknown;
|
|
1203
1361
|
}
|
|
1204
|
-
/**
|
|
1362
|
+
/**
|
|
1363
|
+
* What can start a listener. Express's app satisfies it: Express 5 passes a failure to bind to the
|
|
1364
|
+
* callback, Express 4 only emits it on the returned server.
|
|
1365
|
+
*/
|
|
1205
1366
|
interface ListenableApp {
|
|
1206
|
-
listen(port: number, cb: () => void): ListenerLike;
|
|
1367
|
+
listen(port: number, cb: (err?: Error) => void): ListenerLike;
|
|
1207
1368
|
}
|
|
1208
1369
|
/**
|
|
1209
1370
|
* Load a peer dependency, or fail with a message that says what to install.
|
|
@@ -1218,9 +1379,27 @@ declare function loadPeer<T>(load: () => Promise<unknown>, onMissing: () => neve
|
|
|
1218
1379
|
* Every provider signs the exact bytes, so a body that was parsed and re-serialised hashes
|
|
1219
1380
|
* differently and fails verification for a correct request. The bytes are attached as `rawBody`.
|
|
1220
1381
|
*
|
|
1382
|
+
* With `maxBytes`, a body larger than that many bytes is refused before it is held. The rest of
|
|
1383
|
+
* the stream is read and dropped, and once it ends the middleware answers 413 with the JSON body
|
|
1384
|
+
* `{ "error": "request body too large" }` itself; `next` is not called. A route that must stay
|
|
1385
|
+
* public (a provider dials in) sets it, or any client can stream a body until the heap runs out.
|
|
1386
|
+
* The refusal is answered here rather than handed to `next` as an error because Express's final
|
|
1387
|
+
* handler writes an error as an HTML page carrying its stack whenever `NODE_ENV` is not
|
|
1388
|
+
* `production`, and these routes answer anyone.
|
|
1389
|
+
*
|
|
1390
|
+
* The middleware settles once: after a refusal, more data, the end of the stream or a stream
|
|
1391
|
+
* error do nothing, and after a stream error the end of the stream does nothing.
|
|
1392
|
+
*
|
|
1221
1393
|
* @param tag the package name for the diagnostic, so a reader knows which router is complaining
|
|
1394
|
+
* @param options `maxBytes`, the largest body accepted; no limit when absent
|
|
1395
|
+
* @throws RangeError when `maxBytes` is not a finite number of zero or more
|
|
1222
1396
|
*/
|
|
1223
|
-
declare function rawBodyCapture(tag: string): (rawReq: unknown,
|
|
1397
|
+
declare function rawBodyCapture(tag: string, options?: RawBodyCaptureOptions): (rawReq: unknown, rawRes: unknown, next: (err?: unknown) => void) => void;
|
|
1398
|
+
/** Options for {@link rawBodyCapture}. */
|
|
1399
|
+
interface RawBodyCaptureOptions {
|
|
1400
|
+
/** The largest body accepted, in bytes. A larger one is refused with 413. No limit when absent. */
|
|
1401
|
+
readonly maxBytes?: number;
|
|
1402
|
+
}
|
|
1224
1403
|
/**
|
|
1225
1404
|
* The start/stop pair, with the latches that make a restart a restart.
|
|
1226
1405
|
*
|
|
@@ -1231,6 +1410,9 @@ declare function rawBodyCapture(tag: string): (rawReq: unknown, _res: unknown, n
|
|
|
1231
1410
|
*
|
|
1232
1411
|
* `injected` is for the case where the caller owns the app: there is no listener to open or close,
|
|
1233
1412
|
* and `start()`/`stop()` must still be callable and idempotent.
|
|
1413
|
+
*
|
|
1414
|
+
* `start()` rejects with the error the bind failed with (`EADDRINUSE` for a port another listener
|
|
1415
|
+
* holds), under Express 4 and 5 alike, and a later `start()` tries again.
|
|
1234
1416
|
*/
|
|
1235
1417
|
declare function listenerLifecycle(opts: {
|
|
1236
1418
|
readonly app: ListenableApp;
|
|
@@ -1241,4 +1423,4 @@ declare function listenerLifecycle(opts: {
|
|
|
1241
1423
|
stop(): Promise<void>;
|
|
1242
1424
|
};
|
|
1243
1425
|
|
|
1244
|
-
export { type AgentIdStrategy, type BaseMessageEvent, BasePlatformAdapter, CREDENTIAL_SHAPES, type ChannelConfigField, type ChannelDescriptor, type ChannelEntry, type ChannelRejection, type ChannelRendering, type ChannelWebhook, type ChunkByGraphemeOptions, type ChunkTextOptions, type ConnectFailure, type CoveredShape, type CreateChannelsResult, type DeliveryRequest, DeliveryRouter, type DeliveryTarget, type DiscordMessageEvent, type EmailMessageEvent, GatewayConfigurationError, type GatewayConfigurationErrorOptions, type GatewayContext, type GatewayHandler, type GatewayHook, GatewayLifecycleError, type GatewayLifecycleErrorOptions, GatewayRunner, type GatewayRunnerOptions, type HookDecision, HookExecutor, type HookName, type IngestResult, type LineMessageEvent, type ListenableApp, type ListenerLike, type MatrixMessageEvent, type MattermostMessageEvent, type MessageEvent, type OnErrorContext, type OutboundMessage, type PlatformEventRegistry, type PlatformName, type PostOutboundContext, type PreInboundContext, type RawBodyRequest, type SMSMessageEvent, type SendResult, SessionRouter, type SlackMessageEvent, type StartResult, type TeamsMessageEvent, type TelegramMessageEvent, type UncoveredShape, type WebhookRequest, type WhatsAppMessageEvent, channelRendering, chunkByGrapheme, chunkText, createChannels, defaultStrategy, listenerLifecycle, loadPeer, maskShapes, rawBodyCapture, redactSecrets, toDialect };
|
|
1426
|
+
export { type AgentIdStrategy, type BaseMessageEvent, BasePlatformAdapter, CREDENTIAL_SHAPES, type ChannelConfigField, type ChannelDescriptor, type ChannelEntry, type ChannelRejection, type ChannelRendering, type ChannelWebhook, type ChunkByGraphemeOptions, type ChunkTextOptions, type ConnectFailure, type CoveredShape, type CreateChannelsResult, type DeliveryRequest, DeliveryRouter, type DeliveryTarget, type DiscordMessageEvent, type EmailMessageEvent, GatewayConfigurationError, type GatewayConfigurationErrorOptions, type GatewayContext, type GatewayHandler, type GatewayHook, GatewayLifecycleError, type GatewayLifecycleErrorOptions, GatewayRunner, type GatewayRunnerOptions, type GoogleChatMessageEvent, type HookDecision, HookExecutor, type HookName, type IMessageMessageEvent, type IngestResult, type IrcMessageEvent, type LineMessageEvent, type ListenableApp, type ListenerLike, type MatrixMessageEvent, type MattermostMessageEvent, type MessageEvent, type NextcloudTalkMessageEvent, type OnErrorContext, type OutboundMessage, type PlatformEventRegistry, type PlatformName, type PostOutboundContext, type PreInboundContext, type RawBodyCaptureOptions, type RawBodyRequest, type SMSMessageEvent, type SendResult, SessionRouter, type SignalMessageEvent, type SlackMessageEvent, type StartResult, type TeamsMessageEvent, type TelegramMessageEvent, type UncoveredShape, type WebhookRequest, type WhatsAppMessageEvent, channelRendering, chunkByGrapheme, chunkText, createChannels, defaultStrategy, listenerLifecycle, loadPeer, maskShapes, rawBodyCapture, redactSecrets, toDialect };
|