Job
Background job execution and status polling.
Job
Represents a background job execution submitted via flow.job().
Methods
async status() -> JobStatus
Poll the current job status.
Returns: JobStatus object with state and results
Throws:
- Network/API errors
Example:
async wait(options?) -> ExecuteResult
Wait for the job to complete and return the result.
Parameters:
timeoutMs(number, optional): Maximum time to wait in milliseconds. Default:undefined(wait indefinitely)
Returns: ExecuteResult when complete
Throws:
TimeoutErroriftimeoutMsis exceeded- Network/API errors
Example:
async cancel() -> void
Cancel a running job. Has no effect if the job is already complete.
Example:
Properties
id (string)
Unique job identifier.
Example:
JobStatus (Type)
Job status information.
Attributes:
id(string): Job IDstate(string): One of"pending","running","completed","failed","cancelled"result(ExecuteResult | undefined): Final result if completederror(string | undefined): Error message if failedcreatedAt(string): ISO 8601 timestamp of job creationstartedAt(string | undefined): ISO 8601 timestamp when job startedcompletedAt(string | undefined): ISO 8601 timestamp when job completedprogress(object | undefined): Progress metadata (implementation-specific)
Example:
JobAccepted (Type)
Response when a job is successfully submitted (via flow.job()).
Attributes:
id(string): Job ID (same asJob.id)state(string): Always"pending"
Example:
Job Lifecycle
- Submit via
flow.job(...)→ returnsJob - Poll via
job.status()→ returnsJobStatuswith current state - Wait via
job.wait()→ blocks until complete - Cancel (optional) via
job.cancel() - Retrieve result from
JobStatus.resultorjob.wait()return value
Example: