import type { WsFrame } from '@boocode/contracts/ws-frames';
import type { DeltaEmitter } from './delta-emitter.js';

type ControlJobFrame = Extract<WsFrame, { type: 'control_job' }>;
export type JobType = ControlJobFrame['jobType'];
export type JobStatus = ControlJobFrame['status'];

export interface PublishJobParams {
  seq: number;
  jobType: JobType;
  jobId: string;
  status: JobStatus;
  detail?: Record<string, unknown>;
}

export function publishJob(emitter: DeltaEmitter, params: PublishJobParams): void {
  emitter.publish({ type: 'control_job' as const, ...params });
}
