import type { CreateWorkflowRequest, ListWorkflowsRequest, UpdateWorkflowGraphRequest, UpdateWorkflowRequest, WorkflowActivity, WorkflowCreateResult, WorkflowDelivery, WorkflowExecution, WorkflowGetResult, WorkflowListResult, WorkflowUpdateResult, TestWorkflowRequest, TestWorkflowResult } from './types.ts'; import type { FetchAdapter } from '@agentuity/adapter'; /** * Client for the Agentuity Workflow service. * * Provides methods for creating and managing workflows that route events from * sources (email, queue, webhook, schedule) to configured destinations. The * service supports: * * - **Workflows**: Named routing configurations with a source and graph * - **Executions**: Records of workflow runs with step-level detail * - **Deliveries**: Records of destination delivery attempts * - **Testing**: Send test payloads through a workflow * * All methods are instrumented with OpenTelemetry spans for observability. * * @example * ```typescript * const workflows = new WorkflowService(baseUrl, adapter); * * // Create a workflow * const { workflow } = await workflows.create({ * name: 'GitHub to Slack', * source_type: 'webhook', * source_ref_id: 'wh_abc123', * }); * * // List active workflows * const { workflows: list } = await workflows.list({ status: 'enabled' }); * ``` */ export declare class WorkflowService { #private; /** * Creates a new WorkflowService instance. * * @param baseUrl - The base URL of the workflow API * @param adapter - The HTTP fetch adapter used for making API requests */ constructor(baseUrl: string, adapter: FetchAdapter); /** * Lists all workflows for the authenticated organization. * * @param params - Optional filter and pagination parameters * @returns A promise resolving to the paginated list of workflows * @throws {@link WorkflowResponseError} If the API returns a failure response body * @throws {@link ServiceException} If the HTTP request fails * * @example * ```typescript * const result = await service.list({ status: 'enabled', limit: 10 }); * console.log(`Found ${result.total} workflows`); * for (const wf of result.workflows) { * console.log(`${wf.name} (${wf.source_type})`); * } * ``` */ list(params?: ListWorkflowsRequest): Promise; /** * Gets a single workflow by its ID. * * @param workflowId - The unique workflow identifier (prefixed with wf_) * @returns A promise resolving to the workflow details * @throws {@link WorkflowResponseError} If the API returns a failure response body * @throws {@link ServiceException} If the HTTP request fails * * @example * ```typescript * const result = await service.get('wf_abc123'); * console.log(result.workflow.name); * ``` */ get(workflowId: string): Promise; /** * Creates a new workflow. * * @param params - The workflow creation parameters including name, source type, and source reference * @returns A promise resolving to the newly created workflow * @throws {@link WorkflowResponseError} If the API returns a failure response body * @throws {@link ServiceException} If the HTTP request fails * * @example * ```typescript * const result = await service.create({ * name: 'Email to Slack', * source_type: 'email', * source_ref_id: 'user@example.com', * }); * console.log('Created:', result.workflow.id); * ``` */ create(params: CreateWorkflowRequest): Promise; /** * Updates an existing workflow's name, description, or status. * * @param workflowId - The unique workflow identifier * @param params - Fields to update; only provided fields are changed * @returns A promise resolving to the updated workflow * @throws {@link WorkflowResponseError} If the API returns a failure response body * @throws {@link ServiceException} If the HTTP request fails * * @example * ```typescript * const result = await service.update('wf_abc123', { * name: 'Updated Workflow Name', * status: 'disabled', * }); * console.log('Updated:', result.workflow.name); * ``` */ update(workflowId: string, params: UpdateWorkflowRequest): Promise; /** * Updates the workflow graph (nodes and edges) for a workflow. * * @param workflowId - The unique workflow identifier * @param params - The new graph definition with nodes and edges * @returns A promise resolving to the updated workflow * @throws {@link WorkflowResponseError} If the API returns a failure response body * @throws {@link ServiceException} If the HTTP request fails * * @example * ```typescript * const result = await service.updateGraph('wf_abc123', { * nodes: [{ id: 'n1', type: 'filter', data: { expr: '...' } }], * edges: [{ id: 'e1', source: 'n1', target: 'n2' }], * }); * ``` */ updateGraph(workflowId: string, params: UpdateWorkflowGraphRequest): Promise; /** * Deletes a workflow and all associated data. * * @param workflowId - The unique workflow identifier * @throws {@link WorkflowResponseError} If the API returns a failure response body * @throws {@link ServiceException} If the HTTP request fails * * @example * ```typescript * await service.delete('wf_abc123'); * console.log('Workflow deleted'); * ``` */ delete(workflowId: string): Promise; /** * Tests a workflow with a sample payload. * * Sends the provided payload through the workflow and returns the execution * result including individual step outcomes. * * @param workflowId - The unique workflow identifier * @param params - The test parameters including the payload to send * @returns A promise resolving to the test execution result * @throws {@link WorkflowResponseError} If the API returns a failure response body * @throws {@link ServiceException} If the HTTP request fails * * @example * ```typescript * const result = await service.test('wf_abc123', { * payload: { event: 'push', repo: 'my-repo' }, * }); * console.log('Test status:', result.status); * ``` */ test(workflowId: string, params: TestWorkflowRequest): Promise; /** * Gets workflow activity statistics for the authenticated organization. * * Returns aggregate counts of workflows, executions, and their statuses. * * @param days - Optional number of days to look back for activity (default: server-side default) * @returns A promise resolving to the activity statistics * @throws {@link WorkflowResponseError} If the API returns a failure response body * @throws {@link ServiceException} If the HTTP request fails * * @example * ```typescript * const activity = await service.activity(7); * console.log(`${activity.total_workflows} workflows, ${activity.total_executions} executions`); * ``` */ activity(days?: number): Promise; /** * Lists execution records for a specific workflow. * * @param workflowId - The unique workflow identifier * @returns A promise resolving to the list of executions * @throws {@link WorkflowResponseError} If the API returns a failure response body * @throws {@link ServiceException} If the HTTP request fails * * @example * ```typescript * const executions = await service.listExecutions('wf_abc123'); * for (const exec of executions) { * console.log(`${exec.id}: ${exec.status}`); * } * ``` */ listExecutions(workflowId: string): Promise; /** * Lists delivery records for a specific workflow execution. * * @param executionId - The unique execution identifier * @returns A promise resolving to the list of deliveries * @throws {@link WorkflowResponseError} If the API returns a failure response body * @throws {@link ServiceException} If the HTTP request fails * * @example * ```typescript * const deliveries = await service.listDeliveries('exec_abc123'); * for (const d of deliveries) { * console.log(`${d.destination_type}: ${d.status}`); * } * ``` */ listDeliveries(executionId: string): Promise; /** * Gets the most recent payload received by a workflow. * * Useful for inspecting the last event that triggered the workflow, e.g. * when building or debugging workflow graphs. * * @param workflowId - The unique workflow identifier * @returns A promise resolving to the recent payload data * @throws {@link WorkflowResponseError} If the API returns a failure response body * @throws {@link ServiceException} If the HTTP request fails * * @example * ```typescript * const payload = await service.getRecentPayload('wf_abc123'); * console.log('Last payload:', JSON.stringify(payload, null, 2)); * ``` */ getRecentPayload(workflowId: string): Promise; } //# sourceMappingURL=service.d.ts.map