/** Queue/job names and their typed payloads. Shared by the web (producer) and worker (consumer). */ import { z } from "zod"; export const QUEUES = { generateEpisode: "episode.generate", generateSeries: "series.generate", repurpose: "episode.repurpose", reconcileBilling: "billing.reconcile", echo: "system.echo", } as const; export type QueueName = (typeof QUEUES)[keyof typeof QUEUES]; export const generationTypeSchema = z.enum([ "full", "script", "audio", "art", "section", "repurpose", ]); export type GenerationType = z.infer; export const generateEpisodePayloadSchema = z.object({ episodeId: z.string().min(1), /** "full" runs the whole pipeline; the others re-run a single stage. */ type: generationTypeSchema.optional(), /** For type="section", the script section to regenerate. */ sectionId: z.string().optional(), }); export type GenerateEpisodePayload = z.infer; export const repurposePayloadSchema = z.object({ episodeId: z.string().min(1), format: z.enum(["blog", "social_thread", "newsletter"]), }); export type RepurposePayload = z.infer; export const generateSeriesPayloadSchema = z.object({ seriesId: z.string().min(1), }); export type GenerateSeriesPayload = z.infer; export const echoPayloadSchema = z.object({ message: z.string(), episodeId: z.string().optional(), }); export type EchoPayload = z.infer; /** All queues that must exist before send/work. */ export const ALL_QUEUES: QueueName[] = Object.values(QUEUES);