@squidcloud/client
Version:
A typescript implementation of the Squid client
33 lines (32 loc) • 1.29 kB
TypeScript
import { AsyncJob, JobId } from '../../internal-common/src/public-types/job.public-types';
/**
* Handles job subscriptions and notifications.
*
* **Important:** Each `jobId` must be globally unique and kept private.
* Anyone who knows a job’s ID can query its status or result.
*/
export declare class JobClient {
private readonly socketManager;
private readonly rpcManager;
private readonly clientIdService;
private isListening;
private readonly listeners;
/**
* Retrieves the current status (and, if completed, the result) of a job.
*
* @param jobId A unique, private identifier for the job.
* Do **not** reuse a `jobId` across clients—possessing the ID
* allows anyone to inspect the job’s state.
*/
getJob<T = any>(jobId: JobId): Promise<AsyncJob<T> | undefined>;
/**
* Waits until the specified job finishes, then resolves with its result or
* throws if the job fails.
*
* @param jobId A unique, private identifier for the job.
* Do **not** reuse a `jobId` across clients—possessing the ID
* allows anyone to inspect the job’s state.
*/
awaitJob<T = any>(jobId: JobId): Promise<T>;
private maybeListenToJobs;
}