No JSDoc comment in source yet.
API
@Component()
export class MessagingBindingsRepo implements MessagingBindings {
@Use() private readonly db!: Db;
find(sessionId: string, channel: string): MessagingBindingRow | null;
findEnabled(sessionId: string): MessagingBindingRow | null;
listForSession(sessionId: string): MessagingBindingRow[];
findEnabledByAccount(channel: string, accountId: string): MessagingBindingRow | null;
listAll(): MessagingBindingRow[];
upsert(args: {
sessionId: string;
channel: string;
accountId: string;
config: Record<string, unknown>;
linePerMessage?: boolean;
finalReplyOnly?: boolean;
renderMarkdown?: boolean;
}): MessagingBindingRow;
setEnabled(sessionId: string, channel: string, enabled: boolean): void;
recordChat(sessionId: string, channel: string, chatId: string, isDirect: boolean): void;
recordInboundWatermark(sessionId: string, channel: string, messageId: string | null): void;
delete(sessionId: string, channel: string): void;
deleteSession(sessionId: string): void;
}Dependencies & Wiring
Extracted from class decoratorsMethods (11)
find
find(sessionId: string, channel: string): MessagingBindingRow | nullThe Session's saved config of ONE channel (null when that channel is not configured).
stringstringMessagingBindingRow | nullfindEnabled
findEnabled(sessionId: string): MessagingBindingRow | nullThe Session's enabled binding — at most one exists (route-enforced); null when all are dark.
stringMessagingBindingRow | nulllistForSession
listForSession(sessionId: string): MessagingBindingRow[]Every channel config the Session has saved, in stable channel order.
stringMessagingBindingRow[]findEnabledByAccount
findEnabledByAccount(channel: string, accountId: string): MessagingBindingRow | nullWhichever binding currently holds this account's connection — null while every Session
that saved the account keeps it dark. At most one row can match, for the same reason
findEnabled is at-most-one: the state route refuses the second enable, and its
guard-then-flip runs in one synchronous block, so two requests cannot interleave
between the check and the write.
stringstringMessagingBindingRow | nulllistAll
listAll(): MessagingBindingRow[]MessagingBindingRow[]upsert
upsert(args: { sessionId: string; channel: string; accountId: string; config: Record<string, unknown>; linePerMessage?: boolean; finalReplyOnly?: boolean; renderMarkdown?: boolean; }): MessagingBindingRowCreate or replace the Session's config for one channel — credentials/config only:
enabled is intent state the state toggle owns, so an insert starts disabled and an
update keeps the stored value. linePerMessage, finalReplyOnly and renderMarkdown are
ordinary saved fields this write does own, and an omitted one keeps the stored value (a
fresh row starts with the first two off and the third ON, matching the column defaults).
It cannot fail on another Session: the same account saved elsewhere is none of this
write's business, since only enabling is exclusive.
Re-saving a Session's own binding keeps its last-chat memory, so a settings edit never
loses the reply target — unless the account changed, whose chats are unrelated: the
remembered chat is dropped so replies can never land in the old bot's conversation.
{ sessionId: string; channel: string; accountId: string; config: Record<string, unknown>; linePerMessage?: boolean; finalReplyOnly?: boolean; renderMarkdown?: boolean; }MessagingBindingRowsetEnabled
setEnabled(sessionId: string, channel: string, enabled: boolean): voidThe state toggle's write: flip one channel's connection intent (the bridge then aligns the live connection).
stringstringbooleanvoidrecordChat
recordChat(sessionId: string, channel: string, chatId: string, isDirect: boolean): voidRemember the most recent inbound chat (the reply and test-message target; chats are channel-scoped).
stringstringstringbooleanvoidrecordInboundWatermark
recordInboundWatermark(sessionId: string, channel: string, messageId: string | null): voidAdvance the bridge's durable redelivery watermark to a message it has FINISHED with. Deliberately its own statement, issued after the work rather than folded into recordChat: a watermark written first would, if the process died before the Task existed, mark as processed a message nothing ever ran — and the seeding in MessagingBridge.connect would then swallow the channel's replay of it.
A null messageId (a channel that mints no message identity) leaves the column
alone rather than clearing it: such a message opts out of the dedupe entirely, so it
has nothing to say about the last message that did carry one.
stringstringstring | nullvoiddelete
delete(sessionId: string, channel: string): voidDrop one channel's config.
stringstringvoiddeleteSession
deleteSession(sessionId: string): voidDrop every channel config of a Session (the session-delete cascade).
stringvoid