bknd
Version:
Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.
49 lines (48 loc) • 1.63 kB
TypeScript
import { BkndError } from "../../core/errors";
import { s } from "bknd/utils";
import type { InputsMap } from "../flows/Execution";
export type TaskResult<Output = any> = {
start: Date;
output?: Output;
error?: any;
success: boolean;
params: any;
};
export type TaskRenderProps<T extends Task = Task> = any;
export declare const dynamic: <S extends s.Schema>(a: S, b?: any) => S;
export declare abstract class Task<Params extends s.Schema = s.Schema, Output = unknown> {
abstract type: string;
name: string;
/**
* The schema of the task's parameters.
*/
static schema: s.Schema<s.IAnyOptions, any, any> & s.IAnyOptions;
/**
* The task's parameters.
*/
_params: s.Static<Params>;
constructor(name: string, params?: s.Static<Params>);
get params(): s.StaticCoerced<Params>;
protected clone(name: string, params: s.Static<Params>): Task;
static resolveParams<S extends s.Schema>(schema: S, params: any, inputs?: object): Promise<s.StaticCoerced<S>>;
private cloneWithResolvedParams;
/**
* The internal execution of the flow.
* Wraps the execute() function to gather log results.
*/
run(inputs?: InputsMap): Promise<{
start: Date;
output: Output | undefined;
error: any;
success: boolean;
params: any;
time: number;
}>;
protected error(message: string, details?: Record<string, any>): BkndError;
abstract execute(inputs: Map<string, any>): Promise<Output>;
get label(): string;
toJSON(): {
type: string;
params: s.StaticCoerced<Params>;
};
}