/** * Utility functions used throughout the DagEngine * * This module contains pure utility functions that don't fit into * specific classes but are used across multiple components. * * @module shared/utils */ import type { SectionData, DimensionResult, DimensionDependencies } from "../../types.js"; /** * Checks if dependencies contain any failures * * Used to determine if a dimension should be skipped due to failed dependencies. * * @param deps - The dependencies to check * @returns true if any dependency has an error * * @example * ```typescript * if (hasFailedDependencies(dependencies)) { * throw new Error('Cannot execute due to failed dependencies'); * } * ``` */ export declare function hasFailedDependencies(deps: DimensionDependencies): boolean; /** * Gets list of failed dependency names * * @param deps - The dependencies to check * @returns Array of dependency names that have errors */ export declare function getFailedDependencies(deps: DimensionDependencies): string[]; /** * Counts successful dimension executions * * Counts both global and section-level successes. * * @param globalResults - Results from global dimensions * @param sectionResults - Results from section dimensions * @returns Total number of successful executions */ export declare function countSuccessful(globalResults: Record, sectionResults: Array<{ section: SectionData; results: Record; }>): number; /** * Counts failed dimension executions * * Counts both global and section-level failures. * * @param globalResults - Results from global dimensions * @param sectionResults - Results from section dimensions * @returns Total number of failed executions */ export declare function countFailed(globalResults: Record, sectionResults: Array<{ section: SectionData; results: Record; }>): number; /** * Resets the section results map for new section count * * Used when sections are transformed and the count changes. * * @param map - The section results map to reset * @param newLength - The new number of sections */ export declare function resetSectionResultsMap(map: Map>, newLength: number): void; /** * Applies finalized results back to section results and global results * * Used after the finalizeResults hook to update results with any * modifications made by the plugin. * * @param sectionResults - Original section results * @param finalizedResults - Results from finalizeResults hook * @param globalResults - Global results to update (mutated in place) * @returns Updated section results */ export declare function applyFinalizedResults(sectionResults: Array<{ section: SectionData; results: Record; }>, finalizedResults: Record, globalResults: Record): Array<{ section: SectionData; results: Record; }>; /** * Creates a timeout promise for dimension execution * * Returns a promise that rejects after the specified timeout with * a DimensionTimeoutError. * * @param timeoutMs - Timeout in milliseconds * @param dimension - Dimension name for error message * @returns Promise that rejects on timeout */ export declare function createTimeoutPromise(timeoutMs: number, dimension: string): Promise; /** * Executes a function with timeout protection * * Races the function execution against a timeout, throwing a * DimensionTimeoutError if the timeout is reached first. * * @param fn - Function to execute * @param dimension - Dimension name for error message * @param timeoutMs - Timeout in milliseconds * @returns Result of the function * @throws {DimensionTimeoutError} If timeout is reached * * @example * ```typescript * const result = await executeWithTimeout( * () => expensiveOperation(), * 'myDimension', * 30000 * ); * ``` */ export declare function executeWithTimeout(fn: () => Promise, dimension: string, timeoutMs: number): Promise; //# sourceMappingURL=utils.d.ts.map