Interface ITaskDefinition<TInput, TOutput, TDependencies, TMeta, TTags, TMiddleware>

interface ITaskDefinition<TInput, TOutput, TDependencies, TMeta, TTags, TMiddleware> {
    dependencies?: TDependencies | (() => TDependencies);
    id: string;
    inputSchema?: IValidationSchema<TInput>;
    meta?: TMeta;
    middleware?: TMiddleware;
    resultSchema?: IValidationSchema<TOutput extends Promise<U>
        ? U
        : never>;
    run: ((input: HasInputContracts<[...TTags[], ...TMiddleware[]]> extends true
        ? [TInput] extends [undefined]
            ? InferInputOrViolationFromContracts<[...TTags[], ...TMiddleware[]]>
            : EnsureInputSatisfiesContracts<[...TTags[], ...TMiddleware[]], TInput>
        : TInput, dependencies: DependencyValuesType<TDependencies>) => HasOutputContracts<[...TTags[], ...TMiddleware[]]> extends true
        ? EnsureOutputSatisfiesContracts<[...TTags[], ...TMiddleware[]], TOutput>
        : TOutput);
    tags?: TTags;
}

Type Parameters

Hierarchy (view full)

Properties

dependencies?: TDependencies | (() => TDependencies)

Access other tasks/resources/events. Can be an object or a function when you need late or config‑dependent resolution.

id: string
inputSchema?: IValidationSchema<TInput>

Optional validation schema for runtime input validation. When provided, task input will be validated before execution.

meta?: TMeta

Optional metadata used for docs, filtering and tooling.

middleware?: TMiddleware

Middleware applied around task execution.

resultSchema?: IValidationSchema<TOutput extends Promise<U>
    ? U
    : never>

Optional validation schema for the task result. When provided, the result will be validated immediately after the task's run resolves, without considering middleware.

run: ((input: HasInputContracts<[...TTags[], ...TMiddleware[]]> extends true
    ? [TInput] extends [undefined]
        ? InferInputOrViolationFromContracts<[...TTags[], ...TMiddleware[]]>
        : EnsureInputSatisfiesContracts<[...TTags[], ...TMiddleware[]], TInput>
    : TInput, dependencies: DependencyValuesType<TDependencies>) => HasOutputContracts<[...TTags[], ...TMiddleware[]]> extends true
    ? EnsureOutputSatisfiesContracts<[...TTags[], ...TMiddleware[]], TOutput>
    : TOutput)
tags?: TTags

Tags applied to the task that might define its behvaiour or impact the systems.