- Next.js 16.0.1 + React 19.2.0 + Tailwind CSS 4.1.16 - Complete Scrapyd API integration (all 12 endpoints) - Dashboard with real-time job monitoring - Projects management (upload, list, delete) - Spiders management with scheduling - Jobs monitoring with filtering and cancellation - System status monitoring - Dark/light theme toggle with next-themes - Server-side authentication via environment variables - Docker deployment with multi-stage builds - GitHub Actions CI/CD workflow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
121 lines
2.7 KiB
TypeScript
121 lines
2.7 KiB
TypeScript
import { z } from "zod";
|
|
|
|
// Scrapyd API Response Schemas
|
|
export const DaemonStatusSchema = z.object({
|
|
status: z.literal("ok"),
|
|
node_name: z.string(),
|
|
pending: z.number(),
|
|
running: z.number(),
|
|
finished: z.number(),
|
|
});
|
|
|
|
export const ListProjectsSchema = z.object({
|
|
status: z.literal("ok"),
|
|
projects: z.array(z.string()),
|
|
});
|
|
|
|
export const ListVersionsSchema = z.object({
|
|
status: z.literal("ok"),
|
|
versions: z.array(z.string()),
|
|
});
|
|
|
|
export const ListSpidersSchema = z.object({
|
|
status: z.literal("ok"),
|
|
spiders: z.array(z.string()),
|
|
});
|
|
|
|
export const JobSchema = z.object({
|
|
id: z.string(),
|
|
spider: z.string(),
|
|
pid: z.number().optional(),
|
|
start_time: z.string(),
|
|
end_time: z.string().optional(),
|
|
log_url: z.string().optional(),
|
|
items_url: z.string().optional(),
|
|
});
|
|
|
|
export const ListJobsSchema = z.object({
|
|
status: z.literal("ok"),
|
|
pending: z.array(JobSchema),
|
|
running: z.array(JobSchema),
|
|
finished: z.array(JobSchema),
|
|
});
|
|
|
|
export const ScheduleJobSchema = z.object({
|
|
status: z.literal("ok"),
|
|
jobid: z.string(),
|
|
});
|
|
|
|
export const CancelJobSchema = z.object({
|
|
status: z.literal("ok"),
|
|
prevstate: z.enum(["pending", "running", "finished"]),
|
|
});
|
|
|
|
export const DeleteVersionSchema = z.object({
|
|
status: z.literal("ok"),
|
|
});
|
|
|
|
export const DeleteProjectSchema = z.object({
|
|
status: z.literal("ok"),
|
|
});
|
|
|
|
export const AddVersionSchema = z.object({
|
|
status: z.literal("ok"),
|
|
spiders: z.number(),
|
|
});
|
|
|
|
// TypeScript Types
|
|
export type DaemonStatus = z.infer<typeof DaemonStatusSchema>;
|
|
export type ListProjects = z.infer<typeof ListProjectsSchema>;
|
|
export type ListVersions = z.infer<typeof ListVersionsSchema>;
|
|
export type ListSpiders = z.infer<typeof ListSpidersSchema>;
|
|
export type Job = z.infer<typeof JobSchema>;
|
|
export type ListJobs = z.infer<typeof ListJobsSchema>;
|
|
export type ScheduleJob = z.infer<typeof ScheduleJobSchema>;
|
|
export type CancelJob = z.infer<typeof CancelJobSchema>;
|
|
export type DeleteVersion = z.infer<typeof DeleteVersionSchema>;
|
|
export type DeleteProject = z.infer<typeof DeleteProjectSchema>;
|
|
export type AddVersion = z.infer<typeof AddVersionSchema>;
|
|
|
|
// Request Parameters
|
|
export interface ScheduleJobParams {
|
|
project: string;
|
|
spider: string;
|
|
jobid?: string;
|
|
settings?: Record<string, string>;
|
|
args?: Record<string, string>;
|
|
}
|
|
|
|
export interface CancelJobParams {
|
|
project: string;
|
|
job: string;
|
|
}
|
|
|
|
export interface ListVersionsParams {
|
|
project: string;
|
|
}
|
|
|
|
export interface ListSpidersParams {
|
|
project: string;
|
|
version?: string;
|
|
}
|
|
|
|
export interface ListJobsParams {
|
|
project: string;
|
|
}
|
|
|
|
export interface DeleteVersionParams {
|
|
project: string;
|
|
version: string;
|
|
}
|
|
|
|
export interface DeleteProjectParams {
|
|
project: string;
|
|
}
|
|
|
|
export interface AddVersionParams {
|
|
project: string;
|
|
version: string;
|
|
egg: File;
|
|
}
|