TaskClient

interface TaskClient { taskStateStore: TaskStateStore; deleteVariable(key: string): Promise<void>; getConnection(connId: string): Promise<ConnectionResult | null>; getConnectionOrThrow(connId: string): Promise<ConnectionResult>; getVariable(key: string): Promise<string | null>; getVariableOrThrow(key: string): Promise<string>; getXCom<T = unknown>(opts: GetXComOpts): Promise<T | null>; setVariable(key: string, value: string, description?: string | null): Promise<void>; setXCom(opts: SetXComOpts): Promise<void>; }

Source: client.ts:34

Client for reading and writing Airflow task-time data from a task handler.

The active runtime selects the concrete transport and implements this interface for the current task attempt.


Properties

taskStateStore: TaskStateStore

Key/value state private to this task instance.

See TaskStateStore.

Methods

deleteVariable(key: string): Promise<void>

Delete an Airflow Variable.

Resolves even when the key does not exist — the Execution API's delete route is idempotent and does not report a missing key as an error.

Parameters

  • key (string)

Returns

  • Promise<void>

getConnection(connId: string): Promise<ConnectionResult | null>

Look up an Airflow Connection by ID.

Returns null when the connection does not exist. Throws on any other error.

This is intentionally JS-friendly behavior. Use getConnectionOrThrow when missing connections should raise.

Parameters

  • connId (string)

Returns

getConnectionOrThrow(connId: string): Promise<ConnectionResult>

Look up an Airflow Connection by ID and raise when it is missing.

This matches Python BaseHook.get_connection behavior.

Parameters

  • connId (string)

Returns

Throws

getVariable(key: string): Promise<string | null>

Look up an Airflow Variable.

Returns null when the key is missing or stored with a null value. Throws on any other error.

This is intentionally JS-friendly behavior. Use getVariableOrThrow when missing variables should raise.

Parameters

  • key (string)

Returns

  • Promise<string | null>

getVariableOrThrow(key: string): Promise<string>

Look up an Airflow Variable and raise when it is missing.

This matches Python Variable.get behavior when no default value is supplied.

Parameters

  • key (string)

Returns

  • Promise<string>

Throws

getXCom<T = unknown>(opts: GetXComOpts): Promise<T | null>

Pull an XCom value.

Returns null when the row is missing. Locator fields default to the current task's context.

The generic T lets callers narrow the return type when the shape is known:

CODE
const data = await client.getXCom<{ count: number }>({ key: "result" });
// data is { count: number } | null

Type Parameters

  • T = unknown

Parameters

Returns

  • Promise<T | null>

setVariable( key: string, value: string, description?: string | null, ): Promise<void>

Store an Airflow Variable, replacing any existing value.

The value is stored as a string. Serialize structured data (for example with JSON.stringify) before storing it.

Omitting description clears the description the Variable had.

Parameters

  • key (string)
  • value (string)
  • description (string | null, optional)

Returns

  • Promise<void>

setXCom(opts: SetXComOpts): Promise<void>

Push an XCom value.

Target fields default to the current task's context.

Parameters

Returns

  • Promise<void>