2026-06-07 03:58:32 -04:00
|
|
|
/** Queue/job names and their typed payloads. Shared by the web (producer) and worker (consumer). */
|
|
|
|
|
|
2026-06-20 20:59:03 -04:00
|
|
|
import { z } from "zod";
|
|
|
|
|
|
2026-06-07 03:58:32 -04:00
|
|
|
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];
|
|
|
|
|
|
2026-06-20 20:59:03 -04:00
|
|
|
export const generationTypeSchema = z.enum([
|
|
|
|
|
"full",
|
|
|
|
|
"script",
|
|
|
|
|
"audio",
|
|
|
|
|
"art",
|
|
|
|
|
"section",
|
|
|
|
|
"repurpose",
|
|
|
|
|
]);
|
|
|
|
|
export type GenerationType = z.infer<typeof generationTypeSchema>;
|
|
|
|
|
|
|
|
|
|
export const generateEpisodePayloadSchema = z.object({
|
|
|
|
|
episodeId: z.string().min(1),
|
2026-06-07 03:58:32 -04:00
|
|
|
/** "full" runs the whole pipeline; the others re-run a single stage. */
|
2026-06-20 20:59:03 -04:00
|
|
|
type: generationTypeSchema.optional(),
|
2026-06-07 03:58:32 -04:00
|
|
|
/** For type="section", the script section to regenerate. */
|
2026-06-20 20:59:03 -04:00
|
|
|
sectionId: z.string().optional(),
|
|
|
|
|
});
|
|
|
|
|
export type GenerateEpisodePayload = z.infer<typeof generateEpisodePayloadSchema>;
|
|
|
|
|
|
|
|
|
|
export const repurposePayloadSchema = z.object({
|
|
|
|
|
episodeId: z.string().min(1),
|
|
|
|
|
format: z.enum(["blog", "social_thread", "newsletter"]),
|
|
|
|
|
});
|
|
|
|
|
export type RepurposePayload = z.infer<typeof repurposePayloadSchema>;
|
|
|
|
|
|
|
|
|
|
export const generateSeriesPayloadSchema = z.object({
|
|
|
|
|
seriesId: z.string().min(1),
|
|
|
|
|
});
|
|
|
|
|
export type GenerateSeriesPayload = z.infer<typeof generateSeriesPayloadSchema>;
|
|
|
|
|
|
|
|
|
|
export const echoPayloadSchema = z.object({
|
|
|
|
|
message: z.string(),
|
|
|
|
|
episodeId: z.string().optional(),
|
|
|
|
|
});
|
|
|
|
|
export type EchoPayload = z.infer<typeof echoPayloadSchema>;
|
2026-06-07 03:58:32 -04:00
|
|
|
|
|
|
|
|
/** All queues that must exist before send/work. */
|
|
|
|
|
export const ALL_QUEUES: QueueName[] = Object.values(QUEUES);
|