bknd
Version:
Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.
57 lines (56 loc) • 1.98 kB
TypeScript
import type { StaticDecode, TSchema } from "@sinclair/typebox";
import { BkndError } from "../../core";
import { type Static, type TObject } from "../../core/utils";
import type { InputsMap } from "../flows/Execution";
import * as tbbox from "@sinclair/typebox";
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 function dynamic<Type extends TSchema>(type: Type, parse?: (val: any | string) => Static<Type>): tbbox.TTransform<tbbox.TUnion<[{
title: string;
} & Type, tbbox.TString]>, (Type & {
params: [];
})["static"]>;
export declare abstract class Task<Params extends TObject = TObject, Output = unknown> {
abstract type: string;
name: string;
/**
* The schema of the task's parameters.
*/
static schema: TObject<{}>;
/**
* The task's parameters.
*/
_params: Static<Params>;
constructor(name: string, params?: Static<Params>);
get params(): StaticDecode<Params>;
protected clone(name: string, params: Static<Params>): Task;
static resolveParams<S extends TSchema>(schema: S, params: any, inputs?: object): Promise<StaticDecode<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: tbbox.StaticDecodeIsAny<Params> extends true ? unknown : (tbbox.TDecodeType<Params> & {
params: [];
})["static"];
};
}