/** * =============================================================================== * RESULT MODULE - UNIFIED RESULT PATTERN * =============================================================================== * * This module provides a type-safe Result pattern for operations that can fail. * It replaces inconsistent { success, error?, data? } patterns throughout the * codebase with a properly typed discriminated union. * * Key Features: * - Type-safe success/failure discrimination via `success` discriminant * - Fluent builders for creating results * - Type guards for narrowing (isSuccess, isFailure) * - Utility functions for unwrapping, mapping, and chaining * - Batch operation support with timing and summary statistics * - Legacy compatibility for gradual migration * * Usage: * ```typescript * import { success, failure, isSuccess, Result } from './core/result/index.js'; * * async function fetchUser(id: string): Promise> { * try { * const user = await db.findUser(id); * if (!user) { * return failure('NOT_FOUND', `User ${id} not found`); * } * return success(user); * } catch (err) { * return fromError(err, 'FETCH_FAILED'); * } * } * * // Usage * const result = await fetchUser('123'); * if (isSuccess(result)) { * console.log(result.data.name); // TypeScript knows data exists * } else { * console.error(result.error.message); // TypeScript knows error exists * } * ``` * * =============================================================================== */ export type { Result, Success, Failure, ResultMetadata, ResultError, BatchResult, BatchResultEntry, BatchSummary, AsyncResult, AsyncBatchResult, LegacyResult, } from './types.js'; export { success, failure, fromError, fromPromise, fromThrowable, isSuccess, isFailure, isRetryable, unwrap, unwrapOr, unwrapOrElse, unwrapError, UnwrapError, map, mapError, flatMap, flatMapAsync, match, all, partition, fromLegacy, toLegacy, } from './builders.js'; export { createBatchResult, runBatch, runBatchSync, extractSuccesses, extractFailures, getResultByKey, toResultMap, filterByKeys, mergeBatchResults, retryFailed, batchBuilder, BatchBuilder, } from './batch.js'; export type { BatchExecutionOptions } from './batch.js'; export { toMcpResult, mcpSuccess, mcpFailure, mcpLegacyFailure, mcpFromError, mcpBatchResult, fromLegacyResponse, wrapToolHandler, wrapToolHandlerSync, } from './mcp-adapter.js'; export type { McpResponseOptions, McpSuccessPayload, McpErrorPayload, LegacyToolResponse, } from './mcp-adapter.js'; //# sourceMappingURL=index.d.ts.map