@crosspost/scheduler-sdk
Version:
TypeScript SDK client for the Scheduler service
103 lines (102 loc) • 2.68 kB
TypeScript
import { Job, JobInput, JobListParams } from './types.js';
/**
* Configuration options for the Scheduler client
*/
export interface SchedulerClientOptions {
/**
* Base URL for the Scheduler API
* @default 'http://localhost:3000'
*/
baseUrl?: string;
/**
* Timeout for API requests in milliseconds
* @default 10000 (10 seconds)
*/
timeout?: number;
/**
* Headers to include with every request
*/
headers?: Record<string, string>;
}
/**
* Client for interacting with the Scheduler API
*/
export declare class SchedulerClient {
private client;
private baseUrl;
/**
* Create a new Scheduler client
* @param options Client configuration options
*/
constructor(options?: SchedulerClientOptions);
/**
* Create a new job
* @param job Job configuration
* @returns Created job
*/
createJob(job: JobInput): Promise<Job>;
/**
* Get a job by ID
* @param id Job ID
* @returns Job
*/
getJob(id: string): Promise<Job>;
/**
* Update a job
* @param id Job ID
* @param job Job configuration
* @returns Updated job
*/
updateJob(id: string, job: Partial<JobInput>): Promise<Job>;
/**
* Delete a job
* @param id Job ID
* @returns Deleted job ID
*/
deleteJob(id: string): Promise<string>;
/**
* List jobs with optional filtering
* @param params Query parameters
* @returns List of jobs
*/
listJobs(params?: JobListParams): Promise<Job[]>;
/**
* Find jobs by name
* @param name Job name to search for
* @returns List of matching jobs
*/
findJobsByName(name: string): Promise<Job[]>;
/**
* Check if a job with the given name exists
* @param name Job name to check
* @returns True if a job with the name exists, false otherwise
*/
jobExistsByName(name: string): Promise<boolean>;
/**
* Create a job if it doesn't already exist
* @param job Job configuration
* @returns Created job or existing job
*/
createJobIfNotExists(job: JobInput): Promise<Job>;
/**
* List active jobs
* @returns List of active jobs
*/
listActiveJobs(): Promise<Job[]>;
/**
* List failed jobs
* @returns List of failed jobs
*/
listFailedJobs(): Promise<Job[]>;
/**
* List inactive jobs
* @returns List of inactive jobs
*/
listInactiveJobs(): Promise<Job[]>;
/**
* Handle API errors
* @param error Error from axios
* @param statusHandlers Custom handlers for specific status codes
*/
private handleError;
}