import type { AnyCallableRef, InputOfRef, OutputOfRef } from "../../references/index.js"; import type { WorkflowRunRef } from "../../sdk/types.js"; import type { RunOpts } from "@hatchet-dev/typescript-sdk"; /** * Describes the return type of the {@link HostRunFn} function. * * @param I The input type of the callable reference. * @param R The callable reference. * @param W Whether to wait for the task to complete before returning. */ export type HostRunReturn | InputOfRef[], R extends AnyCallableRef, W extends boolean> = I extends InputOfRef[] ? W extends true ? OutputOfRef[] : WorkflowRunRef>[] : W extends true ? OutputOfRef : WorkflowRunRef>; export interface HostRunOpts extends RunOpts { /** * Whether to wait for the task to complete before returning. * * @default true */ wait?: W; } /** * Runs a child task or workflow. This can be used to run multiple tasks in parallel. * If `wait` is set to `false`, a `WorkflowRunRef` is returned. */ export type HostRunFn = | InputOfRef[], W extends boolean = true>(ref: R, input: I, options?: HostRunOpts) => Promise>;