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
69 lines • 2.3 kB
TypeScript
/**
* Pure functions for BC handler parsing.
*
* No dependencies - easily testable in isolation.
* Extracted from BCRawWebSocketClient per FUTURE_ERRATA.md Week 2.4
*
* These utilities handle:
* - Handler decompression (gzip → JSON)
* - Compressed data extraction (multiple BC message formats)
* - Session information extraction (recursive parameter search)
*/
import type { BCHandler } from '../interfaces.js';
/**
* Decompress gzip-compressed BC handler array.
*
* BC sends handler responses as base64-encoded gzip-compressed JSON arrays.
* This function reverses that encoding.
*
* @param base64 Base64-encoded gzip data
* @returns Decompressed handler array
* @throws {Error} If decompression or JSON parsing fails
*
* @example
* ```ts
* const handlers = decompressHandlers('H4sIAAAAAAAA...');
* // [{ handlerType: 'DN.LogicalClientEventRaisingHandler', parameters: [...] }]
* ```
*/
export declare function decompressHandlers(base64: string): BCHandler[];
export declare function extractCompressedData(message: unknown): string | null;
/** Session info result type */
interface SessionInfo {
serverSessionId?: string;
sessionKey?: string;
companyName?: string;
roleCenterFormId?: string;
}
/**
* Extract session information from handler array.
*
* BC embeds session info (ServerSessionId, SessionKey, CompanyName) deep
* within handler parameters. This function recursively searches handler
* parameter trees to find these values.
*
* Session info typically appears in OpenSession responses but may also
* appear in other handlers during session establishment.
*
* @param handlers Array of BC handlers to search
* @returns Session info object or null if not found
*
* @example
* ```ts
* const handlers = [
* {
* handlerType: 'DN.SessionHandler',
* parameters: [
* { ServerSessionId: 'abc123', SessionKey: 'key456', CompanyName: 'CRONUS' }
* ]
* }
* ];
*
* const info = extractSessionInfo(handlers);
* // { serverSessionId: 'abc123', sessionKey: 'key456', companyName: 'CRONUS' }
* ```
*/
export declare function extractSessionInfo(handlers: BCHandler[]): SessionInfo | null;
export declare function extractOpenFormIds(message: unknown): string[] | null;
export {};
//# sourceMappingURL=handlers.d.ts.map