feat(dashboard): align contracts and production build

This commit is contained in:
jjbrunton committed 2026-08-08 14:58:27 +01:00
1 parent 69d560d5c5
commit d6d29badcd
9 files changed
+189 -48

No files matched your search

+10 -45
View File
@@ -1,46 +1,11 @@
import { z } from 'zod';
export {
ControlResponseSchema as controlResponseSchema,
StatsResponseSchema as botStatsSchema,
TimersResponseSchema as timersSchema,
} from '../../../../packages/api-contracts/src/index.js';
const activityItemSchema = z.object({
timestamp: z.number(),
type: z.enum(['sent', 'skipped', 'response', 'error', 'info', 'debug']),
message: z.string(),
recipient: z.string().optional(),
imageUrl: z.string().optional(),
});
export const botStatsSchema = z.object({
isRunning: z.boolean(),
dryRunMode: z.boolean(),
totalProcessed: z.number(),
totalMessagesSent: z.number(),
totalResponses: z.number(),
responseRate: z.number(),
messagesThisHour: z.number(),
maxMessagesPerHour: z.number(),
subreddits: z.array(z.object({ name: z.string(), type: z.enum(['image', 'chat']) })),
targetGenders: z.array(z.string()),
recentActivity: z.array(activityItemSchema),
invitationCooldown: z
.object({
until: z.number(),
reason: z.string(),
redditCode: z.string().nullable(),
})
.nullable(),
});
export const timersSchema = z.object({
nextMessageAvailableAt: z.number().nullable(),
hourlyResetAt: z.number(),
isHourlyLimitReached: z.boolean(),
messagesRemaining: z.number(),
});
export const controlResponseSchema = z.object({
success: z.literal(true),
running: z.boolean(),
});
export type BotStats = z.infer<typeof botStatsSchema>;
export type Timers = z.infer<typeof timersSchema>;
export type ControlResponse = z.infer<typeof controlResponseSchema>;
export type {
ControlResponse,
StatsResponse as BotStats,
TimersResponse as Timers,
} from '../../../../packages/api-contracts/src/index.js';