feat: add shared dashboard API contracts

This commit is contained in:
jjbrunton committed 2026-08-08 14:52:06 +01:00
1 parent 939cf408a0
commit 59c3a61a88
14 files changed
+648

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
import { z } from 'zod';
import { ActivityItemSchema } from './activity.js';
const PerformanceFields = {
totalSent: z.number(),
totalResponses: z.number(),
responseRate: z.number(),
};
export const StatsResponseSchema = z.strictObject({
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.strictObject({
name: z.string(),
type: z.union([z.literal('image'), z.literal('chat')]),
})),
targetGenders: z.array(z.string()),
recentActivity: z.array(ActivityItemSchema),
invitationCooldown: z.strictObject({
until: z.number(),
reason: z.string(),
redditCode: z.string().nullable(),
}).nullable(),
});
export const TimersResponseSchema = z.strictObject({
nextMessageAvailableAt: z.number().nullable(),
hourlyResetAt: z.number(),
isHourlyLimitReached: z.boolean(),
messagesRemaining: z.number(),
});
export const SubredditPerformanceSchema = z.strictObject({
subreddit: z.string(),
...PerformanceFields,
});
export const SubredditPerformanceResponseSchema = z.array(SubredditPerformanceSchema);
export const StrategyPerformanceSchema = z.strictObject({
strategyId: z.string(),
...PerformanceFields,
configured: z.boolean().optional(),
});
export const StrategyPerformanceResponseSchema = z.array(StrategyPerformanceSchema);
export const DailyTrendSchema = z.strictObject({
date: z.string(),
...PerformanceFields,
});
export const DailyTrendResponseSchema = z.array(DailyTrendSchema);
export type StatsResponse = z.infer<typeof StatsResponseSchema>;
export type TimersResponse = z.infer<typeof TimersResponseSchema>;