import { Router } from "express"; import { Message, Space, WebhookHandler, WebhookHandler as WebhookHandler$1 } from "@spectrum-ts/core"; //#region src/index.d.ts /** * The minimal structural surface of a Spectrum instance the plugin needs. Kept * structural (rather than importing the generic `SpectrumInstance`) * so the plugin stays decoupled from provider typing; a real instance is * assignable via its raw (`{ body, headers }`) webhook overload. */ interface WebhookReceiver { webhook(request: { body: Uint8Array | ArrayBuffer; headers?: Record; }, handler: WebhookHandler$1): Promise<{ body: Uint8Array; headers: Record; status: number; }>; } export interface SpectrumPluginOptions { /** The Spectrum instance returned by `await Spectrum({...})`. */ app: WebhookReceiver; /** * Invoked once per inbound message, fire-and-forget after the response — the * same `(space, message)` contract as `app.webhook(request, handler)`. Covers * both native Spectrum webhooks and fusor webhooks identically. */ onMessage: WebhookHandler$1; /** * Route the webhook is mounted on. * * @default "/spectrum/webhook" */ path?: string; } /** * Mount a Spectrum webhook endpoint on an Express app. * * @example * ```ts * import express from "express"; * import { Spectrum } from "spectrum-ts"; * import { spectrum } from "@spectrum-ts/express"; * * const app = await Spectrum({ ..., webhookSecret: process.env.SPECTRUM_WEBHOOK_SECRET }); * * const server = express(); * server.use(spectrum({ // mount before any global express.json() * app, * onMessage: async (space, message) => { * if (message.content.type === "text") await space.send(`echo: ${message.content.text}`); * }, * })); * server.listen(3000); * ``` */ export declare function spectrum(options: SpectrumPluginOptions): Router; //#endregion export type { Message, Space, WebhookHandler };