import { InputMessage, OutputMessage, Policy } from './types.ts'; type PolicyTuple = [policy: Policy, opts?: Opts]; type PolicyTuplesRest = { [K in keyof T]: PolicyTuple } /** Processes messages through multiple policies, bailing early on rejection. */ async function pipeline

(msg: InputMessage, policies: [...PolicyTuplesRest

]): Promise { for (const tuple of policies) { const [policy, opts] = tuple; const result = await policy(msg, opts); if (result.action !== 'accept') { return result; } } return { id: msg.event.id, action: 'accept', msg: '', }; } export default pipeline;