@convex-dev/workflow
Version:
Convex component for durably executing workflows.
35 lines • 1.54 kB
TypeScript
import { type WorkpoolOptions } from "@convex-dev/workpool";
import { type FunctionHandle, type RegisteredMutation } from "convex/server";
import { type ObjectType, type PropertyValidators } from "convex/values";
import { type OnCompleteArgs, type WorkflowId } from "../types.js";
import type { WorkflowDefinition, WorkflowHandler } from "./index.js";
import { type WorkflowComponent } from "./types.js";
export type WorkflowArgs<V extends PropertyValidators, Context = unknown> = {
/**
* The arguments to pass to the Workflow handler.
*/
args: ObjectType<V>;
/**
* Whether to enqueue the Workflow for asynchronous execution only.
* By default it will start evaluating the handler's first step in the
* current transaction.
*/
startAsync?: boolean;
} & ({
/**
* A function handle (created with createFunctionHandle) that will be
* called when the Workflow completes.
*/
onComplete: FunctionHandle<"mutation", OnCompleteArgs<Context>>;
/**
* Context forwarded to the `onComplete` mutation.
*/
context: Context;
} | {
onComplete?: undefined;
context?: undefined;
});
export declare function workflowMutation<ArgsValidator extends PropertyValidators>(component: WorkflowComponent, registered: WorkflowDefinition<ArgsValidator> & {
handler: WorkflowHandler<ArgsValidator, any>;
}, defaultWorkpoolOptions?: WorkpoolOptions): RegisteredMutation<"internal", WorkflowArgs<ArgsValidator>, WorkflowId>;
//# sourceMappingURL=workflowMutation.d.ts.map