feat: 新增定时任务功能
This commit is contained in:
75
src/lib/cron-types.ts
Normal file
75
src/lib/cron-types.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* Cron Job Type Definitions
|
||||
* Types for scheduled tasks
|
||||
*/
|
||||
|
||||
export type CronJobDeliveryMode = 'none' | 'announce';
|
||||
|
||||
export interface CronJobDelivery {
|
||||
mode: CronJobDeliveryMode;
|
||||
channel?: string;
|
||||
to?: string;
|
||||
accountId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cron job last run info
|
||||
*/
|
||||
export interface CronJobLastRun {
|
||||
time: string;
|
||||
success: boolean;
|
||||
error?: string;
|
||||
duration?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gateway CronSchedule object format
|
||||
*/
|
||||
export type CronSchedule =
|
||||
| { kind: 'at'; at: string }
|
||||
| { kind: 'every'; everyMs: number; anchorMs?: number }
|
||||
| { kind: 'cron'; expr: string; tz?: string };
|
||||
|
||||
/**
|
||||
* Cron job data structure
|
||||
* schedule can be a plain cron string or a Gateway CronSchedule object
|
||||
*/
|
||||
export interface CronJob {
|
||||
id: string;
|
||||
name: string;
|
||||
message: string;
|
||||
schedule: string | CronSchedule;
|
||||
delivery?: CronJobDelivery;
|
||||
enabled: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
lastRun?: CronJobLastRun;
|
||||
nextRun?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Input for creating a cron job from the UI.
|
||||
*/
|
||||
export interface CronJobCreateInput {
|
||||
name: string;
|
||||
message: string;
|
||||
schedule: string;
|
||||
delivery?: CronJobDelivery;
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Input for updating a cron job
|
||||
*/
|
||||
export interface CronJobUpdateInput {
|
||||
name?: string;
|
||||
message?: string;
|
||||
schedule?: string;
|
||||
delivery?: CronJobDelivery;
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule type for UI picker
|
||||
*/
|
||||
export type ScheduleType = 'daily' | 'weekly' | 'monthly' | 'interval' | 'custom';
|
||||
Reference in New Issue
Block a user