UNPKG

@crosspost/scheduler-sdk

Version:

TypeScript SDK client for the Scheduler service

132 lines (131 loc) 2.99 kB
import { z } from "zod"; /** * Job schedule types */ export declare enum ScheduleType { CRON = "cron", SPECIFIC_TIME = "specific_time", RECURRING = "recurring" } /** * Job types */ export declare enum JobType { HTTP = "http" } /** * Interval types for recurring jobs */ export declare enum IntervalType { MINUTE = "minute", HOUR = "hour", DAY = "day", WEEK = "week", MONTH = "month", YEAR = "year" } /** * Job status types */ export declare enum JobStatus { ACTIVE = "active", INACTIVE = "inactive", FAILED = "failed" } export declare const JobSchema: z.ZodObject<{ name: z.ZodString; description: z.ZodOptional<z.ZodString>; type: z.ZodNativeEnum<typeof JobType>; target: z.ZodString; payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; schedule_type: z.ZodNativeEnum<typeof ScheduleType>; cron_expression: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>; specific_time: z.ZodOptional<z.ZodString>; interval: z.ZodOptional<z.ZodNativeEnum<typeof IntervalType>>; interval_value: z.ZodOptional<z.ZodNumber>; status: z.ZodDefault<z.ZodNativeEnum<typeof JobStatus>>; }, "strip", z.ZodTypeAny, { name: string; type: JobType; status: JobStatus; target: string; schedule_type: ScheduleType; specific_time?: string | undefined; description?: string | undefined; payload?: Record<string, any> | undefined; cron_expression?: string | undefined; interval?: IntervalType | undefined; interval_value?: number | undefined; }, { name: string; type: JobType; target: string; schedule_type: ScheduleType; specific_time?: string | undefined; description?: string | undefined; status?: JobStatus | undefined; payload?: Record<string, any> | undefined; cron_expression?: string | undefined; interval?: IntervalType | undefined; interval_value?: number | undefined; }>; /** * Type for job input from API */ export type JobInput = z.infer<typeof JobSchema>; /** * Type for job stored in database */ export interface Job extends JobInput { id: string; created_at: Date; updated_at: Date; last_run?: Date; next_run?: Date; error_message?: string; } /** * Type for job data stored in BullMQ */ export interface JobData { jobId: string; target: string; type: JobType; payload?: Record<string, any>; } /** * API response types */ /** * Job creation response */ export interface JobCreationResponse { message: string; job: Job; } /** * Job update response */ export interface JobUpdateResponse { message: string; job: Job; } /** * Job deletion response */ export interface JobDeletionResponse { message: string; id: string; } /** * Job list response */ export interface JobListResponse { jobs: Job[]; } /** * Job list query parameters */ export interface JobListParams { status?: JobStatus; }