import ItemsService from "./ItemsService.js";
/**
 * Master switch for the entire workflow subsystem. Default ON (backward compatible).
 * When WORKFLOWS_ENABLED=false:
 *  - no item-event hooks are registered (so reads/writes carry NO per-request
 *    workflow trigger overhead),
 *  - no scheduled workflows run,
 *  - the /workflows/* routes are disabled,
 *  - any stray trigger call short-circuits.
 * This lets a project that doesn't use workflows run the API with zero workflow
 * cost — and also removes the script/service-node code-execution surface (A2/A3).
 */
export declare function workflowsEnabled(): boolean;
/**
 * WorkflowService - Comprehensive workflow execution engine
 * Supports: HTTP requests, data transformation, conditions, loops, service operations
 */
declare class WorkflowService {
    private initialized;
    private scheduledJobs;
    private customModules;
    private stepProcessors;
    constructor();
    /**
     * Register a custom module that can be used in script nodes
     * @param moduleName - Name of the module (used in require())
     * @param moduleExport - The module export (function, object, or class)
     * @param options - Optional configuration
     */
    registerCustomModule(moduleName: string, moduleExport: any, options?: any): void;
    /**
     * Unregister a custom module
     * @param moduleName - Name of the module to unregister
     */
    unregisterCustomModule(moduleName: string): boolean;
    /**
     * Get all registered custom modules
     * @returns List of registered modules with metadata
     */
    getRegisteredModules(): {
        name: any;
        description: any;
        allowRequire: any;
        registeredAt: any;
    }[];
    /**
     * Check if a module is available (built-in or custom)
     * @param moduleName - Name of the module
     * @returns boolean
     */
    isModuleAvailable(moduleName: string): boolean;
    init(): Promise<void>;
    ensureInitialized(): Promise<void>;
    /**
     * Create execution record (without starting execution)
     */
    createExecutionRecord(workflowId: string | number, userId?: any, tenantId?: any): Promise<any>;
    /**
     * Execute workflow asynchronously using existing execution record
     */
    executeWorkflowAsync(workflowId: string | number, triggerData?: any, userId?: any, tenantId?: any, executionId?: any): Promise<void>;
    /**
     * Execute a workflow (legacy method - creates record and executes)
     */
    executeWorkflow(workflowId: string | number, triggerData?: any, userId?: any, tenantId?: any): Promise<any>;
    /**
     * Run workflow execution
     */
    runWorkflowExecution(executionId: string | number, workflow: any, triggerData: any): Promise<void>;
    /**
     * Execute a single node and its descendants
     */
    executeNode(node: any, allNodes: any[], edges: any[], context: any, executionId: string | number, LogService: ItemsService): Promise<any>;
    /**
     * Process trigger node
     */
    processTriggerNode(_node: any, context: any): Promise<any>;
    /**
     * Process HTTP request node
     */
    processHttpNode(node: any, context: any): Promise<{
        status: number;
        statusText: string;
        headers: {
            [k: string]: string;
        };
        data: any;
    }>;
    /**
     * Process transformation node
     */
    processTransformNode(node: any, context: any): Promise<any>;
    /**
     * Execute JavaScript transformation script
     */
    executeTransformScript(script: string, context: any): any;
    /**
     * Apply field mapping transformation
     */
    applyFieldMapping(mapping: Record<string, any>, context: any): Record<string, any>;
    /**
     * Process condition node
     */
    processConditionNode(node: any, context: any, allNodes: any[], edges: any[], executionId: string | number, LogService: ItemsService): Promise<{
        conditionMet: boolean;
        results: any;
        branch: string;
    }>;
    /**
     * Execute a condition branch
     * Executes nodes until they connect back to the condition's "condition-end" handle
     */
    executeConditionBranch(conditionNodeId: string, startNode: any, allNodes: any[], edges: any[], context: any, executionId: string | number, LogService: ItemsService): Promise<void>;
    /**
     * Evaluate a single condition
     */
    evaluateCondition(condition: any, context: any): boolean;
    /**
     * Process service operation node
     */
    processServiceNode(node: any, context: any): Promise<any>;
    /**
     * Process loop node
     */
    processLoopNode(node: any, context: any, allNodes: any[], edges: any[], executionId: string | number, LogService: ItemsService): Promise<{
        items: any[];
        count: number;
    }>;
    /**
     * Execute a single loop iteration
     * Executes nodes until they connect back to the loop's "loop-end" handle
     */
    executeLoopIteration(loopNodeId: string, loopBodyEdges: any[], allNodes: any[], edges: any[], context: any, executionId: string | number, LogService: ItemsService): Promise<Record<string, any>>;
    /**
     * Execute a single node without following its edges
     * Used by loop iteration to have finer control over execution flow
     */
    executeSingleNode(node: any, context: any, executionId: string | number, LogService: ItemsService, allNodes?: any[], edges?: any[]): Promise<any>;
    /**
     * Process filter node
     */
    processFilterNode(node: any, context: any): Promise<{
        items: any[];
        count: number;
    }>;
    /**
     * Process aggregate node
     */
    processAggregateNode(node: any, context: any): Promise<{
        result: any;
    }>;
    /**
     * Process delay node
     */
    processDelayNode(node: any, context: any): Promise<{
        delayed: any;
    }>;
    /**
     * Process notification node
     */
    processNotificationNode(node: any, context: any): Promise<string | number>;
    /**
     * Replace template variables in a value (string, object, or array)
     */
    replaceTemplateVariables(value: any, context: any): any;
    /**
     * Evaluate expression to get value from context
     */
    evaluateExpression(expression: any, context: any, defaultData?: any): any;
    /**
     * Register hooks for workflow triggers
     */
    registerWorkflowHooks(): void;
    /**
     * Trigger workflows by hook event
     * @returns Object with modifiedData if workflows modified the data, null otherwise
     */
    triggerWorkflowsByHook(collection: string, action: string, data: any): Promise<{
        modifiedData: any;
    }>;
    /**
     * Initialize scheduled workflows
     */
    initializeScheduledWorkflows(): Promise<void>;
    /**
     * Try to acquire distributed lock for scheduled workflow execution
     * @param workflowId - Workflow ID
     * @param lockTimeout - Lock timeout in seconds (default: 300 = 5 minutes)
     * @returns True if lock acquired, false otherwise
     */
    tryAcquireScheduledWorkflowLock(workflowId: string | number, lockTimeout?: number): Promise<boolean>;
    /**
     * Release distributed lock for scheduled workflow
     * @param workflowId - Workflow ID
     */
    releaseScheduledWorkflowLock(workflowId: string | number): Promise<void>;
    /**
     * Schedule a workflow
     */
    scheduleWorkflow(workflow: any): void;
    /**
     * Cancel a scheduled workflow
     */
    cancelScheduledWorkflow(workflowId: string | number): void;
    /**
     * Process email node - Send email using MailService
     */
    processEmailNode(node: any, context: any): Promise<{
        success: boolean;
        sent: number;
        failed: number;
        results: any[];
    }>;
    /**
     * Process workflow node - Execute another workflow and return its result
     */
    processWorkflowNode(node: any, context: any): Promise<{
        success: boolean;
        executionId: any;
        status: string;
        result: any;
        async?: undefined;
    } | {
        success: boolean;
        executionId: any;
        status: string;
        async: boolean;
        result?: undefined;
    }>;
    /**
     * Process stats node - Generate statistics using StatsService
     */
    processStatsNode(node: any, context: any): Promise<{
        success: boolean;
        collection: any;
        operation: any;
        stats: any;
    }>;
    /**
     * Process file node - File operations using FilesService
     */
    processFileNode(node: any, context: any): Promise<{
        success: boolean;
        operation: string;
        file: any;
        fileId?: undefined;
        files?: undefined;
        total?: undefined;
    } | {
        success: boolean;
        operation: string;
        fileId: any;
        file?: undefined;
        files?: undefined;
        total?: undefined;
    } | {
        success: boolean;
        operation: string;
        files: any[];
        total: any;
        file?: undefined;
        fileId?: undefined;
    }>;
    /**
     * Process variable node - Set workflow variables
     */
    processVariableNode(node: any, context: any): Promise<{
        success: boolean;
        variables: Record<string, any>;
    }>;
    /**
     * Process script node - Execute custom JavaScript
     */
    processScriptNode(node: any, context: any): Promise<{
        success: boolean;
        result: any;
    }>;
    /**
     * Process try-catch node - Error handling
     */
    processTryNode(node: any, context: any, allNodes: any[], edges: any[], executionId: string | number, LogService: ItemsService): Promise<{
        success: boolean;
        branch: string;
        error: any;
    }>;
    /**
     * Execute a try/catch branch
     * Executes nodes until they connect back to the try node's "try-end" handle
     */
    executeTryBranch(tryNodeId: string, startNode: any, allNodes: any[], edges: any[], context: any, executionId: string | number, LogService: ItemsService): Promise<void>;
    /**
     * Execute a single node (for testing individual steps)
     */
    executeSingleNodeFromAPI(workflowId: string | number, nodeId: string, inputData: any, userId: any, tenantId: any, workflowData?: any): Promise<{
        success: boolean;
        nodeId: string;
        nodeType: any;
        input: {
            trigger: any;
            variables: any;
            loop: any;
            error: any;
        };
        output: any;
        workflow: any;
    }>;
    /**
     * Graceful shutdown
     */
    shutdown(): Promise<void>;
}
declare global {
    var __baasix_workflowService: WorkflowService | undefined;
}
declare const workflowService: WorkflowService;
export default workflowService;
//# sourceMappingURL=WorkflowService.d.ts.map