UNPKG

@squidcloud/client

Version:

A typescript implementation of the Squid client

88 lines (87 loc) 2.49 kB
/** * Represents a unique identifier for a job. */ export type JobId = string; /** Represents a request to get an asynchronous job by its ID. */ export interface GetJobRequest { /** The unique identifier of the job to retrieve */ jobId: JobId; } /** * Represents a request to get an asynchronous job by its ID. */ export interface GetJobResponse { /** The job details */ job: AsyncJob | undefined; } /** * Represents a request to subscribe to job updates. * This allows clients to receive real-time updates about the job's status. */ export interface SubscribeToJobRequest { /** The unique identifier of the job to subscribe to */ jobId: JobId; } /** * Represents a request to start a client-owned job. * The caller generates the jobId; the client that starts the job owns it and must resolve it. */ export interface StartJobRequest { /** The unique identifier of the job to start. */ jobId: JobId; } /** * Represents a request to resolve a client-owned job with its result or error. */ export interface ResolveJobRequest { /** The unique identifier of the job to resolve. */ jobId: JobId; /** The terminal status to set on the job. */ status: 'completed' | 'failed'; /** The job result, present when status is 'completed'. */ result?: unknown; /** The error message, present when status is 'failed'. */ error?: string; } /** * Represents a keep-alive request signalling that the client still owns the listed active jobs. */ export interface KeepAliveRequest { /** The identifiers of the jobs the client is keeping alive. */ jobIds: Array<JobId>; } /** * Represents an asynchronous job */ export interface AsyncJob<T = any> { /** * The unique identifier of the job. */ id: JobId; /** * The timestamp when the job was created. */ createdAt: Date; /** * The timestamp when the job was last updated. */ updatedAt: Date; /** * The current status of the job. * Can be one of the following: * - 'in_progress': The job is currently being processed. * - 'completed': The job has finished successfully. * - 'failed': The job has failed. */ status: 'in_progress' | 'completed' | 'failed'; /** * The result of the job, if available. * This is of type `T` and is optional. */ result?: T; /** * The error message, if the job has failed. * This is optional. */ error?: string; }