polen
Version:
A framework for delightful GraphQL developer portals
44 lines • 1.45 kB
TypeScript
import type { Mask } from '#lib/mask';
import type { Report } from './report.js';
export interface Definition<$Input = any, $Output = any> {
name: string;
mask?: MaskOptions<$Input, $Output>;
}
export interface Task<$Input, $Output> {
(input: $Input): Promise<Report<$Input, $Output>>;
definition: Definition<$Input, $Output>;
}
export interface MaskOptions<$Input, $Output> {
/**
* @default true
*/
input?: Mask.InferOptions<$Input>;
/**
* @default true
*/
output?: Mask.InferOptions<$Output>;
}
export declare const create: <$Input, $Output>(fn: (input: $Input) => Promise<$Output>, options?: {
/**
* @default the fn name
*/
name?: string;
/**
* An optional default mask to use for successfully returned values.
*/
mask?: MaskOptions<$Input, $Output>;
}) => Task<$Input, $Output>;
/**
* Sugar method that creates a task, executes it, and exits with the report.
* Equivalent to: create(fn, options) -> task(input) -> exitWithReport(report)
*
* @param fn - The function to wrap as a task
* @param input - Input to pass to the task
* @param options - Combined task creation and format options
*/
export declare const runAndExit: <$Input, $Output>(fn: (input: $Input) => Promise<$Output>, input: $Input, options?: {
name?: string;
mask?: MaskOptions<$Input, $Output>;
debug?: boolean;
}) => Promise<never>;
//# sourceMappingURL=task.d.ts.map