import type { StandardSchemaV1 } from "@standard-schema/spec"; import type { TracingPort } from "../tracing/index.js"; /** * Any Standard Schema compatible validator. */ export type StandardSchema = StandardSchemaV1; /** * Value or promise of that value. */ export type MaybePromise = T | Promise; /** * Infer the parsed output type from a Standard Schema. */ export type InferSchemaOutput = StandardSchemaV1.InferOutput; /** * Operational task definition created by `defineTask(...)`. */ export interface TaskDef { /** * Discriminator for task definitions. */ readonly kind: "task"; /** * Stable task name used by CLIs and operational runners. */ readonly name: Name; /** * Standard Schema input validator. */ readonly input: Input; /** * Optional human-readable description for docs and tooling. */ readonly description?: string; /** * Handle a parsed task input. */ handle(args: TaskHandleArgs, Ctx>): MaybePromise; } /** * Infer the parsed input type for an operational task. */ export type InferTaskInput = T["input"] extends StandardSchemaV1 ? Output : never; /** * Infer the result type for an operational task. */ export type InferTaskOutput = T extends TaskDef ? Awaited : never; /** * Arguments passed to a task handler. */ export interface TaskHandleArgs { /** * Task definition being handled. */ task: T; /** * Parsed task input. */ input: InferTaskInput; /** Handler context. */ ctx: Ctx; } /** * Options for `defineTask(...)`. */ export interface DefineTaskOptions { /** * Standard Schema input validator. */ input: Input; /** * Optional human-readable description for docs and tooling. */ description?: string; /** * Handle a parsed task input. */ handle(args: TaskHandleArgs, Ctx>): MaybePromise; } /** * Options for one task run. */ export interface RunTaskOptions { /** * Raw task input. It is parsed with the task's Standard Schema before the * handler runs. */ input: unknown; /** Handler context or factory resolved inside the task span. */ ctx: Ctx | (() => MaybePromise); /** Runtime tracing port used before a lazy context factory runs. */ tracing?: TracingPort; } /** * Arguments `beignet task run` passes to the app's `createTaskContext` and * `stopTaskContext` exports in `server/tasks.ts`. */ export interface TaskRunContextArgs { /** * Task definition being run. */ task: T; /** * Stable task name being run. */ taskName: string; /** * Schema-parsed task input. */ input: unknown; /** * Tenant id or slug from `--tenant`, resolved by the app. */ tenant?: string; } /** * Context-bound operational task helper factory. */ export interface Tasks { /** * Define a task with the bound context type. */ defineTask(name: Name, options: DefineTaskOptions): TaskDef; } /** * Error thrown when task input validation fails. */ export declare class TaskValidationError extends Error { /** * Raw Standard Schema validation issues. */ readonly issues: readonly StandardSchemaV1.Issue[]; constructor(args: { name: string; issues: readonly StandardSchemaV1.Issue[]; }); } /** * Validate and parse a task input with the task's Standard Schema. */ export declare function parseTaskInput(task: T, input: unknown): Promise>; /** * Parse input and run an operational task. */ export declare function runTask, Ctx>(task: T, options: RunTaskOptions): Promise>; /** * Define a task registry while preserving tuple inference. */ export declare function defineTasks(tasks: Defs): Defs; /** * Create task helper methods bound to an application context type. * * Call it once in `lib/tasks.ts`: * * ```ts * export const { defineTask } = createTasks(); * ``` */ export declare function createTasks(): Tasks; //# sourceMappingURL=index.d.ts.map