import { MachineUserName } from "../auth/types.mjs"; import { ConcurrencyPolicy, RetryPolicy } from "../../../types/workflow.generated.mjs"; import "../../types/machine-user.mjs"; import { WorkflowJob } from "./job.mjs"; //#region src/configure/services/workflow/workflow.d.ts export interface WorkflowConfig = WorkflowJob> { name: string; mainJob: Job; retryPolicy?: RetryPolicy; concurrencyPolicy?: ConcurrencyPolicy; publishEvents?: boolean; } export interface Workflow = WorkflowJob> { name: string; mainJob: Job; retryPolicy?: RetryPolicy; concurrencyPolicy?: ConcurrencyPolicy; publishEvents?: boolean; start: [Parameters[0]] extends [undefined] ? (args?: undefined, options?: { invoker: MachineUserName; }) => Promise : (args: Parameters[0], options?: { invoker: MachineUserName; }) => Promise; } interface WorkflowDefinition> { name: string; mainJob: Job; retryPolicy?: RetryPolicy; concurrencyPolicy?: ConcurrencyPolicy; /** * Enable publishing this workflow's execution events, letting executors with * a `workflowExecution*` trigger observe them. * * Left unset, it is enabled automatically when an executor in the project * subscribes to this workflow's execution events. */ publishEvents?: boolean; } /** * Create a workflow definition that can be started via the Tailor SDK. * In production, the bundler rewrites `.start()` calls into direct platform workflow calls. * * The workflow MUST be the default export of the file. * All jobs referenced by the workflow MUST be named exports. * @template Job * @param config - Workflow configuration * @returns Defined workflow * @example * export const fetchData = createWorkflowJob({ name: "fetch-data", body: async (input: { id: string }) => ({ id: input.id }) }); * export const processData = createWorkflowJob({ * name: "process-data", * body: (input: { id: string }) => { * const data = fetchData.start({ id: input.id }); * return { data }; * }, * }); * * // Workflow must be default export; mainJob is the entry point * export default createWorkflow({ * name: "data-processing", * mainJob: processData, * }); */ export declare function createWorkflow>(config: WorkflowDefinition): Workflow; //#endregion export type { ConcurrencyPolicy, RetryPolicy };