import type { Scenario } from "../client.js"; import type { APIPromise } from "../core/api-promise.js"; import type { RequestOptions } from "../internal/request-options.js"; import { Jobs, type JobRetrieveParams, type JobRetrieveResponse, type JobTriggerActionParams, type JobTriggerActionResponse } from "../resources/jobs.js"; import { type Scope } from "./scope.js"; export interface WaitOptions { /** Polling interval in milliseconds. Default: 3000 */ intervalMs?: number; /** Maximum wait time in milliseconds. Default: 120000 */ timeoutMs?: number; /** * Override the project scope used for the polling requests. Defaults to * the scope captured on the job (per-call override on the originating * call, else the client's default project). */ projectId?: string; } /** Job methods added on top of the original job fields. */ export declare class JobMethods { /** @internal */ readonly _client: Scenario; /** @internal scope captured from the originating call — replayed on every `.wait()` poll. */ readonly _scope?: Scope; /** * Poll until the job reaches a terminal status (success, failure, or canceled). * * @example * ```ts * const response = await client.workflows.run(workflowId, { body }); * const completed = await response.job.wait(); * console.log(completed.status); * ``` */ wait(this: Job, options?: WaitOptions): Promise; /** @internal Create a Job from raw job data, optionally remembering the originating scope. */ static from(client: Scenario, data: JobRetrieveResponse['job'], scope?: Scope): Job; } /** A job with all original fields plus `.wait()`. */ export type Job = JobRetrieveResponse.Job & JobMethods; export declare const Job: typeof JobMethods; /** * @internal Helper type: adds `.wait()` to the `job` field of a response. * Uses intersection so the original response type is preserved — a `WithJob` is still assignable to `T`. */ export type WithJob = T & { job: JobMethods; }; /** * @internal Wrap `_thenUnwrap` to replace `response.job` with an enhanced Job. * Captures the effective scope (per-call override or client default) so * `.wait()` can replay it on every poll — keeping follow-up calls in sync * with the project the job was originally created in. */ export declare function enhanceJob(client: Scenario, promise: APIPromise, options?: RequestOptions): APIPromise>; /** * Enhanced Jobs resource. `retrieve` and `triggerAction` responses' `job` * field gains a `.wait()` helper — previously only job-creating endpoints * (workflow.run, models.trigger, generate.*) had it. `list` is not enhanced: * its items use a different (but structurally similar) type, and users * typically fetch individual jobs via `retrieve` before acting on them. */ export declare class EnhancedJobs extends Jobs { retrieve(jobID: string, query?: JobRetrieveParams | null | undefined, options?: RequestOptions): APIPromise>; triggerAction(jobID: string, params: JobTriggerActionParams, options?: RequestOptions): APIPromise>; } //# sourceMappingURL=job.d.ts.map