/** * Convert an authoring-time workflow definition into a {@link WorkflowContract}. * * Every `DefinitionSchema` (workflow input/output, every signal/update/query, * every activity, the finalizer) is converted through the existing * `definitionSchemaToJsonSchema()` — this module does not reimplement schema * conversion, and it does not reimplement the "unsupported construct emits * `unknown`" behavior, which lives entirely in `weft codegen`'s emitter. * * @module core/contract/build */ import { WeftError } from '../weft-error.ts'; import type { WorkflowContract, WorkflowContractSource } from './types.ts'; /** Discriminates which part of a workflow contract source failed conversion. */ type ContractEntityKind = 'workflow' | 'signal' | 'update' | 'query' | 'activity' | 'finalizer'; /** * Thrown when {@link buildWorkflowContract} cannot convert a registered * `DefinitionSchema` to JSON Schema — no built-in vendor adapter and no * structural `~standard.jsonSchema` converter. Mirrors * `RegistrySchemaConversionError`'s `entityKind`/`entityName`/`direction` * fields; not root-exported, matching that error's precedent (build-tooling * errors surfaced to the caller of the builder, not part of the public error * vocabulary). * * @example * ```ts * import { WorkflowContractConversionError } from '@lostgradient/weft'; * * try { * throw new WorkflowContractConversionError('activity', 'charge', 'inputSchema', new Error('boom')); * } catch (error) { * console.log(error instanceof WorkflowContractConversionError); // true * } * ``` */ export declare class WorkflowContractConversionError extends WeftError<'WorkflowContractConversionError'> { readonly entityKind: ContractEntityKind; readonly entityName: string; readonly direction: 'inputSchema' | 'outputSchema'; constructor(entityKind: ContractEntityKind, entityName: string, direction: 'inputSchema' | 'outputSchema', cause: unknown); } /** * Build a normalized {@link WorkflowContract} from an authoring-time workflow * definition. * * Accepts anything structurally matching {@link WorkflowContractSource} — * both `WorkflowDefinition` and `BuiltWorkflowDefinition` (the return type * of `workflow({...}).execute(fn)`) satisfy it directly, with no cast. * * Throws {@link WorkflowContractConversionError} if any declared schema * (workflow input/output, a signal/update/query input/output, an activity * input/output, or the finalizer's input/output) cannot be converted to JSON * Schema. * * @example * ```ts * import { buildWorkflowContract } from '@lostgradient/weft'; * * const contract = buildWorkflowContract({ name: 'checkout', version: '2.1.0' }); * console.log(contract.name, contract.workflowVersion); // checkout 2.1.0 * ``` */ export declare function buildWorkflowContract(source: WorkflowContractSource): WorkflowContract; export {};