import { Cfc, CurrentPrincipal, handler, NAME, pattern, RepresentsCurrentUser, UI, type VNode, Writable, WriteAuthorizedBy, } from "commonfabric"; /** A JSON-encoded connector command. */ type CommandValue = string; export const sendSecondCommand = handler< void, { commands: Writable; draft: Writable } >((_, { commands, draft }) => { commands.push(draft.get()); }); type SecondCommandQueue = RepresentsCurrentUser< Cfc< WriteAuthorizedBy, { ownerPrincipal: CurrentPrincipal } > >; export interface SecondInput { commands: Writable; } export interface SecondOutput { [NAME]: string; [UI]: VNode; commandQueue: SecondCommandQueue; commandAuthorization?: WriteAuthorizedBy; } /** A second producer with a writer of its own, for isolation between queues. */ export default pattern(({ commands }) => { const draft = new Writable.perSession(""); return { [NAME]: "Second command producer fixture", [UI]: ( Send ), commandQueue: commands, }; });