UNPKG

bc-webclient-mcp

Version:

Model Context Protocol (MCP) server for Microsoft Dynamics 365 Business Central via WebUI protocol. Enables AI assistants to interact with BC through the web client protocol, supporting Card, List, and Document pages with full line item support and server

108 lines 3.27 kB
/** * AbortSignal Utilities * * Utilities for composing AbortSignals with timeouts and distinguishing * external abort from deadline exceeded. * * Uses Node 20+ native AbortSignal.timeout() and AbortSignal.any() for * efficient signal composition. */ /** * Standard options for cancelable operations. * * Provides consistent timeout and abort signal support across all async operations. */ export type CancelableOptions = { /** Optional AbortSignal for external cancellation */ signal?: AbortSignal; /** Optional timeout in milliseconds */ timeoutMs?: number; }; /** * Composes an optional parent AbortSignal with a timeout deadline. * * Uses Node 20+ native AbortSignal.timeout() and AbortSignal.any() for * efficient composition. The returned signal aborts when either: * - The parent signal aborts (external cancellation) * - The timeout expires (deadline exceeded) * * @param parent - Optional parent AbortSignal (e.g., from upstream caller) * @param timeoutMs - Timeout in milliseconds * @returns Composed AbortSignal that aborts on parent abort OR timeout * * @example * ```ts * // Timeout only * const signal = composeWithTimeout(undefined, 5000); * * // Compose with parent * const userSignal = new AbortController().signal; * const signal = composeWithTimeout(userSignal, 5000); * // Aborts if userSignal aborts OR after 5 seconds * ``` */ export declare function composeWithTimeout(parent: AbortSignal | undefined, timeoutMs: number): AbortSignal; export declare function isTimeoutAbortReason(reason: unknown): boolean; /** * Checks if an error is a DOMException with name 'AbortError'. * * This is thrown by native AbortSignal-aware APIs when aborted. * * @param e - The error to check * @returns true if the error is an abort error * * @example * ```ts * try { * await fetch(url, { signal }); * } catch (e) { * if (isAbortError(e)) { * // Request was aborted * } * } * ``` */ export declare function isAbortError(e: unknown): boolean; /** * Determines if a signal was aborted externally (not by timeout). * * Useful for distinguishing user cancellation from deadline expiration. * * @param signal - The AbortSignal to check * @returns true if aborted by external cancel (not timeout) * * @example * ```ts * if (signal.aborted) { * if (wasExternallyAborted(signal)) { * return new AbortedError('Operation cancelled'); * } else { * return new TimeoutError('Operation timed out'); * } * } * ``` */ export declare function wasExternallyAborted(signal?: AbortSignal): boolean; /** * Creates an abort listener that removes itself after firing once. * * Convenience helper for the common pattern of listening for abort * and cleaning up the listener. * * @param signal - The AbortSignal to listen to * @param callback - Function to call when aborted * @returns Function to manually remove the listener (if not yet aborted) * * @example * ```ts * const cleanup = onceAborted(signal, () => { * // Handle abort * ws.close(); * }); * * // Later, if you want to remove listener before abort: * cleanup(); * ``` */ export declare function onceAborted(signal: AbortSignal, callback: () => void): () => void; //# sourceMappingURL=abort.d.ts.map