/**
 * Workflow Utility Functions
 *
 * Provides helper functions for workflow execution, role-based access control,
 * and workflow validation.
 *
 * Matches Sequelize workflow.js functionality with Drizzle ORM.
 */
import type { Accountability, Workflow } from '../types/index.js';
export type { Accountability, Workflow };
/**
 * Helper function to check if user has required role for workflow execution
 *
 * @param workflow - Workflow object with trigger_type and allowed_roles
 * @param accountability - User accountability object with role info
 * @returns True if user has access, false otherwise
 *
 * @example
 * const hasAccess = checkWorkflowRoleAccess(workflow, { role: { id: '1', name: 'administrator' } });
 * if (!hasAccess) {
 *   throw new APIError('No permission', 403);
 * }
 */
export declare const checkWorkflowRoleAccess: (workflow: Workflow, accountability?: Accountability | null) => boolean;
/**
 * Fetch workflow from database with required fields for role checking
 *
 * @param workflowId - Workflow ID
 * @param includeFlowData - Whether to include flow_data field (default: false)
 * @returns Workflow object
 * @throws APIError if workflow not found
 *
 * @example
 * const workflow = await fetchWorkflowForExecution('workflow-id', true);
 * console.log(workflow.name, workflow.flow_data);
 */
export declare const fetchWorkflowForExecution: (workflowId: string | number, includeFlowData?: boolean) => Promise<Workflow>;
/**
 * Validate workflow is active and user has access
 *
 * @param workflow - Workflow object
 * @param accountability - User accountability object
 * @throws APIError if validation fails (400 if not active, 403 if no permission)
 *
 * @example
 * const workflow = await fetchWorkflowForExecution(id);
 * validateWorkflowAccess(workflow, req.accountability);
 * // If successful, workflow can be executed
 */
export declare const validateWorkflowAccess: (workflow: Workflow, accountability?: Accountability | null) => void;
/**
 * Combined helper: Fetch and validate workflow in one call
 *
 * @param workflowId - Workflow ID
 * @param accountability - User accountability object
 * @param includeFlowData - Whether to include flow_data field
 * @returns Validated workflow object ready for execution
 * @throws APIError if workflow not found, not active, or no permission
 *
 * @example
 * const workflow = await fetchAndValidateWorkflow(id, req.accountability, true);
 * await workflowService.executeWorkflow(workflow);
 */
export declare const fetchAndValidateWorkflow: (workflowId: string | number, accountability?: Accountability | null, includeFlowData?: boolean) => Promise<Workflow>;
/**
 * Check if user can create/edit workflow with specific allowed_roles
 *
 * @param allowedRoles - Array of role IDs that can execute the workflow
 * @param accountability - User accountability object
 * @returns True if user can set these allowed_roles
 *
 * @example
 * const canSetRoles = canSetWorkflowRoles(['admin-role-id'], req.accountability);
 * if (!canSetRoles) {
 *   throw new APIError('Cannot create workflow with these roles', 403);
 * }
 */
export declare const canSetWorkflowRoles: (allowedRoles: string[] | null | undefined, accountability?: Accountability | null) => boolean;
declare const _default: {
    checkWorkflowRoleAccess: (workflow: Workflow, accountability?: Accountability | null) => boolean;
    fetchWorkflowForExecution: (workflowId: string | number, includeFlowData?: boolean) => Promise<Workflow>;
    validateWorkflowAccess: (workflow: Workflow, accountability?: Accountability | null) => void;
    fetchAndValidateWorkflow: (workflowId: string | number, accountability?: Accountability | null, includeFlowData?: boolean) => Promise<Workflow>;
    canSetWorkflowRoles: (allowedRoles: string[] | null | undefined, accountability?: Accountability | null) => boolean;
};
export default _default;
//# sourceMappingURL=workflow.d.ts.map