import { AwaitActivity } from '../../types/activity'; import { ProviderTransaction } from '../../types/provider'; import { Activity } from './activity'; /** * Invokes another graph (sub-flow) and optionally waits for its completion. * The `await` activity enables compositional workflows where one graph * triggers another by publishing to its `subscribes` topic, creating a * parent-child relationship between flows. * * ## YAML Configuration * * The `topic` in the await activity must match the `subscribes` topic of * the child graph. Both graphs are defined in the same app YAML: * * ```yaml * app: * id: myapp * version: '1' * graphs: * * # ── Parent graph ────────────────────────────── * - subscribes: order.placed * expire: 120 * * activities: * t1: * type: trigger * job: * maps: * orderId: '{$self.output.data.id}' * * a1: * type: await * topic: approval.requested # ◄── targets the child graph's subscribes * await: true * input: * schema: * type: object * properties: * orderId: { type: string } * maps: * orderId: '{t1.output.data.id}' * output: * schema: * type: object * properties: * approved: { type: boolean } * job: * maps: * approval: '{$self.output.data.approved}' * * done: * type: hook * * transitions: * t1: * - to: a1 * a1: * - to: done * * # ── Child graph (invoked by the await) ──────── * - subscribes: approval.requested # ◄── matched by the await activity's topic * publishes: approval.completed * expire: 60 * * activities: * t1: * type: trigger * review: * type: worker * topic: approval.review * * transitions: * t1: * - to: review * ``` * * ## Fire-and-Forget Mode * * When `await` is explicitly set to `false`, the activity starts the child * flow but does not wait for its completion. The parent flow immediately * continues. The child's `job_id` is returned as the output. * * ```yaml * a1: * type: await * topic: background.process * await: false * job: * maps: * childJobId: '{$self.output.data.job_id}' * ``` * * ## Execution Model * * Await is a **Category A (duplex)** activity: * - **Leg 1** (`process`): Maps input data and publishes a * `StreamDataType.AWAIT` message to the engine stream. The engine * starts the child flow. * - **Leg 2** (`processEvent`, inherited): Receives the child flow's * final output, maps output data, and transitions to adjacent activities. * * @see {@link AwaitActivity} for the TypeScript interface */ declare class Await extends Activity { config: AwaitActivity; process(): Promise; execActivity(transaction: ProviderTransaction): Promise; } export { Await };